@ngstarter-ui/components 22.1.4 → 22.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/component-registry.json +140 -9
- package/fesm2022/ngstarter-ui-components-content-editor-attachment-block-B2GUlWO2.mjs +54 -0
- package/fesm2022/ngstarter-ui-components-content-editor-attachment-block-B2GUlWO2.mjs.map +1 -0
- package/fesm2022/ngstarter-ui-components-content-editor-block-base-BHAxKEOT.mjs +47 -0
- package/fesm2022/ngstarter-ui-components-content-editor-block-base-BHAxKEOT.mjs.map +1 -0
- package/fesm2022/ngstarter-ui-components-content-editor-callout-block-Cnga7Z-6.mjs +27 -0
- package/fesm2022/ngstarter-ui-components-content-editor-callout-block-Cnga7Z-6.mjs.map +1 -0
- package/fesm2022/{ngstarter-ui-components-content-editor-code-block.component-BbK5fCoE.mjs → ngstarter-ui-components-content-editor-code-block.component-DSdVOJtH.mjs} +49 -15
- package/fesm2022/ngstarter-ui-components-content-editor-code-block.component-DSdVOJtH.mjs.map +1 -0
- package/fesm2022/{ngstarter-ui-components-content-editor-divider-block.component-B5wyMHjr.mjs → ngstarter-ui-components-content-editor-divider-block.component-D1nXMRXD.mjs} +5 -3
- package/fesm2022/{ngstarter-ui-components-content-editor-divider-block.component-B5wyMHjr.mjs.map → ngstarter-ui-components-content-editor-divider-block.component-D1nXMRXD.mjs.map} +1 -1
- package/fesm2022/{ngstarter-ui-components-content-editor-embed-block-DGqupBLe.mjs → ngstarter-ui-components-content-editor-embed-block-DhFxtMQS.mjs} +16 -4
- package/fesm2022/ngstarter-ui-components-content-editor-embed-block-DhFxtMQS.mjs.map +1 -0
- package/fesm2022/ngstarter-ui-components-content-editor-gallery-block-cEy-dCMa.mjs +103 -0
- package/fesm2022/ngstarter-ui-components-content-editor-gallery-block-cEy-dCMa.mjs.map +1 -0
- package/fesm2022/ngstarter-ui-components-content-editor-grid-block-DFLGRFiO.mjs +66 -0
- package/fesm2022/ngstarter-ui-components-content-editor-grid-block-DFLGRFiO.mjs.map +1 -0
- package/fesm2022/{ngstarter-ui-components-content-editor-heading-block.component-D1s2yalT.mjs → ngstarter-ui-components-content-editor-heading-block.component-BYpctSPe.mjs} +23 -14
- package/fesm2022/ngstarter-ui-components-content-editor-heading-block.component-BYpctSPe.mjs.map +1 -0
- package/fesm2022/{ngstarter-ui-components-content-editor-image-block.component-D75DrPNq.mjs → ngstarter-ui-components-content-editor-image-block.component-B3MnANpi.mjs} +20 -7
- package/fesm2022/ngstarter-ui-components-content-editor-image-block.component-B3MnANpi.mjs.map +1 -0
- package/fesm2022/{ngstarter-ui-components-content-editor-list-block.component-B7pDlrQ_.mjs → ngstarter-ui-components-content-editor-list-block.component-6SMBxIl4.mjs} +28 -17
- package/fesm2022/ngstarter-ui-components-content-editor-list-block.component-6SMBxIl4.mjs.map +1 -0
- package/fesm2022/ngstarter-ui-components-content-editor-nested-blocks-DSY7xfzf.mjs +117 -0
- package/fesm2022/ngstarter-ui-components-content-editor-nested-blocks-DSY7xfzf.mjs.map +1 -0
- package/fesm2022/ngstarter-ui-components-content-editor-ngstarter-ui-components-content-editor--rb3-UuO.mjs +3310 -0
- package/fesm2022/ngstarter-ui-components-content-editor-ngstarter-ui-components-content-editor--rb3-UuO.mjs.map +1 -0
- package/fesm2022/{ngstarter-ui-components-content-editor-paragraph-block.component-CVV2f-ON.mjs → ngstarter-ui-components-content-editor-paragraph-block.component-JVxf_Cdx.mjs} +25 -14
- package/fesm2022/ngstarter-ui-components-content-editor-paragraph-block.component-JVxf_Cdx.mjs.map +1 -0
- package/fesm2022/{ngstarter-ui-components-content-editor-quote-block.component-CVb-bkJw.mjs → ngstarter-ui-components-content-editor-quote-block.component-7EO7z7Sr.mjs} +29 -16
- package/fesm2022/ngstarter-ui-components-content-editor-quote-block.component-7EO7z7Sr.mjs.map +1 -0
- package/fesm2022/{ngstarter-ui-components-content-editor-table-block.component-DSpLBC4V.mjs → ngstarter-ui-components-content-editor-table-block.component-CJS-IBHw.mjs} +28 -13
- package/fesm2022/ngstarter-ui-components-content-editor-table-block.component-CJS-IBHw.mjs.map +1 -0
- package/fesm2022/ngstarter-ui-components-content-editor-toggle-block-B01lhY_V.mjs +21 -0
- package/fesm2022/ngstarter-ui-components-content-editor-toggle-block-B01lhY_V.mjs.map +1 -0
- package/fesm2022/ngstarter-ui-components-content-editor-upload-block-base-D9ELpJr-.mjs +29 -0
- package/fesm2022/ngstarter-ui-components-content-editor-upload-block-base-D9ELpJr-.mjs.map +1 -0
- package/fesm2022/{ngstarter-ui-components-content-editor-video-block.component-D3U8uXIy.mjs → ngstarter-ui-components-content-editor-video-block.component-DQUPVDwV.mjs} +19 -5
- package/fesm2022/ngstarter-ui-components-content-editor-video-block.component-DQUPVDwV.mjs.map +1 -0
- package/fesm2022/ngstarter-ui-components-content-editor.mjs +1 -1
- package/fesm2022/ngstarter-ui-components-data-view.mjs +2 -2
- package/fesm2022/ngstarter-ui-components-data-view.mjs.map +1 -1
- package/fesm2022/ngstarter-ui-components-filter-builder.mjs +1 -1
- package/fesm2022/ngstarter-ui-components-filter-builder.mjs.map +1 -1
- package/fesm2022/ngstarter-ui-components-headless-editor.mjs +90 -12
- package/fesm2022/ngstarter-ui-components-headless-editor.mjs.map +1 -1
- package/fesm2022/ngstarter-ui-components-image-designer.mjs +1 -1
- package/fesm2022/ngstarter-ui-components-image-designer.mjs.map +1 -1
- package/fesm2022/ngstarter-ui-components-kanban-board.mjs +1 -1
- package/fesm2022/ngstarter-ui-components-kanban-board.mjs.map +1 -1
- package/fesm2022/ngstarter-ui-components-menu.mjs +9 -5
- package/fesm2022/ngstarter-ui-components-menu.mjs.map +1 -1
- package/fesm2022/ngstarter-ui-components-pdf-builder.mjs +1 -1
- package/fesm2022/ngstarter-ui-components-pdf-builder.mjs.map +1 -1
- package/fesm2022/ngstarter-ui-components-pdf-viewer.mjs +1 -1
- package/fesm2022/ngstarter-ui-components-pdf-viewer.mjs.map +1 -1
- package/fesm2022/ngstarter-ui-components-phone-input.mjs +1 -1
- package/fesm2022/ngstarter-ui-components-phone-input.mjs.map +1 -1
- package/fesm2022/ngstarter-ui-components-signature-pad.mjs +1 -1
- package/fesm2022/ngstarter-ui-components-signature-pad.mjs.map +1 -1
- package/fesm2022/ngstarter-ui-components-upload.mjs +2 -2
- package/fesm2022/ngstarter-ui-components-upload.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ngstarter-ui-components-content-editor.d.ts +303 -83
- package/types/ngstarter-ui-components-headless-editor.d.ts +17 -2
- package/types/ngstarter-ui-components-menu.d.ts +3 -1
- package/fesm2022/ngstarter-ui-components-content-editor-code-block.component-BbK5fCoE.mjs.map +0 -1
- package/fesm2022/ngstarter-ui-components-content-editor-content-editor-content-editable.directive-BOXOHcSo.mjs +0 -127
- package/fesm2022/ngstarter-ui-components-content-editor-content-editor-content-editable.directive-BOXOHcSo.mjs.map +0 -1
- package/fesm2022/ngstarter-ui-components-content-editor-embed-block-DGqupBLe.mjs.map +0 -1
- package/fesm2022/ngstarter-ui-components-content-editor-heading-block.component-D1s2yalT.mjs.map +0 -1
- package/fesm2022/ngstarter-ui-components-content-editor-image-block.component-D75DrPNq.mjs.map +0 -1
- package/fesm2022/ngstarter-ui-components-content-editor-list-block.component-B7pDlrQ_.mjs.map +0 -1
- package/fesm2022/ngstarter-ui-components-content-editor-ngstarter-ui-components-content-editor-CV959OGj.mjs +0 -3102
- package/fesm2022/ngstarter-ui-components-content-editor-ngstarter-ui-components-content-editor-CV959OGj.mjs.map +0 -1
- package/fesm2022/ngstarter-ui-components-content-editor-paragraph-block.component-CVV2f-ON.mjs.map +0 -1
- package/fesm2022/ngstarter-ui-components-content-editor-quote-block.component-CVb-bkJw.mjs.map +0 -1
- package/fesm2022/ngstarter-ui-components-content-editor-table-block.component-DSpLBC4V.mjs.map +0 -1
- package/fesm2022/ngstarter-ui-components-content-editor-video-block.component-D3U8uXIy.mjs.map +0 -1
|
@@ -0,0 +1,3310 @@
|
|
|
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';
|
|
3
|
+
import { Button } from '@ngstarter-ui/components/button';
|
|
4
|
+
import { Icon } from '@ngstarter-ui/components/icon';
|
|
5
|
+
import { Menu, MenuItem, MenuTrigger, MenuHeading, MenuContent } from '@ngstarter-ui/components/menu';
|
|
6
|
+
import { DialogRef, DialogContent, DialogTitle, DialogActions, DIALOG_DATA, Dialog } from '@ngstarter-ui/components/dialog';
|
|
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';
|
|
9
|
+
import { DOCUMENT, isPlatformBrowser, isPlatformServer, NgComponentOutlet, AsyncPipe, NgTemplateOutlet } from '@angular/common';
|
|
10
|
+
import { Input } from '@ngstarter-ui/components/input';
|
|
11
|
+
import { FormField, Label, Hint } from '@ngstarter-ui/components/form-field';
|
|
12
|
+
import * as i1$1 from '@angular/forms';
|
|
13
|
+
import { FormBuilder, Validators, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
14
|
+
import { SlideToggle } from '@ngstarter-ui/components/slide-toggle';
|
|
15
|
+
import { Tooltip } from '@ngstarter-ui/components/tooltip';
|
|
16
|
+
import { v7 } from 'uuid';
|
|
17
|
+
import { CdkDropList, CdkDrag, CdkDragHandle, CdkDragPlaceholder } from '@angular/cdk/drag-drop';
|
|
18
|
+
import { ConfirmManager } from '@ngstarter-ui/components/confirm';
|
|
19
|
+
import { CdkMonitorFocus } from '@angular/cdk/a11y';
|
|
20
|
+
import { ComponentPortal } from '@angular/cdk/portal';
|
|
21
|
+
import { Subject, fromEvent } from 'rxjs';
|
|
22
|
+
import { throttleTime, shareReplay, auditTime, map, startWith, distinctUntilChanged } from 'rxjs/operators';
|
|
23
|
+
import * as i1$2 from '@angular/cdk/overlay';
|
|
24
|
+
import SelectionArea from '@viselect/vanilla';
|
|
25
|
+
import { PopoverTriggerForDirective, Popover } from '@ngstarter-ui/components/popover';
|
|
26
|
+
import { SelectionModel } from '@angular/cdk/collections';
|
|
27
|
+
import { ListItemTitle, ListItemIcon, ListItem, List } from '@ngstarter-ui/components/list';
|
|
28
|
+
import { ImageViewerDirective, ImageViewerPictureDirective } from '@ngstarter-ui/components/image-viewer';
|
|
29
|
+
import { CarouselCard, Carousel } from '@ngstarter-ui/components/carousel';
|
|
30
|
+
import { ExpansionPanel, ExpansionPanelHeader, ExpansionPanelTitle } from '@ngstarter-ui/components/expansion';
|
|
31
|
+
import { Alert, AlertIconDirective } from '@ngstarter-ui/components/alert';
|
|
32
|
+
import { CodeHighlighter } from '@ngstarter-ui/components/code-highlighter';
|
|
33
|
+
import { Divider } from '@ngstarter-ui/components/divider';
|
|
34
|
+
import { SafeResourceUrlPipe } from '@ngstarter-ui/components/core';
|
|
35
|
+
import { NativeTable } from '@ngstarter-ui/components/table';
|
|
36
|
+
|
|
37
|
+
/** Plain text used by empty states and literal code editing. */
|
|
38
|
+
function contentEditorText(value) {
|
|
39
|
+
return isNgsHeadlessEditorTextContent(value) ? value.map(run => run.text).join('') : '';
|
|
40
|
+
}
|
|
41
|
+
/** Maps a native block to the existing UI inputs. Saved data always stays native. */
|
|
42
|
+
function contentEditorBlockView(block) {
|
|
43
|
+
return {
|
|
44
|
+
id: block.id, type: block.type, content: block.type === 'table' ? contentEditorTableCells(block) : cloneContentEditorValue(block.content),
|
|
45
|
+
attrs: cloneContentEditorValue(block.attrs),
|
|
46
|
+
settings: cloneContentEditorValue(block.attrs?.['settings'] ?? {}),
|
|
47
|
+
props: cloneContentEditorValue(block.attrs?.['props'] ?? []),
|
|
48
|
+
isEmpty: isContentEditorBlockEmpty(block)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function contentEditorNativeBlock(block) {
|
|
52
|
+
const attrs = {
|
|
53
|
+
...cloneContentEditorValue(block.attrs),
|
|
54
|
+
settings: cloneContentEditorValue(block.settings), props: cloneContentEditorValue(block.props ?? [])
|
|
55
|
+
};
|
|
56
|
+
if (block.type === 'table') {
|
|
57
|
+
const cells = cloneContentEditorValue(block.content);
|
|
58
|
+
return {
|
|
59
|
+
id: block.id, type: 'table', content: null,
|
|
60
|
+
attrs: {
|
|
61
|
+
...attrs,
|
|
62
|
+
rows: cells.map(row => row.map(cell => cell['content'])),
|
|
63
|
+
header: block.attrs?.['header'] === true,
|
|
64
|
+
cellMetadata: cells.map(row => row.map(({ content, ...metadata }) => metadata))
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return { id: block.id, type: block.type, content: cloneContentEditorValue(block.content), attrs };
|
|
69
|
+
}
|
|
70
|
+
/** Text rows use the headless table schema; content-builder cell settings stay in metadata. */
|
|
71
|
+
function contentEditorTableCells(block) {
|
|
72
|
+
const table = getNgsHeadlessEditorTableData(block);
|
|
73
|
+
const metadata = block.attrs?.['cellMetadata'];
|
|
74
|
+
return table.rows.map((row, r) => row.map((content, c) => {
|
|
75
|
+
const cell = metadata?.[r]?.[c] ?? {};
|
|
76
|
+
return {
|
|
77
|
+
...cloneContentEditorValue(cell), content: cloneContentEditorValue(content),
|
|
78
|
+
props: cloneContentEditorValue(cell.props ?? []),
|
|
79
|
+
options: { colspan: 1, rowspan: 1, ...cloneContentEditorValue(cell.options ?? {}) }
|
|
80
|
+
};
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
function isContentEditorBlockEmpty(block) {
|
|
84
|
+
const content = block.content;
|
|
85
|
+
if (isNgsHeadlessEditorTextContent(content))
|
|
86
|
+
return !contentEditorText(content).trim();
|
|
87
|
+
switch (block.type) {
|
|
88
|
+
case 'bulletList':
|
|
89
|
+
case 'orderedList': return !(content ?? []).some((item) => contentEditorText(item.content).trim() || !isContentEditorBlockEmpty({ ...block, content: item.children }));
|
|
90
|
+
case 'table': return !getNgsHeadlessEditorTableData(block).rows.some(row => row.some(cell => contentEditorText(cell).trim()));
|
|
91
|
+
case 'quote': return !contentEditorText(content?.cite?.content).trim() && !contentEditorText(content?.caption?.content).trim();
|
|
92
|
+
case 'image':
|
|
93
|
+
case 'video': return !content?.src;
|
|
94
|
+
case 'embed': return !content?.url;
|
|
95
|
+
case 'attachment': return !content?.url;
|
|
96
|
+
case 'gallery': return !(content?.images ?? []).some((image) => image.src);
|
|
97
|
+
case 'toggle': return !contentEditorText(content?.title).trim() && (content?.blocks ?? []).every(isContentEditorBlockEmpty);
|
|
98
|
+
case 'grid': return (content?.cells ?? []).every((cell) => cell.blocks.every(isContentEditorBlockEmpty));
|
|
99
|
+
case 'divider': return false;
|
|
100
|
+
default: return content == null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function contentEditorChildCollections(block) {
|
|
104
|
+
if (block.type === 'toggle')
|
|
105
|
+
return [block.content?.blocks ?? []];
|
|
106
|
+
if (block.type === 'grid')
|
|
107
|
+
return (block.content?.cells ?? []).map((cell) => cell.blocks);
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
function findContentEditorBlock(blocks, id) {
|
|
111
|
+
for (const block of blocks) {
|
|
112
|
+
if (block.id === id)
|
|
113
|
+
return block;
|
|
114
|
+
for (const children of contentEditorChildCollections(block)) {
|
|
115
|
+
const found = findContentEditorBlock(children, id);
|
|
116
|
+
if (found)
|
|
117
|
+
return found;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
function contentEditorCollection(blocks, scope) {
|
|
123
|
+
if (!scope.parentId)
|
|
124
|
+
return blocks;
|
|
125
|
+
const parent = findContentEditorBlock(blocks, scope.parentId);
|
|
126
|
+
if (parent?.type === 'toggle')
|
|
127
|
+
return parent.content.blocks;
|
|
128
|
+
if (parent?.type === 'grid')
|
|
129
|
+
return parent.content.cells.find((cell) => cell.id === scope.cellId)?.blocks ?? [];
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
/** Update only on a cloned document; callers preserve immutable undo snapshots. */
|
|
133
|
+
function replaceContentEditorCollection(blocks, scope, value) {
|
|
134
|
+
if (!scope.parentId) {
|
|
135
|
+
blocks.splice(0, blocks.length, ...value);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const parent = findContentEditorBlock(blocks, scope.parentId);
|
|
139
|
+
if (parent?.type === 'toggle')
|
|
140
|
+
parent.content.blocks = value;
|
|
141
|
+
if (parent?.type === 'grid') {
|
|
142
|
+
const cell = parent.content.cells.find((cell) => cell.id === scope.cellId);
|
|
143
|
+
if (cell)
|
|
144
|
+
cell.blocks = value;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** Mutable UI payloads must not mutate saved documents or undo snapshots. */
|
|
148
|
+
function cloneContentEditorValue(value) {
|
|
149
|
+
if (Array.isArray(value))
|
|
150
|
+
return value.map(item => cloneContentEditorValue(item));
|
|
151
|
+
if (value !== null && typeof value === 'object') {
|
|
152
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, cloneContentEditorValue(item)]));
|
|
153
|
+
}
|
|
154
|
+
return value;
|
|
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;
|
|
189
|
+
}
|
|
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;
|
|
233
|
+
}
|
|
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
|
+
}
|
|
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 });
|
|
272
|
+
}
|
|
273
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentBuilderStore, decorators: [{
|
|
274
|
+
type: Injectable
|
|
275
|
+
}], ctorParameters: () => [] });
|
|
276
|
+
|
|
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());
|
|
322
|
+
}
|
|
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
|
+
]);
|
|
332
|
+
}
|
|
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' }));
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
ngOnDestroy() {
|
|
348
|
+
regions.delete(this.element);
|
|
349
|
+
this.element.removeEventListener('keydown', this.onKeydown, true);
|
|
350
|
+
this.element.removeEventListener('beforeinput', this.onBeforeInput, true);
|
|
351
|
+
}
|
|
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 });
|
|
354
|
+
}
|
|
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
|
+
|
|
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 });
|
|
388
|
+
}
|
|
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
|
+
|
|
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);
|
|
414
|
+
}
|
|
415
|
+
add() {
|
|
416
|
+
this._dialogRef.close(this.form.value);
|
|
417
|
+
}
|
|
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 });
|
|
420
|
+
}
|
|
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" }]
|
|
436
|
+
}] });
|
|
437
|
+
|
|
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'
|
|
496
|
+
}
|
|
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
|
+
},
|
|
540
|
+
{
|
|
541
|
+
name: 'Pink',
|
|
542
|
+
color: '#fae0ec',
|
|
543
|
+
type: 'background'
|
|
544
|
+
},
|
|
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);
|
|
571
|
+
}
|
|
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]);
|
|
582
|
+
try {
|
|
583
|
+
this._document.defaultView?.localStorage.setItem('ngsContentEditorRecentlyUsedTextColor', JSON.stringify(this.recentlyUsed()));
|
|
584
|
+
}
|
|
585
|
+
catch {
|
|
586
|
+
// Keep the recent colors in memory when browser storage is unavailable.
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
_getRecentlyUsed() {
|
|
590
|
+
try {
|
|
591
|
+
const value = this._document.defaultView?.localStorage.getItem('ngsContentEditorRecentlyUsedTextColor');
|
|
592
|
+
const colors = value ? JSON.parse(value) : [];
|
|
593
|
+
return Array.isArray(colors) ? colors : [];
|
|
594
|
+
}
|
|
595
|
+
catch {
|
|
596
|
+
return [];
|
|
597
|
+
}
|
|
598
|
+
}
|
|
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 });
|
|
601
|
+
}
|
|
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"] }] } });
|
|
609
|
+
|
|
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();
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
preserveSelection(event) {
|
|
657
|
+
event.preventDefault();
|
|
658
|
+
this.region()?.activate();
|
|
659
|
+
this.retainSelection();
|
|
660
|
+
}
|
|
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 };
|
|
668
|
+
}
|
|
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;
|
|
677
|
+
}
|
|
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
|
+
});
|
|
687
|
+
}
|
|
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();
|
|
698
|
+
}
|
|
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();
|
|
708
|
+
}
|
|
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;
|
|
732
|
+
}
|
|
733
|
+
return 'left';
|
|
734
|
+
}
|
|
735
|
+
function getDimensionAttribute(value) {
|
|
736
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
737
|
+
return value;
|
|
738
|
+
}
|
|
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;
|
|
746
|
+
}
|
|
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
|
+
};
|
|
757
|
+
}
|
|
758
|
+
|
|
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: {}
|
|
879
|
+
}
|
|
880
|
+
].map(def => ({ ...def, toHtml: CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS[def.type] }));
|
|
881
|
+
function emptyParagraph() {
|
|
882
|
+
return { id: createNgsHeadlessEditorId('paragraph'), type: 'paragraph', content: [createNgsHeadlessEditorText()] };
|
|
883
|
+
}
|
|
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
|
+
];
|
|
895
|
+
|
|
896
|
+
function escapeContentEditorHtml(value) {
|
|
897
|
+
return String(value ?? '').replace(/[&<>"']/g, character => ({
|
|
898
|
+
'&': '&', '<': '<', '>': '>', '"': '"', "'": '''
|
|
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;
|
|
919
|
+
}
|
|
920
|
+
|
|
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);
|
|
930
|
+
}
|
|
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);
|
|
943
|
+
},
|
|
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);
|
|
950
|
+
},
|
|
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('');
|
|
963
|
+
}
|
|
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>`;
|
|
974
|
+
}
|
|
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;
|
|
978
|
+
}
|
|
979
|
+
return html;
|
|
980
|
+
}
|
|
981
|
+
function defaultConverter(type) {
|
|
982
|
+
return Object.hasOwn(CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS, type) ? CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS[type] : undefined;
|
|
983
|
+
}
|
|
984
|
+
|
|
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));
|
|
993
|
+
}
|
|
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' });
|
|
996
|
+
}
|
|
997
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorHtmlSerializer, decorators: [{
|
|
998
|
+
type: Injectable,
|
|
999
|
+
args: [{ providedIn: 'root' }]
|
|
1000
|
+
}] });
|
|
1001
|
+
|
|
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
|
+
};
|
|
1014
|
+
}
|
|
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;
|
|
1020
|
+
}
|
|
1021
|
+
return result;
|
|
1022
|
+
}
|
|
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
|
+
]);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
// src/app/text-selection-popup.directive.ts
|
|
1035
|
+
const POPUP_VERTICAL_OFFSET = 8;
|
|
1036
|
+
const POPUP_VIEWPORT_MARGIN = 8;
|
|
1037
|
+
class TextSelectionPopupDirective {
|
|
1038
|
+
overlay;
|
|
1039
|
+
viewContainerRef;
|
|
1040
|
+
elementRef;
|
|
1041
|
+
renderer;
|
|
1042
|
+
overlayContainer;
|
|
1043
|
+
ngZone;
|
|
1044
|
+
targetComponent;
|
|
1045
|
+
closestContentObserverClass = null;
|
|
1046
|
+
tagSelected = new EventEmitter();
|
|
1047
|
+
overlayRef = null;
|
|
1048
|
+
hostElement;
|
|
1049
|
+
currentSelectionRange = null;
|
|
1050
|
+
documentClickListener = null;
|
|
1051
|
+
positionStrategy = null;
|
|
1052
|
+
scrollListener = null;
|
|
1053
|
+
popupResizeObserver = null;
|
|
1054
|
+
scrollSubject = new Subject();
|
|
1055
|
+
scrollSubscription = null;
|
|
1056
|
+
constructor(overlay, viewContainerRef, elementRef, renderer, overlayContainer, ngZone) {
|
|
1057
|
+
this.overlay = overlay;
|
|
1058
|
+
this.viewContainerRef = viewContainerRef;
|
|
1059
|
+
this.elementRef = elementRef;
|
|
1060
|
+
this.renderer = renderer;
|
|
1061
|
+
this.overlayContainer = overlayContainer;
|
|
1062
|
+
this.ngZone = ngZone;
|
|
1063
|
+
this.hostElement = this.elementRef.nativeElement;
|
|
1064
|
+
this.scrollSubscription = this.scrollSubject.pipe(throttleTime(50, undefined, { leading: true, trailing: true })).subscribe(() => {
|
|
1065
|
+
this.updatePopupPosition();
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
onDocumentClickHostListener(event) {
|
|
1069
|
+
if (event.target.closest('.cdk-overlay-container')) {
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
this.processSelection();
|
|
1073
|
+
}
|
|
1074
|
+
onDocumentKeyDown(event) {
|
|
1075
|
+
if (!this.overlayRef)
|
|
1076
|
+
return;
|
|
1077
|
+
if (event.target.closest('.cdk-overlay-container'))
|
|
1078
|
+
return;
|
|
1079
|
+
const ignoredKeys = [
|
|
1080
|
+
'Shift', 'Control', 'Alt', 'Meta', 'CapsLock',
|
|
1081
|
+
'Escape', 'Tab',
|
|
1082
|
+
'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight',
|
|
1083
|
+
'Home', 'End', 'PageUp', 'PageDown',
|
|
1084
|
+
'Insert', 'ContextMenu',
|
|
1085
|
+
'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12'
|
|
1086
|
+
];
|
|
1087
|
+
if (ignoredKeys.includes(event.key)) {
|
|
1088
|
+
setTimeout(() => this.processSelection(), 0);
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
if (event.target.closest('.cdk-overlay-container')) {
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
this.closePopup();
|
|
1095
|
+
}
|
|
1096
|
+
processSelection() {
|
|
1097
|
+
// Menus, popovers and dialogs opened from the toolbar live in sibling
|
|
1098
|
+
// overlay panes. Their controls must be able to take focus without disposing
|
|
1099
|
+
// the toolbar or discarding the editor's saved range.
|
|
1100
|
+
if (this.overlayRef && this.isFocusInsidePopup())
|
|
1101
|
+
return;
|
|
1102
|
+
const selection = window.getSelection();
|
|
1103
|
+
if (!selection || selection.isCollapsed || selection.rangeCount === 0) {
|
|
1104
|
+
if (this.overlayRef && !this.isFocusInsidePopup()) {
|
|
1105
|
+
this.closePopup();
|
|
1106
|
+
}
|
|
1107
|
+
this.currentSelectionRange = null;
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
const range = selection.getRangeAt(0);
|
|
1111
|
+
if (!this.hostElement.contains(range.startContainer) || !this.hostElement.contains(range.endContainer)) {
|
|
1112
|
+
this.closePopupIfNeeded();
|
|
1113
|
+
this.currentSelectionRange = null;
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
let observedElement = null;
|
|
1117
|
+
if (this.closestContentObserverClass) {
|
|
1118
|
+
observedElement = this.findClosestElementWithClass(range.startContainer, this.closestContentObserverClass);
|
|
1119
|
+
const endElement = this.findClosestElementWithClass(range.endContainer, this.closestContentObserverClass);
|
|
1120
|
+
if (!observedElement || endElement !== observedElement) {
|
|
1121
|
+
this.closePopupIfNeeded();
|
|
1122
|
+
this.currentSelectionRange = null;
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
const selectedText = selection.toString().trim();
|
|
1127
|
+
if (selectedText) {
|
|
1128
|
+
const selectionRects = range.getClientRects();
|
|
1129
|
+
if (selectionRects.length > 0) {
|
|
1130
|
+
const containingTagName = this.getContainingTagName(range);
|
|
1131
|
+
const newRange = range.cloneRange();
|
|
1132
|
+
if (!this.overlayRef || !this.areRangesEqual(this.currentSelectionRange, newRange)) {
|
|
1133
|
+
this.closePopupIfNeeded();
|
|
1134
|
+
this.currentSelectionRange = newRange;
|
|
1135
|
+
this.showPopup(observedElement);
|
|
1136
|
+
this.tagSelected.emit(containingTagName);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
else {
|
|
1140
|
+
this.closePopupIfNeeded();
|
|
1141
|
+
this.currentSelectionRange = null;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
else {
|
|
1145
|
+
this.closePopupIfNeeded();
|
|
1146
|
+
this.currentSelectionRange = null;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
showPopup(observedElement) {
|
|
1150
|
+
if (!this.targetComponent || this.overlayRef)
|
|
1151
|
+
return;
|
|
1152
|
+
this.positionStrategy = this.overlay.position().global();
|
|
1153
|
+
this.overlayRef = this.overlay.create({
|
|
1154
|
+
positionStrategy: this.positionStrategy,
|
|
1155
|
+
hasBackdrop: false,
|
|
1156
|
+
scrollStrategy: this.overlay.scrollStrategies.noop(),
|
|
1157
|
+
});
|
|
1158
|
+
const portal = new ComponentPortal(this.targetComponent, this.viewContainerRef);
|
|
1159
|
+
const componentRef = this.overlayRef.attach(portal);
|
|
1160
|
+
if (componentRef.instance && 'observedElement' in componentRef.instance) {
|
|
1161
|
+
componentRef.setInput('observedElement', observedElement);
|
|
1162
|
+
}
|
|
1163
|
+
if (this.overlayRef) {
|
|
1164
|
+
Promise.resolve().then(() => {
|
|
1165
|
+
if (this.overlayRef && this.positionStrategy) {
|
|
1166
|
+
this.updatePopupPosition();
|
|
1167
|
+
this.popupResizeObserver = new ResizeObserver(() => this.updatePopupPosition());
|
|
1168
|
+
this.popupResizeObserver.observe(this.overlayRef.overlayElement);
|
|
1169
|
+
this.addDocumentClickListener();
|
|
1170
|
+
this.addScrollListener();
|
|
1171
|
+
}
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
closePopupIfNeeded() {
|
|
1176
|
+
if (this.overlayRef) {
|
|
1177
|
+
this.closePopup();
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
closePopup() {
|
|
1181
|
+
if (!this.overlayRef)
|
|
1182
|
+
return;
|
|
1183
|
+
this.popupResizeObserver?.disconnect();
|
|
1184
|
+
this.popupResizeObserver = null;
|
|
1185
|
+
this.overlayRef.dispose();
|
|
1186
|
+
this.overlayRef = null;
|
|
1187
|
+
this.positionStrategy = null;
|
|
1188
|
+
this.currentSelectionRange = null;
|
|
1189
|
+
this.removeDocumentClickListener();
|
|
1190
|
+
this.removeScrollListener();
|
|
1191
|
+
}
|
|
1192
|
+
addScrollListener() {
|
|
1193
|
+
if (this.scrollListener)
|
|
1194
|
+
return;
|
|
1195
|
+
this.ngZone.runOutsideAngular(() => {
|
|
1196
|
+
this.scrollListener = this.renderer.listen(document, 'scroll', (event) => {
|
|
1197
|
+
this.scrollSubject.next();
|
|
1198
|
+
});
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
removeScrollListener() {
|
|
1202
|
+
if (this.scrollListener) {
|
|
1203
|
+
this.scrollListener();
|
|
1204
|
+
this.scrollListener = null;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
updatePopupPosition() {
|
|
1208
|
+
if (!this.overlayRef || !this.positionStrategy || !this.currentSelectionRange)
|
|
1209
|
+
return;
|
|
1210
|
+
try {
|
|
1211
|
+
const selectionRects = this.currentSelectionRange.getClientRects();
|
|
1212
|
+
if (selectionRects.length > 0) {
|
|
1213
|
+
const selectionBounds = this.currentSelectionRange.getBoundingClientRect();
|
|
1214
|
+
const popupElement = this.overlayRef.overlayElement;
|
|
1215
|
+
const popupHeight = popupElement.offsetHeight;
|
|
1216
|
+
const popupWidth = popupElement.offsetWidth;
|
|
1217
|
+
const viewportWidth = this.hostElement.ownerDocument.documentElement.clientWidth;
|
|
1218
|
+
const centeredLeft = selectionBounds.left + (selectionBounds.width - popupWidth) / 2;
|
|
1219
|
+
const newX = Math.max(POPUP_VIEWPORT_MARGIN, Math.min(centeredLeft, viewportWidth - popupWidth - POPUP_VIEWPORT_MARGIN));
|
|
1220
|
+
const newY = selectionBounds.top - popupHeight - POPUP_VERTICAL_OFFSET;
|
|
1221
|
+
this.ngZone.run(() => {
|
|
1222
|
+
if (this.overlayRef && this.positionStrategy) {
|
|
1223
|
+
this.positionStrategy.left(`${newX}px`).top(`${newY}px`);
|
|
1224
|
+
this.overlayRef.updatePosition();
|
|
1225
|
+
}
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
else {
|
|
1229
|
+
this.ngZone.run(() => this.closePopup());
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
catch (e) {
|
|
1233
|
+
console.error("Error updating popup position:", e);
|
|
1234
|
+
this.ngZone.run(() => this.closePopup());
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
findClosestElementWithClass(startNode, className) {
|
|
1238
|
+
let currentNode = startNode;
|
|
1239
|
+
const hostParent = this.hostElement.parentNode;
|
|
1240
|
+
while (currentNode && currentNode !== hostParent && currentNode !== document.body && currentNode !== document.documentElement) {
|
|
1241
|
+
if (currentNode instanceof Element && currentNode.classList.contains(className)) {
|
|
1242
|
+
return currentNode;
|
|
1243
|
+
}
|
|
1244
|
+
currentNode = currentNode.parentNode;
|
|
1245
|
+
}
|
|
1246
|
+
if (this.hostElement.classList.contains(className)) {
|
|
1247
|
+
return this.hostElement;
|
|
1248
|
+
}
|
|
1249
|
+
return null;
|
|
1250
|
+
}
|
|
1251
|
+
getContainingTagName(range) {
|
|
1252
|
+
let container = range.commonAncestorContainer;
|
|
1253
|
+
while (container && container.nodeType !== Node.ELEMENT_NODE) {
|
|
1254
|
+
container = container.parentNode;
|
|
1255
|
+
}
|
|
1256
|
+
return container instanceof Element ? container.tagName : null;
|
|
1257
|
+
}
|
|
1258
|
+
addDocumentClickListener() {
|
|
1259
|
+
if (this.documentClickListener)
|
|
1260
|
+
return;
|
|
1261
|
+
this.documentClickListener = this.renderer.listen(document, 'click', (event) => {
|
|
1262
|
+
this.handleDocumentClick(event);
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
removeDocumentClickListener() {
|
|
1266
|
+
if (this.documentClickListener) {
|
|
1267
|
+
this.documentClickListener();
|
|
1268
|
+
this.documentClickListener = null;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
handleDocumentClick(event) {
|
|
1272
|
+
if (!this.overlayRef || !event.target)
|
|
1273
|
+
return;
|
|
1274
|
+
const clickedElement = event.target;
|
|
1275
|
+
if (this.isEventInsidePopup(event))
|
|
1276
|
+
return;
|
|
1277
|
+
const overlayContainerElement = this.overlayContainer.getContainerElement();
|
|
1278
|
+
if (overlayContainerElement.contains(clickedElement))
|
|
1279
|
+
return;
|
|
1280
|
+
this.closePopup();
|
|
1281
|
+
}
|
|
1282
|
+
isEventInsidePopup(event) {
|
|
1283
|
+
if (!this.overlayRef?.overlayElement || !event.target)
|
|
1284
|
+
return false;
|
|
1285
|
+
return this.overlayRef.overlayElement.contains(event.target);
|
|
1286
|
+
}
|
|
1287
|
+
isClickInsidePopup(node) {
|
|
1288
|
+
return !!this.overlayRef?.overlayElement?.contains(node);
|
|
1289
|
+
}
|
|
1290
|
+
isFocusInsidePopup() {
|
|
1291
|
+
if (!this.overlayRef?.overlayElement || !document.activeElement)
|
|
1292
|
+
return false;
|
|
1293
|
+
return this.overlayContainer.getContainerElement().contains(document.activeElement);
|
|
1294
|
+
}
|
|
1295
|
+
areRangesEqual(r1, r2) {
|
|
1296
|
+
if (!r1 || !r2)
|
|
1297
|
+
return r1 === r2;
|
|
1298
|
+
return (r1.commonAncestorContainer === r2.commonAncestorContainer &&
|
|
1299
|
+
r1.startContainer === r2.startContainer &&
|
|
1300
|
+
r1.endContainer === r2.endContainer &&
|
|
1301
|
+
r1.startOffset === r2.startOffset &&
|
|
1302
|
+
r1.endOffset === r2.endOffset);
|
|
1303
|
+
}
|
|
1304
|
+
ngOnDestroy() {
|
|
1305
|
+
this.closePopup();
|
|
1306
|
+
if (this.scrollSubscription) {
|
|
1307
|
+
this.scrollSubscription.unsubscribe();
|
|
1308
|
+
this.scrollSubscription = null;
|
|
1309
|
+
}
|
|
1310
|
+
this.removeDocumentClickListener();
|
|
1311
|
+
this.removeScrollListener();
|
|
1312
|
+
}
|
|
1313
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: TextSelectionPopupDirective, deps: [{ token: i1$2.Overlay }, { token: i0.ViewContainerRef }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1$2.OverlayContainer }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1314
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.7", type: TextSelectionPopupDirective, isStandalone: true, selector: "[ngsTextSelectionPopup]", inputs: { targetComponent: "targetComponent", closestContentObserverClass: "closestContentObserverClass" }, outputs: { tagSelected: "tagSelected" }, host: { listeners: { "document:click": "onDocumentClickHostListener($event)", "document:keydown": "onDocumentKeyDown($event)" } }, ngImport: i0 });
|
|
1315
|
+
}
|
|
1316
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: TextSelectionPopupDirective, decorators: [{
|
|
1317
|
+
type: Directive,
|
|
1318
|
+
args: [{
|
|
1319
|
+
selector: '[ngsTextSelectionPopup]',
|
|
1320
|
+
}]
|
|
1321
|
+
}], ctorParameters: () => [{ type: i1$2.Overlay }, { type: i0.ViewContainerRef }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1$2.OverlayContainer }, { type: i0.NgZone }], propDecorators: { targetComponent: [{
|
|
1322
|
+
type: Input$1
|
|
1323
|
+
}], closestContentObserverClass: [{
|
|
1324
|
+
type: Input$1
|
|
1325
|
+
}], tagSelected: [{
|
|
1326
|
+
type: Output
|
|
1327
|
+
}], onDocumentClickHostListener: [{
|
|
1328
|
+
type: HostListener,
|
|
1329
|
+
args: ['document:click', ['$event']]
|
|
1330
|
+
}], onDocumentKeyDown: [{
|
|
1331
|
+
type: HostListener,
|
|
1332
|
+
args: ['document:keydown', ['$event']]
|
|
1333
|
+
}] } });
|
|
1334
|
+
|
|
1335
|
+
/**
|
|
1336
|
+
* Directive to enable mouse-drag selection of child blocks inside a container.
|
|
1337
|
+
*
|
|
1338
|
+
* Behavior:
|
|
1339
|
+
* - Drag can be started only from an area that is NOT inside a block (matched by `blockSelector`).
|
|
1340
|
+
* - While dragging, the directive creates a dynamic selection rectangle element with the
|
|
1341
|
+
* class `selectionAreaClass` (default: `ngs-textContent-builder-selection-area`).
|
|
1342
|
+
* - Any block that intersects the selection rectangle receives `selectedClass` (default: `is-selected`).
|
|
1343
|
+
* When the block leaves the selection area, the class is removed.
|
|
1344
|
+
*/
|
|
1345
|
+
class BlockSelectionDirective {
|
|
1346
|
+
document = inject(DOCUMENT);
|
|
1347
|
+
_platformId = inject(PLATFORM_ID);
|
|
1348
|
+
contentBuilder = inject(CONTENT_BUILDER);
|
|
1349
|
+
/** CSS selector for selectable blocks. Defaults to `.block`. */
|
|
1350
|
+
blockSelector = input('.block-content', /* @ts-ignore */
|
|
1351
|
+
...(ngDevMode ? [{ debugName: "blockSelector" }] : /* istanbul ignore next */ []));
|
|
1352
|
+
autoScrollContainerSelector = input(null, /* @ts-ignore */
|
|
1353
|
+
...(ngDevMode ? [{ debugName: "autoScrollContainerSelector" }] : /* istanbul ignore next */ []));
|
|
1354
|
+
/** CSS class applied to the dynamic selection rectangle element. */
|
|
1355
|
+
selectionAreaClass = input('selection-area', /* @ts-ignore */
|
|
1356
|
+
...(ngDevMode ? [{ debugName: "selectionAreaClass" }] : /* istanbul ignore next */ []));
|
|
1357
|
+
/**
|
|
1358
|
+
* List of CSS class names to ignore when starting selection.
|
|
1359
|
+
* If the mousedown target or any of its ancestors (via closest) contains any of
|
|
1360
|
+
* these classes, the selection will NOT start. Class names can be provided with
|
|
1361
|
+
* or without leading dot (e.g., 'toolbar-button' or '.toolbar-button').
|
|
1362
|
+
*/
|
|
1363
|
+
ignoreClasses = input(['.block-controls'], /* @ts-ignore */
|
|
1364
|
+
...(ngDevMode ? [{ debugName: "ignoreClasses" }] : /* istanbul ignore next */ []));
|
|
1365
|
+
elRef = inject(ElementRef);
|
|
1366
|
+
host = this.elRef.nativeElement;
|
|
1367
|
+
selection = null;
|
|
1368
|
+
// Track only blockIds we toggled via drag selection to avoid interfering with other selection sources
|
|
1369
|
+
selectedSet = new Set();
|
|
1370
|
+
constructor() {
|
|
1371
|
+
if (isPlatformBrowser(this._platformId)) {
|
|
1372
|
+
this.selection = new SelectionArea({
|
|
1373
|
+
selectables: [this.blockSelector()],
|
|
1374
|
+
boundaries: [this.host],
|
|
1375
|
+
container: this.host,
|
|
1376
|
+
features: {
|
|
1377
|
+
touch: false,
|
|
1378
|
+
range: true,
|
|
1379
|
+
deselectOnBlur: true,
|
|
1380
|
+
singleTap: {
|
|
1381
|
+
allow: true,
|
|
1382
|
+
intersect: 'native'
|
|
1383
|
+
}
|
|
1384
|
+
},
|
|
1385
|
+
selectionAreaClass: this.selectionAreaClass()
|
|
1386
|
+
}).on('beforestart', ({ event }) => {
|
|
1387
|
+
const targetEl = event?.target;
|
|
1388
|
+
if (this.isInIgnoredArea(targetEl) || targetEl?.closest(this.blockSelector())) {
|
|
1389
|
+
return false;
|
|
1390
|
+
}
|
|
1391
|
+
if (event) {
|
|
1392
|
+
event.preventDefault();
|
|
1393
|
+
}
|
|
1394
|
+
return true;
|
|
1395
|
+
}).on('stop', () => {
|
|
1396
|
+
this.contentBuilder.isSelectionOfBlocksActive.set(false);
|
|
1397
|
+
}).on('start', ({ store, event }) => {
|
|
1398
|
+
this.contentBuilder.isSelectionOfBlocksActive.set(true);
|
|
1399
|
+
const activeElement = this.document.activeElement;
|
|
1400
|
+
if (activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA' || activeElement.isContentEditable)) {
|
|
1401
|
+
activeElement.blur();
|
|
1402
|
+
}
|
|
1403
|
+
this.host.focus();
|
|
1404
|
+
if (event && !event.ctrlKey && !event.metaKey) {
|
|
1405
|
+
this.contentBuilder.unselectSelectedBlocks();
|
|
1406
|
+
this.selectedSet.clear();
|
|
1407
|
+
}
|
|
1408
|
+
}).on('move', ({ store: { changed: { added, removed } } }) => {
|
|
1409
|
+
added.forEach(el => {
|
|
1410
|
+
const blockEl = el.closest('.block');
|
|
1411
|
+
const blockId = blockEl?.getAttribute('data-block-id');
|
|
1412
|
+
if (blockId) {
|
|
1413
|
+
this.contentBuilder.selectBlock(blockId, true);
|
|
1414
|
+
this.selectedSet.add(blockId);
|
|
1415
|
+
}
|
|
1416
|
+
});
|
|
1417
|
+
removed.forEach(el => {
|
|
1418
|
+
const blockEl = el.closest('.block');
|
|
1419
|
+
const blockId = blockEl?.getAttribute('data-block-id');
|
|
1420
|
+
if (blockId && this.selectedSet.has(blockId)) {
|
|
1421
|
+
this.contentBuilder.unselectBlock(blockId);
|
|
1422
|
+
this.selectedSet.delete(blockId);
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
ngOnDestroy() {
|
|
1429
|
+
this.selection?.destroy();
|
|
1430
|
+
}
|
|
1431
|
+
isInIgnoredArea(target) {
|
|
1432
|
+
const list = this.ignoreClasses();
|
|
1433
|
+
if (!target || !Array.isArray(list) || list.length === 0)
|
|
1434
|
+
return false;
|
|
1435
|
+
const normalized = list
|
|
1436
|
+
.map(c => (c ?? '').toString().trim())
|
|
1437
|
+
.filter(Boolean)
|
|
1438
|
+
.map(c => c.startsWith('.') ? c.slice(1) : c);
|
|
1439
|
+
if (normalized.length === 0)
|
|
1440
|
+
return false;
|
|
1441
|
+
let el = target;
|
|
1442
|
+
// Traverse up through ancestors to emulate "closest" semantics for class names
|
|
1443
|
+
while (el) {
|
|
1444
|
+
for (const cls of normalized) {
|
|
1445
|
+
if (el.classList && el.classList.contains(cls))
|
|
1446
|
+
return true;
|
|
1447
|
+
}
|
|
1448
|
+
el = el.parentElement;
|
|
1449
|
+
}
|
|
1450
|
+
return false;
|
|
1451
|
+
}
|
|
1452
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: BlockSelectionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1453
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.7", type: BlockSelectionDirective, isStandalone: true, selector: "[ngsBlockSelection]", inputs: { blockSelector: { classPropertyName: "blockSelector", publicName: "blockSelector", isSignal: true, isRequired: false, transformFunction: null }, autoScrollContainerSelector: { classPropertyName: "autoScrollContainerSelector", publicName: "autoScrollContainerSelector", isSignal: true, isRequired: false, transformFunction: null }, selectionAreaClass: { classPropertyName: "selectionAreaClass", publicName: "selectionAreaClass", isSignal: true, isRequired: false, transformFunction: null }, ignoreClasses: { classPropertyName: "ignoreClasses", publicName: "ignoreClasses", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
1454
|
+
}
|
|
1455
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: BlockSelectionDirective, decorators: [{
|
|
1456
|
+
type: Directive,
|
|
1457
|
+
args: [{
|
|
1458
|
+
selector: '[ngsBlockSelection]'
|
|
1459
|
+
}]
|
|
1460
|
+
}], ctorParameters: () => [], propDecorators: { blockSelector: [{ type: i0.Input, args: [{ isSignal: true, alias: "blockSelector", required: false }] }], autoScrollContainerSelector: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoScrollContainerSelector", required: false }] }], selectionAreaClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectionAreaClass", required: false }] }], ignoreClasses: [{ type: i0.Input, args: [{ isSignal: true, alias: "ignoreClasses", required: false }] }] } });
|
|
1461
|
+
|
|
1462
|
+
class ContentBuilderComponent {
|
|
1463
|
+
static DRAFT_STORAGE_PREFIX = 'ngs-content-editor-builder:draft';
|
|
1464
|
+
editor = inject(NgsHeadlessEditor);
|
|
1465
|
+
globalConfig = inject(CONTENT_EDITOR_CONFIG);
|
|
1466
|
+
htmlSerializer = inject(ContentEditorHtmlSerializer);
|
|
1467
|
+
config = input({}, /* @ts-ignore */
|
|
1468
|
+
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
1469
|
+
/** One insertion menu shared by root controls, nested collections and custom blocks. */
|
|
1470
|
+
blockMenu = viewChild.required('suggestionsMenu', /* @ts-ignore */
|
|
1471
|
+
...(ngDevMode ? [{ debugName: "blockMenu" }] : /* istanbul ignore next */ []));
|
|
1472
|
+
document = inject(DOCUMENT);
|
|
1473
|
+
loaded = false;
|
|
1474
|
+
lastInput = null;
|
|
1475
|
+
_platformId = inject(PLATFORM_ID);
|
|
1476
|
+
_store = inject(ContentBuilderStore);
|
|
1477
|
+
dropList = viewChild.required(CdkDropList, /* @ts-ignore */
|
|
1478
|
+
...(ngDevMode ? [{ debugName: "dropList" }] : /* istanbul ignore next */ []));
|
|
1479
|
+
connectedDropLists = this._store.dropLists;
|
|
1480
|
+
elRef = inject((ElementRef));
|
|
1481
|
+
envInjector = inject(EnvironmentInjector);
|
|
1482
|
+
cdr = inject(ChangeDetectorRef);
|
|
1483
|
+
confirmManager = inject(ConfirmManager);
|
|
1484
|
+
_resolvedScrollContainer = null;
|
|
1485
|
+
_scrollEffect;
|
|
1486
|
+
_scrollSubject = new Subject();
|
|
1487
|
+
_scrollBindSub = null;
|
|
1488
|
+
_scroll$ = null;
|
|
1489
|
+
get scrollContainerScrolled() {
|
|
1490
|
+
if (!this._scroll$) {
|
|
1491
|
+
this._scroll$ = this._scrollSubject.asObservable().pipe(shareReplay(1));
|
|
1492
|
+
}
|
|
1493
|
+
return this._scroll$;
|
|
1494
|
+
}
|
|
1495
|
+
blockDefs = signal([
|
|
1496
|
+
...CONTENT_EDITOR_EXTRA_BLOCK_DEFS,
|
|
1497
|
+
{
|
|
1498
|
+
component: () => import('./ngstarter-ui-components-content-editor-divider-block.component-D1nXMRXD.mjs').then(c => c.DividerBlockComponent),
|
|
1499
|
+
type: 'divider',
|
|
1500
|
+
options: {},
|
|
1501
|
+
empty: () => {
|
|
1502
|
+
return {
|
|
1503
|
+
content: null,
|
|
1504
|
+
settings: {}
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1507
|
+
},
|
|
1508
|
+
{
|
|
1509
|
+
component: () => import('./ngstarter-ui-components-content-editor-paragraph-block.component-JVxf_Cdx.mjs').then(c => c.ParagraphBlockComponent),
|
|
1510
|
+
type: 'paragraph',
|
|
1511
|
+
options: {},
|
|
1512
|
+
empty: () => {
|
|
1513
|
+
return {
|
|
1514
|
+
content: [createNgsHeadlessEditorText()],
|
|
1515
|
+
props: [],
|
|
1516
|
+
settings: {}
|
|
1517
|
+
};
|
|
1518
|
+
}
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
component: () => import('./ngstarter-ui-components-content-editor-code-block.component-DSdVOJtH.mjs').then(c => c.CodeBlockComponent),
|
|
1522
|
+
type: 'code',
|
|
1523
|
+
options: {},
|
|
1524
|
+
empty: () => {
|
|
1525
|
+
return {
|
|
1526
|
+
content: [createNgsHeadlessEditorText()],
|
|
1527
|
+
settings: {
|
|
1528
|
+
language: 'none',
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
},
|
|
1533
|
+
{
|
|
1534
|
+
component: () => import('./ngstarter-ui-components-content-editor-heading-block.component-BYpctSPe.mjs').then(c => c.HeadingBlockComponent),
|
|
1535
|
+
type: 'heading',
|
|
1536
|
+
options: {},
|
|
1537
|
+
empty: () => {
|
|
1538
|
+
return {
|
|
1539
|
+
content: [createNgsHeadlessEditorText()],
|
|
1540
|
+
props: [],
|
|
1541
|
+
settings: {
|
|
1542
|
+
level: 2
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
},
|
|
1547
|
+
{
|
|
1548
|
+
component: () => import('./ngstarter-ui-components-content-editor-image-block.component-B3MnANpi.mjs').then(c => c.ImageBlockComponent),
|
|
1549
|
+
type: 'image',
|
|
1550
|
+
options: {
|
|
1551
|
+
uploadFn: (file, base64) => {
|
|
1552
|
+
return new Promise((resolve) => {
|
|
1553
|
+
resolve(base64);
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1556
|
+
},
|
|
1557
|
+
empty: () => {
|
|
1558
|
+
return {
|
|
1559
|
+
content: {
|
|
1560
|
+
src: '',
|
|
1561
|
+
alt: ''
|
|
1562
|
+
},
|
|
1563
|
+
settings: {
|
|
1564
|
+
alignment: 'center',
|
|
1565
|
+
width: 'auto',
|
|
1566
|
+
height: 'auto',
|
|
1567
|
+
align: 'center',
|
|
1568
|
+
natualWidth: 'auto',
|
|
1569
|
+
naturalHeight: 'auto'
|
|
1570
|
+
}
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
},
|
|
1574
|
+
{
|
|
1575
|
+
component: () => import('./ngstarter-ui-components-content-editor-video-block.component-DQUPVDwV.mjs').then(c => c.VideoBlockComponent),
|
|
1576
|
+
type: 'video',
|
|
1577
|
+
options: {
|
|
1578
|
+
uploadFn: (file, base64) => {
|
|
1579
|
+
return new Promise((resolve) => {
|
|
1580
|
+
resolve(base64);
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
},
|
|
1584
|
+
empty: () => {
|
|
1585
|
+
return {
|
|
1586
|
+
content: {
|
|
1587
|
+
src: '',
|
|
1588
|
+
caption: '',
|
|
1589
|
+
orientation: 'landscape'
|
|
1590
|
+
},
|
|
1591
|
+
settings: {
|
|
1592
|
+
alignment: 'center',
|
|
1593
|
+
width: 'auto',
|
|
1594
|
+
height: 'auto',
|
|
1595
|
+
align: 'center',
|
|
1596
|
+
natualWidth: 'auto',
|
|
1597
|
+
naturalHeight: 'auto'
|
|
1598
|
+
}
|
|
1599
|
+
};
|
|
1600
|
+
}
|
|
1601
|
+
},
|
|
1602
|
+
{
|
|
1603
|
+
component: () => import('./ngstarter-ui-components-content-editor-list-block.component-6SMBxIl4.mjs').then(c => c.ListBlockComponent),
|
|
1604
|
+
type: 'bulletList',
|
|
1605
|
+
options: {},
|
|
1606
|
+
empty: () => {
|
|
1607
|
+
return {
|
|
1608
|
+
content: [],
|
|
1609
|
+
settings: {
|
|
1610
|
+
listStyle: 'bullet'
|
|
1611
|
+
}
|
|
1612
|
+
};
|
|
1613
|
+
}
|
|
1614
|
+
},
|
|
1615
|
+
{
|
|
1616
|
+
component: () => import('./ngstarter-ui-components-content-editor-list-block.component-6SMBxIl4.mjs').then(c => c.ListBlockComponent),
|
|
1617
|
+
type: 'orderedList',
|
|
1618
|
+
options: {},
|
|
1619
|
+
empty: () => {
|
|
1620
|
+
return {
|
|
1621
|
+
content: [],
|
|
1622
|
+
settings: {
|
|
1623
|
+
listStyle: 'ordered'
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
}
|
|
1627
|
+
},
|
|
1628
|
+
{
|
|
1629
|
+
component: () => import('./ngstarter-ui-components-content-editor-table-block.component-CJS-IBHw.mjs').then(c => c.TableBlockComponent),
|
|
1630
|
+
type: 'table',
|
|
1631
|
+
options: {},
|
|
1632
|
+
empty: () => {
|
|
1633
|
+
return {
|
|
1634
|
+
content: [
|
|
1635
|
+
[
|
|
1636
|
+
{
|
|
1637
|
+
content: [createNgsHeadlessEditorText()],
|
|
1638
|
+
props: [],
|
|
1639
|
+
styles: {},
|
|
1640
|
+
options: {
|
|
1641
|
+
colspan: 1,
|
|
1642
|
+
rowspan: 1
|
|
1643
|
+
},
|
|
1644
|
+
},
|
|
1645
|
+
{
|
|
1646
|
+
content: [createNgsHeadlessEditorText()],
|
|
1647
|
+
props: [],
|
|
1648
|
+
styles: {},
|
|
1649
|
+
options: {
|
|
1650
|
+
colspan: 1,
|
|
1651
|
+
rowspan: 1
|
|
1652
|
+
}
|
|
1653
|
+
},
|
|
1654
|
+
{
|
|
1655
|
+
content: [createNgsHeadlessEditorText()],
|
|
1656
|
+
props: [],
|
|
1657
|
+
styles: {},
|
|
1658
|
+
options: {
|
|
1659
|
+
colspan: 1,
|
|
1660
|
+
rowspan: 1
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
],
|
|
1664
|
+
[
|
|
1665
|
+
{
|
|
1666
|
+
content: [createNgsHeadlessEditorText()],
|
|
1667
|
+
props: [],
|
|
1668
|
+
styles: {},
|
|
1669
|
+
options: {
|
|
1670
|
+
colspan: 1,
|
|
1671
|
+
rowspan: 1
|
|
1672
|
+
}
|
|
1673
|
+
},
|
|
1674
|
+
{
|
|
1675
|
+
content: [createNgsHeadlessEditorText()],
|
|
1676
|
+
props: [],
|
|
1677
|
+
options: {
|
|
1678
|
+
colspan: 1,
|
|
1679
|
+
rowspan: 1
|
|
1680
|
+
}
|
|
1681
|
+
},
|
|
1682
|
+
{
|
|
1683
|
+
content: [createNgsHeadlessEditorText()],
|
|
1684
|
+
props: [],
|
|
1685
|
+
styles: {},
|
|
1686
|
+
options: {
|
|
1687
|
+
colspan: 1,
|
|
1688
|
+
rowspan: 1
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
],
|
|
1692
|
+
],
|
|
1693
|
+
settings: {}
|
|
1694
|
+
};
|
|
1695
|
+
}
|
|
1696
|
+
},
|
|
1697
|
+
{
|
|
1698
|
+
component: () => import('./ngstarter-ui-components-content-editor-quote-block.component-7EO7z7Sr.mjs').then(c => c.QuoteBlockComponent),
|
|
1699
|
+
type: 'quote',
|
|
1700
|
+
options: {},
|
|
1701
|
+
empty: () => {
|
|
1702
|
+
return {
|
|
1703
|
+
content: {
|
|
1704
|
+
cite: {
|
|
1705
|
+
content: [createNgsHeadlessEditorText()],
|
|
1706
|
+
props: []
|
|
1707
|
+
},
|
|
1708
|
+
caption: {
|
|
1709
|
+
content: [createNgsHeadlessEditorText()],
|
|
1710
|
+
props: []
|
|
1711
|
+
}
|
|
1712
|
+
},
|
|
1713
|
+
settings: {}
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
},
|
|
1717
|
+
{
|
|
1718
|
+
component: () => import('./ngstarter-ui-components-content-editor-embed-block-DhFxtMQS.mjs').then(c => c.EmbedBlock),
|
|
1719
|
+
type: 'embed',
|
|
1720
|
+
options: {},
|
|
1721
|
+
empty: () => {
|
|
1722
|
+
return {
|
|
1723
|
+
content: {
|
|
1724
|
+
url: '',
|
|
1725
|
+
type: ''
|
|
1726
|
+
},
|
|
1727
|
+
settings: {}
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1730
|
+
},
|
|
1731
|
+
].map(def => ({ ...def, toHtml: CONTENT_EDITOR_DEFAULT_HTML_CONVERTERS[def.type] })), /* @ts-ignore */
|
|
1732
|
+
...(ngDevMode ? [{ debugName: "blockDefs" }] : /* istanbul ignore next */ []));
|
|
1733
|
+
content = input(createNgsHeadlessEditorDocument(), /* @ts-ignore */
|
|
1734
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
1735
|
+
contentChangedDelay = input(500, { ...(ngDevMode ? { debugName: "contentChangedDelay" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
1736
|
+
persistDraft = input(true, { ...(ngDevMode ? { debugName: "persistDraft" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
1737
|
+
suggestions = input([
|
|
1738
|
+
...CONTENT_EDITOR_EXTRA_SUGGESTIONS,
|
|
1739
|
+
{
|
|
1740
|
+
type: 'heading',
|
|
1741
|
+
title: 'Headings',
|
|
1742
|
+
},
|
|
1743
|
+
{
|
|
1744
|
+
type: 'item',
|
|
1745
|
+
title: 'Heading 1',
|
|
1746
|
+
description: 'Top-level heading',
|
|
1747
|
+
iconName: 'fluent:text-header-1-24-regular',
|
|
1748
|
+
hotKeys: 'ALT + 1',
|
|
1749
|
+
blockType: 'heading',
|
|
1750
|
+
blockSettings: {
|
|
1751
|
+
level: 1
|
|
1752
|
+
}
|
|
1753
|
+
},
|
|
1754
|
+
{
|
|
1755
|
+
type: 'item',
|
|
1756
|
+
title: 'Heading 2',
|
|
1757
|
+
description: 'Key section heading',
|
|
1758
|
+
iconName: 'fluent:text-header-2-24-regular',
|
|
1759
|
+
hotKeys: 'ALT + 2',
|
|
1760
|
+
blockType: 'heading',
|
|
1761
|
+
blockSettings: {
|
|
1762
|
+
level: 2
|
|
1763
|
+
}
|
|
1764
|
+
},
|
|
1765
|
+
{
|
|
1766
|
+
type: 'item',
|
|
1767
|
+
title: 'Heading 3',
|
|
1768
|
+
description: 'Subsection and group heading',
|
|
1769
|
+
iconName: 'fluent:text-header-3-24-regular',
|
|
1770
|
+
hotKeys: 'ALT + 3',
|
|
1771
|
+
blockType: 'heading',
|
|
1772
|
+
blockSettings: {
|
|
1773
|
+
level: 3
|
|
1774
|
+
}
|
|
1775
|
+
},
|
|
1776
|
+
{
|
|
1777
|
+
type: 'heading',
|
|
1778
|
+
title: 'Basic blocks',
|
|
1779
|
+
},
|
|
1780
|
+
{
|
|
1781
|
+
type: 'item',
|
|
1782
|
+
title: 'Paragraph',
|
|
1783
|
+
description: 'The body of your document',
|
|
1784
|
+
iconName: 'fluent:text-paragraph-24-regular',
|
|
1785
|
+
hotKeys: 'ALT + 0',
|
|
1786
|
+
blockType: 'paragraph',
|
|
1787
|
+
blockSettings: {}
|
|
1788
|
+
},
|
|
1789
|
+
{
|
|
1790
|
+
type: 'item',
|
|
1791
|
+
title: 'Numbered List',
|
|
1792
|
+
description: 'List with ordered items',
|
|
1793
|
+
iconName: 'fluent:text-bullet-list-tree-24-regular',
|
|
1794
|
+
hotKeys: 'ALT + 0',
|
|
1795
|
+
blockType: 'orderedList',
|
|
1796
|
+
blockSettings: {}
|
|
1797
|
+
},
|
|
1798
|
+
{
|
|
1799
|
+
type: 'item',
|
|
1800
|
+
title: 'Bullet List',
|
|
1801
|
+
description: 'List with unordered items',
|
|
1802
|
+
iconName: 'fluent:text-bullet-list-ltr-24-regular',
|
|
1803
|
+
hotKeys: 'ALT + 0',
|
|
1804
|
+
blockType: 'bulletList',
|
|
1805
|
+
blockSettings: {}
|
|
1806
|
+
},
|
|
1807
|
+
{
|
|
1808
|
+
type: 'item',
|
|
1809
|
+
title: 'Quote',
|
|
1810
|
+
description: 'Quote or excerpt',
|
|
1811
|
+
iconName: 'fluent:text-quote-24-regular',
|
|
1812
|
+
hotKeys: 'ALT + 0',
|
|
1813
|
+
blockType: 'quote',
|
|
1814
|
+
blockSettings: {}
|
|
1815
|
+
},
|
|
1816
|
+
{
|
|
1817
|
+
type: 'item',
|
|
1818
|
+
title: 'Code',
|
|
1819
|
+
description: 'The code block with syntax highlighting',
|
|
1820
|
+
iconName: 'fluent:code-24-regular',
|
|
1821
|
+
hotKeys: 'ALT + 0',
|
|
1822
|
+
blockType: 'code',
|
|
1823
|
+
blockSettings: {}
|
|
1824
|
+
},
|
|
1825
|
+
{
|
|
1826
|
+
type: 'item',
|
|
1827
|
+
title: 'Divider',
|
|
1828
|
+
description: 'Visually divide blocks',
|
|
1829
|
+
iconName: 'fluent:minimize-24-regular',
|
|
1830
|
+
hotKeys: 'ALT + 0',
|
|
1831
|
+
blockType: 'divider',
|
|
1832
|
+
blockSettings: {}
|
|
1833
|
+
},
|
|
1834
|
+
{
|
|
1835
|
+
type: 'item',
|
|
1836
|
+
title: 'Table',
|
|
1837
|
+
description: 'Table with editable cells',
|
|
1838
|
+
iconName: 'fluent:table-24-regular',
|
|
1839
|
+
hotKeys: 'ALT + 0',
|
|
1840
|
+
blockType: 'table',
|
|
1841
|
+
blockSettings: {}
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
type: 'heading',
|
|
1845
|
+
title: 'Media',
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
type: 'item',
|
|
1849
|
+
title: 'Image',
|
|
1850
|
+
description: 'Image with caption',
|
|
1851
|
+
iconName: 'fluent:image-24-regular',
|
|
1852
|
+
hotKeys: 'ALT + 0',
|
|
1853
|
+
blockType: 'image',
|
|
1854
|
+
blockSettings: {}
|
|
1855
|
+
},
|
|
1856
|
+
{
|
|
1857
|
+
type: 'item',
|
|
1858
|
+
title: 'Video',
|
|
1859
|
+
description: 'Video with caption',
|
|
1860
|
+
iconName: 'fluent:video-24-regular',
|
|
1861
|
+
hotKeys: 'ALT + 0',
|
|
1862
|
+
blockType: 'video',
|
|
1863
|
+
blockSettings: {}
|
|
1864
|
+
},
|
|
1865
|
+
{
|
|
1866
|
+
type: 'heading',
|
|
1867
|
+
title: 'Embeds',
|
|
1868
|
+
},
|
|
1869
|
+
{
|
|
1870
|
+
type: 'item',
|
|
1871
|
+
title: 'Embed',
|
|
1872
|
+
description: 'For PDFs, Google Maps and more',
|
|
1873
|
+
iconName: 'fluent:window-24-regular',
|
|
1874
|
+
hotKeys: 'ALT + 0',
|
|
1875
|
+
blockType: 'embed',
|
|
1876
|
+
blockSettings: {
|
|
1877
|
+
width: null,
|
|
1878
|
+
height: null
|
|
1879
|
+
}
|
|
1880
|
+
},
|
|
1881
|
+
], /* @ts-ignore */
|
|
1882
|
+
...(ngDevMode ? [{ debugName: "suggestions" }] : /* istanbul ignore next */ []));
|
|
1883
|
+
options = input({}, /* @ts-ignore */
|
|
1884
|
+
...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
1885
|
+
scrollContainer = input(/* @ts-ignore */
|
|
1886
|
+
...(ngDevMode ? [undefined, { debugName: "scrollContainer" }] : /* istanbul ignore next */ []));
|
|
1887
|
+
contentChanged = output();
|
|
1888
|
+
focusChanged = new EventEmitter();
|
|
1889
|
+
_content = this._store.blocks;
|
|
1890
|
+
blockDefsMap = new Map();
|
|
1891
|
+
blockDefsOptionsMap = new Map();
|
|
1892
|
+
_blockDragging = signal(false, /* @ts-ignore */
|
|
1893
|
+
...(ngDevMode ? [{ debugName: "_blockDragging" }] : /* istanbul ignore next */ []));
|
|
1894
|
+
isSelectionOfBlocksActive = signal(false, /* @ts-ignore */
|
|
1895
|
+
...(ngDevMode ? [{ debugName: "isSelectionOfBlocksActive" }] : /* istanbul ignore next */ []));
|
|
1896
|
+
selectedBlocksModel = new SelectionModel(true);
|
|
1897
|
+
commandBar = CommandBarComponent;
|
|
1898
|
+
get api() {
|
|
1899
|
+
return {
|
|
1900
|
+
focusChanged: new EventEmitter(),
|
|
1901
|
+
};
|
|
1902
|
+
}
|
|
1903
|
+
// Build helper maps: component map and merged options map
|
|
1904
|
+
buildBlockDefMaps() {
|
|
1905
|
+
const overrides = this.options() || {};
|
|
1906
|
+
const config = mergeContentEditorConfig(this.globalConfig, this.config());
|
|
1907
|
+
this.blockDefsOptionsMap = new Map();
|
|
1908
|
+
this.blockDefs().forEach((def) => {
|
|
1909
|
+
if (!this.blockDefsMap.has(def.type)) {
|
|
1910
|
+
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);
|
|
1920
|
+
});
|
|
1921
|
+
}
|
|
1922
|
+
/** Shared by nested block collections; all edits use this root editor. */
|
|
1923
|
+
get rootBuilder() { return this; }
|
|
1924
|
+
getBlockComponent(type) { return this.blockDefsMap.get(type); }
|
|
1925
|
+
createBlockView(type, settings = {}, content) { return this._createBlock(type, settings, content); }
|
|
1926
|
+
getBlockDefOption(type, key) {
|
|
1927
|
+
return this.blockDefsOptionsMap.get(type)[key];
|
|
1928
|
+
}
|
|
1929
|
+
ngOnInit() {
|
|
1930
|
+
this.lastInput = this.content();
|
|
1931
|
+
const document = this._getDraftContent() ?? this.lastInput;
|
|
1932
|
+
const last = document.blocks.at(-1);
|
|
1933
|
+
const blocks = last && (last.type !== 'paragraph' || contentEditorText(last.content).length > 0)
|
|
1934
|
+
? [...document.blocks, { id: v7(), type: 'paragraph', content: [createNgsHeadlessEditorText()] }]
|
|
1935
|
+
: document.blocks;
|
|
1936
|
+
this._store.setBlocks({ version: 1, blocks });
|
|
1937
|
+
this.buildBlockDefMaps();
|
|
1938
|
+
this.loaded = true;
|
|
1939
|
+
if (!isPlatformServer(this._platformId) && this._content().length === 1) {
|
|
1940
|
+
this.focusBlock(this._content()[0].id);
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
constructor() {
|
|
1944
|
+
effect(() => {
|
|
1945
|
+
this.config();
|
|
1946
|
+
this.options();
|
|
1947
|
+
untracked(() => { if (this.loaded)
|
|
1948
|
+
this.buildBlockDefMaps(); });
|
|
1949
|
+
});
|
|
1950
|
+
effect(() => {
|
|
1951
|
+
const value = this.content();
|
|
1952
|
+
untracked(() => {
|
|
1953
|
+
if (this.loaded && value !== this.lastInput) {
|
|
1954
|
+
this.lastInput = value;
|
|
1955
|
+
this._store.setBlocks(value);
|
|
1956
|
+
}
|
|
1957
|
+
});
|
|
1958
|
+
});
|
|
1959
|
+
effect(() => {
|
|
1960
|
+
const document = this.editor.document();
|
|
1961
|
+
const origin = this.editor.origin();
|
|
1962
|
+
if (this.loaded && origin !== 'external') {
|
|
1963
|
+
untracked(() => {
|
|
1964
|
+
this._saveDraft(document);
|
|
1965
|
+
this.contentChanged.emit(document);
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1970
|
+
ngAfterViewInit() {
|
|
1971
|
+
if (isPlatformServer(this._platformId)) {
|
|
1972
|
+
return;
|
|
1973
|
+
}
|
|
1974
|
+
this._store.registerDropList(this.dropList());
|
|
1975
|
+
// Initial resolve after view init
|
|
1976
|
+
this._resolvedScrollContainer = this._computeScrollContainer();
|
|
1977
|
+
// Bind the scroll subscription to the current container
|
|
1978
|
+
this._rebindScrollListener();
|
|
1979
|
+
// Watch for changes of the input selector and recompute when it changes.
|
|
1980
|
+
// Create the signal effect within a valid injection context to satisfy Angular's requirement.
|
|
1981
|
+
runInInjectionContext(this.envInjector, () => {
|
|
1982
|
+
this._scrollEffect = effect(() => {
|
|
1983
|
+
const _selector = this.scrollContainer();
|
|
1984
|
+
this._resolvedScrollContainer = this._computeScrollContainer();
|
|
1985
|
+
// Rebind the listener when the container changes
|
|
1986
|
+
this._rebindScrollListener();
|
|
1987
|
+
}, /* @ts-ignore */
|
|
1988
|
+
...(ngDevMode ? [{ debugName: "_scrollEffect" }] : /* istanbul ignore next */ []));
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
1991
|
+
/**
|
|
1992
|
+
* Public accessor for the resolved scroll container. If not computed yet, it will compute now.
|
|
1993
|
+
*/
|
|
1994
|
+
getScrollContainer() {
|
|
1995
|
+
if (isPlatformServer(this._platformId)) {
|
|
1996
|
+
return {};
|
|
1997
|
+
}
|
|
1998
|
+
if (!this._resolvedScrollContainer) {
|
|
1999
|
+
this._resolvedScrollContainer = this._computeScrollContainer();
|
|
2000
|
+
}
|
|
2001
|
+
return this._resolvedScrollContainer || window;
|
|
2002
|
+
}
|
|
2003
|
+
/**
|
|
2004
|
+
* Resolves the scroll container element according to the following rules:
|
|
2005
|
+
* - If `scrollContainer` input is provided, uses `closest(selector)` starting from the host element.
|
|
2006
|
+
* - If not provided or `closest` returned null, automatically finds the first scrollable parent by walking up the DOM.
|
|
2007
|
+
* - Fallback to `document.scrollingElement` or `window` if nothing suitable found.
|
|
2008
|
+
*/
|
|
2009
|
+
_computeScrollContainer() {
|
|
2010
|
+
if (isPlatformServer(this._platformId)) {
|
|
2011
|
+
return null;
|
|
2012
|
+
}
|
|
2013
|
+
const host = this.elRef?.nativeElement;
|
|
2014
|
+
if (!host) {
|
|
2015
|
+
return (document.scrollingElement || window);
|
|
2016
|
+
}
|
|
2017
|
+
const selector = this.scrollContainer();
|
|
2018
|
+
if (selector && typeof selector === 'string') {
|
|
2019
|
+
try {
|
|
2020
|
+
const matched = host.closest(selector);
|
|
2021
|
+
if (matched) {
|
|
2022
|
+
return matched;
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
catch (_) {
|
|
2026
|
+
// If selector is invalid, ignore and fallback to auto detection
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
// Auto-detect by traversing parents
|
|
2030
|
+
let parent = host.parentElement;
|
|
2031
|
+
while (parent) {
|
|
2032
|
+
if (this._isElementScrollable(parent)) {
|
|
2033
|
+
return parent;
|
|
2034
|
+
}
|
|
2035
|
+
parent = parent.parentElement;
|
|
2036
|
+
}
|
|
2037
|
+
return (document.scrollingElement || window);
|
|
2038
|
+
}
|
|
2039
|
+
_isElementScrollable(el) {
|
|
2040
|
+
const style = getComputedStyle(el);
|
|
2041
|
+
const overflowY = style.overflowY;
|
|
2042
|
+
const overflowX = style.overflowX;
|
|
2043
|
+
const canScrollY = (overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'overlay') && el.scrollHeight > el.clientHeight;
|
|
2044
|
+
const canScrollX = (overflowX === 'auto' || overflowX === 'scroll' || overflowX === 'overlay') && el.scrollWidth > el.clientWidth;
|
|
2045
|
+
return canScrollY || canScrollX;
|
|
2046
|
+
}
|
|
2047
|
+
_rebindScrollListener() {
|
|
2048
|
+
if (isPlatformServer(this._platformId)) {
|
|
2049
|
+
return;
|
|
2050
|
+
}
|
|
2051
|
+
// Unsubscribe from the previous container, if any
|
|
2052
|
+
if (this._scrollBindSub) {
|
|
2053
|
+
try {
|
|
2054
|
+
this._scrollBindSub.unsubscribe();
|
|
2055
|
+
}
|
|
2056
|
+
catch {
|
|
2057
|
+
}
|
|
2058
|
+
this._scrollBindSub = null;
|
|
2059
|
+
}
|
|
2060
|
+
const container = this._resolvedScrollContainer ?? this._computeScrollContainer();
|
|
2061
|
+
if (!container) {
|
|
2062
|
+
return;
|
|
2063
|
+
}
|
|
2064
|
+
// Create the scroll source
|
|
2065
|
+
const getTop = () => {
|
|
2066
|
+
if (container instanceof Window) {
|
|
2067
|
+
return container.scrollY || container.pageYOffset || 0;
|
|
2068
|
+
}
|
|
2069
|
+
return container.scrollTop || 0;
|
|
2070
|
+
};
|
|
2071
|
+
const source$ = fromEvent(container, 'scroll').pipe(auditTime(50), map(() => getTop()), startWith(getTop()), distinctUntilChanged());
|
|
2072
|
+
// Subscribe and forward values to the shared Subject
|
|
2073
|
+
this._scrollBindSub = source$.subscribe(top => {
|
|
2074
|
+
this._scrollSubject.next(top);
|
|
2075
|
+
});
|
|
2076
|
+
}
|
|
2077
|
+
// Duplicate ngOnDestroy removed; see the implementation at the end of the class
|
|
2078
|
+
appendBlock(type, focus = true) {
|
|
2079
|
+
this.insertBlock(type, this._content().length, {}, focus);
|
|
2080
|
+
}
|
|
2081
|
+
insertBlock(type, index, options, focus = true, content) {
|
|
2082
|
+
const isLastIndex = index === this._content().length;
|
|
2083
|
+
const newBlock = this._createBlock(type, options, content);
|
|
2084
|
+
if (focus) {
|
|
2085
|
+
this.focusBlock(newBlock.id);
|
|
2086
|
+
}
|
|
2087
|
+
this._store.addBlock(newBlock, index);
|
|
2088
|
+
if (isLastIndex && this._content()[index].type !== 'paragraph') {
|
|
2089
|
+
this.appendBlock('paragraph', false);
|
|
2090
|
+
}
|
|
2091
|
+
this.emitContentChangeEvent();
|
|
2092
|
+
return this.editor.document().blocks.find(block => block.id === newBlock.id);
|
|
2093
|
+
}
|
|
2094
|
+
_createBlock(type, settings = {}, content) {
|
|
2095
|
+
const blockDef = this.blockDefs().find(blockDefItem => blockDefItem.type === type);
|
|
2096
|
+
const empty = blockDef.empty();
|
|
2097
|
+
if (settings) {
|
|
2098
|
+
empty.settings = {
|
|
2099
|
+
...empty.settings,
|
|
2100
|
+
...settings
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
2103
|
+
if (content !== undefined) {
|
|
2104
|
+
empty.content = content;
|
|
2105
|
+
}
|
|
2106
|
+
return {
|
|
2107
|
+
id: v7(),
|
|
2108
|
+
type: blockDef.type,
|
|
2109
|
+
isEmpty: content === undefined || (Array.isArray(content) && !contentEditorText(content)),
|
|
2110
|
+
...empty
|
|
2111
|
+
};
|
|
2112
|
+
}
|
|
2113
|
+
addBlock(type, options, index = -1) {
|
|
2114
|
+
if (index === -1) {
|
|
2115
|
+
if (this._store.activeBlockId()) {
|
|
2116
|
+
index = this._content().findIndex(dataBlock => dataBlock.id === this._store.activeBlockId()) + 1;
|
|
2117
|
+
}
|
|
2118
|
+
else {
|
|
2119
|
+
index = this._content().length;
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
this.insertBlock(type, index, options);
|
|
2123
|
+
}
|
|
2124
|
+
duplicateBlock(blockId) {
|
|
2125
|
+
const index = this._content().findIndex(dataBlock => dataBlock.id === blockId);
|
|
2126
|
+
if (index === -1) {
|
|
2127
|
+
return;
|
|
2128
|
+
}
|
|
2129
|
+
const original = this._content()[index];
|
|
2130
|
+
// Deep clone mutable fields to avoid shared references
|
|
2131
|
+
const clonedContent = original.content != null ? JSON.parse(JSON.stringify(original.content)) : original.content;
|
|
2132
|
+
const clonedSettings = original.settings != null ? JSON.parse(JSON.stringify(original.settings)) : original.settings;
|
|
2133
|
+
const clonedProps = original.props != null ? JSON.parse(JSON.stringify(original.props)) : original.props;
|
|
2134
|
+
const duplicated = {
|
|
2135
|
+
...original,
|
|
2136
|
+
id: v7(),
|
|
2137
|
+
isEmpty: false,
|
|
2138
|
+
content: clonedContent,
|
|
2139
|
+
settings: clonedSettings,
|
|
2140
|
+
props: clonedProps,
|
|
2141
|
+
};
|
|
2142
|
+
this.regenerateChildIds(duplicated);
|
|
2143
|
+
const insertIndex = index + 1;
|
|
2144
|
+
this._store.addBlock(duplicated, insertIndex);
|
|
2145
|
+
this.focusBlock(duplicated.id);
|
|
2146
|
+
this.emitContentChangeEvent();
|
|
2147
|
+
}
|
|
2148
|
+
regenerateChildIds(block) {
|
|
2149
|
+
for (const children of contentEditorChildCollections(block)) {
|
|
2150
|
+
for (const child of children) {
|
|
2151
|
+
child.id = v7();
|
|
2152
|
+
this.regenerateChildIds(child);
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
if (block.type === 'grid')
|
|
2156
|
+
for (const cell of block.content.cells)
|
|
2157
|
+
cell.id = v7();
|
|
2158
|
+
if (block.type === 'gallery')
|
|
2159
|
+
for (const image of block.content.images)
|
|
2160
|
+
image.id = v7();
|
|
2161
|
+
}
|
|
2162
|
+
duplicateSelectedBlocks(popover) {
|
|
2163
|
+
const selectedIds = [...this.selectedBlocksModel.selected];
|
|
2164
|
+
if (!selectedIds.length)
|
|
2165
|
+
return;
|
|
2166
|
+
// Process in visual order (top to bottom)
|
|
2167
|
+
const ordered = selectedIds
|
|
2168
|
+
.map(id => ({ id, index: this._content().findIndex(b => b.id === id) }))
|
|
2169
|
+
.filter(x => x.index !== -1)
|
|
2170
|
+
.sort((a, b) => a.index - b.index)
|
|
2171
|
+
.map(x => x.id);
|
|
2172
|
+
const newIds = [];
|
|
2173
|
+
for (const id of ordered) {
|
|
2174
|
+
// Get current index of the original before duplicating
|
|
2175
|
+
const idx = this._content().findIndex(b => b.id === id);
|
|
2176
|
+
if (idx === -1)
|
|
2177
|
+
continue;
|
|
2178
|
+
this.duplicateBlock(id);
|
|
2179
|
+
// After duplication, the new block is placed right after the original
|
|
2180
|
+
const newBlock = this._content()[idx + 1];
|
|
2181
|
+
if (newBlock) {
|
|
2182
|
+
newIds.push(newBlock.id);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
// Select duplicated blocks
|
|
2186
|
+
this.selectedBlocksModel.clear();
|
|
2187
|
+
if (newIds.length) {
|
|
2188
|
+
this.selectedBlocksModel.select(...newIds);
|
|
2189
|
+
}
|
|
2190
|
+
this.cdr.markForCheck();
|
|
2191
|
+
}
|
|
2192
|
+
deleteBlock(blockId) {
|
|
2193
|
+
if (this._content().length === 1) {
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2196
|
+
const index = this._content().findIndex(dataBlock => dataBlock.id === blockId);
|
|
2197
|
+
if (index !== -1) {
|
|
2198
|
+
this._store.deleteBlock(blockId, index);
|
|
2199
|
+
const prevBlock = this._content()[index - 1];
|
|
2200
|
+
if (prevBlock) {
|
|
2201
|
+
this.focusBlock(prevBlock.id);
|
|
2202
|
+
}
|
|
2203
|
+
this.emitContentChangeEvent();
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
setBlockProps(id, props) {
|
|
2207
|
+
this._store.updateBlock(id, { props });
|
|
2208
|
+
this.emitContentChangeEvent();
|
|
2209
|
+
}
|
|
2210
|
+
insertEmptyBlock(index) {
|
|
2211
|
+
this.insertBlock('paragraph', index + 1);
|
|
2212
|
+
this.emitContentChangeEvent();
|
|
2213
|
+
}
|
|
2214
|
+
updateParagraph(id, data) { this._store.updateBlock(id, data); }
|
|
2215
|
+
chooseBlock(target, type, options) {
|
|
2216
|
+
const collection = contentEditorCollection(this.editor.document().blocks, target.scope);
|
|
2217
|
+
const afterIndex = target.afterId ? collection.findIndex(block => block.id === target.afterId) : -1;
|
|
2218
|
+
const index = afterIndex < 0 ? collection.length : afterIndex + 1;
|
|
2219
|
+
if (!target.scope.parentId)
|
|
2220
|
+
this.insertBlock(type, index, options);
|
|
2221
|
+
else {
|
|
2222
|
+
const block = this.createBlockView(type, options);
|
|
2223
|
+
this._store.addBlock(block, index, target.scope);
|
|
2224
|
+
this.focusBlock(block.id);
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
focusBlock(id) {
|
|
2228
|
+
this._store.setFocusedBlockId(id);
|
|
2229
|
+
this.focusChanged.emit();
|
|
2230
|
+
}
|
|
2231
|
+
isBlockFocused(id) {
|
|
2232
|
+
return this._store.focusedBlockId() === id;
|
|
2233
|
+
}
|
|
2234
|
+
isActiveBlock(id) {
|
|
2235
|
+
return this._store.activeBlockId() === id;
|
|
2236
|
+
}
|
|
2237
|
+
drop(event) {
|
|
2238
|
+
this._store.moveBetweenCollections(event.previousIndex, event.currentIndex, event.previousContainer.data, event.container.data);
|
|
2239
|
+
this.emitContentChangeEvent();
|
|
2240
|
+
}
|
|
2241
|
+
canEnterRoot = (_drag, drop) => {
|
|
2242
|
+
const pointer = this._store.dragPointer();
|
|
2243
|
+
// Connected parent lists must yield to the nested collection under the pointer.
|
|
2244
|
+
// Otherwise CDK selects the outer list before considering any of its children.
|
|
2245
|
+
const nearest = pointer ? this.document.elementFromPoint(pointer.x, pointer.y)?.closest('.cdk-drop-list') : null;
|
|
2246
|
+
return !nearest || nearest.id === drop.id;
|
|
2247
|
+
};
|
|
2248
|
+
onTagSelected(tagName) {
|
|
2249
|
+
// console.log('Tag selected event received:', tagName);
|
|
2250
|
+
}
|
|
2251
|
+
getData() {
|
|
2252
|
+
return this.editor.document();
|
|
2253
|
+
}
|
|
2254
|
+
/** Exports the live document, including nested blocks, through the configured converters. */
|
|
2255
|
+
toHtml(config = {}) {
|
|
2256
|
+
const defaults = { blocks: Object.fromEntries(this.blockDefs().map(def => [def.type, { toHtml: def.toHtml }])) };
|
|
2257
|
+
return this.htmlSerializer.toHtml(this.getData(), mergeContentEditorConfig(defaults, this.globalConfig, this.config(), config));
|
|
2258
|
+
}
|
|
2259
|
+
blockToHtml(block, config = {}) {
|
|
2260
|
+
return this.htmlSerializer.blockToHtml(block, mergeContentEditorConfig(this.config(), config));
|
|
2261
|
+
}
|
|
2262
|
+
emitContentChangeEvent() {
|
|
2263
|
+
// Document changes, including undo/redo, are emitted by the root effect.
|
|
2264
|
+
}
|
|
2265
|
+
selectBlock(blockId, multiple = false) {
|
|
2266
|
+
if (!this._content().some(block => block.id === blockId))
|
|
2267
|
+
return;
|
|
2268
|
+
if (!multiple) {
|
|
2269
|
+
this.selectedBlocksModel.clear();
|
|
2270
|
+
}
|
|
2271
|
+
this.selectedBlocksModel.select(blockId);
|
|
2272
|
+
this.cdr.markForCheck();
|
|
2273
|
+
}
|
|
2274
|
+
unselectBlock(blockId) {
|
|
2275
|
+
this.selectedBlocksModel.deselect(blockId);
|
|
2276
|
+
this.cdr.markForCheck();
|
|
2277
|
+
}
|
|
2278
|
+
unselectSelectedBlocks() {
|
|
2279
|
+
this.selectedBlocksModel.clear();
|
|
2280
|
+
this.cdr.markForCheck();
|
|
2281
|
+
}
|
|
2282
|
+
isBlockSelected(blockId) {
|
|
2283
|
+
return this.selectedBlocksModel.isSelected(blockId);
|
|
2284
|
+
}
|
|
2285
|
+
deleteSelectedBlocks(popover) {
|
|
2286
|
+
const selectedIds = [...this.selectedBlocksModel.selected];
|
|
2287
|
+
if (!selectedIds.length) {
|
|
2288
|
+
return;
|
|
2289
|
+
}
|
|
2290
|
+
const confirmRef = this.confirmManager.open({
|
|
2291
|
+
title: 'Delete blocks',
|
|
2292
|
+
description: 'Selected blocks will be deleted.'
|
|
2293
|
+
});
|
|
2294
|
+
confirmRef.confirmed.subscribe(() => {
|
|
2295
|
+
// Delete from bottom to top to keep indexes stable
|
|
2296
|
+
const toDelete = selectedIds
|
|
2297
|
+
.map(id => ({ id, index: this._content().findIndex(b => b.id === id) }))
|
|
2298
|
+
.filter(x => x.index !== -1)
|
|
2299
|
+
.sort((a, b) => b.index - a.index);
|
|
2300
|
+
for (const item of toDelete) {
|
|
2301
|
+
this.deleteBlock(item.id);
|
|
2302
|
+
}
|
|
2303
|
+
this.unselectSelectedBlocks();
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
_onKeyDown(event) {
|
|
2307
|
+
if (event.defaultPrevented)
|
|
2308
|
+
return;
|
|
2309
|
+
if (!event.defaultPrevented && (event.ctrlKey || event.metaKey) && ['z', 'y'].includes(event.key.toLowerCase())) {
|
|
2310
|
+
const redo = event.key.toLowerCase() === 'y' || event.shiftKey;
|
|
2311
|
+
if (redo ? this.editor.redo() : this.editor.undo())
|
|
2312
|
+
event.preventDefault();
|
|
2313
|
+
return;
|
|
2314
|
+
}
|
|
2315
|
+
if ((event.key === 'Delete' || event.key === 'Backspace') && this.selectedBlocksModel.hasValue()) {
|
|
2316
|
+
const target = event.target;
|
|
2317
|
+
const isInput = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
|
2318
|
+
// If we are in an input/contenteditable, only delete if multiple blocks are selected
|
|
2319
|
+
// or if it's not a Backspace (to avoid deleting text while trying to delete blocks)
|
|
2320
|
+
// Actually, if blocks are selected, they usually have a blue background and the user intent is likely to delete blocks.
|
|
2321
|
+
// But if there's only ONE block selected AND we are typing in it, we probably want to delete text.
|
|
2322
|
+
if (isInput && this.selectedBlocksModel.selected.length === 1) {
|
|
2323
|
+
// Let the default behavior happen for text editing
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2326
|
+
event.preventDefault();
|
|
2327
|
+
this.deleteSelectedBlocks();
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
onDragStarted(event, block) {
|
|
2331
|
+
this._blockDragging.set(true);
|
|
2332
|
+
this._store.setDragging(true);
|
|
2333
|
+
}
|
|
2334
|
+
onDragEnded(event, block) {
|
|
2335
|
+
this._blockDragging.set(false);
|
|
2336
|
+
this._store.setDragging(false);
|
|
2337
|
+
}
|
|
2338
|
+
addBlockFromSuggestionMenu(suggestionsMenu, target, type, options) {
|
|
2339
|
+
suggestionsMenu.closed.emit('click');
|
|
2340
|
+
this.chooseBlock(target, type, options);
|
|
2341
|
+
}
|
|
2342
|
+
preventMenuClose(event) {
|
|
2343
|
+
event.stopPropagation();
|
|
2344
|
+
event.preventDefault();
|
|
2345
|
+
}
|
|
2346
|
+
setActiveBlockId(event, id) {
|
|
2347
|
+
event.stopPropagation();
|
|
2348
|
+
event.preventDefault();
|
|
2349
|
+
this._store.setActiveBlockId(id);
|
|
2350
|
+
this._store.setFocusedBlockId(id);
|
|
2351
|
+
this.focusChanged.emit();
|
|
2352
|
+
}
|
|
2353
|
+
onFocusChange(origin, dataBlock) {
|
|
2354
|
+
}
|
|
2355
|
+
onSuggestionsMenuClose(reason) {
|
|
2356
|
+
if (!reason) {
|
|
2357
|
+
this._store.setFocusedBlockId(this._store.activeBlockId());
|
|
2358
|
+
this.focusChanged.emit();
|
|
2359
|
+
}
|
|
2360
|
+
// need some delay to prevent the flickering
|
|
2361
|
+
setTimeout(() => this._store.setActiveBlockId(null), 250);
|
|
2362
|
+
}
|
|
2363
|
+
ngOnDestroy() {
|
|
2364
|
+
if (isPlatformServer(this._platformId)) {
|
|
2365
|
+
return;
|
|
2366
|
+
}
|
|
2367
|
+
this._store.unregisterDropList(this.dropList());
|
|
2368
|
+
if (this._scrollBindSub) {
|
|
2369
|
+
try {
|
|
2370
|
+
this._scrollBindSub.unsubscribe();
|
|
2371
|
+
}
|
|
2372
|
+
catch {
|
|
2373
|
+
}
|
|
2374
|
+
this._scrollBindSub = null;
|
|
2375
|
+
}
|
|
2376
|
+
if (this._scrollEffect) {
|
|
2377
|
+
try {
|
|
2378
|
+
this._scrollEffect.destroy();
|
|
2379
|
+
}
|
|
2380
|
+
catch {
|
|
2381
|
+
}
|
|
2382
|
+
this._scrollEffect = undefined;
|
|
2383
|
+
}
|
|
2384
|
+
try {
|
|
2385
|
+
this._scrollSubject.complete();
|
|
2386
|
+
}
|
|
2387
|
+
catch {
|
|
2388
|
+
}
|
|
2389
|
+
this._scroll$ = null;
|
|
2390
|
+
}
|
|
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
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
_canUseDraftStorage() {
|
|
2418
|
+
return !isPlatformServer(this._platformId) && this.persistDraft();
|
|
2419
|
+
}
|
|
2420
|
+
_getDraftStorageKey(prefix = ContentBuilderComponent.DRAFT_STORAGE_PREFIX) {
|
|
2421
|
+
const elementId = this.elRef.nativeElement.id;
|
|
2422
|
+
const locationKey = typeof window === 'undefined'
|
|
2423
|
+
? 'server'
|
|
2424
|
+
: `${window.location.pathname}${window.location.search}`;
|
|
2425
|
+
const instanceKey = elementId ? `:${elementId}` : '';
|
|
2426
|
+
return `${prefix}:${locationKey}${instanceKey}`;
|
|
2427
|
+
}
|
|
2428
|
+
onSettingsPopoverClose() {
|
|
2429
|
+
}
|
|
2430
|
+
_onPaste(event) {
|
|
2431
|
+
const target = event.target;
|
|
2432
|
+
const isInsideCodeBlock = target.closest('.ngs-code-block') ||
|
|
2433
|
+
target.closest('.cm-editor') ||
|
|
2434
|
+
target.closest('.cm-content') ||
|
|
2435
|
+
target.classList.contains('cm-content') ||
|
|
2436
|
+
target.classList.contains('cm-line');
|
|
2437
|
+
if (event.defaultPrevented || target.closest('input, textarea, ngs-content-editor-nested-blocks, .ngs-headless-editor-surface') || isInsideCodeBlock) {
|
|
2438
|
+
return;
|
|
2439
|
+
}
|
|
2440
|
+
const html = event.clipboardData?.getData('text/html');
|
|
2441
|
+
const text = event.clipboardData?.getData('text/plain');
|
|
2442
|
+
if (!html && !text) {
|
|
2443
|
+
return;
|
|
2444
|
+
}
|
|
2445
|
+
// Check if we are pasting into a block that should handle its own paste (like code block)
|
|
2446
|
+
// but might not have been caught by target.closest if it's currently empty or has different structure.
|
|
2447
|
+
const activeBlockId = this._store.activeBlockId() || this._store.focusedBlockId();
|
|
2448
|
+
if (activeBlockId) {
|
|
2449
|
+
const activeBlock = this._content().find(b => b.id === activeBlockId);
|
|
2450
|
+
if (activeBlock?.type === 'code') {
|
|
2451
|
+
return;
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
event.preventDefault();
|
|
2455
|
+
event.stopPropagation();
|
|
2456
|
+
let index = this._content().length;
|
|
2457
|
+
if (activeBlockId) {
|
|
2458
|
+
const activeIndex = this._content().findIndex(b => b.id === activeBlockId);
|
|
2459
|
+
if (activeIndex !== -1) {
|
|
2460
|
+
index = activeIndex + 1;
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
if (html) {
|
|
2464
|
+
this._handleHtmlPaste(html, index);
|
|
2465
|
+
}
|
|
2466
|
+
else if (text) {
|
|
2467
|
+
this._handleTextPaste(text, index);
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
_handleTextPaste(text, index) {
|
|
2471
|
+
const lines = text.split(/\r?\n/);
|
|
2472
|
+
if (lines.length === 1) {
|
|
2473
|
+
this.insertBlock('paragraph', index, {}, false, [createNgsHeadlessEditorText(text)]);
|
|
2474
|
+
}
|
|
2475
|
+
else {
|
|
2476
|
+
// If it looks like code (has indentation or common code characters), insert as a single code block
|
|
2477
|
+
const isCodeLike = text.includes('{') || text.includes('}') || text.includes(';') || text.includes(' ') || text.includes('\t');
|
|
2478
|
+
if (isCodeLike) {
|
|
2479
|
+
this.insertBlock('code', index, { language: 'none' }, false, [createNgsHeadlessEditorText(text)]);
|
|
2480
|
+
return;
|
|
2481
|
+
}
|
|
2482
|
+
lines.forEach((line, i) => {
|
|
2483
|
+
if (line.trim().length > 0) {
|
|
2484
|
+
this.insertBlock('paragraph', index + i, {}, false, [createNgsHeadlessEditorText(line)]);
|
|
2485
|
+
}
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
_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
|
+
});
|
|
2591
|
+
}
|
|
2592
|
+
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: [
|
|
2594
|
+
provideContentEditor(),
|
|
2595
|
+
ContentEditorHtmlSerializer,
|
|
2596
|
+
ContentBuilderStore,
|
|
2597
|
+
{
|
|
2598
|
+
provide: CONTENT_BUILDER,
|
|
2599
|
+
useExisting: forwardRef(() => ContentBuilderComponent)
|
|
2600
|
+
}
|
|
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 });
|
|
2602
|
+
}
|
|
2603
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentBuilderComponent, decorators: [{
|
|
2604
|
+
type: Component,
|
|
2605
|
+
args: [{ selector: 'ngs-content-editor-builder', exportAs: 'ngsContentEditorBuilder', imports: [
|
|
2606
|
+
Icon,
|
|
2607
|
+
NgComponentOutlet,
|
|
2608
|
+
AsyncPipe,
|
|
2609
|
+
CdkDrag,
|
|
2610
|
+
CdkDropList,
|
|
2611
|
+
CdkDragHandle,
|
|
2612
|
+
CdkDragPlaceholder,
|
|
2613
|
+
Menu,
|
|
2614
|
+
MenuItem,
|
|
2615
|
+
MenuTrigger,
|
|
2616
|
+
CdkMonitorFocus,
|
|
2617
|
+
TextSelectionPopupDirective,
|
|
2618
|
+
PopoverTriggerForDirective,
|
|
2619
|
+
Popover,
|
|
2620
|
+
ListItemTitle,
|
|
2621
|
+
ListItemIcon,
|
|
2622
|
+
ListItem,
|
|
2623
|
+
List,
|
|
2624
|
+
MenuHeading,
|
|
2625
|
+
MenuContent
|
|
2626
|
+
], hostDirectives: [
|
|
2627
|
+
{
|
|
2628
|
+
directive: BlockSelectionDirective,
|
|
2629
|
+
inputs: [
|
|
2630
|
+
'autoScrollContainerSelector',
|
|
2631
|
+
]
|
|
2632
|
+
}
|
|
2633
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
2634
|
+
provideContentEditor(),
|
|
2635
|
+
ContentEditorHtmlSerializer,
|
|
2636
|
+
ContentBuilderStore,
|
|
2637
|
+
{
|
|
2638
|
+
provide: CONTENT_BUILDER,
|
|
2639
|
+
useExisting: forwardRef(() => ContentBuilderComponent)
|
|
2640
|
+
}
|
|
2641
|
+
], host: {
|
|
2642
|
+
'class': 'ngs-content-editor-builder',
|
|
2643
|
+
'[class.is-block-dragging]': '_blockDragging()',
|
|
2644
|
+
'[class.is-selection-of-blocks-active]': 'isSelectionOfBlocksActive()',
|
|
2645
|
+
'[class.select-none]': 'isSelectionOfBlocksActive()',
|
|
2646
|
+
'[style.user-select]': 'isSelectionOfBlocksActive() ? "none" : null',
|
|
2647
|
+
'tabindex': '0',
|
|
2648
|
+
'(paste)': '_onPaste($event)',
|
|
2649
|
+
'(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"] }] } });
|
|
2652
|
+
|
|
2653
|
+
const CONTENT_EDITOR_BLOCK_RENDERERS = new InjectionToken('CONTENT_EDITOR_BLOCK_RENDERERS', {
|
|
2654
|
+
factory: () => [],
|
|
2655
|
+
});
|
|
2656
|
+
function provideContentEditorRenderers(renderers) {
|
|
2657
|
+
return makeEnvironmentProviders([
|
|
2658
|
+
{
|
|
2659
|
+
provide: CONTENT_EDITOR_BLOCK_RENDERERS,
|
|
2660
|
+
useValue: renderers,
|
|
2661
|
+
multi: true,
|
|
2662
|
+
},
|
|
2663
|
+
]);
|
|
2664
|
+
}
|
|
2665
|
+
function provideContentEditorRenderer(renderer) {
|
|
2666
|
+
return provideContentEditorRenderers([renderer]);
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
class ContentEditorRendererBase {
|
|
2670
|
+
block = input(null, /* @ts-ignore */
|
|
2671
|
+
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2672
|
+
id = input('', /* @ts-ignore */
|
|
2673
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2674
|
+
type = input('', /* @ts-ignore */
|
|
2675
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2676
|
+
content = input(null, /* @ts-ignore */
|
|
2677
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2678
|
+
settings = input({}, /* @ts-ignore */
|
|
2679
|
+
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2680
|
+
props = input([], /* @ts-ignore */
|
|
2681
|
+
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2682
|
+
index = input(0, /* @ts-ignore */
|
|
2683
|
+
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2684
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorRendererBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2685
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.7", type: ContentEditorRendererBase, isStandalone: true, inputs: { block: { classPropertyName: "block", publicName: "block", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", 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 }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
2686
|
+
}
|
|
2687
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorRendererBase, decorators: [{
|
|
2688
|
+
type: Directive
|
|
2689
|
+
}], propDecorators: { block: [{ type: i0.Input, args: [{ isSignal: true, alias: "block", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }] } });
|
|
2690
|
+
|
|
2691
|
+
class ContentEditorGridRenderer extends ContentEditorRendererBase {
|
|
2692
|
+
layout = computed(() => contentEditorGridSettings(this.settings()), /* @ts-ignore */
|
|
2693
|
+
...(ngDevMode ? [{ debugName: "layout" }] : /* istanbul ignore next */ []));
|
|
2694
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorGridRenderer, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2695
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorGridRenderer, isStandalone: true, selector: "ngs-content-editor-grid-renderer", usesInheritance: true, ngImport: i0, template: "@if (content(); as data) {\n <div class=\"grid-cells\" [class.columns-3]=\"layout().columns === 3\" [class.columns-4]=\"layout().columns === 4\"\n [class.gap-small]=\"layout().gap === 'small'\" [class.gap-large]=\"layout().gap === 'large'\" [class.stack-on-mobile]=\"layout().stackOnMobile\">\n @for (cell of data.cells; track cell.id) { <ngs-content-editor-renderer class=\"min-w-0\" [blocks]=\"cell.blocks\"/> }\n </div>\n}\n", styles: [":host{container-type:inline-size}:host .grid-cells{display:grid;min-width:0;grid-template-columns:repeat(2,minmax(0,1fr));gap:calc(var(--spacing, .25rem) * 6)}:host .grid-cells.columns-3{grid-template-columns:repeat(3,minmax(0,1fr))}:host .grid-cells.columns-4{grid-template-columns:repeat(4,minmax(0,1fr))}:host .grid-cells.gap-small{gap:calc(var(--spacing, .25rem) * 3)}:host .grid-cells.gap-large{gap:calc(var(--spacing, .25rem) * 9)}@container (max-width: 480px){:host .grid-cells.stack-on-mobile{grid-template-columns:minmax(0,1fr)}}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n", ":host{display:block;min-width:0}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "component", type: i0.forwardRef(() => ContentEditorRenderer), selector: "ngs-content-editor-renderer", inputs: ["config", "content", "blocks"], exportAs: ["ngsContentEditorRenderer"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2696
|
+
}
|
|
2697
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorGridRenderer, decorators: [{
|
|
2698
|
+
type: Component,
|
|
2699
|
+
args: [{ selector: 'ngs-content-editor-grid-renderer', imports: [forwardRef(() => ContentEditorRenderer)], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (content(); as data) {\n <div class=\"grid-cells\" [class.columns-3]=\"layout().columns === 3\" [class.columns-4]=\"layout().columns === 4\"\n [class.gap-small]=\"layout().gap === 'small'\" [class.gap-large]=\"layout().gap === 'large'\" [class.stack-on-mobile]=\"layout().stackOnMobile\">\n @for (cell of data.cells; track cell.id) { <ngs-content-editor-renderer class=\"min-w-0\" [blocks]=\"cell.blocks\"/> }\n </div>\n}\n", styles: [":host{container-type:inline-size}:host .grid-cells{display:grid;min-width:0;grid-template-columns:repeat(2,minmax(0,1fr));gap:calc(var(--spacing, .25rem) * 6)}:host .grid-cells.columns-3{grid-template-columns:repeat(3,minmax(0,1fr))}:host .grid-cells.columns-4{grid-template-columns:repeat(4,minmax(0,1fr))}:host .grid-cells.gap-small{gap:calc(var(--spacing, .25rem) * 3)}:host .grid-cells.gap-large{gap:calc(var(--spacing, .25rem) * 9)}@container (max-width: 480px){:host .grid-cells.stack-on-mobile{grid-template-columns:minmax(0,1fr)}}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n", ":host{display:block;min-width:0}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
|
|
2700
|
+
}] });
|
|
2701
|
+
|
|
2702
|
+
class ContentEditorGalleryRenderer extends ContentEditorRendererBase {
|
|
2703
|
+
images = computed(() => this.content()?.images ?? [], /* @ts-ignore */
|
|
2704
|
+
...(ngDevMode ? [{ debugName: "images" }] : /* istanbul ignore next */ []));
|
|
2705
|
+
selectedId = linkedSignal({ ...(ngDevMode ? { debugName: "selectedId" } : /* istanbul ignore next */ {}), source: this.images,
|
|
2706
|
+
computation: (images, previous) => {
|
|
2707
|
+
if (images.some(image => image.id === previous?.value))
|
|
2708
|
+
return previous.value;
|
|
2709
|
+
const previousIndex = previous?.source.findIndex(image => image.id === previous.value) ?? 0;
|
|
2710
|
+
return images[Math.min(Math.max(previousIndex, 0), images.length - 1)]?.id ?? null;
|
|
2711
|
+
} });
|
|
2712
|
+
selectedIndex = computed(() => this.images().findIndex(image => image.id === this.selectedId()), /* @ts-ignore */
|
|
2713
|
+
...(ngDevMode ? [{ debugName: "selectedIndex" }] : /* istanbul ignore next */ []));
|
|
2714
|
+
selectedImage = computed(() => this.images()[this.selectedIndex()] ?? null, /* @ts-ignore */
|
|
2715
|
+
...(ngDevMode ? [{ debugName: "selectedImage" }] : /* istanbul ignore next */ []));
|
|
2716
|
+
captionText = contentEditorText;
|
|
2717
|
+
cards = viewChildren(CarouselCard, /* @ts-ignore */
|
|
2718
|
+
...(ngDevMode ? [{ debugName: "cards" }] : /* istanbul ignore next */ []));
|
|
2719
|
+
thumbnails = viewChildren('thumbnailButton', { ...(ngDevMode ? { debugName: "thumbnails" } : /* istanbul ignore next */ {}), read: (ElementRef) });
|
|
2720
|
+
constructor() {
|
|
2721
|
+
super();
|
|
2722
|
+
afterRenderEffect(() => {
|
|
2723
|
+
this.images();
|
|
2724
|
+
untracked(() => this.scrollToImage(this.selectedIndex(), 'instant'));
|
|
2725
|
+
});
|
|
2726
|
+
}
|
|
2727
|
+
selectImage(index) {
|
|
2728
|
+
const image = this.images()[index];
|
|
2729
|
+
if (!image)
|
|
2730
|
+
return;
|
|
2731
|
+
this.selectedId.set(image.id);
|
|
2732
|
+
this.scrollToImage(index, 'smooth');
|
|
2733
|
+
this.revealThumbnail(index);
|
|
2734
|
+
}
|
|
2735
|
+
onIndexChange(index) {
|
|
2736
|
+
const image = this.images()[index];
|
|
2737
|
+
if (!image)
|
|
2738
|
+
return;
|
|
2739
|
+
this.selectedId.set(image.id);
|
|
2740
|
+
this.revealThumbnail(index);
|
|
2741
|
+
}
|
|
2742
|
+
onKeydown(event) {
|
|
2743
|
+
let index;
|
|
2744
|
+
switch (event.key) {
|
|
2745
|
+
case 'ArrowLeft':
|
|
2746
|
+
index = this.selectedIndex() - 1;
|
|
2747
|
+
break;
|
|
2748
|
+
case 'ArrowRight':
|
|
2749
|
+
index = this.selectedIndex() + 1;
|
|
2750
|
+
break;
|
|
2751
|
+
case 'Home':
|
|
2752
|
+
index = 0;
|
|
2753
|
+
break;
|
|
2754
|
+
case 'End':
|
|
2755
|
+
index = this.images().length - 1;
|
|
2756
|
+
break;
|
|
2757
|
+
default: return;
|
|
2758
|
+
}
|
|
2759
|
+
event.preventDefault();
|
|
2760
|
+
event.stopPropagation();
|
|
2761
|
+
this.selectImage(index);
|
|
2762
|
+
}
|
|
2763
|
+
scrollToImage(index, behavior) {
|
|
2764
|
+
const card = this.cards()[index]?.element;
|
|
2765
|
+
const track = card?.parentElement;
|
|
2766
|
+
if (card && track)
|
|
2767
|
+
track.scrollTo({ left: card.offsetLeft - track.offsetLeft, behavior });
|
|
2768
|
+
}
|
|
2769
|
+
revealThumbnail(index) {
|
|
2770
|
+
const thumbnail = this.thumbnails()[index]?.nativeElement;
|
|
2771
|
+
const strip = thumbnail?.parentElement;
|
|
2772
|
+
if (!thumbnail || !strip)
|
|
2773
|
+
return;
|
|
2774
|
+
const left = thumbnail.offsetLeft - strip.offsetLeft;
|
|
2775
|
+
const right = left + thumbnail.offsetWidth;
|
|
2776
|
+
if (left < strip.scrollLeft)
|
|
2777
|
+
strip.scrollTo({ left, behavior: 'smooth' });
|
|
2778
|
+
else if (right > strip.scrollLeft + strip.clientWidth) {
|
|
2779
|
+
strip.scrollTo({ left: right - strip.clientWidth, behavior: 'smooth' });
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorGalleryRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2783
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorGalleryRenderer, isStandalone: true, selector: "ngs-content-editor-gallery-renderer", viewQueries: [{ propertyName: "cards", predicate: CarouselCard, descendants: true, isSignal: true }, { propertyName: "thumbnails", predicate: ["thumbnailButton"], descendants: true, read: ElementRef, isSignal: true }], usesInheritance: true, ngImport: i0, 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"], dependencies: [{ kind: "directive", type: NgsHeadlessEditorRuns, selector: "[ngsHeadlessEditorRuns]", inputs: ["ngsHeadlessEditorRuns"] }, { kind: "directive", type: ImageViewerDirective, selector: "[ngsImageViewer]", exportAs: ["ngsImageViewer"] }, { kind: "directive", type: ImageViewerPictureDirective, selector: "[ngsImageViewerPicture]", inputs: ["sourceUrl", "caption", "title", "description"], exportAs: ["ngsImageViewerPicture"] }, { kind: "component", type: Carousel, selector: "ngs-carousel", inputs: ["fade", "snapToCenter", "snapDebounceTime", "snapDuration", "resistanceFactor", "velocityThreshold", "visibilityDebounceTime", "stopPropagation"], outputs: ["indexChange"], exportAs: ["ngsCarousel"] }, { kind: "component", type: CarouselCard, selector: "ngs-carousel-card,[ngs-carousel-card]", exportAs: ["ngsCarouselCard"] }, { 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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2784
|
+
}
|
|
2785
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorGalleryRenderer, decorators: [{
|
|
2786
|
+
type: Component,
|
|
2787
|
+
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
|
+
}], ctorParameters: () => [], propDecorators: { cards: [{ type: i0.ViewChildren, args: [i0.forwardRef(() => CarouselCard), { isSignal: true }] }], thumbnails: [{ type: i0.ViewChildren, args: ['thumbnailButton', { ...{ read: (ElementRef) }, isSignal: true }] }] } });
|
|
2789
|
+
|
|
2790
|
+
/** Read files for the default data URL upload or a consumer's uploadFn. */
|
|
2791
|
+
function readContentEditorFile(file) {
|
|
2792
|
+
return new Promise((resolve, reject) => {
|
|
2793
|
+
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'));
|
|
2797
|
+
reader.readAsDataURL(file);
|
|
2798
|
+
});
|
|
2799
|
+
}
|
|
2800
|
+
function contentEditorFileSize(size) {
|
|
2801
|
+
if (!Number.isFinite(size) || size < 0)
|
|
2802
|
+
return '';
|
|
2803
|
+
if (size < 1024)
|
|
2804
|
+
return `${size} B`;
|
|
2805
|
+
if (size < 1024 * 1024)
|
|
2806
|
+
return `${(size / 1024).toFixed(1)} KB`;
|
|
2807
|
+
return `${(size / (1024 * 1024)).toFixed(1)} MB`;
|
|
2808
|
+
}
|
|
2809
|
+
function contentEditorResourceUrl(url) {
|
|
2810
|
+
const value = url.trim();
|
|
2811
|
+
if (!value || /[\u0000-\u0020]/.test(value))
|
|
2812
|
+
return '';
|
|
2813
|
+
const relative = !/^[a-z][a-z\d+.-]*:/i.test(value);
|
|
2814
|
+
return relative || /^(https?:|blob:|data:[^;,]+;base64,)/i.test(value) ? value : '';
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2817
|
+
class ContentEditorAttachmentRenderer extends ContentEditorRendererBase {
|
|
2818
|
+
sizeLabel = computed(() => contentEditorFileSize(this.content()?.size ?? 0), /* @ts-ignore */
|
|
2819
|
+
...(ngDevMode ? [{ debugName: "sizeLabel" }] : /* istanbul ignore next */ []));
|
|
2820
|
+
href = computed(() => contentEditorResourceUrl(this.content()?.url ?? ''), /* @ts-ignore */
|
|
2821
|
+
...(ngDevMode ? [{ debugName: "href" }] : /* istanbul ignore next */ []));
|
|
2822
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorAttachmentRenderer, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2823
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorAttachmentRenderer, isStandalone: true, selector: "ngs-content-editor-attachment-renderer", usesInheritance: true, ngImport: i0, template: "@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}\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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2824
|
+
}
|
|
2825
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorAttachmentRenderer, decorators: [{
|
|
2826
|
+
type: Component,
|
|
2827
|
+
args: [{ selector: 'ngs-content-editor-attachment-renderer', imports: [Button, Icon], changeDetection: ChangeDetectionStrategy.OnPush, template: "@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}\n" }]
|
|
2828
|
+
}] });
|
|
2829
|
+
|
|
2830
|
+
class ContentEditorToggleRenderer extends ContentEditorRendererBase {
|
|
2831
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorToggleRenderer, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2832
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorToggleRenderer, isStandalone: true, selector: "ngs-content-editor-toggle-renderer", usesInheritance: true, ngImport: i0, template: "@if (content(); as data) {\n <ngs-expansion-panel [expanded]=\"settings().expanded ?? false\">\n <ngs-expansion-panel-header><ngs-expansion-panel-title><span [ngsHeadlessEditorRuns]=\"data.title\"></span></ngs-expansion-panel-title></ngs-expansion-panel-header>\n <ngs-content-editor-renderer [blocks]=\"data.blocks\"/>\n </ngs-expansion-panel>\n}\n", dependencies: [{ kind: "component", type: i0.forwardRef(() => ExpansionPanel), selector: "ngs-expansion-panel", inputs: ["disabled", "expanded", "hideToggle"], outputs: ["opened", "closed", "expandedChange"], exportAs: ["ngsExpansionPanel"] }, { kind: "component", type: i0.forwardRef(() => ExpansionPanelHeader), selector: "ngs-expansion-panel-header", inputs: ["hideToggle"], exportAs: ["ngsExpansionPanelHeader"] }, { kind: "component", type: i0.forwardRef(() => ExpansionPanelTitle), selector: "ngs-expansion-panel-title", exportAs: ["ngsExpansionPanelTitle"] }, { kind: "directive", type: i0.forwardRef(() => NgsHeadlessEditorRuns), selector: "[ngsHeadlessEditorRuns]", inputs: ["ngsHeadlessEditorRuns"] }, { kind: "component", type: i0.forwardRef(() => ContentEditorRenderer), selector: "ngs-content-editor-renderer", inputs: ["config", "content", "blocks"], exportAs: ["ngsContentEditorRenderer"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2833
|
+
}
|
|
2834
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorToggleRenderer, decorators: [{
|
|
2835
|
+
type: Component,
|
|
2836
|
+
args: [{ selector: 'ngs-content-editor-toggle-renderer', imports: [ExpansionPanel, ExpansionPanelHeader, ExpansionPanelTitle, NgsHeadlessEditorRuns, forwardRef(() => ContentEditorRenderer)], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (content(); as data) {\n <ngs-expansion-panel [expanded]=\"settings().expanded ?? false\">\n <ngs-expansion-panel-header><ngs-expansion-panel-title><span [ngsHeadlessEditorRuns]=\"data.title\"></span></ngs-expansion-panel-title></ngs-expansion-panel-header>\n <ngs-content-editor-renderer [blocks]=\"data.blocks\"/>\n </ngs-expansion-panel>\n}\n" }]
|
|
2837
|
+
}] });
|
|
2838
|
+
|
|
2839
|
+
class ContentEditorCalloutRenderer extends ContentEditorRendererBase {
|
|
2840
|
+
appearance = computed(() => ({ note: 'informative', tip: 'positive', warning: 'notice', danger: 'negative' })[this.settings().variant ?? 'note'] ?? 'informative', /* @ts-ignore */
|
|
2841
|
+
...(ngDevMode ? [{ debugName: "appearance" }] : /* istanbul ignore next */ []));
|
|
2842
|
+
icon = computed(() => ({ note: 'fluent:info-24-regular', tip: 'fluent:lightbulb-24-regular', warning: 'fluent:warning-24-regular', danger: 'fluent:error-circle-24-regular' })[this.settings().variant ?? 'note'] ?? 'fluent:info-24-regular', /* @ts-ignore */
|
|
2843
|
+
...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
2844
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorCalloutRenderer, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2845
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.1.7", type: ContentEditorCalloutRenderer, isStandalone: true, selector: "ngs-content-editor-callout-renderer", usesInheritance: true, ngImport: i0, template: "<ngs-alert [variant]=\"appearance()\">\n <ng-template ngsAlertIcon><ngs-icon [name]=\"icon()\"/></ng-template>\n <div [ngsHeadlessEditorRuns]=\"content() ?? []\"></div>\n</ngs-alert>\n", dependencies: [{ kind: "component", type: Alert, selector: "ngs-alert", inputs: ["autoClose", "bordered", "variant"], outputs: ["closed"], exportAs: ["ngsAlert"] }, { kind: "directive", type: AlertIconDirective, selector: "[ngsAlertIcon]", exportAs: ["ngsAlertIcon"] }, { kind: "component", type: Icon, selector: "ngs-icon", inputs: ["name"], exportAs: ["ngsIcon"] }, { kind: "directive", type: NgsHeadlessEditorRuns, selector: "[ngsHeadlessEditorRuns]", inputs: ["ngsHeadlessEditorRuns"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2846
|
+
}
|
|
2847
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorCalloutRenderer, decorators: [{
|
|
2848
|
+
type: Component,
|
|
2849
|
+
args: [{ selector: 'ngs-content-editor-callout-renderer', imports: [Alert, AlertIconDirective, Icon, NgsHeadlessEditorRuns], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ngs-alert [variant]=\"appearance()\">\n <ng-template ngsAlertIcon><ngs-icon [name]=\"icon()\"/></ng-template>\n <div [ngsHeadlessEditorRuns]=\"content() ?? []\"></div>\n</ngs-alert>\n" }]
|
|
2850
|
+
}] });
|
|
2851
|
+
|
|
2852
|
+
class ContentEditorCodeRenderer {
|
|
2853
|
+
block = input(null, /* @ts-ignore */
|
|
2854
|
+
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2855
|
+
id = input('', /* @ts-ignore */
|
|
2856
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2857
|
+
type = input('', /* @ts-ignore */
|
|
2858
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2859
|
+
content = input('', /* @ts-ignore */
|
|
2860
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2861
|
+
props = input([], /* @ts-ignore */
|
|
2862
|
+
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2863
|
+
settings = input({}, /* @ts-ignore */
|
|
2864
|
+
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2865
|
+
index = input(0, /* @ts-ignore */
|
|
2866
|
+
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2867
|
+
code = computed(() => contentEditorText(this.content()), /* @ts-ignore */
|
|
2868
|
+
...(ngDevMode ? [{ debugName: "code" }] : /* istanbul ignore next */ []));
|
|
2869
|
+
language = computed(() => this.settings()?.language && this.settings().language !== 'none' ? this.settings().language : 'text', /* @ts-ignore */
|
|
2870
|
+
...(ngDevMode ? [{ debugName: "language" }] : /* istanbul ignore next */ []));
|
|
2871
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorCodeRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2872
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.7", type: ContentEditorCodeRenderer, isStandalone: true, selector: "ngs-content-editor-code-renderer", inputs: { block: { classPropertyName: "block", publicName: "block", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ngs-content-editor-code-renderer" }, ngImport: i0, template: "<ngs-code-highlighter class=\"border border-border rounded-lg overflow-hidden\"\n [code]=\"code()\"\n [language]=\"language()\"\n showLanguage\n/>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "component", type: CodeHighlighter, selector: "ngs-code-highlighter", inputs: ["code", "language", "theme", "title", "diff", "highlightLines", "showLanguage", "showCopyButton", "disableOverflow"], exportAs: ["ngsCodeHighlighter"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2873
|
+
}
|
|
2874
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorCodeRenderer, decorators: [{
|
|
2875
|
+
type: Component,
|
|
2876
|
+
args: [{ selector: 'ngs-content-editor-code-renderer', imports: [
|
|
2877
|
+
CodeHighlighter,
|
|
2878
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2879
|
+
'class': 'ngs-content-editor-code-renderer',
|
|
2880
|
+
}, template: "<ngs-code-highlighter class=\"border border-border rounded-lg overflow-hidden\"\n [code]=\"code()\"\n [language]=\"language()\"\n showLanguage\n/>\n", styles: [":host{display:block}\n"] }]
|
|
2881
|
+
}], propDecorators: { block: [{ type: i0.Input, args: [{ isSignal: true, alias: "block", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }] } });
|
|
2882
|
+
|
|
2883
|
+
class ContentEditorDividerRenderer {
|
|
2884
|
+
block = input(null, /* @ts-ignore */
|
|
2885
|
+
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2886
|
+
id = input('', /* @ts-ignore */
|
|
2887
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2888
|
+
type = input('', /* @ts-ignore */
|
|
2889
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2890
|
+
content = input(null, /* @ts-ignore */
|
|
2891
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2892
|
+
props = input([], /* @ts-ignore */
|
|
2893
|
+
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2894
|
+
settings = input({}, /* @ts-ignore */
|
|
2895
|
+
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2896
|
+
index = input(0, /* @ts-ignore */
|
|
2897
|
+
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2898
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorDividerRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2899
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.7", type: ContentEditorDividerRenderer, isStandalone: true, selector: "ngs-content-editor-divider-renderer", inputs: { block: { classPropertyName: "block", publicName: "block", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ngs-content-editor-divider-renderer" }, ngImport: i0, template: "<ngs-divider/>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "component", type: Divider, selector: "ngs-divider", inputs: ["vertical", "inset", "fixedHeight"], exportAs: ["ngsDivider"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2900
|
+
}
|
|
2901
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorDividerRenderer, decorators: [{
|
|
2902
|
+
type: Component,
|
|
2903
|
+
args: [{ selector: 'ngs-content-editor-divider-renderer', imports: [
|
|
2904
|
+
Divider,
|
|
2905
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2906
|
+
'class': 'ngs-content-editor-divider-renderer',
|
|
2907
|
+
}, template: "<ngs-divider/>\n", styles: [":host{display:block}\n"] }]
|
|
2908
|
+
}], propDecorators: { block: [{ type: i0.Input, args: [{ isSignal: true, alias: "block", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }] } });
|
|
2909
|
+
|
|
2910
|
+
class ContentEditorEmbedRenderer {
|
|
2911
|
+
block = input(null, /* @ts-ignore */
|
|
2912
|
+
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2913
|
+
id = input('', /* @ts-ignore */
|
|
2914
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2915
|
+
type = input('', /* @ts-ignore */
|
|
2916
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2917
|
+
content = input(null, /* @ts-ignore */
|
|
2918
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2919
|
+
props = input([], /* @ts-ignore */
|
|
2920
|
+
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2921
|
+
settings = input({}, /* @ts-ignore */
|
|
2922
|
+
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2923
|
+
index = input(0, /* @ts-ignore */
|
|
2924
|
+
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2925
|
+
url = computed(() => this.content()?.url || '', /* @ts-ignore */
|
|
2926
|
+
...(ngDevMode ? [{ debugName: "url" }] : /* istanbul ignore next */ []));
|
|
2927
|
+
embedType = computed(() => this.content()?.type || '', /* @ts-ignore */
|
|
2928
|
+
...(ngDevMode ? [{ debugName: "embedType" }] : /* istanbul ignore next */ []));
|
|
2929
|
+
width = computed(() => getDimensionAttribute(this.settings()?.width) || 700, /* @ts-ignore */
|
|
2930
|
+
...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
2931
|
+
height = computed(() => getDimensionAttribute(this.settings()?.height) || 400, /* @ts-ignore */
|
|
2932
|
+
...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
2933
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorEmbedRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2934
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorEmbedRenderer, isStandalone: true, selector: "ngs-content-editor-embed-renderer", inputs: { block: { classPropertyName: "block", publicName: "block", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ngs-content-editor-embed-renderer" }, ngImport: i0, template: "@if (url()) {\n <figure>\n <iframe\n [attr.title]=\"embedType() || 'Embedded content'\"\n [src]=\"url() | safeResourceUrl\"\n [attr.width]=\"width()\"\n [attr.height]=\"height()\"\n frameborder=\"0\"\n allowfullscreen\n ></iframe>\n </figure>\n}\n", styles: [":host{display:block}:host figure{margin:0}:host iframe{background:var(--ngs-color-surface-container-low);display:block;max-width:100%}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "pipe", type: SafeResourceUrlPipe, name: "safeResourceUrl" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2935
|
+
}
|
|
2936
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorEmbedRenderer, decorators: [{
|
|
2937
|
+
type: Component,
|
|
2938
|
+
args: [{ selector: 'ngs-content-editor-embed-renderer', imports: [
|
|
2939
|
+
SafeResourceUrlPipe,
|
|
2940
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2941
|
+
'class': 'ngs-content-editor-embed-renderer',
|
|
2942
|
+
}, template: "@if (url()) {\n <figure>\n <iframe\n [attr.title]=\"embedType() || 'Embedded content'\"\n [src]=\"url() | safeResourceUrl\"\n [attr.width]=\"width()\"\n [attr.height]=\"height()\"\n frameborder=\"0\"\n allowfullscreen\n ></iframe>\n </figure>\n}\n", styles: [":host{display:block}:host figure{margin:0}:host iframe{background:var(--ngs-color-surface-container-low);display:block;max-width:100%}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
|
|
2943
|
+
}], propDecorators: { block: [{ type: i0.Input, args: [{ isSignal: true, alias: "block", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }] } });
|
|
2944
|
+
|
|
2945
|
+
class ContentEditorHeadingRenderer {
|
|
2946
|
+
block = input(null, /* @ts-ignore */
|
|
2947
|
+
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2948
|
+
id = input('', /* @ts-ignore */
|
|
2949
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2950
|
+
type = input('', /* @ts-ignore */
|
|
2951
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2952
|
+
content = input([], /* @ts-ignore */
|
|
2953
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2954
|
+
settings = input({}, /* @ts-ignore */
|
|
2955
|
+
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2956
|
+
props = input([], /* @ts-ignore */
|
|
2957
|
+
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2958
|
+
index = input(0, /* @ts-ignore */
|
|
2959
|
+
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2960
|
+
runs = computed(() => this.content(), /* @ts-ignore */
|
|
2961
|
+
...(ngDevMode ? [{ debugName: "runs" }] : /* istanbul ignore next */ []));
|
|
2962
|
+
level = computed(() => {
|
|
2963
|
+
const level = this.settings()?.level;
|
|
2964
|
+
return level === 1 || level === 2 || level === 3 ? level : 2;
|
|
2965
|
+
}, /* @ts-ignore */
|
|
2966
|
+
...(ngDevMode ? [{ debugName: "level" }] : /* istanbul ignore next */ []));
|
|
2967
|
+
alignment = computed(() => getTextAlignment(this.props()), /* @ts-ignore */
|
|
2968
|
+
...(ngDevMode ? [{ debugName: "alignment" }] : /* istanbul ignore next */ []));
|
|
2969
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorHeadingRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2970
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorHeadingRenderer, isStandalone: true, selector: "ngs-content-editor-heading-renderer", inputs: { block: { classPropertyName: "block", publicName: "block", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", 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 }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.level-1": "level() === 1", "class.level-2": "level() === 2", "class.level-3": "level() === 3" }, classAttribute: "ngs-content-editor-heading-renderer" }, ngImport: i0, template: "@switch (level()) {\n @case (1) {\n <h1\n class=\"content-html\"\n [class.align-left]=\"alignment() === 'left'\"\n [class.align-center]=\"alignment() === 'center'\"\n [class.align-right]=\"alignment() === 'right'\"\n [class.align-justify]=\"alignment() === 'justify'\"\n [ngsHeadlessEditorRuns]=\"runs()\"\n ></h1>\n }\n @case (3) {\n <h3\n class=\"content-html\"\n [class.align-left]=\"alignment() === 'left'\"\n [class.align-center]=\"alignment() === 'center'\"\n [class.align-right]=\"alignment() === 'right'\"\n [class.align-justify]=\"alignment() === 'justify'\"\n [ngsHeadlessEditorRuns]=\"runs()\"\n ></h3>\n }\n @default {\n <h2\n class=\"content-html\"\n [class.align-left]=\"alignment() === 'left'\"\n [class.align-center]=\"alignment() === 'center'\"\n [class.align-right]=\"alignment() === 'right'\"\n [class.align-justify]=\"alignment() === 'justify'\"\n [ngsHeadlessEditorRuns]=\"runs()\"\n ></h2>\n }\n}\n", styles: [":host{display:block}:host .content-html{margin:0;font-weight:700;line-height:1.12}:host.level-1 .content-html{font-size:3rem}:host.level-2 .content-html{font-size:2.25rem}:host.level-3 .content-html{font-size:1.875rem}:host .align-left{text-align:left}:host .align-center{text-align:center}:host .align-right{text-align:right}:host .align-justify{text-align:justify}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "directive", type: NgsHeadlessEditorRuns, selector: "[ngsHeadlessEditorRuns]", inputs: ["ngsHeadlessEditorRuns"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2971
|
+
}
|
|
2972
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorHeadingRenderer, decorators: [{
|
|
2973
|
+
type: Component,
|
|
2974
|
+
args: [{ selector: 'ngs-content-editor-heading-renderer', imports: [
|
|
2975
|
+
NgsHeadlessEditorRuns,
|
|
2976
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2977
|
+
'class': 'ngs-content-editor-heading-renderer',
|
|
2978
|
+
'[class.level-1]': 'level() === 1',
|
|
2979
|
+
'[class.level-2]': 'level() === 2',
|
|
2980
|
+
'[class.level-3]': 'level() === 3',
|
|
2981
|
+
}, template: "@switch (level()) {\n @case (1) {\n <h1\n class=\"content-html\"\n [class.align-left]=\"alignment() === 'left'\"\n [class.align-center]=\"alignment() === 'center'\"\n [class.align-right]=\"alignment() === 'right'\"\n [class.align-justify]=\"alignment() === 'justify'\"\n [ngsHeadlessEditorRuns]=\"runs()\"\n ></h1>\n }\n @case (3) {\n <h3\n class=\"content-html\"\n [class.align-left]=\"alignment() === 'left'\"\n [class.align-center]=\"alignment() === 'center'\"\n [class.align-right]=\"alignment() === 'right'\"\n [class.align-justify]=\"alignment() === 'justify'\"\n [ngsHeadlessEditorRuns]=\"runs()\"\n ></h3>\n }\n @default {\n <h2\n class=\"content-html\"\n [class.align-left]=\"alignment() === 'left'\"\n [class.align-center]=\"alignment() === 'center'\"\n [class.align-right]=\"alignment() === 'right'\"\n [class.align-justify]=\"alignment() === 'justify'\"\n [ngsHeadlessEditorRuns]=\"runs()\"\n ></h2>\n }\n}\n", styles: [":host{display:block}:host .content-html{margin:0;font-weight:700;line-height:1.12}:host.level-1 .content-html{font-size:3rem}:host.level-2 .content-html{font-size:2.25rem}:host.level-3 .content-html{font-size:1.875rem}:host .align-left{text-align:left}:host .align-center{text-align:center}:host .align-right{text-align:right}:host .align-justify{text-align:justify}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
|
|
2982
|
+
}], propDecorators: { block: [{ type: i0.Input, args: [{ isSignal: true, alias: "block", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }] } });
|
|
2983
|
+
|
|
2984
|
+
class ContentEditorImageRenderer {
|
|
2985
|
+
block = input(null, /* @ts-ignore */
|
|
2986
|
+
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2987
|
+
id = input('', /* @ts-ignore */
|
|
2988
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2989
|
+
type = input('', /* @ts-ignore */
|
|
2990
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2991
|
+
content = input(null, /* @ts-ignore */
|
|
2992
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2993
|
+
props = input([], /* @ts-ignore */
|
|
2994
|
+
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2995
|
+
settings = input({}, /* @ts-ignore */
|
|
2996
|
+
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2997
|
+
index = input(0, /* @ts-ignore */
|
|
2998
|
+
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2999
|
+
src = computed(() => this.content()?.src || '', /* @ts-ignore */
|
|
3000
|
+
...(ngDevMode ? [{ debugName: "src" }] : /* istanbul ignore next */ []));
|
|
3001
|
+
alt = computed(() => this.content()?.alt || '', /* @ts-ignore */
|
|
3002
|
+
...(ngDevMode ? [{ debugName: "alt" }] : /* istanbul ignore next */ []));
|
|
3003
|
+
width = computed(() => getDimensionAttribute(this.settings()?.width), /* @ts-ignore */
|
|
3004
|
+
...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
3005
|
+
height = computed(() => getDimensionAttribute(this.settings()?.height), /* @ts-ignore */
|
|
3006
|
+
...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
3007
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorImageRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3008
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorImageRenderer, isStandalone: true, selector: "ngs-content-editor-image-renderer", inputs: { block: { classPropertyName: "block", publicName: "block", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ngs-content-editor-image-renderer" }, ngImport: i0, template: "@if (src()) {\n <figure>\n <img [src]=\"src()\" [alt]=\"alt()\" [attr.width]=\"width()\" [attr.height]=\"height()\">\n @if (alt()) {\n <figcaption>{{ alt() }}</figcaption>\n }\n </figure>\n}\n", styles: [":host{display:block}:host figure{margin:0}:host img{display:block;max-width:100%;height:auto}:host figcaption{margin-top:calc(var(--spacing, .25rem) * 2);color:var(--ngs-color-neutral-600);font-size:var(--ngs-font-size-sm);text-align:center}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3009
|
+
}
|
|
3010
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorImageRenderer, decorators: [{
|
|
3011
|
+
type: Component,
|
|
3012
|
+
args: [{ selector: 'ngs-content-editor-image-renderer', imports: [], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
3013
|
+
'class': 'ngs-content-editor-image-renderer',
|
|
3014
|
+
}, template: "@if (src()) {\n <figure>\n <img [src]=\"src()\" [alt]=\"alt()\" [attr.width]=\"width()\" [attr.height]=\"height()\">\n @if (alt()) {\n <figcaption>{{ alt() }}</figcaption>\n }\n </figure>\n}\n", styles: [":host{display:block}:host figure{margin:0}:host img{display:block;max-width:100%;height:auto}:host figcaption{margin-top:calc(var(--spacing, .25rem) * 2);color:var(--ngs-color-neutral-600);font-size:var(--ngs-font-size-sm);text-align:center}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
|
|
3015
|
+
}], propDecorators: { block: [{ type: i0.Input, args: [{ isSignal: true, alias: "block", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }] } });
|
|
3016
|
+
|
|
3017
|
+
class ContentEditorListRenderer {
|
|
3018
|
+
block = input(null, /* @ts-ignore */
|
|
3019
|
+
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
3020
|
+
id = input('', /* @ts-ignore */
|
|
3021
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
3022
|
+
type = input('', /* @ts-ignore */
|
|
3023
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
3024
|
+
content = input([], /* @ts-ignore */
|
|
3025
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
3026
|
+
props = input([], /* @ts-ignore */
|
|
3027
|
+
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
3028
|
+
settings = input({}, /* @ts-ignore */
|
|
3029
|
+
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
3030
|
+
index = input(0, /* @ts-ignore */
|
|
3031
|
+
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
3032
|
+
items = computed(() => this.content() || [], /* @ts-ignore */
|
|
3033
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
3034
|
+
listStyle = computed(() => this.settings()?.listStyle || 'bullet', /* @ts-ignore */
|
|
3035
|
+
...(ngDevMode ? [{ debugName: "listStyle" }] : /* istanbul ignore next */ []));
|
|
3036
|
+
childItems(item) {
|
|
3037
|
+
return item.children || [];
|
|
3038
|
+
}
|
|
3039
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorListRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3040
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorListRenderer, isStandalone: true, selector: "ngs-content-editor-list-renderer", inputs: { block: { classPropertyName: "block", publicName: "block", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.list-bullet": "listStyle() === 'bullet'", "class.list-ordered": "listStyle() === 'ordered'" }, classAttribute: "ngs-content-editor-list-renderer" }, ngImport: i0, template: "@if (listStyle() === 'ordered') {\n <ol class=\"list\">\n <ng-container\n [ngTemplateOutlet]=\"listTpl\"\n [ngTemplateOutletContext]=\"{ $implicit: items(), ordered: true }\"\n />\n </ol>\n} @else {\n <ul class=\"list\">\n <ng-container\n [ngTemplateOutlet]=\"listTpl\"\n [ngTemplateOutletContext]=\"{ $implicit: items(), ordered: false }\"\n />\n </ul>\n}\n\n<ng-template #listTpl let-list let-ordered=\"ordered\">\n @for (item of list; track $index) {\n <li>\n <span class=\"content-html\" [ngsHeadlessEditorRuns]=\"item.content\"></span>\n @if (childItems(item).length > 0) {\n @if (ordered) {\n <ol class=\"list\">\n <ng-container\n [ngTemplateOutlet]=\"listTpl\"\n [ngTemplateOutletContext]=\"{ $implicit: childItems(item), ordered: ordered }\"\n />\n </ol>\n } @else {\n <ul class=\"list\">\n <ng-container\n [ngTemplateOutlet]=\"listTpl\"\n [ngTemplateOutletContext]=\"{ $implicit: childItems(item), ordered: ordered }\"\n />\n </ul>\n }\n }\n </li>\n }\n</ng-template>\n", styles: [":host{display:block}:host .list{margin:0;padding-inline-start:calc(var(--spacing, .25rem) * 4)}:host .list .list{margin-top:calc(var(--spacing, .25rem) * 2)}:host li{margin:var(--spacing, .25rem) 0}:host.list-bullet .list{list-style-type:disc}:host.list-ordered .list{list-style-type:decimal}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: NgsHeadlessEditorRuns, selector: "[ngsHeadlessEditorRuns]", inputs: ["ngsHeadlessEditorRuns"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3041
|
+
}
|
|
3042
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorListRenderer, decorators: [{
|
|
3043
|
+
type: Component,
|
|
3044
|
+
args: [{ selector: 'ngs-content-editor-list-renderer', imports: [
|
|
3045
|
+
NgTemplateOutlet,
|
|
3046
|
+
NgsHeadlessEditorRuns,
|
|
3047
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
3048
|
+
'class': 'ngs-content-editor-list-renderer',
|
|
3049
|
+
'[class.list-bullet]': "listStyle() === 'bullet'",
|
|
3050
|
+
'[class.list-ordered]': "listStyle() === 'ordered'",
|
|
3051
|
+
}, template: "@if (listStyle() === 'ordered') {\n <ol class=\"list\">\n <ng-container\n [ngTemplateOutlet]=\"listTpl\"\n [ngTemplateOutletContext]=\"{ $implicit: items(), ordered: true }\"\n />\n </ol>\n} @else {\n <ul class=\"list\">\n <ng-container\n [ngTemplateOutlet]=\"listTpl\"\n [ngTemplateOutletContext]=\"{ $implicit: items(), ordered: false }\"\n />\n </ul>\n}\n\n<ng-template #listTpl let-list let-ordered=\"ordered\">\n @for (item of list; track $index) {\n <li>\n <span class=\"content-html\" [ngsHeadlessEditorRuns]=\"item.content\"></span>\n @if (childItems(item).length > 0) {\n @if (ordered) {\n <ol class=\"list\">\n <ng-container\n [ngTemplateOutlet]=\"listTpl\"\n [ngTemplateOutletContext]=\"{ $implicit: childItems(item), ordered: ordered }\"\n />\n </ol>\n } @else {\n <ul class=\"list\">\n <ng-container\n [ngTemplateOutlet]=\"listTpl\"\n [ngTemplateOutletContext]=\"{ $implicit: childItems(item), ordered: ordered }\"\n />\n </ul>\n }\n }\n </li>\n }\n</ng-template>\n", styles: [":host{display:block}:host .list{margin:0;padding-inline-start:calc(var(--spacing, .25rem) * 4)}:host .list .list{margin-top:calc(var(--spacing, .25rem) * 2)}:host li{margin:var(--spacing, .25rem) 0}:host.list-bullet .list{list-style-type:disc}:host.list-ordered .list{list-style-type:decimal}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
|
|
3052
|
+
}], propDecorators: { block: [{ type: i0.Input, args: [{ isSignal: true, alias: "block", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }] } });
|
|
3053
|
+
|
|
3054
|
+
class ContentEditorParagraphRenderer {
|
|
3055
|
+
block = input(null, /* @ts-ignore */
|
|
3056
|
+
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
3057
|
+
id = input('', /* @ts-ignore */
|
|
3058
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
3059
|
+
type = input('', /* @ts-ignore */
|
|
3060
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
3061
|
+
content = input([], /* @ts-ignore */
|
|
3062
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
3063
|
+
props = input([], /* @ts-ignore */
|
|
3064
|
+
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
3065
|
+
settings = input({}, /* @ts-ignore */
|
|
3066
|
+
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
3067
|
+
index = input(0, /* @ts-ignore */
|
|
3068
|
+
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
3069
|
+
runs = computed(() => this.content(), /* @ts-ignore */
|
|
3070
|
+
...(ngDevMode ? [{ debugName: "runs" }] : /* istanbul ignore next */ []));
|
|
3071
|
+
alignment = computed(() => getTextAlignment(this.props()), /* @ts-ignore */
|
|
3072
|
+
...(ngDevMode ? [{ debugName: "alignment" }] : /* istanbul ignore next */ []));
|
|
3073
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorParagraphRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3074
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.7", type: ContentEditorParagraphRenderer, isStandalone: true, selector: "ngs-content-editor-paragraph-renderer", inputs: { block: { classPropertyName: "block", publicName: "block", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ngs-content-editor-paragraph-renderer" }, ngImport: i0, template: "<p\n class=\"content-html\"\n [class.align-left]=\"alignment() === 'left'\"\n [class.align-center]=\"alignment() === 'center'\"\n [class.align-right]=\"alignment() === 'right'\"\n [class.align-justify]=\"alignment() === 'justify'\"\n [ngsHeadlessEditorRuns]=\"runs()\"\n></p>\n", styles: [":host{display:block}:host .content-html{margin:0;line-height:var(--leading-normal)}:host .align-left{text-align:left}:host .align-center{text-align:center}:host .align-right{text-align:right}:host .align-justify{text-align:justify}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "directive", type: NgsHeadlessEditorRuns, selector: "[ngsHeadlessEditorRuns]", inputs: ["ngsHeadlessEditorRuns"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3075
|
+
}
|
|
3076
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorParagraphRenderer, decorators: [{
|
|
3077
|
+
type: Component,
|
|
3078
|
+
args: [{ selector: 'ngs-content-editor-paragraph-renderer', imports: [
|
|
3079
|
+
NgsHeadlessEditorRuns,
|
|
3080
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
3081
|
+
'class': 'ngs-content-editor-paragraph-renderer',
|
|
3082
|
+
}, template: "<p\n class=\"content-html\"\n [class.align-left]=\"alignment() === 'left'\"\n [class.align-center]=\"alignment() === 'center'\"\n [class.align-right]=\"alignment() === 'right'\"\n [class.align-justify]=\"alignment() === 'justify'\"\n [ngsHeadlessEditorRuns]=\"runs()\"\n></p>\n", styles: [":host{display:block}:host .content-html{margin:0;line-height:var(--leading-normal)}:host .align-left{text-align:left}:host .align-center{text-align:center}:host .align-right{text-align:right}:host .align-justify{text-align:justify}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
|
|
3083
|
+
}], propDecorators: { block: [{ type: i0.Input, args: [{ isSignal: true, alias: "block", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }] } });
|
|
3084
|
+
|
|
3085
|
+
class ContentEditorQuoteRenderer {
|
|
3086
|
+
block = input(null, /* @ts-ignore */
|
|
3087
|
+
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
3088
|
+
id = input('', /* @ts-ignore */
|
|
3089
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
3090
|
+
type = input('', /* @ts-ignore */
|
|
3091
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
3092
|
+
content = input(null, /* @ts-ignore */
|
|
3093
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
3094
|
+
props = input([], /* @ts-ignore */
|
|
3095
|
+
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
3096
|
+
settings = input({}, /* @ts-ignore */
|
|
3097
|
+
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
3098
|
+
index = input(0, /* @ts-ignore */
|
|
3099
|
+
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
3100
|
+
quoteRuns = computed(() => this.content()?.cite?.content ?? [], /* @ts-ignore */
|
|
3101
|
+
...(ngDevMode ? [{ debugName: "quoteRuns" }] : /* istanbul ignore next */ []));
|
|
3102
|
+
captionRuns = computed(() => this.content()?.caption?.content ?? [], /* @ts-ignore */
|
|
3103
|
+
...(ngDevMode ? [{ debugName: "captionRuns" }] : /* istanbul ignore next */ []));
|
|
3104
|
+
hasCaption = computed(() => !!contentEditorText(this.captionRuns()).trim(), /* @ts-ignore */
|
|
3105
|
+
...(ngDevMode ? [{ debugName: "hasCaption" }] : /* istanbul ignore next */ []));
|
|
3106
|
+
quoteAlignment = computed(() => getTextAlignment(this.content()?.cite?.props), /* @ts-ignore */
|
|
3107
|
+
...(ngDevMode ? [{ debugName: "quoteAlignment" }] : /* istanbul ignore next */ []));
|
|
3108
|
+
captionAlignment = computed(() => getTextAlignment(this.content()?.caption?.props), /* @ts-ignore */
|
|
3109
|
+
...(ngDevMode ? [{ debugName: "captionAlignment" }] : /* istanbul ignore next */ []));
|
|
3110
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorQuoteRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3111
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorQuoteRenderer, isStandalone: true, selector: "ngs-content-editor-quote-renderer", inputs: { block: { classPropertyName: "block", publicName: "block", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ngs-content-editor-quote-renderer" }, ngImport: i0, template: "<blockquote\n class=\"content-html\"\n [class.align-left]=\"quoteAlignment() === 'left'\"\n [class.align-center]=\"quoteAlignment() === 'center'\"\n [class.align-right]=\"quoteAlignment() === 'right'\"\n [class.align-justify]=\"quoteAlignment() === 'justify'\"\n [ngsHeadlessEditorRuns]=\"quoteRuns()\"\n></blockquote>\n@if (hasCaption()) {\n <figcaption\n class=\"caption-html\"\n [class.align-left]=\"captionAlignment() === 'left'\"\n [class.align-center]=\"captionAlignment() === 'center'\"\n [class.align-right]=\"captionAlignment() === 'right'\"\n [class.align-justify]=\"captionAlignment() === 'justify'\"\n [ngsHeadlessEditorRuns]=\"captionRuns()\"\n ></figcaption>\n}\n", styles: [":host{display:block}:host .content-html{border-inline-start:var(--spacing, .25rem) solid var(--ngs-color-border);margin:0 0 calc(var(--spacing, .25rem) * 2);padding:calc(var(--spacing, .25rem) * 2) calc(var(--spacing, .25rem) * 3)}:host .caption-html{color:var(--ngs-color-neutral-600);display:block;font-size:var(--ngs-font-size-sm)}:host .align-left{text-align:left}:host .align-center{text-align:center}:host .align-right{text-align:right}:host .align-justify{text-align:justify}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "directive", type: NgsHeadlessEditorRuns, selector: "[ngsHeadlessEditorRuns]", inputs: ["ngsHeadlessEditorRuns"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3112
|
+
}
|
|
3113
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorQuoteRenderer, decorators: [{
|
|
3114
|
+
type: Component,
|
|
3115
|
+
args: [{ selector: 'ngs-content-editor-quote-renderer', imports: [
|
|
3116
|
+
NgsHeadlessEditorRuns,
|
|
3117
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
3118
|
+
'class': 'ngs-content-editor-quote-renderer',
|
|
3119
|
+
}, template: "<blockquote\n class=\"content-html\"\n [class.align-left]=\"quoteAlignment() === 'left'\"\n [class.align-center]=\"quoteAlignment() === 'center'\"\n [class.align-right]=\"quoteAlignment() === 'right'\"\n [class.align-justify]=\"quoteAlignment() === 'justify'\"\n [ngsHeadlessEditorRuns]=\"quoteRuns()\"\n></blockquote>\n@if (hasCaption()) {\n <figcaption\n class=\"caption-html\"\n [class.align-left]=\"captionAlignment() === 'left'\"\n [class.align-center]=\"captionAlignment() === 'center'\"\n [class.align-right]=\"captionAlignment() === 'right'\"\n [class.align-justify]=\"captionAlignment() === 'justify'\"\n [ngsHeadlessEditorRuns]=\"captionRuns()\"\n ></figcaption>\n}\n", styles: [":host{display:block}:host .content-html{border-inline-start:var(--spacing, .25rem) solid var(--ngs-color-border);margin:0 0 calc(var(--spacing, .25rem) * 2);padding:calc(var(--spacing, .25rem) * 2) calc(var(--spacing, .25rem) * 3)}:host .caption-html{color:var(--ngs-color-neutral-600);display:block;font-size:var(--ngs-font-size-sm)}:host .align-left{text-align:left}:host .align-center{text-align:center}:host .align-right{text-align:right}:host .align-justify{text-align:justify}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
|
|
3120
|
+
}], propDecorators: { block: [{ type: i0.Input, args: [{ isSignal: true, alias: "block", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }] } });
|
|
3121
|
+
|
|
3122
|
+
class ContentEditorTableRenderer {
|
|
3123
|
+
block = input(null, /* @ts-ignore */
|
|
3124
|
+
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
3125
|
+
id = input('', /* @ts-ignore */
|
|
3126
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
3127
|
+
type = input('', /* @ts-ignore */
|
|
3128
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
3129
|
+
content = input([], /* @ts-ignore */
|
|
3130
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
3131
|
+
props = input([], /* @ts-ignore */
|
|
3132
|
+
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
3133
|
+
settings = input({}, /* @ts-ignore */
|
|
3134
|
+
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
3135
|
+
index = input(0, /* @ts-ignore */
|
|
3136
|
+
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
3137
|
+
header = computed(() => this.block()?.attrs?.['header'] === true, /* @ts-ignore */
|
|
3138
|
+
...(ngDevMode ? [{ debugName: "header" }] : /* istanbul ignore next */ []));
|
|
3139
|
+
rows = computed(() => this.content() || [], /* @ts-ignore */
|
|
3140
|
+
...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
|
|
3141
|
+
firstRow = computed(() => this.rows()[0] || [], /* @ts-ignore */
|
|
3142
|
+
...(ngDevMode ? [{ debugName: "firstRow" }] : /* istanbul ignore next */ []));
|
|
3143
|
+
width(cell) {
|
|
3144
|
+
return getDimensionAttribute(cell.options?.width);
|
|
3145
|
+
}
|
|
3146
|
+
colSpan(cell) {
|
|
3147
|
+
return cell.options?.colspan || 1;
|
|
3148
|
+
}
|
|
3149
|
+
rowSpan(cell) {
|
|
3150
|
+
return cell.options?.rowspan || 1;
|
|
3151
|
+
}
|
|
3152
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorTableRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3153
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorTableRenderer, isStandalone: true, selector: "ngs-content-editor-table-renderer", inputs: { block: { classPropertyName: "block", publicName: "block", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ngs-content-editor-table-renderer" }, ngImport: i0, template: "@if (rows().length > 0) {\n <div class=\"table-overflow\">\n <table ngs-native-table>\n <colgroup>\n @for (cell of firstRow(); track $index) {\n <col [attr.width]=\"width(cell)\">\n }\n </colgroup>\n <tbody>\n @for (row of rows(); track $index; let rowIndex = $index) {\n <tr>\n @for (cell of row; track $index) {\n @if (rowIndex === 0 && header()) {\n <th\n [attr.colspan]=\"colSpan(cell)\"\n [attr.rowspan]=\"rowSpan(cell)\"\n [ngsHeadlessEditorRuns]=\"cell.content || []\"\n ></th>\n } @else {\n <td\n [attr.colspan]=\"colSpan(cell)\"\n [attr.rowspan]=\"rowSpan(cell)\"\n [ngsHeadlessEditorRuns]=\"cell.content || []\"\n ></td>\n }\n }\n </tr>\n }\n </tbody>\n </table>\n </div>\n}\n", styles: [":host{display:block}:host .table-overflow{overflow-x:auto;overflow-y:hidden;width:100%}:host table{min-width:100%;word-break:break-word}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "component", type: NativeTable, selector: "table[ngs-native-table]", exportAs: ["ngsNativeTable"] }, { kind: "directive", type: NgsHeadlessEditorRuns, selector: "[ngsHeadlessEditorRuns]", inputs: ["ngsHeadlessEditorRuns"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3154
|
+
}
|
|
3155
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorTableRenderer, decorators: [{
|
|
3156
|
+
type: Component,
|
|
3157
|
+
args: [{ selector: 'ngs-content-editor-table-renderer', imports: [
|
|
3158
|
+
NativeTable,
|
|
3159
|
+
NgsHeadlessEditorRuns,
|
|
3160
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
3161
|
+
'class': 'ngs-content-editor-table-renderer',
|
|
3162
|
+
}, template: "@if (rows().length > 0) {\n <div class=\"table-overflow\">\n <table ngs-native-table>\n <colgroup>\n @for (cell of firstRow(); track $index) {\n <col [attr.width]=\"width(cell)\">\n }\n </colgroup>\n <tbody>\n @for (row of rows(); track $index; let rowIndex = $index) {\n <tr>\n @for (cell of row; track $index) {\n @if (rowIndex === 0 && header()) {\n <th\n [attr.colspan]=\"colSpan(cell)\"\n [attr.rowspan]=\"rowSpan(cell)\"\n [ngsHeadlessEditorRuns]=\"cell.content || []\"\n ></th>\n } @else {\n <td\n [attr.colspan]=\"colSpan(cell)\"\n [attr.rowspan]=\"rowSpan(cell)\"\n [ngsHeadlessEditorRuns]=\"cell.content || []\"\n ></td>\n }\n }\n </tr>\n }\n </tbody>\n </table>\n </div>\n}\n", styles: [":host{display:block}:host .table-overflow{overflow-x:auto;overflow-y:hidden;width:100%}:host table{min-width:100%;word-break:break-word}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
|
|
3163
|
+
}], propDecorators: { block: [{ type: i0.Input, args: [{ isSignal: true, alias: "block", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }] } });
|
|
3164
|
+
|
|
3165
|
+
class ContentEditorVideoRenderer {
|
|
3166
|
+
block = input(null, /* @ts-ignore */
|
|
3167
|
+
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
3168
|
+
id = input('', /* @ts-ignore */
|
|
3169
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
3170
|
+
type = input('', /* @ts-ignore */
|
|
3171
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
3172
|
+
content = input(null, /* @ts-ignore */
|
|
3173
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
3174
|
+
props = input([], /* @ts-ignore */
|
|
3175
|
+
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
3176
|
+
settings = input({}, /* @ts-ignore */
|
|
3177
|
+
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
3178
|
+
index = input(0, /* @ts-ignore */
|
|
3179
|
+
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
3180
|
+
src = computed(() => this.content()?.src || '', /* @ts-ignore */
|
|
3181
|
+
...(ngDevMode ? [{ debugName: "src" }] : /* istanbul ignore next */ []));
|
|
3182
|
+
caption = computed(() => this.content()?.caption || '', /* @ts-ignore */
|
|
3183
|
+
...(ngDevMode ? [{ debugName: "caption" }] : /* istanbul ignore next */ []));
|
|
3184
|
+
width = computed(() => getDimensionAttribute(this.settings()?.width), /* @ts-ignore */
|
|
3185
|
+
...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
3186
|
+
height = computed(() => getDimensionAttribute(this.settings()?.height), /* @ts-ignore */
|
|
3187
|
+
...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
3188
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorVideoRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3189
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorVideoRenderer, isStandalone: true, selector: "ngs-content-editor-video-renderer", inputs: { block: { classPropertyName: "block", publicName: "block", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ngs-content-editor-video-renderer" }, ngImport: i0, template: "@if (src()) {\n <figure>\n <video\n [src]=\"src()\"\n [attr.width]=\"width()\"\n [attr.height]=\"height()\"\n controls\n ></video>\n @if (caption()) {\n <figcaption>{{ caption() }}</figcaption>\n }\n </figure>\n}\n", styles: [":host{display:block}:host figure{margin:0}:host video{display:block;max-width:100%;height:auto}:host figcaption{margin-top:calc(var(--spacing, .25rem) * 2);color:var(--ngs-color-neutral-600);font-size:var(--ngs-font-size-sm);text-align:center}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3190
|
+
}
|
|
3191
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorVideoRenderer, decorators: [{
|
|
3192
|
+
type: Component,
|
|
3193
|
+
args: [{ selector: 'ngs-content-editor-video-renderer', imports: [], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
3194
|
+
'class': 'ngs-content-editor-video-renderer',
|
|
3195
|
+
}, template: "@if (src()) {\n <figure>\n <video\n [src]=\"src()\"\n [attr.width]=\"width()\"\n [attr.height]=\"height()\"\n controls\n ></video>\n @if (caption()) {\n <figcaption>{{ caption() }}</figcaption>\n }\n </figure>\n}\n", styles: [":host{display:block}:host figure{margin:0}:host video{display:block;max-width:100%;height:auto}:host figcaption{margin-top:calc(var(--spacing, .25rem) * 2);color:var(--ngs-color-neutral-600);font-size:var(--ngs-font-size-sm);text-align:center}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
|
|
3196
|
+
}], propDecorators: { block: [{ type: i0.Input, args: [{ isSignal: true, alias: "block", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }] } });
|
|
3197
|
+
|
|
3198
|
+
const CONTENT_EDITOR_DEFAULT_RENDERERS = [
|
|
3199
|
+
{ type: 'grid', component: ContentEditorGridRenderer },
|
|
3200
|
+
{ type: 'gallery', component: ContentEditorGalleryRenderer },
|
|
3201
|
+
{ type: 'attachment', component: ContentEditorAttachmentRenderer },
|
|
3202
|
+
{ type: 'toggle', component: ContentEditorToggleRenderer },
|
|
3203
|
+
{ type: 'callout', component: ContentEditorCalloutRenderer },
|
|
3204
|
+
{
|
|
3205
|
+
type: 'paragraph',
|
|
3206
|
+
component: ContentEditorParagraphRenderer,
|
|
3207
|
+
},
|
|
3208
|
+
{
|
|
3209
|
+
type: 'heading',
|
|
3210
|
+
component: ContentEditorHeadingRenderer,
|
|
3211
|
+
},
|
|
3212
|
+
{
|
|
3213
|
+
type: 'code',
|
|
3214
|
+
component: ContentEditorCodeRenderer,
|
|
3215
|
+
},
|
|
3216
|
+
{
|
|
3217
|
+
type: 'divider',
|
|
3218
|
+
component: ContentEditorDividerRenderer,
|
|
3219
|
+
},
|
|
3220
|
+
{
|
|
3221
|
+
type: 'image',
|
|
3222
|
+
component: ContentEditorImageRenderer,
|
|
3223
|
+
},
|
|
3224
|
+
{
|
|
3225
|
+
type: 'video',
|
|
3226
|
+
component: ContentEditorVideoRenderer,
|
|
3227
|
+
},
|
|
3228
|
+
{
|
|
3229
|
+
type: 'bulletList',
|
|
3230
|
+
component: ContentEditorListRenderer,
|
|
3231
|
+
},
|
|
3232
|
+
{
|
|
3233
|
+
type: 'orderedList',
|
|
3234
|
+
component: ContentEditorListRenderer,
|
|
3235
|
+
},
|
|
3236
|
+
{
|
|
3237
|
+
type: 'table',
|
|
3238
|
+
component: ContentEditorTableRenderer,
|
|
3239
|
+
},
|
|
3240
|
+
{
|
|
3241
|
+
type: 'quote',
|
|
3242
|
+
component: ContentEditorQuoteRenderer,
|
|
3243
|
+
},
|
|
3244
|
+
{
|
|
3245
|
+
type: 'embed',
|
|
3246
|
+
component: ContentEditorEmbedRenderer,
|
|
3247
|
+
},
|
|
3248
|
+
];
|
|
3249
|
+
|
|
3250
|
+
class ContentEditorRenderer {
|
|
3251
|
+
htmlSerializer = inject(ContentEditorHtmlSerializer);
|
|
3252
|
+
config = input({}, /* @ts-ignore */
|
|
3253
|
+
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
3254
|
+
providedRendererGroups = inject(CONTENT_EDITOR_BLOCK_RENDERERS, {
|
|
3255
|
+
optional: true,
|
|
3256
|
+
}) || [];
|
|
3257
|
+
content = input(createNgsHeadlessEditorDocument(), /* @ts-ignore */
|
|
3258
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
3259
|
+
blocks = input(null, /* @ts-ignore */
|
|
3260
|
+
...(ngDevMode ? [{ debugName: "blocks" }] : /* istanbul ignore next */ []));
|
|
3261
|
+
toHtml(config = {}) {
|
|
3262
|
+
return this.htmlSerializer.toHtml({ version: 1, blocks: this.blocks() ?? this.content().blocks }, mergeContentEditorConfig(this.config(), config));
|
|
3263
|
+
}
|
|
3264
|
+
rendererMap = computed(() => {
|
|
3265
|
+
const renderers = [
|
|
3266
|
+
...CONTENT_EDITOR_DEFAULT_RENDERERS,
|
|
3267
|
+
...this.providedRendererGroups.flat(),
|
|
3268
|
+
];
|
|
3269
|
+
return new Map(renderers.map(renderer => [renderer.type, renderer.component]));
|
|
3270
|
+
}, /* @ts-ignore */
|
|
3271
|
+
...(ngDevMode ? [{ debugName: "rendererMap" }] : /* istanbul ignore next */ []));
|
|
3272
|
+
items = computed(() => {
|
|
3273
|
+
const content = this.blocks() ?? this.content().blocks;
|
|
3274
|
+
const rendererMap = this.rendererMap();
|
|
3275
|
+
return content.map((block, index) => {
|
|
3276
|
+
const view = contentEditorBlockView(block);
|
|
3277
|
+
return {
|
|
3278
|
+
block,
|
|
3279
|
+
component: rendererMap.get(block.type) || null,
|
|
3280
|
+
inputs: {
|
|
3281
|
+
block,
|
|
3282
|
+
id: block.id,
|
|
3283
|
+
type: block.type,
|
|
3284
|
+
content: view.content,
|
|
3285
|
+
props: view.props || [],
|
|
3286
|
+
settings: view.settings || {},
|
|
3287
|
+
index,
|
|
3288
|
+
},
|
|
3289
|
+
};
|
|
3290
|
+
});
|
|
3291
|
+
}, /* @ts-ignore */
|
|
3292
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
3293
|
+
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 });
|
|
3295
|
+
}
|
|
3296
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorRenderer, decorators: [{
|
|
3297
|
+
type: Component,
|
|
3298
|
+
args: [{ selector: 'ngs-content-editor-renderer', exportAs: 'ngsContentEditorRenderer', providers: [provideContentEditor(), ContentEditorHtmlSerializer], imports: [
|
|
3299
|
+
NgComponentOutlet,
|
|
3300
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
3301
|
+
'class': 'ngs-content-editor-renderer prose max-w-full',
|
|
3302
|
+
}, 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
|
+
}], 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
|
+
|
|
3305
|
+
/**
|
|
3306
|
+
* Generated bundle index. Do not edit.
|
|
3307
|
+
*/
|
|
3308
|
+
|
|
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
|