@malva-ui/editor 0.1.12 → 0.1.14
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 +80 -0
- package/fesm2022/malva-ui-editor-ai.mjs +17 -0
- package/fesm2022/malva-ui-editor-ai.mjs.map +1 -0
- package/fesm2022/malva-ui-editor.mjs +10227 -0
- package/fesm2022/malva-ui-editor.mjs.map +1 -0
- package/package.json +47 -26
- package/types/malva-ui-editor-ai.d.ts +1 -0
- package/types/malva-ui-editor.d.ts +2995 -0
- package/ai/index.d.ts +0 -12
- package/ai/malva-ui-editor-ai.d.ts +0 -5
- package/esm2022/ai/index.js +0 -12
- package/esm2022/ai/index.js.map +0 -1
- package/esm2022/ai/malva-ui-editor-ai.js +0 -5
- package/esm2022/ai/malva-ui-editor-ai.js.map +0 -1
- package/esm2022/index.js +0 -37
- package/esm2022/index.js.map +0 -1
- package/esm2022/lib/ai/editor-ai-actions.js +0 -69
- package/esm2022/lib/ai/editor-ai-actions.js.map +0 -1
- package/esm2022/lib/ai/editor-ai-context.js +0 -612
- package/esm2022/lib/ai/editor-ai-context.js.map +0 -1
- package/esm2022/lib/ai/editor-ai-menu.js +0 -288
- package/esm2022/lib/ai/editor-ai-menu.js.map +0 -1
- package/esm2022/lib/ai/editor-ai-review-bar.js +0 -223
- package/esm2022/lib/ai/editor-ai-review-bar.js.map +0 -1
- package/esm2022/lib/ai/editor-ai-stream.js +0 -677
- package/esm2022/lib/ai/editor-ai-stream.js.map +0 -1
- package/esm2022/lib/ai/editor-ai-suggestions.js +0 -751
- package/esm2022/lib/ai/editor-ai-suggestions.js.map +0 -1
- package/esm2022/lib/ai/editor-ai.tokens.js +0 -10
- package/esm2022/lib/ai/editor-ai.tokens.js.map +0 -1
- package/esm2022/lib/ai/editor-ai.types.js +0 -1
- package/esm2022/lib/ai/editor-ai.types.js.map +0 -1
- package/esm2022/lib/editor/editor.js +0 -985
- package/esm2022/lib/editor/editor.js.map +0 -1
- package/esm2022/lib/editor-extension-preflight.js +0 -83
- package/esm2022/lib/editor-extension-preflight.js.map +0 -1
- package/esm2022/lib/editor-serialization.js +0 -152
- package/esm2022/lib/editor-serialization.js.map +0 -1
- package/esm2022/lib/editor-toolbar-context.js +0 -259
- package/esm2022/lib/editor-toolbar-context.js.map +0 -1
- package/esm2022/lib/editor.tokens.js +0 -10
- package/esm2022/lib/editor.tokens.js.map +0 -1
- package/esm2022/lib/editor.types.js +0 -48
- package/esm2022/lib/editor.types.js.map +0 -1
- package/esm2022/lib/extensions/editor-block-handle.js +0 -760
- package/esm2022/lib/extensions/editor-block-handle.js.map +0 -1
- package/esm2022/lib/extensions/editor-extensions.js +0 -321
- package/esm2022/lib/extensions/editor-extensions.js.map +0 -1
- package/esm2022/lib/extensions/editor-markdown-compatibility.js +0 -162
- package/esm2022/lib/extensions/editor-markdown-compatibility.js.map +0 -1
- package/esm2022/lib/extensions/editor-upload-placeholder.js +0 -156
- package/esm2022/lib/extensions/editor-upload-placeholder.js.map +0 -1
- package/esm2022/lib/status/editor-status.js +0 -64
- package/esm2022/lib/status/editor-status.js.map +0 -1
- package/esm2022/lib/toolbar/editor-alignment.js +0 -203
- package/esm2022/lib/toolbar/editor-alignment.js.map +0 -1
- package/esm2022/lib/toolbar/editor-block-insert.js +0 -101
- package/esm2022/lib/toolbar/editor-block-insert.js.map +0 -1
- package/esm2022/lib/toolbar/editor-color-control.js +0 -71
- package/esm2022/lib/toolbar/editor-color-control.js.map +0 -1
- package/esm2022/lib/toolbar/editor-command-button.js +0 -115
- package/esm2022/lib/toolbar/editor-command-button.js.map +0 -1
- package/esm2022/lib/toolbar/editor-heading.js +0 -266
- package/esm2022/lib/toolbar/editor-heading.js.map +0 -1
- package/esm2022/lib/toolbar/editor-highlight.js +0 -84
- package/esm2022/lib/toolbar/editor-highlight.js.map +0 -1
- package/esm2022/lib/toolbar/editor-image-upload-dialog.js +0 -289
- package/esm2022/lib/toolbar/editor-image-upload-dialog.js.map +0 -1
- package/esm2022/lib/toolbar/editor-image-upload.js +0 -315
- package/esm2022/lib/toolbar/editor-image-upload.js.map +0 -1
- package/esm2022/lib/toolbar/editor-inline-marks.js +0 -124
- package/esm2022/lib/toolbar/editor-inline-marks.js.map +0 -1
- package/esm2022/lib/toolbar/editor-link.js +0 -265
- package/esm2022/lib/toolbar/editor-link.js.map +0 -1
- package/esm2022/lib/toolbar/editor-list.js +0 -249
- package/esm2022/lib/toolbar/editor-list.js.map +0 -1
- package/esm2022/lib/toolbar/editor-table.js +0 -292
- package/esm2022/lib/toolbar/editor-table.js.map +0 -1
- package/esm2022/lib/toolbar/editor-text-color.js +0 -82
- package/esm2022/lib/toolbar/editor-text-color.js.map +0 -1
- package/esm2022/lib/toolbar/editor-toolbar-widget.js +0 -41
- package/esm2022/lib/toolbar/editor-toolbar-widget.js.map +0 -1
- package/esm2022/lib/toolbar/editor-toolbar.defs.js +0 -60
- package/esm2022/lib/toolbar/editor-toolbar.defs.js.map +0 -1
- package/esm2022/lib/toolbar/editor-toolbar.js +0 -826
- package/esm2022/lib/toolbar/editor-toolbar.js.map +0 -1
- package/esm2022/lib/toolbar/editor-undo-redo.js +0 -72
- package/esm2022/lib/toolbar/editor-undo-redo.js.map +0 -1
- package/esm2022/lib/toolbar/editor-zoom.js +0 -330
- package/esm2022/lib/toolbar/editor-zoom.js.map +0 -1
- package/esm2022/lib/upload/editor-image-upload-coordinator.js +0 -480
- package/esm2022/lib/upload/editor-image-upload-coordinator.js.map +0 -1
- package/esm2022/malva-ui-editor.js +0 -5
- package/esm2022/malva-ui-editor.js.map +0 -1
- package/index.d.ts +0 -35
- package/lib/ai/editor-ai-actions.d.ts +0 -27
- package/lib/ai/editor-ai-context.d.ts +0 -307
- package/lib/ai/editor-ai-menu.d.ts +0 -142
- package/lib/ai/editor-ai-review-bar.d.ts +0 -116
- package/lib/ai/editor-ai-stream.d.ts +0 -207
- package/lib/ai/editor-ai-suggestions.d.ts +0 -219
- package/lib/ai/editor-ai.tokens.d.ts +0 -10
- package/lib/ai/editor-ai.types.d.ts +0 -176
- package/lib/editor/editor.d.ts +0 -243
- package/lib/editor-extension-preflight.d.ts +0 -23
- package/lib/editor-serialization.d.ts +0 -74
- package/lib/editor-toolbar-context.d.ts +0 -116
- package/lib/editor.tokens.d.ts +0 -6
- package/lib/editor.types.d.ts +0 -194
- package/lib/extensions/editor-block-handle.d.ts +0 -59
- package/lib/extensions/editor-extensions.d.ts +0 -165
- package/lib/extensions/editor-markdown-compatibility.d.ts +0 -11
- package/lib/extensions/editor-upload-placeholder.d.ts +0 -75
- package/lib/status/editor-status.d.ts +0 -24
- package/lib/toolbar/editor-alignment.d.ts +0 -61
- package/lib/toolbar/editor-block-insert.d.ts +0 -26
- package/lib/toolbar/editor-color-control.d.ts +0 -32
- package/lib/toolbar/editor-command-button.d.ts +0 -29
- package/lib/toolbar/editor-heading.d.ts +0 -68
- package/lib/toolbar/editor-highlight.d.ts +0 -21
- package/lib/toolbar/editor-image-upload-dialog.d.ts +0 -96
- package/lib/toolbar/editor-image-upload.d.ts +0 -71
- package/lib/toolbar/editor-inline-marks.d.ts +0 -30
- package/lib/toolbar/editor-link.d.ts +0 -78
- package/lib/toolbar/editor-list.d.ts +0 -67
- package/lib/toolbar/editor-table.d.ts +0 -133
- package/lib/toolbar/editor-text-color.d.ts +0 -21
- package/lib/toolbar/editor-toolbar-widget.d.ts +0 -19
- package/lib/toolbar/editor-toolbar.d.ts +0 -157
- package/lib/toolbar/editor-toolbar.defs.d.ts +0 -35
- package/lib/toolbar/editor-undo-redo.d.ts +0 -26
- package/lib/toolbar/editor-zoom.d.ts +0 -108
- package/lib/upload/editor-image-upload-coordinator.d.ts +0 -55
- package/malva-ui-editor.d.ts +0 -5
|
@@ -0,0 +1,2995 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { Signal, InjectionToken, ElementRef, WritableSignal, TemplateRef, AfterViewInit, OnChanges, SimpleChanges } from '@angular/core';
|
|
3
|
+
import { Editor, Extensions, Extension } from '@tiptap/core';
|
|
4
|
+
export { Editor, EditorOptions, Extension, Extensions } from '@tiptap/core';
|
|
5
|
+
import { Transaction } from '@tiptap/pm/state';
|
|
6
|
+
import { MlvEditorI18n } from '@malva-ui/i18n';
|
|
7
|
+
import * as _malva_ui_core_menu from '@malva-ui/core/menu';
|
|
8
|
+
import { MlvMenu, MlvMenuTrigger } from '@malva-ui/core/menu';
|
|
9
|
+
import * as _malva_ui_editor from '@malva-ui/editor';
|
|
10
|
+
import { BooleanInput } from '@angular/cdk/coercion';
|
|
11
|
+
import { MlvInput } from '@malva-ui/core/input';
|
|
12
|
+
import { MlvPopup, MlvPopupTrigger } from '@malva-ui/core/popup';
|
|
13
|
+
import { MlvSignalFormControlBase, MlvFormControl } from '@malva-ui/core/form-utils';
|
|
14
|
+
import * as _tiptap_extension_file_handler from '@tiptap/extension-file-handler';
|
|
15
|
+
import { MlvColorPickerPopup } from '@malva-ui/core/color-picker';
|
|
16
|
+
import { MlvSelectOption } from '@malva-ui/core/dropdown';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Supported external serialization formats for editor content.
|
|
20
|
+
*
|
|
21
|
+
* `'html'` and `'markdown'` carry text markup. `'json'` carries the Tiptap
|
|
22
|
+
* document itself as `JSON.stringify(editor.getJSON())`, so custom block nodes
|
|
23
|
+
* round-trip their typed attributes instead of being flattened into HTML
|
|
24
|
+
* attributes. The model type stays `string | null` in every format; a JSON
|
|
25
|
+
* host parses that string at its own boundary.
|
|
26
|
+
*/
|
|
27
|
+
type MlvEditorFormat = 'html' | 'markdown' | 'json';
|
|
28
|
+
/**
|
|
29
|
+
* Width of the centred editor content column.
|
|
30
|
+
*
|
|
31
|
+
* `'default'` is a comfortable reading measure, `'wide'` suits dense or tabular
|
|
32
|
+
* documents, and `'full'` lets the column fill its host. A horizontal gutter is
|
|
33
|
+
* reserved at every value, so block affordances never overlap text.
|
|
34
|
+
*/
|
|
35
|
+
type MlvEditorContentWidth = 'default' | 'wide' | 'full';
|
|
36
|
+
/** Origin of an image file supplied to the editor. */
|
|
37
|
+
type MlvEditorImageUploadSource = 'button' | 'paste' | 'drop';
|
|
38
|
+
/** Decides whether an uploaded image URL is safe to insert into the editor. */
|
|
39
|
+
type MlvEditorImageUrlPolicy = (url: string) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Default image URL policy used by the editor upload coordinator.
|
|
42
|
+
*
|
|
43
|
+
* Only absolute HTTP(S) URLs with a hostname and without credentials are
|
|
44
|
+
* accepted. Leading and trailing whitespace is ignored, while whitespace or
|
|
45
|
+
* control characters inside the URL are rejected.
|
|
46
|
+
*
|
|
47
|
+
* @param url Candidate image URL returned by an uploader.
|
|
48
|
+
* @returns Whether the URL is safe to insert.
|
|
49
|
+
*/
|
|
50
|
+
declare function mlvEditorDefaultImageUrlPolicy(url: string): boolean;
|
|
51
|
+
/** Details emitted when the Tiptap selection changes. */
|
|
52
|
+
interface MlvEditorSelectionChange {
|
|
53
|
+
/** Editor that produced the selection transaction. */
|
|
54
|
+
readonly editor: Editor;
|
|
55
|
+
/** Tiptap transaction containing the updated selection. */
|
|
56
|
+
readonly transaction: Transaction;
|
|
57
|
+
}
|
|
58
|
+
/** Details emitted for every Tiptap transaction. */
|
|
59
|
+
interface MlvEditorTransactionEvent {
|
|
60
|
+
/** Editor that produced the transaction. */
|
|
61
|
+
readonly editor: Editor;
|
|
62
|
+
/** Tiptap transaction emitted by the editor. */
|
|
63
|
+
readonly transaction: Transaction;
|
|
64
|
+
}
|
|
65
|
+
/** Details emitted when the editor receives or loses focus. */
|
|
66
|
+
interface MlvEditorFocusEvent {
|
|
67
|
+
/** Editor associated with the native focus event. */
|
|
68
|
+
readonly editor: Editor;
|
|
69
|
+
/** Native browser focus event. */
|
|
70
|
+
readonly event: FocusEvent;
|
|
71
|
+
}
|
|
72
|
+
/** Context supplied to an image uploader for one upload operation. */
|
|
73
|
+
interface MlvEditorImageUploadContext {
|
|
74
|
+
/** Origin of the image file. */
|
|
75
|
+
readonly source: MlvEditorImageUploadSource;
|
|
76
|
+
/** Signal that is aborted when the upload should stop. */
|
|
77
|
+
readonly signal: AbortSignal;
|
|
78
|
+
/** Reports upload progress as a percentage from 0 through 100. */
|
|
79
|
+
readonly reportProgress: (percentage: number) => void;
|
|
80
|
+
}
|
|
81
|
+
/** Image metadata returned by an image uploader after a successful upload. */
|
|
82
|
+
interface MlvEditorImageUploadResult {
|
|
83
|
+
/** URL used in the inserted image node. */
|
|
84
|
+
readonly src: string;
|
|
85
|
+
/** Optional alternative text for the image. */
|
|
86
|
+
readonly alt?: string;
|
|
87
|
+
/** Optional image title. */
|
|
88
|
+
readonly title?: string;
|
|
89
|
+
/** Optional rendered image width. */
|
|
90
|
+
readonly width?: number;
|
|
91
|
+
/** Optional rendered image height. */
|
|
92
|
+
readonly height?: number;
|
|
93
|
+
}
|
|
94
|
+
/** Adapter used to transfer image files selected, pasted, or dropped in the editor. */
|
|
95
|
+
interface MlvEditorImageUploader {
|
|
96
|
+
/**
|
|
97
|
+
* Uploads an image file and returns the metadata used to insert it.
|
|
98
|
+
*
|
|
99
|
+
* @param file Image file to upload.
|
|
100
|
+
* @param context Source, cancellation, and progress facilities for this upload.
|
|
101
|
+
* @returns Metadata for the successfully uploaded image.
|
|
102
|
+
*/
|
|
103
|
+
upload(file: File, context: MlvEditorImageUploadContext): Promise<MlvEditorImageUploadResult>;
|
|
104
|
+
}
|
|
105
|
+
/** Constraints applied before images are sent to an uploader. */
|
|
106
|
+
interface MlvEditorImageUploadOptions {
|
|
107
|
+
/** MIME types or patterns accepted by the editor. */
|
|
108
|
+
readonly accept: readonly string[];
|
|
109
|
+
/** Largest allowed file size in bytes. */
|
|
110
|
+
readonly maxSize: number;
|
|
111
|
+
/** Maximum number of files accepted in one upload action. */
|
|
112
|
+
readonly maxFiles: number;
|
|
113
|
+
/** Optional host policy replacing the default uploaded-image URL decision. */
|
|
114
|
+
readonly urlPolicy?: MlvEditorImageUrlPolicy;
|
|
115
|
+
}
|
|
116
|
+
/** One upload retained by the editor while it is active or retryable. */
|
|
117
|
+
interface MlvEditorPendingUpload {
|
|
118
|
+
/** Stable identifier shared with the non-serializable placeholder. */
|
|
119
|
+
readonly id: string;
|
|
120
|
+
/** Image file supplied by the host interaction. */
|
|
121
|
+
readonly file: File;
|
|
122
|
+
/** Interaction that supplied the file. */
|
|
123
|
+
readonly source: MlvEditorImageUploadSource;
|
|
124
|
+
/** Current finite upload progress from zero through one hundred. */
|
|
125
|
+
readonly progress: number;
|
|
126
|
+
/** Whether the upload is active or retained after a recoverable failure. */
|
|
127
|
+
readonly status: 'uploading' | 'failed';
|
|
128
|
+
/** Recoverable failure retained while the upload can be retried or removed. */
|
|
129
|
+
readonly error?: MlvEditorError;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Editor-owned image-upload capability forwarded to standalone toolbars.
|
|
133
|
+
*
|
|
134
|
+
* The capability is intentionally one shared reference so toolbar controls
|
|
135
|
+
* never create a second uploader, request registry, or placeholder owner. Its
|
|
136
|
+
* private brand makes this a library-owned capability rather than a structural
|
|
137
|
+
* protocol for consumers to implement.
|
|
138
|
+
*/
|
|
139
|
+
declare abstract class MlvEditorImageUploadControl {
|
|
140
|
+
/** @private Nominal brand preventing structural implementations. */
|
|
141
|
+
private readonly _mlvEditorImageUploadControlBrand;
|
|
142
|
+
protected constructor();
|
|
143
|
+
/** Whether this editor can currently begin image uploads. */
|
|
144
|
+
abstract readonly available: Signal<boolean>;
|
|
145
|
+
/** Whether either the input or injected adapter resolves for this editor. */
|
|
146
|
+
abstract readonly adapterAvailable: Signal<boolean>;
|
|
147
|
+
/** Current editor-scoped validation options. */
|
|
148
|
+
abstract readonly options: Signal<MlvEditorImageUploadOptions>;
|
|
149
|
+
/** Active and retryable uploads owned by this editor. */
|
|
150
|
+
abstract readonly pending: Signal<readonly MlvEditorPendingUpload[]>;
|
|
151
|
+
/** Starts validated uploads in the owning editor. */
|
|
152
|
+
abstract start(files: readonly File[], source: MlvEditorImageUploadSource, metadata?: {
|
|
153
|
+
readonly position?: number;
|
|
154
|
+
readonly alt?: string;
|
|
155
|
+
readonly title?: string;
|
|
156
|
+
}): readonly string[];
|
|
157
|
+
/** Cancels one active request. */
|
|
158
|
+
abstract cancel(id: string): void;
|
|
159
|
+
/** Retries one recoverable request. */
|
|
160
|
+
abstract retry(id: string): void;
|
|
161
|
+
/** Removes one recoverable failure. */
|
|
162
|
+
abstract remove(id: string): void;
|
|
163
|
+
}
|
|
164
|
+
/** Details emitted after a successful image upload. */
|
|
165
|
+
interface MlvEditorImageUploadSuccess {
|
|
166
|
+
/** Image file that was uploaded. */
|
|
167
|
+
readonly file: File;
|
|
168
|
+
/** Origin of the image file. */
|
|
169
|
+
readonly source: MlvEditorImageUploadSource;
|
|
170
|
+
/** Metadata returned by the image uploader. */
|
|
171
|
+
readonly result: MlvEditorImageUploadResult;
|
|
172
|
+
}
|
|
173
|
+
/** Details emitted when an image upload fails. */
|
|
174
|
+
interface MlvEditorImageUploadFailure {
|
|
175
|
+
/** Image file whose upload failed. */
|
|
176
|
+
readonly file: File;
|
|
177
|
+
/** Origin of the image file. */
|
|
178
|
+
readonly source: MlvEditorImageUploadSource;
|
|
179
|
+
/** Recoverable error describing the failed upload. */
|
|
180
|
+
readonly error: MlvEditorError;
|
|
181
|
+
}
|
|
182
|
+
/** Details emitted when an image upload is cancelled. */
|
|
183
|
+
interface MlvEditorImageUploadCancelled {
|
|
184
|
+
/** Image file whose upload was cancelled. */
|
|
185
|
+
readonly file: File;
|
|
186
|
+
/** Origin of the image file. */
|
|
187
|
+
readonly source: MlvEditorImageUploadSource;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Categories of recoverable errors emitted by the editor.
|
|
191
|
+
*
|
|
192
|
+
* `'ai-transport'` reports an AI provider that threw or whose stream failed;
|
|
193
|
+
* `'ai-result'` reports AI output that could not be used. Both restore the
|
|
194
|
+
* document to its pre-request checkpoint; cancellation is silent and never
|
|
195
|
+
* emits an error.
|
|
196
|
+
*/
|
|
197
|
+
type MlvEditorErrorCode = 'configuration' | 'parse' | 'serialize' | 'unsupported-command' | 'upload-validation' | 'upload-transport' | 'upload-result' | 'ai-transport' | 'ai-result';
|
|
198
|
+
/** Structured error emitted instead of throwing through Angular change detection. */
|
|
199
|
+
interface MlvEditorError {
|
|
200
|
+
/** Stable category that callers can use for error handling. */
|
|
201
|
+
readonly code: MlvEditorErrorCode;
|
|
202
|
+
/** Human-readable description of the failure. */
|
|
203
|
+
readonly message: string;
|
|
204
|
+
/** Whether the editor can continue operating after the failure. */
|
|
205
|
+
readonly recoverable: boolean;
|
|
206
|
+
/** Original failure when one is available. */
|
|
207
|
+
readonly cause?: unknown;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Optional dependency-injection token for a host-provided image uploader. */
|
|
211
|
+
declare const MLV_EDITOR_IMAGE_UPLOADER: InjectionToken<MlvEditorImageUploader>;
|
|
212
|
+
/** Default restrictions for image files inserted through the editor. */
|
|
213
|
+
declare const MLV_EDITOR_DEFAULT_IMAGE_UPLOAD_OPTIONS: MlvEditorImageUploadOptions;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Lifecycle of the per-editor AI surface.
|
|
217
|
+
*
|
|
218
|
+
* `'idle'` — no AI work is in flight. `'running'` — a transform is streaming
|
|
219
|
+
* into the document, or a `'review'` transform is collecting its result.
|
|
220
|
+
* `'reviewing'` — a collected result was applied as tracked suggestions that
|
|
221
|
+
* await per-change or bulk accept/reject; the state ends when the suggestion
|
|
222
|
+
* set empties.
|
|
223
|
+
*/
|
|
224
|
+
type MlvEditorAiStatus = 'idle' | 'running' | 'reviewing';
|
|
225
|
+
/** Options accepted by {@link MlvEditorAiContext.runTransform}. */
|
|
226
|
+
interface MlvEditorAiTransformOptions {
|
|
227
|
+
/**
|
|
228
|
+
* Free-form transform argument: the prompt for `'custom'`, the target tone
|
|
229
|
+
* for `'tone'`, or the target language for `'translate'`.
|
|
230
|
+
*/
|
|
231
|
+
readonly instruction?: string;
|
|
232
|
+
/**
|
|
233
|
+
* Where the streamed result lands; defaults to `'replace-selection'`.
|
|
234
|
+
* `'review'` collects the complete result without touching the document
|
|
235
|
+
* and applies it as reviewable tracked suggestions on success.
|
|
236
|
+
*/
|
|
237
|
+
readonly output?: MlvEditorAiOutputMode;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Per-editor AI command state provided by `mlv-editor`.
|
|
241
|
+
*
|
|
242
|
+
* The context owns provider resolution, request shaping, and the streaming
|
|
243
|
+
* and review session lifecycles; the framework-free engines
|
|
244
|
+
* ({@link runMlvEditorAiStream}, {@link applyMlvEditorAiSuggestions}) own
|
|
245
|
+
* document mutation. Every mutation is
|
|
246
|
+
* gated by the toolbar context's guard, so readonly and disabled editors
|
|
247
|
+
* refuse to start AI work — controls stay visible while a provider exists
|
|
248
|
+
* (presence) and disable with the editor (executability), matching the
|
|
249
|
+
* toolbar's presence-vs-executability rule.
|
|
250
|
+
*
|
|
251
|
+
* Failures never throw or reject: they surface as recoverable
|
|
252
|
+
* {@link MlvEditorError} emissions through the owning editor's `editorError`
|
|
253
|
+
* output. Cancellation stays silent.
|
|
254
|
+
*/
|
|
255
|
+
declare class MlvEditorAiContext {
|
|
256
|
+
/** @private Guarded command surface and error channel of the owning editor. */
|
|
257
|
+
private readonly _toolbar;
|
|
258
|
+
/** @private Application-level provider used when the input supplies none. */
|
|
259
|
+
private readonly _injectedProvider;
|
|
260
|
+
/** @private The owning editor's `aiProvider` input; wins over the token. */
|
|
261
|
+
private readonly _inputProvider;
|
|
262
|
+
/** @private Announces streaming lifecycle politely; decorations are aria-hidden. */
|
|
263
|
+
private readonly _liveAnnouncer;
|
|
264
|
+
/** @private Optional translated announcement strings. */
|
|
265
|
+
private readonly _i18n;
|
|
266
|
+
/** @private Resolves the ICU review-count announcement template. */
|
|
267
|
+
private readonly _resolver;
|
|
268
|
+
/** @private Writable lifecycle state behind the readonly public signal. */
|
|
269
|
+
private readonly _status;
|
|
270
|
+
/** @private Writable pending-suggestion projection behind the readonly signal. */
|
|
271
|
+
private readonly _suggestions;
|
|
272
|
+
/**
|
|
273
|
+
* @private Latest streaming session. Retained after settlement so
|
|
274
|
+
* {@link restoreCheckpoint} can undo a committed transform; replaced when
|
|
275
|
+
* the next transform starts.
|
|
276
|
+
*/
|
|
277
|
+
private _session;
|
|
278
|
+
/** @private Abort control for the in-flight provider request, if any. */
|
|
279
|
+
private _abortController;
|
|
280
|
+
/**
|
|
281
|
+
* @private Active review wiring: the engine session plus the teardown that
|
|
282
|
+
* detaches the editor `transaction`/`destroy` listeners mirroring it into
|
|
283
|
+
* {@link suggestions}. `null` outside `'reviewing'`.
|
|
284
|
+
*/
|
|
285
|
+
private _review;
|
|
286
|
+
/**
|
|
287
|
+
* @private Last suggestion id {@link revealSuggestion} announced. Repeated
|
|
288
|
+
* reveals of the same suggestion (the review bar re-runs its outline effect
|
|
289
|
+
* on unrelated signal updates) must not re-announce it.
|
|
290
|
+
*/
|
|
291
|
+
private _revealedId;
|
|
292
|
+
/** Lifecycle of the AI surface for this editor. */
|
|
293
|
+
readonly status: Signal<MlvEditorAiStatus>;
|
|
294
|
+
/**
|
|
295
|
+
* Pending suggestions of the active review session, in document order.
|
|
296
|
+
* Empty outside `'reviewing'`. Refreshed after every editor transaction, so
|
|
297
|
+
* accept/reject calls, intersecting user edits, and an undo of the
|
|
298
|
+
* application are all reflected immediately. Document ranges deliberately
|
|
299
|
+
* stay internal — they remap on every transaction and would be stale the
|
|
300
|
+
* moment a consumer stored them.
|
|
301
|
+
*/
|
|
302
|
+
readonly suggestions: Signal<readonly MlvEditorAiReviewSuggestion[]>;
|
|
303
|
+
/**
|
|
304
|
+
* Whether a review session with unresolved suggestions is active. Hosts
|
|
305
|
+
* gate saves on this: during `'reviewing'` the document serializes in its
|
|
306
|
+
* accepted-by-default shape (inserted text present, removed text absent).
|
|
307
|
+
*/
|
|
308
|
+
readonly hasPendingSuggestions: Signal<boolean>;
|
|
309
|
+
/**
|
|
310
|
+
* Whether an AI provider is resolvable for this editor, either through the
|
|
311
|
+
* `aiProvider` input or `MLV_EDITOR_AI_PROVIDER`. AI UI modules hide
|
|
312
|
+
* entirely without a provider.
|
|
313
|
+
*/
|
|
314
|
+
readonly hasProvider: Signal<boolean>;
|
|
315
|
+
/**
|
|
316
|
+
* Runs one selection transform through the resolved provider and lands the
|
|
317
|
+
* result according to the output mode: `'replace-selection'` and
|
|
318
|
+
* `'insert-below'` stream into the document, while `'review'` collects the
|
|
319
|
+
* complete result without writing and then applies it over the selection
|
|
320
|
+
* captured at start as reviewable tracked suggestions — status moves to
|
|
321
|
+
* `'reviewing'` and the suggestion surface
|
|
322
|
+
* ({@link suggestions}, {@link acceptSuggestion}, …) takes over. A review
|
|
323
|
+
* result identical to the region applies nothing: status returns straight
|
|
324
|
+
* to `'idle'` with a polite no-changes announcement and no error.
|
|
325
|
+
*
|
|
326
|
+
* The returned promise resolves after the session settles and never
|
|
327
|
+
* rejects; every failure is reported as a recoverable error through the
|
|
328
|
+
* editor's `editorError` output instead:
|
|
329
|
+
*
|
|
330
|
+
* - a transform already running, or a review still pending
|
|
331
|
+
* (`configuration`) — concurrent calls are refused rather than queued,
|
|
332
|
+
* so one editor never hosts two writers and pending suggestions are
|
|
333
|
+
* never silently replaced;
|
|
334
|
+
* - a readonly, disabled, or absent editor (`configuration`) — the toolbar
|
|
335
|
+
* guard refuses to start, and a `'review'` run re-checks the same guard
|
|
336
|
+
* after collection: an editor that became readonly or disabled mid-run
|
|
337
|
+
* refuses to apply the collected suggestions (checkpoint untouched — a
|
|
338
|
+
* review collection never wrote);
|
|
339
|
+
* - no resolvable provider (`configuration`);
|
|
340
|
+
* - a provider that throws or whose stream fails (`'ai-transport'`) — the
|
|
341
|
+
* checkpoint is restored;
|
|
342
|
+
* - unusable output (`'ai-result'`) — the checkpoint is restored. Both
|
|
343
|
+
* restore paths are no-ops for `'review'`, which never wrote.
|
|
344
|
+
*
|
|
345
|
+
* Start, successful finish, and cancellation are announced through the CDK
|
|
346
|
+
* `LiveAnnouncer` at `'polite'`; a successful `'review'` run announces the
|
|
347
|
+
* pending suggestion count instead of the generic finish. A failure
|
|
348
|
+
* announces nothing because the error channel already reports it.
|
|
349
|
+
*
|
|
350
|
+
* @param kind Transform requested from the provider.
|
|
351
|
+
* @param options Optional instruction and output mode.
|
|
352
|
+
*/
|
|
353
|
+
runTransform(kind: MlvEditorAiTransformKind, options?: MlvEditorAiTransformOptions): Promise<void>;
|
|
354
|
+
/**
|
|
355
|
+
* Aborts the in-flight request and rolls the document back to the
|
|
356
|
+
* checkpoint captured when the transform started.
|
|
357
|
+
*
|
|
358
|
+
* The provider's `AbortSignal` aborts, the streaming session restores the
|
|
359
|
+
* checkpoint, and the transform resolves silently — no error is emitted
|
|
360
|
+
* and only the cancellation announcement is made. A no-op while idle.
|
|
361
|
+
*/
|
|
362
|
+
cancel(): void;
|
|
363
|
+
/**
|
|
364
|
+
* Restores the document to the checkpoint of the most recent transform.
|
|
365
|
+
*
|
|
366
|
+
* While a transform is running this behaves exactly like {@link cancel}.
|
|
367
|
+
* After a committed transform it reverts the commit in one history-visible
|
|
368
|
+
* step, so the restore is itself undoable. While `'reviewing'`, restoring
|
|
369
|
+
* reverts the applied suggestions wholesale, which drops the suggestion
|
|
370
|
+
* set and ends the review. The restore is a document mutation and
|
|
371
|
+
* therefore passes the toolbar guard: readonly and disabled editors refuse
|
|
372
|
+
* it. A no-op when no transform has run.
|
|
373
|
+
*/
|
|
374
|
+
restoreCheckpoint(): void;
|
|
375
|
+
/**
|
|
376
|
+
* Accepts one pending suggestion: the applied change stays in the document
|
|
377
|
+
* and its decorations drop. Delegates to the review engine — a pure
|
|
378
|
+
* plugin-state update that creates no history entry. Announces the
|
|
379
|
+
* acceptance politely; when the last suggestion resolves the review ends
|
|
380
|
+
* and {@link status} returns to `'idle'`.
|
|
381
|
+
*
|
|
382
|
+
* Refused silently — decorations stay visible, nothing changes — while no
|
|
383
|
+
* review is active, the id is unknown, or the editor is readonly or
|
|
384
|
+
* disabled (the same guard rule that blocks every other AI mutation).
|
|
385
|
+
*
|
|
386
|
+
* @param id Identifier from {@link suggestions}.
|
|
387
|
+
*/
|
|
388
|
+
acceptSuggestion(id: string): void;
|
|
389
|
+
/**
|
|
390
|
+
* Rejects one pending suggestion: the original content is restored over
|
|
391
|
+
* the suggestion's range in exactly one history-visible step and its
|
|
392
|
+
* decorations drop. Announces the rejection politely; when the last
|
|
393
|
+
* suggestion resolves the review ends and {@link status} returns to
|
|
394
|
+
* `'idle'`.
|
|
395
|
+
*
|
|
396
|
+
* Refused silently while no review is active, the id is unknown, or the
|
|
397
|
+
* editor is readonly or disabled — the restore is a document mutation and
|
|
398
|
+
* runs through the toolbar guard.
|
|
399
|
+
*
|
|
400
|
+
* @param id Identifier from {@link suggestions}.
|
|
401
|
+
*/
|
|
402
|
+
rejectSuggestion(id: string): void;
|
|
403
|
+
/**
|
|
404
|
+
* Accepts every pending suggestion in one plugin-state update — no
|
|
405
|
+
* document step, no history entry — then ends the review and returns
|
|
406
|
+
* {@link status} to `'idle'`. Announced politely. Refused silently while
|
|
407
|
+
* no review is active or the editor is readonly or disabled.
|
|
408
|
+
*/
|
|
409
|
+
acceptAll(): void;
|
|
410
|
+
/**
|
|
411
|
+
* Rejects every pending suggestion in exactly one history-visible step,
|
|
412
|
+
* restoring the original content of the whole reviewed region, then ends
|
|
413
|
+
* the review and returns {@link status} to `'idle'`. Announced politely.
|
|
414
|
+
* Refused silently while no review is active or the editor is readonly or
|
|
415
|
+
* disabled — the restore is a document mutation and runs through the
|
|
416
|
+
* toolbar guard.
|
|
417
|
+
*/
|
|
418
|
+
rejectAll(): void;
|
|
419
|
+
/**
|
|
420
|
+
* Outlines one pending suggestion as the current one under review and
|
|
421
|
+
* scrolls its document range into view; `null` clears the outline (review
|
|
422
|
+
* surfaces call that on teardown so no marker strands).
|
|
423
|
+
*
|
|
424
|
+
* The outline decorations are `aria-hidden`, so revealing a suggestion also
|
|
425
|
+
* announces its {@link describeSuggestion} description politely — index,
|
|
426
|
+
* count, and the removed/added text — the non-visual equivalent the spec
|
|
427
|
+
* requires. Each suggestion is announced once per reveal: repeating the
|
|
428
|
+
* current id moves nothing and re-announces nothing.
|
|
429
|
+
*
|
|
430
|
+
* Otherwise a pure view affordance: the outline is a decoration-only
|
|
431
|
+
* plugin-state update, so no document step and no history entry is created
|
|
432
|
+
* — which is why, unlike accept/reject, it stays available in readonly
|
|
433
|
+
* editors, whose pending reviews remain visible and navigable. Refused
|
|
434
|
+
* silently while no review is active or the id is unknown. The review bar
|
|
435
|
+
* drives this from its navigation cursor.
|
|
436
|
+
*
|
|
437
|
+
* @param id Identifier from {@link suggestions}, or `null` to clear.
|
|
438
|
+
*/
|
|
439
|
+
revealSuggestion(id: string | null): void;
|
|
440
|
+
/**
|
|
441
|
+
* Human-readable description of one pending suggestion — its one-based
|
|
442
|
+
* position in the pending list plus what it replaces, inserts, or removes —
|
|
443
|
+
* resolved through the `aiCurrentSuggestionReplace`/`-Insert`/`-Delete`
|
|
444
|
+
* ICU templates.
|
|
445
|
+
*
|
|
446
|
+
* This is the non-visual equivalent of the `aria-hidden` suggestion
|
|
447
|
+
* decorations: {@link revealSuggestion} announces it, and the review bar
|
|
448
|
+
* additionally exposes it to its accept/reject controls through
|
|
449
|
+
* `aria-describedby`, so the change under decision is inspectable without
|
|
450
|
+
* sight of the decorations. Returns `null` while no review is active or
|
|
451
|
+
* for an unknown id.
|
|
452
|
+
*
|
|
453
|
+
* @param id Identifier from {@link suggestions}.
|
|
454
|
+
*/
|
|
455
|
+
describeSuggestion(id: string): string | null;
|
|
456
|
+
/**
|
|
457
|
+
* @private Scrolls the rendered element at one document position into view.
|
|
458
|
+
* Best effort: position resolution can fail transiently mid-transaction and
|
|
459
|
+
* jsdom offers no `scrollIntoView`, so failure never fails the reveal.
|
|
460
|
+
*/
|
|
461
|
+
private _scrollPositionIntoView;
|
|
462
|
+
/**
|
|
463
|
+
* @private Routes a committed review collection through the suggestion
|
|
464
|
+
* engine. An engine refusal — the replacement is identical to the region,
|
|
465
|
+
* or otherwise nothing reviewable results — is the no-changes case: status
|
|
466
|
+
* returns to `'idle'` with a polite announcement, no error, and no
|
|
467
|
+
* document change. Otherwise the context enters `'reviewing'`, mirrors the
|
|
468
|
+
* engine's suggestion set into {@link suggestions} after every editor
|
|
469
|
+
* transaction (the session has no change notification of its own), and
|
|
470
|
+
* announces the pending count.
|
|
471
|
+
*/
|
|
472
|
+
private _startReview;
|
|
473
|
+
/**
|
|
474
|
+
* @private Ends the review session exactly once: detaches the editor
|
|
475
|
+
* listeners, clears the suggestion projection, and returns to `'idle'`.
|
|
476
|
+
* Runs when the suggestion set empties — accept/reject calls, intersecting
|
|
477
|
+
* edits dropping the last suggestion, or an undo of the application — and
|
|
478
|
+
* when the editor is destroyed.
|
|
479
|
+
*/
|
|
480
|
+
private _endReview;
|
|
481
|
+
/** @private Projects engine suggestions into the range-free public shape. */
|
|
482
|
+
private _projectSuggestions;
|
|
483
|
+
/** @private Announces the pending review count politely through the ICU template. */
|
|
484
|
+
private _announceReviewStarted;
|
|
485
|
+
/** @private Resolves the active provider; the input wins over the token. */
|
|
486
|
+
private _resolveProvider;
|
|
487
|
+
/** @private Reports a recoverable configuration refusal through the editor. */
|
|
488
|
+
private _reportConfiguration;
|
|
489
|
+
/** @private Announces one localized AI lifecycle message politely. */
|
|
490
|
+
private _announce;
|
|
491
|
+
/**
|
|
492
|
+
* @private Serializes the current selection as Markdown, or `null` when the
|
|
493
|
+
* selection is empty. Uses the editor's Markdown manager — the same
|
|
494
|
+
* serialization path as `getMarkdown()` — over the selection sliced into
|
|
495
|
+
* its own document; a replacement extension set without Markdown falls back
|
|
496
|
+
* to plain text so providers still receive usable context.
|
|
497
|
+
*/
|
|
498
|
+
private _serializeSelection;
|
|
499
|
+
/**
|
|
500
|
+
* @private Serializes the whole document as Markdown, or `null` when the
|
|
501
|
+
* document is semantically empty. The document window is currently the full
|
|
502
|
+
* document; a bounded window is a later refinement. Falls back to plain
|
|
503
|
+
* text when the extension set carries no Markdown manager.
|
|
504
|
+
*/
|
|
505
|
+
private _serializeDocument;
|
|
506
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorAiContext, never>;
|
|
507
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<MlvEditorAiContext>;
|
|
508
|
+
}
|
|
509
|
+
/** Injects the AI command state belonging to the nearest `mlv-editor`. */
|
|
510
|
+
declare const MLV_EDITOR_AI_CONTEXT: InjectionToken<MlvEditorAiContext>;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* CSS class of the inline decoration highlighting text a pending suggestion
|
|
514
|
+
* inserted into the document.
|
|
515
|
+
*
|
|
516
|
+
* The class is applied through a ProseMirror decoration held in plugin state,
|
|
517
|
+
* never through document content, so it can appear in no HTML, Markdown, or
|
|
518
|
+
* JSON serialization.
|
|
519
|
+
*/
|
|
520
|
+
declare const MLV_EDITOR_AI_SUGGESTION_INSERT_CLASS = "mlv-editor__ai-suggestion-insert";
|
|
521
|
+
/**
|
|
522
|
+
* CSS class of the widget decoration rendering text a pending suggestion
|
|
523
|
+
* removed from the document.
|
|
524
|
+
*
|
|
525
|
+
* The removed text lives only inside the widget element — a strikethrough,
|
|
526
|
+
* `aria-hidden` affordance — so it is absent from the document and from every
|
|
527
|
+
* serialization the moment the suggestion is applied.
|
|
528
|
+
*/
|
|
529
|
+
declare const MLV_EDITOR_AI_SUGGESTION_DELETE_CLASS = "mlv-editor__ai-suggestion-delete";
|
|
530
|
+
/**
|
|
531
|
+
* CSS class added on top of the insert and delete decorations of the one
|
|
532
|
+
* suggestion a review surface currently navigates
|
|
533
|
+
* ({@link MlvEditorAiSuggestionsSession.setCurrent}).
|
|
534
|
+
*
|
|
535
|
+
* A decoration-only outline affordance: it never enters document content or
|
|
536
|
+
* any serialization, and marking a suggestion current dispatches no document
|
|
537
|
+
* step, so it can never create a history entry.
|
|
538
|
+
*/
|
|
539
|
+
declare const MLV_EDITOR_AI_SUGGESTION_CURRENT_CLASS = "mlv-editor__ai-suggestion-current";
|
|
540
|
+
/**
|
|
541
|
+
* Shape of one reviewable change.
|
|
542
|
+
*
|
|
543
|
+
* `'insert'` — new text was added; reject removes it. `'delete'` — text was
|
|
544
|
+
* removed; reject restores it. `'replace'` — text was swapped; reject
|
|
545
|
+
* restores the original.
|
|
546
|
+
*/
|
|
547
|
+
type MlvEditorAiSuggestionKind = 'insert' | 'delete' | 'replace';
|
|
548
|
+
/** Document range a suggestion currently occupies. */
|
|
549
|
+
interface MlvEditorAiSuggestionRange {
|
|
550
|
+
/** Start position of the suggestion's inserted content. */
|
|
551
|
+
readonly from: number;
|
|
552
|
+
/**
|
|
553
|
+
* End position of the suggestion's inserted content. Equals {@link from}
|
|
554
|
+
* for `'delete'` suggestions, whose removed text exists only in the widget
|
|
555
|
+
* decoration anchored at this collapsed position.
|
|
556
|
+
*/
|
|
557
|
+
readonly to: number;
|
|
558
|
+
}
|
|
559
|
+
/** One pending, reviewable AI change. */
|
|
560
|
+
interface MlvEditorAiSuggestion {
|
|
561
|
+
/** Stable identifier, unique across sessions within this runtime. */
|
|
562
|
+
readonly id: string;
|
|
563
|
+
/** Shape of the change. */
|
|
564
|
+
readonly kind: MlvEditorAiSuggestionKind;
|
|
565
|
+
/**
|
|
566
|
+
* Current document range of the inserted content, remapped through every
|
|
567
|
+
* concurrent transaction. Collapsed for `'delete'` suggestions.
|
|
568
|
+
*/
|
|
569
|
+
readonly range: MlvEditorAiSuggestionRange;
|
|
570
|
+
/** Plain text the change removed; empty for `'insert'`. */
|
|
571
|
+
readonly oldText: string;
|
|
572
|
+
/** Plain text the change added; empty for `'delete'`. */
|
|
573
|
+
readonly newText: string;
|
|
574
|
+
}
|
|
575
|
+
/** Options accepted by {@link applyMlvEditorAiSuggestions}. */
|
|
576
|
+
interface MlvEditorAiSuggestionsOptions {
|
|
577
|
+
/** Start of the document region the replacement rewrites. */
|
|
578
|
+
readonly from: number;
|
|
579
|
+
/** End of the document region the replacement rewrites. */
|
|
580
|
+
readonly to: number;
|
|
581
|
+
/**
|
|
582
|
+
* AI-produced replacement for the region, as Markdown. Parsed through the
|
|
583
|
+
* editor's Markdown manager when one is registered; treated as plain text
|
|
584
|
+
* otherwise — the same fallback the streaming engine uses for its commit.
|
|
585
|
+
*/
|
|
586
|
+
readonly replacementMarkdown: string;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Handle over one review session created by {@link applyMlvEditorAiSuggestions}.
|
|
590
|
+
*
|
|
591
|
+
* Undo semantics — a deliberate refinement of the spec sentence "each
|
|
592
|
+
* accept/reject = one undo step": in the applied-edits storage model the
|
|
593
|
+
* document already carries every change, so **accepting changes no document
|
|
594
|
+
* content**. Accept operations (including {@link acceptAll}) are pure
|
|
595
|
+
* plugin-state updates that drop decorations and entries without dispatching
|
|
596
|
+
* a single step, and therefore create **no** history entry — an "accept undo
|
|
597
|
+
* step" would necessarily be an empty one. Rejects mutate the document:
|
|
598
|
+
* {@link reject} is exactly one history-visible step per call, and
|
|
599
|
+
* {@link rejectAll} is exactly one step total.
|
|
600
|
+
*
|
|
601
|
+
* Every method returns `false` once the session has ended — all suggestions
|
|
602
|
+
* resolved, the application undone, a newer session started, or the editor
|
|
603
|
+
* destroyed.
|
|
604
|
+
*/
|
|
605
|
+
interface MlvEditorAiSuggestionsSession {
|
|
606
|
+
/**
|
|
607
|
+
* Current pending suggestions in document order, with ranges remapped
|
|
608
|
+
* through every transaction dispatched since application. Empty once the
|
|
609
|
+
* session has ended.
|
|
610
|
+
*/
|
|
611
|
+
suggestions(): readonly MlvEditorAiSuggestion[];
|
|
612
|
+
/**
|
|
613
|
+
* Accepts one suggestion: the applied change stays in the document and its
|
|
614
|
+
* decorations are dropped. A pure plugin-state update — no document step,
|
|
615
|
+
* no history entry. Returns whether the suggestion existed.
|
|
616
|
+
*/
|
|
617
|
+
accept(id: string): boolean;
|
|
618
|
+
/**
|
|
619
|
+
* Rejects one suggestion: the original content is restored over the
|
|
620
|
+
* suggestion's current range in exactly one history-visible step, and the
|
|
621
|
+
* suggestion's decorations are dropped. Returns whether the suggestion
|
|
622
|
+
* existed and the restore succeeded.
|
|
623
|
+
*
|
|
624
|
+
* Restored is the reviewed region, not the editor's own schema-maintenance
|
|
625
|
+
* reactions to the suggested state: for example, the default preset's
|
|
626
|
+
* `trailingNode` paragraph appended while a structural suggestion was the
|
|
627
|
+
* last block stays behind — the same residue an ordinary user edit leaves.
|
|
628
|
+
*/
|
|
629
|
+
reject(id: string): boolean;
|
|
630
|
+
/**
|
|
631
|
+
* Accepts every pending suggestion in one plugin-state update. Like
|
|
632
|
+
* {@link accept}, dispatches no document step and creates no history
|
|
633
|
+
* entry. Returns whether any suggestion was pending.
|
|
634
|
+
*/
|
|
635
|
+
acceptAll(): boolean;
|
|
636
|
+
/**
|
|
637
|
+
* Rejects every pending suggestion in exactly one history-visible step,
|
|
638
|
+
* restoring the original content of the whole reviewed region. Returns
|
|
639
|
+
* whether any suggestion was pending and the restore succeeded.
|
|
640
|
+
*/
|
|
641
|
+
rejectAll(): boolean;
|
|
642
|
+
/**
|
|
643
|
+
* Marks one suggestion as the current one under review: its decorations
|
|
644
|
+
* gain {@link MLV_EDITOR_AI_SUGGESTION_CURRENT_CLASS} and the previous
|
|
645
|
+
* current suggestion loses it. `null` clears the marker. Like
|
|
646
|
+
* {@link accept}, a pure plugin-state update — no document step, no
|
|
647
|
+
* history entry. The marker clears itself when its suggestion resolves or
|
|
648
|
+
* is dropped by a concurrent edit. Returns `false` once the session has
|
|
649
|
+
* ended or for an unknown id.
|
|
650
|
+
*/
|
|
651
|
+
setCurrent(id: string | null): boolean;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Applies an AI replacement for `[from, to]` as reviewable tracked changes —
|
|
655
|
+
* the Phase 2 suggestion engine (storage option B of the design spec).
|
|
656
|
+
*
|
|
657
|
+
* Framework-free: only the editor instance and the replacement Markdown are
|
|
658
|
+
* needed — no Angular, no provider token, no network.
|
|
659
|
+
*
|
|
660
|
+
* Diff granularity (pragmatic, documented rule): when the original region is
|
|
661
|
+
* a single textblock of plain, unmarked text **and** the parsed replacement
|
|
662
|
+
* is a single paragraph of plain text, the two are diffed token-by-token
|
|
663
|
+
* (tokens are whitespace or word runs) over a longest common subsequence,
|
|
664
|
+
* producing individual insert/delete/replace suggestions. Any structural or
|
|
665
|
+
* formatted content on either side falls back to **one** whole-region
|
|
666
|
+
* replace suggestion.
|
|
667
|
+
*
|
|
668
|
+
* Representation: inserted text enters the document immediately and is
|
|
669
|
+
* highlighted by an inline decoration
|
|
670
|
+
* ({@link MLV_EDITOR_AI_SUGGESTION_INSERT_CLASS}); deleted text is removed
|
|
671
|
+
* from the document and re-rendered at its position by a strikethrough
|
|
672
|
+
* `aria-hidden` widget decoration
|
|
673
|
+
* ({@link MLV_EDITOR_AI_SUGGESTION_DELETE_CLASS}). Because both are
|
|
674
|
+
* decorations, `getHTML`/`getMarkdown`/`getJSON` during review serialize the
|
|
675
|
+
* document as-is — inserted text present, removed text absent — the spec's
|
|
676
|
+
* accepted-by-default rule. Hosts gate saves on pending suggestions.
|
|
677
|
+
*
|
|
678
|
+
* The whole application is exactly **one** history-visible transaction:
|
|
679
|
+
* one undo removes every suggested change at once — and, because the undo
|
|
680
|
+
* intersects every suggestion range, it also drops the whole session.
|
|
681
|
+
*
|
|
682
|
+
* Concurrent edits: user transactions remap all suggestion ranges through
|
|
683
|
+
* their step maps; an edit that intersects a suggestion's range drops that
|
|
684
|
+
* one suggestion (decorations removed, the current document text stands,
|
|
685
|
+
* nothing is restored). The session ends when every suggestion is resolved
|
|
686
|
+
* or dropped, and editor destruction cleans up listeners and plugin state.
|
|
687
|
+
* Starting a new session on an editor first ends the previous one, leaving
|
|
688
|
+
* its remaining suggestions applied (accepted-by-default).
|
|
689
|
+
*
|
|
690
|
+
* Undo-step semantics of the returned session are documented on
|
|
691
|
+
* {@link MlvEditorAiSuggestionsSession}.
|
|
692
|
+
*
|
|
693
|
+
* @param editor Live Tiptap editor the suggestions are applied to.
|
|
694
|
+
* @param options Region to rewrite and the replacement Markdown.
|
|
695
|
+
* @returns The review session, or `null` when nothing reviewable results —
|
|
696
|
+
* destroyed editor, out-of-range positions, unusable replacement, or a
|
|
697
|
+
* replacement identical to the region.
|
|
698
|
+
*/
|
|
699
|
+
declare function applyMlvEditorAiSuggestions(editor: Editor, options: MlvEditorAiSuggestionsOptions): MlvEditorAiSuggestionsSession | null;
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* The transform kinds the library itself ships menu entries and i18n copy for.
|
|
703
|
+
*
|
|
704
|
+
* `'improve'`, `'fix-grammar'`, `'shorten'`, `'extend'`, and `'summarize'`
|
|
705
|
+
* rewrite the selection without further arguments. `'tone'` and `'translate'`
|
|
706
|
+
* carry their target tone or language in
|
|
707
|
+
* {@link MlvEditorAiRequest.instruction}. `'custom'` carries a free-form host
|
|
708
|
+
* or user prompt in the same field.
|
|
709
|
+
*/
|
|
710
|
+
type MlvEditorAiBuiltInTransformKind = 'improve' | 'fix-grammar' | 'shorten' | 'extend' | 'summarize' | 'tone' | 'translate' | 'custom';
|
|
711
|
+
/**
|
|
712
|
+
* Selection transform requested from an AI provider: one of the
|
|
713
|
+
* {@link MlvEditorAiBuiltInTransformKind} values, or any host-authored string.
|
|
714
|
+
*
|
|
715
|
+
* The provider owns prompting, so a kind is a name the *provider* understands
|
|
716
|
+
* and is fully opaque to the editor: nothing in the library branches on it,
|
|
717
|
+
* and it is forwarded verbatim on {@link MlvEditorAiRequest.kind}. A host that
|
|
718
|
+
* supplies its own {@link MlvEditorAiAction} list can therefore name kinds the
|
|
719
|
+
* library has never heard of (`'legal-review'`, `'to-bullets'`, …) and answer
|
|
720
|
+
* them in its own provider.
|
|
721
|
+
*
|
|
722
|
+
* The union with `string` deliberately keeps the built-in literals in
|
|
723
|
+
* autocomplete — `(string & {})` is not reduced to `string` by the compiler,
|
|
724
|
+
* so editors still suggest `'improve'` while any other string remains
|
|
725
|
+
* assignable. The corollary for providers: `request.kind` is not exhaustively
|
|
726
|
+
* checkable, so a `switch` over it needs a `default` branch that tolerates
|
|
727
|
+
* kinds it does not know.
|
|
728
|
+
*/
|
|
729
|
+
type MlvEditorAiTransformKind = MlvEditorAiBuiltInTransformKind | (string & {});
|
|
730
|
+
/**
|
|
731
|
+
* One entry of the AI menu's action list.
|
|
732
|
+
*
|
|
733
|
+
* Hosts pass an array of these to `MlvEditorAiMenu.actions` to replace the
|
|
734
|
+
* built-in list literally — see `mlvEditorAiDefaultActions()` to start from
|
|
735
|
+
* the built-ins instead of retyping them.
|
|
736
|
+
*/
|
|
737
|
+
interface MlvEditorAiAction {
|
|
738
|
+
/**
|
|
739
|
+
* Transform kind forwarded verbatim to the provider through
|
|
740
|
+
* {@link MlvEditorAiContext.runTransform}. Any string is valid; see
|
|
741
|
+
* {@link MlvEditorAiTransformKind}. Ignored when {@link run} is present.
|
|
742
|
+
*
|
|
743
|
+
* Kinds are not required to be unique within one list: two entries may run
|
|
744
|
+
* the same kind with different instructions.
|
|
745
|
+
*/
|
|
746
|
+
readonly kind: MlvEditorAiTransformKind;
|
|
747
|
+
/**
|
|
748
|
+
* Display text of the menu item, already resolved. The menu renders it as
|
|
749
|
+
* given and never translates it — a localized list is built by resolving
|
|
750
|
+
* the copy before constructing the actions.
|
|
751
|
+
*/
|
|
752
|
+
readonly label: string;
|
|
753
|
+
/**
|
|
754
|
+
* Free-form transform argument passed through as
|
|
755
|
+
* {@link MlvEditorAiRequest.instruction}: a fixed tone for `'tone'`, a fixed
|
|
756
|
+
* target language for `'translate'`, or a canned prompt for `'custom'`.
|
|
757
|
+
* Omitted from the request when absent. Ignored when {@link run} is present.
|
|
758
|
+
*/
|
|
759
|
+
readonly instruction?: string;
|
|
760
|
+
/**
|
|
761
|
+
* Where the result lands; defaults to `'replace-selection'`. Ignored when
|
|
762
|
+
* {@link run} is present.
|
|
763
|
+
*/
|
|
764
|
+
readonly output?: MlvEditorAiOutputMode;
|
|
765
|
+
/**
|
|
766
|
+
* Escape hatch replacing the menu's own behaviour for this entry.
|
|
767
|
+
*
|
|
768
|
+
* When present the menu calls this instead of `runTransform` and reads
|
|
769
|
+
* neither {@link kind}, {@link instruction}, nor {@link output} — they stay
|
|
770
|
+
* available to the callback itself, which owns the whole action. The
|
|
771
|
+
* argument is the live per-editor {@link MlvEditorAiContext}, so the
|
|
772
|
+
* callback can call `runTransform` with anything (including options this
|
|
773
|
+
* shape cannot express), chain several calls, inspect `status()` /
|
|
774
|
+
* `hasProvider()` / the review surface, or do something else entirely and
|
|
775
|
+
* never touch the AI context at all.
|
|
776
|
+
*
|
|
777
|
+
* It runs only when the item is enabled, so the readonly, disabled, and
|
|
778
|
+
* already-running guards still hold.
|
|
779
|
+
*
|
|
780
|
+
* @param context The AI context of the editor this menu belongs to.
|
|
781
|
+
*/
|
|
782
|
+
readonly run?: (context: MlvEditorAiContext) => void;
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Where the streamed result of a transform lands in the document.
|
|
786
|
+
*
|
|
787
|
+
* `'replace-selection'` overwrites the selected fragment in place.
|
|
788
|
+
* `'insert-below'` keeps the selection and streams the result into a new
|
|
789
|
+
* block after it. `'review'` collects the complete result without touching
|
|
790
|
+
* the document, then lands it as reviewable tracked suggestions the user
|
|
791
|
+
* accepts or rejects through the context's suggestion surface.
|
|
792
|
+
*/
|
|
793
|
+
type MlvEditorAiOutputMode = 'replace-selection' | 'insert-below' | 'review';
|
|
794
|
+
/**
|
|
795
|
+
* One pending AI change as the Angular context exposes it to review UIs.
|
|
796
|
+
*
|
|
797
|
+
* A projection of the engine-level `MlvEditorAiSuggestion`: the live document
|
|
798
|
+
* range stays internal to the context — positions remap on every transaction
|
|
799
|
+
* and would be stale the moment a template read them. Review surfaces render
|
|
800
|
+
* identity, shape, and the two texts; accept/reject go back through the
|
|
801
|
+
* context by `id`.
|
|
802
|
+
*/
|
|
803
|
+
interface MlvEditorAiReviewSuggestion {
|
|
804
|
+
/** Stable identifier, unique across sessions within this runtime. */
|
|
805
|
+
readonly id: string;
|
|
806
|
+
/**
|
|
807
|
+
* Shape of the change: `'insert'` added text, `'delete'` removed text,
|
|
808
|
+
* `'replace'` swapped text.
|
|
809
|
+
*/
|
|
810
|
+
readonly kind: MlvEditorAiSuggestionKind;
|
|
811
|
+
/** Plain text the change removed; empty for `'insert'`. */
|
|
812
|
+
readonly oldText: string;
|
|
813
|
+
/** Plain text the change added; empty for `'delete'`. */
|
|
814
|
+
readonly newText: string;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* One structured request handed to an {@link MlvEditorAiProvider}.
|
|
818
|
+
*
|
|
819
|
+
* The editor never builds a prompt: the provider receives the transform kind,
|
|
820
|
+
* the optional instruction, and Markdown context, and owns prompting, model
|
|
821
|
+
* choice, and server-side policy itself.
|
|
822
|
+
*/
|
|
823
|
+
interface MlvEditorAiRequest {
|
|
824
|
+
/**
|
|
825
|
+
* Requested capability. Either a selection transform or `'autocomplete'`
|
|
826
|
+
* for ghost-text completion at the caret.
|
|
827
|
+
*
|
|
828
|
+
* Not a closed union: a host-supplied action list can name any kind, so a
|
|
829
|
+
* provider that branches on this field must tolerate kinds it does not
|
|
830
|
+
* recognize rather than assume exhaustiveness.
|
|
831
|
+
*/
|
|
832
|
+
readonly kind: MlvEditorAiTransformKind | 'autocomplete';
|
|
833
|
+
/**
|
|
834
|
+
* Free-form argument for the transform: the custom prompt for `'custom'`,
|
|
835
|
+
* the target tone for `'tone'`, or the target language for `'translate'`.
|
|
836
|
+
* Absent for transforms that need no argument.
|
|
837
|
+
*/
|
|
838
|
+
readonly instruction?: string;
|
|
839
|
+
/** Markdown context captured from the editor when the request started. */
|
|
840
|
+
readonly context: {
|
|
841
|
+
/** Selected fragment as Markdown, or `null` when nothing is selected. */
|
|
842
|
+
readonly selection: string | null;
|
|
843
|
+
/** Optional surrounding document window as Markdown, or `null`. */
|
|
844
|
+
readonly document: string | null;
|
|
845
|
+
};
|
|
846
|
+
/**
|
|
847
|
+
* Aborted when the user cancels, presses Escape, or edits the document
|
|
848
|
+
* mid-stream. Providers should stop producing chunks once aborted.
|
|
849
|
+
*/
|
|
850
|
+
readonly signal: AbortSignal;
|
|
851
|
+
/** Host-defined passthrough metadata; the editor never reads it. */
|
|
852
|
+
readonly meta?: Record<string, unknown>;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Host-supplied transport for AI transforms.
|
|
856
|
+
*
|
|
857
|
+
* The library performs no network requests itself. Hosts provide an
|
|
858
|
+
* implementation through the `aiProvider` input on `mlv-editor` or the
|
|
859
|
+
* `MLV_EDITOR_AI_PROVIDER` injection token; the input wins, mirroring the
|
|
860
|
+
* image-uploader precedence rule.
|
|
861
|
+
*/
|
|
862
|
+
interface MlvEditorAiProvider {
|
|
863
|
+
/**
|
|
864
|
+
* Streams the result of one request as plain Markdown/text chunks.
|
|
865
|
+
*
|
|
866
|
+
* Non-streaming transports may return a single-chunk iterable. A thrown
|
|
867
|
+
* error or rejected iteration surfaces as a recoverable `'ai-transport'`
|
|
868
|
+
* editor error; unusable output surfaces as `'ai-result'`.
|
|
869
|
+
*
|
|
870
|
+
* @param request Structured transform or autocomplete request.
|
|
871
|
+
* @returns Async iterable of Markdown/text chunks in document order.
|
|
872
|
+
*/
|
|
873
|
+
stream(request: MlvEditorAiRequest): AsyncIterable<string>;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Builds the seven built-in AI menu actions, labelled from the supplied
|
|
878
|
+
* editor copy.
|
|
879
|
+
*
|
|
880
|
+
* This is the exact list `MlvEditorAiMenu` renders when its `actions` input is
|
|
881
|
+
* omitted, so a host that wants to *extend* rather than replace the built-ins
|
|
882
|
+
* spreads the result instead of retyping it:
|
|
883
|
+
*
|
|
884
|
+
* ```ts
|
|
885
|
+
* private readonly _copy = inject(MLV_EDITOR_I18N, { optional: true });
|
|
886
|
+
*
|
|
887
|
+
* readonly actions = computed<readonly MlvEditorAiAction[]>(() => [
|
|
888
|
+
* ...mlvEditorAiDefaultActions(this._copy?.()),
|
|
889
|
+
* { kind: 'legal-review', label: 'Legal review', output: 'review' },
|
|
890
|
+
* ]);
|
|
891
|
+
* ```
|
|
892
|
+
*
|
|
893
|
+
* The custom-prompt entry is not part of this list: the menu renders it
|
|
894
|
+
* separately and it is dropped with `showCustomPrompt="false"`.
|
|
895
|
+
*
|
|
896
|
+
* @param copy Resolved editor copy, typically `inject(MLV_EDITOR_I18N)()`.
|
|
897
|
+
* `null`/`undefined`, or any missing key, falls back to the English label.
|
|
898
|
+
* @returns A fresh array of the seven built-in actions, in menu order.
|
|
899
|
+
*/
|
|
900
|
+
declare function mlvEditorAiDefaultActions(copy: MlvEditorI18n | null | undefined): readonly MlvEditorAiAction[];
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Toolbar command group for the editor's AI transforms.
|
|
904
|
+
*
|
|
905
|
+
* A sparkles trigger opens a Malva menu with one item per action; an action
|
|
906
|
+
* runs its kind through the context with `output: 'replace-selection'` unless
|
|
907
|
+
* it says otherwise, while the custom-prompt item opens a Malva popup with an
|
|
908
|
+
* instruction field and an output-mode choice (replace selection, insert
|
|
909
|
+
* below, or land as reviewable suggestions). While a transform is running the
|
|
910
|
+
* same trigger becomes a stop affordance that cancels the in-flight request,
|
|
911
|
+
* so the control stays one roving tab stop throughout.
|
|
912
|
+
*
|
|
913
|
+
* The action list is a thin layer over {@link MlvEditorAiContext.runTransform}:
|
|
914
|
+
* the seven built-in kinds are only the default. `actions` replaces them
|
|
915
|
+
* literally with a host-authored list — any kind string, a fixed instruction,
|
|
916
|
+
* a per-action output mode, or an own `run` callback — and
|
|
917
|
+
* `showCustomPrompt="false"` drops the custom-prompt item and its popup.
|
|
918
|
+
*
|
|
919
|
+
* The group hides entirely when the nearest {@link MLV_EDITOR_AI_CONTEXT}
|
|
920
|
+
* resolves no provider (presence), and its actions disable — without hiding —
|
|
921
|
+
* while the editor is readonly or disabled or a transform is already running
|
|
922
|
+
* (executability), matching the toolbar's presence-vs-executability rule.
|
|
923
|
+
*/
|
|
924
|
+
declare class MlvEditorAiMenu {
|
|
925
|
+
/**
|
|
926
|
+
* The menu's action list, replacing the built-in kinds literally — the
|
|
927
|
+
* house rule for list-shaped inputs (`extensions`, the toolbar definitions):
|
|
928
|
+
* a supplied array is never merged with the defaults.
|
|
929
|
+
*
|
|
930
|
+
* Omitted (the default), the menu renders the seven built-in transforms
|
|
931
|
+
* labelled from `MLV_EDITOR_I18N`. To keep them and add to them, spread
|
|
932
|
+
* `mlvEditorAiDefaultActions(copy)` — the very list this component uses.
|
|
933
|
+
* The custom-prompt item is independent of this input; drop it with
|
|
934
|
+
* {@link showCustomPrompt}.
|
|
935
|
+
*/
|
|
936
|
+
readonly actions: _angular_core.InputSignal<readonly MlvEditorAiAction[] | undefined>;
|
|
937
|
+
/**
|
|
938
|
+
* Whether the built-in custom-prompt item and its popup exist at all.
|
|
939
|
+
*
|
|
940
|
+
* `false` removes the menu item and never renders the prompt popup, for
|
|
941
|
+
* hosts whose action list already covers everything they want offered.
|
|
942
|
+
*/
|
|
943
|
+
readonly showCustomPrompt: _angular_core.InputSignalWithTransform<BooleanInput, string | boolean>;
|
|
944
|
+
/** @protected AI command state of the nearest editor, if provided. */
|
|
945
|
+
protected readonly _ai: _malva_ui_editor.MlvEditorAiContext | null;
|
|
946
|
+
/** @protected Editor-scoped form state gating executability. */
|
|
947
|
+
protected readonly _context: _malva_ui_editor.MlvEditorToolbarContext;
|
|
948
|
+
/** @private Detached panel ownership for composite focus. */
|
|
949
|
+
private readonly _overlays;
|
|
950
|
+
/** @private Document used to resolve the public menu panel id. */
|
|
951
|
+
private readonly _document;
|
|
952
|
+
/** @private Cleans an active menu-overlay registration. */
|
|
953
|
+
private readonly _destroyRef;
|
|
954
|
+
/** @private Optional localized editor copy. */
|
|
955
|
+
private readonly _i18n;
|
|
956
|
+
/** @protected Rendered Malva transforms menu. */
|
|
957
|
+
protected readonly _menu: Signal<MlvMenu<_malva_ui_core_menu.MlvMenuItemData<unknown>>>;
|
|
958
|
+
/** @protected Trigger owning the menu overlay. */
|
|
959
|
+
protected readonly _menuTrigger: Signal<MlvMenuTrigger>;
|
|
960
|
+
/**
|
|
961
|
+
* @protected Custom-prompt popup opened programmatically. Optional because
|
|
962
|
+
* `showCustomPrompt="false"` removes it from the template entirely.
|
|
963
|
+
*/
|
|
964
|
+
protected readonly _popup: Signal<MlvPopup | undefined>;
|
|
965
|
+
/** @protected Native trigger restored after popup teardown. */
|
|
966
|
+
protected readonly _triggerElement: Signal<ElementRef<HTMLButtonElement>>;
|
|
967
|
+
/** @protected Instruction field focused when the prompt opens. */
|
|
968
|
+
protected readonly _instructionInput: Signal<MlvInput>;
|
|
969
|
+
/** @private Detached prompt panel queried through Angular rather than selectors. */
|
|
970
|
+
private readonly _panel;
|
|
971
|
+
/** @protected Custom-prompt instruction draft, retained across opens. */
|
|
972
|
+
protected readonly _instruction: _angular_core.WritableSignal<string>;
|
|
973
|
+
/** @protected Output mode applied to the custom transform. */
|
|
974
|
+
protected readonly _output: _angular_core.WritableSignal<MlvEditorAiOutputMode>;
|
|
975
|
+
/** @private Menu-overlay registration teardown. */
|
|
976
|
+
private _unregisterMenu;
|
|
977
|
+
/** @private Guards queued menu registration after a quick close or destroy. */
|
|
978
|
+
private _menuOpen;
|
|
979
|
+
/**
|
|
980
|
+
* @protected Action entries rendered before the custom-prompt item: the
|
|
981
|
+
* host's list when supplied, otherwise the localized built-ins. The factory
|
|
982
|
+
* is the single source of the built-in label table.
|
|
983
|
+
*/
|
|
984
|
+
protected readonly _actions: Signal<readonly MlvEditorAiAction[]>;
|
|
985
|
+
/** @protected Reactive localized copy for the trigger and prompt. */
|
|
986
|
+
protected readonly _copy: Signal<{
|
|
987
|
+
aiMenu: string;
|
|
988
|
+
aiCustom: string;
|
|
989
|
+
aiPromptPlaceholder: string;
|
|
990
|
+
aiOutputMode: string;
|
|
991
|
+
aiReplaceSelection: string;
|
|
992
|
+
aiInsertBelow: string;
|
|
993
|
+
aiReviewChanges: string;
|
|
994
|
+
aiApply: string;
|
|
995
|
+
aiCancel: string;
|
|
996
|
+
}>;
|
|
997
|
+
/** @protected Whether an AI provider is resolvable; the group hides without one. */
|
|
998
|
+
protected readonly _hasProvider: Signal<boolean>;
|
|
999
|
+
/** @protected Whether a transform is streaming, swapping the trigger to stop. */
|
|
1000
|
+
protected readonly _running: Signal<boolean>;
|
|
1001
|
+
/** @protected Whether readonly/disabled state blocks every AI mutation. */
|
|
1002
|
+
protected readonly _disabled: Signal<boolean>;
|
|
1003
|
+
/** @protected Whether menu items cannot currently start a transform. */
|
|
1004
|
+
protected readonly _itemsDisabled: Signal<boolean>;
|
|
1005
|
+
/** @protected Whether the apply action cannot submit the custom prompt. */
|
|
1006
|
+
protected readonly _applyDisabled: Signal<boolean>;
|
|
1007
|
+
constructor();
|
|
1008
|
+
/** @protected Stops the running transform; the menu trigger opens otherwise. */
|
|
1009
|
+
protected _onTriggerClick(): void;
|
|
1010
|
+
/**
|
|
1011
|
+
* @protected Runs one action: its own `run` callback when it has one,
|
|
1012
|
+
* otherwise its kind through the context with the action's instruction and
|
|
1013
|
+
* output mode. The executability guard is re-checked here so a host `run`
|
|
1014
|
+
* callback cannot fire on a readonly, disabled, or busy editor either.
|
|
1015
|
+
*/
|
|
1016
|
+
protected _runAction(action: MlvEditorAiAction): void;
|
|
1017
|
+
/** @protected Opens the custom-prompt popup from its menu item. */
|
|
1018
|
+
protected _openPrompt(): void;
|
|
1019
|
+
/** @protected Closes the custom-prompt popup without running a transform. */
|
|
1020
|
+
protected _closePrompt(): void;
|
|
1021
|
+
/** @protected Runs the custom transform with the drafted instruction and mode. */
|
|
1022
|
+
protected _apply(): void;
|
|
1023
|
+
/** @protected Focuses and selects the instruction draft once the prompt opens. */
|
|
1024
|
+
protected _onPromptOpened(): void;
|
|
1025
|
+
/** @protected Restores the connected toolbar trigger after final teardown. */
|
|
1026
|
+
protected _onPromptClosed(): void;
|
|
1027
|
+
/** @protected Narrows the radio group's untyped value to an output mode. */
|
|
1028
|
+
protected _onOutputChange(value: unknown): void;
|
|
1029
|
+
/** @protected Registers the portaled menu panel with the editor composite. */
|
|
1030
|
+
protected _registerMenuOverlay(): void;
|
|
1031
|
+
/** @protected Removes menu panel focus ownership after close. */
|
|
1032
|
+
protected _unregisterMenuOverlay(): void;
|
|
1033
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorAiMenu, never>;
|
|
1034
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorAiMenu, "mlv-editor-ai-menu", never, { "actions": { "alias": "actions"; "required": false; "isSignal": true; }; "showCustomPrompt": { "alias": "showCustomPrompt"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* Review surface for pending AI suggestions.
|
|
1039
|
+
*
|
|
1040
|
+
* Rendered inside the editor composite — hosts project it into the status
|
|
1041
|
+
* region (`<mlv-editor-ai-review-bar mlvEditorStatus />`), following the
|
|
1042
|
+
* `MlvEditorStatus` placement. Hidden while the nearest
|
|
1043
|
+
* {@link MLV_EDITOR_AI_CONTEXT} is `'idle'` (or absent); while `'running'` it
|
|
1044
|
+
* shows a stop affordance that cancels the in-flight request, and while
|
|
1045
|
+
* `'reviewing'` it shows the pending-suggestion count, previous/next
|
|
1046
|
+
* navigation, accept/reject for the current suggestion, and accept-all/
|
|
1047
|
+
* reject-all.
|
|
1048
|
+
*
|
|
1049
|
+
* Navigation keeps an internal cursor over the context's suggestion list;
|
|
1050
|
+
* moving it outlines the current suggestion in the document
|
|
1051
|
+
* (`MLV_EDITOR_AI_SUGGESTION_CURRENT_CLASS` decoration) and scrolls its range
|
|
1052
|
+
* into view through {@link MlvEditorAiContext.revealSuggestion}. Accepting or
|
|
1053
|
+
* rejecting the current suggestion advances to the next remaining one (the
|
|
1054
|
+
* list shrinks under a clamped cursor); when the set empties the context
|
|
1055
|
+
* returns to `'idle'` and the bar disappears.
|
|
1056
|
+
*
|
|
1057
|
+
* Announcement choice: the count region is deliberately **not** an
|
|
1058
|
+
* `aria-live` region. The AI context already announces the review lifecycle —
|
|
1059
|
+
* `aiReviewStarted` with the count, and every accept/reject outcome — through
|
|
1060
|
+
* the CDK `LiveAnnouncer`; a live count would double-announce each change.
|
|
1061
|
+
*
|
|
1062
|
+
* The host element registers with the editor's composite-overlay registry, so
|
|
1063
|
+
* interacting with the bar never emits a false editor blur wherever a host
|
|
1064
|
+
* renders it. All controls are plain tab stops inside the composite. Accept,
|
|
1065
|
+
* reject, and navigation disable while the editor is readonly or disabled
|
|
1066
|
+
* (mutations are refused by the context anyway; the disabled state makes the
|
|
1067
|
+
* refusal visible), and the whole bar disables with the editor.
|
|
1068
|
+
*/
|
|
1069
|
+
declare class MlvEditorAiReviewBar {
|
|
1070
|
+
/** @protected AI command state of the nearest editor, if provided. */
|
|
1071
|
+
protected readonly _ai: _malva_ui_editor.MlvEditorAiContext | null;
|
|
1072
|
+
/** @protected Editor-scoped form state gating executability. */
|
|
1073
|
+
protected readonly _context: _malva_ui_editor.MlvEditorToolbarContext;
|
|
1074
|
+
/** @private Composite focus ownership for the bar's host element. */
|
|
1075
|
+
private readonly _overlays;
|
|
1076
|
+
/** @private Host element registered with the composite-overlay registry. */
|
|
1077
|
+
private readonly _host;
|
|
1078
|
+
/** @private Clears the current-suggestion outline on teardown. */
|
|
1079
|
+
private readonly _destroyRef;
|
|
1080
|
+
/** @private Optional localized editor copy. */
|
|
1081
|
+
private readonly _i18n;
|
|
1082
|
+
/** @private Resolves the ICU pending-count template. */
|
|
1083
|
+
private readonly _resolver;
|
|
1084
|
+
/**
|
|
1085
|
+
* @private Navigation cursor over the suggestion list. Reset for every new
|
|
1086
|
+
* review; reads clamp through {@link _index}, so a cursor left beyond the
|
|
1087
|
+
* end after the list shrinks points at the last remaining suggestion.
|
|
1088
|
+
*/
|
|
1089
|
+
private readonly _cursor;
|
|
1090
|
+
/** @protected Reactive localized copy for every control and the count. */
|
|
1091
|
+
protected readonly _copy: _angular_core.Signal<{
|
|
1092
|
+
aiReviewBar: string;
|
|
1093
|
+
aiReviewCount: string;
|
|
1094
|
+
aiPreviousSuggestion: string;
|
|
1095
|
+
aiNextSuggestion: string;
|
|
1096
|
+
aiAcceptSuggestion: string;
|
|
1097
|
+
aiRejectSuggestion: string;
|
|
1098
|
+
aiAcceptAll: string;
|
|
1099
|
+
aiRejectAll: string;
|
|
1100
|
+
aiStopGeneration: string;
|
|
1101
|
+
}>;
|
|
1102
|
+
/** @protected Whether a transform is streaming, showing the stop affordance. */
|
|
1103
|
+
protected readonly _running: _angular_core.Signal<boolean>;
|
|
1104
|
+
/** @protected Whether a review with pending suggestions is active. */
|
|
1105
|
+
protected readonly _reviewing: _angular_core.Signal<boolean>;
|
|
1106
|
+
/** @protected The bar renders only while AI work is running or under review. */
|
|
1107
|
+
protected readonly _visible: _angular_core.Signal<boolean>;
|
|
1108
|
+
/** @protected Whether readonly/disabled state blocks every AI action. */
|
|
1109
|
+
protected readonly _disabled: _angular_core.Signal<boolean>;
|
|
1110
|
+
/** @protected Pending suggestions mirrored from the AI context. */
|
|
1111
|
+
protected readonly _suggestions: _angular_core.Signal<readonly _malva_ui_editor.MlvEditorAiReviewSuggestion[]>;
|
|
1112
|
+
/** @protected Pending-suggestion count shown in the bar. */
|
|
1113
|
+
protected readonly _count: _angular_core.Signal<number>;
|
|
1114
|
+
/** @protected Clamped cursor index of the current suggestion. */
|
|
1115
|
+
protected readonly _index: _angular_core.Signal<number>;
|
|
1116
|
+
/** @private Identifier of the current suggestion, if any is pending. */
|
|
1117
|
+
private readonly _currentId;
|
|
1118
|
+
/**
|
|
1119
|
+
* @protected Id of the visually hidden current-suggestion description
|
|
1120
|
+
* element the accept/reject buttons reference through `aria-describedby`.
|
|
1121
|
+
* Unique per bar instance so multiple editors on one page cannot collide.
|
|
1122
|
+
*/
|
|
1123
|
+
protected readonly _descriptionId: string;
|
|
1124
|
+
/**
|
|
1125
|
+
* @protected Non-visual description of the current suggestion — index,
|
|
1126
|
+
* count, and the removed/added text — from
|
|
1127
|
+
* {@link MlvEditorAiContext.describeSuggestion}. The removed text otherwise
|
|
1128
|
+
* exists only inside the `aria-hidden` strikethrough widget, so this is
|
|
1129
|
+
* what makes the accept/reject decision inspectable without sight.
|
|
1130
|
+
*/
|
|
1131
|
+
protected readonly _currentDescription: _angular_core.Signal<string>;
|
|
1132
|
+
/** @protected Localized pending count resolved through the ICU template. */
|
|
1133
|
+
protected readonly _countText: _angular_core.Signal<string>;
|
|
1134
|
+
constructor();
|
|
1135
|
+
/** @protected Cancels the in-flight AI request from the stop affordance. */
|
|
1136
|
+
protected _stop(): void;
|
|
1137
|
+
/** @protected Moves the cursor to the previous suggestion, wrapping at the start. */
|
|
1138
|
+
protected _previous(): void;
|
|
1139
|
+
/** @protected Moves the cursor to the next suggestion, wrapping at the end. */
|
|
1140
|
+
protected _next(): void;
|
|
1141
|
+
/** @protected Accepts the current suggestion; the clamped cursor advances. */
|
|
1142
|
+
protected _acceptCurrent(): void;
|
|
1143
|
+
/** @protected Rejects the current suggestion; the clamped cursor advances. */
|
|
1144
|
+
protected _rejectCurrent(): void;
|
|
1145
|
+
/** @protected Accepts every pending suggestion. */
|
|
1146
|
+
protected _acceptAll(): void;
|
|
1147
|
+
/** @protected Rejects every pending suggestion. */
|
|
1148
|
+
protected _rejectAll(): void;
|
|
1149
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorAiReviewBar, never>;
|
|
1150
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorAiReviewBar, "mlv-editor-ai-review-bar", never, {}, {}, never, never, true, never>;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* CSS class of the inline decoration marking the active streaming region.
|
|
1155
|
+
*
|
|
1156
|
+
* The class is applied through a ProseMirror decoration held in plugin state,
|
|
1157
|
+
* never through document content, so it can appear in no HTML, Markdown, or
|
|
1158
|
+
* JSON serialization.
|
|
1159
|
+
*/
|
|
1160
|
+
declare const MLV_EDITOR_AI_STREAMING_CLASS = "mlv-editor__ai-streaming";
|
|
1161
|
+
/**
|
|
1162
|
+
* CSS class of the one-shot inline decoration over each flush's newly
|
|
1163
|
+
* revealed slice of the streaming region.
|
|
1164
|
+
*
|
|
1165
|
+
* Created exactly once per revealed delta and only mapped afterwards — never
|
|
1166
|
+
* rebuilt for old ranges — so a one-shot CSS entrance animation runs once per
|
|
1167
|
+
* chunk and earlier text never re-animates. Removed with the region
|
|
1168
|
+
* decoration on commit, cancel, and abandonment, and excluded from every
|
|
1169
|
+
* serialization the same way.
|
|
1170
|
+
*/
|
|
1171
|
+
declare const MLV_EDITOR_AI_STREAMING_CHUNK_CLASS = "mlv-editor__ai-streaming-chunk";
|
|
1172
|
+
/**
|
|
1173
|
+
* CSS class of the `aria-hidden` widget decoration the streaming engine
|
|
1174
|
+
* keeps at the current insertion tip while a writing session is active.
|
|
1175
|
+
*
|
|
1176
|
+
* View-layer only: it exists in no HTML, Markdown, or JSON serialization and
|
|
1177
|
+
* is removed when the session settles (commit, cancel, abandonment, failure).
|
|
1178
|
+
* Collect-only `'review'` sessions never render it — they never write.
|
|
1179
|
+
*/
|
|
1180
|
+
declare const MLV_EDITOR_AI_CARET_CLASS = "mlv-editor__ai-caret";
|
|
1181
|
+
/**
|
|
1182
|
+
* Output modes a streaming session supports.
|
|
1183
|
+
*
|
|
1184
|
+
* `'replace-selection'` and `'insert-below'` write into the document while
|
|
1185
|
+
* streaming. `'review'` is collect-only: the session runs the full lifecycle
|
|
1186
|
+
* — Escape cancellation, external-transaction abandonment, transport/result
|
|
1187
|
+
* error detection — but never writes; the caller routes the accumulated text
|
|
1188
|
+
* through the suggestion engine after commit.
|
|
1189
|
+
*/
|
|
1190
|
+
type MlvEditorAiStreamOutputMode = MlvEditorAiOutputMode;
|
|
1191
|
+
/**
|
|
1192
|
+
* Error categories a streaming session can report.
|
|
1193
|
+
*
|
|
1194
|
+
* `'ai-transport'` — the chunk iterable threw or rejected mid-stream.
|
|
1195
|
+
* `'ai-result'` — the completed stream produced no usable content (empty or
|
|
1196
|
+
* whitespace-only total output), or the target region rejected the write.
|
|
1197
|
+
* Both are narrowed from {@link MlvEditorErrorCode} so hosts can forward them
|
|
1198
|
+
* to `editorError` unchanged.
|
|
1199
|
+
*/
|
|
1200
|
+
type MlvEditorAiStreamErrorCode = Extract<MlvEditorErrorCode, 'ai-transport' | 'ai-result'>;
|
|
1201
|
+
/**
|
|
1202
|
+
* Terminal state of one streaming session.
|
|
1203
|
+
*
|
|
1204
|
+
* `'committed'` — the stream completed and the final content landed as exactly
|
|
1205
|
+
* one history-visible step. `'cancelled'` — {@link MlvEditorAiStreamHandle.cancel}
|
|
1206
|
+
* aborted the session and the checkpoint was restored silently. `'abandoned'`
|
|
1207
|
+
* — an external document change ended the session without any restore.
|
|
1208
|
+
* `'failed'` — the session ended with an {@link MlvEditorAiStreamErrorCode}
|
|
1209
|
+
* and the checkpoint was restored.
|
|
1210
|
+
*/
|
|
1211
|
+
type MlvEditorAiStreamStatus = 'committed' | 'cancelled' | 'abandoned' | 'failed';
|
|
1212
|
+
/**
|
|
1213
|
+
* Schedules one buffered-chunk flush for the next animation frame.
|
|
1214
|
+
*
|
|
1215
|
+
* Receives the flush callback and returns a cancel function. The default
|
|
1216
|
+
* implementation uses `requestAnimationFrame` and falls back to a short
|
|
1217
|
+
* `setTimeout` where no frame API exists (server rendering, test DOMs).
|
|
1218
|
+
* Tests inject a manual scheduler to control flush timing deterministically.
|
|
1219
|
+
*/
|
|
1220
|
+
type MlvEditorAiFrameScheduler = (flush: () => void) => () => void;
|
|
1221
|
+
/** Options accepted by {@link runMlvEditorAiStream}. */
|
|
1222
|
+
interface MlvEditorAiStreamOptions {
|
|
1223
|
+
/**
|
|
1224
|
+
* Markdown/text chunks in document order, typically produced by an
|
|
1225
|
+
* `MlvEditorAiProvider`. A non-streaming source may yield a single chunk.
|
|
1226
|
+
*/
|
|
1227
|
+
readonly chunks: AsyncIterable<string>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Where the streamed content lands: `'replace-selection'` replaces the
|
|
1230
|
+
* selection captured when the session started, `'insert-below'` streams
|
|
1231
|
+
* into a new paragraph after the selection's top-level block, and
|
|
1232
|
+
* `'review'` collects the complete stream without touching the document —
|
|
1233
|
+
* the result is read from {@link MlvEditorAiStreamResult.text}.
|
|
1234
|
+
*/
|
|
1235
|
+
readonly output: MlvEditorAiStreamOutputMode;
|
|
1236
|
+
/** Frame scheduler override; defaults to `requestAnimationFrame`. */
|
|
1237
|
+
readonly scheduler?: MlvEditorAiFrameScheduler;
|
|
1238
|
+
/**
|
|
1239
|
+
* Maximum characters one frame flush reveals into the document. Buffered
|
|
1240
|
+
* text beyond the cap carries over: the session keeps scheduling follow-up
|
|
1241
|
+
* frames until the buffer drains, so bursty provider chunks render at an
|
|
1242
|
+
* even typing cadence instead of appearing in per-chunk lumps. Defaults to
|
|
1243
|
+
* 4; `Infinity` restores the uncapped write-everything-per-frame behavior.
|
|
1244
|
+
* Non-finite values other than `Infinity` and values below 1 fall back to
|
|
1245
|
+
* the default; fractions are floored. The cap never delays settlement —
|
|
1246
|
+
* commit, cancellation, and abandonment still apply the complete
|
|
1247
|
+
* accumulated text immediately. Collect-only `'review'` sessions ignore it
|
|
1248
|
+
* entirely (they never flush).
|
|
1249
|
+
*/
|
|
1250
|
+
readonly revealCharsPerFrame?: number;
|
|
1251
|
+
}
|
|
1252
|
+
/** Terminal result every streaming session resolves with; it never rejects. */
|
|
1253
|
+
interface MlvEditorAiStreamResult {
|
|
1254
|
+
/** Terminal state of the session. */
|
|
1255
|
+
readonly status: MlvEditorAiStreamStatus;
|
|
1256
|
+
/** Error category for `'failed'` sessions, `null` for every other status. */
|
|
1257
|
+
readonly error: MlvEditorAiStreamErrorCode | null;
|
|
1258
|
+
/**
|
|
1259
|
+
* Whether the session was stopped before completing: `true` for
|
|
1260
|
+
* `'cancelled'` and `'abandoned'`, `false` for `'committed'` and
|
|
1261
|
+
* `'failed'`. Cancellation and abandonment are silent — neither carries an
|
|
1262
|
+
* error code.
|
|
1263
|
+
*/
|
|
1264
|
+
readonly aborted: boolean;
|
|
1265
|
+
/** Complete text accumulated from the stream, including unwritten chunks. */
|
|
1266
|
+
readonly text: string;
|
|
1267
|
+
}
|
|
1268
|
+
/** Handle controlling one in-flight or finished streaming session. */
|
|
1269
|
+
interface MlvEditorAiStreamHandle {
|
|
1270
|
+
/** Resolves with the terminal {@link MlvEditorAiStreamResult}; never rejects. */
|
|
1271
|
+
readonly done: Promise<MlvEditorAiStreamResult>;
|
|
1272
|
+
/**
|
|
1273
|
+
* Aborts an in-flight session: stops consuming chunks, restores the
|
|
1274
|
+
* checkpoint through a history-invisible step, and resolves {@link done}
|
|
1275
|
+
* with `'cancelled'` and no error. A no-op once the session has settled.
|
|
1276
|
+
*/
|
|
1277
|
+
cancel(): void;
|
|
1278
|
+
/**
|
|
1279
|
+
* Restores the checkpoint captured when the session started.
|
|
1280
|
+
*
|
|
1281
|
+
* While the session is running this behaves exactly like {@link cancel}.
|
|
1282
|
+
* After the session has settled it replaces the whole document with the
|
|
1283
|
+
* checkpoint in one history-visible step — so a post-commit restore is
|
|
1284
|
+
* itself undoable. Returns whether the document changed; `false` when the
|
|
1285
|
+
* document already matches the checkpoint or the editor was destroyed.
|
|
1286
|
+
* After an `'abandoned'` session this overwrites the external edit too —
|
|
1287
|
+
* callers own that decision.
|
|
1288
|
+
*/
|
|
1289
|
+
restoreCheckpoint(): boolean;
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Runs one AI streaming session against a live Tiptap editor.
|
|
1293
|
+
*
|
|
1294
|
+
* Framework-free: the runner needs only the editor instance and an async
|
|
1295
|
+
* iterable of Markdown/text chunks — no Angular, no provider token, no
|
|
1296
|
+
* network. Interim writes render the chunks as plain text inside the target
|
|
1297
|
+
* region; the final commit parses the accumulated Markdown through the
|
|
1298
|
+
* editor's Markdown manager, so the committed document carries real
|
|
1299
|
+
* structure rather than literal Markdown syntax. An editor without a
|
|
1300
|
+
* Markdown manager commits plain text — the same fallback the Angular
|
|
1301
|
+
* context uses for request serialization. The `'review'` output mode is
|
|
1302
|
+
* collect-only: no interim write, no decoration, and no final commit ever
|
|
1303
|
+
* touches the document — a `'committed'` result just carries the complete
|
|
1304
|
+
* text for the caller to route through the suggestion engine. Every other
|
|
1305
|
+
* lifecycle rule below (Escape, cancellation, abandonment, transport and
|
|
1306
|
+
* result errors) applies to it unchanged.
|
|
1307
|
+
*
|
|
1308
|
+
* Lifecycle:
|
|
1309
|
+
*
|
|
1310
|
+
* - A checkpoint (document JSON) and the target coordinates are captured when
|
|
1311
|
+
* the session starts, before the first mutating step.
|
|
1312
|
+
* - Chunks are buffered and written at most once per animation frame, and
|
|
1313
|
+
* each flush reveals at most {@link MlvEditorAiStreamOptions.revealCharsPerFrame}
|
|
1314
|
+
* characters — the remainder carries over to self-scheduled follow-up
|
|
1315
|
+
* frames, smoothing bursty providers into a steady typing cadence. Every
|
|
1316
|
+
* interim write dispatches with `addToHistory: false`, so no partial state
|
|
1317
|
+
* ever becomes an undo step.
|
|
1318
|
+
* - Each flush's newly revealed slice carries a one-shot
|
|
1319
|
+
* {@link MLV_EDITOR_AI_STREAMING_CHUNK_CLASS} entrance decoration (created
|
|
1320
|
+
* once, then only mapped), and an `aria-hidden`
|
|
1321
|
+
* {@link MLV_EDITOR_AI_CARET_CLASS} widget marks the insertion tip while
|
|
1322
|
+
* the session writes. Both are view-layer decorations: removed when the
|
|
1323
|
+
* session settles and excluded from every serialization, exactly like the
|
|
1324
|
+
* region tint.
|
|
1325
|
+
* - On successful completion the session silently reverts to the checkpoint
|
|
1326
|
+
* and commits the complete content as exactly one history-visible step
|
|
1327
|
+
* (closed against the previous history group): one undo restores the
|
|
1328
|
+
* pre-session document.
|
|
1329
|
+
* - {@link MlvEditorAiStreamHandle.cancel} restores the checkpoint and
|
|
1330
|
+
* resolves with `'cancelled'` — silently, with no error code. Pressing
|
|
1331
|
+
* Escape inside the content region triggers the same cancellation through
|
|
1332
|
+
* the session plugin's key handler.
|
|
1333
|
+
* - A thrown or rejected chunk iteration restores the checkpoint and resolves
|
|
1334
|
+
* `'failed'` with `'ai-transport'`. Empty or whitespace-only total output
|
|
1335
|
+
* restores the checkpoint and resolves `'failed'` with `'ai-result'`.
|
|
1336
|
+
* - **Abandonment**: any external transaction — one whose root carries no
|
|
1337
|
+
* session metadata but changes the document (directly or through appended
|
|
1338
|
+
* transactions) — ends the session immediately following the drag-lifecycle
|
|
1339
|
+
* precedent. The session stops consuming and writing, removes its
|
|
1340
|
+
* decoration, and resolves `'abandoned'` with `error: null` and
|
|
1341
|
+
* `aborted: true`. **Nothing is restored**: inverting the checkpoint
|
|
1342
|
+
* through foreign steps is unsafe, so the document is left exactly as the
|
|
1343
|
+
* external edit made it, including any interim session writes (which were
|
|
1344
|
+
* history-invisible and therefore cannot be undone individually).
|
|
1345
|
+
* - Destroying the editor mid-session settles it as `'abandoned'` without
|
|
1346
|
+
* touching the DOM.
|
|
1347
|
+
*
|
|
1348
|
+
* The session never throws and {@link MlvEditorAiStreamHandle.done} never
|
|
1349
|
+
* rejects. Starting a new session on an editor cancels the session already
|
|
1350
|
+
* running there.
|
|
1351
|
+
*
|
|
1352
|
+
* @param editor Live Tiptap editor the session writes into.
|
|
1353
|
+
* @param options Chunk source, output mode, and optional frame scheduler.
|
|
1354
|
+
* @returns Handle exposing completion, cancellation, and checkpoint restore.
|
|
1355
|
+
*/
|
|
1356
|
+
/**
|
|
1357
|
+
* Document region a replacing AI transform writes over.
|
|
1358
|
+
*
|
|
1359
|
+
* A non-empty selection is the region. A **collapsed** selection means the user
|
|
1360
|
+
* asked for the transform without choosing a target — and the provider was
|
|
1361
|
+
* handed the whole document rather than a region (`context.selection` is `null`
|
|
1362
|
+
* exactly when the selection is empty) — so the result lands over the whole
|
|
1363
|
+
* document body: the first text position through the last, never the raw caret.
|
|
1364
|
+
*
|
|
1365
|
+
* Only replacing outputs (`'replace-selection'` streaming, `'review'` applying
|
|
1366
|
+
* its collected result) resolve through here. `'insert-below'` adds a block
|
|
1367
|
+
* after the caret's own top-level block and is unaffected.
|
|
1368
|
+
*/
|
|
1369
|
+
declare function mlvEditorAiReplaceRange(editor: Editor): {
|
|
1370
|
+
readonly from: number;
|
|
1371
|
+
readonly to: number;
|
|
1372
|
+
};
|
|
1373
|
+
declare function runMlvEditorAiStream(editor: Editor, options: MlvEditorAiStreamOptions): MlvEditorAiStreamHandle;
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* Optional dependency-injection token for a host-provided AI transport.
|
|
1377
|
+
*
|
|
1378
|
+
* The per-editor `aiProvider` input wins over this token, mirroring
|
|
1379
|
+
* `MLV_EDITOR_IMAGE_UPLOADER` precedence. Without either, AI UI modules hide
|
|
1380
|
+
* and AI commands are unavailable.
|
|
1381
|
+
*/
|
|
1382
|
+
declare const MLV_EDITOR_AI_PROVIDER: InjectionToken<MlvEditorAiProvider>;
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* Editor-scoped command state made available to toolbar and projected controls.
|
|
1386
|
+
*
|
|
1387
|
+
* Commands are deliberately supplied as callbacks so Malva does not conceal
|
|
1388
|
+
* Tiptap's API or constrain third-party extensions.
|
|
1389
|
+
*/
|
|
1390
|
+
interface MlvEditorToolbarContext {
|
|
1391
|
+
/** The editor instance owned by the nearest editor shell. */
|
|
1392
|
+
readonly editor: Signal<Editor | null>;
|
|
1393
|
+
/** Whether every interactive command surface is disabled. */
|
|
1394
|
+
readonly disabled: Signal<boolean>;
|
|
1395
|
+
/** Whether document mutation commands are unavailable. */
|
|
1396
|
+
readonly readonly: Signal<boolean>;
|
|
1397
|
+
/** Whether focus is currently inside the editor composite. */
|
|
1398
|
+
readonly focused: Signal<boolean>;
|
|
1399
|
+
/** Whether the owner has an editor and permits document mutation. */
|
|
1400
|
+
readonly editable: Signal<boolean>;
|
|
1401
|
+
/** The current serialization format. */
|
|
1402
|
+
readonly format: Signal<MlvEditorFormat>;
|
|
1403
|
+
/** View-only editor zoom percentage. */
|
|
1404
|
+
readonly zoom: WritableSignal<number>;
|
|
1405
|
+
/** Optional editor-owned image upload capability for standalone toolbars. */
|
|
1406
|
+
readonly imageUpload?: MlvEditorImageUploadControl;
|
|
1407
|
+
/** Runs a mutation command without allowing unavailable commands to throw. */
|
|
1408
|
+
run(command: (editor: Editor) => boolean): boolean;
|
|
1409
|
+
/** Checks a command without allowing unavailable commands to throw. */
|
|
1410
|
+
can(command: (editor: Editor) => boolean): boolean;
|
|
1411
|
+
/** Safely reads a Tiptap active state. */
|
|
1412
|
+
isActive(name: string, attributes?: Record<string, unknown>): boolean;
|
|
1413
|
+
/** Reports a typed recoverable error through the owning editor. */
|
|
1414
|
+
reportError(error: MlvEditorError): void;
|
|
1415
|
+
}
|
|
1416
|
+
/** Injects the command state belonging to the nearest `mlv-editor`. */
|
|
1417
|
+
declare const MLV_EDITOR_TOOLBAR_CONTEXT: InjectionToken<MlvEditorToolbarContext>;
|
|
1418
|
+
|
|
1419
|
+
/** @internal Template context supplied to replaceable toolbar definitions. */
|
|
1420
|
+
interface MlvEditorToolbarTemplateContext {
|
|
1421
|
+
readonly $implicit: MlvEditorToolbarContext;
|
|
1422
|
+
}
|
|
1423
|
+
/** Complete replacement template for an editor's built-in toolbar. */
|
|
1424
|
+
declare class MlvEditorToolbarDef {
|
|
1425
|
+
/** The projected template, whose implicit context is `MlvEditorToolbarContext`. */
|
|
1426
|
+
readonly templateRef: TemplateRef<MlvEditorToolbarTemplateContext> | null;
|
|
1427
|
+
/** Narrows `let-context` to the editor toolbar context. */
|
|
1428
|
+
static ngTemplateContextGuard(_dir: MlvEditorToolbarDef, _context: unknown): _context is MlvEditorToolbarTemplateContext;
|
|
1429
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorToolbarDef, never>;
|
|
1430
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<MlvEditorToolbarDef, "[mlvEditorToolbar]", never, {}, {}, never, never, true, never>;
|
|
1431
|
+
}
|
|
1432
|
+
/** Template rendered before the built-in toolbar groups. */
|
|
1433
|
+
declare class MlvEditorToolbarStartDef {
|
|
1434
|
+
/** The projected template, whose implicit context is `MlvEditorToolbarContext`. */
|
|
1435
|
+
readonly templateRef: TemplateRef<MlvEditorToolbarTemplateContext> | null;
|
|
1436
|
+
/** Narrows `let-context` to the editor toolbar context. */
|
|
1437
|
+
static ngTemplateContextGuard(_dir: MlvEditorToolbarStartDef, _context: unknown): _context is MlvEditorToolbarTemplateContext;
|
|
1438
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorToolbarStartDef, never>;
|
|
1439
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<MlvEditorToolbarStartDef, "[mlvEditorToolbarStart]", never, {}, {}, never, never, true, never>;
|
|
1440
|
+
}
|
|
1441
|
+
/** Template rendered after the built-in toolbar groups. */
|
|
1442
|
+
declare class MlvEditorToolbarEndDef {
|
|
1443
|
+
/** The projected template, whose implicit context is `MlvEditorToolbarContext`. */
|
|
1444
|
+
readonly templateRef: TemplateRef<MlvEditorToolbarTemplateContext> | null;
|
|
1445
|
+
/** Narrows `let-context` to the editor toolbar context. */
|
|
1446
|
+
static ngTemplateContextGuard(_dir: MlvEditorToolbarEndDef, _context: unknown): _context is MlvEditorToolbarTemplateContext;
|
|
1447
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorToolbarEndDef, never>;
|
|
1448
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<MlvEditorToolbarEndDef, "[mlvEditorToolbarEnd]", never, {}, {}, never, never, true, never>;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
/**
|
|
1452
|
+
* Browser-only Tiptap form control with nullable HTML, Markdown, or JSON
|
|
1453
|
+
* values.
|
|
1454
|
+
*
|
|
1455
|
+
* The component is a pure Angular `FormValueControl`; it deliberately does
|
|
1456
|
+
* not implement a `ControlValueAccessor` or provide `NG_VALUE_ACCESSOR`.
|
|
1457
|
+
*/
|
|
1458
|
+
declare class MlvEditor extends MlvSignalFormControlBase<string | null> implements MlvFormControl, AfterViewInit, MlvEditorToolbarContext {
|
|
1459
|
+
/** @private Tiptap instance owned exclusively by this component. */
|
|
1460
|
+
private readonly _editor;
|
|
1461
|
+
/** Nullable editor model used by direct, reactive, template, and signal forms. */
|
|
1462
|
+
readonly value: _angular_core.ModelSignal<string | null>;
|
|
1463
|
+
/** Serialization format for the visual editor. */
|
|
1464
|
+
readonly format: _angular_core.InputSignal<MlvEditorFormat>;
|
|
1465
|
+
/** Width of the centred content column; a gutter is reserved at every value. */
|
|
1466
|
+
readonly contentWidth: _angular_core.InputSignal<MlvEditorContentWidth>;
|
|
1467
|
+
/** Complete Tiptap extension replacement; omit it for Malva's fresh preset. */
|
|
1468
|
+
readonly extensions: _angular_core.InputSignal<Extensions | undefined>;
|
|
1469
|
+
/** Placeholder displayed by the default extension preset. */
|
|
1470
|
+
readonly placeholder: _angular_core.InputSignal<string>;
|
|
1471
|
+
/** Maximum character count for Malva's default extension preset. */
|
|
1472
|
+
readonly characterLimit: _angular_core.InputSignal<number | null>;
|
|
1473
|
+
/** IDREF(s) naming the editable content region. */
|
|
1474
|
+
readonly ariaLabelledBy: _angular_core.InputSignal<string | undefined>;
|
|
1475
|
+
/** IDREF(s) describing the editable content region. */
|
|
1476
|
+
readonly ariaDescribedBy: _angular_core.InputSignal<string | undefined>;
|
|
1477
|
+
/** Per-editor image upload adapter, taking precedence over an injected adapter. */
|
|
1478
|
+
readonly imageUploader: _angular_core.InputSignal<MlvEditorImageUploader | undefined>;
|
|
1479
|
+
/** Image upload restrictions used by the later upload controls. */
|
|
1480
|
+
readonly imageUploadOptions: _angular_core.InputSignal<MlvEditorImageUploadOptions>;
|
|
1481
|
+
/**
|
|
1482
|
+
* Per-editor AI transport, taking precedence over an injected
|
|
1483
|
+
* `MLV_EDITOR_AI_PROVIDER`. Without either, AI UI modules hide and AI
|
|
1484
|
+
* commands report a recoverable `configuration` error.
|
|
1485
|
+
*/
|
|
1486
|
+
readonly aiProvider: _angular_core.InputSignal<MlvEditorAiProvider | undefined>;
|
|
1487
|
+
/** Read-only signal exposing the one Tiptap editor instance after browser mount. */
|
|
1488
|
+
readonly editor: _angular_core.Signal<Editor | null>;
|
|
1489
|
+
/** Exact editor-owned image upload capability forwarded to public toolbars. */
|
|
1490
|
+
get imageUpload(): MlvEditorImageUploadControl;
|
|
1491
|
+
/** View-only zoom percentage shared with the nearest toolbar. */
|
|
1492
|
+
readonly zoom: _angular_core.WritableSignal<number>;
|
|
1493
|
+
/** Whether the mounted editor currently accepts document mutations. */
|
|
1494
|
+
readonly editable: _angular_core.Signal<boolean>;
|
|
1495
|
+
/** Emits after the browser-only Tiptap editor has been created. */
|
|
1496
|
+
readonly editorReady: _angular_core.OutputEmitterRef<Editor>;
|
|
1497
|
+
/** Emits when focus enters the editable Tiptap content. */
|
|
1498
|
+
readonly focus: _angular_core.OutputEmitterRef<MlvEditorFocusEvent>;
|
|
1499
|
+
/** Emits when focus leaves the editor composite. */
|
|
1500
|
+
readonly blur: _angular_core.OutputEmitterRef<MlvEditorFocusEvent>;
|
|
1501
|
+
/** Emits Tiptap selection updates. */
|
|
1502
|
+
readonly selectionChange: _angular_core.OutputEmitterRef<MlvEditorSelectionChange>;
|
|
1503
|
+
/** Emits every Tiptap transaction. */
|
|
1504
|
+
readonly transaction: _angular_core.OutputEmitterRef<MlvEditorTransactionEvent>;
|
|
1505
|
+
/** Emits recoverable construction, parsing, and serialization errors. */
|
|
1506
|
+
readonly editorError: _angular_core.OutputEmitterRef<MlvEditorError>;
|
|
1507
|
+
/** Emits after an image upload succeeds. */
|
|
1508
|
+
readonly imageUploadSuccess: _angular_core.OutputEmitterRef<MlvEditorImageUploadSuccess>;
|
|
1509
|
+
/** Emits after an image upload fails. */
|
|
1510
|
+
readonly imageUploadFailure: _angular_core.OutputEmitterRef<MlvEditorImageUploadFailure>;
|
|
1511
|
+
/** Emits after an image upload is cancelled. */
|
|
1512
|
+
readonly imageUploadCancelled: _angular_core.OutputEmitterRef<MlvEditorImageUploadCancelled>;
|
|
1513
|
+
/** Whether the nullable model contains meaningful serialized content. */
|
|
1514
|
+
readonly hasValue: _angular_core.Signal<boolean>;
|
|
1515
|
+
/** @private Browser-only mount element for Tiptap's ProseMirror DOM. */
|
|
1516
|
+
private readonly _content;
|
|
1517
|
+
/**
|
|
1518
|
+
* @private Zoom-transformed layer the floating block handle is mounted into.
|
|
1519
|
+
*
|
|
1520
|
+
* Deliberately optional rather than `viewChild.required`: the block-handle
|
|
1521
|
+
* `mount` capability is typed `() => HTMLElement | null`, and the extension
|
|
1522
|
+
* may call it from a ProseMirror plugin view during a user interaction. A
|
|
1523
|
+
* required query throws `NG0951` while unresolved, which would surface as an
|
|
1524
|
+
* uncaught error rather than the absent mount the contract already allows.
|
|
1525
|
+
*/
|
|
1526
|
+
private readonly _view;
|
|
1527
|
+
/** @protected Complete projected toolbar replacement, if the consumer provides one. */
|
|
1528
|
+
protected readonly _toolbarDefs: _angular_core.Signal<readonly MlvEditorToolbarDef[]>;
|
|
1529
|
+
/** @protected Projected controls displayed before the built-in toolbar groups. */
|
|
1530
|
+
protected readonly _toolbarStartDefs: _angular_core.Signal<readonly MlvEditorToolbarStartDef[]>;
|
|
1531
|
+
/** @protected Projected controls displayed after the built-in toolbar groups. */
|
|
1532
|
+
protected readonly _toolbarEndDefs: _angular_core.Signal<readonly MlvEditorToolbarEndDef[]>;
|
|
1533
|
+
/** @protected Whether a consumer declared a complete toolbar replacement. */
|
|
1534
|
+
protected readonly _hasToolbarDef: _angular_core.Signal<boolean>;
|
|
1535
|
+
/** @protected Context supplied as the implicit value of projected toolbar templates. */
|
|
1536
|
+
protected readonly _toolbarContext: MlvEditorToolbarContext;
|
|
1537
|
+
/** @private Platform marker used to keep all editor construction out of SSR. */
|
|
1538
|
+
private readonly _isBrowser;
|
|
1539
|
+
/** @private Teardown registration for the browser editor instance. */
|
|
1540
|
+
private readonly _destroyRef;
|
|
1541
|
+
/** @private Registry for overlay roots logically owned by this composite control. */
|
|
1542
|
+
private readonly _overlayRegistry;
|
|
1543
|
+
/** @private Injector used after construction to resolve the editor coordinator safely. */
|
|
1544
|
+
private readonly _injector;
|
|
1545
|
+
/** @private Invalidates built-in command state after Tiptap state changes. */
|
|
1546
|
+
private readonly _toolbarRevision;
|
|
1547
|
+
/** @private Registry of in-flight upload abort callbacks. */
|
|
1548
|
+
private readonly _uploadAbortRegistry;
|
|
1549
|
+
/** @private Physical host used to determine the composite focus boundary. */
|
|
1550
|
+
private readonly _host;
|
|
1551
|
+
/** @private Optional translated accessible defaults. */
|
|
1552
|
+
private readonly _i18n;
|
|
1553
|
+
/** @private Announces block moves politely; the editor content itself is not a live region. */
|
|
1554
|
+
private readonly _liveAnnouncer;
|
|
1555
|
+
/** @private Last external value applied to Tiptap without an update event. */
|
|
1556
|
+
private _lastAppliedValue;
|
|
1557
|
+
/** @private Last value emitted from a user transaction or format conversion. */
|
|
1558
|
+
private _lastEmittedValue;
|
|
1559
|
+
/** @private Active serialization mode for the current editor document. */
|
|
1560
|
+
private _activeFormat;
|
|
1561
|
+
/** @private Guards against duplicate Tiptap teardown. */
|
|
1562
|
+
private _destroyed;
|
|
1563
|
+
/** @private Suppresses document-transaction serialization while applying an external value. */
|
|
1564
|
+
private _applyingExternalValue;
|
|
1565
|
+
/** @private Tracks the disabled edge so overlays/uploads close once per transition. */
|
|
1566
|
+
private _wasDisabled;
|
|
1567
|
+
/** @private Tracks the readonly edge so uploads stop before they can mutate content. */
|
|
1568
|
+
private _wasReadonly;
|
|
1569
|
+
/** @private Text selection retained while ProseMirror is made non-editable. */
|
|
1570
|
+
private _disabledSelection;
|
|
1571
|
+
/** @private Stored marks retained with a collapsed selection while disabled. */
|
|
1572
|
+
private _disabledStoredMarks;
|
|
1573
|
+
/** @private Avoids duplicate queued focus-leave checks. */
|
|
1574
|
+
private _blurCheckQueued;
|
|
1575
|
+
/** @private The last boundary event, retained until the microtask resolves focus ownership. */
|
|
1576
|
+
private _pendingBlurEvent;
|
|
1577
|
+
/** @private Stable capture listener for focus entering the physical host. */
|
|
1578
|
+
private readonly _onHostFocusIn;
|
|
1579
|
+
/** @private Stable capture listener for focus leaving the physical host. */
|
|
1580
|
+
private readonly _onHostFocusOut;
|
|
1581
|
+
/** @private Stable capture listener that blocks disabled projected controls. */
|
|
1582
|
+
private readonly _onDisabledPointerOrClick;
|
|
1583
|
+
/** @private Stable capture listener that blocks disabled keyboard activation. */
|
|
1584
|
+
private readonly _onDisabledKeydown;
|
|
1585
|
+
/** @protected Fallback-accessible name when no visible label is supplied. */
|
|
1586
|
+
protected readonly _resolvedAriaLabel: _angular_core.Signal<string>;
|
|
1587
|
+
/** @protected Descriptions supplied explicitly or by the inherited validation message. */
|
|
1588
|
+
protected readonly _resolvedAriaDescribedBy: _angular_core.Signal<string | undefined>;
|
|
1589
|
+
/** @protected ID used to connect a visible inherited label to ProseMirror. */
|
|
1590
|
+
protected readonly _labelId: _angular_core.Signal<string>;
|
|
1591
|
+
/** @protected Accessible label for the projected toolbar region. */
|
|
1592
|
+
protected readonly _toolbarAriaLabel: _angular_core.Signal<string>;
|
|
1593
|
+
constructor();
|
|
1594
|
+
/** Creates the one Tiptap editor after Angular has rendered the mount element. */
|
|
1595
|
+
ngAfterViewInit(): void;
|
|
1596
|
+
/** Clears the document through Tiptap when the shared form wrapper is clearable. */
|
|
1597
|
+
clearValue(): void;
|
|
1598
|
+
/** @private Formats a completed block move and announces it politely. */
|
|
1599
|
+
private _announceBlockMove;
|
|
1600
|
+
/** @private Whether a browser MIME type matches the current coordinator options. */
|
|
1601
|
+
private _acceptsImageMimeType;
|
|
1602
|
+
/** Runs a Tiptap mutation command when the editor is available and editable. */
|
|
1603
|
+
run(command: (editor: Editor) => boolean): boolean;
|
|
1604
|
+
/** Checks a Tiptap command when the editor is available and editable. */
|
|
1605
|
+
can(command: (editor: Editor) => boolean): boolean;
|
|
1606
|
+
/** Safely reads a Tiptap active state without requiring a particular extension. */
|
|
1607
|
+
isActive(name: string, attributes?: Record<string, unknown>): boolean;
|
|
1608
|
+
/** Reports a typed recoverable error through the owning editor output. */
|
|
1609
|
+
reportError(error: MlvEditorError): void;
|
|
1610
|
+
/** @private Applies the current inputs to the already-created editor instance. */
|
|
1611
|
+
private _synchronizeEditor;
|
|
1612
|
+
/** @private Applies an external value without reflecting it back through `onUpdate`. */
|
|
1613
|
+
private _applyExternalValue;
|
|
1614
|
+
/**
|
|
1615
|
+
* @private Converts one nonempty external value into Tiptap content and
|
|
1616
|
+
* options.
|
|
1617
|
+
*
|
|
1618
|
+
* The branch is exhaustive over every format rather than special-casing one:
|
|
1619
|
+
* HTML is parsed from its own markup, Markdown declares its content type so
|
|
1620
|
+
* the Markdown manager parses it, and JSON is handed over as an
|
|
1621
|
+
* already-parsed document node because Tiptap reads any string argument as
|
|
1622
|
+
* HTML. A rejected JSON value carries its cause instead of a document.
|
|
1623
|
+
*/
|
|
1624
|
+
private _prepareContent;
|
|
1625
|
+
/**
|
|
1626
|
+
* @private Construction options mounting an empty document for one format.
|
|
1627
|
+
*
|
|
1628
|
+
* Tiptap is always constructed against an empty document so every real
|
|
1629
|
+
* value travels the same strict parsing path. Markdown still declares its
|
|
1630
|
+
* content type here because the Markdown manager validates that declaration
|
|
1631
|
+
* against the supplied content before the first document is published. HTML
|
|
1632
|
+
* needs no declaration, and JSON never reaches Tiptap as a string at all.
|
|
1633
|
+
*/
|
|
1634
|
+
private _emptyDocumentOptions;
|
|
1635
|
+
/** @private Restores the last valid value and reports a recoverable parse failure. */
|
|
1636
|
+
private _recoverFromInvalidValue;
|
|
1637
|
+
/**
|
|
1638
|
+
* @private Serializes an editor transaction and writes only valid distinct
|
|
1639
|
+
* values.
|
|
1640
|
+
*
|
|
1641
|
+
* The distinctness check runs in the serialized format, so a JSON document
|
|
1642
|
+
* that differs from the model only by key order or whitespace is not
|
|
1643
|
+
* re-emitted. An emission therefore follows only a real user transaction or
|
|
1644
|
+
* an explicit format conversion.
|
|
1645
|
+
*/
|
|
1646
|
+
private _serializeAndWrite;
|
|
1647
|
+
/**
|
|
1648
|
+
* @private Applies the initial model through the same strict parsing path as
|
|
1649
|
+
* later updates.
|
|
1650
|
+
*
|
|
1651
|
+
* Only Markdown has a capability requirement; HTML and JSON mount against
|
|
1652
|
+
* any valid extension set.
|
|
1653
|
+
*/
|
|
1654
|
+
private _applyInitialValue;
|
|
1655
|
+
/** @private Whether the runtime editor exposes Tiptap Markdown serialization. */
|
|
1656
|
+
private _supportsMarkdown;
|
|
1657
|
+
/** @private Emits the stable unsupported-Markdown error without throwing through Angular. */
|
|
1658
|
+
private _emitUnsupportedMarkdownError;
|
|
1659
|
+
/** @private Builds the exact accessible attributes assigned to Tiptap's contenteditable root. */
|
|
1660
|
+
private _editorAttributes;
|
|
1661
|
+
/** @internal Capture handler for focus entering the host or an owned overlay root. */
|
|
1662
|
+
_handleCompositeFocusIn(event: FocusEvent): void;
|
|
1663
|
+
/** @internal Capture handler for focus leaving the host or an owned overlay root. */
|
|
1664
|
+
_handleCompositeFocusOut(event: FocusEvent): void;
|
|
1665
|
+
/** @private Whether the browser's current focus remains in the host or an owned overlay. */
|
|
1666
|
+
private _isFocusInsideComposite;
|
|
1667
|
+
/** @private Whether a node belongs to the physical shell or an owned overlay. */
|
|
1668
|
+
private _isOwnedFocusNode;
|
|
1669
|
+
/** @private Installs native capture listeners because overlay focus is outside Angular's view tree. */
|
|
1670
|
+
private _bindCompositeFocusEvents;
|
|
1671
|
+
/** @private Stops all pointer/click/activation-key command surfaces while disabled. */
|
|
1672
|
+
private _blockDisabledInteraction;
|
|
1673
|
+
/** @private Removes browser focus when the composite becomes disabled without marking it touched. */
|
|
1674
|
+
private _removeCompositeFocusForDisabledState;
|
|
1675
|
+
/** @private Keeps the real ProseMirror root in sync with dynamic ARIA/tabindex state. */
|
|
1676
|
+
private _synchronizeContentSurfaceState;
|
|
1677
|
+
/** @private Aborts registered upload work while preserving the document/editor instance. */
|
|
1678
|
+
private _abortInFlightUploads;
|
|
1679
|
+
/** @private Destroys the owned Tiptap editor exactly once. */
|
|
1680
|
+
private _destroyEditor;
|
|
1681
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditor, never>;
|
|
1682
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditor, "mlv-editor", never, { "value": { "alias": "value"; "required": false; "isSignal": true; }; "format": { "alias": "format"; "required": false; "isSignal": true; }; "contentWidth": { "alias": "contentWidth"; "required": false; "isSignal": true; }; "extensions": { "alias": "extensions"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "characterLimit": { "alias": "characterLimit"; "required": false; "isSignal": true; }; "ariaLabelledBy": { "alias": "ariaLabelledBy"; "required": false; "isSignal": true; }; "ariaDescribedBy": { "alias": "ariaDescribedBy"; "required": false; "isSignal": true; }; "imageUploader": { "alias": "imageUploader"; "required": false; "isSignal": true; }; "imageUploadOptions": { "alias": "imageUploadOptions"; "required": false; "isSignal": true; }; "aiProvider": { "alias": "aiProvider"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "editorReady": "editorReady"; "focus": "focus"; "blur": "blur"; "selectionChange": "selectionChange"; "transaction": "transaction"; "editorError": "editorError"; "imageUploadSuccess": "imageUploadSuccess"; "imageUploadFailure": "imageUploadFailure"; "imageUploadCancelled": "imageUploadCancelled"; }, ["_toolbarDefs", "_toolbarStartDefs", "_toolbarEndDefs"], ["[mlvEditorToolbar]", "[mlvEditorToolbarStart]", "[mlvEditorToolbarEnd]", "[mlvEditorStatus]"], true, never>;
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
/** A completed block move, reported so the host can announce it. */
|
|
1686
|
+
interface MlvEditorBlockMove {
|
|
1687
|
+
/** ProseMirror node type name of the moved block, untranslated. */
|
|
1688
|
+
readonly type: string;
|
|
1689
|
+
/** One-based position the block now occupies among the blocks counted by `total`. */
|
|
1690
|
+
readonly position: number;
|
|
1691
|
+
/**
|
|
1692
|
+
* Top-level block count of the document the move was computed against, i.e.
|
|
1693
|
+
* **before** the move — the same snapshot `position` is derived from. Reading
|
|
1694
|
+
* it after the move instead would announce schema-maintained artifacts the
|
|
1695
|
+
* user never authored: `trailingNode` appends an empty paragraph whenever the
|
|
1696
|
+
* last block is not a textblock, so moving a horizontal rule to the end would
|
|
1697
|
+
* otherwise report "3 of 4".
|
|
1698
|
+
*/
|
|
1699
|
+
readonly total: number;
|
|
1700
|
+
}
|
|
1701
|
+
/** Host-supplied capabilities for the block drag handle. */
|
|
1702
|
+
interface MlvEditorBlockHandleOptions {
|
|
1703
|
+
/**
|
|
1704
|
+
* Container the floating handle is appended to. Must be the layer carrying the
|
|
1705
|
+
* editor zoom transform so the handle shares its coordinate space.
|
|
1706
|
+
*/
|
|
1707
|
+
readonly mount: () => HTMLElement | null;
|
|
1708
|
+
/** Accessible label for the handle, read live so locale changes apply. */
|
|
1709
|
+
readonly label: () => string;
|
|
1710
|
+
/** Receives every completed move; the host formats and announces it. */
|
|
1711
|
+
readonly announceMove: (move: MlvEditorBlockMove) => void;
|
|
1712
|
+
/** Whether block moving is currently permitted; false while readonly or disabled. */
|
|
1713
|
+
readonly enabled: () => boolean;
|
|
1714
|
+
}
|
|
1715
|
+
declare module '@tiptap/core' {
|
|
1716
|
+
interface Commands<ReturnType> {
|
|
1717
|
+
mlvEditorBlockHandle: {
|
|
1718
|
+
/**
|
|
1719
|
+
* Moves one top-level block. Both indices address the document as it stands
|
|
1720
|
+
* **before** the move, so moving index 0 to index 2 of three blocks yields
|
|
1721
|
+
* the order `[1, 2, 0]`.
|
|
1722
|
+
*/
|
|
1723
|
+
moveBlock: (options: {
|
|
1724
|
+
from: number;
|
|
1725
|
+
to: number;
|
|
1726
|
+
}) => ReturnType;
|
|
1727
|
+
/** Moves the top-level block containing the selection one position earlier. */
|
|
1728
|
+
moveBlockUp: () => ReturnType;
|
|
1729
|
+
/** Moves the top-level block containing the selection one position later. */
|
|
1730
|
+
moveBlockDown: () => ReturnType;
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Tiptap extension supplying top-level block reordering.
|
|
1736
|
+
*
|
|
1737
|
+
* The pointer handle and the keyboard shortcuts both route through `moveBlock`,
|
|
1738
|
+
* so the two paths cannot drift apart. The handle itself is rendered by this
|
|
1739
|
+
* extension's ProseMirror plugin into the host-supplied mount container and is
|
|
1740
|
+
* never part of the document, so no serialized representation can contain it.
|
|
1741
|
+
*/
|
|
1742
|
+
declare const MlvEditorBlockHandle: Extension<MlvEditorBlockHandleOptions, any>;
|
|
1743
|
+
|
|
1744
|
+
/** A rendered, temporary image-upload placeholder tracked by its stable identifier. */
|
|
1745
|
+
interface MlvEditorUploadPlaceholderItem {
|
|
1746
|
+
/** Identifier that associates this placeholder with one upload operation. */
|
|
1747
|
+
readonly id: string;
|
|
1748
|
+
/** Current document position of the placeholder decoration. */
|
|
1749
|
+
readonly position: number;
|
|
1750
|
+
/** Upload progress percentage from 0 through 100. */
|
|
1751
|
+
readonly progress: number;
|
|
1752
|
+
}
|
|
1753
|
+
/** Options accepted when a temporary upload placeholder is inserted. */
|
|
1754
|
+
interface MlvEditorInsertUploadPlaceholderOptions {
|
|
1755
|
+
/** Unique caller-owned identifier for the upload operation. */
|
|
1756
|
+
readonly id: string;
|
|
1757
|
+
/** Optional document position; the current selection is used when omitted. */
|
|
1758
|
+
readonly position?: number;
|
|
1759
|
+
/** Initial upload progress percentage. Defaults to zero. */
|
|
1760
|
+
readonly progress?: number;
|
|
1761
|
+
}
|
|
1762
|
+
/** Options accepted when an existing upload placeholder is updated. */
|
|
1763
|
+
interface MlvEditorUpdateUploadPlaceholderOptions {
|
|
1764
|
+
/** Identifier of the placeholder to update. */
|
|
1765
|
+
readonly id: string;
|
|
1766
|
+
/** New upload progress percentage, clamped to the inclusive 0–100 range. */
|
|
1767
|
+
readonly progress: number;
|
|
1768
|
+
}
|
|
1769
|
+
/** Options accepted when a temporary upload placeholder is removed. */
|
|
1770
|
+
interface MlvEditorRemoveUploadPlaceholderOptions {
|
|
1771
|
+
/** Identifier of the placeholder to remove. */
|
|
1772
|
+
readonly id: string;
|
|
1773
|
+
}
|
|
1774
|
+
/** Image attributes inserted while atomically removing an upload placeholder. */
|
|
1775
|
+
interface MlvEditorReplaceUploadPlaceholderOptions {
|
|
1776
|
+
/** Identifier of the placeholder to replace. */
|
|
1777
|
+
readonly id: string;
|
|
1778
|
+
/** Validated image attributes used to create the final schema node. */
|
|
1779
|
+
readonly attributes: {
|
|
1780
|
+
/** Trimmed image URL. */
|
|
1781
|
+
readonly src: string;
|
|
1782
|
+
/** Optional alternative text. */
|
|
1783
|
+
readonly alt?: string;
|
|
1784
|
+
/** Optional image title. */
|
|
1785
|
+
readonly title?: string;
|
|
1786
|
+
/** Optional finite positive rendered width. */
|
|
1787
|
+
readonly width?: number;
|
|
1788
|
+
/** Optional finite positive rendered height. */
|
|
1789
|
+
readonly height?: number;
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1792
|
+
/** Read-only upload-placeholder state exposed through Tiptap extension storage. */
|
|
1793
|
+
interface MlvEditorUploadPlaceholderStorage {
|
|
1794
|
+
/** Current temporary placeholders; decorations, never serializable document nodes. */
|
|
1795
|
+
readonly placeholders: readonly MlvEditorUploadPlaceholderItem[];
|
|
1796
|
+
}
|
|
1797
|
+
declare module '@tiptap/core' {
|
|
1798
|
+
interface Commands<ReturnType> {
|
|
1799
|
+
mlvEditorUploadPlaceholder: {
|
|
1800
|
+
/** Inserts an upload decoration without changing persisted editor content. */
|
|
1801
|
+
insertUploadPlaceholder: (options: MlvEditorInsertUploadPlaceholderOptions) => ReturnType;
|
|
1802
|
+
/** Updates the progress decoration for one pending image upload. */
|
|
1803
|
+
updateUploadPlaceholder: (options: MlvEditorUpdateUploadPlaceholderOptions) => ReturnType;
|
|
1804
|
+
/** Removes the decoration for one completed, failed, or cancelled image upload. */
|
|
1805
|
+
removeUploadPlaceholder: (options: MlvEditorRemoveUploadPlaceholderOptions) => ReturnType;
|
|
1806
|
+
/** Atomically inserts an image at the mapped placeholder and removes it. */
|
|
1807
|
+
replaceUploadPlaceholder: (options: MlvEditorReplaceUploadPlaceholderOptions) => ReturnType;
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
/**
|
|
1812
|
+
* Tiptap extension that renders image-upload progress outside the document model.
|
|
1813
|
+
*
|
|
1814
|
+
* Its widget decorations are intentionally excluded from HTML and Markdown output,
|
|
1815
|
+
* so a pending upload can never become persisted editor content.
|
|
1816
|
+
*/
|
|
1817
|
+
declare const MlvEditorUploadPlaceholder: Extension<Record<string, never>, MlvEditorUploadPlaceholderStorage>;
|
|
1818
|
+
|
|
1819
|
+
/**
|
|
1820
|
+
* Public Malva wrapper around Tiptap's official free file handling extension.
|
|
1821
|
+
*
|
|
1822
|
+
* The upstream plugin intentionally consumes accepted file-only paste/drop
|
|
1823
|
+
* events. This companion plugin inserts a simultaneous `text/plain` payload
|
|
1824
|
+
* first, then delegates the file interaction exactly once to the upstream
|
|
1825
|
+
* `FileHandlePlugin`. It remains inert for either interaction when the
|
|
1826
|
+
* corresponding callback is not configured, so custom presets can safely
|
|
1827
|
+
* include it before they opt into file handling.
|
|
1828
|
+
*/
|
|
1829
|
+
declare const MlvEditorFileHandler: Extension<Omit<_tiptap_extension_file_handler.FileHandlePluginOptions, "key" | "editor">, any>;
|
|
1830
|
+
/** Options used to configure formatting extensions in a Malva editor preset. */
|
|
1831
|
+
interface MlvEditorFormattingExtensionOptions {
|
|
1832
|
+
/** Node types that accept text alignment. Defaults to headings and paragraphs. */
|
|
1833
|
+
readonly textAlignTypes?: readonly string[];
|
|
1834
|
+
}
|
|
1835
|
+
/** Options used to configure task-list support. */
|
|
1836
|
+
interface MlvEditorListExtensionOptions {
|
|
1837
|
+
/** Whether task-list items may be nested. Defaults to false. */
|
|
1838
|
+
readonly nestedTaskItems?: boolean;
|
|
1839
|
+
}
|
|
1840
|
+
/** Options used to configure table support. */
|
|
1841
|
+
interface MlvEditorTableExtensionOptions {
|
|
1842
|
+
/** Whether users can resize table columns. Defaults to true. */
|
|
1843
|
+
readonly resizable?: boolean;
|
|
1844
|
+
}
|
|
1845
|
+
/** A pasted or dropped file event passed from Tiptap to the editor upload coordinator. */
|
|
1846
|
+
interface MlvEditorFileHandlerEvent {
|
|
1847
|
+
/** Editor that received the file event. */
|
|
1848
|
+
readonly editor: Editor;
|
|
1849
|
+
/** Files selected by the browser paste or drop event. */
|
|
1850
|
+
readonly files: readonly File[];
|
|
1851
|
+
/** Origin of the image files. */
|
|
1852
|
+
readonly source: Exclude<MlvEditorImageUploadSource, 'button'>;
|
|
1853
|
+
/** Document position at which files were dropped, when applicable. */
|
|
1854
|
+
readonly position?: number;
|
|
1855
|
+
/** HTML clipboard content accompanying pasted files, when available. */
|
|
1856
|
+
readonly pasteContent?: string;
|
|
1857
|
+
}
|
|
1858
|
+
/** Options used to configure the image and file-handler extensions. */
|
|
1859
|
+
interface MlvEditorImageExtensionOptions {
|
|
1860
|
+
/** Whether image node resizing is enabled. Defaults to true. */
|
|
1861
|
+
readonly resizable?: boolean;
|
|
1862
|
+
/**
|
|
1863
|
+
* Smallest width, in CSS pixels, a resized image may be dragged to.
|
|
1864
|
+
* Defaults to 8. Must be a finite number: an undefined minimum leaves
|
|
1865
|
+
* Tiptap's resize arithmetic producing `NaN` and silently disables resizing.
|
|
1866
|
+
*/
|
|
1867
|
+
readonly minWidth?: number;
|
|
1868
|
+
/** Smallest height, in CSS pixels, a resized image may be dragged to. Defaults to 8. */
|
|
1869
|
+
readonly minHeight?: number;
|
|
1870
|
+
/** MIME types forwarded to Tiptap's file handler. */
|
|
1871
|
+
readonly allowedMimeTypes?: readonly string[];
|
|
1872
|
+
/** Runtime guard applied before Tiptap consumes a matching file event. */
|
|
1873
|
+
readonly fileHandlingEnabled?: () => boolean;
|
|
1874
|
+
/** Optional runtime MIME decision used for editor-scoped upload options. */
|
|
1875
|
+
readonly acceptsMimeType?: (mimeType: string) => boolean;
|
|
1876
|
+
/** Callback invoked for pasted and dropped files. */
|
|
1877
|
+
readonly onFiles?: (event: MlvEditorFileHandlerEvent) => void;
|
|
1878
|
+
}
|
|
1879
|
+
/** Options used to configure editor utility extensions. */
|
|
1880
|
+
interface MlvEditorUtilityExtensionOptions {
|
|
1881
|
+
/** Placeholder text shown for an empty editor. */
|
|
1882
|
+
readonly placeholder?: string;
|
|
1883
|
+
/** Maximum character count, or null for no limit. */
|
|
1884
|
+
readonly characterLimit?: number | null;
|
|
1885
|
+
}
|
|
1886
|
+
/**
|
|
1887
|
+
* Counts words using every Unicode whitespace separator as a boundary.
|
|
1888
|
+
*
|
|
1889
|
+
* @param text Plain editor text.
|
|
1890
|
+
* @returns The deterministic number of non-empty words.
|
|
1891
|
+
*/
|
|
1892
|
+
declare function countMlvEditorWords(text: string): number;
|
|
1893
|
+
/**
|
|
1894
|
+
* Normalizes a character limit to a positive finite integer.
|
|
1895
|
+
*
|
|
1896
|
+
* @param limit Candidate limit.
|
|
1897
|
+
* @returns The usable limit, or `null` for unlimited content.
|
|
1898
|
+
*/
|
|
1899
|
+
declare function normalizeMlvEditorCharacterLimit(limit: number | null | undefined): number | null;
|
|
1900
|
+
/** Options used to configure the beta Markdown extension. */
|
|
1901
|
+
interface MlvEditorMarkdownExtensionOptions {
|
|
1902
|
+
/** Indentation used by Markdown lists and code blocks. */
|
|
1903
|
+
readonly indentation?: {
|
|
1904
|
+
/** Use spaces or tabs for indentation. */
|
|
1905
|
+
readonly style?: 'space' | 'tab';
|
|
1906
|
+
/** Number of indentation characters per nesting level. */
|
|
1907
|
+
readonly size?: number;
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
/** Aggregate options accepted by the standard Malva editor extension preset. */
|
|
1911
|
+
interface MlvEditorDefaultExtensionOptions extends MlvEditorFormattingExtensionOptions, MlvEditorListExtensionOptions, MlvEditorTableExtensionOptions, MlvEditorImageExtensionOptions, MlvEditorUtilityExtensionOptions, MlvEditorMarkdownExtensionOptions {
|
|
1912
|
+
/** Serialization format; Markdown support is added only for `markdown`. */
|
|
1913
|
+
readonly format?: MlvEditorFormat;
|
|
1914
|
+
/** Host capabilities for the block drag handle. */
|
|
1915
|
+
readonly blockHandle?: Partial<MlvEditorBlockHandleOptions>;
|
|
1916
|
+
}
|
|
1917
|
+
/**
|
|
1918
|
+
* Creates the core formatting extensions used by the default Malva preset.
|
|
1919
|
+
*
|
|
1920
|
+
* @param options Optional text-alignment configuration.
|
|
1921
|
+
* @returns Fresh Tiptap extension instances safe to compose into one editor.
|
|
1922
|
+
*/
|
|
1923
|
+
declare function mlvEditorFormattingExtensions(options?: MlvEditorFormattingExtensionOptions): Extensions;
|
|
1924
|
+
/**
|
|
1925
|
+
* Creates task-list extensions. Bullet and ordered lists remain supplied by StarterKit.
|
|
1926
|
+
*
|
|
1927
|
+
* @param options Optional task-item nesting configuration.
|
|
1928
|
+
* @returns Fresh task-list extension instances.
|
|
1929
|
+
*/
|
|
1930
|
+
declare function mlvEditorListExtensions(options?: MlvEditorListExtensionOptions): Extensions;
|
|
1931
|
+
/**
|
|
1932
|
+
* Creates the free Tiptap table kit.
|
|
1933
|
+
*
|
|
1934
|
+
* @param options Optional table resize configuration.
|
|
1935
|
+
* @returns A fresh configured table-kit extension.
|
|
1936
|
+
*/
|
|
1937
|
+
declare function mlvEditorTableExtensions(options?: MlvEditorTableExtensionOptions): Extensions;
|
|
1938
|
+
/**
|
|
1939
|
+
* Creates the image and paste/drop file-handler extensions.
|
|
1940
|
+
*
|
|
1941
|
+
* @param options Optional image resize, MIME-type, and file callback configuration.
|
|
1942
|
+
* @returns Fresh image and file-handler extension instances.
|
|
1943
|
+
*/
|
|
1944
|
+
declare function mlvEditorImageExtensions(options?: MlvEditorImageExtensionOptions): Extensions;
|
|
1945
|
+
/**
|
|
1946
|
+
* Creates placeholder and character-count utility extensions.
|
|
1947
|
+
*
|
|
1948
|
+
* @param options Optional placeholder text and character limit.
|
|
1949
|
+
* @returns Fresh utility extension instances.
|
|
1950
|
+
*/
|
|
1951
|
+
declare function mlvEditorUtilityExtensions(options?: MlvEditorUtilityExtensionOptions): Extensions;
|
|
1952
|
+
/**
|
|
1953
|
+
* Creates the block drag-handle extension.
|
|
1954
|
+
*
|
|
1955
|
+
* Every option is host-supplied. Omitting them yields an inert handle that never
|
|
1956
|
+
* mounts, which is what a bare `mlvEditorDefaultExtensions()` call outside the
|
|
1957
|
+
* `MlvEditor` shell should produce.
|
|
1958
|
+
*
|
|
1959
|
+
* @param options Optional host capabilities for mounting, labelling, and announcing.
|
|
1960
|
+
* @returns A fresh configured block-handle extension.
|
|
1961
|
+
*/
|
|
1962
|
+
declare function mlvEditorBlockHandleExtensions(options?: Partial<MlvEditorBlockHandleOptions>): Extensions;
|
|
1963
|
+
/**
|
|
1964
|
+
* Creates the official beta Tiptap Markdown extension.
|
|
1965
|
+
*
|
|
1966
|
+
* @param options Optional Markdown indentation configuration.
|
|
1967
|
+
* @returns A fresh Markdown extension instance.
|
|
1968
|
+
*/
|
|
1969
|
+
declare function mlvEditorMarkdownExtensions(options?: MlvEditorMarkdownExtensionOptions): Extensions;
|
|
1970
|
+
/**
|
|
1971
|
+
* Creates Malva's complete default extension preset.
|
|
1972
|
+
*
|
|
1973
|
+
* Every call creates new arrays and extension instances. Passing a custom extension
|
|
1974
|
+
* list to the editor shell intentionally replaces this preset instead of extending it.
|
|
1975
|
+
*
|
|
1976
|
+
* @param options Optional preset configuration.
|
|
1977
|
+
* @returns A duplicate-free extension set for one new Tiptap editor instance.
|
|
1978
|
+
*/
|
|
1979
|
+
declare function mlvEditorDefaultExtensions(options?: MlvEditorDefaultExtensionOptions): Extensions;
|
|
1980
|
+
|
|
1981
|
+
/** Public character and word summary for the nearest editor context. */
|
|
1982
|
+
declare class MlvEditorStatus {
|
|
1983
|
+
/** Optional maximum character count; invalid values mean unlimited. */
|
|
1984
|
+
readonly characterLimit: _angular_core.InputSignal<number | null>;
|
|
1985
|
+
/** Current character count, or zero when CharacterCount is unavailable. */
|
|
1986
|
+
readonly characters: _angular_core.Signal<number>;
|
|
1987
|
+
/** Current Unicode-whitespace-aware word count. */
|
|
1988
|
+
readonly words: _angular_core.Signal<number>;
|
|
1989
|
+
/** Whether the active extension set exposes CharacterCount storage. */
|
|
1990
|
+
readonly available: _angular_core.Signal<boolean>;
|
|
1991
|
+
/** @protected Normalized limit displayed by the summary. */
|
|
1992
|
+
protected readonly _limit: _angular_core.Signal<number | null>;
|
|
1993
|
+
/** @protected Accessible count and remaining-limit description. */
|
|
1994
|
+
protected readonly _ariaLabel: _angular_core.Signal<string>;
|
|
1995
|
+
/** @private Nearest public editor command context. */
|
|
1996
|
+
private readonly _context;
|
|
1997
|
+
/** @private Invalidates storage reads after transactions and selections. */
|
|
1998
|
+
private readonly _revision;
|
|
1999
|
+
/** @private Safely resolves optional Tiptap CharacterCount storage. */
|
|
2000
|
+
private readonly _storage;
|
|
2001
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorStatus, never>;
|
|
2002
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorStatus, "mlv-editor-status", never, { "characterLimit": { "alias": "characterLimit"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
/** Left, center, right, and justified paragraph alignment commands in a menu. */
|
|
2006
|
+
declare class MlvEditorAlignment {
|
|
2007
|
+
/** @protected Editor command state. */
|
|
2008
|
+
protected readonly _context: _malva_ui_editor.MlvEditorToolbarContext;
|
|
2009
|
+
/** @private Per-editor state invalidation signal. */
|
|
2010
|
+
private readonly _revision;
|
|
2011
|
+
/** @private The editor-owned overlay registry. */
|
|
2012
|
+
private readonly _overlays;
|
|
2013
|
+
/** @private Document used to resolve the public menu panel id. */
|
|
2014
|
+
private readonly _document;
|
|
2015
|
+
/** @private Removes a pending or active overlay registration. */
|
|
2016
|
+
private readonly _destroyRef;
|
|
2017
|
+
/** @private Optional localized editor copy. */
|
|
2018
|
+
private readonly _i18n;
|
|
2019
|
+
/** @protected Rendered Malva menu. */
|
|
2020
|
+
protected readonly _menu: _angular_core.Signal<MlvMenu<_malva_ui_core_menu.MlvMenuItemData<unknown>>>;
|
|
2021
|
+
/** @protected Trigger owning the menu overlay. */
|
|
2022
|
+
protected readonly _trigger: _angular_core.Signal<MlvMenuTrigger>;
|
|
2023
|
+
/** @private Tears down the active panel registration. */
|
|
2024
|
+
private _unregister;
|
|
2025
|
+
/** @private Guards queued registration after a quick close or destroy. */
|
|
2026
|
+
private _menuOpen;
|
|
2027
|
+
/** @protected Supported alignments in visual order. */
|
|
2028
|
+
protected readonly _alignments: readonly ["left", "center", "right", "justify"];
|
|
2029
|
+
/** @protected Resolved localized copy. */
|
|
2030
|
+
protected _copy(): {
|
|
2031
|
+
alignment: string;
|
|
2032
|
+
left: string;
|
|
2033
|
+
center: string;
|
|
2034
|
+
right: string;
|
|
2035
|
+
justify: string;
|
|
2036
|
+
};
|
|
2037
|
+
constructor();
|
|
2038
|
+
/** @protected Resolves a translated alignment label. */
|
|
2039
|
+
protected _label(alignment: (typeof this._alignments)[number]): string;
|
|
2040
|
+
/** @protected Current alignment, with left as the semantic default. */
|
|
2041
|
+
protected _activeAlignment(): (typeof this._alignments)[number];
|
|
2042
|
+
/** @protected Whether the current selection has this alignment. */
|
|
2043
|
+
protected _isActive(alignment: (typeof this._alignments)[number]): boolean;
|
|
2044
|
+
/** @protected Whether alignment is registered by the active extension set. */
|
|
2045
|
+
protected _supported(): boolean;
|
|
2046
|
+
/** @protected Whether the menu trigger cannot be opened. */
|
|
2047
|
+
protected _triggerDisabled(): boolean;
|
|
2048
|
+
/** @protected Whether an alignment cannot be applied at the current selection. */
|
|
2049
|
+
protected _disabled(alignment: (typeof this._alignments)[number]): boolean;
|
|
2050
|
+
/** @private Checks whether alignment can be applied without changing focus or selection. */
|
|
2051
|
+
private _canAlign;
|
|
2052
|
+
/** @protected Alignment command factory. */
|
|
2053
|
+
protected _align(alignment: (typeof this._alignments)[number]): (editor: Editor) => boolean;
|
|
2054
|
+
/** @protected Runs a selection-restoring alignment command. */
|
|
2055
|
+
protected _run(alignment: (typeof this._alignments)[number]): void;
|
|
2056
|
+
/** @protected Registers the portaled panel as editor-owned focus. */
|
|
2057
|
+
protected _registerOverlay(): void;
|
|
2058
|
+
/** @protected Removes menu-panel focus ownership after close. */
|
|
2059
|
+
protected _unregisterOverlay(): void;
|
|
2060
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorAlignment, never>;
|
|
2061
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorAlignment, "mlv-editor-alignment", never, {}, {}, never, never, true, never>;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
/** Blockquote and code-block toggles plus horizontal-rule insertion. */
|
|
2065
|
+
declare class MlvEditorBlockInsert {
|
|
2066
|
+
/** @protected Editor command state. */ protected readonly _context: _malva_ui_editor.MlvEditorToolbarContext;
|
|
2067
|
+
/** @private Triggers active-state refreshes after editor events. */ private readonly _revision;
|
|
2068
|
+
/** @private Optional localized copy. */ private readonly _i18n;
|
|
2069
|
+
/** @protected Resolved labels. */ protected readonly _copy: _angular_core.Signal<{
|
|
2070
|
+
blockquote: string;
|
|
2071
|
+
codeBlock: string;
|
|
2072
|
+
horizontalRule: string;
|
|
2073
|
+
}>;
|
|
2074
|
+
/** @protected Registered blockquote command. */ protected readonly _canBlockquote: (editor: Editor) => boolean;
|
|
2075
|
+
/** @protected Current blockquote command availability. */ protected readonly _canBlockquoteNow: (editor: Editor) => boolean;
|
|
2076
|
+
/** @protected Registered code-block command. */ protected readonly _canCodeBlock: (editor: Editor) => boolean;
|
|
2077
|
+
/** @protected Current code-block command availability. */ protected readonly _canCodeBlockNow: (editor: Editor) => boolean;
|
|
2078
|
+
/** @protected Registered horizontal-rule command. */ protected readonly _canHorizontalRule: (editor: Editor) => boolean;
|
|
2079
|
+
/** @protected Current horizontal-rule command availability. */ protected readonly _canHorizontalRuleNow: (editor: Editor) => boolean;
|
|
2080
|
+
/** @protected Blockquote command. */ protected readonly _blockquote: (editor: Editor) => boolean;
|
|
2081
|
+
/** @protected Code-block command. */ protected readonly _codeBlock: (editor: Editor) => boolean;
|
|
2082
|
+
/** @protected Horizontal-rule command. */ protected readonly _horizontalRule: (editor: Editor) => boolean;
|
|
2083
|
+
/** @protected Reads command state after the toolbar receives an editor update. */
|
|
2084
|
+
protected readonly _isActive: (name: "blockquote" | "codeBlock") => boolean;
|
|
2085
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorBlockInsert, never>;
|
|
2086
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorBlockInsert, "mlv-editor-block-insert", never, {}, {}, never, never, true, never>;
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
/** Heading levels supported by Tiptap's standard heading node. */
|
|
2090
|
+
type MlvEditorHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
2091
|
+
/** Paragraph and heading-level dropdown commands. */
|
|
2092
|
+
declare class MlvEditorHeading {
|
|
2093
|
+
/** Heading levels displayed in the menu; paragraph is always retained. */
|
|
2094
|
+
readonly levels: _angular_core.InputSignal<readonly MlvEditorHeadingLevel[]>;
|
|
2095
|
+
/** @protected Editor command state. */
|
|
2096
|
+
protected readonly _context: _malva_ui_editor.MlvEditorToolbarContext;
|
|
2097
|
+
/** @private Per-editor state invalidation signal. */
|
|
2098
|
+
private readonly _revision;
|
|
2099
|
+
/** @private The editor-owned overlay registry. */
|
|
2100
|
+
private readonly _overlays;
|
|
2101
|
+
/** @private Document used to resolve the public menu panel id. */
|
|
2102
|
+
private readonly _document;
|
|
2103
|
+
/** @private Cleans an active overlay registration. */
|
|
2104
|
+
private readonly _destroyRef;
|
|
2105
|
+
/** @private Optional localized editor copy. */
|
|
2106
|
+
private readonly _i18n;
|
|
2107
|
+
/** @protected Rendered Malva menu. */
|
|
2108
|
+
protected readonly _menu: _angular_core.Signal<MlvMenu<_malva_ui_core_menu.MlvMenuItemData<unknown>>>;
|
|
2109
|
+
/** @protected Trigger owning the menu overlay. */
|
|
2110
|
+
protected readonly _trigger: _angular_core.Signal<MlvMenuTrigger>;
|
|
2111
|
+
/** @private Overlay-registration teardown. */
|
|
2112
|
+
private _unregister;
|
|
2113
|
+
/** @private Guards queued registration after a quick close or destroy. */
|
|
2114
|
+
private _menuOpen;
|
|
2115
|
+
/** @protected Normalized levels supported by the active heading extension. */
|
|
2116
|
+
protected readonly _levels: _angular_core.Signal<readonly MlvEditorHeadingLevel[]>;
|
|
2117
|
+
/** @protected Localized labels. */
|
|
2118
|
+
protected readonly _copy: _angular_core.Signal<{
|
|
2119
|
+
paragraph: string;
|
|
2120
|
+
headingLevel: string;
|
|
2121
|
+
}>;
|
|
2122
|
+
/** @protected Paragraph command availability at the current selection. */
|
|
2123
|
+
protected readonly _canParagraph: (editor: Editor) => boolean;
|
|
2124
|
+
constructor();
|
|
2125
|
+
/**
|
|
2126
|
+
* @protected Heading level under the caret, or `null` on a paragraph. Probes
|
|
2127
|
+
* every level the node supports rather than {@link _levels}: the caret can
|
|
2128
|
+
* land in a heading the menu deliberately omits, and the trigger still has to
|
|
2129
|
+
* report what the block actually is.
|
|
2130
|
+
*
|
|
2131
|
+
* Drives both the trigger glyph and its selected paint. The paint is a class,
|
|
2132
|
+
* not `aria-pressed` — this is a menu button, and its state semantics are
|
|
2133
|
+
* `aria-haspopup`/`aria-expanded` plus the level-bearing accessible name.
|
|
2134
|
+
*/
|
|
2135
|
+
protected _activeLevel(): MlvEditorHeadingLevel | null;
|
|
2136
|
+
/** @protected Label describing the active block type. */
|
|
2137
|
+
protected _label(): string;
|
|
2138
|
+
/** @protected Localized heading label. */
|
|
2139
|
+
protected _headingLabel(level: number): string;
|
|
2140
|
+
/** @protected Whether a heading command is registered by the extension set. */
|
|
2141
|
+
protected _supported(): boolean;
|
|
2142
|
+
/** @protected Whether the paragraph command is registered. */
|
|
2143
|
+
protected _hasParagraph(): boolean;
|
|
2144
|
+
/** @protected Whether heading commands are registered. */
|
|
2145
|
+
protected _hasHeading(): boolean;
|
|
2146
|
+
/** @protected Whether the trigger cannot be opened. */
|
|
2147
|
+
protected _triggerDisabled(): boolean;
|
|
2148
|
+
/** @protected Whether one menu action currently cannot mutate the editor. */
|
|
2149
|
+
protected _disabled(command: (editor: Editor) => boolean): boolean;
|
|
2150
|
+
/** @protected Paragraph command. */
|
|
2151
|
+
protected readonly _paragraph: (editor: Editor) => boolean;
|
|
2152
|
+
/** @protected Heading command factory. */
|
|
2153
|
+
protected _heading(level: MlvEditorHeadingLevel): (editor: Editor) => boolean;
|
|
2154
|
+
/** @protected Heading command availability factory. */
|
|
2155
|
+
protected _canHeading(level: MlvEditorHeadingLevel): (editor: Editor) => boolean;
|
|
2156
|
+
/** @protected Runs a selection-restoring command. */
|
|
2157
|
+
protected _run(command: (editor: Editor) => boolean): void;
|
|
2158
|
+
/** @protected Registers the portaled panel with the editor composite. */
|
|
2159
|
+
protected _registerOverlay(): void;
|
|
2160
|
+
/** @protected Removes menu panel focus ownership after close. */
|
|
2161
|
+
protected _unregisterOverlay(): void;
|
|
2162
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorHeading, never>;
|
|
2163
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorHeading, "mlv-editor-heading", never, { "levels": { "alias": "levels"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
interface EditorSelectionRange {
|
|
2167
|
+
readonly from: number;
|
|
2168
|
+
readonly to: number;
|
|
2169
|
+
}
|
|
2170
|
+
/** @internal Shared selection, roving, and overlay lifecycle for colour controls. */
|
|
2171
|
+
declare abstract class MlvEditorColorControl {
|
|
2172
|
+
/** @protected Editor-scoped command and state boundary. */
|
|
2173
|
+
protected readonly _context: _malva_ui_editor.MlvEditorToolbarContext;
|
|
2174
|
+
/** @protected Reactive toolbar invalidation state. */
|
|
2175
|
+
protected readonly _revision: _angular_core.Signal<number> | null;
|
|
2176
|
+
/** @protected Public color-picker composition surface. */
|
|
2177
|
+
protected readonly _picker: _angular_core.Signal<MlvColorPickerPopup>;
|
|
2178
|
+
/** @private Editor toolbar roving-focus owner. */
|
|
2179
|
+
private readonly _roving;
|
|
2180
|
+
/** @private Editor composite detached-overlay owner. */
|
|
2181
|
+
private readonly _overlays;
|
|
2182
|
+
/** @private ProseMirror selection retained while focus is inside the picker. */
|
|
2183
|
+
private _selection;
|
|
2184
|
+
constructor();
|
|
2185
|
+
/** @protected Snapshots the document selection at open intent. */
|
|
2186
|
+
protected _onOpenedChange(opened: boolean): void;
|
|
2187
|
+
/** @protected Restores the snapshot and delegates the distinct colour command. */
|
|
2188
|
+
protected _apply(color: string): void;
|
|
2189
|
+
/** @protected Distinct foreground/highlight command policy. */
|
|
2190
|
+
protected abstract _run(editor: Editor, selection: EditorSelectionRange, color: string): boolean;
|
|
2191
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorColorControl, never>;
|
|
2192
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<MlvEditorColorControl, never, never, {}, {}, never, never, true, never>;
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
/** Background-highlight toolbar control backed by the reusable swatch picker. */
|
|
2196
|
+
declare class MlvEditorHighlight extends MlvEditorColorControl {
|
|
2197
|
+
/** @private Optional localized editor labels. */
|
|
2198
|
+
private readonly _i18n;
|
|
2199
|
+
/** @protected Localized accessible trigger and dialog label. */
|
|
2200
|
+
protected readonly _label: _angular_core.Signal<string>;
|
|
2201
|
+
/** @protected Exact command-presence capability without command execution. */
|
|
2202
|
+
protected readonly _supported: _angular_core.Signal<boolean>;
|
|
2203
|
+
/** @protected Active highlight colour rendered by the independent swatch. */
|
|
2204
|
+
protected readonly _activeColor: _angular_core.Signal<string>;
|
|
2205
|
+
/** @protected Applies or clears highlight colour without focusing Tiptap. */
|
|
2206
|
+
protected _run(editor: Editor, selection: {
|
|
2207
|
+
readonly from: number;
|
|
2208
|
+
readonly to: number;
|
|
2209
|
+
}, color: string): boolean;
|
|
2210
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorHighlight, never>;
|
|
2211
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorHighlight, "mlv-editor-highlight", never, {}, {}, never, never, true, never>;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
/** Inline bold, italic, strike-through, and underline toggles. */
|
|
2215
|
+
declare class MlvEditorInlineMarks {
|
|
2216
|
+
/** @protected Editor command state. */ protected readonly _context: _malva_ui_editor.MlvEditorToolbarContext;
|
|
2217
|
+
/** @private Per-editor state invalidation signal. */ private readonly _revision;
|
|
2218
|
+
/** @private Optional localized copy. */ private readonly _i18n;
|
|
2219
|
+
/** @protected Resolved labels. */ protected readonly _copy: _angular_core.Signal<{
|
|
2220
|
+
bold: string;
|
|
2221
|
+
italic: string;
|
|
2222
|
+
strike: string;
|
|
2223
|
+
underline: string;
|
|
2224
|
+
}>;
|
|
2225
|
+
/** @protected Bold availability. */ protected readonly _canBold: (editor: Editor) => boolean;
|
|
2226
|
+
/** @protected Reads active state after the latest transaction or selection update. */
|
|
2227
|
+
protected _isActive(name: string): boolean;
|
|
2228
|
+
/** @protected Current bold command availability. */ protected readonly _canBoldNow: (editor: Editor) => boolean;
|
|
2229
|
+
/** @protected Italic availability. */ protected readonly _canItalic: (editor: Editor) => boolean;
|
|
2230
|
+
/** @protected Current italic command availability. */ protected readonly _canItalicNow: (editor: Editor) => boolean;
|
|
2231
|
+
/** @protected Strike availability. */ protected readonly _canStrike: (editor: Editor) => boolean;
|
|
2232
|
+
/** @protected Current strike command availability. */ protected readonly _canStrikeNow: (editor: Editor) => boolean;
|
|
2233
|
+
/** @protected Underline availability. */ protected readonly _canUnderline: (editor: Editor) => boolean;
|
|
2234
|
+
/** @protected Current underline command availability. */ protected readonly _canUnderlineNow: (editor: Editor) => boolean;
|
|
2235
|
+
/** @protected Bold command. */ protected readonly _bold: (editor: Editor) => boolean;
|
|
2236
|
+
/** @protected Italic command. */ protected readonly _italic: (editor: Editor) => boolean;
|
|
2237
|
+
/** @protected Strike command. */ protected readonly _strike: (editor: Editor) => boolean;
|
|
2238
|
+
/** @protected Underline command. */ protected readonly _underline: (editor: Editor) => boolean;
|
|
2239
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorInlineMarks, never>;
|
|
2240
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorInlineMarks, "mlv-editor-inline-marks", never, {}, {}, never, never, true, never>;
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
/** Bullet, ordered, and task-list toolbar commands in a compact menu. */
|
|
2244
|
+
declare class MlvEditorList {
|
|
2245
|
+
/** @protected Editor command state. */
|
|
2246
|
+
protected readonly _context: _malva_ui_editor.MlvEditorToolbarContext;
|
|
2247
|
+
/** @private Per-editor state invalidation signal. */
|
|
2248
|
+
private readonly _revision;
|
|
2249
|
+
/** @private The editor-owned overlay registry. */
|
|
2250
|
+
private readonly _overlays;
|
|
2251
|
+
/** @private Document used to resolve the public menu panel id. */
|
|
2252
|
+
private readonly _document;
|
|
2253
|
+
/** @private Removes a pending or active overlay registration. */
|
|
2254
|
+
private readonly _destroyRef;
|
|
2255
|
+
/** @private Optional localized editor copy. */
|
|
2256
|
+
private readonly _i18n;
|
|
2257
|
+
/** @protected Rendered Malva menu. */
|
|
2258
|
+
protected readonly _menu: _angular_core.Signal<MlvMenu<_malva_ui_core_menu.MlvMenuItemData<unknown>>>;
|
|
2259
|
+
/** @protected Trigger owning the menu overlay. */
|
|
2260
|
+
protected readonly _trigger: _angular_core.Signal<MlvMenuTrigger>;
|
|
2261
|
+
/** @private Tears down the active panel registration. */
|
|
2262
|
+
private _unregister;
|
|
2263
|
+
/** @private Guards queued registration after a quick close or destroy. */
|
|
2264
|
+
private _menuOpen;
|
|
2265
|
+
/** @protected Resolved menu labels. */
|
|
2266
|
+
protected readonly _copy: _angular_core.Signal<{
|
|
2267
|
+
bullet: string;
|
|
2268
|
+
ordered: string;
|
|
2269
|
+
task: string;
|
|
2270
|
+
}>;
|
|
2271
|
+
/** @protected Bullet-list command availability at the current selection. */
|
|
2272
|
+
protected readonly _canBullet: (editor: Editor) => boolean;
|
|
2273
|
+
/** @protected Ordered-list command availability at the current selection. */
|
|
2274
|
+
protected readonly _canOrdered: (editor: Editor) => boolean;
|
|
2275
|
+
/** @protected Task-list command availability at the current selection. */
|
|
2276
|
+
protected readonly _canTask: (editor: Editor) => boolean;
|
|
2277
|
+
/** @protected Bullet-list command. */
|
|
2278
|
+
protected readonly _bullet: (editor: Editor) => boolean;
|
|
2279
|
+
/** @protected Ordered-list command. */
|
|
2280
|
+
protected readonly _ordered: (editor: Editor) => boolean;
|
|
2281
|
+
/** @protected Task-list command. */
|
|
2282
|
+
protected readonly _task: (editor: Editor) => boolean;
|
|
2283
|
+
constructor();
|
|
2284
|
+
/** @protected The list style currently active at the selection. */
|
|
2285
|
+
protected _label(): string;
|
|
2286
|
+
/** @protected Whether one list command is registered by the active extension set. */
|
|
2287
|
+
protected _supported(): boolean;
|
|
2288
|
+
/** @protected Whether the bullet-list command is registered. */
|
|
2289
|
+
protected _hasBullet(): boolean;
|
|
2290
|
+
/** @protected Whether the ordered-list command is registered. */
|
|
2291
|
+
protected _hasOrdered(): boolean;
|
|
2292
|
+
/** @protected Whether the task-list command is registered. */
|
|
2293
|
+
protected _hasTask(): boolean;
|
|
2294
|
+
/** @protected Whether the menu trigger cannot be opened. */
|
|
2295
|
+
protected _triggerDisabled(): boolean;
|
|
2296
|
+
/** @protected Whether an available menu item currently cannot mutate. */
|
|
2297
|
+
protected _disabled(command: (editor: Editor) => boolean): boolean;
|
|
2298
|
+
/** @protected Runs a selection-restoring list command. */
|
|
2299
|
+
protected _run(command: (editor: Editor) => boolean): void;
|
|
2300
|
+
/** @protected Registers the portaled panel as editor-owned focus. */
|
|
2301
|
+
protected _registerOverlay(): void;
|
|
2302
|
+
/** @protected Removes menu-panel focus ownership after close. */
|
|
2303
|
+
protected _unregisterOverlay(): void;
|
|
2304
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorList, never>;
|
|
2305
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorList, "mlv-editor-list", never, {}, {}, never, never, true, never>;
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2308
|
+
/** Safe URL and label editor for the active Tiptap link mark. */
|
|
2309
|
+
declare class MlvEditorLink {
|
|
2310
|
+
/**
|
|
2311
|
+
* URL schemes accepted by Malva before the active Tiptap Link extension
|
|
2312
|
+
* applies its own configured protocol policy.
|
|
2313
|
+
*/
|
|
2314
|
+
readonly allowedProtocols: _angular_core.InputSignal<readonly string[]>;
|
|
2315
|
+
/** @protected Editor-scoped command and form state. */
|
|
2316
|
+
protected readonly _context: _malva_ui_editor.MlvEditorToolbarContext;
|
|
2317
|
+
/** @private Toolbar transaction/selection invalidation state. */
|
|
2318
|
+
private readonly _revision;
|
|
2319
|
+
/** @private Detached panel ownership for composite focus. */
|
|
2320
|
+
private readonly _overlays;
|
|
2321
|
+
/** @private Optional localized editor copy. */
|
|
2322
|
+
private readonly _i18n;
|
|
2323
|
+
/** @protected Popup controller owned by the trigger. */
|
|
2324
|
+
protected readonly _popup: Signal<MlvPopup>;
|
|
2325
|
+
/** @protected Connected trigger controller. */
|
|
2326
|
+
protected readonly _trigger: Signal<MlvPopupTrigger>;
|
|
2327
|
+
/** @protected Native trigger restored after popup teardown. */
|
|
2328
|
+
protected readonly _triggerElement: Signal<ElementRef<HTMLButtonElement>>;
|
|
2329
|
+
/** @protected URL field focused on open. */
|
|
2330
|
+
protected readonly _urlInput: Signal<MlvInput>;
|
|
2331
|
+
/** @private Detached panel queried through Angular rather than selectors. */
|
|
2332
|
+
private readonly _panel;
|
|
2333
|
+
/** @protected URL draft retained when validation fails. */
|
|
2334
|
+
protected readonly _urlDraft: _angular_core.WritableSignal<string>;
|
|
2335
|
+
/** @protected Linked/selected text draft. */
|
|
2336
|
+
protected readonly _textDraft: _angular_core.WritableSignal<string>;
|
|
2337
|
+
/** @protected Whether the link should open in a new browsing context. */
|
|
2338
|
+
protected readonly _newTab: _angular_core.WritableSignal<boolean>;
|
|
2339
|
+
/** @protected Whether the current URL draft failed strict policy. */
|
|
2340
|
+
protected readonly _invalid: _angular_core.WritableSignal<boolean>;
|
|
2341
|
+
/** @protected Whether the currently edited range already carries a link. */
|
|
2342
|
+
protected readonly _canRemove: _angular_core.WritableSignal<boolean>;
|
|
2343
|
+
/** @private Whole mark or selected range retained while focus is detached. */
|
|
2344
|
+
private _selection;
|
|
2345
|
+
/** @protected Reactive localized copy for trigger, fields, and actions. */
|
|
2346
|
+
protected readonly _copy: Signal<{
|
|
2347
|
+
link: string;
|
|
2348
|
+
linkUrl: string;
|
|
2349
|
+
linkText: string;
|
|
2350
|
+
invalidLink: string;
|
|
2351
|
+
openInNewTab: string;
|
|
2352
|
+
applyLink: string;
|
|
2353
|
+
removeLink: string;
|
|
2354
|
+
}>;
|
|
2355
|
+
/** @protected Exact command presence without dispatching a transaction. */
|
|
2356
|
+
protected readonly _supported: Signal<boolean>;
|
|
2357
|
+
/** @protected Link mark state at the retained editor selection. */
|
|
2358
|
+
protected readonly _active: Signal<boolean>;
|
|
2359
|
+
/** @protected Whether readonly/disabled state blocks the complete popup. */
|
|
2360
|
+
protected readonly _disabled: Signal<boolean>;
|
|
2361
|
+
constructor();
|
|
2362
|
+
/** @protected Preloads the active whole-link range or current selection. */
|
|
2363
|
+
protected _onOpened(): void;
|
|
2364
|
+
/** @protected Restores the connected toolbar trigger after final teardown. */
|
|
2365
|
+
protected _onClosed(): void;
|
|
2366
|
+
/** @protected Clears stale validation as the user edits without closing. */
|
|
2367
|
+
protected _onUrlChange(value: string): void;
|
|
2368
|
+
/** @protected Applies an inserted or updated link after both policy checks. */
|
|
2369
|
+
protected _apply(): void;
|
|
2370
|
+
/** @protected Removes only the link mark while retaining its text. */
|
|
2371
|
+
protected _remove(): void;
|
|
2372
|
+
/** @private Preflights Link policy before replacing text and applying attributes. */
|
|
2373
|
+
private _applyToEditor;
|
|
2374
|
+
/** @private Strict scheme allowlist validation before Tiptap's own policy. */
|
|
2375
|
+
private _validateUrl;
|
|
2376
|
+
/** @private Trims, lowercases, and removes trailing colons from the API input. */
|
|
2377
|
+
private _normalizedProtocols;
|
|
2378
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorLink, never>;
|
|
2379
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorLink, "mlv-editor-link", never, { "allowedProtocols": { "alias": "allowedProtocols"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
type MlvEditorImageUploadTerminalReason = 'success' | 'cancelled' | 'lifecycle-abort' | 'removed';
|
|
2383
|
+
interface MlvEditorImageUploadTerminalEvent {
|
|
2384
|
+
readonly id: string;
|
|
2385
|
+
readonly reason: MlvEditorImageUploadTerminalReason;
|
|
2386
|
+
}
|
|
2387
|
+
/** Internal upload coordinator shared by every editor image entry point. */
|
|
2388
|
+
interface MlvEditorImageUploadCoordinator extends MlvEditorImageUploadControl {
|
|
2389
|
+
/** Observes explicit terminal transitions synchronously. */
|
|
2390
|
+
onTerminal(listener: (event: MlvEditorImageUploadTerminalEvent) => void): () => void;
|
|
2391
|
+
/** Claims live dialog ownership until the returned release is called. */
|
|
2392
|
+
claimDialogOwnership(id: string): () => void;
|
|
2393
|
+
/** Whether a live dialog owned this upload at the current terminal delivery. */
|
|
2394
|
+
hasDialogOwner(id: string): boolean;
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
/** Public toolbar entry point for the editor image-upload dialog. */
|
|
2398
|
+
declare class MlvEditorImageUpload {
|
|
2399
|
+
/** @protected Editor-scoped command/form state. */
|
|
2400
|
+
protected readonly _context: _malva_ui_editor.MlvEditorToolbarContext;
|
|
2401
|
+
/** @protected Shared upload coordinator for this editor instance. */
|
|
2402
|
+
protected readonly _coordinator: Signal<MlvEditorImageUploadCoordinator | undefined>;
|
|
2403
|
+
/** @private Transaction invalidation for runtime command support. */
|
|
2404
|
+
private readonly _revision;
|
|
2405
|
+
/** @private Malva dialog service used for the one modal surface. */
|
|
2406
|
+
private readonly _dialogs;
|
|
2407
|
+
/** @private Exact child injector passed through to the dialog portal. */
|
|
2408
|
+
private readonly _injector;
|
|
2409
|
+
/** @private Trigger restored by the shared dialog lifecycle. */
|
|
2410
|
+
private readonly _trigger;
|
|
2411
|
+
/** @private Current dialog, preventing duplicate opens. */
|
|
2412
|
+
private _dialogRef;
|
|
2413
|
+
/** @private Component teardown closes any owned dialog. */
|
|
2414
|
+
private readonly _destroyRef;
|
|
2415
|
+
/** @private Optional localized editor copy. */
|
|
2416
|
+
private readonly _i18n;
|
|
2417
|
+
/** @protected Reactive localized trigger copy. */
|
|
2418
|
+
protected readonly _copy: Signal<string>;
|
|
2419
|
+
/** @protected Whether the editor has both required upload commands. */
|
|
2420
|
+
protected readonly _supported: Signal<boolean>;
|
|
2421
|
+
/** @protected Whether the mutation entry point belongs in this toolbar. */
|
|
2422
|
+
protected readonly _visible: Signal<boolean>;
|
|
2423
|
+
/** @protected Whether the visible trigger is currently inert. */
|
|
2424
|
+
protected readonly _disabled: Signal<boolean>;
|
|
2425
|
+
constructor();
|
|
2426
|
+
/** @protected Opens one editor-scoped Malva upload dialog. */
|
|
2427
|
+
protected _open(): void;
|
|
2428
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorImageUpload, never>;
|
|
2429
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorImageUpload, "mlv-editor-image-upload", never, {}, {}, never, never, true, never>;
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
interface EditorTableSize {
|
|
2433
|
+
readonly rows: number;
|
|
2434
|
+
readonly cols: number;
|
|
2435
|
+
}
|
|
2436
|
+
/** Resizable table insertion and contextual command control. */
|
|
2437
|
+
declare class MlvEditorTable {
|
|
2438
|
+
/** @protected Editor-scoped command and form state. */
|
|
2439
|
+
protected readonly _context: _malva_ui_editor.MlvEditorToolbarContext;
|
|
2440
|
+
/** @private Normalizes horizontal grid movement for RTL. */
|
|
2441
|
+
private readonly _rtlService;
|
|
2442
|
+
/** @private Transaction and selection invalidation bridge. */
|
|
2443
|
+
private readonly _revision;
|
|
2444
|
+
/** @private Detached popup ownership for composite editor focus. */
|
|
2445
|
+
private readonly _overlays;
|
|
2446
|
+
/** @private Optional localized editor copy. */
|
|
2447
|
+
private readonly _i18n;
|
|
2448
|
+
/** @protected Popup controller owned by the insertion-grid trigger. */
|
|
2449
|
+
protected readonly _popup: Signal<MlvPopup | undefined>;
|
|
2450
|
+
/** @protected Connected insertion-grid popup trigger. */
|
|
2451
|
+
protected readonly _trigger: Signal<MlvPopupTrigger | undefined>;
|
|
2452
|
+
/** @protected Menu holding the in-table commands. */
|
|
2453
|
+
protected readonly _menu: Signal<MlvMenu<_malva_ui_core_menu.MlvMenuItemData<unknown>> | undefined>;
|
|
2454
|
+
/** @protected Connected in-table menu trigger. */
|
|
2455
|
+
protected readonly _menuTrigger: Signal<MlvMenuTrigger | undefined>;
|
|
2456
|
+
/** @protected Native trigger restored after final popup teardown. */
|
|
2457
|
+
protected readonly _triggerElement: Signal<ElementRef<HTMLButtonElement> | undefined>;
|
|
2458
|
+
/** @private Detached popup panel used by the overlay focus registry. */
|
|
2459
|
+
private readonly _panel;
|
|
2460
|
+
/** @protected First contextual action focused when a table popup opens. */
|
|
2461
|
+
protected readonly _firstAction: Signal<ElementRef<HTMLButtonElement> | undefined>;
|
|
2462
|
+
/** @private Native insertion-grid buttons in row-major order. */
|
|
2463
|
+
private readonly _gridCells;
|
|
2464
|
+
/** @protected Fixed row and column choices exposed by the grid. */
|
|
2465
|
+
protected readonly _gridRows: readonly (readonly EditorTableSize[])[];
|
|
2466
|
+
/** @protected Currently selected insertion dimensions. */
|
|
2467
|
+
protected readonly _selectedSize: _angular_core.WritableSignal<EditorTableSize>;
|
|
2468
|
+
/** @protected Whether insertion creates a header first row. */
|
|
2469
|
+
protected readonly _withHeaderRow: _angular_core.WritableSignal<boolean>;
|
|
2470
|
+
/** @protected Reactive localized copy for the trigger and insertion panel. */
|
|
2471
|
+
protected readonly _copy: Signal<{
|
|
2472
|
+
table: string;
|
|
2473
|
+
insertTable: string;
|
|
2474
|
+
addRowBefore: string;
|
|
2475
|
+
addRowAfter: string;
|
|
2476
|
+
deleteRow: string;
|
|
2477
|
+
addColumnBefore: string;
|
|
2478
|
+
addColumnAfter: string;
|
|
2479
|
+
deleteColumn: string;
|
|
2480
|
+
mergeCells: string;
|
|
2481
|
+
splitCell: string;
|
|
2482
|
+
toggleHeaderRow: string;
|
|
2483
|
+
toggleHeaderColumn: string;
|
|
2484
|
+
toggleHeaderCell: string;
|
|
2485
|
+
deleteTable: string;
|
|
2486
|
+
}>;
|
|
2487
|
+
/** @protected Whether the current editor registered table commands. */
|
|
2488
|
+
protected readonly _supported: Signal<boolean>;
|
|
2489
|
+
/** @protected Whether the retained selection is inside a table. */
|
|
2490
|
+
protected readonly _active: Signal<boolean>;
|
|
2491
|
+
/** @protected Whether editor form state blocks the complete control. */
|
|
2492
|
+
protected readonly _disabled: Signal<boolean>;
|
|
2493
|
+
/** @protected Adds a row before the selected cell. */
|
|
2494
|
+
protected readonly _addRowBefore: (editor: Editor) => boolean;
|
|
2495
|
+
/** @protected Adds a row after the selected cell. */
|
|
2496
|
+
protected readonly _addRowAfter: (editor: Editor) => boolean;
|
|
2497
|
+
/** @protected Deletes the selected row. */
|
|
2498
|
+
protected readonly _deleteRow: (editor: Editor) => boolean;
|
|
2499
|
+
/** @protected Adds a column before the selected cell. */
|
|
2500
|
+
protected readonly _addColumnBefore: (editor: Editor) => boolean;
|
|
2501
|
+
/** @protected Adds a column after the selected cell. */
|
|
2502
|
+
protected readonly _addColumnAfter: (editor: Editor) => boolean;
|
|
2503
|
+
/** @protected Deletes the selected column. */
|
|
2504
|
+
protected readonly _deleteColumn: (editor: Editor) => boolean;
|
|
2505
|
+
/** @protected Merges the selected rectangular cell range. */
|
|
2506
|
+
protected readonly _mergeCells: (editor: Editor) => boolean;
|
|
2507
|
+
/** @protected Splits the current merged cell. */
|
|
2508
|
+
protected readonly _splitCell: (editor: Editor) => boolean;
|
|
2509
|
+
/** @protected Toggles header nodes across the first row. */
|
|
2510
|
+
protected readonly _toggleHeaderRow: (editor: Editor) => boolean;
|
|
2511
|
+
/** @protected Toggles header nodes down the first column. */
|
|
2512
|
+
protected readonly _toggleHeaderColumn: (editor: Editor) => boolean;
|
|
2513
|
+
/** @protected Toggles the selected table cell's header node type. */
|
|
2514
|
+
protected readonly _toggleHeaderCell: (editor: Editor) => boolean;
|
|
2515
|
+
/** @protected Deletes the complete active table. */
|
|
2516
|
+
protected readonly _deleteTable: (editor: Editor) => boolean;
|
|
2517
|
+
/** @protected Non-dispatching add-row-before capability check. */
|
|
2518
|
+
protected readonly _canAddRowBefore: (editor: Editor) => boolean;
|
|
2519
|
+
/** @protected Non-dispatching add-row-after capability check. */
|
|
2520
|
+
protected readonly _canAddRowAfter: (editor: Editor) => boolean;
|
|
2521
|
+
/** @protected Non-dispatching delete-row capability check. */
|
|
2522
|
+
protected readonly _canDeleteRow: (editor: Editor) => boolean;
|
|
2523
|
+
/** @protected Non-dispatching add-column-before capability check. */
|
|
2524
|
+
protected readonly _canAddColumnBefore: (editor: Editor) => boolean;
|
|
2525
|
+
/** @protected Non-dispatching add-column-after capability check. */
|
|
2526
|
+
protected readonly _canAddColumnAfter: (editor: Editor) => boolean;
|
|
2527
|
+
/** @protected Non-dispatching delete-column capability check. */
|
|
2528
|
+
protected readonly _canDeleteColumn: (editor: Editor) => boolean;
|
|
2529
|
+
/** @protected Non-dispatching merge capability check. */
|
|
2530
|
+
protected readonly _canMergeCells: (editor: Editor) => boolean;
|
|
2531
|
+
/** @protected Non-dispatching split capability check. */
|
|
2532
|
+
protected readonly _canSplitCell: (editor: Editor) => boolean;
|
|
2533
|
+
/** @protected Non-dispatching header-row capability check. */
|
|
2534
|
+
protected readonly _canToggleHeaderRow: (editor: Editor) => boolean;
|
|
2535
|
+
/** @protected Non-dispatching header-column capability check. */
|
|
2536
|
+
protected readonly _canToggleHeaderColumn: (editor: Editor) => boolean;
|
|
2537
|
+
/** @protected Non-dispatching header-cell capability check. */
|
|
2538
|
+
protected readonly _canToggleHeaderCell: (editor: Editor) => boolean;
|
|
2539
|
+
/** @protected Non-dispatching table-deletion capability check. */
|
|
2540
|
+
protected readonly _canDeleteTable: (editor: Editor) => boolean;
|
|
2541
|
+
constructor();
|
|
2542
|
+
/** @protected Initializes and focuses the default insertion-grid choice. */
|
|
2543
|
+
protected _onOpened(): void;
|
|
2544
|
+
/** @protected Restores the connected toolbar trigger after final teardown. */
|
|
2545
|
+
protected _onClosed(): void;
|
|
2546
|
+
/** @protected Names an exact insertion size from localized table copy. */
|
|
2547
|
+
protected _sizeLabel(size: EditorTableSize): string;
|
|
2548
|
+
/** @protected Whether a grid cell belongs to the selected dimensions. */
|
|
2549
|
+
protected _sizeSelected(size: EditorTableSize): boolean;
|
|
2550
|
+
/** @protected Updates the current pointer/focus-selected dimensions. */
|
|
2551
|
+
protected _selectSize(size: EditorTableSize): void;
|
|
2552
|
+
/** @protected Executes insertion for a selected pointer cell. */
|
|
2553
|
+
protected _insertSize(size: EditorTableSize): void;
|
|
2554
|
+
/**
|
|
2555
|
+
* @protected Whether the caret's cell is already a header cell. Drives the
|
|
2556
|
+
* `aria-current` marker on the header-cell row so the menu says what the
|
|
2557
|
+
* table is, not only what it can become.
|
|
2558
|
+
*/
|
|
2559
|
+
protected _isHeaderCell(): boolean;
|
|
2560
|
+
/** @private Overlay-registration teardown for the open command menu. */
|
|
2561
|
+
private _unregisterMenu;
|
|
2562
|
+
/** @private Guards queued registration after a quick close or destroy. */
|
|
2563
|
+
private _menuOpen;
|
|
2564
|
+
/**
|
|
2565
|
+
* @protected Keeps the portalled menu panel inside the editor's composite
|
|
2566
|
+
* focus boundary. The panel exists only once the overlay has rendered, hence
|
|
2567
|
+
* the microtask; `_menuOpen` guards a close that beats it.
|
|
2568
|
+
*/
|
|
2569
|
+
protected _registerMenuOverlay(): void;
|
|
2570
|
+
/** @protected Drops the menu's overlay registration. */
|
|
2571
|
+
protected _unregisterMenuOverlay(): void;
|
|
2572
|
+
/** @protected Whether current selection and form state block an action. */
|
|
2573
|
+
protected _commandDisabled(command: (editor: Editor) => boolean): boolean;
|
|
2574
|
+
/** @protected Executes one contextual mutation through the public guard. */
|
|
2575
|
+
protected _run(command: (editor: Editor) => boolean, closeAfter?: boolean): void;
|
|
2576
|
+
/** @protected Handles bounded grid navigation and keyboard insertion. */
|
|
2577
|
+
protected _onGridKeydown(event: KeyboardEvent): void;
|
|
2578
|
+
/** @private Focuses the single row-major button matching selected dimensions. */
|
|
2579
|
+
private _focusSelectedCell;
|
|
2580
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorTable, never>;
|
|
2581
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorTable, "mlv-editor-table", never, {}, {}, never, never, true, never>;
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
/** A box in the zoom layer's own unscaled coordinate space. */
|
|
2585
|
+
interface MlvEditorTableBox {
|
|
2586
|
+
/** Distance from the layer's top edge, in unscaled pixels. */
|
|
2587
|
+
readonly top: number;
|
|
2588
|
+
/** Distance from the layer's start edge, in unscaled pixels. */
|
|
2589
|
+
readonly left: number;
|
|
2590
|
+
/** Unscaled width. */
|
|
2591
|
+
readonly width: number;
|
|
2592
|
+
/** Unscaled height. */
|
|
2593
|
+
readonly height: number;
|
|
2594
|
+
}
|
|
2595
|
+
/** Placement of the three grips that address one hovered table cell. */
|
|
2596
|
+
interface MlvEditorTableGeometry {
|
|
2597
|
+
/** Grip spanning the hovered row, sitting just outside the table's start edge. */
|
|
2598
|
+
readonly row: MlvEditorTableBox;
|
|
2599
|
+
/** Grip spanning the hovered column, sitting just above the table. */
|
|
2600
|
+
readonly column: MlvEditorTableBox;
|
|
2601
|
+
/** Square grip in the table's start-top corner, addressing the whole table. */
|
|
2602
|
+
readonly corner: MlvEditorTableBox;
|
|
2603
|
+
}
|
|
2604
|
+
/** Measurements `mlvEditorTableGeometry` derives the grip boxes from. */
|
|
2605
|
+
interface MlvEditorTableGeometryInput {
|
|
2606
|
+
/** Viewport rect of the hovered `td`/`th`. */
|
|
2607
|
+
readonly cell: MlvEditorTableBox;
|
|
2608
|
+
/** Viewport rect of the `table` the cell belongs to. */
|
|
2609
|
+
readonly table: MlvEditorTableBox;
|
|
2610
|
+
/** Viewport rect of the positioned zoom layer the grips are appended to. */
|
|
2611
|
+
readonly layer: MlvEditorTableBox;
|
|
2612
|
+
/**
|
|
2613
|
+
* Live scale of that layer. Viewport rects are scaled; the grips are laid out
|
|
2614
|
+
* inside the layer and scale with it, so every measurement is divided back
|
|
2615
|
+
* out exactly once here rather than at each use site.
|
|
2616
|
+
*/
|
|
2617
|
+
readonly scale: number;
|
|
2618
|
+
/** Thickness of a grip, already in the layer's unscaled space. */
|
|
2619
|
+
readonly gripSize: number;
|
|
2620
|
+
}
|
|
2621
|
+
/**
|
|
2622
|
+
* Places the row, column and corner grips for one hovered cell.
|
|
2623
|
+
*
|
|
2624
|
+
* The grips live inside the zoom layer, so they inherit its scale: everything
|
|
2625
|
+
* below is expressed in the layer's unscaled coordinates, and `gripSize` is
|
|
2626
|
+
* subtracted **after** the conversion so a grip keeps the same rendered
|
|
2627
|
+
* thickness at every zoom level.
|
|
2628
|
+
*
|
|
2629
|
+
* @param input Viewport rects for the cell, its table and the layer, plus the
|
|
2630
|
+
* layer scale and the unscaled grip thickness.
|
|
2631
|
+
* @returns Boxes ready to write onto `top` / `left` / `width` / `height`.
|
|
2632
|
+
*/
|
|
2633
|
+
declare function mlvEditorTableGeometry(input: MlvEditorTableGeometryInput): MlvEditorTableGeometry;
|
|
2634
|
+
|
|
2635
|
+
/**
|
|
2636
|
+
* Hover affordances for the table under the pointer: a grip beside the hovered
|
|
2637
|
+
* row, one above the hovered column and one in the table's corner, each opening
|
|
2638
|
+
* the commands scoped to what it points at.
|
|
2639
|
+
*
|
|
2640
|
+
* Pointer-only by design, matching `MlvEditorBlockHandle`: the grips are
|
|
2641
|
+
* `aria-hidden` and never focusable, so the content region stays the single
|
|
2642
|
+
* `role="textbox"` tab stop. Keyboard and assistive-technology users reach the
|
|
2643
|
+
* same commands through `mlv-editor-table` in the toolbar, which acts on the
|
|
2644
|
+
* cell the caret is already in.
|
|
2645
|
+
*/
|
|
2646
|
+
declare class MlvEditorTableControls {
|
|
2647
|
+
/**
|
|
2648
|
+
* The positioned, zoom-carrying layer the grips are laid out inside. Grips
|
|
2649
|
+
* are placed in its unscaled coordinate space, so they follow the content at
|
|
2650
|
+
* every zoom level without a second transform of their own.
|
|
2651
|
+
*/
|
|
2652
|
+
readonly layer: _angular_core.InputSignal<HTMLElement>;
|
|
2653
|
+
/** @protected Editor-scoped command and form state. */
|
|
2654
|
+
protected readonly _context: _malva_ui_editor.MlvEditorToolbarContext;
|
|
2655
|
+
/** @private Transaction and selection invalidation bridge. */
|
|
2656
|
+
private readonly _revision;
|
|
2657
|
+
/** @private Keeps grip menus inside the editor's composite focus boundary. */
|
|
2658
|
+
private readonly _overlays;
|
|
2659
|
+
/** @private Document used to resolve the public menu panel id. */
|
|
2660
|
+
private readonly _document;
|
|
2661
|
+
/** @private Reactive localized copy source. */
|
|
2662
|
+
private readonly _i18n;
|
|
2663
|
+
/**
|
|
2664
|
+
* @private The cell the grips currently address. Held as an element rather
|
|
2665
|
+
* than a document position so a re-measure after a scroll or a zoom change
|
|
2666
|
+
* needs no second `posAtDOM` round trip.
|
|
2667
|
+
*/
|
|
2668
|
+
private readonly _cell;
|
|
2669
|
+
/** @protected Placement of the three grips, or null while none are shown. */
|
|
2670
|
+
protected readonly _geometry: _angular_core.WritableSignal<MlvEditorTableGeometry | null>;
|
|
2671
|
+
/**
|
|
2672
|
+
* @private Set while a grip menu is open. The grips must survive the pointer
|
|
2673
|
+
* leaving the table to reach the menu, which is portalled outside it.
|
|
2674
|
+
*/
|
|
2675
|
+
private readonly _pinned;
|
|
2676
|
+
/** @private Overlay-registration teardown for the open grip menu. */
|
|
2677
|
+
private _unregister;
|
|
2678
|
+
/** @private Guards queued registration after a quick close or destroy. */
|
|
2679
|
+
private _menuOpen;
|
|
2680
|
+
/** @protected Localized labels for the three grips. */
|
|
2681
|
+
protected readonly _copy: _angular_core.Signal<{
|
|
2682
|
+
rowActions: string;
|
|
2683
|
+
columnActions: string;
|
|
2684
|
+
tableActions: string;
|
|
2685
|
+
addRowBefore: string;
|
|
2686
|
+
addRowAfter: string;
|
|
2687
|
+
deleteRow: string;
|
|
2688
|
+
addColumnBefore: string;
|
|
2689
|
+
addColumnAfter: string;
|
|
2690
|
+
deleteColumn: string;
|
|
2691
|
+
mergeCells: string;
|
|
2692
|
+
splitCell: string;
|
|
2693
|
+
toggleHeaderRow: string;
|
|
2694
|
+
toggleHeaderColumn: string;
|
|
2695
|
+
toggleHeaderCell: string;
|
|
2696
|
+
deleteTable: string;
|
|
2697
|
+
}>;
|
|
2698
|
+
/** @protected Whether the grips may act at all. */
|
|
2699
|
+
protected readonly _enabled: _angular_core.Signal<boolean>;
|
|
2700
|
+
constructor();
|
|
2701
|
+
/** @protected Inline placement for one grip box. */
|
|
2702
|
+
protected _style(box: MlvEditorTableBox): Record<string, string>;
|
|
2703
|
+
/**
|
|
2704
|
+
* @protected Keeps the grips mounted while their menu is open and keeps the
|
|
2705
|
+
* portalled panel inside the editor's composite focus boundary.
|
|
2706
|
+
*
|
|
2707
|
+
* The panel only exists once the overlay has rendered, hence the microtask;
|
|
2708
|
+
* `_menuOpen` guards a close that beats it.
|
|
2709
|
+
*/
|
|
2710
|
+
protected _openMenu(menu: MlvMenu): void;
|
|
2711
|
+
/** @protected Releases the pin and re-measures against the current pointer. */
|
|
2712
|
+
protected _closeMenu(): void;
|
|
2713
|
+
/** @private Drops any active overlay registration. */
|
|
2714
|
+
private _unregisterOverlay;
|
|
2715
|
+
/**
|
|
2716
|
+
* @protected Runs one table command against the cell the grip points at.
|
|
2717
|
+
*
|
|
2718
|
+
* The Tiptap table commands all act on the current selection, so the caret is
|
|
2719
|
+
* moved into the grip's own cell first. That is also what makes the grips
|
|
2720
|
+
* honest: the command a user picks from the row grip cannot land on whichever
|
|
2721
|
+
* row the caret happened to be sitting in.
|
|
2722
|
+
*/
|
|
2723
|
+
protected _run(command: (editor: Editor) => boolean): void;
|
|
2724
|
+
/** @protected Whether a command is currently unavailable for the grip's cell. */
|
|
2725
|
+
protected _disabled(command: (editor: Editor) => boolean): boolean;
|
|
2726
|
+
/** @protected `addRowBefore` in dispatching form. */
|
|
2727
|
+
protected readonly _addRowBefore: (editor: Editor) => boolean;
|
|
2728
|
+
/** @protected Non-dispatching `addRowBefore` capability check. */
|
|
2729
|
+
protected readonly _canAddRowBefore: (editor: Editor) => boolean;
|
|
2730
|
+
/** @protected `addRowAfter` in dispatching form. */
|
|
2731
|
+
protected readonly _addRowAfter: (editor: Editor) => boolean;
|
|
2732
|
+
/** @protected Non-dispatching `addRowAfter` capability check. */
|
|
2733
|
+
protected readonly _canAddRowAfter: (editor: Editor) => boolean;
|
|
2734
|
+
/** @protected `deleteRow` in dispatching form. */
|
|
2735
|
+
protected readonly _deleteRow: (editor: Editor) => boolean;
|
|
2736
|
+
/** @protected Non-dispatching `deleteRow` capability check. */
|
|
2737
|
+
protected readonly _canDeleteRow: (editor: Editor) => boolean;
|
|
2738
|
+
/** @protected `addColumnBefore` in dispatching form. */
|
|
2739
|
+
protected readonly _addColumnBefore: (editor: Editor) => boolean;
|
|
2740
|
+
/** @protected Non-dispatching `addColumnBefore` capability check. */
|
|
2741
|
+
protected readonly _canAddColumnBefore: (editor: Editor) => boolean;
|
|
2742
|
+
/** @protected `addColumnAfter` in dispatching form. */
|
|
2743
|
+
protected readonly _addColumnAfter: (editor: Editor) => boolean;
|
|
2744
|
+
/** @protected Non-dispatching `addColumnAfter` capability check. */
|
|
2745
|
+
protected readonly _canAddColumnAfter: (editor: Editor) => boolean;
|
|
2746
|
+
/** @protected `deleteColumn` in dispatching form. */
|
|
2747
|
+
protected readonly _deleteColumn: (editor: Editor) => boolean;
|
|
2748
|
+
/** @protected Non-dispatching `deleteColumn` capability check. */
|
|
2749
|
+
protected readonly _canDeleteColumn: (editor: Editor) => boolean;
|
|
2750
|
+
/** @protected `mergeCells` in dispatching form. */
|
|
2751
|
+
protected readonly _mergeCells: (editor: Editor) => boolean;
|
|
2752
|
+
/** @protected Non-dispatching `mergeCells` capability check. */
|
|
2753
|
+
protected readonly _canMergeCells: (editor: Editor) => boolean;
|
|
2754
|
+
/** @protected `splitCell` in dispatching form. */
|
|
2755
|
+
protected readonly _splitCell: (editor: Editor) => boolean;
|
|
2756
|
+
/** @protected Non-dispatching `splitCell` capability check. */
|
|
2757
|
+
protected readonly _canSplitCell: (editor: Editor) => boolean;
|
|
2758
|
+
/** @protected `toggleHeaderRow` in dispatching form. */
|
|
2759
|
+
protected readonly _toggleHeaderRow: (editor: Editor) => boolean;
|
|
2760
|
+
/** @protected Non-dispatching `toggleHeaderRow` capability check. */
|
|
2761
|
+
protected readonly _canToggleHeaderRow: (editor: Editor) => boolean;
|
|
2762
|
+
/** @protected `toggleHeaderColumn` in dispatching form. */
|
|
2763
|
+
protected readonly _toggleHeaderColumn: (editor: Editor) => boolean;
|
|
2764
|
+
/** @protected Non-dispatching `toggleHeaderColumn` capability check. */
|
|
2765
|
+
protected readonly _canToggleHeaderColumn: (editor: Editor) => boolean;
|
|
2766
|
+
/** @protected `toggleHeaderCell` in dispatching form. */
|
|
2767
|
+
protected readonly _toggleHeaderCell: (editor: Editor) => boolean;
|
|
2768
|
+
/** @protected Non-dispatching `toggleHeaderCell` capability check. */
|
|
2769
|
+
protected readonly _canToggleHeaderCell: (editor: Editor) => boolean;
|
|
2770
|
+
/** @protected `deleteTable` in dispatching form. */
|
|
2771
|
+
protected readonly _deleteTable: (editor: Editor) => boolean;
|
|
2772
|
+
/** @protected Non-dispatching `deleteTable` capability check. */
|
|
2773
|
+
protected readonly _canDeleteTable: (editor: Editor) => boolean;
|
|
2774
|
+
/** @private Resolves the cell under the pointer and re-places the grips. */
|
|
2775
|
+
private _track;
|
|
2776
|
+
/** @private Drops the grips. */
|
|
2777
|
+
private _release;
|
|
2778
|
+
/** @private Re-measures the pinned cell against the live layout. */
|
|
2779
|
+
private _measure;
|
|
2780
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorTableControls, never>;
|
|
2781
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorTableControls, "mlv-editor-table-controls", never, { "layer": { "alias": "layer"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
/** Public compatibility toolbar shell for standalone consumer use. */
|
|
2785
|
+
declare class MlvEditorToolbar {
|
|
2786
|
+
/** Accessible toolbar name. */
|
|
2787
|
+
readonly ariaLabel: _angular_core.InputSignal<string | undefined>;
|
|
2788
|
+
/** Whether all toolbar interactions are disabled. */
|
|
2789
|
+
readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
|
|
2790
|
+
/** Optional content rendered before built-in groups. */
|
|
2791
|
+
readonly startTemplate: _angular_core.InputSignal<TemplateRef<{
|
|
2792
|
+
$implicit: MlvEditorToolbarContext;
|
|
2793
|
+
}> | null>;
|
|
2794
|
+
/** Optional content rendered after built-in groups. */
|
|
2795
|
+
readonly endTemplate: _angular_core.InputSignal<TemplateRef<{
|
|
2796
|
+
$implicit: MlvEditorToolbarContext;
|
|
2797
|
+
}> | null>;
|
|
2798
|
+
/** Context supplied to custom toolbar templates. */
|
|
2799
|
+
readonly context: _angular_core.InputSignal<MlvEditorToolbarContext>;
|
|
2800
|
+
/** @internal Invalidates built-in command state for the supplied standalone editor. */
|
|
2801
|
+
private readonly _revision;
|
|
2802
|
+
constructor();
|
|
2803
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorToolbar, never>;
|
|
2804
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorToolbar, "mlv-editor-toolbar", never, { "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "startTemplate": { "alias": "startTemplate"; "required": false; "isSignal": true; }; "endTemplate": { "alias": "endTemplate"; "required": false; "isSignal": true; }; "context": { "alias": "context"; "required": true; "isSignal": true; }; }, {}, never, ["[mlvEditorToolbarStart]", "[mlvEditorToolbarEnd]", "*"], true, never>;
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
/** Marks a projected or built-in editor control as one editor-toolbar roving widget. */
|
|
2808
|
+
declare class MlvEditorToolbarWidget {
|
|
2809
|
+
/** @internal Native widget registered with the enclosing toolbar. */
|
|
2810
|
+
private readonly _element;
|
|
2811
|
+
/** @internal Editor-scoped roving-focus coordinator. */
|
|
2812
|
+
private readonly _registry;
|
|
2813
|
+
/** @internal Widget lifecycle for deregistration. */
|
|
2814
|
+
private readonly _destroyRef;
|
|
2815
|
+
/** @internal Derived tab stop for roving keyboard navigation. */
|
|
2816
|
+
protected readonly _tabIndex: _angular_core.Signal<0 | -1>;
|
|
2817
|
+
constructor();
|
|
2818
|
+
/** @internal Promotes this widget when it receives focus. */
|
|
2819
|
+
protected _activate(): void;
|
|
2820
|
+
/** @internal Promotes this widget before pointer activation. */
|
|
2821
|
+
protected _activateOnPointerDown(): void;
|
|
2822
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorToolbarWidget, never>;
|
|
2823
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<MlvEditorToolbarWidget, "[mlvEditorToolbarWidget]", never, {}, {}, never, never, true, never>;
|
|
2824
|
+
}
|
|
2825
|
+
|
|
2826
|
+
/** Undo and redo actions backed by Tiptap history commands. */
|
|
2827
|
+
declare class MlvEditorUndoRedo {
|
|
2828
|
+
/** @private Optional localized editor copy. */
|
|
2829
|
+
private readonly _i18n;
|
|
2830
|
+
/** @protected Resolved copy with SSR-safe English fallbacks. */
|
|
2831
|
+
protected readonly _copy: _angular_core.Signal<{
|
|
2832
|
+
undo: string;
|
|
2833
|
+
redo: string;
|
|
2834
|
+
}>;
|
|
2835
|
+
/** @protected Tiptap availability query for undo. */
|
|
2836
|
+
protected readonly _canUndo: (editor: Editor) => boolean;
|
|
2837
|
+
/** @protected Tiptap availability query for redo. */
|
|
2838
|
+
protected readonly _canRedo: (editor: Editor) => boolean;
|
|
2839
|
+
/** @protected Current history availability for undo. */
|
|
2840
|
+
protected readonly _canExecuteUndo: (editor: Editor) => boolean;
|
|
2841
|
+
/** @protected Current history availability for redo. */
|
|
2842
|
+
protected readonly _canExecuteRedo: (editor: Editor) => boolean;
|
|
2843
|
+
/** @protected Selection-restoring undo command. */
|
|
2844
|
+
protected readonly _undo: (editor: Editor) => boolean;
|
|
2845
|
+
/** @protected Selection-restoring redo command. */
|
|
2846
|
+
protected readonly _redo: (editor: Editor) => boolean;
|
|
2847
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorUndoRedo, never>;
|
|
2848
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorUndoRedo, "mlv-editor-undo-redo", never, {}, {}, never, never, true, never>;
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
/** View-only editor zoom stepper and preset menu. */
|
|
2852
|
+
declare class MlvEditorZoom implements OnChanges {
|
|
2853
|
+
/** Current view-only zoom percentage. */
|
|
2854
|
+
readonly zoom: _angular_core.ModelSignal<number>;
|
|
2855
|
+
/** Preset percentages displayed by the zoom menu. */
|
|
2856
|
+
readonly zoomLevels: _angular_core.InputSignal<readonly number[]>;
|
|
2857
|
+
/** Smallest permitted zoom percentage. */
|
|
2858
|
+
readonly min: _angular_core.InputSignal<number>;
|
|
2859
|
+
/** Largest permitted zoom percentage. */
|
|
2860
|
+
readonly max: _angular_core.InputSignal<number>;
|
|
2861
|
+
/** Recalculates the largest safe zoom whenever the content viewport resizes. */
|
|
2862
|
+
readonly fitToContainer: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
|
|
2863
|
+
/** @protected Editor-scoped view and command state. */
|
|
2864
|
+
protected readonly _context: _malva_ui_editor.MlvEditorToolbarContext;
|
|
2865
|
+
/** @private Shared observer abstraction for the editor viewport. */
|
|
2866
|
+
private readonly _resizeObserver;
|
|
2867
|
+
/** @private Component host used to retain a stable focus-restore target. */
|
|
2868
|
+
private readonly _host;
|
|
2869
|
+
/** @private Registry that keeps focus within the editor composite. */
|
|
2870
|
+
private readonly _overlays;
|
|
2871
|
+
/** @private Document used only after a browser menu opens. */
|
|
2872
|
+
private readonly _document;
|
|
2873
|
+
/** @private Component teardown scope. */
|
|
2874
|
+
private readonly _destroyRef;
|
|
2875
|
+
/** @private Prevents browser view access during server rendering. */
|
|
2876
|
+
private readonly _isBrowser;
|
|
2877
|
+
/** @private Optional reactive localized editor copy. */
|
|
2878
|
+
private readonly _i18n;
|
|
2879
|
+
/** @protected Rendered mixed-control popup. */
|
|
2880
|
+
protected readonly _popup: _angular_core.Signal<MlvPopup>;
|
|
2881
|
+
/** @protected Trigger that owns the detached popup. */
|
|
2882
|
+
protected readonly _trigger: _angular_core.Signal<MlvPopupTrigger>;
|
|
2883
|
+
/** @protected Percentage field focused when the popup opens. */
|
|
2884
|
+
protected readonly _input: _angular_core.Signal<MlvInput>;
|
|
2885
|
+
/** @protected Stable id used to resolve this component's detached panel. */
|
|
2886
|
+
protected readonly _panelId: string;
|
|
2887
|
+
/** @private Last synchronized model value. */
|
|
2888
|
+
private _lastZoom;
|
|
2889
|
+
/** @private Last synchronized editor-context value. */
|
|
2890
|
+
private _lastContextZoom;
|
|
2891
|
+
/** @private Distinguishes initial context adoption from later writes. */
|
|
2892
|
+
private _initialized;
|
|
2893
|
+
/** @private Whether Angular assigned the public model, including an explicit default. */
|
|
2894
|
+
private _zoomWasSupplied;
|
|
2895
|
+
/** @private Current detached-popup registration teardown. */
|
|
2896
|
+
private _unregister;
|
|
2897
|
+
/** @private Guards a queued popup registration after close or destroy. */
|
|
2898
|
+
private _menuOpen;
|
|
2899
|
+
/** @private Connected trigger retained while the popup is open. */
|
|
2900
|
+
private _restoreFocusTarget;
|
|
2901
|
+
/** @protected Numeric field draft kept separate until commit. */
|
|
2902
|
+
protected readonly _draft: _angular_core.WritableSignal<string>;
|
|
2903
|
+
/** @protected Normalized inclusive zoom bounds. */
|
|
2904
|
+
protected readonly _bounds: _angular_core.Signal<{
|
|
2905
|
+
min: number;
|
|
2906
|
+
max: number;
|
|
2907
|
+
}>;
|
|
2908
|
+
/** @protected Finite, in-range, sorted menu presets. */
|
|
2909
|
+
protected readonly _presetLevels: _angular_core.Signal<number[]>;
|
|
2910
|
+
/**
|
|
2911
|
+
* @protected Largest panel height in px. Nine presets plus the fit row scroll
|
|
2912
|
+
* inside the panel's own scrollbar rather than growing the popup, so the
|
|
2913
|
+
* percentage field above them stays pinned.
|
|
2914
|
+
*/
|
|
2915
|
+
protected readonly _PANEL_MAX_HEIGHT = 240;
|
|
2916
|
+
/** @protected Preset rows rendered by the dropdown panel, fit action last. */
|
|
2917
|
+
protected readonly _levelOptions: _angular_core.Signal<MlvSelectOption<number>[]>;
|
|
2918
|
+
/**
|
|
2919
|
+
* @protected Selected preset, or nothing when the current percentage is a
|
|
2920
|
+
* free-form value (typed in the field, or produced by a fit).
|
|
2921
|
+
*/
|
|
2922
|
+
protected readonly _selectedLevels: _angular_core.Signal<number[]>;
|
|
2923
|
+
/** @protected Whether the complete editor composite is disabled. */
|
|
2924
|
+
protected readonly _disabled: _angular_core.Signal<boolean>;
|
|
2925
|
+
/** @protected Reactive localized labels for every zoom surface. */
|
|
2926
|
+
protected readonly _copy: _angular_core.Signal<{
|
|
2927
|
+
zoom: string;
|
|
2928
|
+
zoomOut: string;
|
|
2929
|
+
zoomIn: string;
|
|
2930
|
+
fitToContainer: string;
|
|
2931
|
+
}>;
|
|
2932
|
+
/** @protected Whether decrementing would exceed the lower bound. */
|
|
2933
|
+
protected readonly _zoomOutDisabled: _angular_core.Signal<boolean>;
|
|
2934
|
+
/** @protected Whether incrementing would exceed the upper bound. */
|
|
2935
|
+
protected readonly _zoomInDisabled: _angular_core.Signal<boolean>;
|
|
2936
|
+
constructor();
|
|
2937
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
2938
|
+
/** @protected Selects the previous preset or the exact minimum. */
|
|
2939
|
+
protected _zoomOut(): void;
|
|
2940
|
+
/** @protected Selects the next preset or the exact maximum. */
|
|
2941
|
+
protected _zoomIn(): void;
|
|
2942
|
+
/** @protected Applies a menu preset without dispatching an editor transaction. */
|
|
2943
|
+
protected _select(level: number): void;
|
|
2944
|
+
/**
|
|
2945
|
+
* @protected Applies a dropdown row. The aria listbox also emits while it
|
|
2946
|
+
* reconciles its value against the rendered options — which drops a
|
|
2947
|
+
* free-form percentage to an empty array — so only a non-empty emission is a
|
|
2948
|
+
* user pick.
|
|
2949
|
+
*/
|
|
2950
|
+
protected _selectLevel(values: readonly number[]): void;
|
|
2951
|
+
/** @protected Commits a finite numeric field value and restores the normalized display. */
|
|
2952
|
+
protected _applyDraft(event?: Event): void;
|
|
2953
|
+
/** @protected Fits against the viewport's latest synchronous width. */
|
|
2954
|
+
protected _fitCurrentViewport(): void;
|
|
2955
|
+
/** @protected Registers the detached dialog and moves focus to its field. */
|
|
2956
|
+
protected _onPopupOpened(): void;
|
|
2957
|
+
/** @protected Releases focus ownership and restores the visible trigger. */
|
|
2958
|
+
protected _onPopupClosed(): void;
|
|
2959
|
+
/** @private Removes detached popup focus ownership without moving focus. */
|
|
2960
|
+
private _releaseOverlay;
|
|
2961
|
+
/** @private Synchronizes the literal public model with the nearest toolbar context. */
|
|
2962
|
+
private _synchronizeZoom;
|
|
2963
|
+
/** @private Ordered stepping levels, including exact configured bounds. */
|
|
2964
|
+
private _steps;
|
|
2965
|
+
/** @private Applies a clamped visual-only percentage to model and context. */
|
|
2966
|
+
private _setZoom;
|
|
2967
|
+
/** @private Calculates the largest integer zoom whose natural content fits. */
|
|
2968
|
+
private _fit;
|
|
2969
|
+
/** @private Clamps a finite percentage to the configured inclusive bounds. */
|
|
2970
|
+
private _clamp;
|
|
2971
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorZoom, never>;
|
|
2972
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorZoom, "mlv-editor-zoom", never, { "zoom": { "alias": "zoom"; "required": false; "isSignal": true; }; "zoomLevels": { "alias": "zoomLevels"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "fitToContainer": { "alias": "fitToContainer"; "required": false; "isSignal": true; }; }, { "zoom": "zoomChange"; }, never, never, true, never>;
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
/** Foreground-colour toolbar control backed by the reusable swatch picker. */
|
|
2976
|
+
declare class MlvEditorTextColor extends MlvEditorColorControl {
|
|
2977
|
+
/** @private Optional localized editor labels. */
|
|
2978
|
+
private readonly _i18n;
|
|
2979
|
+
/** @protected Localized accessible trigger and dialog label. */
|
|
2980
|
+
protected readonly _label: _angular_core.Signal<string>;
|
|
2981
|
+
/** @protected Exact command-presence capability without command execution. */
|
|
2982
|
+
protected readonly _supported: _angular_core.Signal<boolean>;
|
|
2983
|
+
/** @protected Active foreground colour rendered by the swatch. */
|
|
2984
|
+
protected readonly _activeColor: _angular_core.Signal<string>;
|
|
2985
|
+
/** @protected Applies or clears foreground colour without focusing Tiptap. */
|
|
2986
|
+
protected _run(editor: Editor, selection: {
|
|
2987
|
+
readonly from: number;
|
|
2988
|
+
readonly to: number;
|
|
2989
|
+
}, color: string): boolean;
|
|
2990
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MlvEditorTextColor, never>;
|
|
2991
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MlvEditorTextColor, "mlv-editor-text-color", never, {}, {}, never, never, true, never>;
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
export { MLV_EDITOR_AI_CARET_CLASS, MLV_EDITOR_AI_CONTEXT, MLV_EDITOR_AI_PROVIDER, MLV_EDITOR_AI_STREAMING_CHUNK_CLASS, MLV_EDITOR_AI_STREAMING_CLASS, MLV_EDITOR_AI_SUGGESTION_CURRENT_CLASS, MLV_EDITOR_AI_SUGGESTION_DELETE_CLASS, MLV_EDITOR_AI_SUGGESTION_INSERT_CLASS, MLV_EDITOR_DEFAULT_IMAGE_UPLOAD_OPTIONS, MLV_EDITOR_IMAGE_UPLOADER, MLV_EDITOR_TOOLBAR_CONTEXT, MlvEditor, MlvEditorAiContext, MlvEditorAiMenu, MlvEditorAiReviewBar, MlvEditorAlignment, MlvEditorBlockHandle, MlvEditorBlockInsert, MlvEditorFileHandler, MlvEditorHeading, MlvEditorHighlight, MlvEditorImageUpload, MlvEditorImageUploadControl, MlvEditorInlineMarks, MlvEditorLink, MlvEditorList, MlvEditorStatus, MlvEditorTable, MlvEditorTableControls, MlvEditorTextColor, MlvEditorToolbar, MlvEditorToolbarDef, MlvEditorToolbarEndDef, MlvEditorToolbarStartDef, MlvEditorToolbarWidget, MlvEditorUndoRedo, MlvEditorUploadPlaceholder, MlvEditorZoom, applyMlvEditorAiSuggestions, countMlvEditorWords, mlvEditorAiDefaultActions, mlvEditorAiReplaceRange, mlvEditorBlockHandleExtensions, mlvEditorDefaultExtensions, mlvEditorDefaultImageUrlPolicy, mlvEditorFormattingExtensions, mlvEditorImageExtensions, mlvEditorListExtensions, mlvEditorMarkdownExtensions, mlvEditorTableExtensions, mlvEditorTableGeometry, mlvEditorUtilityExtensions, normalizeMlvEditorCharacterLimit, runMlvEditorAiStream };
|
|
2995
|
+
export type { MlvEditorAiAction, MlvEditorAiBuiltInTransformKind, MlvEditorAiFrameScheduler, MlvEditorAiOutputMode, MlvEditorAiProvider, MlvEditorAiRequest, MlvEditorAiReviewSuggestion, MlvEditorAiStatus, MlvEditorAiStreamErrorCode, MlvEditorAiStreamHandle, MlvEditorAiStreamOptions, MlvEditorAiStreamOutputMode, MlvEditorAiStreamResult, MlvEditorAiStreamStatus, MlvEditorAiSuggestion, MlvEditorAiSuggestionKind, MlvEditorAiSuggestionRange, MlvEditorAiSuggestionsOptions, MlvEditorAiSuggestionsSession, MlvEditorAiTransformKind, MlvEditorAiTransformOptions, MlvEditorBlockHandleOptions, MlvEditorBlockMove, MlvEditorContentWidth, MlvEditorDefaultExtensionOptions, MlvEditorError, MlvEditorErrorCode, MlvEditorFileHandlerEvent, MlvEditorFocusEvent, MlvEditorFormat, MlvEditorFormattingExtensionOptions, MlvEditorHeadingLevel, MlvEditorImageExtensionOptions, MlvEditorImageUploadCancelled, MlvEditorImageUploadContext, MlvEditorImageUploadFailure, MlvEditorImageUploadOptions, MlvEditorImageUploadResult, MlvEditorImageUploadSource, MlvEditorImageUploadSuccess, MlvEditorImageUploader, MlvEditorImageUrlPolicy, MlvEditorInsertUploadPlaceholderOptions, MlvEditorListExtensionOptions, MlvEditorMarkdownExtensionOptions, MlvEditorPendingUpload, MlvEditorRemoveUploadPlaceholderOptions, MlvEditorReplaceUploadPlaceholderOptions, MlvEditorSelectionChange, MlvEditorTableBox, MlvEditorTableExtensionOptions, MlvEditorTableGeometry, MlvEditorTableGeometryInput, MlvEditorToolbarContext, MlvEditorTransactionEvent, MlvEditorUpdateUploadPlaceholderOptions, MlvEditorUploadPlaceholderItem, MlvEditorUploadPlaceholderStorage, MlvEditorUtilityExtensionOptions };
|