prosemirror-collab
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -103,7 +103,17 @@ 'use strict'; | ||
// :: (state: EditorState, steps: [Step], clientIDs: [union<number, string>]) → Transaction | ||
// :: (state: EditorState, steps: [Step], clientIDs: [union<number, string>], options: ?Object) → Transaction | ||
// Create a transaction that represents a set of new steps received from | ||
// the authority. Applying this transaction moves the state forward to | ||
// adjust to the authority's view of the document. | ||
function receiveTransaction(state, steps, clientIDs) { | ||
// | ||
// options::- Additional options. | ||
// | ||
// mapSelectionBackward:: ?boolean | ||
// When enabled (the default is `false`), if the current selection | ||
// is a [text selection](#state.TextSelection), its sides are | ||
// mapped with a negative bias for this transaction, so that | ||
// content inserted at the cursor ends up after the cursor. Users | ||
// usually prefer this, but it isn't done by default for reasons | ||
// of backwards compatibility. | ||
function receiveTransaction(state, steps, clientIDs, options) { | ||
// Pushes a set of steps (received from the central authority) into | ||
@@ -138,2 +148,7 @@ // the editor state (which should have the collab plugin enabled). | ||
var newCollabState = new CollabState(version, unconfirmed); | ||
if (options && options.mapSelectionBackard && state.selection instanceof prosemirrorState.TextSelection) { | ||
tr.setSelection(prosemirrorState.TextSelection.between(tr.doc.resolve(tr.mapping.map(state.selection.head, -1)), | ||
tr.doc.resolve(tr.mapping.map(state.selection.anchor, -1)), -1)); | ||
tr.updated &= ~1; | ||
} | ||
return tr.setMeta("rebased", nUnconfirmed).setMeta("addToHistory", false).setMeta(collabKey, newCollabState) | ||
@@ -140,0 +155,0 @@ } |
{ | ||
"name": "prosemirror-collab", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Collaborative editing for ProseMirror", | ||
@@ -5,0 +5,0 @@ "main": "dist/collab.js", |
@@ -1,2 +0,2 @@ | ||
import {Plugin, PluginKey} from "prosemirror-state" | ||
import {Plugin, PluginKey, TextSelection} from "prosemirror-state" | ||
@@ -101,7 +101,17 @@ class Rebaseable { | ||
// :: (state: EditorState, steps: [Step], clientIDs: [union<number, string>]) → Transaction | ||
// :: (state: EditorState, steps: [Step], clientIDs: [union<number, string>], options: ?Object) → Transaction | ||
// Create a transaction that represents a set of new steps received from | ||
// the authority. Applying this transaction moves the state forward to | ||
// adjust to the authority's view of the document. | ||
export function receiveTransaction(state, steps, clientIDs) { | ||
// | ||
// options::- Additional options. | ||
// | ||
// mapSelectionBackward:: ?boolean | ||
// When enabled (the default is `false`), if the current selection | ||
// is a [text selection](#state.TextSelection), its sides are | ||
// mapped with a negative bias for this transaction, so that | ||
// content inserted at the cursor ends up after the cursor. Users | ||
// usually prefer this, but it isn't done by default for reasons | ||
// of backwards compatibility. | ||
export function receiveTransaction(state, steps, clientIDs, options) { | ||
// Pushes a set of steps (received from the central authority) into | ||
@@ -136,2 +146,7 @@ // the editor state (which should have the collab plugin enabled). | ||
let newCollabState = new CollabState(version, unconfirmed) | ||
if (options && options.mapSelectionBackard && state.selection instanceof TextSelection) { | ||
tr.setSelection(TextSelection.between(tr.doc.resolve(tr.mapping.map(state.selection.head, -1)), | ||
tr.doc.resolve(tr.mapping.map(state.selection.anchor, -1)), -1)) | ||
tr.updated &= ~1 | ||
} | ||
return tr.setMeta("rebased", nUnconfirmed).setMeta("addToHistory", false).setMeta(collabKey, newCollabState) | ||
@@ -138,0 +153,0 @@ } |
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
35515
11
336