add some types

This commit is contained in:
Philipp Kühn 2021-02-11 23:25:21 +01:00
parent 8a62339ab9
commit e94ed40ceb
3 changed files with 8 additions and 6 deletions

View File

@ -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
},
},
})

View File

@ -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 {

View File

@ -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({