@neural-ui/core 1.5.14 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/neural-ui-core-accordion.mjs +13 -9
- package/fesm2022/neural-ui-core-accordion.mjs.map +1 -1
- package/fesm2022/neural-ui-core-alert.mjs +25 -14
- package/fesm2022/neural-ui-core-alert.mjs.map +1 -1
- package/fesm2022/neural-ui-core-autocomplete.mjs +53 -28
- package/fesm2022/neural-ui-core-autocomplete.mjs.map +1 -1
- package/fesm2022/neural-ui-core-avatar.mjs +23 -13
- package/fesm2022/neural-ui-core-avatar.mjs.map +1 -1
- package/fesm2022/neural-ui-core-badge.mjs +15 -9
- package/fesm2022/neural-ui-core-badge.mjs.map +1 -1
- package/fesm2022/neural-ui-core-block-ui.mjs +16 -11
- package/fesm2022/neural-ui-core-block-ui.mjs.map +1 -1
- package/fesm2022/neural-ui-core-breadcrumb.mjs +8 -6
- package/fesm2022/neural-ui-core-breadcrumb.mjs.map +1 -1
- package/fesm2022/neural-ui-core-button.mjs +29 -16
- package/fesm2022/neural-ui-core-button.mjs.map +1 -1
- package/fesm2022/neural-ui-core-calendar.mjs +75 -50
- package/fesm2022/neural-ui-core-calendar.mjs.map +1 -1
- package/fesm2022/neural-ui-core-card.mjs +13 -8
- package/fesm2022/neural-ui-core-card.mjs.map +1 -1
- package/fesm2022/neural-ui-core-chart.mjs +45 -24
- package/fesm2022/neural-ui-core-chart.mjs.map +1 -1
- package/fesm2022/neural-ui-core-checkbox.mjs +15 -9
- package/fesm2022/neural-ui-core-checkbox.mjs.map +1 -1
- package/fesm2022/neural-ui-core-chip.mjs +23 -13
- package/fesm2022/neural-ui-core-chip.mjs.map +1 -1
- package/fesm2022/neural-ui-core-code-block.mjs +32 -17
- package/fesm2022/neural-ui-core-code-block.mjs.map +1 -1
- package/fesm2022/neural-ui-core-color-picker.mjs +19 -11
- package/fesm2022/neural-ui-core-color-picker.mjs.map +1 -1
- package/fesm2022/neural-ui-core-command-palette.mjs +16 -11
- package/fesm2022/neural-ui-core-command-palette.mjs.map +1 -1
- package/fesm2022/neural-ui-core-confirm-dialog.mjs +6 -6
- package/fesm2022/neural-ui-core-context-menu.mjs +12 -9
- package/fesm2022/neural-ui-core-context-menu.mjs.map +1 -1
- package/fesm2022/neural-ui-core-dashboard-grid.mjs +11 -7
- package/fesm2022/neural-ui-core-dashboard-grid.mjs.map +1 -1
- package/fesm2022/neural-ui-core-date-input.mjs +111 -57
- package/fesm2022/neural-ui-core-date-input.mjs.map +1 -1
- package/fesm2022/neural-ui-core-divider.mjs +7 -5
- package/fesm2022/neural-ui-core-divider.mjs.map +1 -1
- package/fesm2022/neural-ui-core-empty-state.mjs +13 -8
- package/fesm2022/neural-ui-core-empty-state.mjs.map +1 -1
- package/fesm2022/neural-ui-core-filter-bar.mjs +19 -11
- package/fesm2022/neural-ui-core-filter-bar.mjs.map +1 -1
- package/fesm2022/neural-ui-core-icon.mjs +11 -7
- package/fesm2022/neural-ui-core-icon.mjs.map +1 -1
- package/fesm2022/neural-ui-core-image-gallery.mjs +23 -13
- package/fesm2022/neural-ui-core-image-gallery.mjs.map +1 -1
- package/fesm2022/neural-ui-core-image-viewer.mjs +22 -14
- package/fesm2022/neural-ui-core-image-viewer.mjs.map +1 -1
- package/fesm2022/neural-ui-core-input-otp.mjs +19 -11
- package/fesm2022/neural-ui-core-input-otp.mjs.map +1 -1
- package/fesm2022/neural-ui-core-input.mjs +67 -35
- package/fesm2022/neural-ui-core-input.mjs.map +1 -1
- package/fesm2022/neural-ui-core-kanban.mjs +17 -11
- package/fesm2022/neural-ui-core-kanban.mjs.map +1 -1
- package/fesm2022/neural-ui-core-knob.mjs +41 -22
- package/fesm2022/neural-ui-core-knob.mjs.map +1 -1
- package/fesm2022/neural-ui-core-meter-group.mjs +23 -13
- package/fesm2022/neural-ui-core-meter-group.mjs.map +1 -1
- package/fesm2022/neural-ui-core-modal.mjs +16 -11
- package/fesm2022/neural-ui-core-modal.mjs.map +1 -1
- package/fesm2022/neural-ui-core-multiselect.mjs +72 -39
- package/fesm2022/neural-ui-core-multiselect.mjs.map +1 -1
- package/fesm2022/neural-ui-core-nav.mjs +22 -13
- package/fesm2022/neural-ui-core-nav.mjs.map +1 -1
- package/fesm2022/neural-ui-core-notification-center.mjs +27 -10
- package/fesm2022/neural-ui-core-notification-center.mjs.map +1 -1
- package/fesm2022/neural-ui-core-number-input.mjs +35 -19
- package/fesm2022/neural-ui-core-number-input.mjs.map +1 -1
- package/fesm2022/neural-ui-core-pagination.mjs +15 -9
- package/fesm2022/neural-ui-core-pagination.mjs.map +1 -1
- package/fesm2022/neural-ui-core-popover.mjs +22 -14
- package/fesm2022/neural-ui-core-popover.mjs.map +1 -1
- package/fesm2022/neural-ui-core-progress-bar.mjs +19 -11
- package/fesm2022/neural-ui-core-progress-bar.mjs.map +1 -1
- package/fesm2022/neural-ui-core-radio.mjs +24 -15
- package/fesm2022/neural-ui-core-radio.mjs.map +1 -1
- package/fesm2022/neural-ui-core-rating.mjs +13 -8
- package/fesm2022/neural-ui-core-rating.mjs.map +1 -1
- package/fesm2022/neural-ui-core-rich-text-editor.mjs +773 -0
- package/fesm2022/neural-ui-core-rich-text-editor.mjs.map +1 -0
- package/fesm2022/neural-ui-core-scheduler-gantt.mjs +41 -22
- package/fesm2022/neural-ui-core-scheduler-gantt.mjs.map +1 -1
- package/fesm2022/neural-ui-core-select.mjs +77 -43
- package/fesm2022/neural-ui-core-select.mjs.map +1 -1
- package/fesm2022/neural-ui-core-sidebar.mjs +23 -14
- package/fesm2022/neural-ui-core-sidebar.mjs.map +1 -1
- package/fesm2022/neural-ui-core-skeleton.mjs +11 -7
- package/fesm2022/neural-ui-core-skeleton.mjs.map +1 -1
- package/fesm2022/neural-ui-core-slider.mjs +23 -13
- package/fesm2022/neural-ui-core-slider.mjs.map +1 -1
- package/fesm2022/neural-ui-core-spinner.mjs +17 -10
- package/fesm2022/neural-ui-core-spinner.mjs.map +1 -1
- package/fesm2022/neural-ui-core-split-button.mjs +27 -15
- package/fesm2022/neural-ui-core-split-button.mjs.map +1 -1
- package/fesm2022/neural-ui-core-splitter.mjs +9 -6
- package/fesm2022/neural-ui-core-splitter.mjs.map +1 -1
- package/fesm2022/neural-ui-core-stats-card.mjs +19 -11
- package/fesm2022/neural-ui-core-stats-card.mjs.map +1 -1
- package/fesm2022/neural-ui-core-stepper.mjs +13 -8
- package/fesm2022/neural-ui-core-stepper.mjs.map +1 -1
- package/fesm2022/neural-ui-core-switch.mjs +15 -9
- package/fesm2022/neural-ui-core-switch.mjs.map +1 -1
- package/fesm2022/neural-ui-core-table.mjs +242 -124
- package/fesm2022/neural-ui-core-table.mjs.map +1 -1
- package/fesm2022/neural-ui-core-tabs.mjs +30 -18
- package/fesm2022/neural-ui-core-tabs.mjs.map +1 -1
- package/fesm2022/neural-ui-core-textarea.mjs +43 -23
- package/fesm2022/neural-ui-core-textarea.mjs.map +1 -1
- package/fesm2022/neural-ui-core-timeline-grid.mjs +21 -12
- package/fesm2022/neural-ui-core-timeline-grid.mjs.map +1 -1
- package/fesm2022/neural-ui-core-timeline.mjs +5 -4
- package/fesm2022/neural-ui-core-timeline.mjs.map +1 -1
- package/fesm2022/neural-ui-core-toast.mjs +25 -9
- package/fesm2022/neural-ui-core-toast.mjs.map +1 -1
- package/fesm2022/neural-ui-core-toggle-button-group.mjs +17 -10
- package/fesm2022/neural-ui-core-toggle-button-group.mjs.map +1 -1
- package/fesm2022/neural-ui-core-toolbar.mjs +13 -8
- package/fesm2022/neural-ui-core-toolbar.mjs.map +1 -1
- package/fesm2022/neural-ui-core-tooltip.mjs +16 -11
- package/fesm2022/neural-ui-core-tooltip.mjs.map +1 -1
- package/fesm2022/neural-ui-core-tree-table.mjs +57 -30
- package/fesm2022/neural-ui-core-tree-table.mjs.map +1 -1
- package/fesm2022/neural-ui-core-tree.mjs +31 -17
- package/fesm2022/neural-ui-core-tree.mjs.map +1 -1
- package/fesm2022/neural-ui-core-uploader.mjs +91 -47
- package/fesm2022/neural-ui-core-uploader.mjs.map +1 -1
- package/fesm2022/neural-ui-core-url-state.mjs +7 -5
- package/fesm2022/neural-ui-core-url-state.mjs.map +1 -1
- package/fesm2022/neural-ui-core-virtual-list.mjs +32 -19
- package/fesm2022/neural-ui-core-virtual-list.mjs.map +1 -1
- package/package.json +5 -1
- package/types/neural-ui-core-notification-center.d.ts +2 -0
- package/types/neural-ui-core-rich-text-editor.d.ts +97 -0
- package/types/neural-ui-core-toast.d.ts +2 -0
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, output, signal, viewChild, computed, forwardRef, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
|
|
3
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
import { NeuButtonComponent } from '@neural-ui/core/button';
|
|
5
|
+
|
|
6
|
+
const NEU_RICH_TEXT_ALLOWED_TAGS = new Set([
|
|
7
|
+
'a',
|
|
8
|
+
'b',
|
|
9
|
+
'blockquote',
|
|
10
|
+
'br',
|
|
11
|
+
'div',
|
|
12
|
+
'em',
|
|
13
|
+
'h1',
|
|
14
|
+
'h2',
|
|
15
|
+
'h3',
|
|
16
|
+
'h4',
|
|
17
|
+
'h5',
|
|
18
|
+
'h6',
|
|
19
|
+
'i',
|
|
20
|
+
'img',
|
|
21
|
+
'li',
|
|
22
|
+
'ol',
|
|
23
|
+
'p',
|
|
24
|
+
'span',
|
|
25
|
+
'strong',
|
|
26
|
+
'table',
|
|
27
|
+
'tbody',
|
|
28
|
+
'td',
|
|
29
|
+
'th',
|
|
30
|
+
'thead',
|
|
31
|
+
'tr',
|
|
32
|
+
'u',
|
|
33
|
+
'ul',
|
|
34
|
+
]);
|
|
35
|
+
const VOID_TAGS = new Set(['br', 'img']);
|
|
36
|
+
const BLOCKED_TAGS = 'script|style|iframe|object|embed|form|input|button|textarea|select|option|meta|link|svg|math';
|
|
37
|
+
function normalizeRichTextHtml(value) {
|
|
38
|
+
const clean = value.trim();
|
|
39
|
+
if (!clean) {
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
return hasHtmlTags(clean) ? sanitizeRichTextHtml(clean) : plainTextToRichTextHtml(clean);
|
|
43
|
+
}
|
|
44
|
+
function plainTextToRichTextHtml(value) {
|
|
45
|
+
return value
|
|
46
|
+
.trim()
|
|
47
|
+
.split(/\n{2,}/)
|
|
48
|
+
.map((paragraph) => `<p>${escapeRichTextHtml(paragraph).replace(/\n/g, '<br>')}</p>`)
|
|
49
|
+
.join('');
|
|
50
|
+
}
|
|
51
|
+
function sanitizeRichTextHtml(value) {
|
|
52
|
+
const blockedTagPattern = new RegExp(`<\\s*(?:${BLOCKED_TAGS})[\\s\\S]*?>[\\s\\S]*?<\\s*\\/\\s*(?:${BLOCKED_TAGS})\\s*>`, 'gi');
|
|
53
|
+
const blockedSingleTagPattern = new RegExp(`<\\s*\\/?\\s*(?:${BLOCKED_TAGS})[^>]*>`, 'gi');
|
|
54
|
+
const withoutDangerousContent = value
|
|
55
|
+
.replace(/<!--[\s\S]*?-->/g, '')
|
|
56
|
+
.replace(blockedTagPattern, '')
|
|
57
|
+
.replace(blockedSingleTagPattern, '')
|
|
58
|
+
.replace(/\s+on[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, '')
|
|
59
|
+
.replace(/\s+style\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, '');
|
|
60
|
+
return withoutDangerousContent
|
|
61
|
+
.replace(/<\/?([a-z][a-z0-9]*)([^>]*)>/gi, (match, tagName, rawAttributes) => {
|
|
62
|
+
const tag = tagName.toLowerCase();
|
|
63
|
+
const isClosing = /^<\s*\//.test(match);
|
|
64
|
+
if (!NEU_RICH_TEXT_ALLOWED_TAGS.has(tag)) {
|
|
65
|
+
return '';
|
|
66
|
+
}
|
|
67
|
+
if (isClosing) {
|
|
68
|
+
return VOID_TAGS.has(tag) ? '' : `</${tag}>`;
|
|
69
|
+
}
|
|
70
|
+
return `<${tag}${sanitizeAttributes(tag, rawAttributes || '')}>`;
|
|
71
|
+
})
|
|
72
|
+
.trim();
|
|
73
|
+
}
|
|
74
|
+
function escapeRichTextHtml(value) {
|
|
75
|
+
return value
|
|
76
|
+
.replaceAll('&', '&')
|
|
77
|
+
.replaceAll('<', '<')
|
|
78
|
+
.replaceAll('>', '>')
|
|
79
|
+
.replaceAll('"', '"')
|
|
80
|
+
.replaceAll("'", ''');
|
|
81
|
+
}
|
|
82
|
+
function escapeRichTextAttribute(value) {
|
|
83
|
+
return escapeRichTextHtml(value).replaceAll('`', '`');
|
|
84
|
+
}
|
|
85
|
+
function sanitizeAttributes(tag, rawAttributes) {
|
|
86
|
+
const attributes = new Map();
|
|
87
|
+
rawAttributes.replace(/([a-zA-Z:-]+)(?:\s*=\s*("([^"]*)"|'([^']*)'|([^\s"'>`]+)))?/g, (_match, rawName, _rawValue, doubleQuoted, singleQuoted, bareValue) => {
|
|
88
|
+
const name = rawName.toLowerCase();
|
|
89
|
+
const value = doubleQuoted ?? singleQuoted ?? bareValue ?? '';
|
|
90
|
+
if (name.startsWith('on') || name === 'style' || !isAllowedAttribute(tag, name)) {
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
if (tag === 'a' && name === 'href') {
|
|
94
|
+
if (isSafeHref(value)) {
|
|
95
|
+
attributes.set('href', value.trim());
|
|
96
|
+
attributes.set('target', '_blank');
|
|
97
|
+
attributes.set('rel', 'noopener noreferrer');
|
|
98
|
+
}
|
|
99
|
+
return '';
|
|
100
|
+
}
|
|
101
|
+
if (tag === 'img' && name === 'src') {
|
|
102
|
+
if (isSafeImageSource(value)) {
|
|
103
|
+
attributes.set('src', value.trim());
|
|
104
|
+
}
|
|
105
|
+
return '';
|
|
106
|
+
}
|
|
107
|
+
if ((name === 'width' || name === 'height') && !/^\d{1,4}$/.test(value.trim())) {
|
|
108
|
+
return '';
|
|
109
|
+
}
|
|
110
|
+
if (name === 'target' || name === 'rel') {
|
|
111
|
+
return '';
|
|
112
|
+
}
|
|
113
|
+
attributes.set(name, value.trim());
|
|
114
|
+
return '';
|
|
115
|
+
});
|
|
116
|
+
return Array.from(attributes.entries())
|
|
117
|
+
.filter(([, value]) => value.length > 0)
|
|
118
|
+
.map(([name, value]) => ` ${name}="${escapeRichTextAttribute(value)}"`)
|
|
119
|
+
.join('');
|
|
120
|
+
}
|
|
121
|
+
function isAllowedAttribute(tag, name) {
|
|
122
|
+
if (name === 'title') {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
if (tag === 'a') {
|
|
126
|
+
return ['href', 'target', 'rel'].includes(name);
|
|
127
|
+
}
|
|
128
|
+
if (tag === 'img') {
|
|
129
|
+
return ['src', 'alt', 'width', 'height'].includes(name);
|
|
130
|
+
}
|
|
131
|
+
if (['td', 'th'].includes(tag)) {
|
|
132
|
+
return ['colspan', 'rowspan'].includes(name);
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
function hasHtmlTags(value) {
|
|
137
|
+
return /<\/?[a-z][\s\S]*>/i.test(value);
|
|
138
|
+
}
|
|
139
|
+
function isSafeHref(value) {
|
|
140
|
+
const clean = value.trim();
|
|
141
|
+
return /^{{[a-zA-Z0-9_. -]+}}$/.test(clean) || /^(https?:|mailto:|tel:)/i.test(clean);
|
|
142
|
+
}
|
|
143
|
+
function isSafeImageSource(value) {
|
|
144
|
+
const clean = value.trim();
|
|
145
|
+
if (/^https?:\/\//i.test(clean)) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
return (/^data:image\/(?:png|jpe?g|gif|webp);base64,[a-z0-9+/=\s]+$/i.test(clean) &&
|
|
149
|
+
clean.length <= 1_500_000);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const DEFAULT_RICH_TEXT_EDITOR_LABELS = {
|
|
153
|
+
toolbar: 'Rich text editor',
|
|
154
|
+
formatGroup: 'Text formatting',
|
|
155
|
+
listsGroup: 'Lists',
|
|
156
|
+
insertGroup: 'Insert',
|
|
157
|
+
clearGroup: 'Clear',
|
|
158
|
+
bold: 'Bold',
|
|
159
|
+
italic: 'Italic',
|
|
160
|
+
underline: 'Underline',
|
|
161
|
+
unorderedList: 'Bullet list',
|
|
162
|
+
orderedList: 'Numbered list',
|
|
163
|
+
addLink: 'Add link',
|
|
164
|
+
addImageUrl: 'Add image by URL',
|
|
165
|
+
clearFormat: 'Clear formatting',
|
|
166
|
+
linkUrlPrompt: 'Link URL',
|
|
167
|
+
linkTextPrompt: 'Link text',
|
|
168
|
+
imageUrlPrompt: 'Image URL',
|
|
169
|
+
imageAltPrompt: 'Alternative text',
|
|
170
|
+
imageAltFallback: 'Image',
|
|
171
|
+
pastedImageAlt: 'Pasted image',
|
|
172
|
+
};
|
|
173
|
+
let _neuRichTextEditorIdSeq = 0;
|
|
174
|
+
class NeuRichTextEditorComponent {
|
|
175
|
+
label = input('', /* @ts-ignore */
|
|
176
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
177
|
+
placeholder = input('Write here...', /* @ts-ignore */
|
|
178
|
+
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
179
|
+
hint = input('', /* @ts-ignore */
|
|
180
|
+
...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
181
|
+
errorMessage = input('', /* @ts-ignore */
|
|
182
|
+
...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
|
|
183
|
+
size = input('md', /* @ts-ignore */
|
|
184
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
185
|
+
minHeight = input('180px', /* @ts-ignore */
|
|
186
|
+
...(ngDevMode ? [{ debugName: "minHeight" }] : /* istanbul ignore next */ []));
|
|
187
|
+
disabled = input(false, /* @ts-ignore */
|
|
188
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
189
|
+
readonly = input(false, /* @ts-ignore */
|
|
190
|
+
...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
|
|
191
|
+
/**
|
|
192
|
+
* @deprecated Use `labels.toolbar` instead.
|
|
193
|
+
*/
|
|
194
|
+
toolbarAriaLabel = input('', /* @ts-ignore */
|
|
195
|
+
...(ngDevMode ? [{ debugName: "toolbarAriaLabel" }] : /* istanbul ignore next */ []));
|
|
196
|
+
labels = input({}, /* @ts-ignore */
|
|
197
|
+
...(ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []));
|
|
198
|
+
variables = input([], /* @ts-ignore */
|
|
199
|
+
...(ngDevMode ? [{ debugName: "variables" }] : /* istanbul ignore next */ []));
|
|
200
|
+
variablesLabel = input('Variables', /* @ts-ignore */
|
|
201
|
+
...(ngDevMode ? [{ debugName: "variablesLabel" }] : /* istanbul ignore next */ []));
|
|
202
|
+
variablesAriaLabel = input('Available variables', /* @ts-ignore */
|
|
203
|
+
...(ngDevMode ? [{ debugName: "variablesAriaLabel" }] : /* istanbul ignore next */ []));
|
|
204
|
+
maxPastedImageBytes = input(1_500_000, /* @ts-ignore */
|
|
205
|
+
...(ngDevMode ? [{ debugName: "maxPastedImageBytes" }] : /* istanbul ignore next */ []));
|
|
206
|
+
showPreview = input(false, /* @ts-ignore */
|
|
207
|
+
...(ngDevMode ? [{ debugName: "showPreview" }] : /* istanbul ignore next */ []));
|
|
208
|
+
previewLabel = input('Preview', /* @ts-ignore */
|
|
209
|
+
...(ngDevMode ? [{ debugName: "previewLabel" }] : /* istanbul ignore next */ []));
|
|
210
|
+
editorId = input(`neu-rich-text-editor-${++_neuRichTextEditorIdSeq}`, /* @ts-ignore */
|
|
211
|
+
...(ngDevMode ? [{ debugName: "editorId" }] : /* istanbul ignore next */ []));
|
|
212
|
+
valueChange = output();
|
|
213
|
+
imageRejected = output();
|
|
214
|
+
value = signal('', /* @ts-ignore */
|
|
215
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
216
|
+
focused = signal(false, /* @ts-ignore */
|
|
217
|
+
...(ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []));
|
|
218
|
+
cvaDisabled = signal(false, /* @ts-ignore */
|
|
219
|
+
...(ngDevMode ? [{ debugName: "cvaDisabled" }] : /* istanbul ignore next */ []));
|
|
220
|
+
editorRef = viewChild('editorRef', /* @ts-ignore */
|
|
221
|
+
...(ngDevMode ? [{ debugName: "editorRef" }] : /* istanbul ignore next */ []));
|
|
222
|
+
viewReady = false;
|
|
223
|
+
onChange = () => undefined;
|
|
224
|
+
onTouched = () => undefined;
|
|
225
|
+
isDisabledFinal = computed(() => this.disabled() || this.readonly() || this.cvaDisabled(), /* @ts-ignore */
|
|
226
|
+
...(ngDevMode ? [{ debugName: "isDisabledFinal" }] : /* istanbul ignore next */ []));
|
|
227
|
+
mergedLabels = computed(() => ({
|
|
228
|
+
...DEFAULT_RICH_TEXT_EDITOR_LABELS,
|
|
229
|
+
...(this.toolbarAriaLabel() ? { toolbar: this.toolbarAriaLabel() } : {}),
|
|
230
|
+
...this.labels(),
|
|
231
|
+
}), /* @ts-ignore */
|
|
232
|
+
...(ngDevMode ? [{ debugName: "mergedLabels" }] : /* istanbul ignore next */ []));
|
|
233
|
+
hasError = computed(() => !!this.errorMessage(), /* @ts-ignore */
|
|
234
|
+
...(ngDevMode ? [{ debugName: "hasError" }] : /* istanbul ignore next */ []));
|
|
235
|
+
ariaDescribedBy = computed(() => {
|
|
236
|
+
if (this.hasError()) {
|
|
237
|
+
return `${this.editorId()}-error`;
|
|
238
|
+
}
|
|
239
|
+
return this.hint() ? `${this.editorId()}-hint` : null;
|
|
240
|
+
}, /* @ts-ignore */
|
|
241
|
+
...(ngDevMode ? [{ debugName: "ariaDescribedBy" }] : /* istanbul ignore next */ []));
|
|
242
|
+
ngAfterViewInit() {
|
|
243
|
+
this.viewReady = true;
|
|
244
|
+
this.renderValue(this.value());
|
|
245
|
+
}
|
|
246
|
+
writeValue(value) {
|
|
247
|
+
const html = normalizeRichTextHtml(value ?? '');
|
|
248
|
+
this.value.set(html);
|
|
249
|
+
this.renderValue(html);
|
|
250
|
+
}
|
|
251
|
+
registerOnChange(fn) {
|
|
252
|
+
this.onChange = fn;
|
|
253
|
+
}
|
|
254
|
+
registerOnTouched(fn) {
|
|
255
|
+
this.onTouched = fn;
|
|
256
|
+
}
|
|
257
|
+
setDisabledState(isDisabled) {
|
|
258
|
+
this.cvaDisabled.set(isDisabled);
|
|
259
|
+
}
|
|
260
|
+
format(command) {
|
|
261
|
+
if (this.isDisabledFinal())
|
|
262
|
+
return;
|
|
263
|
+
this.focus();
|
|
264
|
+
document.execCommand(command);
|
|
265
|
+
this.syncValueFromEditor();
|
|
266
|
+
}
|
|
267
|
+
addLink() {
|
|
268
|
+
if (this.isDisabledFinal())
|
|
269
|
+
return;
|
|
270
|
+
const url = window.prompt(this.mergedLabels().linkUrlPrompt);
|
|
271
|
+
if (!url)
|
|
272
|
+
return;
|
|
273
|
+
const text = window.prompt(this.mergedLabels().linkTextPrompt) || url;
|
|
274
|
+
this.insertHtml(`<a href="${escapeRichTextAttribute(url)}">${escapeRichTextHtml(text)}</a>`);
|
|
275
|
+
}
|
|
276
|
+
addImageUrl() {
|
|
277
|
+
if (this.isDisabledFinal())
|
|
278
|
+
return;
|
|
279
|
+
const url = window.prompt(this.mergedLabels().imageUrlPrompt);
|
|
280
|
+
if (!url)
|
|
281
|
+
return;
|
|
282
|
+
const alt = window.prompt(this.mergedLabels().imageAltPrompt) || this.mergedLabels().imageAltFallback;
|
|
283
|
+
this.insertHtml(`<img src="${escapeRichTextAttribute(url)}" alt="${escapeRichTextAttribute(alt)}">`);
|
|
284
|
+
}
|
|
285
|
+
insertVariable(variable) {
|
|
286
|
+
if (this.isDisabledFinal())
|
|
287
|
+
return;
|
|
288
|
+
this.insertHtml(escapeRichTextHtml(variable));
|
|
289
|
+
}
|
|
290
|
+
handleInput() {
|
|
291
|
+
this.syncValueFromEditor();
|
|
292
|
+
}
|
|
293
|
+
onFocus() {
|
|
294
|
+
this.focused.set(true);
|
|
295
|
+
}
|
|
296
|
+
onBlur() {
|
|
297
|
+
this.focused.set(false);
|
|
298
|
+
this.onTouched();
|
|
299
|
+
}
|
|
300
|
+
handlePaste(event) {
|
|
301
|
+
if (this.isDisabledFinal())
|
|
302
|
+
return;
|
|
303
|
+
const imageFile = Array.from(event.clipboardData?.files ?? []).find((file) => file.type.startsWith('image/'));
|
|
304
|
+
if (imageFile) {
|
|
305
|
+
event.preventDefault();
|
|
306
|
+
this.insertPastedImage(imageFile);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
const html = event.clipboardData?.getData('text/html');
|
|
310
|
+
if (html) {
|
|
311
|
+
event.preventDefault();
|
|
312
|
+
this.insertHtml(sanitizeRichTextHtml(html));
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const text = event.clipboardData?.getData('text/plain');
|
|
316
|
+
if (text) {
|
|
317
|
+
event.preventDefault();
|
|
318
|
+
this.insertHtml(plainTextToRichTextHtml(text));
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
insertPastedImage(file) {
|
|
322
|
+
const maxBytes = this.maxPastedImageBytes();
|
|
323
|
+
if (file.size > maxBytes) {
|
|
324
|
+
this.imageRejected.emit({ file, maxBytes, reason: 'size' });
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const reader = new FileReader();
|
|
328
|
+
reader.onload = () => {
|
|
329
|
+
const src = typeof reader.result === 'string' ? reader.result : '';
|
|
330
|
+
this.insertHtml(sanitizeRichTextHtml(`<img src="${escapeRichTextAttribute(src)}" alt="${escapeRichTextAttribute(this.mergedLabels().pastedImageAlt)}">`));
|
|
331
|
+
};
|
|
332
|
+
reader.readAsDataURL(file);
|
|
333
|
+
}
|
|
334
|
+
insertHtml(html) {
|
|
335
|
+
this.focus();
|
|
336
|
+
document.execCommand('insertHTML', false, sanitizeRichTextHtml(html));
|
|
337
|
+
this.syncValueFromEditor();
|
|
338
|
+
}
|
|
339
|
+
syncValueFromEditor() {
|
|
340
|
+
const html = sanitizeRichTextHtml(this.editorRef()?.nativeElement.innerHTML ?? '');
|
|
341
|
+
this.value.set(html);
|
|
342
|
+
this.onChange(html);
|
|
343
|
+
this.valueChange.emit(html);
|
|
344
|
+
}
|
|
345
|
+
focus() {
|
|
346
|
+
this.editorRef()?.nativeElement.focus();
|
|
347
|
+
}
|
|
348
|
+
renderValue(html) {
|
|
349
|
+
const editor = this.editorRef()?.nativeElement;
|
|
350
|
+
if (!this.viewReady || !editor)
|
|
351
|
+
return;
|
|
352
|
+
if (editor.innerHTML !== html) {
|
|
353
|
+
editor.innerHTML = html;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: NeuRichTextEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
357
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.4", type: NeuRichTextEditorComponent, isStandalone: true, selector: "neu-rich-text-editor", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, toolbarAriaLabel: { classPropertyName: "toolbarAriaLabel", publicName: "toolbarAriaLabel", isSignal: true, isRequired: false, transformFunction: null }, labels: { classPropertyName: "labels", publicName: "labels", isSignal: true, isRequired: false, transformFunction: null }, variables: { classPropertyName: "variables", publicName: "variables", isSignal: true, isRequired: false, transformFunction: null }, variablesLabel: { classPropertyName: "variablesLabel", publicName: "variablesLabel", isSignal: true, isRequired: false, transformFunction: null }, variablesAriaLabel: { classPropertyName: "variablesAriaLabel", publicName: "variablesAriaLabel", isSignal: true, isRequired: false, transformFunction: null }, maxPastedImageBytes: { classPropertyName: "maxPastedImageBytes", publicName: "maxPastedImageBytes", isSignal: true, isRequired: false, transformFunction: null }, showPreview: { classPropertyName: "showPreview", publicName: "showPreview", isSignal: true, isRequired: false, transformFunction: null }, previewLabel: { classPropertyName: "previewLabel", publicName: "previewLabel", isSignal: true, isRequired: false, transformFunction: null }, editorId: { classPropertyName: "editorId", publicName: "editorId", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", imageRejected: "imageRejected" }, host: { properties: { "class.neu-rich-text-editor-host--sm": "size() === \"sm\"", "class.neu-rich-text-editor-host--lg": "size() === \"lg\"" }, classAttribute: "neu-rich-text-editor-host" }, providers: [
|
|
358
|
+
{
|
|
359
|
+
provide: NG_VALUE_ACCESSOR,
|
|
360
|
+
useExisting: forwardRef(() => NeuRichTextEditorComponent),
|
|
361
|
+
multi: true,
|
|
362
|
+
},
|
|
363
|
+
], viewQueries: [{ propertyName: "editorRef", first: true, predicate: ["editorRef"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
364
|
+
<div class="neu-rich-text-editor" [class.neu-rich-text-editor--disabled]="isDisabledFinal()">
|
|
365
|
+
@if (label()) {
|
|
366
|
+
<label class="neu-rich-text-editor__label" [id]="editorId() + '-label'" [for]="editorId()">
|
|
367
|
+
{{ label() }}
|
|
368
|
+
</label>
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
<div
|
|
372
|
+
class="neu-rich-text-editor__frame"
|
|
373
|
+
[class.neu-rich-text-editor__frame--focused]="focused()"
|
|
374
|
+
[class.neu-rich-text-editor__frame--error]="hasError()"
|
|
375
|
+
>
|
|
376
|
+
<div
|
|
377
|
+
class="neu-rich-text-editor__toolbar"
|
|
378
|
+
role="toolbar"
|
|
379
|
+
[attr.aria-label]="mergedLabels().toolbar"
|
|
380
|
+
>
|
|
381
|
+
<div
|
|
382
|
+
class="neu-rich-text-editor__toolbar-group"
|
|
383
|
+
role="group"
|
|
384
|
+
[attr.aria-label]="mergedLabels().formatGroup"
|
|
385
|
+
>
|
|
386
|
+
<button
|
|
387
|
+
neu-button
|
|
388
|
+
type="button"
|
|
389
|
+
variant="ghost"
|
|
390
|
+
size="sm"
|
|
391
|
+
icon="lucideBold"
|
|
392
|
+
[iconOnly]="true"
|
|
393
|
+
[ariaLabel]="mergedLabels().bold"
|
|
394
|
+
[title]="mergedLabels().bold"
|
|
395
|
+
[disabled]="isDisabledFinal()"
|
|
396
|
+
(click)="format('bold')"
|
|
397
|
+
></button>
|
|
398
|
+
<button
|
|
399
|
+
neu-button
|
|
400
|
+
type="button"
|
|
401
|
+
variant="ghost"
|
|
402
|
+
size="sm"
|
|
403
|
+
icon="lucideItalic"
|
|
404
|
+
[iconOnly]="true"
|
|
405
|
+
[ariaLabel]="mergedLabels().italic"
|
|
406
|
+
[title]="mergedLabels().italic"
|
|
407
|
+
[disabled]="isDisabledFinal()"
|
|
408
|
+
(click)="format('italic')"
|
|
409
|
+
></button>
|
|
410
|
+
<button
|
|
411
|
+
neu-button
|
|
412
|
+
type="button"
|
|
413
|
+
variant="ghost"
|
|
414
|
+
size="sm"
|
|
415
|
+
icon="lucideUnderline"
|
|
416
|
+
[iconOnly]="true"
|
|
417
|
+
[ariaLabel]="mergedLabels().underline"
|
|
418
|
+
[title]="mergedLabels().underline"
|
|
419
|
+
[disabled]="isDisabledFinal()"
|
|
420
|
+
(click)="format('underline')"
|
|
421
|
+
></button>
|
|
422
|
+
</div>
|
|
423
|
+
|
|
424
|
+
<div
|
|
425
|
+
class="neu-rich-text-editor__toolbar-group"
|
|
426
|
+
role="group"
|
|
427
|
+
[attr.aria-label]="mergedLabels().listsGroup"
|
|
428
|
+
>
|
|
429
|
+
<button
|
|
430
|
+
neu-button
|
|
431
|
+
type="button"
|
|
432
|
+
variant="ghost"
|
|
433
|
+
size="sm"
|
|
434
|
+
icon="lucideList"
|
|
435
|
+
[iconOnly]="true"
|
|
436
|
+
[ariaLabel]="mergedLabels().unorderedList"
|
|
437
|
+
[title]="mergedLabels().unorderedList"
|
|
438
|
+
[disabled]="isDisabledFinal()"
|
|
439
|
+
(click)="format('insertUnorderedList')"
|
|
440
|
+
></button>
|
|
441
|
+
<button
|
|
442
|
+
neu-button
|
|
443
|
+
type="button"
|
|
444
|
+
variant="ghost"
|
|
445
|
+
size="sm"
|
|
446
|
+
icon="lucideListOrdered"
|
|
447
|
+
[iconOnly]="true"
|
|
448
|
+
[ariaLabel]="mergedLabels().orderedList"
|
|
449
|
+
[title]="mergedLabels().orderedList"
|
|
450
|
+
[disabled]="isDisabledFinal()"
|
|
451
|
+
(click)="format('insertOrderedList')"
|
|
452
|
+
></button>
|
|
453
|
+
</div>
|
|
454
|
+
|
|
455
|
+
<div
|
|
456
|
+
class="neu-rich-text-editor__toolbar-group"
|
|
457
|
+
role="group"
|
|
458
|
+
[attr.aria-label]="mergedLabels().insertGroup"
|
|
459
|
+
>
|
|
460
|
+
<button
|
|
461
|
+
neu-button
|
|
462
|
+
type="button"
|
|
463
|
+
variant="ghost"
|
|
464
|
+
size="sm"
|
|
465
|
+
icon="lucideLink"
|
|
466
|
+
[iconOnly]="true"
|
|
467
|
+
[ariaLabel]="mergedLabels().addLink"
|
|
468
|
+
[title]="mergedLabels().addLink"
|
|
469
|
+
[disabled]="isDisabledFinal()"
|
|
470
|
+
(click)="addLink()"
|
|
471
|
+
></button>
|
|
472
|
+
<button
|
|
473
|
+
neu-button
|
|
474
|
+
type="button"
|
|
475
|
+
variant="ghost"
|
|
476
|
+
size="sm"
|
|
477
|
+
icon="lucideImage"
|
|
478
|
+
[iconOnly]="true"
|
|
479
|
+
[ariaLabel]="mergedLabels().addImageUrl"
|
|
480
|
+
[title]="mergedLabels().addImageUrl"
|
|
481
|
+
[disabled]="isDisabledFinal()"
|
|
482
|
+
(click)="addImageUrl()"
|
|
483
|
+
></button>
|
|
484
|
+
</div>
|
|
485
|
+
|
|
486
|
+
<div
|
|
487
|
+
class="neu-rich-text-editor__toolbar-group"
|
|
488
|
+
role="group"
|
|
489
|
+
[attr.aria-label]="mergedLabels().clearGroup"
|
|
490
|
+
>
|
|
491
|
+
<button
|
|
492
|
+
neu-button
|
|
493
|
+
type="button"
|
|
494
|
+
variant="ghost"
|
|
495
|
+
size="sm"
|
|
496
|
+
icon="lucideEraser"
|
|
497
|
+
[iconOnly]="true"
|
|
498
|
+
[ariaLabel]="mergedLabels().clearFormat"
|
|
499
|
+
[title]="mergedLabels().clearFormat"
|
|
500
|
+
[disabled]="isDisabledFinal()"
|
|
501
|
+
(click)="format('removeFormat')"
|
|
502
|
+
></button>
|
|
503
|
+
</div>
|
|
504
|
+
</div>
|
|
505
|
+
|
|
506
|
+
@if (variables().length) {
|
|
507
|
+
<div class="neu-rich-text-editor__variables" [attr.aria-label]="variablesAriaLabel()">
|
|
508
|
+
<span class="neu-rich-text-editor__variables-label">{{ variablesLabel() }}</span>
|
|
509
|
+
@for (variable of variables(); track variable) {
|
|
510
|
+
<button
|
|
511
|
+
class="neu-rich-text-editor__variable"
|
|
512
|
+
type="button"
|
|
513
|
+
[disabled]="isDisabledFinal()"
|
|
514
|
+
(click)="insertVariable(variable)"
|
|
515
|
+
>
|
|
516
|
+
{{ variable }}
|
|
517
|
+
</button>
|
|
518
|
+
}
|
|
519
|
+
</div>
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
<div
|
|
523
|
+
#editorRef
|
|
524
|
+
class="neu-rich-text-editor__surface"
|
|
525
|
+
role="textbox"
|
|
526
|
+
aria-multiline="true"
|
|
527
|
+
[id]="editorId()"
|
|
528
|
+
[attr.aria-label]="label() ? null : mergedLabels().toolbar"
|
|
529
|
+
[attr.aria-labelledby]="label() ? editorId() + '-label' : null"
|
|
530
|
+
[attr.contenteditable]="isDisabledFinal() ? 'false' : 'true'"
|
|
531
|
+
[attr.data-placeholder]="placeholder()"
|
|
532
|
+
[attr.aria-describedby]="ariaDescribedBy()"
|
|
533
|
+
[attr.aria-invalid]="hasError() ? 'true' : null"
|
|
534
|
+
[style.min-height]="minHeight()"
|
|
535
|
+
(input)="handleInput()"
|
|
536
|
+
(focus)="onFocus()"
|
|
537
|
+
(blur)="onBlur()"
|
|
538
|
+
(paste)="handlePaste($event)"
|
|
539
|
+
></div>
|
|
540
|
+
</div>
|
|
541
|
+
|
|
542
|
+
@if (hasError()) {
|
|
543
|
+
<p class="neu-rich-text-editor__error" [id]="editorId() + '-error'" role="alert">
|
|
544
|
+
{{ errorMessage() }}
|
|
545
|
+
</p>
|
|
546
|
+
} @else if (hint()) {
|
|
547
|
+
<p class="neu-rich-text-editor__hint" [id]="editorId() + '-hint'">{{ hint() }}</p>
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
@if (showPreview() && value()) {
|
|
551
|
+
<details class="neu-rich-text-editor__preview">
|
|
552
|
+
<summary>{{ previewLabel() }}</summary>
|
|
553
|
+
<div class="neu-rich-text-editor__preview-content" [innerHTML]="value()"></div>
|
|
554
|
+
</details>
|
|
555
|
+
}
|
|
556
|
+
</div>
|
|
557
|
+
`, isInline: true, styles: [".neu-rich-text-editor-host{display:block;font-family:var(--neu-font-sans)}.neu-rich-text-editor{display:grid;gap:var(--neu-space-2, .5rem);color:var(--neu-text)}.neu-rich-text-editor__label{color:var(--neu-text);font-size:var(--neu-text-sm);font-weight:700;line-height:1.2}.neu-rich-text-editor__frame{overflow:hidden;background:var(--neu-surface);border:1px solid var(--neu-border);border-radius:var(--neu-radius-lg, .75rem);box-shadow:var(--neu-shadow-sm, 0 1px 2px rgba(15, 23, 42, .08));transition:border-color var(--neu-transition),box-shadow var(--neu-transition),background-color var(--neu-transition)}.neu-rich-text-editor__frame--focused{border-color:var(--neu-border-focus, var(--neu-primary));box-shadow:var(--neu-focus-ring, 0 0 0 3px rgba(0, 176, 160, .18))}.neu-rich-text-editor__frame--error{border-color:var(--neu-error)}.neu-rich-text-editor__toolbar{display:flex;flex-wrap:wrap;gap:var(--neu-space-2, .5rem);align-items:center;min-height:46px;padding:var(--neu-space-2, .5rem);background:var(--neu-surface-2, #f8fafc);border-bottom:1px solid var(--neu-border)}.neu-rich-text-editor__toolbar-group{display:inline-flex;align-items:center;gap:2px;padding:2px;background:var(--neu-surface);border:1px solid var(--neu-border);border-radius:var(--neu-radius, .5rem)}.neu-rich-text-editor__toolbar .neu-button--ghost{color:var(--neu-text-muted)}.neu-rich-text-editor__toolbar .neu-button--ghost:hover:not(:disabled):not(.neu-button--disabled){color:var(--neu-text);background:var(--neu-primary-50, rgba(0, 176, 160, .1))}.neu-rich-text-editor__variables{display:flex;flex-wrap:wrap;gap:var(--neu-space-2, .5rem);align-items:center;padding:var(--neu-space-2, .5rem) var(--neu-space-3, .75rem);background:var(--neu-surface);border-bottom:1px solid var(--neu-border)}.neu-rich-text-editor__variables-label{color:var(--neu-text-muted);font-size:var(--neu-text-xs, .75rem);font-weight:700}.neu-rich-text-editor__variable{min-height:28px;padding:0 var(--neu-space-2, .5rem);color:var(--neu-primary-dark, var(--neu-primary));font:inherit;font-size:var(--neu-text-xs, .75rem);font-weight:700;cursor:pointer;background:var(--neu-primary-50, rgba(0, 176, 160, .1));border:1px solid var(--neu-primary-100, rgba(0, 176, 160, .22));border-radius:var(--neu-radius-full, 999px)}.neu-rich-text-editor__variable:hover:not(:disabled){background:var(--neu-primary-100, rgba(0, 176, 160, .18))}.neu-rich-text-editor__surface{min-height:180px;max-height:min(60vh,560px);padding:var(--neu-space-4, 1rem);overflow:auto;color:var(--neu-text);font-size:var(--neu-text-base, 1rem);line-height:1.55;background:var(--neu-surface);outline:none;-webkit-overflow-scrolling:touch}.neu-rich-text-editor-host--sm .neu-rich-text-editor__surface{min-height:140px;padding:var(--neu-space-3, .75rem);font-size:var(--neu-text-sm, .875rem)}.neu-rich-text-editor-host--lg .neu-rich-text-editor__surface{min-height:240px;padding:var(--neu-space-5, 1.25rem);font-size:var(--neu-text-lg, 1.125rem)}.neu-rich-text-editor__surface:empty:before{color:var(--neu-text-muted);pointer-events:none;content:attr(data-placeholder)}.neu-rich-text-editor__surface :where(p,ul,ol,blockquote,table){margin:0 0 .85em}.neu-rich-text-editor__surface :where(p:last-child,ul:last-child,ol:last-child,blockquote:last-child){margin-bottom:0}.neu-rich-text-editor__surface :where(ul,ol){padding-left:1.4rem}.neu-rich-text-editor__surface :where(a){color:var(--neu-primary-dark, var(--neu-primary));text-decoration:underline;text-underline-offset:2px}.neu-rich-text-editor__surface :where(img){max-width:100%;height:auto;border-radius:var(--neu-radius-sm, .375rem)}.neu-rich-text-editor__surface :where(blockquote){padding-left:var(--neu-space-4, 1rem);color:var(--neu-text-muted);border-left:3px solid var(--neu-primary-100, rgba(0, 176, 160, .22))}.neu-rich-text-editor__surface :where(table){width:100%;border-collapse:collapse}.neu-rich-text-editor__surface :where(td,th){padding:.45rem;border:1px solid var(--neu-border)}.neu-rich-text-editor__hint,.neu-rich-text-editor__error{margin:0;font-size:var(--neu-text-xs, .75rem);line-height:1.45}.neu-rich-text-editor__hint{color:var(--neu-text-muted)}.neu-rich-text-editor__error{color:var(--neu-error);font-weight:600}.neu-rich-text-editor__preview{padding:var(--neu-space-3, .75rem);background:var(--neu-surface-2, #f8fafc);border:1px solid var(--neu-border);border-radius:var(--neu-radius, .5rem)}.neu-rich-text-editor__preview summary{cursor:pointer;color:var(--neu-text);font-weight:700}.neu-rich-text-editor__preview-content{margin-top:var(--neu-space-3, .75rem)}.neu-rich-text-editor--disabled{opacity:.72}.neu-rich-text-editor--disabled .neu-rich-text-editor__surface{cursor:not-allowed;background:var(--neu-surface-2, #f8fafc)}\n"], dependencies: [{ kind: "component", type: NeuButtonComponent, selector: "button[neu-button]", inputs: ["variant", "size", "disabled", "loading", "fullWidth", "icon", "iconPosition", "iconOnly", "ariaLabel"], outputs: ["neuClick"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
558
|
+
}
|
|
559
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: NeuRichTextEditorComponent, decorators: [{
|
|
560
|
+
type: Component,
|
|
561
|
+
args: [{ selector: 'neu-rich-text-editor', imports: [NeuButtonComponent], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
562
|
+
class: 'neu-rich-text-editor-host',
|
|
563
|
+
'[class.neu-rich-text-editor-host--sm]': 'size() === "sm"',
|
|
564
|
+
'[class.neu-rich-text-editor-host--lg]': 'size() === "lg"',
|
|
565
|
+
}, providers: [
|
|
566
|
+
{
|
|
567
|
+
provide: NG_VALUE_ACCESSOR,
|
|
568
|
+
useExisting: forwardRef(() => NeuRichTextEditorComponent),
|
|
569
|
+
multi: true,
|
|
570
|
+
},
|
|
571
|
+
], template: `
|
|
572
|
+
<div class="neu-rich-text-editor" [class.neu-rich-text-editor--disabled]="isDisabledFinal()">
|
|
573
|
+
@if (label()) {
|
|
574
|
+
<label class="neu-rich-text-editor__label" [id]="editorId() + '-label'" [for]="editorId()">
|
|
575
|
+
{{ label() }}
|
|
576
|
+
</label>
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
<div
|
|
580
|
+
class="neu-rich-text-editor__frame"
|
|
581
|
+
[class.neu-rich-text-editor__frame--focused]="focused()"
|
|
582
|
+
[class.neu-rich-text-editor__frame--error]="hasError()"
|
|
583
|
+
>
|
|
584
|
+
<div
|
|
585
|
+
class="neu-rich-text-editor__toolbar"
|
|
586
|
+
role="toolbar"
|
|
587
|
+
[attr.aria-label]="mergedLabels().toolbar"
|
|
588
|
+
>
|
|
589
|
+
<div
|
|
590
|
+
class="neu-rich-text-editor__toolbar-group"
|
|
591
|
+
role="group"
|
|
592
|
+
[attr.aria-label]="mergedLabels().formatGroup"
|
|
593
|
+
>
|
|
594
|
+
<button
|
|
595
|
+
neu-button
|
|
596
|
+
type="button"
|
|
597
|
+
variant="ghost"
|
|
598
|
+
size="sm"
|
|
599
|
+
icon="lucideBold"
|
|
600
|
+
[iconOnly]="true"
|
|
601
|
+
[ariaLabel]="mergedLabels().bold"
|
|
602
|
+
[title]="mergedLabels().bold"
|
|
603
|
+
[disabled]="isDisabledFinal()"
|
|
604
|
+
(click)="format('bold')"
|
|
605
|
+
></button>
|
|
606
|
+
<button
|
|
607
|
+
neu-button
|
|
608
|
+
type="button"
|
|
609
|
+
variant="ghost"
|
|
610
|
+
size="sm"
|
|
611
|
+
icon="lucideItalic"
|
|
612
|
+
[iconOnly]="true"
|
|
613
|
+
[ariaLabel]="mergedLabels().italic"
|
|
614
|
+
[title]="mergedLabels().italic"
|
|
615
|
+
[disabled]="isDisabledFinal()"
|
|
616
|
+
(click)="format('italic')"
|
|
617
|
+
></button>
|
|
618
|
+
<button
|
|
619
|
+
neu-button
|
|
620
|
+
type="button"
|
|
621
|
+
variant="ghost"
|
|
622
|
+
size="sm"
|
|
623
|
+
icon="lucideUnderline"
|
|
624
|
+
[iconOnly]="true"
|
|
625
|
+
[ariaLabel]="mergedLabels().underline"
|
|
626
|
+
[title]="mergedLabels().underline"
|
|
627
|
+
[disabled]="isDisabledFinal()"
|
|
628
|
+
(click)="format('underline')"
|
|
629
|
+
></button>
|
|
630
|
+
</div>
|
|
631
|
+
|
|
632
|
+
<div
|
|
633
|
+
class="neu-rich-text-editor__toolbar-group"
|
|
634
|
+
role="group"
|
|
635
|
+
[attr.aria-label]="mergedLabels().listsGroup"
|
|
636
|
+
>
|
|
637
|
+
<button
|
|
638
|
+
neu-button
|
|
639
|
+
type="button"
|
|
640
|
+
variant="ghost"
|
|
641
|
+
size="sm"
|
|
642
|
+
icon="lucideList"
|
|
643
|
+
[iconOnly]="true"
|
|
644
|
+
[ariaLabel]="mergedLabels().unorderedList"
|
|
645
|
+
[title]="mergedLabels().unorderedList"
|
|
646
|
+
[disabled]="isDisabledFinal()"
|
|
647
|
+
(click)="format('insertUnorderedList')"
|
|
648
|
+
></button>
|
|
649
|
+
<button
|
|
650
|
+
neu-button
|
|
651
|
+
type="button"
|
|
652
|
+
variant="ghost"
|
|
653
|
+
size="sm"
|
|
654
|
+
icon="lucideListOrdered"
|
|
655
|
+
[iconOnly]="true"
|
|
656
|
+
[ariaLabel]="mergedLabels().orderedList"
|
|
657
|
+
[title]="mergedLabels().orderedList"
|
|
658
|
+
[disabled]="isDisabledFinal()"
|
|
659
|
+
(click)="format('insertOrderedList')"
|
|
660
|
+
></button>
|
|
661
|
+
</div>
|
|
662
|
+
|
|
663
|
+
<div
|
|
664
|
+
class="neu-rich-text-editor__toolbar-group"
|
|
665
|
+
role="group"
|
|
666
|
+
[attr.aria-label]="mergedLabels().insertGroup"
|
|
667
|
+
>
|
|
668
|
+
<button
|
|
669
|
+
neu-button
|
|
670
|
+
type="button"
|
|
671
|
+
variant="ghost"
|
|
672
|
+
size="sm"
|
|
673
|
+
icon="lucideLink"
|
|
674
|
+
[iconOnly]="true"
|
|
675
|
+
[ariaLabel]="mergedLabels().addLink"
|
|
676
|
+
[title]="mergedLabels().addLink"
|
|
677
|
+
[disabled]="isDisabledFinal()"
|
|
678
|
+
(click)="addLink()"
|
|
679
|
+
></button>
|
|
680
|
+
<button
|
|
681
|
+
neu-button
|
|
682
|
+
type="button"
|
|
683
|
+
variant="ghost"
|
|
684
|
+
size="sm"
|
|
685
|
+
icon="lucideImage"
|
|
686
|
+
[iconOnly]="true"
|
|
687
|
+
[ariaLabel]="mergedLabels().addImageUrl"
|
|
688
|
+
[title]="mergedLabels().addImageUrl"
|
|
689
|
+
[disabled]="isDisabledFinal()"
|
|
690
|
+
(click)="addImageUrl()"
|
|
691
|
+
></button>
|
|
692
|
+
</div>
|
|
693
|
+
|
|
694
|
+
<div
|
|
695
|
+
class="neu-rich-text-editor__toolbar-group"
|
|
696
|
+
role="group"
|
|
697
|
+
[attr.aria-label]="mergedLabels().clearGroup"
|
|
698
|
+
>
|
|
699
|
+
<button
|
|
700
|
+
neu-button
|
|
701
|
+
type="button"
|
|
702
|
+
variant="ghost"
|
|
703
|
+
size="sm"
|
|
704
|
+
icon="lucideEraser"
|
|
705
|
+
[iconOnly]="true"
|
|
706
|
+
[ariaLabel]="mergedLabels().clearFormat"
|
|
707
|
+
[title]="mergedLabels().clearFormat"
|
|
708
|
+
[disabled]="isDisabledFinal()"
|
|
709
|
+
(click)="format('removeFormat')"
|
|
710
|
+
></button>
|
|
711
|
+
</div>
|
|
712
|
+
</div>
|
|
713
|
+
|
|
714
|
+
@if (variables().length) {
|
|
715
|
+
<div class="neu-rich-text-editor__variables" [attr.aria-label]="variablesAriaLabel()">
|
|
716
|
+
<span class="neu-rich-text-editor__variables-label">{{ variablesLabel() }}</span>
|
|
717
|
+
@for (variable of variables(); track variable) {
|
|
718
|
+
<button
|
|
719
|
+
class="neu-rich-text-editor__variable"
|
|
720
|
+
type="button"
|
|
721
|
+
[disabled]="isDisabledFinal()"
|
|
722
|
+
(click)="insertVariable(variable)"
|
|
723
|
+
>
|
|
724
|
+
{{ variable }}
|
|
725
|
+
</button>
|
|
726
|
+
}
|
|
727
|
+
</div>
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
<div
|
|
731
|
+
#editorRef
|
|
732
|
+
class="neu-rich-text-editor__surface"
|
|
733
|
+
role="textbox"
|
|
734
|
+
aria-multiline="true"
|
|
735
|
+
[id]="editorId()"
|
|
736
|
+
[attr.aria-label]="label() ? null : mergedLabels().toolbar"
|
|
737
|
+
[attr.aria-labelledby]="label() ? editorId() + '-label' : null"
|
|
738
|
+
[attr.contenteditable]="isDisabledFinal() ? 'false' : 'true'"
|
|
739
|
+
[attr.data-placeholder]="placeholder()"
|
|
740
|
+
[attr.aria-describedby]="ariaDescribedBy()"
|
|
741
|
+
[attr.aria-invalid]="hasError() ? 'true' : null"
|
|
742
|
+
[style.min-height]="minHeight()"
|
|
743
|
+
(input)="handleInput()"
|
|
744
|
+
(focus)="onFocus()"
|
|
745
|
+
(blur)="onBlur()"
|
|
746
|
+
(paste)="handlePaste($event)"
|
|
747
|
+
></div>
|
|
748
|
+
</div>
|
|
749
|
+
|
|
750
|
+
@if (hasError()) {
|
|
751
|
+
<p class="neu-rich-text-editor__error" [id]="editorId() + '-error'" role="alert">
|
|
752
|
+
{{ errorMessage() }}
|
|
753
|
+
</p>
|
|
754
|
+
} @else if (hint()) {
|
|
755
|
+
<p class="neu-rich-text-editor__hint" [id]="editorId() + '-hint'">{{ hint() }}</p>
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
@if (showPreview() && value()) {
|
|
759
|
+
<details class="neu-rich-text-editor__preview">
|
|
760
|
+
<summary>{{ previewLabel() }}</summary>
|
|
761
|
+
<div class="neu-rich-text-editor__preview-content" [innerHTML]="value()"></div>
|
|
762
|
+
</details>
|
|
763
|
+
}
|
|
764
|
+
</div>
|
|
765
|
+
`, styles: [".neu-rich-text-editor-host{display:block;font-family:var(--neu-font-sans)}.neu-rich-text-editor{display:grid;gap:var(--neu-space-2, .5rem);color:var(--neu-text)}.neu-rich-text-editor__label{color:var(--neu-text);font-size:var(--neu-text-sm);font-weight:700;line-height:1.2}.neu-rich-text-editor__frame{overflow:hidden;background:var(--neu-surface);border:1px solid var(--neu-border);border-radius:var(--neu-radius-lg, .75rem);box-shadow:var(--neu-shadow-sm, 0 1px 2px rgba(15, 23, 42, .08));transition:border-color var(--neu-transition),box-shadow var(--neu-transition),background-color var(--neu-transition)}.neu-rich-text-editor__frame--focused{border-color:var(--neu-border-focus, var(--neu-primary));box-shadow:var(--neu-focus-ring, 0 0 0 3px rgba(0, 176, 160, .18))}.neu-rich-text-editor__frame--error{border-color:var(--neu-error)}.neu-rich-text-editor__toolbar{display:flex;flex-wrap:wrap;gap:var(--neu-space-2, .5rem);align-items:center;min-height:46px;padding:var(--neu-space-2, .5rem);background:var(--neu-surface-2, #f8fafc);border-bottom:1px solid var(--neu-border)}.neu-rich-text-editor__toolbar-group{display:inline-flex;align-items:center;gap:2px;padding:2px;background:var(--neu-surface);border:1px solid var(--neu-border);border-radius:var(--neu-radius, .5rem)}.neu-rich-text-editor__toolbar .neu-button--ghost{color:var(--neu-text-muted)}.neu-rich-text-editor__toolbar .neu-button--ghost:hover:not(:disabled):not(.neu-button--disabled){color:var(--neu-text);background:var(--neu-primary-50, rgba(0, 176, 160, .1))}.neu-rich-text-editor__variables{display:flex;flex-wrap:wrap;gap:var(--neu-space-2, .5rem);align-items:center;padding:var(--neu-space-2, .5rem) var(--neu-space-3, .75rem);background:var(--neu-surface);border-bottom:1px solid var(--neu-border)}.neu-rich-text-editor__variables-label{color:var(--neu-text-muted);font-size:var(--neu-text-xs, .75rem);font-weight:700}.neu-rich-text-editor__variable{min-height:28px;padding:0 var(--neu-space-2, .5rem);color:var(--neu-primary-dark, var(--neu-primary));font:inherit;font-size:var(--neu-text-xs, .75rem);font-weight:700;cursor:pointer;background:var(--neu-primary-50, rgba(0, 176, 160, .1));border:1px solid var(--neu-primary-100, rgba(0, 176, 160, .22));border-radius:var(--neu-radius-full, 999px)}.neu-rich-text-editor__variable:hover:not(:disabled){background:var(--neu-primary-100, rgba(0, 176, 160, .18))}.neu-rich-text-editor__surface{min-height:180px;max-height:min(60vh,560px);padding:var(--neu-space-4, 1rem);overflow:auto;color:var(--neu-text);font-size:var(--neu-text-base, 1rem);line-height:1.55;background:var(--neu-surface);outline:none;-webkit-overflow-scrolling:touch}.neu-rich-text-editor-host--sm .neu-rich-text-editor__surface{min-height:140px;padding:var(--neu-space-3, .75rem);font-size:var(--neu-text-sm, .875rem)}.neu-rich-text-editor-host--lg .neu-rich-text-editor__surface{min-height:240px;padding:var(--neu-space-5, 1.25rem);font-size:var(--neu-text-lg, 1.125rem)}.neu-rich-text-editor__surface:empty:before{color:var(--neu-text-muted);pointer-events:none;content:attr(data-placeholder)}.neu-rich-text-editor__surface :where(p,ul,ol,blockquote,table){margin:0 0 .85em}.neu-rich-text-editor__surface :where(p:last-child,ul:last-child,ol:last-child,blockquote:last-child){margin-bottom:0}.neu-rich-text-editor__surface :where(ul,ol){padding-left:1.4rem}.neu-rich-text-editor__surface :where(a){color:var(--neu-primary-dark, var(--neu-primary));text-decoration:underline;text-underline-offset:2px}.neu-rich-text-editor__surface :where(img){max-width:100%;height:auto;border-radius:var(--neu-radius-sm, .375rem)}.neu-rich-text-editor__surface :where(blockquote){padding-left:var(--neu-space-4, 1rem);color:var(--neu-text-muted);border-left:3px solid var(--neu-primary-100, rgba(0, 176, 160, .22))}.neu-rich-text-editor__surface :where(table){width:100%;border-collapse:collapse}.neu-rich-text-editor__surface :where(td,th){padding:.45rem;border:1px solid var(--neu-border)}.neu-rich-text-editor__hint,.neu-rich-text-editor__error{margin:0;font-size:var(--neu-text-xs, .75rem);line-height:1.45}.neu-rich-text-editor__hint{color:var(--neu-text-muted)}.neu-rich-text-editor__error{color:var(--neu-error);font-weight:600}.neu-rich-text-editor__preview{padding:var(--neu-space-3, .75rem);background:var(--neu-surface-2, #f8fafc);border:1px solid var(--neu-border);border-radius:var(--neu-radius, .5rem)}.neu-rich-text-editor__preview summary{cursor:pointer;color:var(--neu-text);font-weight:700}.neu-rich-text-editor__preview-content{margin-top:var(--neu-space-3, .75rem)}.neu-rich-text-editor--disabled{opacity:.72}.neu-rich-text-editor--disabled .neu-rich-text-editor__surface{cursor:not-allowed;background:var(--neu-surface-2, #f8fafc)}\n"] }]
|
|
766
|
+
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], errorMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessage", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], minHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "minHeight", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], toolbarAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "toolbarAriaLabel", required: false }] }], labels: [{ type: i0.Input, args: [{ isSignal: true, alias: "labels", required: false }] }], variables: [{ type: i0.Input, args: [{ isSignal: true, alias: "variables", required: false }] }], variablesLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "variablesLabel", required: false }] }], variablesAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "variablesAriaLabel", required: false }] }], maxPastedImageBytes: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxPastedImageBytes", required: false }] }], showPreview: [{ type: i0.Input, args: [{ isSignal: true, alias: "showPreview", required: false }] }], previewLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "previewLabel", required: false }] }], editorId: [{ type: i0.Input, args: [{ isSignal: true, alias: "editorId", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], imageRejected: [{ type: i0.Output, args: ["imageRejected"] }], editorRef: [{ type: i0.ViewChild, args: ['editorRef', { isSignal: true }] }] } });
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Generated bundle index. Do not edit.
|
|
770
|
+
*/
|
|
771
|
+
|
|
772
|
+
export { NEU_RICH_TEXT_ALLOWED_TAGS, NeuRichTextEditorComponent, escapeRichTextAttribute, escapeRichTextHtml, normalizeRichTextHtml, plainTextToRichTextHtml, sanitizeRichTextHtml };
|
|
773
|
+
//# sourceMappingURL=neural-ui-core-rich-text-editor.mjs.map
|