y-prosemirror
Advanced tools
Comparing version 1.0.13 to 1.0.14
export function undo(state: any): boolean; | ||
export function redo(state: any): boolean; | ||
export function yUndoPlugin({ protectedNodes, trackedOrigins }?: { | ||
export const defaultProtectedNodes: Set<string>; | ||
export function defaultDeleteFilter(item: any, protectedNodes: any): boolean; | ||
export function yUndoPlugin({ protectedNodes, trackedOrigins, undoManager }?: { | ||
protectedNodes?: Set<string>; | ||
trackedOrigins?: any[]; | ||
undoManager?: any; | ||
}): Plugin<any, any>; | ||
import { Plugin } from "prosemirror-state"; |
{ | ||
"name": "y-prosemirror", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "Prosemirror bindings for Yjs", | ||
@@ -5,0 +5,0 @@ "main": "./dist/y-prosemirror.cjs", |
@@ -45,3 +45,3 @@ # y-prosemirror [![Build Status](https://travis-ci.com/yjs/y-prosemirror.svg?branch=master)](https://travis-ci.com/yjs/y-prosemirror) | ||
The shared cursors depend on the Awareness instance that is exported by most providers. The Awareness protocol handles non-permanent data like the number of users, their user names, their cursor location, and their colors. You can change the name and color of the user like this: | ||
The shared cursors depend on the Awareness instance that is exported by most providers. The [Awareness protocol](https://github.com/yjs/y-protocols#awareness-protocol) handles non-permanent data like the number of users, their user names, their cursor location, and their colors. You can change the name and color of the user like this: | ||
@@ -48,0 +48,0 @@ ```js |
import { Plugin, PluginKey } from 'prosemirror-state' // eslint-disable-line | ||
import { Plugin } from 'prosemirror-state' // eslint-disable-line | ||
@@ -24,3 +24,11 @@ import { getRelativeSelection } from './sync-plugin.js' | ||
export const yUndoPlugin = ({ protectedNodes = new Set(['paragraph']), trackedOrigins = [] } = {}) => new Plugin({ | ||
export const defaultProtectedNodes = new Set(['paragraph']) | ||
export const defaultDeleteFilter = (item, protectedNodes) => !(item instanceof Item) || | ||
!(item.content instanceof ContentType) || | ||
!(item.content.type instanceof Text || | ||
(item.content.type instanceof XmlElement && protectedNodes.has(item.content.type.nodeName))) || | ||
item.content.type._length === 0 | ||
export const yUndoPlugin = ({ protectedNodes = defaultProtectedNodes, trackedOrigins = [], undoManager = null } = {}) => new Plugin({ | ||
key: yUndoPluginKey, | ||
@@ -31,15 +39,11 @@ state: { | ||
const ystate = ySyncPluginKey.getState(state) | ||
const undoManager = new UndoManager(ystate.type, { | ||
const _undoManager = undoManager || new UndoManager(ystate.type, { | ||
trackedOrigins: new Set([ySyncPluginKey].concat(trackedOrigins)), | ||
deleteFilter: item => !(item instanceof Item) || | ||
!(item.content instanceof ContentType) || | ||
!(item.content.type instanceof Text || | ||
(item.content.type instanceof XmlElement && protectedNodes.has(item.content.type.nodeName))) || | ||
item.content.type._length === 0 | ||
deleteFilter: (item) => defaultDeleteFilter(item, protectedNodes) | ||
}) | ||
return { | ||
undoManager, | ||
undoManager: _undoManager, | ||
prevSel: null, | ||
hasUndoOps: undoManager.undoStack.length > 0, | ||
hasRedoOps: undoManager.redoStack.length > 0 | ||
hasUndoOps: _undoManager.undoStack.length > 0, | ||
hasRedoOps: _undoManager.redoStack.length > 0 | ||
} | ||
@@ -46,0 +50,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3994483
38371