annotations: refactoring

This commit is contained in:
Hans Pagel
2021-02-11 20:25:51 +01:00
parent 967f43fda5
commit 5e168bec73
3 changed files with 6 additions and 6 deletions

View File

@@ -4,12 +4,12 @@ import { AnnotationState } from './AnnotationState'
export const AnnotationPluginKey = new PluginKey('annotation') export const AnnotationPluginKey = new PluginKey('annotation')
export const AnnotationPlugin = (options: any, editor: any) => new Plugin({ export const AnnotationPlugin = (options: any) => new Plugin({
key: AnnotationPluginKey, key: AnnotationPluginKey,
state: { state: {
init: AnnotationState.init, init: AnnotationState.init,
apply(transaction, oldState) { apply(transaction, oldState, newState) {
return oldState.apply(transaction, editor) return oldState.apply(transaction, newState)
}, },
}, },
props: { props: {

View File

@@ -24,7 +24,7 @@ export class AnnotationState {
return this.decorations.find(position, position) return this.decorations.find(position, position)
} }
apply(transaction: any, editor: any) { apply(transaction: any, newState: any) {
const action = transaction.getMeta(AnnotationPluginKey) const action = transaction.getMeta(AnnotationPluginKey)
const actionType = action && action.type const actionType = action && action.type
@@ -44,7 +44,7 @@ export class AnnotationState {
return new AnnotationState(decorations) return new AnnotationState(decorations)
} }
const ystate = ySyncPluginKey.getState(editor.state) const ystate = ySyncPluginKey.getState(newState)
if (ystate && ystate.isChangeOrigin) { if (ystate && ystate.isChangeOrigin) {
// TODO: Create new decorations // TODO: Create new decorations

View File

@@ -58,7 +58,7 @@ export const Annotation = Extension.create({
addProseMirrorPlugins() { addProseMirrorPlugins() {
return [ return [
AnnotationPlugin(this.options, this.editor), AnnotationPlugin(this.options),
] ]
}, },
}) })