1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-06 03:50:04 +02:00

Update npm

This commit is contained in:
Daniel Neto 2024-04-03 15:54:35 -03:00
parent 8341712d58
commit 1bd85100b9
5320 changed files with 58396 additions and 344722 deletions

View file

@ -1,3 +1,47 @@
## 6.4.1 (2024-02-19)
### Bug fixes
Fix an issue that caused widgets at the end of a mark decoration to be rendered in their own separate mark DOM element.
## 6.4.0 (2023-12-28)
### Bug fixes
When multiple ranges in a single range set overlap, put the smaller ones inside the bigger ones, so that overlapping decorations don't break up each other's elements when coming from the same source.
### New features
Selection and selection range `eq` methods now support an optional argument that makes them also compare by cursor associativity.
The `RangeSet.join` function can be used to join multiple range sets together.
## 6.3.3 (2023-12-06)
### Bug fixes
Fix an issue where `Text.slice` and `Text.replace` could return objects with incorrect `length` when the given `from`/`to` values were out of range for the text.
## 6.3.2 (2023-11-27)
### Bug fixes
Make sure transactions cannot add multiple selections when `allowMultipleSelections` is false.
Fix a bug that caused `Text.iterLines` to not return empty lines at the end of the iterated ranges.
## 6.3.1 (2023-10-18)
### Bug fixes
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.3.0 (2023-10-12)
### New features
The new `FacetReader` type provides a way to export a read-only handle to a `Facet`.
## 6.2.1 (2023-05-23)
### Bug fixes

View file

