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