mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 06:03:22 +08:00
add some types
This commit is contained in:
parent
8a62339ab9
commit
e94ed40ceb
@ -1,3 +1,4 @@
|
||||
import * as Y from 'yjs'
|
||||
import { Plugin, PluginKey } from 'prosemirror-state'
|
||||
import { AnnotationState } from './AnnotationState'
|
||||
|
||||
@ -8,7 +9,7 @@ export interface AnnotationPluginOptions {
|
||||
[key: string]: any
|
||||
},
|
||||
onUpdate: (items: [any?]) => {},
|
||||
map: any,
|
||||
map: Y.Map<any>,
|
||||
}
|
||||
|
||||
export const AnnotationPlugin = (options: AnnotationPluginOptions) => new Plugin({
|
||||
@ -41,6 +42,5 @@ export const AnnotationPlugin = (options: AnnotationPluginOptions) => new Plugin
|
||||
|
||||
return decorations
|
||||
},
|
||||
|
||||
},
|
||||
})
|
||||
|
@ -1,4 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import * as Y from 'yjs'
|
||||
import { EditorState } from 'prosemirror-state'
|
||||
import { Decoration, DecorationSet } from 'prosemirror-view'
|
||||
import { ySyncPluginKey, relativePositionToAbsolutePosition, absolutePositionToRelativePosition } from 'y-prosemirror'
|
||||
@ -8,7 +9,7 @@ export interface AnnotationStateOptions {
|
||||
HTMLAttributes: {
|
||||
[key: string]: any
|
||||
},
|
||||
map: any,
|
||||
map: Y.Map<any>,
|
||||
}
|
||||
|
||||
export class AnnotationState {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import * as Y from 'yjs'
|
||||
import { Extension, Command } from '@tiptap/core'
|
||||
import { AnnotationItem } from './AnnotationItem'
|
||||
import { AnnotationPlugin, AnnotationPluginKey } from './AnnotationPlugin'
|
||||
@ -14,7 +15,7 @@ export interface AnnotationOptions {
|
||||
/**
|
||||
* An initialized Y.js document.
|
||||
*/
|
||||
document: any,
|
||||
document: Y.Doc | null,
|
||||
/**
|
||||
* Name of a Y.js fragment, can be changed to sync multiple fields with one Y.js document.
|
||||
*/
|
||||
@ -22,7 +23,7 @@ export interface AnnotationOptions {
|
||||
/**
|
||||
* A raw Y.js map, can be used instead of `document` and `field`.
|
||||
*/
|
||||
map: any,
|
||||
map: Y.Map<any> | null,
|
||||
}
|
||||
|
||||
export const Annotation = Extension.create({
|
||||
@ -74,7 +75,7 @@ export const Annotation = Extension.create({
|
||||
addProseMirrorPlugins() {
|
||||
const map = this.options.map
|
||||
? this.options.map
|
||||
: this.options.document.getMap(this.options.field)
|
||||
: this.options.document?.getMap(this.options.field) as Y.Map<any>
|
||||
|
||||
return [
|
||||
AnnotationPlugin({
|
||||
|
Loading…
Reference in New Issue
Block a user