@adecore/editor 0.0.1 → 0.17.0-beta.2

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.
Files changed (107) hide show
  1. package/LICENSE +110 -0
  2. package/README.md +57 -0
  3. package/dist/attribution.d.ts +28 -0
  4. package/dist/attribution.js +55 -0
  5. package/dist/code-block.d.ts +2 -0
  6. package/dist/code-block.js +89 -0
  7. package/dist/column-selection.d.ts +9 -0
  8. package/dist/column-selection.js +52 -0
  9. package/dist/controller.d.ts +64 -0
  10. package/dist/controller.js +772 -0
  11. package/dist/editor.css +813 -0
  12. package/dist/engine.d.ts +2 -0
  13. package/dist/engine.js +610 -0
  14. package/dist/fake.d.ts +192 -0
  15. package/dist/fake.js +663 -0
  16. package/dist/find.d.ts +30 -0
  17. package/dist/find.js +108 -0
  18. package/dist/index.d.ts +5 -0
  19. package/dist/index.js +4 -0
  20. package/dist/input.d.ts +9 -0
  21. package/dist/input.js +57 -0
  22. package/dist/keymap-table.d.ts +102 -0
  23. package/dist/keymap-table.js +130 -0
  24. package/dist/keymap.d.ts +36 -0
  25. package/dist/keymap.js +163 -0
  26. package/dist/layout.d.ts +167 -0
  27. package/dist/layout.js +583 -0
  28. package/dist/lens.d.ts +3 -0
  29. package/dist/lens.js +29 -0
  30. package/dist/listeners.d.ts +3 -0
  31. package/dist/listeners.js +12 -0
  32. package/dist/metrics.d.ts +8 -0
  33. package/dist/metrics.js +54 -0
  34. package/dist/modifier-gesture.d.ts +24 -0
  35. package/dist/modifier-gesture.js +98 -0
  36. package/dist/native-input.d.ts +26 -0
  37. package/dist/native-input.js +147 -0
  38. package/dist/offsets.d.ts +2 -0
  39. package/dist/offsets.js +14 -0
  40. package/dist/outline.d.ts +55 -0
  41. package/dist/outline.js +181 -0
  42. package/dist/overview.d.ts +17 -0
  43. package/dist/overview.js +55 -0
  44. package/dist/paint.d.ts +86 -0
  45. package/dist/paint.js +481 -0
  46. package/dist/php-html.d.ts +9 -0
  47. package/dist/php-html.js +36 -0
  48. package/dist/pointer.d.ts +49 -0
  49. package/dist/pointer.js +243 -0
  50. package/dist/scroll-animation.d.ts +3 -0
  51. package/dist/scroll-animation.js +45 -0
  52. package/dist/scroll.d.ts +28 -0
  53. package/dist/scroll.js +76 -0
  54. package/dist/semantic.d.ts +8 -0
  55. package/dist/semantic.js +47 -0
  56. package/dist/shiki.d.ts +7 -0
  57. package/dist/shiki.js +106 -0
  58. package/dist/smart-keys.d.ts +3 -0
  59. package/dist/smart-keys.js +14 -0
  60. package/dist/testing.d.ts +34 -0
  61. package/dist/testing.js +117 -0
  62. package/dist/theme-scopes.d.ts +9 -0
  63. package/dist/theme-scopes.js +61 -0
  64. package/dist/tokens.d.ts +28 -0
  65. package/dist/tokens.js +152 -0
  66. package/dist/tracked-range.d.ts +5 -0
  67. package/dist/tracked-range.js +20 -0
  68. package/dist/types.d.ts +344 -0
  69. package/dist/types.js +1 -0
  70. package/dist/view.d.ts +383 -0
  71. package/dist/view.js +2134 -0
  72. package/package.json +63 -3
  73. package/src/attribution.ts +85 -0
  74. package/src/code-block.ts +100 -0
  75. package/src/column-selection.ts +63 -0
  76. package/src/controller.ts +838 -0
  77. package/src/editor.css +813 -0
  78. package/src/engine.ts +764 -0
  79. package/src/fake.ts +838 -0
  80. package/src/find.ts +128 -0
  81. package/src/index.ts +69 -0
  82. package/src/input.ts +63 -0
  83. package/src/keymap-table.ts +163 -0
  84. package/src/keymap.ts +204 -0
  85. package/src/layout.ts +754 -0
  86. package/src/lens.ts +32 -0
  87. package/src/listeners.ts +15 -0
  88. package/src/metrics.ts +65 -0
  89. package/src/modifier-gesture.ts +115 -0
  90. package/src/native-input.ts +179 -0
  91. package/src/offsets.ts +16 -0
  92. package/src/outline.ts +248 -0
  93. package/src/overview.ts +80 -0
  94. package/src/paint.ts +608 -0
  95. package/src/php-html.ts +43 -0
  96. package/src/pointer.ts +326 -0
  97. package/src/scroll-animation.ts +48 -0
  98. package/src/scroll.ts +102 -0
  99. package/src/semantic.ts +54 -0
  100. package/src/shiki.ts +118 -0
  101. package/src/smart-keys.ts +17 -0
  102. package/src/testing.ts +157 -0
  103. package/src/theme-scopes.ts +75 -0
  104. package/src/tokens.ts +175 -0
  105. package/src/tracked-range.ts +22 -0
  106. package/src/types.ts +659 -0
  107. package/src/view.ts +2437 -0
