@adecore/editor 0.62.0 → 0.63.0-untangle.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/dist/attribution.js +0 -1
- package/dist/bidi.js +0 -1
- package/dist/column-selection.d.ts +0 -1
- package/dist/column-selection.js +1 -1
- package/dist/controller.d.ts +4 -2
- package/dist/controller.js +0 -5
- package/dist/engine.js +0 -3
- package/dist/fake.d.ts +3 -0
- package/dist/fake.js +29 -24
- package/dist/find.d.ts +3 -2
- package/dist/find.js +0 -2
- package/dist/geometry-stops.d.ts +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/keymap-table.d.ts +8 -1
- package/dist/keymap-table.js +0 -1
- package/dist/keymap.d.ts +2 -1
- package/dist/layout-changes.d.ts +2 -1
- package/dist/layout.d.ts +3 -57
- package/dist/layout.js +1 -6
- package/dist/line-geometry.d.ts +55 -0
- package/dist/line-geometry.js +1 -0
- package/dist/metrics.d.ts +1 -1
- package/dist/modifier-gesture.d.ts +2 -1
- package/dist/modifier-gesture.js +0 -1
- package/dist/native-input.d.ts +2 -1
- package/dist/outline.d.ts +3 -3
- package/dist/outline.js +0 -1
- package/dist/overview.d.ts +3 -2
- package/dist/paint.d.ts +5 -5
- package/dist/paint.js +3 -4
- package/dist/php-html.d.ts +0 -6
- package/dist/php-html.js +2 -2
- package/dist/pointer.d.ts +2 -1
- package/dist/scroll-animation.d.ts +0 -1
- package/dist/scroll-animation.js +1 -1
- package/dist/scroll.js +0 -1
- package/dist/search-client.d.ts +2 -2
- package/dist/shiki-document.js +1 -1
- package/dist/shiki-grammar.d.ts +7 -0
- package/dist/shiki-grammar.js +168 -0
- package/dist/shiki-worker.js +1 -1
- package/dist/shiki.d.ts +1 -7
- package/dist/shiki.js +1 -168
- package/dist/smart-keys.js +0 -1
- package/dist/testing.js +0 -2
- package/dist/todos.d.ts +2 -1
- package/dist/tokens.d.ts +2 -1
- package/dist/tokens.js +0 -1
- package/dist/touch.d.ts +2 -1
- package/dist/types.d.ts +5 -13
- package/dist/uniform-geometry.d.ts +1 -1
- package/dist/view.d.ts +12 -10
- package/dist/view.js +61 -38
- package/dist/zoom.d.ts +0 -2
- package/dist/zoom.js +2 -2
- package/package.json +8 -3
- package/src/attribution.ts +0 -1
- package/src/bidi.ts +0 -1
- package/src/column-selection.ts +1 -1
- package/src/controller.ts +3 -9
- package/src/engine.ts +0 -3
- package/src/fake.ts +38 -24
- package/src/find.ts +2 -4
- package/src/geometry-stops.ts +1 -1
- package/src/index.ts +2 -2
- package/src/keymap-table.ts +10 -3
- package/src/keymap.ts +2 -1
- package/src/layout-changes.ts +1 -1
- package/src/layout.ts +4 -81
- package/src/line-geometry.ts +69 -0
- package/src/metrics.ts +1 -1
- package/src/modifier-gesture.ts +1 -2
- package/src/native-input.ts +1 -1
- package/src/outline.ts +3 -5
- package/src/overview.ts +2 -2
- package/src/paint.ts +5 -11
- package/src/php-html.ts +2 -2
- package/src/pointer.ts +1 -4
- package/src/scroll-animation.ts +1 -1
- package/src/scroll.ts +0 -2
- package/src/search-client.ts +2 -2
- package/src/shiki-document.ts +1 -1
- package/src/shiki-grammar.ts +223 -0
- package/src/shiki-worker.ts +1 -1
- package/src/shiki.ts +1 -224
- package/src/smart-keys.ts +0 -1
- package/src/testing.ts +0 -2
- package/src/todos.ts +1 -1
- package/src/tokens.ts +1 -2
- package/src/touch.ts +1 -1
- package/src/types.ts +9 -22
- package/src/uniform-geometry.ts +1 -1
- package/src/view.ts +89 -56
- package/src/zoom.ts +2 -2
package/dist/tokens.js
CHANGED
|
@@ -175,7 +175,6 @@ export class TokenCache {
|
|
|
175
175
|
this.reusableFrom = Number.POSITIVE_INFINITY;
|
|
176
176
|
this.pivotLine = -1;
|
|
177
177
|
}
|
|
178
|
-
/* Whether lines through `line` are colored for the text as it is now. */
|
|
179
178
|
covers(line) {
|
|
180
179
|
return this.frontier > line || this.frontier >= this.source.getLineCount();
|
|
181
180
|
}
|
package/dist/touch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DocumentModel } from '@adecore/editor-core';
|
|
2
|
-
|
|
2
|
+
interface TouchHost {
|
|
3
3
|
readonly model: DocumentModel;
|
|
4
4
|
offsetAt(clientX: number, clientY: number): number;
|
|
5
5
|
camelHumps(): boolean;
|
|
@@ -25,3 +25,4 @@ export declare class TouchSelection {
|
|
|
25
25
|
private clearTimer;
|
|
26
26
|
private cancel;
|
|
27
27
|
}
|
|
28
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { EditorCommand, FoldRole, TextPlaceKind, UnwrapKind, WhitespaceCleanupOptions } from '@adecore/editor-core';
|
|
2
|
-
import type { Keymap } from './keymap-table.ts';
|
|
3
|
-
import type { EditorSearchClientOptions } from './search-client.ts';
|
|
2
|
+
import type { KeyChord, Keymap } from './keymap-table.ts';
|
|
4
3
|
export type { EditorCommand, FoldRole };
|
|
5
4
|
export type EditorWhitespaceCleanup = WhitespaceCleanupOptions;
|
|
6
5
|
export type EditorFoldOutline = 'off' | 'hover' | 'always';
|
|
@@ -242,7 +241,7 @@ export interface EditorReplacement {
|
|
|
242
241
|
export interface EditorLineAction {
|
|
243
242
|
readonly id: string;
|
|
244
243
|
readonly line: number;
|
|
245
|
-
render(container: HTMLElement): void;
|
|
244
|
+
render(container: HTMLElement): (() => void) | void;
|
|
246
245
|
}
|
|
247
246
|
export interface EditorCodeVisionEntry {
|
|
248
247
|
readonly id: string;
|
|
@@ -297,7 +296,7 @@ export type EditorInlayClickHandler = (click: EditorInlayClick) => boolean;
|
|
|
297
296
|
export interface EditorGhostText {
|
|
298
297
|
readonly position: EditorPosition;
|
|
299
298
|
readonly text: string;
|
|
300
|
-
readonly accessory?: (container: HTMLElement) => void;
|
|
299
|
+
readonly accessory?: (container: HTMLElement) => (() => void) | void;
|
|
301
300
|
}
|
|
302
301
|
export interface EditorGutterAction {
|
|
303
302
|
readonly line: number;
|
|
@@ -316,6 +315,7 @@ export interface EditorIndentation {
|
|
|
316
315
|
readonly tabSize: number;
|
|
317
316
|
readonly insertSpaces: boolean;
|
|
318
317
|
}
|
|
318
|
+
export type EditorSearchWorkerFactory = () => Pick<Worker, 'addEventListener' | 'removeEventListener' | 'postMessage' | 'terminate'>;
|
|
319
319
|
export interface EditorFindQuery {
|
|
320
320
|
readonly text: string;
|
|
321
321
|
readonly caseSensitive: boolean;
|
|
@@ -461,14 +461,6 @@ export interface Editor {
|
|
|
461
461
|
export interface EditorEngine {
|
|
462
462
|
mount(element: HTMLElement, options: EditorOptions): Editor;
|
|
463
463
|
}
|
|
464
|
-
export interface KeyChord {
|
|
465
|
-
readonly mod: boolean;
|
|
466
|
-
readonly ctrl: boolean;
|
|
467
|
-
readonly meta: boolean;
|
|
468
|
-
readonly alt: boolean;
|
|
469
|
-
readonly shift: boolean;
|
|
470
|
-
readonly key: string;
|
|
471
|
-
}
|
|
472
464
|
export interface LineToken {
|
|
473
465
|
readonly length: number;
|
|
474
466
|
readonly color: string;
|
|
@@ -488,7 +480,7 @@ export interface LineTokenizer {
|
|
|
488
480
|
}
|
|
489
481
|
export type TokenizerSource = (language: string | undefined, theme: EditorTheme, text?: string) => Promise<LineTokenizer | null>;
|
|
490
482
|
export interface SmartEditorEngineOptions {
|
|
491
|
-
readonly searchWorker?:
|
|
483
|
+
readonly searchWorker?: EditorSearchWorkerFactory;
|
|
492
484
|
readonly keymap?: Keymap | (() => Keymap);
|
|
493
485
|
readonly tokenizer: TokenizerSource;
|
|
494
486
|
readonly scopeColors?: ScopeColorSource;
|
package/dist/view.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type DocumentModel, type FoldHints, type FoldRole, type FoldingRange, type Selection as EditorSelection } from '@adecore/editor-core';
|
|
2
2
|
import { FindController } from './find.ts';
|
|
3
|
-
import { type BlockReplacement, type BlockWidget, EditorLayout
|
|
3
|
+
import { type BlockReplacement, type BlockWidget, EditorLayout } from './layout.ts';
|
|
4
|
+
import { type Inlay } from './line-geometry.ts';
|
|
4
5
|
import { type ScrollKind } from './scroll.ts';
|
|
5
6
|
import { type EditorSearchClientOptions } from './search-client.ts';
|
|
6
7
|
import { TokenCache } from './tokens.ts';
|
|
@@ -24,28 +25,26 @@ export interface ViewSettings {
|
|
|
24
25
|
stickyScroll?: boolean;
|
|
25
26
|
todoWords?: readonly string[];
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
export interface Occurrence {
|
|
28
|
+
type HostMount = (container: HTMLElement) => (() => void) | void;
|
|
29
|
+
interface Occurrence {
|
|
31
30
|
from: number;
|
|
32
31
|
to: number;
|
|
33
32
|
kind?: EditorHighlightKind;
|
|
34
33
|
}
|
|
35
|
-
|
|
34
|
+
interface ViewSemanticToken {
|
|
36
35
|
from: number;
|
|
37
36
|
to: number;
|
|
38
37
|
scopes: readonly string[];
|
|
39
38
|
within?: LineTokenKind;
|
|
40
39
|
}
|
|
41
|
-
|
|
40
|
+
interface GutterMarker {
|
|
42
41
|
id: string;
|
|
43
42
|
line: number;
|
|
44
43
|
label: string;
|
|
45
44
|
icon?: EditorGutterIcon;
|
|
46
45
|
pressed?: boolean;
|
|
47
46
|
}
|
|
48
|
-
|
|
47
|
+
interface ViewMarker {
|
|
49
48
|
severity: EditorMarkerSeverity;
|
|
50
49
|
from: number;
|
|
51
50
|
to: number;
|
|
@@ -241,7 +240,7 @@ export declare class EditorView {
|
|
|
241
240
|
setGhost(ghost: {
|
|
242
241
|
at: number;
|
|
243
242
|
text: string;
|
|
244
|
-
accessory:
|
|
243
|
+
accessory: HostMount | undefined;
|
|
245
244
|
} | null): void;
|
|
246
245
|
private layoutGhostParts;
|
|
247
246
|
private configureText;
|
|
@@ -416,9 +415,11 @@ export declare class EditorView {
|
|
|
416
415
|
setLineActions(owner: string, actions: readonly {
|
|
417
416
|
id: string;
|
|
418
417
|
at: number;
|
|
419
|
-
render:
|
|
418
|
+
render: HostMount;
|
|
420
419
|
}[]): void;
|
|
420
|
+
private removeActionElement;
|
|
421
421
|
private paintLineActions;
|
|
422
|
+
private paintOwnerActions;
|
|
422
423
|
setAttributionMarks(marks: readonly {
|
|
423
424
|
id: string;
|
|
424
425
|
startLine: number;
|
|
@@ -469,3 +470,4 @@ export declare class EditorView {
|
|
|
469
470
|
foldLineOf(target: EventTarget | null): number | null;
|
|
470
471
|
dispose(): void;
|
|
471
472
|
}
|
|
473
|
+
export {};
|
package/dist/view.js
CHANGED
|
@@ -5,6 +5,7 @@ import { renderCodeBlock } from './code-block.js';
|
|
|
5
5
|
import { FindController } from './find.js';
|
|
6
6
|
import { offsetOfStop, xOfStop } from './geometry-stops.js';
|
|
7
7
|
import { EditorLayout, RIGHT_PADDING, subRowBand } from './layout.js';
|
|
8
|
+
import {} from './line-geometry.js';
|
|
8
9
|
import { emit, subscribe } from './listeners.js';
|
|
9
10
|
import { createMetrics, readEditorFont } from './metrics.js';
|
|
10
11
|
import { mapOffset, offsetMapper } from './offsets.js';
|
|
@@ -177,7 +178,6 @@ export class EditorView {
|
|
|
177
178
|
activeGuideCache;
|
|
178
179
|
/* Column mode: a drag or Shift with the arrows selects a box of columns, as Alt does for a drag. */
|
|
179
180
|
columnMode = false;
|
|
180
|
-
/* A scroll on its way: where it started and ends, when, and the frame that moves it. */
|
|
181
181
|
scrollRun = null;
|
|
182
182
|
selectionOccurrenceCache = { key: '', ranges: [] };
|
|
183
183
|
link = null;
|
|
@@ -349,7 +349,6 @@ export class EditorView {
|
|
|
349
349
|
this.fontSize = size;
|
|
350
350
|
this.refreshFont();
|
|
351
351
|
}
|
|
352
|
-
/* The size the code is drawn at, in pixels. */
|
|
353
352
|
getFontSize() {
|
|
354
353
|
return this.font.size;
|
|
355
354
|
}
|
|
@@ -783,7 +782,7 @@ export class EditorView {
|
|
|
783
782
|
at: ghost.at,
|
|
784
783
|
render: (container) => {
|
|
785
784
|
container.classList.add('se-ghost-accessory');
|
|
786
|
-
ghost.accessory?.(container);
|
|
785
|
+
return ghost.accessory?.(container);
|
|
787
786
|
}
|
|
788
787
|
}
|
|
789
788
|
]);
|
|
@@ -1234,7 +1233,6 @@ export class EditorView {
|
|
|
1234
1233
|
const candidates = anchor !== head ? [Math.min(anchor, head)] : [head, head - 1];
|
|
1235
1234
|
return candidates.find((at) => at >= 0 && /[()[\]{}]/.test(this.model.slice(at, at + 1)));
|
|
1236
1235
|
}
|
|
1237
|
-
/* The offset a bracket at the caret pairs with, if it is one. */
|
|
1238
1236
|
matchingBracket(selection) {
|
|
1239
1237
|
const at = this.bracketAt(selection);
|
|
1240
1238
|
return at === undefined ? null : { at, mate: this.model.matchBracket(at, this.settings.language)?.mate };
|
|
@@ -1386,7 +1384,6 @@ export class EditorView {
|
|
|
1386
1384
|
: geometry.start + offsetOfStop(geometry, geometry.rowStarts[band.last + 1])
|
|
1387
1385
|
};
|
|
1388
1386
|
}
|
|
1389
|
-
/* The arrows of the soft wraps in the rows on screen. */
|
|
1390
1387
|
wrapSigns(rows) {
|
|
1391
1388
|
if (!this.layout.wrapping) {
|
|
1392
1389
|
return [];
|
|
@@ -1530,7 +1527,6 @@ export class EditorView {
|
|
|
1530
1527
|
}
|
|
1531
1528
|
return { plain, active: marked };
|
|
1532
1529
|
}
|
|
1533
|
-
/* The selection under a point of the screen, which a press there may drag away. */
|
|
1534
1530
|
selectionAtPoint(clientX, clientY) {
|
|
1535
1531
|
const point = this.contentPoint(clientX, clientY);
|
|
1536
1532
|
const rows = this.layout.visibleRows(this.viewport.scrollTop, this.viewportHeight, 0);
|
|
@@ -1547,7 +1543,6 @@ export class EditorView {
|
|
|
1547
1543
|
this.columnMode = on;
|
|
1548
1544
|
this.root.dataset.column = String(on);
|
|
1549
1545
|
}
|
|
1550
|
-
/* Where text being carried would land, drawn as a caret of its own. */
|
|
1551
1546
|
setDropCaret(offset) {
|
|
1552
1547
|
this.dropCaret = offset;
|
|
1553
1548
|
this.render();
|
|
@@ -1567,7 +1562,6 @@ export class EditorView {
|
|
|
1567
1562
|
const part = target.closest('[data-part]');
|
|
1568
1563
|
return { id: element.dataset.inlayId, part: part === null ? null : Number(part.dataset.part), element: part ?? element };
|
|
1569
1564
|
}
|
|
1570
|
-
/* Says which hint the pointer is on, or that it left them all. */
|
|
1571
1565
|
setInlayHover(target) {
|
|
1572
1566
|
const found = this.inlayAt(target);
|
|
1573
1567
|
if (found?.id === this.inlayHover?.id && found?.part === this.inlayHover?.part) {
|
|
@@ -1731,7 +1725,6 @@ export class EditorView {
|
|
|
1731
1725
|
revealCaret(kind = 'relative') {
|
|
1732
1726
|
this.revealOffset(this.model.getPrimary().head, kind);
|
|
1733
1727
|
}
|
|
1734
|
-
/* What a regular expression replacement writes for the match the find is on, drawn under that match; null takes it away. */
|
|
1735
1728
|
setReplacePreview(replacement, preserveCase = false) {
|
|
1736
1729
|
this.replacePreview = replacement === null ? null : { text: replacement, preserveCase };
|
|
1737
1730
|
this.find.setPreview(replacement !== null);
|
|
@@ -2185,43 +2178,74 @@ export class EditorView {
|
|
|
2185
2178
|
this.lineActions.set(owner, [...actions]);
|
|
2186
2179
|
}
|
|
2187
2180
|
const wanted = new Set([...this.lineActions].flatMap(([name, entries]) => entries.map((entry) => `${name}\0${entry.id}`)));
|
|
2188
|
-
for (const
|
|
2181
|
+
for (const key of [...this.actionElements.keys()]) {
|
|
2189
2182
|
if (!wanted.has(key)) {
|
|
2190
|
-
|
|
2191
|
-
this.actionElements.delete(key);
|
|
2183
|
+
this.removeActionElement(key);
|
|
2192
2184
|
}
|
|
2193
2185
|
}
|
|
2194
2186
|
this.render();
|
|
2195
2187
|
}
|
|
2188
|
+
/* Out of the map first, so a disposer that sets actions again finds the element gone. */
|
|
2189
|
+
removeActionElement(key) {
|
|
2190
|
+
const mounted = this.actionElements.get(key);
|
|
2191
|
+
if (mounted === undefined) {
|
|
2192
|
+
return;
|
|
2193
|
+
}
|
|
2194
|
+
this.actionElements.delete(key);
|
|
2195
|
+
mounted.element.remove();
|
|
2196
|
+
mounted.dispose?.();
|
|
2197
|
+
}
|
|
2196
2198
|
paintLineActions() {
|
|
2199
|
+
for (const owner of this.lineActions.keys()) {
|
|
2200
|
+
// An owner that set its actions anew from inside a render is painted once more, with the new ones; a draw never nests.
|
|
2201
|
+
if (!this.paintOwnerActions(owner)) {
|
|
2202
|
+
this.paintOwnerActions(owner);
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
/* False when the owner set its actions anew from inside a render, which leaves the rest of the list it was painting stale. */
|
|
2207
|
+
paintOwnerActions(owner) {
|
|
2197
2208
|
const lineHeight = this.layout.metrics.lineHeight;
|
|
2198
2209
|
const top = this.scrollTop;
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2210
|
+
const entries = this.lineActions.get(owner) ?? [];
|
|
2211
|
+
for (const entry of entries) {
|
|
2212
|
+
const key = `${owner}\0${entry.id}`;
|
|
2213
|
+
let element = this.actionElements.get(key)?.element;
|
|
2214
|
+
if (element === undefined) {
|
|
2215
|
+
element = this.document.createElement('div');
|
|
2216
|
+
element.className = 'se-line-action';
|
|
2217
|
+
element.addEventListener('pointerdown', (event) => event.stopPropagation());
|
|
2218
|
+
element.addEventListener('mousedown', (event) => event.stopPropagation());
|
|
2219
|
+
this.actions.append(element);
|
|
2220
|
+
const mounted = { element, dispose: undefined };
|
|
2221
|
+
this.actionElements.set(key, mounted);
|
|
2222
|
+
const dispose = entry.render(element);
|
|
2223
|
+
// An owner that took the element away again from inside its own render gets it disposed at once.
|
|
2224
|
+
if (this.actionElements.get(key) !== mounted) {
|
|
2225
|
+
dispose?.();
|
|
2226
|
+
if (this.lineActions.get(owner) !== entries) {
|
|
2227
|
+
return false;
|
|
2228
|
+
}
|
|
2217
2229
|
continue;
|
|
2218
2230
|
}
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2231
|
+
mounted.dispose = dispose;
|
|
2232
|
+
if (this.lineActions.get(owner) !== entries) {
|
|
2233
|
+
return false;
|
|
2234
|
+
}
|
|
2223
2235
|
}
|
|
2236
|
+
const line = this.model.positionAt(entry.at).line;
|
|
2237
|
+
const row = this.layout.rowForLine(line);
|
|
2238
|
+
const place = row.kind === 'text' && row.line === line ? this.layout.caret(this.model.getLine(line).end) : null;
|
|
2239
|
+
if (place === null || place.y + lineHeight < top - this.viewportHeight || place.y > top + 2 * this.viewportHeight) {
|
|
2240
|
+
element.hidden = true;
|
|
2241
|
+
continue;
|
|
2242
|
+
}
|
|
2243
|
+
element.hidden = false;
|
|
2244
|
+
element.style.left = `${Math.round(place.x) + LINE_ACTION_GAP}px`;
|
|
2245
|
+
element.style.top = `${Math.round(place.y)}px`;
|
|
2246
|
+
element.style.height = `${lineHeight}px`;
|
|
2224
2247
|
}
|
|
2248
|
+
return true;
|
|
2225
2249
|
}
|
|
2226
2250
|
/* Bars in the gutter for runs of lines, which follow their text through edits until the host sets them again. */
|
|
2227
2251
|
setAttributionMarks(marks) {
|
|
@@ -2264,7 +2288,6 @@ export class EditorView {
|
|
|
2264
2288
|
...[...emphasisByColor].map(([background, rects]) => ({ className: 'se-line-emphasis', rects, background }))
|
|
2265
2289
|
];
|
|
2266
2290
|
}
|
|
2267
|
-
/* Code that is not in the document, drawn in the editor's own face and colors. */
|
|
2268
2291
|
renderCode(container, text, options) {
|
|
2269
2292
|
renderCodeBlock(container, text, options.tokens === undefined ? this.tokens.tokenizeText(text.split(/\r?\n/)) : options.tokens, this.settings.tabSize, options);
|
|
2270
2293
|
}
|
|
@@ -2477,7 +2500,6 @@ export class EditorView {
|
|
|
2477
2500
|
});
|
|
2478
2501
|
paintOverview(this.overview, overviewTicks(spans, this.layout.height, trackHeight));
|
|
2479
2502
|
}
|
|
2480
|
-
/* The blocks sticky scroll and the breadcrumb go by; null goes back to the editor's own reading. */
|
|
2481
2503
|
setBlocks(blocks) {
|
|
2482
2504
|
this.outline.setProvided(blocks, this.model);
|
|
2483
2505
|
this.render();
|
|
@@ -2622,7 +2644,6 @@ export class EditorView {
|
|
|
2622
2644
|
pressGutterAction(line) {
|
|
2623
2645
|
emit(this.gutterActionListeners, line);
|
|
2624
2646
|
}
|
|
2625
|
-
/* The line a fold control in the gutter folds. */
|
|
2626
2647
|
foldLineOf(target) {
|
|
2627
2648
|
const button = closestElement(target, '[data-fold-line]');
|
|
2628
2649
|
return button ? Number(button.dataset.foldLine) : null;
|
|
@@ -2659,7 +2680,9 @@ export class EditorView {
|
|
|
2659
2680
|
this.tracked.clear();
|
|
2660
2681
|
this.remoteCarets = [];
|
|
2661
2682
|
this.lineActions.clear();
|
|
2662
|
-
this.actionElements.
|
|
2683
|
+
for (const key of [...this.actionElements.keys()]) {
|
|
2684
|
+
this.removeActionElement(key);
|
|
2685
|
+
}
|
|
2663
2686
|
this.attribution.clear();
|
|
2664
2687
|
this.highlights.clear();
|
|
2665
2688
|
this.attributionListeners.clear();
|
package/dist/zoom.d.ts
CHANGED
package/dist/zoom.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Nothing a person reads is smaller. */
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const MIN_FONT_SIZE = 12;
|
|
3
|
+
const MAX_FONT_SIZE = 90;
|
|
4
4
|
/* A trackpad or a pinch sends the wheel in small steps; this many pixels of them are one step of the size. */
|
|
5
5
|
const PIXELS_PER_STEP = 20;
|
|
6
6
|
export function fontSizeRange(zoom) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0-untangle.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"test": "bun test --conditions=source"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@adecore/editor-core": "0.
|
|
58
|
-
"@adecore/utils": "0.
|
|
57
|
+
"@adecore/editor-core": "0.63.0-untangle.1",
|
|
58
|
+
"@adecore/utils": "0.63.0-untangle.1",
|
|
59
59
|
"linkedom": "^0.18.14",
|
|
60
60
|
"shiki": "^4.5.0"
|
|
61
61
|
},
|
|
@@ -64,6 +64,11 @@
|
|
|
64
64
|
"@types/node": "^26.6.6",
|
|
65
65
|
"typescript": "^7.0.2"
|
|
66
66
|
},
|
|
67
|
+
"adecore": {
|
|
68
|
+
"dedupe": [
|
|
69
|
+
"shiki"
|
|
70
|
+
]
|
|
71
|
+
},
|
|
67
72
|
"license": "FSL-1.1-MIT",
|
|
68
73
|
"author": "Bas Milius",
|
|
69
74
|
"repository": {
|
package/src/attribution.ts
CHANGED
|
@@ -30,7 +30,6 @@ export function tintValue(color: string): string {
|
|
|
30
30
|
return `color-mix(in srgb, ${colorValue(color)} 14%, transparent)`;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
/* The CSS value of a mark's color: `--agent-1` is the page's custom property of that name, anything else is a color as it stands. */
|
|
34
33
|
export function colorValue(color: string): string {
|
|
35
34
|
return color.startsWith('--') ? `var(${color})` : color;
|
|
36
35
|
}
|
package/src/bidi.ts
CHANGED
|
@@ -21,7 +21,6 @@ export const BIDI_COLUMNS = 3;
|
|
|
21
21
|
|
|
22
22
|
export const BIDI_PATTERN = /[--]/g;
|
|
23
23
|
|
|
24
|
-
/* The placeholder of a bidirectional control character, or null for any other text. */
|
|
25
24
|
export function bidiControl(character: string): (typeof BIDI_CONTROLS)[BidiControl] | null {
|
|
26
25
|
return character.length === 1 ? ((BIDI_CONTROLS as Record<string, (typeof BIDI_CONTROLS)[BidiControl]>)[character] ?? null) : null;
|
|
27
26
|
}
|
package/src/column-selection.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface ContentPoint {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/* The cell of a monospaced grid an x falls in, which stands in for the visual column since a tab is a whole number of cells. */
|
|
11
|
-
|
|
11
|
+
function cellAt(layout: EditorLayout, x: number): number {
|
|
12
12
|
return Math.max(0, Math.round((x - TEXT_PADDING) / layout.metrics.charWidth));
|
|
13
13
|
}
|
|
14
14
|
|
package/src/controller.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { CommandOptions, EditorCommand, Selection, TextEdit } from '@adecor
|
|
|
2
2
|
import { columnSelections, sameCell } from './column-selection.ts';
|
|
3
3
|
import { replacementEdits } from './input.ts';
|
|
4
4
|
import type { Keymap } from './keymap-table.ts';
|
|
5
|
+
import type { KeyChord } from './keymap-table.ts';
|
|
5
6
|
import { chordMatches, type KeyAction, keyAction, type MoveKey } from './keymap.ts';
|
|
6
7
|
import { emit, subscribe } from './listeners.ts';
|
|
7
8
|
import { DoubleModifierGesture } from './modifier-gesture.ts';
|
|
@@ -20,13 +21,12 @@ import type {
|
|
|
20
21
|
EditorPosition,
|
|
21
22
|
EditorRunCommand,
|
|
22
23
|
EditorSelectionRanges,
|
|
23
|
-
EditorViewCommand
|
|
24
|
-
KeyChord
|
|
24
|
+
EditorViewCommand
|
|
25
25
|
} from './types.ts';
|
|
26
26
|
import type { EditorView } from './view.ts';
|
|
27
27
|
import { WheelZoom } from './zoom.ts';
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
interface ControllerOptions {
|
|
30
30
|
/* Read on every key press, so a rebind reaches an editor that is already open. */
|
|
31
31
|
keymap(): Keymap | undefined;
|
|
32
32
|
handBack(): readonly KeyChord[];
|
|
@@ -35,7 +35,6 @@ export interface ControllerOptions {
|
|
|
35
35
|
blur(): void;
|
|
36
36
|
/* One pixel larger (1) or smaller (-1), or back to the page's size (0). */
|
|
37
37
|
zoom(step: -1 | 0 | 1): void;
|
|
38
|
-
/* Whether the zoom modifier with the wheel, or a pinch, zooms. */
|
|
39
38
|
wheelZooms(): boolean;
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -405,7 +404,6 @@ export class InputController {
|
|
|
405
404
|
return pasted;
|
|
406
405
|
}
|
|
407
406
|
|
|
408
|
-
/* Told what a copy or cut put on the clipboard. */
|
|
409
407
|
onCopy(listener: (copy: EditorCopy) => void): () => void {
|
|
410
408
|
return subscribe(this.copyListeners, listener);
|
|
411
409
|
}
|
|
@@ -715,7 +713,6 @@ export class InputController {
|
|
|
715
713
|
}
|
|
716
714
|
}
|
|
717
715
|
|
|
718
|
-
/* Moves the corner of the box by a step and selects the columns between it and the other corner. */
|
|
719
716
|
private extendBlock(step: { x: number; y: number }): void {
|
|
720
717
|
const { model, layout } = this.view;
|
|
721
718
|
const signature = selectionSignature(model.getSelections());
|
|
@@ -735,7 +732,6 @@ export class InputController {
|
|
|
735
732
|
block.signature = selectionSignature(model.getSelections());
|
|
736
733
|
}
|
|
737
734
|
|
|
738
|
-
/* A box between the two ends of a selection. */
|
|
739
735
|
private blockOf(selection: Selection, signature: string): NonNullable<InputController['block']> {
|
|
740
736
|
const { layout } = this.view;
|
|
741
737
|
const anchor = layout.caret(selection.anchor);
|
|
@@ -1174,7 +1170,6 @@ export class InputController {
|
|
|
1174
1170
|
emit(this.contextListeners, menu);
|
|
1175
1171
|
}
|
|
1176
1172
|
|
|
1177
|
-
/* A press on a pinned header goes to that header. */
|
|
1178
1173
|
private stickyDown(event: PointerEvent): void {
|
|
1179
1174
|
const row = (event.target as HTMLElement | null)?.closest?.<HTMLElement>('.se-sticky-row');
|
|
1180
1175
|
|
|
@@ -1187,7 +1182,6 @@ export class InputController {
|
|
|
1187
1182
|
this.view.focus();
|
|
1188
1183
|
}
|
|
1189
1184
|
|
|
1190
|
-
/* A press on a line number selects the line. */
|
|
1191
1185
|
private gutterDown(event: PointerEvent): void {
|
|
1192
1186
|
this.view.cancelScroll();
|
|
1193
1187
|
|
package/src/engine.ts
CHANGED
|
@@ -76,7 +76,6 @@ const DEFAULT_WIDGET_OWNER = 'default';
|
|
|
76
76
|
/* The space a hint's padding keeps clear; a whole pixel count so the pill stays on the pixel grid. */
|
|
77
77
|
const INLAY_GAP = 4;
|
|
78
78
|
|
|
79
|
-
/* A value an app hands over as it is, or as a function the editor asks again each time it needs it. */
|
|
80
79
|
function live<T>(source: T | (() => T)): () => T {
|
|
81
80
|
return typeof source === 'function' ? (source as () => T) : () => source;
|
|
82
81
|
}
|
|
@@ -186,7 +185,6 @@ class SmartEditor implements Editor {
|
|
|
186
185
|
this.placeCursor(options);
|
|
187
186
|
}
|
|
188
187
|
|
|
189
|
-
/* Where the editor opens: on a line and column, scrolled to a position, or with that line in view. */
|
|
190
188
|
private placeCursor(options: EditorOptions): void {
|
|
191
189
|
if (options.line !== undefined) {
|
|
192
190
|
const line = this.clampLine(options.line);
|
|
@@ -321,7 +319,6 @@ class SmartEditor implements Editor {
|
|
|
321
319
|
return this.model.getSelections().map((selection) => this.rangeOf(selection));
|
|
322
320
|
}
|
|
323
321
|
|
|
324
|
-
/* A selection as a range, start before end. */
|
|
325
322
|
private rangeOf({ anchor, head }: { anchor: number; head: number }): EditorRange {
|
|
326
323
|
return { start: this.positionAt(Math.min(anchor, head)), end: this.positionAt(Math.max(anchor, head)) };
|
|
327
324
|
}
|