prosemirror-history
Advanced tools
Comparing version 0.19.0 to 0.20.0
@@ -5,3 +5,2 @@ var RopeSequence = require("rope-sequence") | ||
var ref$1 = require("prosemirror-state"); | ||
var Selection = ref$1.Selection; | ||
var Plugin = ref$1.Plugin; | ||
@@ -20,7 +19,7 @@ var PluginKey = ref$1.PluginKey; | ||
// | ||
// An item that has both a step and a selection JSON representation is | ||
// the start of an 'event' — a group of changes that will be undone | ||
// or redone at once. (It stores only the JSON, since that way we don't | ||
// have to provide a document until the selection is actually applied, | ||
// which is useful when compressing.) | ||
// An item that has both a step and a selection bookmark is the start | ||
// of an 'event' — a group of changes that will be undone or redone at | ||
// once. (It stores only the bookmark, since that way we don't have to | ||
// provide a document until the selection is actually applied, which | ||
// is useful when compressing.) | ||
@@ -84,3 +83,3 @@ // Used to schedule history compression | ||
if (item.selection) { | ||
selection = remap ? Selection.mapJSON(item.selection, remap.slice(mapFrom)) : item.selection | ||
selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection | ||
remaining = new Branch(this$1.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), this$1.eventCount - 1) | ||
@@ -159,3 +158,3 @@ return false | ||
var step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]) | ||
var selection = item.selection && Selection.mapJSON(item.selection, mapping.slice(iRebased, pos)) | ||
var selection = item.selection && item.selection.map(mapping.slice(iRebased, pos)) | ||
rebasedItems.push(new Item(map, step, selection)) | ||
@@ -204,3 +203,3 @@ } else { | ||
if (step) { | ||
var selection = item.selection && Selection.mapJSON(item.selection, remap.slice(mapFrom)) | ||
var selection = item.selection && item.selection.map(remap.slice(mapFrom)) | ||
if (selection) { events++ } | ||
@@ -268,9 +267,10 @@ var newItem = new Item(map.invert(), step, selection), merged, last = items.length - 1 | ||
var appended = tr.getMeta("appendedTransaction") | ||
if (tr.steps.length == 0) { | ||
return history | ||
} else if (tr.getMeta("addToHistory") !== false) { | ||
} else if ((appended || tr).getMeta("addToHistory") !== false) { | ||
// Group transforms that occur in quick succession into one event. | ||
var newGroup = history.prevTime < (tr.time || 0) - options.newGroupDelay || | ||
!isAdjacentToLastStep(tr, history.prevMap, history.done) | ||
return new HistoryState(history.done.addTransform(tr, newGroup ? selection.toJSON() : null, options), | ||
!appended && !isAdjacentToLastStep(tr, history.prevMap, history.done) | ||
return new HistoryState(history.done.addTransform(tr, newGroup ? selection.getBookmark() : null, options), | ||
Branch.empty, tr.mapping.maps[tr.steps.length - 1], tr.time) | ||
@@ -320,4 +320,4 @@ } else if (rebased = tr.getMeta("rebased")) { | ||
var selectionBefore = state.selection | ||
var selection = Selection.fromJSON(pop.transform.doc, pop.selection) | ||
var added = (redo ? history.done : history.undone).addTransform(pop.transform, selectionBefore.toJSON(), histOptions) | ||
var selection = pop.selection.resolve(pop.transform.doc) | ||
var added = (redo ? history.done : history.undone).addTransform(pop.transform, selectionBefore.getBookmark(), histOptions) | ||
@@ -324,0 +324,0 @@ var newHist = new HistoryState(redo ? added : pop.remaining, redo ? pop.remaining : added, null, 0) |
{ | ||
"name": "prosemirror-history", | ||
"version": "0.19.0", | ||
"version": "0.20.0", | ||
"description": "Undo history for ProseMirror", | ||
@@ -19,4 +19,4 @@ "main": "dist/history.js", | ||
"dependencies": { | ||
"prosemirror-state": "^0.19.0", | ||
"prosemirror-transform": "^0.19.0", | ||
"prosemirror-state": "^0.20.0", | ||
"prosemirror-transform": "^0.20.0", | ||
"rope-sequence": "^1.2.0" | ||
@@ -29,3 +29,4 @@ }, | ||
"rimraf": "^2.5.4", | ||
"prosemirror-model": "^0.19.0" | ||
"prosemirror-model": "^0.20.0", | ||
"prosemirror-test-builder": "^0.20.0" | ||
}, | ||
@@ -32,0 +33,0 @@ "scripts": { |
const RopeSequence = require("rope-sequence") | ||
const {Mapping} = require("prosemirror-transform") | ||
const {Selection, Plugin, PluginKey} = require("prosemirror-state") | ||
const {Plugin, PluginKey} = require("prosemirror-state") | ||
@@ -15,7 +15,7 @@ // ProseMirror's history isn't simply a way to roll back to a previous | ||
// | ||
// An item that has both a step and a selection JSON representation is | ||
// the start of an 'event' — a group of changes that will be undone | ||
// or redone at once. (It stores only the JSON, since that way we don't | ||
// have to provide a document until the selection is actually applied, | ||
// which is useful when compressing.) | ||
// An item that has both a step and a selection bookmark is the start | ||
// of an 'event' — a group of changes that will be undone or redone at | ||
// once. (It stores only the bookmark, since that way we don't have to | ||
// provide a document until the selection is actually applied, which | ||
// is useful when compressing.) | ||
@@ -78,3 +78,3 @@ // Used to schedule history compression | ||
if (item.selection) { | ||
selection = remap ? Selection.mapJSON(item.selection, remap.slice(mapFrom)) : item.selection | ||
selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection | ||
remaining = new Branch(this.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), this.eventCount - 1) | ||
@@ -153,3 +153,3 @@ return false | ||
let step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]) | ||
let selection = item.selection && Selection.mapJSON(item.selection, mapping.slice(iRebased, pos)) | ||
let selection = item.selection && item.selection.map(mapping.slice(iRebased, pos)) | ||
rebasedItems.push(new Item(map, step, selection)) | ||
@@ -196,3 +196,3 @@ } else { | ||
if (step) { | ||
let selection = item.selection && Selection.mapJSON(item.selection, remap.slice(mapFrom)) | ||
let selection = item.selection && item.selection.map(remap.slice(mapFrom)) | ||
if (selection) events++ | ||
@@ -265,9 +265,10 @@ let newItem = new Item(map.invert(), step, selection), merged, last = items.length - 1 | ||
let appended = tr.getMeta("appendedTransaction") | ||
if (tr.steps.length == 0) { | ||
return history | ||
} else if (tr.getMeta("addToHistory") !== false) { | ||
} else if ((appended || tr).getMeta("addToHistory") !== false) { | ||
// Group transforms that occur in quick succession into one event. | ||
let newGroup = history.prevTime < (tr.time || 0) - options.newGroupDelay || | ||
!isAdjacentToLastStep(tr, history.prevMap, history.done) | ||
return new HistoryState(history.done.addTransform(tr, newGroup ? selection.toJSON() : null, options), | ||
!appended && !isAdjacentToLastStep(tr, history.prevMap, history.done) | ||
return new HistoryState(history.done.addTransform(tr, newGroup ? selection.getBookmark() : null, options), | ||
Branch.empty, tr.mapping.maps[tr.steps.length - 1], tr.time) | ||
@@ -317,4 +318,4 @@ } else if (rebased = tr.getMeta("rebased")) { | ||
let selectionBefore = state.selection | ||
let selection = Selection.fromJSON(pop.transform.doc, pop.selection) | ||
let added = (redo ? history.done : history.undone).addTransform(pop.transform, selectionBefore.toJSON(), histOptions) | ||
let selection = pop.selection.resolve(pop.transform.doc) | ||
let added = (redo ? history.done : history.undone).addTransform(pop.transform, selectionBefore.getBookmark(), histOptions) | ||
@@ -321,0 +322,0 @@ let newHist = new HistoryState(redo ? added : pop.remaining, redo ? pop.remaining : added, null, 0) |
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
37801
749
6
+ Addedprosemirror-model@0.20.0(transitive)
+ Addedprosemirror-state@0.20.0(transitive)
+ Addedprosemirror-transform@0.20.0(transitive)
- Removedprosemirror-model@0.19.0(transitive)
- Removedprosemirror-state@0.19.1(transitive)
- Removedprosemirror-transform@0.19.0(transitive)
Updatedprosemirror-state@^0.20.0