You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

y-prosemirror

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.0.2

src/y-prosemirror.js

66

dist/y-prosemirror.js

@@ -50,3 +50,3 @@ 'use strict';

type: yXmlFragment,
y: yXmlFragment._y,
doc: yXmlFragment.doc,
binding: null,

@@ -127,3 +127,3 @@ snapshot: null,

const ystate = prosemirrorPluginKey.getState(state);
const y = ystate.y;
const y = ystate.doc;
const awareness = y.getAwarenessInfo();

@@ -147,4 +147,4 @@ const decorations = [];

}
let anchor = relativePositionToAbsolutePosition(y, ystate.type, Y.createCursorFromJSON(aw.cursor.anchor), ystate.binding.mapping);
let head = relativePositionToAbsolutePosition(y, ystate.type, Y.createCursorFromJSON(aw.cursor.head), ystate.binding.mapping);
let anchor = relativePositionToAbsolutePosition(y, ystate.type, Y.createRelativePositionFromJSON(aw.cursor.anchor), ystate.binding.mapping);
let head = relativePositionToAbsolutePosition(y, ystate.type, Y.createRelativePositionFromJSON(aw.cursor.head), ystate.binding.mapping);
if (anchor !== null && head !== null) {

@@ -175,3 +175,3 @@ let maxsize = math.max(state.doc.content.size - 1, 0);

const ystate = prosemirrorPluginKey.getState(view.state);
const y = ystate.y;
const y = ystate.doc;
const awarenessListener = () => {

@@ -184,12 +184,12 @@ view.updateState(view.state);

/**
* @type {Y.Cursor}
* @type {Y.RelativePosition}
*/
const anchor = absolutePositionToRelativePosition(view.state.selection.anchor, ystate.type, ystate.binding.mapping);
/**
* @type {Y.Cursor}
* @type {Y.RelativePosition}
*/
const head = absolutePositionToRelativePosition(view.state.selection.head, ystate.type, ystate.binding.mapping);
if (current.cursor == null || !Y.compareCursors(Y.createCursorFromJSON(current.cursor.anchor), anchor) || !Y.compareCursors(Y.createCursorFromJSON(current.cursor.head), head)) {
if (current.cursor == null || !Y.compareRelativePositions(Y.createRelativePositionFromJSON(current.cursor.anchor), anchor) || !Y.compareRelativePositions(Y.createRelativePositionFromJSON(current.cursor.head), head)) {
y.setAwarenessField('cursor', {
anchor: anchor.toJSON(), head: head.toJSON()
anchor, head
});

@@ -207,3 +207,3 @@ }

destroy: () => {
const y = prosemirrorPluginKey.getState(view.state).y;
const y = prosemirrorPluginKey.getState(view.state).doc;
y.setAwarenessField('cursor', null);

@@ -226,3 +226,3 @@ y.off('awareness', awarenessListener);

if (pos === 0) {
return Y.createCursorFromTypeOffset(type, 0)
return Y.createRelativePositionFromTypeIndex(type, 0)
}

@@ -234,3 +234,3 @@ let n = type._first !== null ? /** @type {Y.ItemType} */ (type._first).type : null;

if (n._length >= pos) {
return Y.createCursorFromTypeOffset(n, pos)
return Y.createRelativePositionFromTypeIndex(n, pos)
} else {

@@ -257,3 +257,3 @@ pos -= n._length;

// edge case, should end in this paragraph
return new Y.Cursor(n._item === null ? null : n._item.id, n._item === null ? Y.findRootTypeKey(n) : null, null)
return new Y.RelativePosition(n._item === null ? null : n._item.id, n._item === null ? Y.findRootTypeKey(n) : null, null)
}

@@ -267,3 +267,3 @@ pos -= pNodeSize;

n = n._item === null ? n : n._item.parent;
return new Y.Cursor(n._item === null ? null : n._item.id, n._item === null ? Y.findRootTypeKey(n) : null, null)
return new Y.RelativePosition(n._item === null ? null : n._item.id, n._item === null ? Y.findRootTypeKey(n) : null, null)
}

@@ -284,10 +284,10 @@ do {

if (pos === 0 && n.constructor !== Y.XmlText && n !== type) { // TODO: set to <= 0
return new Y.Cursor(n._item === null ? null : n._item.id, n._item === null ? Y.findRootTypeKey(n) : null, null)
return new Y.RelativePosition(n._item === null ? null : n._item.id, n._item === null ? Y.findRootTypeKey(n) : null, null)
}
}
return Y.createCursorFromTypeOffset(type, type._length)
return Y.createRelativePositionFromTypeIndex(type, type._length)
};
/**
* @param {Y.Y} y
* @param {Y.Doc} y
* @param {Y.XmlFragment} yDoc Top level type that is bound to pView

@@ -298,3 +298,3 @@ * @param {any} relPos Encoded Yjs based relative position

const relativePositionToAbsolutePosition = (y, yDoc, relPos, mapping) => {
const decodedPos = Y.createAbsolutePositionFromCursor(relPos, y);
const decodedPos = Y.createAbsolutePositionFromRelativePosition(relPos, y);
if (decodedPos === null) {

@@ -306,7 +306,7 @@ return null

if (type.constructor === Y.XmlText) {
pos = decodedPos.offset;
pos = decodedPos.index;
} else if (type._item === null || !type._item.deleted) {
let n = /** @type {Y.ItemType} */ (type._first);
let i = 0;
while (i < type._length && i < decodedPos.offset && n !== null) {
while (i < type._length && i < decodedPos.index && n !== null) {
i++;

@@ -367,6 +367,6 @@ if (n.type.constructor === Y.XmlText) {

/**
* @type {Y.Y}
* @type {Y.Doc}
*/
// @ts-ignore
this.y = yXmlFragment._y;
this.doc = yXmlFragment.doc;
/**

@@ -376,3 +376,3 @@ * current selection as relative positions in the Yjs model

this._relSelection = null;
this.y.on('beforeTransaction', e => {
this.doc.on('beforeTransaction', e => {
this._relSelection = {

@@ -402,3 +402,3 @@ anchor: absolutePositionToRelativePosition(this.prosemirrorView.state.selection.anchor, yXmlFragment, this.mapping),

this.mux(() => {
const fragmentContent = Y.typeArrayToArraySnapshot(this.type, new Y.Snapshot(prevSnapshot.ds, snapshot.sm, snapshot.userMap)).map(t => createNodeFromYElement(t, this.prosemirrorView.state.schema, new Map(), snapshot, prevSnapshot)).filter(n => n !== null);
const fragmentContent = Y.typeListToArraySnapshot(this.type, new Y.Snapshot(prevSnapshot.ds, snapshot.sm)).map(t => createNodeFromYElement(t, this.prosemirrorView.state.schema, new Map(), snapshot, prevSnapshot)).filter(n => n !== null);
const tr = this.prosemirrorView.state.tr.replace(0, this.prosemirrorView.state.doc.content.size, new PModel.Slice(new PModel.Fragment(fragmentContent), 0, 0));

@@ -419,3 +419,3 @@ this.prosemirrorView.dispatch(tr);

const delStruct = (_, struct) => this.mapping.delete(struct);
Y.iterateDeletedStructs(transaction.deleteSet, this.y.store, struct => this.mapping.delete(/** @type {Y.ItemType} */ (struct).type));
Y.iterateDeletedStructs(transaction.deleteSet, this.doc.store, struct => this.mapping.delete(/** @type {Y.ItemType} */ (struct).type));
transaction.changed.forEach(delStruct);

@@ -427,4 +427,4 @@ transaction.changedParentTypes.forEach(delStruct);

if (relSel !== null && relSel.anchor !== null && relSel.head !== null) {
const anchor = relativePositionToAbsolutePosition(this.y, this.type, relSel.anchor, this.mapping);
const head = relativePositionToAbsolutePosition(this.y, this.type, relSel.head, this.mapping);
const anchor = relativePositionToAbsolutePosition(this.doc, this.type, relSel.anchor, this.mapping);
const head = relativePositionToAbsolutePosition(this.doc, this.type, relSel.head, this.mapping);
if (anchor !== null && head !== null) {

@@ -440,3 +440,3 @@ tr = tr.setSelection(prosemirrorState.TextSelection.create(tr.doc, anchor, head));

this.mux(() => {
updateYFragment(this.y, this.type, doc.content, this.mapping);
updateYFragment(this.doc, this.type, doc.content, this.mapping);
});

@@ -485,3 +485,3 @@ }

// if this element is already rendered as deleted (ychange), then do not render children as deleted
_snapshot = new Y.Snapshot(prevSnapshot.ds, snapshot.sm, snapshot.userMap);
_snapshot = new Y.Snapshot(prevSnapshot.ds, snapshot.sm);
_prevSnapshot = _snapshot;

@@ -513,3 +513,3 @@ } else if (!isVisible(el, prevSnapshot)) {

} else {
Y.typeArrayToArraySnapshot(el, new Y.Snapshot(prevSnapshot.ds, snapshot.sm, snapshot.userMap)).forEach(createChildren);
Y.typeListToArraySnapshot(el, new Y.Snapshot(prevSnapshot.ds, snapshot.sm)).forEach(createChildren);
}

@@ -529,3 +529,3 @@ let node;

// an error occured while creating the node. This is probably a result of a concurrent action.
/** @type {Y.Y} */ (el._y).transact(transaction => {
/** @type {Y.Doc} */ (el.doc).transact(transaction => {
/** @type {Y.ItemType} */ (el._item).delete(transaction);

@@ -565,3 +565,3 @@ });

// an error occured while creating the node. This is probably a result of a concurrent action.
/** @type {Y.Y} */ (text._y).transact(transaction => {
/** @type {Y.Doc} */ (text.doc).transact(transaction => {
/** @type {Y.ItemType} */ (text._item).delete(transaction);

@@ -670,3 +670,3 @@ });

* @private
* @param {Y.Y} y
* @param {Y.Doc} y
* @param {Y.XmlFragment} yDomFragment

@@ -673,0 +673,0 @@ * @param {Object} pContent

{
"name": "y-prosemirror",
"version": "0.0.1",
"version": "0.0.2",
"description": "Prosemirror bindings for Yjs",

@@ -9,3 +9,3 @@ "main": "./dist/y-prosemirror.js",

"scripts": {
"dist": "rm -rf dist/* && rollup -c",
"dist": "rm -rf dist && rollup -c",
"test": "echo 'should lint here'",

@@ -19,3 +19,4 @@ "lint": "standard",

"files": [
"dist/*"
"dist/*",
"src/*"
],

@@ -36,4 +37,4 @@ "repository": {

"peerDependencies": {
"lib0": "*",
"yjs": "13.0.0-81",
"lib0": "0.0.4",
"yjs": "13.0.0-82",
"prosemirror-model": "^1.7.0",

@@ -44,6 +45,6 @@ "prosemirror-state": "^1.2.2",

"devDependencies": {
"yjs": "13.0.0-81",
"concurrently": "^4.1.0",
"live-server": "^1.2.1",
"prosemirror-model": "^1.7.0",
"prosemirror-schema-basic": "^1.0.1",
"prosemirror-state": "^1.2.2",

@@ -53,4 +54,5 @@ "prosemirror-view": "^1.7.1",

"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-node-resolve": "^4.2.3"
"rollup-plugin-node-resolve": "^4.2.3",
"yjs": "13.0.0-82"
}
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc