From 5e168bec7353224b47baccd3a7ecc70e6ce0d293 Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Thu, 11 Feb 2021 20:25:51 +0100 Subject: [PATCH] annotations: refactoring --- .../Experiments/Annotation/extension/AnnotationPlugin.ts | 6 +++--- .../Experiments/Annotation/extension/AnnotationState.ts | 4 ++-- .../demos/Experiments/Annotation/extension/annotation.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/src/demos/Experiments/Annotation/extension/AnnotationPlugin.ts b/docs/src/demos/Experiments/Annotation/extension/AnnotationPlugin.ts index b5069bca..57c806b2 100644 --- a/docs/src/demos/Experiments/Annotation/extension/AnnotationPlugin.ts +++ b/docs/src/demos/Experiments/Annotation/extension/AnnotationPlugin.ts @@ -4,12 +4,12 @@ import { AnnotationState } from './AnnotationState' export const AnnotationPluginKey = new PluginKey('annotation') -export const AnnotationPlugin = (options: any, editor: any) => new Plugin({ +export const AnnotationPlugin = (options: any) => new Plugin({ key: AnnotationPluginKey, state: { init: AnnotationState.init, - apply(transaction, oldState) { - return oldState.apply(transaction, editor) + apply(transaction, oldState, newState) { + return oldState.apply(transaction, newState) }, }, props: { diff --git a/docs/src/demos/Experiments/Annotation/extension/AnnotationState.ts b/docs/src/demos/Experiments/Annotation/extension/AnnotationState.ts index 9fe26ed4..6d01dada 100644 --- a/docs/src/demos/Experiments/Annotation/extension/AnnotationState.ts +++ b/docs/src/demos/Experiments/Annotation/extension/AnnotationState.ts @@ -24,7 +24,7 @@ export class AnnotationState { return this.decorations.find(position, position) } - apply(transaction: any, editor: any) { + apply(transaction: any, newState: any) { const action = transaction.getMeta(AnnotationPluginKey) const actionType = action && action.type @@ -44,7 +44,7 @@ export class AnnotationState { return new AnnotationState(decorations) } - const ystate = ySyncPluginKey.getState(editor.state) + const ystate = ySyncPluginKey.getState(newState) if (ystate && ystate.isChangeOrigin) { // TODO: Create new decorations diff --git a/docs/src/demos/Experiments/Annotation/extension/annotation.ts b/docs/src/demos/Experiments/Annotation/extension/annotation.ts index 726e552f..06c666b6 100644 --- a/docs/src/demos/Experiments/Annotation/extension/annotation.ts +++ b/docs/src/demos/Experiments/Annotation/extension/annotation.ts @@ -58,7 +58,7 @@ export const Annotation = Extension.create({ addProseMirrorPlugins() { return [ - AnnotationPlugin(this.options, this.editor), + AnnotationPlugin(this.options), ] }, })