@codemirror/view 6.20.0 → 6.20.1

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.20.1 (2023-09-22)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a crash in plugin event handlers after dynamic reconfiguration.
6
+
7
+ Fix an issue where, on Chrome, tooltips would no longer use fixed positioning.
8
+
1
9
  ## 6.20.0 (2023-09-20)
2
10
 
3
11
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -5335,9 +5335,9 @@ class ViewState {
5335
5335
  if (domRect.width && domRect.height) {
5336
5336
  let scaleX = domRect.width / dom.offsetWidth;
5337
5337
  let scaleY = domRect.height / dom.offsetHeight;
5338
- if (scaleX > 0.995 && scaleX < 1.005)
5338
+ if (scaleX > 0.995 && scaleX < 1.005 || !isFinite(scaleX))
5339
5339
  scaleX = 1;
5340
- if (scaleY > 0.995 && scaleY < 1.005)
5340
+ if (scaleY > 0.995 && scaleY < 1.005 || !isFinite(scaleY))
5341
5341
  scaleY = 1;
5342
5342
  if (this.scaleX != scaleX || this.scaleY != scaleY) {
5343
5343
  this.scaleX = scaleX;
@@ -7084,7 +7084,6 @@ class EditorView {
7084
7084
  plugin.destroy(this);
7085
7085
  this.plugins = newPlugins;
7086
7086
  this.pluginMap.clear();
7087
- this.inputState.ensureHandlers(this.plugins);
7088
7087
  }
7089
7088
  else {
7090
7089
  for (let p of this.plugins)
@@ -7092,6 +7091,8 @@ class EditorView {
7092
7091
  }
7093
7092
  for (let i = 0; i < this.plugins.length; i++)
7094
7093
  this.plugins[i].update(this);
7094
+ if (prevSpecs != specs)
7095
+ this.inputState.ensureHandlers(this.plugins);
7095
7096
  }
7096
7097
  /**
7097
7098
  @internal
@@ -9189,13 +9190,13 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
9189
9190
  readMeasure() {
9190
9191
  let editor = this.view.dom.getBoundingClientRect();
9191
9192
  let scaleX = 1, scaleY = 1, makeAbsolute = false;
9192
- if (this.position == "fixed") {
9193
- let views = this.manager.tooltipViews;
9194
- // When the dialog's offset parent isn't the body, we are
9195
- // probably in a transformed container, and should use absolute
9196
- // positioning instead, since fixed positioning inside a
9197
- // transform works in a very broken way.
9198
- makeAbsolute = views.length > 0 && views[0].dom.offsetParent != this.container.ownerDocument.body;
9193
+ if (this.position == "fixed" && this.manager.tooltipViews.length) {
9194
+ // When the dialog's offset parent isn't the body (Firefox) or
9195
+ // null (Webkit), we are probably in a transformed container,
9196
+ // and should use absolute positioning instead, since fixed
9197
+ // positioning inside a transform works in a very broken way.
9198
+ let { offsetParent } = this.manager.tooltipViews[0].dom;
9199
+ makeAbsolute = !!(offsetParent && offsetParent != this.container.ownerDocument.body);
9199
9200
  }
9200
9201
  if (makeAbsolute || this.position == "absolute") {
9201
9202
  if (this.parent) {
package/dist/index.js CHANGED
@@ -5330,9 +5330,9 @@ class ViewState {
5330
5330
  if (domRect.width && domRect.height) {
5331
5331
  let scaleX = domRect.width / dom.offsetWidth;
5332
5332
  let scaleY = domRect.height / dom.offsetHeight;
5333
- if (scaleX > 0.995 && scaleX < 1.005)
5333
+ if (scaleX > 0.995 && scaleX < 1.005 || !isFinite(scaleX))
5334
5334
  scaleX = 1;
5335
- if (scaleY > 0.995 && scaleY < 1.005)
5335
+ if (scaleY > 0.995 && scaleY < 1.005 || !isFinite(scaleY))
5336
5336
  scaleY = 1;
5337
5337
  if (this.scaleX != scaleX || this.scaleY != scaleY) {
5338
5338
  this.scaleX = scaleX;
@@ -7079,7 +7079,6 @@ class EditorView {
7079
7079
  plugin.destroy(this);
7080
7080
  this.plugins = newPlugins;
7081
7081
  this.pluginMap.clear();
7082
- this.inputState.ensureHandlers(this.plugins);
7083
7082
  }
7084
7083
  else {
7085
7084
  for (let p of this.plugins)
@@ -7087,6 +7086,8 @@ class EditorView {
7087
7086
  }
7088
7087
  for (let i = 0; i < this.plugins.length; i++)
7089
7088
  this.plugins[i].update(this);
7089
+ if (prevSpecs != specs)
7090
+ this.inputState.ensureHandlers(this.plugins);
7090
7091
  }
7091
7092
  /**
7092
7093
  @internal
@@ -9184,13 +9185,13 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
9184
9185
  readMeasure() {
9185
9186
  let editor = this.view.dom.getBoundingClientRect();
9186
9187
  let scaleX = 1, scaleY = 1, makeAbsolute = false;
9187
- if (this.position == "fixed") {
9188
- let views = this.manager.tooltipViews;
9189
- // When the dialog's offset parent isn't the body, we are
9190
- // probably in a transformed container, and should use absolute
9191
- // positioning instead, since fixed positioning inside a
9192
- // transform works in a very broken way.
9193
- makeAbsolute = views.length > 0 && views[0].dom.offsetParent != this.container.ownerDocument.body;
9188
+ if (this.position == "fixed" && this.manager.tooltipViews.length) {
9189
+ // When the dialog's offset parent isn't the body (Firefox) or
9190
+ // null (Webkit), we are probably in a transformed container,
9191
+ // and should use absolute positioning instead, since fixed
9192
+ // positioning inside a transform works in a very broken way.
9193
+ let { offsetParent } = this.manager.tooltipViews[0].dom;
9194
+ makeAbsolute = !!(offsetParent && offsetParent != this.container.ownerDocument.body);
9194
9195
  }
9195
9196
  if (makeAbsolute || this.position == "absolute") {
9196
9197
  if (this.parent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "6.20.0",
3
+ "version": "6.20.1",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",