@3kles/kles-richtext-editor 1.2.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.
@@ -1,9 +1,10 @@
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 { APP_ID, ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injectable, InjectionToken, PLATFORM_ID, ViewChild, booleanAttribute, computed, effect, forwardRef, inject, input, output, signal, untracked, viewChild } from "@angular/core";
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";
7
8
  import { importHtml } from "@3kles/richtext-formats";
8
9
  const RICHTEXT_I18N = new InjectionToken("RICHTEXT_I18N", {
9
10
  providedIn: "root",
@@ -18,103 +19,6 @@ function provideRichTextI18n(options) {
18
19
  })
19
20
  };
20
21
  }
21
- const RICHTEXT_MESSAGES_FR = Object.freeze({
22
- editorLabel: "Contenu du document",
23
- invalidDocument: "La valeur doit être un document 3KLES valide.",
24
- requiredDocument: "Le document doit contenir du texte.",
25
- validationError: "Le document comporte une erreur de validation.",
26
- previewLabel: "Représentation JSON du document",
27
- toolbarLabel: "Mise en forme du document",
28
- toolbarFields: "Options de titre et de lien",
29
- headingLevel: "Niveau",
30
- headingLevelLabel: "Niveau du titre",
31
- linkAddress: "Adresse du lien",
32
- applyLink: "Appliquer le lien",
33
- removeLink: "Retirer le lien",
34
- invalidLink: "Saisissez une adresse HTTP, HTTPS, mailto ou une destination dynamique valide.",
35
- actionUnavailable: "Cette action ne peut pas être appliquée à la sélection.",
36
- undoDone: "Annulation effectuée.",
37
- redoDone: "Rétablissement effectué.",
38
- formatDone: "Mise en forme mise à jour.",
39
- linkApplied: "Lien appliqué.",
40
- linkNotApplied: "Le lien ne peut pas être appliqué à la sélection.",
41
- linkRemoved: "Lien retiré.",
42
- linkNotRemoved: "Le lien ne peut pas être retiré de la sélection.",
43
- bold: "Gras",
44
- italic: "Italique",
45
- underline: "Souligné",
46
- paragraph: "Paragraphe",
47
- heading: "Titre",
48
- strike: "Barré",
49
- code: "Code en ligne",
50
- bulletList: "Liste à puces",
51
- orderedList: "Liste numérotée",
52
- indent: "Indenter",
53
- outdent: "Réduire le retrait",
54
- blockquote: "Citation",
55
- codeBlock: "Bloc de code",
56
- clear: "Effacer la mise en forme",
57
- undo: "Annuler",
58
- redo: "Rétablir"
59
- });
60
- const RICHTEXT_MESSAGES_EN = Object.freeze({
61
- editorLabel: "Document content",
62
- invalidDocument: "The value must be a valid 3KLES document.",
63
- requiredDocument: "The document must contain text.",
64
- validationError: "The document has a validation error.",
65
- previewLabel: "Document JSON representation",
66
- toolbarLabel: "Document formatting",
67
- toolbarFields: "Heading and link options",
68
- headingLevel: "Level",
69
- headingLevelLabel: "Heading level",
70
- linkAddress: "Link address",
71
- applyLink: "Apply link",
72
- removeLink: "Remove link",
73
- invalidLink: "Enter a valid HTTP, HTTPS, mailto, or dynamic link destination.",
74
- actionUnavailable: "This action cannot be applied to the selection.",
75
- undoDone: "Undo completed.",
76
- redoDone: "Redo completed.",
77
- formatDone: "Formatting updated.",
78
- linkApplied: "Link applied.",
79
- linkNotApplied: "The link cannot be applied to the selection.",
80
- linkRemoved: "Link removed.",
81
- linkNotRemoved: "The link cannot be removed from the selection.",
82
- bold: "Bold",
83
- italic: "Italic",
84
- underline: "Underline",
85
- paragraph: "Paragraph",
86
- heading: "Heading",
87
- strike: "Strikethrough",
88
- code: "Inline code",
89
- bulletList: "Bullet list",
90
- orderedList: "Numbered list",
91
- indent: "Indent",
92
- outdent: "Outdent",
93
- blockquote: "Blockquote",
94
- codeBlock: "Code block",
95
- clear: "Clear formatting",
96
- undo: "Undo",
97
- redo: "Redo"
98
- });
99
- function richTextLocale(locale) {
100
- return locale?.trim().toLowerCase().split(/[-_]/u)[0] === "en" ? "en" : "fr";
101
- }
102
- function resolveRichTextMessages(locale, ...overrides) {
103
- const messages = { ...richTextLocale(locale) === "en" ? RICHTEXT_MESSAGES_EN : RICHTEXT_MESSAGES_FR };
104
- for (const override of overrides) {
105
- if (!override) continue;
106
- for (const [key, value] of Object.entries(override)) if (typeof value === "string" && value.trim().length > 0) Object.defineProperty(messages, key, {
107
- value,
108
- enumerable: true,
109
- configurable: true,
110
- writable: true
111
- });
112
- }
113
- return Object.freeze(messages);
114
- }
115
- function richTextLabel(value, fallback) {
116
- return value?.trim() ? value : fallback;
117
- }
118
22
  var RichTextDocumentPreviewComponent = class RichTextDocumentPreviewComponent {
119
23
  document = input.required(...ngDevMode ? [{ debugName: "document" }] : /* istanbul ignore next */ []);
120
24
  labelOverride = input(void 0, {
@@ -232,38 +136,6 @@ i0.ɵɵngDeclareClassMetadata({
232
136
  }
233
137
  });
234
138
  const RICHTEXT_EDITOR_EXTENSIONS = new InjectionToken("RICHTEXT_EDITOR_EXTENSIONS");
235
- var RichTextAccessibilityIds = class RichTextAccessibilityIds {
236
- appId = inject(APP_ID);
237
- sequence = 0;
238
- next(purpose) {
239
- return `${this.appId}-kles-richtext-${purpose}-${++this.sequence}`;
240
- }
241
- static ɵfac = i0.ɵɵngDeclareFactory({
242
- minVersion: "12.0.0",
243
- version: "22.2.6",
244
- ngImport: i0,
245
- type: RichTextAccessibilityIds,
246
- deps: [],
247
- target: i0.ɵɵFactoryTarget.Injectable
248
- });
249
- static ɵprov = i0.ɵɵngDeclareInjectable({
250
- minVersion: "12.0.0",
251
- version: "22.2.6",
252
- ngImport: i0,
253
- type: RichTextAccessibilityIds,
254
- providedIn: "root"
255
- });
256
- };
257
- i0.ɵɵngDeclareClassMetadata({
258
- minVersion: "12.0.0",
259
- version: "22.2.6",
260
- ngImport: i0,
261
- type: RichTextAccessibilityIds,
262
- decorators: [{
263
- type: Injectable,
264
- args: [{ providedIn: "root" }]
265
- }]
266
- });
267
139
  const RICHTEXT_REQUIRED_ERROR = Object.freeze({ required: true });
268
140
  function validateRichTextValue(value) {
269
141
  return value === null ? {
@@ -1075,176 +947,6 @@ function provideRichTextToolbar(config) {
1075
947
  useValue: config
1076
948
  };
1077
949
  }
1078
- const TOOLBAR_ACTIONS = Object.freeze([
1079
- {
1080
- id: "bold",
1081
- key: "bold",
1082
- command: "bold",
1083
- toggle: true
1084
- },
1085
- {
1086
- id: "italic",
1087
- key: "italic",
1088
- command: "italic",
1089
- toggle: true
1090
- },
1091
- {
1092
- id: "underline",
1093
- key: "underline",
1094
- command: "underline",
1095
- toggle: true
1096
- },
1097
- {
1098
- id: "paragraph",
1099
- key: "paragraph",
1100
- command: "paragraph",
1101
- toggle: true
1102
- },
1103
- {
1104
- id: "heading",
1105
- key: "heading",
1106
- command: "heading",
1107
- toggle: true
1108
- },
1109
- {
1110
- id: "strike",
1111
- key: "strike",
1112
- command: "strike",
1113
- toggle: true
1114
- },
1115
- {
1116
- id: "code",
1117
- key: "code",
1118
- command: "code",
1119
- toggle: true
1120
- },
1121
- {
1122
- id: "bulletList",
1123
- key: "bulletList",
1124
- command: "bulletList",
1125
- toggle: true
1126
- },
1127
- {
1128
- id: "orderedList",
1129
- key: "orderedList",
1130
- command: "orderedList",
1131
- toggle: true
1132
- },
1133
- {
1134
- id: "indent",
1135
- key: "indent",
1136
- command: Object.freeze({ type: "indentListItem" })
1137
- },
1138
- {
1139
- id: "outdent",
1140
- key: "outdent",
1141
- command: Object.freeze({ type: "outdentListItem" })
1142
- },
1143
- {
1144
- id: "blockquote",
1145
- key: "blockquote",
1146
- command: "blockquote",
1147
- toggle: true
1148
- },
1149
- {
1150
- id: "codeBlock",
1151
- key: "codeBlock",
1152
- command: "codeBlock",
1153
- toggle: true
1154
- },
1155
- {
1156
- id: "clear",
1157
- key: "clear",
1158
- command: Object.freeze({ type: "clearFormatting" })
1159
- },
1160
- {
1161
- id: "undo",
1162
- key: "undo",
1163
- command: "undo"
1164
- },
1165
- {
1166
- id: "redo",
1167
- key: "redo",
1168
- command: "redo"
1169
- }
1170
- ]);
1171
- const DEFAULT_RICHTEXT_TOOLBAR_ITEMS = Object.freeze([
1172
- ...TOOLBAR_ACTIONS.map(({ id }) => id),
1173
- "headingLevel",
1174
- "link"
1175
- ]);
1176
- function resolveToolbarItems(items) {
1177
- const seen = /* @__PURE__ */ new Set();
1178
- const resolved = [];
1179
- for (const input of items) {
1180
- const item = typeof input === "string" ? { id: input } : input;
1181
- if (!item.id.trim()) throw new TypeError("Toolbar item IDs must be nonempty.");
1182
- if (seen.has(item.id)) throw new TypeError(`Duplicate toolbar item ID: ${item.id}`);
1183
- seen.add(item.id);
1184
- if (item.visible === false) continue;
1185
- if ("kind" in item && item.kind === "command") {
1186
- 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}`);
1187
- if (!item.label.trim()) throw new TypeError("Custom toolbar commands need a nonempty label.");
1188
- resolved.push(Object.freeze({
1189
- ...item,
1190
- kind: "action",
1191
- builtin: false,
1192
- toggle: item.toggle ?? false
1193
- }));
1194
- } else if (item.id === "headingLevel" || item.id === "link") resolved.push(Object.freeze({
1195
- ...item,
1196
- kind: "field",
1197
- id: item.id
1198
- }));
1199
- else {
1200
- const definition = TOOLBAR_ACTIONS.find((action) => action.id === item.id);
1201
- if (!definition) throw new TypeError(`Unknown toolbar item ID: ${item.id}`);
1202
- resolved.push(Object.freeze({
1203
- ...item,
1204
- ...definition,
1205
- kind: "action",
1206
- builtin: true,
1207
- toggle: definition.toggle ?? false
1208
- }));
1209
- }
1210
- }
1211
- return Object.freeze(resolved);
1212
- }
1213
- function toolbarActionQueries(items) {
1214
- return items.filter((item) => item.kind === "action").map((item) => ({
1215
- id: item.id,
1216
- builtin: item.builtin,
1217
- command: item.command,
1218
- disabled: item.disabled ?? false,
1219
- toggle: item.toggle
1220
- }));
1221
- }
1222
- function sameToolbarActionQueries(left, right) {
1223
- return left.length === right.length && left.every((item, index) => {
1224
- const next = right[index];
1225
- return next !== void 0 && item.id === next.id && item.builtin === next.builtin && item.command === next.command && item.disabled === next.disabled && item.toggle === next.toggle;
1226
- });
1227
- }
1228
- function toolbarItemLabel(item, messages) {
1229
- const override = item.labelKey !== void 0 && Object.hasOwn(messages, item.labelKey) ? messages[item.labelKey] : void 0;
1230
- 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);
1231
- }
1232
- function toolbarButtonContent(action, messages, preferIconOnly = false) {
1233
- const label = toolbarItemLabel(action, messages);
1234
- const ariaLabel = richTextLabel(action.ariaLabel, label);
1235
- const icon = action.icon?.trim();
1236
- if (!icon) return {
1237
- label,
1238
- ariaLabel
1239
- };
1240
- const iconType = action.iconType ?? (icon === "undo" || icon === "redo" ? "material" : "text");
1241
- return {
1242
- icon,
1243
- iconType,
1244
- label: preferIconOnly || action.label?.trim() === "" || iconType === "material" && action.label === void 0 && action.labelKey === void 0 ? "" : label,
1245
- ariaLabel
1246
- };
1247
- }
1248
950
  function nextToolbarItem(items, current, key) {
1249
951
  const available = items.filter((item) => !item.disabled);
1250
952
  if (key === "Home") return available[0]?.id;
@@ -1285,6 +987,46 @@ function toolbarLinkHref(snapshot) {
1285
987
  function isToolbarHeadingLevel(level) {
1286
988
  return level === 1 || level === 2 || level === 3 || level === 4 || level === 5 || level === 6;
1287
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
+ };
1288
1030
  var RichTextToolbarComponent = class RichTextToolbarComponent {
1289
1031
  editor = input.required(...ngDevMode ? [{ debugName: "editor" }] : /* istanbul ignore next */ []);
1290
1032
  labelOverride = input(void 0, {
@@ -1324,11 +1066,51 @@ var RichTextToolbarComponent = class RichTextToolbarComponent {
1324
1066
  iconOnly = computed(() => this.config()?.iconOnly ?? this.defaults.iconOnly ?? false, ...ngDevMode ? [{ debugName: "iconOnly" }] : /* istanbul ignore next */ []);
1325
1067
  resolvedItems = computed(() => resolveToolbarItems(this.items() ?? this.config()?.items ?? this.defaults.items ?? DEFAULT_RICHTEXT_TOOLBAR_ITEMS), ...ngDevMode ? [{ debugName: "resolvedItems" }] : /* istanbul ignore next */ []);
1326
1068
  hasItems = computed(() => this.resolvedItems().length > 0, ...ngDevMode ? [{ debugName: "hasItems" }] : /* istanbul ignore next */ []);
1327
- actions = computed(() => this.resolvedItems().filter((item) => item.kind === "action"), ...ngDevMode ? [{ debugName: "actions" }] : /* istanbul ignore next */ []);
1328
- fields = computed(() => this.resolvedItems().filter((item) => item.kind === "field").map((item) => ({
1329
- ...item,
1330
- label: toolbarItemLabel(item, this.text())
1331
- })), ...ngDevMode ? [{ debugName: "fields" }] : /* istanbul ignore next */ []);
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 */ []);
1332
1114
  queries = computed(() => toolbarActionQueries(this.resolvedItems()), {
1333
1115
  ...ngDevMode ? { debugName: "queries" } : /* istanbul ignore next */ {},
1334
1116
  equal: sameToolbarActionQueries
@@ -1370,11 +1152,23 @@ var RichTextToolbarComponent = class RichTextToolbarComponent {
1370
1152
  const messages = this.text();
1371
1153
  const iconOnly = this.iconOnly();
1372
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
+ }
1373
1166
  const capability = capabilities.get(action.id);
1374
1167
  if (!capability) return [];
1375
1168
  return [{
1376
1169
  ...capability,
1377
- ...toolbarButtonContent(action, messages, iconOnly)
1170
+ ...content,
1171
+ kind: "command"
1378
1172
  }];
1379
1173
  });
1380
1174
  }, ...ngDevMode ? [{ debugName: "buttons" }] : /* istanbul ignore next */ []);
@@ -1509,11 +1303,33 @@ var RichTextToolbarComponent = class RichTextToolbarComponent {
1509
1303
  const result = this.editor().execute(button.command);
1510
1304
  this.announce(result && !result.ok ? "actionUnavailable" : button.id === "undo" ? "undoDone" : button.id === "redo" ? "redoDone" : "formatDone");
1511
1305
  }
1306
+ executeMenuCommand(command) {
1307
+ if (this.blocked()) return;
1308
+ const result = this.editor().execute(command);
1309
+ this.announce(result?.ok ? "formatDone" : "actionUnavailable");
1310
+ }
1512
1311
  changeHeadingLevel(event) {
1513
1312
  if (!(event.target instanceof HTMLSelectElement)) return;
1514
1313
  const level = Number(event.target.value);
1515
1314
  if (isToolbarHeadingLevel(level)) this.headingLevel.set(level);
1516
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
+ }
1517
1333
  changeLink(value) {
1518
1334
  this.linkDirty.set(true);
1519
1335
  this.linkHref.set(value);
@@ -1546,7 +1362,7 @@ var RichTextToolbarComponent = class RichTextToolbarComponent {
1546
1362
  if (id) this.currentAction.set(id);
1547
1363
  }
1548
1364
  navigate(event) {
1549
- 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;
1550
1366
  const key = event.key;
1551
1367
  if (key !== "ArrowLeft" && key !== "ArrowRight" && key !== "Home" && key !== "End") return;
1552
1368
  const id = nextToolbarItem(this.buttons(), event.target.getAttribute("data-richtext-action") ?? void 0, key);
@@ -1639,8 +1455,8 @@ var RichTextToolbarComponent = class RichTextToolbarComponent {
1639
1455
  isSignal: true
1640
1456
  }],
1641
1457
  ngImport: i0,
1642
- 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",
1643
- 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"],
1644
1460
  dependencies: [{
1645
1461
  kind: "directive",
1646
1462
  type: NgTemplateOutlet,
@@ -1651,97 +1467,101 @@ var RichTextToolbarComponent = class RichTextToolbarComponent {
1651
1467
  "ngTemplateOutletInjector"
1652
1468
  ]
1653
1469
  }],
1654
- 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)]]
1655
1472
  });
1656
1473
  };
1657
- i0.ɵɵngDeclareClassMetadata({
1658
- minVersion: "12.0.0",
1474
+ i0.ɵɵngDeclareClassMetadataAsync({
1475
+ minVersion: "18.0.0",
1659
1476
  version: "22.2.6",
1660
1477
  ngImport: i0,
1661
1478
  type: RichTextToolbarComponent,
1662
- decorators: [{
1663
- type: Component,
1664
- args: [{
1665
- selector: "kles-richtext-toolbar",
1666
- standalone: true,
1667
- imports: [NgTemplateOutlet],
1668
- changeDetection: ChangeDetectionStrategy.OnPush,
1669
- 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",
1670
- 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"]
1671
- }]
1672
- }],
1673
- ctorParameters: () => [],
1674
- propDecorators: {
1675
- editor: [{
1676
- type: i0.Input,
1677
- args: [{
1678
- isSignal: true,
1679
- alias: "editor",
1680
- required: true
1681
- }]
1682
- }],
1683
- labelOverride: [{
1684
- type: i0.Input,
1685
- args: [{
1686
- isSignal: true,
1687
- alias: "label",
1688
- required: false
1689
- }]
1690
- }],
1691
- locale: [{
1692
- type: i0.Input,
1693
- args: [{
1694
- isSignal: true,
1695
- alias: "locale",
1696
- required: false
1697
- }]
1698
- }],
1699
- messages: [{
1700
- type: i0.Input,
1701
- args: [{
1702
- isSignal: true,
1703
- alias: "messages",
1704
- required: false
1705
- }]
1706
- }],
1707
- config: [{
1708
- type: i0.Input,
1709
- args: [{
1710
- isSignal: true,
1711
- alias: "config",
1712
- required: false
1713
- }]
1714
- }],
1715
- items: [{
1716
- 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,
1717
1483
  args: [{
1718
- isSignal: true,
1719
- alias: "items",
1720
- required: false
1721
- }]
1722
- }],
1723
- buttonTemplate: [{
1724
- type: i0.Input,
1725
- args: [{
1726
- isSignal: true,
1727
- alias: "buttonTemplate",
1728
- required: false
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"]
1729
1490
  }]
1730
1491
  }],
1731
- refreshKey: [{
1732
- type: i0.Input,
1733
- args: [{
1734
- isSignal: true,
1735
- alias: "refreshKey",
1736
- required: false
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 }]
1737
1561
  }]
1738
- }],
1739
- commands: [{
1740
- type: i0.ViewChild,
1741
- args: ["commands", { isSignal: true }]
1742
- }]
1743
- }
1562
+ }
1563
+ })
1744
1564
  });
1745
- 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, richTextHtmlRequiredValidator, 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 };
1746
1566
 
1747
1567
  //# sourceMappingURL=3kles-kles-richtext-editor.mjs.map