@vscode/markdown-editor 0.0.2-41 → 0.0.2-43

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.
@@ -1,8 +1,11 @@
1
- const S = "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?", f = {
2
- wordSeparators: S,
1
+ const C = "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?", f = {
2
+ wordSeparators: C,
3
3
  wordSegmenterLocales: []
4
4
  };
5
- class C {
5
+ function _(e, n) {
6
+ return e !== void 0 && !/\s/u.test(e) && !n.includes(e);
7
+ }
8
+ class S {
6
9
  _separators;
7
10
  _segmenter;
8
11
  _cachedLine;
@@ -59,13 +62,13 @@ function L(e) {
59
62
  return;
60
63
  }
61
64
  }
62
- const v = /* @__PURE__ */ new Map();
65
+ const y = /* @__PURE__ */ new Map();
63
66
  function W(e) {
64
67
  const n = `${e.wordSeparators}/${e.wordSegmenterLocales.join(",")}`;
65
- let i = v.get(n);
66
- return i || (i = new C(e), v.set(n, i)), i;
68
+ let i = y.get(n);
69
+ return i || (i = new S(e), y.set(n, i)), i;
67
70
  }
68
- function _(e, n, i = f) {
71
+ function x(e, n, i = f) {
69
72
  if (n = p(n, 0, e.length), n === 0)
70
73
  return 0;
71
74
  let t = e.lastIndexOf(`
@@ -79,10 +82,10 @@ function _(e, n, i = f) {
79
82
  `, a - 1) + 1, r = a, s = Math.max(0, a - t);
80
83
  }
81
84
  const l = e.slice(t, r), d = W(i);
82
- let o = y(l, d, s);
83
- return o?.type === 1 && o.end - o.start === 1 && o.nextClass === 0 && (o = y(l, d, o.start)), t + (o?.start ?? 0);
85
+ let o = v(l, d, s);
86
+ return o?.type === 1 && o.end - o.start === 1 && o.nextClass === 0 && (o = v(l, d, o.start)), t + (o?.start ?? 0);
84
87
  }
85
- function x(e, n, i = f) {
88
+ function E(e, n, i = f) {
86
89
  if (n = p(n, 0, e.length), n === e.length)
87
90
  return e.length;
88
91
  let t = e.lastIndexOf(`
@@ -96,7 +99,7 @@ function x(e, n, i = f) {
96
99
  let o = O(l, d, s);
97
100
  return o?.type === 1 && o.end - o.start === 1 && o.nextClass === 0 && (o = O(l, d, o.end)), t + (o?.end ?? l.length);
98
101
  }
99
- function E(e, n, i = f) {
102
+ function A(e, n, i = f) {
100
103
  if (n = p(n, 0, e.length), n === 0)
101
104
  return 0;
102
105
  const t = n === 0 ? 0 : e.lastIndexOf(`
@@ -111,10 +114,10 @@ function E(e, n, i = f) {
111
114
  let l = e.indexOf(`
112
115
  `, n);
113
116
  l === -1 && (l = e.length);
114
- const d = e.slice(t, l), o = y(d, W(i), r);
117
+ const d = e.slice(t, l), o = v(d, W(i), r);
115
118
  return t + (o?.start ?? 0);
116
119
  }
117
- function A(e, n, i = f) {
120
+ function D(e, n, i = f) {
118
121
  if (n = p(n, 0, e.length), n === e.length)
119
122
  return e.length;
120
123
  const t = e.lastIndexOf(`
@@ -140,7 +143,7 @@ function A(e, n, i = f) {
140
143
  const u = e.slice(h, c), g = O(u, o, 0);
141
144
  return h + (g?.start ?? u.length);
142
145
  }
143
- function D(e, n, i = f) {
146
+ function R(e, n, i = f) {
144
147
  if (n = p(n, 0, e.length), n === e.length)
145
148
  return { start: n, end: n };
146
149
  const t = e[n];
@@ -171,7 +174,7 @@ function D(e, n, i = f) {
171
174
  u++;
172
175
  return { start: r + c, end: r + u };
173
176
  }
174
- function y(e, n, i) {
177
+ function v(e, n, i) {
175
178
  let t;
176
179
  const r = n.previousIntlWord(e, i - 1);
177
180
  for (let s = i - 1; s >= 0; s--) {
@@ -272,11 +275,12 @@ function p(e, n, i) {
272
275
  }
273
276
  export {
274
277
  f as D,
275
- x as a,
276
- E as b,
277
- A as c,
278
- D as d,
279
- S as e,
280
- _ as f
278
+ E as a,
279
+ A as b,
280
+ D as c,
281
+ R as d,
282
+ C as e,
283
+ x as f,
284
+ _ as i
281
285
  };
282
- //# sourceMappingURL=config-Dvgk17FF.js.map
286
+ //# sourceMappingURL=config-BGeaJqWk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-BGeaJqWk.js","sources":["../src/core/wordUtils.ts"],"sourcesContent":["export const DEFAULT_WORD_SEPARATORS = '`~!@#$%^&*()-=+[{]}\\\\|;:\\'\",.<>/?';\n\nexport interface WordNavigationConfig {\n\treadonly wordSeparators: string;\n\treadonly wordSegmenterLocales: readonly string[];\n}\n\nexport const DEFAULT_WORD_NAVIGATION_CONFIG: WordNavigationConfig = {\n\twordSeparators: DEFAULT_WORD_SEPARATORS,\n\twordSegmenterLocales: [],\n};\n\nexport function isRegularWordCharacter(character: string | undefined, wordSeparators: string): boolean {\n\treturn character !== undefined\n\t\t&& !/\\s/u.test(character)\n\t\t&& !wordSeparators.includes(character);\n}\n\nconst enum WordCharacterClass {\n\tRegular,\n\tWhitespace,\n\tSeparator,\n}\n\nconst enum WordType {\n\tRegular,\n\tSeparator,\n}\n\ninterface WordSpan {\n\treadonly start: number;\n\treadonly end: number;\n\treadonly type: WordType;\n\treadonly nextClass: WordCharacterClass;\n}\n\ninterface IntlWordSpan {\n\treadonly index: number;\n\treadonly segment: string;\n}\n\nclass WordClassifier {\n\tprivate readonly _separators: ReadonlySet<string>;\n\tprivate readonly _segmenter: Intl.Segmenter | undefined;\n\tprivate _cachedLine: string | undefined;\n\tprivate _cachedWords: readonly IntlWordSpan[] = [];\n\n\tconstructor(config: WordNavigationConfig) {\n\t\tthis._separators = new Set(config.wordSeparators);\n\t\tthis._segmenter = createWordSegmenter(config.wordSegmenterLocales);\n\t}\n\n\tclassify(character: string | undefined): WordCharacterClass {\n\t\tif (character === undefined) {\n\t\t\treturn WordCharacterClass.Whitespace;\n\t\t}\n\t\tif (character === ' ' || character === '\\t') {\n\t\t\treturn WordCharacterClass.Whitespace;\n\t\t}\n\t\treturn this._separators.has(character)\n\t\t\t? WordCharacterClass.Separator\n\t\t\t: WordCharacterClass.Regular;\n\t}\n\n\tpreviousIntlWord(line: string, offset: number): IntlWordSpan | undefined {\n\t\tlet candidate: IntlWordSpan | undefined;\n\t\tfor (const word of this._intlWords(line)) {\n\t\t\tif (word.index > offset) { break; }\n\t\t\tcandidate = word;\n\t\t}\n\t\treturn candidate;\n\t}\n\n\tnextIntlWord(line: string, offset: number): IntlWordSpan | undefined {\n\t\treturn this._intlWords(line).find(word => word.index >= offset);\n\t}\n\n\tprivate _intlWords(line: string): readonly IntlWordSpan[] {\n\t\tif (!this._segmenter) { return []; }\n\t\tif (this._cachedLine === line) { return this._cachedWords; }\n\n\t\tconst words: IntlWordSpan[] = [];\n\t\tfor (const segment of this._segmenter.segment(line)) {\n\t\t\tif (segment.isWordLike) {\n\t\t\t\twords.push({ index: segment.index, segment: segment.segment });\n\t\t\t}\n\t\t}\n\t\tthis._cachedLine = line;\n\t\tthis._cachedWords = words;\n\t\treturn words;\n\t}\n}\n\nfunction createWordSegmenter(locales: readonly string[]): Intl.Segmenter | undefined {\n\tif (locales.length === 0) { return undefined; }\n\tconst supportedLocales: string[] = [];\n\tfor (const locale of locales as readonly unknown[]) {\n\t\tif (typeof locale !== 'string' || locale.length === 0) {\n\t\t\tconsole.warn('Ignoring invalid editor.wordSegmenterLocales entry', locale);\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tsupportedLocales.push(...Intl.Segmenter.supportedLocalesOf(locale));\n\t\t} catch (error) {\n\t\t\tconsole.warn(`Ignoring invalid editor.wordSegmenterLocales entry: ${locale}`, error);\n\t\t}\n\t}\n\tif (supportedLocales.length === 0) { return undefined; }\n\ttry {\n\t\treturn new Intl.Segmenter(supportedLocales, { granularity: 'word' });\n\t} catch (error) {\n\t\tconsole.warn(`Unable to initialize editor.wordSegmenterLocales: ${supportedLocales.join(', ')}`, error);\n\t\treturn undefined;\n\t}\n}\n\nconst classifierCache = new Map<string, WordClassifier>();\n\nfunction getClassifier(config: WordNavigationConfig): WordClassifier {\n\tconst key = `${config.wordSeparators}/${config.wordSegmenterLocales.join(',')}`;\n\tlet classifier = classifierCache.get(key);\n\tif (!classifier) {\n\t\tclassifier = new WordClassifier(config);\n\t\tclassifierCache.set(key, classifier);\n\t}\n\treturn classifier;\n}\n\nexport function findWordBoundaryLeft(\n\ttext: string,\n\toffset: number,\n\tconfig: WordNavigationConfig = DEFAULT_WORD_NAVIGATION_CONFIG,\n): number {\n\toffset = clamp(offset, 0, text.length);\n\tif (offset === 0) { return 0; }\n\n\tlet lineStart = text.lastIndexOf('\\n', offset - 1) + 1;\n\tlet lineEnd = text.indexOf('\\n', offset);\n\tif (lineEnd === -1) { lineEnd = text.length; }\n\tlet localOffset = offset - lineStart;\n\tif (localOffset === 0) {\n\t\tconst previousLineEnd = lineStart - 1;\n\t\tlineStart = previousLineEnd <= 0\n\t\t\t? 0\n\t\t\t: text.lastIndexOf('\\n', previousLineEnd - 1) + 1;\n\t\tlineEnd = previousLineEnd;\n\t\tlocalOffset = Math.max(0, previousLineEnd - lineStart);\n\t}\n\n\tconst line = text.slice(lineStart, lineEnd);\n\tconst classifier = getClassifier(config);\n\tlet previous = findPreviousWord(line, classifier, localOffset);\n\tif (\n\t\tprevious?.type === WordType.Separator\n\t\t&& previous.end - previous.start === 1\n\t\t&& previous.nextClass === WordCharacterClass.Regular\n\t) {\n\t\tprevious = findPreviousWord(line, classifier, previous.start);\n\t}\n\treturn lineStart + (previous?.start ?? 0);\n}\n\nexport function findWordBoundaryRight(\n\ttext: string,\n\toffset: number,\n\tconfig: WordNavigationConfig = DEFAULT_WORD_NAVIGATION_CONFIG,\n): number {\n\toffset = clamp(offset, 0, text.length);\n\tif (offset === text.length) { return text.length; }\n\n\tlet lineStart = text.lastIndexOf('\\n', offset - 1) + 1;\n\tlet lineEnd = text.indexOf('\\n', offset);\n\tif (lineEnd === -1) { lineEnd = text.length; }\n\tlet localOffset = offset - lineStart;\n\tif (offset === lineEnd && lineEnd < text.length) {\n\t\tlineStart = lineEnd + 1;\n\t\tlineEnd = text.indexOf('\\n', lineStart);\n\t\tif (lineEnd === -1) { lineEnd = text.length; }\n\t\tlocalOffset = 0;\n\t}\n\n\tconst line = text.slice(lineStart, lineEnd);\n\tconst classifier = getClassifier(config);\n\tlet next = findNextWord(line, classifier, localOffset);\n\tif (\n\t\tnext?.type === WordType.Separator\n\t\t&& next.end - next.start === 1\n\t\t&& next.nextClass === WordCharacterClass.Regular\n\t) {\n\t\tnext = findNextWord(line, classifier, next.end);\n\t}\n\treturn lineStart + (next?.end ?? line.length);\n}\n\nexport function findWordDeleteBoundaryLeft(\n\ttext: string,\n\toffset: number,\n\tconfig: WordNavigationConfig = DEFAULT_WORD_NAVIGATION_CONFIG,\n): number {\n\toffset = clamp(offset, 0, text.length);\n\tif (offset === 0) { return 0; }\n\n\tconst lineStart = offset === 0 ? 0 : text.lastIndexOf('\\n', offset - 1) + 1;\n\tconst localOffset = offset - lineStart;\n\tif (localOffset === 0) {\n\t\treturn offset - 1;\n\t}\n\n\tlet lastNonWhitespace = localOffset - 1;\n\twhile (\n\t\tlastNonWhitespace >= 0\n\t\t&& (text[lineStart + lastNonWhitespace] === ' ' || text[lineStart + lastNonWhitespace] === '\\t')\n\t) {\n\t\tlastNonWhitespace--;\n\t}\n\tif (lastNonWhitespace + 1 < localOffset - 1) {\n\t\treturn lineStart + lastNonWhitespace + 1;\n\t}\n\n\tlet lineEnd = text.indexOf('\\n', offset);\n\tif (lineEnd === -1) { lineEnd = text.length; }\n\tconst line = text.slice(lineStart, lineEnd);\n\tconst previous = findPreviousWord(line, getClassifier(config), localOffset);\n\treturn lineStart + (previous?.start ?? 0);\n}\n\nexport function findWordDeleteBoundaryRight(\n\ttext: string,\n\toffset: number,\n\tconfig: WordNavigationConfig = DEFAULT_WORD_NAVIGATION_CONFIG,\n): number {\n\toffset = clamp(offset, 0, text.length);\n\tif (offset === text.length) { return text.length; }\n\n\tconst lineStart = text.lastIndexOf('\\n', offset - 1) + 1;\n\tlet lineEnd = text.indexOf('\\n', offset);\n\tif (lineEnd === -1) { lineEnd = text.length; }\n\tconst localOffset = offset - lineStart;\n\tconst line = text.slice(lineStart, lineEnd);\n\n\tlet firstNonWhitespace = localOffset;\n\twhile (\n\t\tfirstNonWhitespace < line.length\n\t\t&& (line[firstNonWhitespace] === ' ' || line[firstNonWhitespace] === '\\t')\n\t) {\n\t\tfirstNonWhitespace++;\n\t}\n\tif (localOffset < firstNonWhitespace) {\n\t\treturn lineStart + firstNonWhitespace;\n\t}\n\n\tconst classifier = getClassifier(config);\n\tconst next = findNextWord(line, classifier, localOffset);\n\tif (next) {\n\t\treturn lineStart + next.end;\n\t}\n\tif (offset < lineEnd || lineEnd === text.length) {\n\t\treturn lineEnd;\n\t}\n\n\tconst nextLineStart = lineEnd + 1;\n\tlet nextLineEnd = text.indexOf('\\n', nextLineStart);\n\tif (nextLineEnd === -1) { nextLineEnd = text.length; }\n\tconst nextLine = text.slice(nextLineStart, nextLineEnd);\n\tconst nextLineWord = findNextWord(nextLine, classifier, 0);\n\treturn nextLineStart + (nextLineWord?.start ?? nextLine.length);\n}\n\nexport function findWordAt(\n\ttext: string,\n\toffset: number,\n\tconfig: WordNavigationConfig = DEFAULT_WORD_NAVIGATION_CONFIG,\n): { start: number; end: number } {\n\toffset = clamp(offset, 0, text.length);\n\tif (offset === text.length) {\n\t\treturn { start: offset, end: offset };\n\t}\n\n\tconst character = text[offset];\n\tif (/\\s/u.test(character)) {\n\t\tlet start = offset;\n\t\tlet end = offset + 1;\n\t\twhile (start > 0 && /\\s/u.test(text[start - 1])) { start--; }\n\t\twhile (end < text.length && /\\s/u.test(text[end])) { end++; }\n\t\treturn { start, end };\n\t}\n\n\tconst lineStart = text.lastIndexOf('\\n', offset - 1) + 1;\n\tlet lineEnd = text.indexOf('\\n', offset);\n\tif (lineEnd === -1) { lineEnd = text.length; }\n\tconst line = text.slice(lineStart, lineEnd);\n\tconst localOffset = offset - lineStart;\n\tconst classifier = getClassifier(config);\n\n\tconst intlWord = classifier.previousIntlWord(line, localOffset);\n\tif (intlWord && localOffset < intlWord.index + intlWord.segment.length) {\n\t\treturn {\n\t\t\tstart: lineStart + intlWord.index,\n\t\t\tend: lineStart + intlWord.index + intlWord.segment.length,\n\t\t};\n\t}\n\n\tconst characterClass = classifier.classify(character);\n\tlet start = localOffset;\n\tlet end = localOffset + 1;\n\twhile (start > 0 && classifier.classify(line[start - 1]) === characterClass) { start--; }\n\twhile (end < line.length && classifier.classify(line[end]) === characterClass) { end++; }\n\treturn { start: lineStart + start, end: lineStart + end };\n}\n\nfunction findPreviousWord(line: string, classifier: WordClassifier, offset: number): WordSpan | undefined {\n\tlet type: WordType | undefined;\n\tconst previousIntlWord = classifier.previousIntlWord(line, offset - 1);\n\n\tfor (let index = offset - 1; index >= 0; index--) {\n\t\tconst characterClass = classifier.classify(line[index]);\n\t\tif (previousIntlWord && index === previousIntlWord.index) {\n\t\t\treturn {\n\t\t\t\tstart: previousIntlWord.index,\n\t\t\t\tend: previousIntlWord.index + previousIntlWord.segment.length,\n\t\t\t\ttype: WordType.Regular,\n\t\t\t\tnextClass: characterClass,\n\t\t\t};\n\t\t}\n\n\t\tif (characterClass === WordCharacterClass.Regular) {\n\t\t\tif (type === WordType.Separator) {\n\t\t\t\tconst start = index + 1;\n\t\t\t\treturn { start, end: findWordEnd(line, classifier, type, start), type, nextClass: characterClass };\n\t\t\t}\n\t\t\ttype = WordType.Regular;\n\t\t} else if (characterClass === WordCharacterClass.Separator) {\n\t\t\tif (type === WordType.Regular) {\n\t\t\t\tconst start = index + 1;\n\t\t\t\treturn { start, end: findWordEnd(line, classifier, type, start), type, nextClass: characterClass };\n\t\t\t}\n\t\t\ttype = WordType.Separator;\n\t\t} else if (type !== undefined) {\n\t\t\tconst start = index + 1;\n\t\t\treturn { start, end: findWordEnd(line, classifier, type, start), type, nextClass: characterClass };\n\t\t}\n\t}\n\n\treturn type === undefined\n\t\t? undefined\n\t\t: { start: 0, end: findWordEnd(line, classifier, type, 0), type, nextClass: WordCharacterClass.Whitespace };\n}\n\nfunction findNextWord(line: string, classifier: WordClassifier, offset: number): WordSpan | undefined {\n\tlet type: WordType | undefined;\n\tconst nextIntlWord = classifier.nextIntlWord(line, offset);\n\n\tfor (let index = offset; index < line.length; index++) {\n\t\tconst characterClass = classifier.classify(line[index]);\n\t\tif (nextIntlWord && index === nextIntlWord.index) {\n\t\t\treturn {\n\t\t\t\tstart: nextIntlWord.index,\n\t\t\t\tend: nextIntlWord.index + nextIntlWord.segment.length,\n\t\t\t\ttype: WordType.Regular,\n\t\t\t\tnextClass: characterClass,\n\t\t\t};\n\t\t}\n\n\t\tif (characterClass === WordCharacterClass.Regular) {\n\t\t\tif (type === WordType.Separator) {\n\t\t\t\tconst end = index;\n\t\t\t\treturn { start: findWordStart(line, classifier, type, end - 1), end, type, nextClass: characterClass };\n\t\t\t}\n\t\t\ttype = WordType.Regular;\n\t\t} else if (characterClass === WordCharacterClass.Separator) {\n\t\t\tif (type === WordType.Regular) {\n\t\t\t\tconst end = index;\n\t\t\t\treturn { start: findWordStart(line, classifier, type, end - 1), end, type, nextClass: characterClass };\n\t\t\t}\n\t\t\ttype = WordType.Separator;\n\t\t} else if (type !== undefined) {\n\t\t\tconst end = index;\n\t\t\treturn { start: findWordStart(line, classifier, type, end - 1), end, type, nextClass: characterClass };\n\t\t}\n\t}\n\n\treturn type === undefined\n\t\t? undefined\n\t\t: {\n\t\t\tstart: findWordStart(line, classifier, type, line.length - 1),\n\t\t\tend: line.length,\n\t\t\ttype,\n\t\t\tnextClass: WordCharacterClass.Whitespace,\n\t\t};\n}\n\nfunction findWordEnd(line: string, classifier: WordClassifier, type: WordType, start: number): number {\n\tconst nextIntlWord = classifier.nextIntlWord(line, start);\n\tfor (let index = start; index < line.length; index++) {\n\t\tif (nextIntlWord && index === nextIntlWord.index + nextIntlWord.segment.length) {\n\t\t\treturn index;\n\t\t}\n\t\tconst characterClass = classifier.classify(line[index]);\n\t\tif (\n\t\t\tcharacterClass === WordCharacterClass.Whitespace\n\t\t\t|| (type === WordType.Regular && characterClass === WordCharacterClass.Separator)\n\t\t\t|| (type === WordType.Separator && characterClass === WordCharacterClass.Regular)\n\t\t) {\n\t\t\treturn index;\n\t\t}\n\t}\n\treturn line.length;\n}\n\nfunction findWordStart(line: string, classifier: WordClassifier, type: WordType, start: number): number {\n\tconst previousIntlWord = classifier.previousIntlWord(line, start);\n\tfor (let index = start; index >= 0; index--) {\n\t\tif (previousIntlWord && index === previousIntlWord.index) {\n\t\t\treturn index;\n\t\t}\n\t\tconst characterClass = classifier.classify(line[index]);\n\t\tif (\n\t\t\tcharacterClass === WordCharacterClass.Whitespace\n\t\t\t|| (type === WordType.Regular && characterClass === WordCharacterClass.Separator)\n\t\t\t|| (type === WordType.Separator && characterClass === WordCharacterClass.Regular)\n\t\t) {\n\t\t\treturn index + 1;\n\t\t}\n\t}\n\treturn 0;\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n\treturn Math.min(Math.max(value, min), max);\n}\n"],"names":["DEFAULT_WORD_SEPARATORS","DEFAULT_WORD_NAVIGATION_CONFIG","isRegularWordCharacter","character","wordSeparators","WordClassifier","config","createWordSegmenter","line","offset","candidate","word","words","segment","locales","supportedLocales","locale","error","classifierCache","getClassifier","key","classifier","findWordBoundaryLeft","text","clamp","lineStart","lineEnd","localOffset","previousLineEnd","previous","findPreviousWord","findWordBoundaryRight","next","findNextWord","findWordDeleteBoundaryLeft","lastNonWhitespace","findWordDeleteBoundaryRight","firstNonWhitespace","nextLineStart","nextLineEnd","nextLine","nextLineWord","findWordAt","start","end","intlWord","characterClass","type","previousIntlWord","index","findWordEnd","nextIntlWord","findWordStart","value","min","max"],"mappings":"AAAO,MAAMA,IAA0B,qCAO1BC,IAAuD;AAAA,EACnE,gBAAgBD;AAAA,EAChB,sBAAsB,CAAA;AACvB;AAEO,SAASE,EAAuBC,GAA+BC,GAAiC;AACtG,SAAOD,MAAc,UACjB,CAAC,MAAM,KAAKA,CAAS,KACrB,CAACC,EAAe,SAASD,CAAS;AACvC;AAyBA,MAAME,EAAe;AAAA,EACH;AAAA,EACA;AAAA,EACT;AAAA,EACA,e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AAc5C,GAAMa,GAAY0B,GAAMvC,EAAK,SAAS,CAAC;AAAA,IAC5D,KAAKA,EAAK;AAAA,IACV,MAAAuC;AAAA,IACA,WAAW;AAAA;AAAA,EAAA;AAEd;AAEA,SAASG,EAAY1C,GAAca,GAA4B0B,GAAgBJ,GAAuB;AACrG,QAAMQ,IAAe9B,EAAW,aAAab,GAAMmC,CAAK;AACxD,WAASM,IAAQN,GAAOM,IAAQzC,EAAK,QAAQyC,KAAS;AACrD,QAAIE,KAAgBF,MAAUE,EAAa,QAAQA,EAAa,QAAQ;AACvE,aAAOF;AAER,UAAMH,IAAiBzB,EAAW,SAASb,EAAKyC,CAAK,CAAC;AACtD,QACCH,MAAmB,KACfC,MAAS,KAAoBD,MAAmB,KAChDC,MAAS,KAAsBD,MAAmB;AAEtD,aAAOG;AAAA,EAET;AACA,SAAOzC,EAAK;AACb;AAEA,SAAS4C,EAAc5C,GAAca,GAA4B0B,GAAgBJ,GAAuB;AACvG,QAAMK,IAAmB3B,EAAW,iBAAiBb,GAAMmC,CAAK;AAChE,WAASM,IAAQN,GAAOM,KAAS,GAAGA,KAAS;AAC5C,QAAID,KAAoBC,MAAUD,EAAiB;AAClD,aAAOC;AAER,UAAMH,IAAiBzB,EAAW,SAASb,EAAKyC,CAAK,CAAC;AACtD,QACCH,MAAmB,KACfC,MAAS,KAAoBD,MAAmB,KAChDC,MAAS,KAAsBD,MAAmB;AAEtD,aAAOG,IAAQ;AAAA,EAEjB;AACA,SAAO;AACR;AAEA,SAASzB,EAAM6B,GAAeC,GAAaC,GAAqB;AAC/D,SAAO,KAAK,IAAI,KAAK,IAAIF,GAAOC,CAAG,GAAGC,CAAG;AAC1C;"}
package/dist/config.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D as O, e as _ } from "./config-Dvgk17FF.js";
1
+ import { D as O, e as _ } from "./config-BGeaJqWk.js";
2
2
  export {
3
3
  O as DEFAULT_WORD_NAVIGATION_CONFIG,
4
4
  _ as DEFAULT_WORD_SEPARATORS
package/dist/index.d.ts CHANGED
@@ -154,6 +154,13 @@ declare class BlockQuoteViewData {
154
154
  constructor(ast: BlockQuoteAstNode, content: readonly AnyViewData[]);
155
155
  }
156
156
 
157
+ /**
158
+ * All blocks whose source range intersects `[start, endExclusive]`. A
159
+ * collapsed range (start === endExclusive) matches the block containing
160
+ * that offset (with the same boundary rule as {@link findBlockAtOffset}).
161
+ */
162
+ export declare function blocksIntersecting(doc: DocumentAstNode, start: SourceOffset, endExclusive: SourceOffset): BlockAstNode[];
163
+
157
164
  declare type BlockViewData = HeadingViewData | ParagraphViewData | FrontMatterViewData | CodeBlockViewData | MathBlockViewData | ThematicBreakViewData | BlockQuoteViewData | ListViewData | TableViewData | UnhandledBlockViewData;
158
165
 
159
166
  /**
@@ -405,9 +412,10 @@ export declare interface CommentInputWidgetOptions {
405
412
  *
406
413
  * Behaviour:
407
414
  * - Only active in read-only mode (the "review" view).
408
- * - When the selection is non-empty, the input box appears next to the caret
409
- * (the selection's active end) but does NOT take focus, so keyboard selection
410
- * keeps working. Press Tab to move focus into the box, then type.
415
+ * - When a user-created selection is non-empty, the input box appears next to
416
+ * the caret (the selection's active end) but does NOT take focus, so keyboard
417
+ * selection keeps working. Programmatic selections such as find matches do
418
+ * not summon it. Press Tab to move focus into the box, then type.
411
419
  * - The box appears on mouse-up, not mid-drag, so it doesn't flicker/jump
412
420
  * while a selection is being dragged out (keyboard selection shows at once).
413
421
  * - While the box has focus or holds a draft it is frozen in place (selection
@@ -421,6 +429,7 @@ export declare class CommentModeController extends Disposable {
421
429
  private readonly _model;
422
430
  private readonly _view;
423
431
  private readonly _options?;
432
+ private static _isCommentableSelectionSource;
424
433
  private readonly _widget;
425
434
  private readonly _gap;
426
435
  private _visible;
@@ -872,6 +881,7 @@ export declare type EditKeyboardAction = 'deleteLeft' | 'deleteRight' | 'deleteW
872
881
  export declare class EditorController extends Disposable {
873
882
  private readonly _model;
874
883
  private readonly _view;
884
+ readonly findController: FindController | undefined;
875
885
  private _desiredColumn;
876
886
  private readonly _keyboardPlatform;
877
887
  private readonly _keyboardProfile;
@@ -889,6 +899,7 @@ export declare class EditorController extends Disposable {
889
899
  private _executeEditCommand;
890
900
  private _runUndoableEdit;
891
901
  private _executeVisualCursorCommand;
902
+ private _setUserSelection;
892
903
  /** Move the cursor down one visual line (Arrow Down). */
893
904
  cursorDown(extend?: boolean): void;
894
905
  /** Move the cursor up one visual line (Arrow Up). */
@@ -940,6 +951,7 @@ export declare interface EditorControllerOptions {
940
951
  readonly historyStrategy?: IHistoryStrategy;
941
952
  readonly keyboardPlatform?: KeyboardPlatform;
942
953
  readonly keyboardProfile?: KeyboardProfile;
954
+ readonly find?: false;
943
955
  }
944
956
 
945
957
  /**
@@ -989,6 +1001,9 @@ export declare type EditorKeyboardAction = {
989
1001
 
990
1002
  export declare class EditorModel {
991
1003
  private readonly _parser;
1004
+ private readonly _sourceEditListeners;
1005
+ private readonly _sourceTextIds;
1006
+ private _lastSourceTextId;
992
1007
  /**
993
1008
  * The most recent edit applied to {@link sourceText}, used by
994
1009
  * {@link document} to let the parser link incrementally edited code
@@ -1013,6 +1028,7 @@ export declare class EditorModel {
1013
1028
  * (e.g. an inactive/unfocused rendering).
1014
1029
  */
1015
1030
  readonly selection: ISettableObservable<Selection_2 | undefined, void>;
1031
+ readonly selectionSource: ISettableObservable<SelectionSource, void>;
1016
1032
  /**
1017
1033
  * Whether a Ctrl/Cmd modifier is currently held. Set by the controller from
1018
1034
  * live keyboard state; the view reads it to show the link-open affordance
@@ -1093,6 +1109,9 @@ export declare class EditorModel {
1093
1109
  changedBlocks: Set<BlockAstNode>;
1094
1110
  } | undefined, void>;
1095
1111
  readonly markerVisibleBlocks: IObservableWithChange<Set<BlockAstNode>, void>;
1112
+ onWillApplySourceEdit(listener: (event: SourceEditEvent) => void): IDisposable;
1113
+ /** Returns a stable per-object identity without retaining the source text. */
1114
+ getSourceTextId(sourceText: StringValue): number;
1096
1115
  /**
1097
1116
  * Arm a {@link PendingParagraph} at the given gap, minting a fresh synthetic
1098
1117
  * AST node for it, and park the caret at the gap start. No source edit is
@@ -1119,8 +1138,13 @@ export declare class EditorModel {
1119
1138
  materializePendingParagraph(text: string): void;
1120
1139
  applyEdit(edit: StringEdit, selection?: Selection_2): void;
1121
1140
  applyEditForSelection(edit: StringEdit): void;
1141
+ private _applySourceEdit;
1142
+ private _identifySourceEdit;
1143
+ private _emitWillApplySourceEdit;
1122
1144
  }
1123
1145
 
1146
+ export declare type EditorOverlayPosition = 'top-chrome' | 'below-selection' | 'above-decorations';
1147
+
1124
1148
  /**
1125
1149
  * Pure-render view of an {@link EditorModel}.
1126
1150
  *
@@ -1151,6 +1175,7 @@ export declare class EditorView extends Disposable {
1151
1175
  readonly editContext: EditContext;
1152
1176
  readonly measuredLayout: MeasuredLayoutModel;
1153
1177
  readonly coordinateSpace: EditorCoordinateSpace;
1178
+ readonly forcedMarkerVisibleBlocks: ISettableObservable<ReadonlySet<BlockAstNode>, void>;
1154
1179
  /**
1155
1180
  * Inner container that holds the rendered document and the cursor/selection
1156
1181
  * overlays. The outer {@link element} spans the full width; this container
@@ -1163,6 +1188,8 @@ export declare class EditorView extends Disposable {
1163
1188
  private readonly _gutterMarkersView;
1164
1189
  private readonly _diffHighlightsView;
1165
1190
  private _readonlyToggleButton;
1191
+ private readonly _editContextSuspensions;
1192
+ private readonly _revealOcclusions;
1166
1193
  /**
1167
1194
  * The mounted block sequence, in source order. Rebuilt (not mutated) each
1168
1195
  * frame by {@link DocumentViewNode.create}; the view just swaps one
@@ -1259,6 +1286,17 @@ export declare class EditorView extends Disposable {
1259
1286
  /** Draws attention to the mode toggle after text input is attempted while locked. */
1260
1287
  showReadonlyEditingAttempt(): void;
1261
1288
  focus(): void;
1289
+ mountOverlay(element: HTMLElement | SVGSVGElement, position: EditorOverlayPosition): IDisposable;
1290
+ /** Registers floating editor chrome that should count as covering a range during reveal. */
1291
+ registerRevealOcclusion(element: Element): IDisposable;
1292
+ /**
1293
+ * Temporarily detaches the root {@link EditContext} while focus is inside
1294
+ * nested editor chrome. Chromium otherwise reclaims focus from non-text
1295
+ * controls inside the EditContext host, breaking keyboard access to controls
1296
+ * such as the find actions and read-only toggle.
1297
+ */
1298
+ suspendEditContextWhileFocused(element: HTMLElement): IDisposable;
1299
+ revealRangeInCenterIfOutsideViewport(range: OffsetRange, behavior?: ScrollBehavior): IDisposable;
1262
1300
  /**
1263
1301
  * Samples the ambient focus state that decides whether taking focus on open
1264
1302
  * would steal it from an explicit user target: whether the window is focused
@@ -1345,6 +1383,9 @@ export declare class EditorView extends Disposable {
1345
1383
  */
1346
1384
  private _paintDiff;
1347
1385
  private _clearDiff;
1386
+ private _syncEditContextAttachment;
1387
+ private _revealRange;
1388
+ private _isRevealOccluded;
1348
1389
  }
1349
1390
 
1350
1391
  export declare interface EditorViewOptions extends BlockViewOptions {
@@ -1398,6 +1439,111 @@ declare class EmphasisViewData {
1398
1439
  constructor(ast: EmphasisAstNode, content: readonly AnyViewData[]);
1399
1440
  }
1400
1441
 
1442
+ export declare function escapeFindRegex(value: string): string;
1443
+
1444
+ export declare const FIND_MATCH_LIMIT = 19999;
1445
+
1446
+ export declare function findBlockAtOffset(doc: DocumentAstNode, offset: SourceOffset): BlockAstNode | undefined;
1447
+
1448
+ export declare class FindController extends Disposable {
1449
+ private readonly _editorModel;
1450
+ private readonly _view;
1451
+ private readonly _options;
1452
+ readonly model: FindModel;
1453
+ readonly widget: FindWidget;
1454
+ private readonly _selectionForScope;
1455
+ private _forcedMatch;
1456
+ private _selectedMatch;
1457
+ private _observedSourceTextId;
1458
+ private readonly _sourceEditTracker;
1459
+ private _revealRequest;
1460
+ constructor(_editorModel: EditorModel, _view: EditorView, _options: FindControllerOptions);
1461
+ private _setForcedMarkerVisibleBlocks;
1462
+ openAndFocus(): void;
1463
+ close(): void;
1464
+ private _handleKeyDown;
1465
+ private _cancelRevealRequest;
1466
+ private _findByKeyboard;
1467
+ private _querySeed;
1468
+ private _prepareSeed;
1469
+ private _selectedSingleLineText;
1470
+ private _toggleFindInSelection;
1471
+ }
1472
+
1473
+ export declare interface FindControllerOptions {
1474
+ readonly keyboardPlatform: KeyboardPlatform;
1475
+ }
1476
+
1477
+ export declare type FindDirection = 'next' | 'previous';
1478
+
1479
+ export declare class FindHighlightsView extends Disposable {
1480
+ private readonly _view;
1481
+ private readonly _matchesLayer;
1482
+ private readonly _currentLayer;
1483
+ private readonly _highlightRegistration;
1484
+ private readonly _resizeObserver;
1485
+ private readonly _resizeObservedElements;
1486
+ private _snapshot;
1487
+ private _paintRaf;
1488
+ constructor(_view: EditorView, findModel: FindModel);
1489
+ private _schedulePaint;
1490
+ private _paint;
1491
+ private _observeResizeAncestors;
1492
+ private _paintRanges;
1493
+ }
1494
+
1495
+ export declare interface FindMatchesResult {
1496
+ readonly matches: readonly OffsetRange[];
1497
+ readonly isCapped: boolean;
1498
+ }
1499
+
1500
+ export declare class FindModel extends Disposable {
1501
+ private readonly _editorModel;
1502
+ readonly isRevealed: ISettableObservable<boolean, void>;
1503
+ readonly searchString: ISettableObservable<string, void>;
1504
+ readonly isRegex: ISettableObservable<boolean, void>;
1505
+ readonly matchCase: ISettableObservable<boolean, void>;
1506
+ readonly wholeWord: ISettableObservable<boolean, void>;
1507
+ readonly searchScope: ISettableObservable<OffsetRange | undefined, void>;
1508
+ readonly currentMatch: ISettableObservable<OffsetRange | undefined, void>;
1509
+ readonly loop: ISettableObservable<boolean, void>;
1510
+ readonly searchResult: IObservableWithChange< {
1511
+ kind: "invalid";
1512
+ error: Error;
1513
+ pattern?: undefined;
1514
+ matches?: undefined;
1515
+ isCapped?: undefined;
1516
+ } | {
1517
+ kind: "valid";
1518
+ pattern: FindPattern;
1519
+ matches: readonly OffsetRange[];
1520
+ isCapped: boolean;
1521
+ error?: undefined;
1522
+ }, void>;
1523
+ readonly matchesCount: IObservableWithChange<number, void>;
1524
+ readonly isCapped: IObservableWithChange<boolean, void>;
1525
+ readonly currentMatchPosition: IObservableWithChange<number, void>;
1526
+ private _searchOrigin;
1527
+ private readonly _sourceEditTracker;
1528
+ private _pendingInitialDirection;
1529
+ constructor(_editorModel: EditorModel);
1530
+ reveal(options: {
1531
+ readonly origin: number;
1532
+ readonly searchString?: string;
1533
+ readonly direction?: FindDirection;
1534
+ }): void;
1535
+ hide(): void;
1536
+ setSearchOrigin(offset: number): void;
1537
+ setSearchScope(scope: OffsetRange | undefined): void;
1538
+ moveToNextMatch(): OffsetRange | undefined;
1539
+ moveToPreviousMatch(): OffsetRange | undefined;
1540
+ private _move;
1541
+ private _selectFromOrigin;
1542
+ private _mapStateThroughEdit;
1543
+ private _inputSnapshot;
1544
+ private _readInputSnapshot;
1545
+ }
1546
+
1401
1547
  /**
1402
1548
  * Source offset (relative to `root`) of the node with `target`'s id, or
1403
1549
  * `undefined` when it is not in the tree. Ids are stable across edits, so this
@@ -1405,6 +1551,77 @@ declare class EmphasisViewData {
1405
1551
  */
1406
1552
  export declare function findNodeOffsetById(root: AstNode, target: AstNode): number | undefined;
1407
1553
 
1554
+ export declare class FindPattern {
1555
+ private readonly _source;
1556
+ private readonly _flags;
1557
+ private readonly _wholeWord;
1558
+ private readonly _wordSeparators;
1559
+ readonly isEmpty: boolean;
1560
+ private constructor();
1561
+ static create(query: FindQuery): FindQueryResult;
1562
+ findMatches(text: string, scope?: OffsetRange, limit?: number): FindMatchesResult;
1563
+ findNextMatch(text: string, after: number, scope?: OffsetRange, loop?: boolean, skip?: OffsetRange): OffsetRange | undefined;
1564
+ findPreviousMatch(text: string, before: number, scope?: OffsetRange, loop?: boolean, skip?: OffsetRange): OffsetRange | undefined;
1565
+ private _forEachMatch;
1566
+ }
1567
+
1568
+ export declare interface FindQuery {
1569
+ readonly searchString: string;
1570
+ readonly isRegex: boolean;
1571
+ readonly matchCase: boolean;
1572
+ readonly wholeWord: boolean;
1573
+ readonly wordSeparators: string;
1574
+ }
1575
+
1576
+ export declare type FindQueryResult = {
1577
+ readonly kind: 'valid';
1578
+ readonly pattern: FindPattern;
1579
+ } | {
1580
+ readonly kind: 'invalid';
1581
+ readonly error: Error;
1582
+ };
1583
+
1584
+ export declare type FindSearchResult = {
1585
+ readonly kind: 'valid';
1586
+ readonly pattern: FindPattern;
1587
+ readonly matches: readonly OffsetRange[];
1588
+ readonly isCapped: boolean;
1589
+ } | {
1590
+ readonly kind: 'invalid';
1591
+ readonly error: Error;
1592
+ };
1593
+
1594
+ export declare class FindWidget extends Disposable {
1595
+ private readonly _view;
1596
+ private readonly _options;
1597
+ readonly element: HTMLElement;
1598
+ readonly panelElement: HTMLElement;
1599
+ readonly focused: ISettableObservable<boolean, void>;
1600
+ private readonly _inputShell;
1601
+ private readonly _input;
1602
+ private readonly _matchesCount;
1603
+ private readonly _previousButton;
1604
+ private readonly _nextButton;
1605
+ private readonly _selectionButton;
1606
+ private readonly _caseButton;
1607
+ private readonly _wholeWordButton;
1608
+ private readonly _regexButton;
1609
+ private readonly _error;
1610
+ constructor(_view: EditorView, _options: FindWidgetOptions);
1611
+ focusAndSelect(): void;
1612
+ private _registerButton;
1613
+ private _render;
1614
+ }
1615
+
1616
+ export declare interface FindWidgetOptions {
1617
+ readonly findModel: FindModel;
1618
+ readonly canFindInSelection: IObservable<boolean>;
1619
+ readonly onNext: () => void;
1620
+ readonly onPrevious: () => void;
1621
+ readonly onToggleFindInSelection: () => void;
1622
+ readonly onClose: () => void;
1623
+ }
1624
+
1408
1625
  export declare function findWordAt(text: string, offset: number, config?: WordNavigationConfig): {
1409
1626
  start: number;
1410
1627
  end: number;
@@ -2353,6 +2570,9 @@ export declare interface SelectionRect {
2353
2570
  readonly height: number;
2354
2571
  }
2355
2572
 
2573
+ /** The interaction that produced the current editor selection. */
2574
+ export declare type SelectionSource = 'user' | 'find';
2575
+
2356
2576
  /**
2357
2577
  * Owns the SVG overlay that paints the selection.
2358
2578
  *
@@ -2424,6 +2644,14 @@ export declare interface SnapshotTokens {
2424
2644
  readonly tokens: readonly Token[];
2425
2645
  }
2426
2646
 
2647
+ /** Metadata delivered synchronously immediately before a model-owned source edit is applied. */
2648
+ export declare interface SourceEditEvent {
2649
+ readonly baseSourceTextId: number;
2650
+ readonly resultSourceTextId: number;
2651
+ readonly edit: StringEdit;
2652
+ readonly transaction: ITransaction;
2653
+ }
2654
+
2427
2655
  export declare type SourceOffset = number;
2428
2656
 
2429
2657
  export declare abstract class StackedCommentsPresenter extends Disposable implements ICommentsPresenter {