@ -1,7 +1,5 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/**
The data structure for documents. @nonabstract
*/
@ -26,6 +24,7 @@ class Text {
Replace a range of the text with the given content.
*/
replace(from, to, text) {
[from, to] = clip(this, from, to);
let parts = [];
this.decompose(0, from, parts, 2 /* Open.To */);
if (text.length)
@ -43,6 +42,7 @@ class Text {
Retrieve the text between the given points.
*/
slice(from, to = this.length) {
[from, to] = clip(this, from, to);
let parts = [];
this.decompose(from, to, parts, 0);
return TextNode.from(parts, to - from);
@ -169,6 +169,7 @@ class TextLeaf extends Text {
replace(from, to, text) {
if (!(text instanceof TextLeaf))
return super.replace(from, to, text);
[from, to] = clip(this, from, to);
let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);
let newLen = this.length + text.length - (to - from);
if (lines.length <= 32 /* Tree.Branch */)
@ -176,6 +177,7 @@ class TextLeaf extends Text {
return TextNode.from(TextLeaf.split(lines, []), newLen);
}
sliceString(from, to = this.length, lineSep = "\n") {
[from, to] = clip(this, from, to);
let result = "";
for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {
let line = this.text[i], end = pos + line.length;
@ -244,6 +246,7 @@ class TextNode extends Text {
}
}
replace(from, to, text) {
[from, to] = clip(this, from, to);
if (text.lines < this.lines)
for (let i = 0, pos = 0; i < this.children.length; i++) {
let child = this.children[i], end = pos + child.length;
@ -266,6 +269,7 @@ class TextNode extends Text {
return super.replace(from, to, text);
}
sliceString(from, to = this.length, lineSep = "\n") {
[from, to] = clip(this, from, to);
let result = "";
for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {
let child = this.children[i], end = pos + child.length;
@ -487,7 +491,11 @@ class LineCursor {
}
next(skip = 0) {
let { done, lineBreak, value } = this.inner.next(skip);
if (done) {
if (done && this.afterBreak) {
this.value = "";
this.afterBreak = false;
}
else if (done) {
this.done = true;
this.value = "";
}
@ -549,6 +557,10 @@ class Line {
*/
get length() { return this.to - this.from; }
}
function clip(text, from, to) {
from = Math.max(0, Math.min(text.length, from));
return [from, Math.max(from, Math.min(text.length, to))];
}
// Compressed representation of the Grapheme_Cluster_Break=Extend
// information from
@ -1317,12 +1329,12 @@ class SelectionRange {
The anchor of the rangethe side that doesn't move when you
extend it.
*/
get anchor() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.to : this.from; }
get anchor() { return this.flags & 32 /* RangeFlag.Inverted */ ? this.to : this.from; }
/**
The head of the range, which is moved when the range is
[extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
*/
get head() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.from : this.to; }
get head() { return this.flags & 32 /* RangeFlag.Inverted */ ? this.from : this.to; }
/**
True when `anchor` and `head` are at the same position.
*/
@ -1333,14 +1345,14 @@ class SelectionRange {
the character before its position, 1 the character after, and 0
means no association.
*/
get assoc() { return this.flags & 4 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 8 /* RangeFlag.AssocAfter */ ? 1 : 0; }
get assoc() { return this.flags & 8 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 16 /* RangeFlag.AssocAfter */ ? 1 : 0; }
/**
The bidirectional text level associated with this cursor, if
any.
*/
get bidiLevel() {
let level = this.flags & 3 /* RangeFlag.BidiLevelMask */;
return level == 3 ? null : level;
let level = this.flags & 7 /* RangeFlag.BidiLevelMask */;
return level == 7 ? null : level;
}
/**
The goal column (stored vertical offset) associated with a
@ -1349,8 +1361,8 @@ class SelectionRange {
lines of different length.
*/
get goalColumn() {
let value = this.flags >> 5 /* RangeFlag.GoalColumnOffset */;
return value == 33554431 /* RangeFlag.NoGoalColumn */ ? undefined : value;
let value = this.flags >> 6 /* RangeFlag.GoalColumnOffset */;
return value == 16777215 /* RangeFlag.NoGoalColumn */ ? undefined : value;
}
/**
Map this range through a change, producing a valid range in the
@ -1379,8 +1391,9 @@ class SelectionRange {
/**
Compare this range to another range.
*/
eq(other) {
return this.anchor == other.anchor && this.head == other.head;
eq(other, includeAssoc = false) {
return this.anchor == other.anchor && this.head == other.head &&
(!includeAssoc || !this.empty || this.assoc == other.assoc);
}
/**
Return a JSON-serializable object representing the range.
@ -1430,14 +1443,17 @@ class EditorSelection {
return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), this.mainIndex);
}
/**
Compare this selection to another selection.
Compare this selection to another selection. By default, ranges
are compared only by position. When `includeAssoc` is true,
cursor ranges must also have the same
[`assoc`](https://codemirror.net/6/docs/ref/#state.SelectionRange.assoc) value.
*/
eq(other) {
eq(other, includeAssoc = false) {
if (this.ranges.length != other.ranges.length ||
this.mainIndex != other.mainIndex)
return false;
for (let i = 0; i < this.ranges.length; i++)
if (!this.ranges[i].eq(other.ranges[i]))
if (!this.ranges[i].eq(other.ranges[i], includeAssoc))
return false;
return true;
}
@ -1510,18 +1526,18 @@ class EditorSelection {
safely ignore the optional arguments in most situations.
*/
static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* RangeFlag.AssocBefore */ : 8 /* RangeFlag.AssocAfter */) |
(bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |
((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */));
return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 8 /* RangeFlag.AssocBefore */ : 16 /* RangeFlag.AssocAfter */) |
(bidiLevel == null ? 7 : Math.min(6, bidiLevel)) |
((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 16777215 /* RangeFlag.NoGoalColumn */) << 6 /* RangeFlag.GoalColumnOffset */));
}
/**
Create a selection range.
*/
static range(anchor, head, goalColumn, bidiLevel) {
let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */) |
(bidiLevel == null ? 3 : Math.min(2, bidiLevel));
return head < anchor ? SelectionRange.create(head, anchor, 16 /* RangeFlag.Inverted */ | 8 /* RangeFlag.AssocAfter */ | flags)
: SelectionRange.create(anchor, head, (head > anchor ? 4 /* RangeFlag.AssocBefore */ : 0) | flags);
let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 16777215 /* RangeFlag.NoGoalColumn */) << 6 /* RangeFlag.GoalColumnOffset */) |
(bidiLevel == null ? 7 : Math.min(6, bidiLevel));
return head < anchor ? SelectionRange.create(head, anchor, 32 /* RangeFlag.Inverted */ | 16 /* RangeFlag.AssocAfter */ | flags)
: SelectionRange.create(anchor, head, (head > anchor ? 8 /* RangeFlag.AssocBefore */ : 0) | flags);
}
/**
@internal
@ -1558,6 +1574,9 @@ Examples of uses of facets are the [tab
size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
Note that `Facet` instances can be used anywhere where
[`FacetReader`](https://codemirror.net/6/docs/ref/#state.FacetReader) is expected.
*/
class Facet {
constructor(
@ -1585,6 +1604,11 @@ class Facet {
this.extensions = typeof enables == "function" ? enables(this) : enables;
}
/**
Returns a facet reader for this facet, which can be used to
[read](https://codemirror.net/6/docs/ref/#state.EditorState.facet) it but not to define values for it.
*/
get reader() { return this; }
/**
Define a new facet.
*/
static define(config = {}) {
@ -2637,7 +2661,8 @@ class EditorState {
else {
startValues = tr.startState.values.slice();
}
new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);
let selection = tr.startState.facet(allowMultipleSelections) ? tr.newSelection : tr.newSelection.asSingle();
new EditorState(conf, tr.newDoc, selection, startValues, (state, slot) => slot.update(state, tr), tr);
}
/**
Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
@ -3371,7 +3396,9 @@ class RangeSet {
let curTo = Math.min(cursor.to, to);
if (cursor.point) {
let active = cursor.activeForPoint(cursor.to);
let openCount = cursor.pointFrom < from ? active.length + 1 : Math.min(active.length, openRanges);
let openCount = cursor.pointFrom < from ? active.length + 1
: cursor.point.startSide < 0 ? active.length
: Math.min(active.length, openRanges);
iterator.point(pos, curTo, cursor.point, active, openCount, cursor.pointRank);
openRanges = Math.min(cursor.openEnd(curTo), active.length);
}
@ -3398,6 +3425,19 @@ class RangeSet {
build.add(range.from, range.to, range.value);
return build.finish();
}
/**
Join an array of range sets into a single set.
*/
static join(sets) {
if (!sets.length)
return RangeSet.empty;
let result = sets[sets.length - 1];
for (let i = sets.length - 2; i >= 0; i--) {
for (let layer = sets[i]; layer != RangeSet.empty; layer = layer.nextLayer)
result = new RangeSet(layer.chunkPos, layer.chunk, result, Math.max(layer.maxPoint, result.maxPoint));
}
return result;
}
}
/**
The empty set of ranges.
@ -3715,7 +3755,8 @@ class SpanCursor {
}
addActive(trackOpen) {
let i = 0, { value, to, rank } = this.cursor;
while (i < this.activeRank.length && this.activeRank[i] <= rank)
// Organize active marks by rank first, then by size
while (i < this.activeRank.length && (rank - this.activeRank[i] || to - this.activeTo[i]) > 0)
i++;
insert(this.active, i, value);
insert(this.activeTo, i, to);

1693
node_modules/@codemirror/state/dist/index.d.cts generated vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -400,7 +400,7 @@ declare class SelectionRange {
/**
Compare this range to another range.
*/
eq(other: SelectionRange): boolean;
eq(other: SelectionRange, includeAssoc?: boolean): boolean;
/**
Return a JSON-serializable object representing the range.
*/
@ -432,9 +432,12 @@ declare class EditorSelection {
*/
map(change: ChangeDesc, assoc?: number): EditorSelection;
/**
Compare this selection to another selection.
Compare this selection to another selection. By default, ranges
are compared only by position. When `includeAssoc` is true,
cursor ranges must also have the same
[`assoc`](https://codemirror.net/6/docs/ref/#state.SelectionRange.assoc) value.
*/
eq(other: EditorSelection): boolean;
eq(other: EditorSelection, includeAssoc?: boolean): boolean;
/**
Get the primary selection range. Usually, you should make sure
your code applies to _all_ ranges, by using methods like
@ -528,11 +531,19 @@ Examples of uses of facets are the [tab
size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
Note that `Facet` instances can be used anywhere where
[`FacetReader`](https://codemirror.net/6/docs/ref/#state.FacetReader) is expected.
*/
declare class Facet<Input, Output = readonly Input[]> {
declare class Facet<Input, Output = readonly Input[]> implements FacetReader<Output> {
private isStatic;
private constructor();
/**
Returns a facet reader for this facet, which can be used to
[read](https://codemirror.net/6/docs/ref/#state.EditorState.facet) it but not to define values for it.
*/
get reader(): FacetReader<Output>;
/**
Define a new facet.
*/
static define<Input, Output = readonly Input[]>(config?: FacetConfig<Input, Output>): Facet<Input, Output>;
@ -563,8 +574,23 @@ declare class Facet<Input, Output = readonly Input[]> {
*/
from<T extends Input>(field: StateField<T>): Extension;
from<T>(field: StateField<T>, get: (value: T) => Input): Extension;
tag: Output;
}
type Slot<T> = Facet<any, T> | StateField<T> | "doc" | "selection";
/**
A facet reader can be used to fetch the value of a facet, through
[`EditorState.facet`](https://codemirror.net/6/docs/ref/#state.EditorState.facet) or as a dependency
in [`Facet.compute`](https://codemirror.net/6/docs/ref/#state.Facet.compute), but not to define new
values for the facet.
*/
type FacetReader<Output> = {
/**
Dummy tag that makes sure TypeScript doesn't consider all object
types as conforming to this type. Not actually present on the
object.
*/
tag: Output;
};
type Slot<T> = FacetReader<T> | StateField<T> | "doc" | "selection";
type StateFieldSpec<Value> = {
/**
Creates the initial value for the field when a state is created.
@ -825,7 +851,7 @@ interface TransactionSpec {
selection?: EditorSelection | {
anchor: number;
head?: number;
};
} | undefined;
/**
Attach [state effects](https://codemirror.net/6/docs/ref/#state.StateEffect) to this transaction.
Again, when they contain positions and this same spec makes
@ -1123,7 +1149,7 @@ declare class EditorState {
/**
Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
*/
facet<Output>(facet: Facet<any, Output>): Output;
facet<Output>(facet: FacetReader<Output>): Output;
/**
Convert this state to a JSON-serializable object. When custom
fields should be serialized, you can pass them in as an object
@ -1581,6 +1607,10 @@ declare class RangeSet<T extends RangeValue> {
*/
static of<T extends RangeValue>(ranges: readonly Range<T>[] | Range<T>, sort?: boolean): RangeSet<T>;
/**
Join an array of range sets into a single set.
*/
static join<T extends RangeValue>(sets: readonly RangeSet<T>[]): RangeSet<T>;
/**
The empty set of ranges.
*/
static empty: RangeSet<any>;
@ -1660,4 +1690,4 @@ situation.
*/
declare function findColumn(string: string, col: number, tabSize: number, strict?: boolean): number;
export { Annotation, AnnotationType, ChangeDesc, ChangeSet, ChangeSpec, CharCategory, Compartment, EditorSelection, EditorState, EditorStateConfig, Extension, Facet, Line, MapMode, Prec, Range, RangeComparator, RangeCursor, RangeSet, RangeSetBuilder, RangeValue, SelectionRange, SpanIterator, StateCommand, StateEffect, StateEffectType, StateField, Text, TextIterator, Transaction, TransactionSpec, codePointAt, codePointSize, combineConfig, countColumn, findClusterBreak, findColumn, fromCodePoint };
export { Annotation, AnnotationType, ChangeDesc, ChangeSet, type ChangeSpec, CharCategory, Compartment, EditorSelection, EditorState, type EditorStateConfig, type Extension, Facet, type FacetReader, Line, MapMode, Prec, Range, type RangeComparator, type RangeCursor, RangeSet, RangeSetBuilder, RangeValue, SelectionRange, type SpanIterator, type StateCommand, StateEffect, StateEffectType, StateField, Text, type TextIterator, Transaction, type TransactionSpec, codePointAt, codePointSize, combineConfig, countColumn, findClusterBreak, findColumn, fromCodePoint };

View file

@ -22,6 +22,7 @@ class Text {
Replace a range of the text with the given content.
*/
replace(from, to, text) {
[from, to] = clip(this, from, to);
let parts = [];
this.decompose(0, from, parts, 2 /* Open.To */);
if (text.length)
@ -39,6 +40,7 @@ class Text {
Retrieve the text between the given points.
*/
slice(from, to = this.length) {
[from, to] = clip(this, from, to);
let parts = [];
this.decompose(from, to, parts, 0);
return TextNode.from(parts, to - from);
@ -165,6 +167,7 @@ class TextLeaf extends Text {
replace(from, to, text) {
if (!(text instanceof TextLeaf))
return super.replace(from, to, text);
[from, to] = clip(this, from, to);
let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);
let newLen = this.length + text.length - (to - from);
if (lines.length <= 32 /* Tree.Branch */)
@ -172,6 +175,7 @@ class TextLeaf extends Text {
return TextNode.from(TextLeaf.split(lines, []), newLen);
}
sliceString(from, to = this.length, lineSep = "\n") {
[from, to] = clip(this, from, to);
let result = "";
for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {
let line = this.text[i], end = pos + line.length;
@ -240,6 +244,7 @@ class TextNode extends Text {
}
}
replace(from, to, text) {
[from, to] = clip(this, from, to);
if (text.lines < this.lines)
for (let i = 0, pos = 0; i < this.children.length; i++) {
let child = this.children[i], end = pos + child.length;
@ -262,6 +267,7 @@ class TextNode extends Text {
return super.replace(from, to, text);
}
sliceString(from, to = this.length, lineSep = "\n") {
[from, to] = clip(this, from, to);
let result = "";
for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {
let child = this.children[i], end = pos + child.length;
@ -483,7 +489,11 @@ class LineCursor {
}
next(skip = 0) {
let { done, lineBreak, value } = this.inner.next(skip);
if (done) {
if (done && this.afterBreak) {
this.value = "";
this.afterBreak = false;
}
else if (done) {
this.done = true;
this.value = "";
}
@ -545,6 +555,10 @@ class Line {
*/
get length() { return this.to - this.from; }
}
function clip(text, from, to) {
from = Math.max(0, Math.min(text.length, from));
return [from, Math.max(from, Math.min(text.length, to))];
}
// Compressed representation of the Grapheme_Cluster_Break=Extend
// information from
@ -1312,12 +1326,12 @@ class SelectionRange {
The anchor of the rangethe side that doesn't move when you
extend it.
*/
get anchor() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.to : this.from; }
get anchor() { return this.flags & 32 /* RangeFlag.Inverted */ ? this.to : this.from; }
/**
The head of the range, which is moved when the range is
[extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
*/
get head() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.from : this.to; }
get head() { return this.flags & 32 /* RangeFlag.Inverted */ ? this.from : this.to; }
/**
True when `anchor` and `head` are at the same position.
*/
@ -1328,14 +1342,14 @@ class SelectionRange {
the character before its position, 1 the character after, and 0
means no association.
*/
get assoc() { return this.flags & 4 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 8 /* RangeFlag.AssocAfter */ ? 1 : 0; }
get assoc() { return this.flags & 8 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 16 /* RangeFlag.AssocAfter */ ? 1 : 0; }
/**
The bidirectional text level associated with this cursor, if
any.
*/
get bidiLevel() {
let level = this.flags & 3 /* RangeFlag.BidiLevelMask */;
return level == 3 ? null : level;
let level = this.flags & 7 /* RangeFlag.BidiLevelMask */;
return level == 7 ? null : level;
}
/**
The goal column (stored vertical offset) associated with a
@ -1344,8 +1358,8 @@ class SelectionRange {
lines of different length.
*/
get goalColumn() {
let value = this.flags >> 5 /* RangeFlag.GoalColumnOffset */;
return value == 33554431 /* RangeFlag.NoGoalColumn */ ? undefined : value;
let value = this.flags >> 6 /* RangeFlag.GoalColumnOffset */;
return value == 16777215 /* RangeFlag.NoGoalColumn */ ? undefined : value;
}
/**
Map this range through a change, producing a valid range in the
@ -1374,8 +1388,9 @@ class SelectionRange {
/**
Compare this range to another range.
*/
eq(other) {
return this.anchor == other.anchor && this.head == other.head;
eq(other, includeAssoc = false) {
return this.anchor == other.anchor && this.head == other.head &&
(!includeAssoc || !this.empty || this.assoc == other.assoc);
}
/**
Return a JSON-serializable object representing the range.
@ -1425,14 +1440,17 @@ class EditorSelection {
return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), this.mainIndex);
}
/**
Compare this selection to another selection.
Compare this selection to another selection. By default, ranges
are compared only by position. When `includeAssoc` is true,
cursor ranges must also have the same
[`assoc`](https://codemirror.net/6/docs/ref/#state.SelectionRange.assoc) value.
*/
eq(other) {
eq(other, includeAssoc = false) {
if (this.ranges.length != other.ranges.length ||
this.mainIndex != other.mainIndex)
return false;
for (let i = 0; i < this.ranges.length; i++)
if (!this.ranges[i].eq(other.ranges[i]))
if (!this.ranges[i].eq(other.ranges[i], includeAssoc))
return false;
return true;
}
@ -1505,18 +1523,18 @@ class EditorSelection {
safely ignore the optional arguments in most situations.
*/
static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* RangeFlag.AssocBefore */ : 8 /* RangeFlag.AssocAfter */) |
(bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |
((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */));
return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 8 /* RangeFlag.AssocBefore */ : 16 /* RangeFlag.AssocAfter */) |
(bidiLevel == null ? 7 : Math.min(6, bidiLevel)) |
((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 16777215 /* RangeFlag.NoGoalColumn */) << 6 /* RangeFlag.GoalColumnOffset */));
}
/**
Create a selection range.
*/
static range(anchor, head, goalColumn, bidiLevel) {
let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */) |
(bidiLevel == null ? 3 : Math.min(2, bidiLevel));
return head < anchor ? SelectionRange.create(head, anchor, 16 /* RangeFlag.Inverted */ | 8 /* RangeFlag.AssocAfter */ | flags)
: SelectionRange.create(anchor, head, (head > anchor ? 4 /* RangeFlag.AssocBefore */ : 0) | flags);
let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 16777215 /* RangeFlag.NoGoalColumn */) << 6 /* RangeFlag.GoalColumnOffset */) |
(bidiLevel == null ? 7 : Math.min(6, bidiLevel));
return head < anchor ? SelectionRange.create(head, anchor, 32 /* RangeFlag.Inverted */ | 16 /* RangeFlag.AssocAfter */ | flags)
: SelectionRange.create(anchor, head, (head > anchor ? 8 /* RangeFlag.AssocBefore */ : 0) | flags);
}
/**
@internal
@ -1553,6 +1571,9 @@ Examples of uses of facets are the [tab
size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
Note that `Facet` instances can be used anywhere where
[`FacetReader`](https://codemirror.net/6/docs/ref/#state.FacetReader) is expected.
*/
class Facet {
constructor(
@ -1580,6 +1601,11 @@ class Facet {
this.extensions = typeof enables == "function" ? enables(this) : enables;
}
/**
Returns a facet reader for this facet, which can be used to
[read](https://codemirror.net/6/docs/ref/#state.EditorState.facet) it but not to define values for it.
*/
get reader() { return this; }
/**
Define a new facet.
*/
static define(config = {}) {
@ -2631,7 +2657,8 @@ class EditorState {
else {
startValues = tr.startState.values.slice();
}
new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);
let selection = tr.startState.facet(allowMultipleSelections) ? tr.newSelection : tr.newSelection.asSingle();
new EditorState(conf, tr.newDoc, selection, startValues, (state, slot) => slot.update(state, tr), tr);
}
/**
Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
@ -3365,7 +3392,9 @@ class RangeSet {
let curTo = Math.min(cursor.to, to);
if (cursor.point) {
let active = cursor.activeForPoint(cursor.to);
let openCount = cursor.pointFrom < from ? active.length + 1 : Math.min(active.length, openRanges);
let openCount = cursor.pointFrom < from ? active.length + 1
: cursor.point.startSide < 0 ? active.length
: Math.min(active.length, openRanges);
iterator.point(pos, curTo, cursor.point, active, openCount, cursor.pointRank);
openRanges = Math.min(cursor.openEnd(curTo), active.length);
}
@ -3392,6 +3421,19 @@ class RangeSet {
build.add(range.from, range.to, range.value);
return build.finish();
}
/**
Join an array of range sets into a single set.
*/
static join(sets) {
if (!sets.length)
return RangeSet.empty;
let result = sets[sets.length - 1];
for (let i = sets.length - 2; i >= 0; i--) {
for (let layer = sets[i]; layer != RangeSet.empty; layer = layer.nextLayer)
result = new RangeSet(layer.chunkPos, layer.chunk, result, Math.max(layer.maxPoint, result.maxPoint));
}
return result;
}
}
/**
The empty set of ranges.
@ -3709,7 +3751,8 @@ class SpanCursor {
}
addActive(trackOpen) {
let i = 0, { value, to, rank } = this.cursor;
while (i < this.activeRank.length && this.activeRank[i] <= rank)
// Organize active marks by rank first, then by size
while (i < this.activeRank.length && (rank - this.activeRank[i] || to - this.activeTo[i]) > 0)
i++;
insert(this.active, i, value);
insert(this.activeTo, i, to);

View file

@ -1,6 +1,6 @@
{
"name": "@codemirror/state",
"version": "6.2.1",
"version": "6.4.1",
"description": "Editor state data structures for the CodeMirror code editor",
"scripts": {
"test": "cm-runtests",
@ -26,7 +26,7 @@
"sideEffects": false,
"license": "MIT",
"devDependencies": {
"@codemirror/buildhelper": "^0.1.5"
"@codemirror/buildhelper": "^1.0.0"
},
"repository": {
"type": "git",