@noldova/code.editor.angular 0.0.0-stage → 0.0.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/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
|
@@ -0,0 +1,648 @@
|
|
|
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 { afterNextRender, Component, computed, DestroyRef, effect, inject, input, output, signal, viewChild } from "@angular/core";
|
|
10
|
+
import { CommandContext, ConditionValues, CoreCommands, CoreConditions, CoreSettings, EditorFeatures, EditorFeatureSet, EditorRegistries, EditorSession, KeyDispatchResult, KeyPress, Required, SearchResults, TextPosition, TextSelection, TokenCache } from "@noldova/code.editor";
|
|
11
|
+
import { List } from "@noldova/context.collections";
|
|
12
|
+
import { Resources } from "../../../resources.js";
|
|
13
|
+
import { CodeRowKind } from "../../enums/code-row-kind.js";
|
|
14
|
+
import { BarShape } from "../../models/shapes/bar-shape.js";
|
|
15
|
+
import { ChangeShape } from "../../models/shapes/change-shape.js";
|
|
16
|
+
import { CodeBarActionEvent } from "../../models/decorations/code-bar-action-event.js";
|
|
17
|
+
import { CodeBlocks } from "../../models/folding/code-blocks.js";
|
|
18
|
+
import { FoldShortcuts } from "../../models/folding/fold-shortcuts.js";
|
|
19
|
+
import { LanguageTokenizer } from "../../models/language-tokenizer.js";
|
|
20
|
+
import { CodeSearch } from "../../models/code-search.js";
|
|
21
|
+
import { CodeShape } from "../../models/shapes/code-shape.js";
|
|
22
|
+
import { RowBuilder } from "../../models/rows/row-builder.js";
|
|
23
|
+
import { RowLayout } from "../../models/rows/row-layout.js";
|
|
24
|
+
import { TextMeasure } from "../../models/text-measure.js";
|
|
25
|
+
import { CodeEditorView } from "../../models/code-editor-view.js";
|
|
26
|
+
import { BackgroundTicker } from "../../services/background-ticker.js";
|
|
27
|
+
import { CodeEditorFeatures } from "../../services/code-editor-features.js";
|
|
28
|
+
import { KeyScope } from "../../services/key-scope.js";
|
|
29
|
+
import { CodeEditorRegistries } from "../../services/code-editor-registries.js";
|
|
30
|
+
import { TokenStyleSheet } from "../../services/token-style-sheet.js";
|
|
31
|
+
import { FindBarComponent } from "../find-bar/find-bar.component.js";
|
|
32
|
+
import * as i0 from "@angular/core";
|
|
33
|
+
export class CodeEditorComponent {
|
|
34
|
+
static NO_DECORATIONS = new List();
|
|
35
|
+
static NO_FOLDS = new List();
|
|
36
|
+
static NO_SELECTIONS = new List();
|
|
37
|
+
scroller = viewChild.required("scroller", /* @ts-ignore */
|
|
38
|
+
...(ngDevMode ? [{ debugName: "scroller" }] : /* istanbul ignore next */ []));
|
|
39
|
+
content = viewChild.required("content", /* @ts-ignore */
|
|
40
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
41
|
+
textInput = viewChild.required("input", /* @ts-ignore */
|
|
42
|
+
...(ngDevMode ? [{ debugName: "textInput" }] : /* istanbul ignore next */ []));
|
|
43
|
+
probe = viewChild.required("probe", /* @ts-ignore */
|
|
44
|
+
...(ngDevMode ? [{ debugName: "probe" }] : /* istanbul ignore next */ []));
|
|
45
|
+
findBar = viewChild(FindBarComponent, /* @ts-ignore */
|
|
46
|
+
...(ngDevMode ? [{ debugName: "findBar" }] : /* istanbul ignore next */ []));
|
|
47
|
+
registries = new EditorRegistries(inject(CodeEditorRegistries).registries);
|
|
48
|
+
conditions = new ConditionValues(this.registries.conditions);
|
|
49
|
+
tokenTypes = this.registries.tokenTypes;
|
|
50
|
+
view = new CodeEditorView(t => this.openSearch(t), () => this.closeSearch(), t => this.toggleFold(t));
|
|
51
|
+
query = signal(null, /* @ts-ignore */
|
|
52
|
+
...(ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []));
|
|
53
|
+
cache = signal(null, /* @ts-ignore */
|
|
54
|
+
...(ngDevMode ? [{ debugName: "cache" }] : /* istanbul ignore next */ []));
|
|
55
|
+
searchProgress = signal(0, /* @ts-ignore */
|
|
56
|
+
...(ngDevMode ? [{ debugName: "searchProgress" }] : /* istanbul ignore next */ []));
|
|
57
|
+
measure = signal(null, /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "measure" }] : /* istanbul ignore next */ []));
|
|
59
|
+
scrollTop = signal(0, /* @ts-ignore */
|
|
60
|
+
...(ngDevMode ? [{ debugName: "scrollTop" }] : /* istanbul ignore next */ []));
|
|
61
|
+
viewportHeight = signal(0, /* @ts-ignore */
|
|
62
|
+
...(ngDevMode ? [{ debugName: "viewportHeight" }] : /* istanbul ignore next */ []));
|
|
63
|
+
scrollLeft = signal(0, /* @ts-ignore */
|
|
64
|
+
...(ngDevMode ? [{ debugName: "scrollLeft" }] : /* istanbul ignore next */ []));
|
|
65
|
+
viewportWidth = signal(0, /* @ts-ignore */
|
|
66
|
+
...(ngDevMode ? [{ debugName: "viewportWidth" }] : /* istanbul ignore next */ []));
|
|
67
|
+
stopDrag = null;
|
|
68
|
+
keys = inject(KeyScope);
|
|
69
|
+
document = input.required(/* @ts-ignore */
|
|
70
|
+
...(ngDevMode ? [{ debugName: "document" }] : /* istanbul ignore next */ []));
|
|
71
|
+
history = input.required(/* @ts-ignore */
|
|
72
|
+
...(ngDevMode ? [{ debugName: "history" }] : /* istanbul ignore next */ []));
|
|
73
|
+
language = input(null, /* @ts-ignore */
|
|
74
|
+
...(ngDevMode ? [{ debugName: "language" }] : /* istanbul ignore next */ []));
|
|
75
|
+
label = input.required(/* @ts-ignore */
|
|
76
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
77
|
+
readOnly = input(false, /* @ts-ignore */
|
|
78
|
+
...(ngDevMode ? [{ debugName: "readOnly" }] : /* istanbul ignore next */ []));
|
|
79
|
+
tabIndents = input(false, /* @ts-ignore */
|
|
80
|
+
...(ngDevMode ? [{ debugName: "tabIndents" }] : /* istanbul ignore next */ []));
|
|
81
|
+
decorations = input(CodeEditorComponent.NO_DECORATIONS, /* @ts-ignore */
|
|
82
|
+
...(ngDevMode ? [{ debugName: "decorations" }] : /* istanbul ignore next */ []));
|
|
83
|
+
folds = input(CodeEditorComponent.NO_FOLDS, /* @ts-ignore */
|
|
84
|
+
...(ngDevMode ? [{ debugName: "folds" }] : /* istanbul ignore next */ []));
|
|
85
|
+
selectionsChange = output();
|
|
86
|
+
scrollChange = output();
|
|
87
|
+
foldToggle = output();
|
|
88
|
+
barAction = output();
|
|
89
|
+
keySequencePending = output();
|
|
90
|
+
tokenizer = LanguageTokenizer.of(this.language);
|
|
91
|
+
version = signal(0, /* @ts-ignore */
|
|
92
|
+
...(ngDevMode ? [{ debugName: "version" }] : /* istanbul ignore next */ []));
|
|
93
|
+
tokensVersion = signal(0, /* @ts-ignore */
|
|
94
|
+
...(ngDevMode ? [{ debugName: "tokensVersion" }] : /* istanbul ignore next */ []));
|
|
95
|
+
focused = signal(false, /* @ts-ignore */
|
|
96
|
+
...(ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []));
|
|
97
|
+
composing = signal(null, /* @ts-ignore */
|
|
98
|
+
...(ngDevMode ? [{ debugName: "composing" }] : /* istanbul ignore next */ []));
|
|
99
|
+
session = computed(() => new EditorSession(this.document(), this.history()), /* @ts-ignore */
|
|
100
|
+
...(ngDevMode ? [{ debugName: "session" }] : /* istanbul ignore next */ []));
|
|
101
|
+
selections = computed(() => {
|
|
102
|
+
this.version();
|
|
103
|
+
return this.session().selections;
|
|
104
|
+
}, /* @ts-ignore */
|
|
105
|
+
...(ngDevMode ? [{ debugName: "selections" }] : /* istanbul ignore next */ []));
|
|
106
|
+
lineHeight = computed(() => this.measure()?.lineHeight ?? 0, /* @ts-ignore */
|
|
107
|
+
...(ngDevMode ? [{ debugName: "lineHeight" }] : /* istanbul ignore next */ []));
|
|
108
|
+
plan = computed(() => {
|
|
109
|
+
this.version();
|
|
110
|
+
return new CodeBlocks(this.document().lineCount, this.decorations(), this.folds());
|
|
111
|
+
}, /* @ts-ignore */
|
|
112
|
+
...(ngDevMode ? [{ debugName: "plan" }] : /* istanbul ignore next */ []));
|
|
113
|
+
layout = computed(() => new RowLayout(this.document().lineCount, this.plan().blocks), /* @ts-ignore */
|
|
114
|
+
...(ngDevMode ? [{ debugName: "layout" }] : /* istanbul ignore next */ []));
|
|
115
|
+
height = computed(() => this.layout().rowCount * this.lineHeight(), /* @ts-ignore */
|
|
116
|
+
...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
117
|
+
digits = computed(() => String(this.plan().largestNumber).length, /* @ts-ignore */
|
|
118
|
+
...(ngDevMode ? [{ debugName: "digits" }] : /* istanbul ignore next */ []));
|
|
119
|
+
firstRow = computed(() => {
|
|
120
|
+
const lineHeight = this.lineHeight();
|
|
121
|
+
return lineHeight === 0 ? 0 : Math.max(0, Math.floor(this.scrollTop() / lineHeight) - Resources.marginLines);
|
|
122
|
+
}, /* @ts-ignore */
|
|
123
|
+
...(ngDevMode ? [{ debugName: "firstRow" }] : /* istanbul ignore next */ []));
|
|
124
|
+
lastRow = computed(() => {
|
|
125
|
+
const lineHeight = this.lineHeight();
|
|
126
|
+
return lineHeight === 0 ? 0 : Math.min(this.layout().rowCount, Math.ceil((this.scrollTop() + this.viewportHeight()) / lineHeight) + Resources.marginLines);
|
|
127
|
+
}, /* @ts-ignore */
|
|
128
|
+
...(ngDevMode ? [{ debugName: "lastRow" }] : /* istanbul ignore next */ []));
|
|
129
|
+
offset = computed(() => this.firstRow() * this.lineHeight(), /* @ts-ignore */
|
|
130
|
+
...(ngDevMode ? [{ debugName: "offset" }] : /* istanbul ignore next */ []));
|
|
131
|
+
marked = computed(() => this.decorations().any(), /* @ts-ignore */
|
|
132
|
+
...(ngDevMode ? [{ debugName: "marked" }] : /* istanbul ignore next */ []));
|
|
133
|
+
paired = computed(() => this.decorations().any(t => !Object.isNull(t.numbering)), /* @ts-ignore */
|
|
134
|
+
...(ngDevMode ? [{ debugName: "paired" }] : /* istanbul ignore next */ []));
|
|
135
|
+
foldable = computed(() => this.folds().any(), /* @ts-ignore */
|
|
136
|
+
...(ngDevMode ? [{ debugName: "foldable" }] : /* istanbul ignore next */ []));
|
|
137
|
+
rowed = computed(() => this.marked() || this.foldable(), /* @ts-ignore */
|
|
138
|
+
...(ngDevMode ? [{ debugName: "rowed" }] : /* istanbul ignore next */ []));
|
|
139
|
+
openFolds = computed(() => this.openFoldsOf(), /* @ts-ignore */
|
|
140
|
+
...(ngDevMode ? [{ debugName: "openFolds" }] : /* istanbul ignore next */ []));
|
|
141
|
+
rows = computed(() => this.rowsOf(), /* @ts-ignore */
|
|
142
|
+
...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
|
|
143
|
+
changeShapes = computed(() => this.changeShapesOf(), /* @ts-ignore */
|
|
144
|
+
...(ngDevMode ? [{ debugName: "changeShapes" }] : /* istanbul ignore next */ []));
|
|
145
|
+
barShapes = computed(() => this.barShapesOf(), /* @ts-ignore */
|
|
146
|
+
...(ngDevMode ? [{ debugName: "barShapes" }] : /* istanbul ignore next */ []));
|
|
147
|
+
barLeft = this.scrollLeft.asReadonly();
|
|
148
|
+
barWidth = this.viewportWidth.asReadonly();
|
|
149
|
+
selectionShapes = computed(() => this.selectionShapesOf(), /* @ts-ignore */
|
|
150
|
+
...(ngDevMode ? [{ debugName: "selectionShapes" }] : /* istanbul ignore next */ []));
|
|
151
|
+
caretShapes = computed(() => this.caretShapesOf(), /* @ts-ignore */
|
|
152
|
+
...(ngDevMode ? [{ debugName: "caretShapes" }] : /* istanbul ignore next */ []));
|
|
153
|
+
primaryCaret = computed(() => {
|
|
154
|
+
this.selections();
|
|
155
|
+
return this.caretOf(this.session().primary);
|
|
156
|
+
}, /* @ts-ignore */
|
|
157
|
+
...(ngDevMode ? [{ debugName: "primaryCaret" }] : /* istanbul ignore next */ []));
|
|
158
|
+
resources = Resources;
|
|
159
|
+
foldKind = CodeRowKind.Fold;
|
|
160
|
+
dropCaret = signal(null, /* @ts-ignore */
|
|
161
|
+
...(ngDevMode ? [{ debugName: "dropCaret" }] : /* istanbul ignore next */ []));
|
|
162
|
+
searchOpen = signal(false, /* @ts-ignore */
|
|
163
|
+
...(ngDevMode ? [{ debugName: "searchOpen" }] : /* istanbul ignore next */ []));
|
|
164
|
+
replaceOpen = signal(false, /* @ts-ignore */
|
|
165
|
+
...(ngDevMode ? [{ debugName: "replaceOpen" }] : /* istanbul ignore next */ []));
|
|
166
|
+
searchSeed = signal(Resources.empty, /* @ts-ignore */
|
|
167
|
+
...(ngDevMode ? [{ debugName: "searchSeed" }] : /* istanbul ignore next */ []));
|
|
168
|
+
search = computed(() => CodeSearch.searchOf(this.query()), /* @ts-ignore */
|
|
169
|
+
...(ngDevMode ? [{ debugName: "search" }] : /* istanbul ignore next */ []));
|
|
170
|
+
results = computed(() => {
|
|
171
|
+
const search = this.search();
|
|
172
|
+
return Object.isNull(search) ? null : new SearchResults(this.document(), search);
|
|
173
|
+
}, /* @ts-ignore */
|
|
174
|
+
...(ngDevMode ? [{ debugName: "results" }] : /* istanbul ignore next */ []));
|
|
175
|
+
searchStatus = computed(() => {
|
|
176
|
+
this.version();
|
|
177
|
+
this.selections();
|
|
178
|
+
this.searchProgress();
|
|
179
|
+
return CodeSearch.statusOf(this.query(), this.results(), CodeSearch.rangeOf(this.session().primary));
|
|
180
|
+
}, /* @ts-ignore */
|
|
181
|
+
...(ngDevMode ? [{ debugName: "searchStatus" }] : /* istanbul ignore next */ []));
|
|
182
|
+
matchShapes = computed(() => this.matchShapesOf(), /* @ts-ignore */
|
|
183
|
+
...(ngDevMode ? [{ debugName: "matchShapes" }] : /* istanbul ignore next */ []));
|
|
184
|
+
constructor() {
|
|
185
|
+
const destroyRef = inject(DestroyRef);
|
|
186
|
+
inject(TokenStyleSheet).apply(inject(CodeEditorRegistries).registries.tokenTypes, Resources.tokenClassPrefix);
|
|
187
|
+
this.keys.listen(t => this.keySequencePending.emit(t));
|
|
188
|
+
effect(onCleanup => onCleanup(this.document().onChange(() => this.version.update(t => t + 1))));
|
|
189
|
+
effect(onCleanup => {
|
|
190
|
+
const tokenizer = this.tokenizer();
|
|
191
|
+
const document = this.document();
|
|
192
|
+
const cache = Object.isNull(tokenizer) ? null : new TokenCache(document, tokenizer);
|
|
193
|
+
const ticker = Object.isNull(cache) ? null : new BackgroundTicker(document, hasTime => {
|
|
194
|
+
const from = cache.validLineCount;
|
|
195
|
+
const more = cache.advance(hasTime);
|
|
196
|
+
this.onTokens(from, cache.validLineCount);
|
|
197
|
+
return more;
|
|
198
|
+
});
|
|
199
|
+
this.cache.set(cache);
|
|
200
|
+
onCleanup(() => {
|
|
201
|
+
ticker?.[Symbol.dispose]();
|
|
202
|
+
cache?.[Symbol.dispose]();
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
effect(onCleanup => {
|
|
206
|
+
const results = this.results();
|
|
207
|
+
const ticker = Object.isNull(results) ? null : new BackgroundTicker(this.document(), hasTime => {
|
|
208
|
+
const more = results.advance(hasTime);
|
|
209
|
+
this.searchProgress.update(t => t + 1);
|
|
210
|
+
return more;
|
|
211
|
+
});
|
|
212
|
+
onCleanup(() => {
|
|
213
|
+
ticker?.[Symbol.dispose]();
|
|
214
|
+
results?.[Symbol.dispose]();
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
effect(() => {
|
|
218
|
+
this.session().readOnly = this.readOnly();
|
|
219
|
+
});
|
|
220
|
+
effect(() => {
|
|
221
|
+
const history = this.history();
|
|
222
|
+
history.limit = this.registries.settings.get(CoreSettings.undoLimit);
|
|
223
|
+
history.groupMilliseconds = this.registries.settings.get(CoreSettings.undoGroupMilliseconds);
|
|
224
|
+
});
|
|
225
|
+
effect(() => {
|
|
226
|
+
this.selections();
|
|
227
|
+
if (Object.isNull(this.composing()))
|
|
228
|
+
this.syncInput();
|
|
229
|
+
});
|
|
230
|
+
afterNextRender(() => {
|
|
231
|
+
this.measure.set(new TextMeasure(this.probe().nativeElement, this.content().nativeElement));
|
|
232
|
+
const scroller = this.scroller().nativeElement;
|
|
233
|
+
const observer = new ResizeObserver(() => this.measureViewport(scroller));
|
|
234
|
+
observer.observe(scroller);
|
|
235
|
+
this.measureViewport(scroller);
|
|
236
|
+
destroyRef.onDestroy(() => observer.disconnect());
|
|
237
|
+
});
|
|
238
|
+
destroyRef.onDestroy(() => this.stopDrag?.());
|
|
239
|
+
}
|
|
240
|
+
focus() {
|
|
241
|
+
this.textInput().nativeElement.focus();
|
|
242
|
+
}
|
|
243
|
+
select(selections) {
|
|
244
|
+
this.session().select(selections);
|
|
245
|
+
this.changed();
|
|
246
|
+
}
|
|
247
|
+
caret() {
|
|
248
|
+
return this.session().primary.head;
|
|
249
|
+
}
|
|
250
|
+
hasFocus() {
|
|
251
|
+
return this.focused();
|
|
252
|
+
}
|
|
253
|
+
refreshTokens() {
|
|
254
|
+
this.tokensVersion.update(t => t + 1);
|
|
255
|
+
}
|
|
256
|
+
scrollTo(top) {
|
|
257
|
+
const scroller = this.scroller().nativeElement;
|
|
258
|
+
scroller.scrollTop = top;
|
|
259
|
+
this.scrollTop.set(scroller.scrollTop);
|
|
260
|
+
}
|
|
261
|
+
onAction(bar, action) {
|
|
262
|
+
this.barAction.emit(new CodeBarActionEvent(bar, action));
|
|
263
|
+
}
|
|
264
|
+
onFoldToggle(event, fold) {
|
|
265
|
+
event.preventDefault();
|
|
266
|
+
event.stopPropagation();
|
|
267
|
+
this.foldToggle.emit(fold);
|
|
268
|
+
}
|
|
269
|
+
onScroll() {
|
|
270
|
+
const top = this.scroller().nativeElement.scrollTop;
|
|
271
|
+
this.scrollTop.set(top);
|
|
272
|
+
this.scrollLeft.set(this.scroller().nativeElement.scrollLeft);
|
|
273
|
+
this.scrollChange.emit(top);
|
|
274
|
+
}
|
|
275
|
+
onKeyDown(event) {
|
|
276
|
+
if (event.isComposing)
|
|
277
|
+
return;
|
|
278
|
+
const before = this.session().selections;
|
|
279
|
+
const press = new KeyPress(event.key, event.code, event.shiftKey, event.ctrlKey, event.altKey, event.metaKey);
|
|
280
|
+
const result = this.keys.dispatch(press, this.contextAt(event.timeStamp));
|
|
281
|
+
if (result === KeyDispatchResult.None)
|
|
282
|
+
return;
|
|
283
|
+
event.preventDefault();
|
|
284
|
+
if (this.session().selections !== before)
|
|
285
|
+
this.changed();
|
|
286
|
+
}
|
|
287
|
+
onBeforeInput(event) {
|
|
288
|
+
if (event.isComposing)
|
|
289
|
+
return;
|
|
290
|
+
event.preventDefault();
|
|
291
|
+
switch (event.inputType) {
|
|
292
|
+
case Resources.inputInsertText:
|
|
293
|
+
case Resources.inputInsertReplacementText:
|
|
294
|
+
this.session().type(Required.value(event.data), event.timeStamp);
|
|
295
|
+
break;
|
|
296
|
+
case Resources.inputInsertLineBreak:
|
|
297
|
+
case Resources.inputInsertParagraph:
|
|
298
|
+
this.registries.commands.run(CoreCommands.newLine.id, this.contextAt(event.timeStamp));
|
|
299
|
+
break;
|
|
300
|
+
default:
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
this.changed();
|
|
304
|
+
}
|
|
305
|
+
onCompositionStart() {
|
|
306
|
+
this.composing.set(Resources.empty);
|
|
307
|
+
}
|
|
308
|
+
onCompositionUpdate(event) {
|
|
309
|
+
this.composing.set(event.data);
|
|
310
|
+
}
|
|
311
|
+
onCompositionEnd(event) {
|
|
312
|
+
this.composing.set(null);
|
|
313
|
+
if (!String.isNullOrEmpty(event.data))
|
|
314
|
+
this.session().type(event.data, event.timeStamp);
|
|
315
|
+
this.changed();
|
|
316
|
+
}
|
|
317
|
+
onPaste(event) {
|
|
318
|
+
event.preventDefault();
|
|
319
|
+
this.session().paste(Required.value(event.clipboardData).getData(Resources.plainText), event.timeStamp);
|
|
320
|
+
this.changed();
|
|
321
|
+
}
|
|
322
|
+
onCopy(event) {
|
|
323
|
+
this.copyInto(event, this.session().selectedText());
|
|
324
|
+
}
|
|
325
|
+
onCut(event) {
|
|
326
|
+
this.copyInto(event, this.session().cut(event.timeStamp));
|
|
327
|
+
this.changed();
|
|
328
|
+
}
|
|
329
|
+
onBlur() {
|
|
330
|
+
this.focused.set(false);
|
|
331
|
+
this.keys.cancel();
|
|
332
|
+
}
|
|
333
|
+
onMouseDown(event) {
|
|
334
|
+
this.keys.cancel();
|
|
335
|
+
if (event.button !== 0)
|
|
336
|
+
return;
|
|
337
|
+
event.preventDefault();
|
|
338
|
+
const block = this.rowAtPoint(event.clientY).block;
|
|
339
|
+
if (!Object.isNull(block) && !Object.isNull(block.fold)) {
|
|
340
|
+
this.foldToggle.emit(block.fold);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
this.focus();
|
|
344
|
+
const kept = event.altKey ? this.session().selections : CodeEditorComponent.NO_SELECTIONS;
|
|
345
|
+
const position = this.positionAt(event.clientX, event.clientY);
|
|
346
|
+
const selected = CodeSearch.rangeOf(this.session().primary);
|
|
347
|
+
if (!event.altKey && !event.shiftKey && !this.readOnly() && this.session().selections.count() === 1 &&
|
|
348
|
+
position.compareTo(selected.start) > 0 && position.compareTo(selected.end) < 0) {
|
|
349
|
+
this.moveSelected(selected);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
this.session().placeCaret(position, event.shiftKey, event.altKey);
|
|
353
|
+
this.changed();
|
|
354
|
+
const anchor = event.altKey ? position : this.session().primary.anchor;
|
|
355
|
+
const owner = this.textInput().nativeElement.ownerDocument;
|
|
356
|
+
const move = moved => {
|
|
357
|
+
this.session().select(new List(kept.append(new TextSelection(anchor, this.positionAt(moved.clientX, moved.clientY)))));
|
|
358
|
+
this.changed();
|
|
359
|
+
};
|
|
360
|
+
const stop = () => {
|
|
361
|
+
owner.removeEventListener(Resources.mouseMove, move);
|
|
362
|
+
owner.removeEventListener(Resources.mouseUp, stop);
|
|
363
|
+
this.stopDrag = null;
|
|
364
|
+
};
|
|
365
|
+
this.stopDrag?.();
|
|
366
|
+
owner.addEventListener(Resources.mouseMove, move);
|
|
367
|
+
owner.addEventListener(Resources.mouseUp, stop);
|
|
368
|
+
this.stopDrag = stop;
|
|
369
|
+
}
|
|
370
|
+
onDragOver(event) {
|
|
371
|
+
event.preventDefault();
|
|
372
|
+
const data = event.dataTransfer;
|
|
373
|
+
if (Object.isNull(data))
|
|
374
|
+
return;
|
|
375
|
+
const accepted = !this.readOnly() && CodeEditorComponent.isText(data);
|
|
376
|
+
data.dropEffect = accepted ? Resources.copyEffect : Resources.noEffect;
|
|
377
|
+
this.dropCaret.set(accepted ? this.caretOf(new TextSelection(this.positionAt(event.clientX, event.clientY))) : null);
|
|
378
|
+
}
|
|
379
|
+
onDrop(event) {
|
|
380
|
+
event.preventDefault();
|
|
381
|
+
this.dropCaret.set(null);
|
|
382
|
+
const data = event.dataTransfer;
|
|
383
|
+
if (Object.isNull(data) || !CodeEditorComponent.isText(data) || !this.session().drop(this.positionAt(event.clientX, event.clientY), data.getData(Resources.plainText), event.timeStamp))
|
|
384
|
+
return;
|
|
385
|
+
this.focus();
|
|
386
|
+
this.changed();
|
|
387
|
+
}
|
|
388
|
+
onQuery(query) {
|
|
389
|
+
this.query.set(query);
|
|
390
|
+
this.searchSeed.set(query.text);
|
|
391
|
+
this.goTo(this.results()?.next(CodeSearch.rangeOf(this.session().primary).start) ?? null);
|
|
392
|
+
}
|
|
393
|
+
findNext() {
|
|
394
|
+
this.goTo(this.results()?.next(CodeSearch.rangeOf(this.session().primary).end) ?? null);
|
|
395
|
+
}
|
|
396
|
+
findPrevious() {
|
|
397
|
+
this.goTo(this.results()?.previous(CodeSearch.rangeOf(this.session().primary).start) ?? null);
|
|
398
|
+
}
|
|
399
|
+
replaceOne(text) {
|
|
400
|
+
const results = this.results();
|
|
401
|
+
if (Object.isNull(results))
|
|
402
|
+
return;
|
|
403
|
+
const range = CodeSearch.rangeOf(this.session().primary);
|
|
404
|
+
if (results.indexOf(range) !== -1)
|
|
405
|
+
this.session().replace(results.search.replaceEdits(this.document(), new List([range]), text), performance.now());
|
|
406
|
+
this.changed();
|
|
407
|
+
this.findNext();
|
|
408
|
+
}
|
|
409
|
+
replaceEvery(text) {
|
|
410
|
+
const results = this.results();
|
|
411
|
+
if (Object.isNull(results))
|
|
412
|
+
return;
|
|
413
|
+
this.session().replace(results.search.replaceEdits(this.document(), results.all(), text), performance.now());
|
|
414
|
+
this.changed();
|
|
415
|
+
}
|
|
416
|
+
closeSearch() {
|
|
417
|
+
this.searchOpen.set(false);
|
|
418
|
+
this.query.set(null);
|
|
419
|
+
this.focus();
|
|
420
|
+
}
|
|
421
|
+
copyInto(event, text) {
|
|
422
|
+
if (String.isNullOrEmpty(text))
|
|
423
|
+
return;
|
|
424
|
+
event.preventDefault();
|
|
425
|
+
Required.value(event.clipboardData).setData(Resources.plainText, text);
|
|
426
|
+
}
|
|
427
|
+
toggleFold(shortcut) {
|
|
428
|
+
const fold = FoldShortcuts.foldAt(this.folds(), this.session().primary.head.line, shortcut);
|
|
429
|
+
if (!Object.isNull(fold))
|
|
430
|
+
this.foldToggle.emit(fold);
|
|
431
|
+
}
|
|
432
|
+
contextAt(time) {
|
|
433
|
+
const session = this.session();
|
|
434
|
+
const features = new EditorFeatureSet();
|
|
435
|
+
features.provide(EditorFeatures.session, session);
|
|
436
|
+
features.provide(CodeEditorFeatures.view, this.view);
|
|
437
|
+
this.conditions.set(CoreConditions.readOnly, this.readOnly());
|
|
438
|
+
this.conditions.set(CoreConditions.tabIndents, this.tabIndents());
|
|
439
|
+
this.conditions.set(CoreConditions.hasSelection, session.selections.any(t => !t.anchor.equals(t.head)));
|
|
440
|
+
this.conditions.set(CoreConditions.hasMultipleSelections, session.selections.count() > 1);
|
|
441
|
+
this.conditions.set(CodeEditorFeatures.findVisible, this.searchOpen());
|
|
442
|
+
return new CommandContext(this.registries, this.conditions, features, null, time, Math.floor(this.viewportHeight() / this.lineHeight()));
|
|
443
|
+
}
|
|
444
|
+
openSearch(replace) {
|
|
445
|
+
const selected = this.session().selectedText();
|
|
446
|
+
const seed = !String.isNullOrEmpty(selected) && !selected.includes(Resources.lineFeed) ? selected : this.searchSeed();
|
|
447
|
+
this.replaceOpen.set(replace && !this.readOnly());
|
|
448
|
+
this.searchSeed.set(seed);
|
|
449
|
+
const bar = this.findBar();
|
|
450
|
+
if (Object.isUndefined(bar))
|
|
451
|
+
this.searchOpen.set(true);
|
|
452
|
+
else
|
|
453
|
+
bar.open(seed);
|
|
454
|
+
}
|
|
455
|
+
moveSelected(selected) {
|
|
456
|
+
const owner = this.textInput().nativeElement.ownerDocument;
|
|
457
|
+
const listening = new AbortController();
|
|
458
|
+
let moved = false;
|
|
459
|
+
const end = () => {
|
|
460
|
+
listening.abort();
|
|
461
|
+
this.dropCaret.set(null);
|
|
462
|
+
this.stopDrag = null;
|
|
463
|
+
};
|
|
464
|
+
this.stopDrag?.();
|
|
465
|
+
owner.addEventListener(Resources.mouseMove, event => {
|
|
466
|
+
moved = true;
|
|
467
|
+
this.dropCaret.set(this.caretOf(new TextSelection(this.positionAt(event.clientX, event.clientY))));
|
|
468
|
+
}, { signal: listening.signal });
|
|
469
|
+
owner.addEventListener(Resources.mouseUp, event => {
|
|
470
|
+
end();
|
|
471
|
+
const position = this.positionAt(event.clientX, event.clientY);
|
|
472
|
+
if (moved)
|
|
473
|
+
this.session().moveText(selected, position, event.timeStamp);
|
|
474
|
+
else
|
|
475
|
+
this.session().placeCaret(position, false, false);
|
|
476
|
+
this.changed();
|
|
477
|
+
}, { signal: listening.signal });
|
|
478
|
+
this.stopDrag = end;
|
|
479
|
+
}
|
|
480
|
+
goTo(match) {
|
|
481
|
+
if (Object.isNull(match))
|
|
482
|
+
return;
|
|
483
|
+
this.session().select(new List([new TextSelection(match.start, match.end)]));
|
|
484
|
+
this.changed();
|
|
485
|
+
}
|
|
486
|
+
matchShapesOf() {
|
|
487
|
+
const results = this.results();
|
|
488
|
+
if (Object.isNull(results))
|
|
489
|
+
return [];
|
|
490
|
+
this.version();
|
|
491
|
+
this.selections();
|
|
492
|
+
const rows = Array.from({ length: this.lastRow() - this.firstRow() }, (_, i) => this.firstRow() + i);
|
|
493
|
+
return CodeSearch.shapesOf(results, this.document(), this.layout(), rows, Required.value(this.measure()), CodeSearch.rangeOf(this.session().primary));
|
|
494
|
+
}
|
|
495
|
+
changed() {
|
|
496
|
+
this.version.update(t => t + 1);
|
|
497
|
+
this.selectionsChange.emit(this.session().selections);
|
|
498
|
+
this.reveal();
|
|
499
|
+
}
|
|
500
|
+
reveal() {
|
|
501
|
+
const measure = this.measure();
|
|
502
|
+
if (Object.isNull(measure))
|
|
503
|
+
return;
|
|
504
|
+
const scroller = this.scroller().nativeElement;
|
|
505
|
+
const caret = this.caretOf(this.session().primary);
|
|
506
|
+
if (caret.top < scroller.scrollTop)
|
|
507
|
+
scroller.scrollTop = caret.top;
|
|
508
|
+
else if (caret.top + caret.height > scroller.scrollTop + scroller.clientHeight)
|
|
509
|
+
scroller.scrollTop = caret.top + caret.height - scroller.clientHeight;
|
|
510
|
+
const start = this.content().nativeElement.offsetLeft + measure.inset;
|
|
511
|
+
if (caret.left < scroller.scrollLeft)
|
|
512
|
+
scroller.scrollLeft = caret.left;
|
|
513
|
+
else if (start + caret.left + measure.spaceWidth > scroller.scrollLeft + scroller.clientWidth)
|
|
514
|
+
scroller.scrollLeft = start + caret.left + measure.spaceWidth - scroller.clientWidth;
|
|
515
|
+
this.scrollTop.set(scroller.scrollTop);
|
|
516
|
+
}
|
|
517
|
+
syncInput() {
|
|
518
|
+
const element = this.textInput().nativeElement;
|
|
519
|
+
const document = this.document();
|
|
520
|
+
const primary = this.session().primary;
|
|
521
|
+
const first = Math.max(0, primary.head.line - Resources.inputContextLines);
|
|
522
|
+
const last = Math.min(document.lineCount - 1, primary.head.line + Resources.inputContextLines);
|
|
523
|
+
const lines = [];
|
|
524
|
+
for (let line = first; line <= last; line++)
|
|
525
|
+
lines.push(document.lineText(line));
|
|
526
|
+
element.value = lines.join(Resources.lineFeed);
|
|
527
|
+
const offsetOf = (position) => {
|
|
528
|
+
if (position.line < first)
|
|
529
|
+
return 0;
|
|
530
|
+
if (position.line > last)
|
|
531
|
+
return element.value.length;
|
|
532
|
+
return lines.slice(0, position.line - first).reduce((sum, t) => sum + t.length + Resources.lineFeed.length, 0) + position.column;
|
|
533
|
+
};
|
|
534
|
+
const anchor = offsetOf(primary.anchor);
|
|
535
|
+
const head = offsetOf(primary.head);
|
|
536
|
+
element.setSelectionRange(Math.min(anchor, head), Math.max(anchor, head), anchor > head ? Resources.backward : Resources.forward);
|
|
537
|
+
}
|
|
538
|
+
positionAt(clientX, clientY) {
|
|
539
|
+
const measure = Required.value(this.measure());
|
|
540
|
+
const document = this.document();
|
|
541
|
+
const rect = this.content().nativeElement.getBoundingClientRect();
|
|
542
|
+
const item = this.rowAtPoint(clientY);
|
|
543
|
+
if (Object.isNull(item.block))
|
|
544
|
+
return new TextPosition(item.line, measure.columnAt(document.lineText(item.line), clientX - rect.left - measure.inset));
|
|
545
|
+
const line = Math.min(item.line, document.lineCount - 1);
|
|
546
|
+
return new TextPosition(line, line === item.line ? 0 : document.lineText(line).length);
|
|
547
|
+
}
|
|
548
|
+
rowAtPoint(clientY) {
|
|
549
|
+
const layout = this.layout();
|
|
550
|
+
const top = this.content().nativeElement.getBoundingClientRect().top;
|
|
551
|
+
return layout.rowAt(Math.min(layout.rowCount - 1, Math.max(0, Math.floor((clientY - top) / Required.value(this.measure()).lineHeight))));
|
|
552
|
+
}
|
|
553
|
+
isShown(row) {
|
|
554
|
+
return row >= this.firstRow() && row < this.lastRow();
|
|
555
|
+
}
|
|
556
|
+
onTokens(from, to) {
|
|
557
|
+
if (this.rows().some(t => !Object.isNull(t.number) && t.number > from && t.number <= to))
|
|
558
|
+
this.refreshTokens();
|
|
559
|
+
}
|
|
560
|
+
rowsOf() {
|
|
561
|
+
this.tokensVersion();
|
|
562
|
+
const layout = this.layout();
|
|
563
|
+
const items = [];
|
|
564
|
+
for (let row = this.firstRow(); row < this.lastRow(); row++)
|
|
565
|
+
items.push(layout.rowAt(row));
|
|
566
|
+
return new RowBuilder(this.document(), this.cache(), this.decorations(), this.openFolds()).rowsOf(items);
|
|
567
|
+
}
|
|
568
|
+
changeShapesOf() {
|
|
569
|
+
const measure = this.measure();
|
|
570
|
+
if (Object.isNull(measure))
|
|
571
|
+
return [];
|
|
572
|
+
const shapes = [];
|
|
573
|
+
this.rows().forEach((row, index) => {
|
|
574
|
+
for (const span of row.spans) {
|
|
575
|
+
const left = measure.x(row.text, span.start);
|
|
576
|
+
shapes.push(new ChangeShape((this.firstRow() + index) * measure.lineHeight, left, measure.x(row.text, span.end) - left, span.background));
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
return shapes;
|
|
580
|
+
}
|
|
581
|
+
measureViewport(scroller) {
|
|
582
|
+
this.viewportHeight.set(scroller.clientHeight);
|
|
583
|
+
this.viewportWidth.set(scroller.clientWidth);
|
|
584
|
+
}
|
|
585
|
+
barShapesOf() {
|
|
586
|
+
const shapes = [];
|
|
587
|
+
this.rows().forEach((row, index) => {
|
|
588
|
+
if (!Object.isNull(row.bar))
|
|
589
|
+
shapes.push(new BarShape((this.firstRow() + index) * this.lineHeight(), row.bar));
|
|
590
|
+
});
|
|
591
|
+
return shapes;
|
|
592
|
+
}
|
|
593
|
+
selectionShapesOf() {
|
|
594
|
+
const measure = this.measure();
|
|
595
|
+
if (Object.isNull(measure))
|
|
596
|
+
return [];
|
|
597
|
+
const document = this.document();
|
|
598
|
+
const layout = this.layout();
|
|
599
|
+
const lineHeight = measure.lineHeight;
|
|
600
|
+
const ranges = Array.from(this.selections(), t => CodeSearch.rangeOf(t));
|
|
601
|
+
const shapes = [];
|
|
602
|
+
for (let row = this.firstRow(); row < this.lastRow(); row++) {
|
|
603
|
+
const item = layout.rowAt(row);
|
|
604
|
+
if (!Object.isNull(item.block))
|
|
605
|
+
continue;
|
|
606
|
+
const line = item.line;
|
|
607
|
+
const text = document.lineText(line);
|
|
608
|
+
for (const range of ranges.filter(t => t.start.line <= line && t.end.line >= line)) {
|
|
609
|
+
const left = line === range.start.line ? measure.x(text, range.start.column) : 0;
|
|
610
|
+
const right = line === range.end.line ? measure.x(text, range.end.column) : measure.x(text, text.length) + measure.spaceWidth;
|
|
611
|
+
if (right > left)
|
|
612
|
+
shapes.push(new CodeShape(row * lineHeight, left, right - left, lineHeight));
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return shapes;
|
|
616
|
+
}
|
|
617
|
+
caretShapesOf() {
|
|
618
|
+
const shapes = [];
|
|
619
|
+
for (const selection of this.selections())
|
|
620
|
+
if (this.isShown(this.layout().rowOfLine(selection.head.line)))
|
|
621
|
+
shapes.push(this.caretOf(selection));
|
|
622
|
+
return shapes;
|
|
623
|
+
}
|
|
624
|
+
openFoldsOf() {
|
|
625
|
+
const open = new Map();
|
|
626
|
+
for (const fold of this.folds())
|
|
627
|
+
if (!fold.collapsed && fold.lineCount > 0)
|
|
628
|
+
open.set(fold.startLine, fold);
|
|
629
|
+
return open;
|
|
630
|
+
}
|
|
631
|
+
caretOf(selection) {
|
|
632
|
+
const measure = this.measure();
|
|
633
|
+
const left = Object.isNull(measure) ? 0 : measure.x(this.document().lineText(selection.head.line), selection.head.column);
|
|
634
|
+
return new CodeShape(this.layout().rowOfLine(selection.head.line) * this.lineHeight(), left, 0, this.lineHeight());
|
|
635
|
+
}
|
|
636
|
+
static isText(data) {
|
|
637
|
+
return !data.types.includes(Resources.files) && data.types.includes(Resources.plainText);
|
|
638
|
+
}
|
|
639
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: CodeEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
640
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.3.0", type: CodeEditorComponent, isStandalone: true, selector: "noldova-code-editor", inputs: { document: { classPropertyName: "document", publicName: "document", isSignal: true, isRequired: true, transformFunction: null }, history: { classPropertyName: "history", publicName: "history", isSignal: true, isRequired: true, transformFunction: null }, language: { classPropertyName: "language", publicName: "language", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, readOnly: { classPropertyName: "readOnly", publicName: "readOnly", isSignal: true, isRequired: false, transformFunction: null }, tabIndents: { classPropertyName: "tabIndents", publicName: "tabIndents", isSignal: true, isRequired: false, transformFunction: null }, decorations: { classPropertyName: "decorations", publicName: "decorations", isSignal: true, isRequired: false, transformFunction: null }, folds: { classPropertyName: "folds", publicName: "folds", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectionsChange: "selectionsChange", scrollChange: "scrollChange", foldToggle: "foldToggle", barAction: "barAction", keySequencePending: "keySequencePending" }, host: { properties: { "class.nol-code-editor-focused": "focused()" }, classAttribute: "nol-code-editor" }, providers: [KeyScope], viewQueries: [{ propertyName: "scroller", first: true, predicate: ["scroller"], descendants: true, isSignal: true }, { propertyName: "content", first: true, predicate: ["content"], descendants: true, isSignal: true }, { propertyName: "textInput", first: true, predicate: ["input"], descendants: true, isSignal: true }, { propertyName: "probe", first: true, predicate: ["probe"], descendants: true, isSignal: true }, { propertyName: "findBar", first: true, predicate: FindBarComponent, descendants: true, isSignal: true }], ngImport: i0, template: "<!--\n@license\nCopyright (c) Noldova.\n\nThis source code is licensed under the license found in the\nLICENSE file in the root directory of this source tree.\n-->\n<div #scroller class=\"nol-code-editor-scroller\" (scroll)=\"onScroll()\" (mousedown)=\"onMouseDown($event)\" (dragover)=\"onDragOver($event)\"\n (dragleave)=\"dropCaret.set(null)\" (drop)=\"onDrop($event)\">\n <div class=\"nol-code-editor-sizer\" [style.height.px]=\"height()\" [style.--nol-code-editor-digits]=\"digits()\">\n <div class=\"nol-code-editor-gutter\" aria-hidden=\"true\">\n <div class=\"nol-code-editor-numbers\" [style.transform]=\"'translateY(' + offset() + 'px)'\">\n @for (row of rows(); track $index) {\n <div class=\"nol-code-editor-line-number\" [class]=\"resources.rowClass(row.kind)\">@for (paint of row.paints; track $index) {<span class=\"nol-code-editor-paint\" [style.background]=\"paint\"></span>}@if (paired()) {<span class=\"nol-code-editor-number\">{{ row.otherNumber }}</span>}<span class=\"nol-code-editor-number\">{{ row.number }}</span>@if (marked()) {<span class=\"nol-code-editor-sign\" [style.color]=\"row.marker?.color ?? null\">{{ row.marker?.text ?? resources.empty }}</span>}@if (foldable()) {<span class=\"nol-code-editor-fold-toggle\">@if (row.fold; as fold) {<span class=\"nol-code-editor-fold-icon material-symbols-rounded\" (mousedown)=\"onFoldToggle($event, fold)\">{{ fold.collapsed ? resources.foldClosedIcon : resources.foldOpenIcon }}</span>}</span>}</div>\n }\n </div>\n </div>\n @for (shape of barShapes(); track $index) {\n <div class=\"nol-code-editor-bar\" [style.top.px]=\"shape.top\" [style.left.px]=\"barLeft()\" [style.width.px]=\"barWidth()\" [style.background]=\"shape.bar.background\"\n [style.color]=\"shape.bar.color\" (mousedown)=\"$event.stopPropagation()\">@if (shape.bar.icon; as icon) {<span class=\"nol-code-editor-bar-icon material-symbols-rounded\" aria-hidden=\"true\">{{ icon }}</span>}<span class=\"nol-code-editor-bar-note\">{{ shape.bar.note }}</span>@for (action of shape.bar.actions; track action.id) {<button type=\"button\" class=\"nol-code-editor-action\" (click)=\"onAction(shape.bar, action)\">@if (action.icon; as icon) {<span class=\"nol-code-editor-action-icon material-symbols-rounded\" aria-hidden=\"true\">{{ icon }}</span>}{{ action.label }}</button>}</div>\n }\n <div #content class=\"nol-code-editor-content\">\n @if (rowed()) {\n <div class=\"nol-code-editor-rows\" aria-hidden=\"true\" [style.transform]=\"'translateY(' + offset() + 'px)'\">\n @for (row of rows(); track $index) {\n <div class=\"nol-code-editor-row\" [class]=\"resources.rowClass(row.kind)\">@for (paint of row.paints; track $index) {<div class=\"nol-code-editor-paint\" [style.background]=\"paint\"></div>}</div>\n }\n </div>\n @for (shape of changeShapes(); track $index) {\n <div class=\"nol-code-editor-change\" [style.top.px]=\"shape.top\" [style.left.px]=\"shape.left\" [style.width.px]=\"shape.width\" [style.background]=\"shape.background\"></div>\n }\n }\n @for (shape of selectionShapes(); track $index) {\n <div class=\"nol-code-editor-selection\" [style.top.px]=\"shape.top\" [style.left.px]=\"shape.left\" [style.width.px]=\"shape.width\" [style.height.px]=\"shape.height\"></div>\n }\n @for (shape of matchShapes(); track $index) {\n <div class=\"nol-code-editor-match\" [class.nol-code-editor-match-current]=\"shape.current\" [style.top.px]=\"shape.top\" [style.left.px]=\"shape.left\"\n [style.width.px]=\"shape.width\"></div>\n }\n <div class=\"nol-code-editor-lines\" aria-hidden=\"true\" [style.transform]=\"'translateY(' + offset() + 'px)'\">\n @for (row of rows(); track $index) {\n <div class=\"nol-code-editor-line\" [class.nol-code-editor-line-fold]=\"row.kind === foldKind\">@for (segment of row.segments; track $index) {<span [class]=\"resources.segmentClass(tokenTypes, segment)\">{{ row.text.slice(segment.start, segment.end) }}</span>}</div>\n }\n </div>\n @for (shape of caretShapes(); track $index) {\n <div class=\"nol-code-editor-caret\" [style.top.px]=\"shape.top\" [style.left.px]=\"shape.left\" [style.height.px]=\"shape.height\"></div>\n }\n @if (dropCaret(); as shape) {\n <div class=\"nol-code-editor-drop-caret\" [style.top.px]=\"shape.top\" [style.left.px]=\"shape.left\" [style.height.px]=\"shape.height\"></div>\n }\n @if (composing(); as text) {\n <span class=\"nol-code-editor-composition\" [style.top.px]=\"primaryCaret().top\" [style.left.px]=\"primaryCaret().left\">{{ text }}</span>\n }\n <textarea #input class=\"nol-code-editor-input\" [attr.aria-label]=\"label()\" [readOnly]=\"readOnly()\" autocapitalize=\"off\" autocomplete=\"off\" spellcheck=\"false\"\n wrap=\"off\" [style.top.px]=\"primaryCaret().top\" [style.left.px]=\"primaryCaret().left\" (keydown)=\"onKeyDown($event)\" (beforeinput)=\"onBeforeInput($event)\"\n (compositionstart)=\"onCompositionStart()\" (compositionupdate)=\"onCompositionUpdate($event)\" (compositionend)=\"onCompositionEnd($event)\"\n (paste)=\"onPaste($event)\" (copy)=\"onCopy($event)\" (cut)=\"onCut($event)\" (focus)=\"focused.set(true)\" (blur)=\"onBlur()\"></textarea>\n <span #probe class=\"nol-code-editor-probe\" aria-hidden=\"true\">0</span>\n </div>\n </div>\n</div>\n@if (searchOpen()) {\n <noldova-find-bar [seed]=\"searchSeed()\" [status]=\"searchStatus()\" [replacing]=\"replaceOpen()\" (queryChange)=\"onQuery($event)\" (next)=\"findNext()\"\n (previous)=\"findPrevious()\" (replace)=\"replaceOne($event)\" (replaceAll)=\"replaceEvery($event)\" (dismiss)=\"closeSearch()\" />\n}\n", styles: ["/**\n * @license\n * Copyright (c) Noldova.\n *\n * This source code is licensed under the license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n:host {\n\n display: block;\n position: relative;\n box-sizing: border-box;\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n background-color: var(--nol-code);\n color: var(--nol-text);\n font-family: var(--nol-font-mono);\n font-size: var(--nol-code-editor-font-size, var(--nol-text-code));\n line-height: var(--nol-code-editor-line-height, var(--nol-line-code));\n tab-size: 4;\n}\n\n:host(.nol-code-editor-focused) {\n outline: var(--nol-border-width) solid var(--nol-accent);\n outline-offset: calc(0px - var(--nol-border-width));\n\n @media (forced-colors: active) {\n outline: calc(var(--nol-border-width) * 2) solid Highlight;\n }\n}\n\n.nol-code-editor-scroller {\n position: relative;\n height: 100%;\n overflow: auto;\n cursor: text;\n}\n\n.nol-code-editor-sizer {\n display: flex;\n position: relative;\n box-sizing: border-box;\n width: max-content;\n min-width: 100%;\n}\n\n.nol-code-editor-gutter {\n position: sticky;\n inset-inline-start: 0;\n z-index: 2;\n flex: none;\n box-sizing: content-box;\n min-width: max(calc(var(--nol-code-editor-digits) * 1ch),\n calc(var(--nol-code-editor-gutter-width, 0px) - var(--nol-space-2) - var(--nol-code-editor-gutter-end, var(--nol-space-2))));\n padding-inline: var(--nol-space-2) var(--nol-code-editor-gutter-end, var(--nol-space-2));\n background-color: var(--nol-code);\n color: var(--nol-text-muted);\n text-align: end;\n user-select: none;\n}\n\n.nol-code-editor-line-number,\n.nol-code-editor-line {\n height: 1lh;\n white-space: pre;\n}\n\n.nol-code-editor-line-number,\n.nol-code-editor-row {\n position: relative;\n isolation: isolate;\n}\n\n.nol-code-editor-paint {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n\n.nol-code-editor-fold-toggle {\n display: inline-block;\n width: 1.5rem;\n margin-inline-start: var(--nol-space-1);\n vertical-align: top;\n text-align: center;\n}\n\n.nol-code-editor-fold-icon {\n display: block;\n width: 100%;\n height: 1lh;\n font-size: 1em;\n line-height: inherit;\n cursor: pointer;\n}\n\n.nol-code-editor-fold-icon:hover {\n color: var(--nol-text);\n}\n\n.nol-code-editor-number {\n display: inline-block;\n width: calc(var(--nol-code-editor-digits) * 1ch);\n}\n\n.nol-code-editor-number + .nol-code-editor-number {\n margin-inline-start: var(--nol-space-2);\n}\n\n.nol-code-editor-sign {\n display: var(--nol-code-editor-signs, inline-block);\n width: 1ch;\n margin-inline-start: var(--nol-space-1);\n text-align: center;\n}\n\n.nol-code-editor-content {\n position: relative;\n flex: 1 0 auto;\n padding-inline: var(--nol-code-editor-inset, var(--nol-space-2)) var(--nol-space-2);\n}\n\n.nol-code-editor-selection,\n.nol-code-editor-caret,\n.nol-code-editor-drop-caret,\n.nol-code-editor-composition,\n.nol-code-editor-input,\n.nol-code-editor-probe {\n position: absolute;\n margin-inline-start: var(--nol-code-editor-inset, var(--nol-space-2));\n}\n\n.nol-code-editor-match {\n position: absolute;\n height: 1lh;\n margin-inline-start: var(--nol-code-editor-inset, var(--nol-space-2));\n background-color: color-mix(in srgb, var(--nol-list-highlight) 25%, transparent);\n pointer-events: none;\n}\n\n.nol-code-editor-match-current {\n background-color: color-mix(in srgb, var(--nol-list-highlight) 45%, transparent);\n box-shadow: inset 0 0 0 var(--nol-border-width) var(--nol-accent);\n}\n\n@media (forced-colors: active) {\n .nol-code-editor-match {\n outline: var(--nol-border-width) solid Highlight;\n }\n}\n\n.nol-code-editor-selection {\n background-color: var(--nol-text-selection);\n}\n\n.nol-code-editor-rows {\n position: absolute;\n inset-inline: 0;\n top: 0;\n}\n\n.nol-code-editor-row {\n height: 1lh;\n}\n\n.nol-code-editor-change {\n position: absolute;\n height: 1lh;\n margin-inline-start: var(--nol-code-editor-inset, var(--nol-space-2));\n}\n\n.nol-code-editor-bar {\n display: flex;\n position: absolute;\n z-index: 3;\n align-items: center;\n gap: 0.375rem;\n box-sizing: border-box;\n height: 1lh;\n padding-inline: 0.75rem;\n background-color: var(--nol-code-header);\n color: var(--nol-text-muted);\n font-family: var(--nol-font-sans);\n font-size: 0.75rem;\n white-space: nowrap;\n cursor: default;\n}\n\n.nol-code-editor-bar-icon {\n flex: none;\n color: var(--nol-warning);\n font-size: var(--nol-icon);\n}\n\n.nol-code-editor-bar-note {\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.nol-code-editor-action {\n display: inline-flex;\n position: relative;\n flex: none;\n align-items: center;\n gap: 0.25rem;\n box-sizing: border-box;\n height: 1.25rem;\n margin: 0;\n padding-block: 0;\n padding-inline: 0.375rem;\n border: var(--nol-border-width) solid var(--nol-border);\n border-radius: var(--nol-radius-small);\n background-color: var(--nol-panel);\n color: var(--nol-text);\n font-family: var(--nol-font-sans);\n font-size: 0.75rem;\n line-height: 1;\n white-space: nowrap;\n cursor: pointer;\n}\n\n.nol-code-editor-action::before {\n position: absolute;\n inset-block: calc((1.25rem - var(--nol-pointer-target)) / 2 - var(--nol-border-width));\n inset-inline: calc(0px - var(--nol-border-width));\n content: \"\";\n}\n\n.nol-code-editor-action-icon {\n font-size: 0.875rem;\n}\n\n.nol-code-editor-action:hover {\n background-color: var(--nol-hover);\n}\n\n.nol-code-editor-action:focus-visible {\n outline: var(--nol-border-width) solid var(--nol-accent);\n outline-offset: var(--nol-border-width);\n}\n\n.nol-code-editor-row-spacer {\n background-image: repeating-linear-gradient(-45deg, var(--nol-card-border) 0 var(--nol-border-width), transparent var(--nol-border-width) var(--nol-space-2));\n}\n\n.nol-code-editor-row-fold {\n background-color: var(--nol-code-header);\n}\n\n.nol-code-editor-line-fold {\n color: var(--nol-text-muted);\n cursor: pointer;\n}\n\n@media (forced-colors: active) {\n .nol-code-editor-change {\n box-sizing: border-box;\n border-block-end: calc(var(--nol-border-width) * 2) solid Highlight;\n }\n}\n\n.nol-code-editor-lines {\n position: relative;\n}\n\n.nol-code-editor-caret,\n.nol-code-editor-drop-caret {\n z-index: 1;\n box-sizing: border-box;\n width: 0;\n border-inline-start: calc(var(--nol-border-width) * 2) solid var(--nol-text);\n pointer-events: none;\n}\n\n:host(:not(.nol-code-editor-focused)) .nol-code-editor-caret {\n visibility: hidden;\n}\n\n.nol-code-editor-composition {\n z-index: 1;\n background-color: var(--nol-code);\n text-decoration: underline;\n white-space: pre;\n pointer-events: none;\n}\n\n.nol-code-editor-input {\n box-sizing: border-box;\n width: 1px;\n height: 1lh;\n margin-block: 0;\n padding: 0;\n overflow: hidden;\n border: 0;\n outline: none;\n background: transparent;\n color: transparent;\n font: inherit;\n white-space: pre;\n caret-color: transparent;\n opacity: 0;\n resize: none;\n}\n\n.nol-code-editor-probe {\n top: 0;\n height: 1lh;\n visibility: hidden;\n}\n"], dependencies: [{ kind: "component", type: FindBarComponent, selector: "noldova-find-bar", inputs: ["seed", "status", "replacing"], outputs: ["queryChange", "next", "previous", "replace", "replaceAll", "dismiss"] }] });
|
|
641
|
+
}
|
|
642
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: CodeEditorComponent, decorators: [{
|
|
643
|
+
type: Component,
|
|
644
|
+
args: [{ selector: "noldova-code-editor", imports: [FindBarComponent], providers: [KeyScope], host: {
|
|
645
|
+
"class": Resources.codeEditorClass,
|
|
646
|
+
[Resources.focusedClassBinding]: "focused()"
|
|
647
|
+
}, template: "<!--\n@license\nCopyright (c) Noldova.\n\nThis source code is licensed under the license found in the\nLICENSE file in the root directory of this source tree.\n-->\n<div #scroller class=\"nol-code-editor-scroller\" (scroll)=\"onScroll()\" (mousedown)=\"onMouseDown($event)\" (dragover)=\"onDragOver($event)\"\n (dragleave)=\"dropCaret.set(null)\" (drop)=\"onDrop($event)\">\n <div class=\"nol-code-editor-sizer\" [style.height.px]=\"height()\" [style.--nol-code-editor-digits]=\"digits()\">\n <div class=\"nol-code-editor-gutter\" aria-hidden=\"true\">\n <div class=\"nol-code-editor-numbers\" [style.transform]=\"'translateY(' + offset() + 'px)'\">\n @for (row of rows(); track $index) {\n <div class=\"nol-code-editor-line-number\" [class]=\"resources.rowClass(row.kind)\">@for (paint of row.paints; track $index) {<span class=\"nol-code-editor-paint\" [style.background]=\"paint\"></span>}@if (paired()) {<span class=\"nol-code-editor-number\">{{ row.otherNumber }}</span>}<span class=\"nol-code-editor-number\">{{ row.number }}</span>@if (marked()) {<span class=\"nol-code-editor-sign\" [style.color]=\"row.marker?.color ?? null\">{{ row.marker?.text ?? resources.empty }}</span>}@if (foldable()) {<span class=\"nol-code-editor-fold-toggle\">@if (row.fold; as fold) {<span class=\"nol-code-editor-fold-icon material-symbols-rounded\" (mousedown)=\"onFoldToggle($event, fold)\">{{ fold.collapsed ? resources.foldClosedIcon : resources.foldOpenIcon }}</span>}</span>}</div>\n }\n </div>\n </div>\n @for (shape of barShapes(); track $index) {\n <div class=\"nol-code-editor-bar\" [style.top.px]=\"shape.top\" [style.left.px]=\"barLeft()\" [style.width.px]=\"barWidth()\" [style.background]=\"shape.bar.background\"\n [style.color]=\"shape.bar.color\" (mousedown)=\"$event.stopPropagation()\">@if (shape.bar.icon; as icon) {<span class=\"nol-code-editor-bar-icon material-symbols-rounded\" aria-hidden=\"true\">{{ icon }}</span>}<span class=\"nol-code-editor-bar-note\">{{ shape.bar.note }}</span>@for (action of shape.bar.actions; track action.id) {<button type=\"button\" class=\"nol-code-editor-action\" (click)=\"onAction(shape.bar, action)\">@if (action.icon; as icon) {<span class=\"nol-code-editor-action-icon material-symbols-rounded\" aria-hidden=\"true\">{{ icon }}</span>}{{ action.label }}</button>}</div>\n }\n <div #content class=\"nol-code-editor-content\">\n @if (rowed()) {\n <div class=\"nol-code-editor-rows\" aria-hidden=\"true\" [style.transform]=\"'translateY(' + offset() + 'px)'\">\n @for (row of rows(); track $index) {\n <div class=\"nol-code-editor-row\" [class]=\"resources.rowClass(row.kind)\">@for (paint of row.paints; track $index) {<div class=\"nol-code-editor-paint\" [style.background]=\"paint\"></div>}</div>\n }\n </div>\n @for (shape of changeShapes(); track $index) {\n <div class=\"nol-code-editor-change\" [style.top.px]=\"shape.top\" [style.left.px]=\"shape.left\" [style.width.px]=\"shape.width\" [style.background]=\"shape.background\"></div>\n }\n }\n @for (shape of selectionShapes(); track $index) {\n <div class=\"nol-code-editor-selection\" [style.top.px]=\"shape.top\" [style.left.px]=\"shape.left\" [style.width.px]=\"shape.width\" [style.height.px]=\"shape.height\"></div>\n }\n @for (shape of matchShapes(); track $index) {\n <div class=\"nol-code-editor-match\" [class.nol-code-editor-match-current]=\"shape.current\" [style.top.px]=\"shape.top\" [style.left.px]=\"shape.left\"\n [style.width.px]=\"shape.width\"></div>\n }\n <div class=\"nol-code-editor-lines\" aria-hidden=\"true\" [style.transform]=\"'translateY(' + offset() + 'px)'\">\n @for (row of rows(); track $index) {\n <div class=\"nol-code-editor-line\" [class.nol-code-editor-line-fold]=\"row.kind === foldKind\">@for (segment of row.segments; track $index) {<span [class]=\"resources.segmentClass(tokenTypes, segment)\">{{ row.text.slice(segment.start, segment.end) }}</span>}</div>\n }\n </div>\n @for (shape of caretShapes(); track $index) {\n <div class=\"nol-code-editor-caret\" [style.top.px]=\"shape.top\" [style.left.px]=\"shape.left\" [style.height.px]=\"shape.height\"></div>\n }\n @if (dropCaret(); as shape) {\n <div class=\"nol-code-editor-drop-caret\" [style.top.px]=\"shape.top\" [style.left.px]=\"shape.left\" [style.height.px]=\"shape.height\"></div>\n }\n @if (composing(); as text) {\n <span class=\"nol-code-editor-composition\" [style.top.px]=\"primaryCaret().top\" [style.left.px]=\"primaryCaret().left\">{{ text }}</span>\n }\n <textarea #input class=\"nol-code-editor-input\" [attr.aria-label]=\"label()\" [readOnly]=\"readOnly()\" autocapitalize=\"off\" autocomplete=\"off\" spellcheck=\"false\"\n wrap=\"off\" [style.top.px]=\"primaryCaret().top\" [style.left.px]=\"primaryCaret().left\" (keydown)=\"onKeyDown($event)\" (beforeinput)=\"onBeforeInput($event)\"\n (compositionstart)=\"onCompositionStart()\" (compositionupdate)=\"onCompositionUpdate($event)\" (compositionend)=\"onCompositionEnd($event)\"\n (paste)=\"onPaste($event)\" (copy)=\"onCopy($event)\" (cut)=\"onCut($event)\" (focus)=\"focused.set(true)\" (blur)=\"onBlur()\"></textarea>\n <span #probe class=\"nol-code-editor-probe\" aria-hidden=\"true\">0</span>\n </div>\n </div>\n</div>\n@if (searchOpen()) {\n <noldova-find-bar [seed]=\"searchSeed()\" [status]=\"searchStatus()\" [replacing]=\"replaceOpen()\" (queryChange)=\"onQuery($event)\" (next)=\"findNext()\"\n (previous)=\"findPrevious()\" (replace)=\"replaceOne($event)\" (replaceAll)=\"replaceEvery($event)\" (dismiss)=\"closeSearch()\" />\n}\n", styles: ["/**\n * @license\n * Copyright (c) Noldova.\n *\n * This source code is licensed under the license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n:host {\n\n display: block;\n position: relative;\n box-sizing: border-box;\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n background-color: var(--nol-code);\n color: var(--nol-text);\n font-family: var(--nol-font-mono);\n font-size: var(--nol-code-editor-font-size, var(--nol-text-code));\n line-height: var(--nol-code-editor-line-height, var(--nol-line-code));\n tab-size: 4;\n}\n\n:host(.nol-code-editor-focused) {\n outline: var(--nol-border-width) solid var(--nol-accent);\n outline-offset: calc(0px - var(--nol-border-width));\n\n @media (forced-colors: active) {\n outline: calc(var(--nol-border-width) * 2) solid Highlight;\n }\n}\n\n.nol-code-editor-scroller {\n position: relative;\n height: 100%;\n overflow: auto;\n cursor: text;\n}\n\n.nol-code-editor-sizer {\n display: flex;\n position: relative;\n box-sizing: border-box;\n width: max-content;\n min-width: 100%;\n}\n\n.nol-code-editor-gutter {\n position: sticky;\n inset-inline-start: 0;\n z-index: 2;\n flex: none;\n box-sizing: content-box;\n min-width: max(calc(var(--nol-code-editor-digits) * 1ch),\n calc(var(--nol-code-editor-gutter-width, 0px) - var(--nol-space-2) - var(--nol-code-editor-gutter-end, var(--nol-space-2))));\n padding-inline: var(--nol-space-2) var(--nol-code-editor-gutter-end, var(--nol-space-2));\n background-color: var(--nol-code);\n color: var(--nol-text-muted);\n text-align: end;\n user-select: none;\n}\n\n.nol-code-editor-line-number,\n.nol-code-editor-line {\n height: 1lh;\n white-space: pre;\n}\n\n.nol-code-editor-line-number,\n.nol-code-editor-row {\n position: relative;\n isolation: isolate;\n}\n\n.nol-code-editor-paint {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n\n.nol-code-editor-fold-toggle {\n display: inline-block;\n width: 1.5rem;\n margin-inline-start: var(--nol-space-1);\n vertical-align: top;\n text-align: center;\n}\n\n.nol-code-editor-fold-icon {\n display: block;\n width: 100%;\n height: 1lh;\n font-size: 1em;\n line-height: inherit;\n cursor: pointer;\n}\n\n.nol-code-editor-fold-icon:hover {\n color: var(--nol-text);\n}\n\n.nol-code-editor-number {\n display: inline-block;\n width: calc(var(--nol-code-editor-digits) * 1ch);\n}\n\n.nol-code-editor-number + .nol-code-editor-number {\n margin-inline-start: var(--nol-space-2);\n}\n\n.nol-code-editor-sign {\n display: var(--nol-code-editor-signs, inline-block);\n width: 1ch;\n margin-inline-start: var(--nol-space-1);\n text-align: center;\n}\n\n.nol-code-editor-content {\n position: relative;\n flex: 1 0 auto;\n padding-inline: var(--nol-code-editor-inset, var(--nol-space-2)) var(--nol-space-2);\n}\n\n.nol-code-editor-selection,\n.nol-code-editor-caret,\n.nol-code-editor-drop-caret,\n.nol-code-editor-composition,\n.nol-code-editor-input,\n.nol-code-editor-probe {\n position: absolute;\n margin-inline-start: var(--nol-code-editor-inset, var(--nol-space-2));\n}\n\n.nol-code-editor-match {\n position: absolute;\n height: 1lh;\n margin-inline-start: var(--nol-code-editor-inset, var(--nol-space-2));\n background-color: color-mix(in srgb, var(--nol-list-highlight) 25%, transparent);\n pointer-events: none;\n}\n\n.nol-code-editor-match-current {\n background-color: color-mix(in srgb, var(--nol-list-highlight) 45%, transparent);\n box-shadow: inset 0 0 0 var(--nol-border-width) var(--nol-accent);\n}\n\n@media (forced-colors: active) {\n .nol-code-editor-match {\n outline: var(--nol-border-width) solid Highlight;\n }\n}\n\n.nol-code-editor-selection {\n background-color: var(--nol-text-selection);\n}\n\n.nol-code-editor-rows {\n position: absolute;\n inset-inline: 0;\n top: 0;\n}\n\n.nol-code-editor-row {\n height: 1lh;\n}\n\n.nol-code-editor-change {\n position: absolute;\n height: 1lh;\n margin-inline-start: var(--nol-code-editor-inset, var(--nol-space-2));\n}\n\n.nol-code-editor-bar {\n display: flex;\n position: absolute;\n z-index: 3;\n align-items: center;\n gap: 0.375rem;\n box-sizing: border-box;\n height: 1lh;\n padding-inline: 0.75rem;\n background-color: var(--nol-code-header);\n color: var(--nol-text-muted);\n font-family: var(--nol-font-sans);\n font-size: 0.75rem;\n white-space: nowrap;\n cursor: default;\n}\n\n.nol-code-editor-bar-icon {\n flex: none;\n color: var(--nol-warning);\n font-size: var(--nol-icon);\n}\n\n.nol-code-editor-bar-note {\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.nol-code-editor-action {\n display: inline-flex;\n position: relative;\n flex: none;\n align-items: center;\n gap: 0.25rem;\n box-sizing: border-box;\n height: 1.25rem;\n margin: 0;\n padding-block: 0;\n padding-inline: 0.375rem;\n border: var(--nol-border-width) solid var(--nol-border);\n border-radius: var(--nol-radius-small);\n background-color: var(--nol-panel);\n color: var(--nol-text);\n font-family: var(--nol-font-sans);\n font-size: 0.75rem;\n line-height: 1;\n white-space: nowrap;\n cursor: pointer;\n}\n\n.nol-code-editor-action::before {\n position: absolute;\n inset-block: calc((1.25rem - var(--nol-pointer-target)) / 2 - var(--nol-border-width));\n inset-inline: calc(0px - var(--nol-border-width));\n content: \"\";\n}\n\n.nol-code-editor-action-icon {\n font-size: 0.875rem;\n}\n\n.nol-code-editor-action:hover {\n background-color: var(--nol-hover);\n}\n\n.nol-code-editor-action:focus-visible {\n outline: var(--nol-border-width) solid var(--nol-accent);\n outline-offset: var(--nol-border-width);\n}\n\n.nol-code-editor-row-spacer {\n background-image: repeating-linear-gradient(-45deg, var(--nol-card-border) 0 var(--nol-border-width), transparent var(--nol-border-width) var(--nol-space-2));\n}\n\n.nol-code-editor-row-fold {\n background-color: var(--nol-code-header);\n}\n\n.nol-code-editor-line-fold {\n color: var(--nol-text-muted);\n cursor: pointer;\n}\n\n@media (forced-colors: active) {\n .nol-code-editor-change {\n box-sizing: border-box;\n border-block-end: calc(var(--nol-border-width) * 2) solid Highlight;\n }\n}\n\n.nol-code-editor-lines {\n position: relative;\n}\n\n.nol-code-editor-caret,\n.nol-code-editor-drop-caret {\n z-index: 1;\n box-sizing: border-box;\n width: 0;\n border-inline-start: calc(var(--nol-border-width) * 2) solid var(--nol-text);\n pointer-events: none;\n}\n\n:host(:not(.nol-code-editor-focused)) .nol-code-editor-caret {\n visibility: hidden;\n}\n\n.nol-code-editor-composition {\n z-index: 1;\n background-color: var(--nol-code);\n text-decoration: underline;\n white-space: pre;\n pointer-events: none;\n}\n\n.nol-code-editor-input {\n box-sizing: border-box;\n width: 1px;\n height: 1lh;\n margin-block: 0;\n padding: 0;\n overflow: hidden;\n border: 0;\n outline: none;\n background: transparent;\n color: transparent;\n font: inherit;\n white-space: pre;\n caret-color: transparent;\n opacity: 0;\n resize: none;\n}\n\n.nol-code-editor-probe {\n top: 0;\n height: 1lh;\n visibility: hidden;\n}\n"] }]
|
|
648
|
+
}], ctorParameters: () => [], propDecorators: { scroller: [{ type: i0.ViewChild, args: ["scroller", { isSignal: true }] }], content: [{ type: i0.ViewChild, args: ["content", { isSignal: true }] }], textInput: [{ type: i0.ViewChild, args: ["input", { isSignal: true }] }], probe: [{ type: i0.ViewChild, args: ["probe", { isSignal: true }] }], findBar: [{ type: i0.ViewChild, args: [i0.forwardRef(() => FindBarComponent), { isSignal: true }] }], document: [{ type: i0.Input, args: [{ isSignal: true, alias: "document", required: true }] }], history: [{ type: i0.Input, args: [{ isSignal: true, alias: "history", required: true }] }], language: [{ type: i0.Input, args: [{ isSignal: true, alias: "language", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], readOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readOnly", required: false }] }], tabIndents: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabIndents", required: false }] }], decorations: [{ type: i0.Input, args: [{ isSignal: true, alias: "decorations", required: false }] }], folds: [{ type: i0.Input, args: [{ isSignal: true, alias: "folds", required: false }] }], selectionsChange: [{ type: i0.Output, args: ["selectionsChange"] }], scrollChange: [{ type: i0.Output, args: ["scrollChange"] }], foldToggle: [{ type: i0.Output, args: ["foldToggle"] }], barAction: [{ type: i0.Output, args: ["barAction"] }], keySequencePending: [{ type: i0.Output, args: ["keySequencePending"] }] } });
|