prosemirror-view 1.18.7 → 1.18.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.18.7",
3
+ "version": "1.18.8",
4
4
  "description": "ProseMirror's view component",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
package/src/input.js CHANGED
@@ -100,7 +100,7 @@ export function dispatchEvent(view, event) {
100
100
  editHandlers.keydown = (view, event) => {
101
101
  view.shiftKey = event.keyCode == 16 || event.shiftKey
102
102
  if (inOrNearComposition(view, event)) return
103
- view.domObserver.forceFlush()
103
+ if (event.keyCode != 229) view.domObserver.forceFlush()
104
104
  view.lastKeyCode = event.keyCode
105
105
  view.lastKeyCodeTime = Date.now()
106
106
  // On iOS, if we preventDefault enter key presses, the virtual
@@ -220,10 +220,11 @@ function handleDoubleClick(view, pos, inside, event) {
220
220
  function handleTripleClick(view, pos, inside, event) {
221
221
  return runHandlerOnContext(view, "handleTripleClickOn", pos, inside, event) ||
222
222
  view.someProp("handleTripleClick", f => f(view, pos, event)) ||
223
- defaultTripleClick(view, inside)
223
+ defaultTripleClick(view, inside, event)
224
224
  }
225
225
 
226
- function defaultTripleClick(view, inside) {
226
+ function defaultTripleClick(view, inside, event) {
227
+ if (event.button != 0) return false
227
228
  let doc = view.state.doc
228
229
  if (inside == -1) {
229
230
  if (doc.inlineContent) {
@@ -284,7 +285,7 @@ class MouseDown {
284
285
  this.event = event
285
286
  this.flushed = flushed
286
287
  this.selectNode = event[selectNodeModifier]
287
- this.allowDefault = event.shiftKey
288
+ this.allowDefault = event.shiftKey || event.button != 0
288
289
 
289
290
  let targetNode, targetPos
290
291
  if (pos.inside > -1) {
@@ -303,7 +304,8 @@ class MouseDown {
303
304
  this.target = targetDesc ? targetDesc.dom : null
304
305
 
305
306
  let {selection} = view.state
306
- if (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
307
+ if (event.button == 0 &&
308
+ targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
307
309
  selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)
308
310
  this.mightDrag = {node: targetNode,
309
311
  pos: targetPos,
package/src/viewdesc.js CHANGED
@@ -113,7 +113,7 @@ class ViewDesc {
113
113
  matchesWidget() { return false }
114
114
  matchesMark() { return false }
115
115
  matchesNode() { return false }
116
- matchesHack() { return false }
116
+ matchesHack(_nodeName) { return false }
117
117
 
118
118
  get beforePosition() { return false }
119
119
 
@@ -374,9 +374,17 @@ class ViewDesc {
374
374
  if (node.nodeType == 3) {
375
375
  brKludge = offset && node.nodeValue[offset - 1] == "\n"
376
376
  // Issue #1128
377
- if (brKludge && offset == node.nodeValue.length &&
378
- node.nextSibling && node.nextSibling.nodeName == "BR")
379
- anchorDOM = headDOM = {node: node.parentNode, offset: domIndex(node) + 1}
377
+ if (brKludge && offset == node.nodeValue.length) {
378
+ for (let scan = node, after; scan; scan = scan.parentNode) {
379
+ if (after = scan.nextSibling) {
380
+ if (after.nodeName == "BR")
381
+ anchorDOM = headDOM = {node: after.parentNode, offset: domIndex(after) + 1}
382
+ break
383
+ }
384
+ let desc = scan.pmViewDesc
385
+ if (desc && desc.node && desc.node.isBlock) break
386
+ }
387
+ }
380
388
  } else {
381
389
  let prev = node.childNodes[offset - 1]
382
390
  brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false")
@@ -844,6 +852,12 @@ class TextViewDesc extends NodeViewDesc {
844
852
  return new TextViewDesc(this.parent, node, this.outerDeco, this.innerDeco, dom, dom, view)
845
853
  }
846
854
 
855
+ markDirty(from, to) {
856
+ super.markDirty(from, to)
857
+ if (this.dom != this.nodeDOM && (from == 0 || to == this.nodeDOM.nodeValue.length))
858
+ this.dirty = NODE_DIRTY
859
+ }
860
+
847
861
  get domAtom() { return false }
848
862
  }
849
863
 
@@ -851,7 +865,7 @@ class TextViewDesc extends NodeViewDesc {
851
865
  // around contentEditable terribleness.
852
866
  class TrailingHackViewDesc extends ViewDesc {
853
867
  parseRule() { return {ignore: true} }
854
- matchesHack() { return this.dirty == NOT_DIRTY }
868
+ matchesHack(nodeName) { return this.dirty == NOT_DIRTY && this.dom.nodeName == nodeName }
855
869
  get domAtom() { return true }
856
870
  }
857
871
 
@@ -1188,13 +1202,20 @@ class ViewTreeUpdater {
1188
1202
  if (!lastChild || // Empty textblock
1189
1203
  !(lastChild instanceof TextViewDesc) ||
1190
1204
  /\n$/.test(lastChild.node.text)) {
1191
- if (this.index < this.top.children.length && this.top.children[this.index].matchesHack()) {
1192
- this.index++
1193
- } else {
1194
- let dom = document.createElement("br")
1195
- this.top.children.splice(this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null))
1196
- this.changed = true
1197
- }
1205
+ // Avoid a bug in Safari's cursor drawing (#1165)
1206
+ if (browser.safari && lastChild && lastChild.dom.contentEditable == "false")
1207
+ this.addHackNode("IMG")
1208
+ this.addHackNode("BR")
1209
+ }
1210
+ }
1211
+
1212
+ addHackNode(nodeName) {
1213
+ if (this.index < this.top.children.length && this.top.children[this.index].matchesHack(nodeName)) {
1214
+ this.index++
1215
+ } else {
1216
+ let dom = document.createElement(nodeName)
1217
+ this.top.children.splice(this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null))
1218
+ this.changed = true
1198
1219
  }
1199
1220
  }
1200
1221
  }