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.2 to 0.0.3

LICENSE

21

dist/y-prosemirror.js

@@ -14,2 +14,3 @@ 'use strict';

var Y = require('yjs');
require('y-protocols/awareness.js');

@@ -40,3 +41,3 @@ /**

*/
const prosemirrorPlugin = yXmlFragment => {
const prosemirrorPlugin = (yXmlFragment) => {
let changedInitialContent = false;

@@ -122,4 +123,6 @@ const plugin = new prosemirrorState.Plugin({

* @public
* @param {Awareness} awareness
* @return {Plugin}
*/
const cursorPlugin = new prosemirrorState.Plugin({
const cursorPlugin = awareness => new prosemirrorState.Plugin({
key: cursorPluginKey,

@@ -130,3 +133,2 @@ props: {

const y = ystate.doc;
const awareness = y.getAwarenessInfo();
const decorations = [];

@@ -137,3 +139,3 @@ if (ystate.snapshot != null || ystate.binding === null) {

}
awareness.forEach((aw, clientId) => {
awareness.getStates().forEach((aw, clientId) => {
if (clientId === y.clientID) {

@@ -177,3 +179,2 @@ return

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

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

const updateCursorInfo = () => {
const current = y.getLocalAwarenessInfo();
const current = awareness.getLocalState() || {};
if (view.hasFocus() && ystate.binding !== null) {

@@ -195,3 +196,3 @@ /**

if (current.cursor == null || !Y.compareRelativePositions(Y.createRelativePositionFromJSON(current.cursor.anchor), anchor) || !Y.compareRelativePositions(Y.createRelativePositionFromJSON(current.cursor.head), head)) {
y.setAwarenessField('cursor', {
awareness.setLocalStateField('cursor', {
anchor, head

@@ -201,6 +202,6 @@ });

} else if (current.cursor !== null) {
y.setAwarenessField('cursor', null);
awareness.setLocalStateField('cursor', null);
}
};
y.on('awareness', awarenessListener);
awareness.on('change', awarenessListener);
view.dom.addEventListener('focusin', updateCursorInfo);

@@ -213,3 +214,3 @@ view.dom.addEventListener('focusout', updateCursorInfo);

y.setAwarenessField('cursor', null);
y.off('awareness', awarenessListener);
y.off('change', awarenessListener);
}

@@ -216,0 +217,0 @@ }

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

@@ -10,8 +10,7 @@ "main": "./dist/y-prosemirror.js",

"dist": "rm -rf dist && rollup -c",
"test": "echo 'should lint here'",
"test": "rollup -c && node test/test.node.js",
"lint": "standard",
"watch": "rollup -wc",
"debug": "concurrently 'live-server --port=3443 --entry-file=test.html' 'npm run watch'",
"preversion": "npm run test",
"version": "npm run dist"
"preversion": "npm run lint && npm run dist && npm run test"
},

@@ -35,5 +34,8 @@ "files": [

"homepage": "https://github.com/y-js/y-prosemirror#readme",
"dependencies": {
"lib0": "0.0.5"
},
"peerDependencies": {
"lib0": "0.0.4",
"yjs": "13.0.0-82",
"yjs": "13.0.0-83",
"y-protocols": ">=0.0.6",
"prosemirror-model": "^1.7.0",

@@ -45,2 +47,3 @@ "prosemirror-state": "^1.2.2",

"concurrently": "^4.1.0",
"jsdom": "^15.0.0",
"live-server": "^1.2.1",

@@ -54,4 +57,5 @@ "prosemirror-model": "^1.7.0",

"rollup-plugin-node-resolve": "^4.2.3",
"yjs": "13.0.0-82"
"yjs": "13.0.0-83",
"y-protocols": "0.0.6"
}
}
# y-prosemirror
> [ProseMirror](http://prosemirror.net/) Binding for [Yjs](https://github.com/y-js/yjs) - [Demo](https://yjs-demos.now.sh/prosemirror/)
This binding maps a YXmlFragment to a ProseMirror model.
This binding maps a Y.XmlFragment to the ProseMirror state.

@@ -28,2 +28,6 @@ ### Features

Also look [here](https://github.com/y-js/yjs-demos/tree/master/prosemirror) for a working example.
Also look [here](https://github.com/y-js/yjs-demos/tree/master/prosemirror) for a working example.
### License
[The MIT License](./LICENSE) © Kevin Jahns

@@ -14,2 +14,3 @@ /**

import * as Y from 'yjs'
import { Awareness } from 'y-protocols/awareness.js' // eslint-disable-line

@@ -36,3 +37,3 @@ export const isVisible = (item, snapshot) => snapshot === undefined ? !item._deleted : (snapshot.sm.has(item._id.user) && snapshot.sm.get(item._id.user) > item._id.clock && !snapshot.ds.isDeleted(item._id))

*/
export const prosemirrorPlugin = yXmlFragment => {
export const prosemirrorPlugin = (yXmlFragment) => {
let changedInitialContent = false

@@ -118,4 +119,6 @@ const plugin = new Plugin({

* @public
* @param {Awareness} awareness
* @return {Plugin}
*/
export const cursorPlugin = new Plugin({
export const cursorPlugin = awareness => new Plugin({
key: cursorPluginKey,

@@ -126,3 +129,2 @@ props: {

const y = ystate.doc
const awareness = y.getAwarenessInfo()
const decorations = []

@@ -133,3 +135,3 @@ if (ystate.snapshot != null || ystate.binding === null) {

}
awareness.forEach((aw, clientId) => {
awareness.getStates().forEach((aw, clientId) => {
if (clientId === y.clientID) {

@@ -173,3 +175,2 @@ return

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

@@ -179,3 +180,3 @@ view.updateState(view.state)

const updateCursorInfo = () => {
const current = y.getLocalAwarenessInfo()
const current = awareness.getLocalState() || {}
if (view.hasFocus() && ystate.binding !== null) {

@@ -191,3 +192,3 @@ /**

if (current.cursor == null || !Y.compareRelativePositions(Y.createRelativePositionFromJSON(current.cursor.anchor), anchor) || !Y.compareRelativePositions(Y.createRelativePositionFromJSON(current.cursor.head), head)) {
y.setAwarenessField('cursor', {
awareness.setLocalStateField('cursor', {
anchor, head

@@ -197,6 +198,6 @@ })

} else if (current.cursor !== null) {
y.setAwarenessField('cursor', null)
awareness.setLocalStateField('cursor', null)
}
}
y.on('awareness', awarenessListener)
awareness.on('change', awarenessListener)
view.dom.addEventListener('focusin', updateCursorInfo)

@@ -209,3 +210,3 @@ view.dom.addEventListener('focusout', updateCursorInfo)

y.setAwarenessField('cursor', null)
y.off('awareness', awarenessListener)
y.off('change', awarenessListener)
}

@@ -212,0 +213,0 @@ }

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