Fix images in note rich text (#6550)
## Before <img width="439" alt="Screenshot 2024-08-06 at 11 20 06" src="https://github.com/user-attachments/assets/d2aa9411-cdf4-4457-8997-7cbecb8fe7e3"> ## After <img width="501" alt="Screenshot 2024-08-06 at 11 20 09" src="https://github.com/user-attachments/assets/a5a68fff-1542-4b62-939c-50070f15b692">
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
import { FileUploadResolver } from 'src/engine/core-modules/file/file-upload/resolvers/file-upload.resolver';
|
||||
import { FileUploadService } from 'src/engine/core-modules/file/file-upload/services/file-upload.service';
|
||||
import { FileModule } from 'src/engine/core-modules/file/file.module';
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
|
||||
@Module({
|
||||
imports: [FileModule],
|
||||
providers: [FileUploadService, FileUploadResolver, EnvironmentService],
|
||||
exports: [FileUploadService, FileUploadResolver],
|
||||
})
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
import { FileStorageService } from 'src/engine/integrations/file-storage/file-storage.service';
|
||||
|
||||
import { FileUploadService } from './file-upload.service';
|
||||
|
||||
describe('FileUploadService', () => {
|
||||
let service: FileUploadService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [
|
||||
FileUploadService,
|
||||
{
|
||||
provide: FileStorageService,
|
||||
useValue: {},
|
||||
},
|
||||
{
|
||||
provide: EnvironmentService,
|
||||
useValue: {},
|
||||
},
|
||||
],
|
||||
}).compile();
|
||||
|
||||
service = module.get<FileUploadService>(FileUploadService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@ -8,12 +8,16 @@ import { v4 as uuidV4 } from 'uuid';
|
||||
import { FileFolder } from 'src/engine/core-modules/file/interfaces/file-folder.interface';
|
||||
|
||||
import { settings } from 'src/engine/constants/settings';
|
||||
import { FileService } from 'src/engine/core-modules/file/services/file.service';
|
||||
import { FileStorageService } from 'src/engine/integrations/file-storage/file-storage.service';
|
||||
import { getCropSize } from 'src/utils/image';
|
||||
|
||||
@Injectable()
|
||||
export class FileUploadService {
|
||||
constructor(private readonly fileStorage: FileStorageService) {}
|
||||
constructor(
|
||||
private readonly fileStorage: FileStorageService,
|
||||
private readonly fileService: FileService,
|
||||
) {}
|
||||
|
||||
private async _uploadFile({
|
||||
file,
|
||||
@ -78,10 +82,14 @@ export class FileUploadService {
|
||||
folder,
|
||||
});
|
||||
|
||||
const signedPayload = await this.fileService.encodeFileToken({
|
||||
workspace_id: workspaceId,
|
||||
});
|
||||
|
||||
return {
|
||||
id,
|
||||
mimeType,
|
||||
path: `${fileFolder}/${name}`,
|
||||
path: `${fileFolder}/${name}?token=${signedPayload}`,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { FileUploadModule } from 'src/engine/core-modules/file/file-upload/file-upload.module';
|
||||
import { FilePathGuard } from 'src/engine/core-modules/file/guards/file-path-guard';
|
||||
import { JwtModule } from 'src/engine/core-modules/jwt/jwt.module';
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
@ -9,7 +8,7 @@ import { FileController } from './controllers/file.controller';
|
||||
import { FileService } from './services/file.service';
|
||||
|
||||
@Module({
|
||||
imports: [FileUploadModule, JwtModule],
|
||||
imports: [JwtModule],
|
||||
providers: [FileService, EnvironmentService, FilePathGuard],
|
||||
exports: [FileService],
|
||||
controllers: [FileController],
|
||||
|
||||
Reference in New Issue
Block a user