@codemirror/view 0.19.38 → 0.19.39

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
+ ## 0.19.39 (2022-01-06)
2
+
3
+ ### Bug fixes
4
+
5
+ Make sure the editor signals a `geometryChanged` update when its width changes.
6
+
7
+ ### New features
8
+
9
+ `EditorView.darkTheme` can now be queried to figure out whether the editor is using a dark theme.
10
+
1
11
  ## 0.19.38 (2022-01-05)
2
12
 
3
13
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -4599,6 +4599,7 @@ class ViewState {
4599
4599
  this.contentDOMWidth = 0;
4600
4600
  this.contentDOMHeight = 0;
4601
4601
  this.editorHeight = 0;
4602
+ this.editorWidth = 0;
4602
4603
  this.heightOracle = new HeightOracle;
4603
4604
  // See VP.MaxDOMHeight
4604
4605
  this.scaler = IdScaler;
@@ -4704,11 +4705,18 @@ class ViewState {
4704
4705
  }
4705
4706
  if (!this.inView)
4706
4707
  return 0;
4708
+ let contentWidth = dom.clientWidth;
4709
+ if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight ||
4710
+ this.editorWidth != view.scrollDOM.clientWidth) {
4711
+ this.contentDOMWidth = contentWidth;
4712
+ this.editorHeight = view.scrollDOM.clientHeight;
4713
+ this.editorWidth = view.scrollDOM.clientWidth;
4714
+ result |= 8 /* Geometry */;
4715
+ }
4707
4716
  if (measureContent) {
4708
4717
  let lineHeights = view.docView.measureVisibleLineHeights();
4709
4718
  if (oracle.mustRefreshForHeights(lineHeights))
4710
4719
  refresh = true;
4711
- let contentWidth = dom.clientWidth;
4712
4720
  if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
4713
4721
  let { lineHeight, charWidth } = view.docView.measureTextSize();
4714
4722
  refresh = oracle.refresh(whiteSpace, direction, lineHeight, charWidth, contentWidth / charWidth, lineHeights);
@@ -4717,14 +4725,6 @@ class ViewState {
4717
4725
  result |= 8 /* Geometry */;
4718
4726
  }
4719
4727
  }
4720
- if (this.contentDOMWidth != contentWidth) {
4721
- this.contentDOMWidth = contentWidth;
4722
- result |= 8 /* Geometry */;
4723
- }
4724
- if (this.editorHeight != view.scrollDOM.clientHeight) {
4725
- this.editorHeight = view.scrollDOM.clientHeight;
4726
- result |= 8 /* Geometry */;
4727
- }
4728
4728
  if (dTop > 0 && dBottom > 0)
4729
4729
  bias = Math.max(dTop, dBottom);
4730
4730
  else if (dTop < 0 && dBottom < 0)
@@ -6585,6 +6585,13 @@ mechanism for providing decorations.
6585
6585
  */
6586
6586
  EditorView.decorations = decorations;
6587
6587
  /**
6588
+ This facet records whether a dark theme is active. The extension
6589
+ returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
6590
+ includes an instance of this when the `dark` option is set to
6591
+ true.
6592
+ */
6593
+ EditorView.darkTheme = darkTheme;
6594
+ /**
6588
6595
  Facet that provides additional DOM attributes for the editor's
6589
6596
  editable DOM element.
6590
6597
  */
package/dist/index.d.ts CHANGED
@@ -1156,6 +1156,13 @@ declare class EditorView {
1156
1156
  dark?: boolean;
1157
1157
  }): Extension;
1158
1158
  /**
1159
+ This facet records whether a dark theme is active. The extension
1160
+ returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
1161
+ includes an instance of this when the `dark` option is set to
1162
+ true.
1163
+ */
1164
+ static darkTheme: Facet<boolean, boolean>;
1165
+ /**
1159
1166
  Create an extension that adds styles to the base theme. Like
1160
1167
  with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
1161
1168
  place of the editor wrapper element when directly targeting
package/dist/index.js CHANGED
@@ -4593,6 +4593,7 @@ class ViewState {
4593
4593
  this.contentDOMWidth = 0;
4594
4594
  this.contentDOMHeight = 0;
4595
4595
  this.editorHeight = 0;
4596
+ this.editorWidth = 0;
4596
4597
  this.heightOracle = new HeightOracle;
4597
4598
  // See VP.MaxDOMHeight
4598
4599
  this.scaler = IdScaler;
@@ -4698,11 +4699,18 @@ class ViewState {
4698
4699
  }
4699
4700
  if (!this.inView)
4700
4701
  return 0;
4702
+ let contentWidth = dom.clientWidth;
4703
+ if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight ||
4704
+ this.editorWidth != view.scrollDOM.clientWidth) {
4705
+ this.contentDOMWidth = contentWidth;
4706
+ this.editorHeight = view.scrollDOM.clientHeight;
4707
+ this.editorWidth = view.scrollDOM.clientWidth;
4708
+ result |= 8 /* Geometry */;
4709
+ }
4701
4710
  if (measureContent) {
4702
4711
  let lineHeights = view.docView.measureVisibleLineHeights();
4703
4712
  if (oracle.mustRefreshForHeights(lineHeights))
4704
4713
  refresh = true;
4705
- let contentWidth = dom.clientWidth;
4706
4714
  if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
4707
4715
  let { lineHeight, charWidth } = view.docView.measureTextSize();
4708
4716
  refresh = oracle.refresh(whiteSpace, direction, lineHeight, charWidth, contentWidth / charWidth, lineHeights);
@@ -4711,14 +4719,6 @@ class ViewState {
4711
4719
  result |= 8 /* Geometry */;
4712
4720
  }
4713
4721
  }
4714
- if (this.contentDOMWidth != contentWidth) {
4715
- this.contentDOMWidth = contentWidth;
4716
- result |= 8 /* Geometry */;
4717
- }
4718
- if (this.editorHeight != view.scrollDOM.clientHeight) {
4719
- this.editorHeight = view.scrollDOM.clientHeight;
4720
- result |= 8 /* Geometry */;
4721
- }
4722
4722
  if (dTop > 0 && dBottom > 0)
4723
4723
  bias = Math.max(dTop, dBottom);
4724
4724
  else if (dTop < 0 && dBottom < 0)
@@ -6579,6 +6579,13 @@ mechanism for providing decorations.
6579
6579
  */
6580
6580
  EditorView.decorations = decorations;
6581
6581
  /**
6582
+ This facet records whether a dark theme is active. The extension
6583
+ returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
6584
+ includes an instance of this when the `dark` option is set to
6585
+ true.
6586
+ */
6587
+ EditorView.darkTheme = darkTheme;
6588
+ /**
6582
6589
  Facet that provides additional DOM attributes for the editor's
6583
6590
  editable DOM element.
6584
6591
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "0.19.38",
3
+ "version": "0.19.39",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",