@ngstarter-ui/components 22.0.5 → 22.1.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/ai/component-registry.json +250 -198
- package/fesm2022/ngstarter-ui-components-comment-editor.mjs +781 -749
- package/fesm2022/ngstarter-ui-components-comment-editor.mjs.map +1 -1
- package/fesm2022/ngstarter-ui-components-headless-editor.mjs +3689 -0
- package/fesm2022/ngstarter-ui-components-headless-editor.mjs.map +1 -0
- package/package.json +5 -23
- package/styles/_tokens.scss +17 -2
- package/styles/themes/chalk.scss +1 -0
- package/types/ngstarter-ui-components-comment-editor.d.ts +150 -99
- package/types/ngstarter-ui-components-headless-editor.d.ts +795 -0
- package/fesm2022/ngstarter-ui-components-motion.mjs +0 -27
- package/fesm2022/ngstarter-ui-components-motion.mjs.map +0 -1
- package/fesm2022/ngstarter-ui-components-text-editor.mjs +0 -1038
- package/fesm2022/ngstarter-ui-components-text-editor.mjs.map +0 -1
- package/types/ngstarter-ui-components-motion.d.ts +0 -13
- package/types/ngstarter-ui-components-text-editor.d.ts +0 -192
|
@@ -0,0 +1,795 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { Signal, InjectionToken, Provider, Type, WritableSignal } from '@angular/core';
|
|
3
|
+
import * as _ngstarter_ui_components_headless_editor from '@ngstarter-ui/components/headless-editor';
|
|
4
|
+
import { Menu } from '@ngstarter-ui/components/menu';
|
|
5
|
+
|
|
6
|
+
type NgsHeadlessEditorMarkAttributes = Readonly<Record<string, string | number | boolean | null>>;
|
|
7
|
+
interface NgsHeadlessEditorMark {
|
|
8
|
+
readonly type: string;
|
|
9
|
+
readonly attrs?: NgsHeadlessEditorMarkAttributes;
|
|
10
|
+
}
|
|
11
|
+
interface NgsHeadlessEditorText {
|
|
12
|
+
readonly type: 'text';
|
|
13
|
+
readonly text: string;
|
|
14
|
+
readonly marks: readonly NgsHeadlessEditorMark[];
|
|
15
|
+
}
|
|
16
|
+
interface NgsHeadlessEditorBlock<TContent = unknown> {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly type: string;
|
|
19
|
+
readonly content: TContent;
|
|
20
|
+
readonly attrs?: Readonly<Record<string, unknown>>;
|
|
21
|
+
}
|
|
22
|
+
interface NgsHeadlessEditorDocument {
|
|
23
|
+
readonly version: 1;
|
|
24
|
+
readonly blocks: readonly NgsHeadlessEditorBlock[];
|
|
25
|
+
}
|
|
26
|
+
interface NgsHeadlessEditorPoint {
|
|
27
|
+
readonly blockId: string;
|
|
28
|
+
readonly offset: number;
|
|
29
|
+
}
|
|
30
|
+
interface NgsHeadlessEditorSelection {
|
|
31
|
+
readonly anchor: NgsHeadlessEditorPoint;
|
|
32
|
+
readonly focus: NgsHeadlessEditorPoint;
|
|
33
|
+
}
|
|
34
|
+
declare function createNgsHeadlessEditorId(prefix?: string): string;
|
|
35
|
+
declare function createNgsHeadlessEditorText(text?: string, marks?: readonly NgsHeadlessEditorMark[]): NgsHeadlessEditorText;
|
|
36
|
+
declare function createNgsHeadlessEditorParagraph(text?: string, marks?: readonly NgsHeadlessEditorMark[]): NgsHeadlessEditorBlock<readonly NgsHeadlessEditorText[]>;
|
|
37
|
+
declare function createNgsHeadlessEditorDocument(text?: string): NgsHeadlessEditorDocument;
|
|
38
|
+
declare function cloneNgsHeadlessEditorDocument(document: NgsHeadlessEditorDocument): NgsHeadlessEditorDocument;
|
|
39
|
+
/**
|
|
40
|
+
* Normalizes a document. The model is immutable, so unchanged blocks keep their
|
|
41
|
+
* object identity; the surface relies on it to re-render only changed blocks.
|
|
42
|
+
* When nothing needs fixing the input document itself is returned.
|
|
43
|
+
*/
|
|
44
|
+
declare function normalizeNgsHeadlessEditorDocument(document: NgsHeadlessEditorDocument): NgsHeadlessEditorDocument;
|
|
45
|
+
declare function normalizeNgsHeadlessEditorTextContent(content: readonly NgsHeadlessEditorText[]): readonly NgsHeadlessEditorText[];
|
|
46
|
+
declare function normalizeNgsHeadlessEditorMarks(marks: readonly NgsHeadlessEditorMark[]): readonly NgsHeadlessEditorMark[];
|
|
47
|
+
declare function ngsHeadlessEditorMarksEqual(left: readonly NgsHeadlessEditorMark[], right: readonly NgsHeadlessEditorMark[]): boolean;
|
|
48
|
+
/** Structural equality of two blocks (id, type, attrs and content). */
|
|
49
|
+
declare function ngsHeadlessEditorBlocksEqual(left: NgsHeadlessEditorBlock, right: NgsHeadlessEditorBlock): boolean;
|
|
50
|
+
/** Structural document equality; short-circuits on shared (unchanged) blocks. */
|
|
51
|
+
declare function ngsHeadlessEditorDocumentsEqual(left: NgsHeadlessEditorDocument, right: NgsHeadlessEditorDocument): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Deep equality for JSON-like values. Object key order is ignored and keys with
|
|
54
|
+
* `undefined` values are treated as absent, matching JSON serialization.
|
|
55
|
+
*/
|
|
56
|
+
declare function ngsHeadlessEditorValuesEqual(left: unknown, right: unknown): boolean;
|
|
57
|
+
declare function isNgsHeadlessEditorTextContent(content: unknown): content is readonly NgsHeadlessEditorText[];
|
|
58
|
+
declare function getNgsHeadlessEditorBlockText(block: NgsHeadlessEditorBlock): string;
|
|
59
|
+
declare function getNgsHeadlessEditorDocumentText(document: NgsHeadlessEditorDocument): string;
|
|
60
|
+
declare function isNgsHeadlessEditorDocumentEmpty(document: NgsHeadlessEditorDocument): boolean;
|
|
61
|
+
|
|
62
|
+
type NgsHeadlessEditorChangeOrigin = 'external' | 'api' | 'keyboard' | 'paste' | 'composition' | 'history' | 'command';
|
|
63
|
+
declare const NGS_HEADLESS_EDITOR_PLUGINS: InjectionToken<readonly NgsHeadlessEditorPlugin[]>;
|
|
64
|
+
declare function provideNgsHeadlessEditor(...features: readonly NgsHeadlessEditorFeature[]): Provider[];
|
|
65
|
+
declare class NgsHeadlessEditor {
|
|
66
|
+
private readonly history;
|
|
67
|
+
private readonly destroyRef;
|
|
68
|
+
private readonly injectedPlugins;
|
|
69
|
+
private readonly _document;
|
|
70
|
+
private readonly _selection;
|
|
71
|
+
/** Marks for the next insertion at a collapsed caret; `null` means "inherit from the text". */
|
|
72
|
+
private readonly _storedMarks;
|
|
73
|
+
private readonly _focused;
|
|
74
|
+
private readonly _composing;
|
|
75
|
+
private readonly _readOnly;
|
|
76
|
+
private readonly _revision;
|
|
77
|
+
private readonly _origin;
|
|
78
|
+
private readonly _plugins;
|
|
79
|
+
private readonly _inlineTarget;
|
|
80
|
+
private readonly commands;
|
|
81
|
+
private readonly marks;
|
|
82
|
+
private readonly blocks;
|
|
83
|
+
private keymap;
|
|
84
|
+
private pluginCleanups;
|
|
85
|
+
readonly document: Signal<NgsHeadlessEditorDocument>;
|
|
86
|
+
/**
|
|
87
|
+
* Nested editor that currently receives formatting, for example the editor of
|
|
88
|
+
* the focused table cell. See setInlineTarget().
|
|
89
|
+
*/
|
|
90
|
+
readonly inlineTarget: Signal<NgsHeadlessEditor | null>;
|
|
91
|
+
/** Selection of the inline target while one is active, otherwise of this editor. */
|
|
92
|
+
readonly selection: Signal<NgsHeadlessEditorSelection | null>;
|
|
93
|
+
readonly storedMarks: Signal<readonly NgsHeadlessEditorMark[]>;
|
|
94
|
+
readonly focused: Signal<boolean>;
|
|
95
|
+
readonly composing: Signal<boolean>;
|
|
96
|
+
readonly readOnly: Signal<boolean>;
|
|
97
|
+
readonly revision: Signal<number>;
|
|
98
|
+
readonly origin: Signal<NgsHeadlessEditorChangeOrigin>;
|
|
99
|
+
readonly plugins: Signal<readonly NgsHeadlessEditorPlugin[]>;
|
|
100
|
+
readonly empty: Signal<boolean>;
|
|
101
|
+
readonly canUndo: Signal<boolean>;
|
|
102
|
+
readonly canRedo: Signal<boolean>;
|
|
103
|
+
constructor();
|
|
104
|
+
setPlugins(plugins: readonly NgsHeadlessEditorPlugin[]): void;
|
|
105
|
+
getMarkDefinition(type: string): NgsHeadlessEditorMarkDefinition | undefined;
|
|
106
|
+
getMarkDefinitions(): readonly NgsHeadlessEditorMarkDefinition[];
|
|
107
|
+
getBlockDefinition(type: string): NgsHeadlessEditorBlockDefinition | undefined;
|
|
108
|
+
getBlockDefinitions(): readonly NgsHeadlessEditorBlockDefinition[];
|
|
109
|
+
setDocument(document: NgsHeadlessEditorDocument, resetHistory?: boolean): void;
|
|
110
|
+
setReadOnly(readOnly: boolean): void;
|
|
111
|
+
setFocused(focused: boolean): void;
|
|
112
|
+
setComposing(composing: boolean): void;
|
|
113
|
+
setSelection(selection: NgsHeadlessEditorSelection | null): void;
|
|
114
|
+
execute<TPayload>(command: NgsHeadlessEditorCommand<TPayload> | string, payload?: TPayload): boolean;
|
|
115
|
+
isCommandEnabled<TPayload>(command: NgsHeadlessEditorCommand<TPayload>, payload?: TPayload): boolean;
|
|
116
|
+
isCommandActive<TPayload>(command: NgsHeadlessEditorCommand<TPayload>, payload?: TPayload): boolean;
|
|
117
|
+
handleKeydown(event: KeyboardEvent): boolean;
|
|
118
|
+
handlePaste(event: ClipboardEvent): boolean;
|
|
119
|
+
insertText(text: string, origin?: NgsHeadlessEditorChangeOrigin): boolean;
|
|
120
|
+
deleteBackward(): boolean;
|
|
121
|
+
deleteForward(): boolean;
|
|
122
|
+
deleteRange(selection: NgsHeadlessEditorSelection, origin: NgsHeadlessEditorChangeOrigin, historyGroup?: string | null): boolean;
|
|
123
|
+
splitBlock(): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Routes formatting (marks, stored marks, the selection used by mark commands
|
|
126
|
+
* and insertText()) to a nested editor, such as the editor of a focused table
|
|
127
|
+
* cell. Toolbar commands keep working unchanged: they run against this editor
|
|
128
|
+
* and act on the nested one. Pass null to restore normal behavior. Block-level
|
|
129
|
+
* operations are disabled while a target is active.
|
|
130
|
+
*/
|
|
131
|
+
setInlineTarget(target: NgsHeadlessEditor | null): void;
|
|
132
|
+
/** Whether a mark can be applied at the current selection (registered, writable). */
|
|
133
|
+
canApplyMark(type: string): boolean;
|
|
134
|
+
/** Whether block operations such as toggleBlock() are possible right now. */
|
|
135
|
+
canEditBlocks(): boolean;
|
|
136
|
+
toggleMark(type: string, attrs?: NgsHeadlessEditorMark['attrs']): boolean;
|
|
137
|
+
isMarkActive(type: string): boolean;
|
|
138
|
+
getActiveMark(type: string): NgsHeadlessEditorMark | undefined;
|
|
139
|
+
setMark(type: string, attrs?: NgsHeadlessEditorMark['attrs']): boolean;
|
|
140
|
+
unsetMark(type: string): boolean;
|
|
141
|
+
toggleBlock(type: string, fallbackType?: string): boolean;
|
|
142
|
+
isBlockActive(type: string): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Inserts one or more blocks after the block that holds the caret, as one
|
|
145
|
+
* undo step. With `selectInserted` the caret moves to the end of the last
|
|
146
|
+
* inserted block.
|
|
147
|
+
*/
|
|
148
|
+
insertBlock(block: NgsHeadlessEditorBlock | readonly NgsHeadlessEditorBlock[], selectInserted?: boolean): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Replaces a block with zero or more blocks as one undo step, for example to
|
|
151
|
+
* turn an empty line into a table. The caret moves to `selection` when given.
|
|
152
|
+
*/
|
|
153
|
+
replaceBlock(blockId: string, replacement: readonly NgsHeadlessEditorBlock[], selection?: NgsHeadlessEditorSelection): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Replaces type, content or attrs of a block. Updates that share a non-null
|
|
156
|
+
* `historyGroup` in quick succession (for example typing in one table cell)
|
|
157
|
+
* form a single undo step.
|
|
158
|
+
*/
|
|
159
|
+
updateBlock(blockId: string, update: Partial<Pick<NgsHeadlessEditorBlock, 'type' | 'content' | 'attrs'>>, origin?: NgsHeadlessEditorChangeOrigin, historyGroup?: string | null): boolean;
|
|
160
|
+
removeBlock(blockId: string): boolean;
|
|
161
|
+
commitDomDocument(document: NgsHeadlessEditorDocument, selection: NgsHeadlessEditorSelection | null): boolean;
|
|
162
|
+
undo(): boolean;
|
|
163
|
+
redo(): boolean;
|
|
164
|
+
clear(): void;
|
|
165
|
+
/** Marks that apply at a collapsed caret, including pending stored marks. */
|
|
166
|
+
private getCollapsedMarks;
|
|
167
|
+
private getMarksAtSelection;
|
|
168
|
+
private applyMarkToSelection;
|
|
169
|
+
private ensureSelection;
|
|
170
|
+
private commit;
|
|
171
|
+
private restoreSnapshot;
|
|
172
|
+
private destroyPlugins;
|
|
173
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgsHeadlessEditor, never>;
|
|
174
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<any>;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
interface NgsHeadlessEditorCommand<TPayload = void> {
|
|
178
|
+
readonly id: string;
|
|
179
|
+
execute(editor: NgsHeadlessEditor, payload: TPayload): boolean;
|
|
180
|
+
enabled?(editor: NgsHeadlessEditor, payload: TPayload): boolean;
|
|
181
|
+
active?(editor: NgsHeadlessEditor, payload: TPayload): boolean;
|
|
182
|
+
}
|
|
183
|
+
interface NgsHeadlessEditorKeyBinding<TPayload = unknown> {
|
|
184
|
+
readonly key: string;
|
|
185
|
+
readonly command: NgsHeadlessEditorCommand<TPayload> | string;
|
|
186
|
+
readonly payload?: TPayload;
|
|
187
|
+
}
|
|
188
|
+
interface NgsHeadlessEditorMarkDefinition {
|
|
189
|
+
readonly type: string;
|
|
190
|
+
readonly tagName: string;
|
|
191
|
+
readonly parseTags?: readonly string[];
|
|
192
|
+
/**
|
|
193
|
+
* Whether the mark is available in nested editors such as table cells.
|
|
194
|
+
* Default: true. Set false for marks that only make sense in the main text.
|
|
195
|
+
*/
|
|
196
|
+
readonly nested?: boolean;
|
|
197
|
+
/** An indivisible inline token: its text cannot be edited and deletion removes the whole token. */
|
|
198
|
+
readonly atomic?: boolean;
|
|
199
|
+
applyAttributes?(element: HTMLElement, mark: NgsHeadlessEditorMark): void;
|
|
200
|
+
readAttributes?(element: HTMLElement): NgsHeadlessEditorMark['attrs'];
|
|
201
|
+
}
|
|
202
|
+
interface NgsHeadlessEditorBlockDefinition<TContent = unknown> {
|
|
203
|
+
readonly type: string;
|
|
204
|
+
readonly tagName: string;
|
|
205
|
+
readonly contentTagName?: string;
|
|
206
|
+
readonly editable?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Enter on an empty block of this type leaves the block: the empty line is
|
|
209
|
+
* replaced by a block of `exitType` (paragraph by default). This is what makes
|
|
210
|
+
* "Enter, Enter" leave a quote, a list or a code block. Defaults to true for
|
|
211
|
+
* every text block whose type differs from `exitType`; set false to keep
|
|
212
|
+
* creating empty blocks of the same type.
|
|
213
|
+
*/
|
|
214
|
+
readonly exitOnEmptyEnter?: boolean;
|
|
215
|
+
/** Block type used when leaving this block. Defaults to 'paragraph'. */
|
|
216
|
+
readonly exitType?: string;
|
|
217
|
+
/**
|
|
218
|
+
* Creates an empty block of this type. Enter on a non-empty block uses it for
|
|
219
|
+
* the block that follows, so return a paragraph to leave the type after one
|
|
220
|
+
* Enter (headings) or the same type to continue it (quotes, list items).
|
|
221
|
+
*/
|
|
222
|
+
create(): NgsHeadlessEditorBlock<TContent>;
|
|
223
|
+
render?(element: HTMLElement, block: NgsHeadlessEditorBlock<TContent>): void;
|
|
224
|
+
read?(element: HTMLElement, previous: NgsHeadlessEditorBlock<TContent>): NgsHeadlessEditorBlock<TContent>;
|
|
225
|
+
isEmpty?(block: NgsHeadlessEditorBlock<TContent>): boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Angular component rendered as the block while the surface is editable. The
|
|
228
|
+
* block element becomes its host (`tagName`), is non-editable for the browser,
|
|
229
|
+
* and the component receives the block through a `block` input when it declares
|
|
230
|
+
* one. It can inject `NgsHeadlessEditor` and call `updateBlock()` to change its data.
|
|
231
|
+
* The instance is kept while the block id and type stay the same.
|
|
232
|
+
*/
|
|
233
|
+
readonly editorComponent?: Type<unknown>;
|
|
234
|
+
/** Component used instead of `editorComponent` while the surface is read-only or disabled. */
|
|
235
|
+
readonly rendererComponent?: Type<unknown>;
|
|
236
|
+
}
|
|
237
|
+
/** Recommended shape for `editorComponent` / `rendererComponent` implementations. */
|
|
238
|
+
interface NgsHeadlessEditorBlockComponent<TContent = unknown> {
|
|
239
|
+
readonly block: () => NgsHeadlessEditorBlock<TContent>;
|
|
240
|
+
}
|
|
241
|
+
interface NgsHeadlessEditorPlugin {
|
|
242
|
+
readonly id: string;
|
|
243
|
+
readonly blocks?: readonly NgsHeadlessEditorBlockDefinition[];
|
|
244
|
+
readonly marks?: readonly NgsHeadlessEditorMarkDefinition[];
|
|
245
|
+
readonly commands?: readonly NgsHeadlessEditorCommand<unknown>[];
|
|
246
|
+
readonly keymap?: readonly NgsHeadlessEditorKeyBinding[];
|
|
247
|
+
readonly providers?: readonly Provider[];
|
|
248
|
+
handlePaste?(event: ClipboardEvent, editor: NgsHeadlessEditor): boolean;
|
|
249
|
+
setup?(editor: NgsHeadlessEditor): void | (() => void);
|
|
250
|
+
}
|
|
251
|
+
interface NgsHeadlessEditorFeature {
|
|
252
|
+
readonly plugin: NgsHeadlessEditorPlugin;
|
|
253
|
+
}
|
|
254
|
+
declare function defineNgsHeadlessEditorPlugin<TPlugin extends NgsHeadlessEditorPlugin>(plugin: TPlugin): TPlugin;
|
|
255
|
+
declare function withHeadlessEditorPlugin(plugin: NgsHeadlessEditorPlugin): NgsHeadlessEditorFeature;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Documents and selections are immutable, so snapshots share structure with the
|
|
259
|
+
* live document instead of deep-copying it on every change.
|
|
260
|
+
*/
|
|
261
|
+
interface NgsHeadlessEditorSnapshot {
|
|
262
|
+
readonly document: NgsHeadlessEditorDocument;
|
|
263
|
+
readonly selection: NgsHeadlessEditorSelection | null;
|
|
264
|
+
}
|
|
265
|
+
/** Maximum number of undo steps kept in memory. */
|
|
266
|
+
declare const NGS_HEADLESS_EDITOR_HISTORY_LIMIT = 200;
|
|
267
|
+
/** Consecutive changes of the same group within this window form one undo step. */
|
|
268
|
+
declare const NGS_HEADLESS_EDITOR_HISTORY_GROUP_DELAY = 1000;
|
|
269
|
+
declare class NgsHeadlessEditorHistory {
|
|
270
|
+
private readonly _past;
|
|
271
|
+
private readonly _future;
|
|
272
|
+
private lastGroup;
|
|
273
|
+
private lastRecordedAt;
|
|
274
|
+
readonly canUndo: _angular_core.Signal<boolean>;
|
|
275
|
+
readonly canRedo: _angular_core.Signal<boolean>;
|
|
276
|
+
/**
|
|
277
|
+
* Records the state before a change. Changes that share a non-null `group`
|
|
278
|
+
* (for example consecutive typed characters) and follow each other quickly
|
|
279
|
+
* are merged into a single undo step.
|
|
280
|
+
*/
|
|
281
|
+
record(snapshot: NgsHeadlessEditorSnapshot, group?: string | null, now?: number): void;
|
|
282
|
+
/** Starts a new undo step for the next recorded change. */
|
|
283
|
+
breakGroup(): void;
|
|
284
|
+
undo(current: NgsHeadlessEditorSnapshot): NgsHeadlessEditorSnapshot | null;
|
|
285
|
+
redo(current: NgsHeadlessEditorSnapshot): NgsHeadlessEditorSnapshot | null;
|
|
286
|
+
clear(): void;
|
|
287
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgsHeadlessEditorHistory, never>;
|
|
288
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<any>;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
declare const NGS_HEADLESS_EDITOR_TOGGLE_BOLD: NgsHeadlessEditorCommand<void>;
|
|
292
|
+
declare const NGS_HEADLESS_EDITOR_TOGGLE_ITALIC: NgsHeadlessEditorCommand<void>;
|
|
293
|
+
declare const NGS_HEADLESS_EDITOR_TOGGLE_STRIKE: NgsHeadlessEditorCommand<void>;
|
|
294
|
+
declare const NGS_HEADLESS_EDITOR_TOGGLE_CODE: NgsHeadlessEditorCommand<void>;
|
|
295
|
+
declare function basicTextEditorPlugin(): NgsHeadlessEditorPlugin;
|
|
296
|
+
|
|
297
|
+
declare const NGS_HEADLESS_EDITOR_TEXT_COLOR_MARK = "textColor";
|
|
298
|
+
declare const NGS_HEADLESS_EDITOR_BACKGROUND_COLOR_MARK = "backgroundColor";
|
|
299
|
+
declare const NGS_HEADLESS_EDITOR_SET_TEXT_COLOR: NgsHeadlessEditorCommand<string>;
|
|
300
|
+
declare const NGS_HEADLESS_EDITOR_UNSET_TEXT_COLOR: NgsHeadlessEditorCommand<void>;
|
|
301
|
+
declare const NGS_HEADLESS_EDITOR_SET_BACKGROUND_COLOR: NgsHeadlessEditorCommand<string>;
|
|
302
|
+
declare const NGS_HEADLESS_EDITOR_UNSET_BACKGROUND_COLOR: NgsHeadlessEditorCommand<void>;
|
|
303
|
+
declare function colorEditorPlugin(): NgsHeadlessEditorPlugin;
|
|
304
|
+
/**
|
|
305
|
+
* Keeps color values serializable and safe to write to an inline style attribute.
|
|
306
|
+
* The editor accepts common CSS colors and design-token variables, but rejects
|
|
307
|
+
* declarations, URLs, and other values that could escape the color property.
|
|
308
|
+
*/
|
|
309
|
+
declare function normalizeNgsHeadlessEditorColor(value: string | null | undefined): string | null;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Binds an `NgsHeadlessEditor` to a contenteditable element.
|
|
313
|
+
*
|
|
314
|
+
* Rendering is keyed by block id. Because the model is immutable, a block whose
|
|
315
|
+
* object did not change keeps its DOM element untouched; only changed, added and
|
|
316
|
+
* removed blocks are patched. Browser-owned DOM changes (IME composition, drag and
|
|
317
|
+
* drop, unmapped input types) are tracked with a MutationObserver, read back only
|
|
318
|
+
* for the blocks that were touched, and then re-rendered canonically.
|
|
319
|
+
*/
|
|
320
|
+
declare class NgsHeadlessEditorSurface {
|
|
321
|
+
readonly editor: NgsHeadlessEditor;
|
|
322
|
+
private readonly elementRef;
|
|
323
|
+
private readonly documentRef;
|
|
324
|
+
private readonly renderer;
|
|
325
|
+
private readonly zone;
|
|
326
|
+
private readonly destroyRef;
|
|
327
|
+
private readonly injector;
|
|
328
|
+
private readonly environmentInjector;
|
|
329
|
+
private readonly appRef;
|
|
330
|
+
readonly placeholder: _angular_core.InputSignal<string>;
|
|
331
|
+
readonly ariaLabel: _angular_core.InputSignal<string>;
|
|
332
|
+
readonly disabled: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
333
|
+
readonly spellcheck: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
334
|
+
private rendering;
|
|
335
|
+
private initialized;
|
|
336
|
+
private programmaticFocus;
|
|
337
|
+
private removeSelectionListener?;
|
|
338
|
+
private rendered;
|
|
339
|
+
private renderedPlugins;
|
|
340
|
+
private mutationObserver;
|
|
341
|
+
private pendingMutations;
|
|
342
|
+
constructor();
|
|
343
|
+
onBeforeInput(event: InputEvent): void;
|
|
344
|
+
onKeydown(event: KeyboardEvent): void;
|
|
345
|
+
onPaste(event: ClipboardEvent): void;
|
|
346
|
+
onInput(event?: Event): void;
|
|
347
|
+
onCompositionStart(event?: Event): void;
|
|
348
|
+
onCompositionEnd(event?: Event): void;
|
|
349
|
+
onFocus(): void;
|
|
350
|
+
onBlur(): void;
|
|
351
|
+
onClick(event: MouseEvent): void;
|
|
352
|
+
onPointerDown(event: PointerEvent): void;
|
|
353
|
+
focus(): void;
|
|
354
|
+
getSelectionRect(): DOMRect | null;
|
|
355
|
+
/** Returns the element that currently renders a block, if any. */
|
|
356
|
+
getBlockElement(blockId: string): HTMLElement | null;
|
|
357
|
+
/**
|
|
358
|
+
* Events that originate inside a non-editable block (for example an input or a
|
|
359
|
+
* textarea rendered by a component block) belong to that widget, not to the
|
|
360
|
+
* editor, even though they bubble through the surface.
|
|
361
|
+
*/
|
|
362
|
+
private isForeignEvent;
|
|
363
|
+
/**
|
|
364
|
+
* Brings the DOM in line with the model. Blocks whose object, definition,
|
|
365
|
+
* placeholder and component did not change are reused as-is; `dirty` forces
|
|
366
|
+
* a re-render of block elements the browser modified.
|
|
367
|
+
*/
|
|
368
|
+
private renderDocument;
|
|
369
|
+
private createRenderedBlock;
|
|
370
|
+
private destroyRendered;
|
|
371
|
+
private commitDomState;
|
|
372
|
+
/** Editable block elements touched by the browser since the last render. */
|
|
373
|
+
private collectDirtyBlocks;
|
|
374
|
+
private discardMutations;
|
|
375
|
+
private readDocumentFromDom;
|
|
376
|
+
/** Deletes the range the browser reports for a word/line deletion. */
|
|
377
|
+
private deleteTargetRange;
|
|
378
|
+
private readTargetRange;
|
|
379
|
+
private syncSelectionFromDom;
|
|
380
|
+
private readSelectionFromDom;
|
|
381
|
+
private domPositionToPoint;
|
|
382
|
+
/**
|
|
383
|
+
* The top-level block element that contains a node. Only direct children of
|
|
384
|
+
* the surface are blocks of this editor; elements with block attributes deeper
|
|
385
|
+
* down belong to nested editors (for example inside a table cell).
|
|
386
|
+
*/
|
|
387
|
+
private closestBlock;
|
|
388
|
+
/** True when a node is inside a block rendered by an Angular component. */
|
|
389
|
+
private isInsideComponentBlock;
|
|
390
|
+
private restoreSelectionToDom;
|
|
391
|
+
private pointToDomPosition;
|
|
392
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgsHeadlessEditorSurface, never>;
|
|
393
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgsHeadlessEditorSurface, "[ngsHeadlessEditorSurface]", ["ngsHeadlessEditorSurface"], { "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "spellcheck": { "alias": "spellcheck"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
declare class NgsHeadlessEditorCommandDirective<TPayload = void> {
|
|
397
|
+
private readonly editor;
|
|
398
|
+
readonly command: _angular_core.InputSignal<NgsHeadlessEditorCommand<TPayload>>;
|
|
399
|
+
readonly commandData: _angular_core.InputSignal<TPayload | undefined>;
|
|
400
|
+
readonly active: _angular_core.Signal<boolean>;
|
|
401
|
+
readonly disabled: _angular_core.Signal<boolean>;
|
|
402
|
+
preserveSelection(event: MouseEvent): void;
|
|
403
|
+
execute(event: Event): void;
|
|
404
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgsHeadlessEditorCommandDirective<any>, never>;
|
|
405
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgsHeadlessEditorCommandDirective<any>, "[ngsHeadlessEditorCommand]", ["ngsHeadlessEditorCommand"], { "command": { "alias": "ngsHeadlessEditorCommand"; "required": true; "isSignal": true; }; "commandData": { "alias": "commandData"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** Resolves mark definitions for rendering and parsing. */
|
|
409
|
+
interface NgsHeadlessEditorMarkRegistry {
|
|
410
|
+
getMarkDefinition(type: string): NgsHeadlessEditorMarkDefinition | undefined;
|
|
411
|
+
getMarkDefinitions(): readonly NgsHeadlessEditorMarkDefinition[];
|
|
412
|
+
}
|
|
413
|
+
/** Attribute written on every mark wrapper element. */
|
|
414
|
+
declare const NGS_HEADLESS_EDITOR_MARK_ATTRIBUTE = "data-ngs-headless-editor-mark";
|
|
415
|
+
/**
|
|
416
|
+
* Renders one text run: a text node wrapped in one element per mark, in mark
|
|
417
|
+
* order. Unknown marks are wrapped in a span that only carries the mark type.
|
|
418
|
+
*/
|
|
419
|
+
declare function renderNgsHeadlessEditorTextRun(document: Document, text: string, marks: readonly NgsHeadlessEditorMark[], registry: NgsHeadlessEditorMarkRegistry): Node;
|
|
420
|
+
/** Replaces the children of `target` with rendered runs, or a <br> when empty. */
|
|
421
|
+
declare function renderNgsHeadlessEditorRuns(target: HTMLElement, runs: readonly NgsHeadlessEditorText[], registry: NgsHeadlessEditorMarkRegistry): void;
|
|
422
|
+
/** Finds the mark definition that produced (or matches) an element. */
|
|
423
|
+
declare function findNgsHeadlessEditorMarkDefinition(element: HTMLElement, registry: NgsHeadlessEditorMarkRegistry): NgsHeadlessEditorMarkDefinition | undefined;
|
|
424
|
+
/**
|
|
425
|
+
* Reads text runs from DOM, turning elements into marks through the registry.
|
|
426
|
+
* With `lineBreaks`, <br> and the boundaries of block-level elements become "\n".
|
|
427
|
+
* Elements without a matching mark definition keep their text but add no mark.
|
|
428
|
+
*/
|
|
429
|
+
declare function readNgsHeadlessEditorInlineContent(element: Element, registry: NgsHeadlessEditorMarkRegistry, options?: {
|
|
430
|
+
lineBreaks?: boolean;
|
|
431
|
+
}): NgsHeadlessEditorText[];
|
|
432
|
+
|
|
433
|
+
/** Block type used by the table plugin. */
|
|
434
|
+
declare const NGS_HEADLESS_EDITOR_TABLE_TYPE = "table";
|
|
435
|
+
/**
|
|
436
|
+
* Content of one cell: text runs with marks, like a paragraph. Line breaks
|
|
437
|
+
* inside a cell are newline characters.
|
|
438
|
+
*/
|
|
439
|
+
type NgsHeadlessEditorTableCellContent = readonly NgsHeadlessEditorText[];
|
|
440
|
+
/** Cell input accepted by the helpers: plain text or text runs. */
|
|
441
|
+
type NgsHeadlessEditorTableCellInput = string | NgsHeadlessEditorTableCellContent;
|
|
442
|
+
/** Serializable table data stored in `block.attrs`. */
|
|
443
|
+
interface NgsHeadlessEditorTableData {
|
|
444
|
+
/** Cell content by row, then column. Every row has the same number of cells. */
|
|
445
|
+
readonly rows: readonly (readonly NgsHeadlessEditorTableCellContent[])[];
|
|
446
|
+
/** Renders the first row as a header row. */
|
|
447
|
+
readonly header: boolean;
|
|
448
|
+
}
|
|
449
|
+
interface NgsHeadlessEditorTableSize {
|
|
450
|
+
readonly rows: number;
|
|
451
|
+
readonly columns: number;
|
|
452
|
+
readonly header?: boolean;
|
|
453
|
+
}
|
|
454
|
+
/** Position of a cell inside a table block. */
|
|
455
|
+
interface NgsHeadlessEditorTableCell {
|
|
456
|
+
readonly blockId: string;
|
|
457
|
+
readonly row: number;
|
|
458
|
+
readonly column: number;
|
|
459
|
+
}
|
|
460
|
+
type NgsHeadlessEditorTableBlock = NgsHeadlessEditorBlock<null>;
|
|
461
|
+
/** Normalizes one cell from plain text, text runs or untrusted JSON. */
|
|
462
|
+
declare function normalizeNgsHeadlessEditorTableCell(cell: unknown): NgsHeadlessEditorTableCellContent;
|
|
463
|
+
/** Makes the rows rectangular, normalizes every cell and keeps at least one cell. */
|
|
464
|
+
declare function normalizeNgsHeadlessEditorTableRows(rows: unknown): NgsHeadlessEditorTableCellContent[][];
|
|
465
|
+
/** Plain text of a cell. */
|
|
466
|
+
declare function getNgsHeadlessEditorTableCellText(cell: NgsHeadlessEditorTableCellContent): string;
|
|
467
|
+
/** Reads and normalizes the table data of a block. */
|
|
468
|
+
declare function getNgsHeadlessEditorTableData(block: NgsHeadlessEditorBlock): NgsHeadlessEditorTableData;
|
|
469
|
+
/** Creates a table block from cell text or from a size. */
|
|
470
|
+
declare function createNgsHeadlessEditorTable(source: NgsHeadlessEditorTableSize | readonly (readonly NgsHeadlessEditorTableCellInput[])[], header?: boolean): NgsHeadlessEditorTableBlock;
|
|
471
|
+
declare function isNgsHeadlessEditorTable(block: NgsHeadlessEditorBlock | undefined): boolean;
|
|
472
|
+
declare function setNgsHeadlessEditorTableCell(data: NgsHeadlessEditorTableData, row: number, column: number, content: NgsHeadlessEditorTableCellInput): NgsHeadlessEditorTableData;
|
|
473
|
+
declare function insertNgsHeadlessEditorTableRow(data: NgsHeadlessEditorTableData, index: number): NgsHeadlessEditorTableData;
|
|
474
|
+
declare function removeNgsHeadlessEditorTableRow(data: NgsHeadlessEditorTableData, index: number): NgsHeadlessEditorTableData;
|
|
475
|
+
declare function insertNgsHeadlessEditorTableColumn(data: NgsHeadlessEditorTableData, index: number): NgsHeadlessEditorTableData;
|
|
476
|
+
declare function removeNgsHeadlessEditorTableColumn(data: NgsHeadlessEditorTableData, index: number): NgsHeadlessEditorTableData;
|
|
477
|
+
/**
|
|
478
|
+
* Parses tab-separated text as copied from Excel, Google Sheets or Numbers.
|
|
479
|
+
* Returns null unless the text has at least two cells. Quoted cells with tabs,
|
|
480
|
+
* newlines and doubled quotes are supported.
|
|
481
|
+
*/
|
|
482
|
+
declare function parseNgsHeadlessEditorTableText(text: string | null | undefined): NgsHeadlessEditorTableCellContent[][] | null;
|
|
483
|
+
/**
|
|
484
|
+
* Extracts the table from clipboard HTML (text content only; markup and
|
|
485
|
+
* attributes are discarded). Returns null when the clipboard also contains text
|
|
486
|
+
* outside the table, so copying an article that happens to include a table is
|
|
487
|
+
* pasted as text, and on the server where there is no DOMParser.
|
|
488
|
+
*/
|
|
489
|
+
declare function parseNgsHeadlessEditorTableHtml(html: string | null | undefined, marks?: NgsHeadlessEditorMarkRegistry): NgsHeadlessEditorTableCellContent[][] | null;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* The table cell that currently has focus, or the last focused one while focus
|
|
493
|
+
* is on a toolbar control. Table commands operate on this cell.
|
|
494
|
+
*/
|
|
495
|
+
declare function ngsHeadlessEditorActiveTableCell(editor: NgsHeadlessEditor): Signal<NgsHeadlessEditorTableCell | null>;
|
|
496
|
+
/** @internal Used by the table component. */
|
|
497
|
+
declare function setNgsHeadlessEditorActiveTableCell(editor: NgsHeadlessEditor, cell: NgsHeadlessEditorTableCell | null): void;
|
|
498
|
+
/** Moves focus to a table cell once its table is rendered. */
|
|
499
|
+
declare function focusNgsHeadlessEditorTableCell(editor: NgsHeadlessEditor, cell: NgsHeadlessEditorTableCell): void;
|
|
500
|
+
/** @internal Used by the table component. */
|
|
501
|
+
declare function pendingNgsHeadlessEditorTableFocus(editor: NgsHeadlessEditor): WritableSignal<NgsHeadlessEditorTableCell | null>;
|
|
502
|
+
|
|
503
|
+
interface NgsHeadlessEditorTablePluginOptions {
|
|
504
|
+
/** Turn pasted spreadsheet ranges and HTML tables into table blocks. Default: true. */
|
|
505
|
+
readonly paste?: boolean;
|
|
506
|
+
/**
|
|
507
|
+
* Formatting inside cells. true (default) allows every mark of the editor that
|
|
508
|
+
* is not marked `nested: false`; false keeps cells plain text; a list allows
|
|
509
|
+
* only those mark types.
|
|
510
|
+
*/
|
|
511
|
+
readonly formatting?: boolean | readonly string[];
|
|
512
|
+
}
|
|
513
|
+
/** Options of the table plugin, provided by withHeadlessEditorPlugin(tableEditorPlugin(...)). */
|
|
514
|
+
declare const NGS_HEADLESS_EDITOR_TABLE_OPTIONS: InjectionToken<NgsHeadlessEditorTablePluginOptions>;
|
|
515
|
+
/** Marks allowed in cells for the given formatting option. */
|
|
516
|
+
declare function ngsHeadlessEditorTableCellMarks(registry: NgsHeadlessEditorMarkRegistry, formatting?: boolean | readonly string[]): NgsHeadlessEditorMarkRegistry;
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Inserts a table block. An empty paragraph at the caret is replaced; otherwise
|
|
520
|
+
* the table goes after the current block. A paragraph is added after the table
|
|
521
|
+
* when it would be the last block, so the caret can always continue below it.
|
|
522
|
+
* Focus moves to the first cell.
|
|
523
|
+
*/
|
|
524
|
+
declare function insertNgsHeadlessEditorTable(editor: NgsHeadlessEditor, table: NgsHeadlessEditorBlock): boolean;
|
|
525
|
+
/** Inserts a table. Payload: size and header row, default 3 × 3 with a header. */
|
|
526
|
+
declare const NGS_HEADLESS_EDITOR_INSERT_TABLE: NgsHeadlessEditorCommand<NgsHeadlessEditorTableSize | undefined>;
|
|
527
|
+
declare const NGS_HEADLESS_EDITOR_TABLE_ADD_ROW_BEFORE: NgsHeadlessEditorCommand<void>;
|
|
528
|
+
declare const NGS_HEADLESS_EDITOR_TABLE_ADD_ROW_AFTER: NgsHeadlessEditorCommand<void>;
|
|
529
|
+
declare const NGS_HEADLESS_EDITOR_TABLE_ADD_COLUMN_BEFORE: NgsHeadlessEditorCommand<void>;
|
|
530
|
+
declare const NGS_HEADLESS_EDITOR_TABLE_ADD_COLUMN_AFTER: NgsHeadlessEditorCommand<void>;
|
|
531
|
+
declare const NGS_HEADLESS_EDITOR_TABLE_DELETE_ROW: NgsHeadlessEditorCommand<void>;
|
|
532
|
+
declare const NGS_HEADLESS_EDITOR_TABLE_DELETE_COLUMN: NgsHeadlessEditorCommand<void>;
|
|
533
|
+
declare const NGS_HEADLESS_EDITOR_TABLE_TOGGLE_HEADER: NgsHeadlessEditorCommand;
|
|
534
|
+
declare const NGS_HEADLESS_EDITOR_TABLE_DELETE: NgsHeadlessEditorCommand;
|
|
535
|
+
/**
|
|
536
|
+
* Adds a `table` block edited through an Angular component, commands for rows,
|
|
537
|
+
* columns and the header row, and (optionally) pasting spreadsheet ranges and
|
|
538
|
+
* HTML tables as tables. Cells hold rich text: every formatting command of the
|
|
539
|
+
* editor works inside a focused cell unless `formatting` restricts it.
|
|
540
|
+
*/
|
|
541
|
+
declare function tableEditorPlugin(options?: NgsHeadlessEditorTablePluginOptions): NgsHeadlessEditorPlugin;
|
|
542
|
+
|
|
543
|
+
interface CellPosition {
|
|
544
|
+
readonly row: number;
|
|
545
|
+
readonly column: number;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Editing component for table blocks.
|
|
549
|
+
*
|
|
550
|
+
* Cells are rendered as static rich text. The focused cell is edited by one
|
|
551
|
+
* nested editor (NgsHeadlessEditorInlineRegion) that reuses the marks, commands
|
|
552
|
+
* and shortcuts of the document editor and becomes its inline target, so the
|
|
553
|
+
* regular toolbar formats the cell. Changes are written back with updateBlock()
|
|
554
|
+
* and recorded in the document history, grouped per cell.
|
|
555
|
+
*
|
|
556
|
+
* Styling hooks: `ngs-headless-editor-table`, `ngs-headless-editor-table-cell`
|
|
557
|
+
* (th for header cells), `active` on the focused cell,
|
|
558
|
+
* `ngs-headless-editor-table-cell-content` and `ngs-headless-editor-table-cell-editor`.
|
|
559
|
+
*/
|
|
560
|
+
declare class NgsHeadlessEditorTableBlockEditor implements NgsHeadlessEditorBlockComponent<null> {
|
|
561
|
+
private readonly region;
|
|
562
|
+
private readonly editor;
|
|
563
|
+
private readonly host;
|
|
564
|
+
private readonly documentRef;
|
|
565
|
+
private readonly injector;
|
|
566
|
+
private readonly options;
|
|
567
|
+
private readonly activeCell;
|
|
568
|
+
private readonly pendingFocus;
|
|
569
|
+
private readonly surface;
|
|
570
|
+
readonly block: _angular_core.InputSignal<NgsHeadlessEditorBlock<null>>;
|
|
571
|
+
readonly data: _angular_core.Signal<NgsHeadlessEditorTableData>;
|
|
572
|
+
/** Cell edited by the nested editor, if any. */
|
|
573
|
+
readonly editing: _angular_core.WritableSignal<CellPosition | null>;
|
|
574
|
+
/** Set while focus returns to a static cell after Escape, so it is not edited again. */
|
|
575
|
+
private skipFocusEdit;
|
|
576
|
+
constructor();
|
|
577
|
+
isActive(row: number, column: number): boolean;
|
|
578
|
+
isEditing(row: number, column: number): boolean;
|
|
579
|
+
onContentPointerDown(event: PointerEvent, row: number, column: number): void;
|
|
580
|
+
onContentFocus(row: number, column: number): void;
|
|
581
|
+
onKeydown(event: KeyboardEvent, row: number, column: number): void;
|
|
582
|
+
/** Starts editing a cell, with the caret at a point or at the end of the cell. */
|
|
583
|
+
edit(row: number, column: number, point?: {
|
|
584
|
+
x: number;
|
|
585
|
+
y: number;
|
|
586
|
+
}): void;
|
|
587
|
+
private stopEditing;
|
|
588
|
+
private focusEditor;
|
|
589
|
+
private rangeFromPoint;
|
|
590
|
+
private cellContent;
|
|
591
|
+
private writeCell;
|
|
592
|
+
private writeData;
|
|
593
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgsHeadlessEditorTableBlockEditor, never>;
|
|
594
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NgsHeadlessEditorTableBlockEditor, "ngs-headless-editor-table-editor", never, { "block": { "alias": "block"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/** Read-only rendering of table blocks, used while the surface is disabled or read-only. */
|
|
598
|
+
declare class NgsHeadlessEditorTableView implements NgsHeadlessEditorBlockComponent<null> {
|
|
599
|
+
readonly block: _angular_core.InputSignal<NgsHeadlessEditorBlock<null>>;
|
|
600
|
+
readonly data: _angular_core.Signal<_ngstarter_ui_components_headless_editor.NgsHeadlessEditorTableData>;
|
|
601
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgsHeadlessEditorTableView, never>;
|
|
602
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NgsHeadlessEditorTableView, "ngs-headless-editor-table-view", never, { "block": { "alias": "block"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
interface NgsHeadlessEditorInlineRegionOptions {
|
|
606
|
+
/**
|
|
607
|
+
* Marks available in the region: true for every mark of the parent editor
|
|
608
|
+
* (except marks with `nested: false`), false for plain text, or a list of types.
|
|
609
|
+
*/
|
|
610
|
+
readonly marks?: boolean | readonly string[];
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Provides a nested editor for rich text inside a component block, for example a
|
|
614
|
+
* table cell or a caption. Add it to the component's providers; the component
|
|
615
|
+
* then injects NgsHeadlessEditorInlineRegion and renders an
|
|
616
|
+
* ngsHeadlessEditorSurface, which binds to the nested editor.
|
|
617
|
+
*/
|
|
618
|
+
declare function provideNgsHeadlessEditorInlineRegion(): Provider[];
|
|
619
|
+
/**
|
|
620
|
+
* A small editor for inline rich text that lives inside a block of a parent
|
|
621
|
+
* editor. It reuses the parent's marks, mark commands and key bindings, sends
|
|
622
|
+
* undo and redo to the parent history, and, while active, becomes the parent's
|
|
623
|
+
* inline target so toolbar formatting commands apply to it.
|
|
624
|
+
*
|
|
625
|
+
* Content is exchanged as text runs; line breaks are "\n" characters.
|
|
626
|
+
*/
|
|
627
|
+
declare class NgsHeadlessEditorInlineRegion {
|
|
628
|
+
/** Editor of the document that contains the region. */
|
|
629
|
+
readonly parent: NgsHeadlessEditor;
|
|
630
|
+
/** Nested editor that edits the region. */
|
|
631
|
+
readonly editor: NgsHeadlessEditor;
|
|
632
|
+
private readonly options;
|
|
633
|
+
/** True while formatting commands of the parent act on this region. */
|
|
634
|
+
readonly active: _angular_core.Signal<boolean>;
|
|
635
|
+
/** Region content as text runs. */
|
|
636
|
+
readonly content: _angular_core.Signal<readonly NgsHeadlessEditorText[]>;
|
|
637
|
+
constructor();
|
|
638
|
+
configure(options: NgsHeadlessEditorInlineRegionOptions): void;
|
|
639
|
+
/** Makes the region the parent's inline target. */
|
|
640
|
+
activate(): void;
|
|
641
|
+
deactivate(): void;
|
|
642
|
+
/**
|
|
643
|
+
* Loads content into the nested editor unless it already shows it. The caret
|
|
644
|
+
* position is kept when possible.
|
|
645
|
+
*/
|
|
646
|
+
load(content: readonly NgsHeadlessEditorText[]): void;
|
|
647
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgsHeadlessEditorInlineRegion, never>;
|
|
648
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<any>;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Renders text runs with the mark definitions of the nearest editor, exactly as
|
|
653
|
+
* the surface renders them. Use it for read-only previews of rich text such as
|
|
654
|
+
* table cells that are not being edited. Line breaks ("\n") are preserved.
|
|
655
|
+
*/
|
|
656
|
+
declare class NgsHeadlessEditorRuns {
|
|
657
|
+
private readonly editor;
|
|
658
|
+
private readonly element;
|
|
659
|
+
readonly runs: _angular_core.InputSignal<readonly NgsHeadlessEditorText[]>;
|
|
660
|
+
constructor();
|
|
661
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgsHeadlessEditorRuns, never>;
|
|
662
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgsHeadlessEditorRuns, "[ngsHeadlessEditorRuns]", never, { "runs": { "alias": "ngsHeadlessEditorRuns"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/** Inputs expected by the Angular component used to render each menu option. */
|
|
666
|
+
interface NgsHeadlessEditorMentionOptionComponent<TOption extends NgsHeadlessEditorMentionOption = NgsHeadlessEditorMentionOption> {
|
|
667
|
+
readonly option: () => TOption;
|
|
668
|
+
readonly active: () => boolean;
|
|
669
|
+
}
|
|
670
|
+
/** Consumer-defined local or remote search. The query excludes the trigger. */
|
|
671
|
+
type NgsHeadlessEditorMentionSearch<TOption extends NgsHeadlessEditorMentionOption = NgsHeadlessEditorMentionOption> = (query: string) => Promise<readonly TOption[]>;
|
|
672
|
+
interface NgsHeadlessEditorMentionPluginOptions<TOption extends NgsHeadlessEditorMentionOption = NgsHeadlessEditorMentionOption> {
|
|
673
|
+
/** Async search callback for this registration. */
|
|
674
|
+
readonly options?: NgsHeadlessEditorMentionSearch<TOption>;
|
|
675
|
+
/** Angular component receiving `option` and `active` inputs for every candidate. */
|
|
676
|
+
readonly optionComponent?: Type<NgsHeadlessEditorMentionOptionComponent<TOption>>;
|
|
677
|
+
/** Unique trigger text for this registration. Default: @. */
|
|
678
|
+
readonly trigger?: string;
|
|
679
|
+
}
|
|
680
|
+
/** One normalized trigger configuration inside the mention plugin. */
|
|
681
|
+
interface NgsHeadlessEditorMentionRegistration extends NgsHeadlessEditorMentionPluginOptions {
|
|
682
|
+
readonly trigger: string;
|
|
683
|
+
}
|
|
684
|
+
/** Editor-scoped configurations installed together by mentionEditorPlugin(). */
|
|
685
|
+
declare const NGS_HEADLESS_EDITOR_MENTION_OPTIONS: InjectionToken<readonly NgsHeadlessEditorMentionRegistration[]>;
|
|
686
|
+
|
|
687
|
+
declare const NGS_HEADLESS_EDITOR_MENTION_MARK = "mention";
|
|
688
|
+
/** Extend this interface with avatar, description or other menu presentation data. */
|
|
689
|
+
interface NgsHeadlessEditorMentionOption {
|
|
690
|
+
readonly id: string;
|
|
691
|
+
readonly label: string;
|
|
692
|
+
/** Exact text to insert (for example an emoji). Defaults to trigger + label. */
|
|
693
|
+
readonly text?: string;
|
|
694
|
+
}
|
|
695
|
+
interface NgsHeadlessEditorMentionQuery {
|
|
696
|
+
readonly blockId: string;
|
|
697
|
+
readonly from: number;
|
|
698
|
+
readonly to: number;
|
|
699
|
+
readonly query: string;
|
|
700
|
+
readonly trigger: string;
|
|
701
|
+
}
|
|
702
|
+
/** One plugin accepts independently configured triggers with their own option components. */
|
|
703
|
+
declare function mentionEditorPlugin<TOption extends NgsHeadlessEditorMentionOption = NgsHeadlessEditorMentionOption>(options?: NgsHeadlessEditorMentionPluginOptions<TOption>): NgsHeadlessEditorPlugin;
|
|
704
|
+
declare function mentionEditorPlugin(options: readonly NgsHeadlessEditorMentionPluginOptions[]): NgsHeadlessEditorPlugin;
|
|
705
|
+
/** Finds trigger/query at a collapsed caret, excluding e-mail addresses and existing mentions. */
|
|
706
|
+
declare function findNgsHeadlessEditorMentionQuery(editor: NgsHeadlessEditor, trigger?: string): NgsHeadlessEditorMentionQuery | null;
|
|
707
|
+
/** Replaces the current trigger/query with a mention and a plain space in one undo step. */
|
|
708
|
+
declare function insertNgsHeadlessEditorMention(editor: NgsHeadlessEditor, option: NgsHeadlessEditorMentionOption, query: NgsHeadlessEditorMentionQuery): boolean;
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Routes trigger/query to the matching mention plugin registration. Focus stays in the editor;
|
|
712
|
+
* ArrowUp/Down, Enter/Tab and Escape control the suggestions. Works in nested
|
|
713
|
+
* inline editors too. The menu owns its option templates; call select(option)
|
|
714
|
+
* on click and use optionId(index) / activeIndex() for accessible highlighting.
|
|
715
|
+
*/
|
|
716
|
+
declare class NgsHeadlessEditorMentions<TOption extends NgsHeadlessEditorMentionOption = NgsHeadlessEditorMentionOption> {
|
|
717
|
+
private readonly editor;
|
|
718
|
+
private readonly surface;
|
|
719
|
+
private readonly host;
|
|
720
|
+
private readonly document;
|
|
721
|
+
private readonly overlay;
|
|
722
|
+
private readonly viewContainer;
|
|
723
|
+
private readonly config;
|
|
724
|
+
private readonly initialized;
|
|
725
|
+
private readonly dismissed;
|
|
726
|
+
private readonly menuId;
|
|
727
|
+
private overlayRef;
|
|
728
|
+
private shownMenu;
|
|
729
|
+
private ariaHost;
|
|
730
|
+
private readonly previousAria;
|
|
731
|
+
private frame;
|
|
732
|
+
private previousEditor;
|
|
733
|
+
private previousQuery;
|
|
734
|
+
private defaultMenu;
|
|
735
|
+
private menuClosed;
|
|
736
|
+
readonly menu: _angular_core.InputSignal<"" | Menu | null>;
|
|
737
|
+
/** Single-configuration compatibility override. Configure multiple triggers in the plugin's array. */
|
|
738
|
+
readonly options: _angular_core.InputSignal<NgsHeadlessEditorMentionSearch<TOption> | null>;
|
|
739
|
+
/** Single-configuration compatibility override. */
|
|
740
|
+
readonly trigger: _angular_core.InputSignal<string | null>;
|
|
741
|
+
readonly selected: _angular_core.OutputEmitterRef<TOption>;
|
|
742
|
+
readonly queryChange: _angular_core.OutputEmitterRef<string | null>;
|
|
743
|
+
private readonly target;
|
|
744
|
+
private readonly registrations;
|
|
745
|
+
private readonly session;
|
|
746
|
+
private readonly match;
|
|
747
|
+
/** Settings of the plugin handling the current query, or null outside a query. */
|
|
748
|
+
readonly registration: _angular_core.Signal<{
|
|
749
|
+
options: NgsHeadlessEditorMentionSearch<NgsHeadlessEditorMentionOption> | undefined;
|
|
750
|
+
trigger: string;
|
|
751
|
+
optionComponent?: _angular_core.Type<_ngstarter_ui_components_headless_editor.NgsHeadlessEditorMentionOptionComponent<NgsHeadlessEditorMentionOption>> | undefined;
|
|
752
|
+
} | null>;
|
|
753
|
+
readonly activeTrigger: _angular_core.Signal<string | null>;
|
|
754
|
+
readonly optionComponent: _angular_core.Signal<_angular_core.Type<_ngstarter_ui_components_headless_editor.NgsHeadlessEditorMentionOptionComponent<NgsHeadlessEditorMentionOption>> | undefined>;
|
|
755
|
+
readonly query: _angular_core.Signal<string | null>;
|
|
756
|
+
private readonly results;
|
|
757
|
+
private readonly searching;
|
|
758
|
+
private readonly searchError;
|
|
759
|
+
readonly suggestions: _angular_core.Signal<readonly TOption[]>;
|
|
760
|
+
readonly loading: _angular_core.Signal<boolean>;
|
|
761
|
+
readonly error: _angular_core.Signal<unknown>;
|
|
762
|
+
readonly activeIndex: _angular_core.WritableSignal<number>;
|
|
763
|
+
readonly open: _angular_core.Signal<boolean>;
|
|
764
|
+
constructor();
|
|
765
|
+
optionId(index: number): string;
|
|
766
|
+
select(option: TOption): boolean;
|
|
767
|
+
dismiss(): void;
|
|
768
|
+
private readonly onKeydown;
|
|
769
|
+
private readonly onViewportChange;
|
|
770
|
+
private schedulePosition;
|
|
771
|
+
private positionMenu;
|
|
772
|
+
private closeOverlay;
|
|
773
|
+
private resolveMenu;
|
|
774
|
+
private clearAria;
|
|
775
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgsHeadlessEditorMentions<any>, never>;
|
|
776
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgsHeadlessEditorMentions<any>, "[ngsHeadlessEditorSurface][ngsHeadlessEditorMentions]", ["ngsHeadlessEditorMentions"], { "menu": { "alias": "ngsHeadlessEditorMentions"; "required": false; "isSignal": true; }; "options": { "alias": "mentionOptions"; "required": false; "isSignal": true; }; "trigger": { "alias": "mentionTrigger"; "required": false; "isSignal": true; }; }, { "selected": "mentionSelected"; "queryChange": "mentionQueryChange"; }, never, never, true, never>;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
interface NgsHeadlessEditorMentionMenuState {
|
|
780
|
+
readonly suggestions: Signal<readonly NgsHeadlessEditorMentionOption[]>;
|
|
781
|
+
readonly activeIndex: Signal<number>;
|
|
782
|
+
readonly optionComponent: Signal<Type<NgsHeadlessEditorMentionOptionComponent> | undefined>;
|
|
783
|
+
optionId(index: number): string;
|
|
784
|
+
select(option: NgsHeadlessEditorMentionOption): boolean;
|
|
785
|
+
}
|
|
786
|
+
/** Default menu; the active plugin registration supplies the option component. */
|
|
787
|
+
declare class NgsHeadlessEditorMentionMenu {
|
|
788
|
+
readonly mentions: _angular_core.InputSignal<NgsHeadlessEditorMentionMenuState>;
|
|
789
|
+
readonly menu: Signal<Menu>;
|
|
790
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgsHeadlessEditorMentionMenu, never>;
|
|
791
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NgsHeadlessEditorMentionMenu, "ngs-headless-editor-mention-menu", never, { "mentions": { "alias": "mentions"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
export { NGS_HEADLESS_EDITOR_BACKGROUND_COLOR_MARK, NGS_HEADLESS_EDITOR_HISTORY_GROUP_DELAY, NGS_HEADLESS_EDITOR_HISTORY_LIMIT, NGS_HEADLESS_EDITOR_INSERT_TABLE, NGS_HEADLESS_EDITOR_MARK_ATTRIBUTE, NGS_HEADLESS_EDITOR_MENTION_MARK, NGS_HEADLESS_EDITOR_MENTION_OPTIONS, NGS_HEADLESS_EDITOR_PLUGINS, NGS_HEADLESS_EDITOR_SET_BACKGROUND_COLOR, NGS_HEADLESS_EDITOR_SET_TEXT_COLOR, NGS_HEADLESS_EDITOR_TABLE_ADD_COLUMN_AFTER, NGS_HEADLESS_EDITOR_TABLE_ADD_COLUMN_BEFORE, NGS_HEADLESS_EDITOR_TABLE_ADD_ROW_AFTER, NGS_HEADLESS_EDITOR_TABLE_ADD_ROW_BEFORE, NGS_HEADLESS_EDITOR_TABLE_DELETE, NGS_HEADLESS_EDITOR_TABLE_DELETE_COLUMN, NGS_HEADLESS_EDITOR_TABLE_DELETE_ROW, NGS_HEADLESS_EDITOR_TABLE_OPTIONS, NGS_HEADLESS_EDITOR_TABLE_TOGGLE_HEADER, NGS_HEADLESS_EDITOR_TABLE_TYPE, NGS_HEADLESS_EDITOR_TEXT_COLOR_MARK, NGS_HEADLESS_EDITOR_TOGGLE_BOLD, NGS_HEADLESS_EDITOR_TOGGLE_CODE, NGS_HEADLESS_EDITOR_TOGGLE_ITALIC, NGS_HEADLESS_EDITOR_TOGGLE_STRIKE, NGS_HEADLESS_EDITOR_UNSET_BACKGROUND_COLOR, NGS_HEADLESS_EDITOR_UNSET_TEXT_COLOR, NgsHeadlessEditor, NgsHeadlessEditorCommandDirective, NgsHeadlessEditorHistory, NgsHeadlessEditorInlineRegion, NgsHeadlessEditorMentionMenu, NgsHeadlessEditorMentions, NgsHeadlessEditorRuns, NgsHeadlessEditorSurface, NgsHeadlessEditorTableBlockEditor, NgsHeadlessEditorTableView, basicTextEditorPlugin, cloneNgsHeadlessEditorDocument, colorEditorPlugin, createNgsHeadlessEditorDocument, createNgsHeadlessEditorId, createNgsHeadlessEditorParagraph, createNgsHeadlessEditorTable, createNgsHeadlessEditorText, defineNgsHeadlessEditorPlugin, findNgsHeadlessEditorMarkDefinition, findNgsHeadlessEditorMentionQuery, focusNgsHeadlessEditorTableCell, getNgsHeadlessEditorBlockText, getNgsHeadlessEditorDocumentText, getNgsHeadlessEditorTableCellText, getNgsHeadlessEditorTableData, insertNgsHeadlessEditorMention, insertNgsHeadlessEditorTable, insertNgsHeadlessEditorTableColumn, insertNgsHeadlessEditorTableRow, isNgsHeadlessEditorDocumentEmpty, isNgsHeadlessEditorTable, isNgsHeadlessEditorTextContent, mentionEditorPlugin, ngsHeadlessEditorActiveTableCell, ngsHeadlessEditorBlocksEqual, ngsHeadlessEditorDocumentsEqual, ngsHeadlessEditorMarksEqual, ngsHeadlessEditorTableCellMarks, ngsHeadlessEditorValuesEqual, normalizeNgsHeadlessEditorColor, normalizeNgsHeadlessEditorDocument, normalizeNgsHeadlessEditorMarks, normalizeNgsHeadlessEditorTableCell, normalizeNgsHeadlessEditorTableRows, normalizeNgsHeadlessEditorTextContent, parseNgsHeadlessEditorTableHtml, parseNgsHeadlessEditorTableText, pendingNgsHeadlessEditorTableFocus, provideNgsHeadlessEditor, provideNgsHeadlessEditorInlineRegion, readNgsHeadlessEditorInlineContent, removeNgsHeadlessEditorTableColumn, removeNgsHeadlessEditorTableRow, renderNgsHeadlessEditorRuns, renderNgsHeadlessEditorTextRun, setNgsHeadlessEditorActiveTableCell, setNgsHeadlessEditorTableCell, tableEditorPlugin, withHeadlessEditorPlugin };
|
|
795
|
+
export type { NgsHeadlessEditorBlock, NgsHeadlessEditorBlockComponent, NgsHeadlessEditorBlockDefinition, NgsHeadlessEditorChangeOrigin, NgsHeadlessEditorCommand, NgsHeadlessEditorDocument, NgsHeadlessEditorFeature, NgsHeadlessEditorInlineRegionOptions, NgsHeadlessEditorKeyBinding, NgsHeadlessEditorMark, NgsHeadlessEditorMarkAttributes, NgsHeadlessEditorMarkDefinition, NgsHeadlessEditorMarkRegistry, NgsHeadlessEditorMentionMenuState, NgsHeadlessEditorMentionOption, NgsHeadlessEditorMentionOptionComponent, NgsHeadlessEditorMentionPluginOptions, NgsHeadlessEditorMentionQuery, NgsHeadlessEditorMentionRegistration, NgsHeadlessEditorMentionSearch, NgsHeadlessEditorPlugin, NgsHeadlessEditorPoint, NgsHeadlessEditorSelection, NgsHeadlessEditorSnapshot, NgsHeadlessEditorTableBlock, NgsHeadlessEditorTableCell, NgsHeadlessEditorTableCellContent, NgsHeadlessEditorTableCellInput, NgsHeadlessEditorTableData, NgsHeadlessEditorTablePluginOptions, NgsHeadlessEditorTableSize, NgsHeadlessEditorText };
|