mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-08-06 13:38:49 +08:00
annotations: refactoring
This commit is contained in:
parent
967f43fda5
commit
5e168bec73
@ -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: {
|
||||
|
@ -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
|
||||
|
@ -58,7 +58,7 @@ export const Annotation = Extension.create({
|
||||
|
||||
addProseMirrorPlugins() {
|
||||
return [
|
||||
AnnotationPlugin(this.options, this.editor),
|
||||
AnnotationPlugin(this.options),
|
||||
]
|
||||
},
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user