prosemirror-view 1.23.7 → 1.23.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/index.es.js +25 -9
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +25 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/decoration.js +10 -4
- package/src/domchange.js +5 -2
- package/src/index.js +1 -0
- package/src/viewdesc.js +9 -3
package/package.json
CHANGED
package/src/decoration.js
CHANGED
|
@@ -512,9 +512,10 @@ function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, op
|
|
|
512
512
|
let shift = (oldStart, oldEnd, newStart, newEnd) => {
|
|
513
513
|
for (let i = 0; i < children.length; i += 3) {
|
|
514
514
|
let end = children[i + 1], dSize
|
|
515
|
-
if (end
|
|
516
|
-
|
|
517
|
-
|
|
515
|
+
if (end < 0 || oldStart > end + oldOffset) continue
|
|
516
|
+
let start = children[i] + oldOffset
|
|
517
|
+
if (oldEnd >= start) {
|
|
518
|
+
children[i + 1] = oldStart <= start ? -2 : -1
|
|
518
519
|
} else if (newStart >= offset && (dSize = (newEnd - newStart) - (oldEnd - oldStart))) {
|
|
519
520
|
children[i] += dSize
|
|
520
521
|
children[i + 1] += dSize
|
|
@@ -526,7 +527,12 @@ function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, op
|
|
|
526
527
|
// Find the child nodes that still correspond to a single node,
|
|
527
528
|
// recursively call mapInner on them and update their positions.
|
|
528
529
|
let mustRebuild = false
|
|
529
|
-
for (let i = 0; i < children.length; i += 3) if (children[i + 1]
|
|
530
|
+
for (let i = 0; i < children.length; i += 3) if (children[i + 1] < 0) { // Touched nodes
|
|
531
|
+
if (children[i + 1] == -2) {
|
|
532
|
+
mustRebuild = true
|
|
533
|
+
children[i + 1] = -1
|
|
534
|
+
continue
|
|
535
|
+
}
|
|
530
536
|
let from = mapping.map(oldChildren[i] + oldOffset), fromLocal = from - offset
|
|
531
537
|
if (fromLocal < 0 || fromLocal >= node.content.size) {
|
|
532
538
|
mustRebuild = true
|
package/src/domchange.js
CHANGED
|
@@ -93,6 +93,7 @@ export function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
93
93
|
|
|
94
94
|
let sel = view.state.selection
|
|
95
95
|
let parse = parseBetween(view, from, to)
|
|
96
|
+
|
|
96
97
|
// Chrome sometimes leaves the cursor before the inserted text when
|
|
97
98
|
// composing after a cursor wrapper. This moves it forward.
|
|
98
99
|
if (browser.chrome && view.cursorWrapper && parse.sel && parse.sel.anchor == view.cursorWrapper.deco.from) {
|
|
@@ -138,9 +139,11 @@ export function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
138
139
|
if (view.state.selection.from < view.state.selection.to &&
|
|
139
140
|
change.start == change.endB &&
|
|
140
141
|
view.state.selection instanceof TextSelection) {
|
|
141
|
-
if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2
|
|
142
|
+
if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 &&
|
|
143
|
+
view.state.selection.from >= parse.from) {
|
|
142
144
|
change.start = view.state.selection.from
|
|
143
|
-
} else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2
|
|
145
|
+
} else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2 &&
|
|
146
|
+
view.state.selection.to <= parse.to) {
|
|
144
147
|
change.endB += (view.state.selection.to - change.endA)
|
|
145
148
|
change.endA = view.state.selection.to
|
|
146
149
|
}
|
package/src/index.js
CHANGED
|
@@ -428,6 +428,7 @@ function updateCursorWrapper(view) {
|
|
|
428
428
|
let dom = document.createElement("img")
|
|
429
429
|
dom.className = "ProseMirror-separator"
|
|
430
430
|
dom.setAttribute("mark-placeholder", "true")
|
|
431
|
+
dom.setAttribute("alt", "")
|
|
431
432
|
view.cursorWrapper = {dom, deco: Decoration.widget(view.state.selection.head, dom, {raw: true, marks: view.markCursor})}
|
|
432
433
|
} else {
|
|
433
434
|
view.cursorWrapper = null
|
package/src/viewdesc.js
CHANGED
|
@@ -1267,7 +1267,10 @@ class ViewTreeUpdater {
|
|
|
1267
1267
|
this.index++
|
|
1268
1268
|
} else {
|
|
1269
1269
|
let dom = document.createElement(nodeName)
|
|
1270
|
-
if (nodeName == "IMG")
|
|
1270
|
+
if (nodeName == "IMG") {
|
|
1271
|
+
dom.className = "ProseMirror-separator"
|
|
1272
|
+
dom.alt = ""
|
|
1273
|
+
}
|
|
1271
1274
|
if (nodeName == "BR") dom.className = "ProseMirror-trailingBreak"
|
|
1272
1275
|
this.top.children.splice(this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null))
|
|
1273
1276
|
this.changed = true
|
|
@@ -1426,10 +1429,13 @@ function findTextInFragment(frag, text, from, to) {
|
|
|
1426
1429
|
if (!next.isText) break
|
|
1427
1430
|
str += next.text
|
|
1428
1431
|
}
|
|
1429
|
-
if (pos >= from
|
|
1430
|
-
let found = str.lastIndexOf(text, to - childStart - 1)
|
|
1432
|
+
if (pos >= from) {
|
|
1433
|
+
let found = childStart < to ? str.lastIndexOf(text, to - childStart - 1) : -1
|
|
1431
1434
|
if (found >= 0 && found + text.length + childStart >= from)
|
|
1432
1435
|
return childStart + found
|
|
1436
|
+
if (from == to && str.length >= (to + text.length) - childStart &&
|
|
1437
|
+
str.slice(to - childStart, to - childStart + text.length) == text)
|
|
1438
|
+
return to
|
|
1433
1439
|
}
|
|
1434
1440
|
}
|
|
1435
1441
|
return -1
|