@ngstarter-ui/components 22.1.4 → 22.2.2
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-color-picker.mjs +147 -272
- package/fesm2022/ngstarter-ui-components-color-picker.mjs.map +1 -1
- 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-color-picker.d.ts +2 -2
- 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
|
@@ -1,3102 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, inject, ChangeDetectionStrategy, Component, DOCUMENT, model, input, output, Renderer2, signal, computed, Input as Input$1, InjectionToken, EventEmitter, HostListener, Output, Directive, PLATFORM_ID, ElementRef, EnvironmentInjector, ChangeDetectorRef, numberAttribute, booleanAttribute, runInInjectionContext, effect, forwardRef, makeEnvironmentProviders } 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 } from '@ngstarter-ui/components/menu';
|
|
6
|
-
import { DialogRef, DialogContent, DialogTitle, DialogActions, DIALOG_DATA, Dialog } from '@ngstarter-ui/components/dialog';
|
|
7
|
-
import { Input } from '@ngstarter-ui/components/input';
|
|
8
|
-
import { FormField, Label, Hint } from '@ngstarter-ui/components/form-field';
|
|
9
|
-
import * as i1 from '@angular/forms';
|
|
10
|
-
import { FormBuilder, Validators, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
11
|
-
import { SlideToggle } from '@ngstarter-ui/components/slide-toggle';
|
|
12
|
-
import { DOCUMENT as DOCUMENT$1, isPlatformBrowser, isPlatformServer, NgComponentOutlet, AsyncPipe, NgTemplateOutlet } from '@angular/common';
|
|
13
|
-
import { Tooltip } from '@ngstarter-ui/components/tooltip';
|
|
14
|
-
import { v7 } from 'uuid';
|
|
15
|
-
import { signalStore, withState, withMethods, patchState } from '@ngrx/signals';
|
|
16
|
-
import { moveItemInArray, CdkDrag, CdkDropList, CdkDragHandle, CdkDragPlaceholder } from '@angular/cdk/drag-drop';
|
|
17
|
-
import { ConfirmManager } from '@ngstarter-ui/components/confirm';
|
|
18
|
-
import { CdkMonitorFocus } from '@angular/cdk/a11y';
|
|
19
|
-
import { ComponentPortal } from '@angular/cdk/portal';
|
|
20
|
-
import { Subject, fromEvent } from 'rxjs';
|
|
21
|
-
import { throttleTime, shareReplay, auditTime, map, startWith, distinctUntilChanged } from 'rxjs/operators';
|
|
22
|
-
import * as i1$1 from '@angular/cdk/overlay';
|
|
23
|
-
import SelectionArea from '@viselect/vanilla';
|
|
24
|
-
import { PopoverTriggerForDirective, Popover } from '@ngstarter-ui/components/popover';
|
|
25
|
-
import { SelectionModel } from '@angular/cdk/collections';
|
|
26
|
-
import { ListItemTitle, ListItemIcon, ListItem, List } from '@ngstarter-ui/components/list';
|
|
27
|
-
import { CodeHighlighter } from '@ngstarter-ui/components/code-highlighter';
|
|
28
|
-
import { Divider } from '@ngstarter-ui/components/divider';
|
|
29
|
-
import { SafeResourceUrlPipe, SafeHtmlPipe } from '@ngstarter-ui/components/core';
|
|
30
|
-
import { NativeTable } from '@ngstarter-ui/components/table';
|
|
31
|
-
|
|
32
|
-
class TextHighlightService {
|
|
33
|
-
savedRange = null;
|
|
34
|
-
constructor() { }
|
|
35
|
-
saveCurrentSelection() {
|
|
36
|
-
const selection = window.getSelection();
|
|
37
|
-
const range = this.getCurrentRangeInternal(selection);
|
|
38
|
-
this.savedRange = range ? range.cloneRange() : null;
|
|
39
|
-
// // console.log('TextHighlightService: Selection saved/cleared.');
|
|
40
|
-
}
|
|
41
|
-
restoreSelection() {
|
|
42
|
-
if (!this.savedRange) {
|
|
43
|
-
// // console.warn('TextHighlightService: No saved selection to restore.');
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const selection = window.getSelection();
|
|
47
|
-
if (!selection) {
|
|
48
|
-
// // console.error('TextHighlightService: Failed to get window.getSelection() for restoration.');
|
|
49
|
-
this.savedRange = null;
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (this.savedRange.startContainer.isConnected && this.savedRange.endContainer.isConnected) {
|
|
53
|
-
try {
|
|
54
|
-
selection.removeAllRanges();
|
|
55
|
-
selection.addRange(this.savedRange);
|
|
56
|
-
// // console.log('TextHighlightService: Selection restored.');
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
// // console.error('TextHighlightService: Error restoring selection:', e);
|
|
60
|
-
this.savedRange = null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
// // console.warn('TextHighlightService: The saved range is no longer valid and cannot be restored.');
|
|
65
|
-
this.savedRange = null;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Wraps current selection with specified tag, applying styles, classes, and attributes.
|
|
70
|
-
* If the selection EXACTLY MATCHES THE BOUNDARIES of an existing tag of the same type,
|
|
71
|
-
* then styles, classes, and attributes are ADDED/OVERWRITTEN on that existing tag.
|
|
72
|
-
* Otherwise, a new wrapper is always created.
|
|
73
|
-
* DOES NOT attempt to "cut" elements.
|
|
74
|
-
*/
|
|
75
|
-
wrapSelection(tagName, styles, classNames, attrs) {
|
|
76
|
-
const selection = window.getSelection();
|
|
77
|
-
const range = this.getCurrentRangeInternal(selection);
|
|
78
|
-
if (!range || !selection) {
|
|
79
|
-
// // console.warn('TextHighlightService (wrapSelection): No valid selection.');
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const normalizedTagName = tagName.toLowerCase();
|
|
83
|
-
const exactExistingContainer = this.findExactWrappingElement(range, normalizedTagName);
|
|
84
|
-
if (exactExistingContainer) {
|
|
85
|
-
this.applyStylesAttributesAndClasses(exactExistingContainer, styles, classNames, attrs);
|
|
86
|
-
selection.removeAllRanges();
|
|
87
|
-
const newExactRange = document.createRange();
|
|
88
|
-
newExactRange.selectNodeContents(exactExistingContainer);
|
|
89
|
-
selection.addRange(newExactRange);
|
|
90
|
-
// // console.log(`TextHighlightService (wrapSelection): Modified existing <${normalizedTagName}> element.`);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
this.wrapRange(selection, range, normalizedTagName, styles, classNames, attrs);
|
|
94
|
-
// // console.log(`TextHighlightService (wrapSelection): Created a new <${normalizedTagName}> wrapper.`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* "Smart" wrapping:
|
|
99
|
-
* - If the selection exactly covers an existing element of the same type -> modifies it.
|
|
100
|
-
* - If the selection is partially inside an inline element of the same type -> splits it and wraps the selected part.
|
|
101
|
-
* - In other cases -> creates a new wrapper.
|
|
102
|
-
*/
|
|
103
|
-
wrapOrSplitInlineSelection(tagName, styles, classNames, attrs) {
|
|
104
|
-
const selection = window.getSelection();
|
|
105
|
-
const range = this.getCurrentRangeInternal(selection);
|
|
106
|
-
if (!range || !selection) {
|
|
107
|
-
// // console.warn('TextHighlightService (wrapOrSplitInlineSelection): No valid selection.');
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const normalizedTagName = tagName.toLowerCase();
|
|
111
|
-
const exactContainer = this.findExactWrappingElement(range, normalizedTagName);
|
|
112
|
-
if (exactContainer) {
|
|
113
|
-
this.applyStylesAttributesAndClasses(exactContainer, styles, classNames, attrs);
|
|
114
|
-
selection.removeAllRanges();
|
|
115
|
-
const newExactRange = document.createRange();
|
|
116
|
-
newExactRange.selectNodeContents(exactContainer);
|
|
117
|
-
selection.addRange(newExactRange);
|
|
118
|
-
// // console.log(`TextHighlightService (wrapOrSplitInlineSelection): Modified existing <${normalizedTagName}>.`);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const containingAncestor = this.findContainingAncestor(range, normalizedTagName);
|
|
122
|
-
if (containingAncestor && this.isInlineElement(containingAncestor)) {
|
|
123
|
-
// // console.log(`TextHighlightService (wrapOrSplitInlineSelection): Attempting to split inline <${normalizedTagName}>.`);
|
|
124
|
-
this.splitInlineElementAndApplyToSelection(selection, range, containingAncestor, normalizedTagName, styles, classNames, attrs);
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
// // console.log(`TextHighlightService (wrapOrSplitInlineSelection): Creating a new <${normalizedTagName}> wrapper.`);
|
|
128
|
-
this.wrapRange(selection, range, normalizedTagName, styles, classNames, attrs);
|
|
129
|
-
}
|
|
130
|
-
unwrapSelection(tagName) {
|
|
131
|
-
const selection = window.getSelection();
|
|
132
|
-
const range = this.getCurrentRangeInternal(selection);
|
|
133
|
-
if (!range || !selection)
|
|
134
|
-
return;
|
|
135
|
-
const normalizedTagName = tagName.toLowerCase();
|
|
136
|
-
const elementToUnwrap = this.findExactWrappingElement(range, normalizedTagName)
|
|
137
|
-
?? this.findContainingAncestor(range, normalizedTagName);
|
|
138
|
-
if (elementToUnwrap) {
|
|
139
|
-
this.unwrapElementAndReselect(selection, elementToUnwrap);
|
|
140
|
-
// // console.log(`TextHighlightService (unwrapSelection): Unwrapped <${normalizedTagName}>.`);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
// // console.warn(`TextHighlightService (unwrapSelection): No <${normalizedTagName}> found to unwrap.`);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
toggleWrapSelection(tagName, styles, classNames, attrs) {
|
|
147
|
-
const range = this.getCurrentRange();
|
|
148
|
-
if (!range)
|
|
149
|
-
return;
|
|
150
|
-
const normalizedTagName = tagName.toLowerCase();
|
|
151
|
-
const elementToUnwrap = this.findExactWrappingElement(range, normalizedTagName)
|
|
152
|
-
?? this.findContainingAncestor(range, normalizedTagName);
|
|
153
|
-
if (elementToUnwrap) {
|
|
154
|
-
this.unwrapSelection(normalizedTagName);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
this.wrapOrSplitInlineSelection(normalizedTagName, styles, classNames, attrs);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
isSelectionWrappedInTag(tagName) {
|
|
161
|
-
const range = this.getCurrentRange();
|
|
162
|
-
if (!range)
|
|
163
|
-
return false;
|
|
164
|
-
const normalizedTagName = tagName.toLowerCase();
|
|
165
|
-
const containingElement = this.findContainingAncestor(range, normalizedTagName);
|
|
166
|
-
return !!containingElement;
|
|
167
|
-
}
|
|
168
|
-
getCurrentRange() {
|
|
169
|
-
const selection = window.getSelection();
|
|
170
|
-
return this.getCurrentRangeInternal(selection);
|
|
171
|
-
}
|
|
172
|
-
findClosestBlockAncestor(requiredClassName) {
|
|
173
|
-
const range = this.getCurrentRange();
|
|
174
|
-
if (!range)
|
|
175
|
-
return null;
|
|
176
|
-
let node = range.commonAncestorContainer;
|
|
177
|
-
const trimmedClassName = requiredClassName?.trim();
|
|
178
|
-
while (node && node !== document.body && node !== document) {
|
|
179
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
180
|
-
const element = node;
|
|
181
|
-
if (!this.isInlineElement(element)) {
|
|
182
|
-
if (!trimmedClassName || element.classList.contains(trimmedClassName)) {
|
|
183
|
-
return element;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
node = node.parentNode;
|
|
188
|
-
}
|
|
189
|
-
if (document.body && document.body.contains(range.commonAncestorContainer)) {
|
|
190
|
-
if (!this.isInlineElement(document.body)) {
|
|
191
|
-
if (!trimmedClassName || document.body.classList.contains(trimmedClassName)) {
|
|
192
|
-
return document.body;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return null;
|
|
197
|
-
}
|
|
198
|
-
setTextAlignment(alignment) {
|
|
199
|
-
const blockAncestor = this.findClosestBlockAncestor();
|
|
200
|
-
if (!blockAncestor)
|
|
201
|
-
return;
|
|
202
|
-
if (alignment && alignment.trim() !== '') {
|
|
203
|
-
blockAncestor.style.textAlign = alignment;
|
|
204
|
-
blockAncestor.setAttribute('data-props-text-alignment', alignment);
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
blockAncestor.style.textAlign = '';
|
|
208
|
-
blockAncestor.removeAttribute('data-props-text-alignment');
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
unwrapElementByClassAndSelectContents(className) {
|
|
212
|
-
if (!className || !className.trim())
|
|
213
|
-
return;
|
|
214
|
-
const trimmedClassName = className.trim();
|
|
215
|
-
const selector = `.${trimmedClassName}`;
|
|
216
|
-
const elementToUnwrap = document.querySelector(selector);
|
|
217
|
-
if (!elementToUnwrap)
|
|
218
|
-
return;
|
|
219
|
-
const parent = elementToUnwrap.parentNode;
|
|
220
|
-
if (!parent)
|
|
221
|
-
return;
|
|
222
|
-
const firstChildToSelect = elementToUnwrap.firstChild;
|
|
223
|
-
const lastChildToSelect = elementToUnwrap.lastChild;
|
|
224
|
-
while (elementToUnwrap.firstChild) {
|
|
225
|
-
parent.insertBefore(elementToUnwrap.firstChild, elementToUnwrap);
|
|
226
|
-
}
|
|
227
|
-
parent.removeChild(elementToUnwrap);
|
|
228
|
-
const selection = window.getSelection();
|
|
229
|
-
if (!selection)
|
|
230
|
-
return;
|
|
231
|
-
selection.removeAllRanges();
|
|
232
|
-
if (firstChildToSelect && lastChildToSelect && firstChildToSelect.isConnected && lastChildToSelect.isConnected) {
|
|
233
|
-
try {
|
|
234
|
-
const newRange = document.createRange();
|
|
235
|
-
newRange.setStartBefore(firstChildToSelect);
|
|
236
|
-
newRange.setEndAfter(lastChildToSelect);
|
|
237
|
-
selection.addRange(newRange);
|
|
238
|
-
}
|
|
239
|
-
catch (e) { /* ... */ }
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
getContainingAncestorByTagName(tagName) {
|
|
243
|
-
const range = this.getCurrentRange();
|
|
244
|
-
if (!range)
|
|
245
|
-
return null;
|
|
246
|
-
const normalizedTagName = tagName.toLowerCase();
|
|
247
|
-
return this.findContainingAncestor(range, normalizedTagName);
|
|
248
|
-
}
|
|
249
|
-
clearSelectionFormatting() {
|
|
250
|
-
const selection = window.getSelection();
|
|
251
|
-
const range = this.getCurrentRangeInternal(selection);
|
|
252
|
-
if (!range || !selection)
|
|
253
|
-
return;
|
|
254
|
-
try {
|
|
255
|
-
const selectedContents = range.extractContents();
|
|
256
|
-
const plainText = selectedContents.textContent || '';
|
|
257
|
-
const textNode = document.createTextNode(plainText);
|
|
258
|
-
range.insertNode(textNode);
|
|
259
|
-
selection.removeAllRanges();
|
|
260
|
-
const newRange = document.createRange();
|
|
261
|
-
newRange.selectNodeContents(textNode);
|
|
262
|
-
selection.addRange(newRange);
|
|
263
|
-
}
|
|
264
|
-
catch (e) {
|
|
265
|
-
selection.removeAllRanges();
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
getCurrentRangeInternal(selection) {
|
|
269
|
-
if (!selection || selection.rangeCount === 0)
|
|
270
|
-
return null;
|
|
271
|
-
const range = selection.getRangeAt(0);
|
|
272
|
-
if (range.collapsed || !range.toString().trim())
|
|
273
|
-
return null;
|
|
274
|
-
return range;
|
|
275
|
-
}
|
|
276
|
-
findExactWrappingElement(range, tagName) {
|
|
277
|
-
const commonAncestor = range.commonAncestorContainer;
|
|
278
|
-
let candidateElement = (commonAncestor.nodeType === Node.ELEMENT_NODE && commonAncestor.tagName.toLowerCase() === tagName)
|
|
279
|
-
? commonAncestor
|
|
280
|
-
: this.findClosestAncestorByTagName(commonAncestor, tagName);
|
|
281
|
-
if (!candidateElement)
|
|
282
|
-
return null;
|
|
283
|
-
const elementRange = document.createRange();
|
|
284
|
-
try {
|
|
285
|
-
elementRange.selectNodeContents(candidateElement);
|
|
286
|
-
if (range.compareBoundaryPoints(Range.START_TO_START, elementRange) === 0 &&
|
|
287
|
-
range.compareBoundaryPoints(Range.END_TO_END, elementRange) === 0) {
|
|
288
|
-
return candidateElement;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
catch (e) { /*// console.error("Error in findExactWrappingElement:", e);*/ }
|
|
292
|
-
return null;
|
|
293
|
-
}
|
|
294
|
-
findContainingAncestor(range, tagName) {
|
|
295
|
-
let node = range.commonAncestorContainer;
|
|
296
|
-
while (node && node !== document.body && node !== document) {
|
|
297
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
298
|
-
const element = node;
|
|
299
|
-
if (element.tagName.toLowerCase() === tagName) {
|
|
300
|
-
const elementRange = document.createRange();
|
|
301
|
-
try {
|
|
302
|
-
elementRange.selectNodeContents(element);
|
|
303
|
-
if (range.compareBoundaryPoints(Range.START_TO_START, elementRange) >= 0 &&
|
|
304
|
-
range.compareBoundaryPoints(Range.END_TO_END, elementRange) <= 0) {
|
|
305
|
-
return element;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
catch (e) { /*// console.error("Error in findContainingAncestor:", e); */ }
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
node = node.parentNode;
|
|
312
|
-
}
|
|
313
|
-
return null;
|
|
314
|
-
}
|
|
315
|
-
findClosestAncestorByTagName(node, tagName) {
|
|
316
|
-
let currentNode = node;
|
|
317
|
-
while (currentNode && currentNode !== document.body && currentNode !== document) {
|
|
318
|
-
if (currentNode.nodeType === Node.ELEMENT_NODE && currentNode.tagName.toLowerCase() === tagName) {
|
|
319
|
-
return currentNode;
|
|
320
|
-
}
|
|
321
|
-
currentNode = currentNode.parentNode;
|
|
322
|
-
}
|
|
323
|
-
return null;
|
|
324
|
-
}
|
|
325
|
-
findClosestAncestorByClassName(node, className) {
|
|
326
|
-
let currentNode = node;
|
|
327
|
-
const trimmedClassName = className.trim();
|
|
328
|
-
if (!trimmedClassName)
|
|
329
|
-
return null;
|
|
330
|
-
while (currentNode && currentNode !== document.body && currentNode !== document) {
|
|
331
|
-
if (currentNode.nodeType === Node.ELEMENT_NODE && currentNode.classList.contains(trimmedClassName)) {
|
|
332
|
-
return currentNode;
|
|
333
|
-
}
|
|
334
|
-
currentNode = currentNode.parentNode;
|
|
335
|
-
}
|
|
336
|
-
return null;
|
|
337
|
-
}
|
|
338
|
-
applyStylesAttributesAndClasses(element, styles, classNames, attrs) {
|
|
339
|
-
if (styles) {
|
|
340
|
-
for (const styleName in styles) {
|
|
341
|
-
if (Object.prototype.hasOwnProperty.call(styles, styleName)) {
|
|
342
|
-
// @ts-ignore
|
|
343
|
-
if (styles[styleName] !== undefined && isNaN(Number(styleName))) {
|
|
344
|
-
try {
|
|
345
|
-
element.style[styleName] = styles[styleName];
|
|
346
|
-
}
|
|
347
|
-
catch (e) { /* ... */ }
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
if (classNames && classNames.length > 0) {
|
|
353
|
-
const validClasses = classNames.filter(cn => cn && cn.trim());
|
|
354
|
-
if (validClasses.length > 0) {
|
|
355
|
-
element.classList.add(...validClasses);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
if (attrs) {
|
|
359
|
-
for (const attrName in attrs) {
|
|
360
|
-
if (Object.prototype.hasOwnProperty.call(attrs, attrName)) {
|
|
361
|
-
const attrValue = attrs[attrName];
|
|
362
|
-
if (attrValue === null) {
|
|
363
|
-
element.removeAttribute(attrName);
|
|
364
|
-
}
|
|
365
|
-
else if (attrValue !== undefined) {
|
|
366
|
-
element.setAttribute(attrName, attrValue);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
wrapRange(selection, range, tagName, styles, classNames, attrs) {
|
|
373
|
-
try {
|
|
374
|
-
const wrapperElement = document.createElement(tagName);
|
|
375
|
-
this.applyStylesAttributesAndClasses(wrapperElement, styles, classNames, attrs);
|
|
376
|
-
const selectedContents = range.extractContents();
|
|
377
|
-
wrapperElement.appendChild(selectedContents);
|
|
378
|
-
range.insertNode(wrapperElement);
|
|
379
|
-
selection.removeAllRanges();
|
|
380
|
-
const newRange = document.createRange();
|
|
381
|
-
newRange.selectNodeContents(wrapperElement);
|
|
382
|
-
selection.addRange(newRange);
|
|
383
|
-
}
|
|
384
|
-
catch (e) {
|
|
385
|
-
selection.removeAllRanges();
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
createMarker(id) {
|
|
389
|
-
const marker = document.createElement('span');
|
|
390
|
-
marker.id = id;
|
|
391
|
-
marker.style.display = 'none';
|
|
392
|
-
marker.setAttribute('data-selection-marker', 'true');
|
|
393
|
-
return marker;
|
|
394
|
-
}
|
|
395
|
-
unwrapElementAndReselect(selection, elementToUnwrap) {
|
|
396
|
-
const parent = elementToUnwrap.parentNode;
|
|
397
|
-
if (!parent)
|
|
398
|
-
return;
|
|
399
|
-
const startMarkerId = `__sel_start_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`;
|
|
400
|
-
const endMarkerId = `__sel_end_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`;
|
|
401
|
-
let markersInserted = false;
|
|
402
|
-
const originalRange = this.getCurrentRangeInternal(selection);
|
|
403
|
-
try {
|
|
404
|
-
if (originalRange) {
|
|
405
|
-
const startMarker = this.createMarker(startMarkerId);
|
|
406
|
-
const endMarker = this.createMarker(endMarkerId);
|
|
407
|
-
const rangeEnd = originalRange.cloneRange();
|
|
408
|
-
rangeEnd.collapse(false);
|
|
409
|
-
rangeEnd.insertNode(endMarker);
|
|
410
|
-
const rangeStart = originalRange.cloneRange();
|
|
411
|
-
rangeStart.collapse(true);
|
|
412
|
-
rangeStart.insertNode(startMarker);
|
|
413
|
-
markersInserted = true;
|
|
414
|
-
selection.removeAllRanges();
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
catch (e) {
|
|
418
|
-
markersInserted = false;
|
|
419
|
-
if (selection)
|
|
420
|
-
selection.removeAllRanges();
|
|
421
|
-
}
|
|
422
|
-
if (markersInserted || !originalRange) {
|
|
423
|
-
while (elementToUnwrap.firstChild) {
|
|
424
|
-
parent.insertBefore(elementToUnwrap.firstChild, elementToUnwrap);
|
|
425
|
-
}
|
|
426
|
-
parent.removeChild(elementToUnwrap);
|
|
427
|
-
}
|
|
428
|
-
else {
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
if (markersInserted) {
|
|
432
|
-
const startMarker = document.getElementById(startMarkerId);
|
|
433
|
-
const endMarker = document.getElementById(endMarkerId);
|
|
434
|
-
if (startMarker?.parentNode && endMarker?.parentNode) {
|
|
435
|
-
try {
|
|
436
|
-
const newRange = document.createRange();
|
|
437
|
-
newRange.setStartAfter(startMarker);
|
|
438
|
-
newRange.setEndBefore(endMarker);
|
|
439
|
-
const currentSelection = window.getSelection();
|
|
440
|
-
if (currentSelection) {
|
|
441
|
-
currentSelection.removeAllRanges();
|
|
442
|
-
currentSelection.addRange(newRange);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
catch (e) {
|
|
446
|
-
window.getSelection()?.removeAllRanges();
|
|
447
|
-
}
|
|
448
|
-
finally {
|
|
449
|
-
startMarker.parentNode.removeChild(startMarker);
|
|
450
|
-
endMarker.parentNode.removeChild(endMarker);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
else {
|
|
454
|
-
document.getElementById(startMarkerId)?.remove();
|
|
455
|
-
document.getElementById(endMarkerId)?.remove();
|
|
456
|
-
window.getSelection()?.removeAllRanges();
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
else {
|
|
460
|
-
window.getSelection()?.removeAllRanges();
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
isInlineElement(element) {
|
|
464
|
-
if (!element)
|
|
465
|
-
return false;
|
|
466
|
-
const display = window.getComputedStyle(element).display;
|
|
467
|
-
return display.startsWith('inline');
|
|
468
|
-
}
|
|
469
|
-
splitInlineElementAndApplyToSelection(selection, selectedRange, existingElement, newTagName, newWrapperStyles, newWrapperClassNames, newWrapperAttrs) {
|
|
470
|
-
const parent = existingElement.parentNode;
|
|
471
|
-
if (!parent) {
|
|
472
|
-
this.wrapRange(selection, selectedRange, newTagName, newWrapperStyles, newWrapperClassNames, newWrapperAttrs);
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
const newWrapperForSelection = document.createElement(newTagName);
|
|
476
|
-
this.applyStylesAttributesAndClasses(newWrapperForSelection, newWrapperStyles, newWrapperClassNames, newWrapperAttrs);
|
|
477
|
-
const originalElementAttributes = {};
|
|
478
|
-
for (let i = 0; i < existingElement.attributes.length; i++) {
|
|
479
|
-
const attr = existingElement.attributes[i];
|
|
480
|
-
originalElementAttributes[attr.name] = attr.value;
|
|
481
|
-
}
|
|
482
|
-
const prefixRange = document.createRange();
|
|
483
|
-
prefixRange.setStart(existingElement, 0); // From the start of existingElement's contents
|
|
484
|
-
try {
|
|
485
|
-
prefixRange.setEnd(selectedRange.startContainer, selectedRange.startOffset);
|
|
486
|
-
}
|
|
487
|
-
catch (e) {
|
|
488
|
-
// If selectedRange.startContainer is not a descendant of existingElement, this may throw an error.
|
|
489
|
-
// In that case, there is no prefix, or it cannot be determined correctly this way.
|
|
490
|
-
// console.warn("Error setting prefixRange end:", e);
|
|
491
|
-
prefixRange.setEnd(existingElement, 0); // Collapse to the start
|
|
492
|
-
}
|
|
493
|
-
let prefixElementClone = null;
|
|
494
|
-
if (!prefixRange.collapsed) {
|
|
495
|
-
try {
|
|
496
|
-
const prefixFragment = prefixRange.extractContents();
|
|
497
|
-
prefixElementClone = document.createElement(existingElement.tagName);
|
|
498
|
-
for (const attrName in originalElementAttributes) {
|
|
499
|
-
if (Object.prototype.hasOwnProperty.call(originalElementAttributes, attrName)) {
|
|
500
|
-
prefixElementClone.setAttribute(attrName, originalElementAttributes[attrName]);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
prefixElementClone.appendChild(prefixFragment);
|
|
504
|
-
}
|
|
505
|
-
catch (e) {
|
|
506
|
-
// console.error("Error extracting/creating prefix:", e);
|
|
507
|
-
prefixElementClone = null; // Failed to create the prefix
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
// Extract the selected content BEFORE processing the suffix because selectedRange may become invalid
|
|
511
|
-
let selectedFragment;
|
|
512
|
-
try {
|
|
513
|
-
if (selectedRange.commonAncestorContainer.isConnected && !selectedRange.collapsed) {
|
|
514
|
-
selectedFragment = selectedRange.extractContents();
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
selectedFragment = document.createDocumentFragment(); // Empty if extraction failed
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
catch (e) {
|
|
521
|
-
// console.error("Error extracting selectedFragment:", e);
|
|
522
|
-
selectedFragment = document.createDocumentFragment();
|
|
523
|
-
}
|
|
524
|
-
let suffixElementClone = null;
|
|
525
|
-
// What remains in existingElement after extracting the prefix and selected part is the suffix
|
|
526
|
-
if (existingElement.hasChildNodes()) {
|
|
527
|
-
suffixElementClone = document.createElement(existingElement.tagName);
|
|
528
|
-
for (const attrName in originalElementAttributes) {
|
|
529
|
-
if (Object.prototype.hasOwnProperty.call(originalElementAttributes, attrName)) {
|
|
530
|
-
suffixElementClone.setAttribute(attrName, originalElementAttributes[attrName]);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
while (existingElement.firstChild) {
|
|
534
|
-
suffixElementClone.appendChild(existingElement.firstChild);
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
newWrapperForSelection.appendChild(selectedFragment);
|
|
538
|
-
const insertBeforeOriginal = existingElement;
|
|
539
|
-
if (prefixElementClone) {
|
|
540
|
-
parent.insertBefore(prefixElementClone, insertBeforeOriginal);
|
|
541
|
-
}
|
|
542
|
-
parent.insertBefore(newWrapperForSelection, insertBeforeOriginal);
|
|
543
|
-
if (suffixElementClone) {
|
|
544
|
-
parent.insertBefore(suffixElementClone, insertBeforeOriginal);
|
|
545
|
-
}
|
|
546
|
-
parent.removeChild(existingElement);
|
|
547
|
-
selection.removeAllRanges();
|
|
548
|
-
const finalRange = document.createRange();
|
|
549
|
-
finalRange.selectNodeContents(newWrapperForSelection);
|
|
550
|
-
selection.addRange(finalRange);
|
|
551
|
-
}
|
|
552
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: TextHighlightService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
553
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: TextHighlightService, providedIn: 'root' });
|
|
554
|
-
}
|
|
555
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: TextHighlightService, decorators: [{
|
|
556
|
-
type: Injectable,
|
|
557
|
-
args: [{
|
|
558
|
-
providedIn: 'root'
|
|
559
|
-
}]
|
|
560
|
-
}], ctorParameters: () => [] });
|
|
561
|
-
|
|
562
|
-
class AddLinkDialog {
|
|
563
|
-
_dialogRef = inject(DialogRef);
|
|
564
|
-
_formBuilder = inject(FormBuilder);
|
|
565
|
-
form = this._formBuilder.group({
|
|
566
|
-
href: [''],
|
|
567
|
-
openInNewTab: [true, [Validators.required]]
|
|
568
|
-
});
|
|
569
|
-
cancel() {
|
|
570
|
-
this._dialogRef.close(false);
|
|
571
|
-
}
|
|
572
|
-
add() {
|
|
573
|
-
this._dialogRef.close(this.form.value);
|
|
574
|
-
}
|
|
575
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: AddLinkDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
576
|
-
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.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.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.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 });
|
|
577
|
-
}
|
|
578
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: AddLinkDialog, decorators: [{
|
|
579
|
-
type: Component,
|
|
580
|
-
args: [{ selector: 'ngs-add-link', imports: [
|
|
581
|
-
DialogContent,
|
|
582
|
-
FormField,
|
|
583
|
-
Input,
|
|
584
|
-
DialogTitle,
|
|
585
|
-
DialogActions,
|
|
586
|
-
Button,
|
|
587
|
-
ReactiveFormsModule,
|
|
588
|
-
Label,
|
|
589
|
-
SlideToggle
|
|
590
|
-
], 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" }]
|
|
591
|
-
}] });
|
|
592
|
-
|
|
593
|
-
class EditLinkDialog {
|
|
594
|
-
_dialogRef = inject(DialogRef);
|
|
595
|
-
_dialogData = inject(DIALOG_DATA);
|
|
596
|
-
_formBuilder = inject(FormBuilder);
|
|
597
|
-
form = this._formBuilder.group({
|
|
598
|
-
href: [this._dialogData.href],
|
|
599
|
-
openInNewTab: [this._dialogData.openInNewTab, [Validators.required]]
|
|
600
|
-
});
|
|
601
|
-
cancel() {
|
|
602
|
-
this._dialogRef.close(false);
|
|
603
|
-
}
|
|
604
|
-
add() {
|
|
605
|
-
this._dialogRef.close(this.form.value);
|
|
606
|
-
}
|
|
607
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: EditLinkDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
608
|
-
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.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.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.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.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: Hint, selector: "ngs-hint", inputs: ["align"], exportAs: ["ngsHint"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
|
|
609
|
-
}
|
|
610
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: EditLinkDialog, decorators: [{
|
|
611
|
-
type: Component,
|
|
612
|
-
args: [{ selector: 'ngs-edit-link', imports: [
|
|
613
|
-
FormsModule,
|
|
614
|
-
Button,
|
|
615
|
-
DialogActions,
|
|
616
|
-
DialogContent,
|
|
617
|
-
DialogTitle,
|
|
618
|
-
FormField,
|
|
619
|
-
Input,
|
|
620
|
-
Label,
|
|
621
|
-
SlideToggle,
|
|
622
|
-
ReactiveFormsModule,
|
|
623
|
-
Hint
|
|
624
|
-
], 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" }]
|
|
625
|
-
}] });
|
|
626
|
-
|
|
627
|
-
class TextColorComponent {
|
|
628
|
-
_document = inject(DOCUMENT);
|
|
629
|
-
recentlyUsed = model(this._getRecentlyUsed(), /* @ts-ignore */
|
|
630
|
-
...(ngDevMode ? [{ debugName: "recentlyUsed" }] : /* istanbul ignore next */ []));
|
|
631
|
-
selectedTextColor = model(null, /* @ts-ignore */
|
|
632
|
-
...(ngDevMode ? [{ debugName: "selectedTextColor" }] : /* istanbul ignore next */ []));
|
|
633
|
-
selectedBackgroundColor = model(null, /* @ts-ignore */
|
|
634
|
-
...(ngDevMode ? [{ debugName: "selectedBackgroundColor" }] : /* istanbul ignore next */ []));
|
|
635
|
-
textColors = input([
|
|
636
|
-
{
|
|
637
|
-
name: 'Default',
|
|
638
|
-
color: '',
|
|
639
|
-
type: 'text'
|
|
640
|
-
},
|
|
641
|
-
{
|
|
642
|
-
name: 'Gray',
|
|
643
|
-
color: '#7f7f7f',
|
|
644
|
-
type: 'text'
|
|
645
|
-
},
|
|
646
|
-
{
|
|
647
|
-
name: 'Brown',
|
|
648
|
-
color: '#ae2012',
|
|
649
|
-
type: 'text'
|
|
650
|
-
},
|
|
651
|
-
{
|
|
652
|
-
name: 'Orange',
|
|
653
|
-
color: '#fb5607',
|
|
654
|
-
type: 'text'
|
|
655
|
-
},
|
|
656
|
-
{
|
|
657
|
-
name: 'Yellow',
|
|
658
|
-
color: '#ffa200',
|
|
659
|
-
type: 'text'
|
|
660
|
-
},
|
|
661
|
-
{
|
|
662
|
-
name: 'Green',
|
|
663
|
-
color: '#40916c',
|
|
664
|
-
type: 'text'
|
|
665
|
-
},
|
|
666
|
-
{
|
|
667
|
-
name: 'Blue',
|
|
668
|
-
color: '#00bbf9',
|
|
669
|
-
type: 'text'
|
|
670
|
-
},
|
|
671
|
-
{
|
|
672
|
-
name: 'Purple',
|
|
673
|
-
color: '#907ad6',
|
|
674
|
-
type: 'text'
|
|
675
|
-
},
|
|
676
|
-
{
|
|
677
|
-
name: 'Pink',
|
|
678
|
-
color: '#fa3faf',
|
|
679
|
-
type: 'text'
|
|
680
|
-
},
|
|
681
|
-
{
|
|
682
|
-
name: 'Red',
|
|
683
|
-
color: '#ef233c',
|
|
684
|
-
type: 'text'
|
|
685
|
-
}
|
|
686
|
-
], /* @ts-ignore */
|
|
687
|
-
...(ngDevMode ? [{ debugName: "textColors" }] : /* istanbul ignore next */ []));
|
|
688
|
-
backgroundColors = input([
|
|
689
|
-
{
|
|
690
|
-
name: 'Default',
|
|
691
|
-
color: '',
|
|
692
|
-
type: 'background'
|
|
693
|
-
},
|
|
694
|
-
{
|
|
695
|
-
name: 'Gray',
|
|
696
|
-
color: '#e9ecef',
|
|
697
|
-
type: 'background'
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
name: 'Brown',
|
|
701
|
-
color: '#ffe0c0',
|
|
702
|
-
type: 'background'
|
|
703
|
-
},
|
|
704
|
-
{
|
|
705
|
-
name: 'Orange',
|
|
706
|
-
color: '#ffd8c6',
|
|
707
|
-
type: 'background'
|
|
708
|
-
},
|
|
709
|
-
{
|
|
710
|
-
name: 'Yellow',
|
|
711
|
-
color: '#fff3b0',
|
|
712
|
-
type: 'background'
|
|
713
|
-
},
|
|
714
|
-
{
|
|
715
|
-
name: 'Green',
|
|
716
|
-
color: '#eff6e0',
|
|
717
|
-
type: 'background'
|
|
718
|
-
},
|
|
719
|
-
{
|
|
720
|
-
name: 'Blue',
|
|
721
|
-
color: '#edf6f9',
|
|
722
|
-
type: 'background'
|
|
723
|
-
},
|
|
724
|
-
{
|
|
725
|
-
name: 'Purple',
|
|
726
|
-
color: '#e0aaff',
|
|
727
|
-
type: 'background'
|
|
728
|
-
},
|
|
729
|
-
{
|
|
730
|
-
name: 'Pink',
|
|
731
|
-
color: '#fae0ec',
|
|
732
|
-
type: 'background'
|
|
733
|
-
},
|
|
734
|
-
{
|
|
735
|
-
name: 'Red',
|
|
736
|
-
color: '#ffdccc',
|
|
737
|
-
type: 'background'
|
|
738
|
-
}
|
|
739
|
-
], /* @ts-ignore */
|
|
740
|
-
...(ngDevMode ? [{ debugName: "backgroundColors" }] : /* istanbul ignore next */ []));
|
|
741
|
-
textColorChanged = output();
|
|
742
|
-
backgroundColorChanged = output();
|
|
743
|
-
selectRecentlyColor(color) {
|
|
744
|
-
if (color.type === 'text') {
|
|
745
|
-
this.selectTextColor(color);
|
|
746
|
-
}
|
|
747
|
-
else if (color.type === 'background') {
|
|
748
|
-
this.selectBackgroundColor(color);
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
selectTextColor(color) {
|
|
752
|
-
this.selectedTextColor.set(color);
|
|
753
|
-
this.textColorChanged.emit(color.color);
|
|
754
|
-
this._addToRecently(color);
|
|
755
|
-
}
|
|
756
|
-
selectBackgroundColor(color) {
|
|
757
|
-
this.selectedBackgroundColor.set(color);
|
|
758
|
-
this.backgroundColorChanged.emit(color.color);
|
|
759
|
-
this._addToRecently(color);
|
|
760
|
-
}
|
|
761
|
-
_addToRecently(color) {
|
|
762
|
-
const hasRecentlyUsed = this.recentlyUsed()
|
|
763
|
-
.filter(recentlyColor => recentlyColor.name === color.name && recentlyColor.type === color.type)
|
|
764
|
-
.length > 0;
|
|
765
|
-
if (hasRecentlyUsed) {
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
let colors = [...this.recentlyUsed()];
|
|
769
|
-
colors = colors.length >= 5 ? colors.slice(1, 5) : colors;
|
|
770
|
-
this.recentlyUsed.set([...colors, color]);
|
|
771
|
-
try {
|
|
772
|
-
this._document.defaultView?.localStorage.setItem('ngsContentEditorRecentlyUsedTextColor', JSON.stringify(this.recentlyUsed()));
|
|
773
|
-
}
|
|
774
|
-
catch {
|
|
775
|
-
// Keep the recent colors in memory when browser storage is unavailable.
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
_getRecentlyUsed() {
|
|
779
|
-
try {
|
|
780
|
-
const value = this._document.defaultView?.localStorage.getItem('ngsContentEditorRecentlyUsedTextColor');
|
|
781
|
-
const colors = value ? JSON.parse(value) : [];
|
|
782
|
-
return Array.isArray(colors) ? colors : [];
|
|
783
|
-
}
|
|
784
|
-
catch {
|
|
785
|
-
return [];
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: TextColorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
789
|
-
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 });
|
|
790
|
-
}
|
|
791
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: TextColorComponent, decorators: [{
|
|
792
|
-
type: Component,
|
|
793
|
-
args: [{ selector: 'ngs-text-color', imports: [
|
|
794
|
-
Icon,
|
|
795
|
-
Tooltip
|
|
796
|
-
], 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"] }]
|
|
797
|
-
}], 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"] }] } });
|
|
798
|
-
|
|
799
|
-
class CommandBarComponent {
|
|
800
|
-
_document = inject(DOCUMENT$1);
|
|
801
|
-
_textHighlightService = inject(TextHighlightService);
|
|
802
|
-
_renderer = inject(Renderer2);
|
|
803
|
-
_dialog = inject(Dialog);
|
|
804
|
-
observedElement = null;
|
|
805
|
-
_linkDialogOpen = false;
|
|
806
|
-
props = signal([], /* @ts-ignore */
|
|
807
|
-
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
808
|
-
alignment = computed(() => {
|
|
809
|
-
const alignment = this.props().find(prop => prop.name === 'text-alignment');
|
|
810
|
-
return alignment?.value || 'left';
|
|
811
|
-
}, /* @ts-ignore */
|
|
812
|
-
...(ngDevMode ? [{ debugName: "alignment" }] : /* istanbul ignore next */ []));
|
|
813
|
-
ngOnInit() {
|
|
814
|
-
this._extractProps();
|
|
815
|
-
}
|
|
816
|
-
toggleBold() {
|
|
817
|
-
this._textHighlightService.toggleWrapSelection('strong');
|
|
818
|
-
}
|
|
819
|
-
toggleItalic() {
|
|
820
|
-
this._textHighlightService.toggleWrapSelection('em');
|
|
821
|
-
}
|
|
822
|
-
toggleCode() {
|
|
823
|
-
this._textHighlightService.toggleWrapSelection('code', undefined, ['code']);
|
|
824
|
-
}
|
|
825
|
-
toggleStrike() {
|
|
826
|
-
this._textHighlightService.toggleWrapSelection('s');
|
|
827
|
-
}
|
|
828
|
-
toggleUnderline() {
|
|
829
|
-
this._textHighlightService.toggleWrapSelection('u');
|
|
830
|
-
}
|
|
831
|
-
toggleSuperscript() {
|
|
832
|
-
this._textHighlightService.toggleWrapSelection('sup');
|
|
833
|
-
}
|
|
834
|
-
toggleSubscript() {
|
|
835
|
-
this._textHighlightService.toggleWrapSelection('sub');
|
|
836
|
-
}
|
|
837
|
-
isLinkActive() {
|
|
838
|
-
const fakeSelection = this._document.querySelector('.link-selection');
|
|
839
|
-
if (fakeSelection) {
|
|
840
|
-
return true;
|
|
841
|
-
}
|
|
842
|
-
return this._textHighlightService.isSelectionWrappedInTag('a');
|
|
843
|
-
}
|
|
844
|
-
isActive(tagName) {
|
|
845
|
-
return this._textHighlightService.isSelectionWrappedInTag(tagName);
|
|
846
|
-
}
|
|
847
|
-
setTextAlignment(alignment) {
|
|
848
|
-
this._textHighlightService.setTextAlignment(alignment);
|
|
849
|
-
this._extractProps();
|
|
850
|
-
}
|
|
851
|
-
isTextAlignment(alignment) {
|
|
852
|
-
return this.alignment() === alignment;
|
|
853
|
-
}
|
|
854
|
-
addLink() {
|
|
855
|
-
this._textHighlightService.toggleWrapSelection('span', undefined, ['link-selection']);
|
|
856
|
-
this._linkDialogOpen = true;
|
|
857
|
-
const dialogRef = this._dialog.open(AddLinkDialog, {
|
|
858
|
-
width: '500px',
|
|
859
|
-
disableClose: true,
|
|
860
|
-
hasBackdrop: true
|
|
861
|
-
});
|
|
862
|
-
dialogRef.afterClosed().subscribe((res) => {
|
|
863
|
-
this._linkDialogOpen = false;
|
|
864
|
-
this._textHighlightService.unwrapElementByClassAndSelectContents('link-selection');
|
|
865
|
-
if (res && res.href) {
|
|
866
|
-
this._textHighlightService.toggleWrapSelection('a', undefined, ['link'], {
|
|
867
|
-
href: res.href,
|
|
868
|
-
target: res.openInNewTab ? '_blank' : '_self'
|
|
869
|
-
});
|
|
870
|
-
}
|
|
871
|
-
});
|
|
872
|
-
}
|
|
873
|
-
editLink() {
|
|
874
|
-
const link = this._textHighlightService.getContainingAncestorByTagName('a');
|
|
875
|
-
this._textHighlightService.toggleWrapSelection('span', undefined, ['link-selection']);
|
|
876
|
-
if (!link) {
|
|
877
|
-
return;
|
|
878
|
-
}
|
|
879
|
-
this._linkDialogOpen = true;
|
|
880
|
-
const dialogRef = this._dialog.open(EditLinkDialog, {
|
|
881
|
-
data: {
|
|
882
|
-
href: link.getAttribute('href'),
|
|
883
|
-
openInNewTab: link.getAttribute('target') === '_blank',
|
|
884
|
-
},
|
|
885
|
-
width: '500px',
|
|
886
|
-
disableClose: true,
|
|
887
|
-
hasBackdrop: true
|
|
888
|
-
});
|
|
889
|
-
dialogRef.afterClosed().subscribe((res) => {
|
|
890
|
-
this._linkDialogOpen = false;
|
|
891
|
-
this._textHighlightService.unwrapElementByClassAndSelectContents('link-selection');
|
|
892
|
-
if (res) {
|
|
893
|
-
if (res.href) {
|
|
894
|
-
this._renderer.setAttribute(link, 'href', res.href);
|
|
895
|
-
this._renderer.setAttribute(link, 'target', res.openInNewTab ? '_blank' : '_self');
|
|
896
|
-
}
|
|
897
|
-
else {
|
|
898
|
-
this._textHighlightService.toggleWrapSelection('a');
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
onMenuOpen() {
|
|
904
|
-
this._textHighlightService.wrapSelection('span', undefined, ['text-selection']);
|
|
905
|
-
}
|
|
906
|
-
onMenuClose() {
|
|
907
|
-
let textSelectionElement = this._document.querySelector('.text-selection');
|
|
908
|
-
if (textSelectionElement) {
|
|
909
|
-
if (textSelectionElement.style.color || textSelectionElement.style.backgroundColor) {
|
|
910
|
-
this._renderer.removeClass(textSelectionElement, 'text-selection');
|
|
911
|
-
}
|
|
912
|
-
else {
|
|
913
|
-
this._textHighlightService.unwrapElementByClassAndSelectContents('text-selection');
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
preventMenuClose(event) {
|
|
918
|
-
event.stopPropagation();
|
|
919
|
-
event.preventDefault();
|
|
920
|
-
}
|
|
921
|
-
onTextColorChanged(color) {
|
|
922
|
-
let textSelectionElement = this._document.querySelector('.text-selection');
|
|
923
|
-
if (color) {
|
|
924
|
-
this._renderer.setStyle(textSelectionElement, 'color', color);
|
|
925
|
-
}
|
|
926
|
-
else {
|
|
927
|
-
this._renderer.removeStyle(textSelectionElement, 'color');
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
onBackgroundColorChanged(color) {
|
|
931
|
-
let textSelectionElement = this._document.querySelector('.text-selection');
|
|
932
|
-
if (color) {
|
|
933
|
-
this._renderer.setStyle(textSelectionElement, 'backgroundColor', color);
|
|
934
|
-
}
|
|
935
|
-
else {
|
|
936
|
-
this._renderer.removeStyle(textSelectionElement, 'backgroundColor');
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
_extractProps() {
|
|
940
|
-
if (!this.observedElement) {
|
|
941
|
-
return;
|
|
942
|
-
}
|
|
943
|
-
const props = [];
|
|
944
|
-
for (const attribute of this.observedElement.attributes) {
|
|
945
|
-
if (!attribute.name.startsWith('data-props-')) {
|
|
946
|
-
continue;
|
|
947
|
-
}
|
|
948
|
-
const prop = {
|
|
949
|
-
name: attribute.name.replace('data-props-', ''),
|
|
950
|
-
value: attribute.value
|
|
951
|
-
};
|
|
952
|
-
props.push(prop);
|
|
953
|
-
}
|
|
954
|
-
this.props.set(props);
|
|
955
|
-
}
|
|
956
|
-
ngOnDestroy() {
|
|
957
|
-
if (!this._linkDialogOpen) {
|
|
958
|
-
this._textHighlightService.unwrapElementByClassAndSelectContents('link-selection');
|
|
959
|
-
}
|
|
960
|
-
this._unwrapTextSelection();
|
|
961
|
-
}
|
|
962
|
-
_unwrapTextSelection() {
|
|
963
|
-
let textSelectionElement = this._document.querySelector('.text-selection');
|
|
964
|
-
if (textSelectionElement) {
|
|
965
|
-
if (!textSelectionElement.style.color && !textSelectionElement.style.backgroundColor) {
|
|
966
|
-
this._textHighlightService.unwrapElementByClassAndSelectContents('text-selection');
|
|
967
|
-
}
|
|
968
|
-
else {
|
|
969
|
-
this._renderer.removeClass(textSelectionElement, 'text-selection');
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: CommandBarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
974
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: CommandBarComponent, isStandalone: true, selector: "ngs-command-bar", inputs: { observedElement: "observedElement" }, host: { 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 @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\" (menuOpened)=\"onMenuOpen()\">\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\" (closed)=\"onMenuClose()\">\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-surface-container);border-radius:calc(var(--spacing, .25rem) * 3);padding:var(--spacing, .25rem);box-shadow:var(--ngs-shadow-lg)}:host button.is-active{background:var(--ngs-color-surface-container-highest);color:var(--ngs-color-primary)}\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"], 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.Eager });
|
|
975
|
-
}
|
|
976
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: CommandBarComponent, decorators: [{
|
|
977
|
-
type: Component,
|
|
978
|
-
args: [{ selector: 'ngs-command-bar', imports: [
|
|
979
|
-
Button,
|
|
980
|
-
Icon,
|
|
981
|
-
Menu,
|
|
982
|
-
MenuItem,
|
|
983
|
-
MenuTrigger,
|
|
984
|
-
TextColorComponent
|
|
985
|
-
], changeDetection: ChangeDetectionStrategy.Eager, host: {
|
|
986
|
-
'class': 'ngs-command-bar'
|
|
987
|
-
}, 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 @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\" (menuOpened)=\"onMenuOpen()\">\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\" (closed)=\"onMenuClose()\">\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-surface-container);border-radius:calc(var(--spacing, .25rem) * 3);padding:var(--spacing, .25rem);box-shadow:var(--ngs-shadow-lg)}:host button.is-active{background:var(--ngs-color-surface-container-highest);color:var(--ngs-color-primary)}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
|
|
988
|
-
}], propDecorators: { observedElement: [{
|
|
989
|
-
type: Input$1
|
|
990
|
-
}] } });
|
|
991
|
-
|
|
992
|
-
const CONTENT_BUILDER = new InjectionToken('CONTENT_BUILDER');
|
|
993
|
-
const CONTENT_EDITOR_BLOCK = new InjectionToken('CONTENT_EDITOR_BLOCK');
|
|
994
|
-
|
|
995
|
-
const initialState = {
|
|
996
|
-
focusedBlockId: null,
|
|
997
|
-
activeBlockId: null,
|
|
998
|
-
blocks: []
|
|
999
|
-
};
|
|
1000
|
-
const ContentBuilderStore = signalStore(withState(initialState), withMethods((store) => ({
|
|
1001
|
-
setFocusedBlockId(focusedBlockId) {
|
|
1002
|
-
patchState(store, (state) => ({ focusedBlockId }));
|
|
1003
|
-
},
|
|
1004
|
-
setActiveBlockId(activeBlockId) {
|
|
1005
|
-
patchState(store, (state) => ({ activeBlockId }));
|
|
1006
|
-
},
|
|
1007
|
-
setBlocks(blocks) {
|
|
1008
|
-
patchState(store, (state) => ({ blocks }));
|
|
1009
|
-
},
|
|
1010
|
-
addBlock(dataBlock, index) {
|
|
1011
|
-
patchState(store, (state) => {
|
|
1012
|
-
const blocks = [...state.blocks];
|
|
1013
|
-
blocks.splice(index, 0, dataBlock);
|
|
1014
|
-
return {
|
|
1015
|
-
blocks
|
|
1016
|
-
};
|
|
1017
|
-
});
|
|
1018
|
-
},
|
|
1019
|
-
deleteBlock(blockId, index) {
|
|
1020
|
-
patchState(store, (state) => {
|
|
1021
|
-
const blocks = [...state.blocks];
|
|
1022
|
-
blocks.splice(index, 1);
|
|
1023
|
-
return {
|
|
1024
|
-
blocks
|
|
1025
|
-
};
|
|
1026
|
-
});
|
|
1027
|
-
},
|
|
1028
|
-
updateBlock(blockId, data) {
|
|
1029
|
-
patchState(store, (state) => {
|
|
1030
|
-
const blocks = [...state.blocks];
|
|
1031
|
-
const index = blocks.findIndex(block => block.id === blockId);
|
|
1032
|
-
if (index !== -1) {
|
|
1033
|
-
blocks[index] = {
|
|
1034
|
-
...blocks[index],
|
|
1035
|
-
...data
|
|
1036
|
-
};
|
|
1037
|
-
}
|
|
1038
|
-
return {
|
|
1039
|
-
blocks
|
|
1040
|
-
};
|
|
1041
|
-
});
|
|
1042
|
-
},
|
|
1043
|
-
moveBlock(fromIndex, toIndex) {
|
|
1044
|
-
patchState(store, (state) => {
|
|
1045
|
-
const newBlocks = [...state.blocks];
|
|
1046
|
-
const [movedItem] = newBlocks.splice(fromIndex, 1);
|
|
1047
|
-
newBlocks.splice(toIndex, 0, movedItem);
|
|
1048
|
-
return {
|
|
1049
|
-
...state,
|
|
1050
|
-
blocks: newBlocks,
|
|
1051
|
-
};
|
|
1052
|
-
});
|
|
1053
|
-
},
|
|
1054
|
-
})));
|
|
1055
|
-
|
|
1056
|
-
// src/app/text-selection-popup.directive.ts
|
|
1057
|
-
const POPUP_VERTICAL_OFFSET = 8;
|
|
1058
|
-
class TextSelectionPopupDirective {
|
|
1059
|
-
overlay;
|
|
1060
|
-
viewContainerRef;
|
|
1061
|
-
elementRef;
|
|
1062
|
-
renderer;
|
|
1063
|
-
overlayContainer;
|
|
1064
|
-
ngZone;
|
|
1065
|
-
targetComponent;
|
|
1066
|
-
closestContentObserverClass = null;
|
|
1067
|
-
tagSelected = new EventEmitter();
|
|
1068
|
-
overlayRef = null;
|
|
1069
|
-
hostElement;
|
|
1070
|
-
currentSelectionRange = null;
|
|
1071
|
-
documentClickListener = null;
|
|
1072
|
-
positionStrategy = null;
|
|
1073
|
-
scrollListener = null;
|
|
1074
|
-
scrollSubject = new Subject();
|
|
1075
|
-
scrollSubscription = null;
|
|
1076
|
-
constructor(overlay, viewContainerRef, elementRef, renderer, overlayContainer, ngZone) {
|
|
1077
|
-
this.overlay = overlay;
|
|
1078
|
-
this.viewContainerRef = viewContainerRef;
|
|
1079
|
-
this.elementRef = elementRef;
|
|
1080
|
-
this.renderer = renderer;
|
|
1081
|
-
this.overlayContainer = overlayContainer;
|
|
1082
|
-
this.ngZone = ngZone;
|
|
1083
|
-
this.hostElement = this.elementRef.nativeElement;
|
|
1084
|
-
this.scrollSubscription = this.scrollSubject.pipe(throttleTime(50, undefined, { leading: true, trailing: true })).subscribe(() => {
|
|
1085
|
-
this.updatePopupPositionOnScroll();
|
|
1086
|
-
});
|
|
1087
|
-
}
|
|
1088
|
-
onDocumentClickHostListener(event) {
|
|
1089
|
-
if (event.target.closest('.cdk-overlay-container')) {
|
|
1090
|
-
return;
|
|
1091
|
-
}
|
|
1092
|
-
this.processSelection();
|
|
1093
|
-
}
|
|
1094
|
-
onDocumentKeyDown(event) {
|
|
1095
|
-
if (!this.overlayRef)
|
|
1096
|
-
return;
|
|
1097
|
-
if (this.isEventInsidePopup(event))
|
|
1098
|
-
return;
|
|
1099
|
-
const ignoredKeys = [
|
|
1100
|
-
'Shift', 'Control', 'Alt', 'Meta', 'CapsLock',
|
|
1101
|
-
'Escape', 'Tab',
|
|
1102
|
-
'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight',
|
|
1103
|
-
'Home', 'End', 'PageUp', 'PageDown',
|
|
1104
|
-
'Insert', 'ContextMenu',
|
|
1105
|
-
'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12'
|
|
1106
|
-
];
|
|
1107
|
-
if (ignoredKeys.includes(event.key)) {
|
|
1108
|
-
setTimeout(() => this.processSelection(), 0);
|
|
1109
|
-
return;
|
|
1110
|
-
}
|
|
1111
|
-
if (event.target.closest('.cdk-overlay-container')) {
|
|
1112
|
-
return;
|
|
1113
|
-
}
|
|
1114
|
-
this.closePopup();
|
|
1115
|
-
}
|
|
1116
|
-
processSelection() {
|
|
1117
|
-
const selection = window.getSelection();
|
|
1118
|
-
if (!selection || selection.isCollapsed || selection.rangeCount === 0) {
|
|
1119
|
-
if (this.overlayRef && !this.isFocusInsidePopup()) {
|
|
1120
|
-
this.closePopup();
|
|
1121
|
-
}
|
|
1122
|
-
this.currentSelectionRange = null;
|
|
1123
|
-
return;
|
|
1124
|
-
}
|
|
1125
|
-
const range = selection.getRangeAt(0);
|
|
1126
|
-
if (!this.hostElement.contains(range.startContainer) || !this.hostElement.contains(range.endContainer)) {
|
|
1127
|
-
this.closePopupIfNeeded();
|
|
1128
|
-
this.currentSelectionRange = null;
|
|
1129
|
-
return;
|
|
1130
|
-
}
|
|
1131
|
-
let observedElement = null;
|
|
1132
|
-
if (this.closestContentObserverClass) {
|
|
1133
|
-
observedElement = this.findClosestElementWithClass(range.startContainer, this.closestContentObserverClass);
|
|
1134
|
-
if (!observedElement) {
|
|
1135
|
-
this.closePopupIfNeeded();
|
|
1136
|
-
this.currentSelectionRange = null;
|
|
1137
|
-
return;
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
const selectedText = selection.toString().trim();
|
|
1141
|
-
if (selectedText) {
|
|
1142
|
-
const selectionRects = range.getClientRects();
|
|
1143
|
-
if (selectionRects.length > 0) {
|
|
1144
|
-
const startRect = selectionRects[0];
|
|
1145
|
-
const lastRect = selectionRects[selectionRects.length - 1];
|
|
1146
|
-
const hostRect = this.hostElement.getBoundingClientRect();
|
|
1147
|
-
const hostCenterX = hostRect.left + hostRect.width / 2;
|
|
1148
|
-
const selectionStartX = startRect.left;
|
|
1149
|
-
const selectionEndX = lastRect.right;
|
|
1150
|
-
const selectionCenterX = selectionStartX + (selectionEndX - selectionStartX) / 2;
|
|
1151
|
-
const alignRight = selectionCenterX >= hostCenterX;
|
|
1152
|
-
const scrollX = document.body.scrollLeft;
|
|
1153
|
-
const scrollY = document.body.scrollTop;
|
|
1154
|
-
const anchorX = selectionStartX + scrollX;
|
|
1155
|
-
const endX = selectionEndX + scrollX;
|
|
1156
|
-
const anchorY = startRect.top + scrollY;
|
|
1157
|
-
const containingTagName = this.getContainingTagName(range);
|
|
1158
|
-
const newRange = range.cloneRange();
|
|
1159
|
-
if (!this.overlayRef || !this.areRangesEqual(this.currentSelectionRange, newRange)) {
|
|
1160
|
-
this.closePopupIfNeeded();
|
|
1161
|
-
this.currentSelectionRange = newRange;
|
|
1162
|
-
this.showPopup({ x: anchorX, y: anchorY }, endX, alignRight, observedElement);
|
|
1163
|
-
this.tagSelected.emit(containingTagName);
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
else {
|
|
1167
|
-
this.closePopupIfNeeded();
|
|
1168
|
-
this.currentSelectionRange = null;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
else {
|
|
1172
|
-
this.closePopupIfNeeded();
|
|
1173
|
-
this.currentSelectionRange = null;
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
showPopup(anchorPosition, selectionEndX, alignRight, observedElement) {
|
|
1177
|
-
if (!this.targetComponent || this.overlayRef)
|
|
1178
|
-
return;
|
|
1179
|
-
this.positionStrategy = this.overlay.position().global();
|
|
1180
|
-
this.positionStrategy.left(`${anchorPosition.x}px`).top(`${anchorPosition.y}px`);
|
|
1181
|
-
this.overlayRef = this.overlay.create({
|
|
1182
|
-
positionStrategy: this.positionStrategy,
|
|
1183
|
-
hasBackdrop: false,
|
|
1184
|
-
scrollStrategy: this.overlay.scrollStrategies.noop(),
|
|
1185
|
-
});
|
|
1186
|
-
const portal = new ComponentPortal(this.targetComponent, this.viewContainerRef);
|
|
1187
|
-
const componentRef = this.overlayRef.attach(portal);
|
|
1188
|
-
if (componentRef.instance && 'observedElement' in componentRef.instance) {
|
|
1189
|
-
componentRef.instance.observedElement = observedElement;
|
|
1190
|
-
}
|
|
1191
|
-
if (this.overlayRef) {
|
|
1192
|
-
Promise.resolve().then(() => {
|
|
1193
|
-
if (this.overlayRef && this.positionStrategy) {
|
|
1194
|
-
try {
|
|
1195
|
-
const overlayElement = this.overlayRef.overlayElement;
|
|
1196
|
-
const popupHeight = overlayElement.offsetHeight;
|
|
1197
|
-
const popupWidth = overlayElement.offsetWidth;
|
|
1198
|
-
if (popupHeight > 0 && popupWidth > 0) {
|
|
1199
|
-
const correctTop = anchorPosition.y - popupHeight - POPUP_VERTICAL_OFFSET;
|
|
1200
|
-
const correctLeft = alignRight ? selectionEndX - popupWidth : anchorPosition.x;
|
|
1201
|
-
this.positionStrategy.left(`${correctLeft}px`).top(`${correctTop}px`);
|
|
1202
|
-
this.overlayRef.updatePosition();
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
catch (e) {
|
|
1206
|
-
console.error("Error correcting initial popup position:", e);
|
|
1207
|
-
}
|
|
1208
|
-
this.addDocumentClickListener();
|
|
1209
|
-
this.addScrollListener();
|
|
1210
|
-
}
|
|
1211
|
-
});
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
closePopupIfNeeded() {
|
|
1215
|
-
if (this.overlayRef) {
|
|
1216
|
-
this.closePopup();
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
closePopup() {
|
|
1220
|
-
if (!this.overlayRef)
|
|
1221
|
-
return;
|
|
1222
|
-
this.overlayRef.dispose();
|
|
1223
|
-
this.overlayRef = null;
|
|
1224
|
-
this.positionStrategy = null;
|
|
1225
|
-
this.currentSelectionRange = null;
|
|
1226
|
-
this.removeDocumentClickListener();
|
|
1227
|
-
this.removeScrollListener();
|
|
1228
|
-
}
|
|
1229
|
-
addScrollListener() {
|
|
1230
|
-
if (this.scrollListener)
|
|
1231
|
-
return;
|
|
1232
|
-
this.ngZone.runOutsideAngular(() => {
|
|
1233
|
-
this.scrollListener = this.renderer.listen(document, 'scroll', (event) => {
|
|
1234
|
-
this.scrollSubject.next();
|
|
1235
|
-
});
|
|
1236
|
-
});
|
|
1237
|
-
}
|
|
1238
|
-
removeScrollListener() {
|
|
1239
|
-
if (this.scrollListener) {
|
|
1240
|
-
this.scrollListener();
|
|
1241
|
-
this.scrollListener = null;
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
updatePopupPositionOnScroll() {
|
|
1245
|
-
if (!this.overlayRef || !this.positionStrategy || !this.currentSelectionRange)
|
|
1246
|
-
return;
|
|
1247
|
-
try {
|
|
1248
|
-
const selectionRects = this.currentSelectionRange.getClientRects();
|
|
1249
|
-
if (selectionRects.length > 0) {
|
|
1250
|
-
const startRect = selectionRects[0];
|
|
1251
|
-
const lastRect = selectionRects[selectionRects.length - 1];
|
|
1252
|
-
const hostRect = this.hostElement.getBoundingClientRect();
|
|
1253
|
-
const hostCenterX = hostRect.left + hostRect.width / 2;
|
|
1254
|
-
const selectionStartX = startRect.left;
|
|
1255
|
-
const selectionEndX = lastRect.right;
|
|
1256
|
-
const selectionCenterX = selectionStartX + (selectionEndX - selectionStartX) / 2;
|
|
1257
|
-
const alignRight = selectionCenterX >= hostCenterX;
|
|
1258
|
-
const scrollX = document.body.scrollLeft;
|
|
1259
|
-
const scrollY = document.body.scrollTop;
|
|
1260
|
-
const textTop = startRect.top + scrollY;
|
|
1261
|
-
const popupElement = this.overlayRef.overlayElement;
|
|
1262
|
-
const popupHeight = popupElement.offsetHeight;
|
|
1263
|
-
const popupWidth = popupElement.offsetWidth;
|
|
1264
|
-
let newX;
|
|
1265
|
-
if (alignRight) {
|
|
1266
|
-
newX = (lastRect.right + scrollX) - popupWidth;
|
|
1267
|
-
}
|
|
1268
|
-
else {
|
|
1269
|
-
newX = startRect.left + scrollX;
|
|
1270
|
-
}
|
|
1271
|
-
const newY = textTop - popupHeight - POPUP_VERTICAL_OFFSET;
|
|
1272
|
-
this.ngZone.run(() => {
|
|
1273
|
-
if (this.overlayRef && this.positionStrategy) {
|
|
1274
|
-
this.positionStrategy.left(`${newX}px`).top(`${newY}px`);
|
|
1275
|
-
this.overlayRef.updatePosition();
|
|
1276
|
-
}
|
|
1277
|
-
});
|
|
1278
|
-
}
|
|
1279
|
-
else {
|
|
1280
|
-
this.ngZone.run(() => this.closePopup());
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
catch (e) {
|
|
1284
|
-
console.error("Error updating popup position on scroll:", e);
|
|
1285
|
-
this.ngZone.run(() => this.closePopup());
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
findClosestElementWithClass(startNode, className) {
|
|
1289
|
-
let currentNode = startNode;
|
|
1290
|
-
const hostParent = this.hostElement.parentNode;
|
|
1291
|
-
while (currentNode && currentNode !== hostParent && currentNode !== document.body && currentNode !== document.documentElement) {
|
|
1292
|
-
if (currentNode instanceof Element && currentNode.classList.contains(className)) {
|
|
1293
|
-
return currentNode;
|
|
1294
|
-
}
|
|
1295
|
-
currentNode = currentNode.parentNode;
|
|
1296
|
-
}
|
|
1297
|
-
if (this.hostElement.classList.contains(className)) {
|
|
1298
|
-
return this.hostElement;
|
|
1299
|
-
}
|
|
1300
|
-
return null;
|
|
1301
|
-
}
|
|
1302
|
-
getContainingTagName(range) {
|
|
1303
|
-
let container = range.commonAncestorContainer;
|
|
1304
|
-
while (container && container.nodeType !== Node.ELEMENT_NODE) {
|
|
1305
|
-
container = container.parentNode;
|
|
1306
|
-
}
|
|
1307
|
-
return container instanceof Element ? container.tagName : null;
|
|
1308
|
-
}
|
|
1309
|
-
addDocumentClickListener() {
|
|
1310
|
-
if (this.documentClickListener)
|
|
1311
|
-
return;
|
|
1312
|
-
this.documentClickListener = this.renderer.listen(document, 'click', (event) => {
|
|
1313
|
-
this.handleDocumentClick(event);
|
|
1314
|
-
});
|
|
1315
|
-
}
|
|
1316
|
-
removeDocumentClickListener() {
|
|
1317
|
-
if (this.documentClickListener) {
|
|
1318
|
-
this.documentClickListener();
|
|
1319
|
-
this.documentClickListener = null;
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
handleDocumentClick(event) {
|
|
1323
|
-
if (!this.overlayRef || !event.target)
|
|
1324
|
-
return;
|
|
1325
|
-
const clickedElement = event.target;
|
|
1326
|
-
if (this.isEventInsidePopup(event))
|
|
1327
|
-
return;
|
|
1328
|
-
const overlayContainerElement = this.overlayContainer.getContainerElement();
|
|
1329
|
-
if (overlayContainerElement.contains(clickedElement))
|
|
1330
|
-
return;
|
|
1331
|
-
this.closePopup();
|
|
1332
|
-
}
|
|
1333
|
-
isEventInsidePopup(event) {
|
|
1334
|
-
if (!this.overlayRef?.overlayElement || !event.target)
|
|
1335
|
-
return false;
|
|
1336
|
-
return this.overlayRef.overlayElement.contains(event.target);
|
|
1337
|
-
}
|
|
1338
|
-
isClickInsidePopup(node) {
|
|
1339
|
-
return !!this.overlayRef?.overlayElement?.contains(node);
|
|
1340
|
-
}
|
|
1341
|
-
isFocusInsidePopup() {
|
|
1342
|
-
if (!this.overlayRef?.overlayElement || !document.activeElement)
|
|
1343
|
-
return false;
|
|
1344
|
-
return this.overlayRef.overlayElement.contains(document.activeElement);
|
|
1345
|
-
}
|
|
1346
|
-
areRangesEqual(r1, r2) {
|
|
1347
|
-
if (!r1 || !r2)
|
|
1348
|
-
return r1 === r2;
|
|
1349
|
-
return (r1.commonAncestorContainer === r2.commonAncestorContainer &&
|
|
1350
|
-
r1.startContainer === r2.startContainer &&
|
|
1351
|
-
r1.endContainer === r2.endContainer &&
|
|
1352
|
-
r1.startOffset === r2.startOffset &&
|
|
1353
|
-
r1.endOffset === r2.endOffset);
|
|
1354
|
-
}
|
|
1355
|
-
ngOnDestroy() {
|
|
1356
|
-
this.closePopup();
|
|
1357
|
-
if (this.scrollSubscription) {
|
|
1358
|
-
this.scrollSubscription.unsubscribe();
|
|
1359
|
-
this.scrollSubscription = null;
|
|
1360
|
-
}
|
|
1361
|
-
this.removeDocumentClickListener();
|
|
1362
|
-
this.removeScrollListener();
|
|
1363
|
-
}
|
|
1364
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: TextSelectionPopupDirective, deps: [{ token: i1$1.Overlay }, { token: i0.ViewContainerRef }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1$1.OverlayContainer }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1365
|
-
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 });
|
|
1366
|
-
}
|
|
1367
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: TextSelectionPopupDirective, decorators: [{
|
|
1368
|
-
type: Directive,
|
|
1369
|
-
args: [{
|
|
1370
|
-
selector: '[ngsTextSelectionPopup]',
|
|
1371
|
-
}]
|
|
1372
|
-
}], ctorParameters: () => [{ type: i1$1.Overlay }, { type: i0.ViewContainerRef }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1$1.OverlayContainer }, { type: i0.NgZone }], propDecorators: { targetComponent: [{
|
|
1373
|
-
type: Input$1
|
|
1374
|
-
}], closestContentObserverClass: [{
|
|
1375
|
-
type: Input$1
|
|
1376
|
-
}], tagSelected: [{
|
|
1377
|
-
type: Output
|
|
1378
|
-
}], onDocumentClickHostListener: [{
|
|
1379
|
-
type: HostListener,
|
|
1380
|
-
args: ['document:click', ['$event']]
|
|
1381
|
-
}], onDocumentKeyDown: [{
|
|
1382
|
-
type: HostListener,
|
|
1383
|
-
args: ['document:keydown', ['$event']]
|
|
1384
|
-
}] } });
|
|
1385
|
-
|
|
1386
|
-
/**
|
|
1387
|
-
* Directive to enable mouse-drag selection of child blocks inside a container.
|
|
1388
|
-
*
|
|
1389
|
-
* Behavior:
|
|
1390
|
-
* - Drag can be started only from an area that is NOT inside a block (matched by `blockSelector`).
|
|
1391
|
-
* - While dragging, the directive creates a dynamic selection rectangle element with the
|
|
1392
|
-
* class `selectionAreaClass` (default: `ngs-textContent-builder-selection-area`).
|
|
1393
|
-
* - Any block that intersects the selection rectangle receives `selectedClass` (default: `is-selected`).
|
|
1394
|
-
* When the block leaves the selection area, the class is removed.
|
|
1395
|
-
*/
|
|
1396
|
-
class BlockSelectionDirective {
|
|
1397
|
-
document = inject(DOCUMENT$1);
|
|
1398
|
-
_platformId = inject(PLATFORM_ID);
|
|
1399
|
-
contentBuilder = inject(CONTENT_BUILDER);
|
|
1400
|
-
/** CSS selector for selectable blocks. Defaults to `.block`. */
|
|
1401
|
-
blockSelector = input('.block-content', /* @ts-ignore */
|
|
1402
|
-
...(ngDevMode ? [{ debugName: "blockSelector" }] : /* istanbul ignore next */ []));
|
|
1403
|
-
autoScrollContainerSelector = input(null, /* @ts-ignore */
|
|
1404
|
-
...(ngDevMode ? [{ debugName: "autoScrollContainerSelector" }] : /* istanbul ignore next */ []));
|
|
1405
|
-
/** CSS class applied to the dynamic selection rectangle element. */
|
|
1406
|
-
selectionAreaClass = input('selection-area', /* @ts-ignore */
|
|
1407
|
-
...(ngDevMode ? [{ debugName: "selectionAreaClass" }] : /* istanbul ignore next */ []));
|
|
1408
|
-
/**
|
|
1409
|
-
* List of CSS class names to ignore when starting selection.
|
|
1410
|
-
* If the mousedown target or any of its ancestors (via closest) contains any of
|
|
1411
|
-
* these classes, the selection will NOT start. Class names can be provided with
|
|
1412
|
-
* or without leading dot (e.g., 'toolbar-button' or '.toolbar-button').
|
|
1413
|
-
*/
|
|
1414
|
-
ignoreClasses = input(['.block-controls'], /* @ts-ignore */
|
|
1415
|
-
...(ngDevMode ? [{ debugName: "ignoreClasses" }] : /* istanbul ignore next */ []));
|
|
1416
|
-
elRef = inject(ElementRef);
|
|
1417
|
-
host = this.elRef.nativeElement;
|
|
1418
|
-
selection = null;
|
|
1419
|
-
// Track only blockIds we toggled via drag selection to avoid interfering with other selection sources
|
|
1420
|
-
selectedSet = new Set();
|
|
1421
|
-
constructor() {
|
|
1422
|
-
if (isPlatformBrowser(this._platformId)) {
|
|
1423
|
-
this.selection = new SelectionArea({
|
|
1424
|
-
selectables: [this.blockSelector()],
|
|
1425
|
-
boundaries: [this.host],
|
|
1426
|
-
container: this.host,
|
|
1427
|
-
features: {
|
|
1428
|
-
touch: false,
|
|
1429
|
-
range: true,
|
|
1430
|
-
deselectOnBlur: true,
|
|
1431
|
-
singleTap: {
|
|
1432
|
-
allow: true,
|
|
1433
|
-
intersect: 'native'
|
|
1434
|
-
}
|
|
1435
|
-
},
|
|
1436
|
-
selectionAreaClass: this.selectionAreaClass()
|
|
1437
|
-
}).on('beforestart', ({ event }) => {
|
|
1438
|
-
const targetEl = event?.target;
|
|
1439
|
-
if (this.isInIgnoredArea(targetEl) || targetEl?.closest(this.blockSelector())) {
|
|
1440
|
-
return false;
|
|
1441
|
-
}
|
|
1442
|
-
if (event) {
|
|
1443
|
-
event.preventDefault();
|
|
1444
|
-
}
|
|
1445
|
-
return true;
|
|
1446
|
-
}).on('stop', () => {
|
|
1447
|
-
this.contentBuilder.isSelectionOfBlocksActive.set(false);
|
|
1448
|
-
}).on('start', ({ store, event }) => {
|
|
1449
|
-
this.contentBuilder.isSelectionOfBlocksActive.set(true);
|
|
1450
|
-
const activeElement = this.document.activeElement;
|
|
1451
|
-
if (activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA' || activeElement.isContentEditable)) {
|
|
1452
|
-
activeElement.blur();
|
|
1453
|
-
}
|
|
1454
|
-
this.host.focus();
|
|
1455
|
-
if (event && !event.ctrlKey && !event.metaKey) {
|
|
1456
|
-
this.contentBuilder.unselectSelectedBlocks();
|
|
1457
|
-
this.selectedSet.clear();
|
|
1458
|
-
}
|
|
1459
|
-
}).on('move', ({ store: { changed: { added, removed } } }) => {
|
|
1460
|
-
added.forEach(el => {
|
|
1461
|
-
const blockEl = el.closest('.block');
|
|
1462
|
-
const blockId = blockEl?.getAttribute('data-block-id');
|
|
1463
|
-
if (blockId) {
|
|
1464
|
-
this.contentBuilder.selectBlock(blockId, true);
|
|
1465
|
-
this.selectedSet.add(blockId);
|
|
1466
|
-
}
|
|
1467
|
-
});
|
|
1468
|
-
removed.forEach(el => {
|
|
1469
|
-
const blockEl = el.closest('.block');
|
|
1470
|
-
const blockId = blockEl?.getAttribute('data-block-id');
|
|
1471
|
-
if (blockId && this.selectedSet.has(blockId)) {
|
|
1472
|
-
this.contentBuilder.unselectBlock(blockId);
|
|
1473
|
-
this.selectedSet.delete(blockId);
|
|
1474
|
-
}
|
|
1475
|
-
});
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
ngOnDestroy() {
|
|
1480
|
-
this.selection?.destroy();
|
|
1481
|
-
}
|
|
1482
|
-
isInIgnoredArea(target) {
|
|
1483
|
-
const list = this.ignoreClasses();
|
|
1484
|
-
if (!target || !Array.isArray(list) || list.length === 0)
|
|
1485
|
-
return false;
|
|
1486
|
-
const normalized = list
|
|
1487
|
-
.map(c => (c ?? '').toString().trim())
|
|
1488
|
-
.filter(Boolean)
|
|
1489
|
-
.map(c => c.startsWith('.') ? c.slice(1) : c);
|
|
1490
|
-
if (normalized.length === 0)
|
|
1491
|
-
return false;
|
|
1492
|
-
let el = target;
|
|
1493
|
-
// Traverse up through ancestors to emulate "closest" semantics for class names
|
|
1494
|
-
while (el) {
|
|
1495
|
-
for (const cls of normalized) {
|
|
1496
|
-
if (el.classList && el.classList.contains(cls))
|
|
1497
|
-
return true;
|
|
1498
|
-
}
|
|
1499
|
-
el = el.parentElement;
|
|
1500
|
-
}
|
|
1501
|
-
return false;
|
|
1502
|
-
}
|
|
1503
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: BlockSelectionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1504
|
-
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 });
|
|
1505
|
-
}
|
|
1506
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: BlockSelectionDirective, decorators: [{
|
|
1507
|
-
type: Directive,
|
|
1508
|
-
args: [{
|
|
1509
|
-
selector: '[ngsBlockSelection]'
|
|
1510
|
-
}]
|
|
1511
|
-
}], 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 }] }] } });
|
|
1512
|
-
|
|
1513
|
-
class ContentBuilderComponent {
|
|
1514
|
-
static DRAFT_STORAGE_PREFIX = 'ngs-content-editor-builder:draft';
|
|
1515
|
-
_platformId = inject(PLATFORM_ID);
|
|
1516
|
-
_store = inject(ContentBuilderStore);
|
|
1517
|
-
elRef = inject((ElementRef));
|
|
1518
|
-
envInjector = inject(EnvironmentInjector);
|
|
1519
|
-
cdr = inject(ChangeDetectorRef);
|
|
1520
|
-
confirmManager = inject(ConfirmManager);
|
|
1521
|
-
_resolvedScrollContainer = null;
|
|
1522
|
-
_scrollEffect;
|
|
1523
|
-
_scrollSubject = new Subject();
|
|
1524
|
-
_scrollBindSub = null;
|
|
1525
|
-
_scroll$ = null;
|
|
1526
|
-
get scrollContainerScrolled() {
|
|
1527
|
-
if (!this._scroll$) {
|
|
1528
|
-
this._scroll$ = this._scrollSubject.asObservable().pipe(shareReplay(1));
|
|
1529
|
-
}
|
|
1530
|
-
return this._scroll$;
|
|
1531
|
-
}
|
|
1532
|
-
blockDefs = signal([
|
|
1533
|
-
{
|
|
1534
|
-
component: () => import('./ngstarter-ui-components-content-editor-divider-block.component-B5wyMHjr.mjs').then(c => c.DividerBlockComponent),
|
|
1535
|
-
type: 'divider',
|
|
1536
|
-
options: {},
|
|
1537
|
-
empty: () => {
|
|
1538
|
-
return {
|
|
1539
|
-
content: null,
|
|
1540
|
-
settings: {}
|
|
1541
|
-
};
|
|
1542
|
-
}
|
|
1543
|
-
},
|
|
1544
|
-
{
|
|
1545
|
-
component: () => import('./ngstarter-ui-components-content-editor-paragraph-block.component-CVV2f-ON.mjs').then(c => c.ParagraphBlockComponent),
|
|
1546
|
-
type: 'paragraph',
|
|
1547
|
-
options: {},
|
|
1548
|
-
empty: () => {
|
|
1549
|
-
return {
|
|
1550
|
-
content: '',
|
|
1551
|
-
props: [],
|
|
1552
|
-
settings: {}
|
|
1553
|
-
};
|
|
1554
|
-
}
|
|
1555
|
-
},
|
|
1556
|
-
{
|
|
1557
|
-
component: () => import('./ngstarter-ui-components-content-editor-code-block.component-BbK5fCoE.mjs').then(c => c.CodeBlockComponent),
|
|
1558
|
-
type: 'code',
|
|
1559
|
-
options: {},
|
|
1560
|
-
empty: () => {
|
|
1561
|
-
return {
|
|
1562
|
-
content: '',
|
|
1563
|
-
settings: {
|
|
1564
|
-
language: 'none',
|
|
1565
|
-
}
|
|
1566
|
-
};
|
|
1567
|
-
}
|
|
1568
|
-
},
|
|
1569
|
-
{
|
|
1570
|
-
component: () => import('./ngstarter-ui-components-content-editor-heading-block.component-D1s2yalT.mjs').then(c => c.HeadingBlockComponent),
|
|
1571
|
-
type: 'heading',
|
|
1572
|
-
options: {},
|
|
1573
|
-
empty: () => {
|
|
1574
|
-
return {
|
|
1575
|
-
content: '',
|
|
1576
|
-
props: [],
|
|
1577
|
-
settings: {
|
|
1578
|
-
level: 2
|
|
1579
|
-
}
|
|
1580
|
-
};
|
|
1581
|
-
}
|
|
1582
|
-
},
|
|
1583
|
-
{
|
|
1584
|
-
component: () => import('./ngstarter-ui-components-content-editor-image-block.component-D75DrPNq.mjs').then(c => c.ImageBlockComponent),
|
|
1585
|
-
type: 'image',
|
|
1586
|
-
options: {
|
|
1587
|
-
uploadFn: (file, base64) => {
|
|
1588
|
-
return new Promise((resolve) => {
|
|
1589
|
-
resolve(base64);
|
|
1590
|
-
});
|
|
1591
|
-
}
|
|
1592
|
-
},
|
|
1593
|
-
empty: () => {
|
|
1594
|
-
return {
|
|
1595
|
-
content: {
|
|
1596
|
-
src: '',
|
|
1597
|
-
alt: ''
|
|
1598
|
-
},
|
|
1599
|
-
settings: {
|
|
1600
|
-
alignment: 'center',
|
|
1601
|
-
width: 'auto',
|
|
1602
|
-
height: 'auto',
|
|
1603
|
-
align: 'center',
|
|
1604
|
-
natualWidth: 'auto',
|
|
1605
|
-
naturalHeight: 'auto'
|
|
1606
|
-
}
|
|
1607
|
-
};
|
|
1608
|
-
}
|
|
1609
|
-
},
|
|
1610
|
-
{
|
|
1611
|
-
component: () => import('./ngstarter-ui-components-content-editor-video-block.component-D3U8uXIy.mjs').then(c => c.VideoBlockComponent),
|
|
1612
|
-
type: 'video',
|
|
1613
|
-
options: {
|
|
1614
|
-
uploadFn: (file, base64) => {
|
|
1615
|
-
return new Promise((resolve) => {
|
|
1616
|
-
resolve(base64);
|
|
1617
|
-
});
|
|
1618
|
-
}
|
|
1619
|
-
},
|
|
1620
|
-
empty: () => {
|
|
1621
|
-
return {
|
|
1622
|
-
content: {
|
|
1623
|
-
src: '',
|
|
1624
|
-
caption: '',
|
|
1625
|
-
orientation: 'landscape'
|
|
1626
|
-
},
|
|
1627
|
-
settings: {
|
|
1628
|
-
alignment: 'center',
|
|
1629
|
-
width: 'auto',
|
|
1630
|
-
height: 'auto',
|
|
1631
|
-
align: 'center',
|
|
1632
|
-
natualWidth: 'auto',
|
|
1633
|
-
naturalHeight: 'auto'
|
|
1634
|
-
}
|
|
1635
|
-
};
|
|
1636
|
-
}
|
|
1637
|
-
},
|
|
1638
|
-
{
|
|
1639
|
-
component: () => import('./ngstarter-ui-components-content-editor-list-block.component-B7pDlrQ_.mjs').then(c => c.ListBlockComponent),
|
|
1640
|
-
type: 'bulletList',
|
|
1641
|
-
options: {},
|
|
1642
|
-
empty: () => {
|
|
1643
|
-
return {
|
|
1644
|
-
content: [],
|
|
1645
|
-
settings: {
|
|
1646
|
-
listStyle: 'bullet'
|
|
1647
|
-
}
|
|
1648
|
-
};
|
|
1649
|
-
}
|
|
1650
|
-
},
|
|
1651
|
-
{
|
|
1652
|
-
component: () => import('./ngstarter-ui-components-content-editor-list-block.component-B7pDlrQ_.mjs').then(c => c.ListBlockComponent),
|
|
1653
|
-
type: 'orderedList',
|
|
1654
|
-
options: {},
|
|
1655
|
-
empty: () => {
|
|
1656
|
-
return {
|
|
1657
|
-
content: [],
|
|
1658
|
-
settings: {
|
|
1659
|
-
listStyle: 'ordered'
|
|
1660
|
-
}
|
|
1661
|
-
};
|
|
1662
|
-
}
|
|
1663
|
-
},
|
|
1664
|
-
{
|
|
1665
|
-
component: () => import('./ngstarter-ui-components-content-editor-table-block.component-DSpLBC4V.mjs').then(c => c.TableBlockComponent),
|
|
1666
|
-
type: 'table',
|
|
1667
|
-
options: {},
|
|
1668
|
-
empty: () => {
|
|
1669
|
-
return {
|
|
1670
|
-
content: [
|
|
1671
|
-
[
|
|
1672
|
-
{
|
|
1673
|
-
content: '',
|
|
1674
|
-
props: [],
|
|
1675
|
-
styles: {},
|
|
1676
|
-
options: {
|
|
1677
|
-
colspan: 1,
|
|
1678
|
-
rowspan: 1
|
|
1679
|
-
},
|
|
1680
|
-
},
|
|
1681
|
-
{
|
|
1682
|
-
content: '',
|
|
1683
|
-
props: [],
|
|
1684
|
-
styles: {},
|
|
1685
|
-
options: {
|
|
1686
|
-
colspan: 1,
|
|
1687
|
-
rowspan: 1
|
|
1688
|
-
}
|
|
1689
|
-
},
|
|
1690
|
-
{
|
|
1691
|
-
content: '',
|
|
1692
|
-
props: [],
|
|
1693
|
-
styles: {},
|
|
1694
|
-
options: {
|
|
1695
|
-
colspan: 1,
|
|
1696
|
-
rowspan: 1
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
],
|
|
1700
|
-
[
|
|
1701
|
-
{
|
|
1702
|
-
content: '',
|
|
1703
|
-
props: [],
|
|
1704
|
-
styles: {},
|
|
1705
|
-
options: {
|
|
1706
|
-
colspan: 1,
|
|
1707
|
-
rowspan: 1
|
|
1708
|
-
}
|
|
1709
|
-
},
|
|
1710
|
-
{
|
|
1711
|
-
content: '',
|
|
1712
|
-
props: [],
|
|
1713
|
-
options: {
|
|
1714
|
-
colspan: 1,
|
|
1715
|
-
rowspan: 1
|
|
1716
|
-
}
|
|
1717
|
-
},
|
|
1718
|
-
{
|
|
1719
|
-
content: '',
|
|
1720
|
-
props: [],
|
|
1721
|
-
styles: {},
|
|
1722
|
-
options: {
|
|
1723
|
-
colspan: 1,
|
|
1724
|
-
rowspan: 1
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
],
|
|
1728
|
-
],
|
|
1729
|
-
settings: {}
|
|
1730
|
-
};
|
|
1731
|
-
}
|
|
1732
|
-
},
|
|
1733
|
-
{
|
|
1734
|
-
component: () => import('./ngstarter-ui-components-content-editor-quote-block.component-CVb-bkJw.mjs').then(c => c.QuoteBlockComponent),
|
|
1735
|
-
type: 'quote',
|
|
1736
|
-
options: {},
|
|
1737
|
-
empty: () => {
|
|
1738
|
-
return {
|
|
1739
|
-
content: {
|
|
1740
|
-
cite: {
|
|
1741
|
-
content: '',
|
|
1742
|
-
props: []
|
|
1743
|
-
},
|
|
1744
|
-
caption: {
|
|
1745
|
-
content: '',
|
|
1746
|
-
props: []
|
|
1747
|
-
}
|
|
1748
|
-
},
|
|
1749
|
-
settings: {}
|
|
1750
|
-
};
|
|
1751
|
-
}
|
|
1752
|
-
},
|
|
1753
|
-
{
|
|
1754
|
-
component: () => import('./ngstarter-ui-components-content-editor-embed-block-DGqupBLe.mjs').then(c => c.EmbedBlock),
|
|
1755
|
-
type: 'embed',
|
|
1756
|
-
options: {},
|
|
1757
|
-
empty: () => {
|
|
1758
|
-
return {
|
|
1759
|
-
content: {
|
|
1760
|
-
url: '',
|
|
1761
|
-
type: ''
|
|
1762
|
-
},
|
|
1763
|
-
settings: {}
|
|
1764
|
-
};
|
|
1765
|
-
}
|
|
1766
|
-
},
|
|
1767
|
-
], /* @ts-ignore */
|
|
1768
|
-
...(ngDevMode ? [{ debugName: "blockDefs" }] : /* istanbul ignore next */ []));
|
|
1769
|
-
content = input([], /* @ts-ignore */
|
|
1770
|
-
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
1771
|
-
contentChangedDelay = input(500, { ...(ngDevMode ? { debugName: "contentChangedDelay" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
1772
|
-
persistDraft = input(true, { ...(ngDevMode ? { debugName: "persistDraft" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
1773
|
-
suggestions = input([
|
|
1774
|
-
{
|
|
1775
|
-
type: 'heading',
|
|
1776
|
-
title: 'Headings',
|
|
1777
|
-
},
|
|
1778
|
-
{
|
|
1779
|
-
type: 'item',
|
|
1780
|
-
title: 'Heading 1',
|
|
1781
|
-
description: 'Top-level heading',
|
|
1782
|
-
iconName: 'fluent:text-header-1-24-regular',
|
|
1783
|
-
hotKeys: 'ALT + 1',
|
|
1784
|
-
blockType: 'heading',
|
|
1785
|
-
blockSettings: {
|
|
1786
|
-
level: 1
|
|
1787
|
-
}
|
|
1788
|
-
},
|
|
1789
|
-
{
|
|
1790
|
-
type: 'item',
|
|
1791
|
-
title: 'Heading 2',
|
|
1792
|
-
description: 'Key section heading',
|
|
1793
|
-
iconName: 'fluent:text-header-2-24-regular',
|
|
1794
|
-
hotKeys: 'ALT + 2',
|
|
1795
|
-
blockType: 'heading',
|
|
1796
|
-
blockSettings: {
|
|
1797
|
-
level: 2
|
|
1798
|
-
}
|
|
1799
|
-
},
|
|
1800
|
-
{
|
|
1801
|
-
type: 'item',
|
|
1802
|
-
title: 'Heading 3',
|
|
1803
|
-
description: 'Subsection and group heading',
|
|
1804
|
-
iconName: 'fluent:text-header-3-24-regular',
|
|
1805
|
-
hotKeys: 'ALT + 3',
|
|
1806
|
-
blockType: 'heading',
|
|
1807
|
-
blockSettings: {
|
|
1808
|
-
level: 3
|
|
1809
|
-
}
|
|
1810
|
-
},
|
|
1811
|
-
{
|
|
1812
|
-
type: 'heading',
|
|
1813
|
-
title: 'Basic blocks',
|
|
1814
|
-
},
|
|
1815
|
-
{
|
|
1816
|
-
type: 'item',
|
|
1817
|
-
title: 'Paragraph',
|
|
1818
|
-
description: 'The body of your document',
|
|
1819
|
-
iconName: 'fluent:text-paragraph-24-regular',
|
|
1820
|
-
hotKeys: 'ALT + 0',
|
|
1821
|
-
blockType: 'paragraph',
|
|
1822
|
-
blockSettings: {}
|
|
1823
|
-
},
|
|
1824
|
-
{
|
|
1825
|
-
type: 'item',
|
|
1826
|
-
title: 'Numbered List',
|
|
1827
|
-
description: 'List with ordered items',
|
|
1828
|
-
iconName: 'fluent:text-bullet-list-tree-24-regular',
|
|
1829
|
-
hotKeys: 'ALT + 0',
|
|
1830
|
-
blockType: 'orderedList',
|
|
1831
|
-
blockSettings: {}
|
|
1832
|
-
},
|
|
1833
|
-
{
|
|
1834
|
-
type: 'item',
|
|
1835
|
-
title: 'Bullet List',
|
|
1836
|
-
description: 'List with unordered items',
|
|
1837
|
-
iconName: 'fluent:text-bullet-list-ltr-24-regular',
|
|
1838
|
-
hotKeys: 'ALT + 0',
|
|
1839
|
-
blockType: 'bulletList',
|
|
1840
|
-
blockSettings: {}
|
|
1841
|
-
},
|
|
1842
|
-
{
|
|
1843
|
-
type: 'item',
|
|
1844
|
-
title: 'Quote',
|
|
1845
|
-
description: 'Quote or excerpt',
|
|
1846
|
-
iconName: 'fluent:text-quote-24-regular',
|
|
1847
|
-
hotKeys: 'ALT + 0',
|
|
1848
|
-
blockType: 'quote',
|
|
1849
|
-
blockSettings: {}
|
|
1850
|
-
},
|
|
1851
|
-
{
|
|
1852
|
-
type: 'item',
|
|
1853
|
-
title: 'Code',
|
|
1854
|
-
description: 'The code block with syntax highlighting',
|
|
1855
|
-
iconName: 'fluent:code-24-regular',
|
|
1856
|
-
hotKeys: 'ALT + 0',
|
|
1857
|
-
blockType: 'code',
|
|
1858
|
-
blockSettings: {}
|
|
1859
|
-
},
|
|
1860
|
-
{
|
|
1861
|
-
type: 'item',
|
|
1862
|
-
title: 'Divider',
|
|
1863
|
-
description: 'Visually divide blocks',
|
|
1864
|
-
iconName: 'fluent:minimize-24-regular',
|
|
1865
|
-
hotKeys: 'ALT + 0',
|
|
1866
|
-
blockType: 'divider',
|
|
1867
|
-
blockSettings: {}
|
|
1868
|
-
},
|
|
1869
|
-
{
|
|
1870
|
-
type: 'item',
|
|
1871
|
-
title: 'Table',
|
|
1872
|
-
description: 'Table with editable cells',
|
|
1873
|
-
iconName: 'fluent:table-24-regular',
|
|
1874
|
-
hotKeys: 'ALT + 0',
|
|
1875
|
-
blockType: 'table',
|
|
1876
|
-
blockSettings: {}
|
|
1877
|
-
},
|
|
1878
|
-
{
|
|
1879
|
-
type: 'heading',
|
|
1880
|
-
title: 'Media',
|
|
1881
|
-
},
|
|
1882
|
-
{
|
|
1883
|
-
type: 'item',
|
|
1884
|
-
title: 'Image',
|
|
1885
|
-
description: 'Image with caption',
|
|
1886
|
-
iconName: 'fluent:image-24-regular',
|
|
1887
|
-
hotKeys: 'ALT + 0',
|
|
1888
|
-
blockType: 'image',
|
|
1889
|
-
blockSettings: {}
|
|
1890
|
-
},
|
|
1891
|
-
{
|
|
1892
|
-
type: 'item',
|
|
1893
|
-
title: 'Video',
|
|
1894
|
-
description: 'Video with caption',
|
|
1895
|
-
iconName: 'fluent:video-24-regular',
|
|
1896
|
-
hotKeys: 'ALT + 0',
|
|
1897
|
-
blockType: 'video',
|
|
1898
|
-
blockSettings: {}
|
|
1899
|
-
},
|
|
1900
|
-
{
|
|
1901
|
-
type: 'heading',
|
|
1902
|
-
title: 'Embeds',
|
|
1903
|
-
},
|
|
1904
|
-
{
|
|
1905
|
-
type: 'item',
|
|
1906
|
-
title: 'Embed',
|
|
1907
|
-
description: 'For PDFs, Google Maps and more',
|
|
1908
|
-
iconName: 'fluent:window-24-regular',
|
|
1909
|
-
hotKeys: 'ALT + 0',
|
|
1910
|
-
blockType: 'embed',
|
|
1911
|
-
blockSettings: {
|
|
1912
|
-
width: null,
|
|
1913
|
-
height: null
|
|
1914
|
-
}
|
|
1915
|
-
},
|
|
1916
|
-
], /* @ts-ignore */
|
|
1917
|
-
...(ngDevMode ? [{ debugName: "suggestions" }] : /* istanbul ignore next */ []));
|
|
1918
|
-
options = input({}, /* @ts-ignore */
|
|
1919
|
-
...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
1920
|
-
scrollContainer = input(/* @ts-ignore */
|
|
1921
|
-
...(ngDevMode ? [undefined, { debugName: "scrollContainer" }] : /* istanbul ignore next */ []));
|
|
1922
|
-
contentChanged = output();
|
|
1923
|
-
focusChanged = new EventEmitter();
|
|
1924
|
-
_content = signal([], /* @ts-ignore */
|
|
1925
|
-
...(ngDevMode ? [{ debugName: "_content" }] : /* istanbul ignore next */ []));
|
|
1926
|
-
blockDefsMap = new Map();
|
|
1927
|
-
blockDefsOptionsMap = new Map();
|
|
1928
|
-
_blockDragging = signal(false, /* @ts-ignore */
|
|
1929
|
-
...(ngDevMode ? [{ debugName: "_blockDragging" }] : /* istanbul ignore next */ []));
|
|
1930
|
-
isSelectionOfBlocksActive = signal(false, /* @ts-ignore */
|
|
1931
|
-
...(ngDevMode ? [{ debugName: "isSelectionOfBlocksActive" }] : /* istanbul ignore next */ []));
|
|
1932
|
-
_oldContent = signal({}, /* @ts-ignore */
|
|
1933
|
-
...(ngDevMode ? [{ debugName: "_oldContent" }] : /* istanbul ignore next */ []));
|
|
1934
|
-
selectedBlocksModel = new SelectionModel(true);
|
|
1935
|
-
commandBar = CommandBarComponent;
|
|
1936
|
-
get api() {
|
|
1937
|
-
return {
|
|
1938
|
-
focusChanged: new EventEmitter(),
|
|
1939
|
-
};
|
|
1940
|
-
}
|
|
1941
|
-
// Build helper maps: component map and merged options map
|
|
1942
|
-
buildBlockDefMaps() {
|
|
1943
|
-
const overrides = this.options() || {};
|
|
1944
|
-
this.blockDefsMap = new Map();
|
|
1945
|
-
this.blockDefsOptionsMap = new Map();
|
|
1946
|
-
this.blockDefs().forEach((def) => {
|
|
1947
|
-
if (!this.blockDefsMap.has(def.type)) {
|
|
1948
|
-
this.blockDefsMap.set(def.type, def.component());
|
|
1949
|
-
}
|
|
1950
|
-
const merged = {
|
|
1951
|
-
...(def.options || {}),
|
|
1952
|
-
...(overrides[def.type] || {})
|
|
1953
|
-
};
|
|
1954
|
-
this.blockDefsOptionsMap.set(def.type, merged);
|
|
1955
|
-
});
|
|
1956
|
-
}
|
|
1957
|
-
getBlockDefOption(type, key) {
|
|
1958
|
-
return this.blockDefsOptionsMap.get(type)[key];
|
|
1959
|
-
}
|
|
1960
|
-
ngOnInit() {
|
|
1961
|
-
const draftContent = this._getDraftContent();
|
|
1962
|
-
const content = draftContent || this.content();
|
|
1963
|
-
if (content.length > 0) {
|
|
1964
|
-
const lastItem = content[content.length - 1];
|
|
1965
|
-
if (lastItem.type !== 'paragraph' || (lastItem.type === 'paragraph' && lastItem.content !== '')) {
|
|
1966
|
-
content.push(this._createBlock('paragraph'));
|
|
1967
|
-
}
|
|
1968
|
-
}
|
|
1969
|
-
else {
|
|
1970
|
-
content.push(this._createBlock('paragraph'));
|
|
1971
|
-
}
|
|
1972
|
-
this._content.set(content);
|
|
1973
|
-
this._oldContent.set(this._content());
|
|
1974
|
-
// Build block component map and merged options map
|
|
1975
|
-
this.buildBlockDefMaps();
|
|
1976
|
-
this._store.setBlocks(JSON.parse(JSON.stringify(content)));
|
|
1977
|
-
if (isPlatformServer(this._platformId)) {
|
|
1978
|
-
return;
|
|
1979
|
-
}
|
|
1980
|
-
if (content.length === 1) {
|
|
1981
|
-
this.focusBlock(content[0].id);
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
ngAfterViewInit() {
|
|
1985
|
-
if (isPlatformServer(this._platformId)) {
|
|
1986
|
-
return;
|
|
1987
|
-
}
|
|
1988
|
-
// Initial resolve after view init
|
|
1989
|
-
this._resolvedScrollContainer = this._computeScrollContainer();
|
|
1990
|
-
// Bind the scroll subscription to the current container
|
|
1991
|
-
this._rebindScrollListener();
|
|
1992
|
-
// Watch for changes of the input selector and recompute when it changes.
|
|
1993
|
-
// Create the signal effect within a valid injection context to satisfy Angular's requirement.
|
|
1994
|
-
runInInjectionContext(this.envInjector, () => {
|
|
1995
|
-
this._scrollEffect = effect(() => {
|
|
1996
|
-
const _selector = this.scrollContainer();
|
|
1997
|
-
this._resolvedScrollContainer = this._computeScrollContainer();
|
|
1998
|
-
// Rebind the listener when the container changes
|
|
1999
|
-
this._rebindScrollListener();
|
|
2000
|
-
}, /* @ts-ignore */
|
|
2001
|
-
...(ngDevMode ? [{ debugName: "_scrollEffect" }] : /* istanbul ignore next */ []));
|
|
2002
|
-
});
|
|
2003
|
-
}
|
|
2004
|
-
/**
|
|
2005
|
-
* Public accessor for the resolved scroll container. If not computed yet, it will compute now.
|
|
2006
|
-
*/
|
|
2007
|
-
getScrollContainer() {
|
|
2008
|
-
if (isPlatformServer(this._platformId)) {
|
|
2009
|
-
return {};
|
|
2010
|
-
}
|
|
2011
|
-
if (!this._resolvedScrollContainer) {
|
|
2012
|
-
this._resolvedScrollContainer = this._computeScrollContainer();
|
|
2013
|
-
}
|
|
2014
|
-
return this._resolvedScrollContainer || window;
|
|
2015
|
-
}
|
|
2016
|
-
/**
|
|
2017
|
-
* Resolves the scroll container element according to the following rules:
|
|
2018
|
-
* - If `scrollContainer` input is provided, uses `closest(selector)` starting from the host element.
|
|
2019
|
-
* - If not provided or `closest` returned null, automatically finds the first scrollable parent by walking up the DOM.
|
|
2020
|
-
* - Fallback to `document.scrollingElement` or `window` if nothing suitable found.
|
|
2021
|
-
*/
|
|
2022
|
-
_computeScrollContainer() {
|
|
2023
|
-
if (isPlatformServer(this._platformId)) {
|
|
2024
|
-
return null;
|
|
2025
|
-
}
|
|
2026
|
-
const host = this.elRef?.nativeElement;
|
|
2027
|
-
if (!host) {
|
|
2028
|
-
return (document.scrollingElement || window);
|
|
2029
|
-
}
|
|
2030
|
-
const selector = this.scrollContainer();
|
|
2031
|
-
if (selector && typeof selector === 'string') {
|
|
2032
|
-
try {
|
|
2033
|
-
const matched = host.closest(selector);
|
|
2034
|
-
if (matched) {
|
|
2035
|
-
return matched;
|
|
2036
|
-
}
|
|
2037
|
-
}
|
|
2038
|
-
catch (_) {
|
|
2039
|
-
// If selector is invalid, ignore and fallback to auto detection
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
// Auto-detect by traversing parents
|
|
2043
|
-
let parent = host.parentElement;
|
|
2044
|
-
while (parent) {
|
|
2045
|
-
if (this._isElementScrollable(parent)) {
|
|
2046
|
-
return parent;
|
|
2047
|
-
}
|
|
2048
|
-
parent = parent.parentElement;
|
|
2049
|
-
}
|
|
2050
|
-
return (document.scrollingElement || window);
|
|
2051
|
-
}
|
|
2052
|
-
_isElementScrollable(el) {
|
|
2053
|
-
const style = getComputedStyle(el);
|
|
2054
|
-
const overflowY = style.overflowY;
|
|
2055
|
-
const overflowX = style.overflowX;
|
|
2056
|
-
const canScrollY = (overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'overlay') && el.scrollHeight > el.clientHeight;
|
|
2057
|
-
const canScrollX = (overflowX === 'auto' || overflowX === 'scroll' || overflowX === 'overlay') && el.scrollWidth > el.clientWidth;
|
|
2058
|
-
return canScrollY || canScrollX;
|
|
2059
|
-
}
|
|
2060
|
-
_rebindScrollListener() {
|
|
2061
|
-
if (isPlatformServer(this._platformId)) {
|
|
2062
|
-
return;
|
|
2063
|
-
}
|
|
2064
|
-
// Unsubscribe from the previous container, if any
|
|
2065
|
-
if (this._scrollBindSub) {
|
|
2066
|
-
try {
|
|
2067
|
-
this._scrollBindSub.unsubscribe();
|
|
2068
|
-
}
|
|
2069
|
-
catch {
|
|
2070
|
-
}
|
|
2071
|
-
this._scrollBindSub = null;
|
|
2072
|
-
}
|
|
2073
|
-
const container = this._resolvedScrollContainer ?? this._computeScrollContainer();
|
|
2074
|
-
if (!container) {
|
|
2075
|
-
return;
|
|
2076
|
-
}
|
|
2077
|
-
// Create the scroll source
|
|
2078
|
-
const getTop = () => {
|
|
2079
|
-
if (container instanceof Window) {
|
|
2080
|
-
return container.scrollY || container.pageYOffset || 0;
|
|
2081
|
-
}
|
|
2082
|
-
return container.scrollTop || 0;
|
|
2083
|
-
};
|
|
2084
|
-
const source$ = fromEvent(container, 'scroll').pipe(auditTime(50), map(() => getTop()), startWith(getTop()), distinctUntilChanged());
|
|
2085
|
-
// Subscribe and forward values to the shared Subject
|
|
2086
|
-
this._scrollBindSub = source$.subscribe(top => {
|
|
2087
|
-
this._scrollSubject.next(top);
|
|
2088
|
-
});
|
|
2089
|
-
}
|
|
2090
|
-
// Duplicate ngOnDestroy removed; see the implementation at the end of the class
|
|
2091
|
-
appendBlock(type, focus = true) {
|
|
2092
|
-
this.insertBlock(type, this._content().length, {}, focus);
|
|
2093
|
-
}
|
|
2094
|
-
insertBlock(type, index, options, focus = true, content) {
|
|
2095
|
-
const isLastIndex = index === this._content().length;
|
|
2096
|
-
const newBlock = this._createBlock(type, options, content);
|
|
2097
|
-
if (focus) {
|
|
2098
|
-
this.focusBlock(newBlock.id);
|
|
2099
|
-
}
|
|
2100
|
-
this._content.update((data) => {
|
|
2101
|
-
return [...data.slice(0, index), newBlock, ...data.slice(index)];
|
|
2102
|
-
});
|
|
2103
|
-
this._store.addBlock(newBlock, index);
|
|
2104
|
-
if (isLastIndex && this._content()[index].type !== 'paragraph') {
|
|
2105
|
-
this.appendBlock('paragraph', false);
|
|
2106
|
-
}
|
|
2107
|
-
this.emitContentChangeEvent();
|
|
2108
|
-
return newBlock;
|
|
2109
|
-
}
|
|
2110
|
-
_createBlock(type, settings = {}, content) {
|
|
2111
|
-
const blockDef = this.blockDefs().find(blockDefItem => blockDefItem.type === type);
|
|
2112
|
-
const empty = blockDef.empty();
|
|
2113
|
-
if (settings) {
|
|
2114
|
-
empty.settings = {
|
|
2115
|
-
...empty.settings,
|
|
2116
|
-
...settings
|
|
2117
|
-
};
|
|
2118
|
-
}
|
|
2119
|
-
if (content !== undefined) {
|
|
2120
|
-
empty.content = content;
|
|
2121
|
-
}
|
|
2122
|
-
return {
|
|
2123
|
-
id: v7(),
|
|
2124
|
-
type: blockDef.type,
|
|
2125
|
-
isEmpty: content === undefined || content === '' || (Array.isArray(content) && content.length === 0),
|
|
2126
|
-
...empty
|
|
2127
|
-
};
|
|
2128
|
-
}
|
|
2129
|
-
addBlock(type, options, index = -1) {
|
|
2130
|
-
if (index === -1) {
|
|
2131
|
-
if (this._store.activeBlockId()) {
|
|
2132
|
-
index = this._content().findIndex(dataBlock => dataBlock.id === this._store.activeBlockId()) + 1;
|
|
2133
|
-
}
|
|
2134
|
-
else {
|
|
2135
|
-
index = this._content().length;
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
this.insertBlock(type, index, options);
|
|
2139
|
-
}
|
|
2140
|
-
duplicateBlock(blockId) {
|
|
2141
|
-
const index = this._content().findIndex(dataBlock => dataBlock.id === blockId);
|
|
2142
|
-
if (index === -1) {
|
|
2143
|
-
return;
|
|
2144
|
-
}
|
|
2145
|
-
const original = this._content()[index];
|
|
2146
|
-
// Deep clone mutable fields to avoid shared references
|
|
2147
|
-
const clonedContent = original.content != null ? JSON.parse(JSON.stringify(original.content)) : original.content;
|
|
2148
|
-
const clonedSettings = original.settings != null ? JSON.parse(JSON.stringify(original.settings)) : original.settings;
|
|
2149
|
-
const clonedProps = original.props != null ? JSON.parse(JSON.stringify(original.props)) : original.props;
|
|
2150
|
-
const duplicated = {
|
|
2151
|
-
...original,
|
|
2152
|
-
id: v7(),
|
|
2153
|
-
isEmpty: false,
|
|
2154
|
-
content: clonedContent,
|
|
2155
|
-
settings: clonedSettings,
|
|
2156
|
-
props: clonedProps,
|
|
2157
|
-
};
|
|
2158
|
-
const insertIndex = index + 1;
|
|
2159
|
-
this._content.update((data) => {
|
|
2160
|
-
data.splice(insertIndex, 0, duplicated);
|
|
2161
|
-
return data;
|
|
2162
|
-
});
|
|
2163
|
-
this._store.addBlock(duplicated, insertIndex);
|
|
2164
|
-
this.focusBlock(duplicated.id);
|
|
2165
|
-
this.emitContentChangeEvent();
|
|
2166
|
-
}
|
|
2167
|
-
duplicateSelectedBlocks(popover) {
|
|
2168
|
-
const selectedIds = [...this.selectedBlocksModel.selected];
|
|
2169
|
-
if (!selectedIds.length)
|
|
2170
|
-
return;
|
|
2171
|
-
// Process in visual order (top to bottom)
|
|
2172
|
-
const ordered = selectedIds
|
|
2173
|
-
.map(id => ({ id, index: this._content().findIndex(b => b.id === id) }))
|
|
2174
|
-
.filter(x => x.index !== -1)
|
|
2175
|
-
.sort((a, b) => a.index - b.index)
|
|
2176
|
-
.map(x => x.id);
|
|
2177
|
-
const newIds = [];
|
|
2178
|
-
for (const id of ordered) {
|
|
2179
|
-
// Get current index of the original before duplicating
|
|
2180
|
-
const idx = this._content().findIndex(b => b.id === id);
|
|
2181
|
-
if (idx === -1)
|
|
2182
|
-
continue;
|
|
2183
|
-
this.duplicateBlock(id);
|
|
2184
|
-
// After duplication, the new block is placed right after the original
|
|
2185
|
-
const newBlock = this._content()[idx + 1];
|
|
2186
|
-
if (newBlock) {
|
|
2187
|
-
newIds.push(newBlock.id);
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
// Select duplicated blocks
|
|
2191
|
-
this.selectedBlocksModel.clear();
|
|
2192
|
-
if (newIds.length) {
|
|
2193
|
-
this.selectedBlocksModel.select(...newIds);
|
|
2194
|
-
}
|
|
2195
|
-
this.cdr.markForCheck();
|
|
2196
|
-
}
|
|
2197
|
-
deleteBlock(blockId) {
|
|
2198
|
-
if (this._content().length === 1) {
|
|
2199
|
-
return;
|
|
2200
|
-
}
|
|
2201
|
-
const index = this._content().findIndex(dataBlock => dataBlock.id === blockId);
|
|
2202
|
-
if (index !== -1) {
|
|
2203
|
-
this._content.update(data => {
|
|
2204
|
-
data.splice(index, 1);
|
|
2205
|
-
return data;
|
|
2206
|
-
});
|
|
2207
|
-
this._store.deleteBlock(blockId, index);
|
|
2208
|
-
const prevBlock = this._content()[index - 1];
|
|
2209
|
-
if (prevBlock) {
|
|
2210
|
-
this.focusBlock(prevBlock.id);
|
|
2211
|
-
}
|
|
2212
|
-
this.emitContentChangeEvent();
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
setBlockProps(id, props) {
|
|
2216
|
-
const data = this._content();
|
|
2217
|
-
const index = data.findIndex((dataBlock) => dataBlock.id === id);
|
|
2218
|
-
data[index].props = props;
|
|
2219
|
-
this.emitContentChangeEvent();
|
|
2220
|
-
}
|
|
2221
|
-
insertEmptyBlock(index) {
|
|
2222
|
-
this.insertBlock('paragraph', index + 1);
|
|
2223
|
-
this.emitContentChangeEvent();
|
|
2224
|
-
}
|
|
2225
|
-
focusBlock(id) {
|
|
2226
|
-
this._store.setFocusedBlockId(id);
|
|
2227
|
-
this.focusChanged.emit();
|
|
2228
|
-
}
|
|
2229
|
-
isBlockFocused(id) {
|
|
2230
|
-
return this._store.focusedBlockId() === id;
|
|
2231
|
-
}
|
|
2232
|
-
isActiveBlock(id) {
|
|
2233
|
-
return this._store.activeBlockId() === id;
|
|
2234
|
-
}
|
|
2235
|
-
drop(event) {
|
|
2236
|
-
moveItemInArray(this._content(), event.previousIndex, event.currentIndex);
|
|
2237
|
-
this._store.moveBlock(event.previousIndex, event.currentIndex);
|
|
2238
|
-
this.emitContentChangeEvent();
|
|
2239
|
-
}
|
|
2240
|
-
onTagSelected(tagName) {
|
|
2241
|
-
// console.log('Tag selected event received:', tagName);
|
|
2242
|
-
}
|
|
2243
|
-
getData() {
|
|
2244
|
-
return this._store.blocks();
|
|
2245
|
-
}
|
|
2246
|
-
emitContentChangeEvent() {
|
|
2247
|
-
const data = this.getData();
|
|
2248
|
-
this._saveDraft(data);
|
|
2249
|
-
this.contentChanged.emit(data);
|
|
2250
|
-
}
|
|
2251
|
-
selectBlock(blockId, multiple = false) {
|
|
2252
|
-
if (!multiple) {
|
|
2253
|
-
this.selectedBlocksModel.clear();
|
|
2254
|
-
}
|
|
2255
|
-
this.selectedBlocksModel.select(blockId);
|
|
2256
|
-
this.cdr.markForCheck();
|
|
2257
|
-
}
|
|
2258
|
-
unselectBlock(blockId) {
|
|
2259
|
-
this.selectedBlocksModel.deselect(blockId);
|
|
2260
|
-
this.cdr.markForCheck();
|
|
2261
|
-
}
|
|
2262
|
-
unselectSelectedBlocks() {
|
|
2263
|
-
this.selectedBlocksModel.clear();
|
|
2264
|
-
this.cdr.markForCheck();
|
|
2265
|
-
}
|
|
2266
|
-
isBlockSelected(blockId) {
|
|
2267
|
-
return this.selectedBlocksModel.isSelected(blockId);
|
|
2268
|
-
}
|
|
2269
|
-
deleteSelectedBlocks(popover) {
|
|
2270
|
-
const selectedIds = [...this.selectedBlocksModel.selected];
|
|
2271
|
-
if (!selectedIds.length) {
|
|
2272
|
-
return;
|
|
2273
|
-
}
|
|
2274
|
-
const confirmRef = this.confirmManager.open({
|
|
2275
|
-
title: 'Delete blocks',
|
|
2276
|
-
description: 'This action cannot be undone. Selected blocks will be deleted.'
|
|
2277
|
-
});
|
|
2278
|
-
confirmRef.confirmed.subscribe(() => {
|
|
2279
|
-
// Delete from bottom to top to keep indexes stable
|
|
2280
|
-
const toDelete = selectedIds
|
|
2281
|
-
.map(id => ({ id, index: this._content().findIndex(b => b.id === id) }))
|
|
2282
|
-
.filter(x => x.index !== -1)
|
|
2283
|
-
.sort((a, b) => b.index - a.index);
|
|
2284
|
-
for (const item of toDelete) {
|
|
2285
|
-
this.deleteBlock(item.id);
|
|
2286
|
-
}
|
|
2287
|
-
this.unselectSelectedBlocks();
|
|
2288
|
-
});
|
|
2289
|
-
}
|
|
2290
|
-
_onKeyDown(event) {
|
|
2291
|
-
if ((event.key === 'Delete' || event.key === 'Backspace') && this.selectedBlocksModel.hasValue()) {
|
|
2292
|
-
const target = event.target;
|
|
2293
|
-
const isInput = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
|
2294
|
-
// If we are in an input/contenteditable, only delete if multiple blocks are selected
|
|
2295
|
-
// or if it's not a Backspace (to avoid deleting text while trying to delete blocks)
|
|
2296
|
-
// Actually, if blocks are selected, they usually have a blue background and the user intent is likely to delete blocks.
|
|
2297
|
-
// But if there's only ONE block selected AND we are typing in it, we probably want to delete text.
|
|
2298
|
-
if (isInput && this.selectedBlocksModel.selected.length === 1) {
|
|
2299
|
-
// Let the default behavior happen for text editing
|
|
2300
|
-
return;
|
|
2301
|
-
}
|
|
2302
|
-
event.preventDefault();
|
|
2303
|
-
this.deleteSelectedBlocks();
|
|
2304
|
-
}
|
|
2305
|
-
}
|
|
2306
|
-
onDragStarted(event, block) {
|
|
2307
|
-
this._blockDragging.set(true);
|
|
2308
|
-
}
|
|
2309
|
-
onDragEnded(event, block) {
|
|
2310
|
-
this._blockDragging.set(false);
|
|
2311
|
-
}
|
|
2312
|
-
addBlockFromSuggestionMenu(suggestionsMenu, type, options) {
|
|
2313
|
-
suggestionsMenu.closed.emit('click');
|
|
2314
|
-
this.addBlock(type, options);
|
|
2315
|
-
}
|
|
2316
|
-
preventMenuClose(event) {
|
|
2317
|
-
event.stopPropagation();
|
|
2318
|
-
event.preventDefault();
|
|
2319
|
-
}
|
|
2320
|
-
setActiveBlockId(event, id) {
|
|
2321
|
-
event.stopPropagation();
|
|
2322
|
-
event.preventDefault();
|
|
2323
|
-
this._store.setActiveBlockId(id);
|
|
2324
|
-
this._store.setFocusedBlockId(id);
|
|
2325
|
-
this.focusChanged.emit();
|
|
2326
|
-
}
|
|
2327
|
-
onFocusChange(origin, dataBlock) {
|
|
2328
|
-
}
|
|
2329
|
-
onSuggestionsMenuOpen() {
|
|
2330
|
-
}
|
|
2331
|
-
onSuggestionsMenuClose(reason) {
|
|
2332
|
-
if (!reason) {
|
|
2333
|
-
this._store.setFocusedBlockId(this._store.activeBlockId());
|
|
2334
|
-
this.focusChanged.emit();
|
|
2335
|
-
}
|
|
2336
|
-
// need some delay to prevent the flickering
|
|
2337
|
-
setTimeout(() => this._store.setActiveBlockId(null), 250);
|
|
2338
|
-
}
|
|
2339
|
-
ngOnDestroy() {
|
|
2340
|
-
if (isPlatformServer(this._platformId)) {
|
|
2341
|
-
return;
|
|
2342
|
-
}
|
|
2343
|
-
if (this._scrollBindSub) {
|
|
2344
|
-
try {
|
|
2345
|
-
this._scrollBindSub.unsubscribe();
|
|
2346
|
-
}
|
|
2347
|
-
catch {
|
|
2348
|
-
}
|
|
2349
|
-
this._scrollBindSub = null;
|
|
2350
|
-
}
|
|
2351
|
-
if (this._scrollEffect) {
|
|
2352
|
-
try {
|
|
2353
|
-
this._scrollEffect.destroy();
|
|
2354
|
-
}
|
|
2355
|
-
catch {
|
|
2356
|
-
}
|
|
2357
|
-
this._scrollEffect = undefined;
|
|
2358
|
-
}
|
|
2359
|
-
try {
|
|
2360
|
-
this._scrollSubject.complete();
|
|
2361
|
-
}
|
|
2362
|
-
catch {
|
|
2363
|
-
}
|
|
2364
|
-
this._scroll$ = null;
|
|
2365
|
-
}
|
|
2366
|
-
_getDraftContent() {
|
|
2367
|
-
if (!this._canUseDraftStorage()) {
|
|
2368
|
-
return null;
|
|
2369
|
-
}
|
|
2370
|
-
try {
|
|
2371
|
-
const draft = localStorage.getItem(this._getDraftStorageKey());
|
|
2372
|
-
if (!draft) {
|
|
2373
|
-
return null;
|
|
2374
|
-
}
|
|
2375
|
-
const content = JSON.parse(draft);
|
|
2376
|
-
return Array.isArray(content) ? content : null;
|
|
2377
|
-
}
|
|
2378
|
-
catch {
|
|
2379
|
-
return null;
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
_saveDraft(content) {
|
|
2383
|
-
if (!this._canUseDraftStorage()) {
|
|
2384
|
-
return;
|
|
2385
|
-
}
|
|
2386
|
-
try {
|
|
2387
|
-
localStorage.setItem(this._getDraftStorageKey(), JSON.stringify(content));
|
|
2388
|
-
}
|
|
2389
|
-
catch {
|
|
2390
|
-
}
|
|
2391
|
-
}
|
|
2392
|
-
_canUseDraftStorage() {
|
|
2393
|
-
return !isPlatformServer(this._platformId) && this.persistDraft();
|
|
2394
|
-
}
|
|
2395
|
-
_getDraftStorageKey(prefix = ContentBuilderComponent.DRAFT_STORAGE_PREFIX) {
|
|
2396
|
-
const elementId = this.elRef.nativeElement.id;
|
|
2397
|
-
const locationKey = typeof window === 'undefined'
|
|
2398
|
-
? 'server'
|
|
2399
|
-
: `${window.location.pathname}${window.location.search}`;
|
|
2400
|
-
const instanceKey = elementId ? `:${elementId}` : '';
|
|
2401
|
-
return `${prefix}:${locationKey}${instanceKey}`;
|
|
2402
|
-
}
|
|
2403
|
-
onSettingsPopoverClose() {
|
|
2404
|
-
}
|
|
2405
|
-
_onPaste(event) {
|
|
2406
|
-
const target = event.target;
|
|
2407
|
-
const isInsideCodeBlock = target.closest('.ngs-code-block') ||
|
|
2408
|
-
target.closest('.cm-editor') ||
|
|
2409
|
-
target.closest('.cm-content') ||
|
|
2410
|
-
target.classList.contains('cm-content') ||
|
|
2411
|
-
target.classList.contains('cm-line');
|
|
2412
|
-
if (isInsideCodeBlock) {
|
|
2413
|
-
return;
|
|
2414
|
-
}
|
|
2415
|
-
const html = event.clipboardData?.getData('text/html');
|
|
2416
|
-
const text = event.clipboardData?.getData('text/plain');
|
|
2417
|
-
if (!html && !text) {
|
|
2418
|
-
return;
|
|
2419
|
-
}
|
|
2420
|
-
// Check if we are pasting into a block that should handle its own paste (like code block)
|
|
2421
|
-
// but might not have been caught by target.closest if it's currently empty or has different structure.
|
|
2422
|
-
const activeBlockId = this._store.activeBlockId() || this._store.focusedBlockId();
|
|
2423
|
-
if (activeBlockId) {
|
|
2424
|
-
const activeBlock = this._content().find(b => b.id === activeBlockId);
|
|
2425
|
-
if (activeBlock?.type === 'code') {
|
|
2426
|
-
return;
|
|
2427
|
-
}
|
|
2428
|
-
}
|
|
2429
|
-
event.preventDefault();
|
|
2430
|
-
event.stopPropagation();
|
|
2431
|
-
let index = this._content().length;
|
|
2432
|
-
if (activeBlockId) {
|
|
2433
|
-
const activeIndex = this._content().findIndex(b => b.id === activeBlockId);
|
|
2434
|
-
if (activeIndex !== -1) {
|
|
2435
|
-
index = activeIndex + 1;
|
|
2436
|
-
}
|
|
2437
|
-
}
|
|
2438
|
-
if (html) {
|
|
2439
|
-
this._handleHtmlPaste(html, index);
|
|
2440
|
-
}
|
|
2441
|
-
else if (text) {
|
|
2442
|
-
this._handleTextPaste(text, index);
|
|
2443
|
-
}
|
|
2444
|
-
}
|
|
2445
|
-
_handleTextPaste(text, index) {
|
|
2446
|
-
const lines = text.split(/\r?\n/);
|
|
2447
|
-
if (lines.length === 1) {
|
|
2448
|
-
this.insertBlock('paragraph', index, {}, false, text);
|
|
2449
|
-
}
|
|
2450
|
-
else {
|
|
2451
|
-
// If it looks like code (has indentation or common code characters), insert as a single code block
|
|
2452
|
-
const isCodeLike = text.includes('{') || text.includes('}') || text.includes(';') || text.includes(' ') || text.includes('\t');
|
|
2453
|
-
if (isCodeLike) {
|
|
2454
|
-
this.insertBlock('code', index, { language: 'none' }, false, text);
|
|
2455
|
-
return;
|
|
2456
|
-
}
|
|
2457
|
-
lines.forEach((line, i) => {
|
|
2458
|
-
if (line.trim().length > 0) {
|
|
2459
|
-
this.insertBlock('paragraph', index + i, {}, false, line);
|
|
2460
|
-
}
|
|
2461
|
-
});
|
|
2462
|
-
}
|
|
2463
|
-
}
|
|
2464
|
-
_handleHtmlPaste(html, index) {
|
|
2465
|
-
const parser = new DOMParser();
|
|
2466
|
-
const doc = parser.parseFromString(html, 'text/html');
|
|
2467
|
-
const body = doc.body;
|
|
2468
|
-
let currentIndex = index;
|
|
2469
|
-
Array.from(body.children).forEach(node => {
|
|
2470
|
-
const block = this._mapNodeToBlock(node);
|
|
2471
|
-
if (block) {
|
|
2472
|
-
this.insertBlock(block.type, currentIndex, block.settings, false, block.content);
|
|
2473
|
-
currentIndex++;
|
|
2474
|
-
}
|
|
2475
|
-
});
|
|
2476
|
-
}
|
|
2477
|
-
_mapNodeToBlock(node) {
|
|
2478
|
-
const tag = node.tagName.toLowerCase();
|
|
2479
|
-
switch (tag) {
|
|
2480
|
-
case 'h1':
|
|
2481
|
-
case 'h2':
|
|
2482
|
-
case 'h3':
|
|
2483
|
-
case 'h4':
|
|
2484
|
-
case 'h5':
|
|
2485
|
-
case 'h6':
|
|
2486
|
-
return {
|
|
2487
|
-
type: 'heading',
|
|
2488
|
-
settings: { level: parseInt(tag.substring(1)) },
|
|
2489
|
-
content: node.innerHTML
|
|
2490
|
-
};
|
|
2491
|
-
case 'p':
|
|
2492
|
-
return {
|
|
2493
|
-
type: 'paragraph',
|
|
2494
|
-
settings: {},
|
|
2495
|
-
content: node.innerHTML
|
|
2496
|
-
};
|
|
2497
|
-
case 'ul':
|
|
2498
|
-
return {
|
|
2499
|
-
type: 'bulletList',
|
|
2500
|
-
settings: { listStyle: 'bullet' },
|
|
2501
|
-
content: this._mapListItems(node)
|
|
2502
|
-
};
|
|
2503
|
-
case 'ol':
|
|
2504
|
-
return {
|
|
2505
|
-
type: 'orderedList',
|
|
2506
|
-
settings: { listStyle: 'ordered' },
|
|
2507
|
-
content: this._mapListItems(node)
|
|
2508
|
-
};
|
|
2509
|
-
case 'img':
|
|
2510
|
-
return {
|
|
2511
|
-
type: 'image',
|
|
2512
|
-
settings: {},
|
|
2513
|
-
content: {
|
|
2514
|
-
src: node.getAttribute('src') || '',
|
|
2515
|
-
alt: node.getAttribute('alt') || ''
|
|
2516
|
-
}
|
|
2517
|
-
};
|
|
2518
|
-
case 'video':
|
|
2519
|
-
return {
|
|
2520
|
-
type: 'video',
|
|
2521
|
-
settings: {},
|
|
2522
|
-
content: {
|
|
2523
|
-
src: node.getAttribute('src') || '',
|
|
2524
|
-
caption: node.getAttribute('title') || ''
|
|
2525
|
-
}
|
|
2526
|
-
};
|
|
2527
|
-
case 'blockquote':
|
|
2528
|
-
return {
|
|
2529
|
-
type: 'quote',
|
|
2530
|
-
settings: {},
|
|
2531
|
-
content: node.innerHTML
|
|
2532
|
-
};
|
|
2533
|
-
case 'pre':
|
|
2534
|
-
const codeNode = node.querySelector('code');
|
|
2535
|
-
const content = (codeNode || node).textContent || '';
|
|
2536
|
-
return {
|
|
2537
|
-
type: 'code',
|
|
2538
|
-
settings: { language: 'none' },
|
|
2539
|
-
content: content.replace(/\r\n/g, '\n').replace(/\r/g, '\n').trimEnd()
|
|
2540
|
-
};
|
|
2541
|
-
case 'hr':
|
|
2542
|
-
return {
|
|
2543
|
-
type: 'divider',
|
|
2544
|
-
settings: {}
|
|
2545
|
-
};
|
|
2546
|
-
default:
|
|
2547
|
-
if (node.textContent?.trim()) {
|
|
2548
|
-
return {
|
|
2549
|
-
type: 'paragraph',
|
|
2550
|
-
settings: {},
|
|
2551
|
-
content: node.innerHTML
|
|
2552
|
-
};
|
|
2553
|
-
}
|
|
2554
|
-
return null;
|
|
2555
|
-
}
|
|
2556
|
-
}
|
|
2557
|
-
_mapListItems(node) {
|
|
2558
|
-
return Array.from(node.children)
|
|
2559
|
-
.filter(child => child.tagName.toLowerCase() === 'li')
|
|
2560
|
-
.map(li => ({
|
|
2561
|
-
content: li.innerHTML,
|
|
2562
|
-
children: []
|
|
2563
|
-
}));
|
|
2564
|
-
}
|
|
2565
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentBuilderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2566
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentBuilderComponent, isStandalone: true, selector: "ngs-content-editor-builder", inputs: { 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: [
|
|
2567
|
-
ContentBuilderStore,
|
|
2568
|
-
{
|
|
2569
|
-
provide: CONTENT_BUILDER,
|
|
2570
|
-
useExisting: forwardRef(() => ContentBuilderComponent)
|
|
2571
|
-
}
|
|
2572
|
-
], exportAs: ["ngsContentEditorBuilder"], hostDirectives: [{ directive: BlockSelectionDirective, inputs: ["autoScrollContainerSelector", "autoScrollContainerSelector"] }], ngImport: i0, template: "<div class=\"container py-4\">\n <div class=\"content\"\n cdkDropList\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 cdkDragLockAxis=\"y\"\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\">\n <ngs-icon name=\"fluent:add-24-regular\"\n (mousedown)=\"setActiveBlockId($event, contentBlock.id)\"\n [ngsMenuTriggerFor]=\"suggestionsMenu\"\n [ngsMenuTriggerRestoreFocus]=\"false\"\n (menuOpened)=\"onSuggestionsMenuOpen()\"\n (menuClosed)=\"onSuggestionsMenuClose($event)\"/>\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 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\">\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 (click)=\"addBlockFromSuggestionMenu(suggestionsMenu, suggestionItem.blockType, suggestionItem.blockOptions)\">\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-500\">{{ 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</ngs-menu>\n", styles: [":host{--ngs-content-editor-builder-content-width: 704px;outline:none}:host ::ng-deep .link-selection,:host ::ng-deep .text-selection{display:inline-block;background:var(--ngs-color-secondary-fixed)}:host.is-block-dragging{cursor:grabbing}:host .container{display:flex;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:calc(var(--ngs-content-editor-builder-content-width) + calc(var(--spacing, .25rem) * 10))}: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;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.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"], 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: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2573
|
-
}
|
|
2574
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentBuilderComponent, decorators: [{
|
|
2575
|
-
type: Component,
|
|
2576
|
-
args: [{ selector: 'ngs-content-editor-builder', exportAs: 'ngsContentEditorBuilder', imports: [
|
|
2577
|
-
Icon,
|
|
2578
|
-
NgComponentOutlet,
|
|
2579
|
-
AsyncPipe,
|
|
2580
|
-
CdkDrag,
|
|
2581
|
-
CdkDropList,
|
|
2582
|
-
CdkDragHandle,
|
|
2583
|
-
CdkDragPlaceholder,
|
|
2584
|
-
Menu,
|
|
2585
|
-
MenuItem,
|
|
2586
|
-
MenuTrigger,
|
|
2587
|
-
CdkMonitorFocus,
|
|
2588
|
-
TextSelectionPopupDirective,
|
|
2589
|
-
PopoverTriggerForDirective,
|
|
2590
|
-
Popover,
|
|
2591
|
-
ListItemTitle,
|
|
2592
|
-
ListItemIcon,
|
|
2593
|
-
ListItem,
|
|
2594
|
-
List,
|
|
2595
|
-
MenuHeading
|
|
2596
|
-
], hostDirectives: [
|
|
2597
|
-
{
|
|
2598
|
-
directive: BlockSelectionDirective,
|
|
2599
|
-
inputs: [
|
|
2600
|
-
'autoScrollContainerSelector',
|
|
2601
|
-
]
|
|
2602
|
-
}
|
|
2603
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
2604
|
-
ContentBuilderStore,
|
|
2605
|
-
{
|
|
2606
|
-
provide: CONTENT_BUILDER,
|
|
2607
|
-
useExisting: forwardRef(() => ContentBuilderComponent)
|
|
2608
|
-
}
|
|
2609
|
-
], host: {
|
|
2610
|
-
'class': 'ngs-content-editor-builder',
|
|
2611
|
-
'[class.is-block-dragging]': '_blockDragging()',
|
|
2612
|
-
'[class.is-selection-of-blocks-active]': 'isSelectionOfBlocksActive()',
|
|
2613
|
-
'[class.select-none]': 'isSelectionOfBlocksActive()',
|
|
2614
|
-
'[style.user-select]': 'isSelectionOfBlocksActive() ? "none" : null',
|
|
2615
|
-
'tabindex': '0',
|
|
2616
|
-
'(paste)': '_onPaste($event)',
|
|
2617
|
-
'(keydown)': '_onKeyDown($event)',
|
|
2618
|
-
}, template: "<div class=\"container py-4\">\n <div class=\"content\"\n cdkDropList\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 cdkDragLockAxis=\"y\"\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\">\n <ngs-icon name=\"fluent:add-24-regular\"\n (mousedown)=\"setActiveBlockId($event, contentBlock.id)\"\n [ngsMenuTriggerFor]=\"suggestionsMenu\"\n [ngsMenuTriggerRestoreFocus]=\"false\"\n (menuOpened)=\"onSuggestionsMenuOpen()\"\n (menuClosed)=\"onSuggestionsMenuClose($event)\"/>\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 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\">\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 (click)=\"addBlockFromSuggestionMenu(suggestionsMenu, suggestionItem.blockType, suggestionItem.blockOptions)\">\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-500\">{{ 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</ngs-menu>\n", styles: [":host{--ngs-content-editor-builder-content-width: 704px;outline:none}:host ::ng-deep .link-selection,:host ::ng-deep .text-selection{display:inline-block;background:var(--ngs-color-secondary-fixed)}:host.is-block-dragging{cursor:grabbing}:host .container{display:flex;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:calc(var(--ngs-content-editor-builder-content-width) + calc(var(--spacing, .25rem) * 10))}: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;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.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"] }]
|
|
2619
|
-
}], propDecorators: { 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"] }] } });
|
|
2620
|
-
|
|
2621
|
-
const CONTENT_EDITOR_BLOCK_RENDERERS = new InjectionToken('CONTENT_EDITOR_BLOCK_RENDERERS', {
|
|
2622
|
-
factory: () => [],
|
|
2623
|
-
});
|
|
2624
|
-
function provideContentEditorRenderers(renderers) {
|
|
2625
|
-
return makeEnvironmentProviders([
|
|
2626
|
-
{
|
|
2627
|
-
provide: CONTENT_EDITOR_BLOCK_RENDERERS,
|
|
2628
|
-
useValue: renderers,
|
|
2629
|
-
multi: true,
|
|
2630
|
-
},
|
|
2631
|
-
]);
|
|
2632
|
-
}
|
|
2633
|
-
function provideContentEditorRenderer(renderer) {
|
|
2634
|
-
return provideContentEditorRenderers([renderer]);
|
|
2635
|
-
}
|
|
2636
|
-
|
|
2637
|
-
function getTextAlignment(props) {
|
|
2638
|
-
const value = props?.find(prop => prop.name === 'text-alignment')?.value;
|
|
2639
|
-
if (value === 'center' || value === 'right' || value === 'justify') {
|
|
2640
|
-
return value;
|
|
2641
|
-
}
|
|
2642
|
-
return 'left';
|
|
2643
|
-
}
|
|
2644
|
-
function getDimensionAttribute(value) {
|
|
2645
|
-
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
2646
|
-
return value;
|
|
2647
|
-
}
|
|
2648
|
-
if (typeof value === 'string') {
|
|
2649
|
-
const trimmed = value.trim();
|
|
2650
|
-
if (!trimmed || trimmed === 'auto') {
|
|
2651
|
-
return null;
|
|
2652
|
-
}
|
|
2653
|
-
const parsed = Number.parseFloat(trimmed);
|
|
2654
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
2655
|
-
}
|
|
2656
|
-
return null;
|
|
2657
|
-
}
|
|
2658
|
-
function getHtmlContent(value) {
|
|
2659
|
-
return typeof value === 'string' ? value : '';
|
|
2660
|
-
}
|
|
2661
|
-
|
|
2662
|
-
class ContentEditorCodeRenderer {
|
|
2663
|
-
block = input(null, /* @ts-ignore */
|
|
2664
|
-
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2665
|
-
id = input('', /* @ts-ignore */
|
|
2666
|
-
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2667
|
-
type = input('', /* @ts-ignore */
|
|
2668
|
-
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2669
|
-
content = input('', /* @ts-ignore */
|
|
2670
|
-
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2671
|
-
props = input([], /* @ts-ignore */
|
|
2672
|
-
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2673
|
-
settings = input({}, /* @ts-ignore */
|
|
2674
|
-
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2675
|
-
index = input(0, /* @ts-ignore */
|
|
2676
|
-
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2677
|
-
code = computed(() => getHtmlContent(this.content()), /* @ts-ignore */
|
|
2678
|
-
...(ngDevMode ? [{ debugName: "code" }] : /* istanbul ignore next */ []));
|
|
2679
|
-
language = computed(() => this.settings()?.language || 'none', /* @ts-ignore */
|
|
2680
|
-
...(ngDevMode ? [{ debugName: "language" }] : /* istanbul ignore next */ []));
|
|
2681
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorCodeRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2682
|
-
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 });
|
|
2683
|
-
}
|
|
2684
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorCodeRenderer, decorators: [{
|
|
2685
|
-
type: Component,
|
|
2686
|
-
args: [{ selector: 'ngs-content-editor-code-renderer', imports: [
|
|
2687
|
-
CodeHighlighter,
|
|
2688
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2689
|
-
'class': 'ngs-content-editor-code-renderer',
|
|
2690
|
-
}, 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"] }]
|
|
2691
|
-
}], 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 }] }] } });
|
|
2692
|
-
|
|
2693
|
-
class ContentEditorDividerRenderer {
|
|
2694
|
-
block = input(null, /* @ts-ignore */
|
|
2695
|
-
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2696
|
-
id = input('', /* @ts-ignore */
|
|
2697
|
-
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2698
|
-
type = input('', /* @ts-ignore */
|
|
2699
|
-
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2700
|
-
content = input(null, /* @ts-ignore */
|
|
2701
|
-
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2702
|
-
props = input([], /* @ts-ignore */
|
|
2703
|
-
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2704
|
-
settings = input({}, /* @ts-ignore */
|
|
2705
|
-
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2706
|
-
index = input(0, /* @ts-ignore */
|
|
2707
|
-
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2708
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorDividerRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2709
|
-
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 });
|
|
2710
|
-
}
|
|
2711
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorDividerRenderer, decorators: [{
|
|
2712
|
-
type: Component,
|
|
2713
|
-
args: [{ selector: 'ngs-content-editor-divider-renderer', imports: [
|
|
2714
|
-
Divider,
|
|
2715
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2716
|
-
'class': 'ngs-content-editor-divider-renderer',
|
|
2717
|
-
}, template: "<ngs-divider/>\n", styles: [":host{display:block}\n"] }]
|
|
2718
|
-
}], 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 }] }] } });
|
|
2719
|
-
|
|
2720
|
-
class ContentEditorEmbedRenderer {
|
|
2721
|
-
block = input(null, /* @ts-ignore */
|
|
2722
|
-
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2723
|
-
id = input('', /* @ts-ignore */
|
|
2724
|
-
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2725
|
-
type = input('', /* @ts-ignore */
|
|
2726
|
-
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2727
|
-
content = input(null, /* @ts-ignore */
|
|
2728
|
-
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2729
|
-
props = input([], /* @ts-ignore */
|
|
2730
|
-
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2731
|
-
settings = input({}, /* @ts-ignore */
|
|
2732
|
-
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2733
|
-
index = input(0, /* @ts-ignore */
|
|
2734
|
-
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2735
|
-
url = computed(() => this.content()?.url || '', /* @ts-ignore */
|
|
2736
|
-
...(ngDevMode ? [{ debugName: "url" }] : /* istanbul ignore next */ []));
|
|
2737
|
-
embedType = computed(() => this.content()?.type || '', /* @ts-ignore */
|
|
2738
|
-
...(ngDevMode ? [{ debugName: "embedType" }] : /* istanbul ignore next */ []));
|
|
2739
|
-
width = computed(() => getDimensionAttribute(this.settings()?.width) || 700, /* @ts-ignore */
|
|
2740
|
-
...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
2741
|
-
height = computed(() => getDimensionAttribute(this.settings()?.height) || 400, /* @ts-ignore */
|
|
2742
|
-
...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
2743
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorEmbedRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2744
|
-
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 });
|
|
2745
|
-
}
|
|
2746
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorEmbedRenderer, decorators: [{
|
|
2747
|
-
type: Component,
|
|
2748
|
-
args: [{ selector: 'ngs-content-editor-embed-renderer', imports: [
|
|
2749
|
-
SafeResourceUrlPipe,
|
|
2750
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2751
|
-
'class': 'ngs-content-editor-embed-renderer',
|
|
2752
|
-
}, 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"] }]
|
|
2753
|
-
}], 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 }] }] } });
|
|
2754
|
-
|
|
2755
|
-
class ContentEditorHeadingRenderer {
|
|
2756
|
-
block = input(null, /* @ts-ignore */
|
|
2757
|
-
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2758
|
-
id = input('', /* @ts-ignore */
|
|
2759
|
-
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2760
|
-
type = input('', /* @ts-ignore */
|
|
2761
|
-
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2762
|
-
content = input('', /* @ts-ignore */
|
|
2763
|
-
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2764
|
-
settings = input({}, /* @ts-ignore */
|
|
2765
|
-
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2766
|
-
props = input([], /* @ts-ignore */
|
|
2767
|
-
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2768
|
-
index = input(0, /* @ts-ignore */
|
|
2769
|
-
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2770
|
-
html = computed(() => getHtmlContent(this.content()), /* @ts-ignore */
|
|
2771
|
-
...(ngDevMode ? [{ debugName: "html" }] : /* istanbul ignore next */ []));
|
|
2772
|
-
level = computed(() => {
|
|
2773
|
-
const level = this.settings()?.level;
|
|
2774
|
-
return level === 1 || level === 2 || level === 3 ? level : 2;
|
|
2775
|
-
}, /* @ts-ignore */
|
|
2776
|
-
...(ngDevMode ? [{ debugName: "level" }] : /* istanbul ignore next */ []));
|
|
2777
|
-
alignment = computed(() => getTextAlignment(this.props()), /* @ts-ignore */
|
|
2778
|
-
...(ngDevMode ? [{ debugName: "alignment" }] : /* istanbul ignore next */ []));
|
|
2779
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorHeadingRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2780
|
-
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 [innerHTML]=\"html() | safeHtml\"\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 [innerHTML]=\"html() | safeHtml\"\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 [innerHTML]=\"html() | safeHtml\"\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: "pipe", type: SafeHtmlPipe, name: "safeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2781
|
-
}
|
|
2782
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorHeadingRenderer, decorators: [{
|
|
2783
|
-
type: Component,
|
|
2784
|
-
args: [{ selector: 'ngs-content-editor-heading-renderer', imports: [
|
|
2785
|
-
SafeHtmlPipe,
|
|
2786
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2787
|
-
'class': 'ngs-content-editor-heading-renderer',
|
|
2788
|
-
'[class.level-1]': 'level() === 1',
|
|
2789
|
-
'[class.level-2]': 'level() === 2',
|
|
2790
|
-
'[class.level-3]': 'level() === 3',
|
|
2791
|
-
}, 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 [innerHTML]=\"html() | safeHtml\"\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 [innerHTML]=\"html() | safeHtml\"\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 [innerHTML]=\"html() | safeHtml\"\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"] }]
|
|
2792
|
-
}], 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 }] }] } });
|
|
2793
|
-
|
|
2794
|
-
class ContentEditorImageRenderer {
|
|
2795
|
-
block = input(null, /* @ts-ignore */
|
|
2796
|
-
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2797
|
-
id = input('', /* @ts-ignore */
|
|
2798
|
-
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2799
|
-
type = input('', /* @ts-ignore */
|
|
2800
|
-
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2801
|
-
content = input(null, /* @ts-ignore */
|
|
2802
|
-
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2803
|
-
props = input([], /* @ts-ignore */
|
|
2804
|
-
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2805
|
-
settings = input({}, /* @ts-ignore */
|
|
2806
|
-
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2807
|
-
index = input(0, /* @ts-ignore */
|
|
2808
|
-
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2809
|
-
src = computed(() => this.content()?.src || '', /* @ts-ignore */
|
|
2810
|
-
...(ngDevMode ? [{ debugName: "src" }] : /* istanbul ignore next */ []));
|
|
2811
|
-
alt = computed(() => this.content()?.alt || '', /* @ts-ignore */
|
|
2812
|
-
...(ngDevMode ? [{ debugName: "alt" }] : /* istanbul ignore next */ []));
|
|
2813
|
-
width = computed(() => getDimensionAttribute(this.settings()?.width), /* @ts-ignore */
|
|
2814
|
-
...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
2815
|
-
height = computed(() => getDimensionAttribute(this.settings()?.height), /* @ts-ignore */
|
|
2816
|
-
...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
2817
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorImageRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2818
|
-
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 });
|
|
2819
|
-
}
|
|
2820
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorImageRenderer, decorators: [{
|
|
2821
|
-
type: Component,
|
|
2822
|
-
args: [{ selector: 'ngs-content-editor-image-renderer', imports: [], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2823
|
-
'class': 'ngs-content-editor-image-renderer',
|
|
2824
|
-
}, 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"] }]
|
|
2825
|
-
}], 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 }] }] } });
|
|
2826
|
-
|
|
2827
|
-
class ContentEditorListRenderer {
|
|
2828
|
-
block = input(null, /* @ts-ignore */
|
|
2829
|
-
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2830
|
-
id = input('', /* @ts-ignore */
|
|
2831
|
-
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2832
|
-
type = input('', /* @ts-ignore */
|
|
2833
|
-
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2834
|
-
content = input([], /* @ts-ignore */
|
|
2835
|
-
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2836
|
-
props = input([], /* @ts-ignore */
|
|
2837
|
-
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2838
|
-
settings = input({}, /* @ts-ignore */
|
|
2839
|
-
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2840
|
-
index = input(0, /* @ts-ignore */
|
|
2841
|
-
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2842
|
-
items = computed(() => this.content() || [], /* @ts-ignore */
|
|
2843
|
-
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
2844
|
-
listStyle = computed(() => this.settings()?.listStyle || 'bullet', /* @ts-ignore */
|
|
2845
|
-
...(ngDevMode ? [{ debugName: "listStyle" }] : /* istanbul ignore next */ []));
|
|
2846
|
-
childItems(item) {
|
|
2847
|
-
return item.children || [];
|
|
2848
|
-
}
|
|
2849
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorListRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2850
|
-
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\" [innerHTML]=\"item.content | safeHtml\"></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: "pipe", type: SafeHtmlPipe, name: "safeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2851
|
-
}
|
|
2852
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorListRenderer, decorators: [{
|
|
2853
|
-
type: Component,
|
|
2854
|
-
args: [{ selector: 'ngs-content-editor-list-renderer', imports: [
|
|
2855
|
-
NgTemplateOutlet,
|
|
2856
|
-
SafeHtmlPipe,
|
|
2857
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2858
|
-
'class': 'ngs-content-editor-list-renderer',
|
|
2859
|
-
'[class.list-bullet]': "listStyle() === 'bullet'",
|
|
2860
|
-
'[class.list-ordered]': "listStyle() === 'ordered'",
|
|
2861
|
-
}, 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\" [innerHTML]=\"item.content | safeHtml\"></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"] }]
|
|
2862
|
-
}], 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 }] }] } });
|
|
2863
|
-
|
|
2864
|
-
class ContentEditorParagraphRenderer {
|
|
2865
|
-
block = input(null, /* @ts-ignore */
|
|
2866
|
-
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2867
|
-
id = input('', /* @ts-ignore */
|
|
2868
|
-
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2869
|
-
type = input('', /* @ts-ignore */
|
|
2870
|
-
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2871
|
-
content = input('', /* @ts-ignore */
|
|
2872
|
-
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2873
|
-
props = input([], /* @ts-ignore */
|
|
2874
|
-
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2875
|
-
settings = input({}, /* @ts-ignore */
|
|
2876
|
-
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2877
|
-
index = input(0, /* @ts-ignore */
|
|
2878
|
-
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2879
|
-
html = computed(() => getHtmlContent(this.content()), /* @ts-ignore */
|
|
2880
|
-
...(ngDevMode ? [{ debugName: "html" }] : /* istanbul ignore next */ []));
|
|
2881
|
-
alignment = computed(() => getTextAlignment(this.props()), /* @ts-ignore */
|
|
2882
|
-
...(ngDevMode ? [{ debugName: "alignment" }] : /* istanbul ignore next */ []));
|
|
2883
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorParagraphRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2884
|
-
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 [innerHTML]=\"html() | safeHtml\"\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: "pipe", type: SafeHtmlPipe, name: "safeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2885
|
-
}
|
|
2886
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorParagraphRenderer, decorators: [{
|
|
2887
|
-
type: Component,
|
|
2888
|
-
args: [{ selector: 'ngs-content-editor-paragraph-renderer', imports: [
|
|
2889
|
-
SafeHtmlPipe,
|
|
2890
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2891
|
-
'class': 'ngs-content-editor-paragraph-renderer',
|
|
2892
|
-
}, 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 [innerHTML]=\"html() | safeHtml\"\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"] }]
|
|
2893
|
-
}], 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 }] }] } });
|
|
2894
|
-
|
|
2895
|
-
class ContentEditorQuoteRenderer {
|
|
2896
|
-
block = input(null, /* @ts-ignore */
|
|
2897
|
-
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2898
|
-
id = input('', /* @ts-ignore */
|
|
2899
|
-
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2900
|
-
type = input('', /* @ts-ignore */
|
|
2901
|
-
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2902
|
-
content = input(null, /* @ts-ignore */
|
|
2903
|
-
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2904
|
-
props = input([], /* @ts-ignore */
|
|
2905
|
-
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2906
|
-
settings = input({}, /* @ts-ignore */
|
|
2907
|
-
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2908
|
-
index = input(0, /* @ts-ignore */
|
|
2909
|
-
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2910
|
-
quoteHtml = computed(() => getHtmlContent(this.content()?.cite?.content), /* @ts-ignore */
|
|
2911
|
-
...(ngDevMode ? [{ debugName: "quoteHtml" }] : /* istanbul ignore next */ []));
|
|
2912
|
-
captionHtml = computed(() => getHtmlContent(this.content()?.caption?.content), /* @ts-ignore */
|
|
2913
|
-
...(ngDevMode ? [{ debugName: "captionHtml" }] : /* istanbul ignore next */ []));
|
|
2914
|
-
quoteAlignment = computed(() => getTextAlignment(this.content()?.cite?.props), /* @ts-ignore */
|
|
2915
|
-
...(ngDevMode ? [{ debugName: "quoteAlignment" }] : /* istanbul ignore next */ []));
|
|
2916
|
-
captionAlignment = computed(() => getTextAlignment(this.content()?.caption?.props), /* @ts-ignore */
|
|
2917
|
-
...(ngDevMode ? [{ debugName: "captionAlignment" }] : /* istanbul ignore next */ []));
|
|
2918
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorQuoteRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2919
|
-
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 [innerHTML]=\"quoteHtml() | safeHtml\"\n></blockquote>\n@if (captionHtml()) {\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 [innerHTML]=\"captionHtml() | safeHtml\"\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: "pipe", type: SafeHtmlPipe, name: "safeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2920
|
-
}
|
|
2921
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorQuoteRenderer, decorators: [{
|
|
2922
|
-
type: Component,
|
|
2923
|
-
args: [{ selector: 'ngs-content-editor-quote-renderer', imports: [
|
|
2924
|
-
SafeHtmlPipe,
|
|
2925
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2926
|
-
'class': 'ngs-content-editor-quote-renderer',
|
|
2927
|
-
}, 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 [innerHTML]=\"quoteHtml() | safeHtml\"\n></blockquote>\n@if (captionHtml()) {\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 [innerHTML]=\"captionHtml() | safeHtml\"\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"] }]
|
|
2928
|
-
}], 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 }] }] } });
|
|
2929
|
-
|
|
2930
|
-
class ContentEditorTableRenderer {
|
|
2931
|
-
block = input(null, /* @ts-ignore */
|
|
2932
|
-
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2933
|
-
id = input('', /* @ts-ignore */
|
|
2934
|
-
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2935
|
-
type = input('', /* @ts-ignore */
|
|
2936
|
-
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2937
|
-
content = input([], /* @ts-ignore */
|
|
2938
|
-
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2939
|
-
props = input([], /* @ts-ignore */
|
|
2940
|
-
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2941
|
-
settings = input({}, /* @ts-ignore */
|
|
2942
|
-
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2943
|
-
index = input(0, /* @ts-ignore */
|
|
2944
|
-
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2945
|
-
rows = computed(() => this.content() || [], /* @ts-ignore */
|
|
2946
|
-
...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
|
|
2947
|
-
firstRow = computed(() => this.rows()[0] || [], /* @ts-ignore */
|
|
2948
|
-
...(ngDevMode ? [{ debugName: "firstRow" }] : /* istanbul ignore next */ []));
|
|
2949
|
-
width(cell) {
|
|
2950
|
-
return getDimensionAttribute(cell.options?.width);
|
|
2951
|
-
}
|
|
2952
|
-
colSpan(cell) {
|
|
2953
|
-
return cell.options?.colspan || 1;
|
|
2954
|
-
}
|
|
2955
|
-
rowSpan(cell) {
|
|
2956
|
-
return cell.options?.rowspan || 1;
|
|
2957
|
-
}
|
|
2958
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorTableRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2959
|
-
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) {\n <tr>\n @for (cell of row; track $index) {\n <td\n [attr.colspan]=\"colSpan(cell)\"\n [attr.rowspan]=\"rowSpan(cell)\"\n [innerHTML]=\"(cell.content || '') | safeHtml\"\n ></td>\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: "pipe", type: SafeHtmlPipe, name: "safeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2960
|
-
}
|
|
2961
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorTableRenderer, decorators: [{
|
|
2962
|
-
type: Component,
|
|
2963
|
-
args: [{ selector: 'ngs-content-editor-table-renderer', imports: [
|
|
2964
|
-
NativeTable,
|
|
2965
|
-
SafeHtmlPipe,
|
|
2966
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2967
|
-
'class': 'ngs-content-editor-table-renderer',
|
|
2968
|
-
}, 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) {\n <tr>\n @for (cell of row; track $index) {\n <td\n [attr.colspan]=\"colSpan(cell)\"\n [attr.rowspan]=\"rowSpan(cell)\"\n [innerHTML]=\"(cell.content || '') | safeHtml\"\n ></td>\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"] }]
|
|
2969
|
-
}], 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 }] }] } });
|
|
2970
|
-
|
|
2971
|
-
class ContentEditorVideoRenderer {
|
|
2972
|
-
block = input(null, /* @ts-ignore */
|
|
2973
|
-
...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
2974
|
-
id = input('', /* @ts-ignore */
|
|
2975
|
-
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
2976
|
-
type = input('', /* @ts-ignore */
|
|
2977
|
-
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
2978
|
-
content = input(null, /* @ts-ignore */
|
|
2979
|
-
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2980
|
-
props = input([], /* @ts-ignore */
|
|
2981
|
-
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
2982
|
-
settings = input({}, /* @ts-ignore */
|
|
2983
|
-
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2984
|
-
index = input(0, /* @ts-ignore */
|
|
2985
|
-
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
2986
|
-
src = computed(() => this.content()?.src || '', /* @ts-ignore */
|
|
2987
|
-
...(ngDevMode ? [{ debugName: "src" }] : /* istanbul ignore next */ []));
|
|
2988
|
-
caption = computed(() => this.content()?.caption || '', /* @ts-ignore */
|
|
2989
|
-
...(ngDevMode ? [{ debugName: "caption" }] : /* istanbul ignore next */ []));
|
|
2990
|
-
width = computed(() => getDimensionAttribute(this.settings()?.width), /* @ts-ignore */
|
|
2991
|
-
...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
2992
|
-
height = computed(() => getDimensionAttribute(this.settings()?.height), /* @ts-ignore */
|
|
2993
|
-
...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
2994
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorVideoRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2995
|
-
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 });
|
|
2996
|
-
}
|
|
2997
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorVideoRenderer, decorators: [{
|
|
2998
|
-
type: Component,
|
|
2999
|
-
args: [{ selector: 'ngs-content-editor-video-renderer', imports: [], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
3000
|
-
'class': 'ngs-content-editor-video-renderer',
|
|
3001
|
-
}, 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"] }]
|
|
3002
|
-
}], 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 }] }] } });
|
|
3003
|
-
|
|
3004
|
-
const CONTENT_EDITOR_DEFAULT_RENDERERS = [
|
|
3005
|
-
{
|
|
3006
|
-
type: 'paragraph',
|
|
3007
|
-
component: ContentEditorParagraphRenderer,
|
|
3008
|
-
},
|
|
3009
|
-
{
|
|
3010
|
-
type: 'heading',
|
|
3011
|
-
component: ContentEditorHeadingRenderer,
|
|
3012
|
-
},
|
|
3013
|
-
{
|
|
3014
|
-
type: 'code',
|
|
3015
|
-
component: ContentEditorCodeRenderer,
|
|
3016
|
-
},
|
|
3017
|
-
{
|
|
3018
|
-
type: 'divider',
|
|
3019
|
-
component: ContentEditorDividerRenderer,
|
|
3020
|
-
},
|
|
3021
|
-
{
|
|
3022
|
-
type: 'image',
|
|
3023
|
-
component: ContentEditorImageRenderer,
|
|
3024
|
-
},
|
|
3025
|
-
{
|
|
3026
|
-
type: 'video',
|
|
3027
|
-
component: ContentEditorVideoRenderer,
|
|
3028
|
-
},
|
|
3029
|
-
{
|
|
3030
|
-
type: 'bulletList',
|
|
3031
|
-
component: ContentEditorListRenderer,
|
|
3032
|
-
},
|
|
3033
|
-
{
|
|
3034
|
-
type: 'orderedList',
|
|
3035
|
-
component: ContentEditorListRenderer,
|
|
3036
|
-
},
|
|
3037
|
-
{
|
|
3038
|
-
type: 'table',
|
|
3039
|
-
component: ContentEditorTableRenderer,
|
|
3040
|
-
},
|
|
3041
|
-
{
|
|
3042
|
-
type: 'quote',
|
|
3043
|
-
component: ContentEditorQuoteRenderer,
|
|
3044
|
-
},
|
|
3045
|
-
{
|
|
3046
|
-
type: 'embed',
|
|
3047
|
-
component: ContentEditorEmbedRenderer,
|
|
3048
|
-
},
|
|
3049
|
-
];
|
|
3050
|
-
|
|
3051
|
-
class ContentEditorRenderer {
|
|
3052
|
-
providedRendererGroups = inject(CONTENT_EDITOR_BLOCK_RENDERERS, {
|
|
3053
|
-
optional: true,
|
|
3054
|
-
}) || [];
|
|
3055
|
-
content = input([], /* @ts-ignore */
|
|
3056
|
-
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
3057
|
-
blocks = input(null, /* @ts-ignore */
|
|
3058
|
-
...(ngDevMode ? [{ debugName: "blocks" }] : /* istanbul ignore next */ []));
|
|
3059
|
-
rendererMap = computed(() => {
|
|
3060
|
-
const renderers = [
|
|
3061
|
-
...CONTENT_EDITOR_DEFAULT_RENDERERS,
|
|
3062
|
-
...this.providedRendererGroups.flat(),
|
|
3063
|
-
];
|
|
3064
|
-
return new Map(renderers.map(renderer => [renderer.type, renderer.component]));
|
|
3065
|
-
}, /* @ts-ignore */
|
|
3066
|
-
...(ngDevMode ? [{ debugName: "rendererMap" }] : /* istanbul ignore next */ []));
|
|
3067
|
-
items = computed(() => {
|
|
3068
|
-
const content = this.blocks() || this.content() || [];
|
|
3069
|
-
const rendererMap = this.rendererMap();
|
|
3070
|
-
return content.map((block, index) => ({
|
|
3071
|
-
block,
|
|
3072
|
-
component: rendererMap.get(block.type) || null,
|
|
3073
|
-
inputs: {
|
|
3074
|
-
block,
|
|
3075
|
-
id: block.id,
|
|
3076
|
-
type: block.type,
|
|
3077
|
-
content: block.content,
|
|
3078
|
-
props: block.props || [],
|
|
3079
|
-
settings: block.settings || {},
|
|
3080
|
-
index,
|
|
3081
|
-
},
|
|
3082
|
-
}));
|
|
3083
|
-
}, /* @ts-ignore */
|
|
3084
|
-
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
3085
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3086
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: ContentEditorRenderer, isStandalone: true, selector: "ngs-content-editor-renderer", inputs: { 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" }, 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}\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 });
|
|
3087
|
-
}
|
|
3088
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: ContentEditorRenderer, decorators: [{
|
|
3089
|
-
type: Component,
|
|
3090
|
-
args: [{ selector: 'ngs-content-editor-renderer', exportAs: 'ngsContentEditorRenderer', imports: [
|
|
3091
|
-
NgComponentOutlet,
|
|
3092
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
3093
|
-
'class': 'ngs-content-editor-renderer prose max-w-full',
|
|
3094
|
-
}, 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}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"] }]
|
|
3095
|
-
}], propDecorators: { content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], blocks: [{ type: i0.Input, args: [{ isSignal: true, alias: "blocks", required: false }] }] } });
|
|
3096
|
-
|
|
3097
|
-
/**
|
|
3098
|
-
* Generated bundle index. Do not edit.
|
|
3099
|
-
*/
|
|
3100
|
-
|
|
3101
|
-
export { BlockSelectionDirective as B, ContentBuilderStore as C, TextSelectionPopupDirective as T, CONTENT_BUILDER as a, CONTENT_EDITOR_BLOCK as b, CONTENT_EDITOR_BLOCK_RENDERERS as c, CONTENT_EDITOR_DEFAULT_RENDERERS as d, CommandBarComponent as e, ContentBuilderComponent as f, ContentEditorCodeRenderer as g, ContentEditorDividerRenderer as h, ContentEditorEmbedRenderer as i, ContentEditorHeadingRenderer as j, ContentEditorImageRenderer as k, ContentEditorListRenderer as l, ContentEditorParagraphRenderer as m, ContentEditorQuoteRenderer as n, ContentEditorRenderer as o, ContentEditorTableRenderer as p, ContentEditorVideoRenderer as q, provideContentEditorRenderer as r, provideContentEditorRenderers as s };
|
|
3102
|
-
//# sourceMappingURL=ngstarter-ui-components-content-editor-ngstarter-ui-components-content-editor-CV959OGj.mjs.map
|