@codemirror/view 6.36.4 → 6.36.5

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,11 @@
1
+ ## 6.36.5 (2025-03-29)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix an issue where some browsers wouldn't enable context menu paste when clicking on placeholder text.
6
+
7
+ Fix an issue where cursor height would unnecessarily be based on a placeholder node's dimensions, and thus be off from the text height.
8
+
1
9
  ## 6.36.4 (2025-03-03)
2
10
 
3
11
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -1072,7 +1072,7 @@ function coordsInChildren(view, pos, side) {
1072
1072
  if (child.children.length) {
1073
1073
  scan(child, pos - off);
1074
1074
  }
1075
- else if ((!after || after.isHidden && side > 0) &&
1075
+ else if ((!after || after.isHidden && (side > 0 || onSameLine(after, child))) &&
1076
1076
  (end > pos || off == end && child.getSide() > 0)) {
1077
1077
  after = child;
1078
1078
  afterPos = pos - off;
@@ -1098,6 +1098,10 @@ function fallbackRect(view) {
1098
1098
  let rects = clientRectsFor(last);
1099
1099
  return rects[rects.length - 1] || null;
1100
1100
  }
1101
+ function onSameLine(a, b) {
1102
+ let posA = a.coordsAt(0, 1), posB = b.coordsAt(0, 1);
1103
+ return posA && posB && posB.top < posA.bottom;
1104
+ }
1101
1105
 
1102
1106
  function combineAttrs(source, target) {
1103
1107
  for (let name in source) {
@@ -6619,6 +6623,7 @@ const baseTheme$1 = buildTheme("." + baseThemeID, {
6619
6623
  color: "#888",
6620
6624
  display: "inline-block",
6621
6625
  verticalAlign: "top",
6626
+ userSelect: "none"
6622
6627
  },
6623
6628
  ".cm-highlightSpace": {
6624
6629
  backgroundImage: "radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",
@@ -9033,7 +9038,6 @@ function layer(config) {
9033
9038
  ];
9034
9039
  }
9035
9040
 
9036
- const CanHidePrimary = !(browser.ios && browser.webkit && browser.webkit_version < 534);
9037
9041
  const selectionConfig = state.Facet.define({
9038
9042
  combine(configs) {
9039
9043
  return state.combineConfig(configs, {
@@ -9090,7 +9094,7 @@ const cursorLayer = layer({
9090
9094
  let cursors = [];
9091
9095
  for (let r of state$1.selection.ranges) {
9092
9096
  let prim = r == state$1.selection.main;
9093
- if (r.empty ? !prim || CanHidePrimary : conf.drawRangeCursor) {
9097
+ if (r.empty || conf.drawRangeCursor) {
9094
9098
  let className = prim ? "cm-cursor cm-cursor-primary" : "cm-cursor cm-cursor-secondary";
9095
9099
  let cursor = r.empty ? r : state.EditorSelection.cursor(r.head, r.head > r.anchor ? -1 : 1);
9096
9100
  for (let piece of RectangleMarker.forRange(view, className, cursor))
@@ -9126,11 +9130,13 @@ const selectionLayer = layer({
9126
9130
  },
9127
9131
  class: "cm-selectionLayer"
9128
9132
  });
9129
- const themeSpec = {
9133
+ const hideNativeSelection = state.Prec.highest(EditorView.theme({
9130
9134
  ".cm-line": {
9131
9135
  "& ::selection, &::selection": { backgroundColor: "transparent !important" },
9136
+ caretColor: "transparent !important"
9132
9137
  },
9133
9138
  ".cm-content": {
9139
+ caretColor: "transparent !important",
9134
9140
  "& :focus": {
9135
9141
  caretColor: "initial !important",
9136
9142
  "&::selection, & ::selection": {
@@ -9138,10 +9144,7 @@ const themeSpec = {
9138
9144
  }
9139
9145
  }
9140
9146
  }
9141
- };
9142
- if (CanHidePrimary)
9143
- themeSpec[".cm-line"].caretColor = themeSpec[".cm-content"].caretColor = "transparent !important";
9144
- const hideNativeSelection = state.Prec.highest(EditorView.theme(themeSpec));
9147
+ }));
9145
9148
 
9146
9149
  const setDropCursorPos = state.StateEffect.define({
9147
9150
  map(pos, mapping) { return pos == null ? null : mapping.mapPos(pos); }
package/dist/index.js CHANGED
@@ -1070,7 +1070,7 @@ function coordsInChildren(view, pos, side) {
1070
1070
  if (child.children.length) {
1071
1071
  scan(child, pos - off);
1072
1072
  }
1073
- else if ((!after || after.isHidden && side > 0) &&
1073
+ else if ((!after || after.isHidden && (side > 0 || onSameLine(after, child))) &&
1074
1074
  (end > pos || off == end && child.getSide() > 0)) {
1075
1075
  after = child;
1076
1076
  afterPos = pos - off;
@@ -1096,6 +1096,10 @@ function fallbackRect(view) {
1096
1096
  let rects = clientRectsFor(last);
1097
1097
  return rects[rects.length - 1] || null;
1098
1098
  }
1099
+ function onSameLine(a, b) {
1100
+ let posA = a.coordsAt(0, 1), posB = b.coordsAt(0, 1);
1101
+ return posA && posB && posB.top < posA.bottom;
1102
+ }
1099
1103
 
1100
1104
  function combineAttrs(source, target) {
1101
1105
  for (let name in source) {
@@ -6614,6 +6618,7 @@ const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
6614
6618
  color: "#888",
6615
6619
  display: "inline-block",
6616
6620
  verticalAlign: "top",
6621
+ userSelect: "none"
6617
6622
  },
6618
6623
  ".cm-highlightSpace": {
6619
6624
  backgroundImage: "radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",
@@ -9028,7 +9033,6 @@ function layer(config) {
9028
9033
  ];
9029
9034
  }
9030
9035
 
9031
- const CanHidePrimary = !(browser.ios && browser.webkit && browser.webkit_version < 534);
9032
9036
  const selectionConfig = /*@__PURE__*/Facet.define({
9033
9037
  combine(configs) {
9034
9038
  return combineConfig(configs, {
@@ -9085,7 +9089,7 @@ const cursorLayer = /*@__PURE__*/layer({
9085
9089
  let cursors = [];
9086
9090
  for (let r of state.selection.ranges) {
9087
9091
  let prim = r == state.selection.main;
9088
- if (r.empty ? !prim || CanHidePrimary : conf.drawRangeCursor) {
9092
+ if (r.empty || conf.drawRangeCursor) {
9089
9093
  let className = prim ? "cm-cursor cm-cursor-primary" : "cm-cursor cm-cursor-secondary";
9090
9094
  let cursor = r.empty ? r : EditorSelection.cursor(r.head, r.head > r.anchor ? -1 : 1);
9091
9095
  for (let piece of RectangleMarker.forRange(view, className, cursor))
@@ -9121,11 +9125,13 @@ const selectionLayer = /*@__PURE__*/layer({
9121
9125
  },
9122
9126
  class: "cm-selectionLayer"
9123
9127
  });
9124
- const themeSpec = {
9128
+ const hideNativeSelection = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.theme({
9125
9129
  ".cm-line": {
9126
9130
  "& ::selection, &::selection": { backgroundColor: "transparent !important" },
9131
+ caretColor: "transparent !important"
9127
9132
  },
9128
9133
  ".cm-content": {
9134
+ caretColor: "transparent !important",
9129
9135
  "& :focus": {
9130
9136
  caretColor: "initial !important",
9131
9137
  "&::selection, & ::selection": {
@@ -9133,10 +9139,7 @@ const themeSpec = {
9133
9139
  }
9134
9140
  }
9135
9141
  }
9136
- };
9137
- if (CanHidePrimary)
9138
- themeSpec[".cm-line"].caretColor = themeSpec[".cm-content"].caretColor = "transparent !important";
9139
- const hideNativeSelection = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.theme(themeSpec));
9142
+ }));
9140
9143
 
9141
9144
  const setDropCursorPos = /*@__PURE__*/StateEffect.define({
9142
9145
  map(pos, mapping) { return pos == null ? null : mapping.mapPos(pos); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "6.36.4",
3
+ "version": "6.36.5",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",