mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
rename contentOperation -> operation
This commit is contained in:
@@ -31,11 +31,11 @@ export class CollaborationHandler {
|
||||
documentName: string,
|
||||
payload: {
|
||||
prosemirrorJson: any;
|
||||
contentOperation: string;
|
||||
operation: string;
|
||||
user: User;
|
||||
},
|
||||
) => {
|
||||
const { prosemirrorJson, contentOperation, user } = payload;
|
||||
const { prosemirrorJson, operation, user } = payload;
|
||||
this.logger.debug('Updating page content via yjs', documentName);
|
||||
await this.withYdocConnection(
|
||||
hocuspocus,
|
||||
@@ -44,7 +44,7 @@ export class CollaborationHandler {
|
||||
(doc) => {
|
||||
const fragment = doc.getXmlFragment('default');
|
||||
|
||||
if (contentOperation === 'replace') {
|
||||
if (operation === 'replace') {
|
||||
if (fragment.length > 0) {
|
||||
fragment.delete(0, fragment.length);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ export class CollaborationHandler {
|
||||
const newContent = prosemirrorJson.content || [];
|
||||
const yElements = newContent.map(prosemirrorNodeToYElement);
|
||||
const position =
|
||||
contentOperation === 'prepend' ? 0 : fragment.length;
|
||||
operation === 'prepend' ? 0 : fragment.length;
|
||||
fragment.insert(position, yElements);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -15,7 +15,7 @@ export class UpdatePageDto extends PartialType(CreatePageDto) {
|
||||
@ValidateIf((o) => o.content !== undefined)
|
||||
@Transform(({ value }) => value?.toLowerCase())
|
||||
@IsIn(['append', 'prepend', 'replace'])
|
||||
contentOperation?: ContentOperation;
|
||||
operation?: ContentOperation;
|
||||
|
||||
@ValidateIf((o) => o.content !== undefined)
|
||||
@Transform(({ value }) => value?.toLowerCase() ?? 'json')
|
||||
|
||||
@@ -212,13 +212,13 @@ export class PageService {
|
||||
|
||||
if (
|
||||
updatePageDto.content &&
|
||||
updatePageDto.contentOperation &&
|
||||
updatePageDto.operation &&
|
||||
updatePageDto.format
|
||||
) {
|
||||
await this.updatePageContent(
|
||||
page.id,
|
||||
updatePageDto.content,
|
||||
updatePageDto.contentOperation,
|
||||
updatePageDto.operation,
|
||||
updatePageDto.format,
|
||||
user,
|
||||
);
|
||||
@@ -236,7 +236,7 @@ export class PageService {
|
||||
async updatePageContent(
|
||||
pageId: string,
|
||||
content: string | object,
|
||||
contentOperation: ContentOperation,
|
||||
operation: ContentOperation,
|
||||
format: ContentFormat,
|
||||
user: User,
|
||||
): Promise<void> {
|
||||
@@ -269,7 +269,7 @@ export class PageService {
|
||||
await this.collaborationGateway.handleYjsEvent(
|
||||
'updatePageContent',
|
||||
documentName,
|
||||
{ contentOperation, prosemirrorJson, user },
|
||||
{ operation, prosemirrorJson, user },
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user