@malva-ui/editor 0.1.13 → 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.
Files changed (134) hide show
  1. package/README.md +5 -5
  2. package/fesm2022/malva-ui-editor-ai.mjs +17 -0
  3. package/fesm2022/malva-ui-editor-ai.mjs.map +1 -0
  4. package/fesm2022/malva-ui-editor.mjs +10227 -0
  5. package/fesm2022/malva-ui-editor.mjs.map +1 -0
  6. package/package.json +35 -26
  7. package/types/malva-ui-editor-ai.d.ts +1 -0
  8. package/types/malva-ui-editor.d.ts +2995 -0
  9. package/ai/index.d.ts +0 -12
  10. package/ai/malva-ui-editor-ai.d.ts +0 -5
  11. package/esm2022/ai/index.js +0 -12
  12. package/esm2022/ai/index.js.map +0 -1
  13. package/esm2022/ai/malva-ui-editor-ai.js +0 -5
  14. package/esm2022/ai/malva-ui-editor-ai.js.map +0 -1
  15. package/esm2022/index.js +0 -37
  16. package/esm2022/index.js.map +0 -1
  17. package/esm2022/lib/ai/editor-ai-actions.js +0 -69
  18. package/esm2022/lib/ai/editor-ai-actions.js.map +0 -1
  19. package/esm2022/lib/ai/editor-ai-context.js +0 -612
  20. package/esm2022/lib/ai/editor-ai-context.js.map +0 -1
  21. package/esm2022/lib/ai/editor-ai-menu.js +0 -288
  22. package/esm2022/lib/ai/editor-ai-menu.js.map +0 -1
  23. package/esm2022/lib/ai/editor-ai-review-bar.js +0 -223
  24. package/esm2022/lib/ai/editor-ai-review-bar.js.map +0 -1
  25. package/esm2022/lib/ai/editor-ai-stream.js +0 -677
  26. package/esm2022/lib/ai/editor-ai-stream.js.map +0 -1
  27. package/esm2022/lib/ai/editor-ai-suggestions.js +0 -751
  28. package/esm2022/lib/ai/editor-ai-suggestions.js.map +0 -1
  29. package/esm2022/lib/ai/editor-ai.tokens.js +0 -10
  30. package/esm2022/lib/ai/editor-ai.tokens.js.map +0 -1
  31. package/esm2022/lib/ai/editor-ai.types.js +0 -1
  32. package/esm2022/lib/ai/editor-ai.types.js.map +0 -1
  33. package/esm2022/lib/editor/editor.js +0 -985
  34. package/esm2022/lib/editor/editor.js.map +0 -1
  35. package/esm2022/lib/editor-extension-preflight.js +0 -83
  36. package/esm2022/lib/editor-extension-preflight.js.map +0 -1
  37. package/esm2022/lib/editor-serialization.js +0 -152
  38. package/esm2022/lib/editor-serialization.js.map +0 -1
  39. package/esm2022/lib/editor-toolbar-context.js +0 -259
  40. package/esm2022/lib/editor-toolbar-context.js.map +0 -1
  41. package/esm2022/lib/editor.tokens.js +0 -10
  42. package/esm2022/lib/editor.tokens.js.map +0 -1
  43. package/esm2022/lib/editor.types.js +0 -48
  44. package/esm2022/lib/editor.types.js.map +0 -1
  45. package/esm2022/lib/extensions/editor-block-handle.js +0 -760
  46. package/esm2022/lib/extensions/editor-block-handle.js.map +0 -1
  47. package/esm2022/lib/extensions/editor-extensions.js +0 -321
  48. package/esm2022/lib/extensions/editor-extensions.js.map +0 -1
  49. package/esm2022/lib/extensions/editor-markdown-compatibility.js +0 -162
  50. package/esm2022/lib/extensions/editor-markdown-compatibility.js.map +0 -1
  51. package/esm2022/lib/extensions/editor-upload-placeholder.js +0 -156
  52. package/esm2022/lib/extensions/editor-upload-placeholder.js.map +0 -1
  53. package/esm2022/lib/status/editor-status.js +0 -64
  54. package/esm2022/lib/status/editor-status.js.map +0 -1
  55. package/esm2022/lib/toolbar/editor-alignment.js +0 -203
  56. package/esm2022/lib/toolbar/editor-alignment.js.map +0 -1
  57. package/esm2022/lib/toolbar/editor-block-insert.js +0 -101
  58. package/esm2022/lib/toolbar/editor-block-insert.js.map +0 -1
  59. package/esm2022/lib/toolbar/editor-color-control.js +0 -71
  60. package/esm2022/lib/toolbar/editor-color-control.js.map +0 -1
  61. package/esm2022/lib/toolbar/editor-command-button.js +0 -115
  62. package/esm2022/lib/toolbar/editor-command-button.js.map +0 -1
  63. package/esm2022/lib/toolbar/editor-heading.js +0 -266
  64. package/esm2022/lib/toolbar/editor-heading.js.map +0 -1
  65. package/esm2022/lib/toolbar/editor-highlight.js +0 -84
  66. package/esm2022/lib/toolbar/editor-highlight.js.map +0 -1
  67. package/esm2022/lib/toolbar/editor-image-upload-dialog.js +0 -289
  68. package/esm2022/lib/toolbar/editor-image-upload-dialog.js.map +0 -1
  69. package/esm2022/lib/toolbar/editor-image-upload.js +0 -315
  70. package/esm2022/lib/toolbar/editor-image-upload.js.map +0 -1
  71. package/esm2022/lib/toolbar/editor-inline-marks.js +0 -124
  72. package/esm2022/lib/toolbar/editor-inline-marks.js.map +0 -1
  73. package/esm2022/lib/toolbar/editor-link.js +0 -265
  74. package/esm2022/lib/toolbar/editor-link.js.map +0 -1
  75. package/esm2022/lib/toolbar/editor-list.js +0 -249
  76. package/esm2022/lib/toolbar/editor-list.js.map +0 -1
  77. package/esm2022/lib/toolbar/editor-table.js +0 -292
  78. package/esm2022/lib/toolbar/editor-table.js.map +0 -1
  79. package/esm2022/lib/toolbar/editor-text-color.js +0 -82
  80. package/esm2022/lib/toolbar/editor-text-color.js.map +0 -1
  81. package/esm2022/lib/toolbar/editor-toolbar-widget.js +0 -41
  82. package/esm2022/lib/toolbar/editor-toolbar-widget.js.map +0 -1
  83. package/esm2022/lib/toolbar/editor-toolbar.defs.js +0 -60
  84. package/esm2022/lib/toolbar/editor-toolbar.defs.js.map +0 -1
  85. package/esm2022/lib/toolbar/editor-toolbar.js +0 -826
  86. package/esm2022/lib/toolbar/editor-toolbar.js.map +0 -1
  87. package/esm2022/lib/toolbar/editor-undo-redo.js +0 -72
  88. package/esm2022/lib/toolbar/editor-undo-redo.js.map +0 -1
  89. package/esm2022/lib/toolbar/editor-zoom.js +0 -330
  90. package/esm2022/lib/toolbar/editor-zoom.js.map +0 -1
  91. package/esm2022/lib/upload/editor-image-upload-coordinator.js +0 -480
  92. package/esm2022/lib/upload/editor-image-upload-coordinator.js.map +0 -1
  93. package/esm2022/malva-ui-editor.js +0 -5
  94. package/esm2022/malva-ui-editor.js.map +0 -1
  95. package/index.d.ts +0 -35
  96. package/lib/ai/editor-ai-actions.d.ts +0 -27
  97. package/lib/ai/editor-ai-context.d.ts +0 -307
  98. package/lib/ai/editor-ai-menu.d.ts +0 -142
  99. package/lib/ai/editor-ai-review-bar.d.ts +0 -116
  100. package/lib/ai/editor-ai-stream.d.ts +0 -207
  101. package/lib/ai/editor-ai-suggestions.d.ts +0 -219
  102. package/lib/ai/editor-ai.tokens.d.ts +0 -10
  103. package/lib/ai/editor-ai.types.d.ts +0 -176
  104. package/lib/editor/editor.d.ts +0 -243
  105. package/lib/editor-extension-preflight.d.ts +0 -23
  106. package/lib/editor-serialization.d.ts +0 -74
  107. package/lib/editor-toolbar-context.d.ts +0 -116
  108. package/lib/editor.tokens.d.ts +0 -6
  109. package/lib/editor.types.d.ts +0 -194
  110. package/lib/extensions/editor-block-handle.d.ts +0 -59
  111. package/lib/extensions/editor-extensions.d.ts +0 -165
  112. package/lib/extensions/editor-markdown-compatibility.d.ts +0 -11
  113. package/lib/extensions/editor-upload-placeholder.d.ts +0 -75
  114. package/lib/status/editor-status.d.ts +0 -24
  115. package/lib/toolbar/editor-alignment.d.ts +0 -61
  116. package/lib/toolbar/editor-block-insert.d.ts +0 -26
  117. package/lib/toolbar/editor-color-control.d.ts +0 -32
  118. package/lib/toolbar/editor-command-button.d.ts +0 -29
  119. package/lib/toolbar/editor-heading.d.ts +0 -68
  120. package/lib/toolbar/editor-highlight.d.ts +0 -21
  121. package/lib/toolbar/editor-image-upload-dialog.d.ts +0 -96
  122. package/lib/toolbar/editor-image-upload.d.ts +0 -71
  123. package/lib/toolbar/editor-inline-marks.d.ts +0 -30
  124. package/lib/toolbar/editor-link.d.ts +0 -78
  125. package/lib/toolbar/editor-list.d.ts +0 -67
  126. package/lib/toolbar/editor-table.d.ts +0 -133
  127. package/lib/toolbar/editor-text-color.d.ts +0 -21
  128. package/lib/toolbar/editor-toolbar-widget.d.ts +0 -19
  129. package/lib/toolbar/editor-toolbar.d.ts +0 -157
  130. package/lib/toolbar/editor-toolbar.defs.d.ts +0 -35
  131. package/lib/toolbar/editor-undo-redo.d.ts +0 -26
  132. package/lib/toolbar/editor-zoom.d.ts +0 -108
  133. package/lib/upload/editor-image-upload-coordinator.d.ts +0 -55
  134. package/malva-ui-editor.d.ts +0 -5
