@iamakulov/codemirror-view 6.39.9-debug.7294 → 6.39.11

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,25 +4377,9 @@ class InputState {
4377
4377
  firefoxCopyCutHack(view.contentDOM.ownerDocument);
4378
4378
  }
4379
4379
  handleEvent(event) {
4380
- // DEBUG: Log when copy/cut events enter handleEvent
4381
- if (event.type === "copy" || event.type === "cut") {
4382
- const belongsToEditor = eventBelongsToEditor(this.view, event);
4383
- const ignoreDuringComp = this.ignoreDuringComposition(event);
4384
- const ignoreDuringTransient = this.ignoreDuringTransientFocus(event);
4385
- console.log("[CM DEBUG] handleEvent for", event.type, {
4386
- belongsToEditor,
4387
- ignoreDuringComposition: ignoreDuringComp,
4388
- ignoreDuringTransientFocus: ignoreDuringTransient,
4389
- willProcess: belongsToEditor && !ignoreDuringComp && !ignoreDuringTransient
4390
- });
4391
- if (!belongsToEditor || ignoreDuringComp || ignoreDuringTransient)
4392
- return;
4393
- }
4394
- else {
4395
- if (!eventBelongsToEditor(this.view, event) || this.ignoreDuringComposition(event) ||
4396
- this.ignoreDuringTransientFocus(event))
4397
- return;
4398
- }
4380
+ if (!eventBelongsToEditor(this.view, event) || this.ignoreDuringComposition(event) ||
4381
+ this.ignoreDuringTransientFocus(event))
4382
+ return;
4399
4383
  if (event.type == "keydown" && this.keydown(event))
4400
4384
  return;
4401
4385
  if (this.view.updateState != 0 /* UpdateState.Idle */)
@@ -4715,40 +4699,14 @@ function isInPrimarySelection(view, event) {
4715
4699
  return false;
4716
4700
  }
4717
4701
  function eventBelongsToEditor(view, event) {
4718
- var _a, _b;
4719
4702
  if (!event.bubbles)
4720
4703
  return true;
4721
4704
  if (event.defaultPrevented)
4722
4705
  return false;
4723
- for (let node = event.target, tile; node != view.contentDOM; node = node.parentNode) {
4706
+ for (let node = event.target, tile; node != view.contentDOM; node = node.parentNode)
4724
4707
  if (!node || node.nodeType == 11 ||
4725
- ((tile = Tile.get(node)) && tile.isWidget() && !tile.isHidden && tile.widget.ignoreEvent(event))) {
4726
- // DEBUG: Log when copy/cut events are NOT considered to belong to this editor
4727
- if (event.type === "copy" || event.type === "cut") {
4728
- console.log("[CM DEBUG] eventBelongsToEditor for", event.type, "=> FALSE (event rejected)", {
4729
- eventTarget: event.target,
4730
- contentDOM: view.contentDOM,
4731
- stoppedAtNode: node,
4732
- reason: !node ? "node is null" : node.nodeType == 11 ? "shadow root" : "widget ignoreEvent",
4733
- browser: { gecko: browser.gecko, chrome: browser.chrome, safari: browser.safari }
4734
- });
4735
- }
4708
+ ((tile = Tile.get(node)) && tile.isWidget() && !tile.isHidden && tile.widget.ignoreEvent(event)))
4736
4709
  return false;
4737
- }
4738
- }
4739
- // DEBUG: Log when copy/cut events are considered to belong to this editor
4740
- if (event.type === "copy" || event.type === "cut") {
4741
- console.log("[CM DEBUG] eventBelongsToEditor for", event.type, "=> true", {
4742
- eventTarget: event.target,
4743
- contentDOM: view.contentDOM,
4744
- targetIsInsideContentDOM: view.contentDOM.contains(event.target),
4745
- // Firefox difference: where is event.target relative to the whole document?
4746
- targetTagName: (_a = event.target) === null || _a === void 0 ? void 0 : _a.tagName,
4747
- targetClassName: (_b = event.target) === null || _b === void 0 ? void 0 : _b.className,
4748
- // Is the event even reaching us in the first place?
4749
- browser: { gecko: browser.gecko, chrome: browser.chrome, safari: browser.safari }
4750
- });
4751
- }
4752
4710
  return true;
4753
4711
  }
