@shival99/z-ui 2.1.28 → 2.1.29
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/package.json +1 -1
- package/types/shival99-z-ui-components-z-select.d.ts +1 -1
- package/fesm2022/shival99-z-ui-components-z-autocomplete.mjs +0 -1079
- package/fesm2022/shival99-z-ui-components-z-autocomplete.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-drawer.mjs +0 -742
- package/fesm2022/shival99-z-ui-components-z-drawer.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-dropdown-menu.mjs +0 -58
- package/fesm2022/shival99-z-ui-components-z-dropdown-menu.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-editor.mjs +0 -1750
- package/fesm2022/shival99-z-ui-components-z-editor.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-gallery.mjs +0 -2419
- package/fesm2022/shival99-z-ui-components-z-gallery.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-kanban.mjs +0 -981
- package/fesm2022/shival99-z-ui-components-z-kanban.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-marquee.mjs +0 -70
- package/fesm2022/shival99-z-ui-components-z-marquee.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-media-player.mjs +0 -668
- package/fesm2022/shival99-z-ui-components-z-media-player.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-menu.mjs +0 -843
- package/fesm2022/shival99-z-ui-components-z-menu.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-metric-card.mjs +0 -128
- package/fesm2022/shival99-z-ui-components-z-metric-card.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-pagination.mjs +0 -158
- package/fesm2022/shival99-z-ui-components-z-pagination.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-qrcode.mjs +0 -383
- package/fesm2022/shival99-z-ui-components-z-qrcode.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-radio.mjs +0 -167
- package/fesm2022/shival99-z-ui-components-z-radio.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-scrollarea.mjs +0 -131
- package/fesm2022/shival99-z-ui-components-z-scrollarea.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-show-more.mjs +0 -121
- package/fesm2022/shival99-z-ui-components-z-show-more.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-skeleton-auto.mjs +0 -61
- package/fesm2022/shival99-z-ui-components-z-skeleton-auto.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-steps.mjs +0 -396
- package/fesm2022/shival99-z-ui-components-z-steps.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-table.mjs +0 -10508
- package/fesm2022/shival99-z-ui-components-z-table.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-tabs.mjs +0 -507
- package/fesm2022/shival99-z-ui-components-z-tabs.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-tags.mjs +0 -349
- package/fesm2022/shival99-z-ui-components-z-tags.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-timeline.mjs +0 -237
- package/fesm2022/shival99-z-ui-components-z-timeline.mjs.map +0 -1
- package/fesm2022/shival99-z-ui-components-z-upload.mjs +0 -523
- package/fesm2022/shival99-z-ui-components-z-upload.mjs.map +0 -1
- package/types/shival99-z-ui-components-z-autocomplete.d.ts +0 -290
- package/types/shival99-z-ui-components-z-drawer.d.ts +0 -266
- package/types/shival99-z-ui-components-z-dropdown-menu.d.ts +0 -54
- package/types/shival99-z-ui-components-z-editor.d.ts +0 -337
- package/types/shival99-z-ui-components-z-gallery.d.ts +0 -402
- package/types/shival99-z-ui-components-z-kanban.d.ts +0 -237
- package/types/shival99-z-ui-components-z-marquee.d.ts +0 -35
- package/types/shival99-z-ui-components-z-media-player.d.ts +0 -124
- package/types/shival99-z-ui-components-z-menu.d.ts +0 -222
- package/types/shival99-z-ui-components-z-metric-card.d.ts +0 -67
- package/types/shival99-z-ui-components-z-pagination.d.ts +0 -55
- package/types/shival99-z-ui-components-z-qrcode.d.ts +0 -76
- package/types/shival99-z-ui-components-z-radio.d.ts +0 -69
- package/types/shival99-z-ui-components-z-scrollarea.d.ts +0 -46
- package/types/shival99-z-ui-components-z-show-more.d.ts +0 -36
- package/types/shival99-z-ui-components-z-skeleton-auto.d.ts +0 -35
- package/types/shival99-z-ui-components-z-steps.d.ts +0 -106
- package/types/shival99-z-ui-components-z-table.d.ts +0 -1924
- package/types/shival99-z-ui-components-z-tabs.d.ts +0 -92
- package/types/shival99-z-ui-components-z-tags.d.ts +0 -128
- package/types/shival99-z-ui-components-z-timeline.d.ts +0 -71
- package/types/shival99-z-ui-components-z-upload.d.ts +0 -153
|
@@ -1,1750 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, Injector, DestroyRef, viewChild, output, input, signal, computed, afterNextRender, effect, forwardRef, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
-
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
-
import * as i1 from '@angular/forms';
|
|
5
|
-
import { NgControl, NgModel, PristineChangeEvent, TouchedChangeEvent, FormsModule, ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
6
|
-
import { TranslatePipe } from '@ngx-translate/core';
|
|
7
|
-
import { ZButtonComponent } from '@shival99/z-ui/components/z-button';
|
|
8
|
-
import { ZIconComponent } from '@shival99/z-ui/components/z-icon';
|
|
9
|
-
import { ZInputComponent } from '@shival99/z-ui/components/z-input';
|
|
10
|
-
import { ZPopoverDirective } from '@shival99/z-ui/components/z-popover';
|
|
11
|
-
import { ZTooltipDirective } from '@shival99/z-ui/components/z-tooltip';
|
|
12
|
-
import { ZTranslateService } from '@shival99/z-ui/services';
|
|
13
|
-
import { zTransform, zUuid, Z_EMOJI_SHEET, zMergeClasses, zCreateEvent, Z_EMOJI_KEYWORDS } from '@shival99/z-ui/utils';
|
|
14
|
-
import { Editor, posToDOMRect } from '@tiptap/core';
|
|
15
|
-
import BubbleMenu from '@tiptap/extension-bubble-menu';
|
|
16
|
-
import Code from '@tiptap/extension-code';
|
|
17
|
-
import HorizontalRule from '@tiptap/extension-horizontal-rule';
|
|
18
|
-
import Link from '@tiptap/extension-link';
|
|
19
|
-
import Mention from '@tiptap/extension-mention';
|
|
20
|
-
import Placeholder from '@tiptap/extension-placeholder';
|
|
21
|
-
import TextAlign from '@tiptap/extension-text-align';
|
|
22
|
-
import { TextStyle, Color, BackgroundColor } from '@tiptap/extension-text-style';
|
|
23
|
-
import FontSize from '@tiptap/extension-text-style/font-size';
|
|
24
|
-
import Underline from '@tiptap/extension-underline';
|
|
25
|
-
import { Markdown } from '@tiptap/markdown';
|
|
26
|
-
import { TextSelection } from '@tiptap/pm/state';
|
|
27
|
-
import StarterKit from '@tiptap/starter-kit';
|
|
28
|
-
import { merge, filter } from 'rxjs';
|
|
29
|
-
import ImageResize from 'tiptap-extension-resize-image';
|
|
30
|
-
import { cva } from 'class-variance-authority';
|
|
31
|
-
|
|
32
|
-
const Z_EDITOR_DEFAULT_TOOLBAR = [
|
|
33
|
-
{ id: 'undo', icon: 'lucideUndo', label: 'Undo' },
|
|
34
|
-
{ id: 'redo', icon: 'lucideRedo', label: 'Redo' },
|
|
35
|
-
{ id: 'bold', icon: 'lucideBold', label: 'Bold' },
|
|
36
|
-
{ id: 'italic', icon: 'lucideItalic', label: 'Italic' },
|
|
37
|
-
{ id: 'underline', icon: 'lucideUnderline', label: 'Underline' },
|
|
38
|
-
{ id: 'strike', icon: 'lucideStrikethrough', label: 'Strike' },
|
|
39
|
-
{ id: 'code', icon: 'lucideCode', label: 'Code' },
|
|
40
|
-
{ id: 'blockStyle', icon: 'lucidePilcrow', label: 'Block style' },
|
|
41
|
-
{ id: 'bulletList', icon: 'lucideList', label: 'Bullet list' },
|
|
42
|
-
{ id: 'orderedList', icon: 'lucideListOrdered', label: 'Ordered list' },
|
|
43
|
-
{ id: 'blockquote', icon: 'lucideQuote', label: 'Blockquote' },
|
|
44
|
-
{ id: 'codeBlock', icon: 'lucideFileCode', label: 'Code block' },
|
|
45
|
-
{ id: 'link', icon: 'lucideLink', label: 'Link' },
|
|
46
|
-
{ id: 'image', icon: 'lucideImage', label: 'Image' },
|
|
47
|
-
{ id: 'emoji', icon: 'lucideSmilePlus', label: 'Emoji' },
|
|
48
|
-
{ id: 'textColor', icon: 'lucidePalette', label: 'Text color' },
|
|
49
|
-
{ id: 'backgroundColor', icon: 'lucideHighlighter', label: 'Background color' },
|
|
50
|
-
{ id: 'align', icon: 'lucideAlignLeft', label: 'Align' },
|
|
51
|
-
{ id: 'horizontalRule', icon: 'lucideMinus', label: 'Horizontal rule' },
|
|
52
|
-
{ id: 'clearFormatting', icon: 'lucideRemoveFormatting', label: 'Clear formatting' },
|
|
53
|
-
];
|
|
54
|
-
const Z_EDITOR_COLOR_SWATCHES = [
|
|
55
|
-
'#000000',
|
|
56
|
-
'#111827',
|
|
57
|
-
'#374151',
|
|
58
|
-
'#6b7280',
|
|
59
|
-
'#9ca3af',
|
|
60
|
-
'#ffffff',
|
|
61
|
-
'#7f1d1d',
|
|
62
|
-
'#ef4444',
|
|
63
|
-
'#f97316',
|
|
64
|
-
'#f59e0b',
|
|
65
|
-
'#eab308',
|
|
66
|
-
'#365314',
|
|
67
|
-
'#22c55e',
|
|
68
|
-
'#0f766e',
|
|
69
|
-
'#06b6d4',
|
|
70
|
-
'#1d4ed8',
|
|
71
|
-
'#3b82f6',
|
|
72
|
-
'#8b5cf6',
|
|
73
|
-
'#6d28d9',
|
|
74
|
-
'#ec4899',
|
|
75
|
-
];
|
|
76
|
-
const Z_EDITOR_BACKGROUND_SWATCHES = [
|
|
77
|
-
'#ffffff',
|
|
78
|
-
'#f9fafb',
|
|
79
|
-
'#f3f4f6',
|
|
80
|
-
'#e5e7eb',
|
|
81
|
-
'#d1d5db',
|
|
82
|
-
'#fef3c7',
|
|
83
|
-
'#fde68a',
|
|
84
|
-
'#ffedd5',
|
|
85
|
-
'#fed7aa',
|
|
86
|
-
'#fee2e2',
|
|
87
|
-
'#fecaca',
|
|
88
|
-
'#fce7f3',
|
|
89
|
-
'#fbcfe8',
|
|
90
|
-
'#ede9fe',
|
|
91
|
-
'#ddd6fe',
|
|
92
|
-
'#dbeafe',
|
|
93
|
-
'#bfdbfe',
|
|
94
|
-
'#cffafe',
|
|
95
|
-
'#a5f3fc',
|
|
96
|
-
'#dcfce7',
|
|
97
|
-
];
|
|
98
|
-
const Z_EDITOR_SLASH_COMMANDS = [
|
|
99
|
-
{
|
|
100
|
-
id: 'text',
|
|
101
|
-
command: 'paragraph',
|
|
102
|
-
icon: 'lucideType',
|
|
103
|
-
label: 'Text',
|
|
104
|
-
description: 'Plain paragraph text',
|
|
105
|
-
group: 'Formatting',
|
|
106
|
-
aliases: ['paragraph', 'p'],
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
id: 'standard',
|
|
110
|
-
command: 'paragraph',
|
|
111
|
-
icon: 'lucideType',
|
|
112
|
-
label: 'Standard',
|
|
113
|
-
description: '',
|
|
114
|
-
group: 'Formatting',
|
|
115
|
-
aliases: ['standard', 'normal'],
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
id: 'small',
|
|
119
|
-
command: 'small',
|
|
120
|
-
icon: 'lucideCaseLower',
|
|
121
|
-
label: 'Small',
|
|
122
|
-
description: '',
|
|
123
|
-
group: 'Formatting',
|
|
124
|
-
aliases: ['small', 'caption'],
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
id: 'heading-1',
|
|
128
|
-
command: 'heading1',
|
|
129
|
-
icon: 'lucideHeading1',
|
|
130
|
-
label: 'Heading 1',
|
|
131
|
-
description: 'Large section heading',
|
|
132
|
-
group: 'Formatting',
|
|
133
|
-
aliases: ['h1', 'title'],
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
id: 'heading-2',
|
|
137
|
-
command: 'heading2',
|
|
138
|
-
icon: 'lucideHeading2',
|
|
139
|
-
label: 'Heading 2',
|
|
140
|
-
description: 'Medium section heading',
|
|
141
|
-
group: 'Formatting',
|
|
142
|
-
aliases: ['h2', 'subtitle'],
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
id: 'heading-3',
|
|
146
|
-
command: 'heading3',
|
|
147
|
-
icon: 'lucideHeading3',
|
|
148
|
-
label: 'Heading 3',
|
|
149
|
-
description: 'Small section heading',
|
|
150
|
-
group: 'Formatting',
|
|
151
|
-
aliases: ['h3'],
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
id: 'heading-4',
|
|
155
|
-
command: 'heading4',
|
|
156
|
-
icon: 'lucideHeading4',
|
|
157
|
-
label: 'Heading 4',
|
|
158
|
-
description: '',
|
|
159
|
-
group: 'Formatting',
|
|
160
|
-
aliases: ['h4'],
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
id: 'bullet-list',
|
|
164
|
-
command: 'bulletList',
|
|
165
|
-
icon: 'lucideList',
|
|
166
|
-
label: 'Bullet list',
|
|
167
|
-
description: 'Unordered list',
|
|
168
|
-
group: 'Lists',
|
|
169
|
-
aliases: ['ul', 'list'],
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
id: 'ordered-list',
|
|
173
|
-
command: 'orderedList',
|
|
174
|
-
icon: 'lucideListOrdered',
|
|
175
|
-
label: 'Ordered list',
|
|
176
|
-
description: 'Numbered list',
|
|
177
|
-
group: 'Lists',
|
|
178
|
-
aliases: ['ol', 'number'],
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
id: 'alphabetical-list',
|
|
182
|
-
command: 'orderedList',
|
|
183
|
-
icon: 'lucideListOrdered',
|
|
184
|
-
label: 'Alphabetical list',
|
|
185
|
-
description: '',
|
|
186
|
-
group: 'Lists',
|
|
187
|
-
aliases: ['ordered', 'ol', 'number', 'alphabetical'],
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
id: 'blockquote',
|
|
191
|
-
command: 'blockquote',
|
|
192
|
-
icon: 'lucideQuote',
|
|
193
|
-
label: 'Blockquote',
|
|
194
|
-
description: 'Quote block',
|
|
195
|
-
group: 'Blocks',
|
|
196
|
-
aliases: ['quote'],
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
id: 'code-block',
|
|
200
|
-
command: 'codeBlock',
|
|
201
|
-
icon: 'lucideFileCode',
|
|
202
|
-
label: 'Code block',
|
|
203
|
-
description: 'Preformatted code',
|
|
204
|
-
group: 'Blocks',
|
|
205
|
-
aliases: ['code', 'pre'],
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
id: 'horizontal-rule',
|
|
209
|
-
command: 'horizontalRule',
|
|
210
|
-
icon: 'lucideMinus',
|
|
211
|
-
label: 'Divider',
|
|
212
|
-
description: 'Horizontal separator',
|
|
213
|
-
group: 'Insert',
|
|
214
|
-
aliases: ['hr', 'line', 'divider'],
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
id: 'image',
|
|
218
|
-
command: 'image',
|
|
219
|
-
icon: 'lucideImage',
|
|
220
|
-
label: 'Image',
|
|
221
|
-
description: 'Upload image',
|
|
222
|
-
group: 'Insert',
|
|
223
|
-
aliases: ['photo', 'picture'],
|
|
224
|
-
},
|
|
225
|
-
];
|
|
226
|
-
|
|
227
|
-
const zEditorVariants = cva([
|
|
228
|
-
'z-editor block w-full rounded-[0.375rem] border border-input bg-white shadow-xs',
|
|
229
|
-
'transition-[border-color,box-shadow,background-color,color,opacity] duration-200',
|
|
230
|
-
'dark:bg-input/30 dark:border-input',
|
|
231
|
-
'outline-none',
|
|
232
|
-
], {
|
|
233
|
-
variants: {
|
|
234
|
-
zSize: {
|
|
235
|
-
sm: '[&_.z-editor-prosemirror]:min-h-24 [&_.z-editor-prosemirror]:text-sm',
|
|
236
|
-
default: '[&_.z-editor-prosemirror]:min-h-40 [&_.z-editor-prosemirror]:text-sm',
|
|
237
|
-
lg: '[&_.z-editor-prosemirror]:min-h-60 [&_.z-editor-prosemirror]:text-base',
|
|
238
|
-
},
|
|
239
|
-
zStatus: {
|
|
240
|
-
default: 'focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]',
|
|
241
|
-
error: 'border-destructive! ring-destructive/20 ring-[3px] focus-within:border-destructive! focus-within:ring-destructive/30',
|
|
242
|
-
disabled: 'opacity-50 cursor-not-allowed bg-muted! text-muted-foreground',
|
|
243
|
-
readonly: 'bg-muted/50! text-muted-foreground cursor-default',
|
|
244
|
-
},
|
|
245
|
-
zPlaceholderMode: {
|
|
246
|
-
firstLine: 'z-editor-placeholder-first-line',
|
|
247
|
-
everyLine: '',
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
defaultVariants: {
|
|
251
|
-
zSize: 'default',
|
|
252
|
-
zStatus: 'default',
|
|
253
|
-
zPlaceholderMode: 'everyLine',
|
|
254
|
-
},
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
class ZEditorComponent {
|
|
258
|
-
static _bubbleMenuOffset = 8;
|
|
259
|
-
_injector = inject(Injector);
|
|
260
|
-
_destroyRef = inject(DestroyRef);
|
|
261
|
-
_zTranslate = inject(ZTranslateService);
|
|
262
|
-
_editorHost = viewChild.required('editorHost');
|
|
263
|
-
_floatingToolbar = viewChild.required('floatingToolbar');
|
|
264
|
-
_slashMenuTrigger = viewChild.required('slashMenuTrigger');
|
|
265
|
-
_linkPopoverTrigger = viewChild.required('linkPopoverTrigger');
|
|
266
|
-
_slashMenuScrollHost = viewChild('slashMenuScrollHost', ...(ngDevMode ? [{ debugName: "_slashMenuScrollHost" }] : []));
|
|
267
|
-
zOnChange = output();
|
|
268
|
-
zOnFocus = output();
|
|
269
|
-
zOnBlur = output();
|
|
270
|
-
zControl = output();
|
|
271
|
-
zEvent = output();
|
|
272
|
-
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : []));
|
|
273
|
-
zSize = input('default', ...(ngDevMode ? [{ debugName: "zSize" }] : []));
|
|
274
|
-
zLabel = input('', ...(ngDevMode ? [{ debugName: "zLabel" }] : []));
|
|
275
|
-
zLabelClass = input('', ...(ngDevMode ? [{ debugName: "zLabelClass" }] : []));
|
|
276
|
-
zPlaceholder = input('', ...(ngDevMode ? [{ debugName: "zPlaceholder" }] : []));
|
|
277
|
-
zRequired = input(false, { ...(ngDevMode ? { debugName: "zRequired" } : {}), transform: zTransform });
|
|
278
|
-
zDisabled = input(false, { ...(ngDevMode ? { debugName: "zDisabled" } : {}), transform: zTransform });
|
|
279
|
-
zReadonly = input(false, { ...(ngDevMode ? { debugName: "zReadonly" } : {}), transform: zTransform });
|
|
280
|
-
zContentType = input('html', ...(ngDevMode ? [{ debugName: "zContentType" }] : []));
|
|
281
|
-
zToolbar = input(Z_EDITOR_DEFAULT_TOOLBAR, ...(ngDevMode ? [{ debugName: "zToolbar" }] : []));
|
|
282
|
-
zTipTap = input({}, ...(ngDevMode ? [{ debugName: "zTipTap" }] : []));
|
|
283
|
-
zValidators = input([], ...(ngDevMode ? [{ debugName: "zValidators" }] : []));
|
|
284
|
-
editorId = zUuid('z-editor');
|
|
285
|
-
linkInputId = zUuid('z-editor-link');
|
|
286
|
-
_value = signal('', ...(ngDevMode ? [{ debugName: "_value" }] : []));
|
|
287
|
-
_disabled = signal(false, ...(ngDevMode ? [{ debugName: "_disabled" }] : []));
|
|
288
|
-
_formControl = signal(null, ...(ngDevMode ? [{ debugName: "_formControl" }] : []));
|
|
289
|
-
_formStateVersion = signal(0, ...(ngDevMode ? [{ debugName: "_formStateVersion" }] : []));
|
|
290
|
-
_isNgModel = signal(false, ...(ngDevMode ? [{ debugName: "_isNgModel" }] : []));
|
|
291
|
-
_selectionVersion = signal(0, ...(ngDevMode ? [{ debugName: "_selectionVersion" }] : []));
|
|
292
|
-
_plainText = signal('', ...(ngDevMode ? [{ debugName: "_plainText" }] : []));
|
|
293
|
-
slashMenuState = signal({
|
|
294
|
-
visible: false,
|
|
295
|
-
query: '',
|
|
296
|
-
from: 0,
|
|
297
|
-
to: 0,
|
|
298
|
-
left: 0,
|
|
299
|
-
top: 0,
|
|
300
|
-
}, ...(ngDevMode ? [{ debugName: "slashMenuState" }] : []));
|
|
301
|
-
slashMenuActiveIndex = signal(0, ...(ngDevMode ? [{ debugName: "slashMenuActiveIndex" }] : []));
|
|
302
|
-
linkPopoverState = signal({
|
|
303
|
-
visible: false,
|
|
304
|
-
left: 0,
|
|
305
|
-
top: 0,
|
|
306
|
-
width: 0,
|
|
307
|
-
height: 0,
|
|
308
|
-
}, ...(ngDevMode ? [{ debugName: "linkPopoverState" }] : []));
|
|
309
|
-
linkUrl = signal('', ...(ngDevMode ? [{ debugName: "linkUrl" }] : []));
|
|
310
|
-
activeLinkHref = signal('', ...(ngDevMode ? [{ debugName: "activeLinkHref" }] : []));
|
|
311
|
-
linkValidators = [
|
|
312
|
-
{
|
|
313
|
-
error: 'url',
|
|
314
|
-
message: 'i18n_z_ui_editor_invalid_url',
|
|
315
|
-
validate: value => this._normalizeUrl(String(value ?? '')) !== '',
|
|
316
|
-
},
|
|
317
|
-
];
|
|
318
|
-
textColorSwatches = Z_EDITOR_COLOR_SWATCHES;
|
|
319
|
-
backgroundColorSwatches = Z_EDITOR_BACKGROUND_SWATCHES;
|
|
320
|
-
slashCommands = Z_EDITOR_SLASH_COMMANDS;
|
|
321
|
-
blockStyleOptions = [
|
|
322
|
-
{ command: 'paragraph', icon: 'lucidePilcrow', label: 'Paragraph' },
|
|
323
|
-
{ command: 'heading1', icon: 'lucideHeading1', label: 'Heading 1' },
|
|
324
|
-
{ command: 'heading2', icon: 'lucideHeading2', label: 'Heading 2' },
|
|
325
|
-
{ command: 'heading3', icon: 'lucideHeading3', label: 'Heading 3' },
|
|
326
|
-
{ command: 'heading4', icon: 'lucideHeading4', label: 'Heading 4' },
|
|
327
|
-
];
|
|
328
|
-
alignOptions = [
|
|
329
|
-
{ command: 'alignLeft', icon: 'lucideAlignLeft', label: 'Left' },
|
|
330
|
-
{ command: 'alignCenter', icon: 'lucideAlignCenter', label: 'Center' },
|
|
331
|
-
{ command: 'alignRight', icon: 'lucideAlignRight', label: 'Right' },
|
|
332
|
-
{ command: 'alignJustify', icon: 'lucideAlignJustify', label: 'Justify' },
|
|
333
|
-
];
|
|
334
|
-
_toolbarShortcutLabels = {
|
|
335
|
-
bold: 'Ctrl+B',
|
|
336
|
-
italic: 'Ctrl+I',
|
|
337
|
-
underline: 'Ctrl+U',
|
|
338
|
-
strike: 'Ctrl+Shift+S',
|
|
339
|
-
code: 'Ctrl+E',
|
|
340
|
-
link: 'Ctrl+K',
|
|
341
|
-
clearFormatting: 'Ctrl+\\',
|
|
342
|
-
undo: 'Ctrl+Z',
|
|
343
|
-
redo: 'Ctrl+Y',
|
|
344
|
-
};
|
|
345
|
-
uiState = signal({
|
|
346
|
-
touched: false,
|
|
347
|
-
dirty: false,
|
|
348
|
-
}, ...(ngDevMode ? [{ debugName: "uiState" }] : []));
|
|
349
|
-
_customError = signal(null, ...(ngDevMode ? [{ debugName: "_customError" }] : []));
|
|
350
|
-
_onChange = () => void 0;
|
|
351
|
-
_onTouched = () => void 0;
|
|
352
|
-
_ngControl = null;
|
|
353
|
-
_editor = null;
|
|
354
|
-
_pendingValue = '';
|
|
355
|
-
_linkSelection = null;
|
|
356
|
-
_linkAnchorElement = null;
|
|
357
|
-
_emojiPopoverControl = null;
|
|
358
|
-
_blockStylePopoverControl = null;
|
|
359
|
-
_alignPopoverControl = null;
|
|
360
|
-
_textColorPopoverControl = null;
|
|
361
|
-
_backgroundColorPopoverControl = null;
|
|
362
|
-
_slashMenuPopoverControl = null;
|
|
363
|
-
_dismissedSlashMenu = null;
|
|
364
|
-
_linkPopoverControl = null;
|
|
365
|
-
_resizeObserver = null;
|
|
366
|
-
_resizeListenerCleanup = null;
|
|
367
|
-
_bubbleMenuPositionFrame = null;
|
|
368
|
-
emojiCategories = Z_EMOJI_SHEET;
|
|
369
|
-
activeEmojiCategoryId = signal(this.emojiCategories[0]?.id ?? 'smileys-people', ...(ngDevMode ? [{ debugName: "activeEmojiCategoryId" }] : []));
|
|
370
|
-
emojiSearch = signal('', ...(ngDevMode ? [{ debugName: "emojiSearch" }] : []));
|
|
371
|
-
activeEmojiCategory = computed(() => this.emojiCategories.find(category => category.id === this.activeEmojiCategoryId()) ?? this.emojiCategories[0], ...(ngDevMode ? [{ debugName: "activeEmojiCategory" }] : []));
|
|
372
|
-
activeEmojiCategoryLabel = computed(() => this.activeEmojiCategory()?.labelKey ?? 'i18n_z_ui_emoji_category_smileys', ...(ngDevMode ? [{ debugName: "activeEmojiCategoryLabel" }] : []));
|
|
373
|
-
emojiSearchQuery = computed(() => this.emojiSearch().trim().toLowerCase(), ...(ngDevMode ? [{ debugName: "emojiSearchQuery" }] : []));
|
|
374
|
-
activeEmojis = computed(() => {
|
|
375
|
-
const query = this.emojiSearchQuery();
|
|
376
|
-
if (query) {
|
|
377
|
-
return this._searchEmojis(query);
|
|
378
|
-
}
|
|
379
|
-
return this.activeEmojiCategory()?.emojis ?? [];
|
|
380
|
-
}, ...(ngDevMode ? [{ debugName: "activeEmojis" }] : []));
|
|
381
|
-
hasEmojiResults = computed(() => this.activeEmojis().length > 0, ...(ngDevMode ? [{ debugName: "hasEmojiResults" }] : []));
|
|
382
|
-
isDisabled = computed(() => this._disabled() || this.zDisabled(), ...(ngDevMode ? [{ debugName: "isDisabled" }] : []));
|
|
383
|
-
showToolbar = computed(() => this.zToolbar() !== false && !this.zReadonly() && !this.isDisabled(), ...(ngDevMode ? [{ debugName: "showToolbar" }] : []));
|
|
384
|
-
normalizedLinkUrl = computed(() => this._normalizeUrl(this.linkUrl()), ...(ngDevMode ? [{ debugName: "normalizedLinkUrl" }] : []));
|
|
385
|
-
activeTextColor = computed(() => this._getTextStyleAttribute('color') || '#111827', ...(ngDevMode ? [{ debugName: "activeTextColor" }] : []));
|
|
386
|
-
activeBackgroundColor = computed(() => this._getTextStyleAttribute('backgroundColor') || '#ffffff', ...(ngDevMode ? [{ debugName: "activeBackgroundColor" }] : []));
|
|
387
|
-
activeBlockStyle = computed(() => this._getActiveBlockStyle(), ...(ngDevMode ? [{ debugName: "activeBlockStyle" }] : []));
|
|
388
|
-
activeBlockStyleLabel = computed(() => this.blockStyleOptions.find(option => option.command === this.activeBlockStyle())?.label ?? 'Paragraph', ...(ngDevMode ? [{ debugName: "activeBlockStyleLabel" }] : []));
|
|
389
|
-
activeAlign = computed(() => this._getActiveAlign(), ...(ngDevMode ? [{ debugName: "activeAlign" }] : []));
|
|
390
|
-
activeAlignLabel = computed(() => this.alignOptions.find(option => option.command === this.activeAlign())?.label ?? 'Left', ...(ngDevMode ? [{ debugName: "activeAlignLabel" }] : []));
|
|
391
|
-
activeAlignIcon = computed(() => this.alignOptions.find(option => option.command === this.activeAlign())?.icon ?? 'lucideAlignLeft', ...(ngDevMode ? [{ debugName: "activeAlignIcon" }] : []));
|
|
392
|
-
filteredSlashCommands = computed(() => {
|
|
393
|
-
const query = this.slashMenuState().query.trim().toLowerCase();
|
|
394
|
-
const commands = this.slashCommands;
|
|
395
|
-
let matchedCommands = commands;
|
|
396
|
-
if (query) {
|
|
397
|
-
matchedCommands = commands.filter(item => {
|
|
398
|
-
const label = item.label.toLowerCase();
|
|
399
|
-
const description = item.description.toLowerCase();
|
|
400
|
-
return (label.includes(query) || description.includes(query) || item.aliases.some(alias => alias.includes(query)));
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
return matchedCommands.map((item, index) => ({
|
|
404
|
-
...item,
|
|
405
|
-
showGroupLabel: index === 0 || matchedCommands[index - 1]?.group !== item.group,
|
|
406
|
-
}));
|
|
407
|
-
}, ...(ngDevMode ? [{ debugName: "filteredSlashCommands" }] : []));
|
|
408
|
-
canApplyLink = computed(() => !!this.normalizedLinkUrl(), ...(ngDevMode ? [{ debugName: "canApplyLink" }] : []));
|
|
409
|
-
effectivePlaceholder = computed(() => {
|
|
410
|
-
this._zTranslate.currentLang();
|
|
411
|
-
return this.zPlaceholder() || this._zTranslate.instant('i18n_z_ui_editor_placeholder');
|
|
412
|
-
}, ...(ngDevMode ? [{ debugName: "effectivePlaceholder" }] : []));
|
|
413
|
-
toolbarItems = computed(() => {
|
|
414
|
-
this._selectionVersion();
|
|
415
|
-
const toolbar = this.zToolbar();
|
|
416
|
-
if (toolbar === false) {
|
|
417
|
-
return [];
|
|
418
|
-
}
|
|
419
|
-
return toolbar.map(item => ({
|
|
420
|
-
...item,
|
|
421
|
-
active: this._isToolbarCommandActive(item.id),
|
|
422
|
-
disabled: this._isToolbarCommandDisabled(item.id),
|
|
423
|
-
}));
|
|
424
|
-
}, ...(ngDevMode ? [{ debugName: "toolbarItems" }] : []));
|
|
425
|
-
floatingToolbarItems = computed(() => {
|
|
426
|
-
this._selectionVersion();
|
|
427
|
-
const itemIds = [
|
|
428
|
-
'bold',
|
|
429
|
-
'italic',
|
|
430
|
-
'underline',
|
|
431
|
-
'strike',
|
|
432
|
-
'code',
|
|
433
|
-
'blockStyle',
|
|
434
|
-
'clearFormatting',
|
|
435
|
-
'textColor',
|
|
436
|
-
'backgroundColor',
|
|
437
|
-
'align',
|
|
438
|
-
'link',
|
|
439
|
-
];
|
|
440
|
-
return Z_EDITOR_DEFAULT_TOOLBAR.filter(item => itemIds.includes(item.id)).map(item => ({
|
|
441
|
-
...item,
|
|
442
|
-
active: this._isToolbarCommandActive(item.id),
|
|
443
|
-
disabled: this._isToolbarCommandDisabled(item.id),
|
|
444
|
-
shortcut: this._toolbarShortcutLabels[item.id] ?? '',
|
|
445
|
-
tooltip: this._getToolbarTooltip(item.id, item.label),
|
|
446
|
-
}));
|
|
447
|
-
}, ...(ngDevMode ? [{ debugName: "floatingToolbarItems" }] : []));
|
|
448
|
-
_shouldShowValidation = computed(() => {
|
|
449
|
-
const control = this._formControl();
|
|
450
|
-
this._formStateVersion();
|
|
451
|
-
if (this._isNgModel()) {
|
|
452
|
-
return this.uiState().dirty || this.uiState().touched;
|
|
453
|
-
}
|
|
454
|
-
if (control) {
|
|
455
|
-
return control.dirty;
|
|
456
|
-
}
|
|
457
|
-
return this.uiState().dirty || this.uiState().touched;
|
|
458
|
-
}, ...(ngDevMode ? [{ debugName: "_shouldShowValidation" }] : []));
|
|
459
|
-
_getValidationErrors() {
|
|
460
|
-
const errors = [];
|
|
461
|
-
const plainText = this._plainText().trim();
|
|
462
|
-
const valueText = this._serializeValueAsText();
|
|
463
|
-
const validators = this.zValidators();
|
|
464
|
-
if (!this._shouldShowValidation()) {
|
|
465
|
-
return errors;
|
|
466
|
-
}
|
|
467
|
-
const isRequired = this.zRequired() || this._formControl()?.errors?.['required'];
|
|
468
|
-
if (isRequired && !plainText && this._isEditorEmpty()) {
|
|
469
|
-
this._zTranslate.currentLang();
|
|
470
|
-
errors.push(this._zTranslate.instant('i18n_z_ui_editor_required'));
|
|
471
|
-
}
|
|
472
|
-
for (const validator of validators) {
|
|
473
|
-
if (validator.error === 'required') {
|
|
474
|
-
continue;
|
|
475
|
-
}
|
|
476
|
-
if (validator.minLength && valueText.length < validator.minLength) {
|
|
477
|
-
errors.push(validator.message);
|
|
478
|
-
continue;
|
|
479
|
-
}
|
|
480
|
-
if (validator.maxLength && valueText.length > validator.maxLength) {
|
|
481
|
-
errors.push(validator.message);
|
|
482
|
-
continue;
|
|
483
|
-
}
|
|
484
|
-
if (validator.pattern && !validator.pattern.test(valueText)) {
|
|
485
|
-
errors.push(validator.message);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
return errors;
|
|
489
|
-
}
|
|
490
|
-
hasError = computed(() => {
|
|
491
|
-
if (this._customError()) {
|
|
492
|
-
return true;
|
|
493
|
-
}
|
|
494
|
-
const customErrors = this._getValidationErrors();
|
|
495
|
-
if (customErrors.length > 0) {
|
|
496
|
-
return true;
|
|
497
|
-
}
|
|
498
|
-
const control = this._formControl();
|
|
499
|
-
this._formStateVersion();
|
|
500
|
-
if (!control) {
|
|
501
|
-
return false;
|
|
502
|
-
}
|
|
503
|
-
return control.invalid && this._shouldShowValidation();
|
|
504
|
-
}, ...(ngDevMode ? [{ debugName: "hasError" }] : []));
|
|
505
|
-
errorMessage = computed(() => {
|
|
506
|
-
const customError = this._customError();
|
|
507
|
-
if (customError) {
|
|
508
|
-
return customError;
|
|
509
|
-
}
|
|
510
|
-
const customErrors = this._getValidationErrors();
|
|
511
|
-
if (customErrors.length > 0) {
|
|
512
|
-
return customErrors[0];
|
|
513
|
-
}
|
|
514
|
-
const control = this._formControl();
|
|
515
|
-
const errors = control?.errors;
|
|
516
|
-
if (!errors) {
|
|
517
|
-
return '';
|
|
518
|
-
}
|
|
519
|
-
this._zTranslate.currentLang();
|
|
520
|
-
if (errors['required']) {
|
|
521
|
-
return this._zTranslate.instant('i18n_z_ui_editor_required');
|
|
522
|
-
}
|
|
523
|
-
if (errors['minlength']) {
|
|
524
|
-
return this._zTranslate.instant('i18n_z_ui_editor_min_length', {
|
|
525
|
-
min: errors['minlength'].requiredLength,
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
if (errors['maxlength']) {
|
|
529
|
-
return this._zTranslate.instant('i18n_z_ui_editor_max_length', {
|
|
530
|
-
max: errors['maxlength'].requiredLength,
|
|
531
|
-
});
|
|
532
|
-
}
|
|
533
|
-
return this._zTranslate.instant('i18n_z_ui_editor_invalid');
|
|
534
|
-
}, ...(ngDevMode ? [{ debugName: "errorMessage" }] : []));
|
|
535
|
-
currentStatus = computed(() => {
|
|
536
|
-
if (this.isDisabled()) {
|
|
537
|
-
return 'disabled';
|
|
538
|
-
}
|
|
539
|
-
if (this.zReadonly()) {
|
|
540
|
-
return 'readonly';
|
|
541
|
-
}
|
|
542
|
-
if (this.hasError()) {
|
|
543
|
-
return 'error';
|
|
544
|
-
}
|
|
545
|
-
return 'default';
|
|
546
|
-
}, ...(ngDevMode ? [{ debugName: "currentStatus" }] : []));
|
|
547
|
-
wrapperClasses = computed(() => 'z-editor-wrapper flex w-full flex-col gap-2', ...(ngDevMode ? [{ debugName: "wrapperClasses" }] : []));
|
|
548
|
-
editorClasses = computed(() => zMergeClasses(zEditorVariants({
|
|
549
|
-
zSize: this.zSize(),
|
|
550
|
-
zStatus: this.currentStatus(),
|
|
551
|
-
zPlaceholderMode: this._placeholderMode(),
|
|
552
|
-
}), this.class()), ...(ngDevMode ? [{ debugName: "editorClasses" }] : []));
|
|
553
|
-
constructor() {
|
|
554
|
-
afterNextRender(() => {
|
|
555
|
-
this._createEditor();
|
|
556
|
-
});
|
|
557
|
-
effect(() => {
|
|
558
|
-
const editor = this._editor;
|
|
559
|
-
const editable = !this.isDisabled() && !this.zReadonly();
|
|
560
|
-
if (!editor || editor.isEditable === editable) {
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
editor.setEditable(editable);
|
|
564
|
-
this._selectionVersion.update(v => v + 1);
|
|
565
|
-
});
|
|
566
|
-
this._destroyRef.onDestroy(() => {
|
|
567
|
-
this._teardownBubbleMenuPositionUpdates();
|
|
568
|
-
this._editor?.destroy();
|
|
569
|
-
this._editor = null;
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
ngOnInit() {
|
|
573
|
-
queueMicrotask(() => {
|
|
574
|
-
try {
|
|
575
|
-
this._ngControl = this._injector.get(NgControl, null);
|
|
576
|
-
this._isNgModel.set(this._ngControl instanceof NgModel);
|
|
577
|
-
if (this._ngControl?.control) {
|
|
578
|
-
const { control } = this._ngControl;
|
|
579
|
-
this._formControl.set(control);
|
|
580
|
-
merge(control.statusChanges, control.valueChanges, control.events.pipe(filter(event => event instanceof PristineChangeEvent || event instanceof TouchedChangeEvent)))
|
|
581
|
-
.pipe(takeUntilDestroyed(this._destroyRef))
|
|
582
|
-
.subscribe(() => {
|
|
583
|
-
this._formStateVersion.update(v => v + 1);
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
catch {
|
|
588
|
-
this._ngControl = null;
|
|
589
|
-
}
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
writeValue(value) {
|
|
593
|
-
const nextValue = value || '';
|
|
594
|
-
this._pendingValue = nextValue;
|
|
595
|
-
this._value.set(nextValue);
|
|
596
|
-
if (!this._editor || this._isCurrentEditorContent(nextValue)) {
|
|
597
|
-
return;
|
|
598
|
-
}
|
|
599
|
-
this._editor.commands.setContent(nextValue, { emitUpdate: false });
|
|
600
|
-
this._refreshEditorState();
|
|
601
|
-
}
|
|
602
|
-
registerOnChange(fn) {
|
|
603
|
-
this._onChange = fn;
|
|
604
|
-
}
|
|
605
|
-
registerOnTouched(fn) {
|
|
606
|
-
this._onTouched = fn;
|
|
607
|
-
}
|
|
608
|
-
setDisabledState(isDisabled) {
|
|
609
|
-
this._disabled.set(isDisabled);
|
|
610
|
-
this._editor?.setEditable(!isDisabled && !this.zReadonly());
|
|
611
|
-
}
|
|
612
|
-
onToolbarClick(command) {
|
|
613
|
-
const editor = this._editor;
|
|
614
|
-
if (!editor || this._isToolbarCommandDisabled(command)) {
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
617
|
-
switch (command) {
|
|
618
|
-
case 'bold':
|
|
619
|
-
editor.chain().focus().toggleBold().run();
|
|
620
|
-
break;
|
|
621
|
-
case 'italic':
|
|
622
|
-
editor.chain().focus().toggleItalic().run();
|
|
623
|
-
break;
|
|
624
|
-
case 'underline':
|
|
625
|
-
editor.chain().focus().toggleUnderline().run();
|
|
626
|
-
break;
|
|
627
|
-
case 'strike':
|
|
628
|
-
editor.chain().focus().toggleStrike().run();
|
|
629
|
-
break;
|
|
630
|
-
case 'code':
|
|
631
|
-
editor.chain().focus().toggleCode().run();
|
|
632
|
-
break;
|
|
633
|
-
case 'blockStyle':
|
|
634
|
-
break;
|
|
635
|
-
case 'heading1':
|
|
636
|
-
editor.chain().focus().toggleHeading({ level: 1 }).run();
|
|
637
|
-
break;
|
|
638
|
-
case 'heading2':
|
|
639
|
-
editor.chain().focus().toggleHeading({ level: 2 }).run();
|
|
640
|
-
break;
|
|
641
|
-
case 'heading3':
|
|
642
|
-
editor.chain().focus().toggleHeading({ level: 3 }).run();
|
|
643
|
-
break;
|
|
644
|
-
case 'heading4':
|
|
645
|
-
editor.chain().focus().toggleHeading({ level: 4 }).run();
|
|
646
|
-
break;
|
|
647
|
-
case 'small':
|
|
648
|
-
editor.chain().focus().setParagraph().setFontSize('0.875rem').run();
|
|
649
|
-
break;
|
|
650
|
-
case 'paragraph':
|
|
651
|
-
editor.chain().focus().setParagraph().unsetFontSize().run();
|
|
652
|
-
break;
|
|
653
|
-
case 'bulletList':
|
|
654
|
-
editor.chain().focus().toggleBulletList().run();
|
|
655
|
-
break;
|
|
656
|
-
case 'orderedList':
|
|
657
|
-
editor.chain().focus().toggleOrderedList().run();
|
|
658
|
-
break;
|
|
659
|
-
case 'blockquote':
|
|
660
|
-
editor.chain().focus().toggleBlockquote().run();
|
|
661
|
-
break;
|
|
662
|
-
case 'codeBlock':
|
|
663
|
-
editor.chain().focus().toggleCodeBlock().run();
|
|
664
|
-
break;
|
|
665
|
-
case 'horizontalRule':
|
|
666
|
-
editor.chain().focus().setHorizontalRule().run();
|
|
667
|
-
break;
|
|
668
|
-
case 'link':
|
|
669
|
-
this._toggleLink();
|
|
670
|
-
break;
|
|
671
|
-
case 'image':
|
|
672
|
-
this._insertImage();
|
|
673
|
-
break;
|
|
674
|
-
case 'emoji':
|
|
675
|
-
case 'align':
|
|
676
|
-
case 'textColor':
|
|
677
|
-
case 'backgroundColor':
|
|
678
|
-
break;
|
|
679
|
-
case 'alignLeft':
|
|
680
|
-
this._setTextAlign('left');
|
|
681
|
-
break;
|
|
682
|
-
case 'alignCenter':
|
|
683
|
-
this._setTextAlign('center');
|
|
684
|
-
break;
|
|
685
|
-
case 'alignRight':
|
|
686
|
-
this._setTextAlign('right');
|
|
687
|
-
break;
|
|
688
|
-
case 'alignJustify':
|
|
689
|
-
this._setTextAlign('justify');
|
|
690
|
-
break;
|
|
691
|
-
case 'undo':
|
|
692
|
-
editor.chain().focus().undo().run();
|
|
693
|
-
break;
|
|
694
|
-
case 'redo':
|
|
695
|
-
editor.chain().focus().redo().run();
|
|
696
|
-
break;
|
|
697
|
-
case 'clearFormatting':
|
|
698
|
-
editor.chain().focus().clearNodes().unsetAllMarks().run();
|
|
699
|
-
this._collapseSelectionToAnchor();
|
|
700
|
-
break;
|
|
701
|
-
}
|
|
702
|
-
this._refreshEditorState();
|
|
703
|
-
}
|
|
704
|
-
_createEditor() {
|
|
705
|
-
if (this._editor) {
|
|
706
|
-
return;
|
|
707
|
-
}
|
|
708
|
-
const host = this._editorHost().nativeElement;
|
|
709
|
-
const tiptapOptions = this.zTipTap();
|
|
710
|
-
const placeholderConfig = this._placeholderConfig();
|
|
711
|
-
this._editor = new Editor({
|
|
712
|
-
element: host,
|
|
713
|
-
content: this._pendingValue,
|
|
714
|
-
editable: !this.isDisabled() && !this.zReadonly(),
|
|
715
|
-
extensions: [
|
|
716
|
-
this.zContentType() === 'markdown' &&
|
|
717
|
-
Markdown.configure({
|
|
718
|
-
markedOptions: {
|
|
719
|
-
gfm: true,
|
|
720
|
-
},
|
|
721
|
-
}),
|
|
722
|
-
StarterKit.configure({
|
|
723
|
-
code: false,
|
|
724
|
-
horizontalRule: false,
|
|
725
|
-
link: false,
|
|
726
|
-
underline: false,
|
|
727
|
-
dropcursor: {
|
|
728
|
-
color: 'var(--primary)',
|
|
729
|
-
width: 2,
|
|
730
|
-
},
|
|
731
|
-
...tiptapOptions.starterKit,
|
|
732
|
-
}),
|
|
733
|
-
Code.extend({
|
|
734
|
-
excludes: 'code',
|
|
735
|
-
}),
|
|
736
|
-
Underline,
|
|
737
|
-
TextStyle,
|
|
738
|
-
FontSize,
|
|
739
|
-
Color,
|
|
740
|
-
BackgroundColor,
|
|
741
|
-
BubbleMenu.configure({
|
|
742
|
-
element: this._floatingToolbar().nativeElement,
|
|
743
|
-
pluginKey: 'zEditorBubbleMenu',
|
|
744
|
-
updateDelay: 0,
|
|
745
|
-
options: {
|
|
746
|
-
strategy: 'fixed',
|
|
747
|
-
placement: 'top-start',
|
|
748
|
-
offset: ZEditorComponent._bubbleMenuOffset,
|
|
749
|
-
flip: true,
|
|
750
|
-
shift: {
|
|
751
|
-
padding: 8,
|
|
752
|
-
},
|
|
753
|
-
},
|
|
754
|
-
getReferencedVirtualElement: () => this._getSelectionFloatingElement(),
|
|
755
|
-
shouldShow: ({ editor, from, to }) => editor.isEditable &&
|
|
756
|
-
!this.isDisabled() &&
|
|
757
|
-
!this.zReadonly() &&
|
|
758
|
-
from !== to &&
|
|
759
|
-
!editor.isActive('image') &&
|
|
760
|
-
editor.state.doc.textBetween(from, to).trim().length > 0,
|
|
761
|
-
}),
|
|
762
|
-
TextAlign.configure({
|
|
763
|
-
types: ['heading', 'paragraph', 'image'],
|
|
764
|
-
}),
|
|
765
|
-
Link.configure({
|
|
766
|
-
openOnClick: false,
|
|
767
|
-
...tiptapOptions.link,
|
|
768
|
-
}),
|
|
769
|
-
HorizontalRule,
|
|
770
|
-
tiptapOptions.image !== false &&
|
|
771
|
-
this._createImageExtension(typeof tiptapOptions.image === 'boolean' ? {} : (tiptapOptions.image ?? {})),
|
|
772
|
-
tiptapOptions.mention !== false &&
|
|
773
|
-
Mention.configure({
|
|
774
|
-
HTMLAttributes: {
|
|
775
|
-
class: 'mention',
|
|
776
|
-
},
|
|
777
|
-
...(typeof tiptapOptions.mention === 'boolean' ? {} : tiptapOptions.mention),
|
|
778
|
-
}),
|
|
779
|
-
Placeholder.configure({
|
|
780
|
-
placeholder: this.effectivePlaceholder(),
|
|
781
|
-
showOnlyWhenEditable: false,
|
|
782
|
-
showOnlyCurrent: true,
|
|
783
|
-
...placeholderConfig,
|
|
784
|
-
}),
|
|
785
|
-
...(tiptapOptions.extensions ?? []),
|
|
786
|
-
].filter(extension => !!extension),
|
|
787
|
-
editorProps: {
|
|
788
|
-
attributes: {
|
|
789
|
-
class: 'z-editor-prosemirror',
|
|
790
|
-
autocomplete: 'off',
|
|
791
|
-
autocorrect: 'off',
|
|
792
|
-
autocapitalize: 'off',
|
|
793
|
-
translate: 'no',
|
|
794
|
-
},
|
|
795
|
-
handleKeyDown: (_view, event) => this._handleSlashMenuKeyDown(event) || this._handleEditorShortcutKeyDown(event),
|
|
796
|
-
handleClick: (view, _pos, event) => this._handleEditorClick(view, event),
|
|
797
|
-
},
|
|
798
|
-
onUpdate: () => this._handleEditorUpdate(),
|
|
799
|
-
onSelectionUpdate: () => this._refreshEditorState(),
|
|
800
|
-
onTransaction: () => this._refreshEditorState(),
|
|
801
|
-
onFocus: () => this._handleFocus(),
|
|
802
|
-
onBlur: () => this._handleBlur(),
|
|
803
|
-
});
|
|
804
|
-
this._refreshEditorState();
|
|
805
|
-
this._setupBubbleMenuPositionUpdates();
|
|
806
|
-
this._emitControl();
|
|
807
|
-
}
|
|
808
|
-
_handleEditorUpdate() {
|
|
809
|
-
const value = this._getSerializedContent();
|
|
810
|
-
this._value.set(value);
|
|
811
|
-
this.uiState.update(s => ({ ...s, dirty: true }));
|
|
812
|
-
this._onChange(value);
|
|
813
|
-
this.zOnChange.emit(value);
|
|
814
|
-
this._refreshEditorState();
|
|
815
|
-
}
|
|
816
|
-
_handleFocus() {
|
|
817
|
-
const focusEvent = new FocusEvent('focus');
|
|
818
|
-
this.zOnFocus.emit(focusEvent);
|
|
819
|
-
this.zEvent.emit(zCreateEvent('focus', focusEvent));
|
|
820
|
-
}
|
|
821
|
-
_handleBlur() {
|
|
822
|
-
if (this.uiState().dirty) {
|
|
823
|
-
this.uiState.update(s => ({ ...s, touched: true }));
|
|
824
|
-
}
|
|
825
|
-
this._dismissCurrentSlashMenu();
|
|
826
|
-
this._onTouched();
|
|
827
|
-
const blurEvent = new FocusEvent('blur');
|
|
828
|
-
this.zOnBlur.emit(blurEvent);
|
|
829
|
-
this.zEvent.emit(zCreateEvent('blur', blurEvent));
|
|
830
|
-
}
|
|
831
|
-
_emitControl() {
|
|
832
|
-
const control = {
|
|
833
|
-
focus: () => this._editor?.commands.focus(),
|
|
834
|
-
blur: () => this._editor?.commands.blur(),
|
|
835
|
-
clear: () => this._setEditorContent(''),
|
|
836
|
-
setContent: content => this._setEditorContent(content),
|
|
837
|
-
getContent: () => this._getSerializedContent(),
|
|
838
|
-
getHTML: () => this._editor?.getHTML() ?? '',
|
|
839
|
-
getJSON: () => this._editor?.getJSON() ?? { type: 'doc', content: [] },
|
|
840
|
-
getMarkdown: () => this._getMarkdown(),
|
|
841
|
-
getText: () => this._editor?.getText() ?? '',
|
|
842
|
-
getLength: () => this._editor?.state.doc.content.size ?? 0,
|
|
843
|
-
getEditor: () => this._editor,
|
|
844
|
-
valid: () => this._validateControl(),
|
|
845
|
-
validate: () => !this._validateControl(),
|
|
846
|
-
reset: () => {
|
|
847
|
-
this._customError.set(null);
|
|
848
|
-
this.uiState.set({ touched: false, dirty: false });
|
|
849
|
-
this._setEditorContent('');
|
|
850
|
-
},
|
|
851
|
-
setValue: content => this._setEditorContent(content),
|
|
852
|
-
setErrorMessage: message => {
|
|
853
|
-
this._customError.set(message);
|
|
854
|
-
this._formStateVersion.update(v => v + 1);
|
|
855
|
-
},
|
|
856
|
-
hasError: this.hasError,
|
|
857
|
-
value: this._value.asReadonly(),
|
|
858
|
-
errorMessage: this.errorMessage,
|
|
859
|
-
};
|
|
860
|
-
this.zControl.emit(control);
|
|
861
|
-
}
|
|
862
|
-
_setEditorContent(content) {
|
|
863
|
-
this._pendingValue = content;
|
|
864
|
-
this._editor?.commands.setContent(content, { emitUpdate: false });
|
|
865
|
-
const value = this._getSerializedContent();
|
|
866
|
-
this._value.set(value);
|
|
867
|
-
this._plainText.set(this._editor?.getText() ?? '');
|
|
868
|
-
this._onChange(value);
|
|
869
|
-
this.zOnChange.emit(value);
|
|
870
|
-
this._refreshEditorState();
|
|
871
|
-
}
|
|
872
|
-
_validateControl() {
|
|
873
|
-
this.uiState.set({ touched: true, dirty: true });
|
|
874
|
-
this._formControl()?.markAsDirty();
|
|
875
|
-
this._formControl()?.markAsTouched();
|
|
876
|
-
this._formControl()?.updateValueAndValidity({ onlySelf: true });
|
|
877
|
-
this._formStateVersion.update(v => v + 1);
|
|
878
|
-
return !this.hasError();
|
|
879
|
-
}
|
|
880
|
-
_getSerializedContent() {
|
|
881
|
-
const editor = this._editor;
|
|
882
|
-
if (!editor) {
|
|
883
|
-
return this._value();
|
|
884
|
-
}
|
|
885
|
-
if (this.zContentType() === 'json') {
|
|
886
|
-
return editor.getJSON();
|
|
887
|
-
}
|
|
888
|
-
if (this.zContentType() === 'markdown') {
|
|
889
|
-
return this._getMarkdown();
|
|
890
|
-
}
|
|
891
|
-
return editor.getHTML();
|
|
892
|
-
}
|
|
893
|
-
_getMarkdown() {
|
|
894
|
-
const editor = this._editor;
|
|
895
|
-
return editor?.getMarkdown?.() ?? this._editor?.getText() ?? '';
|
|
896
|
-
}
|
|
897
|
-
_serializeValueAsText() {
|
|
898
|
-
const value = this._value();
|
|
899
|
-
if (typeof value === 'string') {
|
|
900
|
-
return value;
|
|
901
|
-
}
|
|
902
|
-
return JSON.stringify(value);
|
|
903
|
-
}
|
|
904
|
-
_refreshEditorState() {
|
|
905
|
-
this._plainText.set(this._editor?.getText() ?? '');
|
|
906
|
-
this._selectionVersion.update(v => v + 1);
|
|
907
|
-
this._formStateVersion.update(v => v + 1);
|
|
908
|
-
this._syncSlashMenu();
|
|
909
|
-
this._syncLinkPopoverPosition();
|
|
910
|
-
}
|
|
911
|
-
_searchEmojis(query) {
|
|
912
|
-
const results = [];
|
|
913
|
-
for (const category of this.emojiCategories) {
|
|
914
|
-
for (const entry of category.emojis) {
|
|
915
|
-
const emoji = typeof entry === 'string' ? entry : entry.emoji;
|
|
916
|
-
const keywords = typeof entry === 'string' ? Z_EMOJI_KEYWORDS.get(entry) : entry.keywords;
|
|
917
|
-
const matchesKeywords = keywords?.some(kw => kw.includes(query)) ?? false;
|
|
918
|
-
if (matchesKeywords || emoji.includes(query)) {
|
|
919
|
-
results.push(emoji);
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
return results;
|
|
924
|
-
}
|
|
925
|
-
_setupBubbleMenuPositionUpdates() {
|
|
926
|
-
if (typeof ResizeObserver === 'undefined') {
|
|
927
|
-
this._resizeListenerCleanup = this._listenWindowResize();
|
|
928
|
-
return;
|
|
929
|
-
}
|
|
930
|
-
const editorElement = this._editorHost().nativeElement;
|
|
931
|
-
this._resizeObserver = new ResizeObserver(() => this._requestBubbleMenuPositionUpdate());
|
|
932
|
-
this._resizeObserver.observe(editorElement);
|
|
933
|
-
const wrapperElement = editorElement.closest('.z-editor-wrapper');
|
|
934
|
-
if (wrapperElement instanceof HTMLElement) {
|
|
935
|
-
this._resizeObserver.observe(wrapperElement);
|
|
936
|
-
}
|
|
937
|
-
this._resizeListenerCleanup = this._listenWindowResize();
|
|
938
|
-
}
|
|
939
|
-
_listenWindowResize() {
|
|
940
|
-
const listener = (event) => {
|
|
941
|
-
if (event.type === 'scroll' && event.target instanceof Element && event.target.closest('.z-popover')) {
|
|
942
|
-
return;
|
|
943
|
-
}
|
|
944
|
-
this._requestBubbleMenuPositionUpdate();
|
|
945
|
-
};
|
|
946
|
-
window.addEventListener('resize', listener, { passive: true });
|
|
947
|
-
window.addEventListener('scroll', listener, { passive: true, capture: true });
|
|
948
|
-
return () => {
|
|
949
|
-
window.removeEventListener('resize', listener);
|
|
950
|
-
window.removeEventListener('scroll', listener, { capture: true });
|
|
951
|
-
};
|
|
952
|
-
}
|
|
953
|
-
_teardownBubbleMenuPositionUpdates() {
|
|
954
|
-
this._resizeObserver?.disconnect();
|
|
955
|
-
this._resizeObserver = null;
|
|
956
|
-
this._resizeListenerCleanup?.();
|
|
957
|
-
this._resizeListenerCleanup = null;
|
|
958
|
-
if (this._bubbleMenuPositionFrame !== null) {
|
|
959
|
-
cancelAnimationFrame(this._bubbleMenuPositionFrame);
|
|
960
|
-
this._bubbleMenuPositionFrame = null;
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
_requestBubbleMenuPositionUpdate() {
|
|
964
|
-
if (this._bubbleMenuPositionFrame !== null) {
|
|
965
|
-
return;
|
|
966
|
-
}
|
|
967
|
-
if (this._isAnyBubbleMenuPopoverOpen()) {
|
|
968
|
-
return;
|
|
969
|
-
}
|
|
970
|
-
this._bubbleMenuPositionFrame = requestAnimationFrame(() => {
|
|
971
|
-
this._bubbleMenuPositionFrame = null;
|
|
972
|
-
this._editor?.view.dispatch(this._editor.state.tr.setMeta('zEditorBubbleMenu', 'updatePosition'));
|
|
973
|
-
this._syncLinkPopoverPosition();
|
|
974
|
-
});
|
|
975
|
-
}
|
|
976
|
-
_isAnyBubbleMenuPopoverOpen() {
|
|
977
|
-
return (!!this._blockStylePopoverControl?.isVisible() ||
|
|
978
|
-
!!this._alignPopoverControl?.isVisible() ||
|
|
979
|
-
!!this._textColorPopoverControl?.isVisible() ||
|
|
980
|
-
!!this._backgroundColorPopoverControl?.isVisible());
|
|
981
|
-
}
|
|
982
|
-
_syncLinkPopoverPosition() {
|
|
983
|
-
if (!this.linkPopoverState().visible) {
|
|
984
|
-
return;
|
|
985
|
-
}
|
|
986
|
-
const rect = this._getLinkPopoverReferenceRect();
|
|
987
|
-
if (!rect) {
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
990
|
-
this.linkPopoverState.set({
|
|
991
|
-
visible: true,
|
|
992
|
-
left: rect.left,
|
|
993
|
-
top: rect.top,
|
|
994
|
-
width: rect.width,
|
|
995
|
-
height: rect.height,
|
|
996
|
-
});
|
|
997
|
-
requestAnimationFrame(() => {
|
|
998
|
-
if (this.linkPopoverState().visible) {
|
|
999
|
-
this._linkPopoverControl?.show();
|
|
1000
|
-
}
|
|
1001
|
-
});
|
|
1002
|
-
}
|
|
1003
|
-
_getSelectionFloatingElement() {
|
|
1004
|
-
const editor = this._editor;
|
|
1005
|
-
if (!editor) {
|
|
1006
|
-
return null;
|
|
1007
|
-
}
|
|
1008
|
-
// Freeze the bubble menu in place while any popover triggered from it is open,
|
|
1009
|
-
// so the popover (positioned relative to the bubble menu) does not flicker.
|
|
1010
|
-
if (this._isAnyBubbleMenuPopoverOpen()) {
|
|
1011
|
-
const frozenRect = this._getFrozenBubbleMenuReferenceRect();
|
|
1012
|
-
if (frozenRect) {
|
|
1013
|
-
return this._createVirtualElement(frozenRect);
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
const { from, to } = editor.state.selection;
|
|
1017
|
-
if (from === to) {
|
|
1018
|
-
return null;
|
|
1019
|
-
}
|
|
1020
|
-
const selectionRect = posToDOMRect(editor.view, from, to);
|
|
1021
|
-
const menuWidth = this._floatingToolbar().nativeElement.getBoundingClientRect().width;
|
|
1022
|
-
const activeAlign = this._getActiveAlignFromEditor(editor);
|
|
1023
|
-
const left = activeAlign === 'alignCenter'
|
|
1024
|
-
? selectionRect.left + selectionRect.width / 2 - menuWidth / 2
|
|
1025
|
-
: activeAlign === 'alignRight'
|
|
1026
|
-
? selectionRect.right - menuWidth
|
|
1027
|
-
: selectionRect.left;
|
|
1028
|
-
const rect = new DOMRect(Math.max(left, 0), selectionRect.top, menuWidth, selectionRect.height);
|
|
1029
|
-
return this._createVirtualElement(rect);
|
|
1030
|
-
}
|
|
1031
|
-
_getFrozenBubbleMenuReferenceRect() {
|
|
1032
|
-
const toolbarRect = this._floatingToolbar().nativeElement.getBoundingClientRect();
|
|
1033
|
-
if (toolbarRect.width <= 0 || toolbarRect.height <= 0) {
|
|
1034
|
-
return null;
|
|
1035
|
-
}
|
|
1036
|
-
return new DOMRect(toolbarRect.left, toolbarRect.bottom + ZEditorComponent._bubbleMenuOffset, toolbarRect.width, 0);
|
|
1037
|
-
}
|
|
1038
|
-
_createVirtualElement(rect) {
|
|
1039
|
-
return {
|
|
1040
|
-
getBoundingClientRect: () => rect,
|
|
1041
|
-
getClientRects: () => [rect],
|
|
1042
|
-
};
|
|
1043
|
-
}
|
|
1044
|
-
_isEditorEmpty() {
|
|
1045
|
-
const editor = this._editor;
|
|
1046
|
-
if (editor) {
|
|
1047
|
-
return editor.isEmpty;
|
|
1048
|
-
}
|
|
1049
|
-
const value = this._value();
|
|
1050
|
-
if (typeof value === 'string') {
|
|
1051
|
-
return !value || value === '<p></p>' || value === '<p><br></p>';
|
|
1052
|
-
}
|
|
1053
|
-
return false;
|
|
1054
|
-
}
|
|
1055
|
-
_isCurrentEditorContent(content) {
|
|
1056
|
-
const editor = this._editor;
|
|
1057
|
-
if (!editor) {
|
|
1058
|
-
return false;
|
|
1059
|
-
}
|
|
1060
|
-
if (this.zContentType() === 'json') {
|
|
1061
|
-
return JSON.stringify(editor.getJSON()) === JSON.stringify(content);
|
|
1062
|
-
}
|
|
1063
|
-
return editor.getHTML() === String(content);
|
|
1064
|
-
}
|
|
1065
|
-
_isToolbarCommandActive(command) {
|
|
1066
|
-
const editor = this._editor;
|
|
1067
|
-
if (!editor || !editor.isEditable) {
|
|
1068
|
-
return false;
|
|
1069
|
-
}
|
|
1070
|
-
switch (command) {
|
|
1071
|
-
case 'bold':
|
|
1072
|
-
case 'italic':
|
|
1073
|
-
case 'underline':
|
|
1074
|
-
case 'strike':
|
|
1075
|
-
case 'code':
|
|
1076
|
-
case 'bulletList':
|
|
1077
|
-
case 'orderedList':
|
|
1078
|
-
case 'blockquote':
|
|
1079
|
-
case 'codeBlock':
|
|
1080
|
-
case 'link':
|
|
1081
|
-
return editor.isActive(command);
|
|
1082
|
-
case 'heading1':
|
|
1083
|
-
return editor.isActive('heading', { level: 1 });
|
|
1084
|
-
case 'heading2':
|
|
1085
|
-
return editor.isActive('heading', { level: 2 });
|
|
1086
|
-
case 'heading3':
|
|
1087
|
-
return editor.isActive('heading', { level: 3 });
|
|
1088
|
-
case 'heading4':
|
|
1089
|
-
return editor.isActive('heading', { level: 4 });
|
|
1090
|
-
case 'paragraph':
|
|
1091
|
-
return editor.isActive('paragraph');
|
|
1092
|
-
case 'blockStyle':
|
|
1093
|
-
return this.activeBlockStyle() !== 'paragraph';
|
|
1094
|
-
case 'align':
|
|
1095
|
-
return this.activeAlign() !== 'alignLeft';
|
|
1096
|
-
default:
|
|
1097
|
-
return false;
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
_isToolbarCommandDisabled(command) {
|
|
1101
|
-
const editor = this._editor;
|
|
1102
|
-
if (!editor || !editor.isEditable || this.isDisabled() || this.zReadonly()) {
|
|
1103
|
-
return true;
|
|
1104
|
-
}
|
|
1105
|
-
switch (command) {
|
|
1106
|
-
case 'undo':
|
|
1107
|
-
return !editor.can().undo();
|
|
1108
|
-
case 'redo':
|
|
1109
|
-
return !editor.can().redo();
|
|
1110
|
-
case 'link':
|
|
1111
|
-
return editor.state.selection.empty && !editor.isActive('link');
|
|
1112
|
-
case 'emoji':
|
|
1113
|
-
case 'blockStyle':
|
|
1114
|
-
case 'align':
|
|
1115
|
-
case 'textColor':
|
|
1116
|
-
case 'backgroundColor':
|
|
1117
|
-
return false;
|
|
1118
|
-
default:
|
|
1119
|
-
return false;
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
onFloatingToolbarClick(command) {
|
|
1123
|
-
this.onToolbarClick(command);
|
|
1124
|
-
}
|
|
1125
|
-
_getToolbarTooltip(command, label) {
|
|
1126
|
-
const shortcut = this._toolbarShortcutLabels[command];
|
|
1127
|
-
return shortcut ? `${label} (${shortcut})` : label;
|
|
1128
|
-
}
|
|
1129
|
-
applySlashCommand(item) {
|
|
1130
|
-
const editor = this._editor;
|
|
1131
|
-
const { from, to } = this.slashMenuState();
|
|
1132
|
-
if (!editor) {
|
|
1133
|
-
return;
|
|
1134
|
-
}
|
|
1135
|
-
editor.chain().focus().deleteRange({ from, to }).run();
|
|
1136
|
-
this._hideSlashMenu();
|
|
1137
|
-
this.onToolbarClick(item.command);
|
|
1138
|
-
}
|
|
1139
|
-
applyBlockStyle(command, closePopover) {
|
|
1140
|
-
this.onToolbarClick(command);
|
|
1141
|
-
this._closePopover(closePopover, this._blockStylePopoverControl);
|
|
1142
|
-
}
|
|
1143
|
-
applyAlign(command, closePopover) {
|
|
1144
|
-
this.onToolbarClick(command);
|
|
1145
|
-
this._closePopover(closePopover, this._alignPopoverControl);
|
|
1146
|
-
}
|
|
1147
|
-
insertEmoji(emoji) {
|
|
1148
|
-
this._editor?.chain().focus().insertContent(emoji).run();
|
|
1149
|
-
this._refreshEditorState();
|
|
1150
|
-
}
|
|
1151
|
-
setEmojiCategory(categoryId) {
|
|
1152
|
-
this.activeEmojiCategoryId.set(categoryId);
|
|
1153
|
-
this.emojiSearch.set('');
|
|
1154
|
-
}
|
|
1155
|
-
onEmojiPopoverControl(control) {
|
|
1156
|
-
this._emojiPopoverControl = control;
|
|
1157
|
-
}
|
|
1158
|
-
onEmojiPopoverShow() {
|
|
1159
|
-
setTimeout(() => {
|
|
1160
|
-
const overlay = document.querySelector('.z-editor-emoji-popover');
|
|
1161
|
-
const input = overlay?.querySelector('input');
|
|
1162
|
-
input?.focus();
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1165
|
-
onBlockStylePopoverControl(control) {
|
|
1166
|
-
this._blockStylePopoverControl = control;
|
|
1167
|
-
}
|
|
1168
|
-
onAlignPopoverControl(control) {
|
|
1169
|
-
this._alignPopoverControl = control;
|
|
1170
|
-
}
|
|
1171
|
-
onTextColorPopoverControl(control) {
|
|
1172
|
-
this._textColorPopoverControl = control;
|
|
1173
|
-
}
|
|
1174
|
-
onBackgroundColorPopoverControl(control) {
|
|
1175
|
-
this._backgroundColorPopoverControl = control;
|
|
1176
|
-
}
|
|
1177
|
-
onSlashMenuPopoverControl(control) {
|
|
1178
|
-
this._slashMenuPopoverControl = control;
|
|
1179
|
-
}
|
|
1180
|
-
onSlashMenuPopoverHide() {
|
|
1181
|
-
this.slashMenuState.update(state => ({ ...state, visible: false }));
|
|
1182
|
-
this.slashMenuActiveIndex.set(0);
|
|
1183
|
-
}
|
|
1184
|
-
onLinkPopoverControl(control) {
|
|
1185
|
-
this._linkPopoverControl = control;
|
|
1186
|
-
}
|
|
1187
|
-
onLinkPopoverHide() {
|
|
1188
|
-
this.linkPopoverState.update(state => ({ ...state, visible: false }));
|
|
1189
|
-
this._linkAnchorElement = null;
|
|
1190
|
-
}
|
|
1191
|
-
onFloatingPopoverHide() {
|
|
1192
|
-
// Yêu cầu cập nhật vị trí của floating toolbar khi popover đóng
|
|
1193
|
-
this._requestBubbleMenuPositionUpdate();
|
|
1194
|
-
}
|
|
1195
|
-
setTextColor(color, closePopover) {
|
|
1196
|
-
this._editor?.chain().focus().setColor(color).run();
|
|
1197
|
-
this._closePopover(closePopover, this._textColorPopoverControl);
|
|
1198
|
-
this._refreshEditorState();
|
|
1199
|
-
}
|
|
1200
|
-
setTextColorFromEvent(event, closePopover) {
|
|
1201
|
-
const input = event.target;
|
|
1202
|
-
this.setTextColor(input?.value ?? '', closePopover);
|
|
1203
|
-
}
|
|
1204
|
-
unsetTextColor(closePopover) {
|
|
1205
|
-
this._editor?.chain().focus().unsetColor().run();
|
|
1206
|
-
this._closePopover(closePopover, this._textColorPopoverControl);
|
|
1207
|
-
this._refreshEditorState();
|
|
1208
|
-
}
|
|
1209
|
-
setBackgroundColor(color, closePopover) {
|
|
1210
|
-
this._editor?.chain().focus().setBackgroundColor(color).run();
|
|
1211
|
-
this._closePopover(closePopover, this._backgroundColorPopoverControl);
|
|
1212
|
-
this._refreshEditorState();
|
|
1213
|
-
}
|
|
1214
|
-
setBackgroundColorFromEvent(event, closePopover) {
|
|
1215
|
-
const input = event.target;
|
|
1216
|
-
this.setBackgroundColor(input?.value ?? '', closePopover);
|
|
1217
|
-
}
|
|
1218
|
-
unsetBackgroundColor(closePopover) {
|
|
1219
|
-
this._editor?.chain().focus().unsetBackgroundColor().run();
|
|
1220
|
-
this._closePopover(closePopover, this._backgroundColorPopoverControl);
|
|
1221
|
-
this._refreshEditorState();
|
|
1222
|
-
}
|
|
1223
|
-
_closePopover(closePopover, control) {
|
|
1224
|
-
const close = closePopover ?? (() => control?.close());
|
|
1225
|
-
requestAnimationFrame(() => {
|
|
1226
|
-
close();
|
|
1227
|
-
});
|
|
1228
|
-
}
|
|
1229
|
-
_handleSlashMenuKeyDown(event) {
|
|
1230
|
-
if (!this.slashMenuState().visible) {
|
|
1231
|
-
return false;
|
|
1232
|
-
}
|
|
1233
|
-
const commands = this.filteredSlashCommands();
|
|
1234
|
-
if (event.key === 'Escape' || event.key === 'Tab') {
|
|
1235
|
-
this._hideSlashMenu();
|
|
1236
|
-
return event.key === 'Escape';
|
|
1237
|
-
}
|
|
1238
|
-
if (event.key === 'ArrowDown') {
|
|
1239
|
-
event.preventDefault();
|
|
1240
|
-
this.slashMenuActiveIndex.update(index => (commands.length ? (index + 1) % commands.length : 0));
|
|
1241
|
-
this._scrollActiveSlashMenuItemIntoView();
|
|
1242
|
-
return true;
|
|
1243
|
-
}
|
|
1244
|
-
if (event.key === 'ArrowUp') {
|
|
1245
|
-
event.preventDefault();
|
|
1246
|
-
this.slashMenuActiveIndex.update(index => commands.length ? (index - 1 + commands.length) % commands.length : 0);
|
|
1247
|
-
this._scrollActiveSlashMenuItemIntoView();
|
|
1248
|
-
return true;
|
|
1249
|
-
}
|
|
1250
|
-
if (event.key === 'Enter') {
|
|
1251
|
-
const item = commands[this.slashMenuActiveIndex()];
|
|
1252
|
-
if (!item) {
|
|
1253
|
-
return false;
|
|
1254
|
-
}
|
|
1255
|
-
event.preventDefault();
|
|
1256
|
-
this.applySlashCommand(item);
|
|
1257
|
-
return true;
|
|
1258
|
-
}
|
|
1259
|
-
return false;
|
|
1260
|
-
}
|
|
1261
|
-
_handleEditorShortcutKeyDown(event) {
|
|
1262
|
-
if (!this._editor || this.isDisabled() || this.zReadonly() || !this._isPrimaryShortcut(event)) {
|
|
1263
|
-
return false;
|
|
1264
|
-
}
|
|
1265
|
-
const key = event.key.toLowerCase();
|
|
1266
|
-
const command = this._getShortcutCommand(event, key);
|
|
1267
|
-
if (!command || this._isToolbarCommandDisabled(command)) {
|
|
1268
|
-
return false;
|
|
1269
|
-
}
|
|
1270
|
-
event.preventDefault();
|
|
1271
|
-
this.onToolbarClick(command);
|
|
1272
|
-
return true;
|
|
1273
|
-
}
|
|
1274
|
-
_getShortcutCommand(event, key) {
|
|
1275
|
-
if (!event.shiftKey) {
|
|
1276
|
-
switch (key) {
|
|
1277
|
-
case 'b':
|
|
1278
|
-
return 'bold';
|
|
1279
|
-
case 'i':
|
|
1280
|
-
return 'italic';
|
|
1281
|
-
case 'u':
|
|
1282
|
-
return 'underline';
|
|
1283
|
-
case 'e':
|
|
1284
|
-
return 'code';
|
|
1285
|
-
case 'k':
|
|
1286
|
-
return 'link';
|
|
1287
|
-
case '\\':
|
|
1288
|
-
return 'clearFormatting';
|
|
1289
|
-
case 'z':
|
|
1290
|
-
return 'undo';
|
|
1291
|
-
case 'y':
|
|
1292
|
-
return 'redo';
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
if (event.shiftKey && key === 's') {
|
|
1296
|
-
return 'strike';
|
|
1297
|
-
}
|
|
1298
|
-
return null;
|
|
1299
|
-
}
|
|
1300
|
-
_isPrimaryShortcut(event) {
|
|
1301
|
-
return (event.ctrlKey || event.metaKey) && !event.altKey;
|
|
1302
|
-
}
|
|
1303
|
-
_syncSlashMenu() {
|
|
1304
|
-
const editor = this._editor;
|
|
1305
|
-
if (!editor || !editor.isEditable || this.isDisabled() || this.zReadonly()) {
|
|
1306
|
-
this._hideSlashMenu();
|
|
1307
|
-
return;
|
|
1308
|
-
}
|
|
1309
|
-
const { selection } = editor.state;
|
|
1310
|
-
if (!selection.empty) {
|
|
1311
|
-
this._hideSlashMenu();
|
|
1312
|
-
return;
|
|
1313
|
-
}
|
|
1314
|
-
const { $from } = selection;
|
|
1315
|
-
const textBeforeCursor = $from.parent.textBetween(0, $from.parentOffset, '\0', '\0');
|
|
1316
|
-
const match = /(?:^|\s)\/([^\s/]*)$/.exec(textBeforeCursor);
|
|
1317
|
-
if (!match) {
|
|
1318
|
-
if (!this._isDismissedSlashStillPresent()) {
|
|
1319
|
-
this._dismissedSlashMenu = null;
|
|
1320
|
-
}
|
|
1321
|
-
this._hideSlashMenu();
|
|
1322
|
-
return;
|
|
1323
|
-
}
|
|
1324
|
-
const query = match[1] ?? '';
|
|
1325
|
-
const from = selection.from - query.length - 1;
|
|
1326
|
-
const to = selection.from;
|
|
1327
|
-
if (this._dismissedSlashMenu?.from === from &&
|
|
1328
|
-
this._dismissedSlashMenu.to === to &&
|
|
1329
|
-
this._dismissedSlashMenu.query === query) {
|
|
1330
|
-
this._hideSlashMenu();
|
|
1331
|
-
return;
|
|
1332
|
-
}
|
|
1333
|
-
if (this._dismissedSlashMenu) {
|
|
1334
|
-
this._dismissedSlashMenu = null;
|
|
1335
|
-
}
|
|
1336
|
-
const coords = editor.view.coordsAtPos(selection.from);
|
|
1337
|
-
this.slashMenuState.set({
|
|
1338
|
-
visible: true,
|
|
1339
|
-
query,
|
|
1340
|
-
from,
|
|
1341
|
-
to,
|
|
1342
|
-
left: coords.left,
|
|
1343
|
-
top: coords.bottom,
|
|
1344
|
-
});
|
|
1345
|
-
const commandsLength = this.filteredSlashCommands().length;
|
|
1346
|
-
if (this.slashMenuActiveIndex() >= commandsLength) {
|
|
1347
|
-
this.slashMenuActiveIndex.set(0);
|
|
1348
|
-
}
|
|
1349
|
-
requestAnimationFrame(() => {
|
|
1350
|
-
if (this.slashMenuState().visible) {
|
|
1351
|
-
this._alignFixedTrigger(this._slashMenuTrigger().nativeElement, coords.left, coords.bottom, state => this.slashMenuState.update(current => ({ ...current, ...state })));
|
|
1352
|
-
const popoverControl = this._slashMenuPopoverControl;
|
|
1353
|
-
if (popoverControl?.isVisible()) {
|
|
1354
|
-
popoverControl.updatePosition();
|
|
1355
|
-
this._scrollActiveSlashMenuItemIntoView();
|
|
1356
|
-
return;
|
|
1357
|
-
}
|
|
1358
|
-
popoverControl?.show();
|
|
1359
|
-
this._scrollActiveSlashMenuItemIntoView();
|
|
1360
|
-
}
|
|
1361
|
-
});
|
|
1362
|
-
}
|
|
1363
|
-
_scrollActiveSlashMenuItemIntoView() {
|
|
1364
|
-
requestAnimationFrame(() => {
|
|
1365
|
-
const scrollHost = this._slashMenuScrollHost()?.nativeElement;
|
|
1366
|
-
const activeIndex = this.slashMenuActiveIndex();
|
|
1367
|
-
const lastIndex = this.filteredSlashCommands().length - 1;
|
|
1368
|
-
if (!scrollHost) {
|
|
1369
|
-
return;
|
|
1370
|
-
}
|
|
1371
|
-
if (activeIndex === 0) {
|
|
1372
|
-
scrollHost.scrollTop = 0;
|
|
1373
|
-
return;
|
|
1374
|
-
}
|
|
1375
|
-
if (activeIndex === lastIndex) {
|
|
1376
|
-
scrollHost.scrollTop = scrollHost.scrollHeight - scrollHost.clientHeight;
|
|
1377
|
-
return;
|
|
1378
|
-
}
|
|
1379
|
-
const activeItem = scrollHost?.querySelector('.z-editor-slash-menu-item-active');
|
|
1380
|
-
if (!(activeItem instanceof HTMLElement)) {
|
|
1381
|
-
return;
|
|
1382
|
-
}
|
|
1383
|
-
activeItem.scrollIntoView({ block: 'nearest' });
|
|
1384
|
-
});
|
|
1385
|
-
}
|
|
1386
|
-
_hideSlashMenu() {
|
|
1387
|
-
if (!this.slashMenuState().visible) {
|
|
1388
|
-
return;
|
|
1389
|
-
}
|
|
1390
|
-
this.slashMenuState.update(state => ({ ...state, visible: false }));
|
|
1391
|
-
this.slashMenuActiveIndex.set(0);
|
|
1392
|
-
this._slashMenuPopoverControl?.closeImmediate();
|
|
1393
|
-
}
|
|
1394
|
-
_dismissCurrentSlashMenu() {
|
|
1395
|
-
const { visible, query, from, to } = this.slashMenuState();
|
|
1396
|
-
if (visible) {
|
|
1397
|
-
this._dismissedSlashMenu = { query, from, to };
|
|
1398
|
-
this._hideSlashMenu();
|
|
1399
|
-
return;
|
|
1400
|
-
}
|
|
1401
|
-
const currentSlashMenuMatch = this._getCurrentSlashMenuMatch();
|
|
1402
|
-
if (currentSlashMenuMatch) {
|
|
1403
|
-
this._dismissedSlashMenu = currentSlashMenuMatch;
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
_getCurrentSlashMenuMatch() {
|
|
1407
|
-
const selection = this._editor?.state.selection;
|
|
1408
|
-
if (!selection?.empty) {
|
|
1409
|
-
return null;
|
|
1410
|
-
}
|
|
1411
|
-
const textBeforeCursor = selection.$from.parent.textBetween(0, selection.$from.parentOffset, '\0', '\0');
|
|
1412
|
-
const match = /(?:^|\s)\/([^\s/]*)$/.exec(textBeforeCursor);
|
|
1413
|
-
if (!match) {
|
|
1414
|
-
return null;
|
|
1415
|
-
}
|
|
1416
|
-
const query = match[1] ?? '';
|
|
1417
|
-
return {
|
|
1418
|
-
query,
|
|
1419
|
-
from: selection.from - query.length - 1,
|
|
1420
|
-
to: selection.from,
|
|
1421
|
-
};
|
|
1422
|
-
}
|
|
1423
|
-
_isDismissedSlashStillPresent() {
|
|
1424
|
-
const dismissed = this._dismissedSlashMenu;
|
|
1425
|
-
const doc = this._editor?.state.doc;
|
|
1426
|
-
if (!dismissed || !doc || dismissed.from < 0 || dismissed.from >= doc.content.size) {
|
|
1427
|
-
return false;
|
|
1428
|
-
}
|
|
1429
|
-
return doc.textBetween(dismissed.from, dismissed.from + 1, '\0', '\0') === '/';
|
|
1430
|
-
}
|
|
1431
|
-
_toggleLink() {
|
|
1432
|
-
const editor = this._editor;
|
|
1433
|
-
if (!editor) {
|
|
1434
|
-
return;
|
|
1435
|
-
}
|
|
1436
|
-
const { from, to } = editor.state.selection;
|
|
1437
|
-
this._linkAnchorElement = null;
|
|
1438
|
-
this._linkSelection = { from, to };
|
|
1439
|
-
const href = String(editor.getAttributes('link')['href'] ?? '');
|
|
1440
|
-
this.activeLinkHref.set(href);
|
|
1441
|
-
this.linkUrl.set(href);
|
|
1442
|
-
this._showLinkPopover();
|
|
1443
|
-
}
|
|
1444
|
-
closeLinkPopover() {
|
|
1445
|
-
this.linkPopoverState.update(state => ({ ...state, visible: false }));
|
|
1446
|
-
this._linkAnchorElement = null;
|
|
1447
|
-
this._linkPopoverControl?.closeImmediate();
|
|
1448
|
-
}
|
|
1449
|
-
onLinkUrlChange(value) {
|
|
1450
|
-
this.linkUrl.set(String(value ?? ''));
|
|
1451
|
-
}
|
|
1452
|
-
applyLink() {
|
|
1453
|
-
const editor = this._editor;
|
|
1454
|
-
const href = this.normalizedLinkUrl();
|
|
1455
|
-
const selection = this._linkSelection;
|
|
1456
|
-
if (!editor || !href || !selection) {
|
|
1457
|
-
return;
|
|
1458
|
-
}
|
|
1459
|
-
editor.chain().focus().setTextSelection(selection).extendMarkRange('link').setLink({ href }).run();
|
|
1460
|
-
this.closeLinkPopover();
|
|
1461
|
-
this._refreshEditorState();
|
|
1462
|
-
}
|
|
1463
|
-
_normalizeUrl(value) {
|
|
1464
|
-
const trimmed = value.trim();
|
|
1465
|
-
if (!trimmed) {
|
|
1466
|
-
return '';
|
|
1467
|
-
}
|
|
1468
|
-
try {
|
|
1469
|
-
const url = new URL(trimmed);
|
|
1470
|
-
return url.protocol === 'http:' || url.protocol === 'https:' ? url.toString() : '';
|
|
1471
|
-
}
|
|
1472
|
-
catch {
|
|
1473
|
-
return '';
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
removeLink() {
|
|
1477
|
-
const editor = this._editor;
|
|
1478
|
-
const selection = this._linkSelection;
|
|
1479
|
-
if (!editor || !selection) {
|
|
1480
|
-
this.closeLinkPopover();
|
|
1481
|
-
return;
|
|
1482
|
-
}
|
|
1483
|
-
editor.chain().focus().setTextSelection(selection).extendMarkRange('link').unsetLink().run();
|
|
1484
|
-
this.closeLinkPopover();
|
|
1485
|
-
this._refreshEditorState();
|
|
1486
|
-
}
|
|
1487
|
-
openActiveLink() {
|
|
1488
|
-
const href = this.activeLinkHref();
|
|
1489
|
-
if (!href) {
|
|
1490
|
-
return;
|
|
1491
|
-
}
|
|
1492
|
-
window.open(href, '_blank', 'noopener,noreferrer');
|
|
1493
|
-
}
|
|
1494
|
-
_handleEditorClick(view, event) {
|
|
1495
|
-
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
1496
|
-
const link = target?.closest('a[href]');
|
|
1497
|
-
if (!(link instanceof HTMLAnchorElement) || this.isDisabled() || this.zReadonly()) {
|
|
1498
|
-
return false;
|
|
1499
|
-
}
|
|
1500
|
-
if (event.detail >= 2) {
|
|
1501
|
-
this.closeLinkPopover();
|
|
1502
|
-
return false;
|
|
1503
|
-
}
|
|
1504
|
-
const position = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
1505
|
-
if (!position) {
|
|
1506
|
-
return false;
|
|
1507
|
-
}
|
|
1508
|
-
event.preventDefault();
|
|
1509
|
-
view.dispatch(view.state.tr.setSelection(TextSelection.near(view.state.doc.resolve(position.pos))));
|
|
1510
|
-
this._editor?.chain().focus().run();
|
|
1511
|
-
const selection = this._editor?.state.selection;
|
|
1512
|
-
if (!selection) {
|
|
1513
|
-
return true;
|
|
1514
|
-
}
|
|
1515
|
-
this._linkSelection = { from: selection.from, to: selection.to };
|
|
1516
|
-
this._linkAnchorElement = link;
|
|
1517
|
-
const href = link.href || link.getAttribute('href') || '';
|
|
1518
|
-
this.activeLinkHref.set(href);
|
|
1519
|
-
this.linkUrl.set(href);
|
|
1520
|
-
this._showLinkPopover();
|
|
1521
|
-
return true;
|
|
1522
|
-
}
|
|
1523
|
-
_showLinkPopover() {
|
|
1524
|
-
const rect = this._getLinkPopoverReferenceRect();
|
|
1525
|
-
if (!rect) {
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
this.linkPopoverState.set({
|
|
1529
|
-
visible: true,
|
|
1530
|
-
left: rect.left,
|
|
1531
|
-
top: rect.top,
|
|
1532
|
-
width: rect.width,
|
|
1533
|
-
height: rect.height,
|
|
1534
|
-
});
|
|
1535
|
-
requestAnimationFrame(() => {
|
|
1536
|
-
if (this.linkPopoverState().visible) {
|
|
1537
|
-
this._alignFixedTrigger(this._linkPopoverTrigger().nativeElement, rect.left, rect.top, state => this.linkPopoverState.update(current => ({ ...current, ...state })));
|
|
1538
|
-
this._linkPopoverControl?.show();
|
|
1539
|
-
}
|
|
1540
|
-
});
|
|
1541
|
-
}
|
|
1542
|
-
_alignFixedTrigger(trigger, targetLeft, targetTop, updatePosition) {
|
|
1543
|
-
const triggerRect = trigger.getBoundingClientRect();
|
|
1544
|
-
const left = Number.parseFloat(trigger.style.left) || 0;
|
|
1545
|
-
const top = Number.parseFloat(trigger.style.top) || 0;
|
|
1546
|
-
const correctedLeft = left + targetLeft - triggerRect.left;
|
|
1547
|
-
const correctedTop = top + targetTop - triggerRect.top;
|
|
1548
|
-
updatePosition({
|
|
1549
|
-
left: correctedLeft,
|
|
1550
|
-
top: correctedTop,
|
|
1551
|
-
});
|
|
1552
|
-
trigger.style.left = `${correctedLeft}px`;
|
|
1553
|
-
trigger.style.top = `${correctedTop}px`;
|
|
1554
|
-
}
|
|
1555
|
-
_getLinkPopoverReferenceRect() {
|
|
1556
|
-
const anchorRect = this._getLinkAnchorRect();
|
|
1557
|
-
if (anchorRect) {
|
|
1558
|
-
return anchorRect;
|
|
1559
|
-
}
|
|
1560
|
-
const editor = this._editor;
|
|
1561
|
-
const selection = this._linkSelection;
|
|
1562
|
-
if (!editor || !selection) {
|
|
1563
|
-
return null;
|
|
1564
|
-
}
|
|
1565
|
-
return posToDOMRect(editor.view, selection.from, selection.to);
|
|
1566
|
-
}
|
|
1567
|
-
_getLinkAnchorRect() {
|
|
1568
|
-
const anchor = this._linkAnchorElement;
|
|
1569
|
-
if (!anchor || !this._editorHost().nativeElement.contains(anchor)) {
|
|
1570
|
-
return null;
|
|
1571
|
-
}
|
|
1572
|
-
const rect = anchor.getBoundingClientRect();
|
|
1573
|
-
if (rect.width === 0 && rect.height === 0) {
|
|
1574
|
-
return null;
|
|
1575
|
-
}
|
|
1576
|
-
return rect;
|
|
1577
|
-
}
|
|
1578
|
-
_insertImage() {
|
|
1579
|
-
const editor = this._editor;
|
|
1580
|
-
if (!editor) {
|
|
1581
|
-
return;
|
|
1582
|
-
}
|
|
1583
|
-
const selectionFrom = editor.state.selection.from;
|
|
1584
|
-
const input = document.createElement('input');
|
|
1585
|
-
input.type = 'file';
|
|
1586
|
-
input.accept = 'image/*';
|
|
1587
|
-
input.style.display = 'none';
|
|
1588
|
-
const removeInput = () => {
|
|
1589
|
-
input.remove();
|
|
1590
|
-
};
|
|
1591
|
-
input.addEventListener('change', () => {
|
|
1592
|
-
const file = input.files?.[0];
|
|
1593
|
-
if (!file) {
|
|
1594
|
-
removeInput();
|
|
1595
|
-
return;
|
|
1596
|
-
}
|
|
1597
|
-
const reader = new FileReader();
|
|
1598
|
-
reader.addEventListener('load', () => {
|
|
1599
|
-
const src = typeof reader.result === 'string' ? reader.result : '';
|
|
1600
|
-
if (src) {
|
|
1601
|
-
editor.chain().focus().setTextSelection(selectionFrom).setImage({ src, alt: file.name }).run();
|
|
1602
|
-
}
|
|
1603
|
-
removeInput();
|
|
1604
|
-
});
|
|
1605
|
-
reader.addEventListener('error', removeInput);
|
|
1606
|
-
reader.readAsDataURL(file);
|
|
1607
|
-
}, { once: true });
|
|
1608
|
-
document.body.appendChild(input);
|
|
1609
|
-
input.click();
|
|
1610
|
-
}
|
|
1611
|
-
_setTextAlign(alignment) {
|
|
1612
|
-
const editor = this._editor;
|
|
1613
|
-
if (!editor) {
|
|
1614
|
-
return;
|
|
1615
|
-
}
|
|
1616
|
-
const command = alignment === 'left' ? editor.chain().focus().unsetTextAlign() : editor.chain().focus().setTextAlign(alignment);
|
|
1617
|
-
command.run();
|
|
1618
|
-
}
|
|
1619
|
-
_collapseSelectionToAnchor() {
|
|
1620
|
-
const editor = this._editor;
|
|
1621
|
-
if (!editor) {
|
|
1622
|
-
return;
|
|
1623
|
-
}
|
|
1624
|
-
const { from } = editor.state.selection;
|
|
1625
|
-
editor.commands.setTextSelection(from);
|
|
1626
|
-
editor.view.dispatch(editor.state.tr.setMeta('zEditorBubbleMenu', 'updatePosition'));
|
|
1627
|
-
}
|
|
1628
|
-
_getTextStyleAttribute(attribute) {
|
|
1629
|
-
this._selectionVersion();
|
|
1630
|
-
return String(this._editor?.getAttributes('textStyle')[attribute] ?? '');
|
|
1631
|
-
}
|
|
1632
|
-
_getActiveBlockStyle() {
|
|
1633
|
-
const editor = this._editor;
|
|
1634
|
-
this._selectionVersion();
|
|
1635
|
-
if (!editor) {
|
|
1636
|
-
return 'paragraph';
|
|
1637
|
-
}
|
|
1638
|
-
if (editor.isActive('heading', { level: 1 })) {
|
|
1639
|
-
return 'heading1';
|
|
1640
|
-
}
|
|
1641
|
-
if (editor.isActive('heading', { level: 2 })) {
|
|
1642
|
-
return 'heading2';
|
|
1643
|
-
}
|
|
1644
|
-
if (editor.isActive('heading', { level: 3 })) {
|
|
1645
|
-
return 'heading3';
|
|
1646
|
-
}
|
|
1647
|
-
if (editor.isActive('heading', { level: 4 })) {
|
|
1648
|
-
return 'heading4';
|
|
1649
|
-
}
|
|
1650
|
-
return 'paragraph';
|
|
1651
|
-
}
|
|
1652
|
-
_getActiveAlign() {
|
|
1653
|
-
const editor = this._editor;
|
|
1654
|
-
this._selectionVersion();
|
|
1655
|
-
if (!editor) {
|
|
1656
|
-
return 'alignLeft';
|
|
1657
|
-
}
|
|
1658
|
-
return this._getActiveAlignFromEditor(editor);
|
|
1659
|
-
}
|
|
1660
|
-
_getActiveAlignFromEditor(editor) {
|
|
1661
|
-
if (editor.isActive({ textAlign: 'center' })) {
|
|
1662
|
-
return 'alignCenter';
|
|
1663
|
-
}
|
|
1664
|
-
if (editor.isActive({ textAlign: 'right' })) {
|
|
1665
|
-
return 'alignRight';
|
|
1666
|
-
}
|
|
1667
|
-
if (editor.isActive({ textAlign: 'justify' })) {
|
|
1668
|
-
return 'alignJustify';
|
|
1669
|
-
}
|
|
1670
|
-
return 'alignLeft';
|
|
1671
|
-
}
|
|
1672
|
-
_createImageExtension(options) {
|
|
1673
|
-
return ImageResize.extend({
|
|
1674
|
-
addAttributes() {
|
|
1675
|
-
return {
|
|
1676
|
-
...this.parent?.(),
|
|
1677
|
-
textAlign: {
|
|
1678
|
-
default: null,
|
|
1679
|
-
parseHTML: element => element.style.textAlign || element.getAttribute('data-text-align') || null,
|
|
1680
|
-
renderHTML: attributes => {
|
|
1681
|
-
const textAlign = String(attributes['textAlign'] ?? '');
|
|
1682
|
-
if (!textAlign) {
|
|
1683
|
-
return {};
|
|
1684
|
-
}
|
|
1685
|
-
return {
|
|
1686
|
-
'data-text-align': textAlign,
|
|
1687
|
-
style: ZEditorComponent._getImageAlignStyle(textAlign),
|
|
1688
|
-
};
|
|
1689
|
-
},
|
|
1690
|
-
},
|
|
1691
|
-
};
|
|
1692
|
-
},
|
|
1693
|
-
}).configure(options);
|
|
1694
|
-
}
|
|
1695
|
-
static _getImageAlignStyle(textAlign) {
|
|
1696
|
-
if (textAlign === 'center') {
|
|
1697
|
-
return 'display: block; margin-left: auto; margin-right: auto;';
|
|
1698
|
-
}
|
|
1699
|
-
if (textAlign === 'right') {
|
|
1700
|
-
return 'display: block; margin-left: auto; margin-right: 0;';
|
|
1701
|
-
}
|
|
1702
|
-
return 'display: block; margin-left: 0; margin-right: auto;';
|
|
1703
|
-
}
|
|
1704
|
-
_placeholderConfig() {
|
|
1705
|
-
const { placeholder } = this.zTipTap();
|
|
1706
|
-
if (!placeholder || typeof placeholder === 'string') {
|
|
1707
|
-
return {};
|
|
1708
|
-
}
|
|
1709
|
-
const { mode: _mode, ...config } = placeholder;
|
|
1710
|
-
return config;
|
|
1711
|
-
}
|
|
1712
|
-
_placeholderMode() {
|
|
1713
|
-
const { placeholder } = this.zTipTap();
|
|
1714
|
-
return typeof placeholder === 'object' && placeholder.mode === 'firstLine' ? 'firstLine' : 'everyLine';
|
|
1715
|
-
}
|
|
1716
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: ZEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1717
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.9", type: ZEditorComponent, isStandalone: true, selector: "z-editor", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, zSize: { classPropertyName: "zSize", publicName: "zSize", isSignal: true, isRequired: false, transformFunction: null }, zLabel: { classPropertyName: "zLabel", publicName: "zLabel", isSignal: true, isRequired: false, transformFunction: null }, zLabelClass: { classPropertyName: "zLabelClass", publicName: "zLabelClass", isSignal: true, isRequired: false, transformFunction: null }, zPlaceholder: { classPropertyName: "zPlaceholder", publicName: "zPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, zRequired: { classPropertyName: "zRequired", publicName: "zRequired", isSignal: true, isRequired: false, transformFunction: null }, zDisabled: { classPropertyName: "zDisabled", publicName: "zDisabled", isSignal: true, isRequired: false, transformFunction: null }, zReadonly: { classPropertyName: "zReadonly", publicName: "zReadonly", isSignal: true, isRequired: false, transformFunction: null }, zContentType: { classPropertyName: "zContentType", publicName: "zContentType", isSignal: true, isRequired: false, transformFunction: null }, zToolbar: { classPropertyName: "zToolbar", publicName: "zToolbar", isSignal: true, isRequired: false, transformFunction: null }, zTipTap: { classPropertyName: "zTipTap", publicName: "zTipTap", isSignal: true, isRequired: false, transformFunction: null }, zValidators: { classPropertyName: "zValidators", publicName: "zValidators", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { zOnChange: "zOnChange", zOnFocus: "zOnFocus", zOnBlur: "zOnBlur", zControl: "zControl", zEvent: "zEvent" }, providers: [
|
|
1718
|
-
{
|
|
1719
|
-
provide: NG_VALUE_ACCESSOR,
|
|
1720
|
-
useExisting: forwardRef(() => ZEditorComponent),
|
|
1721
|
-
multi: true,
|
|
1722
|
-
},
|
|
1723
|
-
], viewQueries: [{ propertyName: "_editorHost", first: true, predicate: ["editorHost"], descendants: true, isSignal: true }, { propertyName: "_floatingToolbar", first: true, predicate: ["floatingToolbar"], descendants: true, isSignal: true }, { propertyName: "_slashMenuTrigger", first: true, predicate: ["slashMenuTrigger"], descendants: true, isSignal: true }, { propertyName: "_linkPopoverTrigger", first: true, predicate: ["linkPopoverTrigger"], descendants: true, isSignal: true }, { propertyName: "_slashMenuScrollHost", first: true, predicate: ["slashMenuScrollHost"], descendants: true, isSignal: true }], exportAs: ["zEditor"], ngImport: i0, template: "<div [class]=\"wrapperClasses()\" [class.z-editor-disabled]=\"isDisabled()\" [class.z-editor-readonly]=\"zReadonly()\">\n @if (zLabel()) {\n <label [for]=\"editorId\" class=\"text-xs leading-none font-medium\" [class]=\"zLabelClass()\">\n {{ zLabel() }}\n @if (zRequired()) {\n <span class=\"text-destructive! ml-0.5\">*</span>\n }\n </label>\n }\n\n <div [class]=\"editorClasses()\">\n @if (showToolbar()) {\n <div class=\"z-editor-toolbar\" role=\"toolbar\" [attr.aria-controls]=\"editorId\">\n @for (item of toolbarItems(); track item.id) {\n @switch (item.id) {\n @case ('emoji') {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"emojiPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-emoji-popover\"\n (zControl)=\"onEmojiPopoverControl($event)\"\n (zShow)=\"onEmojiPopoverShow()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n @case ('blockStyle') {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"blockStylePopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-menu-popover\"\n (zControl)=\"onBlockStylePopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n @case ('textColor') {\n @let textColor = activeTextColor();\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"textColorPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-color-popover\"\n (zControl)=\"onTextColorPopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span class=\"z-editor-color-indicator\" [style.background]=\"textColor\"></span>\n </button>\n }\n @case ('backgroundColor') {\n @let bgColor = activeBackgroundColor();\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"backgroundColorPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-color-popover\"\n (zControl)=\"onBackgroundColorPopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span class=\"z-editor-color-indicator\" [style.background]=\"bgColor\"></span>\n </button>\n }\n @case ('align') {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"alignPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-menu-popover\"\n (zControl)=\"onAlignPopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\">\n <i z-icon [zType]=\"activeAlignIcon()\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n @default {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n [class.z-editor-toolbar-button-active]=\"item.active\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\"\n (click)=\"onToolbarClick(item.id)\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n }\n }\n </div>\n }\n\n <div\n #editorHost\n [id]=\"editorId\"\n class=\"z-editor-content\"\n role=\"textbox\"\n [attr.aria-multiline]=\"true\"\n [attr.aria-readonly]=\"isDisabled() || zReadonly()\"></div>\n </div>\n\n @if (hasError()) {\n <p class=\"text-destructive animate-in fade-in slide-in-from-top-1 m-0 text-xs duration-200\">\n {{ errorMessage() }}\n </p>\n }\n\n <ng-template #emojiPopover>\n @let emojiCategoryLabel =\n emojiSearchQuery() ? ('i18n_z_ui_emoji_search_results' | translate) : (activeEmojiCategoryLabel() | translate);\n @let activeCategoryId = activeEmojiCategoryId();\n <div class=\"z-editor-emoji-sheet\">\n <div class=\"z-editor-emoji-header\">\n <div class=\"z-editor-emoji-title mb-1\">\n <span class=\"z-editor-emoji-title-dot\" aria-hidden=\"true\"></span>\n <span>{{ emojiCategoryLabel }}</span>\n </div>\n <z-input\n class=\"z-editor-emoji-search\"\n zSize=\"sm\"\n [zSearch]=\"true\"\n [zDebounce]=\"150\"\n [zPlaceholder]=\"'i18n_z_ui_emoji_search_placeholder' | translate\"\n [ngModel]=\"emojiSearch()\"\n (zOnSearch)=\"emojiSearch.set($any($event))\" />\n </div>\n <div class=\"z-editor-emoji-body\">\n @if (hasEmojiResults()) {\n <div class=\"z-editor-emoji-grid\">\n @for (emoji of activeEmojis(); track emoji) {\n <button\n type=\"button\"\n class=\"z-editor-emoji-button\"\n [attr.aria-label]=\"emoji\"\n (click)=\"insertEmoji($any(emoji))\">\n {{ emoji }}\n </button>\n }\n </div>\n } @else {\n <div class=\"z-editor-emoji-empty\">\n <span class=\"z-editor-emoji-empty-icon\" aria-hidden=\"true\">\n <i z-icon zType=\"lucideSearchX\" zSize=\"14\" [zStrokeWidth]=\"2\"></i>\n </span>\n <span>{{ 'i18n_z_ui_emoji_no_results' | translate }}</span>\n </div>\n }\n </div>\n <div class=\"z-editor-emoji-footer\" role=\"tablist\">\n @for (category of emojiCategories; track category.id) {\n <button\n type=\"button\"\n role=\"tab\"\n class=\"z-editor-emoji-footer-button cursor-pointer!\"\n [class.z-editor-emoji-footer-button-active]=\"category.id === activeCategoryId\"\n [attr.aria-label]=\"category.labelKey | translate\"\n [attr.aria-selected]=\"category.id === activeCategoryId\"\n [attr.title]=\"category.labelKey | translate\"\n (click)=\"setEmojiCategory(category.id)\">\n <i z-icon [zType]=\"category.icon\" zSize=\"15\" [zStrokeWidth]=\"2\"></i>\n </button>\n }\n </div>\n </div>\n </ng-template>\n\n <ng-template #blockStylePopover let-close=\"close\">\n <div class=\"z-editor-menu-list\">\n @for (option of blockStyleOptions; track option.command) {\n <button\n type=\"button\"\n class=\"z-editor-menu-item\"\n [class.z-editor-menu-item-active]=\"activeBlockStyle() === option.command\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"applyBlockStyle(option.command, close)\">\n <i z-icon [zType]=\"option.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span>{{ option.label }}</span>\n </button>\n }\n </div>\n </ng-template>\n\n <ng-template #alignPopover let-close=\"close\">\n <div class=\"z-editor-menu-list\">\n @for (option of alignOptions; track option.command) {\n <button\n type=\"button\"\n class=\"z-editor-menu-item\"\n [class.z-editor-menu-item-active]=\"activeAlign() === option.command\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"applyAlign(option.command, close)\">\n <i z-icon [zType]=\"option.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span>{{ option.label }}</span>\n </button>\n }\n </div>\n </ng-template>\n\n <ng-template #textColorPopover let-close=\"close\">\n @let currentTextColor = activeTextColor();\n <div class=\"z-editor-color-grid\">\n @for (color of textColorSwatches; track color) {\n <button\n type=\"button\"\n class=\"z-editor-color-swatch\"\n [class.z-editor-color-swatch-active]=\"currentTextColor === color\"\n [style.background]=\"color\"\n [attr.aria-label]=\"'Text color ' + color\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"setTextColor(color, close)\"></button>\n }\n <label class=\"z-editor-color-custom\">\n <input type=\"color\" [value]=\"currentTextColor\" (input)=\"setTextColorFromEvent($event, close)\" />\n {{ currentTextColor }}\n </label>\n <button\n type=\"button\"\n z-button\n zType=\"outline\"\n zSize=\"sm\"\n class=\"z-editor-color-reset\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"unsetTextColor(close)\">\n Reset\n </button>\n </div>\n </ng-template>\n\n <ng-template #backgroundColorPopover let-close=\"close\">\n @let currentBgColor = activeBackgroundColor();\n <div class=\"z-editor-color-grid\">\n @for (color of backgroundColorSwatches; track color) {\n <button\n type=\"button\"\n class=\"z-editor-color-swatch\"\n [class.z-editor-color-swatch-active]=\"currentBgColor === color\"\n [style.background]=\"color\"\n [attr.aria-label]=\"'Background color ' + color\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"setBackgroundColor(color, close)\"></button>\n }\n <label class=\"z-editor-color-custom\">\n <input type=\"color\" [value]=\"currentBgColor\" (input)=\"setBackgroundColorFromEvent($event, close)\" />\n {{ currentBgColor }}\n </label>\n <button\n type=\"button\"\n z-button\n zType=\"outline\"\n zSize=\"sm\"\n class=\"z-editor-color-reset\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"unsetBackgroundColor(close)\">\n Reset\n </button>\n </div>\n </ng-template>\n\n <div #floatingToolbar class=\"z-editor-floating-toolbar\" role=\"toolbar\" [attr.aria-controls]=\"editorId\">\n @for (item of floatingToolbarItems(); track item.id) {\n @switch (item.id) {\n @case ('blockStyle') {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"blockStylePopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-menu-popover\"\n (zControl)=\"onBlockStylePopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"activeBlockStyleLabel()\"\n (mousedown)=\"$event.preventDefault()\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n @case ('textColor') {\n @let textColor = activeTextColor();\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"textColorPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-color-popover\"\n (zControl)=\"onTextColorPopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\"\n (mousedown)=\"$event.preventDefault()\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span class=\"z-editor-color-indicator\" [style.background]=\"textColor\"></span>\n </button>\n }\n @case ('backgroundColor') {\n @let bgColor = activeBackgroundColor();\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"backgroundColorPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-color-popover\"\n (zControl)=\"onBackgroundColorPopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\"\n (mousedown)=\"$event.preventDefault()\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span class=\"z-editor-color-indicator\" [style.background]=\"bgColor\"></span>\n </button>\n }\n @case ('align') {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"alignPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-menu-popover\"\n (zControl)=\"onAlignPopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"activeAlignLabel()\"\n (mousedown)=\"$event.preventDefault()\">\n <i z-icon [zType]=\"activeAlignIcon()\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n @default {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-tooltip\n [zContent]=\"item.tooltip\"\n zPosition=\"top\"\n [zAlwaysShow]=\"true\"\n [zDisabled]=\"item.disabled || !item.shortcut\"\n [class.z-editor-toolbar-button-active]=\"item.active\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"onFloatingToolbarClick(item.id)\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n }\n }\n </div>\n\n <span\n #slashMenuTrigger\n class=\"z-editor-slash-menu-trigger\"\n z-popover\n [zPopoverContent]=\"slashMenuPopover\"\n zTrigger=\"manual\"\n zPosition=\"bottom-left\"\n zClass=\"z-editor-slash-popover\"\n [zOffset]=\"4\"\n [zPopoverWidth]=\"300\"\n [style.left.px]=\"slashMenuState().left\"\n [style.top.px]=\"slashMenuState().top\"\n (zControl)=\"onSlashMenuPopoverControl($event)\"\n (zHide)=\"onSlashMenuPopoverHide()\"></span>\n\n <ng-template #slashMenuPopover>\n @let slashActiveIndex = slashMenuActiveIndex();\n <div class=\"z-editor-slash-menu-shell\">\n <div #slashMenuScrollHost class=\"z-editor-slash-menu-scrollbar\">\n <div class=\"z-editor-slash-menu\" role=\"listbox\" [attr.aria-controls]=\"editorId\">\n @for (item of filteredSlashCommands(); track item.id) {\n @if (item.showGroupLabel) {\n <div class=\"z-editor-slash-menu-group\">\n {{ item.group }}\n </div>\n }\n <button\n type=\"button\"\n class=\"z-editor-slash-menu-item\"\n role=\"option\"\n [class.z-editor-slash-menu-item-active]=\"$index === slashActiveIndex\"\n [attr.aria-selected]=\"$index === slashActiveIndex\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"applySlashCommand(item)\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span class=\"z-editor-slash-menu-copy\">\n <span class=\"z-editor-slash-menu-label\">{{ item.label }}</span>\n </span>\n </button>\n } @empty {\n <div class=\"z-editor-slash-menu-empty\">\n <i z-icon zType=\"lucideSearchX\" zSize=\"28\" [zStrokeWidth]=\"1.8\"></i>\n <span>{{ 'i18n_z_ui_editor_no_commands' | translate }}</span>\n </div>\n }\n </div>\n </div>\n <div class=\"z-editor-slash-menu-footer\" aria-hidden=\"true\">\n <span>\n <kbd>\u2191\u2193</kbd>\n {{ 'i18n_z_ui_editor_shortcut_navigate' | translate }}\n </span>\n <span>\n <kbd>Esc</kbd>\n {{ 'i18n_z_ui_editor_shortcut_abort' | translate }}\n </span>\n <span>\n <kbd>\u21B5</kbd>\n {{ 'i18n_z_ui_editor_shortcut_select' | translate }}\n </span>\n </div>\n </div>\n </ng-template>\n\n <span\n #linkPopoverTrigger\n class=\"z-editor-link-popover-trigger\"\n z-popover\n [zPopoverContent]=\"linkPopover\"\n zTrigger=\"manual\"\n zPosition=\"bottom-left\"\n zClass=\"z-editor-link-popover\"\n [zOffset]=\"6\"\n [zPopoverWidth]=\"320\"\n [style.left.px]=\"linkPopoverState().left\"\n [style.top.px]=\"linkPopoverState().top\"\n [style.width.px]=\"linkPopoverState().width\"\n [style.height.px]=\"linkPopoverState().height\"\n (zControl)=\"onLinkPopoverControl($event)\"\n (zHide)=\"onLinkPopoverHide()\"></span>\n\n <ng-template #linkPopover>\n <div class=\"z-editor-link-popover-content\">\n <ng-template #linkPrefix>\n <z-icon zType=\"lucideLink\" zSize=\"16\" class=\"text-muted-foreground\" />\n </ng-template>\n <z-input\n zType=\"url\"\n zSize=\"sm\"\n class=\"z-editor-link-popover-input\"\n [zPrefix]=\"linkPrefix\"\n zPlaceholder=\"https://example.com\"\n [zValidators]=\"linkValidators\"\n [ngModel]=\"linkUrl()\"\n (ngModelChange)=\"onLinkUrlChange($event)\"\n (zOnEnter)=\"applyLink()\" />\n <div class=\"z-editor-link-popover-actions\">\n <button\n type=\"button\"\n z-button\n zType=\"ghost\"\n zSize=\"sm\"\n [zDisabled]=\"!canApplyLink()\"\n (click)=\"applyLink()\"\n aria-label=\"Apply link\">\n <z-icon zType=\"lucideCheck\" zSize=\"16\" [zStrokeWidth]=\"2.5\" />\n </button>\n <button\n type=\"button\"\n z-button\n zType=\"ghost\"\n zSize=\"sm\"\n [zDisabled]=\"!activeLinkHref()\"\n (click)=\"openActiveLink()\"\n aria-label=\"Open link\">\n <z-icon zType=\"lucideExternalLink\" zSize=\"16\" [zStrokeWidth]=\"2.5\" />\n </button>\n <button\n type=\"button\"\n z-button\n zType=\"ghost-destructive\"\n zSize=\"sm\"\n [zDisabled]=\"!activeLinkHref()\"\n (click)=\"removeLink()\"\n aria-label=\"Remove link\">\n <z-icon zType=\"lucideUnlink\" zSize=\"16\" [zStrokeWidth]=\"2.5\" />\n </button>\n </div>\n </div>\n </ng-template>\n</div>\n", styles: [".z-editor-wrapper .z-editor-toolbar{display:flex;flex-wrap:wrap;gap:.125rem;align-items:center;border-bottom:.0625rem solid var(--border);border-top-left-radius:.375rem;border-top-right-radius:.375rem;background-color:color-mix(in srgb,var(--muted) 30%,transparent);padding:.5rem}.z-editor-wrapper .z-editor-toolbar-button{position:relative;display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;border-radius:.25rem;padding:0;color:var(--muted-foreground);transition:background-color .15s ease,color .15s ease,opacity .15s ease}.z-editor-wrapper .z-editor-toolbar-button:hover:not(:disabled){background-color:var(--accent);color:var(--foreground)}.z-editor-wrapper .z-editor-toolbar-button:disabled{cursor:not-allowed;opacity:.45}.z-editor-wrapper .z-editor-toolbar-button.z-editor-toolbar-button-active{background-color:color-mix(in srgb,var(--primary) 10%,transparent);color:var(--primary)}.z-editor-wrapper .z-editor-content{position:relative;border-bottom-right-radius:.375rem;border-bottom-left-radius:.375rem}.z-editor-wrapper .z-editor-prosemirror{width:100%;outline:none;padding:.75rem;color:var(--foreground)}.z-editor-wrapper .z-editor-prosemirror>*{margin-top:1.25rem;margin-bottom:1.25rem}.z-editor-wrapper .z-editor-prosemirror>:first-child{margin-top:0}.z-editor-wrapper .z-editor-prosemirror>:last-child{margin-bottom:0}.z-editor-wrapper .z-editor-prosemirror p{line-height:1.75}.z-editor-wrapper .z-editor-prosemirror a{color:var(--primary);font-weight:500;text-decoration-line:underline;text-decoration-color:currentcolor;text-decoration-thickness:.0625rem;text-underline-offset:.1875rem;cursor:pointer;transition:text-decoration-color .15s ease}.z-editor-wrapper .z-editor-prosemirror a:hover{text-decoration-color:color-mix(in srgb,currentcolor 70%,transparent)}.z-editor-wrapper .z-editor-prosemirror .mention{color:var(--primary);font-weight:500}.z-editor-wrapper .z-editor-prosemirror :is(h1,h2,h3,h4,h5,h6){color:var(--foreground);font-weight:700;line-height:1.2}.z-editor-wrapper .z-editor-prosemirror h1{font-size:1.875rem}.z-editor-wrapper .z-editor-prosemirror h2{font-size:1.5rem}.z-editor-wrapper .z-editor-prosemirror h3{font-size:1.25rem}.z-editor-wrapper .z-editor-prosemirror h4{font-size:1.125rem}.z-editor-wrapper .z-editor-prosemirror h5,.z-editor-wrapper .z-editor-prosemirror h6{font-size:1rem}.z-editor-wrapper .z-editor-prosemirror blockquote{border-left:.25rem solid var(--border);padding-left:1rem;font-style:italic;color:var(--muted-foreground)}.z-editor-wrapper .z-editor-prosemirror [data-type=horizontalRule]{margin-top:2rem;margin-bottom:2rem;padding-top:.5rem;padding-bottom:.5rem}.z-editor-wrapper .z-editor-prosemirror hr{border:0;border-top:.0625rem solid var(--border)}.z-editor-wrapper .z-editor-prosemirror pre{overflow-x:auto;border:.0625rem solid var(--border);border-radius:.375rem;background-color:var(--muted);padding:.75rem 1rem;font-size:.875rem;line-height:1.5;white-space:pre-wrap;word-break:break-word}.z-editor-wrapper .z-editor-prosemirror pre code{display:inline;border:0;border-radius:0;background-color:transparent;padding:0;color:inherit;font:inherit}.z-editor-wrapper .z-editor-prosemirror code{display:inline-block;border:.0625rem solid var(--border);border-radius:.375rem;background-color:var(--muted);padding:.125rem .375rem;color:var(--foreground);font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:.875em;font-weight:500}.z-editor-wrapper .z-editor-prosemirror :is(ul,ol){padding-left:1.5rem}.z-editor-wrapper .z-editor-prosemirror ul{list-style:disc}.z-editor-wrapper .z-editor-prosemirror ol{list-style:decimal}.z-editor-wrapper .z-editor-prosemirror li{margin-top:.375rem;margin-bottom:.375rem;padding-left:.375rem}.z-editor-wrapper .z-editor-prosemirror img{display:block;max-width:100%;border-radius:.375rem}.z-editor-wrapper .z-editor-prosemirror img[data-text-align=center]{margin-right:auto;margin-left:auto}.z-editor-wrapper .z-editor-prosemirror img[data-text-align=right]{margin-right:0;margin-left:auto}.z-editor-wrapper .z-editor-prosemirror img[data-text-align=left],.z-editor-wrapper .z-editor-prosemirror img[data-text-align=justify]{margin-right:auto;margin-left:0}.z-editor-wrapper .z-editor-prosemirror img.ProseMirror-selectednode{outline:.125rem solid var(--primary)}.z-editor-wrapper .z-editor-prosemirror .image-resizer{display:inline-flex;position:relative;flex-grow:0}.z-editor-wrapper .z-editor-prosemirror .image-resizer .resize-trigger{position:absolute;right:-6px;bottom:-9px;width:12px;height:12px;cursor:nwse-resize;border-radius:50%;background-color:var(--primary);opacity:0;transition:opacity .2s ease}.z-editor-wrapper .z-editor-prosemirror .image-resizer:hover .resize-trigger{opacity:1}.z-editor-wrapper .z-editor-prosemirror .image-resizer .image-alignment{display:flex;gap:4px;position:absolute;top:-32px;left:0;padding:4px;border-radius:6px;background-color:var(--popover);box-shadow:0 2px 8px #00000026;opacity:0;transition:opacity .2s ease;pointer-events:none}.z-editor-wrapper .z-editor-prosemirror .image-resizer:hover .image-alignment{opacity:1;pointer-events:auto}.z-editor-wrapper .z-editor-prosemirror .ProseMirror-selectednode:not(img):not(pre):not([data-node-view-wrapper]){background-color:color-mix(in srgb,var(--primary) 20%,transparent)}.z-editor-wrapper .z-editor-prosemirror :is(p,h1,h2,h3,h4,h5,h6).is-empty:before{float:left;height:0;color:var(--muted-foreground);content:attr(data-placeholder);pointer-events:none}.z-editor-placeholder-first-line .z-editor-wrapper .z-editor-prosemirror :is(p,h1,h2,h3,h4,h5,h6).is-empty:before{content:none}.z-editor-placeholder-first-line .z-editor-wrapper .z-editor-prosemirror :is(p,h1,h2,h3,h4,h5,h6).is-editor-empty:first-child:before{content:attr(data-placeholder)}.z-editor-wrapper.z-editor-disabled .z-editor-toolbar,.z-editor-wrapper.z-editor-disabled .z-editor-content{pointer-events:none}.z-editor-wrapper.z-editor-readonly .z-editor-toolbar{display:none}.z-editor-wrapper.z-editor-readonly .z-editor-content{border-radius:.375rem}.z-editor-wrapper.z-editor-readonly .z-editor-prosemirror{cursor:default}.z-editor-link-modal{padding-top:0;padding-bottom:0}.z-editor-link-modal .z-modal-scrollbar main{min-height:0;padding:1rem}.z-editor-emoji-popover{padding:0;overflow:hidden;box-shadow:0 .5rem 1.5rem -.25rem #0000002e,0 .25rem .5rem -.125rem #0000001a}.z-editor-color-popover{padding:.5rem}.z-editor-menu-popover{padding:.25rem}.z-editor-menu-list{display:flex;min-width:9rem;flex-direction:column;gap:.125rem}.z-editor-menu-item{display:flex;width:100%;cursor:pointer;align-items:center;gap:.5rem;border-radius:.25rem;padding:.375rem .5rem;color:var(--muted-foreground);font-size:.8125rem;line-height:1.25;transition:background-color .15s ease,color .15s ease}.z-editor-menu-item:hover,.z-editor-menu-item.z-editor-menu-item-active{background-color:var(--accent);color:var(--foreground)}.z-editor-color-indicator{position:absolute;right:.25rem;bottom:.1875rem;width:.75rem;height:.1875rem;border-radius:999px;box-shadow:0 0 0 .0625rem var(--border)}.z-editor-color-grid{display:grid;grid-template-columns:repeat(5,1.625rem);gap:.25rem}.z-editor-color-swatch{width:1.625rem;height:1.625rem;border:.0625rem solid var(--border);border-radius:.25rem;cursor:pointer;transition:border-color .15s ease,box-shadow .15s ease,transform .15s ease}.z-editor-color-swatch:hover{transform:translateY(-.0625rem);border-color:var(--ring)}.z-editor-color-swatch.z-editor-color-swatch-active{border-color:var(--primary);box-shadow:0 0 0 .125rem color-mix(in srgb,var(--primary) 20%,transparent)}.z-editor-color-custom{grid-column:1/-1;display:flex;height:1.875rem;cursor:pointer;align-items:center;gap:.5rem;border:.0625rem solid var(--border);border-radius:.25rem;padding:.25rem .5rem;color:var(--muted-foreground);font-size:.75rem;transition:border-color .15s ease,background-color .15s ease,color .15s ease}.z-editor-color-custom input{width:1.375rem;height:1.375rem;flex:none;cursor:pointer;border:0;padding:0;background:transparent}.z-editor-color-custom:hover{border-color:var(--ring);background-color:var(--accent);color:var(--foreground)}.z-editor-color-reset{grid-column:1/-1;width:100%;justify-content:center}.z-editor-floating-toolbar{display:inline-flex;align-items:center;gap:.125rem;border:.0625rem solid var(--border);border-radius:.25rem;background-color:var(--popover);padding:.375rem;box-shadow:0 .625rem 1.5rem -.75rem #00000059,0 .25rem .75rem -.5rem #0003;visibility:hidden;opacity:0;position:fixed;top:-10000px;left:-10000px;scale:.98;translate:0 .25rem;transform-origin:top left;transition:opacity .12s ease,visibility .12s ease,scale .16s ease,translate .16s ease}.z-editor-floating-toolbar[style*=\"visibility: visible\"]{animation:z-editor-floating-toolbar-in .16s cubic-bezier(.16,1,.3,1);scale:1;translate:0 0}@keyframes z-editor-floating-toolbar-in{0%{opacity:0;scale:.96;translate:0 .375rem}to{opacity:1;scale:1;translate:0 0}}.z-editor-slash-menu-trigger,.z-editor-link-popover-trigger{position:fixed;z-index:-1;width:.0625rem;height:.0625rem;pointer-events:none}.z-editor-link-popover{padding:.5rem}.z-editor-link-popover-content{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;column-gap:.5rem}.z-editor-link-popover-input{flex:1;min-width:0}.z-editor-link-popover-actions{display:inline-flex;align-self:start;align-items:center;gap:.125rem}.z-editor-slash-popover{box-sizing:border-box;padding:0;overflow:hidden}.z-editor-slash-menu-shell{box-sizing:border-box;display:flex;min-width:0;height:min(16rem,100vh - 4rem);flex-direction:column}.z-editor-slash-menu-scrollbar{box-sizing:border-box;display:block;min-width:0;min-height:0;flex:1;overflow-x:hidden;overflow-y:scroll;overscroll-behavior:contain}.z-editor-slash-menu{box-sizing:border-box;display:flex;min-width:0;min-height:100%;flex-direction:column;padding:.2rem;gap:.2rem;color:var(--popover-foreground)}.z-editor-slash-menu-group{margin:.25rem 0 .125rem;border-top:.0625rem solid var(--border);padding:.5rem .5rem .1875rem;color:var(--muted-foreground);font-size:.6875rem;font-weight:600;line-height:1;text-transform:uppercase}.z-editor-slash-menu-group:first-child{margin-top:0;border-top:0;padding-top:.5rem}.z-editor-slash-menu-item{box-sizing:border-box;display:flex;align-self:stretch;min-width:0;cursor:pointer;align-items:center;gap:.5rem;border-radius:.25rem;padding:.375rem .75rem;text-align:left;transition:background-color .15s ease,color .15s ease}.z-editor-slash-menu-item i{color:var(--muted-foreground);flex:none}.z-editor-slash-menu-item:hover,.z-editor-slash-menu-item.z-editor-slash-menu-item-active{background-color:var(--accent);color:var(--foreground)}.z-editor-slash-menu-copy{display:flex;min-width:0;align-items:center}.z-editor-slash-menu-label{color:var(--foreground);font-size:.8125rem;font-weight:500;line-height:1.2}.z-editor-slash-menu-empty{box-sizing:border-box;display:flex;align-self:stretch;max-width:100%;min-width:0;flex:1;flex-direction:column;align-items:center;justify-content:center;gap:.625rem;padding:1rem;color:var(--muted-foreground);font-size:.8125rem;line-height:1.15;text-align:center}.z-editor-slash-menu-empty i{color:var(--muted-foreground);flex:none}.z-editor-slash-menu-footer{box-sizing:border-box;display:flex;min-width:0;flex:none;align-items:center;gap:.75rem;border-top:.0625rem solid var(--border);padding:.375rem .625rem;color:var(--popover-foreground);font-size:.75rem;font-weight:500;line-height:1;white-space:nowrap}.z-editor-slash-menu-footer span{display:inline-flex;align-items:center;gap:.25rem}.z-editor-slash-menu-footer kbd{color:var(--foreground);font:inherit}.z-editor-emoji-sheet{display:flex;width:18rem;max-width:85vw;height:20rem;max-height:70vh;flex-direction:column;overflow:hidden;background-color:var(--popover);color:var(--popover-foreground)}.z-editor-emoji-header{display:flex;flex-direction:column;gap:.5rem;padding:.75rem .75rem .625rem;flex:none}.z-editor-emoji-title{display:flex;align-items:center;gap:.375rem;padding-inline:.25rem;color:var(--foreground);font-size:.8125rem;font-weight:600;line-height:1;letter-spacing:-.005em}.z-editor-emoji-title-dot{display:inline-block;width:.375rem;height:.375rem;border-radius:999px;background-color:var(--primary);box-shadow:0 0 0 .1875rem color-mix(in srgb,var(--primary) 18%,transparent)}.z-editor-emoji-search{width:100%}.z-editor-emoji-body{flex:1 1 0;min-height:0;overflow-y:auto;overflow-x:hidden;scrollbar-width:thin;scrollbar-color:color-mix(in srgb,var(--muted-foreground) 30%,transparent) transparent}.z-editor-emoji-body::-webkit-scrollbar{width:.375rem}.z-editor-emoji-body::-webkit-scrollbar-track{background:transparent}.z-editor-emoji-body::-webkit-scrollbar-thumb{border-radius:999px;background-color:color-mix(in srgb,var(--muted-foreground) 30%,transparent)}.z-editor-emoji-body::-webkit-scrollbar-thumb:hover{background-color:color-mix(in srgb,var(--muted-foreground) 55%,transparent)}.z-editor-emoji-grid{display:grid;grid-template-columns:repeat(8,1.875rem);justify-content:center;gap:.125rem;padding:.25rem .5rem .5rem}.z-editor-emoji-empty{display:flex;height:100%;min-height:10rem;flex-direction:column;align-items:center;justify-content:center;gap:.375rem;padding:1.5rem .75rem;color:var(--muted-foreground);font-size:.8125rem;text-align:center}.z-editor-emoji-empty-icon{display:inline-flex;align-items:center;justify-content:center;width:2.25rem;height:2.25rem;border-radius:999px;background-color:color-mix(in srgb,var(--muted) 70%,transparent);color:var(--muted-foreground)}.z-editor-emoji-button{display:inline-flex;align-items:center;justify-content:center;width:1.875rem;height:1.875rem;border-radius:.4375rem;font-family:\"Noto Color Emoji\",\"Apple Color Emoji\",\"Segoe UI Emoji\",Twemoji Mozilla,EmojiOne Color,\"Android Emoji\",sans-serif;font-size:1.1875rem;line-height:1;transition:background-color .12s ease,box-shadow .12s ease}.z-editor-emoji-button:hover{background-color:color-mix(in srgb,var(--accent) 80%,transparent);box-shadow:0 0 0 .0625rem color-mix(in srgb,var(--ring) 35%,transparent)}.z-editor-emoji-button:active{background-color:color-mix(in srgb,var(--primary) 18%,transparent);box-shadow:0 0 0 .0625rem color-mix(in srgb,var(--primary) 45%,transparent)}.z-editor-emoji-footer{position:relative;display:grid;grid-template-columns:repeat(8,minmax(0,1fr));align-items:center;border-top:.0625rem solid color-mix(in srgb,var(--border) 70%,transparent);padding:.25rem;background-color:color-mix(in srgb,var(--muted) 35%,transparent);flex:none}.z-editor-emoji-footer-button{position:relative;display:inline-flex;align-items:center;justify-content:center;height:1.875rem;border-radius:.4375rem;color:var(--muted-foreground);transition:color .15s ease,background-color .15s ease}.z-editor-emoji-footer-button:after{content:\"\";position:absolute;bottom:.0625rem;left:50%;width:0;height:.125rem;border-radius:999px;background-color:var(--primary);transition:width .2s ease,transform .2s ease;transform:translate(-50%)}.z-editor-emoji-footer-button:hover{color:var(--foreground);background-color:color-mix(in srgb,var(--accent) 60%,transparent)}.z-editor-emoji-footer-button.z-editor-emoji-footer-button-active{color:var(--primary)}.z-editor-emoji-footer-button.z-editor-emoji-footer-button-active:after{width:.875rem}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "component", type: ZButtonComponent, selector: "z-button, button[z-button], a[z-button]", inputs: ["class", "zType", "zSize", "zShape", "zLabel", "zLoading", "zDisabled", "zTypeIcon", "zAnimatedTypeIcon", "zAnimateIcon", "zAnimationTriggerIcon", "zSizeIcon", "zStrokeWidthIcon", "zWave"], exportAs: ["zButton"] }, { kind: "component", type: ZIconComponent, selector: "z-icon, [z-icon]", inputs: ["class", "zType", "zAnimatedType", "zAnimate", "zAnimationTrigger", "zSize", "zStrokeWidth", "zSvg"] }, { kind: "component", type: ZInputComponent, selector: "z-input", inputs: ["class", "zType", "zSize", "zAlign", "zLabel", "zLabelClass", "zPlaceholder", "zRequired", "zDisabled", "zReadonly", "zLoading", "zLoadingOutline", "zPrefix", "zSuffix", "zMin", "zMax", "zStep", "zShowArrows", "zMask", "zDecimalPlaces", "zAllowNegative", "zThousandSeparator", "zDecimalMarker", "zValidators", "zAsyncValidators", "zAsyncDebounce", "zAsyncValidateOn", "zShowPasswordToggle", "zSearch", "zDebounce", "zAutofocus", "zAutoComplete", "zAllowClear", "zAutoSizeContent", "zRows", "zResize", "zMaxLength", "zAutoSuggest", "zColorConfig"], outputs: ["zOnSearch", "zOnChange", "zOnBlur", "zOnFocus", "zOnKeydown", "zOnEnter", "zOnColorCollapse", "zControl", "zEvent"], exportAs: ["zInput"] }, { kind: "directive", type: ZPopoverDirective, selector: "[z-popover]", inputs: ["zPopoverContent", "zPosition", "zTrigger", "zPopoverTrigger", "zClass", "zShowDelay", "zHideDelay", "zDisabled", "zOffset", "zPopoverWidth", "zTriggerRef", "zManualClose", "zOutsideClickClose", "zScrollClose", "zSticky", "zShowArrow", "zKeyboardSafe"], outputs: ["zShow", "zHide", "zHideStart", "zControl", "zPositionChange", "zOutsideClick"], exportAs: ["zPopover"] }, { kind: "directive", type: ZTooltipDirective, selector: "[z-tooltip], [zTooltip]", inputs: ["zContent", "zPosition", "zTooltipPosition", "zTrigger", "zTooltipTrigger", "zTooltipType", "zTooltipSize", "zClass", "zTooltipClass", "zShowDelay", "zTooltipShowDelay", "zHideDelay", "zTooltipHideDelay", "zArrow", "zTooltipArrow", "zDisabled", "zTooltipDisabled", "zOffset", "zTooltipOffset", "zAutoDetect", "zTriggerElement", "zAlwaysShow", "zMaxWidth"], outputs: ["zShow", "zHide"], exportAs: ["zTooltip"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1724
|
-
}
|
|
1725
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: ZEditorComponent, decorators: [{
|
|
1726
|
-
type: Component,
|
|
1727
|
-
args: [{ selector: 'z-editor', imports: [
|
|
1728
|
-
FormsModule,
|
|
1729
|
-
ReactiveFormsModule,
|
|
1730
|
-
ZButtonComponent,
|
|
1731
|
-
ZIconComponent,
|
|
1732
|
-
ZInputComponent,
|
|
1733
|
-
ZPopoverDirective,
|
|
1734
|
-
ZTooltipDirective,
|
|
1735
|
-
TranslatePipe,
|
|
1736
|
-
], standalone: true, providers: [
|
|
1737
|
-
{
|
|
1738
|
-
provide: NG_VALUE_ACCESSOR,
|
|
1739
|
-
useExisting: forwardRef(() => ZEditorComponent),
|
|
1740
|
-
multi: true,
|
|
1741
|
-
},
|
|
1742
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'zEditor', template: "<div [class]=\"wrapperClasses()\" [class.z-editor-disabled]=\"isDisabled()\" [class.z-editor-readonly]=\"zReadonly()\">\n @if (zLabel()) {\n <label [for]=\"editorId\" class=\"text-xs leading-none font-medium\" [class]=\"zLabelClass()\">\n {{ zLabel() }}\n @if (zRequired()) {\n <span class=\"text-destructive! ml-0.5\">*</span>\n }\n </label>\n }\n\n <div [class]=\"editorClasses()\">\n @if (showToolbar()) {\n <div class=\"z-editor-toolbar\" role=\"toolbar\" [attr.aria-controls]=\"editorId\">\n @for (item of toolbarItems(); track item.id) {\n @switch (item.id) {\n @case ('emoji') {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"emojiPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-emoji-popover\"\n (zControl)=\"onEmojiPopoverControl($event)\"\n (zShow)=\"onEmojiPopoverShow()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n @case ('blockStyle') {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"blockStylePopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-menu-popover\"\n (zControl)=\"onBlockStylePopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n @case ('textColor') {\n @let textColor = activeTextColor();\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"textColorPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-color-popover\"\n (zControl)=\"onTextColorPopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span class=\"z-editor-color-indicator\" [style.background]=\"textColor\"></span>\n </button>\n }\n @case ('backgroundColor') {\n @let bgColor = activeBackgroundColor();\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"backgroundColorPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-color-popover\"\n (zControl)=\"onBackgroundColorPopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span class=\"z-editor-color-indicator\" [style.background]=\"bgColor\"></span>\n </button>\n }\n @case ('align') {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"alignPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-menu-popover\"\n (zControl)=\"onAlignPopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\">\n <i z-icon [zType]=\"activeAlignIcon()\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n @default {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n [class.z-editor-toolbar-button-active]=\"item.active\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\"\n (click)=\"onToolbarClick(item.id)\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n }\n }\n </div>\n }\n\n <div\n #editorHost\n [id]=\"editorId\"\n class=\"z-editor-content\"\n role=\"textbox\"\n [attr.aria-multiline]=\"true\"\n [attr.aria-readonly]=\"isDisabled() || zReadonly()\"></div>\n </div>\n\n @if (hasError()) {\n <p class=\"text-destructive animate-in fade-in slide-in-from-top-1 m-0 text-xs duration-200\">\n {{ errorMessage() }}\n </p>\n }\n\n <ng-template #emojiPopover>\n @let emojiCategoryLabel =\n emojiSearchQuery() ? ('i18n_z_ui_emoji_search_results' | translate) : (activeEmojiCategoryLabel() | translate);\n @let activeCategoryId = activeEmojiCategoryId();\n <div class=\"z-editor-emoji-sheet\">\n <div class=\"z-editor-emoji-header\">\n <div class=\"z-editor-emoji-title mb-1\">\n <span class=\"z-editor-emoji-title-dot\" aria-hidden=\"true\"></span>\n <span>{{ emojiCategoryLabel }}</span>\n </div>\n <z-input\n class=\"z-editor-emoji-search\"\n zSize=\"sm\"\n [zSearch]=\"true\"\n [zDebounce]=\"150\"\n [zPlaceholder]=\"'i18n_z_ui_emoji_search_placeholder' | translate\"\n [ngModel]=\"emojiSearch()\"\n (zOnSearch)=\"emojiSearch.set($any($event))\" />\n </div>\n <div class=\"z-editor-emoji-body\">\n @if (hasEmojiResults()) {\n <div class=\"z-editor-emoji-grid\">\n @for (emoji of activeEmojis(); track emoji) {\n <button\n type=\"button\"\n class=\"z-editor-emoji-button\"\n [attr.aria-label]=\"emoji\"\n (click)=\"insertEmoji($any(emoji))\">\n {{ emoji }}\n </button>\n }\n </div>\n } @else {\n <div class=\"z-editor-emoji-empty\">\n <span class=\"z-editor-emoji-empty-icon\" aria-hidden=\"true\">\n <i z-icon zType=\"lucideSearchX\" zSize=\"14\" [zStrokeWidth]=\"2\"></i>\n </span>\n <span>{{ 'i18n_z_ui_emoji_no_results' | translate }}</span>\n </div>\n }\n </div>\n <div class=\"z-editor-emoji-footer\" role=\"tablist\">\n @for (category of emojiCategories; track category.id) {\n <button\n type=\"button\"\n role=\"tab\"\n class=\"z-editor-emoji-footer-button cursor-pointer!\"\n [class.z-editor-emoji-footer-button-active]=\"category.id === activeCategoryId\"\n [attr.aria-label]=\"category.labelKey | translate\"\n [attr.aria-selected]=\"category.id === activeCategoryId\"\n [attr.title]=\"category.labelKey | translate\"\n (click)=\"setEmojiCategory(category.id)\">\n <i z-icon [zType]=\"category.icon\" zSize=\"15\" [zStrokeWidth]=\"2\"></i>\n </button>\n }\n </div>\n </div>\n </ng-template>\n\n <ng-template #blockStylePopover let-close=\"close\">\n <div class=\"z-editor-menu-list\">\n @for (option of blockStyleOptions; track option.command) {\n <button\n type=\"button\"\n class=\"z-editor-menu-item\"\n [class.z-editor-menu-item-active]=\"activeBlockStyle() === option.command\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"applyBlockStyle(option.command, close)\">\n <i z-icon [zType]=\"option.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span>{{ option.label }}</span>\n </button>\n }\n </div>\n </ng-template>\n\n <ng-template #alignPopover let-close=\"close\">\n <div class=\"z-editor-menu-list\">\n @for (option of alignOptions; track option.command) {\n <button\n type=\"button\"\n class=\"z-editor-menu-item\"\n [class.z-editor-menu-item-active]=\"activeAlign() === option.command\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"applyAlign(option.command, close)\">\n <i z-icon [zType]=\"option.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span>{{ option.label }}</span>\n </button>\n }\n </div>\n </ng-template>\n\n <ng-template #textColorPopover let-close=\"close\">\n @let currentTextColor = activeTextColor();\n <div class=\"z-editor-color-grid\">\n @for (color of textColorSwatches; track color) {\n <button\n type=\"button\"\n class=\"z-editor-color-swatch\"\n [class.z-editor-color-swatch-active]=\"currentTextColor === color\"\n [style.background]=\"color\"\n [attr.aria-label]=\"'Text color ' + color\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"setTextColor(color, close)\"></button>\n }\n <label class=\"z-editor-color-custom\">\n <input type=\"color\" [value]=\"currentTextColor\" (input)=\"setTextColorFromEvent($event, close)\" />\n {{ currentTextColor }}\n </label>\n <button\n type=\"button\"\n z-button\n zType=\"outline\"\n zSize=\"sm\"\n class=\"z-editor-color-reset\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"unsetTextColor(close)\">\n Reset\n </button>\n </div>\n </ng-template>\n\n <ng-template #backgroundColorPopover let-close=\"close\">\n @let currentBgColor = activeBackgroundColor();\n <div class=\"z-editor-color-grid\">\n @for (color of backgroundColorSwatches; track color) {\n <button\n type=\"button\"\n class=\"z-editor-color-swatch\"\n [class.z-editor-color-swatch-active]=\"currentBgColor === color\"\n [style.background]=\"color\"\n [attr.aria-label]=\"'Background color ' + color\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"setBackgroundColor(color, close)\"></button>\n }\n <label class=\"z-editor-color-custom\">\n <input type=\"color\" [value]=\"currentBgColor\" (input)=\"setBackgroundColorFromEvent($event, close)\" />\n {{ currentBgColor }}\n </label>\n <button\n type=\"button\"\n z-button\n zType=\"outline\"\n zSize=\"sm\"\n class=\"z-editor-color-reset\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"unsetBackgroundColor(close)\">\n Reset\n </button>\n </div>\n </ng-template>\n\n <div #floatingToolbar class=\"z-editor-floating-toolbar\" role=\"toolbar\" [attr.aria-controls]=\"editorId\">\n @for (item of floatingToolbarItems(); track item.id) {\n @switch (item.id) {\n @case ('blockStyle') {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"blockStylePopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-menu-popover\"\n (zControl)=\"onBlockStylePopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"activeBlockStyleLabel()\"\n (mousedown)=\"$event.preventDefault()\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n @case ('textColor') {\n @let textColor = activeTextColor();\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"textColorPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-color-popover\"\n (zControl)=\"onTextColorPopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\"\n (mousedown)=\"$event.preventDefault()\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span class=\"z-editor-color-indicator\" [style.background]=\"textColor\"></span>\n </button>\n }\n @case ('backgroundColor') {\n @let bgColor = activeBackgroundColor();\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"backgroundColorPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-color-popover\"\n (zControl)=\"onBackgroundColorPopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\"\n (mousedown)=\"$event.preventDefault()\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span class=\"z-editor-color-indicator\" [style.background]=\"bgColor\"></span>\n </button>\n }\n @case ('align') {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-popover\n [zPopoverContent]=\"alignPopover\"\n zPosition=\"bottom-left\"\n zTrigger=\"click\"\n zClass=\"z-editor-menu-popover\"\n (zControl)=\"onAlignPopoverControl($event)\"\n (zHideStart)=\"onFloatingPopoverHide()\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"activeAlignLabel()\"\n (mousedown)=\"$event.preventDefault()\">\n <i z-icon [zType]=\"activeAlignIcon()\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n @default {\n <button\n type=\"button\"\n class=\"z-editor-toolbar-button\"\n z-tooltip\n [zContent]=\"item.tooltip\"\n zPosition=\"top\"\n [zAlwaysShow]=\"true\"\n [zDisabled]=\"item.disabled || !item.shortcut\"\n [class.z-editor-toolbar-button-active]=\"item.active\"\n [disabled]=\"item.disabled\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"onFloatingToolbarClick(item.id)\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n </button>\n }\n }\n }\n </div>\n\n <span\n #slashMenuTrigger\n class=\"z-editor-slash-menu-trigger\"\n z-popover\n [zPopoverContent]=\"slashMenuPopover\"\n zTrigger=\"manual\"\n zPosition=\"bottom-left\"\n zClass=\"z-editor-slash-popover\"\n [zOffset]=\"4\"\n [zPopoverWidth]=\"300\"\n [style.left.px]=\"slashMenuState().left\"\n [style.top.px]=\"slashMenuState().top\"\n (zControl)=\"onSlashMenuPopoverControl($event)\"\n (zHide)=\"onSlashMenuPopoverHide()\"></span>\n\n <ng-template #slashMenuPopover>\n @let slashActiveIndex = slashMenuActiveIndex();\n <div class=\"z-editor-slash-menu-shell\">\n <div #slashMenuScrollHost class=\"z-editor-slash-menu-scrollbar\">\n <div class=\"z-editor-slash-menu\" role=\"listbox\" [attr.aria-controls]=\"editorId\">\n @for (item of filteredSlashCommands(); track item.id) {\n @if (item.showGroupLabel) {\n <div class=\"z-editor-slash-menu-group\">\n {{ item.group }}\n </div>\n }\n <button\n type=\"button\"\n class=\"z-editor-slash-menu-item\"\n role=\"option\"\n [class.z-editor-slash-menu-item-active]=\"$index === slashActiveIndex\"\n [attr.aria-selected]=\"$index === slashActiveIndex\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"applySlashCommand(item)\">\n <i z-icon [zType]=\"item.icon\" zSize=\"16\" [zStrokeWidth]=\"2.5\"></i>\n <span class=\"z-editor-slash-menu-copy\">\n <span class=\"z-editor-slash-menu-label\">{{ item.label }}</span>\n </span>\n </button>\n } @empty {\n <div class=\"z-editor-slash-menu-empty\">\n <i z-icon zType=\"lucideSearchX\" zSize=\"28\" [zStrokeWidth]=\"1.8\"></i>\n <span>{{ 'i18n_z_ui_editor_no_commands' | translate }}</span>\n </div>\n }\n </div>\n </div>\n <div class=\"z-editor-slash-menu-footer\" aria-hidden=\"true\">\n <span>\n <kbd>\u2191\u2193</kbd>\n {{ 'i18n_z_ui_editor_shortcut_navigate' | translate }}\n </span>\n <span>\n <kbd>Esc</kbd>\n {{ 'i18n_z_ui_editor_shortcut_abort' | translate }}\n </span>\n <span>\n <kbd>\u21B5</kbd>\n {{ 'i18n_z_ui_editor_shortcut_select' | translate }}\n </span>\n </div>\n </div>\n </ng-template>\n\n <span\n #linkPopoverTrigger\n class=\"z-editor-link-popover-trigger\"\n z-popover\n [zPopoverContent]=\"linkPopover\"\n zTrigger=\"manual\"\n zPosition=\"bottom-left\"\n zClass=\"z-editor-link-popover\"\n [zOffset]=\"6\"\n [zPopoverWidth]=\"320\"\n [style.left.px]=\"linkPopoverState().left\"\n [style.top.px]=\"linkPopoverState().top\"\n [style.width.px]=\"linkPopoverState().width\"\n [style.height.px]=\"linkPopoverState().height\"\n (zControl)=\"onLinkPopoverControl($event)\"\n (zHide)=\"onLinkPopoverHide()\"></span>\n\n <ng-template #linkPopover>\n <div class=\"z-editor-link-popover-content\">\n <ng-template #linkPrefix>\n <z-icon zType=\"lucideLink\" zSize=\"16\" class=\"text-muted-foreground\" />\n </ng-template>\n <z-input\n zType=\"url\"\n zSize=\"sm\"\n class=\"z-editor-link-popover-input\"\n [zPrefix]=\"linkPrefix\"\n zPlaceholder=\"https://example.com\"\n [zValidators]=\"linkValidators\"\n [ngModel]=\"linkUrl()\"\n (ngModelChange)=\"onLinkUrlChange($event)\"\n (zOnEnter)=\"applyLink()\" />\n <div class=\"z-editor-link-popover-actions\">\n <button\n type=\"button\"\n z-button\n zType=\"ghost\"\n zSize=\"sm\"\n [zDisabled]=\"!canApplyLink()\"\n (click)=\"applyLink()\"\n aria-label=\"Apply link\">\n <z-icon zType=\"lucideCheck\" zSize=\"16\" [zStrokeWidth]=\"2.5\" />\n </button>\n <button\n type=\"button\"\n z-button\n zType=\"ghost\"\n zSize=\"sm\"\n [zDisabled]=\"!activeLinkHref()\"\n (click)=\"openActiveLink()\"\n aria-label=\"Open link\">\n <z-icon zType=\"lucideExternalLink\" zSize=\"16\" [zStrokeWidth]=\"2.5\" />\n </button>\n <button\n type=\"button\"\n z-button\n zType=\"ghost-destructive\"\n zSize=\"sm\"\n [zDisabled]=\"!activeLinkHref()\"\n (click)=\"removeLink()\"\n aria-label=\"Remove link\">\n <z-icon zType=\"lucideUnlink\" zSize=\"16\" [zStrokeWidth]=\"2.5\" />\n </button>\n </div>\n </div>\n </ng-template>\n</div>\n", styles: [".z-editor-wrapper .z-editor-toolbar{display:flex;flex-wrap:wrap;gap:.125rem;align-items:center;border-bottom:.0625rem solid var(--border);border-top-left-radius:.375rem;border-top-right-radius:.375rem;background-color:color-mix(in srgb,var(--muted) 30%,transparent);padding:.5rem}.z-editor-wrapper .z-editor-toolbar-button{position:relative;display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;border-radius:.25rem;padding:0;color:var(--muted-foreground);transition:background-color .15s ease,color .15s ease,opacity .15s ease}.z-editor-wrapper .z-editor-toolbar-button:hover:not(:disabled){background-color:var(--accent);color:var(--foreground)}.z-editor-wrapper .z-editor-toolbar-button:disabled{cursor:not-allowed;opacity:.45}.z-editor-wrapper .z-editor-toolbar-button.z-editor-toolbar-button-active{background-color:color-mix(in srgb,var(--primary) 10%,transparent);color:var(--primary)}.z-editor-wrapper .z-editor-content{position:relative;border-bottom-right-radius:.375rem;border-bottom-left-radius:.375rem}.z-editor-wrapper .z-editor-prosemirror{width:100%;outline:none;padding:.75rem;color:var(--foreground)}.z-editor-wrapper .z-editor-prosemirror>*{margin-top:1.25rem;margin-bottom:1.25rem}.z-editor-wrapper .z-editor-prosemirror>:first-child{margin-top:0}.z-editor-wrapper .z-editor-prosemirror>:last-child{margin-bottom:0}.z-editor-wrapper .z-editor-prosemirror p{line-height:1.75}.z-editor-wrapper .z-editor-prosemirror a{color:var(--primary);font-weight:500;text-decoration-line:underline;text-decoration-color:currentcolor;text-decoration-thickness:.0625rem;text-underline-offset:.1875rem;cursor:pointer;transition:text-decoration-color .15s ease}.z-editor-wrapper .z-editor-prosemirror a:hover{text-decoration-color:color-mix(in srgb,currentcolor 70%,transparent)}.z-editor-wrapper .z-editor-prosemirror .mention{color:var(--primary);font-weight:500}.z-editor-wrapper .z-editor-prosemirror :is(h1,h2,h3,h4,h5,h6){color:var(--foreground);font-weight:700;line-height:1.2}.z-editor-wrapper .z-editor-prosemirror h1{font-size:1.875rem}.z-editor-wrapper .z-editor-prosemirror h2{font-size:1.5rem}.z-editor-wrapper .z-editor-prosemirror h3{font-size:1.25rem}.z-editor-wrapper .z-editor-prosemirror h4{font-size:1.125rem}.z-editor-wrapper .z-editor-prosemirror h5,.z-editor-wrapper .z-editor-prosemirror h6{font-size:1rem}.z-editor-wrapper .z-editor-prosemirror blockquote{border-left:.25rem solid var(--border);padding-left:1rem;font-style:italic;color:var(--muted-foreground)}.z-editor-wrapper .z-editor-prosemirror [data-type=horizontalRule]{margin-top:2rem;margin-bottom:2rem;padding-top:.5rem;padding-bottom:.5rem}.z-editor-wrapper .z-editor-prosemirror hr{border:0;border-top:.0625rem solid var(--border)}.z-editor-wrapper .z-editor-prosemirror pre{overflow-x:auto;border:.0625rem solid var(--border);border-radius:.375rem;background-color:var(--muted);padding:.75rem 1rem;font-size:.875rem;line-height:1.5;white-space:pre-wrap;word-break:break-word}.z-editor-wrapper .z-editor-prosemirror pre code{display:inline;border:0;border-radius:0;background-color:transparent;padding:0;color:inherit;font:inherit}.z-editor-wrapper .z-editor-prosemirror code{display:inline-block;border:.0625rem solid var(--border);border-radius:.375rem;background-color:var(--muted);padding:.125rem .375rem;color:var(--foreground);font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:.875em;font-weight:500}.z-editor-wrapper .z-editor-prosemirror :is(ul,ol){padding-left:1.5rem}.z-editor-wrapper .z-editor-prosemirror ul{list-style:disc}.z-editor-wrapper .z-editor-prosemirror ol{list-style:decimal}.z-editor-wrapper .z-editor-prosemirror li{margin-top:.375rem;margin-bottom:.375rem;padding-left:.375rem}.z-editor-wrapper .z-editor-prosemirror img{display:block;max-width:100%;border-radius:.375rem}.z-editor-wrapper .z-editor-prosemirror img[data-text-align=center]{margin-right:auto;margin-left:auto}.z-editor-wrapper .z-editor-prosemirror img[data-text-align=right]{margin-right:0;margin-left:auto}.z-editor-wrapper .z-editor-prosemirror img[data-text-align=left],.z-editor-wrapper .z-editor-prosemirror img[data-text-align=justify]{margin-right:auto;margin-left:0}.z-editor-wrapper .z-editor-prosemirror img.ProseMirror-selectednode{outline:.125rem solid var(--primary)}.z-editor-wrapper .z-editor-prosemirror .image-resizer{display:inline-flex;position:relative;flex-grow:0}.z-editor-wrapper .z-editor-prosemirror .image-resizer .resize-trigger{position:absolute;right:-6px;bottom:-9px;width:12px;height:12px;cursor:nwse-resize;border-radius:50%;background-color:var(--primary);opacity:0;transition:opacity .2s ease}.z-editor-wrapper .z-editor-prosemirror .image-resizer:hover .resize-trigger{opacity:1}.z-editor-wrapper .z-editor-prosemirror .image-resizer .image-alignment{display:flex;gap:4px;position:absolute;top:-32px;left:0;padding:4px;border-radius:6px;background-color:var(--popover);box-shadow:0 2px 8px #00000026;opacity:0;transition:opacity .2s ease;pointer-events:none}.z-editor-wrapper .z-editor-prosemirror .image-resizer:hover .image-alignment{opacity:1;pointer-events:auto}.z-editor-wrapper .z-editor-prosemirror .ProseMirror-selectednode:not(img):not(pre):not([data-node-view-wrapper]){background-color:color-mix(in srgb,var(--primary) 20%,transparent)}.z-editor-wrapper .z-editor-prosemirror :is(p,h1,h2,h3,h4,h5,h6).is-empty:before{float:left;height:0;color:var(--muted-foreground);content:attr(data-placeholder);pointer-events:none}.z-editor-placeholder-first-line .z-editor-wrapper .z-editor-prosemirror :is(p,h1,h2,h3,h4,h5,h6).is-empty:before{content:none}.z-editor-placeholder-first-line .z-editor-wrapper .z-editor-prosemirror :is(p,h1,h2,h3,h4,h5,h6).is-editor-empty:first-child:before{content:attr(data-placeholder)}.z-editor-wrapper.z-editor-disabled .z-editor-toolbar,.z-editor-wrapper.z-editor-disabled .z-editor-content{pointer-events:none}.z-editor-wrapper.z-editor-readonly .z-editor-toolbar{display:none}.z-editor-wrapper.z-editor-readonly .z-editor-content{border-radius:.375rem}.z-editor-wrapper.z-editor-readonly .z-editor-prosemirror{cursor:default}.z-editor-link-modal{padding-top:0;padding-bottom:0}.z-editor-link-modal .z-modal-scrollbar main{min-height:0;padding:1rem}.z-editor-emoji-popover{padding:0;overflow:hidden;box-shadow:0 .5rem 1.5rem -.25rem #0000002e,0 .25rem .5rem -.125rem #0000001a}.z-editor-color-popover{padding:.5rem}.z-editor-menu-popover{padding:.25rem}.z-editor-menu-list{display:flex;min-width:9rem;flex-direction:column;gap:.125rem}.z-editor-menu-item{display:flex;width:100%;cursor:pointer;align-items:center;gap:.5rem;border-radius:.25rem;padding:.375rem .5rem;color:var(--muted-foreground);font-size:.8125rem;line-height:1.25;transition:background-color .15s ease,color .15s ease}.z-editor-menu-item:hover,.z-editor-menu-item.z-editor-menu-item-active{background-color:var(--accent);color:var(--foreground)}.z-editor-color-indicator{position:absolute;right:.25rem;bottom:.1875rem;width:.75rem;height:.1875rem;border-radius:999px;box-shadow:0 0 0 .0625rem var(--border)}.z-editor-color-grid{display:grid;grid-template-columns:repeat(5,1.625rem);gap:.25rem}.z-editor-color-swatch{width:1.625rem;height:1.625rem;border:.0625rem solid var(--border);border-radius:.25rem;cursor:pointer;transition:border-color .15s ease,box-shadow .15s ease,transform .15s ease}.z-editor-color-swatch:hover{transform:translateY(-.0625rem);border-color:var(--ring)}.z-editor-color-swatch.z-editor-color-swatch-active{border-color:var(--primary);box-shadow:0 0 0 .125rem color-mix(in srgb,var(--primary) 20%,transparent)}.z-editor-color-custom{grid-column:1/-1;display:flex;height:1.875rem;cursor:pointer;align-items:center;gap:.5rem;border:.0625rem solid var(--border);border-radius:.25rem;padding:.25rem .5rem;color:var(--muted-foreground);font-size:.75rem;transition:border-color .15s ease,background-color .15s ease,color .15s ease}.z-editor-color-custom input{width:1.375rem;height:1.375rem;flex:none;cursor:pointer;border:0;padding:0;background:transparent}.z-editor-color-custom:hover{border-color:var(--ring);background-color:var(--accent);color:var(--foreground)}.z-editor-color-reset{grid-column:1/-1;width:100%;justify-content:center}.z-editor-floating-toolbar{display:inline-flex;align-items:center;gap:.125rem;border:.0625rem solid var(--border);border-radius:.25rem;background-color:var(--popover);padding:.375rem;box-shadow:0 .625rem 1.5rem -.75rem #00000059,0 .25rem .75rem -.5rem #0003;visibility:hidden;opacity:0;position:fixed;top:-10000px;left:-10000px;scale:.98;translate:0 .25rem;transform-origin:top left;transition:opacity .12s ease,visibility .12s ease,scale .16s ease,translate .16s ease}.z-editor-floating-toolbar[style*=\"visibility: visible\"]{animation:z-editor-floating-toolbar-in .16s cubic-bezier(.16,1,.3,1);scale:1;translate:0 0}@keyframes z-editor-floating-toolbar-in{0%{opacity:0;scale:.96;translate:0 .375rem}to{opacity:1;scale:1;translate:0 0}}.z-editor-slash-menu-trigger,.z-editor-link-popover-trigger{position:fixed;z-index:-1;width:.0625rem;height:.0625rem;pointer-events:none}.z-editor-link-popover{padding:.5rem}.z-editor-link-popover-content{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;column-gap:.5rem}.z-editor-link-popover-input{flex:1;min-width:0}.z-editor-link-popover-actions{display:inline-flex;align-self:start;align-items:center;gap:.125rem}.z-editor-slash-popover{box-sizing:border-box;padding:0;overflow:hidden}.z-editor-slash-menu-shell{box-sizing:border-box;display:flex;min-width:0;height:min(16rem,100vh - 4rem);flex-direction:column}.z-editor-slash-menu-scrollbar{box-sizing:border-box;display:block;min-width:0;min-height:0;flex:1;overflow-x:hidden;overflow-y:scroll;overscroll-behavior:contain}.z-editor-slash-menu{box-sizing:border-box;display:flex;min-width:0;min-height:100%;flex-direction:column;padding:.2rem;gap:.2rem;color:var(--popover-foreground)}.z-editor-slash-menu-group{margin:.25rem 0 .125rem;border-top:.0625rem solid var(--border);padding:.5rem .5rem .1875rem;color:var(--muted-foreground);font-size:.6875rem;font-weight:600;line-height:1;text-transform:uppercase}.z-editor-slash-menu-group:first-child{margin-top:0;border-top:0;padding-top:.5rem}.z-editor-slash-menu-item{box-sizing:border-box;display:flex;align-self:stretch;min-width:0;cursor:pointer;align-items:center;gap:.5rem;border-radius:.25rem;padding:.375rem .75rem;text-align:left;transition:background-color .15s ease,color .15s ease}.z-editor-slash-menu-item i{color:var(--muted-foreground);flex:none}.z-editor-slash-menu-item:hover,.z-editor-slash-menu-item.z-editor-slash-menu-item-active{background-color:var(--accent);color:var(--foreground)}.z-editor-slash-menu-copy{display:flex;min-width:0;align-items:center}.z-editor-slash-menu-label{color:var(--foreground);font-size:.8125rem;font-weight:500;line-height:1.2}.z-editor-slash-menu-empty{box-sizing:border-box;display:flex;align-self:stretch;max-width:100%;min-width:0;flex:1;flex-direction:column;align-items:center;justify-content:center;gap:.625rem;padding:1rem;color:var(--muted-foreground);font-size:.8125rem;line-height:1.15;text-align:center}.z-editor-slash-menu-empty i{color:var(--muted-foreground);flex:none}.z-editor-slash-menu-footer{box-sizing:border-box;display:flex;min-width:0;flex:none;align-items:center;gap:.75rem;border-top:.0625rem solid var(--border);padding:.375rem .625rem;color:var(--popover-foreground);font-size:.75rem;font-weight:500;line-height:1;white-space:nowrap}.z-editor-slash-menu-footer span{display:inline-flex;align-items:center;gap:.25rem}.z-editor-slash-menu-footer kbd{color:var(--foreground);font:inherit}.z-editor-emoji-sheet{display:flex;width:18rem;max-width:85vw;height:20rem;max-height:70vh;flex-direction:column;overflow:hidden;background-color:var(--popover);color:var(--popover-foreground)}.z-editor-emoji-header{display:flex;flex-direction:column;gap:.5rem;padding:.75rem .75rem .625rem;flex:none}.z-editor-emoji-title{display:flex;align-items:center;gap:.375rem;padding-inline:.25rem;color:var(--foreground);font-size:.8125rem;font-weight:600;line-height:1;letter-spacing:-.005em}.z-editor-emoji-title-dot{display:inline-block;width:.375rem;height:.375rem;border-radius:999px;background-color:var(--primary);box-shadow:0 0 0 .1875rem color-mix(in srgb,var(--primary) 18%,transparent)}.z-editor-emoji-search{width:100%}.z-editor-emoji-body{flex:1 1 0;min-height:0;overflow-y:auto;overflow-x:hidden;scrollbar-width:thin;scrollbar-color:color-mix(in srgb,var(--muted-foreground) 30%,transparent) transparent}.z-editor-emoji-body::-webkit-scrollbar{width:.375rem}.z-editor-emoji-body::-webkit-scrollbar-track{background:transparent}.z-editor-emoji-body::-webkit-scrollbar-thumb{border-radius:999px;background-color:color-mix(in srgb,var(--muted-foreground) 30%,transparent)}.z-editor-emoji-body::-webkit-scrollbar-thumb:hover{background-color:color-mix(in srgb,var(--muted-foreground) 55%,transparent)}.z-editor-emoji-grid{display:grid;grid-template-columns:repeat(8,1.875rem);justify-content:center;gap:.125rem;padding:.25rem .5rem .5rem}.z-editor-emoji-empty{display:flex;height:100%;min-height:10rem;flex-direction:column;align-items:center;justify-content:center;gap:.375rem;padding:1.5rem .75rem;color:var(--muted-foreground);font-size:.8125rem;text-align:center}.z-editor-emoji-empty-icon{display:inline-flex;align-items:center;justify-content:center;width:2.25rem;height:2.25rem;border-radius:999px;background-color:color-mix(in srgb,var(--muted) 70%,transparent);color:var(--muted-foreground)}.z-editor-emoji-button{display:inline-flex;align-items:center;justify-content:center;width:1.875rem;height:1.875rem;border-radius:.4375rem;font-family:\"Noto Color Emoji\",\"Apple Color Emoji\",\"Segoe UI Emoji\",Twemoji Mozilla,EmojiOne Color,\"Android Emoji\",sans-serif;font-size:1.1875rem;line-height:1;transition:background-color .12s ease,box-shadow .12s ease}.z-editor-emoji-button:hover{background-color:color-mix(in srgb,var(--accent) 80%,transparent);box-shadow:0 0 0 .0625rem color-mix(in srgb,var(--ring) 35%,transparent)}.z-editor-emoji-button:active{background-color:color-mix(in srgb,var(--primary) 18%,transparent);box-shadow:0 0 0 .0625rem color-mix(in srgb,var(--primary) 45%,transparent)}.z-editor-emoji-footer{position:relative;display:grid;grid-template-columns:repeat(8,minmax(0,1fr));align-items:center;border-top:.0625rem solid color-mix(in srgb,var(--border) 70%,transparent);padding:.25rem;background-color:color-mix(in srgb,var(--muted) 35%,transparent);flex:none}.z-editor-emoji-footer-button{position:relative;display:inline-flex;align-items:center;justify-content:center;height:1.875rem;border-radius:.4375rem;color:var(--muted-foreground);transition:color .15s ease,background-color .15s ease}.z-editor-emoji-footer-button:after{content:\"\";position:absolute;bottom:.0625rem;left:50%;width:0;height:.125rem;border-radius:999px;background-color:var(--primary);transition:width .2s ease,transform .2s ease;transform:translate(-50%)}.z-editor-emoji-footer-button:hover{color:var(--foreground);background-color:color-mix(in srgb,var(--accent) 60%,transparent)}.z-editor-emoji-footer-button.z-editor-emoji-footer-button-active{color:var(--primary)}.z-editor-emoji-footer-button.z-editor-emoji-footer-button-active:after{width:.875rem}\n"] }]
|
|
1743
|
-
}], ctorParameters: () => [], propDecorators: { _editorHost: [{ type: i0.ViewChild, args: ['editorHost', { isSignal: true }] }], _floatingToolbar: [{ type: i0.ViewChild, args: ['floatingToolbar', { isSignal: true }] }], _slashMenuTrigger: [{ type: i0.ViewChild, args: ['slashMenuTrigger', { isSignal: true }] }], _linkPopoverTrigger: [{ type: i0.ViewChild, args: ['linkPopoverTrigger', { isSignal: true }] }], _slashMenuScrollHost: [{ type: i0.ViewChild, args: ['slashMenuScrollHost', { isSignal: true }] }], zOnChange: [{ type: i0.Output, args: ["zOnChange"] }], zOnFocus: [{ type: i0.Output, args: ["zOnFocus"] }], zOnBlur: [{ type: i0.Output, args: ["zOnBlur"] }], zControl: [{ type: i0.Output, args: ["zControl"] }], zEvent: [{ type: i0.Output, args: ["zEvent"] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], zSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "zSize", required: false }] }], zLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLabel", required: false }] }], zLabelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLabelClass", required: false }] }], zPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPlaceholder", required: false }] }], zRequired: [{ type: i0.Input, args: [{ isSignal: true, alias: "zRequired", required: false }] }], zDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDisabled", required: false }] }], zReadonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "zReadonly", required: false }] }], zContentType: [{ type: i0.Input, args: [{ isSignal: true, alias: "zContentType", required: false }] }], zToolbar: [{ type: i0.Input, args: [{ isSignal: true, alias: "zToolbar", required: false }] }], zTipTap: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTipTap", required: false }] }], zValidators: [{ type: i0.Input, args: [{ isSignal: true, alias: "zValidators", required: false }] }] } });
|
|
1744
|
-
|
|
1745
|
-
/**
|
|
1746
|
-
* Generated bundle index. Do not edit.
|
|
1747
|
-
*/
|
|
1748
|
-
|
|
1749
|
-
export { ZEditorComponent, Z_EDITOR_DEFAULT_TOOLBAR, zEditorVariants };
|
|
1750
|
-
//# sourceMappingURL=shival99-z-ui-components-z-editor.mjs.map
|