@ngstarter-ui/components 22.2.2 → 22.2.4

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 (56) hide show
  1. package/ai/component-registry.json +37 -0
  2. package/content-editor/BLOCK_FORMAT.md +861 -0
  3. package/content-editor/document.schema.json +1598 -0
  4. package/fesm2022/ngstarter-ui-components-content-editor-attachment-block-rzZKJ2JH.mjs +35 -0
  5. package/fesm2022/ngstarter-ui-components-content-editor-attachment-block-rzZKJ2JH.mjs.map +1 -0
  6. package/fesm2022/{ngstarter-ui-components-content-editor-callout-block-Cnga7Z-6.mjs → ngstarter-ui-components-content-editor-callout-block-DTdApN0r.mjs} +2 -3
  7. package/fesm2022/{ngstarter-ui-components-content-editor-callout-block-Cnga7Z-6.mjs.map → ngstarter-ui-components-content-editor-callout-block-DTdApN0r.mjs.map} +1 -1
  8. package/fesm2022/{ngstarter-ui-components-content-editor-code-block.component-DSdVOJtH.mjs → ngstarter-ui-components-content-editor-code-block.component-DpONkTMU.mjs} +2 -2
  9. package/fesm2022/{ngstarter-ui-components-content-editor-code-block.component-DSdVOJtH.mjs.map → ngstarter-ui-components-content-editor-code-block.component-DpONkTMU.mjs.map} +1 -1
  10. package/fesm2022/{ngstarter-ui-components-content-editor-embed-block-DhFxtMQS.mjs → ngstarter-ui-components-content-editor-embed-block-CmhzpaRk.mjs} +2 -2
  11. package/fesm2022/{ngstarter-ui-components-content-editor-embed-block-DhFxtMQS.mjs.map → ngstarter-ui-components-content-editor-embed-block-CmhzpaRk.mjs.map} +1 -1
  12. package/fesm2022/{ngstarter-ui-components-content-editor-gallery-block-cEy-dCMa.mjs → ngstarter-ui-components-content-editor-gallery-block-gtH7yWd5.mjs} +16 -39
  13. package/fesm2022/ngstarter-ui-components-content-editor-gallery-block-gtH7yWd5.mjs.map +1 -0
  14. package/fesm2022/{ngstarter-ui-components-content-editor-grid-block-DFLGRFiO.mjs → ngstarter-ui-components-content-editor-grid-block-Pb-xV7Pw.mjs} +3 -4
  15. package/fesm2022/{ngstarter-ui-components-content-editor-grid-block-DFLGRFiO.mjs.map → ngstarter-ui-components-content-editor-grid-block-Pb-xV7Pw.mjs.map} +1 -1
  16. package/fesm2022/{ngstarter-ui-components-content-editor-heading-block.component-BYpctSPe.mjs → ngstarter-ui-components-content-editor-heading-block.component-BKe9Zy_x.mjs} +2 -2
  17. package/fesm2022/{ngstarter-ui-components-content-editor-heading-block.component-BYpctSPe.mjs.map → ngstarter-ui-components-content-editor-heading-block.component-BKe9Zy_x.mjs.map} +1 -1
  18. package/fesm2022/ngstarter-ui-components-content-editor-image-block.component-DSpBVTu-.mjs +113 -0
  19. package/fesm2022/ngstarter-ui-components-content-editor-image-block.component-DSpBVTu-.mjs.map +1 -0
  20. package/fesm2022/{ngstarter-ui-components-content-editor-list-block.component-6SMBxIl4.mjs → ngstarter-ui-components-content-editor-list-block.component-BPKPE1uY.mjs} +2 -2
  21. package/fesm2022/{ngstarter-ui-components-content-editor-list-block.component-6SMBxIl4.mjs.map → ngstarter-ui-components-content-editor-list-block.component-BPKPE1uY.mjs.map} +1 -1
  22. package/fesm2022/{ngstarter-ui-components-content-editor-nested-blocks-DSY7xfzf.mjs → ngstarter-ui-components-content-editor-nested-blocks-Dh-p3WMp.mjs} +4 -4
  23. package/fesm2022/ngstarter-ui-components-content-editor-nested-blocks-Dh-p3WMp.mjs.map +1 -0
  24. package/fesm2022/{ngstarter-ui-components-content-editor-ngstarter-ui-components-content-editor--rb3-UuO.mjs → ngstarter-ui-components-content-editor-ngstarter-ui-components-content-editor-CR-NrarE.mjs} +2058 -983
  25. package/fesm2022/ngstarter-ui-components-content-editor-ngstarter-ui-components-content-editor-CR-NrarE.mjs.map +1 -0
  26. package/fesm2022/{ngstarter-ui-components-content-editor-paragraph-block.component-JVxf_Cdx.mjs → ngstarter-ui-components-content-editor-paragraph-block.component-D5wS3m6O.mjs} +2 -2
  27. package/fesm2022/{ngstarter-ui-components-content-editor-paragraph-block.component-JVxf_Cdx.mjs.map → ngstarter-ui-components-content-editor-paragraph-block.component-D5wS3m6O.mjs.map} +1 -1
  28. package/fesm2022/{ngstarter-ui-components-content-editor-quote-block.component-7EO7z7Sr.mjs → ngstarter-ui-components-content-editor-quote-block.component-C3GFAGKF.mjs} +2 -2
  29. package/fesm2022/{ngstarter-ui-components-content-editor-quote-block.component-7EO7z7Sr.mjs.map → ngstarter-ui-components-content-editor-quote-block.component-C3GFAGKF.mjs.map} +1 -1
  30. package/fesm2022/{ngstarter-ui-components-content-editor-table-block.component-CJS-IBHw.mjs → ngstarter-ui-components-content-editor-table-block.component-DQgs_kyN.mjs} +2 -2
  31. package/fesm2022/{ngstarter-ui-components-content-editor-table-block.component-CJS-IBHw.mjs.map → ngstarter-ui-components-content-editor-table-block.component-DQgs_kyN.mjs.map} +1 -1
  32. package/fesm2022/{ngstarter-ui-components-content-editor-toggle-block-B01lhY_V.mjs → ngstarter-ui-components-content-editor-toggle-block-Cb67ChE8.mjs} +3 -4
  33. package/fesm2022/{ngstarter-ui-components-content-editor-toggle-block-B01lhY_V.mjs.map → ngstarter-ui-components-content-editor-toggle-block-Cb67ChE8.mjs.map} +1 -1
  34. package/fesm2022/ngstarter-ui-components-content-editor-upload-status-QnKI_Rfz.mjs +19 -0
  35. package/fesm2022/ngstarter-ui-components-content-editor-upload-status-QnKI_Rfz.mjs.map +1 -0
  36. package/fesm2022/ngstarter-ui-components-content-editor-video-block.component-CRa0g9Ez.mjs +134 -0
  37. package/fesm2022/ngstarter-ui-components-content-editor-video-block.component-CRa0g9Ez.mjs.map +1 -0
  38. package/fesm2022/ngstarter-ui-components-content-editor.mjs +1 -1
  39. package/fesm2022/ngstarter-ui-components-headless-editor.mjs +57 -0
  40. package/fesm2022/ngstarter-ui-components-headless-editor.mjs.map +1 -1
  41. package/package.json +3 -1
  42. package/types/ngstarter-ui-components-content-editor.d.ts +302 -18
  43. package/types/ngstarter-ui-components-headless-editor.d.ts +6 -1
  44. package/fesm2022/ngstarter-ui-components-content-editor-attachment-block-B2GUlWO2.mjs +0 -54
  45. package/fesm2022/ngstarter-ui-components-content-editor-attachment-block-B2GUlWO2.mjs.map +0 -1
  46. package/fesm2022/ngstarter-ui-components-content-editor-block-base-BHAxKEOT.mjs +0 -47
  47. package/fesm2022/ngstarter-ui-components-content-editor-block-base-BHAxKEOT.mjs.map +0 -1
  48. package/fesm2022/ngstarter-ui-components-content-editor-gallery-block-cEy-dCMa.mjs.map +0 -1
  49. package/fesm2022/ngstarter-ui-components-content-editor-image-block.component-B3MnANpi.mjs +0 -169
  50. package/fesm2022/ngstarter-ui-components-content-editor-image-block.component-B3MnANpi.mjs.map +0 -1
  51. package/fesm2022/ngstarter-ui-components-content-editor-nested-blocks-DSY7xfzf.mjs.map +0 -1
  52. package/fesm2022/ngstarter-ui-components-content-editor-ngstarter-ui-components-content-editor--rb3-UuO.mjs.map +0 -1
  53. package/fesm2022/ngstarter-ui-components-content-editor-upload-block-base-D9ELpJr-.mjs +0 -29
  54. package/fesm2022/ngstarter-ui-components-content-editor-upload-block-base-D9ELpJr-.mjs.map +0 -1
  55. package/fesm2022/ngstarter-ui-components-content-editor-video-block.component-DQUPVDwV.mjs +0 -201
  56. package/fesm2022/ngstarter-ui-components-content-editor-video-block.component-DQUPVDwV.mjs.map +0 -1
@@ -1,11 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, DestroyRef, signal, computed, Injectable, ElementRef, input, output, effect, untracked, afterNextRender, Directive, ChangeDetectionStrategy, Component, DOCUMENT as DOCUMENT$1, model, InjectionToken, makeEnvironmentProviders, EventEmitter, HostListener, Output, Input as Input$1, PLATFORM_ID, viewChild, EnvironmentInjector, ChangeDetectorRef, numberAttribute, booleanAttribute, runInInjectionContext, forwardRef, linkedSignal, viewChildren, afterRenderEffect } from '@angular/core';
2
+ import { inject, Injectable, InjectionToken, makeEnvironmentProviders, DestroyRef, signal, computed, ElementRef, input, output, effect, untracked, afterNextRender, afterRenderEffect, Directive, ChangeDetectionStrategy, Component, DOCUMENT as DOCUMENT$1, model, EventEmitter, HostListener, Output, Input as Input$1, PLATFORM_ID, viewChild, numberAttribute, EnvironmentInjector, ChangeDetectorRef, booleanAttribute, runInInjectionContext, forwardRef, linkedSignal, viewChildren } from '@angular/core';
3
3
  import { Button } from '@ngstarter-ui/components/button';
4
4
  import { Icon } from '@ngstarter-ui/components/icon';
5
5
  import { Menu, MenuItem, MenuTrigger, MenuHeading, MenuContent } from '@ngstarter-ui/components/menu';
6
6
  import { DialogRef, DialogContent, DialogTitle, DialogActions, DIALOG_DATA, Dialog } from '@ngstarter-ui/components/dialog';
7
7
  import * as i1 from '@ngstarter-ui/components/headless-editor';
8
- import { isNgsHeadlessEditorTextContent, getNgsHeadlessEditorTableData, NgsHeadlessEditor, NgsHeadlessEditorInlineRegion, NgsHeadlessEditorSurface, createNgsHeadlessEditorId, provideNgsHeadlessEditorInlineRegion, NGS_HEADLESS_EDITOR_TOGGLE_BOLD, NGS_HEADLESS_EDITOR_TOGGLE_ITALIC, NGS_HEADLESS_EDITOR_TOGGLE_CODE, NGS_HEADLESS_EDITOR_TOGGLE_STRIKE, NGS_HEADLESS_EDITOR_TOGGLE_UNDERLINE, NGS_HEADLESS_EDITOR_TOGGLE_SUPERSCRIPT, NGS_HEADLESS_EDITOR_TOGGLE_SUBSCRIPT, NGS_HEADLESS_EDITOR_SET_LINK, NGS_HEADLESS_EDITOR_UNSET_LINK, NGS_HEADLESS_EDITOR_SET_TEXT_COLOR, NGS_HEADLESS_EDITOR_UNSET_TEXT_COLOR, NGS_HEADLESS_EDITOR_SET_BACKGROUND_COLOR, NGS_HEADLESS_EDITOR_UNSET_BACKGROUND_COLOR, provideNgsHeadlessEditor, withHeadlessEditorPlugin, basicTextEditorPlugin, colorEditorPlugin, linkEditorPlugin, createNgsHeadlessEditorText, normalizeNgsHeadlessEditorLink, normalizeNgsHeadlessEditorColor, createNgsHeadlessEditorDocument, readNgsHeadlessEditorInlineContent, NgsHeadlessEditorRuns } from '@ngstarter-ui/components/headless-editor';
8
+ import { isNgsHeadlessEditorTextContent, getNgsHeadlessEditorTableData, createNgsHeadlessEditorId, normalizeNgsHeadlessEditorLink, normalizeNgsHeadlessEditorColor, basicTextEditorPlugin, colorEditorPlugin, linkEditorPlugin, createNgsHeadlessEditorText, normalizeNgsHeadlessEditorTextContent, NgsHeadlessEditor, NgsHeadlessEditorInlineRegion, NgsHeadlessEditorSurface, provideNgsHeadlessEditorInlineRegion, NGS_HEADLESS_EDITOR_TOGGLE_BOLD, NGS_HEADLESS_EDITOR_TOGGLE_ITALIC, NGS_HEADLESS_EDITOR_TOGGLE_CODE, NGS_HEADLESS_EDITOR_TOGGLE_STRIKE, NGS_HEADLESS_EDITOR_TOGGLE_UNDERLINE, NGS_HEADLESS_EDITOR_TOGGLE_SUPERSCRIPT, NGS_HEADLESS_EDITOR_TOGGLE_SUBSCRIPT, NGS_HEADLESS_EDITOR_SET_LINK, NGS_HEADLESS_EDITOR_UNSET_LINK, NGS_HEADLESS_EDITOR_SET_TEXT_COLOR, NGS_HEADLESS_EDITOR_UNSET_TEXT_COLOR, NGS_HEADLESS_EDITOR_SET_BACKGROUND_COLOR, NGS_HEADLESS_EDITOR_UNSET_BACKGROUND_COLOR, provideNgsHeadlessEditor, withHeadlessEditorPlugin, createNgsHeadlessEditorDocument, NgsHeadlessEditorRuns } from '@ngstarter-ui/components/headless-editor';
9
9
  import { DOCUMENT, isPlatformBrowser, isPlatformServer, NgComponentOutlet, AsyncPipe, NgTemplateOutlet } from '@angular/common';
10
10
  import { Input } from '@ngstarter-ui/components/input';
11
11
  import { FormField, Label, Hint } from '@ngstarter-ui/components/form-field';
@@ -153,882 +153,1691 @@ function cloneContentEditorValue(value) {
153
153
  }
154
154
  return value;
155
155
  }
156
-
157
- /** UI state and block operations. The headless document is the only content store. */
158
- class ContentBuilderStore {
159
- editor = inject(NgsHeadlessEditor);
160
- dragging = false;
161
- constructor() {
162
- const document = inject(DOCUMENT);
163
- // Capture the current point before CDK chooses a connected list. Its moved
164
- // output is emitted after hit testing and would provide the previous point.
165
- const mouse = (event) => { if (this.dragging)
166
- this.dragPointer.set({ x: event.clientX, y: event.clientY }); };
167
- const touch = (event) => {
168
- const point = event.touches[0];
169
- if (this.dragging && point)
170
- this.dragPointer.set({ x: point.clientX, y: point.clientY });
171
- };
172
- document.addEventListener('mousemove', mouse, true);
173
- document.addEventListener('touchmove', touch, { capture: true, passive: true });
174
- inject(DestroyRef).onDestroy(() => {
175
- document.removeEventListener('mousemove', mouse, true);
176
- document.removeEventListener('touchmove', touch, true);
177
- });
178
- }
179
- textEdit = null;
180
- /** Scopes typing groups to one text region, so adjacent cells never share undo. */
181
- withTextEdit(origin, group, edit) {
182
- const previous = this.textEdit;
183
- this.textEdit = { origin, group };
184
- try {
185
- edit();
186
- }
187
- finally {
188
- this.textEdit = previous;
156
+ /** Locates the collection owning a block, including deeply nested Grid/Toggle blocks. */
157
+ function contentEditorBlockScope(blocks, id, scope = {}) {
158
+ for (const block of blocks) {
159
+ if (block.id === id)
160
+ return scope;
161
+ if (block.type === 'toggle') {
162
+ const found = contentEditorBlockScope(block.content.blocks, id, { parentId: block.id });
163
+ if (found)
164
+ return found;
189
165
  }
190
- }
191
- focusedBlockId = signal(null, /* @ts-ignore */
192
- ...(ngDevMode ? [{ debugName: "focusedBlockId" }] : /* istanbul ignore next */ []));
193
- activeBlockId = signal(null, /* @ts-ignore */
194
- ...(ngDevMode ? [{ debugName: "activeBlockId" }] : /* istanbul ignore next */ []));
195
- dragPointer = signal(null, /* @ts-ignore */
196
- ...(ngDevMode ? [{ debugName: "dragPointer" }] : /* istanbul ignore next */ []));
197
- setDragging(dragging) {
198
- this.dragging = dragging;
199
- if (!dragging)
200
- this.dragPointer.set(null);
201
- }
202
- dropLists = signal([], /* @ts-ignore */
203
- ...(ngDevMode ? [{ debugName: "dropLists" }] : /* istanbul ignore next */ []));
204
- registerDropList(list) {
205
- if (!this.dropLists().includes(list))
206
- this.dropLists.update(lists => [...lists, list]);
207
- }
208
- unregisterDropList(list) {
209
- this.dropLists.update(lists => lists.filter(item => item !== list));
210
- }
211
- blocks = computed(() => this.editor.document().blocks.map(contentEditorBlockView), /* @ts-ignore */
212
- ...(ngDevMode ? [{ debugName: "blocks" }] : /* istanbul ignore next */ []));
213
- setFocusedBlockId(id) { this.focusedBlockId.set(id); }
214
- setActiveBlockId(id) { this.activeBlockId.set(id); }
215
- setBlocks(value) {
216
- this.editor.setDocument(value);
217
- }
218
- addBlock(block, index, scope = {}) {
219
- const native = contentEditorNativeBlock(block);
220
- const blocks = cloneContentEditorValue([...this.editor.document().blocks]);
221
- const collection = [...contentEditorCollection(blocks, scope)];
222
- collection.splice(index, 0, native);
223
- replaceContentEditorCollection(blocks, scope, collection);
224
- this.editor.updateDocument({ version: 1, blocks });
225
- }
226
- deleteBlock(id, _index) {
227
- const blocks = cloneContentEditorValue([...this.editor.document().blocks]);
228
- const remove = (items) => {
229
- const index = items.findIndex(block => block.id === id);
230
- if (index !== -1) {
231
- items.splice(index, 1);
232
- return true;
166
+ if (block.type === 'grid')
167
+ for (const cell of block.content.cells) {
168
+ const found = contentEditorBlockScope(cell.blocks, id, { parentId: block.id, cellId: cell.id });
169
+ if (found)
170
+ return found;
233
171
  }
234
- return items.some(block => contentEditorChildCollections(block).some(children => remove(children)));
235
- };
236
- if (remove(blocks))
237
- this.editor.updateDocument({ version: 1, blocks });
238
- }
239
- updateBlock(id, data) {
240
- const blocks = cloneContentEditorValue([...this.editor.document().blocks]);
241
- const previous = findContentEditorBlock(blocks, id);
242
- if (!previous)
243
- return;
244
- const next = contentEditorNativeBlock({ ...contentEditorBlockView(previous), ...data });
245
- const origin = this.textEdit?.origin ?? 'command';
246
- const typing = origin === 'keyboard' || origin === 'composition';
247
- const root = blocks.find(block => !!findContentEditorBlock([block], id));
248
- Object.assign(previous, next);
249
- this.editor.updateBlock(root.id, { content: root.content, attrs: root.attrs }, typing ? origin : 'command', typing ? this.textEdit?.group ?? null : null);
250
- }
251
- moveBlock(from, to) {
252
- const blocks = [...this.editor.document().blocks];
253
- const [block] = blocks.splice(from, 1);
254
- blocks.splice(to, 0, block);
255
- this.editor.updateDocument({ version: 1, blocks });
256
- }
257
- moveBetweenCollections(from, to, source, target) {
258
- const blocks = cloneContentEditorValue([...this.editor.document().blocks]);
259
- const sourceItems = [...contentEditorCollection(blocks, source)];
260
- const block = sourceItems[from];
261
- if (!block || (target.parentId && findContentEditorBlock([block], target.parentId)))
262
- return;
263
- sourceItems.splice(from, 1);
264
- replaceContentEditorCollection(blocks, source, sourceItems);
265
- const targetItems = [...contentEditorCollection(blocks, target)];
266
- targetItems.splice(to, 0, block);
267
- replaceContentEditorCollection(blocks, target, targetItems);
268
- this.editor.updateDocument({ version: 1, blocks });
269
172
  }
270
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentBuilderStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
271
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentBuilderStore });
173
+ return null;
174
+ }
175
+ /** Copies for insertion/duplication receive fresh ids throughout the tree. */
176
+ function contentEditorCopyBlocks(blocks) {
177
+ const copy = cloneContentEditorValue([...blocks]);
178
+ const visit = (block) => {
179
+ block.id = createNgsHeadlessEditorId(block.type);
180
+ for (const children of contentEditorChildCollections(block))
181
+ children.forEach(visit);
182
+ if (block.type === 'grid')
183
+ block.content.cells.forEach((cell) => cell.id = createNgsHeadlessEditorId('cell'));
184
+ if (block.type === 'gallery')
185
+ block.content.images.forEach((image) => image.id = createNgsHeadlessEditorId('image'));
186
+ };
187
+ copy.forEach(visit);
188
+ return copy;
189
+ }
190
+ /** UTF-16 offsets match the editor selection model; marks remain on sliced runs. */
191
+ function contentEditorSliceText(content, start, end = Infinity) {
192
+ let offset = 0;
193
+ return content.flatMap(run => {
194
+ const from = Math.max(0, start - offset);
195
+ const to = Math.min(run.text.length, end - offset);
196
+ offset += run.text.length;
197
+ return to > from ? [{ ...run, text: run.text.slice(from, to) }] : [];
198
+ });
272
199
  }
273
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentBuilderStore, decorators: [{
274
- type: Injectable
275
- }], ctorParameters: () => [] });
276
200
 
