@guardian/prosemirror-noting
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -579,4 +579,23 @@ 'use strict'; | ||
}, { | ||
key: "rebuildRange", | ||
value: function rebuildRange(state) { | ||
key: "diffRange", | ||
value: function diffRange(state, oldState) { | ||
var start = oldState.doc.content.findDiffStart(state.doc.content); | ||
if (start) { | ||
var end = oldState.doc.content.findDiffEnd(state.doc.content).b; | ||
if (start < end) { | ||
return this.mergeableRange(start, end); | ||
} else if (oldState.doc.nodeSize < state.doc.nodeSize) { | ||
// make sure we're over-zealous with our rebuild size | ||
var diff = state.doc.nodeSize - oldState.doc.nodeSize; | ||
return this.mergeableRange(start, start + diff); | ||
} | ||
} | ||
return false; | ||
} | ||
}, { | ||
key: "insertedRange", | ||
value: function insertedRange(state) { | ||
var ranges = getInsertedRanges(state); | ||
@@ -648,3 +667,3 @@ | ||
} else if (tr.getMeta("paste") || tr.getMeta(this.historyPlugin)) { | ||
this.handlePaste(); | ||
this.handleChange(!!tr.getMeta(this.historyPlugin), oldState); | ||
} else { | ||
@@ -878,8 +897,8 @@ this.handleInput(oldState); | ||
}, { | ||
key: "handlePaste", | ||
value: function handlePaste() { | ||
key: "handleChange", | ||
value: function handleChange(undo, oldState) { | ||
var noteTracker = this.noteTracker, | ||
tr = this.tr, | ||
markType = this.markType; | ||
var rebuildRange = noteTracker.rebuildRange(tr); | ||
var rebuildRange = undo ? noteTracker.diffRange(tr, oldState) : noteTracker.insertedRange(tr); | ||
@@ -886,0 +905,0 @@ if (rebuildRange) { |
{ | ||
"name": "@guardian/prosemirror-noting", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "A plugin to allow noting in prosemirror", | ||
@@ -5,0 +5,0 @@ "main": "dist/noting.js", |
@@ -158,3 +158,18 @@ import Note from "./Note"; | ||
rebuildRange(state) { | ||
diffRange(state, oldState) { | ||
const start = oldState.doc.content.findDiffStart(state.doc.content); | ||
if (start) { | ||
const end = oldState.doc.content.findDiffEnd(state.doc.content).b; | ||
if (start < end) { | ||
return this.mergeableRange(start, end); | ||
} else if (oldState.doc.nodeSize < state.doc.nodeSize) { | ||
// make sure we're over-zealous with our rebuild size | ||
const diff = state.doc.nodeSize - oldState.doc.nodeSize; | ||
return this.mergeableRange(start, start + diff); | ||
} | ||
} | ||
return false; | ||
} | ||
insertedRange(state) { | ||
let ranges = getInsertedRanges(state); | ||
@@ -161,0 +176,0 @@ |
@@ -34,3 +34,3 @@ import { Selection } from "prosemirror-state"; | ||
} else if (tr.getMeta("paste") || tr.getMeta(this.historyPlugin)) { | ||
this.handlePaste(); | ||
this.handleChange(!!tr.getMeta(this.historyPlugin), oldState); | ||
} else { | ||
@@ -249,5 +249,7 @@ this.handleInput(oldState); | ||
*/ | ||
handlePaste() { | ||
handleChange(undo, oldState) { | ||
const { noteTracker, tr, markType } = this; | ||
const rebuildRange = noteTracker.rebuildRange(tr); | ||
const rebuildRange = undo | ||
? noteTracker.diffRange(tr, oldState) | ||
: noteTracker.insertedRange(tr); | ||
@@ -254,0 +256,0 @@ if (rebuildRange) { |
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
2021087
2472