4754
4712
  const handlers = Object.create(null);
@@ -5029,13 +4987,6 @@ function captureCopy(view, text) {
5029
4987
  }
5030
4988
  function copiedRange(state) {
5031
4989
  let content = [], ranges = [], linewise = false;
5032
- // DEBUG: Log CodeMirror's internal selection state
5033
- console.log("[CM DEBUG] copiedRange - state.selection.ranges:", state.selection.ranges.map(r => ({
5034
- from: r.from,
5035
- to: r.to,
5036
- empty: r.empty,
5037
- content: r.empty ? "(empty)" : state.sliceDoc(r.from, Math.min(r.to, r.from + 50)) + (r.to - r.from > 50 ? "..." : "")
5038
- })));
5039
4990
  for (let range of state.selection.ranges)
5040
4991
  if (!range.empty) {
5041
4992
  content.push(state.sliceDoc(range.from, range.to));
@@ -5043,7 +4994,6 @@ function copiedRange(state) {
5043
4994
  }
5044
4995
  if (!content.length) {
5045
4996
  // Nothing selected, do a line-wise copy
5046
- console.log("[CM DEBUG] copiedRange - No non-empty ranges found, falling back to linewise copy");
5047
4997
  let upto = -1;
5048
4998
  for (let { from } of state.selection.ranges) {
5049
4999
  let line = state.doc.lineAt(from);
@@ -5055,63 +5005,10 @@ function copiedRange(state) {
5055
5005
  }
5056
5006
  linewise = true;
5057
5007
  }
5058
- console.log("[CM DEBUG] copiedRange - Result:", {
5059
- text: content.join(state.lineBreak).slice(0, 100) + (content.join(state.lineBreak).length > 100 ? "..." : ""),
5060
- linewise,
5061
- rangesCount: ranges.length
5062
- });
5063
5008
  return { text: textFilter(state, clipboardOutputFilter, content.join(state.lineBreak)), ranges, linewise };
5064
5009
  }
5065
5010
  let lastLinewiseCopy = null;
5066
5011
  handlers.copy = handlers.cut = (view, event) => {
5067
- var _a, _b, _c, _d;
5068
- // DEBUG: Log DOM selection vs CodeMirror's internal selection
5069
- const domSel = getSelection(view.root);
5070
- console.log("[CM DEBUG] handlers.copy/cut triggered", {
5071
- eventType: event.type,
5072
- eventTarget: event.target,
5073
- // Browser info - helps understand Firefox vs Safari/Chrome difference
5074
- browser: {
5075
- gecko: browser.gecko,
5076
- gecko_version: browser.gecko_version,
5077
- chrome: browser.chrome,
5078
- chrome_version: browser.chrome_version,
5079
- safari: browser.safari,
5080
- safari_version: browser.safari_version,
5081
- },
5082
- // Event propagation details - Firefox may dispatch differently
5083
- eventPhase: event.eventPhase, // 1=capturing, 2=at_target, 3=bubbling
5084
- eventCurrentTarget: event.currentTarget,
5085
- eventIsTrusted: event.isTrusted,
5086
- // Hypothesis 1: Does DOM selection match CodeMirror's internal selection?
5087
- domSelection: domSel ? {
5088
- anchorNode: domSel.anchorNode,
5089
- anchorOffset: domSel.anchorOffset,
5090
- focusNode: domSel.focusNode,
5091
- focusOffset: domSel.focusOffset,
5092
- anchorNodeText: (_b = (_a = domSel.anchorNode) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.slice(0, 50),
5093
- focusNodeText: (_d = (_c = domSel.focusNode) === null || _c === void 0 ? void 0 : _c.textContent) === null || _d === void 0 ? void 0 : _d.slice(0, 50),
5094
- isCollapsed: domSel.isCollapsed,
5095
- rangeCount: domSel.rangeCount,
5096
- // What does the browser think the selection text is?
5097
- selectionToString: domSel.toString().slice(0, 100) + (domSel.toString().length > 100 ? "..." : "")
5098
- } : null,
5099
- // Hypothesis 3: Is DOM selection local to CodeMirror?
5100
- anchorInsideContentDOM: (domSel === null || domSel === void 0 ? void 0 : domSel.anchorNode) ? view.contentDOM.contains(domSel.anchorNode) : null,
5101
- focusInsideContentDOM: (domSel === null || domSel === void 0 ? void 0 : domSel.focusNode) ? view.contentDOM.contains(domSel.focusNode) : null,
5102
- // Hypothesis 2: What's the observer's selectionChanged state?
5103
- observerSelectionChanged: view.observer.selectionChanged,
5104
- // Check if CodeMirror is focused
5105
- hasFocus: view.hasFocus,
5106
- activeElement: view.root.activeElement,
5107
- contentDOMIsActiveElement: view.root.activeElement === view.contentDOM,
5108
- });
5109
- // DEBUG: What would happen if we flushed first? (Like paste handler does)
5110
- console.log("[CM DEBUG] Before flush - state.selection.main:", {
5111
- from: view.state.selection.main.from,
5112
- to: view.state.selection.main.to,
5113
- empty: view.state.selection.main.empty
5114
- });
5115
5012
  let { text, ranges, linewise } = copiedRange(view.state);
5116
5013
  if (!text && !linewise)
5117
5014
  return false;
@@ -5126,7 +5023,6 @@ handlers.copy = handlers.cut = (view, event) => {
5126
5023
  if (data) {
5127
5024
  data.clearData();
5128
5025
  data.setData("text/plain", text);
5129
- console.log("[CM DEBUG] handlers.copy returning true (will preventDefault), text length:", text.length);
5130
5026
  return true;
5131
5027
  }
5132
5028
  else {
package/dist/index.js CHANGED
@@ -4373,25 +4373,9 @@ class InputState {
4373
4373
  firefoxCopyCutHack(view.contentDOM.ownerDocument);
4374
4374
  }
4375
4375
  handleEvent(event) {
4376
- // DEBUG: Log when copy/cut events enter handleEvent
4377
- if (event.type === "copy" || event.type === "cut") {
4378
- const belongsToEditor = eventBelongsToEditor(this.view, event);
4379
- const ignoreDuringComp = this.ignoreDuringComposition(event);
4380
- const ignoreDuringTransient = this.ignoreDuringTransientFocus(event);
4381
- console.log("[CM DEBUG] handleEvent for", event.type, {
4382
- belongsToEditor,
4383
- ignoreDuringComposition: ignoreDuringComp,
4384
- ignoreDuringTransientFocus: ignoreDuringTransient,
4385
- willProcess: belongsToEditor && !ignoreDuringComp && !ignoreDuringTransient
4386
- });
4387
- if (!belongsToEditor || ignoreDuringComp || ignoreDuringTransient)
4388
- return;
4389
- }
4390
- else {
4391
- if (!eventBelongsToEditor(this.view, event) || this.ignoreDuringComposition(event) ||
4392
- this.ignoreDuringTransientFocus(event))
4393
- return;
4394
- }
4376
+ if (!eventBelongsToEditor(this.view, event) || this.ignoreDuringComposition(event) ||
4377
+ this.ignoreDuringTransientFocus(event))
4378
+ return;
4395
4379
  if (event.type == "keydown" && this.keydown(event))
4396
4380
  return;
4397
4381
  if (this.view.updateState != 0 /* UpdateState.Idle */)
@@ -4711,40 +4695,14 @@ function isInPrimarySelection(view, event) {
4711
4695
  return false;
4712
4696
  }
4713
4697
  function eventBelongsToEditor(view, event) {
4714
- var _a, _b;
4715
4698
  if (!event.bubbles)
4716
4699
  return true;
4717
4700
  if (event.defaultPrevented)
4718
4701
  return false;
4719
- for (let node = event.target, tile; node != view.contentDOM; node = node.parentNode) {
4702
+ for (let node = event.target, tile; node != view.contentDOM; node = node.parentNode)
4720
4703
  if (!node || node.nodeType == 11 ||
4721
- ((tile = Tile.get(node)) && tile.isWidget() && !tile.isHidden && tile.widget.ignoreEvent(event))) {
4722
- // DEBUG: Log when copy/cut events are NOT considered to belong to this editor
4723
- if (event.type === "copy" || event.type === "cut") {
4724
- console.log("[CM DEBUG] eventBelongsToEditor for", event.type, "=> FALSE (event rejected)", {
4725
- eventTarget: event.target,
4726
- contentDOM: view.contentDOM,
4727
- stoppedAtNode: node,
4728
- reason: !node ? "node is null" : node.nodeType == 11 ? "shadow root" : "widget ignoreEvent",
4729
- browser: { gecko: browser.gecko, chrome: browser.chrome, safari: browser.safari }
4730
- });
4731
- }
4704
+ ((tile = Tile.get(node)) && tile.isWidget() && !tile.isHidden && tile.widget.ignoreEvent(event)))
4732
4705
  return false;
4733
- }
4734
- }
4735
- // DEBUG: Log when copy/cut events are considered to belong to this editor
4736
- if (event.type === "copy" || event.type === "cut") {
4737
- console.log("[CM DEBUG] eventBelongsToEditor for", event.type, "=> true", {
4738
- eventTarget: event.target,
4739
- contentDOM: view.contentDOM,
4740
- targetIsInsideContentDOM: view.contentDOM.contains(event.target),
4741
- // Firefox difference: where is event.target relative to the whole document?
4742
- targetTagName: (_a = event.target) === null || _a === void 0 ? void 0 : _a.tagName,
4743
- targetClassName: (_b = event.target) === null || _b === void 0 ? void 0 : _b.className,
4744
- // Is the event even reaching us in the first place?
4745
- browser: { gecko: browser.gecko, chrome: browser.chrome, safari: browser.safari }
4746
- });
4747
- }
4748
4706
  return true;
4749
4707
  }
4750
4708
  const handlers = /*@__PURE__*/Object.create(null);
@@ -5025,13 +4983,6 @@ function captureCopy(view, text) {
5025
4983
  }
5026
4984
  function copiedRange(state) {
5027
4985
  let content = [], ranges = [], linewise = false;
5028
- // DEBUG: Log CodeMirror's internal selection state
5029
- console.log("[CM DEBUG] copiedRange - state.selection.ranges:", state.selection.ranges.map(r => ({
5030
- from: r.from,
5031
- to: r.to,
5032
- empty: r.empty,
5033
- content: r.empty ? "(empty)" : state.sliceDoc(r.from, Math.min(r.to, r.from + 50)) + (r.to - r.from > 50 ? "..." : "")
5034
- })));
5035
4986
  for (let range of state.selection.ranges)
5036
4987
  if (!range.empty) {
5037
4988
  content.push(state.sliceDoc(range.from, range.to));
@@ -5039,7 +4990,6 @@ function copiedRange(state) {
5039
4990
  }
5040
4991
  if (!content.length) {
5041
4992
  // Nothing selected, do a line-wise copy
5042
- console.log("[CM DEBUG] copiedRange - No non-empty ranges found, falling back to linewise copy");
5043
4993
  let upto = -1;
5044
4994
  for (let { from } of state.selection.ranges) {
5045
4995
  let line = state.doc.lineAt(from);
@@ -5051,63 +5001,10 @@ function copiedRange(state) {
5051
5001
  }
5052
5002
  linewise = true;
5053
5003
  }
5054
- console.log("[CM DEBUG] copiedRange - Result:", {
5055
- text: content.join(state.lineBreak).slice(0, 100) + (content.join(state.lineBreak).length > 100 ? "..." : ""),
5056
- linewise,
5057
- rangesCount: ranges.length
5058
- });
5059
5004
  return { text: textFilter(state, clipboardOutputFilter, content.join(state.lineBreak)), ranges, linewise };
5060
5005
  }
5061
5006
  let lastLinewiseCopy = null;
5062
5007
  handlers.copy = handlers.cut = (view, event) => {
5063
- var _a, _b, _c, _d;
5064
- // DEBUG: Log DOM selection vs CodeMirror's internal selection
5065
- const domSel = getSelection(view.root);
5066
- console.log("[CM DEBUG] handlers.copy/cut triggered", {
5067
- eventType: event.type,
5068
- eventTarget: event.target,
5069
- // Browser info - helps understand Firefox vs Safari/Chrome difference
5070
- browser: {
5071
- gecko: browser.gecko,
5072
- gecko_version: browser.gecko_version,
5073
- chrome: browser.chrome,
5074
- chrome_version: browser.chrome_version,
5075
- safari: browser.safari,
5076
- safari_version: browser.safari_version,
5077
- },
5078
- // Event propagation details - Firefox may dispatch differently
5079
- eventPhase: event.eventPhase, // 1=capturing, 2=at_target, 3=bubbling
5080
- eventCurrentTarget: event.currentTarget,
5081
- eventIsTrusted: event.isTrusted,
5082
- // Hypothesis 1: Does DOM selection match CodeMirror's internal selection?
5083
- domSelection: domSel ? {
5084
- anchorNode: domSel.anchorNode,
5085
- anchorOffset: domSel.anchorOffset,
5086
- focusNode: domSel.focusNode,
5087
- focusOffset: domSel.focusOffset,
5088
- anchorNodeText: (_b = (_a = domSel.anchorNode) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.slice(0, 50),
5089
- focusNodeText: (_d = (_c = domSel.focusNode) === null || _c === void 0 ? void 0 : _c.textContent) === null || _d === void 0 ? void 0 : _d.slice(0, 50),
5090
- isCollapsed: domSel.isCollapsed,
5091
- rangeCount: domSel.rangeCount,
5092
- // What does the browser think the selection text is?
5093
- selectionToString: domSel.toString().slice(0, 100) + (domSel.toString().length > 100 ? "..." : "")
5094
- } : null,
5095
- // Hypothesis 3: Is DOM selection local to CodeMirror?
5096
- anchorInsideContentDOM: (domSel === null || domSel === void 0 ? void 0 : domSel.anchorNode) ? view.contentDOM.contains(domSel.anchorNode) : null,
5097
- focusInsideContentDOM: (domSel === null || domSel === void 0 ? void 0 : domSel.focusNode) ? view.contentDOM.contains(domSel.focusNode) : null,
5098
- // Hypothesis 2: What's the observer's selectionChanged state?
5099
- observerSelectionChanged: view.observer.selectionChanged,
5100
- // Check if CodeMirror is focused
5101
- hasFocus: view.hasFocus,
5102
- activeElement: view.root.activeElement,
5103
- contentDOMIsActiveElement: view.root.activeElement === view.contentDOM,
5104
- });
5105
- // DEBUG: What would happen if we flushed first? (Like paste handler does)
5106
- console.log("[CM DEBUG] Before flush - state.selection.main:", {
5107
- from: view.state.selection.main.from,
5108
- to: view.state.selection.main.to,
5109
- empty: view.state.selection.main.empty
5110
- });
5111
5008
  let { text, ranges, linewise } = copiedRange(view.state);
5112
5009
  if (!text && !linewise)
5113
5010
  return false;
@@ -5122,7 +5019,6 @@ handlers.copy = handlers.cut = (view, event) => {
5122
5019
  if (data) {
5123
5020
  data.clearData();
5124
5021
  data.setData("text/plain", text);
5125
- console.log("[CM DEBUG] handlers.copy returning true (will preventDefault), text length:", text.length);
5126
5022
  return true;
5127
5023
  }
5128
5024
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iamakulov/codemirror-view",
3
- "version": "6.39.9-debug.7294",
3
+ "version": "6.39.11",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",