@codemirror/view 6.9.1 → 6.9.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 6.9.2 (2023-03-08)
2
+
3
+ ### Bug fixes
4
+
5
+ Work around a Firefox CSS bug that caused cursors to stop blinking in a scrolled editor.
6
+
7
+ Fix an issue in `drawSelection` where the selection extended into the editor's padding.
8
+
9
+ Fix pasting of links copied from iOS share sheet.
10
+
1
11
  ## 6.9.1 (2023-02-17)
2
12
 
3
13
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -3167,7 +3167,7 @@ function domPosInText(node, x, y) {
3167
3167
  return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };
3168
3168
  }
3169
3169
  function posAtCoords(view, coords, precise, bias = -1) {
3170
- var _a;
3170
+ var _a, _b;
3171
3171
  let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;
3172
3172
  let block, { docHeight } = view.viewState;
3173
3173
  let { x, y } = coords, yOffset = y - docTop;
@@ -3244,7 +3244,7 @@ function posAtCoords(view, coords, precise, bias = -1) {
3244
3244
  let nearest = view.docView.nearest(node);
3245
3245
  if (!nearest)
3246
3246
  return null;
3247
- if (nearest.isWidget) {
3247
+ if (nearest.isWidget && ((_b = nearest.dom) === null || _b === void 0 ? void 0 : _b.nodeType) == 1) {
3248
3248
  let rect = nearest.dom.getBoundingClientRect();
3249
3249
  return coords.y < rect.top || coords.y <= rect.bottom && coords.x <= (rect.left + rect.right) / 2
3250
3250
  ? nearest.posAtStart : nearest.posAtEnd;
@@ -3974,7 +3974,7 @@ handlers.paste = (view, event) => {
3974
3974
  view.observer.flush();
3975
3975
  let data = brokenClipboardAPI ? null : event.clipboardData;
3976
3976
  if (data) {
3977
- doPaste(view, data.getData("text/plain"));
3977
+ doPaste(view, data.getData("text/plain") || data.getData("text/uri-text"));
3978
3978
  event.preventDefault();
3979
3979
  }
3980
3980
  else {
@@ -5435,6 +5435,9 @@ const baseTheme$1 = buildTheme("." + baseThemeID, {
5435
5435
  padding: "0 2px 0 6px"
5436
5436
  },
5437
5437
  ".cm-layer": {
5438
+ position: "absolute",
5439
+ left: 0,
5440
+ top: 0,
5438
5441
  contain: "size style",
5439
5442
  "& > *": {
5440
5443
  position: "absolute"
@@ -6595,7 +6598,7 @@ class EditorView {
6595
6598
  if (this.destroyed)
6596
6599
  return;
6597
6600
  if (this.measureScheduled > -1)
6598
- cancelAnimationFrame(this.measureScheduled);
6601
+ this.win.cancelAnimationFrame(this.measureScheduled);
6599
6602
  this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame
6600
6603
  if (flush)
6601
6604
  this.observer.forceFlush();
@@ -7033,7 +7036,7 @@ class EditorView {
7033
7036
  this.dom.remove();
7034
7037
  this.observer.destroy();
7035
7038
  if (this.measureScheduled > -1)
7036
- cancelAnimationFrame(this.measureScheduled);
7039
+ this.win.cancelAnimationFrame(this.measureScheduled);
7037
7040
  this.destroyed = true;
7038
7041
  }
7039
7042
  /**
@@ -7545,9 +7548,10 @@ function rectanglesForRange(view, className, range) {
7545
7548
  let from = Math.max(range.from, view.viewport.from), to = Math.min(range.to, view.viewport.to);
7546
7549
  let ltr = view.textDirection == exports.Direction.LTR;
7547
7550
  let content = view.contentDOM, contentRect = content.getBoundingClientRect(), base = getBase(view);
7548
- let lineStyle = window.getComputedStyle(content.firstChild);
7549
- let leftSide = contentRect.left + parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent));
7550
- let rightSide = contentRect.right - parseInt(lineStyle.paddingRight);
7551
+ let lineElt = content.querySelector(".cm-line"), lineStyle = lineElt && window.getComputedStyle(lineElt);
7552
+ let leftSide = contentRect.left +
7553
+ (lineStyle ? parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent)) : 0);
7554
+ let rightSide = contentRect.right - (lineStyle ? parseInt(lineStyle.paddingRight) : 0);
7551
7555
  let startBlock = blockAt(view, from), endBlock = blockAt(view, to);
7552
7556
  let visualStart = startBlock.type == exports.BlockType.Text ? startBlock : null;
7553
7557
  let visualEnd = endBlock.type == exports.BlockType.Text ? endBlock : null;
package/dist/index.js CHANGED
@@ -3161,7 +3161,7 @@ function domPosInText(node, x, y) {
3161
3161
  return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };
3162
3162
  }
3163
3163
  function posAtCoords(view, coords, precise, bias = -1) {
3164
- var _a;
3164
+ var _a, _b;
3165
3165
  let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;
3166
3166
  let block, { docHeight } = view.viewState;
3167
3167
  let { x, y } = coords, yOffset = y - docTop;
@@ -3238,7 +3238,7 @@ function posAtCoords(view, coords, precise, bias = -1) {
3238
3238
  let nearest = view.docView.nearest(node);
3239
3239
  if (!nearest)
3240
3240
  return null;
3241
- if (nearest.isWidget) {
3241
+ if (nearest.isWidget && ((_b = nearest.dom) === null || _b === void 0 ? void 0 : _b.nodeType) == 1) {
3242
3242
  let rect = nearest.dom.getBoundingClientRect();
3243
3243
  return coords.y < rect.top || coords.y <= rect.bottom && coords.x <= (rect.left + rect.right) / 2
3244
3244
  ? nearest.posAtStart : nearest.posAtEnd;
@@ -3968,7 +3968,7 @@ handlers.paste = (view, event) => {
3968
3968
  view.observer.flush();
3969
3969
  let data = brokenClipboardAPI ? null : event.clipboardData;
3970
3970
  if (data) {
3971
- doPaste(view, data.getData("text/plain"));
3971
+ doPaste(view, data.getData("text/plain") || data.getData("text/uri-text"));
3972
3972
  event.preventDefault();
3973
3973
  }
3974
3974
  else {
@@ -5428,6 +5428,9 @@ const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
5428
5428
  padding: "0 2px 0 6px"
5429
5429
  },
5430
5430
  ".cm-layer": {
5431
+ position: "absolute",
5432
+ left: 0,
5433
+ top: 0,
5431
5434
  contain: "size style",
5432
5435
  "& > *": {
5433
5436
  position: "absolute"
@@ -6588,7 +6591,7 @@ class EditorView {
6588
6591
  if (this.destroyed)
6589
6592
  return;
6590
6593
  if (this.measureScheduled > -1)
6591
- cancelAnimationFrame(this.measureScheduled);
6594
+ this.win.cancelAnimationFrame(this.measureScheduled);
6592
6595
  this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame
6593
6596
  if (flush)
6594
6597
  this.observer.forceFlush();
@@ -7026,7 +7029,7 @@ class EditorView {
7026
7029
  this.dom.remove();
7027
7030
  this.observer.destroy();
7028
7031
  if (this.measureScheduled > -1)
7029
- cancelAnimationFrame(this.measureScheduled);
7032
+ this.win.cancelAnimationFrame(this.measureScheduled);
7030
7033
  this.destroyed = true;
7031
7034
  }
7032
7035
  /**
@@ -7538,9 +7541,10 @@ function rectanglesForRange(view, className, range) {
7538
7541
  let from = Math.max(range.from, view.viewport.from), to = Math.min(range.to, view.viewport.to);
7539
7542
  let ltr = view.textDirection == Direction.LTR;
7540
7543
  let content = view.contentDOM, contentRect = content.getBoundingClientRect(), base = getBase(view);
7541
- let lineStyle = window.getComputedStyle(content.firstChild);
7542
- let leftSide = contentRect.left + parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent));
7543
- let rightSide = contentRect.right - parseInt(lineStyle.paddingRight);
7544
+ let lineElt = content.querySelector(".cm-line"), lineStyle = lineElt && window.getComputedStyle(lineElt);
7545
+ let leftSide = contentRect.left +
7546
+ (lineStyle ? parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent)) : 0);
7547
+ let rightSide = contentRect.right - (lineStyle ? parseInt(lineStyle.paddingRight) : 0);
7544
7548
  let startBlock = blockAt(view, from), endBlock = blockAt(view, to);
7545
7549
  let visualStart = startBlock.type == BlockType.Text ? startBlock : null;
7546
7550
  let visualEnd = endBlock.type == BlockType.Text ? endBlock : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "6.9.1",
3
+ "version": "6.9.2",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",