@@ -1,307 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- import type { Signal } from '@angular/core';
3
- import type { MlvEditorAiOutputMode, MlvEditorAiProvider, MlvEditorAiReviewSuggestion, MlvEditorAiTransformKind } from './editor-ai.types';
4
- import * as i0 from "@angular/core";
5
- /**
6
- * Lifecycle of the per-editor AI surface.
7
- *
8
- * `'idle'` — no AI work is in flight. `'running'` — a transform is streaming
9
- * into the document, or a `'review'` transform is collecting its result.
10
- * `'reviewing'` — a collected result was applied as tracked suggestions that
11
- * await per-change or bulk accept/reject; the state ends when the suggestion
12
- * set empties.
13
- */
14
- export type MlvEditorAiStatus = 'idle' | 'running' | 'reviewing';
15
- /** Options accepted by {@link MlvEditorAiContext.runTransform}. */
16
- export interface MlvEditorAiTransformOptions {
17
- /**
18
- * Free-form transform argument: the prompt for `'custom'`, the target tone
19
- * for `'tone'`, or the target language for `'translate'`.
20
- */
21
- readonly instruction?: string;
22
- /**
23
- * Where the streamed result lands; defaults to `'replace-selection'`.
24
- * `'review'` collects the complete result without touching the document
25
- * and applies it as reviewable tracked suggestions on success.
26
- */
27
- readonly output?: MlvEditorAiOutputMode;
28
- }
29
- /**
30
- * @internal Supplies the owning `mlv-editor`'s `aiProvider` input signal to
31
- * the per-editor AI context. The input wins over `MLV_EDITOR_AI_PROVIDER`,
32
- * mirroring the image-uploader precedence rule. Deliberately excluded from
33
- * the public barrels.
34
- */
35
- export declare const MLV_EDITOR_AI_INPUT_PROVIDER: InjectionToken<Signal<MlvEditorAiProvider | undefined>>;
36
- /**
37
- * Per-editor AI command state provided by `mlv-editor`.
38
- *
39
- * The context owns provider resolution, request shaping, and the streaming
40
- * and review session lifecycles; the framework-free engines
41
- * ({@link runMlvEditorAiStream}, {@link applyMlvEditorAiSuggestions}) own
42
- * document mutation. Every mutation is
43
- * gated by the toolbar context's guard, so readonly and disabled editors
44
- * refuse to start AI work — controls stay visible while a provider exists
45
- * (presence) and disable with the editor (executability), matching the
46
- * toolbar's presence-vs-executability rule.
47
- *
48
- * Failures never throw or reject: they surface as recoverable
49
- * {@link MlvEditorError} emissions through the owning editor's `editorError`
50
- * output. Cancellation stays silent.
51
- */
52
- export declare class MlvEditorAiContext {
53
- /** @private Guarded command surface and error channel of the owning editor. */
54
- private readonly _toolbar;
55
- /** @private Application-level provider used when the input supplies none. */
56
- private readonly _injectedProvider;
57
- /** @private The owning editor's `aiProvider` input; wins over the token. */
58
- private readonly _inputProvider;
59
- /** @private Announces streaming lifecycle politely; decorations are aria-hidden. */
60
- private readonly _liveAnnouncer;
61
- /** @private Optional translated announcement strings. */
62
- private readonly _i18n;
63
- /** @private Resolves the ICU review-count announcement template. */
64
- private readonly _resolver;
65
- /** @private Writable lifecycle state behind the readonly public signal. */
66
- private readonly _status;
67
- /** @private Writable pending-suggestion projection behind the readonly signal. */
68
- private readonly _suggestions;
69
- /**
70
- * @private Latest streaming session. Retained after settlement so
71
- * {@link restoreCheckpoint} can undo a committed transform; replaced when
72
- * the next transform starts.
73
- */
74
- private _session;
75
- /** @private Abort control for the in-flight provider request, if any. */
76
- private _abortController;
77
- /**
78
- * @private Active review wiring: the engine session plus the teardown that
79
- * detaches the editor `transaction`/`destroy` listeners mirroring it into
80
- * {@link suggestions}. `null` outside `'reviewing'`.
81
- */
82
- private _review;
83
- /**
84
- * @private Last suggestion id {@link revealSuggestion} announced. Repeated
85
- * reveals of the same suggestion (the review bar re-runs its outline effect
86
- * on unrelated signal updates) must not re-announce it.
87
- */
88
- private _revealedId;
89
- /** Lifecycle of the AI surface for this editor. */
90
- readonly status: Signal<MlvEditorAiStatus>;
91
- /**
92
- * Pending suggestions of the active review session, in document order.
93
- * Empty outside `'reviewing'`. Refreshed after every editor transaction, so
94
- * accept/reject calls, intersecting user edits, and an undo of the
95
- * application are all reflected immediately. Document ranges deliberately
96
- * stay internal — they remap on every transaction and would be stale the
97
- * moment a consumer stored them.
98
- */
99
- readonly suggestions: Signal<readonly MlvEditorAiReviewSuggestion[]>;
100
- /**
101
- * Whether a review session with unresolved suggestions is active. Hosts
102
- * gate saves on this: during `'reviewing'` the document serializes in its
103
- * accepted-by-default shape (inserted text present, removed text absent).
104
- */
105
- readonly hasPendingSuggestions: Signal<boolean>;
106
- /**
107
- * Whether an AI provider is resolvable for this editor, either through the
108
- * `aiProvider` input or `MLV_EDITOR_AI_PROVIDER`. AI UI modules hide
109
- * entirely without a provider.
110
- */
111
- readonly hasProvider: Signal<boolean>;
112
- /**
113
- * Runs one selection transform through the resolved provider and lands the
114
- * result according to the output mode: `'replace-selection'` and
115
- * `'insert-below'` stream into the document, while `'review'` collects the
116
- * complete result without writing and then applies it over the selection
117
- * captured at start as reviewable tracked suggestions — status moves to
118
- * `'reviewing'` and the suggestion surface
119
- * ({@link suggestions}, {@link acceptSuggestion}, …) takes over. A review
120
- * result identical to the region applies nothing: status returns straight
121
- * to `'idle'` with a polite no-changes announcement and no error.
122
- *
123
- * The returned promise resolves after the session settles and never
124
- * rejects; every failure is reported as a recoverable error through the
125
- * editor's `editorError` output instead:
126
- *
127
- * - a transform already running, or a review still pending
128
- * (`configuration`) — concurrent calls are refused rather than queued,
129
- * so one editor never hosts two writers and pending suggestions are
130
- * never silently replaced;
131
- * - a readonly, disabled, or absent editor (`configuration`) — the toolbar
132
- * guard refuses to start, and a `'review'` run re-checks the same guard
133
- * after collection: an editor that became readonly or disabled mid-run
134
- * refuses to apply the collected suggestions (checkpoint untouched — a
135
- * review collection never wrote);
136
- * - no resolvable provider (`configuration`);
137
- * - a provider that throws or whose stream fails (`'ai-transport'`) — the
138
- * checkpoint is restored;
139
- * - unusable output (`'ai-result'`) — the checkpoint is restored. Both
140
- * restore paths are no-ops for `'review'`, which never wrote.
141
- *
142
- * Start, successful finish, and cancellation are announced through the CDK
143
- * `LiveAnnouncer` at `'polite'`; a successful `'review'` run announces the
144
- * pending suggestion count instead of the generic finish. A failure
145
- * announces nothing because the error channel already reports it.
146
- *
147
- * @param kind Transform requested from the provider.
148
- * @param options Optional instruction and output mode.
149
- */
150
- runTransform(kind: MlvEditorAiTransformKind, options?: MlvEditorAiTransformOptions): Promise<void>;
151
- /**
152
- * Aborts the in-flight request and rolls the document back to the
153
- * checkpoint captured when the transform started.
154
- *
155
- * The provider's `AbortSignal` aborts, the streaming session restores the
156
- * checkpoint, and the transform resolves silently — no error is emitted
157
- * and only the cancellation announcement is made. A no-op while idle.
158
- */
159
- cancel(): void;
160
- /**
161
- * Restores the document to the checkpoint of the most recent transform.
162
- *
163
- * While a transform is running this behaves exactly like {@link cancel}.
164
- * After a committed transform it reverts the commit in one history-visible
165
- * step, so the restore is itself undoable. While `'reviewing'`, restoring
166
- * reverts the applied suggestions wholesale, which drops the suggestion
167
- * set and ends the review. The restore is a document mutation and
168
- * therefore passes the toolbar guard: readonly and disabled editors refuse
169
- * it. A no-op when no transform has run.
170
- */
171
- restoreCheckpoint(): void;
172
- /**
173
- * Accepts one pending suggestion: the applied change stays in the document
174
- * and its decorations drop. Delegates to the review engine — a pure
175
- * plugin-state update that creates no history entry. Announces the
176
- * acceptance politely; when the last suggestion resolves the review ends
177
- * and {@link status} returns to `'idle'`.
178
- *
179
- * Refused silently — decorations stay visible, nothing changes — while no
180
- * review is active, the id is unknown, or the editor is readonly or
181
- * disabled (the same guard rule that blocks every other AI mutation).
182
- *
183
- * @param id Identifier from {@link suggestions}.
184
- */
185
- acceptSuggestion(id: string): void;
186
- /**
187
- * Rejects one pending suggestion: the original content is restored over
188
- * the suggestion's range in exactly one history-visible step and its
189
- * decorations drop. Announces the rejection politely; when the last
190
- * suggestion resolves the review ends and {@link status} returns to
191
- * `'idle'`.
192
- *
193
- * Refused silently while no review is active, the id is unknown, or the
194
- * editor is readonly or disabled — the restore is a document mutation and
195
- * runs through the toolbar guard.
196
- *
197
- * @param id Identifier from {@link suggestions}.
198
- */
199
- rejectSuggestion(id: string): void;
200
- /**
201
- * Accepts every pending suggestion in one plugin-state update — no
202
- * document step, no history entry — then ends the review and returns
203
- * {@link status} to `'idle'`. Announced politely. Refused silently while
204
- * no review is active or the editor is readonly or disabled.
205
- */
206
- acceptAll(): void;
207
- /**
208
- * Rejects every pending suggestion in exactly one history-visible step,
209
- * restoring the original content of the whole reviewed region, then ends
210
- * the review and returns {@link status} to `'idle'`. Announced politely.
211
- * Refused silently while no review is active or the editor is readonly or
212
- * disabled — the restore is a document mutation and runs through the
213
- * toolbar guard.
214
- */
215
- rejectAll(): void;
216
- /**
217
- * Outlines one pending suggestion as the current one under review and
218
- * scrolls its document range into view; `null` clears the outline (review
219
- * surfaces call that on teardown so no marker strands).
220
- *
221
- * The outline decorations are `aria-hidden`, so revealing a suggestion also
222
- * announces its {@link describeSuggestion} description politely — index,
223
- * count, and the removed/added text — the non-visual equivalent the spec
224
- * requires. Each suggestion is announced once per reveal: repeating the
225
- * current id moves nothing and re-announces nothing.
226
- *
227
- * Otherwise a pure view affordance: the outline is a decoration-only
228
- * plugin-state update, so no document step and no history entry is created
229
- * — which is why, unlike accept/reject, it stays available in readonly
230
- * editors, whose pending reviews remain visible and navigable. Refused
231
- * silently while no review is active or the id is unknown. The review bar
232
- * drives this from its navigation cursor.
233
- *
234
- * @param id Identifier from {@link suggestions}, or `null` to clear.
235
- */
236
- revealSuggestion(id: string | null): void;
237
- /**
238
- * Human-readable description of one pending suggestion — its one-based
239
- * position in the pending list plus what it replaces, inserts, or removes —
240
- * resolved through the `aiCurrentSuggestionReplace`/`-Insert`/`-Delete`
241
- * ICU templates.
242
- *
243
- * This is the non-visual equivalent of the `aria-hidden` suggestion
244
- * decorations: {@link revealSuggestion} announces it, and the review bar
245
- * additionally exposes it to its accept/reject controls through
246
- * `aria-describedby`, so the change under decision is inspectable without
247
- * sight of the decorations. Returns `null` while no review is active or
248
- * for an unknown id.
249
- *
250
- * @param id Identifier from {@link suggestions}.
251
- */
252
- describeSuggestion(id: string): string | null;
253
- /**
254
- * @private Scrolls the rendered element at one document position into view.
255
- * Best effort: position resolution can fail transiently mid-transaction and
256
- * jsdom offers no `scrollIntoView`, so failure never fails the reveal.
257
- */
258
- private _scrollPositionIntoView;
259
- /**
260
- * @private Routes a committed review collection through the suggestion
261
- * engine. An engine refusal — the replacement is identical to the region,
262
- * or otherwise nothing reviewable results — is the no-changes case: status
263
- * returns to `'idle'` with a polite announcement, no error, and no
264
- * document change. Otherwise the context enters `'reviewing'`, mirrors the
265
- * engine's suggestion set into {@link suggestions} after every editor
266
- * transaction (the session has no change notification of its own), and
267
- * announces the pending count.
268
- */
269
- private _startReview;
270
- /**
271
- * @private Ends the review session exactly once: detaches the editor
272
- * listeners, clears the suggestion projection, and returns to `'idle'`.
273
- * Runs when the suggestion set empties — accept/reject calls, intersecting
274
- * edits dropping the last suggestion, or an undo of the application — and
275
- * when the editor is destroyed.
276
- */
277
- private _endReview;
278
- /** @private Projects engine suggestions into the range-free public shape. */
279
- private _projectSuggestions;
280
- /** @private Announces the pending review count politely through the ICU template. */
281
- private _announceReviewStarted;
282
- /** @private Resolves the active provider; the input wins over the token. */
283
- private _resolveProvider;
284
- /** @private Reports a recoverable configuration refusal through the editor. */
285
- private _reportConfiguration;
286
- /** @private Announces one localized AI lifecycle message politely. */
287
- private _announce;
288
- /**
289
- * @private Serializes the current selection as Markdown, or `null` when the
290
- * selection is empty. Uses the editor's Markdown manager — the same
291
- * serialization path as `getMarkdown()` — over the selection sliced into
292
- * its own document; a replacement extension set without Markdown falls back
293
- * to plain text so providers still receive usable context.
294
- */
295
- private _serializeSelection;
296
- /**
297
- * @private Serializes the whole document as Markdown, or `null` when the
298
- * document is semantically empty. The document window is currently the full
299
- * document; a bounded window is a later refinement. Falls back to plain
300
- * text when the extension set carries no Markdown manager.
301
- */
302
- private _serializeDocument;
303
- static ɵfac: i0.ɵɵFactoryDeclaration<MlvEditorAiContext, never>;
304
- static ɵprov: i0.ɵɵInjectableDeclaration<MlvEditorAiContext>;
305
- }
306
- /** Injects the AI command state belonging to the nearest `mlv-editor`. */
307
- export declare const MLV_EDITOR_AI_CONTEXT: InjectionToken<MlvEditorAiContext>;
@@ -1,142 +0,0 @@
1
- import type { BooleanInput } from '@angular/cdk/coercion';
2
- import type { Signal } from '@angular/core';
3
- import { ElementRef } from '@angular/core';
4
- import { MlvInput } from '@malva-ui/core/input';
5
- import { MlvMenu, MlvMenuTrigger } from '@malva-ui/core/menu';
6
- import { MlvPopup } from '@malva-ui/core/popup';
7
- import type { MlvEditorAiAction, MlvEditorAiOutputMode } from './editor-ai.types';
8
- import * as i0 from "@angular/core";
9
- /**
10
- * Toolbar command group for the editor's AI transforms.
11
- *
12
- * A sparkles trigger opens a Malva menu with one item per action; an action
13
- * runs its kind through the context with `output: 'replace-selection'` unless
14
- * it says otherwise, while the custom-prompt item opens a Malva popup with an
15
- * instruction field and an output-mode choice (replace selection, insert
16
- * below, or land as reviewable suggestions). While a transform is running the
17
- * same trigger becomes a stop affordance that cancels the in-flight request,
18
- * so the control stays one roving tab stop throughout.
19
- *
20
- * The action list is a thin layer over {@link MlvEditorAiContext.runTransform}:
21
- * the seven built-in kinds are only the default. `actions` replaces them
22
- * literally with a host-authored list — any kind string, a fixed instruction,
23
- * a per-action output mode, or an own `run` callback — and
24
- * `showCustomPrompt="false"` drops the custom-prompt item and its popup.
25
- *
26
- * The group hides entirely when the nearest {@link MLV_EDITOR_AI_CONTEXT}
27
- * resolves no provider (presence), and its actions disable — without hiding —
28
- * while the editor is readonly or disabled or a transform is already running
29
- * (executability), matching the toolbar's presence-vs-executability rule.
30
- */
31
- export declare class MlvEditorAiMenu {
32
- /**
33
- * The menu's action list, replacing the built-in kinds literally — the
34
- * house rule for list-shaped inputs (`extensions`, the toolbar definitions):
35
- * a supplied array is never merged with the defaults.
36
- *
37
- * Omitted (the default), the menu renders the seven built-in transforms
38
- * labelled from `MLV_EDITOR_I18N`. To keep them and add to them, spread
39
- * `mlvEditorAiDefaultActions(copy)` — the very list this component uses.
40
- * The custom-prompt item is independent of this input; drop it with
41
- * {@link showCustomPrompt}.
42
- */
43
- readonly actions: import("@angular/core").InputSignal<readonly MlvEditorAiAction[] | undefined>;
44
- /**
45
- * Whether the built-in custom-prompt item and its popup exist at all.
46
- *
47
- * `false` removes the menu item and never renders the prompt popup, for
48
- * hosts whose action list already covers everything they want offered.
49
- */
50
- readonly showCustomPrompt: import("@angular/core").InputSignalWithTransform<BooleanInput, string | boolean>;
51
- /** @protected AI command state of the nearest editor, if provided. */
52
- protected readonly _ai: import("@malva-ui/editor").MlvEditorAiContext | null;
53
- /** @protected Editor-scoped form state gating executability. */
54
- protected readonly _context: import("@malva-ui/editor").MlvEditorToolbarContext;
55
- /** @private Detached panel ownership for composite focus. */
56
- private readonly _overlays;
57
- /** @private Document used to resolve the public menu panel id. */
58
- private readonly _document;
59
- /** @private Cleans an active menu-overlay registration. */
60
- private readonly _destroyRef;
61
- /** @private Optional localized editor copy. */
62
- private readonly _i18n;
63
- /** @protected Rendered Malva transforms menu. */
64
- protected readonly _menu: Signal<MlvMenu>;
65
- /** @protected Trigger owning the menu overlay. */
66
- protected readonly _menuTrigger: Signal<MlvMenuTrigger>;
67
- /**
68
- * @protected Custom-prompt popup opened programmatically. Optional because
69
- * `showCustomPrompt="false"` removes it from the template entirely.
70
- */
71
- protected readonly _popup: Signal<MlvPopup | undefined>;
72
- /** @protected Native trigger restored after popup teardown. */
73
- protected readonly _triggerElement: Signal<ElementRef<HTMLButtonElement>>;
74
- /** @protected Instruction field focused when the prompt opens. */
75
- protected readonly _instructionInput: Signal<MlvInput>;
76
- /** @private Detached prompt panel queried through Angular rather than selectors. */
77
- private readonly _panel;
78
- /** @protected Custom-prompt instruction draft, retained across opens. */
79
- protected readonly _instruction: import("@angular/core").WritableSignal<string>;
80
- /** @protected Output mode applied to the custom transform. */
81
- protected readonly _output: import("@angular/core").WritableSignal<MlvEditorAiOutputMode>;
82
- /** @private Menu-overlay registration teardown. */
83
- private _unregisterMenu;
84
- /** @private Guards queued menu registration after a quick close or destroy. */
85
- private _menuOpen;
86
- /**
87
- * @protected Action entries rendered before the custom-prompt item: the
88
- * host's list when supplied, otherwise the localized built-ins. The factory
89
- * is the single source of the built-in label table.
90
- */
91
- protected readonly _actions: Signal<readonly MlvEditorAiAction[]>;
92
- /** @protected Reactive localized copy for the trigger and prompt. */
93
- protected readonly _copy: Signal<{
94
- aiMenu: string;
95
- aiCustom: string;
96
- aiPromptPlaceholder: string;
97
- aiOutputMode: string;
98
- aiReplaceSelection: string;
99
- aiInsertBelow: string;
100
- aiReviewChanges: string;
101
- aiApply: string;
102
- aiCancel: string;
103
- }>;
104
- /** @protected Whether an AI provider is resolvable; the group hides without one. */
105
- protected readonly _hasProvider: Signal<boolean>;
106
- /** @protected Whether a transform is streaming, swapping the trigger to stop. */
107
- protected readonly _running: Signal<boolean>;
108
- /** @protected Whether readonly/disabled state blocks every AI mutation. */
109
- protected readonly _disabled: Signal<boolean>;
110
- /** @protected Whether menu items cannot currently start a transform. */
111
- protected readonly _itemsDisabled: Signal<boolean>;
112
- /** @protected Whether the apply action cannot submit the custom prompt. */
113
- protected readonly _applyDisabled: Signal<boolean>;
114
- constructor();
115
- /** @protected Stops the running transform; the menu trigger opens otherwise. */
116
- protected _onTriggerClick(): void;
117
- /**
118
- * @protected Runs one action: its own `run` callback when it has one,
119
- * otherwise its kind through the context with the action's instruction and
120
- * output mode. The executability guard is re-checked here so a host `run`
121
- * callback cannot fire on a readonly, disabled, or busy editor either.
122
- */
123
- protected _runAction(action: MlvEditorAiAction): void;
124
- /** @protected Opens the custom-prompt popup from its menu item. */
125
- protected _openPrompt(): void;
126
- /** @protected Closes the custom-prompt popup without running a transform. */
127
- protected _closePrompt(): void;
128
- /** @protected Runs the custom transform with the drafted instruction and mode. */
129
- protected _apply(): void;
130
- /** @protected Focuses and selects the instruction draft once the prompt opens. */
131
- protected _onPromptOpened(): void;
132
- /** @protected Restores the connected toolbar trigger after final teardown. */
133
- protected _onPromptClosed(): void;
134
- /** @protected Narrows the radio group's untyped value to an output mode. */
135
- protected _onOutputChange(value: unknown): void;
136
- /** @protected Registers the portaled menu panel with the editor composite. */
137
- protected _registerMenuOverlay(): void;
138
- /** @protected Removes menu panel focus ownership after close. */
139
- protected _unregisterMenuOverlay(): void;
140
- static ɵfac: i0.ɵɵFactoryDeclaration<MlvEditorAiMenu, never>;
141
- static ɵcmp: i0.ɵɵ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>;
142
- }
@@ -1,116 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- /**
3
- * Review surface for pending AI suggestions.
4
- *
5
- * Rendered inside the editor composite — hosts project it into the status
6
- * region (`<mlv-editor-ai-review-bar mlvEditorStatus />`), following the
7
- * `MlvEditorStatus` placement. Hidden while the nearest
8
- * {@link MLV_EDITOR_AI_CONTEXT} is `'idle'` (or absent); while `'running'` it
9
- * shows a stop affordance that cancels the in-flight request, and while
10
- * `'reviewing'` it shows the pending-suggestion count, previous/next
11
- * navigation, accept/reject for the current suggestion, and accept-all/
12
- * reject-all.
13
- *
14
- * Navigation keeps an internal cursor over the context's suggestion list;
15
- * moving it outlines the current suggestion in the document
16
- * (`MLV_EDITOR_AI_SUGGESTION_CURRENT_CLASS` decoration) and scrolls its range
17
- * into view through {@link MlvEditorAiContext.revealSuggestion}. Accepting or
18
- * rejecting the current suggestion advances to the next remaining one (the
19
- * list shrinks under a clamped cursor); when the set empties the context
20
- * returns to `'idle'` and the bar disappears.
21
- *
22
- * Announcement choice: the count region is deliberately **not** an
23
- * `aria-live` region. The AI context already announces the review lifecycle —
24
- * `aiReviewStarted` with the count, and every accept/reject outcome — through
25
- * the CDK `LiveAnnouncer`; a live count would double-announce each change.
26
- *
27
- * The host element registers with the editor's composite-overlay registry, so
28
- * interacting with the bar never emits a false editor blur wherever a host
29
- * renders it. All controls are plain tab stops inside the composite. Accept,
30
- * reject, and navigation disable while the editor is readonly or disabled
31
- * (mutations are refused by the context anyway; the disabled state makes the
32
- * refusal visible), and the whole bar disables with the editor.
33
- */
34
- export declare class MlvEditorAiReviewBar {
35
- /** @protected AI command state of the nearest editor, if provided. */
36
- protected readonly _ai: import("@malva-ui/editor").MlvEditorAiContext | null;
37
- /** @protected Editor-scoped form state gating executability. */
38
- protected readonly _context: import("@malva-ui/editor").MlvEditorToolbarContext;
39
- /** @private Composite focus ownership for the bar's host element. */
40
- private readonly _overlays;
41
- /** @private Host element registered with the composite-overlay registry. */
42
- private readonly _host;
43
- /** @private Clears the current-suggestion outline on teardown. */
44
- private readonly _destroyRef;
45
- /** @private Optional localized editor copy. */
46
- private readonly _i18n;
47
- /** @private Resolves the ICU pending-count template. */
48
- private readonly _resolver;
49
- /**
50
- * @private Navigation cursor over the suggestion list. Reset for every new
51
- * review; reads clamp through {@link _index}, so a cursor left beyond the
52
- * end after the list shrinks points at the last remaining suggestion.
53
- */
54
- private readonly _cursor;
55
- /** @protected Reactive localized copy for every control and the count. */
56
- protected readonly _copy: import("@angular/core").Signal<{
57
- aiReviewBar: string;
58
- aiReviewCount: string;
59
- aiPreviousSuggestion: string;
60
- aiNextSuggestion: string;
61
- aiAcceptSuggestion: string;
62
- aiRejectSuggestion: string;
63
- aiAcceptAll: string;
64
- aiRejectAll: string;
65
- aiStopGeneration: string;
66
- }>;
67
- /** @protected Whether a transform is streaming, showing the stop affordance. */
68
- protected readonly _running: import("@angular/core").Signal<boolean>;
69
- /** @protected Whether a review with pending suggestions is active. */
70
- protected readonly _reviewing: import("@angular/core").Signal<boolean>;
71
- /** @protected The bar renders only while AI work is running or under review. */
72
- protected readonly _visible: import("@angular/core").Signal<boolean>;
73
- /** @protected Whether readonly/disabled state blocks every AI action. */
74
- protected readonly _disabled: import("@angular/core").Signal<boolean>;
75
- /** @protected Pending suggestions mirrored from the AI context. */
76
- protected readonly _suggestions: import("@angular/core").Signal<readonly import("@malva-ui/editor").MlvEditorAiReviewSuggestion[]>;
77
- /** @protected Pending-suggestion count shown in the bar. */
78
- protected readonly _count: import("@angular/core").Signal<number>;
79
- /** @protected Clamped cursor index of the current suggestion. */
80
- protected readonly _index: import("@angular/core").Signal<number>;
81
- /** @private Identifier of the current suggestion, if any is pending. */
82
- private readonly _currentId;
83
- /**
84
- * @protected Id of the visually hidden current-suggestion description
85
- * element the accept/reject buttons reference through `aria-describedby`.
86
- * Unique per bar instance so multiple editors on one page cannot collide.
87
- */
88
- protected readonly _descriptionId: string;
89
- /**
90
- * @protected Non-visual description of the current suggestion — index,
91
- * count, and the removed/added text — from
92
- * {@link MlvEditorAiContext.describeSuggestion}. The removed text otherwise
93
- * exists only inside the `aria-hidden` strikethrough widget, so this is
94
- * what makes the accept/reject decision inspectable without sight.
95
- */
96
- protected readonly _currentDescription: import("@angular/core").Signal<string>;
97
- /** @protected Localized pending count resolved through the ICU template. */
98
- protected readonly _countText: import("@angular/core").Signal<string>;
99
- constructor();
100
- /** @protected Cancels the in-flight AI request from the stop affordance. */
101
- protected _stop(): void;
102
- /** @protected Moves the cursor to the previous suggestion, wrapping at the start. */
103
- protected _previous(): void;
104
- /** @protected Moves the cursor to the next suggestion, wrapping at the end. */
105
- protected _next(): void;
106
- /** @protected Accepts the current suggestion; the clamped cursor advances. */
107
- protected _acceptCurrent(): void;
108
- /** @protected Rejects the current suggestion; the clamped cursor advances. */
109
- protected _rejectCurrent(): void;
110
- /** @protected Accepts every pending suggestion. */
111
- protected _acceptAll(): void;
112
- /** @protected Rejects every pending suggestion. */
113
- protected _rejectAll(): void;
114
- static ɵfac: i0.ɵɵFactoryDeclaration<MlvEditorAiReviewBar, never>;
115
- static ɵcmp: i0.ɵɵComponentDeclaration<MlvEditorAiReviewBar, "mlv-editor-ai-review-bar", never, {}, {}, never, never, true, never>;
116
- }