mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 14:43:06 +08:00
feat: editor attachment paste handling (#1975)
* reupload attachments if uploaded to a different page * use image dimensions on paste/DnD * tooltips withinPortal:false * isolating attribute
This commit is contained in:
@@ -52,7 +52,7 @@ import { EnvironmentService } from '../../integrations/environment/environment.s
|
||||
import { TokenService } from '../auth/services/token.service';
|
||||
import { JwtAttachmentPayload, JwtType } from '../auth/dto/jwt-payload';
|
||||
import * as path from 'path';
|
||||
import { RemoveIconDto } from './dto/attachment.dto';
|
||||
import { AttachmentInfoDto, RemoveIconDto } from './dto/attachment.dto';
|
||||
import { PageAccessService } from '../page/page-access/page-access.service';
|
||||
|
||||
@Controller()
|
||||
@@ -349,6 +349,34 @@ export class AttachmentController {
|
||||
}
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post('files/info')
|
||||
async getAttachmentInfo(
|
||||
@Body() dto: AttachmentInfoDto,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
@AuthUser() user: User,
|
||||
) {
|
||||
const attachment = await this.attachmentRepo.findById(dto.attachmentId);
|
||||
if (
|
||||
!attachment ||
|
||||
!attachment.pageId ||
|
||||
attachment.workspaceId !== workspace.id ||
|
||||
attachment.type !== AttachmentType.File
|
||||
) {
|
||||
throw new NotFoundException('File not found');
|
||||
}
|
||||
|
||||
const page = await this.pageRepo.findById(attachment.pageId);
|
||||
if (!page) {
|
||||
throw new NotFoundException('File not found');
|
||||
}
|
||||
|
||||
await this.pageAccessService.validateCanView(page, user);
|
||||
|
||||
return attachment;
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post('attachments/remove-icon')
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { IsEnum, IsIn, IsNotEmpty, IsOptional, IsUUID } from 'class-validator';
|
||||
import { AttachmentType } from '../attachment.constants';
|
||||
|
||||
export class AttachmentInfoDto {
|
||||
@IsNotEmpty()
|
||||
@IsUUID()
|
||||
attachmentId: string;
|
||||
}
|
||||
|
||||
export class RemoveIconDto {
|
||||
@IsEnum(AttachmentType)
|
||||
@IsIn([
|
||||
|
||||
+1
-1
Submodule apps/server/src/ee updated: dc8da28f24...9e493d75f5
Reference in New Issue
Block a user