prosemirror-view 1.23.5 → 1.23.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prosemirror-view",
3
- "version": "1.23.5",
3
+ "version": "1.23.8",
4
4
  "description": "ProseMirror's view component",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
package/src/dom.js CHANGED
@@ -39,7 +39,8 @@ function scanFor(node, off, targetNode, targetOff, dir) {
39
39
  if (node == targetNode && off == targetOff) return true
40
40
  if (off == (dir < 0 ? 0 : nodeSize(node))) {
41
41
  let parent = node.parentNode
42
- if (parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == "false")
42
+ if (!parent || parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) ||
43
+ node.contentEditable == "false")
43
44
  return false
44
45
  off = domIndex(node) + (dir < 0 ? 0 : 1)
45
46
  node = parent
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
  }
@@ -174,7 +174,7 @@ export class DOMObserver {
174
174
  checkCSS(this.view)
175
175
  }
176
176
  this.handleDOMChange(from, to, typeOver, added)
177
- if (this.view.docView.dirty) this.view.updateState(this.view.state)
177
+ if (this.view.docView && this.view.docView.dirty) this.view.updateState(this.view.state)
178
178
  else if (!this.currentSelection.eq(sel)) selectionToDOM(this.view)
179
179
  this.currentSelection.set(sel)
180
180
  }
package/src/index.js CHANGED
@@ -602,7 +602,10 @@ function checkStateComponent(plugin) {
602
602
  // The DOM serializer to use when putting content onto the
603
603
  // clipboard. If not given, the result of
604
604
  // [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema)
605
- // will be used.
605
+ // will be used. This object will only have its
606
+ // [`serializeFragment`](#model.DOMSerializer.serializeFragment)
607
+ // method called, and you may provide an alternative object type
608
+ // implementing a compatible method.
606
609
  //
607
610
  // clipboardTextSerializer:: ?(Slice) → string
608
611
  // A function that will be called to get the text for the current
package/src/input.js CHANGED
@@ -485,7 +485,7 @@ export function endComposition(view, forceUpdate) {
485
485
  if (browser.android && view.domObserver.flushingSoon >= 0) return
486
486
  view.domObserver.forceFlush()
487
487
  clearComposition(view)
488
- if (forceUpdate || view.docView.dirty) {
488
+ if (forceUpdate || view.docView && view.docView.dirty) {
489
489
  let sel = selectionFromDOM(view)
490
490
  if (sel && !sel.eq(view.state.selection)) view.dispatch(view.state.tr.setSelection(sel))
491
491
  else view.updateState(view.state)
package/src/selection.js CHANGED
@@ -42,7 +42,10 @@ export function selectionToDOM(view, force) {
42
42
 
43
43
  if (!editorOwnsSelection(view)) return
44
44
 
45
- if (!force && view.mouseDown && view.mouseDown.allowDefault) {
45
+ // The delayed drag selection causes issues with Cell Selections
46
+ // in Safari. And the drag selection delay is to workarond issues
47
+ // which only present in Chrome.
48
+ if (!force && view.mouseDown && view.mouseDown.allowDefault && browser.chrome) {
46
49
  let domSel = view.root.getSelection(), curSel = view.domObserver.currentSelection
47
50
  if (domSel.anchorNode && isEquivalentPosition(domSel.anchorNode, domSel.anchorOffset,
48
51
  curSel.anchorNode, curSel.anchorOffset)) {
package/src/viewdesc.js CHANGED
@@ -462,7 +462,8 @@ class ViewDesc {
462
462
  else child.markDirty(from - startInside, to - startInside)
463
463
  return
464
464
  } else {
465
- child.dirty = child.dom == child.contentDOM && child.dom.parentNode == this.contentDOM ? CONTENT_DIRTY : NODE_DIRTY
465
+ child.dirty = child.dom == child.contentDOM && child.dom.parentNode == this.contentDOM && !child.children.length
466
+ ? CONTENT_DIRTY : NODE_DIRTY
466
467
  }
467
468
  }
468
469
  offset = end
@@ -577,7 +578,10 @@ class MarkViewDesc extends ViewDesc {
577
578
  return new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom)
578
579
  }
579
580
 
580
- parseRule() { return {mark: this.mark.type.name, attrs: this.mark.attrs, contentElement: this.contentDOM} }
581
+ parseRule() {
582
+ if ((this.dirty & NODE_DIRTY) || this.mark.type.spec.reparseInView) return null
583
+ return {mark: this.mark.type.name, attrs: this.mark.attrs, contentElement: this.contentDOM}
584
+ }
581
585
 
582
586
  matchesMark(mark) { return this.dirty != NODE_DIRTY && this.mark.eq(mark) }
583
587
 
@@ -1422,10 +1426,13 @@ function findTextInFragment(frag, text, from, to) {
1422
1426
  if (!next.isText) break
1423
1427
  str += next.text
1424
1428
  }
1425
- if (pos >= from && childStart < to) {
1426
- let found = str.lastIndexOf(text, to - childStart - 1)
1429
+ if (pos >= from) {
1430
+ let found = childStart < to ? str.lastIndexOf(text, to - childStart - 1) : -1
1427
1431
  if (found >= 0 && found + text.length + childStart >= from)
1428
1432
  return childStart + found
1433
+ if (from == to && str.length >= (to + text.length) - childStart &&
1434
+ str.slice(to - childStart, to - childStart + text.length) == text)
1435
+ return to
1429
1436
  }
1430
1437
  }
1431
1438
  return -1