package/LICENSE ADDED
@@ -0,0 +1,110 @@
1
+ # Functional Source License, Version 1.1, MIT Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-MIT
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 - present Bas Milius
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the MIT license that is effective on the second anniversary of the date we make
91
+ the Software available. On or after that date, you may use the Software under
92
+ the MIT license, in which case the following will apply:
93
+
94
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
95
+ this software and associated documentation files (the "Software"), to deal in
96
+ the Software without restriction, including without limitation the rights to
97
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98
+ of the Software, and to permit persons to whom the Software is furnished to do
99
+ so, subject to the following conditions:
100
+
101
+ The above copyright notice and this permission notice shall be included in all
102
+ copies or substantial portions of the Software.
103
+
104
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # @adecore/editor
2
+
3
+ [![npm](https://img.shields.io/npm/v/@adecore/editor)](https://www.npmjs.com/package/@adecore/editor)
4
+ [![Docs](https://img.shields.io/badge/docs-adecore.dev-blue)](https://adecore.dev/editor/)
5
+
6
+ A code editor for the DOM. It draws a [`DocumentModel`](https://adecore.dev/editor-core/) with a layout of its own, renders only the rows in view, and takes the decorations, rows and marks a host hands it: problems, inlay hints, semantic colors, change marks, widgets between lines, code vision, agent attribution and ghost text. It knows no language server; [`@adecore/editor-react`](https://adecore.dev/editor-react/) adds one.
7
+
8
+ **[Documentation with live demos](https://adecore.dev/editor/)**
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ bun add @adecore/editor
14
+ ```
15
+
16
+ ## Set up
17
+
18
+ ```css
19
+ @import '@adecore/ui/theme.css';
20
+ @import '@adecore/editor/editor.css';
21
+ ```
22
+
23
+ ```ts
24
+ import { createSmartEditorEngine, shikiTokenizers } from '@adecore/editor';
25
+
26
+ const engine = createSmartEditorEngine({ tokenizer: shikiTokenizers(getHighlighter) });
27
+ const editor = engine.mount(element, { text, language: 'typescript', theme: 'github-light' });
28
+ ```
29
+
30
+ The element needs a position and a size from its parent.
31
+
32
+ ## Entry points
33
+
34
+ | Import | What it holds |
35
+ |---|---|
36
+ | `@adecore/editor` | `createSmartEditorEngine`, the `Editor` contract and its types, the Shiki adapters |
37
+ | `@adecore/editor/editor.css` | The styles |
38
+ | `@adecore/editor/shiki` | The Shiki adapters and grammar loading |
39
+ | `@adecore/editor/keymap` | The key table, `resolveKeymap`, `chordOf` and `parseChord` |
40
+ | `@adecore/editor/fake` | `FakeEditorEngine`, for tests of host code |
41
+ | `@adecore/editor/testing` | `mountEditor` on a LinkeDOM page |
42
+
43
+ ## Documentation
44
+
45
+ | Page | What it covers |
46
+ |---|---|
47
+ | [Getting started](https://adecore.dev/editor/getting-started) | Install, styles, mounting and the engine options |
48
+ | [Options and keymaps](https://adecore.dev/editor/options) | Every option and setter, smart keys and the key table |
49
+ | [Text and events](https://adecore.dev/editor/editing) | Positions, edits, selections, events and tracked ranges |
50
+ | [Decorations](https://adecore.dev/editor/decorations), [Rows and widgets](https://adecore.dev/editor/rows), [Agents](https://adecore.dev/editor/agents) | What a host draws into the editor |
51
+ | [Find and folding](https://adecore.dev/editor/find-folding) | The find matcher, folds and sticky scroll |
52
+ | [Theme and syntax](https://adecore.dev/editor/theme) | CSS tokens, Shiki and a tokenizer of your own |
53
+ | [Testing](https://adecore.dev/editor/testing) | `mountEditor` and `FakeEditorEngine` |
54
+
55
+ ## License
56
+
57
+ FSL-1.1-MIT
@@ -0,0 +1,28 @@
1
+ import type { DocumentChange } from '@adecore/editor-core';
2
+ export declare const AGENT_COLORS: readonly ['--agent-1', '--agent-2', '--agent-3', '--agent-4', '--agent-5', '--agent-6'];
3
+ export interface AttributedLines {
4
+ readonly id: string;
5
+ readonly color: string;
6
+ readonly sign?: string;
7
+ readonly fill?: string;
8
+ }
9
+ export declare function tintValue(color: string): string;
10
+ export declare function colorValue(color: string): string;
11
+ export declare class AttributionRuns {
12
+ private runs;
13
+ get size(): number;
14
+ set(marks: readonly {
15
+ id: string;
16
+ startLine: number;
17
+ endLine: number;
18
+ color: string;
19
+ sign?: string;
20
+ fill?: string;
21
+ }[], lineCount: number, lineBounds: (line: number) => {
22
+ start: number;
23
+ end: number;
24
+ }): void;
25
+ clear(): void;
26
+ map(changes: readonly DocumentChange[]): void;
27
+ linesIn(first: number, last: number, from: number, to: number, lineOf: (offset: number) => number): Map<number, AttributedLines>;
28
+ }
@@ -0,0 +1,55 @@
1
+ import { mapOffset } from './offsets.js';
2
+ /* The custom properties of the agent palette, defined in `editor.css` for both themes. */
3
+ export const AGENT_COLORS = ['--agent-1', '--agent-2', '--agent-3', '--agent-4', '--agent-5', '--agent-6'];
4
+ /* A color washed out to a background that text stays readable on in either theme. */
5
+ export function tintValue(color) {
6
+ return `color-mix(in srgb, ${colorValue(color)} 14%, transparent)`;
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
+ export function colorValue(color) {
10
+ return color.startsWith('--') ? `var(${color})` : color;
11
+ }
12
+ /*
13
+ * The runs of lines a host attributed, anchored by offsets so they follow their text through edits. An
14
+ * edit costs one mapping of two offsets per run, and a read works out the lines of only the runs that
15
+ * reach the lines asked for.
16
+ */
17
+ export class AttributionRuns {
18
+ runs = [];
19
+ get size() {
20
+ return this.runs.length;
21
+ }
22
+ /* Marks name lines one-based and inclusive; `lineBounds` answers for the document as it is now. */
23
+ set(marks, lineCount, lineBounds) {
24
+ const clamp = (line) => Math.min(lineCount, Math.max(1, Math.trunc(line) || 1)) - 1;
25
+ this.runs = marks.map((mark) => {
26
+ const start = clamp(mark.startLine);
27
+ const end = Math.max(start, clamp(mark.endLine));
28
+ return { id: mark.id, color: mark.color, sign: mark.sign, fill: mark.fill, from: lineBounds(start).start, to: lineBounds(end).end };
29
+ });
30
+ }
31
+ clear() {
32
+ this.runs = [];
33
+ }
34
+ map(changes) {
35
+ for (const run of this.runs) {
36
+ run.from = mapOffset(run.from, changes);
37
+ run.to = mapOffset(run.to, changes);
38
+ }
39
+ }
40
+ /* The run on each line from `first` to `last`, zero-based, where `from` and `to` are the offsets they span; where runs overlap the one set last wins. */
41
+ linesIn(first, last, from, to, lineOf) {
42
+ const lines = new Map();
43
+ for (const run of this.runs) {
44
+ if (run.to < from || run.from > to) {
45
+ continue;
46
+ }
47
+ const value = { id: run.id, color: run.color, sign: run.sign, fill: run.fill };
48
+ const end = Math.min(Math.max(lineOf(run.from), lineOf(run.to)), last);
49
+ for (let line = Math.max(lineOf(run.from), first); line <= end; line++) {
50
+ lines.set(line, value);
51
+ }
52
+ }
53
+ return lines;
54
+ }
55
+ }
@@ -0,0 +1,2 @@
1
+ import type { EditorCodeBlockOptions, LineToken } from './types.ts';
2
+ export declare function renderCodeBlock(container: HTMLElement, text: string, tokens: readonly (readonly LineToken[])[] | null, tabSize: number, options: EditorCodeBlockOptions): void;
@@ -0,0 +1,89 @@
1
+ import { colorValue, tintValue } from './attribution.js';
2
+ import { styleSpan } from './paint.js';
3
+ /*
4
+ * Lines of code that are not part of the document, in the editor's own face, colors and gutter, for a
5
+ * widget row to show text that is not in the file: lines an agent removed, or the other side of a
6
+ * conflict. The gutter column is as wide as the editor's, so the text lines up with the document's.
7
+ */
8
+ export function renderCodeBlock(container, text, tokens, tabSize, options) {
9
+ const document = container.ownerDocument;
10
+ const block = document.createElement('div');
11
+ block.className = 'se-code-block';
12
+ block.style.tabSize = String(tabSize);
13
+ const lines = text.split(/\r?\n/);
14
+ lines.forEach((line, index) => {
15
+ const row = document.createElement('div');
16
+ row.className = 'se-code-row';
17
+ if (options.color !== undefined) {
18
+ row.style.background = tintValue(options.color);
19
+ }
20
+ const gutter = document.createElement('div');
21
+ gutter.className = 'se-code-gutter';
22
+ if (options.firstLine !== undefined) {
23
+ const number = document.createElement('span');
24
+ number.textContent = String(options.firstLine + index);
25
+ gutter.append(number);
26
+ }
27
+ if (options.sign) {
28
+ const sign = document.createElement('span');
29
+ sign.className = 'se-line-sign';
30
+ sign.textContent = options.sign;
31
+ if (options.color !== undefined) {
32
+ sign.style.color = colorValue(options.color);
33
+ }
34
+ gutter.append(sign);
35
+ }
36
+ if (options.color !== undefined) {
37
+ const bar = document.createElement('span');
38
+ bar.className = 'se-attribution';
39
+ bar.style.background = colorValue(options.color);
40
+ gutter.append(bar);
41
+ }
42
+ const code = document.createElement('div');
43
+ code.className = 'se-code-text';
44
+ if (options.faded) {
45
+ code.dataset.faded = 'true';
46
+ }
47
+ const emphasis = options.emphasis?.[index] ?? [];
48
+ if (emphasis.length > 0 && options.color !== undefined) {
49
+ row.style.setProperty('--se-emphasis', colorValue(options.color));
50
+ }
51
+ fill(code, line, tokens?.[index] ?? null, emphasis);
52
+ row.append(gutter, code);
53
+ block.append(row);
54
+ });
55
+ container.append(block);
56
+ }
57
+ function fill(element, line, tokens, emphasis) {
58
+ if (tokens === null && emphasis.length === 0) {
59
+ element.textContent = line;
60
+ return;
61
+ }
62
+ const spans = [];
63
+ let start = 0;
64
+ for (const token of tokens ?? []) {
65
+ const end = Math.min(line.length, start + token.length);
66
+ if (end > start) {
67
+ spans.push({ start, end, token });
68
+ }
69
+ start = end;
70
+ }
71
+ if (start < line.length) {
72
+ spans.push({ start, end: line.length, token: null });
73
+ }
74
+ for (const { start: from, end: to, token } of spans) {
75
+ // A token is cut at the edges of every emphasis that crosses it, so each piece is one color and either on or off.
76
+ const cuts = [...new Set([from, to, ...emphasis.flatMap((range) => range).filter((cut) => cut > from && cut < to)])].sort((left, right) => left - right);
77
+ for (let i = 0; i < cuts.length - 1; i++) {
78
+ const piece = element.ownerDocument.createElement('span');
79
+ piece.textContent = line.slice(cuts[i], cuts[i + 1]);
80
+ if (token !== null) {
81
+ styleSpan(piece, token);
82
+ }
83
+ if (emphasis.some(([emphasisStart, emphasisEnd]) => emphasisStart <= cuts[i] && cuts[i + 1] <= emphasisEnd)) {
84
+ piece.className = 'se-code-emphasis';
85
+ }
86
+ element.append(piece);
87
+ }
88
+ }
89
+ }
@@ -0,0 +1,9 @@
1
+ import type { Selection } from '@adecore/editor-core';
2
+ import { type EditorLayout } from './layout.ts';
3
+ export interface ContentPoint {
4
+ x: number;
5
+ y: number;
6
+ }
7
+ export declare function cellAt(layout: EditorLayout, x: number): number;
8
+ export declare function columnSelections(layout: EditorLayout, from: ContentPoint, to: ContentPoint): Selection[];
9
+ export declare function sameCell(layout: EditorLayout, from: ContentPoint, to: ContentPoint): boolean;
@@ -0,0 +1,52 @@
1
+ import { TEXT_PADDING } from './layout.js';
2
+ /* 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. */
3
+ export function cellAt(layout, x) {
4
+ return Math.max(0, Math.round((x - TEXT_PADDING) / layout.metrics.charWidth));
5
+ }
6
+ /*
7
+ * One selection per line between two points, each spanning the same visual columns, the way a column
8
+ * (box) selection works. A line that ends before the box starts has no text in it: it gets a caret at
9
+ * its end when the box is only a column of carets, and none otherwise.
10
+ */
11
+ export function columnSelections(layout, from, to) {
12
+ const { charWidth } = layout.metrics;
13
+ const document = layout.document;
14
+ const fromLine = document.positionAt(layout.hitTest(from.x, from.y)).line;
15
+ const toLine = document.positionAt(layout.hitTest(to.x, to.y)).line;
16
+ const fromCell = cellAt(layout, from.x);
17
+ const toCell = cellAt(layout, to.x);
18
+ const left = Math.min(fromCell, toCell);
19
+ const right = Math.max(fromCell, toCell);
20
+ const reversed = toCell < fromCell;
21
+ const result = [];
22
+ for (let line = Math.min(fromLine, toLine); line <= Math.max(fromLine, toLine); line++) {
23
+ const row = layout.rowForLine(line);
24
+ if (row.kind !== 'text' || layout.isHidden(line)) {
25
+ continue;
26
+ }
27
+ const geometry = layout.geometry(row);
28
+ const endX = geometry.rowStarts.length > 1 ? geometry.rowEnds[0] : geometry.before[geometry.before.length - 1];
29
+ const offsetAt = (cell) => layout.offsetAtX(geometry, 0, TEXT_PADDING + cell * charWidth).offset;
30
+ if (cellAt(layout, endX + TEXT_PADDING) < left) {
31
+ if (left === right) {
32
+ const end = document.getLine(line).end;
33
+ result.push({ anchor: end, head: end });
34
+ }
35
+ continue;
36
+ }
37
+ const start = offsetAt(left);
38
+ const end = offsetAt(right);
39
+ result.push(reversed ? { anchor: end, head: start } : { anchor: start, head: end });
40
+ }
41
+ if (result.length === 0) {
42
+ const end = document.getLine(toLine).end;
43
+ result.push({ anchor: end, head: end });
44
+ }
45
+ return result;
46
+ }
47
+ /* Whether two points are in the same cell of the same line, which makes a press with alt a click and not yet a box. */
48
+ export function sameCell(layout, from, to) {
49
+ const document = layout.document;
50
+ return (cellAt(layout, from.x) === cellAt(layout, to.x) &&
51
+ document.positionAt(layout.hitTest(from.x, from.y)).line === document.positionAt(layout.hitTest(to.x, to.y)).line);
52
+ }
@@ -0,0 +1,64 @@
1
+ import type { Keymap } from './keymap-table.ts';
2
+ import type { EditorClickHandler, EditorContextMenu, EditorKeyHandler, EditorRunCommand, EditorSelectionRanges, KeyChord } from './types.ts';
3
+ import type { EditorView } from './view.ts';
4
+ export interface ControllerOptions {
5
+ keymap?: Keymap;
6
+ handBack: readonly KeyChord[];
7
+ apple: boolean;
8
+ save(): void;
9
+ blur(): void;
10
+ }
11
+ export declare class InputController {
12
+ private readonly native;
13
+ private readonly pointer;
14
+ private readonly cleanup;
15
+ private readonly keyHandlers;
16
+ private readonly gesture;
17
+ private readonly clickHandlers;
18
+ private readonly contextListeners;
19
+ private readonly subscription;
20
+ private historyGroup;
21
+ private block;
22
+ private selectionRanges;
23
+ private expansions;
24
+ private lastInputAt;
25
+ private desiredXs;
26
+ private keepDesiredXs;
27
+ private readonly view;
28
+ private readonly options;
29
+ constructor(view: EditorView, options: ControllerOptions);
30
+ private listen;
31
+ private attach;
32
+ dispose(): void;
33
+ private blockedByReadOnly;
34
+ private inputGroup;
35
+ private applyEdits;
36
+ private replaceSelections;
37
+ private paste;
38
+ private commandOptions;
39
+ private viewCommand;
40
+ command(name: EditorRunCommand): boolean;
41
+ setSelectionRanges(provider: EditorSelectionRanges | null): void;
42
+ private expandThrough;
43
+ private modelCommand;
44
+ private typeText;
45
+ private movePages;
46
+ private toggleColumnMode;
47
+ private extendBlock;
48
+ private moveCarets;
49
+ private dropText;
50
+ private goToMatchingBracket;
51
+ private run;
52
+ onKeyDown(handler: EditorKeyHandler): () => void;
53
+ onClick(handler: EditorClickHandler): () => void;
54
+ onContextMenu(listener: (menu: EditorContextMenu) => void): () => void;
55
+ private keydown;
56
+ private beforeInput;
57
+ private copy;
58
+ private pointerDown;
59
+ private takenByHost;
60
+ private positionOf;
61
+ private contextMenu;
62
+ private stickyDown;
63
+ private gutterDown;
64
+ }