prosemirror-view 1.23.12 → 1.23.13

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.12",
3
+ "version": "1.23.13",
4
4
  "description": "ProseMirror's view component",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -1,6 +1,6 @@
1
1
  import browser from "./browser"
2
2
  import {domIndex, isEquivalentPosition} from "./dom"
3
- import {hasFocusAndSelection, hasSelection, selectionToDOM} from "./selection"
3
+ import {hasFocusAndSelection, selectionToDOM} from "./selection"
4
4
 
5
5
  const observeOptions = {
6
6
  childList: true,
@@ -145,7 +145,7 @@ export class DOMObserver {
145
145
  }
146
146
 
147
147
  let sel = this.view.root.getSelection()
148
- let newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasSelection(this.view) && !this.ignoreSelectionChange(sel)
148
+ let newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasFocusAndSelection(this.view) && !this.ignoreSelectionChange(sel)
149
149
 
150
150
  let from = -1, to = -1, typeOver = false, added = []
151
151
  if (this.view.editable) {
package/src/index.js CHANGED
@@ -75,7 +75,7 @@ export class EditorView {
75
75
 
76
76
  // composing:: boolean
77
77
  // Holds `true` when a
78
- // [composition](https://developer.mozilla.org/en-US/docs/Mozilla/IME_handling_guide)
78
+ // [composition](https://w3c.github.io/uievents/#events-compositionevents)
79
79
  // is active.
80
80
 
81
81
  // :: DirectEditorProps
@@ -643,7 +643,7 @@ function checkStateComponent(plugin) {
643
643
 
644
644
  // DirectEditorProps:: interface extends EditorProps
645
645
  //
646
- // The props object given directly to the editor view supports two
646
+ // The props object given directly to the editor view supports some
647
647
  // fields that can't be used in plugins:
648
648
  //
649
649
  // state:: EditorState
package/src/viewdesc.js CHANGED
@@ -1264,21 +1264,24 @@ class ViewTreeUpdater {
1264
1264
  // Make sure a textblock looks and behaves correctly in
1265
1265
  // contentEditable.
1266
1266
  addTextblockHacks() {
1267
- let lastChild = this.top.children[this.index - 1]
1268
- while (lastChild instanceof MarkViewDesc) lastChild = lastChild.children[lastChild.children.length - 1]
1267
+ let lastChild = this.top.children[this.index - 1], parent = this.top
1268
+ while (lastChild instanceof MarkViewDesc) {
1269
+ parent = lastChild
1270
+ lastChild = parent.children[parent.children.length - 1]
1271
+ }
1269
1272
 
1270
1273
  if (!lastChild || // Empty textblock
1271
1274
  !(lastChild instanceof TextViewDesc) ||
1272
1275
  /\n$/.test(lastChild.node.text)) {
1273
1276
  // Avoid bugs in Safari's cursor drawing (#1165) and Chrome's mouse selection (#1152)
1274
1277
  if ((browser.safari || browser.chrome) && lastChild && lastChild.dom.contentEditable == "false")
1275
- this.addHackNode("IMG")
1276
- this.addHackNode("BR")
1278
+ this.addHackNode("IMG", parent)
1279
+ this.addHackNode("BR", this.top)
1277
1280
  }
1278
1281
  }
1279
1282
 
1280
- addHackNode(nodeName) {
1281
- if (this.index < this.top.children.length && this.top.children[this.index].matchesHack(nodeName)) {
1283
+ addHackNode(nodeName, parent) {
1284
+ if (parent == this.top && this.index < parent.children.length && parent.children[this.index].matchesHack(nodeName)) {
1282
1285
  this.index++
1283
1286
  } else {
1284
1287
  let dom = document.createElement(nodeName)
@@ -1287,7 +1290,9 @@ class ViewTreeUpdater {
1287
1290
  dom.alt = ""
1288
1291
  }
1289
1292
  if (nodeName == "BR") dom.className = "ProseMirror-trailingBreak"
1290
- this.top.children.splice(this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null))
1293
+ let hack = new TrailingHackViewDesc(this.top, nothing, dom, null)
1294
+ if (parent != this.top) parent.children.push(hack)
1295
+ else parent.children.splice(this.index++, 0, hack)
1291
1296
  this.changed = true
1292
1297
  }
1293
1298
  }