y-prosemirror
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "y-prosemirror", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Prosemirror bindings for Yjs", | ||
@@ -5,0 +5,0 @@ "main": "./dist/y-prosemirror.cjs", |
@@ -104,3 +104,3 @@ import { updateYFragment, ProsemirrorMapping } from './plugins/sync-plugin.js' // eslint-disable-line | ||
if (pos === 0 && n.constructor !== Y.XmlText && n !== type) { // TODO: set to <= 0 | ||
return new Y.RelativePosition(n._item === null ? null : n._item.id, n._item === null ? Y.findRootTypeKey(n) : null, null) | ||
return createRelativePosition(n._item.parent, n._item) | ||
} | ||
@@ -111,2 +111,13 @@ } | ||
const createRelativePosition = (type, item) => { | ||
let typeid = null | ||
let tname = null | ||
if (type._item === null) { | ||
tname = Y.findRootTypeKey(type) | ||
} else { | ||
typeid = Y.createID(type._item.id.client, type._item.id.clock) | ||
} | ||
return new Y.RelativePosition(typeid, tname, item.id) | ||
} | ||
/** | ||
@@ -121,3 +132,3 @@ * @param {Y.Doc} y | ||
const decodedPos = Y.createAbsolutePositionFromRelativePosition(relPos, y) | ||
if (decodedPos === null || !Y.isParentOf(documentType, decodedPos.type._item)) { | ||
if (decodedPos === null || (decodedPos.type !== documentType && !Y.isParentOf(documentType, decodedPos.type._item))) { | ||
return null | ||
@@ -124,0 +135,0 @@ } |
import * as Y from 'yjs' | ||
import { Decoration, DecorationSet } from 'prosemirror-view' // eslint-disable-line | ||
import { Plugin, PluginKey } from 'prosemirror-state' // eslint-disable-line | ||
import { Plugin } from 'prosemirror-state' // eslint-disable-line | ||
import { Awareness } from 'y-protocols/awareness.js' // eslint-disable-line | ||
@@ -6,0 +6,0 @@ import { absolutePositionToRelativePosition, relativePositionToAbsolutePosition, setMeta } from '../lib.js' |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3745829
36597