@iamakulov/codemirror-view 6.39.11 → 9999.99.99-fixcmdc.0

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/dist/index.cjs CHANGED
@@ -4377,8 +4377,7 @@ class InputState {
4377
4377
  firefoxCopyCutHack(view.contentDOM.ownerDocument);
4378
4378
  }
4379
4379
  handleEvent(event) {
4380
- if (!eventBelongsToEditor(this.view, event) || this.ignoreDuringComposition(event) ||
4381
- this.ignoreDuringTransientFocus(event))
4380
+ if (!eventBelongsToEditor(this.view, event) || this.ignoreDuringComposition(event))
4382
4381
  return;
4383
4382
  if (event.type == "keydown" && this.keydown(event))
4384
4383
  return;
@@ -4482,22 +4481,6 @@ class InputState {
4482
4481
  }
4483
4482
  return false;
4484
4483
  }
4485
- ignoreDuringTransientFocus(event) {
4486
- // Detect transient focus from parent editor selection operations. When a
4487
- // parent contentEditable (like ProseMirror) performs a selection using
4488
- // Selection.collapse() + Selection.extend() [1], and Selection.collapse()
4489
- // collapses to a position where CodeMirror is, the browser will fire a focus
4490
- // event on this CodeMirror. This focus is transient and should be ignored;
4491
- // otherwise, our focus logic will undo the parent’s selection.
4492
- // [1] https://github.com/ProseMirror/prosemirror-view/blob/76c7c47f03730b18397b94bd269ece8a9cb7f486/src/viewdesc.ts#L464-L468
4493
- if (event.type === "focus") {
4494
- let sel = getSelection(this.view.root);
4495
- if (sel && sel.anchorNode && !this.view.contentDOM.contains(sel.anchorNode)) {
4496
- return true;
4497
- }
4498
- }
4499
- return false;
4500
- }
4501
4484
  startMouseSelection(mouseSelection) {
4502
4485
  if (this.mouseSelection)
4503
4486
  this.mouseSelection.destroy();
@@ -5009,6 +4992,17 @@ function copiedRange(state) {
5009
4992
  }
5010
4993
  let lastLinewiseCopy = null;
5011
4994
  handlers.copy = handlers.cut = (view, event) => {
4995
+ // If the DOM selection begins and ends outside this editor, don't intercept.
4996
+ // This happens when a parent editor (like ProseMirror) selects content that
4997
+ // spans multiple elements including this CodeMirror. The copy event may
4998
+ // bubble through CodeMirror (e.g. when CodeMirror is the first or the last
4999
+ // element in the selection), but we should let the parent handle it.
5000
+ let domSel = getSelection(view.root);
5001
+ if (domSel && domSel.anchorNode && domSel.focusNode &&
5002
+ !view.contentDOM.contains(domSel.anchorNode) &&
5003
+ !view.contentDOM.contains(domSel.focusNode)) {
5004
+ return false;
5005
+ }
5012
5006
  let { text, ranges, linewise } = copiedRange(view.state);
5013
5007
  if (!text && !linewise)
5014
5008
  return false;
package/dist/index.js CHANGED
@@ -4373,8 +4373,7 @@ class InputState {
4373
4373
  firefoxCopyCutHack(view.contentDOM.ownerDocument);
4374
4374
  }
4375
4375
  handleEvent(event) {
4376
- if (!eventBelongsToEditor(this.view, event) || this.ignoreDuringComposition(event) ||
4377
- this.ignoreDuringTransientFocus(event))
4376
+ if (!eventBelongsToEditor(this.view, event) || this.ignoreDuringComposition(event))
4378
4377
  return;
4379
4378
  if (event.type == "keydown" && this.keydown(event))
4380
4379
  return;
@@ -4478,22 +4477,6 @@ class InputState {
4478
4477
  }
4479
4478
  return false;
4480
4479
  }
4481
- ignoreDuringTransientFocus(event) {
4482
- // Detect transient focus from parent editor selection operations. When a
4483
- // parent contentEditable (like ProseMirror) performs a selection using
4484
- // Selection.collapse() + Selection.extend() [1], and Selection.collapse()
4485
- // collapses to a position where CodeMirror is, the browser will fire a focus
4486
- // event on this CodeMirror. This focus is transient and should be ignored;
4487
- // otherwise, our focus logic will undo the parent’s selection.
4488
- // [1] https://github.com/ProseMirror/prosemirror-view/blob/76c7c47f03730b18397b94bd269ece8a9cb7f486/src/viewdesc.ts#L464-L468
4489
- if (event.type === "focus") {
4490
- let sel = getSelection(this.view.root);
4491
- if (sel && sel.anchorNode && !this.view.contentDOM.contains(sel.anchorNode)) {
4492
- return true;
4493
- }
4494
- }
4495
- return false;
4496
- }
4497
4480
  startMouseSelection(mouseSelection) {
4498
4481
  if (this.mouseSelection)
4499
4482
  this.mouseSelection.destroy();
@@ -5005,6 +4988,17 @@ function copiedRange(state) {
5005
4988
  }
5006
4989
  let lastLinewiseCopy = null;
5007
4990
  handlers.copy = handlers.cut = (view, event) => {
4991
+ // If the DOM selection begins and ends outside this editor, don't intercept.
4992
+ // This happens when a parent editor (like ProseMirror) selects content that
4993
+ // spans multiple elements including this CodeMirror. The copy event may
4994
+ // bubble through CodeMirror (e.g. when CodeMirror is the first or the last
4995
+ // element in the selection), but we should let the parent handle it.
4996
+ let domSel = getSelection(view.root);
4997
+ if (domSel && domSel.anchorNode && domSel.focusNode &&
4998
+ !view.contentDOM.contains(domSel.anchorNode) &&
4999
+ !view.contentDOM.contains(domSel.focusNode)) {
5000
+ return false;
5001
+ }
5008
5002
  let { text, ranges, linewise } = copiedRange(view.state);
5009
5003
  if (!text && !linewise)
5010
5004
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iamakulov/codemirror-view",
3
- "version": "6.39.11",
3
+ "version": "9999.99.99-fixcmdc.0",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",