@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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ngstarter-ui/components",
3
3
  "description": "NgStarter - AI-friendly Enterprise Angular UI Components and Admin Panel",
4
- "version": "22.2.2",
4
+ "version": "22.2.4",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/elementarlabsdev/ngstarter.git"
@@ -79,6 +79,8 @@
79
79
  "registry": "https://registry.npmjs.org/"
80
80
  },
81
81
  "exports": {
82
+ "./content-editor/document.schema.json": "./content-editor/document.schema.json",
83
+ "./content-editor/BLOCK_FORMAT.md": "./content-editor/BLOCK_FORMAT.md",
82
84
  "./ai/*": "./ai/*",
83
85
  "./styles/*": "./styles/*",
84
86
  "./styles/themes/*": "./styles/themes/*",
@@ -1,7 +1,7 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { InjectionToken, Signal, Type, InputSignal, EnvironmentProviders, OnDestroy, OnInit, AfterViewInit, EventEmitter, ViewContainerRef, ElementRef, Renderer2, NgZone, Provider } from '@angular/core';
3
3
  import * as _ngstarter_ui_components_headless_editor from '@ngstarter-ui/components/headless-editor';
4
- import { NgsHeadlessEditor, NgsHeadlessEditorMark, NgsHeadlessEditorBlock, NgsHeadlessEditorText, NgsHeadlessEditorDocument } from '@ngstarter-ui/components/headless-editor';
4
+ import { NgsHeadlessEditor, NgsHeadlessEditorMark, NgsHeadlessEditorBlock, NgsHeadlessEditorText, NgsHeadlessEditorDocument, NgsHeadlessEditorMarkDefinition, NgsHeadlessEditorChangeOrigin, NgsHeadlessEditorSelection } from '@ngstarter-ui/components/headless-editor';
5
5
  import * as _ngstarter_ui_components_content_editor from '@ngstarter-ui/components/content-editor';
6
6
  import { CdkDropList, CdkDragDrop, CdkDrag, CdkDragStart } from '@angular/cdk/drag-drop';
7
7
  import { Menu, MenuCloseReason } from '@ngstarter-ui/components/menu';
@@ -76,6 +76,35 @@ interface ContentEditorBlockEmpty {
76
76
  type ContentEditorDocument = NgsHeadlessEditorDocument;
77
77
  type ContentEditorBlock<TContent = unknown> = NgsHeadlessEditorBlock<TContent>;
78
78
  type ContentEditorText = readonly NgsHeadlessEditorText[];
79
+ type ContentEditorBuiltinBlockType = 'paragraph' | 'heading' | 'code' | 'divider' | 'bulletList' | 'orderedList' | 'quote' | 'table' | 'image' | 'video' | 'embed' | 'callout' | 'toggle' | 'attachment' | 'gallery' | 'grid';
80
+ type ContentEditorDimension = number | 'auto' | null;
81
+ interface ContentEditorQuoteContent {
82
+ cite: {
83
+ content: ContentEditorText;
84
+ props?: ContentEditorItemProperty[];
85
+ };
86
+ caption: {
87
+ content: ContentEditorText;
88
+ props?: ContentEditorItemProperty[];
89
+ };
90
+ }
91
+ interface ContentEditorTableCellMetadata {
92
+ props?: ContentEditorItemProperty[];
93
+ options?: {
94
+ colspan?: number;
95
+ rowspan?: number;
96
+ width?: ContentEditorDimension;
97
+ };
98
+ styles?: Readonly<Record<string, unknown>>;
99
+ [key: string]: unknown;
100
+ }
101
+ interface ContentEditorTableAttributes {
102
+ rows: readonly (readonly ContentEditorText[])[];
103
+ header?: boolean;
104
+ cellMetadata?: readonly (readonly ContentEditorTableCellMetadata[])[];
105
+ settings?: ContentEditorTableBlockSettings;
106
+ props?: ContentEditorItemProperty[];
107
+ }
79
108
  type ContentEditorCalloutVariant = 'note' | 'tip' | 'warning' | 'danger';
80
109
  interface ContentEditorCalloutSettings {
81
110
  variant: ContentEditorCalloutVariant;
@@ -125,7 +154,13 @@ interface ContentEditorBlockInsertionTarget {
125
154
  scope: ContentEditorBlockScope;
126
155
  afterId?: string;
127
156
  }
128
- type ContentEditorUploadFn = (file: File, dataUrl: string) => Promise<string>;
157
+ interface ContentEditorUploadContext {
158
+ /** Abort the transport when cancelled, replaced or the block is removed. */
159
+ signal: AbortSignal;
160
+ /** Report transport progress from 0 to 100; omit for indeterminate progress. */
161
+ onProgress(percent: number): void;
162
+ }
163
+ type ContentEditorUploadFn = (file: File, dataUrl: string, context: ContentEditorUploadContext) => Promise<string>;
129
164
  /** UI input view of a native document block. Never used as the saved document. */
130
165
  interface ContentEditorBlockView {
131
166
  id: string;
@@ -177,20 +212,20 @@ interface ContentEditorEmbedContent {
177
212
  type: string;
178
213
  }
179
214
  interface ContentEditorImageBlockSettings {
180
- width?: number;
181
- height?: number;
182
- actualWidth?: number;
183
- actualHeight?: number;
215
+ width?: ContentEditorDimension;
216
+ height?: ContentEditorDimension;
217
+ actualWidth?: ContentEditorDimension;
218
+ actualHeight?: ContentEditorDimension;
184
219
  }
185
220
  interface ContentEditorVideoBlockSettings {
186
- width?: number;
187
- height?: number;
188
- actualWidth?: number;
189
- actualHeight?: number;
221
+ width?: ContentEditorDimension;
222
+ height?: ContentEditorDimension;
223
+ actualWidth?: ContentEditorDimension;
224
+ actualHeight?: ContentEditorDimension;
190
225
  }
191
226
  interface ContentEditorEmbedBlockSettings {
192
- width: number | null;
193
- height: number | null;
227
+ width?: ContentEditorDimension;
228
+ height?: ContentEditorDimension;
194
229
  }
195
230
  interface ContentEditorListItem {
196
231
  content: ContentEditorText;
@@ -233,23 +268,118 @@ interface ContentEditorBlockRendererInputSignals<TContent = unknown, TSettings =
233
268
  index: InputSignal<number>;
234
269
  }
235
270
 
271
+ type ContentEditorDraftStatus = 'disabled' | 'idle' | 'saving' | 'saved' | 'error';
272
+ interface ContentEditorDraftStorage {
273
+ getItem(key: string): string | null;
274
+ setItem(key: string, value: string): void;
275
+ removeItem(key: string): void;
276
+ }
277
+ interface ContentEditorDraftConfig {
278
+ storage?: ContentEditorDraftStorage;
279
+ debounceMs?: number;
280
+ }
281
+ /** Delayed persistence keeps storage errors visible and flushes before switching documents. */
282
+ declare class ContentEditorDraftController {
283
+ readonly status: _angular_core.WritableSignal<ContentEditorDraftStatus>;
284
+ readonly error: _angular_core.WritableSignal<string>;
285
+ readonly savedAt: _angular_core.WritableSignal<number | null>;
286
+ private key;
287
+ private storage;
288
+ private debounceMs;
289
+ private enabled;
290
+ private pending;
291
+ private timer;
292
+ configure(key: string, enabled: boolean, config?: ContentEditorDraftConfig): void;
293
+ read(validate: (source: unknown) => ContentEditorDocument): ContentEditorDocument | null;
294
+ schedule(document: ContentEditorDocument): void;
295
+ flush(): void;
296
+ clear(): void;
297
+ private fail;
298
+ }
299
+
300
+ interface ContentEditorImportOptions {
301
+ /** Maximum JSON/HTML nesting depth. Default: 64. */
302
+ maxDepth?: number;
303
+ /** Maximum number of document blocks, including nested blocks. Default: 10000. */
304
+ maxBlocks?: number;
305
+ /** Preserve application-defined JSON block types. Default: false. */
306
+ allowUnknownBlocks?: boolean;
307
+ }
308
+ interface ContentEditorImportPlacement {
309
+ /** Replace the document (default), or insert into a block collection. */
310
+ mode?: 'replace' | 'insert';
311
+ /** Defaults to the active collection and block when inserting. */
312
+ target?: ContentEditorBlockInsertionTarget;
313
+ }
314
+ interface ContentEditorHtmlImportOptions extends ContentEditorImportOptions {
315
+ /** A DOM document supplied by the application, useful for server-side parsers. */
316
+ document?: Document;
317
+ }
318
+ interface ContentEditorHtmlImportContext {
319
+ createBlock(type: string, content: unknown, attrs?: Readonly<Record<string, unknown>>): ContentEditorBlock;
320
+ createId(prefix?: string): string;
321
+ parseBlocks(element: Element): readonly ContentEditorBlock[];
322
+ parseText(element: Element): ContentEditorText;
323
+ /** Uses the built-in parser for this element without invoking the override again. */
324
+ defaultFromHtml(element: Element): readonly ContentEditorBlock[];
325
+ safeUrl(value: unknown, kind?: ContentEditorHtmlUrlKind): string | null;
326
+ }
327
+ interface ContentEditorBlockHtmlImporter {
328
+ /** CSS selector matched against the source element. Overrides run before built-ins. */
329
+ selector: string;
330
+ parse(element: Element, context: ContentEditorHtmlImportContext): ContentEditorBlock | readonly ContentEditorBlock[] | null;
331
+ }
332
+ /** Return an error message to reject a block, or undefined to accept it. */
333
+ type ContentEditorBlockImportValidator = (block: ContentEditorBlock) => string | undefined;
334
+ /** Structured failure. The editor is never modified when parsing fails. */
335
+ declare class ContentEditorImportError extends Error {
336
+ readonly path: string;
337
+ constructor(path: string, message: string);
338
+ }
339
+ type ContentEditorImportMarkDefinition = NgsHeadlessEditorMarkDefinition;
340
+
236
341
  interface ContentEditorBlockConfig {
342
+ /** Eager component, or loadEditor for lazy loading; the lazy loader takes precedence. */
343
+ editor?: Type<unknown>;
344
+ loadEditor?: () => Promise<Type<unknown>>;
345
+ renderer?: Type<unknown>;
346
+ /** Native initial data. The editor supplies a fresh id and the configured type. */
347
+ create?: () => Pick<ContentEditorBlock, 'content' | 'attrs'>;
348
+ /** Adds the block to the global insertion menu. */
349
+ menu?: {
350
+ title: string;
351
+ description?: string;
352
+ iconName?: string;
353
+ settings?: Readonly<Record<string, unknown>>;
354
+ };
237
355
  toHtml?: ContentEditorBlockHtmlConverter;
356
+ fromHtml?: ContentEditorBlockHtmlImporter;
357
+ validateImport?: ContentEditorBlockImportValidator;
238
358
  options?: Readonly<Record<string, unknown>>;
239
359
  }
240
360
  interface ContentEditorConfig {
241
361
  blocks?: Readonly<Record<string, ContentEditorBlockConfig>>;
242
362
  marks?: Readonly<Record<string, ContentEditorMarkHtmlConverter>>;
243
363
  includeStyles?: boolean;
364
+ draft?: ContentEditorDraftConfig;
365
+ /** Additional or overridden mark definitions used when importing HTML. */
366
+ importMarks?: readonly ContentEditorImportMarkDefinition[];
244
367
  /** Unknown blocks throw by default to avoid silently losing saved content. */
245
368
  unknownBlockToHtml?: ContentEditorBlockHtmlConverter;
246
369
  }
370
+ /** Nested renderers inherit per-instance configuration through their parent. */
371
+ declare const CONTENT_EDITOR_RENDER_CONFIG: InjectionToken<Signal<ContentEditorConfig>>;
247
372
  declare const CONTENT_EDITOR_CONFIG: InjectionToken<ContentEditorConfig>;
248
373
  /** Later configurations override individual block fields, preserving unrelated options. */
249
374
  declare function mergeContentEditorConfig(...configs: readonly ContentEditorConfig[]): ContentEditorConfig;
250
375
  /** Application or route environment configuration. Child environments inherit parent settings. */
251
376
  declare function provideContentEditorConfig(config?: ContentEditorConfig): EnvironmentProviders;
252
377
 
378
+ type ContentEditorConvertibleBlockType = 'paragraph' | 'heading' | 'quote' | 'callout';
379
+ declare const CONTENT_EDITOR_CONVERTIBLE_BLOCKS: readonly ContentEditorConvertibleBlockType[];
380
+ /** Retains identity, rich text and alignment. Quote attribution becomes a final line. */
381
+ declare function contentEditorConvertBlock(block: ContentEditorBlock, type: ContentEditorConvertibleBlockType, settings?: Readonly<Record<string, unknown>>): ContentEditorBlock;
382
+
253
383
  /**
254
384
  * Directive to enable mouse-drag selection of child blocks inside a container.
255
385
  *
@@ -292,10 +422,20 @@ declare class ContentBuilderComponent implements OnInit, AfterViewInit, OnDestro
292
422
  readonly editor: NgsHeadlessEditor;
293
423
  private readonly globalConfig;
294
424
  private readonly htmlSerializer;
425
+ private readonly importer;
295
426
  readonly config: _angular_core.InputSignal<ContentEditorConfig>;
296
427
  /** One insertion menu shared by root controls, nested collections and custom blocks. */
428
+ readonly conversionMenu: _angular_core.Signal<Menu>;
429
+ readonly conversionTypes: readonly ContentEditorConvertibleBlockType[];
297
430
  readonly blockMenu: _angular_core.Signal<Menu>;
298
431
  private readonly document;
432
+ private readonly drafts;
433
+ readonly draftStatus: _angular_core.WritableSignal<_ngstarter_ui_components_content_editor.ContentEditorDraftStatus>;
434
+ readonly draftError: _angular_core.WritableSignal<string>;
435
+ readonly draftSavedAt: _angular_core.WritableSignal<number | null>;
436
+ readonly documentId: _angular_core.InputSignal<string | undefined>;
437
+ readonly draftDebounceMs: _angular_core.InputSignalWithTransform<number | undefined, unknown>;
438
+ private draftKey;
299
439
  private loaded;
300
440
  private lastInput;
301
441
  private _platformId;
@@ -326,12 +466,15 @@ declare class ContentBuilderComponent implements OnInit, AfterViewInit, OnDestro
326
466
  protected blockDefsOptionsMap: Map<string, any>;
327
467
  protected _blockDragging: _angular_core.WritableSignal<boolean>;
328
468
  isSelectionOfBlocksActive: _angular_core.WritableSignal<boolean>;
329
- readonly selectedBlocksModel: SelectionModel<unknown>;
469
+ readonly selectedBlocksModel: SelectionModel<string>;
330
470
  commandBar: typeof CommandBarComponent;
331
471
  get api(): {
332
472
  focusChanged: EventEmitter<void>;
333
473
  };
474
+ readonly insertionSuggestions: _angular_core.Signal<any[]>;
475
+ private readonly componentSources;
334
476
  private buildBlockDefMaps;
477
+ private resolvedBlockDefs;
335
478
  /** Shared by nested block collections; all edits use this root editor. */
336
479
  get rootBuilder(): ContentBuilderComponent;
337
480
  getBlockComponent(type: string): any;
@@ -357,6 +500,8 @@ declare class ContentBuilderComponent implements OnInit, AfterViewInit, OnDestro
357
500
  insertBlock(type: string, index: number, options?: object, focus?: boolean, content?: any): ContentEditorBlock;
358
501
  private _createBlock;
359
502
  addBlock(type: string, options: object, index?: number): void;
503
+ canConvertBlock(id: string): boolean;
504
+ convertBlock(id: string, type: ContentEditorConvertibleBlockType, settings?: Readonly<Record<string, unknown>>): boolean;
360
505
  duplicateBlock(blockId: string): void;
361
506
  private regenerateChildIds;
362
507
  duplicateSelectedBlocks(popover: Popover): void;
@@ -372,6 +517,13 @@ declare class ContentBuilderComponent implements OnInit, AfterViewInit, OnDestro
372
517
  readonly canEnterRoot: (_drag: CdkDrag, drop: CdkDropList) => boolean;
373
518
  onTagSelected(tagName: string | null): void;
374
519
  getData(): _ngstarter_ui_components_headless_editor.NgsHeadlessEditorDocument;
520
+ /** Structural HTML paste splits the active text block without flattening lists/tables. */
521
+ pasteBlocksAtSelection(id: string, imported: ContentEditorDocument, start: number, end: number): boolean;
522
+ /** Validates before replacing the document. Import is one undoable edit. */
523
+ importJson(source: unknown, config?: ContentEditorConfig, options?: ContentEditorImportOptions & ContentEditorImportPlacement): ContentEditorDocument;
524
+ importHtml(html: string, config?: ContentEditorConfig, options?: ContentEditorHtmlImportOptions & ContentEditorImportPlacement): ContentEditorDocument;
525
+ getInsertionTarget(): ContentEditorBlockInsertionTarget;
526
+ private applyImport;
375
527
  /** Exports the live document, including nested blocks, through the configured converters. */
376
528
  toHtml(config?: ContentEditorConfig): string;
377
529
  blockToHtml(block: ContentEditorBlock, config?: ContentEditorConfig): string;
@@ -390,18 +542,19 @@ declare class ContentBuilderComponent implements OnInit, AfterViewInit, OnDestro
390
542
  protected onFocusChange(origin: string | null, dataBlock: ContentEditorBlockView): void;
391
543
  protected onSuggestionsMenuClose(reason: MenuCloseReason): void;
392
544
  ngOnDestroy(): void;
545
+ private configureDraft;
393
546
  private _getDraftContent;
394
547
  private _saveDraft;
548
+ saveDraftNow(): void;
549
+ clearDraft(): void;
395
550
  private _canUseDraftStorage;
396
551
  private _getDraftStorageKey;
397
552
  onSettingsPopoverClose(): void;
398
553
  protected _onPaste(event: ClipboardEvent): void;
399
554
  private _handleTextPaste;
400
555
  private _handleHtmlPaste;
401
- private _mapNodeToBlock;
402
- private _mapListItems;
403
556
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<ContentBuilderComponent, never>;
404
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentBuilderComponent, "ngs-content-editor-builder", ["ngsContentEditorBuilder"], { "config": { "alias": "config"; "required": false; "isSignal": true; }; "content": { "alias": "content"; "required": false; "isSignal": true; }; "contentChangedDelay": { "alias": "contentChangedDelay"; "required": false; "isSignal": true; }; "persistDraft": { "alias": "persistDraft"; "required": false; "isSignal": true; }; "suggestions": { "alias": "suggestions"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; "scrollContainer": { "alias": "scrollContainer"; "required": false; "isSignal": true; }; }, { "contentChanged": "contentChanged"; }, never, never, true, [{ directive: typeof BlockSelectionDirective; inputs: { "autoScrollContainerSelector": "autoScrollContainerSelector"; }; outputs: {}; }]>;
557
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentBuilderComponent, "ngs-content-editor-builder", ["ngsContentEditorBuilder"], { "config": { "alias": "config"; "required": false; "isSignal": true; }; "documentId": { "alias": "documentId"; "required": false; "isSignal": true; }; "draftDebounceMs": { "alias": "draftDebounceMs"; "required": false; "isSignal": true; }; "content": { "alias": "content"; "required": false; "isSignal": true; }; "contentChangedDelay": { "alias": "contentChangedDelay"; "required": false; "isSignal": true; }; "persistDraft": { "alias": "persistDraft"; "required": false; "isSignal": true; }; "suggestions": { "alias": "suggestions"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; "scrollContainer": { "alias": "scrollContainer"; "required": false; "isSignal": true; }; }, { "contentChanged": "contentChanged"; }, never, never, true, [{ directive: typeof BlockSelectionDirective; inputs: { "autoScrollContainerSelector": "autoScrollContainerSelector"; }; outputs: {}; }]>;
405
558
  }
406
559
 
407
560
  interface ContentEditorRenderItem {
@@ -410,6 +563,9 @@ interface ContentEditorRenderItem {
410
563
  inputs: ContentEditorBlockRendererInputs;
411
564
  }
412
565
  declare class ContentEditorRenderer {
566
+ private readonly globalConfig;
567
+ private readonly parentConfig;
568
+ readonly resolvedConfig: _angular_core.Signal<ContentEditorConfig>;
413
569
  private readonly htmlSerializer;
414
570
  readonly config: _angular_core.InputSignal<ContentEditorConfig>;
415
571
  private readonly providedRendererGroups;
@@ -697,6 +853,28 @@ declare function contentEditorCollection(blocks: readonly NgsHeadlessEditorBlock
697
853
  declare function replaceContentEditorCollection(blocks: NgsHeadlessEditorBlock[], scope: ContentEditorBlockScope, value: readonly NgsHeadlessEditorBlock[]): void;
698
854
  /** Mutable UI payloads must not mutate saved documents or undo snapshots. */
699
855
  declare function cloneContentEditorValue<T>(value: T): T;
856
+ /** Locates the collection owning a block, including deeply nested Grid/Toggle blocks. */
857
+ declare function contentEditorBlockScope(blocks: readonly NgsHeadlessEditorBlock[], id: string, scope?: ContentEditorBlockScope): ContentEditorBlockScope | null;
858
+ /** Copies for insertion/duplication receive fresh ids throughout the tree. */
859
+ declare function contentEditorCopyBlocks(blocks: readonly NgsHeadlessEditorBlock[]): NgsHeadlessEditorBlock[];
860
+ /** UTF-16 offsets match the editor selection model; marks remain on sliced runs. */
861
+ declare function contentEditorSliceText(content: ContentEditorText, start: number, end?: number): ContentEditorText;
862
+
863
+ /** Parses and validates the native version-1 format without changing the caller's objects. */
864
+ declare function contentEditorFromJson(source: unknown, config?: ContentEditorConfig, options?: ContentEditorImportOptions): ContentEditorDocument;
865
+
866
+ /** Imports semantic HTML into native blocks. Scripts, event handlers and arbitrary CSS are never stored. */
867
+ declare function contentEditorFromHtml(html: string, config?: ContentEditorConfig, options?: ContentEditorHtmlImportOptions): ContentEditorDocument;
868
+
869
+ /** Parsing only: applications decide when to replace their current document. */
870
+ declare class ContentEditorImporter {
871
+ private readonly config;
872
+ private readonly document;
873
+ fromJson(source: unknown, config?: ContentEditorConfig, options?: ContentEditorImportOptions): _ngstarter_ui_components_headless_editor.NgsHeadlessEditorDocument;
874
+ fromHtml(html: string, config?: ContentEditorConfig, options?: ContentEditorHtmlImportOptions): _ngstarter_ui_components_headless_editor.NgsHeadlessEditorDocument;
875
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ContentEditorImporter, never>;
876
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<any>;
877
+ }
700
878
 
701
879
  /** Shared marks and commands for content editing and read-only rendering. */
702
880
  declare function provideContentEditor(): Provider[];
@@ -756,5 +934,111 @@ declare class ContentEditorGridRenderer extends ContentEditorRendererBase<Conten
756
934
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentEditorGridRenderer, "ngs-content-editor-grid-renderer", never, {}, {}, never, never, true, never>;
757
935
  }
758
936
 
759
- export { BlockSelectionDirective, CONTENT_BUILDER, CONTENT_EDITOR_BLOCK, CONTENT_EDITOR_BLOCK_RENDERERS, CONTENT_EDITOR_CALLOUT_HTML_STYLES, CONTENT_EDITOR_CONFIG, CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS, CONTENT_EDITOR_DEFAULT_RENDERERS, CONTENT_EDITOR_GALLERY_HTML_STYLES, CONTENT_EDITOR_GRID_HTML_STYLES, CommandBarComponent, ContentBuilderComponent, ContentEditorAttachmentRenderer, ContentEditorCalloutRenderer, ContentEditorCodeRenderer, ContentEditorDividerRenderer, ContentEditorEmbedRenderer, ContentEditorGalleryRenderer, ContentEditorGridRenderer, ContentEditorHeadingRenderer, ContentEditorHtmlSerializer, ContentEditorImageRenderer, ContentEditorListRenderer, ContentEditorParagraphRenderer, ContentEditorQuoteRenderer, ContentEditorRenderer, ContentEditorTableRenderer, ContentEditorToggleRenderer, ContentEditorVideoRenderer, TextSelectionPopupDirective, cloneContentEditorValue, contentEditorAttachmentToHtml, contentEditorBlockToHtml, contentEditorBlockView, contentEditorCalloutToHtml, contentEditorChildCollections, contentEditorCodeToHtml, contentEditorCollection, contentEditorDividerToHtml, contentEditorEmbedToHtml, contentEditorGalleryToHtml, contentEditorGridToHtml, contentEditorHeadingToHtml, contentEditorImageToHtml, contentEditorListToHtml, contentEditorNativeBlock, contentEditorParagraphToHtml, contentEditorQuoteToHtml, contentEditorTableToHtml, contentEditorText, contentEditorToHtml, contentEditorToggleToHtml, contentEditorVideoToHtml, findContentEditorBlock, isContentEditorBlockEmpty, mergeContentEditorConfig, provideContentEditor, provideContentEditorConfig, provideContentEditorRenderer, provideContentEditorRenderers, replaceContentEditorCollection };
760
- export type { ContentEditorAttachmentContent, ContentEditorBlock, ContentEditorBlockConfig, ContentEditorBlockDef, ContentEditorBlockEmpty, ContentEditorBlockHtmlConverter, ContentEditorBlockInsertionTarget, ContentEditorBlockRendererDef, ContentEditorBlockRendererInputSignals, ContentEditorBlockRendererInputs, ContentEditorBlockScope, ContentEditorBlockView, ContentEditorCalloutSettings, ContentEditorCalloutVariant, ContentEditorCodeRendererSettings, ContentEditorConfig, ContentEditorDataBlock, ContentEditorDocument, ContentEditorEmbedBlockSettings, ContentEditorEmbedContent, ContentEditorGalleryContent, ContentEditorGalleryImage, ContentEditorGridCell, ContentEditorGridContent, ContentEditorGridGap, ContentEditorGridSettings, ContentEditorHeadingBlockSettings, ContentEditorHtmlContext, ContentEditorHtmlUrlKind, ContentEditorImageBlockSettings, ContentEditorImageContent, ContentEditorItemProperty, ContentEditorListItem, ContentEditorListSettings, ContentEditorMarkHtmlConverter, ContentEditorOptions, ContentEditorQuoteRendererContent, ContentEditorQuoteRendererContentPart, ContentEditorSuggestionHeading, ContentEditorSuggestionItem, ContentEditorTableBlockSettings, ContentEditorTableCell, ContentEditorText, ContentEditorToggleContent, ContentEditorToggleSettings, ContentEditorUploadFn, ContentEditorVideoBlockSettings, ContentEditorVideoContent, ISelectionPopupComponent };
937
+ interface ContentEditorUploadedFile {
938
+ file: File;
939
+ url: string;
940
+ dataUrl: string;
941
+ }
942
+ interface ContentEditorUploadRequest {
943
+ files: readonly File[];
944
+ upload: ContentEditorUploadFn;
945
+ accept?: (file: File) => boolean;
946
+ urlKind?: ContentEditorHtmlUrlKind;
947
+ maxFileSize?: number;
948
+ apply(results: readonly ContentEditorUploadedFile[]): void;
949
+ }
950
+ /** One cancellable request per block. Retry only sends failed files again. */
951
+ declare class ContentEditorUploadTask {
952
+ private readonly writable;
953
+ readonly uploading: _angular_core.WritableSignal<boolean>;
954
+ readonly progress: _angular_core.WritableSignal<number | null>;
955
+ readonly error: _angular_core.WritableSignal<string>;
956
+ readonly canRetry: _angular_core.WritableSignal<boolean>;
957
+ private controller;
958
+ private failed;
959
+ constructor(writable: () => boolean);
960
+ cancel(): void;
961
+ retry(): Promise<void>;
962
+ run(request: ContentEditorUploadRequest): Promise<void>;
963
+ }
964
+
965
+ /** UI state and block operations. The headless document is the only content store. */
966
+ declare class ContentBuilderStore {
967
+ readonly editor: NgsHeadlessEditor;
968
+ private dragging;
969
+ constructor();
970
+ private textEdit;
971
+ /** Scopes typing groups to one text region, so adjacent cells never share undo. */
972
+ withTextEdit(origin: NgsHeadlessEditorChangeOrigin, group: string, edit: () => void): void;
973
+ readonly insertionTarget: _angular_core.WritableSignal<ContentEditorBlockInsertionTarget>;
974
+ readonly restoreTextSelection: _angular_core.WritableSignal<{
975
+ blockId: string;
976
+ selection: NgsHeadlessEditorSelection;
977
+ } | null>;
978
+ readonly focusedBlockId: _angular_core.WritableSignal<string | null>;
979
+ readonly activeBlockId: _angular_core.WritableSignal<string | null>;
980
+ readonly dragPointer: _angular_core.WritableSignal<{
981
+ x: number;
982
+ y: number;
983
+ } | null>;
984
+ setDragging(dragging: boolean): void;
985
+ readonly dropLists: _angular_core.WritableSignal<CdkDropList<ContentEditorBlockScope>[]>;
986
+ registerDropList(list: CdkDropList<ContentEditorBlockScope>): void;
987
+ unregisterDropList(list: CdkDropList<ContentEditorBlockScope>): void;
988
+ readonly blocks: _angular_core.Signal<ContentEditorBlockView[]>;
989
+ setFocusedBlockId(id: string | null): void;
990
+ setActiveBlockId(id: string | null): void;
991
+ setBlocks(value: ContentEditorDocument): void;
992
+ addBlock(block: ContentEditorBlockView, index: number, scope?: ContentEditorBlockScope): void;
993
+ deleteBlock(id: string, _index: number): void;
994
+ deleteBlocks(ids: readonly string[]): void;
995
+ updateBlock(id: string, data: Partial<ContentEditorBlockView>): void;
996
+ moveBlock(from: number, to: number): void;
997
+ moveBetweenCollections(from: number, to: number, source: ContentEditorBlockScope, target: ContentEditorBlockScope): void;
998
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ContentBuilderStore, never>;
999
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<any>;
1000
+ }
1001
+
1002
+ /** Shared native inputs and root history for the built-in block editors. */
1003
+ declare abstract class ContentEditorBlockBase<T, S extends object = Record<string, unknown>> implements ContentEditorDataBlock {
1004
+ protected readonly store: ContentBuilderStore;
1005
+ protected readonly builder: ContentBuilderComponent;
1006
+ protected readonly element: HTMLElement;
1007
+ readonly id: _angular_core.InputSignal<string>;
1008
+ readonly content: _angular_core.InputSignal<T>;
1009
+ readonly settings: _angular_core.InputSignal<S>;
1010
+ readonly index: _angular_core.InputSignal<number>;
1011
+ readonly props: _angular_core.InputSignal<ContentEditorItemProperty[]>;
1012
+ readonly initialized: _angular_core.WritableSignal<boolean>;
1013
+ constructor();
1014
+ focus(): void;
1015
+ getData(): {
1016
+ content: T;
1017
+ settings: S;
1018
+ props: ContentEditorItemProperty[];
1019
+ };
1020
+ isEmpty(): boolean;
1021
+ protected save(content: T, settings?: S): void;
1022
+ protected latestContent(): T;
1023
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ContentEditorBlockBase<any, any>, never>;
1024
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<ContentEditorBlockBase<any, any>, never, never, { "id": { "alias": "id"; "required": true; "isSignal": true; }; "content": { "alias": "content"; "required": true; "isSignal": true; }; "settings": { "alias": "settings"; "required": true; "isSignal": true; }; "index": { "alias": "index"; "required": false; "isSignal": true; }; "props": { "alias": "props"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
1025
+ }
1026
+
1027
+ declare abstract class ContentEditorUploadBlockBase<T, S extends object = Record<string, unknown>> extends ContentEditorBlockBase<T, S> {
1028
+ readonly uploadTask: ContentEditorUploadTask;
1029
+ readonly uploading: _angular_core.WritableSignal<boolean>;
1030
+ readonly error: _angular_core.WritableSignal<string>;
1031
+ constructor();
1032
+ protected uploadFiles(type: string, request: Omit<ContentEditorUploadRequest, 'upload' | 'maxFileSize'>): Promise<void>;
1033
+ cancelUpload(): void;
1034
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ContentEditorUploadBlockBase<any, any>, never>;
1035
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<ContentEditorUploadBlockBase<any, any>, never, never, {}, {}, never, never, true, never>;
1036
+ }
1037
+
1038
+ /** Read files with actual cancellation and progress. */
1039
+ declare function readContentEditorFile(file: File, context?: ContentEditorUploadContext): Promise<string>;
1040
+ declare function contentEditorFileSize(size: number): string;
1041
+ declare function contentEditorResourceUrl(url: string): string;
1042
+
1043
+ export { BlockSelectionDirective, CONTENT_BUILDER, CONTENT_EDITOR_BLOCK, CONTENT_EDITOR_BLOCK_RENDERERS, CONTENT_EDITOR_CALLOUT_HTML_STYLES, CONTENT_EDITOR_CONFIG, CONTENT_EDITOR_CONVERTIBLE_BLOCKS, CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS, CONTENT_EDITOR_DEFAULT_RENDERERS, CONTENT_EDITOR_GALLERY_HTML_STYLES, CONTENT_EDITOR_GRID_HTML_STYLES, CONTENT_EDITOR_RENDER_CONFIG, CommandBarComponent, ContentBuilderComponent, ContentEditorAttachmentRenderer, ContentEditorBlockBase, ContentEditorCalloutRenderer, ContentEditorCodeRenderer, ContentEditorDividerRenderer, ContentEditorDraftController, ContentEditorEmbedRenderer, ContentEditorGalleryRenderer, ContentEditorGridRenderer, ContentEditorHeadingRenderer, ContentEditorHtmlSerializer, ContentEditorImageRenderer, ContentEditorImportError, ContentEditorImporter, ContentEditorListRenderer, ContentEditorParagraphRenderer, ContentEditorQuoteRenderer, ContentEditorRenderer, ContentEditorRendererBase, ContentEditorTableRenderer, ContentEditorToggleRenderer, ContentEditorUploadBlockBase, ContentEditorUploadTask, ContentEditorVideoRenderer, TextSelectionPopupDirective, cloneContentEditorValue, contentEditorAttachmentToHtml, contentEditorBlockScope, contentEditorBlockToHtml, contentEditorBlockView, contentEditorCalloutToHtml, contentEditorChildCollections, contentEditorCodeToHtml, contentEditorCollection, contentEditorConvertBlock, contentEditorCopyBlocks, contentEditorDividerToHtml, contentEditorEmbedToHtml, contentEditorFileSize, contentEditorFromHtml, contentEditorFromJson, contentEditorGalleryToHtml, contentEditorGridToHtml, contentEditorHeadingToHtml, contentEditorImageToHtml, contentEditorListToHtml, contentEditorNativeBlock, contentEditorParagraphToHtml, contentEditorQuoteToHtml, contentEditorResourceUrl, contentEditorSliceText, contentEditorTableToHtml, contentEditorText, contentEditorToHtml, contentEditorToggleToHtml, contentEditorVideoToHtml, findContentEditorBlock, isContentEditorBlockEmpty, mergeContentEditorConfig, provideContentEditor, provideContentEditorConfig, provideContentEditorRenderer, provideContentEditorRenderers, readContentEditorFile, replaceContentEditorCollection };
1044
+ export type { ContentEditorAttachmentContent, ContentEditorBlock, ContentEditorBlockConfig, ContentEditorBlockDef, ContentEditorBlockEmpty, ContentEditorBlockHtmlConverter, ContentEditorBlockHtmlImporter, ContentEditorBlockImportValidator, ContentEditorBlockInsertionTarget, ContentEditorBlockRendererDef, ContentEditorBlockRendererInputSignals, ContentEditorBlockRendererInputs, ContentEditorBlockScope, ContentEditorBlockView, ContentEditorBuiltinBlockType, ContentEditorCalloutSettings, ContentEditorCalloutVariant, ContentEditorCodeRendererSettings, ContentEditorConfig, ContentEditorConvertibleBlockType, ContentEditorDataBlock, ContentEditorDimension, ContentEditorDocument, ContentEditorDraftConfig, ContentEditorDraftStatus, ContentEditorDraftStorage, ContentEditorEmbedBlockSettings, ContentEditorEmbedContent, ContentEditorGalleryContent, ContentEditorGalleryImage, ContentEditorGridCell, ContentEditorGridContent, ContentEditorGridGap, ContentEditorGridSettings, ContentEditorHeadingBlockSettings, ContentEditorHtmlContext, ContentEditorHtmlImportContext, ContentEditorHtmlImportOptions, ContentEditorHtmlUrlKind, ContentEditorImageBlockSettings, ContentEditorImageContent, ContentEditorImportMarkDefinition, ContentEditorImportOptions, ContentEditorImportPlacement, ContentEditorItemProperty, ContentEditorListItem, ContentEditorListSettings, ContentEditorMarkHtmlConverter, ContentEditorOptions, ContentEditorQuoteContent, ContentEditorQuoteRendererContent, ContentEditorQuoteRendererContentPart, ContentEditorSuggestionHeading, ContentEditorSuggestionItem, ContentEditorTableAttributes, ContentEditorTableBlockSettings, ContentEditorTableCell, ContentEditorTableCellMetadata, ContentEditorText, ContentEditorToggleContent, ContentEditorToggleSettings, ContentEditorUploadContext, ContentEditorUploadFn, ContentEditorUploadRequest, ContentEditorUploadedFile, ContentEditorVideoBlockSettings, ContentEditorVideoContent, ISelectionPopupComponent };
@@ -117,6 +117,10 @@ declare class NgsHeadlessEditor {
117
117
  handleKeydown(event: KeyboardEvent): boolean;
118
118
  handlePaste(event: ClipboardEvent): boolean;
119
119
  insertText(text: string, origin?: NgsHeadlessEditorChangeOrigin): boolean;
120
+ /** Inserts structured inline runs in one history step, preserving their marks. */
121
+ insertTextContent(content: readonly NgsHeadlessEditorText[], origin?: NgsHeadlessEditorChangeOrigin): boolean;
122
+ /** Word deletion is model-driven on every platform, including Ctrl+Backspace on macOS. */
123
+ deleteWordBackward(): boolean;
120
124
  deleteBackward(): boolean;
121
125
  deleteForward(): boolean;
122
126
  deleteRange(selection: NgsHeadlessEditorSelection, origin: NgsHeadlessEditorChangeOrigin, historyGroup?: string | null): boolean;
@@ -381,7 +385,8 @@ declare class NgsHeadlessEditorSurface {
381
385
  /** Deletes the range the browser reports for a word/line deletion. */
382
386
  private deleteTargetRange;
383
387
  private readTargetRange;
384
- private syncSelectionFromDom;
388
+ /** Synchronizes the DOM range before an application handles a surface event. */
389
+ syncSelectionFromDom(): void;
385
390
  private readSelectionFromDom;
386
391
  private domPositionToPoint;
387
392
  /**
@@ -1,54 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { computed, ChangeDetectionStrategy, Component } from '@angular/core';
3
- import { UploadArea, UploadTriggerDirective } from '@ngstarter-ui/components/upload';
4
- import { ProgressBar } from '@ngstarter-ui/components/progress-bar';
5
- import { Alert } from '@ngstarter-ui/components/alert';
6
- import { Button } from '@ngstarter-ui/components/button';
7
- import { Icon } from '@ngstarter-ui/components/icon';
8
- import { FormField, Label } from '@ngstarter-ui/components/form-field';
9
- import { Input } from '@ngstarter-ui/components/input';
10
- import { C as ContentEditorUploadBlockBase } from './ngstarter-ui-components-content-editor-upload-block-base-D9ELpJr-.mjs';
11
- import { f as contentEditorFileSize, g as contentEditorResourceUrl, r as readContentEditorFile } from './ngstarter-ui-components-content-editor-ngstarter-ui-components-content-editor--rb3-UuO.mjs';
12
-
13
- class ContentEditorAttachmentBlock extends ContentEditorUploadBlockBase {
14
- sizeLabel = computed(() => contentEditorFileSize(this.content().size), /* @ts-ignore */
15
- ...(ngDevMode ? [{ debugName: "sizeLabel" }] : /* istanbul ignore next */ []));
16
- href = computed(() => contentEditorResourceUrl(this.content().url), /* @ts-ignore */
17
- ...(ngDevMode ? [{ debugName: "href" }] : /* istanbul ignore next */ []));
18
- changeName(event) { this.save({ ...this.latestContent(), name: event.target.value }); }
19
- async upload(event) {
20
- const file = event.files[0];
21
- if (!file)
22
- return;
23
- const request = this.beginUpload();
24
- try {
25
- const dataUrl = await readContentEditorFile(file);
26
- if (!this.isCurrentUpload(request))
27
- return;
28
- const uploadFn = this.builder.getBlockDefOption('attachment', 'uploadFn');
29
- const url = await uploadFn(file, dataUrl);
30
- if (!this.isCurrentUpload(request))
31
- return;
32
- if (typeof url !== 'string' || !contentEditorResourceUrl(url))
33
- throw new Error('Invalid file URL');
34
- this.save({ url, name: file.name, size: file.size, mimeType: file.type });
35
- }
36
- catch {
37
- if (this.isCurrentUpload(request))
38
- this.error.set('Could not upload the file. Please try again.');
39
- }
40
- finally {
41
- if (this.isCurrentUpload(request))
42
- this.uploading.set(false);
43
- }
44
- }
45
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorAttachmentBlock, deps: null, target: i0.ɵɵFactoryTarget.Component });
46
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorAttachmentBlock, isStandalone: true, selector: "ngs-content-editor-attachment-block", usesInheritance: true, ngImport: i0, template: "<div class=\"flex flex-col gap-3\">\n @if (href()) {\n <div class=\"flex items-center gap-3\">\n <ngs-icon name=\"fluent:document-24-regular\"/>\n <div class=\"min-w-0 flex-1\"><div class=\"truncate\">{{content().name}}</div><div class=\"text-xs\">{{sizeLabel()}} \u00B7 {{content().mimeType}}</div></div>\n <a ngsButton [href]=\"href()\" [attr.download]=\"content().name\" target=\"_blank\" rel=\"noopener noreferrer\">Download</a>\n </div>\n <ngs-form-field><ngs-label>File name</ngs-label><input ngsInput [value]=\"content().name\" (input)=\"changeName($event)\"></ngs-form-field>\n }\n @if (uploading()) {\n <ngs-progress-bar mode=\"indeterminate\"/>\n <button ngsButton (click)=\"cancelUpload()\">Cancel upload</button>\n } @else {\n <ngs-upload-area ngsUploadTrigger [multiple]=\"false\" (fileSelected)=\"upload($event)\">\n {{href() ? 'Click or drop a file to replace it' : 'Click or drop a file to attach it'}}\n </ngs-upload-area>\n }\n @if (error()) { <ngs-alert variant=\"negative\">{{error()}}</ngs-alert> }\n</div>\n", dependencies: [{ kind: "component", type: UploadArea, selector: "ngs-upload-area", inputs: ["accept", "allowHover", "multiple"], outputs: ["fileSelected"], exportAs: ["ngsUploadArea"] }, { kind: "directive", type: UploadTriggerDirective, selector: "[ngsUploadTrigger]", inputs: ["accept", "multiple"], outputs: ["fileSelected"], exportAs: ["ngsUploadTrigger"] }, { kind: "component", type: ProgressBar, selector: "ngs-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["ngsProgressBar"] }, { kind: "component", type: Alert, selector: "ngs-alert", inputs: ["autoClose", "bordered", "variant"], outputs: ["closed"], exportAs: ["ngsAlert"] }, { 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: FormField, selector: "ngs-form-field", inputs: ["labelMode", "subscriptHiddenIfEmpty", "sameHeightAsButton"], exportAs: ["ngsFormField"] }, { kind: "component", type: Label, selector: "ngs-label" }, { kind: "directive", type: Input, selector: "input[ngsInput], textarea[ngsInput]", inputs: ["id", "placeholder", "required", "disabled", "readonly", "errorStateMatcher"], exportAs: ["ngsInput"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
47
- }
48
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorAttachmentBlock, decorators: [{
49
- type: Component,
50
- args: [{ selector: 'ngs-content-editor-attachment-block', imports: [UploadArea, UploadTriggerDirective, ProgressBar, Alert, Button, Icon, FormField, Label, Input], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"flex flex-col gap-3\">\n @if (href()) {\n <div class=\"flex items-center gap-3\">\n <ngs-icon name=\"fluent:document-24-regular\"/>\n <div class=\"min-w-0 flex-1\"><div class=\"truncate\">{{content().name}}</div><div class=\"text-xs\">{{sizeLabel()}} \u00B7 {{content().mimeType}}</div></div>\n <a ngsButton [href]=\"href()\" [attr.download]=\"content().name\" target=\"_blank\" rel=\"noopener noreferrer\">Download</a>\n </div>\n <ngs-form-field><ngs-label>File name</ngs-label><input ngsInput [value]=\"content().name\" (input)=\"changeName($event)\"></ngs-form-field>\n }\n @if (uploading()) {\n <ngs-progress-bar mode=\"indeterminate\"/>\n <button ngsButton (click)=\"cancelUpload()\">Cancel upload</button>\n } @else {\n <ngs-upload-area ngsUploadTrigger [multiple]=\"false\" (fileSelected)=\"upload($event)\">\n {{href() ? 'Click or drop a file to replace it' : 'Click or drop a file to attach it'}}\n </ngs-upload-area>\n }\n @if (error()) { <ngs-alert variant=\"negative\">{{error()}}</ngs-alert> }\n</div>\n" }]
51
- }] });
52
-
53
- export { ContentEditorAttachmentBlock };
54
- //# sourceMappingURL=ngstarter-ui-components-content-editor-attachment-block-B2GUlWO2.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ngstarter-ui-components-content-editor-attachment-block-B2GUlWO2.mjs","sources":["../../../projects/components/content-editor/src/_builder/attachment-block/attachment-block.ts","../../../projects/components/content-editor/src/_builder/attachment-block/attachment-block.html"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed } from '@angular/core';\nimport { UploadArea, UploadTriggerDirective, UploadFileSelectedEvent } from '@ngstarter-ui/components/upload';\nimport { ProgressBar } from '@ngstarter-ui/components/progress-bar';\nimport { Alert } from '@ngstarter-ui/components/alert';\nimport { Button } from '@ngstarter-ui/components/button';\nimport { Icon } from '@ngstarter-ui/components/icon';\nimport { FormField, Label } from '@ngstarter-ui/components/form-field';\nimport { Input } from '@ngstarter-ui/components/input';\nimport { ContentEditorUploadBlockBase } from '../upload-block-base';\nimport { ContentEditorAttachmentContent, ContentEditorUploadFn } from '../../types';\nimport { contentEditorFileSize, contentEditorResourceUrl, readContentEditorFile } from '../../upload';\n\n@Component({\n selector: 'ngs-content-editor-attachment-block',\n imports: [UploadArea, UploadTriggerDirective, ProgressBar, Alert, Button, Icon, FormField, Label, Input],\n templateUrl: './attachment-block.html', changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class ContentEditorAttachmentBlock extends ContentEditorUploadBlockBase<ContentEditorAttachmentContent> {\n readonly sizeLabel = computed(() => contentEditorFileSize(this.content().size));\n readonly href = computed(() => contentEditorResourceUrl(this.content().url));\n changeName(event: Event): void { this.save({ ...this.latestContent(), name: (event.target as HTMLInputElement).value }); }\n async upload(event: UploadFileSelectedEvent): Promise<void> {\n const file = event.files[0];\n if (!file) return;\n const request = this.beginUpload();\n try {\n const dataUrl = await readContentEditorFile(file);\n if (!this.isCurrentUpload(request)) return;\n const uploadFn: ContentEditorUploadFn = this.builder.getBlockDefOption('attachment', 'uploadFn');\n const url = await uploadFn(file, dataUrl);\n if (!this.isCurrentUpload(request)) return;\n if (typeof url !== 'string' || !contentEditorResourceUrl(url)) throw new Error('Invalid file URL');\n this.save({ url, name: file.name, size: file.size, mimeType: file.type });\n } catch {\n if (this.isCurrentUpload(request)) this.error.set('Could not upload the file. Please try again.');\n } finally {\n if (this.isCurrentUpload(request)) this.uploading.set(false);\n }\n }\n}\n","<div class=\"flex flex-col gap-3\">\n @if (href()) {\n <div class=\"flex items-center gap-3\">\n <ngs-icon name=\"fluent:document-24-regular\"/>\n <div class=\"min-w-0 flex-1\"><div class=\"truncate\">{{content().name}}</div><div class=\"text-xs\">{{sizeLabel()}} · {{content().mimeType}}</div></div>\n <a ngsButton [href]=\"href()\" [attr.download]=\"content().name\" target=\"_blank\" rel=\"noopener noreferrer\">Download</a>\n </div>\n <ngs-form-field><ngs-label>File name</ngs-label><input ngsInput [value]=\"content().name\" (input)=\"changeName($event)\"></ngs-form-field>\n }\n @if (uploading()) {\n <ngs-progress-bar mode=\"indeterminate\"/>\n <button ngsButton (click)=\"cancelUpload()\">Cancel upload</button>\n } @else {\n <ngs-upload-area ngsUploadTrigger [multiple]=\"false\" (fileSelected)=\"upload($event)\">\n {{href() ? 'Click or drop a file to replace it' : 'Click or drop a file to attach it'}}\n </ngs-upload-area>\n }\n @if (error()) { <ngs-alert variant=\"negative\">{{error()}}</ngs-alert> }\n</div>\n"],"names":[],"mappings":"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"}
@@ -1,47 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, ElementRef, input, signal, effect, untracked, Directive } from '@angular/core';
3
- import { C as ContentBuilderStore, a as CONTENT_BUILDER, h as findContentEditorBlock, n as isContentEditorBlockEmpty, l as contentEditorBlockView } from './ngstarter-ui-components-content-editor-ngstarter-ui-components-content-editor--rb3-UuO.mjs';
4
-
5
- /** Shared native inputs and root history for the built-in block editors. */
6
- class ContentEditorBlockBase {
7
- store = inject(ContentBuilderStore);
8
- builder = inject(CONTENT_BUILDER);
9
- element = inject(ElementRef).nativeElement;
10
- id = input.required(/* @ts-ignore */
11
- ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
12
- content = input.required(/* @ts-ignore */
13
- ...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
14
- settings = input.required(/* @ts-ignore */
15
- ...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
16
- index = input(0, /* @ts-ignore */
17
- ...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
18
- props = input([], /* @ts-ignore */
19
- ...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
20
- initialized = signal(true, /* @ts-ignore */
21
- ...(ngDevMode ? [{ debugName: "initialized" }] : /* istanbul ignore next */ []));
22
- constructor() {
23
- effect(() => {
24
- if (this.store.focusedBlockId() === this.id())
25
- untracked(() => this.focus());
26
- });
27
- }
28
- focus() { this.element.querySelector('[contenteditable="true"], input, button')?.focus(); }
29
- getData() { return { content: this.content(), settings: this.settings(), props: this.props() }; }
30
- isEmpty() {
31
- const block = findContentEditorBlock(this.store.editor.document().blocks, this.id());
32
- return !block || isContentEditorBlockEmpty(block);
33
- }
34
- save(content, settings = this.settings()) { this.store.updateBlock(this.id(), { content, settings }); }
35
- latestContent() {
36
- const block = findContentEditorBlock(this.store.editor.document().blocks, this.id());
37
- return block ? contentEditorBlockView(block).content : this.content();
38
- }
39
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorBlockBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
40
- 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 });
41
- }
42
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorBlockBase, decorators: [{
43
- type: Directive
44
- }], 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 }] }] } });
45
-
46
- export { ContentEditorBlockBase as C };
47
- //# sourceMappingURL=ngstarter-ui-components-content-editor-block-base-BHAxKEOT.mjs.map