collaborative editor - wip
This commit is contained in:
@@ -3,7 +3,7 @@ import { JwtService } from '@nestjs/jwt';
|
||||
import { EnvironmentService } from '../../../environment/environment.service';
|
||||
import { User } from '../../user/entities/user.entity';
|
||||
import { FastifyRequest } from 'fastify';
|
||||
import { TokensDto } from "../dto/tokens.dto";
|
||||
import { TokensDto } from '../dto/tokens.dto';
|
||||
|
||||
@Injectable()
|
||||
export class TokenService {
|
||||
|
||||
@@ -20,14 +20,14 @@ export class Page {
|
||||
@Column({ length: 500, nullable: true })
|
||||
title: string;
|
||||
|
||||
@Column({ type: 'text', nullable: true })
|
||||
@Column({ type: 'jsonb', nullable: true })
|
||||
content: string;
|
||||
|
||||
@Column({ type: 'text', nullable: true })
|
||||
html: string;
|
||||
|
||||
@Column({ type: 'jsonb', nullable: true })
|
||||
json: any;
|
||||
@Column({ type: 'bytea', nullable: true })
|
||||
ydoc: any;
|
||||
|
||||
@Column({ nullable: true })
|
||||
slug: string;
|
||||
|
||||
@@ -11,5 +11,6 @@ import { WorkspaceModule } from '../workspace/workspace.module';
|
||||
imports: [TypeOrmModule.forFeature([Page]), AuthModule, WorkspaceModule],
|
||||
controllers: [PageController],
|
||||
providers: [PageService, PageRepository],
|
||||
exports: [PageService, PageRepository],
|
||||
})
|
||||
export class PageModule {}
|
||||
|
||||
@@ -22,19 +22,29 @@ export class PageService {
|
||||
page.creatorId = userId;
|
||||
page.workspaceId = workspaceId;
|
||||
|
||||
console.log(page);
|
||||
return await this.pageRepository.save(page);
|
||||
}
|
||||
|
||||
async update(pageId: string, updatePageDto: UpdatePageDto): Promise<Page> {
|
||||
const existingPage = await this.pageRepository.findById(pageId);
|
||||
if (!existingPage) {
|
||||
throw new Error(`Page with ID ${pageId} not found`);
|
||||
}
|
||||
|
||||
const page = await this.pageRepository.preload({
|
||||
id: pageId,
|
||||
...updatePageDto,
|
||||
} as Page);
|
||||
|
||||
return await this.pageRepository.save(page);
|
||||
}
|
||||
|
||||
async updateState(pageId: string, content: any, ydoc: any): Promise<void> {
|
||||
await this.pageRepository.update(pageId, {
|
||||
content: content,
|
||||
ydoc: ydoc,
|
||||
});
|
||||
}
|
||||
|
||||
async delete(pageId: string): Promise<void> {
|
||||
await this.pageRepository.softDelete(pageId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user