@adecore/editor 0.62.1 → 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/attribution.js
CHANGED
|
@@ -5,7 +5,6 @@ export const AGENT_COLORS = ['--agent-1', '--agent-2', '--agent-3', '--agent-4',
|
|
|
5
5
|
export function tintValue(color) {
|
|
6
6
|
return `color-mix(in srgb, ${colorValue(color)} 14%, transparent)`;
|
|
7
7
|
}
|
|
8
|
-
/* 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. */
|
|
9
8
|
export function colorValue(color) {
|
|
10
9
|
return color.startsWith('--') ? `var(${color})` : color;
|
|
11
10
|
}
|
package/dist/bidi.js
CHANGED
|
@@ -16,7 +16,6 @@ export const BIDI_CONTROLS = {
|
|
|
16
16
|
/* Every label is this many columns wide, so the placeholder is a box of fixed size in the grid. */
|
|
17
17
|
export const BIDI_COLUMNS = 3;
|
|
18
18
|
export const BIDI_PATTERN = /[--]/g;
|
|
19
|
-
/* The placeholder of a bidirectional control character, or null for any other text. */
|
|
20
19
|
export function bidiControl(character) {
|
|
21
20
|
return character.length === 1 ? (BIDI_CONTROLS[character] ?? null) : null;
|
|
22
21
|
}
|
|
@@ -4,6 +4,5 @@ export interface ContentPoint {
|
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
6
6
|
}
|
|
7
|
-
export declare function cellAt(layout: EditorLayout, x: number): number;
|
|
8
7
|
export declare function columnSelections(layout: EditorLayout, from: ContentPoint, to: ContentPoint): Selection[];
|
|
9
8
|
export declare function sameCell(layout: EditorLayout, from: ContentPoint, to: ContentPoint): boolean;
|
package/dist/column-selection.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { stopCount, xOfStop } from './geometry-stops.js';
|
|
2
2
|
import { TEXT_PADDING } from './layout.js';
|
|
3
3
|
/* 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. */
|
|
4
|
-
|
|
4
|
+
function cellAt(layout, x) {
|
|
5
5
|
return Math.max(0, Math.round((x - TEXT_PADDING) / layout.metrics.charWidth));
|
|
6
6
|
}
|
|
7
7
|
/*
|
package/dist/controller.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Keymap } from './keymap-table.ts';
|
|
2
|
-
import type {
|
|
2
|
+
import type { KeyChord } from './keymap-table.ts';
|
|
3
|
+
import type { EditorClickHandler, EditorInlayClickHandler, EditorContextMenu, EditorCopy, EditorKeyHandler, EditorPasteOptions, EditorRunCommand, EditorSelectionRanges } from './types.ts';
|
|
3
4
|
import type { EditorView } from './view.ts';
|
|
4
|
-
|
|
5
|
+
interface ControllerOptions {
|
|
5
6
|
keymap(): Keymap | undefined;
|
|
6
7
|
handBack(): readonly KeyChord[];
|
|
7
8
|
apple: boolean;
|
|
@@ -80,3 +81,4 @@ export declare class InputController {
|
|
|
80
81
|
private stickyDown;
|
|
81
82
|
private gutterDown;
|
|
82
83
|
}
|
|
84
|
+
export {};
|
package/dist/controller.js
CHANGED
|
@@ -317,7 +317,6 @@ export class InputController {
|
|
|
317
317
|
this.view.revealCaret();
|
|
318
318
|
return pasted;
|
|
319
319
|
}
|
|
320
|
-
/* Told what a copy or cut put on the clipboard. */
|
|
321
320
|
onCopy(listener) {
|
|
322
321
|
return subscribe(this.copyListeners, listener);
|
|
323
322
|
}
|
|
@@ -555,7 +554,6 @@ export class InputController {
|
|
|
555
554
|
this.extendBlock({ x: 0, y: 0 });
|
|
556
555
|
}
|
|
557
556
|
}
|
|
558
|
-
/* Moves the corner of the box by a step and selects the columns between it and the other corner. */
|
|
559
557
|
extendBlock(step) {
|
|
560
558
|
const { model, layout } = this.view;
|
|
561
559
|
const signature = selectionSignature(model.getSelections());
|
|
@@ -570,7 +568,6 @@ export class InputController {
|
|
|
570
568
|
model.setSelections(columnSelections(layout, block.anchor, block.head));
|
|
571
569
|
block.signature = selectionSignature(model.getSelections());
|
|
572
570
|
}
|
|
573
|
-
/* A box between the two ends of a selection. */
|
|
574
571
|
blockOf(selection, signature) {
|
|
575
572
|
const { layout } = this.view;
|
|
576
573
|
const anchor = layout.caret(selection.anchor);
|
|
@@ -903,7 +900,6 @@ export class InputController {
|
|
|
903
900
|
const menu = { position: this.positionOf(offset), inSelection: selection, x: event.clientX, y: event.clientY };
|
|
904
901
|
emit(this.contextListeners, menu);
|
|
905
902
|
}
|
|
906
|
-
/* A press on a pinned header goes to that header. */
|
|
907
903
|
stickyDown(event) {
|
|
908
904
|
const row = event.target?.closest?.('.se-sticky-row');
|
|
909
905
|
if (event.button !== 0 || !row) {
|
|
@@ -913,7 +909,6 @@ export class InputController {
|
|
|
913
909
|
this.view.jumpToHeader(Number(row.dataset.line), Number(row.dataset.depth));
|
|
914
910
|
this.view.focus();
|
|
915
911
|
}
|
|
916
|
-
/* A press on a line number selects the line. */
|
|
917
912
|
gutterDown(event) {
|
|
918
913
|
this.view.cancelScroll();
|
|
919
914
|
if (event.button !== 0) {
|
package/dist/engine.js
CHANGED
|
@@ -13,7 +13,6 @@ const DEFAULT_LABEL = 'Code editor';
|
|
|
13
13
|
const DEFAULT_WIDGET_OWNER = 'default';
|
|
14
14
|
/* The space a hint's padding keeps clear; a whole pixel count so the pill stays on the pixel grid. */
|
|
15
15
|
const INLAY_GAP = 4;
|
|
16
|
-
/* A value an app hands over as it is, or as a function the editor asks again each time it needs it. */
|
|
17
16
|
function live(source) {
|
|
18
17
|
return typeof source === 'function' ? source : () => source;
|
|
19
18
|
}
|
|
@@ -106,7 +105,6 @@ class SmartEditor {
|
|
|
106
105
|
}
|
|
107
106
|
this.placeCursor(options);
|
|
108
107
|
}
|
|
109
|
-
/* Where the editor opens: on a line and column, scrolled to a position, or with that line in view. */
|
|
110
108
|
placeCursor(options) {
|
|
111
109
|
if (options.line !== undefined) {
|
|
112
110
|
const line = this.clampLine(options.line);
|
|
@@ -213,7 +211,6 @@ class SmartEditor {
|
|
|
213
211
|
getSelections() {
|
|
214
212
|
return this.model.getSelections().map((selection) => this.rangeOf(selection));
|
|
215
213
|
}
|
|
216
|
-
/* A selection as a range, start before end. */
|
|
217
214
|
rangeOf({ anchor, head }) {
|
|
218
215
|
return { start: this.positionAt(Math.min(anchor, head)), end: this.positionAt(Math.max(anchor, head)) };
|
|
219
216
|
}
|
package/dist/fake.d.ts
CHANGED
|
@@ -197,7 +197,10 @@ export declare class FakeEditor implements Editor {
|
|
|
197
197
|
readonly part: number | null;
|
|
198
198
|
} | null): void;
|
|
199
199
|
ghost: EditorGhostText | null;
|
|
200
|
+
private ghostSerial;
|
|
201
|
+
private ghostDispose;
|
|
200
202
|
setGhostText(ghost: EditorGhostText | null): void;
|
|
203
|
+
private dropGhost;
|
|
201
204
|
semanticTokens: readonly EditorSemanticToken[] | null;
|
|
202
205
|
setSemanticTokens(tokens: readonly EditorSemanticToken[] | null): void;
|
|
203
206
|
link: EditorRange | null;
|
package/dist/fake.js
CHANGED
|
@@ -175,7 +175,6 @@ export class FakeEditor {
|
|
|
175
175
|
this.assertLive();
|
|
176
176
|
emit(this.saves);
|
|
177
177
|
}
|
|
178
|
-
/* The focus leaving the editor. */
|
|
179
178
|
blur() {
|
|
180
179
|
this.assertLive();
|
|
181
180
|
this.focused = false;
|
|
@@ -231,7 +230,7 @@ export class FakeEditor {
|
|
|
231
230
|
this.text = text;
|
|
232
231
|
this.selections = normalized(text, place?.(text) ?? this.selections.map((selection) => ({ anchor: mapOffset(selection.anchor, edits), head: mapOffset(selection.head, edits) })));
|
|
233
232
|
this.followTracked(changed);
|
|
234
|
-
this.
|
|
233
|
+
this.dropGhost();
|
|
235
234
|
this.announceCaret();
|
|
236
235
|
// Last to first, so each change's range is also where it stands once the ones after it are applied, as the real editor reports them.
|
|
237
236
|
const change = {
|
|
@@ -265,7 +264,6 @@ export class FakeEditor {
|
|
|
265
264
|
emit(this.changes);
|
|
266
265
|
return true;
|
|
267
266
|
}
|
|
268
|
-
/* Tells the caret listeners where the primary caret is, when it moved since they last heard. */
|
|
269
267
|
announceCaret() {
|
|
270
268
|
const head = this.selections.at(-1).head;
|
|
271
269
|
if (head !== this.caretOffset) {
|
|
@@ -401,7 +399,6 @@ export class FakeEditor {
|
|
|
401
399
|
this.changeLayers.set(layer, marks);
|
|
402
400
|
}
|
|
403
401
|
}
|
|
404
|
-
/* The tinted lines the host set last. */
|
|
405
402
|
lineHighlights = [];
|
|
406
403
|
setLineHighlights(highlights) {
|
|
407
404
|
this.lineHighlights = highlights;
|
|
@@ -417,7 +414,6 @@ export class FakeEditor {
|
|
|
417
414
|
setLineLabels(labels) {
|
|
418
415
|
this.lineLabels = labels;
|
|
419
416
|
}
|
|
420
|
-
/* What the input points at, as the last call left it. */
|
|
421
417
|
inputPopup = null;
|
|
422
418
|
setInputPopup(popup) {
|
|
423
419
|
this.inputPopup = popup;
|
|
@@ -437,12 +433,10 @@ export class FakeEditor {
|
|
|
437
433
|
renderCode(container, text, options = {}) {
|
|
438
434
|
this.codeBlocks.push({ container, text, options });
|
|
439
435
|
}
|
|
440
|
-
/* The cursors of agents the host set last. */
|
|
441
436
|
remoteCursors = [];
|
|
442
437
|
setRemoteCursors(cursors) {
|
|
443
438
|
this.remoteCursors = cursors;
|
|
444
439
|
}
|
|
445
|
-
/* What the host marked as written by an agent last. */
|
|
446
440
|
attributionMarks = [];
|
|
447
441
|
attributionHovers = new Set();
|
|
448
442
|
setAttributionMarks(marks) {
|
|
@@ -468,7 +462,6 @@ export class FakeEditor {
|
|
|
468
462
|
: { id: mark.id, rect: rect ?? this.rectAt({ line: mark.startLine - 1, character: 0 }) ?? { left: 0, top: 0, right: 0, bottom: 0 } };
|
|
469
463
|
emit(this.attributionHovers, hover);
|
|
470
464
|
}
|
|
471
|
-
/* What each owner put next to lines of the text last. */
|
|
472
465
|
widgetsByOwner = new Map();
|
|
473
466
|
/* The default owner's rows. */
|
|
474
467
|
get widgets() {
|
|
@@ -509,12 +502,10 @@ export class FakeEditor {
|
|
|
509
502
|
this.lineActionsByOwner.set(owner, actions);
|
|
510
503
|
}
|
|
511
504
|
}
|
|
512
|
-
/* The code vision rows the host set last. */
|
|
513
505
|
codeVision = [];
|
|
514
506
|
setCodeVision(rows) {
|
|
515
507
|
this.codeVision = rows;
|
|
516
508
|
}
|
|
517
|
-
/* The button the host set in the gutter last. */
|
|
518
509
|
gutterAction = null;
|
|
519
510
|
gutterActionListeners = new Set();
|
|
520
511
|
setGutterAction(action) {
|
|
@@ -523,7 +514,6 @@ export class FakeEditor {
|
|
|
523
514
|
onGutterAction(listener) {
|
|
524
515
|
return subscribe(this.gutterActionListeners, listener);
|
|
525
516
|
}
|
|
526
|
-
/* What each owner put in the gutter last. */
|
|
527
517
|
gutterMarkersByOwner = new Map();
|
|
528
518
|
gutterMarkerListeners = new Set();
|
|
529
519
|
setGutterMarkers(markers, owner = 'default') {
|
|
@@ -537,11 +527,9 @@ export class FakeEditor {
|
|
|
537
527
|
onGutterMarker(listener) {
|
|
538
528
|
return subscribe(this.gutterMarkerListeners, listener);
|
|
539
529
|
}
|
|
540
|
-
/* A press on a gutter marker. */
|
|
541
530
|
pressGutterMarker(id) {
|
|
542
531
|
emit(this.gutterMarkerListeners, id);
|
|
543
532
|
}
|
|
544
|
-
/* A press on the gutter button, if there is one. */
|
|
545
533
|
pressGutterAction() {
|
|
546
534
|
if (this.gutterAction !== null) {
|
|
547
535
|
emit(this.gutterActionListeners, this.gutterAction.line);
|
|
@@ -613,7 +601,6 @@ export class FakeEditor {
|
|
|
613
601
|
copy(text, wholeLines = false, cut = false) {
|
|
614
602
|
emit(this.copies, { text, wholeLines, cut });
|
|
615
603
|
}
|
|
616
|
-
/* Every paste a host asked for, with its options. */
|
|
617
604
|
pastes = [];
|
|
618
605
|
/* Puts the text at every caret, one line per caret when the lines are as many as the carets, and leaves the carets behind it. */
|
|
619
606
|
paste(text, options) {
|
|
@@ -649,7 +636,6 @@ export class FakeEditor {
|
|
|
649
636
|
setIndentation(indentation) {
|
|
650
637
|
this.indentation = indentation;
|
|
651
638
|
}
|
|
652
|
-
/* What the host marked and highlighted last. */
|
|
653
639
|
markers = [];
|
|
654
640
|
highlights = [];
|
|
655
641
|
/* Where `rectAt` puts a position, which a test can move to simulate scrolling. */
|
|
@@ -682,7 +668,6 @@ export class FakeEditor {
|
|
|
682
668
|
onInlayHover(listener) {
|
|
683
669
|
return subscribe(this.inlayHovers, listener);
|
|
684
670
|
}
|
|
685
|
-
/* The pointer resting on a hint or a part of one, or leaving them. */
|
|
686
671
|
hoverInlay(id, part = null) {
|
|
687
672
|
emit(this.inlayHovers, id === null ? null : { id, part, rect: { left: 0, top: 0, right: 40, bottom: 20 } });
|
|
688
673
|
}
|
|
@@ -697,17 +682,40 @@ export class FakeEditor {
|
|
|
697
682
|
setInlayLink(target) {
|
|
698
683
|
this.inlayLink = target;
|
|
699
684
|
}
|
|
700
|
-
/* The suggestion after the caret now, which any change of the text takes away as the real editor does. */
|
|
685
|
+
/* The suggestion after the caret now, which any change of the text takes away as the real editor does. Its accessory is mounted and disposed as there too. */
|
|
701
686
|
ghost = null;
|
|
687
|
+
ghostSerial = 0;
|
|
688
|
+
ghostDispose = undefined;
|
|
702
689
|
setGhostText(ghost) {
|
|
703
|
-
|
|
690
|
+
const serial = this.dropGhost();
|
|
691
|
+
// A disposer that set a ghost of its own came later than this call.
|
|
692
|
+
if (serial !== this.ghostSerial) {
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
this.ghost = ghost === null || ghost.text === '' ? null : ghost;
|
|
696
|
+
if (this.ghost?.accessory === undefined) {
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
const dispose = this.ghost.accessory(this.element.ownerDocument?.createElement('div') ?? {});
|
|
700
|
+
if (serial !== this.ghostSerial) {
|
|
701
|
+
dispose?.();
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
this.ghostDispose = dispose;
|
|
705
|
+
}
|
|
706
|
+
/* Takes the ghost away and disposes its accessory, returning the serial a caller compares after it. */
|
|
707
|
+
dropGhost() {
|
|
708
|
+
const serial = ++this.ghostSerial;
|
|
709
|
+
const dispose = this.ghostDispose;
|
|
710
|
+
this.ghost = null;
|
|
711
|
+
this.ghostDispose = undefined;
|
|
712
|
+
dispose?.();
|
|
713
|
+
return serial;
|
|
704
714
|
}
|
|
705
|
-
/* What the host classified last. */
|
|
706
715
|
semanticTokens = null;
|
|
707
716
|
setSemanticTokens(tokens) {
|
|
708
717
|
this.semanticTokens = tokens;
|
|
709
718
|
}
|
|
710
|
-
/* What the host drew as a link last. */
|
|
711
719
|
link = null;
|
|
712
720
|
setLink(range) {
|
|
713
721
|
this.link = range;
|
|
@@ -726,7 +734,6 @@ export class FakeEditor {
|
|
|
726
734
|
const offset = this.offsetAt(position);
|
|
727
735
|
this.selections = [...this.selections.slice(0, -1), { anchor: offset, head: offset }];
|
|
728
736
|
}
|
|
729
|
-
/* The folds the host asked to keep. */
|
|
730
737
|
folds = { collapsed: [], custom: [] };
|
|
731
738
|
getFolds() {
|
|
732
739
|
return this.folds;
|
|
@@ -769,7 +776,6 @@ export class FakeEditor {
|
|
|
769
776
|
getSelection() {
|
|
770
777
|
return rangeIn(this.text, this.selections.at(-1));
|
|
771
778
|
}
|
|
772
|
-
/* The other carets of the editor, which a test sets. */
|
|
773
779
|
get otherCarets() {
|
|
774
780
|
return this.selections.slice(0, -1).map((selection) => positionIn(this.text, selection.head));
|
|
775
781
|
}
|
|
@@ -817,7 +823,6 @@ export class FakeEditor {
|
|
|
817
823
|
onHover(listener) {
|
|
818
824
|
return subscribe(this.hovers, listener);
|
|
819
825
|
}
|
|
820
|
-
/* The pointer resting on a position, or leaving the text. */
|
|
821
826
|
hover(position) {
|
|
822
827
|
const hover = position === null ? null : { position, rect: this.rectAt(position) };
|
|
823
828
|
emit(this.hovers, hover);
|
|
@@ -862,7 +867,6 @@ export class FakeEditor {
|
|
|
862
867
|
click(click) {
|
|
863
868
|
return [...this.clickHandlers].some((handler) => handler(click));
|
|
864
869
|
}
|
|
865
|
-
/* The context menu asked for at a position. */
|
|
866
870
|
openContextMenu(menu) {
|
|
867
871
|
emit(this.contextListeners, menu);
|
|
868
872
|
}
|
|
@@ -971,6 +975,7 @@ export class FakeEditor {
|
|
|
971
975
|
this.finds.clear();
|
|
972
976
|
this.scopes.clear();
|
|
973
977
|
this.tracked.clear();
|
|
978
|
+
this.dropGhost();
|
|
974
979
|
}
|
|
975
980
|
announceFind(state) {
|
|
976
981
|
this.findState = state;
|
package/dist/find.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { DocumentChange, DocumentModel, FindMatch } from '@adecore/editor-core';
|
|
2
2
|
import { type FindSearchOptions } from './find-search.ts';
|
|
3
3
|
import type { EditorFindQuery, EditorFindState } from './types.ts';
|
|
4
|
-
|
|
4
|
+
interface FindMark {
|
|
5
5
|
from: number;
|
|
6
6
|
to: number;
|
|
7
7
|
}
|
|
8
8
|
export declare const FIND_LIMIT = 10000;
|
|
9
|
-
|
|
9
|
+
interface FindControllerOptions extends FindSearchOptions {
|
|
10
10
|
readonly changed: (reveal?: boolean) => void;
|
|
11
11
|
}
|
|
12
12
|
export declare class FindController {
|
|
@@ -76,3 +76,4 @@ export declare class FindController {
|
|
|
76
76
|
replaceAll(replacement: string, preserveCase: boolean, canApply: () => boolean): Promise<number>;
|
|
77
77
|
dispose(): void;
|
|
78
78
|
}
|
|
79
|
+
export {};
|
package/dist/find.js
CHANGED
|
@@ -71,7 +71,6 @@ export class FindController {
|
|
|
71
71
|
...(this.query?.inSelection === true && this.bounds === null ? { noSelection: true } : {})
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
/* The range a search in the selection is held to. */
|
|
75
74
|
get scope() {
|
|
76
75
|
return this.query?.inSelection === true ? this.bounds : null;
|
|
77
76
|
}
|
|
@@ -163,7 +162,6 @@ export class FindController {
|
|
|
163
162
|
}
|
|
164
163
|
this.refresh();
|
|
165
164
|
}
|
|
166
|
-
/* The text of a search in the selection moved with an edit. */
|
|
167
165
|
mapBounds(changes) {
|
|
168
166
|
if (this.pendingAnchor !== undefined) {
|
|
169
167
|
this.pendingAnchor = mapOffset(this.pendingAnchor, changes);
|
package/dist/geometry-stops.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Affinity, LineGeometry } from './
|
|
1
|
+
import type { Affinity, LineGeometry } from './line-geometry.ts';
|
|
2
2
|
export declare function stopCount(geometry: LineGeometry): number;
|
|
3
3
|
export declare function offsetOfStop(geometry: LineGeometry, stop: number): number;
|
|
4
4
|
export declare function rowOfStop(geometry: LineGeometry, stop: number): number;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export { commentSyntax, type CommentSyntax } from '@adecore/editor-core';
|
|
|
7
7
|
export { createSmartEditorEngine } from './engine.ts';
|
|
8
8
|
export { rememberCopy } from './controller.ts';
|
|
9
9
|
export { DEFAULT_SMART_KEYS } from './smart-keys.ts';
|
|
10
|
-
export { shikiScopeColors, shikiTokenizers } from './shiki.ts';
|
|
11
|
-
export type { Editor, EditorAttributionHover, EditorAttributionMark, EditorMarkColor, EditorBlock, EditorChangeKind, EditorChangeMark, EditorChangeMarkHover, EditorCodeVision, EditorCodeVisionEntry, EditorClick, EditorCodeBlockOptions, EditorClickHandler, EditorCommand, EditorContextMenu, EditorEngine, EditorFindQuery, EditorFoldHints, EditorFoldRangeHint, EditorFoldOutline, EditorFoldRange, EditorFoldSymbol, EditorFolds, EditorFindState, EditorReplaceOptions, EditorGutterAction, EditorGutterIcon, EditorGutterMarker, EditorReplacement, EditorIndentation, EditorContentChange, EditorHighlight, EditorHighlightKind, EditorHover, EditorGhostText, EditorInlayClick, EditorInlayClickHandler, EditorInlayHint, EditorInlayTarget, EditorKeyHandler, EditorLineAction, EditorLineHighlight, EditorMarker, EditorInputPopup, EditorMessages, EditorMarkerSeverity, EditorReveal, EditorRect, EditorSmartKeys, EditorOptions, EditorPosition, EditorRemoteCursor, EditorRange, EditorApplyEditsOptions, EditorSetTextOptions, EditorCopy, EditorPasteOptions, EditorPostfixOperand, EditorSurroundShape, EditorTextPlace, EditorUnwrapTarget, EditorTextChange, EditorTrackedRange, EditorRunCommand, EditorSelectionRanges, EditorTheme, EditorViewCommand, EditorWhitespaceCleanup, EditorWidget, EditorZoom, FoldRole,
|
|
10
|
+
export { shikiScopeColors, shikiTokenizers } from './shiki-grammar.ts';
|
|
11
|
+
export type { Editor, EditorAttributionHover, EditorAttributionMark, EditorMarkColor, EditorBlock, EditorChangeKind, EditorChangeMark, EditorChangeMarkHover, EditorCodeVision, EditorCodeVisionEntry, EditorClick, EditorCodeBlockOptions, EditorClickHandler, EditorCommand, EditorContextMenu, EditorEngine, EditorFindQuery, EditorFoldHints, EditorFoldRangeHint, EditorFoldOutline, EditorFoldRange, EditorFoldSymbol, EditorFolds, EditorFindState, EditorReplaceOptions, EditorGutterAction, EditorGutterIcon, EditorGutterMarker, EditorReplacement, EditorIndentation, EditorContentChange, EditorHighlight, EditorHighlightKind, EditorHover, EditorGhostText, EditorInlayClick, EditorInlayClickHandler, EditorInlayHint, EditorInlayTarget, EditorKeyHandler, EditorLineAction, EditorLineHighlight, EditorMarker, EditorInputPopup, EditorMessages, EditorMarkerSeverity, EditorReveal, EditorRect, EditorSmartKeys, EditorOptions, EditorPosition, EditorRemoteCursor, EditorRange, EditorApplyEditsOptions, EditorSetTextOptions, EditorCopy, EditorPasteOptions, EditorPostfixOperand, EditorSurroundShape, EditorTextPlace, EditorUnwrapTarget, EditorTextChange, EditorTrackedRange, EditorRunCommand, EditorSelectionRanges, EditorTheme, EditorViewCommand, EditorWhitespaceCleanup, EditorWidget, EditorZoom, FoldRole, LineToken, LineTokenKind, ScopeColorSource, ScopeColors, ScopeStyle, EditorSemanticToken, LineTokenizer, SmartEditorEngineOptions, TokenizedLine, TokenizerSource } from './types.ts';
|
|
12
|
+
export type { KeyChord } from './keymap-table.ts';
|
package/dist/index.js
CHANGED
|
@@ -7,4 +7,4 @@ export { commentSyntax } from '@adecore/editor-core';
|
|
|
7
7
|
export { createSmartEditorEngine } from './engine.js';
|
|
8
8
|
export { rememberCopy } from './controller.js';
|
|
9
9
|
export { DEFAULT_SMART_KEYS } from './smart-keys.js';
|
|
10
|
-
export { shikiScopeColors, shikiTokenizers } from './shiki.js';
|
|
10
|
+
export { shikiScopeColors, shikiTokenizers } from './shiki-grammar.js';
|
package/dist/keymap-table.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
export interface KeyChord {
|
|
2
|
+
readonly mod: boolean;
|
|
3
|
+
readonly ctrl: boolean;
|
|
4
|
+
readonly meta: boolean;
|
|
5
|
+
readonly alt: boolean;
|
|
6
|
+
readonly shift: boolean;
|
|
7
|
+
readonly key: string;
|
|
8
|
+
}
|
|
2
9
|
export interface TakenKey {
|
|
3
10
|
readonly platform: string;
|
|
4
11
|
readonly by: string;
|
package/dist/keymap-table.js
CHANGED
|
@@ -137,7 +137,6 @@ export const KEYMAP_IDS = Object.keys(KEYMAP);
|
|
|
137
137
|
export function resolveKeymap(overrides = {}) {
|
|
138
138
|
return Object.fromEntries(KEYMAP_IDS.map((id) => [id, { ...KEYMAP[id], ...overrides[id] }]));
|
|
139
139
|
}
|
|
140
|
-
/* The chord of a command on a platform, or null when the platform has none. */
|
|
141
140
|
export function chordOf(id, apple, keymap = KEYMAP) {
|
|
142
141
|
return (keymap[id] ?? KEYMAP[id])[apple ? 'mac' : 'other'];
|
|
143
142
|
}
|
package/dist/keymap.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EditorCommand } from '@adecore/editor-core';
|
|
2
2
|
import { type Keymap } from './keymap-table.ts';
|
|
3
|
-
import type {
|
|
3
|
+
import type { KeyChord } from './keymap-table.ts';
|
|
4
|
+
import type { EditorViewCommand } from './types.ts';
|
|
4
5
|
export interface KeyLike {
|
|
5
6
|
key: string;
|
|
6
7
|
code?: string;
|
package/dist/layout-changes.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DocumentChange } from '@adecore/editor-core';
|
|
2
|
-
|
|
2
|
+
interface LineBounds {
|
|
3
3
|
start: number;
|
|
4
4
|
end: number;
|
|
5
5
|
}
|
|
6
6
|
export declare function lineChangeMapper(batches: readonly (readonly DocumentChange[])[]): (bounds: LineBounds) => LineBounds | null;
|
|
7
|
+
export {};
|
package/dist/layout.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DocumentChange, Position } from '@adecore/editor-core';
|
|
2
|
-
|
|
2
|
+
import type { Affinity, Inlay, LayoutMetrics, LineGeometry } from './line-geometry.ts';
|
|
3
3
|
export interface VerticalWindow {
|
|
4
4
|
top: number;
|
|
5
5
|
bottom: number;
|
|
@@ -9,7 +9,7 @@ export interface SubRowBand {
|
|
|
9
9
|
last: number;
|
|
10
10
|
}
|
|
11
11
|
export declare function subRowBand(top: number, subRows: number, lineHeight: number, window: VerticalWindow, block?: number): SubRowBand;
|
|
12
|
-
|
|
12
|
+
interface LayoutDocument {
|
|
13
13
|
getLineCount(): number;
|
|
14
14
|
getLine(line: number): {
|
|
15
15
|
start: number;
|
|
@@ -19,25 +19,6 @@ export interface LayoutDocument {
|
|
|
19
19
|
};
|
|
20
20
|
positionAt(offset: number): Position;
|
|
21
21
|
}
|
|
22
|
-
export interface LayoutMetrics {
|
|
23
|
-
lineHeight: number;
|
|
24
|
-
charWidth: number;
|
|
25
|
-
tabSize: number;
|
|
26
|
-
measureText(text: string): number;
|
|
27
|
-
measureInlay(text: string): number;
|
|
28
|
-
}
|
|
29
|
-
export interface Inlay {
|
|
30
|
-
id: string;
|
|
31
|
-
at: number;
|
|
32
|
-
text: string;
|
|
33
|
-
tooltip?: string;
|
|
34
|
-
parts?: readonly string[];
|
|
35
|
-
gapLeft?: number;
|
|
36
|
-
gapRight?: number;
|
|
37
|
-
composition?: boolean;
|
|
38
|
-
ghost?: boolean;
|
|
39
|
-
swatch?: string;
|
|
40
|
-
}
|
|
41
22
|
export declare const SWATCH_SIZE = 12;
|
|
42
23
|
export interface BlockWidget {
|
|
43
24
|
id: string;
|
|
@@ -83,45 +64,11 @@ export interface TextRow extends RowBase {
|
|
|
83
64
|
subRows: number;
|
|
84
65
|
replacement?: BlockReplacement;
|
|
85
66
|
}
|
|
86
|
-
|
|
67
|
+
interface BlockRow extends RowBase {
|
|
87
68
|
kind: 'block';
|
|
88
69
|
widget: BlockWidget;
|
|
89
70
|
}
|
|
90
71
|
export type LayoutRow = TextRow | BlockRow;
|
|
91
|
-
export interface TextRun {
|
|
92
|
-
from: number;
|
|
93
|
-
to: number;
|
|
94
|
-
x: number;
|
|
95
|
-
subRow: number;
|
|
96
|
-
text: string;
|
|
97
|
-
}
|
|
98
|
-
export interface InlineBox {
|
|
99
|
-
inlay: Inlay;
|
|
100
|
-
x: number;
|
|
101
|
-
width: number;
|
|
102
|
-
subRow: number;
|
|
103
|
-
}
|
|
104
|
-
export interface LineGeometry {
|
|
105
|
-
start: number;
|
|
106
|
-
end: number;
|
|
107
|
-
next: number;
|
|
108
|
-
text: string;
|
|
109
|
-
offsets: number[];
|
|
110
|
-
before: number[];
|
|
111
|
-
after: number[];
|
|
112
|
-
rowOf: number[];
|
|
113
|
-
rowStarts: number[];
|
|
114
|
-
rowEnds: number[];
|
|
115
|
-
rowTriggers: number[];
|
|
116
|
-
uniform?: {
|
|
117
|
-
first: readonly number[];
|
|
118
|
-
continuation: readonly number[];
|
|
119
|
-
};
|
|
120
|
-
runs: TextRun[];
|
|
121
|
-
inlays: InlineBox[];
|
|
122
|
-
subRows: number;
|
|
123
|
-
width: number;
|
|
124
|
-
}
|
|
125
72
|
export interface LayoutRect {
|
|
126
73
|
x: number;
|
|
127
74
|
y: number;
|
|
@@ -129,7 +76,6 @@ export interface LayoutRect {
|
|
|
129
76
|
height: number;
|
|
130
77
|
}
|
|
131
78
|
export declare const TEXT_PADDING = 0;
|
|
132
|
-
export declare const BOTTOM_PADDING = 8;
|
|
133
79
|
export declare const RIGHT_PADDING = 16;
|
|
134
80
|
export declare function wrapIndent(text: string, metrics: LayoutMetrics, limit: number): number;
|
|
135
81
|
export declare function wrapStops(text: string, offsets: readonly number[], metrics: LayoutMetrics, limit: number): number[];
|
package/dist/layout.js
CHANGED
|
@@ -14,7 +14,7 @@ export function subRowBand(top, subRows, lineHeight, window, block = 1) {
|
|
|
14
14
|
/* The side of a swatch in pixels, without its gaps. */
|
|
15
15
|
export const SWATCH_SIZE = 12;
|
|
16
16
|
export const TEXT_PADDING = 0;
|
|
17
|
-
|
|
17
|
+
const BOTTOM_PADDING = 8;
|
|
18
18
|
export const RIGHT_PADDING = 16;
|
|
19
19
|
/* The room the platform keeps past the widest line, in columns of a space. */
|
|
20
20
|
const ADDITIONAL_COLUMNS = 3;
|
|
@@ -104,7 +104,6 @@ function wrapRows(text, offsets, metrics, limit) {
|
|
|
104
104
|
export function wrapStops(text, offsets, metrics, limit) {
|
|
105
105
|
return wrapRows(text, offsets, metrics, limit).breaks;
|
|
106
106
|
}
|
|
107
|
-
/* A line of text laid out against its metrics; wrapped at `limit` pixels unless that is null. */
|
|
108
107
|
export function scanDenseLine(line, metrics, limit, lineInlays) {
|
|
109
108
|
const text = line.text;
|
|
110
109
|
const offsets = characterOffsets(text);
|
|
@@ -221,7 +220,6 @@ class LineRow {
|
|
|
221
220
|
return `line:${this.line}`;
|
|
222
221
|
}
|
|
223
222
|
}
|
|
224
|
-
/* Sorted, with the ranges that overlap or touch joined. */
|
|
225
223
|
function mergeRanges(ranges) {
|
|
226
224
|
ranges.sort((left, right) => left.first - right.first);
|
|
227
225
|
const merged = [];
|
|
@@ -622,7 +620,6 @@ export class EditorLayout {
|
|
|
622
620
|
const bounds = this.document.getLine(line);
|
|
623
621
|
return Math.min(bounds.end, Math.max(bounds.start, offset));
|
|
624
622
|
}
|
|
625
|
-
/* The tops of the rows from `from` on. */
|
|
626
623
|
reflow(from) {
|
|
627
624
|
const previous = this.rows[from - 1];
|
|
628
625
|
let top = previous === undefined ? 0 : previous.top + previous.height;
|
|
@@ -633,7 +630,6 @@ export class EditorLayout {
|
|
|
633
630
|
}
|
|
634
631
|
this.height = top + BOTTOM_PADDING;
|
|
635
632
|
}
|
|
636
|
-
/* The row of a widget, a replacement or a line by its key. */
|
|
637
633
|
rowByKey(key) {
|
|
638
634
|
if (key.startsWith('line:')) {
|
|
639
635
|
const row = this.rowForLine(Number(key.slice(5)));
|
|
@@ -641,7 +637,6 @@ export class EditorLayout {
|
|
|
641
637
|
}
|
|
642
638
|
return this.keyed.get(key);
|
|
643
639
|
}
|
|
644
|
-
/* A widget's measured height. Returns whether it moved anything. */
|
|
645
640
|
setMeasuredHeight(key, height) {
|
|
646
641
|
const row = this.rowByKey(key);
|
|
647
642
|
const next = Math.max(1, Math.round(height));
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type Affinity = 'before' | 'after';
|
|
2
|
+
export interface LayoutMetrics {
|
|
3
|
+
lineHeight: number;
|
|
4
|
+
charWidth: number;
|
|
5
|
+
tabSize: number;
|
|
6
|
+
measureText(text: string): number;
|
|
7
|
+
measureInlay(text: string): number;
|
|
8
|
+
}
|
|
9
|
+
export interface Inlay {
|
|
10
|
+
id: string;
|
|
11
|
+
at: number;
|
|
12
|
+
text: string;
|
|
13
|
+
tooltip?: string;
|
|
14
|
+
parts?: readonly string[];
|
|
15
|
+
gapLeft?: number;
|
|
16
|
+
gapRight?: number;
|
|
17
|
+
composition?: boolean;
|
|
18
|
+
ghost?: boolean;
|
|
19
|
+
swatch?: string;
|
|
20
|
+
}
|
|
21
|
+
interface TextRun {
|
|
22
|
+
from: number;
|
|
23
|
+
to: number;
|
|
24
|
+
x: number;
|
|
25
|
+
subRow: number;
|
|
26
|
+
text: string;
|
|
27
|
+
}
|
|
28
|
+
interface InlineBox {
|
|
29
|
+
inlay: Inlay;
|
|
30
|
+
x: number;
|
|
31
|
+
width: number;
|
|
32
|
+
subRow: number;
|
|
33
|
+
}
|
|
34
|
+
export interface LineGeometry {
|
|
35
|
+
start: number;
|
|
36
|
+
end: number;
|
|
37
|
+
next: number;
|
|
38
|
+
text: string;
|
|
39
|
+
offsets: number[];
|
|
40
|
+
before: number[];
|
|
41
|
+
after: number[];
|
|
42
|
+
rowOf: number[];
|
|
43
|
+
rowStarts: number[];
|
|
44
|
+
rowEnds: number[];
|
|
45
|
+
rowTriggers: number[];
|
|
46
|
+
uniform?: {
|
|
47
|
+
first: readonly number[];
|
|
48
|
+
continuation: readonly number[];
|
|
49
|
+
};
|
|
50
|
+
runs: TextRun[];
|
|
51
|
+
inlays: InlineBox[];
|
|
52
|
+
subRows: number;
|
|
53
|
+
width: number;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/metrics.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface GestureEvent {
|
|
|
7
7
|
metaKey: boolean;
|
|
8
8
|
shiftKey: boolean;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
type GestureAction = 'above' | 'below';
|
|
11
11
|
export declare class DoubleModifierGesture {
|
|
12
12
|
private firstPressed;
|
|
13
13
|
private firstReleased;
|
|
@@ -22,3 +22,4 @@ export declare class DoubleModifierGesture {
|
|
|
22
22
|
keyup(event: GestureEvent): void;
|
|
23
23
|
private step;
|
|
24
24
|
}
|
|
25
|
+
export {};
|
package/dist/modifier-gesture.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* press an arrow, which Option does on macOS and Ctrl elsewhere. The taps have to follow each other
|
|
4
4
|
* within a third of a second; the arrow can come as long as the modifier stays down.
|
|
5
5
|
*/
|
|
6
|
-
/* How long the taps may be apart. */
|
|
7
6
|
const TAP_MS = 300;
|
|
8
7
|
/* A first tap this old is forgotten even by a press that comes after the slower rule. */
|
|
9
8
|
const FORGET_MS = 500;
|