277
- const regions = new WeakMap();
278
- /** A headless inline editor bound to a text field in a content block. */
279
- class ContentEditorContentEditableDirective {
280
- region = inject(NgsHeadlessEditorInlineRegion);
281
- surface = inject(NgsHeadlessEditorSurface);
282
- store = inject(ContentBuilderStore, { optional: true });
283
- historyGroup = createNgsHeadlessEditorId('content-region');
284
- element = inject(ElementRef).nativeElement;
285
- content = input([], { ...(ngDevMode ? { debugName: "content" } : /* istanbul ignore next */ {}), alias: 'ngsContentEditorContentEditable' });
286
- settings = input({}, /* @ts-ignore */
287
- ...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
288
- props = input([], /* @ts-ignore */
289
- ...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
290
- singleLine = input(false, /* @ts-ignore */
291
- ...(ngDevMode ? [{ debugName: "singleLine" }] : /* istanbul ignore next */ []));
292
- contentChanged = output();
293
- propsChanged = output();
294
- pressedEnter = output();
295
- initialized = output();
296
- static forElement(element) {
297
- return element ? regions.get(element) : undefined;
298
- }
299
- constructor() {
300
- regions.set(this.element, this);
301
- effect(() => {
302
- const content = this.content();
303
- untracked(() => this.region.load(content));
304
- });
305
- effect(() => {
306
- const content = this.region.content();
307
- const origin = this.region.editor.origin();
308
- if (origin !== 'external' && origin !== 'history') {
309
- untracked(() => {
310
- if (this.store)
311
- this.store.withTextEdit(origin, this.historyGroup, () => this.contentChanged.emit(content));
312
- else
313
- this.contentChanged.emit(content);
314
- });
315
- }
316
- });
317
- // Capture before the surface and the block's own listeners. Structural Enter
318
- // stays with the content builder; multiline fields use the headless surface.
319
- this.element.addEventListener('keydown', this.onKeydown, true);
320
- this.element.addEventListener('beforeinput', this.onBeforeInput, true);
321
- afterNextRender(() => this.initialized.emit());
201
+ function getTextAlignment(props) {
202
+ const value = props?.find(prop => prop.name === 'text-alignment')?.value;
203
+ if (value === 'center' || value === 'right' || value === 'justify') {
204
+ return value;
322
205
  }
323
- activate() { this.region.activate(); }
324
- focus() { this.activate(); this.surface.focus(); }
325
- getContent() { return this.region.content(); }
326
- alignment() { return this.props().find(prop => prop.name === 'text-alignment')?.value ?? 'left'; }
327
- setAlignment(value) {
328
- this.propsChanged.emit([
329
- ...this.props().filter(prop => prop.name !== 'text-alignment'),
330
- { name: 'text-alignment', value }
331
- ]);
206
+ return 'left';
207
+ }
208
+ function getDimensionAttribute(value) {
209
+ if (typeof value === 'number' && Number.isFinite(value)) {
210
+ return value;
332
211
  }
333
- onKeydown = (event) => {
334
- if (event.key === 'Enter' && this.singleLine() && !event.shiftKey && !event.isComposing) {
335
- event.preventDefault();
336
- event.stopImmediatePropagation();
337
- this.pressedEnter.emit(event);
338
- }
339
- };
340
- onBeforeInput = (event) => {
341
- if (event.inputType === 'insertParagraph' && this.singleLine() && !event.isComposing) {
342
- event.preventDefault();
343
- event.stopImmediatePropagation();
344
- this.pressedEnter.emit(new KeyboardEvent('keydown', { key: 'Enter' }));
212
+ if (typeof value === 'string') {
213
+ const trimmed = value.trim();
214
+ if (!trimmed || trimmed === 'auto') {
215
+ return null;
345
216
  }
346
- };
347
- ngOnDestroy() {
348
- regions.delete(this.element);
349
- this.element.removeEventListener('keydown', this.onKeydown, true);
350
- this.element.removeEventListener('beforeinput', this.onBeforeInput, true);
217
+ const parsed = Number.parseFloat(trimmed);
218
+ return Number.isFinite(parsed) ? parsed : null;
351
219
  }
352
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorContentEditableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
353
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.7", type: ContentEditorContentEditableDirective, isStandalone: true, selector: "[ngsContentEditorContentEditable]", inputs: { content: { classPropertyName: "content", publicName: "ngsContentEditorContentEditable", isSignal: true, isRequired: false, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, singleLine: { classPropertyName: "singleLine", publicName: "singleLine", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { contentChanged: "contentChanged", propsChanged: "propsChanged", pressedEnter: "pressedEnter", initialized: "initialized" }, host: { listeners: { "focus": "activate()" }, properties: { "class.align-left": "alignment() === \"left\"", "class.align-center": "alignment() === \"center\"", "class.align-right": "alignment() === \"right\"", "class.align-justify": "alignment() === \"justify\"" }, classAttribute: "ngs-content-editor-content-editable" }, providers: [provideNgsHeadlessEditorInlineRegion()], exportAs: ["ngsContentEditorContentEditable"], hostDirectives: [{ directive: i1.NgsHeadlessEditorSurface }], ngImport: i0 });
220
+ return null;
354
221
  }
355
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorContentEditableDirective, decorators: [{
356
- type: Directive,
357
- args: [{
358
- selector: '[ngsContentEditorContentEditable]',
359
- exportAs: 'ngsContentEditorContentEditable',
360
- providers: [provideNgsHeadlessEditorInlineRegion()],
361
- hostDirectives: [NgsHeadlessEditorSurface],
362
- host: {
363
- 'class': 'ngs-content-editor-content-editable',
364
- '[class.align-left]': 'alignment() === "left"',
365
- '[class.align-center]': 'alignment() === "center"',
366
- '[class.align-right]': 'alignment() === "right"',
367
- '[class.align-justify]': 'alignment() === "justify"',
368
- '(focus)': 'activate()'
369
- }
370
- }]
371
- }], ctorParameters: () => [], propDecorators: { content: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngsContentEditorContentEditable", required: false }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], singleLine: [{ type: i0.Input, args: [{ isSignal: true, alias: "singleLine", required: false }] }], contentChanged: [{ type: i0.Output, args: ["contentChanged"] }], propsChanged: [{ type: i0.Output, args: ["propsChanged"] }], pressedEnter: [{ type: i0.Output, args: ["pressedEnter"] }], initialized: [{ type: i0.Output, args: ["initialized"] }] } });
372
222
 
373
- class AddLinkDialog {
374
- _dialogRef = inject(DialogRef);
375
- _formBuilder = inject(FormBuilder);
376
- form = this._formBuilder.group({
377
- href: [''],
378
- openInNewTab: [true, [Validators.required]]
379
- });
380
- cancel() {
381
- this._dialogRef.close(false);
382
- }
383
- add() {
384
- this._dialogRef.close(this.form.value);
385
- }
386
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: AddLinkDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
387
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.1.7", type: AddLinkDialog, isStandalone: true, selector: "ngs-add-link", ngImport: i0, template: "<h1 ngs-dialog-title>Add link</h1>\n<ngs-dialog-content [formGroup]=\"form\" class=\"!overflow-hidden\">\n <ngs-form-field class=\"w-full\">\n <ngs-label>Href (Url, Tel or other)</ngs-label>\n <input ngsInput type=\"text\" formControlName=\"href\">\n </ngs-form-field>\n <ngs-slide-toggle formControlName=\"openInNewTab\">Open link in a new tab</ngs-slide-toggle>\n</ngs-dialog-content>\n<ngs-dialog-actions>\n <button ngsButton (click)=\"cancel()\">Cancel</button>\n <button ngsButton=\"filled\"\n [disabled]=\"form.invalid\" (click)=\"add()\">Add</button>\n</ngs-dialog-actions>\n", styles: [""], dependencies: [{ kind: "component", type: DialogContent, selector: "ngs-dialog-content,[ngs-dialog-content],[ngsDialogContent]" }, { kind: "component", type: FormField, selector: "ngs-form-field", inputs: ["labelMode", "subscriptHiddenIfEmpty", "sameHeightAsButton"], exportAs: ["ngsFormField"] }, { kind: "directive", type: Input, selector: "input[ngsInput], textarea[ngsInput]", inputs: ["id", "placeholder", "required", "disabled", "readonly", "errorStateMatcher"], exportAs: ["ngsInput"] }, { kind: "component", type: DialogTitle, selector: "ngs-dialog-title, [ngs-dialog-title], [ngsDialogTitle]", inputs: ["id"], exportAs: ["ngsDialogTitle"] }, { kind: "component", type: DialogActions, selector: "ngs-dialog-actions, [ngs-dialog-actions], [ngsDialogActions]", inputs: ["align"] }, { kind: "component", type: Button, selector: " button[ngsButton], button[ngsIconButton], a[ngsButton], a[ngsIconButton] ", inputs: ["ngsButton", "ngsIconButton", "loading", "disabled", "disabledInteractive", "disableRipple", "reverse", "fullWidth", "hideTextOnMobile"], exportAs: ["ngsButton"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: Label, selector: "ngs-label" }, { kind: "component", type: SlideToggle, selector: "ngs-slide-toggle", inputs: ["id", "name", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "disabled", "disableRipple", "tabIndex", "hideIcon", "color", "checked"], outputs: ["disabledChange", "checkedChange", "change", "toggleChange"], exportAs: ["ngsSlideToggle"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
223
+ /** Defaults shared by editing and read-only layout. */
224
+ function contentEditorGridSettings(settings) {
225
+ return {
226
+ columns: settings.columns === 3 || settings.columns === 4 ? settings.columns : 2,
227
+ gap: settings.gap === 'small' || settings.gap === 'large' ? settings.gap : 'medium',
228
+ stackOnMobile: settings.stackOnMobile !== false
229
+ };
388
230
  }
389
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: AddLinkDialog, decorators: [{
390
- type: Component,
391
- args: [{ selector: 'ngs-add-link', imports: [
392
- DialogContent,
393
- FormField,
394
- Input,
395
- DialogTitle,
396
- DialogActions,
397
- Button,
398
- ReactiveFormsModule,
399
- Label,
400
- SlideToggle
401
- ], changeDetection: ChangeDetectionStrategy.Eager, template: "<h1 ngs-dialog-title>Add link</h1>\n<ngs-dialog-content [formGroup]=\"form\" class=\"!overflow-hidden\">\n <ngs-form-field class=\"w-full\">\n <ngs-label>Href (Url, Tel or other)</ngs-label>\n <input ngsInput type=\"text\" formControlName=\"href\">\n </ngs-form-field>\n <ngs-slide-toggle formControlName=\"openInNewTab\">Open link in a new tab</ngs-slide-toggle>\n</ngs-dialog-content>\n<ngs-dialog-actions>\n <button ngsButton (click)=\"cancel()\">Cancel</button>\n <button ngsButton=\"filled\"\n [disabled]=\"form.invalid\" (click)=\"add()\">Add</button>\n</ngs-dialog-actions>\n" }]
402
- }] });
403
231
 
404
- class EditLinkDialog {
405
- _dialogRef = inject(DialogRef);
406
- _dialogData = inject(DIALOG_DATA);
407
- _formBuilder = inject(FormBuilder);
408
- form = this._formBuilder.group({
409
- href: [this._dialogData.href],
410
- openInNewTab: [this._dialogData.openInNewTab, [Validators.required]]
411
- });
412
- cancel() {
413
- this._dialogRef.close(false);
232
+ /** Plain HTML layout styles, independent of Angular and the component library's theme. */
233
+ const CONTENT_EDITOR_GRID_HTML_STYLES = `.ngs-content-editor-html-grid{container-type:inline-size}.ngs-content-editor-html-grid-cells{display:grid;grid-template-columns:repeat(var(--ngs-html-grid-columns),minmax(0,1fr));gap:var(--ngs-html-grid-gap)}.ngs-content-editor-html-grid-cell{min-width:0}@container(max-width:480px){.ngs-content-editor-html-grid-stack{grid-template-columns:minmax(0,1fr)}}`;
234
+ const CONTENT_EDITOR_CALLOUT_HTML_STYLES = `.ngs-content-editor-html-callout{padding:16px;border-radius:8px;background:var(--ngs-color-primary-container,#eef3ff);color:var(--ngs-color-on-surface,#172033)}.ngs-content-editor-html-callout[data-callout=tip]{background:var(--ngs-color-success-container,#e8f5ee)}.ngs-content-editor-html-callout[data-callout=warning]{background:var(--ngs-color-warning-container,#fff3dc)}.ngs-content-editor-html-callout[data-callout=danger]{background:var(--ngs-color-danger-container,#fdeaea)}`;
235
+ const CONTENT_EDITOR_GALLERY_HTML_STYLES = `.ngs-content-editor-html-gallery{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;gap:16px}.ngs-content-editor-html-gallery>figure{flex:0 0 100%;min-width:0;margin:0;scroll-snap-align:start}.ngs-content-editor-html-gallery img{display:block;width:100%}`;
236
+ function settings(block) { return block.attrs?.['settings'] ?? {}; }
237
+ function alignment(props) {
238
+ const align = getTextAlignment(props);
239
+ return align === 'left' ? '' : ` style="text-align:${align}"`;
240
+ }
241
+ function dimension(name, value) {
242
+ const number = getDimensionAttribute(value);
243
+ return number !== null && number > 0 ? ` ${name}="${Math.round(number)}"` : '';
244
+ }
245
+ const contentEditorParagraphToHtml = (block, ctx) => `<p${alignment(block.attrs?.['props'])}>${ctx.renderText(block.content)}</p>`;
246
+ const contentEditorHeadingToHtml = (block, ctx) => {
247
+ const value = settings(block)['level'];
248
+ const level = Number.isInteger(value) && value >= 1 && value <= 6 ? value : 2;
249
+ return `<h${level}${alignment(block.attrs?.['props'])}>${ctx.renderText(block.content)}</h${level}>`;
250
+ };
251
+ const contentEditorCodeToHtml = (block, ctx) => `<pre><code data-language="${ctx.escape(settings(block)['language'] ?? 'none')}">${ctx.escape(contentEditorText(block.content))}</code></pre>`;
252
+ const contentEditorDividerToHtml = () => '<hr>';
253
+ const contentEditorListToHtml = (block, ctx) => {
254
+ const tag = block.type === 'orderedList' ? 'ol' : 'ul';
255
+ const list = (items) => `<${tag}>${items.map(item => `<li${alignment(item.props)}>${ctx.renderText(item.content)}${item.children?.length ? list(item.children) : ''}</li>`).join('')}</${tag}>`;
256
+ return list(block.content ?? []);
257
+ };
258
+ const contentEditorQuoteToHtml = (block, ctx) => {
259
+ const quote = block.content?.cite;
260
+ const caption = block.content?.caption;
261
+ return `<figure><blockquote${alignment(quote?.props)}>${ctx.renderText(quote?.content ?? [])}</blockquote>${contentEditorText(caption?.content).trim() ? `<figcaption${alignment(caption.props)}>${ctx.renderText(caption.content)}</figcaption>` : ''}</figure>`;
262
+ };
263
+ const contentEditorTableToHtml = (block, ctx) => {
264
+ const table = getNgsHeadlessEditorTableData(block);
265
+ const metadata = block.attrs?.['cellMetadata'];
266
+ const rows = table.rows.map((row, r) => `<tr>${row.map((runs, c) => {
267
+ const tag = r === 0 && table.header ? 'th' : 'td';
268
+ const cell = metadata?.[r]?.[c];
269
+ return `<${tag}${dimension('colspan', cell?.options?.['colspan'])}${dimension('rowspan', cell?.options?.['rowspan'])}${dimension('width', cell?.options?.['width'])}${alignment(cell?.props)}>${ctx.renderText(runs)}</${tag}>`;
270
+ }).join('')}</tr>`).join('');
271
+ return `<table><tbody>${rows}</tbody></table>`;
272
+ };
273
+ const contentEditorImageToHtml = (block, ctx) => {
274
+ const src = ctx.safeUrl(block.content?.src, 'image');
275
+ if (!src)
276
+ return '';
277
+ const alt = block.content?.alt ?? '';
278
+ const config = settings(block);
279
+ return `<figure><img src="${ctx.escape(src)}" alt="${ctx.escape(alt)}"${dimension('width', config['width'])}${dimension('height', config['height'])} style="max-width:100%;height:auto">${alt ? `<figcaption>${ctx.escape(alt)}</figcaption>` : ''}</figure>`;
280
+ };
281
+ const contentEditorVideoToHtml = (block, ctx) => {
282
+ const src = ctx.safeUrl(block.content?.src, 'media');
283
+ if (!src)
284
+ return '';
285
+ const config = settings(block);
286
+ return `<figure><video src="${ctx.escape(src)}" controls${dimension('width', config['width'])}${dimension('height', config['height'])} style="max-width:100%"></video>${block.content?.caption ? `<figcaption>${ctx.escape(block.content.caption)}</figcaption>` : ''}</figure>`;
287
+ };
288
+ const contentEditorEmbedToHtml = (block, ctx) => {
289
+ const src = ctx.safeUrl(block.content?.url, 'embed');
290
+ if (!src)
291
+ return '';
292
+ const config = settings(block);
293
+ return `<figure><iframe src="${ctx.escape(src)}" title="${ctx.escape(block.content?.type || 'Embedded content')}"${dimension('width', config['width'] ?? 700)}${dimension('height', config['height'] ?? 400)} style="max-width:100%" allowfullscreen></iframe></figure>`;
294
+ };
295
+ const contentEditorCalloutToHtml = (block, ctx) => {
296
+ ctx.addStyles(CONTENT_EDITOR_CALLOUT_HTML_STYLES);
297
+ const value = settings(block)['variant'];
298
+ const variant = ['note', 'tip', 'warning', 'danger'].includes(value) ? value : 'note';
299
+ return `<aside class="ngs-content-editor-html-callout" data-callout="${variant}"${alignment(block.attrs?.['props'])}>${ctx.renderText(block.content)}</aside>`;
300
+ };
301
+ const contentEditorToggleToHtml = (block, ctx) => `<details${settings(block)['expanded'] ? ' open' : ''}><summary>${ctx.renderText(block.content?.title ?? [])}</summary>${ctx.renderBlocks(block.content?.blocks ?? [])}</details>`;
302
+ const contentEditorAttachmentToHtml = (block, ctx) => {
303
+ const url = ctx.safeUrl(block.content?.url, 'attachment');
304
+ return url ? `<a href="${ctx.escape(url)}" download="${ctx.escape(block.content?.name)}">${ctx.escape(block.content?.name || 'Download')}</a>` : '';
305
+ };
306
+ const contentEditorGalleryToHtml = (block, ctx) => {
307
+ ctx.addStyles(CONTENT_EDITOR_GALLERY_HTML_STYLES);
308
+ return `<div class="ngs-content-editor-html-gallery" data-content-editor="gallery">${(block.content?.images ?? []).map(image => {
309
+ const src = ctx.safeUrl(image.src, 'image');
310
+ return src ? `<figure><img src="${ctx.escape(src)}" alt="${ctx.escape(image.alt)}" style="max-width:100%;height:auto">${contentEditorText(image.caption).trim() ? `<figcaption>${ctx.renderText(image.caption)}</figcaption>` : ''}</figure>` : '';
311
+ }).join('')}</div>`;
312
+ };
313
+ const contentEditorGridToHtml = (block, ctx) => {
314
+ const layout = contentEditorGridSettings(settings(block));
315
+ ctx.addStyles(CONTENT_EDITOR_GRID_HTML_STYLES);
316
+ const gap = { small: 12, medium: 24, large: 36 }[layout.gap];
317
+ return `<div class="ngs-content-editor-html-grid" style="--ngs-html-grid-columns:${layout.columns};--ngs-html-grid-gap:${gap}px"><div class="ngs-content-editor-html-grid-cells${layout.stackOnMobile ? ' ngs-content-editor-html-grid-stack' : ''}">${(block.content?.cells ?? []).map(cell => `<div class="ngs-content-editor-html-grid-cell">${ctx.renderBlocks(cell.blocks)}</div>`).join('')}</div></div>`;
318
+ };
319
+ const CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS = {
320
+ paragraph: contentEditorParagraphToHtml, heading: contentEditorHeadingToHtml,
321
+ code: contentEditorCodeToHtml, divider: contentEditorDividerToHtml,
322
+ bulletList: contentEditorListToHtml, orderedList: contentEditorListToHtml,
323
+ quote: contentEditorQuoteToHtml, table: contentEditorTableToHtml,
324
+ image: contentEditorImageToHtml, video: contentEditorVideoToHtml,
325
+ embed: contentEditorEmbedToHtml, callout: contentEditorCalloutToHtml,
326
+ toggle: contentEditorToggleToHtml, attachment: contentEditorAttachmentToHtml,
327
+ gallery: contentEditorGalleryToHtml, grid: contentEditorGridToHtml
328
+ };
329
+
330
+ function escapeContentEditorHtml(value) {
331
+ return String(value ?? '').replace(/[&<>"']/g, character => ({
332
+ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;'
333
+ })[character]);
334
+ }
335
+ function safeContentEditorHtmlUrl(value, kind = 'link') {
336
+ if (typeof value !== 'string')
337
+ return null;
338
+ const url = value.trim();
339
+ if (!url || /[\u0000-\u0020\u007f]/.test(url))
340
+ return null;
341
+ if (kind === 'link')
342
+ return normalizeNgsHeadlessEditorLink(url);
343
+ if (/^https?:/i.test(url) || !/^[a-z][a-z\d+.-]*:/i.test(url))
344
+ return url;
345
+ if (kind !== 'embed' && /^blob:https?:\/\//i.test(url))
346
+ return url;
347
+ if (kind === 'attachment' && /^(mailto:|tel:)/i.test(url))
348
+ return url;
349
+ const mime = kind === 'image' ? 'image/[a-z0-9.+-]+' : kind === 'media'
350
+ ? '(?:audio|video)/[a-z0-9.+-]+' : kind === 'attachment'
351
+ ? '(?:application/(?!xhtml\\+xml|xml|javascript)[a-z0-9.+-]+|text/(?:plain|csv)|(?:image|audio|video)/[a-z0-9.+-]+)' : null;
352
+ return mime && new RegExp(`^data:${mime};base64,[a-z0-9+/=]${kind === 'attachment' ? '*' : '+'}$`, 'i').test(url) ? url : null;
353
+ }
354
+
355
+ const MARK_TAGS = {
356
+ bold: 'strong', italic: 'em', strike: 's', underline: 'u', code: 'code', superscript: 'sup', subscript: 'sub'
357
+ };
358
+ /** Pure document export: works without DOM, Angular DI, or a mounted editor. */
359
+ function contentEditorToHtml(document, config = {}) {
360
+ return serialize(document.blocks, config);
361
+ }
362
+ function contentEditorBlockToHtml(block, config = {}) {
363
+ return serialize([block], config);
364
+ }
365
+ function serialize(blocks, config) {
366
+ const styles = new Set();
367
+ const context = {
368
+ escape: escapeContentEditorHtml,
369
+ safeUrl: safeContentEditorHtmlUrl,
370
+ addStyles: css => { if (config.includeStyles !== false)
371
+ styles.add(css); },
372
+ renderBlock: block => {
373
+ const converter = config.blocks?.[block.type]?.toHtml ?? defaultConverter(block.type) ?? config.unknownBlockToHtml;
374
+ if (!converter)
375
+ throw new Error(`No HTML converter for Content Editor block "${block.type}".`);
376
+ return converter(block, context);
377
+ },
378
+ renderBlocks: children => children.map(context.renderBlock).join(''),
379
+ defaultToHtml: block => {
380
+ const converter = defaultConverter(block.type);
381
+ if (!converter)
382
+ throw new Error(`No default HTML converter for Content Editor block "${block.type}".`);
383
+ return converter(block, context);
384
+ },
385
+ renderText: text => renderText(text, context, config)
386
+ };
387
+ const html = context.renderBlocks(blocks);
388
+ return [...styles].map(css => `<style>${css}</style>`).join('') + html;
389
+ }
390
+ function renderText(text, ctx, config) {
391
+ if (!isNgsHeadlessEditorTextContent(text))
392
+ return '';
393
+ return text.map(run => run.marks.reduce((html, mark) => {
394
+ const override = config.marks && Object.hasOwn(config.marks, mark.type) ? config.marks[mark.type] : undefined;
395
+ return override ? override(html, mark, ctx) : renderMark(html, mark, ctx);
396
+ }, ctx.escape(run.text).replace(/\r\n|\r|\n/g, '<br>'))).join('');
397
+ }
398
+ function renderMark(html, mark, ctx) {
399
+ const tag = Object.hasOwn(MARK_TAGS, mark.type) ? MARK_TAGS[mark.type] : undefined;
400
+ if (tag)
401
+ return `<${tag}>${html}</${tag}>`;
402
+ if (mark.type === 'link') {
403
+ const href = ctx.safeUrl(mark.attrs?.['href']);
404
+ if (!href)
405
+ return html;
406
+ const target = mark.attrs?.['target'] === '_blank' ? '_blank' : '_self';
407
+ return `<a href="${ctx.escape(href)}" target="${target}" rel="noopener noreferrer">${html}</a>`;
414
408
  }
415
- add() {
416
- this._dialogRef.close(this.form.value);
409
+ if (mark.type === 'textColor' || mark.type === 'backgroundColor') {
410
+ const color = normalizeNgsHeadlessEditorColor(String(mark.attrs?.['color'] ?? ''));
411
+ return color ? `<span style="${mark.type === 'textColor' ? 'color' : 'background-color'}:${ctx.escape(color)}">${html}</span>` : html;
417
412
  }
418
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: EditLinkDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
419
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.1.7", type: EditLinkDialog, isStandalone: true, selector: "ngs-edit-link", ngImport: i0, template: "<h1 ngs-dialog-title>Edit link</h1>\n<ngs-dialog-content [formGroup]=\"form\" class=\"!overflow-hidden\">\n <ngs-form-field class=\"w-full\">\n <ngs-label>Href (Url, Tel or other)</ngs-label>\n <input ngsInput type=\"text\" formControlName=\"href\">\n <ngs-hint>To delete the link, clear this field and apply</ngs-hint>\n </ngs-form-field>\n <ngs-slide-toggle formControlName=\"openInNewTab\" class=\"mt-5\">Open link in a new tab</ngs-slide-toggle>\n</ngs-dialog-content>\n<ngs-dialog-actions>\n <button ngsButton (click)=\"cancel()\">Cancel</button>\n <button ngsButton=\"filled\"\n [disabled]=\"form.invalid\" (click)=\"add()\">Apply</button>\n</ngs-dialog-actions>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "component", type: Button, selector: " button[ngsButton], button[ngsIconButton], a[ngsButton], a[ngsIconButton] ", inputs: ["ngsButton", "ngsIconButton", "loading", "disabled", "disabledInteractive", "disableRipple", "reverse", "fullWidth", "hideTextOnMobile"], exportAs: ["ngsButton"] }, { kind: "component", type: DialogActions, selector: "ngs-dialog-actions, [ngs-dialog-actions], [ngsDialogActions]", inputs: ["align"] }, { kind: "component", type: DialogContent, selector: "ngs-dialog-content,[ngs-dialog-content],[ngsDialogContent]" }, { kind: "component", type: DialogTitle, selector: "ngs-dialog-title, [ngs-dialog-title], [ngsDialogTitle]", inputs: ["id"], exportAs: ["ngsDialogTitle"] }, { kind: "component", type: FormField, selector: "ngs-form-field", inputs: ["labelMode", "subscriptHiddenIfEmpty", "sameHeightAsButton"], exportAs: ["ngsFormField"] }, { kind: "directive", type: Input, selector: "input[ngsInput], textarea[ngsInput]", inputs: ["id", "placeholder", "required", "disabled", "readonly", "errorStateMatcher"], exportAs: ["ngsInput"] }, { kind: "component", type: Label, selector: "ngs-label" }, { kind: "component", type: SlideToggle, selector: "ngs-slide-toggle", inputs: ["id", "name", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "disabled", "disableRipple", "tabIndex", "hideIcon", "color", "checked"], outputs: ["disabledChange", "checkedChange", "change", "toggleChange"], exportAs: ["ngsSlideToggle"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: Hint, selector: "ngs-hint", inputs: ["align"], exportAs: ["ngsHint"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
413
+ return html;
420
414
  }
421
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: EditLinkDialog, decorators: [{
422
- type: Component,
423
- args: [{ selector: 'ngs-edit-link', imports: [
424
- FormsModule,
425
- Button,
426
- DialogActions,
427
- DialogContent,
428
- DialogTitle,
429
- FormField,
430
- Input,
431
- Label,
432
- SlideToggle,
433
- ReactiveFormsModule,
434
- Hint
435
- ], changeDetection: ChangeDetectionStrategy.Eager, template: "<h1 ngs-dialog-title>Edit link</h1>\n<ngs-dialog-content [formGroup]=\"form\" class=\"!overflow-hidden\">\n <ngs-form-field class=\"w-full\">\n <ngs-label>Href (Url, Tel or other)</ngs-label>\n <input ngsInput type=\"text\" formControlName=\"href\">\n <ngs-hint>To delete the link, clear this field and apply</ngs-hint>\n </ngs-form-field>\n <ngs-slide-toggle formControlName=\"openInNewTab\" class=\"mt-5\">Open link in a new tab</ngs-slide-toggle>\n</ngs-dialog-content>\n<ngs-dialog-actions>\n <button ngsButton (click)=\"cancel()\">Cancel</button>\n <button ngsButton=\"filled\"\n [disabled]=\"form.invalid\" (click)=\"add()\">Apply</button>\n</ngs-dialog-actions>\n" }]
415
+ function defaultConverter(type) {
416
+ return Object.hasOwn(CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS, type) ? CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS[type] : undefined;
417
+ }
418
+
419
+ /** Export saved documents with the current environment's shared configuration. */
420
+ class ContentEditorHtmlSerializer {
421
+ config = inject(CONTENT_EDITOR_CONFIG);
422
+ toHtml(document, config = {}) {
423
+ return contentEditorToHtml(document, mergeContentEditorConfig(this.config, config));
424
+ }
425
+ blockToHtml(block, config = {}) {
426
+ return contentEditorBlockToHtml(block, mergeContentEditorConfig(this.config, config));
427
+ }
428
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorHtmlSerializer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
429
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorHtmlSerializer, providedIn: 'root' });
430
+ }
431
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorHtmlSerializer, decorators: [{
432
+ type: Injectable,
433
+ args: [{ providedIn: 'root' }]
436
434
  }] });
437
435
 
438
- class TextColorComponent {
439
- _document = inject(DOCUMENT$1);
440
- recentlyUsed = model(this._getRecentlyUsed(), /* @ts-ignore */
441
- ...(ngDevMode ? [{ debugName: "recentlyUsed" }] : /* istanbul ignore next */ []));
442
- selectedTextColor = model(null, /* @ts-ignore */
443
- ...(ngDevMode ? [{ debugName: "selectedTextColor" }] : /* istanbul ignore next */ []));
444
- selectedBackgroundColor = model(null, /* @ts-ignore */
445
- ...(ngDevMode ? [{ debugName: "selectedBackgroundColor" }] : /* istanbul ignore next */ []));
446
- textColors = input([
447
- {
448
- name: 'Default',
449
- color: '',
450
- type: 'text'
451
- },
452
- {
453
- name: 'Gray',
454
- color: '#7f7f7f',
455
- type: 'text'
456
- },
457
- {
458
- name: 'Brown',
459
- color: '#ae2012',
460
- type: 'text'
461
- },
462
- {
463
- name: 'Orange',
464
- color: '#fb5607',
465
- type: 'text'
466
- },
467
- {
468
- name: 'Yellow',
469
- color: '#ffa200',
470
- type: 'text'
471
- },
472
- {
473
- name: 'Green',
474
- color: '#40916c',
475
- type: 'text'
476
- },
477
- {
478
- name: 'Blue',
479
- color: '#00bbf9',
480
- type: 'text'
481
- },
482
- {
483
- name: 'Purple',
484
- color: '#907ad6',
485
- type: 'text'
486
- },
487
- {
488
- name: 'Pink',
489
- color: '#fa3faf',
490
- type: 'text'
491
- },
492
- {
493
- name: 'Red',
494
- color: '#ef233c',
495
- type: 'text'
436
+ /** Nested renderers inherit per-instance configuration through their parent. */
437
+ const CONTENT_EDITOR_RENDER_CONFIG = new InjectionToken('CONTENT_EDITOR_RENDER_CONFIG');
438
+ const CONTENT_EDITOR_CONFIG = new InjectionToken('CONTENT_EDITOR_CONFIG', {
439
+ providedIn: 'root', factory: () => ({})
440
+ });
441
+ /** Later configurations override individual block fields, preserving unrelated options. */
442
+ function mergeContentEditorConfig(...configs) {
443
+ const result = { blocks: Object.create(null), marks: {} };
444
+ for (const config of configs) {
445
+ for (const [type, block] of Object.entries(config.blocks ?? {})) {
446
+ const previous = result.blocks[type];
447
+ result.blocks[type] = {
448
+ ...previous, ...block, options: { ...previous?.options, ...block.options }
449
+ };
496
450
  }
497
- ], /* @ts-ignore */
498
- ...(ngDevMode ? [{ debugName: "textColors" }] : /* istanbul ignore next */ []));
499
- backgroundColors = input([
500
- {
501
- name: 'Default',
502
- color: '',
503
- type: 'background'
504
- },
505
- {
506
- name: 'Gray',
507
- color: '#e9ecef',
508
- type: 'background'
509
- },
510
- {
511
- name: 'Brown',
512
- color: '#ffe0c0',
513
- type: 'background'
514
- },
515
- {
516
- name: 'Orange',
517
- color: '#ffd8c6',
518
- type: 'background'
519
- },
520
- {
521
- name: 'Yellow',
522
- color: '#fff3b0',
523
- type: 'background'
524
- },
525
- {
526
- name: 'Green',
527
- color: '#eff6e0',
528
- type: 'background'
529
- },
530
- {
531
- name: 'Blue',
532
- color: '#edf6f9',
533
- type: 'background'
534
- },
535
- {
536
- name: 'Purple',
537
- color: '#e0aaff',
538
- type: 'background'
539
- },
451
+ result.marks = { ...result.marks, ...config.marks };
452
+ if (config.draft !== undefined)
453
+ result.draft = { ...result.draft, ...config.draft };
454
+ if (config.includeStyles !== undefined)
455
+ result.includeStyles = config.includeStyles;
456
+ if (config.importMarks !== undefined)
457
+ result.importMarks = config.importMarks;
458
+ if (config.unknownBlockToHtml !== undefined)
459
+ result.unknownBlockToHtml = config.unknownBlockToHtml;
460
+ }
461
+ return result;
462
+ }
463
+ /** Application or route environment configuration. Child environments inherit parent settings. */
464
+ function provideContentEditorConfig(config = {}) {
465
+ return makeEnvironmentProviders([
540
466
  {
541
- name: 'Pink',
542
- color: '#fae0ec',
543
- type: 'background'
467
+ provide: CONTENT_EDITOR_CONFIG,
468
+ useFactory: () => mergeContentEditorConfig(inject(CONTENT_EDITOR_CONFIG, { skipSelf: true, optional: true }) ?? {}, config)
544
469
  },
545
- {
546
- name: 'Red',
547
- color: '#ffdccc',
548
- type: 'background'
549
- }
550
- ], /* @ts-ignore */
551
- ...(ngDevMode ? [{ debugName: "backgroundColors" }] : /* istanbul ignore next */ []));
552
- textColorChanged = output();
553
- backgroundColorChanged = output();
554
- selectRecentlyColor(color) {
555
- if (color.type === 'text') {
556
- this.selectTextColor(color);
557
- }
558
- else if (color.type === 'background') {
559
- this.selectBackgroundColor(color);
560
- }
561
- }
562
- selectTextColor(color) {
563
- this.selectedTextColor.set(color);
564
- this.textColorChanged.emit(color.color);
565
- this._addToRecently(color);
566
- }
567
- selectBackgroundColor(color) {
568
- this.selectedBackgroundColor.set(color);
569
- this.backgroundColorChanged.emit(color.color);
570
- this._addToRecently(color);
470
+ ContentEditorHtmlSerializer,
471
+ ContentEditorImporter
472
+ ]);
473
+ }
474
+
475
+ /** Structured failure. The editor is never modified when parsing fails. */
476
+ class ContentEditorImportError extends Error {
477
+ path;
478
+ constructor(path, message) {
479
+ super(`${path}: ${message}`);
480
+ this.path = path;
481
+ this.name = 'ContentEditorImportError';
571
482
  }
572
- _addToRecently(color) {
573
- const hasRecentlyUsed = this.recentlyUsed()
574
- .filter(recentlyColor => recentlyColor.name === color.name && recentlyColor.type === color.type)
575
- .length > 0;
576
- if (hasRecentlyUsed) {
577
- return;
578
- }
579
- let colors = [...this.recentlyUsed()];
580
- colors = colors.length >= 5 ? colors.slice(1, 5) : colors;
581
- this.recentlyUsed.set([...colors, color]);
483
+ }
484
+
485
+ /** Parses and validates the native version-1 format without changing the caller's objects. */
486
+ function contentEditorFromJson(source, config = {}, options = {}) {
487
+ const maxDepth = options.maxDepth ?? 64;
488
+ const maxBlocks = options.maxBlocks ?? 10000;
489
+ if (!Number.isInteger(maxDepth) || maxDepth < 1 || !Number.isInteger(maxBlocks) || maxBlocks < 1) {
490
+ throw new ContentEditorImportError('$options', 'maxDepth and maxBlocks must be positive integers');
491
+ }
492
+ let value = source;
493
+ if (typeof source === 'string') {
582
494
  try {
583
- this._document.defaultView?.localStorage.setItem('ngsContentEditorRecentlyUsedTextColor', JSON.stringify(this.recentlyUsed()));
495
+ value = JSON.parse(source);
584
496
  }
585
497
  catch {
586
- // Keep the recent colors in memory when browser storage is unavailable.
498
+ throw new ContentEditorImportError('$', 'Invalid JSON');
587
499
  }
588
500
  }
589
- _getRecentlyUsed() {
501
+ const fail = (path, message) => { throw new ContentEditorImportError(path, message); };
502
+ const ancestors = new Set();
503
+ const copy = (input, path, depth) => {
504
+ if (depth > maxDepth)
505
+ fail(path, `Maximum nesting depth (${maxDepth}) exceeded`);
506
+ if (input === null || typeof input === 'string' || typeof input === 'boolean')
507
+ return input;
508
+ if (typeof input === 'number' && Number.isFinite(input))
509
+ return input;
510
+ if (!input || typeof input !== 'object')
511
+ return fail(path, 'Expected a JSON-compatible value');
512
+ if (ancestors.has(input))
513
+ fail(path, 'Cyclic data is not supported');
514
+ if (!Array.isArray(input) && ![Object.prototype, null].includes(Object.getPrototypeOf(input)))
515
+ fail(path, 'Expected a plain JSON object');
516
+ ancestors.add(input);
517
+ const output = Array.isArray(input)
518
+ ? Array.from(input, (item, i) => copy(item, `${path}[${i}]`, depth + 1))
519
+ : Object.fromEntries(Object.entries(input).filter(([, item]) => item !== undefined).map(([key, item]) => [key, copy(item, `${path}.${key}`, depth + 1)]));
520
+ ancestors.delete(input);
521
+ return output;
522
+ };
523
+ const object = (input, path) => {
524
+ if (input === null || typeof input !== 'object' || Array.isArray(input))
525
+ fail(path, 'Expected an object');
526
+ return input;
527
+ };
528
+ const array = (input, path) => { if (!Array.isArray(input))
529
+ fail(path, 'Expected an array'); return input; };
530
+ const string = (input, path, nonempty = false) => {
531
+ if (typeof input !== 'string' || (nonempty && !input.trim()))
532
+ fail(path, nonempty ? 'Expected a non-empty string' : 'Expected a string');
533
+ };
534
+ const props = (input, path) => {
535
+ if (input === undefined)
536
+ return;
537
+ array(input, path).forEach((prop, i) => {
538
+ object(prop, `${path}[${i}]`);
539
+ string(prop.name, `${path}[${i}].name`, true);
540
+ string(prop.value, `${path}[${i}].value`);
541
+ });
542
+ };
543
+ const runs = (input, path) => {
544
+ array(input, path).forEach((run, i) => {
545
+ const p = `${path}[${i}]`;
546
+ object(run, p);
547
+ if (run.type !== 'text')
548
+ fail(`${p}.type`, 'Expected "text"');
549
+ string(run.text, `${p}.text`);
550
+ array(run.marks, `${p}.marks`).forEach((mark, j) => {
551
+ const m = `${p}.marks[${j}]`;
552
+ object(mark, m);
553
+ string(mark.type, `${m}.type`, true);
554
+ if (mark.attrs !== undefined) {
555
+ for (const [key, attr] of Object.entries(object(mark.attrs, `${m}.attrs`))) {
556
+ if (attr !== null && !['string', 'number', 'boolean'].includes(typeof attr))
557
+ fail(`${m}.attrs.${key}`, 'Expected a scalar mark attribute');
558
+ }
559
+ }
560
+ if (mark.type === 'link' && !safeContentEditorHtmlUrl(mark.attrs?.href))
561
+ fail(`${m}.attrs.href`, 'Expected a supported non-empty link URL');
562
+ if (mark.type === 'link')
563
+ enumValue(mark.attrs?.target, ['_blank', '_self'], `${m}.attrs.target`);
564
+ if (['textColor', 'backgroundColor'].includes(mark.type) && (typeof mark.attrs?.color !== 'string' || !normalizeNgsHeadlessEditorColor(mark.attrs.color)))
565
+ fail(`${m}.attrs.color`, 'Expected a supported CSS color');
566
+ });
567
+ });
568
+ };
569
+ const enumValue = (input, allowed, path) => {
570
+ if (input !== undefined && !allowed.includes(input))
571
+ fail(path, `Expected one of: ${allowed.join(', ')}`);
572
+ };
573
+ const dimension = (input, path) => {
574
+ if (input !== undefined && input !== null && input !== 'auto' && !(typeof input === 'number' && Number.isFinite(input) && input > 0))
575
+ fail(path, 'Expected a positive pixel dimension, "auto", or null');
576
+ };
577
+ const usedIds = new Set();
578
+ let count = 0;
579
+ const list = (input, path) => {
580
+ array(input, path).forEach((item, i) => {
581
+ const p = `${path}[${i}]`;
582
+ object(item, p);
583
+ runs(item.content, `${p}.content`);
584
+ props(item.props, `${p}.props`);
585
+ list(item.children, `${p}.children`);
586
+ });
587
+ };
588
+ const blocks = (input, path) => {
589
+ array(input, path).forEach((block, i) => {
590
+ const p = `${path}[${i}]`;
591
+ object(block, p);
592
+ if (++count > maxBlocks)
593
+ fail(p, `Maximum block count (${maxBlocks}) exceeded`);
594
+ string(block.id, `${p}.id`, true);
595
+ string(block.type, `${p}.type`, true);
596
+ if (usedIds.has(block.id))
597
+ fail(`${p}.id`, `Duplicate block ID "${block.id}"`);
598
+ usedIds.add(block.id);
599
+ if (!Object.hasOwn(block, 'content'))
600
+ fail(`${p}.content`, 'Required field');
601
+ const attrs = block.attrs === undefined ? {} : object(block.attrs, `${p}.attrs`);
602
+ const settings = attrs['settings'] === undefined ? {} : object(attrs['settings'], `${p}.attrs.settings`);
603
+ props(attrs['props'], `${p}.attrs.props`);
604
+ const c = block.content;
605
+ const cp = `${p}.content`;
606
+ const sp = `${p}.attrs.settings`;
607
+ switch (block.type) {
608
+ case 'paragraph':
609
+ case 'heading':
610
+ case 'code':
611
+ case 'callout':
612
+ runs(c, cp);
613
+ if (block.type === 'heading')
614
+ enumValue(settings['level'], [1, 2, 3, 4, 5, 6], `${sp}.level`);
615
+ if (block.type === 'code' && settings['language'] !== undefined)
616
+ string(settings['language'], `${sp}.language`);
617
+ if (block.type === 'callout')
618
+ enumValue(settings['variant'], ['note', 'tip', 'warning', 'danger'], `${sp}.variant`);
619
+ break;
620
+ case 'divider':
621
+ if (c !== null)
622
+ fail(cp, 'Divider content must be null');
623
+ break;
624
+ case 'bulletList':
625
+ case 'orderedList':
626
+ list(c, cp);
627
+ enumValue(settings['listStyle'], ['bullet', 'ordered'], `${sp}.listStyle`);
628
+ break;
629
+ case 'quote':
630
+ object(c, cp);
631
+ for (const name of ['cite', 'caption']) {
632
+ object(c[name], `${cp}.${name}`);
633
+ runs(c[name].content, `${cp}.${name}.content`);
634
+ props(c[name].props, `${cp}.${name}.props`);
635
+ }
636
+ break;
637
+ case 'table':
638
+ if (c !== null)
639
+ fail(cp, 'Native table content must be null; use attrs.rows');
640
+ if (array(attrs['rows'], `${p}.attrs.rows`).length > 500)
641
+ fail(`${p}.attrs.rows`, 'Tables support at most 500 rows');
642
+ attrs['rows'].forEach((row, r) => {
643
+ if (array(row, `${p}.attrs.rows[${r}]`).length > 50)
644
+ fail(`${p}.attrs.rows[${r}]`, 'Tables support at most 50 columns');
645
+ row.forEach((cell, col) => runs(cell, `${p}.attrs.rows[${r}][${col}]`));
646
+ });
647
+ enumValue(attrs['header'], [true, false], `${p}.attrs.header`);
648
+ if (attrs['cellMetadata'] !== undefined)
649
+ array(attrs['cellMetadata'], `${p}.attrs.cellMetadata`).forEach((row, r) => array(row, `${p}.attrs.cellMetadata[${r}]`).forEach((cell, col) => {
650
+ const mp = `${p}.attrs.cellMetadata[${r}][${col}]`;
651
+ object(cell, mp);
652
+ props(cell.props, `${mp}.props`);
653
+ if (cell.options !== undefined) {
654
+ const opts = object(cell.options, `${mp}.options`);
655
+ for (const key of ['colspan', 'rowspan'])
656
+ if (opts[key] !== undefined && !(Number.isInteger(opts[key]) && opts[key] > 0))
657
+ fail(`${mp}.options.${key}`, 'Expected a positive integer');
658
+ dimension(opts['width'], `${mp}.options.width`);
659
+ }
660
+ }));
661
+ break;
662
+ case 'image':
663
+ case 'video':
664
+ case 'embed':
665
+ case 'attachment':
666
+ object(c, cp);
667
+ for (const key of block.type === 'image' ? ['src', 'alt'] : block.type === 'video' ? ['src', 'caption'] : block.type === 'embed' ? ['url', 'type'] : ['url', 'name', 'mimeType'])
668
+ string(c[key], `${cp}.${key}`);
669
+ {
670
+ const key = ['image', 'video'].includes(block.type) ? 'src' : 'url';
671
+ const kind = block.type === 'video' ? 'media' : block.type === 'image' ? 'image' : block.type === 'embed' ? 'embed' : 'attachment';
672
+ if (c[key] && !safeContentEditorHtmlUrl(c[key], kind))
673
+ fail(`${cp}.${key}`, 'Unsupported resource URL');
674
+ }
675
+ if (block.type === 'attachment' && !(Number.isInteger(c.size) && c.size >= 0))
676
+ fail(`${cp}.size`, 'Expected a non-negative integer byte count');
677
+ if (block.type === 'video')
678
+ enumValue(c.orientation, ['portrait', 'landscape'], `${cp}.orientation`);
679
+ for (const key of ['width', 'height', 'actualWidth', 'actualHeight'])
680
+ dimension(settings[key], `${sp}.${key}`);
681
+ break;
682
+ case 'gallery': {
683
+ object(c, cp);
684
+ const ids = new Set();
685
+ array(c.images, `${cp}.images`).forEach((image, j) => {
686
+ const ip = `${cp}.images[${j}]`;
687
+ object(image, ip);
688
+ string(image.id, `${ip}.id`, true);
689
+ if (ids.has(image.id))
690
+ fail(`${ip}.id`, 'Duplicate image ID');
691
+ ids.add(image.id);
692
+ string(image.src, `${ip}.src`);
693
+ string(image.alt, `${ip}.alt`);
694
+ runs(image.caption, `${ip}.caption`);
695
+ if (image.src && !safeContentEditorHtmlUrl(image.src, 'image'))
696
+ fail(`${ip}.src`, 'Unsupported image URL');
697
+ });
698
+ break;
699
+ }
700
+ case 'toggle':
701
+ object(c, cp);
702
+ runs(c.title, `${cp}.title`);
703
+ blocks(c.blocks, `${cp}.blocks`);
704
+ enumValue(settings['expanded'], [true, false], `${sp}.expanded`);
705
+ break;
706
+ case 'grid': {
707
+ object(c, cp);
708
+ const ids = new Set();
709
+ array(c.cells, `${cp}.cells`).forEach((cell, j) => {
710
+ const gp = `${cp}.cells[${j}]`;
711
+ object(cell, gp);
712
+ string(cell.id, `${gp}.id`, true);
713
+ if (ids.has(cell.id))
714
+ fail(`${gp}.id`, 'Duplicate grid cell ID');
715
+ ids.add(cell.id);
716
+ blocks(cell.blocks, `${gp}.blocks`);
717
+ });
718
+ enumValue(settings['columns'], [2, 3, 4], `${sp}.columns`);
719
+ enumValue(settings['gap'], ['small', 'medium', 'large'], `${sp}.gap`);
720
+ enumValue(settings['stackOnMobile'], [true, false], `${sp}.stackOnMobile`);
721
+ break;
722
+ }
723
+ default:
724
+ if (!options.allowUnknownBlocks && !Object.hasOwn(config.blocks ?? {}, block.type))
725
+ fail(`${p}.type`, `Unknown block type "${block.type}"`);
726
+ }
727
+ const validation = config.blocks?.[block.type]?.validateImport?.(block);
728
+ if (validation !== undefined)
729
+ fail(p, validation);
730
+ });
731
+ };
732
+ const document = object(copy(value, '$', 0), '$');
733
+ if (document['version'] !== 1)
734
+ fail('$.version', 'Only document version 1 is supported');
735
+ blocks(document['blocks'], '$.blocks');
736
+ return { version: 1, blocks: document['blocks'] };
737
+ }
738
+
739
+ const ignoredTags = new Set(['script', 'style', 'noscript', 'template', 'object', 'embed', 'head', 'meta', 'link']);
740
+ const blockTags = new Set(['p', 'div', 'section', 'article', 'header', 'footer', 'main', 'aside', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'blockquote', 'figure', 'ul', 'ol', 'table', 'details', 'hr']);
741
+ /** Imports semantic HTML into native blocks. Scripts, event handlers and arbitrary CSS are never stored. */
742
+ function contentEditorFromHtml(html, config = {}, options = {}) {
743
+ if (typeof html !== 'string')
744
+ throw new ContentEditorImportError('$html', 'Expected an HTML string');
745
+ const owner = options.document ?? globalThis.document;
746
+ if (!owner?.implementation?.createHTMLDocument) {
747
+ throw new ContentEditorImportError('$html', 'HTML import requires a DOM document; supply options.document when running on the server');
748
+ }
749
+ const inert = owner.implementation.createHTMLDocument('');
750
+ inert.body.innerHTML = html;
751
+ const maxDepth = options.maxDepth ?? 64;
752
+ const maxBlocks = options.maxBlocks ?? 10000;
753
+ if (!Number.isInteger(maxDepth) || maxDepth < 1 || !Number.isInteger(maxBlocks) || maxBlocks < 1)
754
+ throw new ContentEditorImportError('$options', 'maxDepth and maxBlocks must be positive integers');
755
+ const definitions = [...new Map([...basicTextEditorPlugin().marks, ...colorEditorPlugin().marks, ...linkEditorPlugin().marks, ...(config.importMarks ?? [])].map(mark => [mark.type, mark])).values()];
756
+ const overrides = Object.values(config.blocks ?? {}).flatMap(block => block.fromHtml ? [block.fromHtml] : []);
757
+ let depth = 0;
758
+ let count = 0;
759
+ const guarded = (read) => {
760
+ if (++depth > maxDepth)
761
+ throw new ContentEditorImportError('$html', `Maximum nesting depth (${maxDepth}) exceeded`);
590
762
  try {
591
- const value = this._document.defaultView?.localStorage.getItem('ngsContentEditorRecentlyUsedTextColor');
592
- const colors = value ? JSON.parse(value) : [];
593
- return Array.isArray(colors) ? colors : [];
763
+ return read();
594
764
  }
595
- catch {
765
+ finally {
766
+ depth--;
767
+ }
768
+ };
769
+ const tag = (element) => element.tagName.toLowerCase();
770
+ const children = (element) => Array.from(element.children);
771
+ const direct = (element, selector) => children(element).find(child => child.matches(selector));
772
+ const alignment = (element) => {
773
+ const value = element.style?.textAlign || element.getAttribute('align');
774
+ return value && ['left', 'center', 'right', 'justify'].includes(value) ? [{ name: 'text-alignment', value }] : [];
775
+ };
776
+ const dimension = (element, name) => {
777
+ const raw = element.getAttribute(name);
778
+ if (!raw || !/^\d+(?:\.\d+)?$/.test(raw))
779
+ return null;
780
+ const value = Number(raw);
781
+ return value > 0 && Number.isFinite(value) ? value : null;
782
+ };
783
+ const createBlock = (type, content, attrs) => {
784
+ if (++count > maxBlocks)
785
+ throw new ContentEditorImportError('$html', `Maximum block count (${maxBlocks}) exceeded`);
786
+ return { id: createNgsHeadlessEditorId(type), type, content, ...(attrs ? { attrs } : {}) };
787
+ };
788
+ const parseText = (element) => {
789
+ const runs = [];
790
+ const newline = () => { if (runs.length && !runs.at(-1).text.endsWith('\n'))
791
+ runs.push(createNgsHeadlessEditorText('\n')); };
792
+ const visit = (node, marks) => guarded(() => {
793
+ if (node.nodeType === 3) {
794
+ const text = (node.textContent ?? '').replace(/[\t\r\n ]+/g, ' ');
795
+ if (text)
796
+ runs.push(createNgsHeadlessEditorText(text, marks));
797
+ return;
798
+ }
799
+ if (node.nodeType !== 1)
800
+ return;
801
+ const el = node;
802
+ const name = tag(el);
803
+ if (ignoredTags.has(name) || ['iframe', 'img', 'video', 'audio', 'ul', 'ol'].includes(name))
804
+ return;
805
+ if (name === 'br') {
806
+ runs.push(createNgsHeadlessEditorText('\n', marks));
807
+ return;
808
+ }
809
+ const next = [...marks];
810
+ for (const definition of definitions) {
811
+ const explicit = el.getAttribute('data-ngs-headless-editor-mark');
812
+ const styleMark = ['textColor', 'backgroundColor'].includes(definition.type) && !!el.style;
813
+ if (explicit ? explicit !== definition.type : name !== definition.tagName && !definition.parseTags?.includes(name) && !styleMark)
814
+ continue;
815
+ const attrs = definition.readAttributes?.(el);
816
+ if (!definition.readAttributes || attrs)
817
+ next.push({ type: definition.type, ...(attrs ? { attrs } : {}) });
818
+ }
819
+ // Common HTML produced by external WYSIWYG editors also expresses marks as inline styles.
820
+ const css = el.style;
821
+ if (css?.fontWeight === 'bold' || Number(css?.fontWeight) >= 600)
822
+ next.push({ type: 'bold' });
823
+ if (css?.fontStyle === 'italic')
824
+ next.push({ type: 'italic' });
825
+ if (css?.textDecoration.includes('underline'))
826
+ next.push({ type: 'underline' });
827
+ if (css?.textDecoration.includes('line-through'))
828
+ next.push({ type: 'strike' });
829
+ if (blockTags.has(name))
830
+ newline();
831
+ Array.from(node.childNodes).forEach(child => visit(child, next));
832
+ if (blockTags.has(name))
833
+ newline();
834
+ });
835
+ visit(element, []);
836
+ while (runs.length && !runs[0].text.trim())
837
+ runs.shift();
838
+ while (runs.length && !runs.at(-1).text.trim())
839
+ runs.pop();
840
+ if (runs.length) {
841
+ runs[0] = { ...runs[0], text: runs[0].text.replace(/^\s+/, '') };
842
+ const last = runs.length - 1;
843
+ runs[last] = { ...runs[last], text: runs[last].text.replace(/\s+$/, '') };
844
+ }
845
+ return [...normalizeNgsHeadlessEditorTextContent(runs)];
846
+ };
847
+ const listItems = (element) => guarded(() => children(element).filter(el => tag(el) === 'li').map(li => {
848
+ const text = li.cloneNode(true);
849
+ children(text).filter(el => ['ul', 'ol'].includes(tag(el))).forEach(el => el.remove());
850
+ return { content: parseText(text), props: alignment(li), children: children(li).filter(el => ['ul', 'ol'].includes(tag(el))).flatMap(listItems) };
851
+ }));
852
+ const media = (element, figure) => {
853
+ const name = tag(element);
854
+ const kind = name === 'img' ? 'image' : name === 'video' ? 'media' : 'embed';
855
+ const src = safeContentEditorHtmlUrl(element.getAttribute('src') || element.querySelector('source')?.getAttribute('src'), kind);
856
+ if (!src)
857
+ return [];
858
+ const caption = figure ? direct(figure, 'figcaption') : undefined;
859
+ const settings = Object.fromEntries(['width', 'height'].flatMap(key => { const n = dimension(element, key); return n ? [[key, n]] : []; }));
860
+ const content = name === 'img' ? { src, alt: element.getAttribute('alt') ?? '' }
861
+ : name === 'video' ? { src, caption: caption?.textContent ?? '', orientation: 'landscape' }
862
+ : { url: src, type: element.getAttribute('title') ?? '' };
863
+ return [createBlock(name === 'img' ? 'image' : name === 'video' ? 'video' : 'embed', content, { settings })];
864
+ };
865
+ const builtin = (element) => {
866
+ const name = tag(element);
867
+ const attrs = { props: alignment(element) };
868
+ if (ignoredTags.has(name))
869
+ return [];
870
+ if (element.matches('[data-content-editor="gallery"], .ngs-content-editor-html-gallery')) {
871
+ const images = children(element).flatMap(figure => {
872
+ const image = tag(figure) === 'img' ? figure : direct(figure, 'img');
873
+ const src = safeContentEditorHtmlUrl(image?.getAttribute('src'), 'image');
874
+ if (!image || !src)
875
+ return [];
876
+ const caption = direct(figure, 'figcaption');
877
+ return [{ id: createNgsHeadlessEditorId('image'), src, alt: image.getAttribute('alt') ?? '', caption: caption ? parseText(caption) : [] }];
878
+ });
879
+ return [createBlock('gallery', { images })];
880
+ }
881
+ if (element.matches('.ngs-content-editor-html-grid')) {
882
+ const container = direct(element, '.ngs-content-editor-html-grid-cells') ?? element;
883
+ const css = element.style;
884
+ const columnValue = Number(element.getAttribute('data-columns') || css?.getPropertyValue('--ngs-html-grid-columns'));
885
+ const gapValue = css?.getPropertyValue('--ngs-html-grid-gap').trim();
886
+ const settings = { columns: [2, 3, 4].includes(columnValue) ? columnValue : 2, gap: gapValue === '12px' ? 'small' : gapValue === '36px' ? 'large' : 'medium', stackOnMobile: container.classList.contains('ngs-content-editor-html-grid-stack') };
887
+ const cells = children(container).filter(cell => cell.matches('.ngs-content-editor-html-grid-cell')).map(cell => ({ id: createNgsHeadlessEditorId('cell'), blocks: parseBlocks(cell) }));
888
+ return [createBlock('grid', { cells }, { settings })];
889
+ }
890
+ if (name === 'p' || /^h[1-6]$/.test(name)) {
891
+ if (element.querySelector('img, video, iframe, a[download]'))
892
+ return parseBlocks(element);
893
+ return [createBlock(name === 'p' ? 'paragraph' : 'heading', parseText(element), { ...attrs, ...(name !== 'p' ? { settings: { level: Number(name[1]) } } : {}) })];
894
+ }
895
+ if (name === 'hr')
896
+ return [createBlock('divider', null)];
897
+ if (name === 'pre') {
898
+ const code = direct(element, 'code') ?? element;
899
+ const language = code.getAttribute('data-language') ?? Array.from(code.classList).find(cls => cls.startsWith('language-'))?.slice(9) ?? 'none';
900
+ return [createBlock('code', [createNgsHeadlessEditorText(code.textContent ?? '')], { settings: { language } })];
901
+ }
902
+ if (name === 'ul' || name === 'ol')
903
+ return [createBlock(name === 'ol' ? 'orderedList' : 'bulletList', listItems(element), { settings: { listStyle: name === 'ol' ? 'ordered' : 'bullet' } })];
904
+ if (name === 'details') {
905
+ const summary = direct(element, 'summary');
906
+ const body = element.cloneNode(true);
907
+ direct(body, 'summary')?.remove();
908
+ return [createBlock('toggle', { title: summary ? parseText(summary) : [], blocks: parseBlocks(body) }, { settings: { expanded: element.hasAttribute('open') } })];
909
+ }
910
+ if (name === 'aside' && (element.hasAttribute('data-callout') || element.classList.contains('ngs-content-editor-html-callout'))) {
911
+ const value = element.getAttribute('data-callout');
912
+ return [createBlock('callout', parseText(element), { ...attrs, settings: { variant: ['note', 'tip', 'warning', 'danger'].includes(value ?? '') ? value : 'note' } })];
913
+ }
914
+ if (name === 'blockquote' || (name === 'figure' && direct(element, 'blockquote'))) {
915
+ const quote = name === 'blockquote' ? element : direct(element, 'blockquote');
916
+ const caption = name === 'figure' ? direct(element, 'figcaption') : undefined;
917
+ return [createBlock('quote', { cite: { content: parseText(quote), props: alignment(quote) }, caption: { content: caption ? parseText(caption) : [], props: caption ? alignment(caption) : [] } })];
918
+ }
919
+ if (name === 'table') {
920
+ const rows = Array.from(element.querySelectorAll('tr')).filter(row => row.closest('table') === element);
921
+ const cells = rows.map(row => children(row).filter(cell => ['td', 'th'].includes(tag(cell))));
922
+ return [createBlock('table', null, {
923
+ rows: cells.map(row => row.map(parseText)), header: !!cells[0]?.some(cell => tag(cell) === 'th'),
924
+ cellMetadata: cells.map(row => row.map(cell => ({ props: alignment(cell), options: {
925
+ colspan: Math.max(1, Math.floor(dimension(cell, 'colspan') ?? 1)), rowspan: Math.max(1, Math.floor(dimension(cell, 'rowspan') ?? 1)),
926
+ ...(dimension(cell, 'width') ? { width: dimension(cell, 'width') } : {})
927
+ } })))
928
+ })];
929
+ }
930
+ if (name === 'figure') {
931
+ const child = direct(element, 'img, video, iframe');
932
+ if (child)
933
+ return media(child, element);
934
+ }
935
+ if (['img', 'video', 'iframe'].includes(name))
936
+ return media(element);
937
+ if (name === 'a' && element.hasAttribute('download')) {
938
+ const url = safeContentEditorHtmlUrl(element.getAttribute('href'), 'attachment');
939
+ return url ? [createBlock('attachment', { url, name: element.getAttribute('download') || element.textContent?.trim() || 'Download', size: 0, mimeType: '' })] : [];
940
+ }
941
+ return parseBlocks(element);
942
+ };
943
+ const context = {
944
+ createBlock, createId: createNgsHeadlessEditorId, parseText, parseBlocks: element => parseBlocks(element),
945
+ defaultFromHtml: builtin, safeUrl: safeContentEditorHtmlUrl
946
+ };
947
+ const parseElement = (element) => guarded(() => {
948
+ if (ignoredTags.has(tag(element)))
596
949
  return [];
950
+ for (const override of overrides) {
951
+ if (element.matches(override.selector)) {
952
+ const result = override.parse(element, context);
953
+ return result === null ? [] : Array.isArray(result) ? [...result] : [result];
954
+ }
955
+ }
956
+ return builtin(element);
957
+ });
958
+ const parseBlocks = (element) => guarded(() => {
959
+ const output = [];
960
+ let inline = inert.createElement('div');
961
+ const flush = () => {
962
+ const runs = parseText(inline);
963
+ if (runs.some(run => run.text.trim()))
964
+ output.push(createBlock('paragraph', runs, { props: alignment(element) }));
965
+ inline = inert.createElement('div');
966
+ };
967
+ for (const node of Array.from(element.childNodes)) {
968
+ if (node.nodeType === 1) {
969
+ const child = node;
970
+ if (ignoredTags.has(tag(child)))
971
+ continue;
972
+ if (blockTags.has(tag(child)) || ['img', 'video', 'iframe'].includes(tag(child)) || child.matches('a[download]') || overrides.some(override => child.matches(override.selector))) {
973
+ flush();
974
+ output.push(...parseElement(child));
975
+ continue;
976
+ }
977
+ // Unknown inline wrappers may contain block elements; keep those structures.
978
+ if (child.querySelector([...blockTags, 'img', 'video', 'iframe', 'a[download]'].join(',')) || overrides.some(override => child.querySelector(override.selector))) {
979
+ flush();
980
+ output.push(...parseElement(child));
981
+ continue;
982
+ }
983
+ }
984
+ inline.appendChild(node.cloneNode(true));
597
985
  }
986
+ flush();
987
+ return output;
988
+ });
989
+ return contentEditorFromJson({ version: 1, blocks: parseBlocks(inert.body) }, config, options);
990
+ }
991
+
992
+ /** Parsing only: applications decide when to replace their current document. */
993
+ class ContentEditorImporter {
994
+ config = inject(CONTENT_EDITOR_CONFIG);
995
+ document = inject(DOCUMENT);
996
+ fromJson(source, config = {}, options = {}) {
997
+ return contentEditorFromJson(source, mergeContentEditorConfig(this.config, config), options);
598
998
  }
599
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: TextColorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
600
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: TextColorComponent, isStandalone: true, selector: "ngs-text-color", inputs: { recentlyUsed: { classPropertyName: "recentlyUsed", publicName: "recentlyUsed", isSignal: true, isRequired: false, transformFunction: null }, selectedTextColor: { classPropertyName: "selectedTextColor", publicName: "selectedTextColor", isSignal: true, isRequired: false, transformFunction: null }, selectedBackgroundColor: { classPropertyName: "selectedBackgroundColor", publicName: "selectedBackgroundColor", isSignal: true, isRequired: false, transformFunction: null }, textColors: { classPropertyName: "textColors", publicName: "textColors", isSignal: true, isRequired: false, transformFunction: null }, backgroundColors: { classPropertyName: "backgroundColors", publicName: "backgroundColors", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { recentlyUsed: "recentlyUsedChange", selectedTextColor: "selectedTextColorChange", selectedBackgroundColor: "selectedBackgroundColorChange", textColorChanged: "textColorChanged", backgroundColorChanged: "backgroundColorChanged" }, ngImport: i0, template: "@if (recentlyUsed().length > 0) {\n <div class=\"mb-5\">\n <div class=\"text-xs text-neutral-700 text-semibold\">Recently colors</div>\n <div class=\"flex gap-2 flex-wrap mt-3\">\n @for (recentlyColor of recentlyUsed(); track recentlyColor) {\n @if (recentlyColor.type === 'text') {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\"\n [style.color]=\"recentlyColor.color\" [ngsTooltip]=\"recentlyColor.name\"\n (click)=\"selectRecentlyColor(recentlyColor)\">\n <ngs-icon name=\"fluent:text-field-24-regular\"/>\n </button>\n } @else if (recentlyColor.type === 'background') {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\"\n [style.background-color]=\"recentlyColor.color\" [ngsTooltip]=\"recentlyColor.name\"\n (click)=\"selectRecentlyColor(recentlyColor)\">\n </button>\n }\n }\n </div>\n </div>\n}\n\n<div class=\"mb-5\">\n <div class=\"text-xs text-neutral-700 text-semibold\">Text color</div>\n <div class=\"flex gap-2 flex-wrap mt-3\">\n @for (textColor of textColors(); track $index) {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\n [&.is-selected]:outline [&.is-selected]:outline-primary\"\n [style.color]=\"textColor.color\" [ngsTooltip]=\"textColor.name\"\n [class.is-selected]=\"selectedTextColor()?.color === textColor.color\"\n (click)=\"selectTextColor(textColor)\">\n <ngs-icon name=\"fluent:text-field-24-regular\"/>\n </button>\n }\n </div>\n</div>\n\n<div>\n <div class=\"text-xs text-neutral-700 text-semibold\">Background color</div>\n <div class=\"flex gap-2 flex-wrap mt-3\">\n @for (backgroundColor of backgroundColors(); track $index) {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\n [&.is-selected]:outline [&.is-selected]:outline-primary\"\n [style.background-color]=\"backgroundColor.color\" [ngsTooltip]=\"backgroundColor.name\"\n [class.is-selected]=\"selectedBackgroundColor()?.color === backgroundColor.color\"\n (click)=\"selectBackgroundColor(backgroundColor)\">\n </button>\n }\n </div>\n</div>\n", styles: [":host{display:block;width:172px}\n"], dependencies: [{ kind: "component", type: Icon, selector: "ngs-icon", inputs: ["name"], exportAs: ["ngsIcon"] }, { kind: "directive", type: Tooltip, selector: "[ngsTooltip]", inputs: ["ngsTooltip", "ngsTooltipPosition", "ngsTooltipClass", "ngsTooltipShowDelay", "ngsTooltipHideDelay", "ngsTooltipOffset", "ngsTooltipPositionAtOrigin", "ngsTooltipDisabled"], exportAs: ["ngsTooltip"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
999
+ fromHtml(html, config = {}, options = {}) {
1000
+ return contentEditorFromHtml(html, mergeContentEditorConfig(this.config, config), { document: this.document, ...options });
1001
+ }
1002
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorImporter, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1003
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorImporter, providedIn: 'root' });
601
1004
  }
602
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: TextColorComponent, decorators: [{
603
- type: Component,
604
- args: [{ selector: 'ngs-text-color', imports: [
605
- Icon,
606
- Tooltip
607
- ], changeDetection: ChangeDetectionStrategy.Eager, template: "@if (recentlyUsed().length > 0) {\n <div class=\"mb-5\">\n <div class=\"text-xs text-neutral-700 text-semibold\">Recently colors</div>\n <div class=\"flex gap-2 flex-wrap mt-3\">\n @for (recentlyColor of recentlyUsed(); track recentlyColor) {\n @if (recentlyColor.type === 'text') {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\"\n [style.color]=\"recentlyColor.color\" [ngsTooltip]=\"recentlyColor.name\"\n (click)=\"selectRecentlyColor(recentlyColor)\">\n <ngs-icon name=\"fluent:text-field-24-regular\"/>\n </button>\n } @else if (recentlyColor.type === 'background') {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\"\n [style.background-color]=\"recentlyColor.color\" [ngsTooltip]=\"recentlyColor.name\"\n (click)=\"selectRecentlyColor(recentlyColor)\">\n </button>\n }\n }\n </div>\n </div>\n}\n\n<div class=\"mb-5\">\n <div class=\"text-xs text-neutral-700 text-semibold\">Text color</div>\n <div class=\"flex gap-2 flex-wrap mt-3\">\n @for (textColor of textColors(); track $index) {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\n [&.is-selected]:outline [&.is-selected]:outline-primary\"\n [style.color]=\"textColor.color\" [ngsTooltip]=\"textColor.name\"\n [class.is-selected]=\"selectedTextColor()?.color === textColor.color\"\n (click)=\"selectTextColor(textColor)\">\n <ngs-icon name=\"fluent:text-field-24-regular\"/>\n </button>\n }\n </div>\n</div>\n\n<div>\n <div class=\"text-xs text-neutral-700 text-semibold\">Background color</div>\n <div class=\"flex gap-2 flex-wrap mt-3\">\n @for (backgroundColor of backgroundColors(); track $index) {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\n [&.is-selected]:outline [&.is-selected]:outline-primary\"\n [style.background-color]=\"backgroundColor.color\" [ngsTooltip]=\"backgroundColor.name\"\n [class.is-selected]=\"selectedBackgroundColor()?.color === backgroundColor.color\"\n (click)=\"selectBackgroundColor(backgroundColor)\">\n </button>\n }\n </div>\n</div>\n", styles: [":host{display:block;width:172px}\n"] }]
608
- }], propDecorators: { recentlyUsed: [{ type: i0.Input, args: [{ isSignal: true, alias: "recentlyUsed", required: false }] }, { type: i0.Output, args: ["recentlyUsedChange"] }], selectedTextColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedTextColor", required: false }] }, { type: i0.Output, args: ["selectedTextColorChange"] }], selectedBackgroundColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedBackgroundColor", required: false }] }, { type: i0.Output, args: ["selectedBackgroundColorChange"] }], textColors: [{ type: i0.Input, args: [{ isSignal: true, alias: "textColors", required: false }] }], backgroundColors: [{ type: i0.Input, args: [{ isSignal: true, alias: "backgroundColors", required: false }] }], textColorChanged: [{ type: i0.Output, args: ["textColorChanged"] }], backgroundColorChanged: [{ type: i0.Output, args: ["backgroundColorChanged"] }] } });
1005
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorImporter, decorators: [{
1006
+ type: Injectable,
1007
+ args: [{ providedIn: 'root' }]
1008
+ }] });
609
1009
 
610
- class CommandBarComponent {
611
- editor = inject(NgsHeadlessEditor);
612
- dialog = inject(Dialog);
613
- observedElement = input(null, /* @ts-ignore */
614
- ...(ngDevMode ? [{ debugName: "observedElement" }] : /* istanbul ignore next */ []));
615
- alignment = computed(() => this.region()?.alignment() ?? 'left', /* @ts-ignore */
616
- ...(ngDevMode ? [{ debugName: "alignment" }] : /* istanbul ignore next */ []));
617
- savedSelection = null;
618
- region() { return ContentEditorContentEditableDirective.forElement(this.observedElement()); }
619
- toggleBold() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_BOLD); }
620
- toggleItalic() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_ITALIC); }
621
- toggleCode() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_CODE); }
622
- toggleStrike() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_STRIKE); }
623
- toggleUnderline() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_UNDERLINE); }
624
- toggleSuperscript() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_SUPERSCRIPT); }
625
- toggleSubscript() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_SUBSCRIPT); }
626
- isLinkActive() { return this.editor.isMarkActive('link'); }
627
- isActive(tag) {
628
- return this.editor.isMarkActive({ strong: 'bold', em: 'italic', s: 'strike', u: 'underline', sup: 'superscript', sub: 'subscript' }[tag] ?? tag);
629
- }
630
- setTextAlignment(value) { this.restoreSelection()?.setAlignment(value); }
631
- isTextAlignment(value) { return this.alignment() === value; }
632
- addLink() { this.openLinkDialog(false); }
633
- editLink() { this.openLinkDialog(true); }
634
- openLinkDialog(edit) {
635
- this.retainSelection();
636
- const saved = this.savedSelection;
637
- if (!saved)
638
- return;
639
- const target = saved.region.region.editor;
640
- const mark = target.getActiveMark('link');
641
- const ref = edit
642
- ? this.dialog.open(EditLinkDialog, { data: { href: mark?.attrs?.['href'], openInNewTab: mark?.attrs?.['target'] === '_blank' }, width: '500px', restoreFocus: false })
643
- : this.dialog.open(AddLinkDialog, { width: '500px', restoreFocus: false });
644
- ref.afterClosed().subscribe((value) => {
645
- if (!this.restoreSelection())
646
- return;
647
- if (value) {
648
- if (value.href)
649
- this.editor.execute(NGS_HEADLESS_EDITOR_SET_LINK, { href: value.href, target: value.openInNewTab ? '_blank' : '_self' });
650
- else
651
- this.editor.execute(NGS_HEADLESS_EDITOR_UNSET_LINK);
652
- }
653
- this.restoreSelectionAfterOverlay();
1010
+ /** Text fields use the same HTML parser as documents, flattening structure to lines. */
1011
+ function contentEditorImportedText(blocks) {
1012
+ const parts = [];
1013
+ const read = (block) => {
1014
+ const content = block.content;
1015
+ if (isNgsHeadlessEditorTextContent(content))
1016
+ parts.push(content);
1017
+ else if (block.type === 'quote') {
1018
+ parts.push(content.cite.content, content.caption.content);
1019
+ }
1020
+ else if (block.type === 'bulletList' || block.type === 'orderedList') {
1021
+ const item = (value) => { parts.push(value.content); value.children?.forEach(item); };
1022
+ content.forEach(item);
1023
+ }
1024
+ else if (block.type === 'table') {
1025
+ for (const row of (block.attrs?.['rows'] ?? []))
1026
+ parts.push(row.flatMap((cell, i) => i ? [createNgsHeadlessEditorText('\t'), ...cell] : cell));
1027
+ }
1028
+ else if (block.type === 'toggle') {
1029
+ parts.push(content.title);
1030
+ content.blocks.forEach(read);
1031
+ }
1032
+ else if (block.type === 'grid')
1033
+ content.cells.forEach((cell) => cell.blocks.forEach(read));
1034
+ else if (block.type === 'image' || block.type === 'gallery')
1035
+ parts.push([createNgsHeadlessEditorText(content.alt ?? '')]);
1036
+ };
1037
+ blocks.forEach(read);
1038
+ return normalizeNgsHeadlessEditorTextContent(parts.filter(part => part.some(run => run.text)).flatMap((part, i) => i ? [createNgsHeadlessEditorText('\n'), ...part] : part));
1039
+ }
1040
+
1041
+ const CONTENT_BUILDER = new InjectionToken('CONTENT_BUILDER');
1042
+ const CONTENT_EDITOR_BLOCK = new InjectionToken('CONTENT_EDITOR_BLOCK');
1043
+
1044
+ /** UI state and block operations. The headless document is the only content store. */
1045
+ class ContentBuilderStore {
1046
+ editor = inject(NgsHeadlessEditor);
1047
+ dragging = false;
1048
+ constructor() {
1049
+ const document = inject(DOCUMENT);
1050
+ // Capture the current point before CDK chooses a connected list. Its moved
1051
+ // output is emitted after hit testing and would provide the previous point.
1052
+ const mouse = (event) => { if (this.dragging)
1053
+ this.dragPointer.set({ x: event.clientX, y: event.clientY }); };
1054
+ const touch = (event) => {
1055
+ const point = event.touches[0];
1056
+ if (this.dragging && point)
1057
+ this.dragPointer.set({ x: point.clientX, y: point.clientY });
1058
+ };
1059
+ document.addEventListener('mousemove', mouse, true);
1060
+ document.addEventListener('touchmove', touch, { capture: true, passive: true });
1061
+ inject(DestroyRef).onDestroy(() => {
1062
+ document.removeEventListener('mousemove', mouse, true);
1063
+ document.removeEventListener('touchmove', touch, true);
654
1064
  });
655
1065
  }
656
- preserveSelection(event) {
657
- event.preventDefault();
658
- this.region()?.activate();
659
- this.retainSelection();
1066
+ textEdit = null;
1067
+ /** Scopes typing groups to one text region, so adjacent cells never share undo. */
1068
+ withTextEdit(origin, group, edit) {
1069
+ const previous = this.textEdit;
1070
+ this.textEdit = { origin, group };
1071
+ try {
1072
+ edit();
1073
+ }
1074
+ finally {
1075
+ this.textEdit = previous;
1076
+ }
660
1077
  }
661
- retainSelection() {
662
- if (this.savedSelection)
663
- return;
664
- const region = this.region();
665
- const selection = region?.region.editor.selection();
666
- if (region && selection)
667
- this.savedSelection = { region, selection };
1078
+ insertionTarget = signal({ scope: {} }, /* @ts-ignore */
1079
+ ...(ngDevMode ? [{ debugName: "insertionTarget" }] : /* istanbul ignore next */ []));
1080
+ restoreTextSelection = signal(null, /* @ts-ignore */
1081
+ ...(ngDevMode ? [{ debugName: "restoreTextSelection" }] : /* istanbul ignore next */ []));
1082
+ focusedBlockId = signal(null, /* @ts-ignore */
1083
+ ...(ngDevMode ? [{ debugName: "focusedBlockId" }] : /* istanbul ignore next */ []));
1084
+ activeBlockId = signal(null, /* @ts-ignore */
1085
+ ...(ngDevMode ? [{ debugName: "activeBlockId" }] : /* istanbul ignore next */ []));
1086
+ dragPointer = signal(null, /* @ts-ignore */
1087
+ ...(ngDevMode ? [{ debugName: "dragPointer" }] : /* istanbul ignore next */ []));
1088
+ setDragging(dragging) {
1089
+ this.dragging = dragging;
1090
+ if (!dragging)
1091
+ this.dragPointer.set(null);
668
1092
  }
669
- restoreSelection() {
670
- const saved = this.savedSelection;
671
- if (!saved)
672
- return this.region();
673
- if (!this.observedElement()?.isConnected || saved.region.region.editor !== this.editor.inlineTarget())
674
- return;
675
- saved.region.region.editor.setSelection(saved.selection);
676
- return saved.region;
1093
+ dropLists = signal([], /* @ts-ignore */
1094
+ ...(ngDevMode ? [{ debugName: "dropLists" }] : /* istanbul ignore next */ []));
1095
+ registerDropList(list) {
1096
+ if (!this.dropLists().includes(list))
1097
+ this.dropLists.update(lists => [...lists, list]);
677
1098
  }
678
- restoreSelectionAfterOverlay() {
679
- // MenuTrigger restores its own focus after emitting menuClosed.
680
- // Restore the editor afterwards, using model points rather than old DOM nodes.
681
- Promise.resolve().then(() => {
682
- const region = this.restoreSelection();
683
- this.savedSelection = null;
684
- if (region && this.observedElement()?.isConnected)
685
- region.focus();
686
- });
1099
+ unregisterDropList(list) {
1100
+ this.dropLists.update(lists => lists.filter(item => item !== list));
687
1101
  }
688
- preventMenuClose(event) { event.stopPropagation(); event.preventDefault(); }
689
- onTextColorChanged(color) {
690
- const region = this.restoreSelection();
691
- if (!region)
692
- return;
693
- if (color)
694
- this.editor.execute(NGS_HEADLESS_EDITOR_SET_TEXT_COLOR, color);
695
- else
696
- this.editor.execute(NGS_HEADLESS_EDITOR_UNSET_TEXT_COLOR);
697
- region.focus();
1102
+ blocks = computed(() => this.editor.document().blocks.map(contentEditorBlockView), /* @ts-ignore */
1103
+ ...(ngDevMode ? [{ debugName: "blocks" }] : /* istanbul ignore next */ []));
1104
+ setFocusedBlockId(id) { this.focusedBlockId.set(id); }
1105
+ setActiveBlockId(id) { this.activeBlockId.set(id); }
1106
+ setBlocks(value) {
1107
+ this.editor.setDocument(value);
698
1108
  }
699
- onBackgroundColorChanged(color) {
700
- const region = this.restoreSelection();
701
- if (!region)
702
- return;
703
- if (color)
704
- this.editor.execute(NGS_HEADLESS_EDITOR_SET_BACKGROUND_COLOR, color);
705
- else
706
- this.editor.execute(NGS_HEADLESS_EDITOR_UNSET_BACKGROUND_COLOR);
707
- region.focus();
1109
+ addBlock(block, index, scope = {}) {
1110
+ const native = contentEditorNativeBlock(block);
1111
+ const blocks = cloneContentEditorValue([...this.editor.document().blocks]);
1112
+ const collection = [...contentEditorCollection(blocks, scope)];
1113
+ collection.splice(index, 0, native);
1114
+ replaceContentEditorCollection(blocks, scope, collection);
1115
+ this.editor.updateDocument({ version: 1, blocks });
708
1116
  }
709
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: CommandBarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
710
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: CommandBarComponent, isStandalone: true, selector: "ngs-command-bar", inputs: { observedElement: { classPropertyName: "observedElement", publicName: "observedElement", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mousedown": "preserveSelection($event)" }, classAttribute: "ngs-command-bar" }, ngImport: i0, template: "<div class=\"flex items-center gap-1\">\n <button ngsIconButton (click)=\"toggleBold()\"\n [class.is-active]=\"isActive('strong')\">\n <ngs-icon name=\"fluent:text-bold-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleItalic()\"\n [class.is-active]=\"isActive('em')\">\n <ngs-icon name=\"fluent:text-italic-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleStrike()\"\n [class.is-active]=\"isActive('s')\">\n <ngs-icon name=\"fluent:text-strikethrough-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleUnderline()\"\n [class.is-active]=\"isActive('u')\">\n <ngs-icon name=\"fluent:text-underline-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleSuperscript()\"\n [class.is-active]=\"isActive('sup')\">\n <ngs-icon name=\"fluent:text-superscript-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleSubscript()\"\n [class.is-active]=\"isActive('sub')\">\n <ngs-icon name=\"fluent:text-subscript-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleCode()\"\n [class.is-active]=\"isActive('code')\">\n <ngs-icon name=\"fluent:code-24-regular\"/>\n </button>\n\n @if (isLinkActive()) {\n <button ngsIconButton (click)=\"editLink()\">\n <ngs-icon name=\"fluent:link-24-regular\"/>\n </button>\n } @else {\n <button ngsIconButton (click)=\"addLink()\">\n <ngs-icon name=\"fluent:link-add-24-regular\"/>\n </button>\n }\n <button ngsIconButton [ngsMenuTriggerFor]=\"alignMenu\"\n (menuOpened)=\"retainSelection()\" (menuClosed)=\"restoreSelectionAfterOverlay()\">\n @switch (alignment()) {\n @case ('left') {\n <ngs-icon name=\"fluent:text-align-left-24-regular\"/>\n }\n @case ('center') {\n <ngs-icon name=\"fluent:text-align-center-24-regular\"/>\n }\n @case ('right') {\n <ngs-icon name=\"fluent:text-align-right-24-regular\"/>\n }\n }\n </button>\n <button ngsIconButton [ngsMenuTriggerFor]=\"formatColorText\"\n (menuOpened)=\"retainSelection()\" (menuClosed)=\"restoreSelectionAfterOverlay()\">\n <ngs-icon name=\"fluent:text-color-24-regular\"/>\n </button>\n</div>\n\n<ngs-menu #alignMenu=\"ngsMenu\">\n <button class=\"[&.is-active]:!bg-secondary-container\"\n [class.is-active]=\"isTextAlignment('left')\"\n ngs-menu-item\n (click)=\"setTextAlignment('left')\">\n <ngs-icon name=\"fluent:text-align-left-24-regular\"/>\n Align Left\n </button>\n <button class=\"[&.is-active]:!bg-secondary-container\"\n [class.is-active]=\"isTextAlignment('center')\"\n ngs-menu-item\n (click)=\"setTextAlignment('center')\">\n <ngs-icon name=\"fluent:text-align-center-24-regular\"/>\n Align Center\n </button>\n <button class=\"[&.is-active]:!bg-secondary-container\"\n [class.is-active]=\"isTextAlignment('right')\"\n ngs-menu-item (click)=\"setTextAlignment('right')\">\n <ngs-icon name=\"fluent:text-align-right-24-regular\"/>\n Align Right\n </button>\n</ngs-menu>\n\n<ngs-menu #formatColorText=\"ngsMenu\">\n <div class=\"px-4 py-3\" (mousedown)=\"preventMenuClose($event)\">\n <ngs-text-color (textColorChanged)=\"onTextColorChanged($event)\"\n (backgroundColorChanged)=\"onBackgroundColorChanged($event)\"/>\n </div>\n</ngs-menu>\n", styles: [":host{background:var(--ngs-color-on-surface);color:var(--ngs-color-surface);border-radius:calc(var(--spacing, .25rem) * 3);padding:var(--spacing, .25rem);box-shadow:var(--ngs-shadow-lg)}:host button[ngsIconButton]{--ngs-button-color: var(--ngs-color-surface);--ngs-button-hover-bg: var(--ngs-color-surface);--ngs-state-focus-ring: var(--ngs-color-surface)}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton]{--ngs-button-hover-bg: color-mix(in srgb, var(--ngs-color-surface) 12%, transparent)}}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton]{--ngs-state-focus-ring: color-mix(in srgb, var(--ngs-color-surface) 40%, transparent)}}:host button[ngsIconButton].is-active{--ngs-button-bg: var(--ngs-color-surface);--ngs-button-hover-bg: var(--ngs-color-surface)}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton].is-active{--ngs-button-bg: color-mix(in srgb, var(--ngs-color-surface) 20%, transparent)}}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton].is-active{--ngs-button-hover-bg: color-mix(in srgb, var(--ngs-color-surface) 28%, transparent)}}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "component", type: Button, selector: " button[ngsButton], button[ngsIconButton], a[ngsButton], a[ngsIconButton] ", inputs: ["ngsButton", "ngsIconButton", "loading", "disabled", "disabledInteractive", "disableRipple", "reverse", "fullWidth", "hideTextOnMobile"], exportAs: ["ngsButton"] }, { kind: "component", type: Icon, selector: "ngs-icon", inputs: ["name"], exportAs: ["ngsIcon"] }, { kind: "component", type: Menu, selector: "ngs-menu", inputs: ["role", "classList", "xPosition", "yPosition", "pushIntoViewport"], outputs: ["closed"], exportAs: ["ngsMenu"] }, { kind: "component", type: MenuItem, selector: "ngs-menu-item, [ngs-menu-item]", inputs: ["disabled", "role", "selected"], outputs: ["_triggered"], exportAs: ["ngsMenuItem"] }, { kind: "directive", type: MenuTrigger, selector: "[ngsMenuTriggerFor]", inputs: ["ngsMenuTriggerFor", "ngsMenuTriggerData", "ngsMenuDisabled", "xPosition", "yPosition", "ngsMenuTriggerRestoreFocus"], outputs: ["menuOpened", "menuClosed"], exportAs: ["ngsMenuTrigger"] }, { kind: "component", type: TextColorComponent, selector: "ngs-text-color", inputs: ["recentlyUsed", "selectedTextColor", "selectedBackgroundColor", "textColors", "backgroundColors"], outputs: ["recentlyUsedChange", "selectedTextColorChange", "selectedBackgroundColorChange", "textColorChanged", "backgroundColorChanged"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
711
- }
712
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: CommandBarComponent, decorators: [{
713
- type: Component,
714
- args: [{ selector: 'ngs-command-bar', imports: [Button, Icon, Menu, MenuItem, MenuTrigger, TextColorComponent], changeDetection: ChangeDetectionStrategy.OnPush, host: {
715
- 'class': 'ngs-command-bar',
716
- '(mousedown)': 'preserveSelection($event)'
717
- }, template: "<div class=\"flex items-center gap-1\">\n <button ngsIconButton (click)=\"toggleBold()\"\n [class.is-active]=\"isActive('strong')\">\n <ngs-icon name=\"fluent:text-bold-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleItalic()\"\n [class.is-active]=\"isActive('em')\">\n <ngs-icon name=\"fluent:text-italic-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleStrike()\"\n [class.is-active]=\"isActive('s')\">\n <ngs-icon name=\"fluent:text-strikethrough-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleUnderline()\"\n [class.is-active]=\"isActive('u')\">\n <ngs-icon name=\"fluent:text-underline-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleSuperscript()\"\n [class.is-active]=\"isActive('sup')\">\n <ngs-icon name=\"fluent:text-superscript-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleSubscript()\"\n [class.is-active]=\"isActive('sub')\">\n <ngs-icon name=\"fluent:text-subscript-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleCode()\"\n [class.is-active]=\"isActive('code')\">\n <ngs-icon name=\"fluent:code-24-regular\"/>\n </button>\n\n @if (isLinkActive()) {\n <button ngsIconButton (click)=\"editLink()\">\n <ngs-icon name=\"fluent:link-24-regular\"/>\n </button>\n } @else {\n <button ngsIconButton (click)=\"addLink()\">\n <ngs-icon name=\"fluent:link-add-24-regular\"/>\n </button>\n }\n <button ngsIconButton [ngsMenuTriggerFor]=\"alignMenu\"\n (menuOpened)=\"retainSelection()\" (menuClosed)=\"restoreSelectionAfterOverlay()\">\n @switch (alignment()) {\n @case ('left') {\n <ngs-icon name=\"fluent:text-align-left-24-regular\"/>\n }\n @case ('center') {\n <ngs-icon name=\"fluent:text-align-center-24-regular\"/>\n }\n @case ('right') {\n <ngs-icon name=\"fluent:text-align-right-24-regular\"/>\n }\n }\n </button>\n <button ngsIconButton [ngsMenuTriggerFor]=\"formatColorText\"\n (menuOpened)=\"retainSelection()\" (menuClosed)=\"restoreSelectionAfterOverlay()\">\n <ngs-icon name=\"fluent:text-color-24-regular\"/>\n </button>\n</div>\n\n<ngs-menu #alignMenu=\"ngsMenu\">\n <button class=\"[&.is-active]:!bg-secondary-container\"\n [class.is-active]=\"isTextAlignment('left')\"\n ngs-menu-item\n (click)=\"setTextAlignment('left')\">\n <ngs-icon name=\"fluent:text-align-left-24-regular\"/>\n Align Left\n </button>\n <button class=\"[&.is-active]:!bg-secondary-container\"\n [class.is-active]=\"isTextAlignment('center')\"\n ngs-menu-item\n (click)=\"setTextAlignment('center')\">\n <ngs-icon name=\"fluent:text-align-center-24-regular\"/>\n Align Center\n </button>\n <button class=\"[&.is-active]:!bg-secondary-container\"\n [class.is-active]=\"isTextAlignment('right')\"\n ngs-menu-item (click)=\"setTextAlignment('right')\">\n <ngs-icon name=\"fluent:text-align-right-24-regular\"/>\n Align Right\n </button>\n</ngs-menu>\n\n<ngs-menu #formatColorText=\"ngsMenu\">\n <div class=\"px-4 py-3\" (mousedown)=\"preventMenuClose($event)\">\n <ngs-text-color (textColorChanged)=\"onTextColorChanged($event)\"\n (backgroundColorChanged)=\"onBackgroundColorChanged($event)\"/>\n </div>\n</ngs-menu>\n", styles: [":host{background:var(--ngs-color-on-surface);color:var(--ngs-color-surface);border-radius:calc(var(--spacing, .25rem) * 3);padding:var(--spacing, .25rem);box-shadow:var(--ngs-shadow-lg)}:host button[ngsIconButton]{--ngs-button-color: var(--ngs-color-surface);--ngs-button-hover-bg: var(--ngs-color-surface);--ngs-state-focus-ring: var(--ngs-color-surface)}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton]{--ngs-button-hover-bg: color-mix(in srgb, var(--ngs-color-surface) 12%, transparent)}}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton]{--ngs-state-focus-ring: color-mix(in srgb, var(--ngs-color-surface) 40%, transparent)}}:host button[ngsIconButton].is-active{--ngs-button-bg: var(--ngs-color-surface);--ngs-button-hover-bg: var(--ngs-color-surface)}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton].is-active{--ngs-button-bg: color-mix(in srgb, var(--ngs-color-surface) 20%, transparent)}}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton].is-active{--ngs-button-hover-bg: color-mix(in srgb, var(--ngs-color-surface) 28%, transparent)}}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
718
- }], propDecorators: { observedElement: [{ type: i0.Input, args: [{ isSignal: true, alias: "observedElement", required: false }] }] } });
719
-
720
- const CONTENT_BUILDER = new InjectionToken('CONTENT_BUILDER');
721
- const CONTENT_EDITOR_BLOCK = new InjectionToken('CONTENT_EDITOR_BLOCK');
722
-
723
- /** Shared marks and commands for content editing and read-only rendering. */
724
- function provideContentEditor() {
725
- return provideNgsHeadlessEditor(withHeadlessEditorPlugin(basicTextEditorPlugin()), withHeadlessEditorPlugin(colorEditorPlugin()), withHeadlessEditorPlugin(linkEditorPlugin()));
726
- }
727
-
728
- function getTextAlignment(props) {
729
- const value = props?.find(prop => prop.name === 'text-alignment')?.value;
730
- if (value === 'center' || value === 'right' || value === 'justify') {
731
- return value;
1117
+ deleteBlock(id, _index) { this.deleteBlocks([id]); }
1118
+ deleteBlocks(ids) {
1119
+ const selected = new Set(ids);
1120
+ const blocks = cloneContentEditorValue([...this.editor.document().blocks]);
1121
+ let changed = false;
1122
+ const remove = (items) => {
1123
+ for (let index = items.length - 1; index >= 0; index--) {
1124
+ if (selected.has(items[index].id)) {
1125
+ items.splice(index, 1);
1126
+ changed = true;
1127
+ }
1128
+ else
1129
+ for (const children of contentEditorChildCollections(items[index]))
1130
+ remove(children);
1131
+ }
1132
+ };
1133
+ remove(blocks);
1134
+ if (changed)
1135
+ this.editor.updateDocument({ version: 1, blocks });
732
1136
  }
733
- return 'left';
734
- }
735
- function getDimensionAttribute(value) {
736
- if (typeof value === 'number' && Number.isFinite(value)) {
737
- return value;
1137
+ updateBlock(id, data) {
1138
+ const blocks = cloneContentEditorValue([...this.editor.document().blocks]);
1139
+ const previous = findContentEditorBlock(blocks, id);
1140
+ if (!previous)
1141
+ return;
1142
+ const next = contentEditorNativeBlock({ ...contentEditorBlockView(previous), ...data });
1143
+ const origin = this.textEdit?.origin ?? 'command';
1144
+ const typing = origin === 'keyboard' || origin === 'composition';
1145
+ const root = blocks.find(block => !!findContentEditorBlock([block], id));
1146
+ Object.assign(previous, next);
1147
+ this.editor.updateBlock(root.id, { content: root.content, attrs: root.attrs }, typing ? origin : 'command', typing ? this.textEdit?.group ?? null : null);
738
1148
  }
739
- if (typeof value === 'string') {
740
- const trimmed = value.trim();
741
- if (!trimmed || trimmed === 'auto') {
742
- return null;
743
- }
744
- const parsed = Number.parseFloat(trimmed);
745
- return Number.isFinite(parsed) ? parsed : null;
1149
+ moveBlock(from, to) {
1150
+ const blocks = [...this.editor.document().blocks];
1151
+ const [block] = blocks.splice(from, 1);
1152
+ blocks.splice(to, 0, block);
1153
+ this.editor.updateDocument({ version: 1, blocks });
746
1154
  }
747
- return null;
748
- }
749
-
750
- /** Defaults shared by editing and read-only layout. */
751
- function contentEditorGridSettings(settings) {
752
- return {
753
- columns: settings.columns === 3 || settings.columns === 4 ? settings.columns : 2,
754
- gap: settings.gap === 'small' || settings.gap === 'large' ? settings.gap : 'medium',
755
- stackOnMobile: settings.stackOnMobile !== false
756
- };
1155
+ moveBetweenCollections(from, to, source, target) {
1156
+ const blocks = cloneContentEditorValue([...this.editor.document().blocks]);
1157
+ const sourceItems = [...contentEditorCollection(blocks, source)];
1158
+ const block = sourceItems[from];
1159
+ if (!block || (target.parentId && findContentEditorBlock([block], target.parentId)))
1160
+ return;
1161
+ sourceItems.splice(from, 1);
1162
+ replaceContentEditorCollection(blocks, source, sourceItems);
1163
+ const targetItems = [...contentEditorCollection(blocks, target)];
1164
+ targetItems.splice(to, 0, block);
1165
+ replaceContentEditorCollection(blocks, target, targetItems);
1166
+ this.editor.updateDocument({ version: 1, blocks });
1167
+ }
1168
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentBuilderStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1169
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentBuilderStore });
757
1170
  }
1171
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentBuilderStore, decorators: [{
1172
+ type: Injectable
1173
+ }], ctorParameters: () => [] });
758
1174
 
759
- /** Plain HTML layout styles, independent of Angular and the component library's theme. */
760
- const CONTENT_EDITOR_GRID_HTML_STYLES = `.ngs-content-editor-html-grid{container-type:inline-size}.ngs-content-editor-html-grid-cells{display:grid;grid-template-columns:repeat(var(--ngs-html-grid-columns),minmax(0,1fr));gap:var(--ngs-html-grid-gap)}.ngs-content-editor-html-grid-cell{min-width:0}@container(max-width:480px){.ngs-content-editor-html-grid-stack{grid-template-columns:minmax(0,1fr)}}`;
761
- const CONTENT_EDITOR_CALLOUT_HTML_STYLES = `.ngs-content-editor-html-callout{padding:16px;border-radius:8px;background:var(--ngs-color-primary-container,#eef3ff);color:var(--ngs-color-on-surface,#172033)}.ngs-content-editor-html-callout[data-callout=tip]{background:var(--ngs-color-success-container,#e8f5ee)}.ngs-content-editor-html-callout[data-callout=warning]{background:var(--ngs-color-warning-container,#fff3dc)}.ngs-content-editor-html-callout[data-callout=danger]{background:var(--ngs-color-danger-container,#fdeaea)}`;
762
- const CONTENT_EDITOR_GALLERY_HTML_STYLES = `.ngs-content-editor-html-gallery{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;gap:16px}.ngs-content-editor-html-gallery>figure{flex:0 0 100%;min-width:0;margin:0;scroll-snap-align:start}.ngs-content-editor-html-gallery img{display:block;width:100%}`;
763
- function settings(block) { return block.attrs?.['settings'] ?? {}; }
764
- function alignment(props) {
765
- const align = getTextAlignment(props);
766
- return align === 'left' ? '' : ` style="text-align:${align}"`;
767
- }
768
- function dimension(name, value) {
769
- const number = getDimensionAttribute(value);
770
- return number !== null && number > 0 ? ` ${name}="${Math.round(number)}"` : '';
771
- }
772
- const contentEditorParagraphToHtml = (block, ctx) => `<p${alignment(block.attrs?.['props'])}>${ctx.renderText(block.content)}</p>`;
773
- const contentEditorHeadingToHtml = (block, ctx) => {
774
- const value = settings(block)['level'];
775
- const level = Number.isInteger(value) && value >= 1 && value <= 6 ? value : 2;
776
- return `<h${level}${alignment(block.attrs?.['props'])}>${ctx.renderText(block.content)}</h${level}>`;
777
- };
778
- const contentEditorCodeToHtml = (block, ctx) => `<pre><code data-language="${ctx.escape(settings(block)['language'] ?? 'none')}">${ctx.escape(contentEditorText(block.content))}</code></pre>`;
779
- const contentEditorDividerToHtml = () => '<hr>';
780
- const contentEditorListToHtml = (block, ctx) => {
781
- const tag = block.type === 'orderedList' ? 'ol' : 'ul';
782
- const list = (items) => `<${tag}>${items.map(item => `<li${alignment(item.props)}>${ctx.renderText(item.content)}${item.children?.length ? list(item.children) : ''}</li>`).join('')}</${tag}>`;
783
- return list(block.content ?? []);
784
- };
785
- const contentEditorQuoteToHtml = (block, ctx) => {
786
- const quote = block.content?.cite;
787
- const caption = block.content?.caption;
788
- return `<figure><blockquote${alignment(quote?.props)}>${ctx.renderText(quote?.content ?? [])}</blockquote>${contentEditorText(caption?.content).trim() ? `<figcaption${alignment(caption.props)}>${ctx.renderText(caption.content)}</figcaption>` : ''}</figure>`;
789
- };
790
- const contentEditorTableToHtml = (block, ctx) => {
791
- const table = getNgsHeadlessEditorTableData(block);
792
- const metadata = block.attrs?.['cellMetadata'];
793
- const rows = table.rows.map((row, r) => `<tr>${row.map((runs, c) => {
794
- const tag = r === 0 && table.header ? 'th' : 'td';
795
- const cell = metadata?.[r]?.[c];
796
- return `<${tag}${dimension('colspan', cell?.options?.['colspan'])}${dimension('rowspan', cell?.options?.['rowspan'])}${dimension('width', cell?.options?.['width'])}${alignment(cell?.props)}>${ctx.renderText(runs)}</${tag}>`;
797
- }).join('')}</tr>`).join('');
798
- return `<table><tbody>${rows}</tbody></table>`;
799
- };
800
- const contentEditorImageToHtml = (block, ctx) => {
801
- const src = ctx.safeUrl(block.content?.src, 'image');
802
- if (!src)
803
- return '';
804
- const alt = block.content?.alt ?? '';
805
- const config = settings(block);
806
- return `<figure><img src="${ctx.escape(src)}" alt="${ctx.escape(alt)}"${dimension('width', config['width'])}${dimension('height', config['height'])} style="max-width:100%;height:auto">${alt ? `<figcaption>${ctx.escape(alt)}</figcaption>` : ''}</figure>`;
807
- };
808
- const contentEditorVideoToHtml = (block, ctx) => {
809
- const src = ctx.safeUrl(block.content?.src, 'media');
810
- if (!src)
811
- return '';
812
- const config = settings(block);
813
- return `<figure><video src="${ctx.escape(src)}" controls${dimension('width', config['width'])}${dimension('height', config['height'])} style="max-width:100%"></video>${block.content?.caption ? `<figcaption>${ctx.escape(block.content.caption)}</figcaption>` : ''}</figure>`;
814
- };
815
- const contentEditorEmbedToHtml = (block, ctx) => {
816
- const src = ctx.safeUrl(block.content?.url, 'embed');
817
- if (!src)
818
- return '';
819
- const config = settings(block);
820
- return `<figure><iframe src="${ctx.escape(src)}" title="${ctx.escape(block.content?.type || 'Embedded content')}"${dimension('width', config['width'] ?? 700)}${dimension('height', config['height'] ?? 400)} style="max-width:100%" allowfullscreen></iframe></figure>`;
821
- };
822
- const contentEditorCalloutToHtml = (block, ctx) => {
823
- ctx.addStyles(CONTENT_EDITOR_CALLOUT_HTML_STYLES);
824
- const value = settings(block)['variant'];
825
- const variant = ['note', 'tip', 'warning', 'danger'].includes(value) ? value : 'note';
826
- return `<aside class="ngs-content-editor-html-callout" data-callout="${variant}"${alignment(block.attrs?.['props'])}>${ctx.renderText(block.content)}</aside>`;
827
- };
828
- const contentEditorToggleToHtml = (block, ctx) => `<details${settings(block)['expanded'] ? ' open' : ''}><summary>${ctx.renderText(block.content?.title ?? [])}</summary>${ctx.renderBlocks(block.content?.blocks ?? [])}</details>`;
829
- const contentEditorAttachmentToHtml = (block, ctx) => {
830
- const url = ctx.safeUrl(block.content?.url, 'attachment');
831
- return url ? `<a href="${ctx.escape(url)}" download="${ctx.escape(block.content?.name)}">${ctx.escape(block.content?.name || 'Download')}</a>` : '';
832
- };
833
- const contentEditorGalleryToHtml = (block, ctx) => {
834
- ctx.addStyles(CONTENT_EDITOR_GALLERY_HTML_STYLES);
835
- return `<div class="ngs-content-editor-html-gallery" data-content-editor="gallery">${(block.content?.images ?? []).map(image => {
836
- const src = ctx.safeUrl(image.src, 'image');
837
- return src ? `<figure><img src="${ctx.escape(src)}" alt="${ctx.escape(image.alt)}" style="max-width:100%;height:auto">${contentEditorText(image.caption).trim() ? `<figcaption>${ctx.renderText(image.caption)}</figcaption>` : ''}</figure>` : '';
838
- }).join('')}</div>`;
839
- };
840
- const contentEditorGridToHtml = (block, ctx) => {
841
- const layout = contentEditorGridSettings(settings(block));
842
- ctx.addStyles(CONTENT_EDITOR_GRID_HTML_STYLES);
843
- const gap = { small: 12, medium: 24, large: 36 }[layout.gap];
844
- return `<div class="ngs-content-editor-html-grid" style="--ngs-html-grid-columns:${layout.columns};--ngs-html-grid-gap:${gap}px"><div class="ngs-content-editor-html-grid-cells${layout.stackOnMobile ? ' ngs-content-editor-html-grid-stack' : ''}">${(block.content?.cells ?? []).map(cell => `<div class="ngs-content-editor-html-grid-cell">${ctx.renderBlocks(cell.blocks)}</div>`).join('')}</div></div>`;
845
- };
846
- const CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS = {
847
- paragraph: contentEditorParagraphToHtml, heading: contentEditorHeadingToHtml,
848
- code: contentEditorCodeToHtml, divider: contentEditorDividerToHtml,
849
- bulletList: contentEditorListToHtml, orderedList: contentEditorListToHtml,
850
- quote: contentEditorQuoteToHtml, table: contentEditorTableToHtml,
851
- image: contentEditorImageToHtml, video: contentEditorVideoToHtml,
852
- embed: contentEditorEmbedToHtml, callout: contentEditorCalloutToHtml,
853
- toggle: contentEditorToggleToHtml, attachment: contentEditorAttachmentToHtml,
854
- gallery: contentEditorGalleryToHtml, grid: contentEditorGridToHtml
855
- };
856
-
857
- const CONTENT_EDITOR_EXTRA_BLOCK_DEFS = [
858
- {
859
- type: 'callout', component: () => import('./ngstarter-ui-components-content-editor-callout-block-Cnga7Z-6.mjs').then(m => m.ContentEditorCalloutBlock),
860
- empty: () => ({ content: [createNgsHeadlessEditorText()], settings: { variant: 'note' } }), options: {}
861
- },
862
- {
863
- type: 'toggle', component: () => import('./ngstarter-ui-components-content-editor-toggle-block-B01lhY_V.mjs').then(m => m.ContentEditorToggleBlock),
864
- empty: () => ({ content: { title: [], blocks: [emptyParagraph()] }, settings: { expanded: true } }), options: {}
865
- },
866
- {
867
- type: 'attachment', component: () => import('./ngstarter-ui-components-content-editor-attachment-block-B2GUlWO2.mjs').then(m => m.ContentEditorAttachmentBlock),
868
- empty: () => ({ content: { url: '', name: '', size: 0, mimeType: '' }, settings: {} }),
869
- options: { uploadFn: (_file, dataUrl) => Promise.resolve(dataUrl) }
870
- },
871
- {
872
- type: 'gallery', component: () => import('./ngstarter-ui-components-content-editor-gallery-block-cEy-dCMa.mjs').then(m => m.ContentEditorGalleryBlock),
873
- empty: () => ({ content: { images: [] }, settings: {} }),
874
- options: { uploadFn: (_file, dataUrl) => Promise.resolve(dataUrl) }
875
- },
876
- {
877
- type: 'grid', component: () => import('./ngstarter-ui-components-content-editor-grid-block-DFLGRFiO.mjs').then(m => m.ContentEditorGridBlock),
878
- empty: () => ({ content: { cells: Array.from({ length: 4 }, emptyGridCell) }, settings: { columns: 2, gap: 'medium', stackOnMobile: true } }), options: {}
1175
+ const regions = new WeakMap();
1176
+ /** A headless inline editor bound to a text field in a content block. */
1177
+ class ContentEditorContentEditableDirective {
1178
+ region = inject(NgsHeadlessEditorInlineRegion);
1179
+ surface = inject(NgsHeadlessEditorSurface);
1180
+ importer = inject(ContentEditorImporter);
1181
+ builder = inject(CONTENT_BUILDER, { optional: true });
1182
+ store = inject(ContentBuilderStore, { optional: true });
1183
+ historyGroup = createNgsHeadlessEditorId('content-region');
1184
+ element = inject(ElementRef).nativeElement;
1185
+ content = input([], { ...(ngDevMode ? { debugName: "content" } : /* istanbul ignore next */ {}), alias: 'ngsContentEditorContentEditable' });
1186
+ settings = input({}, /* @ts-ignore */
1187
+ ...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
1188
+ props = input([], /* @ts-ignore */
1189
+ ...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
1190
+ singleLine = input(false, /* @ts-ignore */
1191
+ ...(ngDevMode ? [{ debugName: "singleLine" }] : /* istanbul ignore next */ []));
1192
+ contentChanged = output();
1193
+ propsChanged = output();
1194
+ pressedEnter = output();
1195
+ initialized = output();
1196
+ static forElement(element) {
1197
+ return element ? regions.get(element) : undefined;
879
1198
  }
880
- ].map(def => ({ ...def, toHtml: CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS[def.type] }));
881
- function emptyParagraph() {
882
- return { id: createNgsHeadlessEditorId('paragraph'), type: 'paragraph', content: [createNgsHeadlessEditorText()] };
1199
+ constructor() {
1200
+ regions.set(this.element, this);
1201
+ effect(() => {
1202
+ const content = this.content();
1203
+ untracked(() => this.region.load(content));
1204
+ });
1205
+ effect(() => {
1206
+ const content = this.region.content();
1207
+ const origin = this.region.editor.origin();
1208
+ if (origin !== 'external' && origin !== 'history') {
1209
+ untracked(() => {
1210
+ if (this.store)
1211
+ this.store.withTextEdit(origin, this.historyGroup, () => this.contentChanged.emit(content));
1212
+ else
1213
+ this.contentChanged.emit(content);
1214
+ });
1215
+ }
1216
+ });
1217
+ // Capture before the surface and the block's own listeners. Structural Enter
1218
+ // stays with the content builder; multiline fields use the headless surface.
1219
+ this.element.addEventListener('paste', this.onPaste, true);
1220
+ this.element.addEventListener('keydown', this.onKeydown, true);
1221
+ this.element.addEventListener('beforeinput', this.onBeforeInput, true);
1222
+ afterNextRender(() => this.initialized.emit());
1223
+ afterRenderEffect(() => {
1224
+ const pending = this.store?.restoreTextSelection();
1225
+ const wrapper = this.element.closest('[data-block-id]');
1226
+ if (pending && wrapper?.getAttribute('data-block-id') === pending.blockId &&
1227
+ wrapper.querySelector('.ngs-content-editor-content-editable') === this.element) {
1228
+ this.activate();
1229
+ this.region.editor.setSelection(pending.selection);
1230
+ this.surface.focus();
1231
+ this.store.restoreTextSelection.set(null);
1232
+ }
1233
+ });
1234
+ }
1235
+ activate() {
1236
+ this.region.activate();
1237
+ const id = this.element.closest('[data-block-id]')?.getAttribute('data-block-id');
1238
+ if (id && this.store) {
1239
+ const scope = this.builder && 'scope' in this.builder ? this.builder.scope() : {};
1240
+ this.store.insertionTarget.set({ scope, afterId: id });
1241
+ }
1242
+ }
1243
+ focus() { this.activate(); this.surface.focus(); }
1244
+ getContent() { return this.region.content(); }
1245
+ alignment() { return this.props().find(prop => prop.name === 'text-alignment')?.value ?? 'left'; }
1246
+ setAlignment(value) {
1247
+ this.propsChanged.emit([
1248
+ ...this.props().filter(prop => prop.name !== 'text-alignment'),
1249
+ { name: 'text-alignment', value }
1250
+ ]);
1251
+ }
1252
+ onPaste = (event) => {
1253
+ if (event.defaultPrevented || this.region.editor.readOnly())
1254
+ return;
1255
+ const html = event.clipboardData?.getData('text/html');
1256
+ if (!html)
1257
+ return;
1258
+ try {
1259
+ const config = this.builder?.rootBuilder.config() ?? {};
1260
+ const parsed = this.importer.fromHtml(html, config);
1261
+ this.activate();
1262
+ this.surface.syncSelectionFromDom();
1263
+ const id = this.element.closest('[data-block-id]')?.getAttribute('data-block-id');
1264
+ const structural = parsed.blocks.length > 1 || parsed.blocks.some(block => block.type !== 'paragraph');
1265
+ const selection = this.region.editor.selection();
1266
+ if (structural && id && this.builder && selection) {
1267
+ const lines = this.region.editor.document().blocks;
1268
+ const offset = (point) => lines.slice(0, lines.findIndex(line => line.id === point.blockId))
1269
+ .reduce((sum, line) => sum + line.content.reduce((total, run) => total + run.text.length, 0) + 1, 0) + point.offset;
1270
+ if (this.builder.rootBuilder.pasteBlocksAtSelection(id, parsed, offset(selection.anchor), offset(selection.focus))) {
1271
+ event.preventDefault();
1272
+ event.stopImmediatePropagation();
1273
+ return;
1274
+ }
1275
+ }
1276
+ const content = contentEditorImportedText(parsed.blocks);
1277
+ if (!content.some(run => run.text))
1278
+ return;
1279
+ this.activate();
1280
+ this.surface.syncSelectionFromDom();
1281
+ event.preventDefault();
1282
+ event.stopImmediatePropagation();
1283
+ this.region.editor.insertTextContent(content);
1284
+ }
1285
+ catch {
1286
+ // The surface can still paste the plain-text representation on parse failure.
1287
+ }
1288
+ };
1289
+ onKeydown = (event) => {
1290
+ if (event.key === 'Enter' && this.singleLine() && !event.shiftKey && !event.isComposing) {
1291
+ event.preventDefault();
1292
+ event.stopImmediatePropagation();
1293
+ this.pressedEnter.emit(event);
1294
+ }
1295
+ };
1296
+ onBeforeInput = (event) => {
1297
+ if (event.inputType === 'insertParagraph' && this.singleLine() && !event.isComposing) {
1298
+ event.preventDefault();
1299
+ event.stopImmediatePropagation();
1300
+ this.pressedEnter.emit(new KeyboardEvent('keydown', { key: 'Enter' }));
1301
+ }
1302
+ };
1303
+ ngOnDestroy() {
1304
+ regions.delete(this.element);
1305
+ this.element.removeEventListener('paste', this.onPaste, true);
1306
+ this.element.removeEventListener('keydown', this.onKeydown, true);
1307
+ this.element.removeEventListener('beforeinput', this.onBeforeInput, true);
1308
+ }
1309
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorContentEditableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1310
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.7", type: ContentEditorContentEditableDirective, isStandalone: true, selector: "[ngsContentEditorContentEditable]", inputs: { content: { classPropertyName: "content", publicName: "ngsContentEditorContentEditable", isSignal: true, isRequired: false, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, singleLine: { classPropertyName: "singleLine", publicName: "singleLine", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { contentChanged: "contentChanged", propsChanged: "propsChanged", pressedEnter: "pressedEnter", initialized: "initialized" }, host: { listeners: { "focus": "activate()" }, properties: { "class.align-left": "alignment() === \"left\"", "class.align-center": "alignment() === \"center\"", "class.align-right": "alignment() === \"right\"", "class.align-justify": "alignment() === \"justify\"" }, classAttribute: "ngs-content-editor-content-editable" }, providers: [provideNgsHeadlessEditorInlineRegion()], exportAs: ["ngsContentEditorContentEditable"], hostDirectives: [{ directive: i1.NgsHeadlessEditorSurface }], ngImport: i0 });
883
1311
  }
884
- function emptyGridCell() { return { id: createNgsHeadlessEditorId('cell'), blocks: [emptyParagraph()] }; }
885
- const CONTENT_EDITOR_EXTRA_SUGGESTIONS = [
886
- { type: 'heading', title: 'Content & layout' },
887
- ...[
888
- ['callout', 'Callout', 'Notes, tips and warnings', 'fluent:info-24-regular'],
889
- ['toggle', 'Toggle', 'Collapsible content with nested blocks', 'fluent:chevron-down-24-regular'],
890
- ['attachment', 'Attachment', 'Upload a file for download', 'fluent:attach-24-regular'],
891
- ['gallery', 'Gallery', 'Image carousel with captions', 'fluent:image-multiple-24-regular'],
892
- ['grid', 'Grid', 'Responsive grid with nested blocks', 'fluent:grid-24-regular']
893
- ].map(([blockType, title, description, iconName]) => ({ type: 'item', blockType, title, description, iconName, blockSettings: {} }))
894
- ];
1312
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorContentEditableDirective, decorators: [{
1313
+ type: Directive,
1314
+ args: [{
1315
+ selector: '[ngsContentEditorContentEditable]',
1316
+ exportAs: 'ngsContentEditorContentEditable',
1317
+ providers: [provideNgsHeadlessEditorInlineRegion()],
1318
+ hostDirectives: [NgsHeadlessEditorSurface],
1319
+ host: {
1320
+ 'class': 'ngs-content-editor-content-editable',
1321
+ '[class.align-left]': 'alignment() === "left"',
1322
+ '[class.align-center]': 'alignment() === "center"',
1323
+ '[class.align-right]': 'alignment() === "right"',
1324
+ '[class.align-justify]': 'alignment() === "justify"',
1325
+ '(focus)': 'activate()'
1326
+ }
1327
+ }]
1328
+ }], ctorParameters: () => [], propDecorators: { content: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngsContentEditorContentEditable", required: false }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], singleLine: [{ type: i0.Input, args: [{ isSignal: true, alias: "singleLine", required: false }] }], contentChanged: [{ type: i0.Output, args: ["contentChanged"] }], propsChanged: [{ type: i0.Output, args: ["propsChanged"] }], pressedEnter: [{ type: i0.Output, args: ["pressedEnter"] }], initialized: [{ type: i0.Output, args: ["initialized"] }] } });
895
1329
 
896
- function escapeContentEditorHtml(value) {
897
- return String(value ?? '').replace(/[&<>"']/g, character => ({
898
- '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;'
899
- })[character]);
900
- }
901
- function safeContentEditorHtmlUrl(value, kind = 'link') {
902
- if (typeof value !== 'string')
903
- return null;
904
- const url = value.trim();
905
- if (!url || /[\u0000-\u0020\u007f]/.test(url))
906
- return null;
907
- if (kind === 'link')
908
- return normalizeNgsHeadlessEditorLink(url);
909
- if (/^https?:/i.test(url) || !/^[a-z][a-z\d+.-]*:/i.test(url))
910
- return url;
911
- if (kind !== 'embed' && /^blob:https?:\/\//i.test(url))
912
- return url;
913
- if (kind === 'attachment' && /^(mailto:|tel:)/i.test(url))
914
- return url;
915
- const mime = kind === 'image' ? 'image/[a-z0-9.+-]+' : kind === 'media'
916
- ? '(?:audio|video)/[a-z0-9.+-]+' : kind === 'attachment'
917
- ? '(?:application/(?!xhtml\\+xml|xml|javascript)[a-z0-9.+-]+|text/(?:plain|csv)|(?:image|audio|video)/[a-z0-9.+-]+)' : null;
918
- return mime && new RegExp(`^data:${mime};base64,[a-z0-9+/=]${kind === 'attachment' ? '*' : '+'}$`, 'i').test(url) ? url : null;
1330
+ class AddLinkDialog {
1331
+ _dialogRef = inject(DialogRef);
1332
+ _formBuilder = inject(FormBuilder);
1333
+ form = this._formBuilder.group({
1334
+ href: [''],
1335
+ openInNewTab: [true, [Validators.required]]
1336
+ });
1337
+ cancel() {
1338
+ this._dialogRef.close(false);
1339
+ }
1340
+ add() {
1341
+ this._dialogRef.close(this.form.value);
1342
+ }
1343
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: AddLinkDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
1344
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.1.7", type: AddLinkDialog, isStandalone: true, selector: "ngs-add-link", ngImport: i0, template: "<h1 ngs-dialog-title>Add link</h1>\n<ngs-dialog-content [formGroup]=\"form\" class=\"!overflow-hidden\">\n <ngs-form-field class=\"w-full\">\n <ngs-label>Href (Url, Tel or other)</ngs-label>\n <input ngsInput type=\"text\" formControlName=\"href\">\n </ngs-form-field>\n <ngs-slide-toggle formControlName=\"openInNewTab\">Open link in a new tab</ngs-slide-toggle>\n</ngs-dialog-content>\n<ngs-dialog-actions>\n <button ngsButton (click)=\"cancel()\">Cancel</button>\n <button ngsButton=\"filled\"\n [disabled]=\"form.invalid\" (click)=\"add()\">Add</button>\n</ngs-dialog-actions>\n", styles: [""], dependencies: [{ kind: "component", type: DialogContent, selector: "ngs-dialog-content,[ngs-dialog-content],[ngsDialogContent]" }, { kind: "component", type: FormField, selector: "ngs-form-field", inputs: ["labelMode", "subscriptHiddenIfEmpty", "sameHeightAsButton"], exportAs: ["ngsFormField"] }, { kind: "directive", type: Input, selector: "input[ngsInput], textarea[ngsInput]", inputs: ["id", "placeholder", "required", "disabled", "readonly", "errorStateMatcher"], exportAs: ["ngsInput"] }, { kind: "component", type: DialogTitle, selector: "ngs-dialog-title, [ngs-dialog-title], [ngsDialogTitle]", inputs: ["id"], exportAs: ["ngsDialogTitle"] }, { kind: "component", type: DialogActions, selector: "ngs-dialog-actions, [ngs-dialog-actions], [ngsDialogActions]", inputs: ["align"] }, { kind: "component", type: Button, selector: " button[ngsButton], button[ngsIconButton], a[ngsButton], a[ngsIconButton] ", inputs: ["ngsButton", "ngsIconButton", "loading", "disabled", "disabledInteractive", "disableRipple", "reverse", "fullWidth", "hideTextOnMobile"], exportAs: ["ngsButton"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: Label, selector: "ngs-label" }, { kind: "component", type: SlideToggle, selector: "ngs-slide-toggle", inputs: ["id", "name", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "disabled", "disableRipple", "tabIndex", "hideIcon", "color", "checked"], outputs: ["disabledChange", "checkedChange", "change", "toggleChange"], exportAs: ["ngsSlideToggle"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
919
1345
  }
1346
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: AddLinkDialog, decorators: [{
1347
+ type: Component,
1348
+ args: [{ selector: 'ngs-add-link', imports: [
1349
+ DialogContent,
1350
+ FormField,
1351
+ Input,
1352
+ DialogTitle,
1353
+ DialogActions,
1354
+ Button,
1355
+ ReactiveFormsModule,
1356
+ Label,
1357
+ SlideToggle
1358
+ ], changeDetection: ChangeDetectionStrategy.Eager, template: "<h1 ngs-dialog-title>Add link</h1>\n<ngs-dialog-content [formGroup]=\"form\" class=\"!overflow-hidden\">\n <ngs-form-field class=\"w-full\">\n <ngs-label>Href (Url, Tel or other)</ngs-label>\n <input ngsInput type=\"text\" formControlName=\"href\">\n </ngs-form-field>\n <ngs-slide-toggle formControlName=\"openInNewTab\">Open link in a new tab</ngs-slide-toggle>\n</ngs-dialog-content>\n<ngs-dialog-actions>\n <button ngsButton (click)=\"cancel()\">Cancel</button>\n <button ngsButton=\"filled\"\n [disabled]=\"form.invalid\" (click)=\"add()\">Add</button>\n</ngs-dialog-actions>\n" }]
1359
+ }] });
920
1360
 
921
- const MARK_TAGS = {
922
- bold: 'strong', italic: 'em', strike: 's', underline: 'u', code: 'code', superscript: 'sup', subscript: 'sub'
923
- };
924
- /** Pure document export: works without DOM, Angular DI, or a mounted editor. */
925
- function contentEditorToHtml(document, config = {}) {
926
- return serialize(document.blocks, config);
927
- }
928
- function contentEditorBlockToHtml(block, config = {}) {
929
- return serialize([block], config);
1361
+ class EditLinkDialog {
1362
+ _dialogRef = inject(DialogRef);
1363
+ _dialogData = inject(DIALOG_DATA);
1364
+ _formBuilder = inject(FormBuilder);
1365
+ form = this._formBuilder.group({
1366
+ href: [this._dialogData.href],
1367
+ openInNewTab: [this._dialogData.openInNewTab, [Validators.required]]
1368
+ });
1369
+ cancel() {
1370
+ this._dialogRef.close(false);
1371
+ }
1372
+ add() {
1373
+ this._dialogRef.close(this.form.value);
1374
+ }
1375
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: EditLinkDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
1376
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.1.7", type: EditLinkDialog, isStandalone: true, selector: "ngs-edit-link", ngImport: i0, template: "<h1 ngs-dialog-title>Edit link</h1>\n<ngs-dialog-content [formGroup]=\"form\" class=\"!overflow-hidden\">\n <ngs-form-field class=\"w-full\">\n <ngs-label>Href (Url, Tel or other)</ngs-label>\n <input ngsInput type=\"text\" formControlName=\"href\">\n <ngs-hint>To delete the link, clear this field and apply</ngs-hint>\n </ngs-form-field>\n <ngs-slide-toggle formControlName=\"openInNewTab\" class=\"mt-5\">Open link in a new tab</ngs-slide-toggle>\n</ngs-dialog-content>\n<ngs-dialog-actions>\n <button ngsButton (click)=\"cancel()\">Cancel</button>\n <button ngsButton=\"filled\"\n [disabled]=\"form.invalid\" (click)=\"add()\">Apply</button>\n</ngs-dialog-actions>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "component", type: Button, selector: " button[ngsButton], button[ngsIconButton], a[ngsButton], a[ngsIconButton] ", inputs: ["ngsButton", "ngsIconButton", "loading", "disabled", "disabledInteractive", "disableRipple", "reverse", "fullWidth", "hideTextOnMobile"], exportAs: ["ngsButton"] }, { kind: "component", type: DialogActions, selector: "ngs-dialog-actions, [ngs-dialog-actions], [ngsDialogActions]", inputs: ["align"] }, { kind: "component", type: DialogContent, selector: "ngs-dialog-content,[ngs-dialog-content],[ngsDialogContent]" }, { kind: "component", type: DialogTitle, selector: "ngs-dialog-title, [ngs-dialog-title], [ngsDialogTitle]", inputs: ["id"], exportAs: ["ngsDialogTitle"] }, { kind: "component", type: FormField, selector: "ngs-form-field", inputs: ["labelMode", "subscriptHiddenIfEmpty", "sameHeightAsButton"], exportAs: ["ngsFormField"] }, { kind: "directive", type: Input, selector: "input[ngsInput], textarea[ngsInput]", inputs: ["id", "placeholder", "required", "disabled", "readonly", "errorStateMatcher"], exportAs: ["ngsInput"] }, { kind: "component", type: Label, selector: "ngs-label" }, { kind: "component", type: SlideToggle, selector: "ngs-slide-toggle", inputs: ["id", "name", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "disabled", "disableRipple", "tabIndex", "hideIcon", "color", "checked"], outputs: ["disabledChange", "checkedChange", "change", "toggleChange"], exportAs: ["ngsSlideToggle"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: Hint, selector: "ngs-hint", inputs: ["align"], exportAs: ["ngsHint"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
930
1377
  }
931
- function serialize(blocks, config) {
932
- const styles = new Set();
933
- const context = {
934
- escape: escapeContentEditorHtml,
935
- safeUrl: safeContentEditorHtmlUrl,
936
- addStyles: css => { if (config.includeStyles !== false)
937
- styles.add(css); },
938
- renderBlock: block => {
939
- const converter = config.blocks?.[block.type]?.toHtml ?? defaultConverter(block.type) ?? config.unknownBlockToHtml;
940
- if (!converter)
941
- throw new Error(`No HTML converter for Content Editor block "${block.type}".`);
942
- return converter(block, context);
1378
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: EditLinkDialog, decorators: [{
1379
+ type: Component,
1380
+ args: [{ selector: 'ngs-edit-link', imports: [
1381
+ FormsModule,
1382
+ Button,
1383
+ DialogActions,
1384
+ DialogContent,
1385
+ DialogTitle,
1386
+ FormField,
1387
+ Input,
1388
+ Label,
1389
+ SlideToggle,
1390
+ ReactiveFormsModule,
1391
+ Hint
1392
+ ], changeDetection: ChangeDetectionStrategy.Eager, template: "<h1 ngs-dialog-title>Edit link</h1>\n<ngs-dialog-content [formGroup]=\"form\" class=\"!overflow-hidden\">\n <ngs-form-field class=\"w-full\">\n <ngs-label>Href (Url, Tel or other)</ngs-label>\n <input ngsInput type=\"text\" formControlName=\"href\">\n <ngs-hint>To delete the link, clear this field and apply</ngs-hint>\n </ngs-form-field>\n <ngs-slide-toggle formControlName=\"openInNewTab\" class=\"mt-5\">Open link in a new tab</ngs-slide-toggle>\n</ngs-dialog-content>\n<ngs-dialog-actions>\n <button ngsButton (click)=\"cancel()\">Cancel</button>\n <button ngsButton=\"filled\"\n [disabled]=\"form.invalid\" (click)=\"add()\">Apply</button>\n</ngs-dialog-actions>\n" }]
1393
+ }] });
1394
+
1395
+ class TextColorComponent {
1396
+ _document = inject(DOCUMENT$1);
1397
+ recentlyUsed = model(this._getRecentlyUsed(), /* @ts-ignore */
1398
+ ...(ngDevMode ? [{ debugName: "recentlyUsed" }] : /* istanbul ignore next */ []));
1399
+ selectedTextColor = model(null, /* @ts-ignore */
1400
+ ...(ngDevMode ? [{ debugName: "selectedTextColor" }] : /* istanbul ignore next */ []));
1401
+ selectedBackgroundColor = model(null, /* @ts-ignore */
1402
+ ...(ngDevMode ? [{ debugName: "selectedBackgroundColor" }] : /* istanbul ignore next */ []));
1403
+ textColors = input([
1404
+ {
1405
+ name: 'Default',
1406
+ color: '',
1407
+ type: 'text'
1408
+ },
1409
+ {
1410
+ name: 'Gray',
1411
+ color: '#7f7f7f',
1412
+ type: 'text'
1413
+ },
1414
+ {
1415
+ name: 'Brown',
1416
+ color: '#ae2012',
1417
+ type: 'text'
1418
+ },
1419
+ {
1420
+ name: 'Orange',
1421
+ color: '#fb5607',
1422
+ type: 'text'
1423
+ },
1424
+ {
1425
+ name: 'Yellow',
1426
+ color: '#ffa200',
1427
+ type: 'text'
943
1428
  },
944
- renderBlocks: children => children.map(context.renderBlock).join(''),
945
- defaultToHtml: block => {
946
- const converter = defaultConverter(block.type);
947
- if (!converter)
948
- throw new Error(`No default HTML converter for Content Editor block "${block.type}".`);
949
- return converter(block, context);
1429
+ {
1430
+ name: 'Green',
1431
+ color: '#40916c',
1432
+ type: 'text'
950
1433
  },
951
- renderText: text => renderText(text, context, config)
952
- };
953
- const html = context.renderBlocks(blocks);
954
- return [...styles].map(css => `<style>${css}</style>`).join('') + html;
955
- }
956
- function renderText(text, ctx, config) {
957
- if (!isNgsHeadlessEditorTextContent(text))
958
- return '';
959
- return text.map(run => run.marks.reduce((html, mark) => {
960
- const override = config.marks && Object.hasOwn(config.marks, mark.type) ? config.marks[mark.type] : undefined;
961
- return override ? override(html, mark, ctx) : renderMark(html, mark, ctx);
962
- }, ctx.escape(run.text).replace(/\r\n|\r|\n/g, '<br>'))).join('');
1434
+ {
1435
+ name: 'Blue',
1436
+ color: '#00bbf9',
1437
+ type: 'text'
1438
+ },
1439
+ {
1440
+ name: 'Purple',
1441
+ color: '#907ad6',
1442
+ type: 'text'
1443
+ },
1444
+ {
1445
+ name: 'Pink',
1446
+ color: '#fa3faf',
1447
+ type: 'text'
1448
+ },
1449
+ {
1450
+ name: 'Red',
1451
+ color: '#ef233c',
1452
+ type: 'text'
1453
+ }
1454
+ ], /* @ts-ignore */
1455
+ ...(ngDevMode ? [{ debugName: "textColors" }] : /* istanbul ignore next */ []));
1456
+ backgroundColors = input([
1457
+ {
1458
+ name: 'Default',
1459
+ color: '',
1460
+ type: 'background'
1461
+ },
1462
+ {
1463
+ name: 'Gray',
1464
+ color: '#e9ecef',
1465
+ type: 'background'
1466
+ },
1467
+ {
1468
+ name: 'Brown',
1469
+ color: '#ffe0c0',
1470
+ type: 'background'
1471
+ },
1472
+ {
1473
+ name: 'Orange',
1474
+ color: '#ffd8c6',
1475
+ type: 'background'
1476
+ },
1477
+ {
1478
+ name: 'Yellow',
1479
+ color: '#fff3b0',
1480
+ type: 'background'
1481
+ },
1482
+ {
1483
+ name: 'Green',
1484
+ color: '#eff6e0',
1485
+ type: 'background'
1486
+ },
1487
+ {
1488
+ name: 'Blue',
1489
+ color: '#edf6f9',
1490
+ type: 'background'
1491
+ },
1492
+ {
1493
+ name: 'Purple',
1494
+ color: '#e0aaff',
1495
+ type: 'background'
1496
+ },
1497
+ {
1498
+ name: 'Pink',
1499
+ color: '#fae0ec',
1500
+ type: 'background'
1501
+ },
1502
+ {
1503
+ name: 'Red',
1504
+ color: '#ffdccc',
1505
+ type: 'background'
1506
+ }
1507
+ ], /* @ts-ignore */
1508
+ ...(ngDevMode ? [{ debugName: "backgroundColors" }] : /* istanbul ignore next */ []));
1509
+ textColorChanged = output();
1510
+ backgroundColorChanged = output();
1511
+ selectRecentlyColor(color) {
1512
+ if (color.type === 'text') {
1513
+ this.selectTextColor(color);
1514
+ }
1515
+ else if (color.type === 'background') {
1516
+ this.selectBackgroundColor(color);
1517
+ }
1518
+ }
1519
+ selectTextColor(color) {
1520
+ this.selectedTextColor.set(color);
1521
+ this.textColorChanged.emit(color.color);
1522
+ this._addToRecently(color);
1523
+ }
1524
+ selectBackgroundColor(color) {
1525
+ this.selectedBackgroundColor.set(color);
1526
+ this.backgroundColorChanged.emit(color.color);
1527
+ this._addToRecently(color);
1528
+ }
1529
+ _addToRecently(color) {
1530
+ const hasRecentlyUsed = this.recentlyUsed()
1531
+ .filter(recentlyColor => recentlyColor.name === color.name && recentlyColor.type === color.type)
1532
+ .length > 0;
1533
+ if (hasRecentlyUsed) {
1534
+ return;
1535
+ }
1536
+ let colors = [...this.recentlyUsed()];
1537
+ colors = colors.length >= 5 ? colors.slice(1, 5) : colors;
1538
+ this.recentlyUsed.set([...colors, color]);
1539
+ try {
1540
+ this._document.defaultView?.localStorage.setItem('ngsContentEditorRecentlyUsedTextColor', JSON.stringify(this.recentlyUsed()));
1541
+ }
1542
+ catch {
1543
+ // Keep the recent colors in memory when browser storage is unavailable.
1544
+ }
1545
+ }
1546
+ _getRecentlyUsed() {
1547
+ try {
1548
+ const value = this._document.defaultView?.localStorage.getItem('ngsContentEditorRecentlyUsedTextColor');
1549
+ const colors = value ? JSON.parse(value) : [];
1550
+ return Array.isArray(colors) ? colors : [];
1551
+ }
1552
+ catch {
1553
+ return [];
1554
+ }
1555
+ }
1556
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: TextColorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1557
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: TextColorComponent, isStandalone: true, selector: "ngs-text-color", inputs: { recentlyUsed: { classPropertyName: "recentlyUsed", publicName: "recentlyUsed", isSignal: true, isRequired: false, transformFunction: null }, selectedTextColor: { classPropertyName: "selectedTextColor", publicName: "selectedTextColor", isSignal: true, isRequired: false, transformFunction: null }, selectedBackgroundColor: { classPropertyName: "selectedBackgroundColor", publicName: "selectedBackgroundColor", isSignal: true, isRequired: false, transformFunction: null }, textColors: { classPropertyName: "textColors", publicName: "textColors", isSignal: true, isRequired: false, transformFunction: null }, backgroundColors: { classPropertyName: "backgroundColors", publicName: "backgroundColors", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { recentlyUsed: "recentlyUsedChange", selectedTextColor: "selectedTextColorChange", selectedBackgroundColor: "selectedBackgroundColorChange", textColorChanged: "textColorChanged", backgroundColorChanged: "backgroundColorChanged" }, ngImport: i0, template: "@if (recentlyUsed().length > 0) {\n <div class=\"mb-5\">\n <div class=\"text-xs text-neutral-700 text-semibold\">Recently colors</div>\n <div class=\"flex gap-2 flex-wrap mt-3\">\n @for (recentlyColor of recentlyUsed(); track recentlyColor) {\n @if (recentlyColor.type === 'text') {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\"\n [style.color]=\"recentlyColor.color\" [ngsTooltip]=\"recentlyColor.name\"\n (click)=\"selectRecentlyColor(recentlyColor)\">\n <ngs-icon name=\"fluent:text-field-24-regular\"/>\n </button>\n } @else if (recentlyColor.type === 'background') {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\"\n [style.background-color]=\"recentlyColor.color\" [ngsTooltip]=\"recentlyColor.name\"\n (click)=\"selectRecentlyColor(recentlyColor)\">\n </button>\n }\n }\n </div>\n </div>\n}\n\n<div class=\"mb-5\">\n <div class=\"text-xs text-neutral-700 text-semibold\">Text color</div>\n <div class=\"flex gap-2 flex-wrap mt-3\">\n @for (textColor of textColors(); track $index) {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\n [&.is-selected]:outline [&.is-selected]:outline-primary\"\n [style.color]=\"textColor.color\" [ngsTooltip]=\"textColor.name\"\n [class.is-selected]=\"selectedTextColor()?.color === textColor.color\"\n (click)=\"selectTextColor(textColor)\">\n <ngs-icon name=\"fluent:text-field-24-regular\"/>\n </button>\n }\n </div>\n</div>\n\n<div>\n <div class=\"text-xs text-neutral-700 text-semibold\">Background color</div>\n <div class=\"flex gap-2 flex-wrap mt-3\">\n @for (backgroundColor of backgroundColors(); track $index) {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\n [&.is-selected]:outline [&.is-selected]:outline-primary\"\n [style.background-color]=\"backgroundColor.color\" [ngsTooltip]=\"backgroundColor.name\"\n [class.is-selected]=\"selectedBackgroundColor()?.color === backgroundColor.color\"\n (click)=\"selectBackgroundColor(backgroundColor)\">\n </button>\n }\n </div>\n</div>\n", styles: [":host{display:block;width:172px}\n"], dependencies: [{ kind: "component", type: Icon, selector: "ngs-icon", inputs: ["name"], exportAs: ["ngsIcon"] }, { kind: "directive", type: Tooltip, selector: "[ngsTooltip]", inputs: ["ngsTooltip", "ngsTooltipPosition", "ngsTooltipClass", "ngsTooltipShowDelay", "ngsTooltipHideDelay", "ngsTooltipOffset", "ngsTooltipPositionAtOrigin", "ngsTooltipDisabled"], exportAs: ["ngsTooltip"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
963
1558
  }
964
- function renderMark(html, mark, ctx) {
965
- const tag = Object.hasOwn(MARK_TAGS, mark.type) ? MARK_TAGS[mark.type] : undefined;
966
- if (tag)
967
- return `<${tag}>${html}</${tag}>`;
968
- if (mark.type === 'link') {
969
- const href = ctx.safeUrl(mark.attrs?.['href']);
970
- if (!href)
971
- return html;
972
- const target = mark.attrs?.['target'] === '_blank' ? '_blank' : '_self';
973
- return `<a href="${ctx.escape(href)}" target="${target}" rel="noopener noreferrer">${html}</a>`;
1559
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: TextColorComponent, decorators: [{
1560
+ type: Component,
1561
+ args: [{ selector: 'ngs-text-color', imports: [
1562
+ Icon,
1563
+ Tooltip
1564
+ ], changeDetection: ChangeDetectionStrategy.Eager, template: "@if (recentlyUsed().length > 0) {\n <div class=\"mb-5\">\n <div class=\"text-xs text-neutral-700 text-semibold\">Recently colors</div>\n <div class=\"flex gap-2 flex-wrap mt-3\">\n @for (recentlyColor of recentlyUsed(); track recentlyColor) {\n @if (recentlyColor.type === 'text') {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\"\n [style.color]=\"recentlyColor.color\" [ngsTooltip]=\"recentlyColor.name\"\n (click)=\"selectRecentlyColor(recentlyColor)\">\n <ngs-icon name=\"fluent:text-field-24-regular\"/>\n </button>\n } @else if (recentlyColor.type === 'background') {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\"\n [style.background-color]=\"recentlyColor.color\" [ngsTooltip]=\"recentlyColor.name\"\n (click)=\"selectRecentlyColor(recentlyColor)\">\n </button>\n }\n }\n </div>\n </div>\n}\n\n<div class=\"mb-5\">\n <div class=\"text-xs text-neutral-700 text-semibold\">Text color</div>\n <div class=\"flex gap-2 flex-wrap mt-3\">\n @for (textColor of textColors(); track $index) {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\n [&.is-selected]:outline [&.is-selected]:outline-primary\"\n [style.color]=\"textColor.color\" [ngsTooltip]=\"textColor.name\"\n [class.is-selected]=\"selectedTextColor()?.color === textColor.color\"\n (click)=\"selectTextColor(textColor)\">\n <ngs-icon name=\"fluent:text-field-24-regular\"/>\n </button>\n }\n </div>\n</div>\n\n<div>\n <div class=\"text-xs text-neutral-700 text-semibold\">Background color</div>\n <div class=\"flex gap-2 flex-wrap mt-3\">\n @for (backgroundColor of backgroundColors(); track $index) {\n <button class=\"rounded-sm border border-border size-7 flex-none flex items-center justify-center cursor-pointer\n [&.is-selected]:outline [&.is-selected]:outline-primary\"\n [style.background-color]=\"backgroundColor.color\" [ngsTooltip]=\"backgroundColor.name\"\n [class.is-selected]=\"selectedBackgroundColor()?.color === backgroundColor.color\"\n (click)=\"selectBackgroundColor(backgroundColor)\">\n </button>\n }\n </div>\n</div>\n", styles: [":host{display:block;width:172px}\n"] }]
1565
+ }], propDecorators: { recentlyUsed: [{ type: i0.Input, args: [{ isSignal: true, alias: "recentlyUsed", required: false }] }, { type: i0.Output, args: ["recentlyUsedChange"] }], selectedTextColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedTextColor", required: false }] }, { type: i0.Output, args: ["selectedTextColorChange"] }], selectedBackgroundColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedBackgroundColor", required: false }] }, { type: i0.Output, args: ["selectedBackgroundColorChange"] }], textColors: [{ type: i0.Input, args: [{ isSignal: true, alias: "textColors", required: false }] }], backgroundColors: [{ type: i0.Input, args: [{ isSignal: true, alias: "backgroundColors", required: false }] }], textColorChanged: [{ type: i0.Output, args: ["textColorChanged"] }], backgroundColorChanged: [{ type: i0.Output, args: ["backgroundColorChanged"] }] } });
1566
+
1567
+ class CommandBarComponent {
1568
+ editor = inject(NgsHeadlessEditor);
1569
+ dialog = inject(Dialog);
1570
+ observedElement = input(null, /* @ts-ignore */
1571
+ ...(ngDevMode ? [{ debugName: "observedElement" }] : /* istanbul ignore next */ []));
1572
+ alignment = computed(() => this.region()?.alignment() ?? 'left', /* @ts-ignore */
1573
+ ...(ngDevMode ? [{ debugName: "alignment" }] : /* istanbul ignore next */ []));
1574
+ savedSelection = null;
1575
+ region() { return ContentEditorContentEditableDirective.forElement(this.observedElement()); }
1576
+ toggleBold() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_BOLD); }
1577
+ toggleItalic() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_ITALIC); }
1578
+ toggleCode() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_CODE); }
1579
+ toggleStrike() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_STRIKE); }
1580
+ toggleUnderline() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_UNDERLINE); }
1581
+ toggleSuperscript() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_SUPERSCRIPT); }
1582
+ toggleSubscript() { this.editor.execute(NGS_HEADLESS_EDITOR_TOGGLE_SUBSCRIPT); }
1583
+ isLinkActive() { return this.editor.isMarkActive('link'); }
1584
+ isActive(tag) {
1585
+ return this.editor.isMarkActive({ strong: 'bold', em: 'italic', s: 'strike', u: 'underline', sup: 'superscript', sub: 'subscript' }[tag] ?? tag);
974
1586
  }
975
- if (mark.type === 'textColor' || mark.type === 'backgroundColor') {
976
- const color = normalizeNgsHeadlessEditorColor(String(mark.attrs?.['color'] ?? ''));
977
- return color ? `<span style="${mark.type === 'textColor' ? 'color' : 'background-color'}:${ctx.escape(color)}">${html}</span>` : html;
1587
+ setTextAlignment(value) { this.restoreSelection()?.setAlignment(value); }
1588
+ isTextAlignment(value) { return this.alignment() === value; }
1589
+ addLink() { this.openLinkDialog(false); }
1590
+ editLink() { this.openLinkDialog(true); }
1591
+ openLinkDialog(edit) {
1592
+ this.retainSelection();
1593
+ const saved = this.savedSelection;
1594
+ if (!saved)
1595
+ return;
1596
+ const target = saved.region.region.editor;
1597
+ const mark = target.getActiveMark('link');
1598
+ const ref = edit
1599
+ ? this.dialog.open(EditLinkDialog, { data: { href: mark?.attrs?.['href'], openInNewTab: mark?.attrs?.['target'] === '_blank' }, width: '500px', restoreFocus: false })
1600
+ : this.dialog.open(AddLinkDialog, { width: '500px', restoreFocus: false });
1601
+ ref.afterClosed().subscribe((value) => {
1602
+ if (!this.restoreSelection())
1603
+ return;
1604
+ if (value) {
1605
+ if (value.href)
1606
+ this.editor.execute(NGS_HEADLESS_EDITOR_SET_LINK, { href: value.href, target: value.openInNewTab ? '_blank' : '_self' });
1607
+ else
1608
+ this.editor.execute(NGS_HEADLESS_EDITOR_UNSET_LINK);
1609
+ }
1610
+ this.restoreSelectionAfterOverlay();
1611
+ });
1612
+ }
1613
+ preserveSelection(event) {
1614
+ event.preventDefault();
1615
+ this.region()?.activate();
1616
+ this.retainSelection();
1617
+ }
1618
+ retainSelection() {
1619
+ if (this.savedSelection)
1620
+ return;
1621
+ const region = this.region();
1622
+ const selection = region?.region.editor.selection();
1623
+ if (region && selection)
1624
+ this.savedSelection = { region, selection };
1625
+ }
1626
+ restoreSelection() {
1627
+ const saved = this.savedSelection;
1628
+ if (!saved)
1629
+ return this.region();
1630
+ if (!this.observedElement()?.isConnected || saved.region.region.editor !== this.editor.inlineTarget())
1631
+ return;
1632
+ saved.region.region.editor.setSelection(saved.selection);
1633
+ return saved.region;
1634
+ }
1635
+ restoreSelectionAfterOverlay() {
1636
+ // MenuTrigger restores its own focus after emitting menuClosed.
1637
+ // Restore the editor afterwards, using model points rather than old DOM nodes.
1638
+ Promise.resolve().then(() => {
1639
+ const region = this.restoreSelection();
1640
+ this.savedSelection = null;
1641
+ if (region && this.observedElement()?.isConnected)
1642
+ region.focus();
1643
+ });
1644
+ }
1645
+ preventMenuClose(event) { event.stopPropagation(); event.preventDefault(); }
1646
+ onTextColorChanged(color) {
1647
+ const region = this.restoreSelection();
1648
+ if (!region)
1649
+ return;
1650
+ if (color)
1651
+ this.editor.execute(NGS_HEADLESS_EDITOR_SET_TEXT_COLOR, color);
1652
+ else
1653
+ this.editor.execute(NGS_HEADLESS_EDITOR_UNSET_TEXT_COLOR);
1654
+ region.focus();
978
1655
  }
979
- return html;
1656
+ onBackgroundColorChanged(color) {
1657
+ const region = this.restoreSelection();
1658
+ if (!region)
1659
+ return;
1660
+ if (color)
1661
+ this.editor.execute(NGS_HEADLESS_EDITOR_SET_BACKGROUND_COLOR, color);
1662
+ else
1663
+ this.editor.execute(NGS_HEADLESS_EDITOR_UNSET_BACKGROUND_COLOR);
1664
+ region.focus();
1665
+ }
1666
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: CommandBarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1667
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: CommandBarComponent, isStandalone: true, selector: "ngs-command-bar", inputs: { observedElement: { classPropertyName: "observedElement", publicName: "observedElement", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mousedown": "preserveSelection($event)" }, classAttribute: "ngs-command-bar" }, ngImport: i0, template: "<div class=\"flex items-center gap-1\">\n <button ngsIconButton (click)=\"toggleBold()\"\n [class.is-active]=\"isActive('strong')\">\n <ngs-icon name=\"fluent:text-bold-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleItalic()\"\n [class.is-active]=\"isActive('em')\">\n <ngs-icon name=\"fluent:text-italic-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleStrike()\"\n [class.is-active]=\"isActive('s')\">\n <ngs-icon name=\"fluent:text-strikethrough-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleUnderline()\"\n [class.is-active]=\"isActive('u')\">\n <ngs-icon name=\"fluent:text-underline-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleSuperscript()\"\n [class.is-active]=\"isActive('sup')\">\n <ngs-icon name=\"fluent:text-superscript-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleSubscript()\"\n [class.is-active]=\"isActive('sub')\">\n <ngs-icon name=\"fluent:text-subscript-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleCode()\"\n [class.is-active]=\"isActive('code')\">\n <ngs-icon name=\"fluent:code-24-regular\"/>\n </button>\n\n @if (isLinkActive()) {\n <button ngsIconButton (click)=\"editLink()\">\n <ngs-icon name=\"fluent:link-24-regular\"/>\n </button>\n } @else {\n <button ngsIconButton (click)=\"addLink()\">\n <ngs-icon name=\"fluent:link-add-24-regular\"/>\n </button>\n }\n <button ngsIconButton [ngsMenuTriggerFor]=\"alignMenu\"\n (menuOpened)=\"retainSelection()\" (menuClosed)=\"restoreSelectionAfterOverlay()\">\n @switch (alignment()) {\n @case ('left') {\n <ngs-icon name=\"fluent:text-align-left-24-regular\"/>\n }\n @case ('center') {\n <ngs-icon name=\"fluent:text-align-center-24-regular\"/>\n }\n @case ('right') {\n <ngs-icon name=\"fluent:text-align-right-24-regular\"/>\n }\n }\n </button>\n <button ngsIconButton [ngsMenuTriggerFor]=\"formatColorText\"\n (menuOpened)=\"retainSelection()\" (menuClosed)=\"restoreSelectionAfterOverlay()\">\n <ngs-icon name=\"fluent:text-color-24-regular\"/>\n </button>\n</div>\n\n<ngs-menu #alignMenu=\"ngsMenu\">\n <button class=\"[&.is-active]:!bg-secondary-container\"\n [class.is-active]=\"isTextAlignment('left')\"\n ngs-menu-item\n (click)=\"setTextAlignment('left')\">\n <ngs-icon name=\"fluent:text-align-left-24-regular\"/>\n Align Left\n </button>\n <button class=\"[&.is-active]:!bg-secondary-container\"\n [class.is-active]=\"isTextAlignment('center')\"\n ngs-menu-item\n (click)=\"setTextAlignment('center')\">\n <ngs-icon name=\"fluent:text-align-center-24-regular\"/>\n Align Center\n </button>\n <button class=\"[&.is-active]:!bg-secondary-container\"\n [class.is-active]=\"isTextAlignment('right')\"\n ngs-menu-item (click)=\"setTextAlignment('right')\">\n <ngs-icon name=\"fluent:text-align-right-24-regular\"/>\n Align Right\n </button>\n</ngs-menu>\n\n<ngs-menu #formatColorText=\"ngsMenu\">\n <div class=\"px-4 py-3\" (mousedown)=\"preventMenuClose($event)\">\n <ngs-text-color (textColorChanged)=\"onTextColorChanged($event)\"\n (backgroundColorChanged)=\"onBackgroundColorChanged($event)\"/>\n </div>\n</ngs-menu>\n", styles: [":host{background:var(--ngs-color-on-surface);color:var(--ngs-color-surface);border-radius:calc(var(--spacing, .25rem) * 3);padding:var(--spacing, .25rem);box-shadow:var(--ngs-shadow-lg)}:host button[ngsIconButton]{--ngs-button-color: var(--ngs-color-surface);--ngs-button-hover-bg: var(--ngs-color-surface);--ngs-state-focus-ring: var(--ngs-color-surface)}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton]{--ngs-button-hover-bg: color-mix(in srgb, var(--ngs-color-surface) 12%, transparent)}}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton]{--ngs-state-focus-ring: color-mix(in srgb, var(--ngs-color-surface) 40%, transparent)}}:host button[ngsIconButton].is-active{--ngs-button-bg: var(--ngs-color-surface);--ngs-button-hover-bg: var(--ngs-color-surface)}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton].is-active{--ngs-button-bg: color-mix(in srgb, var(--ngs-color-surface) 20%, transparent)}}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton].is-active{--ngs-button-hover-bg: color-mix(in srgb, var(--ngs-color-surface) 28%, transparent)}}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "component", type: Button, selector: " button[ngsButton], button[ngsIconButton], a[ngsButton], a[ngsIconButton] ", inputs: ["ngsButton", "ngsIconButton", "loading", "disabled", "disabledInteractive", "disableRipple", "reverse", "fullWidth", "hideTextOnMobile"], exportAs: ["ngsButton"] }, { kind: "component", type: Icon, selector: "ngs-icon", inputs: ["name"], exportAs: ["ngsIcon"] }, { kind: "component", type: Menu, selector: "ngs-menu", inputs: ["role", "classList", "xPosition", "yPosition", "pushIntoViewport"], outputs: ["closed"], exportAs: ["ngsMenu"] }, { kind: "component", type: MenuItem, selector: "ngs-menu-item, [ngs-menu-item]", inputs: ["disabled", "role", "selected"], outputs: ["_triggered"], exportAs: ["ngsMenuItem"] }, { kind: "directive", type: MenuTrigger, selector: "[ngsMenuTriggerFor]", inputs: ["ngsMenuTriggerFor", "ngsMenuTriggerData", "ngsMenuDisabled", "xPosition", "yPosition", "ngsMenuTriggerRestoreFocus"], outputs: ["menuOpened", "menuClosed"], exportAs: ["ngsMenuTrigger"] }, { kind: "component", type: TextColorComponent, selector: "ngs-text-color", inputs: ["recentlyUsed", "selectedTextColor", "selectedBackgroundColor", "textColors", "backgroundColors"], outputs: ["recentlyUsedChange", "selectedTextColorChange", "selectedBackgroundColorChange", "textColorChanged", "backgroundColorChanged"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
980
1668
  }
981
- function defaultConverter(type) {
982
- return Object.hasOwn(CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS, type) ? CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS[type] : undefined;
1669
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: CommandBarComponent, decorators: [{
1670
+ type: Component,
1671
+ args: [{ selector: 'ngs-command-bar', imports: [Button, Icon, Menu, MenuItem, MenuTrigger, TextColorComponent], changeDetection: ChangeDetectionStrategy.OnPush, host: {
1672
+ 'class': 'ngs-command-bar',
1673
+ '(mousedown)': 'preserveSelection($event)'
1674
+ }, template: "<div class=\"flex items-center gap-1\">\n <button ngsIconButton (click)=\"toggleBold()\"\n [class.is-active]=\"isActive('strong')\">\n <ngs-icon name=\"fluent:text-bold-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleItalic()\"\n [class.is-active]=\"isActive('em')\">\n <ngs-icon name=\"fluent:text-italic-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleStrike()\"\n [class.is-active]=\"isActive('s')\">\n <ngs-icon name=\"fluent:text-strikethrough-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleUnderline()\"\n [class.is-active]=\"isActive('u')\">\n <ngs-icon name=\"fluent:text-underline-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleSuperscript()\"\n [class.is-active]=\"isActive('sup')\">\n <ngs-icon name=\"fluent:text-superscript-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleSubscript()\"\n [class.is-active]=\"isActive('sub')\">\n <ngs-icon name=\"fluent:text-subscript-24-regular\"/>\n </button>\n <button ngsIconButton (click)=\"toggleCode()\"\n [class.is-active]=\"isActive('code')\">\n <ngs-icon name=\"fluent:code-24-regular\"/>\n </button>\n\n @if (isLinkActive()) {\n <button ngsIconButton (click)=\"editLink()\">\n <ngs-icon name=\"fluent:link-24-regular\"/>\n </button>\n } @else {\n <button ngsIconButton (click)=\"addLink()\">\n <ngs-icon name=\"fluent:link-add-24-regular\"/>\n </button>\n }\n <button ngsIconButton [ngsMenuTriggerFor]=\"alignMenu\"\n (menuOpened)=\"retainSelection()\" (menuClosed)=\"restoreSelectionAfterOverlay()\">\n @switch (alignment()) {\n @case ('left') {\n <ngs-icon name=\"fluent:text-align-left-24-regular\"/>\n }\n @case ('center') {\n <ngs-icon name=\"fluent:text-align-center-24-regular\"/>\n }\n @case ('right') {\n <ngs-icon name=\"fluent:text-align-right-24-regular\"/>\n }\n }\n </button>\n <button ngsIconButton [ngsMenuTriggerFor]=\"formatColorText\"\n (menuOpened)=\"retainSelection()\" (menuClosed)=\"restoreSelectionAfterOverlay()\">\n <ngs-icon name=\"fluent:text-color-24-regular\"/>\n </button>\n</div>\n\n<ngs-menu #alignMenu=\"ngsMenu\">\n <button class=\"[&.is-active]:!bg-secondary-container\"\n [class.is-active]=\"isTextAlignment('left')\"\n ngs-menu-item\n (click)=\"setTextAlignment('left')\">\n <ngs-icon name=\"fluent:text-align-left-24-regular\"/>\n Align Left\n </button>\n <button class=\"[&.is-active]:!bg-secondary-container\"\n [class.is-active]=\"isTextAlignment('center')\"\n ngs-menu-item\n (click)=\"setTextAlignment('center')\">\n <ngs-icon name=\"fluent:text-align-center-24-regular\"/>\n Align Center\n </button>\n <button class=\"[&.is-active]:!bg-secondary-container\"\n [class.is-active]=\"isTextAlignment('right')\"\n ngs-menu-item (click)=\"setTextAlignment('right')\">\n <ngs-icon name=\"fluent:text-align-right-24-regular\"/>\n Align Right\n </button>\n</ngs-menu>\n\n<ngs-menu #formatColorText=\"ngsMenu\">\n <div class=\"px-4 py-3\" (mousedown)=\"preventMenuClose($event)\">\n <ngs-text-color (textColorChanged)=\"onTextColorChanged($event)\"\n (backgroundColorChanged)=\"onBackgroundColorChanged($event)\"/>\n </div>\n</ngs-menu>\n", styles: [":host{background:var(--ngs-color-on-surface);color:var(--ngs-color-surface);border-radius:calc(var(--spacing, .25rem) * 3);padding:var(--spacing, .25rem);box-shadow:var(--ngs-shadow-lg)}:host button[ngsIconButton]{--ngs-button-color: var(--ngs-color-surface);--ngs-button-hover-bg: var(--ngs-color-surface);--ngs-state-focus-ring: var(--ngs-color-surface)}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton]{--ngs-button-hover-bg: color-mix(in srgb, var(--ngs-color-surface) 12%, transparent)}}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton]{--ngs-state-focus-ring: color-mix(in srgb, var(--ngs-color-surface) 40%, transparent)}}:host button[ngsIconButton].is-active{--ngs-button-bg: var(--ngs-color-surface);--ngs-button-hover-bg: var(--ngs-color-surface)}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton].is-active{--ngs-button-bg: color-mix(in srgb, var(--ngs-color-surface) 20%, transparent)}}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton].is-active{--ngs-button-hover-bg: color-mix(in srgb, var(--ngs-color-surface) 28%, transparent)}}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
1675
+ }], propDecorators: { observedElement: [{ type: i0.Input, args: [{ isSignal: true, alias: "observedElement", required: false }] }] } });
1676
+
1677
+ /** Shared marks and commands for content editing and read-only rendering. */
1678
+ function provideContentEditor() {
1679
+ return provideNgsHeadlessEditor(withHeadlessEditorPlugin(basicTextEditorPlugin()), withHeadlessEditorPlugin(colorEditorPlugin()), withHeadlessEditorPlugin(linkEditorPlugin()));
983
1680
  }
984
1681
 
985
- /** Export saved documents with the current environment's shared configuration. */
986
- class ContentEditorHtmlSerializer {
987
- config = inject(CONTENT_EDITOR_CONFIG);
988
- toHtml(document, config = {}) {
989
- return contentEditorToHtml(document, mergeContentEditorConfig(this.config, config));
990
- }
991
- blockToHtml(block, config = {}) {
992
- return contentEditorBlockToHtml(block, mergeContentEditorConfig(this.config, config));
1682
+ const CONTENT_EDITOR_EXTRA_BLOCK_DEFS = [
1683
+ {
1684
+ type: 'callout', component: () => import('./ngstarter-ui-components-content-editor-callout-block-DTdApN0r.mjs').then(m => m.ContentEditorCalloutBlock),
1685
+ empty: () => ({ content: [createNgsHeadlessEditorText()], settings: { variant: 'note' } }), options: {}
1686
+ },
1687
+ {
1688
+ type: 'toggle', component: () => import('./ngstarter-ui-components-content-editor-toggle-block-Cb67ChE8.mjs').then(m => m.ContentEditorToggleBlock),
1689
+ empty: () => ({ content: { title: [], blocks: [emptyParagraph()] }, settings: { expanded: true } }), options: {}
1690
+ },
1691
+ {
1692
+ type: 'attachment', component: () => import('./ngstarter-ui-components-content-editor-attachment-block-rzZKJ2JH.mjs').then(m => m.ContentEditorAttachmentBlock),
1693
+ empty: () => ({ content: { url: '', name: '', size: 0, mimeType: '' }, settings: {} }),
1694
+ options: { uploadFn: (_file, dataUrl) => Promise.resolve(dataUrl) }
1695
+ },
1696
+ {
1697
+ type: 'gallery', component: () => import('./ngstarter-ui-components-content-editor-gallery-block-gtH7yWd5.mjs').then(m => m.ContentEditorGalleryBlock),
1698
+ empty: () => ({ content: { images: [] }, settings: {} }),
1699
+ options: { uploadFn: (_file, dataUrl) => Promise.resolve(dataUrl) }
1700
+ },
1701
+ {
1702
+ type: 'grid', component: () => import('./ngstarter-ui-components-content-editor-grid-block-Pb-xV7Pw.mjs').then(m => m.ContentEditorGridBlock),
1703
+ empty: () => ({ content: { cells: Array.from({ length: 4 }, emptyGridCell) }, settings: { columns: 2, gap: 'medium', stackOnMobile: true } }), options: {}
993
1704
  }
994
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorHtmlSerializer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
995
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorHtmlSerializer, providedIn: 'root' });
1705
+ ].map(def => ({ ...def, toHtml: CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS[def.type] }));
1706
+ function emptyParagraph() {
1707
+ return { id: createNgsHeadlessEditorId('paragraph'), type: 'paragraph', content: [createNgsHeadlessEditorText()] };
996
1708
  }
997
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorHtmlSerializer, decorators: [{
998
- type: Injectable,
999
- args: [{ providedIn: 'root' }]
1000
- }] });
1709
+ function emptyGridCell() { return { id: createNgsHeadlessEditorId('cell'), blocks: [emptyParagraph()] }; }
1710
+ const CONTENT_EDITOR_EXTRA_SUGGESTIONS = [
1711
+ { type: 'heading', title: 'Content & layout' },
1712
+ ...[
1713
+ ['callout', 'Callout', 'Notes, tips and warnings', 'fluent:info-24-regular'],
1714
+ ['toggle', 'Toggle', 'Collapsible content with nested blocks', 'fluent:chevron-down-24-regular'],
1715
+ ['attachment', 'Attachment', 'Upload a file for download', 'fluent:attach-24-regular'],
1716
+ ['gallery', 'Gallery', 'Image carousel with captions', 'fluent:image-multiple-24-regular'],
1717
+ ['grid', 'Grid', 'Responsive grid with nested blocks', 'fluent:grid-24-regular']
1718
+ ].map(([blockType, title, description, iconName]) => ({ type: 'item', blockType, title, description, iconName, blockSettings: {} }))
1719
+ ];
1001
1720
 
1002
- const CONTENT_EDITOR_CONFIG = new InjectionToken('CONTENT_EDITOR_CONFIG', {
1003
- providedIn: 'root', factory: () => ({})
1004
- });
1005
- /** Later configurations override individual block fields, preserving unrelated options. */
1006
- function mergeContentEditorConfig(...configs) {
1007
- const result = { blocks: Object.create(null), marks: {} };
1008
- for (const config of configs) {
1009
- for (const [type, block] of Object.entries(config.blocks ?? {})) {
1010
- const previous = result.blocks[type];
1011
- result.blocks[type] = {
1012
- ...previous, ...block, options: { ...previous?.options, ...block.options }
1013
- };
1721
+ const browserStorage = {
1722
+ getItem: key => globalThis.localStorage.getItem(key),
1723
+ setItem: (key, value) => globalThis.localStorage.setItem(key, value),
1724
+ removeItem: key => globalThis.localStorage.removeItem(key)
1725
+ };
1726
+ /** Delayed persistence keeps storage errors visible and flushes before switching documents. */
1727
+ class ContentEditorDraftController {
1728
+ status = signal('disabled', /* @ts-ignore */
1729
+ ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
1730
+ error = signal('', /* @ts-ignore */
1731
+ ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
1732
+ savedAt = signal(null, /* @ts-ignore */
1733
+ ...(ngDevMode ? [{ debugName: "savedAt" }] : /* istanbul ignore next */ []));
1734
+ key = '';
1735
+ storage = browserStorage;
1736
+ debounceMs = 500;
1737
+ enabled = false;
1738
+ pending = null;
1739
+ timer = null;
1740
+ configure(key, enabled, config = {}) {
1741
+ const storage = config.storage ?? browserStorage;
1742
+ if (this.key !== key || this.enabled !== enabled || this.storage !== storage) {
1743
+ this.flush();
1744
+ this.key = key;
1745
+ this.enabled = enabled;
1746
+ this.storage = storage;
1747
+ this.status.set(enabled ? 'idle' : 'disabled');
1748
+ this.error.set('');
1749
+ this.savedAt.set(null);
1014
1750
  }
1015
- result.marks = { ...result.marks, ...config.marks };
1016
- if (config.includeStyles !== undefined)
1017
- result.includeStyles = config.includeStyles;
1018
- if (config.unknownBlockToHtml !== undefined)
1019
- result.unknownBlockToHtml = config.unknownBlockToHtml;
1751
+ this.debounceMs = Number.isFinite(config.debounceMs) ? Math.max(0, config.debounceMs) : 500;
1020
1752
  }
1021
- return result;
1753
+ read(validate) {
1754
+ if (!this.enabled)
1755
+ return null;
1756
+ try {
1757
+ const source = this.storage.getItem(this.key);
1758
+ if (!source)
1759
+ return null;
1760
+ const document = validate(source);
1761
+ this.status.set('saved');
1762
+ return document;
1763
+ }
1764
+ catch (error) {
1765
+ this.fail(error);
1766
+ return null;
1767
+ }
1768
+ }
1769
+ schedule(document) {
1770
+ if (!this.enabled)
1771
+ return;
1772
+ this.pending = document;
1773
+ this.status.set('saving');
1774
+ this.error.set('');
1775
+ if (this.timer)
1776
+ clearTimeout(this.timer);
1777
+ this.timer = setTimeout(() => this.flush(), this.debounceMs);
1778
+ }
1779
+ flush() {
1780
+ if (this.timer)
1781
+ clearTimeout(this.timer);
1782
+ this.timer = null;
1783
+ if (!this.enabled || !this.pending)
1784
+ return;
1785
+ const document = this.pending;
1786
+ this.pending = null;
1787
+ try {
1788
+ this.storage.setItem(this.key, JSON.stringify(document));
1789
+ this.status.set('saved');
1790
+ this.error.set('');
1791
+ this.savedAt.set(Date.now());
1792
+ }
1793
+ catch (error) {
1794
+ this.fail(error);
1795
+ }
1796
+ }
1797
+ clear() {
1798
+ if (this.timer)
1799
+ clearTimeout(this.timer);
1800
+ this.timer = null;
1801
+ this.pending = null;
1802
+ if (!this.enabled)
1803
+ return;
1804
+ try {
1805
+ this.storage.removeItem(this.key);
1806
+ this.status.set('idle');
1807
+ this.error.set('');
1808
+ this.savedAt.set(null);
1809
+ }
1810
+ catch (error) {
1811
+ this.fail(error);
1812
+ }
1813
+ }
1814
+ fail(error) { this.error.set(error instanceof Error ? error.message : 'Could not save draft'); this.status.set('error'); }
1022
1815
  }
1023
- /** Application or route environment configuration. Child environments inherit parent settings. */
1024
- function provideContentEditorConfig(config = {}) {
1025
- return makeEnvironmentProviders([
1026
- {
1027
- provide: CONTENT_EDITOR_CONFIG,
1028
- useFactory: () => mergeContentEditorConfig(inject(CONTENT_EDITOR_CONFIG, { skipSelf: true, optional: true }) ?? {}, config)
1029
- },
1030
- ContentEditorHtmlSerializer
1031
- ]);
1816
+
1817
+ const CONTENT_EDITOR_CONVERTIBLE_BLOCKS = ['paragraph', 'heading', 'quote', 'callout'];
1818
+ /** Retains identity, rich text and alignment. Quote attribution becomes a final line. */
1819
+ function contentEditorConvertBlock(block, type, settings = {}) {
1820
+ if (!CONTENT_EDITOR_CONVERTIBLE_BLOCKS.includes(block.type) || !CONTENT_EDITOR_CONVERTIBLE_BLOCKS.includes(type)) {
1821
+ throw new Error(`Cannot convert ${block.type} to ${type}`);
1822
+ }
1823
+ if (type === 'heading' && settings['level'] !== undefined && ![1, 2, 3, 4, 5, 6].includes(settings['level']))
1824
+ throw new Error('Heading level must be between 1 and 6');
1825
+ if (type === 'callout' && settings['variant'] !== undefined && !['note', 'tip', 'warning', 'danger'].includes(settings['variant']))
1826
+ throw new Error('Unsupported callout variant');
1827
+ const next = cloneContentEditorValue(block);
1828
+ if (type === block.type)
1829
+ return { ...next, attrs: { ...next.attrs, settings: { ...next.attrs?.['settings'], ...settings } } };
1830
+ const quote = block.type === 'quote' ? block.content : null;
1831
+ const cite = quote ? quote.cite.content : block.content;
1832
+ const caption = quote?.caption?.content ?? [];
1833
+ const text = normalizeNgsHeadlessEditorTextContent(caption.some(run => run.text)
1834
+ ? [...cite, createNgsHeadlessEditorText('\n'), ...caption] : cite);
1835
+ const props = (quote?.cite.props ?? block.attrs?.['props'] ?? []);
1836
+ const defaults = type === 'heading' ? { level: 2 } : type === 'callout' ? { variant: 'note' } : {};
1837
+ return { ...next, type,
1838
+ content: type === 'quote' ? { cite: { content: text, props }, caption: { content: [], props: [] } } : text,
1839
+ attrs: { ...next.attrs, props, settings: { ...defaults, ...(type === block.type ? next.attrs?.['settings'] : {}), ...settings } }
1840
+ };
1032
1841
  }
1033
1842
 
1034
1843
  // src/app/text-selection-popup.directive.ts
@@ -1464,12 +2273,24 @@ class ContentBuilderComponent {
1464
2273
  editor = inject(NgsHeadlessEditor);
1465
2274
  globalConfig = inject(CONTENT_EDITOR_CONFIG);
1466
2275
  htmlSerializer = inject(ContentEditorHtmlSerializer);
2276
+ importer = inject(ContentEditorImporter);
1467
2277
  config = input({}, /* @ts-ignore */
1468
2278
  ...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
1469
2279
  /** One insertion menu shared by root controls, nested collections and custom blocks. */
2280
+ conversionMenu = viewChild.required('conversionMenu', /* @ts-ignore */
2281
+ ...(ngDevMode ? [{ debugName: "conversionMenu" }] : /* istanbul ignore next */ []));
2282
+ conversionTypes = CONTENT_EDITOR_CONVERTIBLE_BLOCKS;
1470
2283
  blockMenu = viewChild.required('suggestionsMenu', /* @ts-ignore */
1471
2284
  ...(ngDevMode ? [{ debugName: "blockMenu" }] : /* istanbul ignore next */ []));
1472
2285
  document = inject(DOCUMENT);
2286
+ drafts = new ContentEditorDraftController();
2287
+ draftStatus = this.drafts.status;
2288
+ draftError = this.drafts.error;
2289
+ draftSavedAt = this.drafts.savedAt;
2290
+ documentId = input(/* @ts-ignore */
2291
+ ...(ngDevMode ? [undefined, { debugName: "documentId" }] : /* istanbul ignore next */ []));
2292
+ draftDebounceMs = input(undefined, { ...(ngDevMode ? { debugName: "draftDebounceMs" } : /* istanbul ignore next */ {}), transform: numberAttribute });
2293
+ draftKey = '';
1473
2294
  loaded = false;
1474
2295
  lastInput = null;
1475
2296
  _platformId = inject(PLATFORM_ID);
@@ -1477,7 +2298,7 @@ class ContentBuilderComponent {
1477
2298
  dropList = viewChild.required(CdkDropList, /* @ts-ignore */
1478
2299
  ...(ngDevMode ? [{ debugName: "dropList" }] : /* istanbul ignore next */ []));
1479
2300
  connectedDropLists = this._store.dropLists;
1480
- elRef = inject((ElementRef));
2301
+ elRef = inject(ElementRef);
1481
2302
  envInjector = inject(EnvironmentInjector);
1482
2303
  cdr = inject(ChangeDetectorRef);
1483
2304
  confirmManager = inject(ConfirmManager);
@@ -1506,7 +2327,7 @@ class ContentBuilderComponent {
1506
2327
  }
1507
2328
  },
1508
2329
  {
1509
- component: () => import('./ngstarter-ui-components-content-editor-paragraph-block.component-JVxf_Cdx.mjs').then(c => c.ParagraphBlockComponent),
2330
+ component: () => import('./ngstarter-ui-components-content-editor-paragraph-block.component-D5wS3m6O.mjs').then(c => c.ParagraphBlockComponent),
1510
2331
  type: 'paragraph',
1511
2332
  options: {},
1512
2333
  empty: () => {
@@ -1518,7 +2339,7 @@ class ContentBuilderComponent {
1518
2339
  }
1519
2340
  },
1520
2341
  {
1521
- component: () => import('./ngstarter-ui-components-content-editor-code-block.component-DSdVOJtH.mjs').then(c => c.CodeBlockComponent),
2342
+ component: () => import('./ngstarter-ui-components-content-editor-code-block.component-DpONkTMU.mjs').then(c => c.CodeBlockComponent),
1522
2343
  type: 'code',
1523
2344
  options: {},
1524
2345
  empty: () => {
@@ -1531,7 +2352,7 @@ class ContentBuilderComponent {
1531
2352
  }
1532
2353
  },
1533
2354
  {
1534
- component: () => import('./ngstarter-ui-components-content-editor-heading-block.component-BYpctSPe.mjs').then(c => c.HeadingBlockComponent),
2355
+ component: () => import('./ngstarter-ui-components-content-editor-heading-block.component-BKe9Zy_x.mjs').then(c => c.HeadingBlockComponent),
1535
2356
  type: 'heading',
1536
2357
  options: {},
1537
2358
  empty: () => {
@@ -1545,7 +2366,7 @@ class ContentBuilderComponent {
1545
2366
  }
1546
2367
  },
1547
2368
  {
1548
- component: () => import('./ngstarter-ui-components-content-editor-image-block.component-B3MnANpi.mjs').then(c => c.ImageBlockComponent),
2369
+ component: () => import('./ngstarter-ui-components-content-editor-image-block.component-DSpBVTu-.mjs').then(c => c.ImageBlockComponent),
1549
2370
  type: 'image',
1550
2371
  options: {
1551
2372
  uploadFn: (file, base64) => {
@@ -1572,7 +2393,7 @@ class ContentBuilderComponent {
1572
2393
  }
1573
2394
  },
1574
2395
  {
1575
- component: () => import('./ngstarter-ui-components-content-editor-video-block.component-DQUPVDwV.mjs').then(c => c.VideoBlockComponent),
2396
+ component: () => import('./ngstarter-ui-components-content-editor-video-block.component-CRa0g9Ez.mjs').then(c => c.VideoBlockComponent),
1576
2397
  type: 'video',
1577
2398
  options: {
1578
2399
  uploadFn: (file, base64) => {
@@ -1600,7 +2421,7 @@ class ContentBuilderComponent {
1600
2421
  }
1601
2422
  },
1602
2423
  {
1603
- component: () => import('./ngstarter-ui-components-content-editor-list-block.component-6SMBxIl4.mjs').then(c => c.ListBlockComponent),
2424
+ component: () => import('./ngstarter-ui-components-content-editor-list-block.component-BPKPE1uY.mjs').then(c => c.ListBlockComponent),
1604
2425
  type: 'bulletList',
1605
2426
  options: {},
1606
2427
  empty: () => {
@@ -1613,7 +2434,7 @@ class ContentBuilderComponent {
1613
2434
  }
1614
2435
  },
1615
2436
  {
1616
- component: () => import('./ngstarter-ui-components-content-editor-list-block.component-6SMBxIl4.mjs').then(c => c.ListBlockComponent),
2437
+ component: () => import('./ngstarter-ui-components-content-editor-list-block.component-BPKPE1uY.mjs').then(c => c.ListBlockComponent),
1617
2438
  type: 'orderedList',
1618
2439
  options: {},
1619
2440
  empty: () => {
@@ -1626,7 +2447,7 @@ class ContentBuilderComponent {
1626
2447
  }
1627
2448
  },
1628
2449
  {
1629
- component: () => import('./ngstarter-ui-components-content-editor-table-block.component-CJS-IBHw.mjs').then(c => c.TableBlockComponent),
2450
+ component: () => import('./ngstarter-ui-components-content-editor-table-block.component-DQgs_kyN.mjs').then(c => c.TableBlockComponent),
1630
2451
  type: 'table',
1631
2452
  options: {},
1632
2453
  empty: () => {
@@ -1695,7 +2516,7 @@ class ContentBuilderComponent {
1695
2516
  }
1696
2517
  },
1697
2518
  {
1698
- component: () => import('./ngstarter-ui-components-content-editor-quote-block.component-7EO7z7Sr.mjs').then(c => c.QuoteBlockComponent),
2519
+ component: () => import('./ngstarter-ui-components-content-editor-quote-block.component-C3GFAGKF.mjs').then(c => c.QuoteBlockComponent),
1699
2520
  type: 'quote',
1700
2521
  options: {},
1701
2522
  empty: () => {
@@ -1715,7 +2536,7 @@ class ContentBuilderComponent {
1715
2536
  }
1716
2537
  },
1717
2538
  {
1718
- component: () => import('./ngstarter-ui-components-content-editor-embed-block-DhFxtMQS.mjs').then(c => c.EmbedBlock),
2539
+ component: () => import('./ngstarter-ui-components-content-editor-embed-block-CmhzpaRk.mjs').then(c => c.EmbedBlock),
1719
2540
  type: 'embed',
1720
2541
  options: {},
1721
2542
  empty: () => {
@@ -1901,33 +2722,67 @@ class ContentBuilderComponent {
1901
2722
  };
1902
2723
  }
1903
2724
  // Build helper maps: component map and merged options map
2725
+ insertionSuggestions = computed(() => {
2726
+ const config = mergeContentEditorConfig(this.globalConfig, this.config());
2727
+ const custom = Object.entries(config.blocks ?? {}).flatMap(([type, definition]) => definition.menu ? [{
2728
+ type: 'item', title: definition.menu.title, description: definition.menu.description ?? '',
2729
+ iconName: definition.menu.iconName ?? 'fluent:document-24-regular', blockType: type,
2730
+ blockSettings: definition.menu.settings ?? {}, hotKeys: ''
2731
+ }] : []);
2732
+ const replaced = new Set(custom.map(item => item.blockType));
2733
+ return [...this.suggestions().filter((item) => !replaced.has(item.blockType)), ...custom];
2734
+ }, /* @ts-ignore */
2735
+ ...(ngDevMode ? [{ debugName: "insertionSuggestions" }] : /* istanbul ignore next */ []));
2736
+ componentSources = new Map();
1904
2737
  buildBlockDefMaps() {
1905
2738
  const overrides = this.options() || {};
1906
2739
  const config = mergeContentEditorConfig(this.globalConfig, this.config());
1907
2740
  this.blockDefsOptionsMap = new Map();
1908
- this.blockDefs().forEach((def) => {
1909
- if (!this.blockDefsMap.has(def.type)) {
2741
+ const definitions = new Map(this.blockDefs().map(def => [def.type, def]));
2742
+ for (const [type, block] of Object.entries(config.blocks ?? {})) {
2743
+ const previous = definitions.get(type);
2744
+ if (!previous && !(block.editor || block.loadEditor))
2745
+ continue;
2746
+ const component = block.loadEditor ?? (block.editor ? () => Promise.resolve(block.editor) : previous.component);
2747
+ definitions.set(type, { ...previous, type, component,
2748
+ empty: block.create ? () => {
2749
+ const initial = block.create();
2750
+ return { content: initial.content, settings: initial.attrs?.['settings'] ?? {}, props: initial.attrs?.['props'] ?? [], attrs: initial.attrs };
2751
+ } : previous?.empty ?? (() => ({ content: null, settings: {} })),
2752
+ toHtml: block.toHtml ?? previous?.toHtml, options: previous?.options ?? {} });
2753
+ const source = block.loadEditor ?? block.editor ?? previous?.component;
2754
+ if (this.componentSources.get(type) !== source)
2755
+ this.blockDefsMap.delete(type);
2756
+ this.componentSources.set(type, source);
2757
+ }
2758
+ for (const type of this.blockDefsMap.keys())
2759
+ if (!definitions.has(type))
2760
+ this.blockDefsMap.delete(type);
2761
+ definitions.forEach(def => {
2762
+ const configured = config.blocks?.[def.type];
2763
+ const source = configured?.loadEditor ?? configured?.editor ?? def.component;
2764
+ if (this.componentSources.get(def.type) !== source)
2765
+ this.blockDefsMap.delete(def.type);
2766
+ this.componentSources.set(def.type, source);
2767
+ if (!this.blockDefsMap.has(def.type))
1910
2768
  this.blockDefsMap.set(def.type, def.component());
1911
- }
1912
- const merged = {
1913
- ...(def.options || {}),
1914
- toHtml: def.toHtml,
1915
- ...config.blocks?.[def.type]?.options,
1916
- ...(config.blocks?.[def.type]?.toHtml ? { toHtml: config.blocks[def.type].toHtml } : {}),
1917
- ...(overrides[def.type] || {})
1918
- };
1919
- this.blockDefsOptionsMap.set(def.type, merged);
2769
+ this.blockDefsOptionsMap.set(def.type, { ...def.options, toHtml: def.toHtml,
2770
+ ...config.blocks?.[def.type]?.options, ...(overrides[def.type] || {}) });
1920
2771
  });
2772
+ this.resolvedBlockDefs = definitions;
1921
2773
  }
2774
+ resolvedBlockDefs = new Map();
1922
2775
  /** Shared by nested block collections; all edits use this root editor. */
1923
2776
  get rootBuilder() { return this; }
1924
2777
  getBlockComponent(type) { return this.blockDefsMap.get(type); }
1925
2778
  createBlockView(type, settings = {}, content) { return this._createBlock(type, settings, content); }
1926
2779
  getBlockDefOption(type, key) {
1927
- return this.blockDefsOptionsMap.get(type)[key];
2780
+ return this.blockDefsOptionsMap.get(type)?.[key];
1928
2781
  }
1929
2782
  ngOnInit() {
1930
2783
  this.lastInput = this.content();
2784
+ this.buildBlockDefMaps();
2785
+ this.configureDraft();
1931
2786
  const document = this._getDraftContent() ?? this.lastInput;
1932
2787
  const last = document.blocks.at(-1);
1933
2788
  const blocks = last && (last.type !== 'paragraph' || contentEditorText(last.content).length > 0)
@@ -1941,6 +2796,7 @@ class ContentBuilderComponent {
1941
2796
  }
1942
2797
  }
1943
2798
  constructor() {
2799
+ inject(DestroyRef).onDestroy(() => this.drafts.flush());
1944
2800
  effect(() => {
1945
2801
  this.config();
1946
2802
  this.options();
@@ -1949,10 +2805,18 @@ class ContentBuilderComponent {
1949
2805
  });
1950
2806
  effect(() => {
1951
2807
  const value = this.content();
2808
+ this.documentId();
2809
+ this.persistDraft();
2810
+ this.draftDebounceMs();
2811
+ this.config();
1952
2812
  untracked(() => {
1953
- if (this.loaded && value !== this.lastInput) {
2813
+ if (!this.loaded)
2814
+ return;
2815
+ const previousKey = this.draftKey;
2816
+ this.configureDraft();
2817
+ if (value !== this.lastInput || previousKey !== this.draftKey) {
1954
2818
  this.lastInput = value;
1955
- this._store.setBlocks(value);
2819
+ this._store.setBlocks(previousKey !== this.draftKey ? this._getDraftContent() ?? value : value);
1956
2820
  }
1957
2821
  });
1958
2822
  });
@@ -2092,7 +2956,9 @@ class ContentBuilderComponent {
2092
2956
  return this.editor.document().blocks.find(block => block.id === newBlock.id);
2093
2957
  }
2094
2958
  _createBlock(type, settings = {}, content) {
2095
- const blockDef = this.blockDefs().find(blockDefItem => blockDefItem.type === type);
2959
+ const blockDef = this.resolvedBlockDefs.get(type) ?? this.blockDefs().find(item => item.type === type);
2960
+ if (!blockDef)
2961
+ throw new Error(`No Content Editor definition for "${type}"`);
2096
2962
  const empty = blockDef.empty();
2097
2963
  if (settings) {
2098
2964
  empty.settings = {
@@ -2121,6 +2987,45 @@ class ContentBuilderComponent {
2121
2987
  }
2122
2988
  this.insertBlock(type, index, options);
2123
2989
  }
2990
+ canConvertBlock(id) {
2991
+ const block = findContentEditorBlock(this.editor.document().blocks, id);
2992
+ return !!block && this.conversionTypes.includes(block.type) && !this.editor.readOnly();
2993
+ }
2994
+ convertBlock(id, type, settings = {}) {
2995
+ if (!this.canConvertBlock(id))
2996
+ return false;
2997
+ const regions = Array.from(this.elRef.nativeElement.querySelectorAll('.ngs-content-editor-content-editable'));
2998
+ const activeElement = regions.find(element => element.closest('[data-block-id]')?.getAttribute('data-block-id') === id && ContentEditorContentEditableDirective.forElement(element)?.region.active());
2999
+ const region = ContentEditorContentEditableDirective.forElement(activeElement ?? null);
3000
+ let selection = region?.region.editor.selection();
3001
+ const source = findContentEditorBlock(this.editor.document().blocks, id);
3002
+ if (selection && source.type === 'quote' && type !== 'quote' && activeElement?.classList.contains('caption')) {
3003
+ const quote = source.content;
3004
+ const caption = contentEditorText(quote.caption?.content);
3005
+ const text = contentEditorText(quote.cite.content) + (caption ? '\n' + caption : '');
3006
+ const shift = contentEditorText(quote.cite.content).length + (caption ? 1 : 0);
3007
+ const lines = text.split('\n');
3008
+ const point = (value) => {
3009
+ const regionLines = region.region.editor.document().blocks;
3010
+ const index = regionLines.findIndex(line => line.id === value.blockId);
3011
+ let offset = shift + regionLines.slice(0, index).reduce((sum, line) => sum + contentEditorText(line.content).length + 1, 0) + value.offset;
3012
+ let line = 0;
3013
+ while (line < lines.length - 1 && offset > lines[line].length) {
3014
+ offset -= lines[line].length + 1;
3015
+ line++;
3016
+ }
3017
+ return { blockId: `line-${line}`, offset };
3018
+ };
3019
+ selection = { anchor: point(selection.anchor), focus: point(selection.focus) };
3020
+ }
3021
+ const blocks = cloneContentEditorValue([...this.editor.document().blocks]);
3022
+ const block = findContentEditorBlock(blocks, id);
3023
+ Object.assign(block, contentEditorConvertBlock(block, type, settings));
3024
+ this.editor.updateDocument({ version: 1, blocks });
3025
+ if (selection)
3026
+ this._store.restoreTextSelection.set({ blockId: id, selection });
3027
+ return true;
3028
+ }
2124
3029
  duplicateBlock(blockId) {
2125
3030
  const index = this._content().findIndex(dataBlock => dataBlock.id === blockId);
2126
3031
  if (index === -1) {
@@ -2251,6 +3156,96 @@ class ContentBuilderComponent {
2251
3156
  getData() {
2252
3157
  return this.editor.document();
2253
3158
  }
3159
+ /** Structural HTML paste splits the active text block without flattening lists/tables. */
3160
+ pasteBlocksAtSelection(id, imported, start, end) {
3161
+ if (this.editor.readOnly() || !imported.blocks.length)
3162
+ return false;
3163
+ const blocks = cloneContentEditorValue([...this.editor.document().blocks]);
3164
+ const source = findContentEditorBlock(blocks, id);
3165
+ const scope = contentEditorBlockScope(blocks, id) ?? this._store.insertionTarget().scope;
3166
+ if (!source) {
3167
+ // The empty nested paragraph is a UI placeholder until its first edit.
3168
+ const collection = contentEditorCollection(blocks, scope);
3169
+ if (collection.length)
3170
+ return false;
3171
+ this.applyImport(imported, { mode: 'insert', target: { scope } });
3172
+ return true;
3173
+ }
3174
+ if (!['paragraph', 'heading'].includes(source.type))
3175
+ return false;
3176
+ const text = source.content;
3177
+ const before = contentEditorSliceText(text, 0, Math.min(start, end));
3178
+ const after = contentEditorSliceText(text, Math.max(start, end));
3179
+ const insertion = contentEditorCopyBlocks(imported.blocks);
3180
+ if (contentEditorText(before)) {
3181
+ if (source.type === 'paragraph' && insertion[0].type === 'paragraph')
3182
+ insertion[0] = {
3183
+ ...source, content: [...before, ...insertion[0].content]
3184
+ };
3185
+ else
3186
+ insertion.unshift({ ...source, content: before });
3187
+ }
3188
+ const last = insertion.at(-1);
3189
+ const textLast = ['paragraph', 'heading'].includes(last.type);
3190
+ const caretLines = textLast ? contentEditorText(last.content).split('\n') : [''];
3191
+ const caretPoint = { blockId: `line-${caretLines.length - 1}`, offset: caretLines.at(-1).length };
3192
+ if (textLast)
3193
+ insertion[insertion.length - 1] = { ...last, content: [...last.content, ...after] };
3194
+ else if (contentEditorText(after))
3195
+ insertion.push({ id: v7(), type: 'paragraph', content: after, attrs: { props: source.attrs?.['props'] ?? [] } });
3196
+ const items = [...contentEditorCollection(blocks, scope)];
3197
+ items.splice(items.findIndex(block => block.id === id), 1, ...insertion);
3198
+ replaceContentEditorCollection(blocks, scope, items);
3199
+ this.editor.updateDocument({ version: 1, blocks });
3200
+ if (textLast)
3201
+ this._store.restoreTextSelection.set({ blockId: last.id, selection: { anchor: caretPoint, focus: caretPoint } });
3202
+ return true;
3203
+ }
3204
+ /** Validates before replacing the document. Import is one undoable edit. */
3205
+ importJson(source, config = {}, options = {}) {
3206
+ return this.applyImport(this.importer.fromJson(source, mergeContentEditorConfig(this.config(), config), options), options);
3207
+ }
3208
+ importHtml(html, config = {}, options = {}) {
3209
+ return this.applyImport(this.importer.fromHtml(html, mergeContentEditorConfig(this.config(), config), options), options);
3210
+ }
3211
+ getInsertionTarget() {
3212
+ const saved = this._store.insertionTarget();
3213
+ const id = saved.afterId ?? this._store.activeBlockId() ?? this._store.focusedBlockId();
3214
+ const scope = id ? contentEditorBlockScope(this.editor.document().blocks, id) : null;
3215
+ if (scope)
3216
+ return { scope, afterId: id };
3217
+ return { scope: saved.scope };
3218
+ }
3219
+ applyImport(document, placement = {}) {
3220
+ if (!this.loaded)
3221
+ throw new ContentEditorImportError('$editor', 'Initialize the builder before importing');
3222
+ if (this.editor.readOnly())
3223
+ throw new ContentEditorImportError('$editor', 'Cannot import into a read-only editor');
3224
+ if (placement.mode === 'insert') {
3225
+ const target = placement.target ?? this.getInsertionTarget();
3226
+ const blocks = cloneContentEditorValue([...this.editor.document().blocks]);
3227
+ if (target.scope.parentId) {
3228
+ const parent = findContentEditorBlock(blocks, target.scope.parentId);
3229
+ if (!parent || !['toggle', 'grid'].includes(parent.type) ||
3230
+ (parent.type === 'grid' && !parent.content.cells.some((cell) => cell.id === target.scope.cellId))) {
3231
+ throw new ContentEditorImportError('$target.scope', 'Insertion collection does not exist');
3232
+ }
3233
+ }
3234
+ const items = [...contentEditorCollection(blocks, target.scope)];
3235
+ const index = target.afterId ? items.findIndex(block => block.id === target.afterId) : items.length - 1;
3236
+ if (target.afterId && index < 0)
3237
+ throw new ContentEditorImportError('$target.afterId', 'Insertion block does not exist in this collection');
3238
+ items.splice(index + 1, 0, ...contentEditorCopyBlocks(document.blocks));
3239
+ replaceContentEditorCollection(blocks, target.scope, items);
3240
+ this.editor.updateDocument({ version: 1, blocks });
3241
+ }
3242
+ else
3243
+ this.editor.updateDocument(document);
3244
+ this.selectedBlocksModel.clear();
3245
+ this._store.setFocusedBlockId(null);
3246
+ this._store.setActiveBlockId(null);
3247
+ return this.getData();
3248
+ }
2254
3249
  /** Exports the live document, including nested blocks, through the configured converters. */
2255
3250
  toHtml(config = {}) {
2256
3251
  const defaults = { blocks: Object.fromEntries(this.blockDefs().map(def => [def.type, { toHtml: def.toHtml }])) };
@@ -2297,9 +3292,7 @@ class ContentBuilderComponent {
2297
3292
  .map(id => ({ id, index: this._content().findIndex(b => b.id === id) }))
2298
3293
  .filter(x => x.index !== -1)
2299
3294
  .sort((a, b) => b.index - a.index);
2300
- for (const item of toDelete) {
2301
- this.deleteBlock(item.id);
2302
- }
3295
+ this._store.deleteBlocks(toDelete.map(item => item.id));
2303
3296
  this.unselectSelectedBlocks();
2304
3297
  });
2305
3298
  }
@@ -2388,36 +3381,23 @@ class ContentBuilderComponent {
2388
3381
  }
2389
3382
  this._scroll$ = null;
2390
3383
  }
2391
- _getDraftContent() {
2392
- if (!this._canUseDraftStorage()) {
2393
- return null;
2394
- }
2395
- try {
2396
- const draft = localStorage.getItem(this._getDraftStorageKey());
2397
- if (!draft) {
2398
- return null;
2399
- }
2400
- const content = JSON.parse(draft);
2401
- return content?.version === 1 && Array.isArray(content.blocks) ? content : null;
2402
- }
2403
- catch {
2404
- return null;
2405
- }
2406
- }
2407
- _saveDraft(content) {
2408
- if (!this._canUseDraftStorage()) {
2409
- return;
2410
- }
2411
- try {
2412
- localStorage.setItem(this._getDraftStorageKey(), JSON.stringify(content));
2413
- }
2414
- catch {
2415
- }
3384
+ configureDraft() {
3385
+ this.draftKey = this._getDraftStorageKey();
3386
+ const config = mergeContentEditorConfig(this.globalConfig, this.config()).draft;
3387
+ this.drafts.configure(this.draftKey, this._canUseDraftStorage(), {
3388
+ ...config, ...(this.draftDebounceMs() === undefined ? {} : { debounceMs: this.draftDebounceMs() })
3389
+ });
2416
3390
  }
2417
- _canUseDraftStorage() {
2418
- return !isPlatformServer(this._platformId) && this.persistDraft();
3391
+ _getDraftContent() {
3392
+ return this.drafts.read(source => this.importer.fromJson(source, this.config()));
2419
3393
  }
3394
+ _saveDraft(content) { this.drafts.schedule(content); }
3395
+ saveDraftNow() { this.drafts.schedule(this.getData()); this.drafts.flush(); }
3396
+ clearDraft() { this.drafts.clear(); }
3397
+ _canUseDraftStorage() { return !isPlatformServer(this._platformId) && this.persistDraft(); }
2420
3398
  _getDraftStorageKey(prefix = ContentBuilderComponent.DRAFT_STORAGE_PREFIX) {
3399
+ if (this.documentId()?.trim())
3400
+ return `${prefix}:document:${encodeURIComponent(this.documentId())}`;
2421
3401
  const elementId = this.elRef.nativeElement.id;
2422
3402
  const locationKey = typeof window === 'undefined'
2423
3403
  ? 'server'
@@ -2461,7 +3441,13 @@ class ContentBuilderComponent {
2461
3441
  }
2462
3442
  }
2463
3443
  if (html) {
2464
- this._handleHtmlPaste(html, index);
3444
+ try {
3445
+ this._handleHtmlPaste(html, index);
3446
+ }
3447
+ catch {
3448
+ if (text)
3449
+ this._handleTextPaste(text, index);
3450
+ }
2465
3451
  }
2466
3452
  else if (text) {
2467
3453
  this._handleTextPaste(text, index);
@@ -2487,118 +3473,20 @@ class ContentBuilderComponent {
2487
3473
  }
2488
3474
  }
2489
3475
  _handleHtmlPaste(html, index) {
2490
- const body = this.document.createElement('div');
2491
- body.innerHTML = html;
2492
- let currentIndex = index;
2493
- Array.from(body.children).forEach(node => {
2494
- const block = this._mapNodeToBlock(node);
2495
- if (block) {
2496
- this.insertBlock(block.type, currentIndex, block.settings, false, block.content);
2497
- currentIndex++;
2498
- }
2499
- });
2500
- }
2501
- _mapNodeToBlock(node) {
2502
- const tag = node.tagName.toLowerCase();
2503
- switch (tag) {
2504
- case 'h1':
2505
- case 'h2':
2506
- case 'h3':
2507
- case 'h4':
2508
- case 'h5':
2509
- case 'h6':
2510
- return {
2511
- type: 'heading',
2512
- settings: { level: parseInt(tag.substring(1)) },
2513
- content: readNgsHeadlessEditorInlineContent(node, this.editor, { lineBreaks: true })
2514
- };
2515
- case 'p':
2516
- return {
2517
- type: 'paragraph',
2518
- settings: {},
2519
- content: readNgsHeadlessEditorInlineContent(node, this.editor, { lineBreaks: true })
2520
- };
2521
- case 'ul':
2522
- return {
2523
- type: 'bulletList',
2524
- settings: { listStyle: 'bullet' },
2525
- content: this._mapListItems(node)
2526
- };
2527
- case 'ol':
2528
- return {
2529
- type: 'orderedList',
2530
- settings: { listStyle: 'ordered' },
2531
- content: this._mapListItems(node)
2532
- };
2533
- case 'img':
2534
- return {
2535
- type: 'image',
2536
- settings: {},
2537
- content: {
2538
- src: node.getAttribute('src') || '',
2539
- alt: node.getAttribute('alt') || ''
2540
- }
2541
- };
2542
- case 'video':
2543
- return {
2544
- type: 'video',
2545
- settings: {},
2546
- content: {
2547
- src: node.getAttribute('src') || '',
2548
- caption: node.getAttribute('title') || ''
2549
- }
2550
- };
2551
- case 'blockquote':
2552
- return {
2553
- type: 'quote',
2554
- settings: {},
2555
- content: { cite: { content: readNgsHeadlessEditorInlineContent(node, this.editor, { lineBreaks: true }), props: [] }, caption: { content: [], props: [] } }
2556
- };
2557
- case 'pre':
2558
- const codeNode = node.querySelector('code');
2559
- const content = (codeNode || node).textContent || '';
2560
- return {
2561
- type: 'code',
2562
- settings: { language: 'none' },
2563
- content: [createNgsHeadlessEditorText(content.replace(/\r\n?/g, '\n').trimEnd())]
2564
- };
2565
- case 'hr':
2566
- return {
2567
- type: 'divider',
2568
- settings: {}
2569
- };
2570
- default:
2571
- if (node.textContent?.trim()) {
2572
- return {
2573
- type: 'paragraph',
2574
- settings: {},
2575
- content: readNgsHeadlessEditorInlineContent(node, this.editor, { lineBreaks: true })
2576
- };
2577
- }
2578
- return null;
2579
- }
2580
- }
2581
- _mapListItems(node) {
2582
- return Array.from(node.children)
2583
- .filter(child => child.tagName.toLowerCase() === 'li')
2584
- .map(li => {
2585
- const inline = li.cloneNode(true);
2586
- const nested = Array.from(inline.children).filter(child => ['ul', 'ol'].includes(child.tagName.toLowerCase()));
2587
- const children = nested.flatMap(list => this._mapListItems(list));
2588
- nested.forEach(list => list.remove());
2589
- return { content: readNgsHeadlessEditorInlineContent(inline, this.editor, { lineBreaks: true }), props: [], children };
2590
- });
3476
+ const afterId = this.editor.document().blocks[index - 1]?.id;
3477
+ this.importHtml(html, {}, { mode: 'insert', target: { scope: {}, afterId } });
2591
3478
  }
2592
3479
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentBuilderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2593
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentBuilderComponent, isStandalone: true, selector: "ngs-content-editor-builder", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, contentChangedDelay: { classPropertyName: "contentChangedDelay", publicName: "contentChangedDelay", isSignal: true, isRequired: false, transformFunction: null }, persistDraft: { classPropertyName: "persistDraft", publicName: "persistDraft", isSignal: true, isRequired: false, transformFunction: null }, suggestions: { classPropertyName: "suggestions", publicName: "suggestions", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, scrollContainer: { classPropertyName: "scrollContainer", publicName: "scrollContainer", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { contentChanged: "contentChanged" }, host: { attributes: { "tabindex": "0" }, listeners: { "paste": "_onPaste($event)", "keydown": "_onKeyDown($event)" }, properties: { "class.is-block-dragging": "_blockDragging()", "class.is-selection-of-blocks-active": "isSelectionOfBlocksActive()", "class.select-none": "isSelectionOfBlocksActive()", "style.user-select": "isSelectionOfBlocksActive() ? \"none\" : null" }, classAttribute: "ngs-content-editor-builder" }, providers: [
3480
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentBuilderComponent, isStandalone: true, selector: "ngs-content-editor-builder", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null }, documentId: { classPropertyName: "documentId", publicName: "documentId", isSignal: true, isRequired: false, transformFunction: null }, draftDebounceMs: { classPropertyName: "draftDebounceMs", publicName: "draftDebounceMs", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, contentChangedDelay: { classPropertyName: "contentChangedDelay", publicName: "contentChangedDelay", isSignal: true, isRequired: false, transformFunction: null }, persistDraft: { classPropertyName: "persistDraft", publicName: "persistDraft", isSignal: true, isRequired: false, transformFunction: null }, suggestions: { classPropertyName: "suggestions", publicName: "suggestions", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, scrollContainer: { classPropertyName: "scrollContainer", publicName: "scrollContainer", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { contentChanged: "contentChanged" }, host: { attributes: { "tabindex": "0" }, listeners: { "paste": "_onPaste($event)", "keydown": "_onKeyDown($event)" }, properties: { "class.is-block-dragging": "_blockDragging()", "class.is-selection-of-blocks-active": "isSelectionOfBlocksActive()", "class.select-none": "isSelectionOfBlocksActive()", "style.user-select": "isSelectionOfBlocksActive() ? \"none\" : null" }, classAttribute: "ngs-content-editor-builder" }, providers: [
2594
3481
  provideContentEditor(),
2595
3482
  ContentEditorHtmlSerializer,
3483
+ ContentEditorImporter,
2596
3484
  ContentBuilderStore,
2597
3485
  {
2598
3486
  provide: CONTENT_BUILDER,
2599
3487
  useExisting: forwardRef(() => ContentBuilderComponent)
2600
3488
  }
2601
- ], viewQueries: [{ propertyName: "blockMenu", first: true, predicate: ["suggestionsMenu"], descendants: true, isSignal: true }, { propertyName: "dropList", first: true, predicate: CdkDropList, descendants: true, isSignal: true }], exportAs: ["ngsContentEditorBuilder"], hostDirectives: [{ directive: BlockSelectionDirective, inputs: ["autoScrollContainerSelector", "autoScrollContainerSelector"] }], ngImport: i0, template: "<div class=\"container py-4\">\n <div class=\"content\"\n cdkDropList\n [cdkDropListData]=\"{}\"\n [cdkDropListConnectedTo]=\"connectedDropLists()\"\n [cdkDropListEnterPredicate]=\"canEnterRoot\"\n ngsTextSelectionPopup\n closestContentObserverClass=\"ngs-content-editor-content-editable\"\n [targetComponent]=\"commandBar\"\n (tagSelected)=\"onTagSelected($event)\"\n (cdkDropListDropped)=\"drop($event)\">\n @for (contentBlock of _content(); track contentBlock.id) {\n <div class=\"block\"\n [attr.data-block-id]=\"contentBlock.id\"\n [class.is-focused]=\"isBlockFocused(contentBlock.id)\"\n [class.is-active]=\"isActiveBlock(contentBlock.id)\"\n cdkDrag\n [cdkDragData]=\"contentBlock.id\"\n cdkMonitorSubtreeFocus\n (cdkDragStarted)=\"onDragStarted($event, contentBlock)\"\n (cdkDragEnded)=\"onDragEnded($event, contentBlock)\"\n (cdkFocusChange)=\"onFocusChange($event, contentBlock)\">\n <div class=\"block-controls\" [class.is-settings-popover-open]=\"settingsTrigger.api.isOpen()\">\n <button class=\"block-control\" aria-label=\"Add block\"\n (mousedown)=\"setActiveBlockId($event, contentBlock.id)\"\n [ngsMenuTriggerFor]=\"suggestionsMenu\"\n [ngsMenuTriggerData]=\"{target: {scope: {}, afterId: contentBlock.id}}\"\n [ngsMenuTriggerRestoreFocus]=\"false\">\n <ngs-icon name=\"fluent:add-24-regular\"/>\n </button>\n <div class=\"block-control block-control-drag\"\n (click)=\"selectBlock(contentBlock.id)\"\n [ngsPopoverTriggerFor]=\"settingsPopover\"\n (closed)=\"onSettingsPopoverClose()\"\n #settingsTrigger=\"ngsPopoverTriggerFor\"\n hasBackdrop\n position=\"before-center\">\n <button cdkDragHandle\n trigger=\"hover\"\n closeOnOriginClick\n closeOnOriginMouseLeave\n #dragTrigger=\"ngsPopoverTriggerFor\"\n [ngsPopoverTriggerFor]=\"dragControlTooltip\"\n position=\"below-center\"\n (mousedown)=\"dragTrigger.api.close()\"\n delay=\"1000\" class=\"w-full h-full flex items-center justify-center\">\n <ngs-icon name=\"fluent:re-order-dots-vertical-24-regular\"/>\n </button>\n </div>\n <ng-template #dragControlTooltip>\n <div class=\"bg-neutral-900 text-xs flex flex-col gap-0.5 rounded-lg items-center px-2 py-1.5 font-medium\">\n <div>\n <div class=\"text-neutral-100\">Drag <span class=\"text-neutral-400\">to move</span></div>\n </div>\n <div>\n <div class=\"text-neutral-100\">Click <span class=\"text-neutral-400\">to open menu</span></div>\n </div>\n </div>\n </ng-template>\n </div>\n <div class=\"block-content\" [class.is-selected]=\"isBlockSelected(contentBlock.id)\">\n <div class=\"drag-placeholder\" *cdkDragPlaceholder></div>\n <ng-container [ngComponentOutlet]=\"blockDefsMap.get(contentBlock.type) | async\"\n [ngComponentOutletInputs]=\"{\n id: contentBlock.id,\n content: contentBlock.content,\n settings: contentBlock.settings,\n props: contentBlock.props,\n index: $index\n }\"/>\n </div>\n </div>\n }\n </div>\n</div>\n\n<ngs-popover #settingsPopover=\"ngsPopover\">\n <div class=\"px-2 py-0 w-72 settings-popover\">\n <ngs-list>\n <ngs-list-item (click)=\"duplicateSelectedBlocks(settingsPopover)\">\n <ngs-icon name=\"fluent:copy-24-regular\" ngsListItemIcon/>\n <div ngsListItemTitle>Duplicate</div>\n </ngs-list-item>\n <ngs-list-item (click)=\"deleteSelectedBlocks(settingsPopover)\">\n <ngs-icon name=\"fluent:delete-24-regular\" ngsListItemIcon/>\n <div ngsListItemTitle>Delete</div>\n </ngs-list-item>\n </ngs-list>\n </div>\n</ngs-popover>\n\n<ngs-menu #suggestionsMenu=\"ngsMenu\" classList=\"min-h-[70vh] max-h-[70vh]!\" pushIntoViewport (closed)=\"onSuggestionsMenuClose($event)\">\n <ng-template ngsMenuContent let-target=\"target\">\n <div (click)=\"preventMenuClose($event)\">\n @for (suggestionItem of suggestions(); track $index; let first = $first) {\n @switch (suggestionItem.type) {\n @case ('heading') {\n <ngs-menu-heading>{{ suggestionItem.title }}</ngs-menu-heading>\n }\n @case ('item') {\n <button ngs-menu-item\n (click)=\"addBlockFromSuggestionMenu(suggestionsMenu, target, suggestionItem.blockType, suggestionItem.blockSettings)\">\n <div class=\"h-full flex items-center gap-3 py-2\">\n <div class=\"size-9 flex items-center rounded-lg justify-center bg-surface-container\">\n <ngs-icon [name]=\"suggestionItem.iconName\" class=\"!me-0\"/>\n </div>\n <div class=\"grow min-w-[200px]\">\n <div>{{ suggestionItem.title }}</div>\n <div class=\"text-2xs text-neutral-600\">{{ suggestionItem.description }}</div>\n </div>\n @if (suggestionItem.hotKeys) {\n <div class=\"ms-auto bg-surface-container-highest rounded-full h-5\n text-4xs px-2 flex items-center font-bold\">{{ suggestionItem.hotKeys }}</div>\n }\n </div>\n </button>\n }\n }\n }\n </div>\n </ng-template>\n</ngs-menu>\n", styles: [":host{--ngs-content-editor-builder-content-width: 704px;outline:none}:host.is-block-dragging{cursor:grabbing}:host .container{display:flex;width:100%;max-width:820px;min-height:200px;height:100%;padding:calc(var(--spacing, .25rem) * 5) calc(var(--spacing, .25rem) * 5) calc(var(--spacing, .25rem) * 5) 0;margin:0 auto;outline:none}:host .content{flex-grow:1;width:100%;min-width:0}:host .block{position:relative;flex:none;padding:var(--spacing, .25rem) 0;display:flex;align-items:center}:host .block:not(:has(.block-content.is-selected)):hover .block-content{background:var(--ngs-color-neutral-50)}:host:not(.is-block-dragging) .block:hover .block-controls,:host:not(.is-block-dragging) .block.is-active .block-controls{opacity:1}:host .block-content{position:relative;flex-grow:1;min-width:0;padding:calc(var(--spacing, .25rem) * 3)}:host .block-content.is-selected{background:var(--ngs-color-primary-100)}:host ::ng-deep .selection-area{background:var(--ngs-color-primary-100);opacity:.4;border:1px solid var(--ngs-color-primary);border-radius:var(--ngs-radius-sm)}:host ::ng-deep .ngs-content-editor-content-editable{-webkit-user-select:text;user-select:text}:host ::ng-deep .ngs-content-editor-content-editable a[data-ngs-headless-editor-mark=link]{color:var(--ngs-color-primary);text-decoration:underline;text-underline-offset:.15em}:host ::ng-deep .ngs-content-editor-content-editable.align-center{text-align:center}:host ::ng-deep .ngs-content-editor-content-editable.align-right{text-align:right}:host ::ng-deep .ngs-content-editor-content-editable.align-justify{text-align:justify}:host ::ng-deep .ngs-content-editor-content-editable>p{margin:0}:host ::ng-deep .ngs-content-editor-content-editable[data-empty]:before{content:attr(data-empty-placeholder);display:block;height:0;color:var(--ngs-color-neutral-500);pointer-events:none}:host.select-none ::ng-deep .ngs-content-editor-content-editable,:host.is-selection-of-blocks-active ::ng-deep .ngs-content-editor-content-editable{-webkit-user-select:none!important;user-select:none!important}:host .block-controls{left:0;display:flex;align-items:center;color:var(--ngs-color-neutral-500);width:calc(var(--spacing, .25rem) * 18);padding:0 calc(var(--spacing, .25rem) * 2);opacity:0;flex:none}:host .block-controls.is-settings-popover-open{opacity:1}:host .block-controls.is-settings-popover-open .block-control:not(.block-control-drag){opacity:0}:host .block-control{cursor:pointer;width:calc(var(--spacing, .25rem) * 7);height:calc(var(--spacing, .25rem) * 7);flex:none;border-radius:var(--ngs-radius-lg);display:inline-flex;align-items:center;justify-content:center}:host .block-control:hover{background:var(--ngs-color-surface-container-low);color:var(--ngs-color-on-surface)}:host .block-control-drag button{cursor:grab}:host .drag-placeholder{height:calc(var(--spacing, .25rem) * 8);flex:none;position:relative}:host .drag-placeholder:before{position:absolute;left:calc(var(--spacing, .25rem) * 18);display:block;right:0;content:\"\";height:calc(var(--spacing, .25rem) * 2);top:50%;transform:translateY(-50%);background:var(--ngs-color-primary-300);border-radius:calc(var(--spacing, .25rem) * .5)}:host ::ng-deep code{color:var(--ngs-color-primary)}.cdk-drag.cdk-drag-preview{overflow:hidden;display:flex;align-items:center;color:var(--ngs-color-neutral-500);width:calc(var(--spacing, .25rem) * 18);padding:0 calc(var(--spacing, .25rem) * 2)}.cdk-drag.cdk-drag-preview .block-control{width:calc(var(--spacing, .25rem) * 7);height:calc(var(--spacing, .25rem) * 7);flex:none;border-radius:var(--ngs-radius-lg);display:inline-flex;align-items:center;justify-content:center;cursor:grabbing}.cdk-drag.cdk-drag-preview .block-control:first-child{opacity:0}.cdk-drag.cdk-drag-preview .block-control:last-child{color:var(--ngs-color-on-surface)}.cdk-drag.cdk-drag-preview .block-content{opacity:0}.settings-popover{--ngs-list-list-item-one-line-container-height: calc(var(--spacing, .25rem) * 10)}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "component", type: Icon, selector: "ngs-icon", inputs: ["name"], exportAs: ["ngsIcon"] }, { kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }, { kind: "directive", type: CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer", "cdkDropListHasAnchor"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { kind: "directive", type: CdkDragPlaceholder, selector: "ng-template[cdkDragPlaceholder]", inputs: ["data"] }, { kind: "component", type: Menu, selector: "ngs-menu", inputs: ["role", "classList", "xPosition", "yPosition", "pushIntoViewport"], outputs: ["closed"], exportAs: ["ngsMenu"] }, { kind: "component", type: MenuItem, selector: "ngs-menu-item, [ngs-menu-item]", inputs: ["disabled", "role", "selected"], outputs: ["_triggered"], exportAs: ["ngsMenuItem"] }, { kind: "directive", type: MenuTrigger, selector: "[ngsMenuTriggerFor]", inputs: ["ngsMenuTriggerFor", "ngsMenuTriggerData", "ngsMenuDisabled", "xPosition", "yPosition", "ngsMenuTriggerRestoreFocus"], outputs: ["menuOpened", "menuClosed"], exportAs: ["ngsMenuTrigger"] }, { kind: "directive", type: CdkMonitorFocus, selector: "[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]", outputs: ["cdkFocusChange"], exportAs: ["cdkMonitorFocus"] }, { kind: "directive", type: TextSelectionPopupDirective, selector: "[ngsTextSelectionPopup]", inputs: ["targetComponent", "closestContentObserverClass"], outputs: ["tagSelected"] }, { kind: "directive", type: PopoverTriggerForDirective, selector: "[ngsPopoverTriggerFor]", inputs: ["ngsPopoverTriggerFor", "ngsPopoverContext", "trigger", "position", "delay", "origin", "closeOnOriginClick", "closeOnOriginMouseLeave", "hasBackdrop"], outputs: ["opened", "closed"], exportAs: ["ngsPopoverTriggerFor"] }, { kind: "component", type: Popover, selector: "ngs-popover", exportAs: ["ngsPopover"] }, { kind: "directive", type: ListItemTitle, selector: "[ngsListItemTitle]" }, { kind: "directive", type: ListItemIcon, selector: "[ngsListItemIcon]" }, { kind: "component", type: ListItem, selector: "ngs-list-item, a[ngs-list-item], button[ngs-list-item]", inputs: ["disabled", "lines"], exportAs: ["ngsListItem"] }, { kind: "component", type: List, selector: "ngs-list", inputs: ["disabled", "disableRipple"], exportAs: ["ngsList"] }, { kind: "component", type: MenuHeading, selector: "ngs-menu-heading" }, { kind: "directive", type: MenuContent, selector: "[ngsMenuContent]" }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
3489
+ ], viewQueries: [{ propertyName: "conversionMenu", first: true, predicate: ["conversionMenu"], descendants: true, isSignal: true }, { propertyName: "blockMenu", first: true, predicate: ["suggestionsMenu"], descendants: true, isSignal: true }, { propertyName: "dropList", first: true, predicate: CdkDropList, descendants: true, isSignal: true }], exportAs: ["ngsContentEditorBuilder"], hostDirectives: [{ directive: BlockSelectionDirective, inputs: ["autoScrollContainerSelector", "autoScrollContainerSelector"] }], ngImport: i0, template: "<div class=\"container py-4\">\n <div class=\"content\"\n cdkDropList\n [cdkDropListData]=\"{}\"\n [cdkDropListConnectedTo]=\"connectedDropLists()\"\n [cdkDropListEnterPredicate]=\"canEnterRoot\"\n ngsTextSelectionPopup\n closestContentObserverClass=\"ngs-content-editor-content-editable\"\n [targetComponent]=\"commandBar\"\n (tagSelected)=\"onTagSelected($event)\"\n (cdkDropListDropped)=\"drop($event)\">\n @for (contentBlock of _content(); track contentBlock.id) {\n <div class=\"block\"\n [attr.data-block-id]=\"contentBlock.id\"\n [class.is-focused]=\"isBlockFocused(contentBlock.id)\"\n [class.is-active]=\"isActiveBlock(contentBlock.id)\"\n cdkDrag\n [cdkDragData]=\"contentBlock.id\"\n cdkMonitorSubtreeFocus\n (cdkDragStarted)=\"onDragStarted($event, contentBlock)\"\n (cdkDragEnded)=\"onDragEnded($event, contentBlock)\"\n (cdkFocusChange)=\"onFocusChange($event, contentBlock)\">\n <div class=\"block-controls\" [class.is-settings-popover-open]=\"settingsTrigger.api.isOpen()\">\n <button class=\"block-control\" aria-label=\"Add block\"\n (mousedown)=\"setActiveBlockId($event, contentBlock.id)\"\n [ngsMenuTriggerFor]=\"suggestionsMenu\"\n [ngsMenuTriggerData]=\"{target: {scope: {}, afterId: contentBlock.id}}\"\n [ngsMenuTriggerRestoreFocus]=\"false\">\n <ngs-icon name=\"fluent:add-24-regular\"/>\n </button>\n <div class=\"block-control block-control-drag\"\n (click)=\"selectBlock(contentBlock.id)\"\n [ngsPopoverTriggerFor]=\"settingsPopover\"\n (closed)=\"onSettingsPopoverClose()\"\n #settingsTrigger=\"ngsPopoverTriggerFor\"\n hasBackdrop\n position=\"before-center\">\n <button cdkDragHandle\n trigger=\"hover\"\n closeOnOriginClick\n closeOnOriginMouseLeave\n #dragTrigger=\"ngsPopoverTriggerFor\"\n [ngsPopoverTriggerFor]=\"dragControlTooltip\"\n position=\"below-center\"\n (mousedown)=\"dragTrigger.api.close()\"\n delay=\"1000\" class=\"w-full h-full flex items-center justify-center\">\n <ngs-icon name=\"fluent:re-order-dots-vertical-24-regular\"/>\n </button>\n </div>\n <ng-template #dragControlTooltip>\n <div class=\"bg-neutral-900 text-xs flex flex-col gap-0.5 rounded-lg items-center px-2 py-1.5 font-medium\">\n <div>\n <div class=\"text-neutral-100\">Drag <span class=\"text-neutral-400\">to move</span></div>\n </div>\n <div>\n <div class=\"text-neutral-100\">Click <span class=\"text-neutral-400\">to open menu</span></div>\n </div>\n </div>\n </ng-template>\n </div>\n <div class=\"block-content\" [class.is-selected]=\"isBlockSelected(contentBlock.id)\">\n <div class=\"drag-placeholder\" *cdkDragPlaceholder></div>\n <ng-container [ngComponentOutlet]=\"blockDefsMap.get(contentBlock.type) | async\"\n [ngComponentOutletInputs]=\"{\n id: contentBlock.id,\n content: contentBlock.content,\n settings: contentBlock.settings,\n props: contentBlock.props,\n index: $index\n }\"/>\n </div>\n </div>\n }\n </div>\n</div>\n\n<ngs-popover #settingsPopover=\"ngsPopover\">\n <div class=\"px-2 py-0 w-72 settings-popover\">\n <ngs-list>\n @if (selectedBlocksModel.selected.length === 1 && canConvertBlock(selectedBlocksModel.selected[0])) {\n <ngs-list-item [ngsMenuTriggerFor]=\"conversionMenu\" [ngsMenuTriggerData]=\"{blockId: selectedBlocksModel.selected[0]}\" [ngsMenuTriggerRestoreFocus]=\"false\">\n <ngs-icon name=\"fluent:arrow-swap-24-regular\" ngsListItemIcon/>\n <div ngsListItemTitle>Turn into</div>\n </ngs-list-item>\n }\n <ngs-list-item (click)=\"duplicateSelectedBlocks(settingsPopover)\">\n <ngs-icon name=\"fluent:copy-24-regular\" ngsListItemIcon/>\n <div ngsListItemTitle>Duplicate</div>\n </ngs-list-item>\n <ngs-list-item (click)=\"deleteSelectedBlocks(settingsPopover)\">\n <ngs-icon name=\"fluent:delete-24-regular\" ngsListItemIcon/>\n <div ngsListItemTitle>Delete</div>\n </ngs-list-item>\n </ngs-list>\n </div>\n</ngs-popover>\n\n<ngs-menu #suggestionsMenu=\"ngsMenu\" classList=\"min-h-[70vh] max-h-[70vh]!\" pushIntoViewport (closed)=\"onSuggestionsMenuClose($event)\">\n <ng-template ngsMenuContent let-target=\"target\">\n <div (click)=\"preventMenuClose($event)\">\n @for (suggestionItem of insertionSuggestions(); track $index; let first = $first) {\n @switch (suggestionItem.type) {\n @case ('heading') {\n <ngs-menu-heading>{{ suggestionItem.title }}</ngs-menu-heading>\n }\n @case ('item') {\n <button ngs-menu-item\n (click)=\"addBlockFromSuggestionMenu(suggestionsMenu, target, suggestionItem.blockType, suggestionItem.blockSettings)\">\n <div class=\"h-full flex items-center gap-3 py-2\">\n <div class=\"size-9 flex items-center rounded-lg justify-center bg-surface-container\">\n <ngs-icon [name]=\"suggestionItem.iconName\" class=\"!me-0\"/>\n </div>\n <div class=\"grow min-w-[200px]\">\n <div>{{ suggestionItem.title }}</div>\n <div class=\"text-2xs text-neutral-600\">{{ suggestionItem.description }}</div>\n </div>\n @if (suggestionItem.hotKeys) {\n <div class=\"ms-auto bg-surface-container-highest rounded-full h-5\n text-4xs px-2 flex items-center font-bold\">{{ suggestionItem.hotKeys }}</div>\n }\n </div>\n </button>\n }\n }\n }\n </div>\n </ng-template>\n</ngs-menu>\n\n<ngs-menu #conversionMenu>\n <ng-template ngsMenuContent let-blockId=\"blockId\">\n @for (type of conversionTypes; track type) {\n <button ngs-menu-item (click)=\"convertBlock(blockId, type); settingsPopover.close()\">{{type}}</button>\n }\n </ng-template>\n</ngs-menu>\n", styles: [":host{--ngs-content-editor-builder-content-width: 704px;outline:none}:host.is-block-dragging{cursor:grabbing}:host .container{display:flex;width:100%;max-width:820px;min-height:200px;height:100%;padding:calc(var(--spacing, .25rem) * 5) calc(var(--spacing, .25rem) * 5) calc(var(--spacing, .25rem) * 5) 0;margin:0 auto;outline:none}:host .content{flex-grow:1;width:100%;min-width:0}:host .block{position:relative;flex:none;padding:var(--spacing, .25rem) 0;display:flex;align-items:center}:host .block:not(:has(.block-content.is-selected)):hover .block-content{background:var(--ngs-color-neutral-50)}:host:not(.is-block-dragging) .block:hover .block-controls,:host:not(.is-block-dragging) .block.is-active .block-controls{opacity:1}:host .block-content{position:relative;flex-grow:1;min-width:0;padding:calc(var(--spacing, .25rem) * 3)}:host .block-content.is-selected{background:var(--ngs-color-primary-100)}:host ::ng-deep .selection-area{background:var(--ngs-color-primary-100);opacity:.4;border:1px solid var(--ngs-color-primary);border-radius:var(--ngs-radius-sm)}:host ::ng-deep .ngs-content-editor-content-editable{-webkit-user-select:text;user-select:text}:host ::ng-deep .ngs-content-editor-content-editable a[data-ngs-headless-editor-mark=link]{color:var(--ngs-color-primary);text-decoration:underline;text-underline-offset:.15em}:host ::ng-deep .ngs-content-editor-content-editable.align-center{text-align:center}:host ::ng-deep .ngs-content-editor-content-editable.align-right{text-align:right}:host ::ng-deep .ngs-content-editor-content-editable.align-justify{text-align:justify}:host ::ng-deep .ngs-content-editor-content-editable>p{margin:0}:host ::ng-deep .ngs-content-editor-content-editable[data-empty]:before{content:attr(data-empty-placeholder);display:block;height:0;color:var(--ngs-color-neutral-500);pointer-events:none}:host.select-none ::ng-deep .ngs-content-editor-content-editable,:host.is-selection-of-blocks-active ::ng-deep .ngs-content-editor-content-editable{-webkit-user-select:none!important;user-select:none!important}:host .block-controls{left:0;display:flex;align-items:center;color:var(--ngs-color-neutral-500);width:calc(var(--spacing, .25rem) * 18);padding:0 calc(var(--spacing, .25rem) * 2);opacity:0;flex:none}:host .block-controls.is-settings-popover-open{opacity:1}:host .block-controls.is-settings-popover-open .block-control:not(.block-control-drag){opacity:0}:host .block-control{cursor:pointer;width:calc(var(--spacing, .25rem) * 7);height:calc(var(--spacing, .25rem) * 7);flex:none;border-radius:var(--ngs-radius-lg);display:inline-flex;align-items:center;justify-content:center}:host .block-control:hover{background:var(--ngs-color-surface-container-low);color:var(--ngs-color-on-surface)}:host .block-control-drag button{cursor:grab}:host .drag-placeholder{height:calc(var(--spacing, .25rem) * 8);flex:none;position:relative}:host .drag-placeholder:before{position:absolute;left:calc(var(--spacing, .25rem) * 18);display:block;right:0;content:\"\";height:calc(var(--spacing, .25rem) * 2);top:50%;transform:translateY(-50%);background:var(--ngs-color-primary-300);border-radius:calc(var(--spacing, .25rem) * .5)}:host ::ng-deep code{color:var(--ngs-color-primary)}.cdk-drag.cdk-drag-preview{overflow:hidden;display:flex;align-items:center;color:var(--ngs-color-neutral-500);width:calc(var(--spacing, .25rem) * 18);padding:0 calc(var(--spacing, .25rem) * 2)}.cdk-drag.cdk-drag-preview .block-control{width:calc(var(--spacing, .25rem) * 7);height:calc(var(--spacing, .25rem) * 7);flex:none;border-radius:var(--ngs-radius-lg);display:inline-flex;align-items:center;justify-content:center;cursor:grabbing}.cdk-drag.cdk-drag-preview .block-control:first-child{opacity:0}.cdk-drag.cdk-drag-preview .block-control:last-child{color:var(--ngs-color-on-surface)}.cdk-drag.cdk-drag-preview .block-content{opacity:0}.settings-popover{--ngs-list-list-item-one-line-container-height: calc(var(--spacing, .25rem) * 10)}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "component", type: Icon, selector: "ngs-icon", inputs: ["name"], exportAs: ["ngsIcon"] }, { kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }, { kind: "directive", type: CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer", "cdkDropListHasAnchor"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { kind: "directive", type: CdkDragPlaceholder, selector: "ng-template[cdkDragPlaceholder]", inputs: ["data"] }, { kind: "component", type: Menu, selector: "ngs-menu", inputs: ["role", "classList", "xPosition", "yPosition", "pushIntoViewport"], outputs: ["closed"], exportAs: ["ngsMenu"] }, { kind: "component", type: MenuItem, selector: "ngs-menu-item, [ngs-menu-item]", inputs: ["disabled", "role", "selected"], outputs: ["_triggered"], exportAs: ["ngsMenuItem"] }, { kind: "directive", type: MenuTrigger, selector: "[ngsMenuTriggerFor]", inputs: ["ngsMenuTriggerFor", "ngsMenuTriggerData", "ngsMenuDisabled", "xPosition", "yPosition", "ngsMenuTriggerRestoreFocus"], outputs: ["menuOpened", "menuClosed"], exportAs: ["ngsMenuTrigger"] }, { kind: "directive", type: CdkMonitorFocus, selector: "[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]", outputs: ["cdkFocusChange"], exportAs: ["cdkMonitorFocus"] }, { kind: "directive", type: TextSelectionPopupDirective, selector: "[ngsTextSelectionPopup]", inputs: ["targetComponent", "closestContentObserverClass"], outputs: ["tagSelected"] }, { kind: "directive", type: PopoverTriggerForDirective, selector: "[ngsPopoverTriggerFor]", inputs: ["ngsPopoverTriggerFor", "ngsPopoverContext", "trigger", "position", "delay", "origin", "closeOnOriginClick", "closeOnOriginMouseLeave", "hasBackdrop"], outputs: ["opened", "closed"], exportAs: ["ngsPopoverTriggerFor"] }, { kind: "component", type: Popover, selector: "ngs-popover", exportAs: ["ngsPopover"] }, { kind: "directive", type: ListItemTitle, selector: "[ngsListItemTitle]" }, { kind: "directive", type: ListItemIcon, selector: "[ngsListItemIcon]" }, { kind: "component", type: ListItem, selector: "ngs-list-item, a[ngs-list-item], button[ngs-list-item]", inputs: ["disabled", "lines"], exportAs: ["ngsListItem"] }, { kind: "component", type: List, selector: "ngs-list", inputs: ["disabled", "disableRipple"], exportAs: ["ngsList"] }, { kind: "component", type: MenuHeading, selector: "ngs-menu-heading" }, { kind: "directive", type: MenuContent, selector: "[ngsMenuContent]" }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2602
3490
  }
2603
3491
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentBuilderComponent, decorators: [{
2604
3492
  type: Component,
@@ -2633,6 +3521,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImpor
2633
3521
  ], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
2634
3522
  provideContentEditor(),
2635
3523
  ContentEditorHtmlSerializer,
3524
+ ContentEditorImporter,
2636
3525
  ContentBuilderStore,
2637
3526
  {
2638
3527
  provide: CONTENT_BUILDER,
@@ -2647,8 +3536,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImpor
2647
3536
  'tabindex': '0',
2648
3537
  '(paste)': '_onPaste($event)',
2649
3538
  '(keydown)': '_onKeyDown($event)',
2650
- }, template: "<div class=\"container py-4\">\n <div class=\"content\"\n cdkDropList\n [cdkDropListData]=\"{}\"\n [cdkDropListConnectedTo]=\"connectedDropLists()\"\n [cdkDropListEnterPredicate]=\"canEnterRoot\"\n ngsTextSelectionPopup\n closestContentObserverClass=\"ngs-content-editor-content-editable\"\n [targetComponent]=\"commandBar\"\n (tagSelected)=\"onTagSelected($event)\"\n (cdkDropListDropped)=\"drop($event)\">\n @for (contentBlock of _content(); track contentBlock.id) {\n <div class=\"block\"\n [attr.data-block-id]=\"contentBlock.id\"\n [class.is-focused]=\"isBlockFocused(contentBlock.id)\"\n [class.is-active]=\"isActiveBlock(contentBlock.id)\"\n cdkDrag\n [cdkDragData]=\"contentBlock.id\"\n cdkMonitorSubtreeFocus\n (cdkDragStarted)=\"onDragStarted($event, contentBlock)\"\n (cdkDragEnded)=\"onDragEnded($event, contentBlock)\"\n (cdkFocusChange)=\"onFocusChange($event, contentBlock)\">\n <div class=\"block-controls\" [class.is-settings-popover-open]=\"settingsTrigger.api.isOpen()\">\n <button class=\"block-control\" aria-label=\"Add block\"\n (mousedown)=\"setActiveBlockId($event, contentBlock.id)\"\n [ngsMenuTriggerFor]=\"suggestionsMenu\"\n [ngsMenuTriggerData]=\"{target: {scope: {}, afterId: contentBlock.id}}\"\n [ngsMenuTriggerRestoreFocus]=\"false\">\n <ngs-icon name=\"fluent:add-24-regular\"/>\n </button>\n <div class=\"block-control block-control-drag\"\n (click)=\"selectBlock(contentBlock.id)\"\n [ngsPopoverTriggerFor]=\"settingsPopover\"\n (closed)=\"onSettingsPopoverClose()\"\n #settingsTrigger=\"ngsPopoverTriggerFor\"\n hasBackdrop\n position=\"before-center\">\n <button cdkDragHandle\n trigger=\"hover\"\n closeOnOriginClick\n closeOnOriginMouseLeave\n #dragTrigger=\"ngsPopoverTriggerFor\"\n [ngsPopoverTriggerFor]=\"dragControlTooltip\"\n position=\"below-center\"\n (mousedown)=\"dragTrigger.api.close()\"\n delay=\"1000\" class=\"w-full h-full flex items-center justify-center\">\n <ngs-icon name=\"fluent:re-order-dots-vertical-24-regular\"/>\n </button>\n </div>\n <ng-template #dragControlTooltip>\n <div class=\"bg-neutral-900 text-xs flex flex-col gap-0.5 rounded-lg items-center px-2 py-1.5 font-medium\">\n <div>\n <div class=\"text-neutral-100\">Drag <span class=\"text-neutral-400\">to move</span></div>\n </div>\n <div>\n <div class=\"text-neutral-100\">Click <span class=\"text-neutral-400\">to open menu</span></div>\n </div>\n </div>\n </ng-template>\n </div>\n <div class=\"block-content\" [class.is-selected]=\"isBlockSelected(contentBlock.id)\">\n <div class=\"drag-placeholder\" *cdkDragPlaceholder></div>\n <ng-container [ngComponentOutlet]=\"blockDefsMap.get(contentBlock.type) | async\"\n [ngComponentOutletInputs]=\"{\n id: contentBlock.id,\n content: contentBlock.content,\n settings: contentBlock.settings,\n props: contentBlock.props,\n index: $index\n }\"/>\n </div>\n </div>\n }\n </div>\n</div>\n\n<ngs-popover #settingsPopover=\"ngsPopover\">\n <div class=\"px-2 py-0 w-72 settings-popover\">\n <ngs-list>\n <ngs-list-item (click)=\"duplicateSelectedBlocks(settingsPopover)\">\n <ngs-icon name=\"fluent:copy-24-regular\" ngsListItemIcon/>\n <div ngsListItemTitle>Duplicate</div>\n </ngs-list-item>\n <ngs-list-item (click)=\"deleteSelectedBlocks(settingsPopover)\">\n <ngs-icon name=\"fluent:delete-24-regular\" ngsListItemIcon/>\n <div ngsListItemTitle>Delete</div>\n </ngs-list-item>\n </ngs-list>\n </div>\n</ngs-popover>\n\n<ngs-menu #suggestionsMenu=\"ngsMenu\" classList=\"min-h-[70vh] max-h-[70vh]!\" pushIntoViewport (closed)=\"onSuggestionsMenuClose($event)\">\n <ng-template ngsMenuContent let-target=\"target\">\n <div (click)=\"preventMenuClose($event)\">\n @for (suggestionItem of suggestions(); track $index; let first = $first) {\n @switch (suggestionItem.type) {\n @case ('heading') {\n <ngs-menu-heading>{{ suggestionItem.title }}</ngs-menu-heading>\n }\n @case ('item') {\n <button ngs-menu-item\n (click)=\"addBlockFromSuggestionMenu(suggestionsMenu, target, suggestionItem.blockType, suggestionItem.blockSettings)\">\n <div class=\"h-full flex items-center gap-3 py-2\">\n <div class=\"size-9 flex items-center rounded-lg justify-center bg-surface-container\">\n <ngs-icon [name]=\"suggestionItem.iconName\" class=\"!me-0\"/>\n </div>\n <div class=\"grow min-w-[200px]\">\n <div>{{ suggestionItem.title }}</div>\n <div class=\"text-2xs text-neutral-600\">{{ suggestionItem.description }}</div>\n </div>\n @if (suggestionItem.hotKeys) {\n <div class=\"ms-auto bg-surface-container-highest rounded-full h-5\n text-4xs px-2 flex items-center font-bold\">{{ suggestionItem.hotKeys }}</div>\n }\n </div>\n </button>\n }\n }\n }\n </div>\n </ng-template>\n</ngs-menu>\n", styles: [":host{--ngs-content-editor-builder-content-width: 704px;outline:none}:host.is-block-dragging{cursor:grabbing}:host .container{display:flex;width:100%;max-width:820px;min-height:200px;height:100%;padding:calc(var(--spacing, .25rem) * 5) calc(var(--spacing, .25rem) * 5) calc(var(--spacing, .25rem) * 5) 0;margin:0 auto;outline:none}:host .content{flex-grow:1;width:100%;min-width:0}:host .block{position:relative;flex:none;padding:var(--spacing, .25rem) 0;display:flex;align-items:center}:host .block:not(:has(.block-content.is-selected)):hover .block-content{background:var(--ngs-color-neutral-50)}:host:not(.is-block-dragging) .block:hover .block-controls,:host:not(.is-block-dragging) .block.is-active .block-controls{opacity:1}:host .block-content{position:relative;flex-grow:1;min-width:0;padding:calc(var(--spacing, .25rem) * 3)}:host .block-content.is-selected{background:var(--ngs-color-primary-100)}:host ::ng-deep .selection-area{background:var(--ngs-color-primary-100);opacity:.4;border:1px solid var(--ngs-color-primary);border-radius:var(--ngs-radius-sm)}:host ::ng-deep .ngs-content-editor-content-editable{-webkit-user-select:text;user-select:text}:host ::ng-deep .ngs-content-editor-content-editable a[data-ngs-headless-editor-mark=link]{color:var(--ngs-color-primary);text-decoration:underline;text-underline-offset:.15em}:host ::ng-deep .ngs-content-editor-content-editable.align-center{text-align:center}:host ::ng-deep .ngs-content-editor-content-editable.align-right{text-align:right}:host ::ng-deep .ngs-content-editor-content-editable.align-justify{text-align:justify}:host ::ng-deep .ngs-content-editor-content-editable>p{margin:0}:host ::ng-deep .ngs-content-editor-content-editable[data-empty]:before{content:attr(data-empty-placeholder);display:block;height:0;color:var(--ngs-color-neutral-500);pointer-events:none}:host.select-none ::ng-deep .ngs-content-editor-content-editable,:host.is-selection-of-blocks-active ::ng-deep .ngs-content-editor-content-editable{-webkit-user-select:none!important;user-select:none!important}:host .block-controls{left:0;display:flex;align-items:center;color:var(--ngs-color-neutral-500);width:calc(var(--spacing, .25rem) * 18);padding:0 calc(var(--spacing, .25rem) * 2);opacity:0;flex:none}:host .block-controls.is-settings-popover-open{opacity:1}:host .block-controls.is-settings-popover-open .block-control:not(.block-control-drag){opacity:0}:host .block-control{cursor:pointer;width:calc(var(--spacing, .25rem) * 7);height:calc(var(--spacing, .25rem) * 7);flex:none;border-radius:var(--ngs-radius-lg);display:inline-flex;align-items:center;justify-content:center}:host .block-control:hover{background:var(--ngs-color-surface-container-low);color:var(--ngs-color-on-surface)}:host .block-control-drag button{cursor:grab}:host .drag-placeholder{height:calc(var(--spacing, .25rem) * 8);flex:none;position:relative}:host .drag-placeholder:before{position:absolute;left:calc(var(--spacing, .25rem) * 18);display:block;right:0;content:\"\";height:calc(var(--spacing, .25rem) * 2);top:50%;transform:translateY(-50%);background:var(--ngs-color-primary-300);border-radius:calc(var(--spacing, .25rem) * .5)}:host ::ng-deep code{color:var(--ngs-color-primary)}.cdk-drag.cdk-drag-preview{overflow:hidden;display:flex;align-items:center;color:var(--ngs-color-neutral-500);width:calc(var(--spacing, .25rem) * 18);padding:0 calc(var(--spacing, .25rem) * 2)}.cdk-drag.cdk-drag-preview .block-control{width:calc(var(--spacing, .25rem) * 7);height:calc(var(--spacing, .25rem) * 7);flex:none;border-radius:var(--ngs-radius-lg);display:inline-flex;align-items:center;justify-content:center;cursor:grabbing}.cdk-drag.cdk-drag-preview .block-control:first-child{opacity:0}.cdk-drag.cdk-drag-preview .block-control:last-child{color:var(--ngs-color-on-surface)}.cdk-drag.cdk-drag-preview .block-content{opacity:0}.settings-popover{--ngs-list-list-item-one-line-container-height: calc(var(--spacing, .25rem) * 10)}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
2651
- }], ctorParameters: () => [], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: false }] }], blockMenu: [{ type: i0.ViewChild, args: ['suggestionsMenu', { isSignal: true }] }], dropList: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CdkDropList), { isSignal: true }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], contentChangedDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentChangedDelay", required: false }] }], persistDraft: [{ type: i0.Input, args: [{ isSignal: true, alias: "persistDraft", required: false }] }], suggestions: [{ type: i0.Input, args: [{ isSignal: true, alias: "suggestions", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], scrollContainer: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollContainer", required: false }] }], contentChanged: [{ type: i0.Output, args: ["contentChanged"] }] } });
3539
+ }, template: "<div class=\"container py-4\">\n <div class=\"content\"\n cdkDropList\n [cdkDropListData]=\"{}\"\n [cdkDropListConnectedTo]=\"connectedDropLists()\"\n [cdkDropListEnterPredicate]=\"canEnterRoot\"\n ngsTextSelectionPopup\n closestContentObserverClass=\"ngs-content-editor-content-editable\"\n [targetComponent]=\"commandBar\"\n (tagSelected)=\"onTagSelected($event)\"\n (cdkDropListDropped)=\"drop($event)\">\n @for (contentBlock of _content(); track contentBlock.id) {\n <div class=\"block\"\n [attr.data-block-id]=\"contentBlock.id\"\n [class.is-focused]=\"isBlockFocused(contentBlock.id)\"\n [class.is-active]=\"isActiveBlock(contentBlock.id)\"\n cdkDrag\n [cdkDragData]=\"contentBlock.id\"\n cdkMonitorSubtreeFocus\n (cdkDragStarted)=\"onDragStarted($event, contentBlock)\"\n (cdkDragEnded)=\"onDragEnded($event, contentBlock)\"\n (cdkFocusChange)=\"onFocusChange($event, contentBlock)\">\n <div class=\"block-controls\" [class.is-settings-popover-open]=\"settingsTrigger.api.isOpen()\">\n <button class=\"block-control\" aria-label=\"Add block\"\n (mousedown)=\"setActiveBlockId($event, contentBlock.id)\"\n [ngsMenuTriggerFor]=\"suggestionsMenu\"\n [ngsMenuTriggerData]=\"{target: {scope: {}, afterId: contentBlock.id}}\"\n [ngsMenuTriggerRestoreFocus]=\"false\">\n <ngs-icon name=\"fluent:add-24-regular\"/>\n </button>\n <div class=\"block-control block-control-drag\"\n (click)=\"selectBlock(contentBlock.id)\"\n [ngsPopoverTriggerFor]=\"settingsPopover\"\n (closed)=\"onSettingsPopoverClose()\"\n #settingsTrigger=\"ngsPopoverTriggerFor\"\n hasBackdrop\n position=\"before-center\">\n <button cdkDragHandle\n trigger=\"hover\"\n closeOnOriginClick\n closeOnOriginMouseLeave\n #dragTrigger=\"ngsPopoverTriggerFor\"\n [ngsPopoverTriggerFor]=\"dragControlTooltip\"\n position=\"below-center\"\n (mousedown)=\"dragTrigger.api.close()\"\n delay=\"1000\" class=\"w-full h-full flex items-center justify-center\">\n <ngs-icon name=\"fluent:re-order-dots-vertical-24-regular\"/>\n </button>\n </div>\n <ng-template #dragControlTooltip>\n <div class=\"bg-neutral-900 text-xs flex flex-col gap-0.5 rounded-lg items-center px-2 py-1.5 font-medium\">\n <div>\n <div class=\"text-neutral-100\">Drag <span class=\"text-neutral-400\">to move</span></div>\n </div>\n <div>\n <div class=\"text-neutral-100\">Click <span class=\"text-neutral-400\">to open menu</span></div>\n </div>\n </div>\n </ng-template>\n </div>\n <div class=\"block-content\" [class.is-selected]=\"isBlockSelected(contentBlock.id)\">\n <div class=\"drag-placeholder\" *cdkDragPlaceholder></div>\n <ng-container [ngComponentOutlet]=\"blockDefsMap.get(contentBlock.type) | async\"\n [ngComponentOutletInputs]=\"{\n id: contentBlock.id,\n content: contentBlock.content,\n settings: contentBlock.settings,\n props: contentBlock.props,\n index: $index\n }\"/>\n </div>\n </div>\n }\n </div>\n</div>\n\n<ngs-popover #settingsPopover=\"ngsPopover\">\n <div class=\"px-2 py-0 w-72 settings-popover\">\n <ngs-list>\n @if (selectedBlocksModel.selected.length === 1 && canConvertBlock(selectedBlocksModel.selected[0])) {\n <ngs-list-item [ngsMenuTriggerFor]=\"conversionMenu\" [ngsMenuTriggerData]=\"{blockId: selectedBlocksModel.selected[0]}\" [ngsMenuTriggerRestoreFocus]=\"false\">\n <ngs-icon name=\"fluent:arrow-swap-24-regular\" ngsListItemIcon/>\n <div ngsListItemTitle>Turn into</div>\n </ngs-list-item>\n }\n <ngs-list-item (click)=\"duplicateSelectedBlocks(settingsPopover)\">\n <ngs-icon name=\"fluent:copy-24-regular\" ngsListItemIcon/>\n <div ngsListItemTitle>Duplicate</div>\n </ngs-list-item>\n <ngs-list-item (click)=\"deleteSelectedBlocks(settingsPopover)\">\n <ngs-icon name=\"fluent:delete-24-regular\" ngsListItemIcon/>\n <div ngsListItemTitle>Delete</div>\n </ngs-list-item>\n </ngs-list>\n </div>\n</ngs-popover>\n\n<ngs-menu #suggestionsMenu=\"ngsMenu\" classList=\"min-h-[70vh] max-h-[70vh]!\" pushIntoViewport (closed)=\"onSuggestionsMenuClose($event)\">\n <ng-template ngsMenuContent let-target=\"target\">\n <div (click)=\"preventMenuClose($event)\">\n @for (suggestionItem of insertionSuggestions(); track $index; let first = $first) {\n @switch (suggestionItem.type) {\n @case ('heading') {\n <ngs-menu-heading>{{ suggestionItem.title }}</ngs-menu-heading>\n }\n @case ('item') {\n <button ngs-menu-item\n (click)=\"addBlockFromSuggestionMenu(suggestionsMenu, target, suggestionItem.blockType, suggestionItem.blockSettings)\">\n <div class=\"h-full flex items-center gap-3 py-2\">\n <div class=\"size-9 flex items-center rounded-lg justify-center bg-surface-container\">\n <ngs-icon [name]=\"suggestionItem.iconName\" class=\"!me-0\"/>\n </div>\n <div class=\"grow min-w-[200px]\">\n <div>{{ suggestionItem.title }}</div>\n <div class=\"text-2xs text-neutral-600\">{{ suggestionItem.description }}</div>\n </div>\n @if (suggestionItem.hotKeys) {\n <div class=\"ms-auto bg-surface-container-highest rounded-full h-5\n text-4xs px-2 flex items-center font-bold\">{{ suggestionItem.hotKeys }}</div>\n }\n </div>\n </button>\n }\n }\n }\n </div>\n </ng-template>\n</ngs-menu>\n\n<ngs-menu #conversionMenu>\n <ng-template ngsMenuContent let-blockId=\"blockId\">\n @for (type of conversionTypes; track type) {\n <button ngs-menu-item (click)=\"convertBlock(blockId, type); settingsPopover.close()\">{{type}}</button>\n }\n </ng-template>\n</ngs-menu>\n", styles: [":host{--ngs-content-editor-builder-content-width: 704px;outline:none}:host.is-block-dragging{cursor:grabbing}:host .container{display:flex;width:100%;max-width:820px;min-height:200px;height:100%;padding:calc(var(--spacing, .25rem) * 5) calc(var(--spacing, .25rem) * 5) calc(var(--spacing, .25rem) * 5) 0;margin:0 auto;outline:none}:host .content{flex-grow:1;width:100%;min-width:0}:host .block{position:relative;flex:none;padding:var(--spacing, .25rem) 0;display:flex;align-items:center}:host .block:not(:has(.block-content.is-selected)):hover .block-content{background:var(--ngs-color-neutral-50)}:host:not(.is-block-dragging) .block:hover .block-controls,:host:not(.is-block-dragging) .block.is-active .block-controls{opacity:1}:host .block-content{position:relative;flex-grow:1;min-width:0;padding:calc(var(--spacing, .25rem) * 3)}:host .block-content.is-selected{background:var(--ngs-color-primary-100)}:host ::ng-deep .selection-area{background:var(--ngs-color-primary-100);opacity:.4;border:1px solid var(--ngs-color-primary);border-radius:var(--ngs-radius-sm)}:host ::ng-deep .ngs-content-editor-content-editable{-webkit-user-select:text;user-select:text}:host ::ng-deep .ngs-content-editor-content-editable a[data-ngs-headless-editor-mark=link]{color:var(--ngs-color-primary);text-decoration:underline;text-underline-offset:.15em}:host ::ng-deep .ngs-content-editor-content-editable.align-center{text-align:center}:host ::ng-deep .ngs-content-editor-content-editable.align-right{text-align:right}:host ::ng-deep .ngs-content-editor-content-editable.align-justify{text-align:justify}:host ::ng-deep .ngs-content-editor-content-editable>p{margin:0}:host ::ng-deep .ngs-content-editor-content-editable[data-empty]:before{content:attr(data-empty-placeholder);display:block;height:0;color:var(--ngs-color-neutral-500);pointer-events:none}:host.select-none ::ng-deep .ngs-content-editor-content-editable,:host.is-selection-of-blocks-active ::ng-deep .ngs-content-editor-content-editable{-webkit-user-select:none!important;user-select:none!important}:host .block-controls{left:0;display:flex;align-items:center;color:var(--ngs-color-neutral-500);width:calc(var(--spacing, .25rem) * 18);padding:0 calc(var(--spacing, .25rem) * 2);opacity:0;flex:none}:host .block-controls.is-settings-popover-open{opacity:1}:host .block-controls.is-settings-popover-open .block-control:not(.block-control-drag){opacity:0}:host .block-control{cursor:pointer;width:calc(var(--spacing, .25rem) * 7);height:calc(var(--spacing, .25rem) * 7);flex:none;border-radius:var(--ngs-radius-lg);display:inline-flex;align-items:center;justify-content:center}:host .block-control:hover{background:var(--ngs-color-surface-container-low);color:var(--ngs-color-on-surface)}:host .block-control-drag button{cursor:grab}:host .drag-placeholder{height:calc(var(--spacing, .25rem) * 8);flex:none;position:relative}:host .drag-placeholder:before{position:absolute;left:calc(var(--spacing, .25rem) * 18);display:block;right:0;content:\"\";height:calc(var(--spacing, .25rem) * 2);top:50%;transform:translateY(-50%);background:var(--ngs-color-primary-300);border-radius:calc(var(--spacing, .25rem) * .5)}:host ::ng-deep code{color:var(--ngs-color-primary)}.cdk-drag.cdk-drag-preview{overflow:hidden;display:flex;align-items:center;color:var(--ngs-color-neutral-500);width:calc(var(--spacing, .25rem) * 18);padding:0 calc(var(--spacing, .25rem) * 2)}.cdk-drag.cdk-drag-preview .block-control{width:calc(var(--spacing, .25rem) * 7);height:calc(var(--spacing, .25rem) * 7);flex:none;border-radius:var(--ngs-radius-lg);display:inline-flex;align-items:center;justify-content:center;cursor:grabbing}.cdk-drag.cdk-drag-preview .block-control:first-child{opacity:0}.cdk-drag.cdk-drag-preview .block-control:last-child{color:var(--ngs-color-on-surface)}.cdk-drag.cdk-drag-preview .block-content{opacity:0}.settings-popover{--ngs-list-list-item-one-line-container-height: calc(var(--spacing, .25rem) * 10)}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
3540
+ }], ctorParameters: () => [], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: false }] }], conversionMenu: [{ type: i0.ViewChild, args: ['conversionMenu', { isSignal: true }] }], blockMenu: [{ type: i0.ViewChild, args: ['suggestionsMenu', { isSignal: true }] }], documentId: [{ type: i0.Input, args: [{ isSignal: true, alias: "documentId", required: false }] }], draftDebounceMs: [{ type: i0.Input, args: [{ isSignal: true, alias: "draftDebounceMs", required: false }] }], dropList: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CdkDropList), { isSignal: true }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], contentChangedDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentChangedDelay", required: false }] }], persistDraft: [{ type: i0.Input, args: [{ isSignal: true, alias: "persistDraft", required: false }] }], suggestions: [{ type: i0.Input, args: [{ isSignal: true, alias: "suggestions", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], scrollContainer: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollContainer", required: false }] }], contentChanged: [{ type: i0.Output, args: ["contentChanged"] }] } });
2652
3541
 
2653
3542
  const CONTENT_EDITOR_BLOCK_RENDERERS = new InjectionToken('CONTENT_EDITOR_BLOCK_RENDERERS', {
2654
3543
  factory: () => [],
@@ -2787,13 +3676,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImpor
2787
3676
  args: [{ selector: 'ngs-content-editor-gallery-renderer', imports: [NgsHeadlessEditorRuns, ImageViewerDirective, ImageViewerPictureDirective, Carousel, CarouselCard, Button, Icon], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (selectedImage(); as image) {\n <figure class=\"gallery m-0 flex min-w-0 flex-col gap-4\" ngsImageViewer role=\"region\" aria-label=\"Image gallery\" aria-roledescription=\"carousel\" (keydown)=\"onKeydown($event)\">\n <div class=\"gallery-preview relative overflow-hidden rounded-lg\">\n <ngs-carousel tabindex=\"0\" aria-label=\"Gallery images. Use arrow keys to navigate.\" (indexChange)=\"onIndexChange($event)\">\n @for (slide of images(); track slide.id) {\n <ngs-carousel-card role=\"group\" aria-roledescription=\"slide\" [attr.aria-label]=\"($index + 1) + ' of ' + images().length\" [attr.aria-hidden]=\"$index !== selectedIndex()\">\n <button ngsButton type=\"button\" class=\"gallery-picture\" [fullWidth]=\"true\" [attr.tabindex]=\"$index === selectedIndex() ? 0 : -1\" ngsImageViewerPicture [sourceUrl]=\"slide.src\" [caption]=\"captionText(slide.caption)\" [attr.aria-label]=\"slide.alt || 'View image'\">\n <img [src]=\"slide.src\" [alt]=\"slide.alt\" draggable=\"false\">\n </button>\n </ngs-carousel-card>\n }\n </ngs-carousel>\n <button ngsIconButton type=\"button\" class=\"preview-action expand-action absolute right-3 top-3\" aria-label=\"View full-size image\" ngsImageViewerPicture [sourceUrl]=\"image.src\" [caption]=\"captionText(image.caption)\">\n <ngs-icon name=\"fluent:arrow-expand-24-regular\"/>\n </button>\n @if (images().length > 1) {\n <button ngsIconButton type=\"button\" class=\"preview-action absolute left-3 top-1/2 -translate-y-1/2\" aria-label=\"Previous image\" [disabled]=\"selectedIndex() === 0\" (click)=\"selectImage(selectedIndex() - 1)\"><ngs-icon name=\"fluent:chevron-left-24-regular\"/></button>\n <button ngsIconButton type=\"button\" class=\"preview-action absolute right-3 top-1/2 -translate-y-1/2\" aria-label=\"Next image\" [disabled]=\"selectedIndex() === images().length - 1\" (click)=\"selectImage(selectedIndex() + 1)\"><ngs-icon name=\"fluent:chevron-right-24-regular\"/></button>\n }\n </div>\n @if (captionText(image.caption) || images().length > 1) {\n <figcaption class=\"flex min-w-0 items-start justify-between gap-4\">\n <span class=\"gallery-caption min-w-0 flex-1 text-sm\" [ngsHeadlessEditorRuns]=\"image.caption\"></span>\n @if (images().length > 1) {\n <span class=\"gallery-counter shrink-0 text-sm\" aria-live=\"polite\" aria-atomic=\"true\">{{ selectedIndex() + 1 }} of {{ images().length }}</span>\n }\n </figcaption>\n }\n @if (images().length > 1) {\n <div class=\"thumbnail-strip relative flex min-w-0 gap-3 overflow-x-auto p-1\" role=\"group\" aria-label=\"Choose an image\">\n @for (thumbnail of images(); track thumbnail.id) {\n <button #thumbnailButton ngsButton type=\"button\" class=\"thumbnail-picture shrink-0\" [class.is-selected]=\"$index === selectedIndex()\" [attr.aria-label]=\"'Select image ' + ($index + 1)\" [attr.aria-pressed]=\"$index === selectedIndex()\" (click)=\"selectImage($index)\">\n <img [src]=\"thumbnail.src\" alt=\"\" draggable=\"false\" loading=\"lazy\">\n </button>\n }\n </div>\n }\n </figure>\n}\n", styles: [":host{display:block;min-width:0}:host .gallery{margin:0}:host figcaption{margin:0}:host ngs-carousel{--ngs-carousel-gap: 0px;outline-offset:-3px}:host ngs-carousel:focus-visible{outline:2px solid var(--ngs-color-primary)}:host ngs-carousel ::ng-deep .content{overflow-x:auto;scrollbar-width:none;scroll-snap-type:x mandatory}:host ngs-carousel ::ng-deep .content::-webkit-scrollbar{display:none}:host ngs-carousel-card{width:100%;min-width:0;scroll-snap-align:center}:host button[ngsButton]{--ngs-button-height: auto;--ngs-button-padding: 0;--ngs-button-content-gap: 0;display:block;min-width:0;overflow:hidden;line-height:0}:host button[ngsButton] img{display:block;width:100%;margin:0;object-fit:cover}:host button[ngsButton] ::ng-deep .content{display:block;width:100%}:host button[ngsButton].gallery-picture{width:100%;border-radius:0}:host button[ngsButton].gallery-picture img{aspect-ratio:16/9}:host button[ngsButton].thumbnail-picture{width:calc(var(--spacing, .25rem) * 32);border-radius:var(--ngs-radius-md)}:host button[ngsButton].thumbnail-picture img{aspect-ratio:16/9}:host button[ngsButton].thumbnail-picture.is-selected{outline:2px solid var(--ngs-color-primary);outline-offset:2px}:host .gallery-preview{background:var(--ngs-color-surface-container-low)}:host button[ngsIconButton].preview-action{--ngs-button-height: calc(var(--spacing, .25rem) * 9);--ngs-button-bg: var(--ngs-color-white);--ngs-button-color: var(--ngs-color-black);--ngs-button-hover-bg: var(--ngs-color-white);position:absolute;box-shadow:var(--ngs-shadow-sm)}@supports (color: color-mix(in lab,red,red)){:host button[ngsIconButton].preview-action{--ngs-button-hover-bg: color-mix(in srgb, var(--ngs-color-white), var(--ngs-color-black) 8%)}}:host button[ngsIconButton].preview-action.ngs-button-disabled{opacity:.55;background:var(--ngs-color-white)}:host .gallery-caption,:host .gallery-counter{color:var(--ngs-color-on-surface-variant)}:host .gallery-caption{overflow-wrap:anywhere}:host .thumbnail-strip{scrollbar-width:thin}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
2788
3677
  }], ctorParameters: () => [], propDecorators: { cards: [{ type: i0.ViewChildren, args: [i0.forwardRef(() => CarouselCard), { isSignal: true }] }], thumbnails: [{ type: i0.ViewChildren, args: ['thumbnailButton', { ...{ read: (ElementRef) }, isSignal: true }] }] } });
2789
3678
 
2790
- /** Read files for the default data URL upload or a consumer's uploadFn. */
2791
- function readContentEditorFile(file) {
3679
+ /** Read files with actual cancellation and progress. */
3680
+ function readContentEditorFile(file, context) {
2792
3681
  return new Promise((resolve, reject) => {
2793
3682
  const reader = new FileReader();
2794
- reader.onload = () => typeof reader.result === 'string' ? resolve(reader.result) : reject(new Error('Could not read file'));
2795
- reader.onerror = () => reject(new Error('Could not read file'));
2796
- reader.onabort = () => reject(new Error('File reading cancelled'));
3683
+ const abort = () => { reader.abort(); reject(new DOMException('Upload cancelled', 'AbortError')); cleanup(); };
3684
+ const cleanup = () => context?.signal.removeEventListener('abort', abort);
3685
+ if (context?.signal.aborted) {
3686
+ abort();
3687
+ return;
3688
+ }
3689
+ context?.signal.addEventListener('abort', abort, { once: true });
3690
+ reader.onload = () => { cleanup(); typeof reader.result === 'string' ? resolve(reader.result) : reject(new Error('Could not read file')); };
3691
+ reader.onerror = () => { cleanup(); reject(new Error('Could not read file')); };
3692
+ reader.onabort = () => { cleanup(); reject(new DOMException('Upload cancelled', 'AbortError')); };
3693
+ reader.onprogress = event => { if (event.lengthComputable)
3694
+ context?.onProgress(event.loaded / event.total * 100); };
2797
3695
  reader.readAsDataURL(file);
2798
3696
  });
2799
3697
  }
@@ -3248,6 +4146,10 @@ const CONTENT_EDITOR_DEFAULT_RENDERERS = [
3248
4146
  ];
3249
4147
 
3250
4148
  class ContentEditorRenderer {
4149
+ globalConfig = inject(CONTENT_EDITOR_CONFIG);
4150
+ parentConfig = inject(CONTENT_EDITOR_RENDER_CONFIG, { skipSelf: true, optional: true });
4151
+ resolvedConfig = computed(() => mergeContentEditorConfig(this.globalConfig, this.parentConfig?.() ?? {}, this.config()), /* @ts-ignore */
4152
+ ...(ngDevMode ? [{ debugName: "resolvedConfig" }] : /* istanbul ignore next */ []));
3251
4153
  htmlSerializer = inject(ContentEditorHtmlSerializer);
3252
4154
  config = input({}, /* @ts-ignore */
3253
4155
  ...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
@@ -3259,12 +4161,13 @@ class ContentEditorRenderer {
3259
4161
  blocks = input(null, /* @ts-ignore */
3260
4162
  ...(ngDevMode ? [{ debugName: "blocks" }] : /* istanbul ignore next */ []));
3261
4163
  toHtml(config = {}) {
3262
- return this.htmlSerializer.toHtml({ version: 1, blocks: this.blocks() ?? this.content().blocks }, mergeContentEditorConfig(this.config(), config));
4164
+ return this.htmlSerializer.toHtml({ version: 1, blocks: this.blocks() ?? this.content().blocks }, mergeContentEditorConfig(this.resolvedConfig(), config));
3263
4165
  }
3264
4166
  rendererMap = computed(() => {
3265
4167
  const renderers = [
3266
4168
  ...CONTENT_EDITOR_DEFAULT_RENDERERS,
3267
4169
  ...this.providedRendererGroups.flat(),
4170
+ ...Object.entries(this.resolvedConfig().blocks ?? {}).flatMap(([type, block]) => block.renderer ? [{ type, component: block.renderer }] : []),
3268
4171
  ];
3269
4172
  return new Map(renderers.map(renderer => [renderer.type, renderer.component]));
3270
4173
  }, /* @ts-ignore */
@@ -3291,20 +4194,192 @@ class ContentEditorRenderer {
3291
4194
  }, /* @ts-ignore */
3292
4195
  ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
3293
4196
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
3294
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorRenderer, isStandalone: true, selector: "ngs-content-editor-renderer", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, blocks: { classPropertyName: "blocks", publicName: "blocks", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ngs-content-editor-renderer prose max-w-full" }, providers: [provideContentEditor(), ContentEditorHtmlSerializer], exportAs: ["ngsContentEditorRenderer"], ngImport: i0, template: "@for (item of items(); track item.block.id || $index) {\n @if (item.component) {\n <div class=\"block\" [attr.data-block-id]=\"item.block.id\" [attr.data-block-type]=\"item.block.type\">\n <ng-container\n [ngComponentOutlet]=\"item.component\"\n [ngComponentOutletInputs]=\"item.inputs\"\n />\n </div>\n }\n}\n", styles: [":host{--ngs-content-editor-renderer-block-gap: calc(var(--spacing, .25rem) * 4);display:flex;flex-direction:column;gap:var(--ngs-content-editor-renderer-block-gap)}:host .block{min-width:0}:host ::ng-deep a[data-ngs-headless-editor-mark=link]{color:var(--ngs-color-primary);text-decoration:underline;text-underline-offset:.15em}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
4197
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorRenderer, isStandalone: true, selector: "ngs-content-editor-renderer", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, blocks: { classPropertyName: "blocks", publicName: "blocks", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ngs-content-editor-renderer prose max-w-full" }, providers: [provideContentEditor(), ContentEditorHtmlSerializer, {
4198
+ provide: CONTENT_EDITOR_RENDER_CONFIG, useFactory: () => inject(forwardRef(() => ContentEditorRenderer)).resolvedConfig
4199
+ }], exportAs: ["ngsContentEditorRenderer"], ngImport: i0, template: "@for (item of items(); track item.block.id || $index) {\n @if (item.component) {\n <div class=\"block\" [attr.data-block-id]=\"item.block.id\" [attr.data-block-type]=\"item.block.type\">\n <ng-container\n [ngComponentOutlet]=\"item.component\"\n [ngComponentOutletInputs]=\"item.inputs\"\n />\n </div>\n }\n}\n", styles: [":host{--ngs-content-editor-renderer-block-gap: calc(var(--spacing, .25rem) * 4);display:flex;flex-direction:column;gap:var(--ngs-content-editor-renderer-block-gap)}:host .block{min-width:0}:host ::ng-deep a[data-ngs-headless-editor-mark=link]{color:var(--ngs-color-primary);text-decoration:underline;text-underline-offset:.15em}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
3295
4200
  }
3296
4201
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorRenderer, decorators: [{
3297
4202
  type: Component,
3298
- args: [{ selector: 'ngs-content-editor-renderer', exportAs: 'ngsContentEditorRenderer', providers: [provideContentEditor(), ContentEditorHtmlSerializer], imports: [
4203
+ args: [{ selector: 'ngs-content-editor-renderer', exportAs: 'ngsContentEditorRenderer', providers: [provideContentEditor(), ContentEditorHtmlSerializer, {
4204
+ provide: CONTENT_EDITOR_RENDER_CONFIG, useFactory: () => inject(forwardRef(() => ContentEditorRenderer)).resolvedConfig
4205
+ }], imports: [
3299
4206
  NgComponentOutlet,
3300
4207
  ], changeDetection: ChangeDetectionStrategy.OnPush, host: {
3301
4208
  'class': 'ngs-content-editor-renderer prose max-w-full',
3302
4209
  }, template: "@for (item of items(); track item.block.id || $index) {\n @if (item.component) {\n <div class=\"block\" [attr.data-block-id]=\"item.block.id\" [attr.data-block-type]=\"item.block.type\">\n <ng-container\n [ngComponentOutlet]=\"item.component\"\n [ngComponentOutletInputs]=\"item.inputs\"\n />\n </div>\n }\n}\n", styles: [":host{--ngs-content-editor-renderer-block-gap: calc(var(--spacing, .25rem) * 4);display:flex;flex-direction:column;gap:var(--ngs-content-editor-renderer-block-gap)}:host .block{min-width:0}:host ::ng-deep a[data-ngs-headless-editor-mark=link]{color:var(--ngs-color-primary);text-decoration:underline;text-underline-offset:.15em}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
3303
4210
  }], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], blocks: [{ type: i0.Input, args: [{ isSignal: true, alias: "blocks", required: false }] }] } });
3304
4211
 
4212
+ /** One cancellable request per block. Retry only sends failed files again. */
4213
+ class ContentEditorUploadTask {
4214
+ writable;
4215
+ uploading = signal(false, /* @ts-ignore */
4216
+ ...(ngDevMode ? [{ debugName: "uploading" }] : /* istanbul ignore next */ []));
4217
+ progress = signal(null, /* @ts-ignore */
4218
+ ...(ngDevMode ? [{ debugName: "progress" }] : /* istanbul ignore next */ []));
4219
+ error = signal('', /* @ts-ignore */
4220
+ ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
4221
+ canRetry = signal(false, /* @ts-ignore */
4222
+ ...(ngDevMode ? [{ debugName: "canRetry" }] : /* istanbul ignore next */ []));
4223
+ controller = null;
4224
+ failed = null;
4225
+ constructor(writable) {
4226
+ this.writable = writable;
4227
+ }
4228
+ cancel() {
4229
+ this.controller?.abort();
4230
+ this.controller = null;
4231
+ this.uploading.set(false);
4232
+ this.progress.set(null);
4233
+ this.failed = null;
4234
+ this.canRetry.set(false);
4235
+ this.error.set('');
4236
+ }
4237
+ retry() { return this.failed ? this.run(this.failed) : Promise.resolve(); }
4238
+ async run(request) {
4239
+ this.cancel();
4240
+ if (!request.files.length || !this.writable())
4241
+ return;
4242
+ const controller = new AbortController();
4243
+ this.controller = controller;
4244
+ const active = () => this.controller === controller && !controller.signal.aborted && this.writable();
4245
+ this.uploading.set(true);
4246
+ const progress = request.files.map(() => null);
4247
+ const report = (index, percent) => {
4248
+ if (!active())
4249
+ return;
4250
+ progress[index] = percent;
4251
+ this.progress.set(progress.every(value => value !== null) ? progress.reduce((sum, value) => sum + (value ?? 0), 0) / progress.length : null);
4252
+ };
4253
+ const results = await Promise.allSettled(request.files.map(async (file, index) => {
4254
+ if (request.accept && !request.accept(file))
4255
+ throw new Error(`Unsupported file: ${file.name}`);
4256
+ if (request.maxFileSize !== undefined && file.size > request.maxFileSize)
4257
+ throw new Error(`File is too large: ${file.name}`);
4258
+ const dataUrl = await readContentEditorFile(file, { signal: controller.signal, onProgress: value => report(index, value * 0.2) });
4259
+ if (!active())
4260
+ throw new DOMException('Upload cancelled', 'AbortError');
4261
+ report(index, null);
4262
+ const url = await abortable(request.upload(file, dataUrl, { signal: controller.signal, onProgress: value => {
4263
+ if (Number.isFinite(value))
4264
+ report(index, 20 + Math.max(0, Math.min(100, value)) * 0.8);
4265
+ } }), controller.signal);
4266
+ if (!active())
4267
+ throw new DOMException('Upload cancelled', 'AbortError');
4268
+ if (typeof url !== 'string' || !safeContentEditorHtmlUrl(url, request.urlKind ?? 'attachment'))
4269
+ throw new Error(`Invalid upload URL: ${file.name}`);
4270
+ report(index, 100);
4271
+ return { file, url, dataUrl };
4272
+ }));
4273
+ if (this.controller !== controller || controller.signal.aborted)
4274
+ return;
4275
+ if (!this.writable()) {
4276
+ this.cancel();
4277
+ return;
4278
+ }
4279
+ const succeeded = results.flatMap(result => result.status === 'fulfilled' ? [result.value] : []);
4280
+ const failed = request.files.filter((_, index) => results[index].status === 'rejected');
4281
+ try {
4282
+ if (succeeded.length)
4283
+ request.apply(succeeded);
4284
+ }
4285
+ catch (error) {
4286
+ this.error.set(error instanceof Error ? error.message : 'Could not save uploaded files.');
4287
+ this.failed = null;
4288
+ this.canRetry.set(false);
4289
+ this.uploading.set(false);
4290
+ return;
4291
+ }
4292
+ if (failed.length) {
4293
+ const reason = results.find(result => result.status === 'rejected');
4294
+ this.error.set(`Could not upload ${failed.length} file(s): ${reason.reason instanceof Error ? reason.reason.message : 'Upload failed'}`);
4295
+ const retryable = failed.filter(file => (!request.accept || request.accept(file)) && (request.maxFileSize === undefined || file.size <= request.maxFileSize));
4296
+ this.failed = retryable.length ? { ...request, files: retryable } : null;
4297
+ this.canRetry.set(!!this.failed);
4298
+ }
4299
+ this.uploading.set(false);
4300
+ }
4301
+ }
4302
+ function abortable(work, signal) {
4303
+ return new Promise((resolve, reject) => {
4304
+ const abort = () => reject(new DOMException('Upload cancelled', 'AbortError'));
4305
+ signal.addEventListener('abort', abort, { once: true });
4306
+ work.then(value => { signal.removeEventListener('abort', abort); resolve(value); }, error => { signal.removeEventListener('abort', abort); reject(error); });
4307
+ if (signal.aborted)
4308
+ abort();
4309
+ });
4310
+ }
4311
+
4312
+ /** Shared native inputs and root history for the built-in block editors. */
4313
+ class ContentEditorBlockBase {
4314
+ store = inject(ContentBuilderStore);
4315
+ builder = inject(CONTENT_BUILDER);
4316
+ element = inject(ElementRef).nativeElement;
4317
+ id = input.required(/* @ts-ignore */
4318
+ ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
4319
+ content = input.required(/* @ts-ignore */
4320
+ ...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
4321
+ settings = input.required(/* @ts-ignore */
4322
+ ...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
4323
+ index = input(0, /* @ts-ignore */
4324
+ ...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
4325
+ props = input([], /* @ts-ignore */
4326
+ ...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
4327
+ initialized = signal(true, /* @ts-ignore */
4328
+ ...(ngDevMode ? [{ debugName: "initialized" }] : /* istanbul ignore next */ []));
4329
+ constructor() {
4330
+ effect(() => {
4331
+ if (this.store.focusedBlockId() === this.id())
4332
+ untracked(() => this.focus());
4333
+ });
4334
+ }
4335
+ focus() { this.element.querySelector('[contenteditable="true"], input, button')?.focus(); }
4336
+ getData() { return { content: this.content(), settings: this.settings(), props: this.props() }; }
4337
+ isEmpty() {
4338
+ const block = findContentEditorBlock(this.store.editor.document().blocks, this.id());
4339
+ return !block || isContentEditorBlockEmpty(block);
4340
+ }
4341
+ save(content, settings = this.settings()) { this.store.updateBlock(this.id(), { content, settings }); }
4342
+ latestContent() {
4343
+ const block = findContentEditorBlock(this.store.editor.document().blocks, this.id());
4344
+ return block ? contentEditorBlockView(block).content : this.content();
4345
+ }
4346
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorBlockBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
4347
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.7", type: ContentEditorBlockBase, isStandalone: true, inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: true, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: true, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: true, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
4348
+ }
4349
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorBlockBase, decorators: [{
4350
+ type: Directive
4351
+ }], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: true }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: true }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: true }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }] } });
4352
+
4353
+ class ContentEditorUploadBlockBase extends ContentEditorBlockBase {
4354
+ uploadTask = new ContentEditorUploadTask(() => !this.store.editor.readOnly() && !!findContentEditorBlock(this.store.editor.document().blocks, this.id()));
4355
+ uploading = this.uploadTask.uploading;
4356
+ error = this.uploadTask.error;
4357
+ constructor() {
4358
+ super();
4359
+ effect(() => {
4360
+ if (this.store.editor.readOnly() || !findContentEditorBlock(this.store.editor.document().blocks, this.id()))
4361
+ this.uploadTask.cancel();
4362
+ });
4363
+ inject(DestroyRef).onDestroy(() => this.uploadTask.cancel());
4364
+ }
4365
+ uploadFiles(type, request) {
4366
+ return this.uploadTask.run({ ...request,
4367
+ urlKind: request.urlKind ?? (type === 'video' ? 'media' : type === 'image' || type === 'gallery' ? 'image' : 'attachment'),
4368
+ upload: this.builder.getBlockDefOption(type, 'uploadFn'),
4369
+ maxFileSize: this.builder.getBlockDefOption(type, 'maxFileSize')
4370
+ });
4371
+ }
4372
+ cancelUpload() { this.uploadTask.cancel(); }
4373
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorUploadBlockBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
4374
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.7", type: ContentEditorUploadBlockBase, isStandalone: true, usesInheritance: true, ngImport: i0 });
4375
+ }
4376
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorUploadBlockBase, decorators: [{
4377
+ type: Directive
4378
+ }], ctorParameters: () => [] });
4379
+
3305
4380
  /**
3306
4381
  * Generated bundle index. Do not edit.
3307
4382
  */
3308
4383
 
3309
- export { contentEditorImageToHtml as $, ContentEditorCodeRenderer as A, BlockSelectionDirective as B, ContentBuilderStore as C, ContentEditorDividerRenderer as D, ContentEditorEmbedRenderer as E, ContentEditorGalleryRenderer as F, ContentEditorGridRenderer as G, ContentEditorHeadingRenderer as H, ContentEditorHtmlSerializer as I, ContentEditorImageRenderer as J, ContentEditorListRenderer as K, ContentEditorParagraphRenderer as L, ContentEditorQuoteRenderer as M, ContentEditorRenderer as N, ContentEditorTableRenderer as O, ContentEditorToggleRenderer as P, ContentEditorVideoRenderer as Q, contentEditorAttachmentToHtml as R, contentEditorBlockToHtml as S, TextSelectionPopupDirective as T, contentEditorCalloutToHtml as U, contentEditorCodeToHtml as V, contentEditorDividerToHtml as W, contentEditorEmbedToHtml as X, contentEditorGalleryToHtml as Y, contentEditorGridToHtml as Z, contentEditorHeadingToHtml as _, CONTENT_BUILDER as a, contentEditorListToHtml as a0, contentEditorNativeBlock as a1, contentEditorParagraphToHtml as a2, contentEditorQuoteToHtml as a3, contentEditorTableToHtml as a4, contentEditorToHtml as a5, contentEditorToggleToHtml as a6, contentEditorVideoToHtml as a7, mergeContentEditorConfig as a8, provideContentEditor as a9, provideContentEditorConfig as aa, provideContentEditorRenderer as ab, provideContentEditorRenderers as ac, replaceContentEditorCollection as ad, contentEditorText as b, cloneContentEditorValue as c, ContentEditorContentEditableDirective as d, CONTENT_EDITOR_BLOCK as e, contentEditorFileSize as f, contentEditorResourceUrl as g, findContentEditorBlock as h, contentEditorGridSettings as i, emptyGridCell as j, contentEditorCollection as k, contentEditorBlockView as l, contentEditorChildCollections as m, isContentEditorBlockEmpty as n, CONTENT_EDITOR_BLOCK_RENDERERS as o, CONTENT_EDITOR_CALLOUT_HTML_STYLES as p, CONTENT_EDITOR_CONFIG as q, readContentEditorFile as r, CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS as s, CONTENT_EDITOR_DEFAULT_RENDERERS as t, CONTENT_EDITOR_GALLERY_HTML_STYLES as u, CONTENT_EDITOR_GRID_HTML_STYLES as v, CommandBarComponent as w, ContentBuilderComponent as x, ContentEditorAttachmentRenderer as y, ContentEditorCalloutRenderer as z };
3310
- //# sourceMappingURL=ngstarter-ui-components-content-editor-ngstarter-ui-components-content-editor--rb3-UuO.mjs.map
4384
+ export { contentEditorBlockToHtml as $, ContentEditorAttachmentRenderer as A, BlockSelectionDirective as B, ContentBuilderStore as C, ContentEditorCalloutRenderer as D, ContentEditorCodeRenderer as E, ContentEditorDividerRenderer as F, ContentEditorDraftController as G, ContentEditorEmbedRenderer as H, ContentEditorGalleryRenderer as I, ContentEditorGridRenderer as J, ContentEditorHeadingRenderer as K, ContentEditorHtmlSerializer as L, ContentEditorImageRenderer as M, ContentEditorImportError as N, ContentEditorImporter as O, ContentEditorListRenderer as P, ContentEditorParagraphRenderer as Q, ContentEditorQuoteRenderer as R, ContentEditorRenderer as S, ContentEditorRendererBase as T, ContentEditorTableRenderer as U, ContentEditorToggleRenderer as V, ContentEditorUploadTask as W, ContentEditorVideoRenderer as X, TextSelectionPopupDirective as Y, contentEditorAttachmentToHtml as Z, contentEditorBlockScope as _, CONTENT_BUILDER as a, contentEditorCalloutToHtml as a0, contentEditorCodeToHtml as a1, contentEditorConvertBlock as a2, contentEditorCopyBlocks as a3, contentEditorDividerToHtml as a4, contentEditorEmbedToHtml as a5, contentEditorFromHtml as a6, contentEditorFromJson as a7, contentEditorGalleryToHtml as a8, contentEditorGridToHtml as a9, contentEditorHeadingToHtml as aa, contentEditorImageToHtml as ab, contentEditorListToHtml as ac, contentEditorNativeBlock as ad, contentEditorParagraphToHtml as ae, contentEditorQuoteToHtml as af, contentEditorSliceText as ag, contentEditorTableToHtml as ah, contentEditorToHtml as ai, contentEditorToggleToHtml as aj, contentEditorVideoToHtml as ak, isContentEditorBlockEmpty as al, mergeContentEditorConfig as am, provideContentEditor as an, provideContentEditorConfig as ao, provideContentEditorRenderer as ap, provideContentEditorRenderers as aq, readContentEditorFile as ar, replaceContentEditorCollection as as, contentEditorText as b, cloneContentEditorValue as c, ContentEditorContentEditableDirective as d, CONTENT_EDITOR_BLOCK as e, ContentEditorUploadBlockBase as f, ContentEditorBlockBase as g, contentEditorFileSize as h, contentEditorResourceUrl as i, contentEditorGridSettings as j, findContentEditorBlock as k, emptyGridCell as l, contentEditorCollection as m, contentEditorBlockView as n, contentEditorChildCollections as o, CONTENT_EDITOR_BLOCK_RENDERERS as p, CONTENT_EDITOR_CALLOUT_HTML_STYLES as q, CONTENT_EDITOR_CONFIG as r, CONTENT_EDITOR_CONVERTIBLE_BLOCKS as s, CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS as t, CONTENT_EDITOR_DEFAULT_RENDERERS as u, CONTENT_EDITOR_GALLERY_HTML_STYLES as v, CONTENT_EDITOR_GRID_HTML_STYLES as w, CONTENT_EDITOR_RENDER_CONFIG as x, CommandBarComponent as y, ContentBuilderComponent as z };
4385
+ //# sourceMappingURL=ngstarter-ui-components-content-editor-ngstarter-ui-components-content-editor-CR-NrarE.mjs.map