@noldova/code.editor.angular 0.0.0-stage → 0.0.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.
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/api/index.d.ts +30 -0
- package/api/index.js +27 -0
- package/app/components/code-editor/code-editor.component.d.ts +332 -0
- package/app/components/code-editor/code-editor.component.js +648 -0
- package/app/components/code-text/code-text.component.d.ts +70 -0
- package/app/components/code-text/code-text.component.js +40 -0
- package/app/components/find-bar/find-bar.component.d.ts +40 -0
- package/app/components/find-bar/find-bar.component.js +95 -0
- package/app/enums/code-row-kind.d.ts +14 -0
- package/app/enums/code-row-kind.js +15 -0
- package/app/enums/fold-shortcut.d.ts +11 -0
- package/app/enums/fold-shortcut.js +12 -0
- package/app/exceptions/background-job-failed.exception.d.ts +33 -0
- package/app/exceptions/background-job-failed.exception.js +15 -0
- package/app/interfaces/i-code-decorations.d.ts +103 -0
- package/app/interfaces/i-code-decorations.js +7 -0
- package/app/interfaces/i-code-editor-view.d.ts +13 -0
- package/app/interfaces/i-code-editor-view.js +7 -0
- package/app/interfaces/i-code-numbering.d.ts +38 -0
- package/app/interfaces/i-code-numbering.js +7 -0
- package/app/models/code-editor-view.d.ts +18 -0
- package/app/models/code-editor-view.js +26 -0
- package/app/models/code-search.d.ts +18 -0
- package/app/models/code-search.js +52 -0
- package/app/models/code-text-line.d.ts +17 -0
- package/app/models/code-text-line.js +42 -0
- package/app/models/code-text-span.d.ts +15 -0
- package/app/models/code-text-span.js +19 -0
- package/app/models/decorations/code-bar-action-event.d.ts +39 -0
- package/app/models/decorations/code-bar-action-event.js +15 -0
- package/app/models/decorations/code-bar-action.d.ts +40 -0
- package/app/models/decorations/code-bar-action.js +17 -0
- package/app/models/decorations/code-bar.d.ts +78 -0
- package/app/models/decorations/code-bar.js +34 -0
- package/app/models/decorations/code-decorations.d.ts +121 -0
- package/app/models/decorations/code-decorations.js +42 -0
- package/app/models/decorations/code-gutter-marker.d.ts +46 -0
- package/app/models/decorations/code-gutter-marker.js +20 -0
- package/app/models/decorations/code-line-decoration.d.ts +48 -0
- package/app/models/decorations/code-line-decoration.js +21 -0
- package/app/models/decorations/code-range-decoration.d.ts +44 -0
- package/app/models/decorations/code-range-decoration.js +15 -0
- package/app/models/folding/code-block.d.ts +17 -0
- package/app/models/folding/code-block.js +21 -0
- package/app/models/folding/code-blocks.d.ts +17 -0
- package/app/models/folding/code-blocks.js +32 -0
- package/app/models/folding/code-fold.d.ts +53 -0
- package/app/models/folding/code-fold.js +23 -0
- package/app/models/folding/fold-shortcuts.d.ts +14 -0
- package/app/models/folding/fold-shortcuts.js +17 -0
- package/app/models/language-tokenizer.d.ts +39 -0
- package/app/models/language-tokenizer.js +22 -0
- package/app/models/rows/code-embedded-lines.d.ts +76 -0
- package/app/models/rows/code-embedded-lines.js +43 -0
- package/app/models/rows/code-inserted-rows.d.ts +19 -0
- package/app/models/rows/code-inserted-rows.js +7 -0
- package/app/models/rows/code-row.d.ts +27 -0
- package/app/models/rows/code-row.js +31 -0
- package/app/models/rows/code-spacer.d.ts +61 -0
- package/app/models/rows/code-spacer.js +30 -0
- package/app/models/rows/inserted-rows.d.ts +12 -0
- package/app/models/rows/inserted-rows.js +18 -0
- package/app/models/rows/layer-lines.d.ts +18 -0
- package/app/models/rows/layer-lines.js +17 -0
- package/app/models/rows/layout-row.d.ts +14 -0
- package/app/models/rows/layout-row.js +17 -0
- package/app/models/rows/line-index.d.ts +58 -0
- package/app/models/rows/line-index.js +50 -0
- package/app/models/rows/row-builder.d.ts +35 -0
- package/app/models/rows/row-builder.js +87 -0
- package/app/models/rows/row-layout.d.ts +22 -0
- package/app/models/rows/row-layout.js +58 -0
- package/app/models/rows/row-span.d.ts +13 -0
- package/app/models/rows/row-span.js +17 -0
- package/app/models/shapes/bar-shape.d.ts +13 -0
- package/app/models/shapes/bar-shape.js +15 -0
- package/app/models/shapes/change-shape.d.ts +14 -0
- package/app/models/shapes/change-shape.js +19 -0
- package/app/models/shapes/code-shape.d.ts +14 -0
- package/app/models/shapes/code-shape.js +19 -0
- package/app/models/shapes/match-shape.d.ts +14 -0
- package/app/models/shapes/match-shape.js +19 -0
- package/app/models/text-measure.d.ts +18 -0
- package/app/models/text-measure.js +50 -0
- package/app/models/view-command.d.ts +16 -0
- package/app/models/view-command.js +24 -0
- package/app/services/background-ticker.d.ts +47 -0
- package/app/services/background-ticker.js +34 -0
- package/app/services/code-editor-classes.d.ts +102 -0
- package/app/services/code-editor-classes.js +30 -0
- package/app/services/code-editor-contribution.d.ts +20 -0
- package/app/services/code-editor-contribution.js +41 -0
- package/app/services/code-editor-features.d.ts +13 -0
- package/app/services/code-editor-features.js +13 -0
- package/app/services/code-editor-registries.d.ts +43 -0
- package/app/services/code-editor-registries.js +23 -0
- package/app/services/key-scope.d.ts +79 -0
- package/app/services/key-scope.js +53 -0
- package/app/services/token-style-sheet.d.ts +11 -0
- package/app/services/token-style-sheet.js +44 -0
- package/app/services/worker-runner.d.ts +87 -0
- package/app/services/worker-runner.js +84 -0
- package/package.json +38 -4
- package/resources.d.ts +124 -0
- package/resources.js +137 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Noldova
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @noldova/code.editor.angular
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The code editor's views in Angular: `CodeEditorComponent`, the `noldova-code-editor` code view, and `CodeTextComponent`, a read-only code block.
|
|
4
|
+
Every edit, undo step, caret move and search goes through `@noldova/code.editor`'s core; the views render the lines in view and send input to it.
|
|
5
|
+
Each view takes a `language`, an id in the app's `CodeEditorRegistries` or a definition, and makes its tokenizer through the app's highlighters with `LanguageTokenizer`, showing the text plain until the tokenizer is ready.
|
|
6
|
+
The code view takes layers of decorations, `CodeDecorations` or any `ICodeDecorations`, each with line backgrounds, character ranges, gutter markers, inserted rows (`CodeBar`, `CodeSpacer`, `CodeEmbeddedLines`) and an optional second numbering; a later layer paints over an earlier one.
|
|
7
|
+
It also takes `CodeFold`s, which collapse to one row and keep a gutter toggle when expanded, and tells its owner of a toggle by `foldToggle` and of a bar's action by `barAction`.
|
|
8
|
+
`@noldova/code.editor.diff.angular`'s diff view is built on that API, and `@noldova/code.editor.merge.angular`'s merge view too.
|
|
9
|
+
They are styled only with the interface kit's tokens, so the page that shows them loads the kit's `kit.css` and `theme.css`, as the tests' page does.
|
|
10
|
+
The code view's element takes six custom properties, each with the kit's value when unset: `--nol-code-editor-font-size` and `--nol-code-editor-line-height` for its text, `--nol-code-editor-gutter-width` for the gutter's least width and `--nol-code-editor-gutter-end` for the space after its numbers, `--nol-code-editor-signs` set to `none` to hide the gutter's signs, and `--nol-code-editor-inset` for the space before the text; the merge view sets them on its panes.
|
|
11
|
+
`WorkerRunner` runs any package's background jobs in a web worker whose script serves them through the core's `WorkerJobHost`, importing no Angular, and runs a job the worker doesn't serve, or every job once the worker fails, on its fallback runner; `KeyScope`, which shares one key dispatcher between a view and the code views inside it, `LanguageTokenizer`, `LineIndex` and `BackgroundTicker` are the helpers other view packages build on.
|
|
12
|
+
|
|
13
|
+
[documents/ARCHITECTURE.md](../../documents/ARCHITECTURE.md) says how the views are built.
|
package/api/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export { CodeBar } from "../app/models/decorations/code-bar.js";
|
|
9
|
+
export { CodeBarAction } from "../app/models/decorations/code-bar-action.js";
|
|
10
|
+
export { CodeBarActionEvent } from "../app/models/decorations/code-bar-action-event.js";
|
|
11
|
+
export { CodeDecorations } from "../app/models/decorations/code-decorations.js";
|
|
12
|
+
export { CodeEditorClasses } from "../app/services/code-editor-classes.js";
|
|
13
|
+
export { CodeEditorComponent } from "../app/components/code-editor/code-editor.component.js";
|
|
14
|
+
export { CodeEditorRegistries } from "../app/services/code-editor-registries.js";
|
|
15
|
+
export { CodeEmbeddedLines } from "../app/models/rows/code-embedded-lines.js";
|
|
16
|
+
export { CodeFold } from "../app/models/folding/code-fold.js";
|
|
17
|
+
export { CodeGutterMarker } from "../app/models/decorations/code-gutter-marker.js";
|
|
18
|
+
export type { CodeInsertedRows } from "../app/models/rows/code-inserted-rows.js";
|
|
19
|
+
export { CodeLineDecoration } from "../app/models/decorations/code-line-decoration.js";
|
|
20
|
+
export { CodeRangeDecoration } from "../app/models/decorations/code-range-decoration.js";
|
|
21
|
+
export { CodeSpacer } from "../app/models/rows/code-spacer.js";
|
|
22
|
+
export { CodeTextComponent } from "../app/components/code-text/code-text.component.js";
|
|
23
|
+
export type { ICodeDecorations } from "../app/interfaces/i-code-decorations.js";
|
|
24
|
+
export type { ICodeNumbering } from "../app/interfaces/i-code-numbering.js";
|
|
25
|
+
export { BackgroundJobFailedException } from "../app/exceptions/background-job-failed.exception.js";
|
|
26
|
+
export { KeyScope } from "../app/services/key-scope.js";
|
|
27
|
+
export { LanguageTokenizer } from "../app/models/language-tokenizer.js";
|
|
28
|
+
export { LineIndex } from "../app/models/rows/line-index.js";
|
|
29
|
+
export { BackgroundTicker } from "../app/services/background-ticker.js";
|
|
30
|
+
export { WorkerRunner } from "../app/services/worker-runner.js";
|
package/api/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export { CodeBar } from "../app/models/decorations/code-bar.js";
|
|
9
|
+
export { CodeBarAction } from "../app/models/decorations/code-bar-action.js";
|
|
10
|
+
export { CodeBarActionEvent } from "../app/models/decorations/code-bar-action-event.js";
|
|
11
|
+
export { CodeDecorations } from "../app/models/decorations/code-decorations.js";
|
|
12
|
+
export { CodeEditorClasses } from "../app/services/code-editor-classes.js";
|
|
13
|
+
export { CodeEditorComponent } from "../app/components/code-editor/code-editor.component.js";
|
|
14
|
+
export { CodeEditorRegistries } from "../app/services/code-editor-registries.js";
|
|
15
|
+
export { CodeEmbeddedLines } from "../app/models/rows/code-embedded-lines.js";
|
|
16
|
+
export { CodeFold } from "../app/models/folding/code-fold.js";
|
|
17
|
+
export { CodeGutterMarker } from "../app/models/decorations/code-gutter-marker.js";
|
|
18
|
+
export { CodeLineDecoration } from "../app/models/decorations/code-line-decoration.js";
|
|
19
|
+
export { CodeRangeDecoration } from "../app/models/decorations/code-range-decoration.js";
|
|
20
|
+
export { CodeSpacer } from "../app/models/rows/code-spacer.js";
|
|
21
|
+
export { CodeTextComponent } from "../app/components/code-text/code-text.component.js";
|
|
22
|
+
export { BackgroundJobFailedException } from "../app/exceptions/background-job-failed.exception.js";
|
|
23
|
+
export { KeyScope } from "../app/services/key-scope.js";
|
|
24
|
+
export { LanguageTokenizer } from "../app/models/language-tokenizer.js";
|
|
25
|
+
export { LineIndex } from "../app/models/rows/line-index.js";
|
|
26
|
+
export { BackgroundTicker } from "../app/services/background-ticker.js";
|
|
27
|
+
export { WorkerRunner } from "../app/services/worker-runner.js";
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import "@noldova/context.core";
|
|
9
|
+
import { type InputSignal, type OutputEmitterRef, type Signal, type WritableSignal } from "@angular/core";
|
|
10
|
+
import { EditorSession, type ILanguageDefinition, type SearchQuery, SearchResults, type TextDocument, TextPosition, type TextSearch, TextSelection, type TokenTypeRegistry, type UndoHistory } from "@noldova/code.editor";
|
|
11
|
+
import { type IReadOnlyList } from "@noldova/context.collections";
|
|
12
|
+
import { Resources } from "../../../resources.js";
|
|
13
|
+
import { CodeRowKind } from "../../enums/code-row-kind.js";
|
|
14
|
+
import type { ICodeDecorations } from "../../interfaces/i-code-decorations.js";
|
|
15
|
+
import { BarShape } from "../../models/shapes/bar-shape.js";
|
|
16
|
+
import { ChangeShape } from "../../models/shapes/change-shape.js";
|
|
17
|
+
import type { CodeBar } from "../../models/decorations/code-bar.js";
|
|
18
|
+
import type { CodeBarAction } from "../../models/decorations/code-bar-action.js";
|
|
19
|
+
import { CodeBarActionEvent } from "../../models/decorations/code-bar-action-event.js";
|
|
20
|
+
import { CodeBlocks } from "../../models/folding/code-blocks.js";
|
|
21
|
+
import type { CodeFold } from "../../models/folding/code-fold.js";
|
|
22
|
+
import type { CodeRow } from "../../models/rows/code-row.js";
|
|
23
|
+
import { CodeShape } from "../../models/shapes/code-shape.js";
|
|
24
|
+
import type { MatchShape } from "../../models/shapes/match-shape.js";
|
|
25
|
+
import { RowLayout } from "../../models/rows/row-layout.js";
|
|
26
|
+
import * as i0 from "@angular/core";
|
|
27
|
+
/**
|
|
28
|
+
* The `noldova-code-editor` component: the code view, which shows and edits
|
|
29
|
+
* one {@link TextDocument}, drawing only the lines in view.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Every edit goes through the core: the view turns keys, paste, cut, drops
|
|
33
|
+
* and composition into transactions on its document and records them in its
|
|
34
|
+
* history. Its keys come from {@link CodeEditorRegistries}: each editor
|
|
35
|
+
* takes a child of the app's set, so a host's bindings, settings and
|
|
36
|
+
* contributions there reach every editor. Ctrl+F, or Cmd+F on Mac, opens its
|
|
37
|
+
* find bar.
|
|
38
|
+
*
|
|
39
|
+
* Its element takes these custom properties, each with the interface kit's
|
|
40
|
+
* value when unset: `--nol-code-editor-font-size` and
|
|
41
|
+
* `--nol-code-editor-line-height` for its text,
|
|
42
|
+
* `--nol-code-editor-gutter-width` for the gutter's least width,
|
|
43
|
+
* `--nol-code-editor-gutter-end` for the space after the gutter's numbers,
|
|
44
|
+
* `--nol-code-editor-signs`, which `none` hides the gutter's signs with, and
|
|
45
|
+
* `--nol-code-editor-inset` for the space before the text.
|
|
46
|
+
*/
|
|
47
|
+
export declare class CodeEditorComponent {
|
|
48
|
+
private static readonly NO_DECORATIONS;
|
|
49
|
+
private static readonly NO_FOLDS;
|
|
50
|
+
private static readonly NO_SELECTIONS;
|
|
51
|
+
private readonly scroller;
|
|
52
|
+
private readonly content;
|
|
53
|
+
private readonly textInput;
|
|
54
|
+
private readonly probe;
|
|
55
|
+
private readonly findBar;
|
|
56
|
+
private readonly registries;
|
|
57
|
+
private readonly conditions;
|
|
58
|
+
protected readonly tokenTypes: TokenTypeRegistry;
|
|
59
|
+
private readonly view;
|
|
60
|
+
private readonly query;
|
|
61
|
+
private readonly cache;
|
|
62
|
+
private readonly searchProgress;
|
|
63
|
+
private readonly measure;
|
|
64
|
+
private readonly scrollTop;
|
|
65
|
+
private readonly viewportHeight;
|
|
66
|
+
private readonly scrollLeft;
|
|
67
|
+
private readonly viewportWidth;
|
|
68
|
+
private stopDrag;
|
|
69
|
+
private readonly keys;
|
|
70
|
+
/**
|
|
71
|
+
* The document the view shows and edits; required.
|
|
72
|
+
*/
|
|
73
|
+
readonly document: InputSignal<TextDocument>;
|
|
74
|
+
/**
|
|
75
|
+
* The document's undo history, which the view's edits, undo and redo go
|
|
76
|
+
* through; required.
|
|
77
|
+
*/
|
|
78
|
+
readonly history: InputSignal<UndoHistory>;
|
|
79
|
+
/**
|
|
80
|
+
* The language that colors the code: its id in the app's
|
|
81
|
+
* {@link CodeEditorRegistries}, its definition, or null, when not bound,
|
|
82
|
+
* for plain text. The view finds the language's highlighter and makes its
|
|
83
|
+
* tokenizer in the background, showing the text plain until it is ready,
|
|
84
|
+
* and for good when no highlighter supports the language or its load fails.
|
|
85
|
+
*/
|
|
86
|
+
readonly language: InputSignal<string | ILanguageDefinition | null>;
|
|
87
|
+
/**
|
|
88
|
+
* The view's accessible name, which screen readers read for its text box;
|
|
89
|
+
* required.
|
|
90
|
+
*/
|
|
91
|
+
readonly label: InputSignal<string>;
|
|
92
|
+
/**
|
|
93
|
+
* Whether the view refuses edits, drops and replacing; false when not
|
|
94
|
+
* bound.
|
|
95
|
+
*/
|
|
96
|
+
readonly readOnly: InputSignal<boolean>;
|
|
97
|
+
/**
|
|
98
|
+
* Whether Tab and Shift+Tab indent and outdent the selected lines, rather
|
|
99
|
+
* than move the focus; false when not bound.
|
|
100
|
+
*/
|
|
101
|
+
readonly tabIndents: InputSignal<boolean>;
|
|
102
|
+
/**
|
|
103
|
+
* The layers of decorations the view draws, in order, a later layer over
|
|
104
|
+
* an earlier one; none when not bound.
|
|
105
|
+
* In 0.0.x their positions are their owner's to remap after an edit.
|
|
106
|
+
*/
|
|
107
|
+
readonly decorations: InputSignal<IReadOnlyList<ICodeDecorations>>;
|
|
108
|
+
/**
|
|
109
|
+
* The folds the view shows, collapsed or expanded, each with a gutter
|
|
110
|
+
* toggle; none when not bound.
|
|
111
|
+
*/
|
|
112
|
+
readonly folds: InputSignal<IReadOnlyList<CodeFold>>;
|
|
113
|
+
/**
|
|
114
|
+
* Emits the selections, primary first, after every change to the text or
|
|
115
|
+
* the selections.
|
|
116
|
+
*/
|
|
117
|
+
readonly selectionsChange: OutputEmitterRef<IReadOnlyList<TextSelection>>;
|
|
118
|
+
/**
|
|
119
|
+
* Emits the vertical scroll position, in pixels, after every scroll.
|
|
120
|
+
*/
|
|
121
|
+
readonly scrollChange: OutputEmitterRef<number>;
|
|
122
|
+
/**
|
|
123
|
+
* Emits a fold whose row or toggle was clicked; the owner gives the view
|
|
124
|
+
* the fold's new state.
|
|
125
|
+
*/
|
|
126
|
+
readonly foldToggle: OutputEmitterRef<CodeFold>;
|
|
127
|
+
/**
|
|
128
|
+
* Emits each click on an action of a {@link CodeBar}.
|
|
129
|
+
*/
|
|
130
|
+
readonly barAction: OutputEmitterRef<CodeBarActionEvent>;
|
|
131
|
+
/**
|
|
132
|
+
* Emits the chords of a key sequence the view waits to complete, as the
|
|
133
|
+
* platform shows them, such as `"⌘K"` on a Mac and `"Ctrl+K"`
|
|
134
|
+
* elsewhere, for the host to show; and null once the sequence completes or
|
|
135
|
+
* drops, on a press no binding completes, Escape, a click or the loss of
|
|
136
|
+
* the focus.
|
|
137
|
+
*/
|
|
138
|
+
readonly keySequencePending: OutputEmitterRef<string | null>;
|
|
139
|
+
private readonly tokenizer;
|
|
140
|
+
protected readonly version: WritableSignal<number>;
|
|
141
|
+
private readonly tokensVersion;
|
|
142
|
+
protected readonly focused: WritableSignal<boolean>;
|
|
143
|
+
protected readonly composing: WritableSignal<string | null>;
|
|
144
|
+
protected readonly session: Signal<EditorSession>;
|
|
145
|
+
protected readonly selections: Signal<IReadOnlyList<TextSelection>>;
|
|
146
|
+
protected readonly lineHeight: Signal<number>;
|
|
147
|
+
protected readonly plan: Signal<CodeBlocks>;
|
|
148
|
+
protected readonly layout: Signal<RowLayout>;
|
|
149
|
+
protected readonly height: Signal<number>;
|
|
150
|
+
protected readonly digits: Signal<number>;
|
|
151
|
+
protected readonly firstRow: Signal<number>;
|
|
152
|
+
protected readonly lastRow: Signal<number>;
|
|
153
|
+
protected readonly offset: Signal<number>;
|
|
154
|
+
protected readonly marked: Signal<boolean>;
|
|
155
|
+
protected readonly paired: Signal<boolean>;
|
|
156
|
+
protected readonly foldable: Signal<boolean>;
|
|
157
|
+
protected readonly rowed: Signal<boolean>;
|
|
158
|
+
private readonly openFolds;
|
|
159
|
+
protected readonly rows: Signal<readonly CodeRow[]>;
|
|
160
|
+
protected readonly changeShapes: Signal<readonly ChangeShape[]>;
|
|
161
|
+
protected readonly barShapes: Signal<readonly BarShape[]>;
|
|
162
|
+
protected readonly barLeft: Signal<number>;
|
|
163
|
+
protected readonly barWidth: Signal<number>;
|
|
164
|
+
protected readonly selectionShapes: Signal<readonly CodeShape[]>;
|
|
165
|
+
protected readonly caretShapes: Signal<readonly CodeShape[]>;
|
|
166
|
+
protected readonly primaryCaret: Signal<CodeShape>;
|
|
167
|
+
protected readonly resources: typeof Resources;
|
|
168
|
+
protected readonly foldKind: CodeRowKind;
|
|
169
|
+
protected readonly dropCaret: WritableSignal<CodeShape | null>;
|
|
170
|
+
protected readonly searchOpen: WritableSignal<boolean>;
|
|
171
|
+
protected readonly replaceOpen: WritableSignal<boolean>;
|
|
172
|
+
protected readonly searchSeed: WritableSignal<string>;
|
|
173
|
+
protected readonly search: Signal<TextSearch | null>;
|
|
174
|
+
protected readonly results: Signal<SearchResults | null>;
|
|
175
|
+
protected readonly searchStatus: Signal<string>;
|
|
176
|
+
protected readonly matchShapes: Signal<readonly MatchShape[]>;
|
|
177
|
+
/**
|
|
178
|
+
* Creates the view, which Angular does for each `noldova-code-editor`
|
|
179
|
+
* element.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* import { Component } from "@angular/core";
|
|
184
|
+
* import { TextDocument, UndoHistory } from "@noldova/code.editor";
|
|
185
|
+
* import { CodeEditorComponent } from "@noldova/code.editor.angular";
|
|
186
|
+
*
|
|
187
|
+
* @Component({
|
|
188
|
+
* selector: "app-source",
|
|
189
|
+
* imports: [CodeEditorComponent],
|
|
190
|
+
* template: "<noldova-code-editor [document]=\"document\" [history]=\"history\" label=\"Source\" />"
|
|
191
|
+
* })
|
|
192
|
+
* export class SourceComponent {
|
|
193
|
+
* protected readonly document: TextDocument = TextDocument.fromText("const a = 1;\n");
|
|
194
|
+
* protected readonly history: UndoHistory = new UndoHistory(this.document);
|
|
195
|
+
* }
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
constructor();
|
|
199
|
+
/**
|
|
200
|
+
* Moves the focus into the view's text box.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* import type { CodeEditorComponent } from "@noldova/code.editor.angular";
|
|
205
|
+
*
|
|
206
|
+
* function startEditing(view: CodeEditorComponent): void {
|
|
207
|
+
* view.focus();
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
focus(): void;
|
|
212
|
+
/**
|
|
213
|
+
* Replaces the view's selections, the first one primary.
|
|
214
|
+
*
|
|
215
|
+
* @param selections The new selections, at least one.
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* import { TextPosition, TextSelection } from "@noldova/code.editor";
|
|
219
|
+
* import { List } from "@noldova/context.collections";
|
|
220
|
+
* import type { CodeEditorComponent } from "@noldova/code.editor.angular";
|
|
221
|
+
*
|
|
222
|
+
* function goToLine(view: CodeEditorComponent, line: number): void {
|
|
223
|
+
* view.select(new List([new TextSelection(new TextPosition(line, 0))]));
|
|
224
|
+
* }
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
select(selections: IReadOnlyList<TextSelection>): void;
|
|
228
|
+
/**
|
|
229
|
+
* Gives the position of the primary selection's caret.
|
|
230
|
+
*
|
|
231
|
+
* @returns The caret's line and column, both from 0.
|
|
232
|
+
* @example
|
|
233
|
+
* ```ts
|
|
234
|
+
* import type { CodeEditorComponent } from "@noldova/code.editor.angular";
|
|
235
|
+
*
|
|
236
|
+
* function caretLine(view: CodeEditorComponent): number {
|
|
237
|
+
* return view.caret().line;
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
caret(): TextPosition;
|
|
242
|
+
/**
|
|
243
|
+
* Tells whether the view's text box holds the focus.
|
|
244
|
+
*
|
|
245
|
+
* @returns True while the view has the focus.
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* import type { CodeEditorComponent } from "@noldova/code.editor.angular";
|
|
249
|
+
*
|
|
250
|
+
* function focusOnce(view: CodeEditorComponent): void {
|
|
251
|
+
* if (!view.hasFocus())
|
|
252
|
+
* view.focus();
|
|
253
|
+
* }
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
hasFocus(): boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Draws the lines in view again with their current tokens, for a
|
|
259
|
+
* tokenizer whose colors changed without an edit to the document.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```ts
|
|
263
|
+
* import type { CodeEditorComponent } from "@noldova/code.editor.angular";
|
|
264
|
+
*
|
|
265
|
+
* function recolor(view: CodeEditorComponent): void {
|
|
266
|
+
* view.refreshTokens();
|
|
267
|
+
* }
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
refreshTokens(): void;
|
|
271
|
+
/**
|
|
272
|
+
* Scrolls the view vertically.
|
|
273
|
+
*
|
|
274
|
+
* @param top The scroll position, in pixels from the first line; the view
|
|
275
|
+
* clamps it to its scroll range.
|
|
276
|
+
* @example
|
|
277
|
+
* ```ts
|
|
278
|
+
* import type { CodeEditorComponent } from "@noldova/code.editor.angular";
|
|
279
|
+
*
|
|
280
|
+
* function scrollToStart(view: CodeEditorComponent): void {
|
|
281
|
+
* view.scrollTo(0);
|
|
282
|
+
* }
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
scrollTo(top: number): void;
|
|
286
|
+
protected onAction(bar: CodeBar, action: CodeBarAction): void;
|
|
287
|
+
protected onFoldToggle(event: MouseEvent, fold: CodeFold): void;
|
|
288
|
+
protected onScroll(): void;
|
|
289
|
+
protected onKeyDown(event: KeyboardEvent): void;
|
|
290
|
+
protected onBeforeInput(event: InputEvent): void;
|
|
291
|
+
protected onCompositionStart(): void;
|
|
292
|
+
protected onCompositionUpdate(event: CompositionEvent): void;
|
|
293
|
+
protected onCompositionEnd(event: CompositionEvent): void;
|
|
294
|
+
protected onPaste(event: ClipboardEvent): void;
|
|
295
|
+
protected onCopy(event: ClipboardEvent): void;
|
|
296
|
+
protected onCut(event: ClipboardEvent): void;
|
|
297
|
+
protected onBlur(): void;
|
|
298
|
+
protected onMouseDown(event: MouseEvent): void;
|
|
299
|
+
protected onDragOver(event: DragEvent): void;
|
|
300
|
+
protected onDrop(event: DragEvent): void;
|
|
301
|
+
protected onQuery(query: SearchQuery): void;
|
|
302
|
+
protected findNext(): void;
|
|
303
|
+
protected findPrevious(): void;
|
|
304
|
+
protected replaceOne(text: string): void;
|
|
305
|
+
protected replaceEvery(text: string): void;
|
|
306
|
+
protected closeSearch(): void;
|
|
307
|
+
private copyInto;
|
|
308
|
+
private toggleFold;
|
|
309
|
+
private contextAt;
|
|
310
|
+
private openSearch;
|
|
311
|
+
private moveSelected;
|
|
312
|
+
private goTo;
|
|
313
|
+
private matchShapesOf;
|
|
314
|
+
private changed;
|
|
315
|
+
private reveal;
|
|
316
|
+
private syncInput;
|
|
317
|
+
private positionAt;
|
|
318
|
+
private rowAtPoint;
|
|
319
|
+
private isShown;
|
|
320
|
+
private onTokens;
|
|
321
|
+
private rowsOf;
|
|
322
|
+
private changeShapesOf;
|
|
323
|
+
private measureViewport;
|
|
324
|
+
private barShapesOf;
|
|
325
|
+
private selectionShapesOf;
|
|
326
|
+
private caretShapesOf;
|
|
327
|
+
private openFoldsOf;
|
|
328
|
+
private caretOf;
|
|
329
|
+
private static isText;
|
|
330
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CodeEditorComponent, never>;
|
|
331
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CodeEditorComponent, "noldova-code-editor", never, { "document": { "alias": "document"; "required": true; "isSignal": true; }; "history": { "alias": "history"; "required": true; "isSignal": true; }; "language": { "alias": "language"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": true; "isSignal": true; }; "readOnly": { "alias": "readOnly"; "required": false; "isSignal": true; }; "tabIndents": { "alias": "tabIndents"; "required": false; "isSignal": true; }; "decorations": { "alias": "decorations"; "required": false; "isSignal": true; }; "folds": { "alias": "folds"; "required": false; "isSignal": true; }; }, { "selectionsChange": "selectionsChange"; "scrollChange": "scrollChange"; "foldToggle": "foldToggle"; "barAction": "barAction"; "keySequencePending": "keySequencePending"; }, never, never, true, never>;
|
|
332
|
+
}
|