y-prosemirror
Advanced tools
Comparing version 1.1.3 to 1.2.0
@@ -88,10 +88,10 @@ /** | ||
export function setMeta(view: any, key: any, value: any): void; | ||
export function absolutePositionToRelativePosition(pos: number, type: Y.XmlFragment, mapping: Map<Y.AbstractType<any>, Node<any> | Node<any>[]>): any; | ||
export function relativePositionToAbsolutePosition(y: Y.Doc, documentType: Y.XmlFragment, relPos: any, mapping: Map<Y.AbstractType<any>, Node<any> | Node<any>[]>): null | number; | ||
export function absolutePositionToRelativePosition(pos: number, type: Y.XmlFragment, mapping: ProsemirrorMapping): any; | ||
export function relativePositionToAbsolutePosition(y: Y.Doc, documentType: Y.XmlFragment, relPos: any, mapping: ProsemirrorMapping): null | number; | ||
/** | ||
* Either a node if type is YXmlElement or an Array of text nodes if YXmlText | ||
*/ | ||
export type ProsemirrorMapping = Map<Y.AbstractType<any>, Node<any> | Node<any>[]>; | ||
export type ProsemirrorMapping = Map<Y.AbstractType<any>, Node | Array<Node>>; | ||
import { Node } from "prosemirror-model"; | ||
import * as Y from "yjs"; | ||
import { Schema } from "prosemirror-model"; |
@@ -11,6 +11,6 @@ export function defaultCursorBuilder(user: any): HTMLElement; | ||
export function yCursorPlugin(awareness: Awareness, { cursorBuilder, selectionBuilder, getSelection }?: { | ||
cursorBuilder: (arg0: any) => HTMLElement; | ||
selectionBuilder: (arg0: any) => import('prosemirror-view').DecorationAttrs; | ||
getSelection: (arg0: any) => any; | ||
cursorBuilder?: (arg0: any) => HTMLElement; | ||
selectionBuilder?: (arg0: any) => import('prosemirror-view').DecorationAttrs; | ||
getSelection?: (arg0: any) => any; | ||
}, cursorStateField?: string): any; | ||
import { Awareness } from "y-protocols/awareness"; |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
export const ySyncPluginKey: PluginKey<any, any>; | ||
export const ySyncPluginKey: PluginKey<any>; | ||
/** | ||
@@ -13,3 +13,3 @@ * The unique prosemirror plugin key for undoPlugin | ||
*/ | ||
export const yUndoPluginKey: PluginKey<any, any>; | ||
export const yUndoPluginKey: PluginKey<any>; | ||
/** | ||
@@ -20,3 +20,3 @@ * The unique prosemirror plugin key for cursorPlugin | ||
*/ | ||
export const yCursorPluginKey: PluginKey<any, any>; | ||
export const yCursorPluginKey: PluginKey<any>; | ||
import { PluginKey } from "prosemirror-state"; |
@@ -25,3 +25,3 @@ export function isVisible(item: Y.Item, snapshot?: Y.Snapshot): boolean; | ||
*/ | ||
mapping: Map<Y.AbstractType<any>, PModel.Node<any> | PModel.Node<any>[]>; | ||
mapping: ProsemirrorMapping; | ||
_observeFunction: any; | ||
@@ -50,3 +50,7 @@ /** | ||
_isDomSelectionInView(): boolean; | ||
renderSnapshot(snapshot: any, prevSnapshot: any): void; | ||
/** | ||
* @param {Y.Snapshot} snapshot | ||
* @param {Y.Snapshot} prevSnapshot | ||
*/ | ||
renderSnapshot(snapshot: Y.Snapshot, prevSnapshot: Y.Snapshot): void; | ||
unrenderSnapshot(): void; | ||
@@ -70,7 +74,7 @@ _forceRerender(): void; | ||
transact: Function; | ||
}, yDomFragment: Y.XmlFragment, pNode: any, mapping: Map<Y.AbstractType<any>, PModel.Node<any> | PModel.Node<any>[]>): void; | ||
}, yDomFragment: Y.XmlFragment, pNode: any, mapping: ProsemirrorMapping): void; | ||
/** | ||
* Either a node if type is YXmlElement or an Array of text nodes if YXmlText | ||
*/ | ||
export type ProsemirrorMapping = Map<Y.AbstractType<any>, PModel.Node<any> | PModel.Node<any>[]>; | ||
export type ProsemirrorMapping = Map<Y.AbstractType<any>, PModel.Node | Array<PModel.Node>>; | ||
export type ColorDef = { | ||
@@ -89,4 +93,4 @@ light: string; | ||
}; | ||
export type NormalizedPNodeContent = (PModel.Node<any> | PModel.Node<any>[])[]; | ||
export type NormalizedPNodeContent = Array<Array<PModel.Node> | PModel.Node>; | ||
import * as Y from "yjs"; | ||
import * as PModel from "prosemirror-model"; |
@@ -9,3 +9,8 @@ export function undo(state: any): boolean; | ||
undoManager?: any; | ||
}): Plugin<any, any>; | ||
}): Plugin<{ | ||
undoManager: any; | ||
prevSel: any; | ||
hasUndoOps: boolean; | ||
hasRedoOps: boolean; | ||
}>; | ||
import { Plugin } from "prosemirror-state"; |
{ | ||
"name": "y-prosemirror", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Prosemirror bindings for Yjs", | ||
@@ -55,3 +55,4 @@ "main": "./dist/y-prosemirror.cjs", | ||
"dependencies": { | ||
"lib0": "^0.2.42" | ||
"lib0": "^0.2.42", | ||
"typescript": "^4.8.4" | ||
}, | ||
@@ -68,14 +69,13 @@ "peerDependencies": { | ||
"@rollup/plugin-node-resolve": "^13.0.6", | ||
"@types/prosemirror-state": "^1.2.8", | ||
"concurrently": "^4.1.0", | ||
"http-server": "^0.12.3", | ||
"jsdom": "^15.1.1", | ||
"prosemirror-example-setup": "^1.1.2", | ||
"prosemirror-model": "^1.15.0", | ||
"prosemirror-schema-basic": "^1.1.2", | ||
"prosemirror-state": "^1.3.4", | ||
"prosemirror-view": "^1.22.0", | ||
"prosemirror-example-setup": "^1.2.1", | ||
"prosemirror-model": "^1.18.1", | ||
"prosemirror-schema-basic": "^1.2.0", | ||
"prosemirror-state": "^1.4.1", | ||
"prosemirror-transform": "^1.6.0", | ||
"prosemirror-view": "^1.26.2", | ||
"rollup": "^2.59.0", | ||
"standard": "^17.0.0", | ||
"typescript": "^3.9.10", | ||
"y-protocols": "^1.0.5", | ||
@@ -82,0 +82,0 @@ "y-webrtc": "^10.2.0", |
@@ -130,3 +130,3 @@ import * as Y from 'yjs' | ||
* @param {Awareness} awareness | ||
* @param {object} [opts] | ||
* @param {object} opts | ||
* @param {function(any):HTMLElement} [opts.cursorBuilder] | ||
@@ -133,0 +133,0 @@ * @param {function(any):import('prosemirror-view').DecorationAttrs} [opts.selectionBuilder] |
@@ -103,2 +103,5 @@ /** | ||
state: { | ||
/** | ||
* @returns {any} | ||
*/ | ||
init: (_initargs, _state) => { | ||
@@ -112,2 +115,3 @@ return { | ||
isChangeOrigin: false, | ||
isUndoRedoOperation: false, | ||
addToHistory: true, | ||
@@ -131,2 +135,3 @@ colors, | ||
!!change.isChangeOrigin | ||
pluginState.isUndoRedoOperation = change !== undefined && !!change.isChangeOrigin && !!change.isUndoRedoOperation | ||
if (pluginState.binding !== null) { | ||
@@ -210,3 +215,3 @@ if ( | ||
binding.mux(() => { | ||
pluginState.doc.transact((tr) => { | ||
/** @type {Y.Doc} */ (pluginState.doc).transact((tr) => { | ||
tr.meta.set('addToHistory', pluginState.addToHistory) | ||
@@ -363,2 +368,6 @@ binding._prosemirrorChanged(view.state.doc) | ||
/** | ||
* @param {Y.Snapshot} snapshot | ||
* @param {Y.Snapshot} prevSnapshot | ||
*/ | ||
renderSnapshot (snapshot, prevSnapshot) { | ||
@@ -537,3 +546,3 @@ if (!prevSnapshot) { | ||
restoreRelativeSelection(tr, this.beforeTransactionSelection, this) | ||
tr = tr.setMeta(ySyncPluginKey, { isChangeOrigin: true }) | ||
tr = tr.setMeta(ySyncPluginKey, { isChangeOrigin: true, isUndoRedoOperation: transaction.origin instanceof Y.UndoManager }) | ||
if ( | ||
@@ -549,3 +558,3 @@ this.beforeTransactionSelection !== null && this._isLocalCursorInView() | ||
_prosemirrorChanged (doc) { | ||
this.doc.transact((tr) => { | ||
this.doc.transact(() => { | ||
updateYFragment(this.doc, this.type, doc, this.mapping) | ||
@@ -689,3 +698,3 @@ this.beforeTransactionSelection = getRelativeSelection( | ||
* @param {any} schema | ||
* @param {ProsemirrorMapping} mapping | ||
* @param {ProsemirrorMapping} _mapping | ||
* @param {Y.Snapshot} [snapshot] | ||
@@ -699,3 +708,3 @@ * @param {Y.Snapshot} [prevSnapshot] | ||
schema, | ||
mapping, | ||
_mapping, | ||
snapshot, | ||
@@ -702,0 +711,0 @@ prevSnapshot, |
@@ -50,2 +50,5 @@ | ||
}, | ||
/** | ||
* @returns {any} | ||
*/ | ||
apply: (tr, val, oldState, state) => { | ||
@@ -52,0 +55,0 @@ const binding = ySyncPluginKey.getState(state).binding |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
248534
16
3875
7
+ Addedtypescript@^4.8.4
+ Addedtypescript@4.9.5(transitive)