@codemirror/state 6.2.1 → 6.3.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,15 @@
1
+ ## 6.3.1 (2023-10-18)
2
+
3
+ ### Bug fixes
4
+
5
+ Give the tag property on `FacetReader` the type of the output type parameter to force TypeScript to infer the proper type when converting from `Facet` to `FacetReader`.
6
+
7
+ ## 6.3.0 (2023-10-12)
8
+
9
+ ### New features
10
+
11
+ The new `FacetReader` type provides a way to export a read-only handle to a `Facet`.
12
+
1
13
  ## 6.2.1 (2023-05-23)
2
14
 
3
15
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  /**
6
4
  The data structure for documents. @nonabstract
7
5
  */
@@ -1317,12 +1315,12 @@ class SelectionRange {
1317
1315
  The anchor of the range—the side that doesn't move when you
1318
1316
  extend it.
1319
1317
  */
1320
- get anchor() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.to : this.from; }
1318
+ get anchor() { return this.flags & 32 /* RangeFlag.Inverted */ ? this.to : this.from; }
1321
1319
  /**
1322
1320
  The head of the range, which is moved when the range is
1323
1321
  [extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
1324
1322
  */
1325
- get head() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.from : this.to; }
1323
+ get head() { return this.flags & 32 /* RangeFlag.Inverted */ ? this.from : this.to; }
1326
1324
  /**
1327
1325
  True when `anchor` and `head` are at the same position.
1328
1326
  */
@@ -1333,14 +1331,14 @@ class SelectionRange {
1333
1331
  the character before its position, 1 the character after, and 0
1334
1332
  means no association.
1335
1333
  */
1336
- get assoc() { return this.flags & 4 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 8 /* RangeFlag.AssocAfter */ ? 1 : 0; }
1334
+ get assoc() { return this.flags & 8 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 16 /* RangeFlag.AssocAfter */ ? 1 : 0; }
1337
1335
  /**
1338
1336
  The bidirectional text level associated with this cursor, if
1339
1337
  any.
1340
1338
  */
1341
1339
  get bidiLevel() {
1342
- let level = this.flags & 3 /* RangeFlag.BidiLevelMask */;
1343
- return level == 3 ? null : level;
1340
+ let level = this.flags & 7 /* RangeFlag.BidiLevelMask */;
1341
+ return level == 7 ? null : level;
1344
1342
  }
1345
1343
  /**
1346
1344
  The goal column (stored vertical offset) associated with a
@@ -1349,8 +1347,8 @@ class SelectionRange {
1349
1347
  lines of different length.
1350
1348
  */
1351
1349
  get goalColumn() {
1352
- let value = this.flags >> 5 /* RangeFlag.GoalColumnOffset */;
1353
- return value == 33554431 /* RangeFlag.NoGoalColumn */ ? undefined : value;
1350
+ let value = this.flags >> 6 /* RangeFlag.GoalColumnOffset */;
1351
+ return value == 16777215 /* RangeFlag.NoGoalColumn */ ? undefined : value;
1354
1352
  }
1355
1353
  /**
1356
1354
  Map this range through a change, producing a valid range in the
@@ -1510,18 +1508,18 @@ class EditorSelection {
1510
1508
  safely ignore the optional arguments in most situations.
1511
1509
  */
1512
1510
  static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
1513
- return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* RangeFlag.AssocBefore */ : 8 /* RangeFlag.AssocAfter */) |
1514
- (bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |
1515
- ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */));
1511
+ return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 8 /* RangeFlag.AssocBefore */ : 16 /* RangeFlag.AssocAfter */) |
1512
+ (bidiLevel == null ? 7 : Math.min(6, bidiLevel)) |
1513
+ ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 16777215 /* RangeFlag.NoGoalColumn */) << 6 /* RangeFlag.GoalColumnOffset */));
1516
1514
  }
1517
1515
  /**
1518
1516
  Create a selection range.
1519
1517
  */
1520
1518
  static range(anchor, head, goalColumn, bidiLevel) {
1521
- let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */) |
1522
- (bidiLevel == null ? 3 : Math.min(2, bidiLevel));
1523
- return head < anchor ? SelectionRange.create(head, anchor, 16 /* RangeFlag.Inverted */ | 8 /* RangeFlag.AssocAfter */ | flags)
1524
- : SelectionRange.create(anchor, head, (head > anchor ? 4 /* RangeFlag.AssocBefore */ : 0) | flags);
1519
+ let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 16777215 /* RangeFlag.NoGoalColumn */) << 6 /* RangeFlag.GoalColumnOffset */) |
1520
+ (bidiLevel == null ? 7 : Math.min(6, bidiLevel));
1521
+ return head < anchor ? SelectionRange.create(head, anchor, 32 /* RangeFlag.Inverted */ | 16 /* RangeFlag.AssocAfter */ | flags)
1522
+ : SelectionRange.create(anchor, head, (head > anchor ? 8 /* RangeFlag.AssocBefore */ : 0) | flags);
1525
1523
  }
1526
1524
  /**
1527
1525
  @internal
@@ -1558,6 +1556,9 @@ Examples of uses of facets are the [tab
1558
1556
  size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
1559
1557
  attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
1560
1558
  listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
1559
+
1560
+ Note that `Facet` instances can be used anywhere where
1561
+ [`FacetReader`](https://codemirror.net/6/docs/ref/#state.FacetReader) is expected.
1561
1562
  */
1562
1563
  class Facet {
1563
1564
  constructor(
@@ -1585,6 +1586,11 @@ class Facet {
1585
1586
  this.extensions = typeof enables == "function" ? enables(this) : enables;
1586
1587
  }
1587
1588
  /**
1589
+ Returns a facet reader for this facet, which can be used to
1590
+ [read](https://codemirror.net/6/docs/ref/#state.EditorState.facet) it but not to define values for it.
1591
+ */
1592
+ get reader() { return this; }
1593
+ /**
1588
1594
  Define a new facet.
1589
1595
  */
1590
1596
  static define(config = {}) {