@3kles/kles-richtext-editor 1.1.0 → 1.3.0
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/README.md +24 -2
- package/fesm2022/3kles-kles-richtext-editor-dynamicforms.mjs +179 -0
- package/fesm2022/3kles-kles-richtext-editor-dynamicforms.mjs.map +1 -0
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-menu.component-Dq2K0CY3.mjs +183 -0
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-menu.component-Dq2K0CY3.mjs.map +1 -0
- package/fesm2022/3kles-kles-richtext-editor-toolbar-configuration-DsbPfSEO.mjs +337 -0
- package/fesm2022/3kles-kles-richtext-editor-toolbar-configuration-DsbPfSEO.mjs.map +1 -0
- package/fesm2022/3kles-kles-richtext-editor.mjs +296 -395
- package/fesm2022/3kles-kles-richtext-editor.mjs.map +1 -1
- package/package.json +15 -4
- package/types/3kles-kles-richtext-editor-dynamicforms.d.ts +24 -0
- package/types/3kles-kles-richtext-editor-dynamicforms.d.ts.map +1 -0
- package/types/3kles-kles-richtext-editor.d.ts +90 -8
- package/types/3kles-kles-richtext-editor.d.ts.map +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { a as toolbarActionQueries, d as RICHTEXT_MESSAGES_FR, f as resolveRichTextMessages, i as sameToolbarActionQueries, l as RichTextAccessibilityIds, n as FULL_RICHTEXT_TOOLBAR_ITEMS, o as toolbarButtonContent, p as richTextLabel, r as resolveToolbarItems, s as toolbarItemLabel, t as DEFAULT_RICHTEXT_TOOLBAR_ITEMS, u as RICHTEXT_MESSAGES_EN } from "./3kles-kles-richtext-editor-toolbar-configuration-DsbPfSEO.mjs";
|
|
1
2
|
import { JsonPipe, NgTemplateOutlet, isPlatformBrowser } from "@angular/common";
|
|
2
3
|
import * as i0 from "@angular/core";
|
|
3
|
-
import {
|
|
4
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, InjectionToken, PLATFORM_ID, ViewChild, booleanAttribute, computed, effect, forwardRef, inject, input, output, signal, untracked, viewChild } from "@angular/core";
|
|
4
5
|
import { NG_VALIDATORS, NG_VALUE_ACCESSOR } from "@angular/forms";
|
|
5
|
-
import { compareTextPoints, createEmptyDocument, getNodeAtPath, getTextBlockText, isSupportedLinkDestination, resolveTextBlock, validateDocument } from "@3kles/richtext-core";
|
|
6
|
-
import { createEditor } from "@3kles/richtext-dom";
|
|
6
|
+
import { compareTextPoints, createEmptyDocument, getNodeAtPath, getTextBlockText, isSupportedLinkDestination, isTextStyleMarkType, normalizeTextStyleValue, resolveTextBlock, validateDocument } from "@3kles/richtext-core";
|
|
7
|
+
import { createEditor, selectedTextStyle } from "@3kles/richtext-dom";
|
|
8
|
+
import { importHtml } from "@3kles/richtext-formats";
|
|
7
9
|
const RICHTEXT_I18N = new InjectionToken("RICHTEXT_I18N", {
|
|
8
10
|
providedIn: "root",
|
|
9
11
|
factory: () => Object.freeze({ locale: "fr" })
|
|
@@ -17,103 +19,6 @@ function provideRichTextI18n(options) {
|
|
|
17
19
|
})
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
|
-
const RICHTEXT_MESSAGES_FR = Object.freeze({
|
|
21
|
-
editorLabel: "Contenu du document",
|
|
22
|
-
invalidDocument: "La valeur doit être un document 3KLES valide.",
|
|
23
|
-
requiredDocument: "Le document doit contenir du texte.",
|
|
24
|
-
validationError: "Le document comporte une erreur de validation.",
|
|
25
|
-
previewLabel: "Représentation JSON du document",
|
|
26
|
-
toolbarLabel: "Mise en forme du document",
|
|
27
|
-
toolbarFields: "Options de titre et de lien",
|
|
28
|
-
headingLevel: "Niveau",
|
|
29
|
-
headingLevelLabel: "Niveau du titre",
|
|
30
|
-
linkAddress: "Adresse du lien",
|
|
31
|
-
applyLink: "Appliquer le lien",
|
|
32
|
-
removeLink: "Retirer le lien",
|
|
33
|
-
invalidLink: "Saisissez une adresse HTTP, HTTPS, mailto ou une destination dynamique valide.",
|
|
34
|
-
actionUnavailable: "Cette action ne peut pas être appliquée à la sélection.",
|
|
35
|
-
undoDone: "Annulation effectuée.",
|
|
36
|
-
redoDone: "Rétablissement effectué.",
|
|
37
|
-
formatDone: "Mise en forme mise à jour.",
|
|
38
|
-
linkApplied: "Lien appliqué.",
|
|
39
|
-
linkNotApplied: "Le lien ne peut pas être appliqué à la sélection.",
|
|
40
|
-
linkRemoved: "Lien retiré.",
|
|
41
|
-
linkNotRemoved: "Le lien ne peut pas être retiré de la sélection.",
|
|
42
|
-
bold: "Gras",
|
|
43
|
-
italic: "Italique",
|
|
44
|
-
underline: "Souligné",
|
|
45
|
-
paragraph: "Paragraphe",
|
|
46
|
-
heading: "Titre",
|
|
47
|
-
strike: "Barré",
|
|
48
|
-
code: "Code en ligne",
|
|
49
|
-
bulletList: "Liste à puces",
|
|
50
|
-
orderedList: "Liste numérotée",
|
|
51
|
-
indent: "Indenter",
|
|
52
|
-
outdent: "Réduire le retrait",
|
|
53
|
-
blockquote: "Citation",
|
|
54
|
-
codeBlock: "Bloc de code",
|
|
55
|
-
clear: "Effacer la mise en forme",
|
|
56
|
-
undo: "Annuler",
|
|
57
|
-
redo: "Rétablir"
|
|
58
|
-
});
|
|
59
|
-
const RICHTEXT_MESSAGES_EN = Object.freeze({
|
|
60
|
-
editorLabel: "Document content",
|
|
61
|
-
invalidDocument: "The value must be a valid 3KLES document.",
|
|
62
|
-
requiredDocument: "The document must contain text.",
|
|
63
|
-
validationError: "The document has a validation error.",
|
|
64
|
-
previewLabel: "Document JSON representation",
|
|
65
|
-
toolbarLabel: "Document formatting",
|
|
66
|
-
toolbarFields: "Heading and link options",
|
|
67
|
-
headingLevel: "Level",
|
|
68
|
-
headingLevelLabel: "Heading level",
|
|
69
|
-
linkAddress: "Link address",
|
|
70
|
-
applyLink: "Apply link",
|
|
71
|
-
removeLink: "Remove link",
|
|
72
|
-
invalidLink: "Enter a valid HTTP, HTTPS, mailto, or dynamic link destination.",
|
|
73
|
-
actionUnavailable: "This action cannot be applied to the selection.",
|
|
74
|
-
undoDone: "Undo completed.",
|
|
75
|
-
redoDone: "Redo completed.",
|
|
76
|
-
formatDone: "Formatting updated.",
|
|
77
|
-
linkApplied: "Link applied.",
|
|
78
|
-
linkNotApplied: "The link cannot be applied to the selection.",
|
|
79
|
-
linkRemoved: "Link removed.",
|
|
80
|
-
linkNotRemoved: "The link cannot be removed from the selection.",
|
|
81
|
-
bold: "Bold",
|
|
82
|
-
italic: "Italic",
|
|
83
|
-
underline: "Underline",
|
|
84
|
-
paragraph: "Paragraph",
|
|
85
|
-
heading: "Heading",
|
|
86
|
-
strike: "Strikethrough",
|
|
87
|
-
code: "Inline code",
|
|
88
|
-
bulletList: "Bullet list",
|
|
89
|
-
orderedList: "Numbered list",
|
|
90
|
-
indent: "Indent",
|
|
91
|
-
outdent: "Outdent",
|
|
92
|
-
blockquote: "Blockquote",
|
|
93
|
-
codeBlock: "Code block",
|
|
94
|
-
clear: "Clear formatting",
|
|
95
|
-
undo: "Undo",
|
|
96
|
-
redo: "Redo"
|
|
97
|
-
});
|
|
98
|
-
function richTextLocale(locale) {
|
|
99
|
-
return locale?.trim().toLowerCase().split(/[-_]/u)[0] === "en" ? "en" : "fr";
|
|
100
|
-
}
|
|
101
|
-
function resolveRichTextMessages(locale, ...overrides) {
|
|
102
|
-
const messages = { ...richTextLocale(locale) === "en" ? RICHTEXT_MESSAGES_EN : RICHTEXT_MESSAGES_FR };
|
|
103
|
-
for (const override of overrides) {
|
|
104
|
-
if (!override) continue;
|
|
105
|
-
for (const [key, value] of Object.entries(override)) if (typeof value === "string" && value.trim().length > 0) Object.defineProperty(messages, key, {
|
|
106
|
-
value,
|
|
107
|
-
enumerable: true,
|
|
108
|
-
configurable: true,
|
|
109
|
-
writable: true
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return Object.freeze(messages);
|
|
113
|
-
}
|
|
114
|
-
function richTextLabel(value, fallback) {
|
|
115
|
-
return value?.trim() ? value : fallback;
|
|
116
|
-
}
|
|
117
22
|
var RichTextDocumentPreviewComponent = class RichTextDocumentPreviewComponent {
|
|
118
23
|
document = input.required(...ngDevMode ? [{ debugName: "document" }] : /* istanbul ignore next */ []);
|
|
119
24
|
labelOverride = input(void 0, {
|
|
@@ -231,38 +136,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
231
136
|
}
|
|
232
137
|
});
|
|
233
138
|
const RICHTEXT_EDITOR_EXTENSIONS = new InjectionToken("RICHTEXT_EDITOR_EXTENSIONS");
|
|
234
|
-
var RichTextAccessibilityIds = class RichTextAccessibilityIds {
|
|
235
|
-
appId = inject(APP_ID);
|
|
236
|
-
sequence = 0;
|
|
237
|
-
next(purpose) {
|
|
238
|
-
return `${this.appId}-kles-richtext-${purpose}-${++this.sequence}`;
|
|
239
|
-
}
|
|
240
|
-
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
241
|
-
minVersion: "12.0.0",
|
|
242
|
-
version: "22.2.6",
|
|
243
|
-
ngImport: i0,
|
|
244
|
-
type: RichTextAccessibilityIds,
|
|
245
|
-
deps: [],
|
|
246
|
-
target: i0.ɵɵFactoryTarget.Injectable
|
|
247
|
-
});
|
|
248
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
249
|
-
minVersion: "12.0.0",
|
|
250
|
-
version: "22.2.6",
|
|
251
|
-
ngImport: i0,
|
|
252
|
-
type: RichTextAccessibilityIds,
|
|
253
|
-
providedIn: "root"
|
|
254
|
-
});
|
|
255
|
-
};
|
|
256
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
257
|
-
minVersion: "12.0.0",
|
|
258
|
-
version: "22.2.6",
|
|
259
|
-
ngImport: i0,
|
|
260
|
-
type: RichTextAccessibilityIds,
|
|
261
|
-
decorators: [{
|
|
262
|
-
type: Injectable,
|
|
263
|
-
args: [{ providedIn: "root" }]
|
|
264
|
-
}]
|
|
265
|
-
});
|
|
266
139
|
const RICHTEXT_REQUIRED_ERROR = Object.freeze({ required: true });
|
|
267
140
|
function validateRichTextValue(value) {
|
|
268
141
|
return value === null ? {
|
|
@@ -271,6 +144,27 @@ function validateRichTextValue(value) {
|
|
|
271
144
|
diagnostics: Object.freeze([])
|
|
272
145
|
} : validateDocument(value);
|
|
273
146
|
}
|
|
147
|
+
function validateRichTextHtmlValue(value) {
|
|
148
|
+
if (value === null) return validateRichTextValue(null);
|
|
149
|
+
const result = importHtml(value);
|
|
150
|
+
if (result.ok) return {
|
|
151
|
+
ok: true,
|
|
152
|
+
value: result.value,
|
|
153
|
+
diagnostics: []
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
ok: false,
|
|
157
|
+
diagnostics: richTextHtmlDiagnostics(result.diagnostics)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function richTextHtmlDiagnostics(diagnostics) {
|
|
161
|
+
return diagnostics.map(({ code, path, message }) => ({
|
|
162
|
+
code: code === "resourceLimit" || code === "invalidUnicode" ? code : "invalidType",
|
|
163
|
+
severity: "error",
|
|
164
|
+
path,
|
|
165
|
+
message
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
274
168
|
function richTextSchemaError(diagnostics) {
|
|
275
169
|
return Object.freeze({ richtextDocument: Object.freeze({ diagnostics }) });
|
|
276
170
|
}
|
|
@@ -291,9 +185,15 @@ function richTextRequiredValidator(control) {
|
|
|
291
185
|
if (!result.ok) return richTextSchemaError(result.diagnostics);
|
|
292
186
|
return hasRichTextContent(result.value) ? null : RICHTEXT_REQUIRED_ERROR;
|
|
293
187
|
}
|
|
188
|
+
function richTextHtmlRequiredValidator(control) {
|
|
189
|
+
const result = validateRichTextHtmlValue(control.value);
|
|
190
|
+
if (!result.ok) return richTextSchemaError(result.diagnostics);
|
|
191
|
+
return hasRichTextContent(result.value) ? null : RICHTEXT_REQUIRED_ERROR;
|
|
192
|
+
}
|
|
294
193
|
var RichTextEditorComponent = class RichTextEditorComponent {
|
|
295
194
|
surface;
|
|
296
195
|
document = input(createEmptyDocument(), ...ngDevMode ? [{ debugName: "document" }] : /* istanbul ignore next */ []);
|
|
196
|
+
formValueFormat = input("document", ...ngDevMode ? [{ debugName: "formValueFormat" }] : /* istanbul ignore next */ []);
|
|
297
197
|
readOnly = input(false, {
|
|
298
198
|
...ngDevMode ? { debugName: "readOnly" } : /* istanbul ignore next */ {},
|
|
299
199
|
transform: booleanAttribute
|
|
@@ -367,6 +267,7 @@ var RichTextEditorComponent = class RichTextEditorComponent {
|
|
|
367
267
|
interacted = false;
|
|
368
268
|
focusRegions = /* @__PURE__ */ new Map();
|
|
369
269
|
onChange = () => void 0;
|
|
270
|
+
htmlFormValue;
|
|
370
271
|
onTouched = () => void 0;
|
|
371
272
|
onValidatorChange = () => void 0;
|
|
372
273
|
constructor() {
|
|
@@ -434,6 +335,11 @@ var RichTextEditorComponent = class RichTextEditorComponent {
|
|
|
434
335
|
this.applyAccess(this.effectiveDisabled(), this.readOnly());
|
|
435
336
|
}
|
|
436
337
|
validate(control) {
|
|
338
|
+
if (this.formValueFormat() === "html") {
|
|
339
|
+
const result = this.decodeHtmlFormValue(control.value);
|
|
340
|
+
if (!result.ok) return richTextSchemaError(result.diagnostics);
|
|
341
|
+
return this.required() && !hasRichTextContent(result.value) ? RICHTEXT_REQUIRED_ERROR : null;
|
|
342
|
+
}
|
|
437
343
|
return this.required() ? richTextRequiredValidator(control) : richTextDocumentValidator(control);
|
|
438
344
|
}
|
|
439
345
|
registerOnValidatorChange(callback) {
|
|
@@ -554,6 +460,7 @@ var RichTextEditorComponent = class RichTextEditorComponent {
|
|
|
554
460
|
this.pendingRejectedWrite = void 0;
|
|
555
461
|
this.pendingBlur = false;
|
|
556
462
|
this.interacted = false;
|
|
463
|
+
this.htmlFormValue = void 0;
|
|
557
464
|
this.stateValue.set(void 0);
|
|
558
465
|
this.composingValue.set(false);
|
|
559
466
|
this.focusedValue.set(false);
|
|
@@ -593,7 +500,7 @@ var RichTextEditorComponent = class RichTextEditorComponent {
|
|
|
593
500
|
if (event.commit.origin !== "load") {
|
|
594
501
|
this.validationPresented.set(true);
|
|
595
502
|
this.interacted = true;
|
|
596
|
-
if (this.formsBound) this.
|
|
503
|
+
if (this.formsBound) this.publishFormValue(event.state.document);
|
|
597
504
|
}
|
|
598
505
|
if (!this.pendingDocument && this.pendingRejectedWrite === void 0) this.documentChange.emit(event.state.document);
|
|
599
506
|
}
|
|
@@ -609,6 +516,37 @@ var RichTextEditorComponent = class RichTextEditorComponent {
|
|
|
609
516
|
this.nativeNotificationDepth--;
|
|
610
517
|
}
|
|
611
518
|
}
|
|
519
|
+
decodeHtmlFormValue(source) {
|
|
520
|
+
if (this.htmlFormValue && this.htmlFormValue.source === source) return this.htmlFormValue.result;
|
|
521
|
+
const result = validateRichTextHtmlValue(source);
|
|
522
|
+
this.htmlFormValue = {
|
|
523
|
+
source,
|
|
524
|
+
result
|
|
525
|
+
};
|
|
526
|
+
return result;
|
|
527
|
+
}
|
|
528
|
+
publishFormValue(document) {
|
|
529
|
+
if (this.formValueFormat() !== "html") {
|
|
530
|
+
this.onChange(document);
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const result = this.getHtml();
|
|
534
|
+
if (!result) return;
|
|
535
|
+
if (!result.ok) {
|
|
536
|
+
this.schemaError.set(richTextSchemaError(richTextHtmlDiagnostics(result.diagnostics)));
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
const html = result.value === "<p></p>" ? "" : result.value;
|
|
540
|
+
this.htmlFormValue = {
|
|
541
|
+
source: html,
|
|
542
|
+
result: {
|
|
543
|
+
ok: true,
|
|
544
|
+
value: document,
|
|
545
|
+
diagnostics: []
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
this.onChange(html);
|
|
549
|
+
}
|
|
612
550
|
receiveDocument(value, fromForms) {
|
|
613
551
|
if (this.destroyed || !fromForms && this.formsBound) return;
|
|
614
552
|
if (!fromForms && value === this.lastLoadedSource) {
|
|
@@ -617,7 +555,7 @@ var RichTextEditorComponent = class RichTextEditorComponent {
|
|
|
617
555
|
this.schemaError.set(null);
|
|
618
556
|
return;
|
|
619
557
|
}
|
|
620
|
-
const validated = validateRichTextValue(value);
|
|
558
|
+
const validated = fromForms && this.formValueFormat() === "html" ? this.decodeHtmlFormValue(value) : validateRichTextValue(value);
|
|
621
559
|
if (!validated.ok) {
|
|
622
560
|
this.pendingDocument = void 0;
|
|
623
561
|
this.pendingRejectedWrite = ++this.rejectedWriteSequence;
|
|
@@ -779,6 +717,13 @@ var RichTextEditorComponent = class RichTextEditorComponent {
|
|
|
779
717
|
isRequired: false,
|
|
780
718
|
transformFunction: null
|
|
781
719
|
},
|
|
720
|
+
formValueFormat: {
|
|
721
|
+
classPropertyName: "formValueFormat",
|
|
722
|
+
publicName: "formValueFormat",
|
|
723
|
+
isSignal: true,
|
|
724
|
+
isRequired: false,
|
|
725
|
+
transformFunction: null
|
|
726
|
+
},
|
|
782
727
|
readOnly: {
|
|
783
728
|
classPropertyName: "readOnly",
|
|
784
729
|
publicName: "readOnly",
|
|
@@ -902,6 +847,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
902
847
|
required: false
|
|
903
848
|
}]
|
|
904
849
|
}],
|
|
850
|
+
formValueFormat: [{
|
|
851
|
+
type: i0.Input,
|
|
852
|
+
args: [{
|
|
853
|
+
isSignal: true,
|
|
854
|
+
alias: "formValueFormat",
|
|
855
|
+
required: false
|
|
856
|
+
}]
|
|
857
|
+
}],
|
|
905
858
|
readOnly: [{
|
|
906
859
|
type: i0.Input,
|
|
907
860
|
args: [{
|
|
@@ -994,176 +947,6 @@ function provideRichTextToolbar(config) {
|
|
|
994
947
|
useValue: config
|
|
995
948
|
};
|
|
996
949
|
}
|
|
997
|
-
const TOOLBAR_ACTIONS = Object.freeze([
|
|
998
|
-
{
|
|
999
|
-
id: "bold",
|
|
1000
|
-
key: "bold",
|
|
1001
|
-
command: "bold",
|
|
1002
|
-
toggle: true
|
|
1003
|
-
},
|
|
1004
|
-
{
|
|
1005
|
-
id: "italic",
|
|
1006
|
-
key: "italic",
|
|
1007
|
-
command: "italic",
|
|
1008
|
-
toggle: true
|
|
1009
|
-
},
|
|
1010
|
-
{
|
|
1011
|
-
id: "underline",
|
|
1012
|
-
key: "underline",
|
|
1013
|
-
command: "underline",
|
|
1014
|
-
toggle: true
|
|
1015
|
-
},
|
|
1016
|
-
{
|
|
1017
|
-
id: "paragraph",
|
|
1018
|
-
key: "paragraph",
|
|
1019
|
-
command: "paragraph",
|
|
1020
|
-
toggle: true
|
|
1021
|
-
},
|
|
1022
|
-
{
|
|
1023
|
-
id: "heading",
|
|
1024
|
-
key: "heading",
|
|
1025
|
-
command: "heading",
|
|
1026
|
-
toggle: true
|
|
1027
|
-
},
|
|
1028
|
-
{
|
|
1029
|
-
id: "strike",
|
|
1030
|
-
key: "strike",
|
|
1031
|
-
command: "strike",
|
|
1032
|
-
toggle: true
|
|
1033
|
-
},
|
|
1034
|
-
{
|
|
1035
|
-
id: "code",
|
|
1036
|
-
key: "code",
|
|
1037
|
-
command: "code",
|
|
1038
|
-
toggle: true
|
|
1039
|
-
},
|
|
1040
|
-
{
|
|
1041
|
-
id: "bulletList",
|
|
1042
|
-
key: "bulletList",
|
|
1043
|
-
command: "bulletList",
|
|
1044
|
-
toggle: true
|
|
1045
|
-
},
|
|
1046
|
-
{
|
|
1047
|
-
id: "orderedList",
|
|
1048
|
-
key: "orderedList",
|
|
1049
|
-
command: "orderedList",
|
|
1050
|
-
toggle: true
|
|
1051
|
-
},
|
|
1052
|
-
{
|
|
1053
|
-
id: "indent",
|
|
1054
|
-
key: "indent",
|
|
1055
|
-
command: Object.freeze({ type: "indentListItem" })
|
|
1056
|
-
},
|
|
1057
|
-
{
|
|
1058
|
-
id: "outdent",
|
|
1059
|
-
key: "outdent",
|
|
1060
|
-
command: Object.freeze({ type: "outdentListItem" })
|
|
1061
|
-
},
|
|
1062
|
-
{
|
|
1063
|
-
id: "blockquote",
|
|
1064
|
-
key: "blockquote",
|
|
1065
|
-
command: "blockquote",
|
|
1066
|
-
toggle: true
|
|
1067
|
-
},
|
|
1068
|
-
{
|
|
1069
|
-
id: "codeBlock",
|
|
1070
|
-
key: "codeBlock",
|
|
1071
|
-
command: "codeBlock",
|
|
1072
|
-
toggle: true
|
|
1073
|
-
},
|
|
1074
|
-
{
|
|
1075
|
-
id: "clear",
|
|
1076
|
-
key: "clear",
|
|
1077
|
-
command: Object.freeze({ type: "clearFormatting" })
|
|
1078
|
-
},
|
|
1079
|
-
{
|
|
1080
|
-
id: "undo",
|
|
1081
|
-
key: "undo",
|
|
1082
|
-
command: "undo"
|
|
1083
|
-
},
|
|
1084
|
-
{
|
|
1085
|
-
id: "redo",
|
|
1086
|
-
key: "redo",
|
|
1087
|
-
command: "redo"
|
|
1088
|
-
}
|
|
1089
|
-
]);
|
|
1090
|
-
const DEFAULT_RICHTEXT_TOOLBAR_ITEMS = Object.freeze([
|
|
1091
|
-
...TOOLBAR_ACTIONS.map(({ id }) => id),
|
|
1092
|
-
"headingLevel",
|
|
1093
|
-
"link"
|
|
1094
|
-
]);
|
|
1095
|
-
function resolveToolbarItems(items) {
|
|
1096
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1097
|
-
const resolved = [];
|
|
1098
|
-
for (const input of items) {
|
|
1099
|
-
const item = typeof input === "string" ? { id: input } : input;
|
|
1100
|
-
if (!item.id.trim()) throw new TypeError("Toolbar item IDs must be nonempty.");
|
|
1101
|
-
if (seen.has(item.id)) throw new TypeError(`Duplicate toolbar item ID: ${item.id}`);
|
|
1102
|
-
seen.add(item.id);
|
|
1103
|
-
if (item.visible === false) continue;
|
|
1104
|
-
if ("kind" in item && item.kind === "command") {
|
|
1105
|
-
if (TOOLBAR_ACTIONS.some((action) => action.id === item.id) || item.id === "headingLevel" || item.id === "link") throw new TypeError(`Custom toolbar item uses a reserved ID: ${item.id}`);
|
|
1106
|
-
if (!item.label.trim()) throw new TypeError("Custom toolbar commands need a nonempty label.");
|
|
1107
|
-
resolved.push(Object.freeze({
|
|
1108
|
-
...item,
|
|
1109
|
-
kind: "action",
|
|
1110
|
-
builtin: false,
|
|
1111
|
-
toggle: item.toggle ?? false
|
|
1112
|
-
}));
|
|
1113
|
-
} else if (item.id === "headingLevel" || item.id === "link") resolved.push(Object.freeze({
|
|
1114
|
-
...item,
|
|
1115
|
-
kind: "field",
|
|
1116
|
-
id: item.id
|
|
1117
|
-
}));
|
|
1118
|
-
else {
|
|
1119
|
-
const definition = TOOLBAR_ACTIONS.find((action) => action.id === item.id);
|
|
1120
|
-
if (!definition) throw new TypeError(`Unknown toolbar item ID: ${item.id}`);
|
|
1121
|
-
resolved.push(Object.freeze({
|
|
1122
|
-
...item,
|
|
1123
|
-
...definition,
|
|
1124
|
-
kind: "action",
|
|
1125
|
-
builtin: true,
|
|
1126
|
-
toggle: definition.toggle ?? false
|
|
1127
|
-
}));
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
return Object.freeze(resolved);
|
|
1131
|
-
}
|
|
1132
|
-
function toolbarActionQueries(items) {
|
|
1133
|
-
return items.filter((item) => item.kind === "action").map((item) => ({
|
|
1134
|
-
id: item.id,
|
|
1135
|
-
builtin: item.builtin,
|
|
1136
|
-
command: item.command,
|
|
1137
|
-
disabled: item.disabled ?? false,
|
|
1138
|
-
toggle: item.toggle
|
|
1139
|
-
}));
|
|
1140
|
-
}
|
|
1141
|
-
function sameToolbarActionQueries(left, right) {
|
|
1142
|
-
return left.length === right.length && left.every((item, index) => {
|
|
1143
|
-
const next = right[index];
|
|
1144
|
-
return next !== void 0 && item.id === next.id && item.builtin === next.builtin && item.command === next.command && item.disabled === next.disabled && item.toggle === next.toggle;
|
|
1145
|
-
});
|
|
1146
|
-
}
|
|
1147
|
-
function toolbarItemLabel(item, messages) {
|
|
1148
|
-
const override = item.labelKey !== void 0 && Object.hasOwn(messages, item.labelKey) ? messages[item.labelKey] : void 0;
|
|
1149
|
-
return (typeof override === "string" && override.trim() ? override : void 0) ?? (item.label?.trim() ? item.label : void 0) ?? (item.kind === "action" && item.key ? messages[item.key] : item.kind === "field" && item.id === "headingLevel" ? messages.headingLevel : messages.linkAddress);
|
|
1150
|
-
}
|
|
1151
|
-
function toolbarButtonContent(action, messages, preferIconOnly = false) {
|
|
1152
|
-
const label = toolbarItemLabel(action, messages);
|
|
1153
|
-
const ariaLabel = richTextLabel(action.ariaLabel, label);
|
|
1154
|
-
const icon = action.icon?.trim();
|
|
1155
|
-
if (!icon) return {
|
|
1156
|
-
label,
|
|
1157
|
-
ariaLabel
|
|
1158
|
-
};
|
|
1159
|
-
const iconType = action.iconType ?? (icon === "undo" || icon === "redo" ? "material" : "text");
|
|
1160
|
-
return {
|
|
1161
|
-
icon,
|
|
1162
|
-
iconType,
|
|
1163
|
-
label: preferIconOnly || action.label?.trim() === "" || iconType === "material" && action.label === void 0 && action.labelKey === void 0 ? "" : label,
|
|
1164
|
-
ariaLabel
|
|
1165
|
-
};
|
|
1166
|
-
}
|
|
1167
950
|
function nextToolbarItem(items, current, key) {
|
|
1168
951
|
const available = items.filter((item) => !item.disabled);
|
|
1169
952
|
if (key === "Home") return available[0]?.id;
|
|
@@ -1204,6 +987,46 @@ function toolbarLinkHref(snapshot) {
|
|
|
1204
987
|
function isToolbarHeadingLevel(level) {
|
|
1205
988
|
return level === 1 || level === 2 || level === 3 || level === 4 || level === 5 || level === 6;
|
|
1206
989
|
}
|
|
990
|
+
const STYLE_OPTIONS = {
|
|
991
|
+
fontFamily: [
|
|
992
|
+
"Arial",
|
|
993
|
+
"Calibri",
|
|
994
|
+
"Courier New",
|
|
995
|
+
"Georgia",
|
|
996
|
+
"Tahoma",
|
|
997
|
+
"Times New Roman",
|
|
998
|
+
"Verdana"
|
|
999
|
+
],
|
|
1000
|
+
fontSize: [
|
|
1001
|
+
"8px",
|
|
1002
|
+
"10px",
|
|
1003
|
+
"12px",
|
|
1004
|
+
"14px",
|
|
1005
|
+
"16px",
|
|
1006
|
+
"18px",
|
|
1007
|
+
"20px",
|
|
1008
|
+
"24px",
|
|
1009
|
+
"28px",
|
|
1010
|
+
"32px",
|
|
1011
|
+
"36px",
|
|
1012
|
+
"48px",
|
|
1013
|
+
"72px"
|
|
1014
|
+
],
|
|
1015
|
+
lineHeight: [
|
|
1016
|
+
"1",
|
|
1017
|
+
"1.15",
|
|
1018
|
+
"1.25",
|
|
1019
|
+
"1.5",
|
|
1020
|
+
"1.75",
|
|
1021
|
+
"2",
|
|
1022
|
+
"2.5",
|
|
1023
|
+
"3"
|
|
1024
|
+
]
|
|
1025
|
+
};
|
|
1026
|
+
const COLOR_DEFAULTS = {
|
|
1027
|
+
color: "#000000",
|
|
1028
|
+
backgroundColor: "#ffff00"
|
|
1029
|
+
};
|
|
1207
1030
|
var RichTextToolbarComponent = class RichTextToolbarComponent {
|
|
1208
1031
|
editor = input.required(...ngDevMode ? [{ debugName: "editor" }] : /* istanbul ignore next */ []);
|
|
1209
1032
|
labelOverride = input(void 0, {
|
|
@@ -1243,11 +1066,51 @@ var RichTextToolbarComponent = class RichTextToolbarComponent {
|
|
|
1243
1066
|
iconOnly = computed(() => this.config()?.iconOnly ?? this.defaults.iconOnly ?? false, ...ngDevMode ? [{ debugName: "iconOnly" }] : /* istanbul ignore next */ []);
|
|
1244
1067
|
resolvedItems = computed(() => resolveToolbarItems(this.items() ?? this.config()?.items ?? this.defaults.items ?? DEFAULT_RICHTEXT_TOOLBAR_ITEMS), ...ngDevMode ? [{ debugName: "resolvedItems" }] : /* istanbul ignore next */ []);
|
|
1245
1068
|
hasItems = computed(() => this.resolvedItems().length > 0, ...ngDevMode ? [{ debugName: "hasItems" }] : /* istanbul ignore next */ []);
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
label
|
|
1250
|
-
|
|
1069
|
+
fieldsLabel = computed(() => this.resolvedItems().some((item) => item.kind === "field" && isTextStyleMarkType(item.id)) ? this.text().toolbarStyleFields : this.text().toolbarFields, ...ngDevMode ? [{ debugName: "fieldsLabel" }] : /* istanbul ignore next */ []);
|
|
1070
|
+
actions = computed(() => this.resolvedItems().filter((item) => item.kind !== "field"), ...ngDevMode ? [{ debugName: "actions" }] : /* istanbul ignore next */ []);
|
|
1071
|
+
fields = computed(() => this.resolvedItems().filter((item) => item.kind === "field").map((item) => {
|
|
1072
|
+
const label = toolbarItemLabel(item, this.text());
|
|
1073
|
+
if (!isTextStyleMarkType(item.id)) return {
|
|
1074
|
+
...item,
|
|
1075
|
+
id: item.id,
|
|
1076
|
+
label,
|
|
1077
|
+
control: "existing"
|
|
1078
|
+
};
|
|
1079
|
+
const state = this.editor().state();
|
|
1080
|
+
const value = state ? selectedTextStyle(state, item.id) : void 0;
|
|
1081
|
+
const disabled = item.disabled === true || this.stylesDisabled();
|
|
1082
|
+
if (item.id === "color" || item.id === "backgroundColor") return {
|
|
1083
|
+
...item,
|
|
1084
|
+
id: item.id,
|
|
1085
|
+
label,
|
|
1086
|
+
disabled,
|
|
1087
|
+
control: "color",
|
|
1088
|
+
colorValue: value ?? COLOR_DEFAULTS[item.id]
|
|
1089
|
+
};
|
|
1090
|
+
const options = STYLE_OPTIONS[item.id];
|
|
1091
|
+
return {
|
|
1092
|
+
...item,
|
|
1093
|
+
id: item.id,
|
|
1094
|
+
label,
|
|
1095
|
+
disabled,
|
|
1096
|
+
value,
|
|
1097
|
+
control: "select",
|
|
1098
|
+
options: value && !options.includes(value) ? [value, ...options] : options
|
|
1099
|
+
};
|
|
1100
|
+
}), ...ngDevMode ? [{ debugName: "fields" }] : /* istanbul ignore next */ []);
|
|
1101
|
+
stylesDisabled = computed(() => {
|
|
1102
|
+
this.refreshKey();
|
|
1103
|
+
this.refreshVersion();
|
|
1104
|
+
const editor = this.editor();
|
|
1105
|
+
editor.state();
|
|
1106
|
+
return this.blocked() || !editor.can({
|
|
1107
|
+
type: "setMark",
|
|
1108
|
+
mark: {
|
|
1109
|
+
type: "fontSize",
|
|
1110
|
+
value: "16px"
|
|
1111
|
+
}
|
|
1112
|
+
});
|
|
1113
|
+
}, ...ngDevMode ? [{ debugName: "stylesDisabled" }] : /* istanbul ignore next */ []);
|
|
1251
1114
|
queries = computed(() => toolbarActionQueries(this.resolvedItems()), {
|
|
1252
1115
|
...ngDevMode ? { debugName: "queries" } : /* istanbul ignore next */ {},
|
|
1253
1116
|
equal: sameToolbarActionQueries
|
|
@@ -1289,11 +1152,23 @@ var RichTextToolbarComponent = class RichTextToolbarComponent {
|
|
|
1289
1152
|
const messages = this.text();
|
|
1290
1153
|
const iconOnly = this.iconOnly();
|
|
1291
1154
|
return this.actions().flatMap((action) => {
|
|
1155
|
+
const content = toolbarButtonContent(action, messages, iconOnly);
|
|
1156
|
+
if (action.kind === "menu") {
|
|
1157
|
+
const disabled = action.disabled === true || this.blocked() || !action.groups.some(({ items }) => items.some((command) => !command.disabled));
|
|
1158
|
+
return [{
|
|
1159
|
+
...content,
|
|
1160
|
+
kind: "menu",
|
|
1161
|
+
id: action.id,
|
|
1162
|
+
disabled,
|
|
1163
|
+
menu: action
|
|
1164
|
+
}];
|
|
1165
|
+
}
|
|
1292
1166
|
const capability = capabilities.get(action.id);
|
|
1293
1167
|
if (!capability) return [];
|
|
1294
1168
|
return [{
|
|
1295
1169
|
...capability,
|
|
1296
|
-
...
|
|
1170
|
+
...content,
|
|
1171
|
+
kind: "command"
|
|
1297
1172
|
}];
|
|
1298
1173
|
});
|
|
1299
1174
|
}, ...ngDevMode ? [{ debugName: "buttons" }] : /* istanbul ignore next */ []);
|
|
@@ -1428,11 +1303,33 @@ var RichTextToolbarComponent = class RichTextToolbarComponent {
|
|
|
1428
1303
|
const result = this.editor().execute(button.command);
|
|
1429
1304
|
this.announce(result && !result.ok ? "actionUnavailable" : button.id === "undo" ? "undoDone" : button.id === "redo" ? "redoDone" : "formatDone");
|
|
1430
1305
|
}
|
|
1306
|
+
executeMenuCommand(command) {
|
|
1307
|
+
if (this.blocked()) return;
|
|
1308
|
+
const result = this.editor().execute(command);
|
|
1309
|
+
this.announce(result?.ok ? "formatDone" : "actionUnavailable");
|
|
1310
|
+
}
|
|
1431
1311
|
changeHeadingLevel(event) {
|
|
1432
1312
|
if (!(event.target instanceof HTMLSelectElement)) return;
|
|
1433
1313
|
const level = Number(event.target.value);
|
|
1434
1314
|
if (isToolbarHeadingLevel(level)) this.headingLevel.set(level);
|
|
1435
1315
|
}
|
|
1316
|
+
changeStyle(markType, rawValue) {
|
|
1317
|
+
const configured = this.resolvedItems().find((item) => item.kind === "field" && item.id === markType);
|
|
1318
|
+
if (!configured || configured.disabled || this.stylesDisabled()) return;
|
|
1319
|
+
const value = normalizeTextStyleValue(markType, rawValue);
|
|
1320
|
+
if (rawValue && value === void 0) return;
|
|
1321
|
+
const result = this.editor().execute(value === void 0 ? {
|
|
1322
|
+
type: "unsetMark",
|
|
1323
|
+
markType
|
|
1324
|
+
} : {
|
|
1325
|
+
type: "setMark",
|
|
1326
|
+
mark: {
|
|
1327
|
+
type: markType,
|
|
1328
|
+
value
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1331
|
+
this.announce(result?.ok ? "formatDone" : "actionUnavailable");
|
|
1332
|
+
}
|
|
1436
1333
|
changeLink(value) {
|
|
1437
1334
|
this.linkDirty.set(true);
|
|
1438
1335
|
this.linkHref.set(value);
|
|
@@ -1465,7 +1362,7 @@ var RichTextToolbarComponent = class RichTextToolbarComponent {
|
|
|
1465
1362
|
if (id) this.currentAction.set(id);
|
|
1466
1363
|
}
|
|
1467
1364
|
navigate(event) {
|
|
1468
|
-
if (event.isComposing || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || !(event.target instanceof HTMLButtonElement)) return;
|
|
1365
|
+
if (event.isComposing || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || !(event.target instanceof HTMLButtonElement) || !event.target.hasAttribute("data-richtext-action")) return;
|
|
1469
1366
|
const key = event.key;
|
|
1470
1367
|
if (key !== "ArrowLeft" && key !== "ArrowRight" && key !== "Home" && key !== "End") return;
|
|
1471
1368
|
const id = nextToolbarItem(this.buttons(), event.target.getAttribute("data-richtext-action") ?? void 0, key);
|
|
@@ -1558,8 +1455,8 @@ var RichTextToolbarComponent = class RichTextToolbarComponent {
|
|
|
1558
1455
|
isSignal: true
|
|
1559
1456
|
}],
|
|
1560
1457
|
ngImport: i0,
|
|
1561
|
-
template: "<div class=\"kles-richtext-toolbar\" (focusin)=\"rememberFocus($event)\">\n @if (hasItems()) {\n @if (buttons().length) {\n <div\n #commands\n class=\"kles-richtext-toolbar__commands\"\n role=\"toolbar\"\n [attr.aria-label]=\"label()\"\n [attr.aria-disabled]=\"blocked()\"\n [attr.aria-busy]=\"editor().composing()\"\n (keydown)=\"navigate($event)\"\n >\n @for (button of buttons(); track button.id) {\n <button\n type=\"button\"\n [attr.data-richtext-action]=\"button.id\"\n [class.kles-richtext-toolbar__button-with-icon]=\"!buttonTemplate() && !!button.icon\"\n [disabled]=\"button.disabled\"\n [attr.aria-label]=\"button.ariaLabel\"\n [attr.title]=\"button.label ? null : button.ariaLabel\"\n [attr.aria-pressed]=\"button.pressed ?? null\"\n [tabIndex]=\"tabStop() === button.id ? 0 : -1\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"execute(button)\"\n >\n @if (buttonTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{ $implicit: button, item: button }\"\n />\n } @else {\n @if (button.iconType === 'material') {\n <span\n class=\"kles-richtext-toolbar__material-icon\"\n [attr.data-material-icon]=\"button.icon\"\n aria-hidden=\"true\"\n ></span>\n } @else if (button.icon) {\n <span aria-hidden=\"true\">{{ button.icon }}</span>\n }\n {{ button.label }}\n }\n </button>\n }\n </div>\n }\n @if (fields().length) {\n <div class=\"kles-richtext-toolbar__fields\" role=\"group\" [attr.aria-label]=\"text().toolbarFields\">\n @for (field of fields(); track field.id) {\n @if (field.id === 'headingLevel') {\n <label class=\"kles-richtext-toolbar__level\" data-richtext-field=\"headingLevel\">\n {{ field.label }}\n <select\n [attr.aria-label]=\"field.ariaLabel?.trim() || text().headingLevelLabel\"\n [disabled]=\"headingDisabled()\"\n (change)=\"changeHeadingLevel($event)\"\n >\n @for (level of headingLevels; track level) {\n <option [value]=\"level\" [selected]=\"level === headingLevel()\">{{ level }}</option>\n }\n </select>\n </label>\n } @else {\n <label class=\"kles-richtext-toolbar__link\" data-richtext-field=\"link\">\n {{ field.label }}\n <input\n #linkInput\n type=\"text\"\n inputmode=\"url\"\n [disabled]=\"linksDisabled()\"\n [value]=\"linkHref()\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n [attr.aria-invalid]=\"linkInvalid() ? 'true' : null\"\n [attr.aria-describedby]=\"linkInvalid() ? linkErrorId : null\"\n (input)=\"changeLink(linkInput.value)\"\n (keydown.enter)=\"applyLink($event)\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n </label>\n <button\n type=\"button\"\n data-richtext-field=\"link\"\n [class.kles-richtext-toolbar__button-with-icon]=\"iconOnly()\"\n [disabled]=\"applyLinkDisabled()\"\n [attr.aria-label]=\"iconOnly() ? text().applyLink : null\"\n [attr.title]=\"iconOnly() ? text().applyLink : null\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"applyLink()\"\n >\n @if (iconOnly()) {\n <span\n class=\"kles-richtext-toolbar__material-icon\"\n data-material-icon=\"link\"\n aria-hidden=\"true\"\n ></span>\n } @else {\n {{ text().applyLink }}\n }\n </button>\n <button\n type=\"button\"\n data-richtext-field=\"link\"\n [class.kles-richtext-toolbar__button-with-icon]=\"iconOnly()\"\n [disabled]=\"removeLinkDisabled()\"\n [attr.aria-label]=\"iconOnly() ? text().removeLink : null\"\n [attr.title]=\"iconOnly() ? text().removeLink : null\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"removeLink()\"\n >\n @if (iconOnly()) {\n <span\n class=\"kles-richtext-toolbar__material-icon\"\n data-material-icon=\"link_off\"\n aria-hidden=\"true\"\n ></span>\n } @else {\n {{ text().removeLink }}\n }\n </button>\n }\n }\n </div>\n }\n @if (linkInvalid()) {\n <p [id]=\"linkErrorId\" class=\"kles-richtext-toolbar__error\">{{ text().invalidLink }}</p>\n }\n <p class=\"kles-richtext-toolbar__status\" role=\"status\" aria-live=\"polite\">{{ status() }}</p>\n }\n</div>\n",
|
|
1562
|
-
styles: [":host{display:block;min-width:0;max-width:100%}.kles-richtext-toolbar{margin-block-end:1rem;color:inherit}.kles-richtext-toolbar__commands,.kles-richtext-toolbar__fields{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem}.kles-richtext-toolbar__fields{align-items:flex-end;margin-block-start:.75rem}.kles-richtext-toolbar__level,.kles-richtext-toolbar__link{display:flex;flex-direction:column;gap:.35rem;margin:0;font-weight:600;min-width:0}.kles-richtext-toolbar__link{flex:1 1 14rem;max-width:28rem}.kles-richtext-toolbar button,.kles-richtext-toolbar input,.kles-richtext-toolbar select{box-sizing:border-box;font:inherit;min-height:2.75rem;max-width:100%;padding:.5rem .7rem;border:1px solid var(--kles-richtext-toolbar-accent, var(--accent, #174f89));border-radius:var(--kles-richtext-toolbar-radius, .5rem);background:var(--kles-richtext-toolbar-background, var(--surface, #fff));color:var(--kles-richtext-toolbar-accent, var(--accent, #174f89))}.kles-richtext-toolbar input{min-width:0;width:100%;color:inherit}.kles-richtext-toolbar button{cursor:pointer;overflow-wrap:anywhere}.kles-richtext-toolbar button.kles-richtext-toolbar__button-with-icon{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;min-inline-size:2.75rem}.kles-richtext-toolbar__material-icon{font-family:var(--kles-richtext-toolbar-material-icon-font, \"Material Icons\");font-feature-settings:\"liga\";font-style:normal;font-weight:400;font-size:1.5rem;line-height:1;letter-spacing:normal;text-transform:none;white-space:nowrap;direction:ltr}.kles-richtext-toolbar__material-icon:before{content:attr(data-material-icon)}.kles-richtext-toolbar button:hover:enabled{text-decoration:underline}.kles-richtext-toolbar button[aria-pressed=true]{background:var(--kles-richtext-toolbar-accent, var(--accent, #174f89));color:var(--kles-richtext-toolbar-background, var(--surface, #fff))}.kles-richtext-toolbar :is(button,input,select):disabled{opacity:.5;cursor:not-allowed}.kles-richtext-toolbar :is(button,input,select):focus-visible{outline:3px solid var(--kles-richtext-toolbar-focus, var(--accent, #174f89));outline-offset:3px}.kles-richtext-toolbar input[aria-invalid=true]{border-color:var(--kles-richtext-toolbar-error, var(--error, #9e2020))}.kles-richtext-toolbar__status{margin:.5rem 0 0;font-size:.9rem;line-height:1.5}.kles-richtext-toolbar__status:empty{margin:0}.kles-richtext-toolbar__error{color:var(--kles-richtext-toolbar-error, var(--error, #9e2020));margin:.5rem 0 0;line-height:1.5}\n"],
|
|
1458
|
+
template: "<div class=\"kles-richtext-toolbar\" (focusin)=\"rememberFocus($event)\">\n @if (hasItems()) {\n @if (buttons().length) {\n <div\n #commands\n class=\"kles-richtext-toolbar__commands\"\n role=\"toolbar\"\n [attr.aria-label]=\"label()\"\n [attr.aria-disabled]=\"blocked()\"\n [attr.aria-busy]=\"editor().composing()\"\n (keydown)=\"navigate($event)\"\n >\n @for (button of buttons(); track button.id) {\n @if (button.kind === 'menu') {\n @defer (on immediate) {\n <kles-richtext-toolbar-menu\n [button]=\"button\"\n [groups]=\"button.menu.groups\"\n [tabStop]=\"tabStop() === button.id ? 0 : -1\"\n [messages]=\"text()\"\n (command)=\"executeMenuCommand($event)\"\n />\n }\n } @else {\n <button\n type=\"button\"\n [attr.data-richtext-action]=\"button.id\"\n [class.kles-richtext-toolbar__button-with-icon]=\"!buttonTemplate() && !!button.icon\"\n [disabled]=\"button.disabled\"\n [attr.aria-label]=\"button.ariaLabel\"\n [attr.title]=\"button.label ? null : button.ariaLabel\"\n [attr.aria-pressed]=\"button.pressed ?? null\"\n [tabIndex]=\"tabStop() === button.id ? 0 : -1\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"execute(button)\"\n >\n @if (buttonTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{ $implicit: button, item: button }\"\n />\n } @else {\n @if (button.iconType === 'material') {\n <span\n class=\"kles-richtext-toolbar__material-icon\"\n [attr.data-material-icon]=\"button.icon\"\n aria-hidden=\"true\"\n ></span>\n } @else if (button.icon) {\n <span aria-hidden=\"true\">{{ button.icon }}</span>\n }\n {{ button.label }}\n }\n </button>\n }\n }\n </div>\n }\n @if (fields().length) {\n <div class=\"kles-richtext-toolbar__fields\" role=\"group\" [attr.aria-label]=\"fieldsLabel()\">\n @for (field of fields(); track field.id) {\n @if (field.id === 'headingLevel') {\n <label class=\"kles-richtext-toolbar__level\" data-richtext-field=\"headingLevel\">\n {{ field.label }}\n <select\n [attr.aria-label]=\"field.ariaLabel?.trim() || text().headingLevelLabel\"\n [disabled]=\"headingDisabled()\"\n (change)=\"changeHeadingLevel($event)\"\n >\n @for (level of headingLevels; track level) {\n <option [value]=\"level\" [selected]=\"level === headingLevel()\">{{ level }}</option>\n }\n </select>\n </label>\n } @else if (field.id === 'link') {\n <label class=\"kles-richtext-toolbar__link\" data-richtext-field=\"link\">\n {{ field.label }}\n <input\n #linkInput\n type=\"text\"\n inputmode=\"url\"\n [disabled]=\"linksDisabled()\"\n [value]=\"linkHref()\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n [attr.aria-invalid]=\"linkInvalid() ? 'true' : null\"\n [attr.aria-describedby]=\"linkInvalid() ? linkErrorId : null\"\n (input)=\"changeLink(linkInput.value)\"\n (keydown.enter)=\"applyLink($event)\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n </label>\n <button\n type=\"button\"\n data-richtext-field=\"link\"\n [class.kles-richtext-toolbar__button-with-icon]=\"iconOnly()\"\n [disabled]=\"applyLinkDisabled()\"\n [attr.aria-label]=\"iconOnly() ? text().applyLink : null\"\n [attr.title]=\"iconOnly() ? text().applyLink : null\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"applyLink()\"\n >\n @if (iconOnly()) {\n <span\n class=\"kles-richtext-toolbar__material-icon\"\n data-material-icon=\"link\"\n aria-hidden=\"true\"\n ></span>\n } @else {\n {{ text().applyLink }}\n }\n </button>\n <button\n type=\"button\"\n data-richtext-field=\"link\"\n [class.kles-richtext-toolbar__button-with-icon]=\"iconOnly()\"\n [disabled]=\"removeLinkDisabled()\"\n [attr.aria-label]=\"iconOnly() ? text().removeLink : null\"\n [attr.title]=\"iconOnly() ? text().removeLink : null\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"removeLink()\"\n >\n @if (iconOnly()) {\n <span\n class=\"kles-richtext-toolbar__material-icon\"\n data-material-icon=\"link_off\"\n aria-hidden=\"true\"\n ></span>\n } @else {\n {{ text().removeLink }}\n }\n </button>\n } @else if (field.control === 'color') {\n <div class=\"kles-richtext-toolbar__color\">\n <label class=\"kles-richtext-toolbar__level\" [attr.data-richtext-field]=\"field.id\">\n {{ field.label }}\n <input\n #colorInput\n type=\"color\"\n [value]=\"field.colorValue\"\n [disabled]=\"field.disabled\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n (change)=\"changeStyle(field.id, colorInput.value)\"\n />\n </label>\n <button\n type=\"button\"\n [disabled]=\"field.disabled\"\n [attr.aria-label]=\"\n field.id === 'color' ? text().resetColor : text().resetBackgroundColor\n \"\n [attr.title]=\"field.id === 'color' ? text().resetColor : text().resetBackgroundColor\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"changeStyle(field.id, '')\"\n >\n <span aria-hidden=\"true\">×</span>\n </button>\n </div>\n } @else if (field.control === 'select') {\n <label class=\"kles-richtext-toolbar__level\" [attr.data-richtext-field]=\"field.id\">\n {{ field.label }}\n <select\n #styleSelect\n [disabled]=\"field.disabled\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n (change)=\"changeStyle(field.id, styleSelect.value)\"\n >\n @if (field.value === null) {\n <option disabled selected>{{ text().mixedStyles }}</option>\n }\n <option value=\"\" [selected]=\"field.value === undefined\">\n {{ text().defaultStyle }}\n </option>\n @for (value of field.options; track value) {\n <option [value]=\"value\" [selected]=\"field.value === value\">{{ value }}</option>\n }\n </select>\n </label>\n }\n }\n </div>\n }\n @if (linkInvalid()) {\n <p [id]=\"linkErrorId\" class=\"kles-richtext-toolbar__error\">{{ text().invalidLink }}</p>\n }\n <p class=\"kles-richtext-toolbar__status\" role=\"status\" aria-live=\"polite\">{{ status() }}</p>\n }\n</div>\n",
|
|
1459
|
+
styles: [":host{display:block;min-width:0;max-width:100%}.kles-richtext-toolbar{margin-block-end:1rem;color:inherit}.kles-richtext-toolbar__commands,.kles-richtext-toolbar__fields{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem}.kles-richtext-toolbar__fields{align-items:flex-end;margin-block-start:.75rem}.kles-richtext-toolbar__level,.kles-richtext-toolbar__link{display:flex;flex-direction:column;gap:.35rem;margin:0;font-weight:600;min-width:0}.kles-richtext-toolbar__link{flex:1 1 14rem;max-width:28rem}.kles-richtext-toolbar__color{display:flex;align-items:flex-end;gap:.25rem}.kles-richtext-toolbar button,.kles-richtext-toolbar input,.kles-richtext-toolbar select{box-sizing:border-box;font:inherit;min-height:2.75rem;max-width:100%;padding:.5rem .7rem;border:1px solid var(--kles-richtext-toolbar-accent, var(--accent, #174f89));border-radius:var(--kles-richtext-toolbar-radius, .5rem);background:var(--kles-richtext-toolbar-background, var(--surface, #fff));color:var(--kles-richtext-toolbar-accent, var(--accent, #174f89))}.kles-richtext-toolbar input{min-width:0;width:100%;color:inherit}.kles-richtext-toolbar input[type=color]{cursor:pointer;padding:.25rem;min-inline-size:2.75rem}.kles-richtext-toolbar button{cursor:pointer;overflow-wrap:anywhere}.kles-richtext-toolbar button.kles-richtext-toolbar__button-with-icon{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;min-inline-size:2.75rem}.kles-richtext-toolbar__material-icon{font-family:var(--kles-richtext-toolbar-material-icon-font, \"Material Icons\");font-feature-settings:\"liga\";font-style:normal;font-weight:400;font-size:1.5rem;line-height:1;letter-spacing:normal;text-transform:none;white-space:nowrap;direction:ltr}.kles-richtext-toolbar__material-icon:before{content:attr(data-material-icon)}.kles-richtext-toolbar button:hover:enabled{text-decoration:underline}.kles-richtext-toolbar button[aria-pressed=true]{background:var(--kles-richtext-toolbar-accent, var(--accent, #174f89));color:var(--kles-richtext-toolbar-background, var(--surface, #fff))}.kles-richtext-toolbar :is(button,input,select):disabled{opacity:.5;cursor:not-allowed}.kles-richtext-toolbar :is(button,input,select):focus-visible{outline:3px solid var(--kles-richtext-toolbar-focus, var(--accent, #174f89));outline-offset:3px}.kles-richtext-toolbar input[aria-invalid=true]{border-color:var(--kles-richtext-toolbar-error, var(--error, #9e2020))}.kles-richtext-toolbar__status{margin:.5rem 0 0;font-size:.9rem;line-height:1.5}.kles-richtext-toolbar__status:empty{margin:0}.kles-richtext-toolbar__error{color:var(--kles-richtext-toolbar-error, var(--error, #9e2020));margin:.5rem 0 0;line-height:1.5}\n"],
|
|
1563
1460
|
dependencies: [{
|
|
1564
1461
|
kind: "directive",
|
|
1565
1462
|
type: NgTemplateOutlet,
|
|
@@ -1570,97 +1467,101 @@ var RichTextToolbarComponent = class RichTextToolbarComponent {
|
|
|
1570
1467
|
"ngTemplateOutletInjector"
|
|
1571
1468
|
]
|
|
1572
1469
|
}],
|
|
1573
|
-
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
1470
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
1471
|
+
deferBlockDependencies: [() => [import("./3kles-kles-richtext-editor-richtext-toolbar-menu.component-Dq2K0CY3.mjs").then((m) => m.RichTextToolbarMenuComponent)]]
|
|
1574
1472
|
});
|
|
1575
1473
|
};
|
|
1576
|
-
i0.ɵɵ
|
|
1577
|
-
minVersion: "
|
|
1474
|
+
i0.ɵɵngDeclareClassMetadataAsync({
|
|
1475
|
+
minVersion: "18.0.0",
|
|
1578
1476
|
version: "22.2.6",
|
|
1579
1477
|
ngImport: i0,
|
|
1580
1478
|
type: RichTextToolbarComponent,
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
standalone: true,
|
|
1586
|
-
imports: [NgTemplateOutlet],
|
|
1587
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1588
|
-
template: "<div class=\"kles-richtext-toolbar\" (focusin)=\"rememberFocus($event)\">\n @if (hasItems()) {\n @if (buttons().length) {\n <div\n #commands\n class=\"kles-richtext-toolbar__commands\"\n role=\"toolbar\"\n [attr.aria-label]=\"label()\"\n [attr.aria-disabled]=\"blocked()\"\n [attr.aria-busy]=\"editor().composing()\"\n (keydown)=\"navigate($event)\"\n >\n @for (button of buttons(); track button.id) {\n <button\n type=\"button\"\n [attr.data-richtext-action]=\"button.id\"\n [class.kles-richtext-toolbar__button-with-icon]=\"!buttonTemplate() && !!button.icon\"\n [disabled]=\"button.disabled\"\n [attr.aria-label]=\"button.ariaLabel\"\n [attr.title]=\"button.label ? null : button.ariaLabel\"\n [attr.aria-pressed]=\"button.pressed ?? null\"\n [tabIndex]=\"tabStop() === button.id ? 0 : -1\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"execute(button)\"\n >\n @if (buttonTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{ $implicit: button, item: button }\"\n />\n } @else {\n @if (button.iconType === 'material') {\n <span\n class=\"kles-richtext-toolbar__material-icon\"\n [attr.data-material-icon]=\"button.icon\"\n aria-hidden=\"true\"\n ></span>\n } @else if (button.icon) {\n <span aria-hidden=\"true\">{{ button.icon }}</span>\n }\n {{ button.label }}\n }\n </button>\n }\n </div>\n }\n @if (fields().length) {\n <div class=\"kles-richtext-toolbar__fields\" role=\"group\" [attr.aria-label]=\"text().toolbarFields\">\n @for (field of fields(); track field.id) {\n @if (field.id === 'headingLevel') {\n <label class=\"kles-richtext-toolbar__level\" data-richtext-field=\"headingLevel\">\n {{ field.label }}\n <select\n [attr.aria-label]=\"field.ariaLabel?.trim() || text().headingLevelLabel\"\n [disabled]=\"headingDisabled()\"\n (change)=\"changeHeadingLevel($event)\"\n >\n @for (level of headingLevels; track level) {\n <option [value]=\"level\" [selected]=\"level === headingLevel()\">{{ level }}</option>\n }\n </select>\n </label>\n } @else {\n <label class=\"kles-richtext-toolbar__link\" data-richtext-field=\"link\">\n {{ field.label }}\n <input\n #linkInput\n type=\"text\"\n inputmode=\"url\"\n [disabled]=\"linksDisabled()\"\n [value]=\"linkHref()\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n [attr.aria-invalid]=\"linkInvalid() ? 'true' : null\"\n [attr.aria-describedby]=\"linkInvalid() ? linkErrorId : null\"\n (input)=\"changeLink(linkInput.value)\"\n (keydown.enter)=\"applyLink($event)\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n </label>\n <button\n type=\"button\"\n data-richtext-field=\"link\"\n [class.kles-richtext-toolbar__button-with-icon]=\"iconOnly()\"\n [disabled]=\"applyLinkDisabled()\"\n [attr.aria-label]=\"iconOnly() ? text().applyLink : null\"\n [attr.title]=\"iconOnly() ? text().applyLink : null\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"applyLink()\"\n >\n @if (iconOnly()) {\n <span\n class=\"kles-richtext-toolbar__material-icon\"\n data-material-icon=\"link\"\n aria-hidden=\"true\"\n ></span>\n } @else {\n {{ text().applyLink }}\n }\n </button>\n <button\n type=\"button\"\n data-richtext-field=\"link\"\n [class.kles-richtext-toolbar__button-with-icon]=\"iconOnly()\"\n [disabled]=\"removeLinkDisabled()\"\n [attr.aria-label]=\"iconOnly() ? text().removeLink : null\"\n [attr.title]=\"iconOnly() ? text().removeLink : null\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"removeLink()\"\n >\n @if (iconOnly()) {\n <span\n class=\"kles-richtext-toolbar__material-icon\"\n data-material-icon=\"link_off\"\n aria-hidden=\"true\"\n ></span>\n } @else {\n {{ text().removeLink }}\n }\n </button>\n }\n }\n </div>\n }\n @if (linkInvalid()) {\n <p [id]=\"linkErrorId\" class=\"kles-richtext-toolbar__error\">{{ text().invalidLink }}</p>\n }\n <p class=\"kles-richtext-toolbar__status\" role=\"status\" aria-live=\"polite\">{{ status() }}</p>\n }\n</div>\n",
|
|
1589
|
-
styles: [":host{display:block;min-width:0;max-width:100%}.kles-richtext-toolbar{margin-block-end:1rem;color:inherit}.kles-richtext-toolbar__commands,.kles-richtext-toolbar__fields{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem}.kles-richtext-toolbar__fields{align-items:flex-end;margin-block-start:.75rem}.kles-richtext-toolbar__level,.kles-richtext-toolbar__link{display:flex;flex-direction:column;gap:.35rem;margin:0;font-weight:600;min-width:0}.kles-richtext-toolbar__link{flex:1 1 14rem;max-width:28rem}.kles-richtext-toolbar button,.kles-richtext-toolbar input,.kles-richtext-toolbar select{box-sizing:border-box;font:inherit;min-height:2.75rem;max-width:100%;padding:.5rem .7rem;border:1px solid var(--kles-richtext-toolbar-accent, var(--accent, #174f89));border-radius:var(--kles-richtext-toolbar-radius, .5rem);background:var(--kles-richtext-toolbar-background, var(--surface, #fff));color:var(--kles-richtext-toolbar-accent, var(--accent, #174f89))}.kles-richtext-toolbar input{min-width:0;width:100%;color:inherit}.kles-richtext-toolbar button{cursor:pointer;overflow-wrap:anywhere}.kles-richtext-toolbar button.kles-richtext-toolbar__button-with-icon{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;min-inline-size:2.75rem}.kles-richtext-toolbar__material-icon{font-family:var(--kles-richtext-toolbar-material-icon-font, \"Material Icons\");font-feature-settings:\"liga\";font-style:normal;font-weight:400;font-size:1.5rem;line-height:1;letter-spacing:normal;text-transform:none;white-space:nowrap;direction:ltr}.kles-richtext-toolbar__material-icon:before{content:attr(data-material-icon)}.kles-richtext-toolbar button:hover:enabled{text-decoration:underline}.kles-richtext-toolbar button[aria-pressed=true]{background:var(--kles-richtext-toolbar-accent, var(--accent, #174f89));color:var(--kles-richtext-toolbar-background, var(--surface, #fff))}.kles-richtext-toolbar :is(button,input,select):disabled{opacity:.5;cursor:not-allowed}.kles-richtext-toolbar :is(button,input,select):focus-visible{outline:3px solid var(--kles-richtext-toolbar-focus, var(--accent, #174f89));outline-offset:3px}.kles-richtext-toolbar input[aria-invalid=true]{border-color:var(--kles-richtext-toolbar-error, var(--error, #9e2020))}.kles-richtext-toolbar__status{margin:.5rem 0 0;font-size:.9rem;line-height:1.5}.kles-richtext-toolbar__status:empty{margin:0}.kles-richtext-toolbar__error{color:var(--kles-richtext-toolbar-error, var(--error, #9e2020));margin:.5rem 0 0;line-height:1.5}\n"]
|
|
1590
|
-
}]
|
|
1591
|
-
}],
|
|
1592
|
-
ctorParameters: () => [],
|
|
1593
|
-
propDecorators: {
|
|
1594
|
-
editor: [{
|
|
1595
|
-
type: i0.Input,
|
|
1596
|
-
args: [{
|
|
1597
|
-
isSignal: true,
|
|
1598
|
-
alias: "editor",
|
|
1599
|
-
required: true
|
|
1600
|
-
}]
|
|
1601
|
-
}],
|
|
1602
|
-
labelOverride: [{
|
|
1603
|
-
type: i0.Input,
|
|
1604
|
-
args: [{
|
|
1605
|
-
isSignal: true,
|
|
1606
|
-
alias: "label",
|
|
1607
|
-
required: false
|
|
1608
|
-
}]
|
|
1609
|
-
}],
|
|
1610
|
-
locale: [{
|
|
1611
|
-
type: i0.Input,
|
|
1612
|
-
args: [{
|
|
1613
|
-
isSignal: true,
|
|
1614
|
-
alias: "locale",
|
|
1615
|
-
required: false
|
|
1616
|
-
}]
|
|
1617
|
-
}],
|
|
1618
|
-
messages: [{
|
|
1619
|
-
type: i0.Input,
|
|
1479
|
+
resolveDeferredDeps: () => [import("./3kles-kles-richtext-editor-richtext-toolbar-menu.component-Dq2K0CY3.mjs").then((m) => m.RichTextToolbarMenuComponent)],
|
|
1480
|
+
resolveMetadata: (RichTextToolbarMenuComponent) => ({
|
|
1481
|
+
decorators: [{
|
|
1482
|
+
type: Component,
|
|
1620
1483
|
args: [{
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1484
|
+
selector: "kles-richtext-toolbar",
|
|
1485
|
+
standalone: true,
|
|
1486
|
+
imports: [NgTemplateOutlet, RichTextToolbarMenuComponent],
|
|
1487
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1488
|
+
template: "<div class=\"kles-richtext-toolbar\" (focusin)=\"rememberFocus($event)\">\n @if (hasItems()) {\n @if (buttons().length) {\n <div\n #commands\n class=\"kles-richtext-toolbar__commands\"\n role=\"toolbar\"\n [attr.aria-label]=\"label()\"\n [attr.aria-disabled]=\"blocked()\"\n [attr.aria-busy]=\"editor().composing()\"\n (keydown)=\"navigate($event)\"\n >\n @for (button of buttons(); track button.id) {\n @if (button.kind === 'menu') {\n @defer (on immediate) {\n <kles-richtext-toolbar-menu\n [button]=\"button\"\n [groups]=\"button.menu.groups\"\n [tabStop]=\"tabStop() === button.id ? 0 : -1\"\n [messages]=\"text()\"\n (command)=\"executeMenuCommand($event)\"\n />\n }\n } @else {\n <button\n type=\"button\"\n [attr.data-richtext-action]=\"button.id\"\n [class.kles-richtext-toolbar__button-with-icon]=\"!buttonTemplate() && !!button.icon\"\n [disabled]=\"button.disabled\"\n [attr.aria-label]=\"button.ariaLabel\"\n [attr.title]=\"button.label ? null : button.ariaLabel\"\n [attr.aria-pressed]=\"button.pressed ?? null\"\n [tabIndex]=\"tabStop() === button.id ? 0 : -1\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"execute(button)\"\n >\n @if (buttonTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{ $implicit: button, item: button }\"\n />\n } @else {\n @if (button.iconType === 'material') {\n <span\n class=\"kles-richtext-toolbar__material-icon\"\n [attr.data-material-icon]=\"button.icon\"\n aria-hidden=\"true\"\n ></span>\n } @else if (button.icon) {\n <span aria-hidden=\"true\">{{ button.icon }}</span>\n }\n {{ button.label }}\n }\n </button>\n }\n }\n </div>\n }\n @if (fields().length) {\n <div class=\"kles-richtext-toolbar__fields\" role=\"group\" [attr.aria-label]=\"fieldsLabel()\">\n @for (field of fields(); track field.id) {\n @if (field.id === 'headingLevel') {\n <label class=\"kles-richtext-toolbar__level\" data-richtext-field=\"headingLevel\">\n {{ field.label }}\n <select\n [attr.aria-label]=\"field.ariaLabel?.trim() || text().headingLevelLabel\"\n [disabled]=\"headingDisabled()\"\n (change)=\"changeHeadingLevel($event)\"\n >\n @for (level of headingLevels; track level) {\n <option [value]=\"level\" [selected]=\"level === headingLevel()\">{{ level }}</option>\n }\n </select>\n </label>\n } @else if (field.id === 'link') {\n <label class=\"kles-richtext-toolbar__link\" data-richtext-field=\"link\">\n {{ field.label }}\n <input\n #linkInput\n type=\"text\"\n inputmode=\"url\"\n [disabled]=\"linksDisabled()\"\n [value]=\"linkHref()\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n [attr.aria-invalid]=\"linkInvalid() ? 'true' : null\"\n [attr.aria-describedby]=\"linkInvalid() ? linkErrorId : null\"\n (input)=\"changeLink(linkInput.value)\"\n (keydown.enter)=\"applyLink($event)\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n </label>\n <button\n type=\"button\"\n data-richtext-field=\"link\"\n [class.kles-richtext-toolbar__button-with-icon]=\"iconOnly()\"\n [disabled]=\"applyLinkDisabled()\"\n [attr.aria-label]=\"iconOnly() ? text().applyLink : null\"\n [attr.title]=\"iconOnly() ? text().applyLink : null\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"applyLink()\"\n >\n @if (iconOnly()) {\n <span\n class=\"kles-richtext-toolbar__material-icon\"\n data-material-icon=\"link\"\n aria-hidden=\"true\"\n ></span>\n } @else {\n {{ text().applyLink }}\n }\n </button>\n <button\n type=\"button\"\n data-richtext-field=\"link\"\n [class.kles-richtext-toolbar__button-with-icon]=\"iconOnly()\"\n [disabled]=\"removeLinkDisabled()\"\n [attr.aria-label]=\"iconOnly() ? text().removeLink : null\"\n [attr.title]=\"iconOnly() ? text().removeLink : null\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"removeLink()\"\n >\n @if (iconOnly()) {\n <span\n class=\"kles-richtext-toolbar__material-icon\"\n data-material-icon=\"link_off\"\n aria-hidden=\"true\"\n ></span>\n } @else {\n {{ text().removeLink }}\n }\n </button>\n } @else if (field.control === 'color') {\n <div class=\"kles-richtext-toolbar__color\">\n <label class=\"kles-richtext-toolbar__level\" [attr.data-richtext-field]=\"field.id\">\n {{ field.label }}\n <input\n #colorInput\n type=\"color\"\n [value]=\"field.colorValue\"\n [disabled]=\"field.disabled\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n (change)=\"changeStyle(field.id, colorInput.value)\"\n />\n </label>\n <button\n type=\"button\"\n [disabled]=\"field.disabled\"\n [attr.aria-label]=\"\n field.id === 'color' ? text().resetColor : text().resetBackgroundColor\n \"\n [attr.title]=\"field.id === 'color' ? text().resetColor : text().resetBackgroundColor\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"changeStyle(field.id, '')\"\n >\n <span aria-hidden=\"true\">×</span>\n </button>\n </div>\n } @else if (field.control === 'select') {\n <label class=\"kles-richtext-toolbar__level\" [attr.data-richtext-field]=\"field.id\">\n {{ field.label }}\n <select\n #styleSelect\n [disabled]=\"field.disabled\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n (change)=\"changeStyle(field.id, styleSelect.value)\"\n >\n @if (field.value === null) {\n <option disabled selected>{{ text().mixedStyles }}</option>\n }\n <option value=\"\" [selected]=\"field.value === undefined\">\n {{ text().defaultStyle }}\n </option>\n @for (value of field.options; track value) {\n <option [value]=\"value\" [selected]=\"field.value === value\">{{ value }}</option>\n }\n </select>\n </label>\n }\n }\n </div>\n }\n @if (linkInvalid()) {\n <p [id]=\"linkErrorId\" class=\"kles-richtext-toolbar__error\">{{ text().invalidLink }}</p>\n }\n <p class=\"kles-richtext-toolbar__status\" role=\"status\" aria-live=\"polite\">{{ status() }}</p>\n }\n</div>\n",
|
|
1489
|
+
styles: [":host{display:block;min-width:0;max-width:100%}.kles-richtext-toolbar{margin-block-end:1rem;color:inherit}.kles-richtext-toolbar__commands,.kles-richtext-toolbar__fields{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem}.kles-richtext-toolbar__fields{align-items:flex-end;margin-block-start:.75rem}.kles-richtext-toolbar__level,.kles-richtext-toolbar__link{display:flex;flex-direction:column;gap:.35rem;margin:0;font-weight:600;min-width:0}.kles-richtext-toolbar__link{flex:1 1 14rem;max-width:28rem}.kles-richtext-toolbar__color{display:flex;align-items:flex-end;gap:.25rem}.kles-richtext-toolbar button,.kles-richtext-toolbar input,.kles-richtext-toolbar select{box-sizing:border-box;font:inherit;min-height:2.75rem;max-width:100%;padding:.5rem .7rem;border:1px solid var(--kles-richtext-toolbar-accent, var(--accent, #174f89));border-radius:var(--kles-richtext-toolbar-radius, .5rem);background:var(--kles-richtext-toolbar-background, var(--surface, #fff));color:var(--kles-richtext-toolbar-accent, var(--accent, #174f89))}.kles-richtext-toolbar input{min-width:0;width:100%;color:inherit}.kles-richtext-toolbar input[type=color]{cursor:pointer;padding:.25rem;min-inline-size:2.75rem}.kles-richtext-toolbar button{cursor:pointer;overflow-wrap:anywhere}.kles-richtext-toolbar button.kles-richtext-toolbar__button-with-icon{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;min-inline-size:2.75rem}.kles-richtext-toolbar__material-icon{font-family:var(--kles-richtext-toolbar-material-icon-font, \"Material Icons\");font-feature-settings:\"liga\";font-style:normal;font-weight:400;font-size:1.5rem;line-height:1;letter-spacing:normal;text-transform:none;white-space:nowrap;direction:ltr}.kles-richtext-toolbar__material-icon:before{content:attr(data-material-icon)}.kles-richtext-toolbar button:hover:enabled{text-decoration:underline}.kles-richtext-toolbar button[aria-pressed=true]{background:var(--kles-richtext-toolbar-accent, var(--accent, #174f89));color:var(--kles-richtext-toolbar-background, var(--surface, #fff))}.kles-richtext-toolbar :is(button,input,select):disabled{opacity:.5;cursor:not-allowed}.kles-richtext-toolbar :is(button,input,select):focus-visible{outline:3px solid var(--kles-richtext-toolbar-focus, var(--accent, #174f89));outline-offset:3px}.kles-richtext-toolbar input[aria-invalid=true]{border-color:var(--kles-richtext-toolbar-error, var(--error, #9e2020))}.kles-richtext-toolbar__status{margin:.5rem 0 0;font-size:.9rem;line-height:1.5}.kles-richtext-toolbar__status:empty{margin:0}.kles-richtext-toolbar__error{color:var(--kles-richtext-toolbar-error, var(--error, #9e2020));margin:.5rem 0 0;line-height:1.5}\n"]
|
|
1624
1490
|
}]
|
|
1625
1491
|
}],
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1492
|
+
ctorParameters: () => [],
|
|
1493
|
+
propDecorators: {
|
|
1494
|
+
editor: [{
|
|
1495
|
+
type: i0.Input,
|
|
1496
|
+
args: [{
|
|
1497
|
+
isSignal: true,
|
|
1498
|
+
alias: "editor",
|
|
1499
|
+
required: true
|
|
1500
|
+
}]
|
|
1501
|
+
}],
|
|
1502
|
+
labelOverride: [{
|
|
1503
|
+
type: i0.Input,
|
|
1504
|
+
args: [{
|
|
1505
|
+
isSignal: true,
|
|
1506
|
+
alias: "label",
|
|
1507
|
+
required: false
|
|
1508
|
+
}]
|
|
1509
|
+
}],
|
|
1510
|
+
locale: [{
|
|
1511
|
+
type: i0.Input,
|
|
1512
|
+
args: [{
|
|
1513
|
+
isSignal: true,
|
|
1514
|
+
alias: "locale",
|
|
1515
|
+
required: false
|
|
1516
|
+
}]
|
|
1517
|
+
}],
|
|
1518
|
+
messages: [{
|
|
1519
|
+
type: i0.Input,
|
|
1520
|
+
args: [{
|
|
1521
|
+
isSignal: true,
|
|
1522
|
+
alias: "messages",
|
|
1523
|
+
required: false
|
|
1524
|
+
}]
|
|
1525
|
+
}],
|
|
1526
|
+
config: [{
|
|
1527
|
+
type: i0.Input,
|
|
1528
|
+
args: [{
|
|
1529
|
+
isSignal: true,
|
|
1530
|
+
alias: "config",
|
|
1531
|
+
required: false
|
|
1532
|
+
}]
|
|
1533
|
+
}],
|
|
1534
|
+
items: [{
|
|
1535
|
+
type: i0.Input,
|
|
1536
|
+
args: [{
|
|
1537
|
+
isSignal: true,
|
|
1538
|
+
alias: "items",
|
|
1539
|
+
required: false
|
|
1540
|
+
}]
|
|
1541
|
+
}],
|
|
1542
|
+
buttonTemplate: [{
|
|
1543
|
+
type: i0.Input,
|
|
1544
|
+
args: [{
|
|
1545
|
+
isSignal: true,
|
|
1546
|
+
alias: "buttonTemplate",
|
|
1547
|
+
required: false
|
|
1548
|
+
}]
|
|
1549
|
+
}],
|
|
1550
|
+
refreshKey: [{
|
|
1551
|
+
type: i0.Input,
|
|
1552
|
+
args: [{
|
|
1553
|
+
isSignal: true,
|
|
1554
|
+
alias: "refreshKey",
|
|
1555
|
+
required: false
|
|
1556
|
+
}]
|
|
1557
|
+
}],
|
|
1558
|
+
commands: [{
|
|
1559
|
+
type: i0.ViewChild,
|
|
1560
|
+
args: ["commands", { isSignal: true }]
|
|
1656
1561
|
}]
|
|
1657
|
-
}
|
|
1658
|
-
|
|
1659
|
-
type: i0.ViewChild,
|
|
1660
|
-
args: ["commands", { isSignal: true }]
|
|
1661
|
-
}]
|
|
1662
|
-
}
|
|
1562
|
+
}
|
|
1563
|
+
})
|
|
1663
1564
|
});
|
|
1664
|
-
export { DEFAULT_RICHTEXT_TOOLBAR_ITEMS, RICHTEXT_EDITOR_EXTENSIONS, RICHTEXT_I18N, RICHTEXT_MESSAGES_EN, RICHTEXT_MESSAGES_FR, RICHTEXT_TOOLBAR_CONFIG, RichTextDocumentPreviewComponent, RichTextEditorComponent, RichTextToolbarComponent, provideRichTextI18n, provideRichTextToolbar, richTextDocumentValidator, richTextRequiredValidator, validateRichTextValue };
|
|
1565
|
+
export { DEFAULT_RICHTEXT_TOOLBAR_ITEMS, FULL_RICHTEXT_TOOLBAR_ITEMS, RICHTEXT_EDITOR_EXTENSIONS, RICHTEXT_I18N, RICHTEXT_MESSAGES_EN, RICHTEXT_MESSAGES_FR, RICHTEXT_TOOLBAR_CONFIG, RichTextDocumentPreviewComponent, RichTextEditorComponent, RichTextToolbarComponent, provideRichTextI18n, provideRichTextToolbar, richTextDocumentValidator, richTextHtmlRequiredValidator, richTextRequiredValidator, validateRichTextValue };
|
|
1665
1566
|
|
|
1666
1567
|
//# sourceMappingURL=3kles-kles-richtext-editor.mjs.map
|