prosemirror-view 1.23.6 → 1.23.9

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.6",
3
+ "version": "1.23.9",
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
@@ -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
@@ -602,7 +603,10 @@ function checkStateComponent(plugin) {
602
603
  // The DOM serializer to use when putting content onto the
603
604
  // clipboard. If not given, the result of
604
605
  // [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema)
605
- // will be used.
606
+ // will be used. This object will only have its
607
+ // [`serializeFragment`](#model.DOMSerializer.serializeFragment)
608
+ // method called, and you may provide an alternative object type
609
+ // implementing a compatible method.
606
610
  //
607
611
  // clipboardTextSerializer:: ?(Slice) → string
608
612
  // 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/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") dom.className = "ProseMirror-separator"
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 && childStart < to) {
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