diff --git a/docs/src/demos/Experiments/Annotation/extension/AnnotationItem.ts b/docs/src/demos/Experiments/Annotation/extension/AnnotationItem.ts index 2f356c31..dfcc92cd 100644 --- a/docs/src/demos/Experiments/Annotation/extension/AnnotationItem.ts +++ b/docs/src/demos/Experiments/Annotation/extension/AnnotationItem.ts @@ -17,8 +17,8 @@ export class AnnotationItem { return this.decoration.to } - get content() { - return this.decoration.type.spec.content + get data() { + return this.decoration.type.spec.data } get HTMLAttributes() { @@ -28,7 +28,7 @@ export class AnnotationItem { toString() { return JSON.stringify({ id: this.id, - content: this.content, + data: this.data, from: this.from, to: this.to, HTMLAttributes: this.HTMLAttributes, diff --git a/docs/src/demos/Experiments/Annotation/extension/AnnotationState.ts b/docs/src/demos/Experiments/Annotation/extension/AnnotationState.ts index 471d8363..9687266a 100644 --- a/docs/src/demos/Experiments/Annotation/extension/AnnotationState.ts +++ b/docs/src/demos/Experiments/Annotation/extension/AnnotationState.ts @@ -41,14 +41,14 @@ export class AnnotationState { const ystate = ySyncPluginKey.getState(state) const { type, binding } = ystate const { map } = this.options - const { from, to, content } = action + const { from, to, data } = action const absoluteFrom = absolutePositionToRelativePosition(from, type, binding.mapping) const absoluteTo = absolutePositionToRelativePosition(to, type, binding.mapping) map.set(this.randomId(), { from: absoluteFrom, to: absoluteTo, - content, + data, }) } @@ -73,16 +73,16 @@ export class AnnotationState { Array .from(map.keys()) .forEach(id => { - const decoration = map.get(id) - const from = relativePositionToAbsolutePosition(doc, type, decoration.from, binding.mapping) - const to = relativePositionToAbsolutePosition(doc, type, decoration.to, binding.mapping) + const annotation = map.get(id) + const from = relativePositionToAbsolutePosition(doc, type, annotation.from, binding.mapping) + const to = relativePositionToAbsolutePosition(doc, type, annotation.to, binding.mapping) if (!from || !to) { return } return decorations.push( - Decoration.inline(from, to, HTMLAttributes, { id, content: decoration.content }), + Decoration.inline(from, to, HTMLAttributes, { id, data: annotation.data }), ) }) diff --git a/docs/src/demos/Experiments/Annotation/extension/annotation.ts b/docs/src/demos/Experiments/Annotation/extension/annotation.ts index 1f9011f4..6ccddb67 100644 --- a/docs/src/demos/Experiments/Annotation/extension/annotation.ts +++ b/docs/src/demos/Experiments/Annotation/extension/annotation.ts @@ -4,7 +4,7 @@ import { AnnotationPlugin, AnnotationPluginKey } from './AnnotationPlugin' export interface AddAnnotationAction { type: 'addAnnotation', - content: any, + data: any, from: number, to: number, } @@ -12,7 +12,7 @@ export interface AddAnnotationAction { export interface UpdateAnnotationAction { type: 'updateAnnotation', id: string, - content: any, + data: any, } export interface DeleteAnnotationAction { @@ -77,29 +77,29 @@ export const Annotation = Extension.create({ addCommands() { return { - addAnnotation: (content: any): Command => ({ dispatch, state }) => { + addAnnotation: (data: any): Command => ({ dispatch, state }) => { const { selection } = state if (selection.empty) { return false } - if (dispatch && content) { + if (dispatch && data) { state.tr.setMeta(AnnotationPluginKey, { type: 'addAnnotation', from: selection.from, to: selection.to, - content, + data, }) } return true }, - updateAnnotation: (id: string, content: any): Command => ({ dispatch, state }) => { + updateAnnotation: (id: string, data: any): Command => ({ dispatch, state }) => { if (dispatch) { state.tr.setMeta(AnnotationPluginKey, { type: 'updateAnnotation', - content, + data, }) } diff --git a/docs/src/demos/Experiments/Annotation/index.vue b/docs/src/demos/Experiments/Annotation/index.vue index 75036ceb..979bbc3f 100644 --- a/docs/src/demos/Experiments/Annotation/index.vue +++ b/docs/src/demos/Experiments/Annotation/index.vue @@ -103,26 +103,26 @@ export default { methods: { addComment() { - const content = prompt('Comment', '') + const data = prompt('Comment', '') - this.editor.commands.addAnnotation(content) + this.editor.commands.addAnnotation(data) }, updateComment(id) { const comment = this.comments.find(item => { return id === item.id }) - const content = prompt('Comment', comment.content) + const data = prompt('Comment', comment.data) - this.editor.commands.updateAnnotation(id, content) + this.editor.commands.updateAnnotation(id, data) }, deleteComment(id) { this.editor.commands.deleteAnnotation(id) }, addAnotherComment() { - const content = prompt('Comment', '') + const data = prompt('Comment', '') - this.anotherEditor.commands.addAnnotation(content) + this.anotherEditor.commands.addAnnotation(data) }, },