y-prosemirror
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -12,3 +12,3 @@ /** | ||
*/ | ||
export function prosemirrorToYDoc(doc: Node, xmlFragment?: string): any; | ||
export function prosemirrorToYDoc(doc: Node, xmlFragment?: string): Y.Doc; | ||
/** | ||
@@ -26,3 +26,3 @@ * Utility method to convert Prosemirror compatible JSON into a Y.Doc. | ||
*/ | ||
export function prosemirrorJSONToYDoc(schema: Schema, state: any, xmlFragment?: string): any; | ||
export function prosemirrorJSONToYDoc(schema: Schema, state: any, xmlFragment?: string): Y.Doc; | ||
/** | ||
@@ -35,3 +35,3 @@ * Utility method to convert a Y.Doc to a Prosemirror Doc node. | ||
*/ | ||
export function yDocToProsemirror(schema: Schema, ydoc: any): Node; | ||
export function yDocToProsemirror(schema: Schema, ydoc: Y.Doc): Node; | ||
/** | ||
@@ -44,11 +44,12 @@ * Utility method to convert a Y.Doc to Prosemirror compatible JSON. | ||
*/ | ||
export function yDocToProsemirrorJSON(ydoc: any, xmlFragment?: string): Record<string, any>; | ||
export function yDocToProsemirrorJSON(ydoc: Y.Doc, xmlFragment?: string): Record<string, any>; | ||
export function setMeta(view: any, key: any, value: any): void; | ||
export function absolutePositionToRelativePosition(pos: number, type: any, mapping: Map<any, Node<any> | Node<any>[]>): any; | ||
export function relativePositionToAbsolutePosition(y: any, documentType: any, relPos: any, mapping: Map<any, Node<any> | Node<any>[]>): null | number; | ||
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; | ||
/** | ||
* Either a node if type is YXmlElement or an Array of text nodes if YXmlText | ||
*/ | ||
export type ProsemirrorMapping = Map<any, Node<any> | Node<any>[]>; | ||
export type ProsemirrorMapping = Map<Y.AbstractType<any>, Node<any> | Node<any>[]>; | ||
import { Node } from "prosemirror-model"; | ||
import * as Y from "yjs"; | ||
import { Schema } from "prosemirror-model"; |
@@ -1,3 +0,3 @@ | ||
export function isVisible(item: any, snapshot?: any): boolean; | ||
export function ySyncPlugin(yXmlFragment: any, { colors, colorMapping, permanentUserData }?: YSyncOpts): any; | ||
export function isVisible(item: Y.Item, snapshot?: Y.Snapshot): boolean; | ||
export function ySyncPlugin(yXmlFragment: Y.XmlFragment, { colors, colorMapping, permanentUserData }?: YSyncOpts): any; | ||
export function getRelativeSelection(pmbinding: any, state: any): { | ||
@@ -17,4 +17,4 @@ anchor: any; | ||
*/ | ||
constructor(yXmlFragment: any, prosemirrorView: any); | ||
type: any; | ||
constructor(yXmlFragment: Y.XmlFragment, prosemirrorView: any); | ||
type: Y.XmlFragment; | ||
prosemirrorView: any; | ||
@@ -25,3 +25,3 @@ mux: import("lib0/mutex").mutex; | ||
*/ | ||
mapping: Map<any, PModel.Node<any> | PModel.Node<any>[]>; | ||
mapping: Map<Y.AbstractType<any>, PModel.Node<any> | PModel.Node<any>[]>; | ||
_observeFunction: any; | ||
@@ -31,3 +31,3 @@ /** | ||
*/ | ||
doc: any; | ||
doc: Y.Doc; | ||
/** | ||
@@ -53,3 +53,3 @@ * current selection as relative positions in the Yjs model | ||
*/ | ||
_renderSnapshot(snapshot: any, prevSnapshot: any, pluginState: any): void; | ||
_renderSnapshot(snapshot: Y.Snapshot, prevSnapshot: Y.Snapshot, pluginState: any): void; | ||
/** | ||
@@ -59,11 +59,11 @@ * @param {Array<Y.YEvent>} events | ||
*/ | ||
_typeChanged(events: Array<any>, transaction: any): void; | ||
_typeChanged(events: Array<Y.YEvent>, transaction: Y.Transaction): void; | ||
_prosemirrorChanged(doc: any): void; | ||
destroy(): void; | ||
} | ||
export function updateYFragment(y: any, yDomFragment: any, pNode: any, mapping: Map<any, PModel.Node<any> | PModel.Node<any>[]>): void; | ||
export function updateYFragment(y: Y.Doc, yDomFragment: Y.XmlFragment, pNode: any, mapping: Map<Y.AbstractType<any>, PModel.Node<any> | PModel.Node<any>[]>): void; | ||
/** | ||
* Either a node if type is YXmlElement or an Array of text nodes if YXmlText | ||
*/ | ||
export type ProsemirrorMapping = Map<any, PModel.Node<any> | PModel.Node<any>[]>; | ||
export type ProsemirrorMapping = Map<Y.AbstractType<any>, PModel.Node<any> | PModel.Node<any>[]>; | ||
export type ColorDef = { | ||
@@ -76,5 +76,6 @@ light: string; | ||
colorMapping?: Map<string, ColorDef>; | ||
permanentUserData?: any | null; | ||
permanentUserData?: Y.PermanentUserData | null; | ||
}; | ||
export type NormalizedPNodeContent = (PModel.Node<any> | PModel.Node<any>[])[]; | ||
import * as Y from "yjs"; | ||
import * as PModel from "prosemirror-model"; |
{ | ||
"name": "y-prosemirror", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "Prosemirror bindings for Yjs", | ||
"main": "./dist/y-prosemirror.cjs", | ||
"module": "./src/y-prosemirror.js", | ||
"type": "module", | ||
"types": "./dist/src/y-prosemirror.d.ts", | ||
@@ -63,4 +64,4 @@ "sideEffects": false, | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^15.1.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"@rollup/plugin-commonjs": "^21.0.1", | ||
"@rollup/plugin-node-resolve": "^13.0.6", | ||
"@types/prosemirror-state": "^1.2.8", | ||
@@ -80,4 +81,4 @@ "concurrently": "^4.1.0", | ||
"y-webrtc": "^10.2.0", | ||
"yjs": "^13.5.18" | ||
"yjs": "^13.5.20" | ||
} | ||
} |
@@ -54,5 +54,8 @@ import { updateYFragment} from './plugins/sync-plugin.js' // eslint-disable-line | ||
} | ||
/** | ||
* @type {any} | ||
*/ | ||
let n = type._first === null ? null : /** @type {Y.ContentType} */ (type._first.content).type | ||
while (n !== null && type !== n) { | ||
if (n.constructor === Y.XmlText) { | ||
if (n instanceof Y.XmlText) { | ||
if (n._length >= pos) { | ||
@@ -150,3 +153,3 @@ return Y.createRelativePositionFromTypeIndex(n, pos) | ||
i++ | ||
if (t.constructor === Y.XmlText) { | ||
if (t instanceof Y.XmlText) { | ||
pos += t._length | ||
@@ -167,3 +170,3 @@ } else { | ||
pos += 1 // the start tag | ||
let n = parent._first | ||
let n = /** @type {Y.AbstractType} */ (parent)._first | ||
// now iterate until we found type | ||
@@ -176,3 +179,3 @@ while (n !== null) { | ||
if (!n.deleted) { | ||
if (contentType.constructor === Y.XmlText) { | ||
if (contentType instanceof Y.XmlText) { | ||
pos += contentType._length | ||
@@ -186,3 +189,3 @@ } else { | ||
} | ||
type = parent | ||
type = /** @type {Y.AbstractType} */ (parent) | ||
} | ||
@@ -205,3 +208,3 @@ return pos - 1 // we don't count the most outer tag, because it is a fragment | ||
const ydoc = new Y.Doc() | ||
const type = ydoc.get(xmlFragment, Y.XmlFragment) | ||
const type = /** @type {Y.XmlFragment} */ (ydoc.get(xmlFragment, Y.XmlFragment)) | ||
if (!type.doc) { | ||
@@ -208,0 +211,0 @@ return ydoc |
@@ -28,2 +28,4 @@ | ||
const rxValidColor = /^#[0-9a-fA-F]{6}$/ | ||
/** | ||
@@ -50,2 +52,5 @@ * @param {any} state | ||
user.color = '#ffa500' | ||
} else if (!rxValidColor.test(user.color)) { | ||
// We only support 6-digit RGB colors in y-prosemirror | ||
console.warn('A user uses an unsupported color format', user) | ||
} | ||
@@ -52,0 +57,0 @@ if (user.name == null) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Yes
3992644
38355