@4sh/ui-kit 0.6.1 → 0.8.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.
Files changed (154) hide show
  1. package/README.fr.md +47 -22
  2. package/README.md +46 -23
  3. package/fesm2022/4sh-ui-kit-actions-ui-button-split.mjs +1 -1
  4. package/fesm2022/4sh-ui-kit-actions-ui-button-split.mjs.map +1 -1
  5. package/fesm2022/4sh-ui-kit-actions-ui-button.mjs +5 -3
  6. package/fesm2022/4sh-ui-kit-actions-ui-button.mjs.map +1 -1
  7. package/fesm2022/4sh-ui-kit-actions-ui-link.mjs.map +1 -1
  8. package/fesm2022/4sh-ui-kit-actions-ui-speed-dial.mjs +439 -0
  9. package/fesm2022/4sh-ui-kit-actions-ui-speed-dial.mjs.map +1 -0
  10. package/fesm2022/4sh-ui-kit-base-ui-icon.mjs.map +1 -1
  11. package/fesm2022/4sh-ui-kit-base-ui-image.mjs +111 -10
  12. package/fesm2022/4sh-ui-kit-base-ui-image.mjs.map +1 -1
  13. package/fesm2022/4sh-ui-kit-forms-ui-autocomplete.mjs +14 -6
  14. package/fesm2022/4sh-ui-kit-forms-ui-autocomplete.mjs.map +1 -1
  15. package/fesm2022/4sh-ui-kit-forms-ui-checkbox.mjs.map +1 -1
  16. package/fesm2022/4sh-ui-kit-forms-ui-datepicker.mjs +655 -92
  17. package/fesm2022/4sh-ui-kit-forms-ui-datepicker.mjs.map +1 -1
  18. package/fesm2022/4sh-ui-kit-forms-ui-editor.mjs +1107 -0
  19. package/fesm2022/4sh-ui-kit-forms-ui-editor.mjs.map +1 -0
  20. package/fesm2022/4sh-ui-kit-forms-ui-field.mjs +43 -3
  21. package/fesm2022/4sh-ui-kit-forms-ui-field.mjs.map +1 -1
  22. package/fesm2022/4sh-ui-kit-forms-ui-file-upload.mjs +5 -3
  23. package/fesm2022/4sh-ui-kit-forms-ui-file-upload.mjs.map +1 -1
  24. package/fesm2022/4sh-ui-kit-forms-ui-input-group.mjs.map +1 -1
  25. package/fesm2022/4sh-ui-kit-forms-ui-input-mask.mjs +8 -2
  26. package/fesm2022/4sh-ui-kit-forms-ui-input-mask.mjs.map +1 -1
  27. package/fesm2022/4sh-ui-kit-forms-ui-input-number.mjs +15 -2
  28. package/fesm2022/4sh-ui-kit-forms-ui-input-number.mjs.map +1 -1
  29. package/fesm2022/4sh-ui-kit-forms-ui-input-otp.mjs.map +1 -1
  30. package/fesm2022/4sh-ui-kit-forms-ui-input-tags.mjs +8 -4
  31. package/fesm2022/4sh-ui-kit-forms-ui-input-tags.mjs.map +1 -1
  32. package/fesm2022/4sh-ui-kit-forms-ui-input.mjs +40 -4
  33. package/fesm2022/4sh-ui-kit-forms-ui-input.mjs.map +1 -1
  34. package/fesm2022/4sh-ui-kit-forms-ui-knob.mjs +282 -0
  35. package/fesm2022/4sh-ui-kit-forms-ui-knob.mjs.map +1 -0
  36. package/fesm2022/4sh-ui-kit-forms-ui-label.mjs +2 -2
  37. package/fesm2022/4sh-ui-kit-forms-ui-label.mjs.map +1 -1
  38. package/fesm2022/4sh-ui-kit-forms-ui-nudger.mjs +1 -1
  39. package/fesm2022/4sh-ui-kit-forms-ui-nudger.mjs.map +1 -1
  40. package/fesm2022/4sh-ui-kit-forms-ui-radio.mjs.map +1 -1
  41. package/fesm2022/4sh-ui-kit-forms-ui-rating.mjs.map +1 -1
  42. package/fesm2022/4sh-ui-kit-forms-ui-segment-control.mjs +6 -4
  43. package/fesm2022/4sh-ui-kit-forms-ui-segment-control.mjs.map +1 -1
  44. package/fesm2022/4sh-ui-kit-forms-ui-select.mjs +8 -3
  45. package/fesm2022/4sh-ui-kit-forms-ui-select.mjs.map +1 -1
  46. package/fesm2022/4sh-ui-kit-forms-ui-slider.mjs.map +1 -1
  47. package/fesm2022/4sh-ui-kit-forms-ui-swatch-picker.mjs +317 -0
  48. package/fesm2022/4sh-ui-kit-forms-ui-swatch-picker.mjs.map +1 -0
  49. package/fesm2022/4sh-ui-kit-forms-ui-textarea.mjs +8 -2
  50. package/fesm2022/4sh-ui-kit-forms-ui-textarea.mjs.map +1 -1
  51. package/fesm2022/4sh-ui-kit-forms-ui-toggle-button.mjs +374 -0
  52. package/fesm2022/4sh-ui-kit-forms-ui-toggle-button.mjs.map +1 -0
  53. package/fesm2022/4sh-ui-kit-forms-ui-toggle.mjs.map +1 -1
  54. package/fesm2022/4sh-ui-kit-forms.mjs +49 -14
  55. package/fesm2022/4sh-ui-kit-forms.mjs.map +1 -1
  56. package/fesm2022/4sh-ui-kit-informative-ui-accordion.mjs.map +1 -1
  57. package/fesm2022/4sh-ui-kit-informative-ui-alert.mjs.map +1 -1
  58. package/fesm2022/4sh-ui-kit-informative-ui-avatar-group.mjs.map +1 -1
  59. package/fesm2022/4sh-ui-kit-informative-ui-avatar.mjs.map +1 -1
  60. package/fesm2022/4sh-ui-kit-informative-ui-badge.mjs +2 -2
  61. package/fesm2022/4sh-ui-kit-informative-ui-badge.mjs.map +1 -1
  62. package/fesm2022/4sh-ui-kit-informative-ui-chip.mjs +2 -2
  63. package/fesm2022/4sh-ui-kit-informative-ui-chip.mjs.map +1 -1
  64. package/fesm2022/4sh-ui-kit-informative-ui-empty-state.mjs.map +1 -1
  65. package/fesm2022/4sh-ui-kit-informative-ui-helper.mjs.map +1 -1
  66. package/fesm2022/4sh-ui-kit-informative-ui-progress-bar.mjs.map +1 -1
  67. package/fesm2022/4sh-ui-kit-informative-ui-read-only.mjs.map +1 -1
  68. package/fesm2022/4sh-ui-kit-informative-ui-separator.mjs.map +1 -1
  69. package/fesm2022/4sh-ui-kit-informative-ui-skeleton.mjs.map +1 -1
  70. package/fesm2022/4sh-ui-kit-informative-ui-spinner.mjs.map +1 -1
  71. package/fesm2022/4sh-ui-kit-informative-ui-tag.mjs +2 -2
  72. package/fesm2022/4sh-ui-kit-informative-ui-tag.mjs.map +1 -1
  73. package/fesm2022/4sh-ui-kit-informative-ui-toast.mjs.map +1 -1
  74. package/fesm2022/4sh-ui-kit-informative-ui-tooltip.mjs +2 -2
  75. package/fesm2022/4sh-ui-kit-informative-ui-tooltip.mjs.map +1 -1
  76. package/fesm2022/4sh-ui-kit-layout-ui-card.mjs.map +1 -1
  77. package/fesm2022/4sh-ui-kit-layout-ui-drawer.mjs.map +1 -1
  78. package/fesm2022/4sh-ui-kit-layout-ui-modal.mjs +45 -4
  79. package/fesm2022/4sh-ui-kit-layout-ui-modal.mjs.map +1 -1
  80. package/fesm2022/4sh-ui-kit-layout-ui-popover.mjs.map +1 -1
  81. package/fesm2022/4sh-ui-kit-motion.mjs.map +1 -1
  82. package/fesm2022/4sh-ui-kit-navigation-ui-bottom-tab-bar.mjs +370 -0
  83. package/fesm2022/4sh-ui-kit-navigation-ui-bottom-tab-bar.mjs.map +1 -0
  84. package/fesm2022/4sh-ui-kit-navigation-ui-breadcrumb.mjs +2 -2
  85. package/fesm2022/4sh-ui-kit-navigation-ui-breadcrumb.mjs.map +1 -1
  86. package/fesm2022/4sh-ui-kit-navigation-ui-context-menu.mjs +5 -3
  87. package/fesm2022/4sh-ui-kit-navigation-ui-context-menu.mjs.map +1 -1
  88. package/fesm2022/4sh-ui-kit-navigation-ui-menu.mjs +5 -3
  89. package/fesm2022/4sh-ui-kit-navigation-ui-menu.mjs.map +1 -1
  90. package/fesm2022/4sh-ui-kit-navigation-ui-sidebar.mjs +5 -3
  91. package/fesm2022/4sh-ui-kit-navigation-ui-sidebar.mjs.map +1 -1
  92. package/fesm2022/4sh-ui-kit-navigation-ui-stepper.mjs +22 -10
  93. package/fesm2022/4sh-ui-kit-navigation-ui-stepper.mjs.map +1 -1
  94. package/fesm2022/4sh-ui-kit-navigation-ui-tabs.mjs +19 -4
  95. package/fesm2022/4sh-ui-kit-navigation-ui-tabs.mjs.map +1 -1
  96. package/fesm2022/4sh-ui-kit-overlay.mjs.map +1 -1
  97. package/fesm2022/4sh-ui-kit-ripple.mjs +298 -0
  98. package/fesm2022/4sh-ui-kit-ripple.mjs.map +1 -0
  99. package/fesm2022/4sh-ui-kit-table-ui-paginator.mjs +5 -3
  100. package/fesm2022/4sh-ui-kit-table-ui-paginator.mjs.map +1 -1
  101. package/fesm2022/4sh-ui-kit-table-ui-table.mjs +2 -2
  102. package/fesm2022/4sh-ui-kit-table-ui-table.mjs.map +1 -1
  103. package/fesm2022/4sh-ui-kit-theming.mjs.map +1 -1
  104. package/fesm2022/4sh-ui-kit.mjs.map +1 -1
  105. package/mcp/data/text-search-docs.json +1083 -83
  106. package/mcp/data/ui-config.json +5592 -2586
  107. package/mcp/index.js +682 -410
  108. package/mcp/package.json +1 -1
  109. package/package.json +29 -1
  110. package/schematics/index.cjs +1 -1
  111. package/styles/base/_ripple.scss +53 -0
  112. package/styles/component-vars.scss +177 -2
  113. package/styles/generated/_tokens-breakpoint.scss +1 -1
  114. package/styles/generated/_tokens-metrics.scss +1 -1
  115. package/styles/generated/_tokens-primitives.scss +1 -1
  116. package/styles/generated/_tokens-responsive.scss +17 -17
  117. package/styles/generated/_tokens-semantics.scss +15 -15
  118. package/styles/generated/_tokens-styles.scss +1 -1
  119. package/styles/generated/_tokens-transitions.scss +1 -1
  120. package/styles/generated/_tokens-typography.scss +1 -1
  121. package/styles/generated/_tokens.scss +1 -1
  122. package/styles/index.scss +1 -0
  123. package/styles/settings/_ui-config.scss +9 -0
  124. package/styles/utils/_helpers.scss +15 -0
  125. package/styles/utils/_mixins.scss +17 -1
  126. package/styles.css +1 -1
  127. package/types/4sh-ui-kit-actions-ui-button.d.ts +3 -1
  128. package/types/4sh-ui-kit-actions-ui-speed-dial.d.ts +234 -0
  129. package/types/4sh-ui-kit-base-ui-image.d.ts +16 -3
  130. package/types/4sh-ui-kit-forms-ui-autocomplete.d.ts +7 -2
  131. package/types/4sh-ui-kit-forms-ui-datepicker.d.ts +242 -37
  132. package/types/4sh-ui-kit-forms-ui-editor.d.ts +481 -0
  133. package/types/4sh-ui-kit-forms-ui-field.d.ts +32 -2
  134. package/types/4sh-ui-kit-forms-ui-file-upload.d.ts +3 -1
  135. package/types/4sh-ui-kit-forms-ui-input-mask.d.ts +4 -0
  136. package/types/4sh-ui-kit-forms-ui-input-number.d.ts +9 -0
  137. package/types/4sh-ui-kit-forms-ui-input-tags.d.ts +4 -1
  138. package/types/4sh-ui-kit-forms-ui-input.d.ts +28 -2
  139. package/types/4sh-ui-kit-forms-ui-knob.d.ts +93 -0
  140. package/types/4sh-ui-kit-forms-ui-segment-control.d.ts +3 -1
  141. package/types/4sh-ui-kit-forms-ui-select.d.ts +5 -1
  142. package/types/4sh-ui-kit-forms-ui-swatch-picker.d.ts +126 -0
  143. package/types/4sh-ui-kit-forms-ui-textarea.d.ts +4 -0
  144. package/types/4sh-ui-kit-forms-ui-toggle-button.d.ts +222 -0
  145. package/types/4sh-ui-kit-forms.d.ts +38 -7
  146. package/types/4sh-ui-kit-layout-ui-modal.d.ts +7 -0
  147. package/types/4sh-ui-kit-navigation-ui-bottom-tab-bar.d.ts +201 -0
  148. package/types/4sh-ui-kit-navigation-ui-context-menu.d.ts +3 -1
  149. package/types/4sh-ui-kit-navigation-ui-menu.d.ts +3 -1
  150. package/types/4sh-ui-kit-navigation-ui-sidebar.d.ts +3 -1
  151. package/types/4sh-ui-kit-navigation-ui-stepper.d.ts +8 -3
  152. package/types/4sh-ui-kit-navigation-ui-tabs.d.ts +16 -3
  153. package/types/4sh-ui-kit-ripple.d.ts +156 -0
  154. package/types/4sh-ui-kit-table-ui-paginator.d.ts +3 -1
@@ -0,0 +1,1107 @@
1
+ import * as i0 from '@angular/core';
2
+ import { input, booleanAttribute, output, inject, viewChild, signal, computed, SecurityContext, afterNextRender, effect, forwardRef, Component } from '@angular/core';
3
+ import { NgTemplateOutlet } from '@angular/common';
4
+ import * as i1 from '@angular/forms';
5
+ import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
6
+ import { DomSanitizer } from '@angular/platform-browser';
7
+ import { BaseFormField } from '@4sh/ui-kit/forms';
8
+ import { UiField } from '@4sh/ui-kit/forms/ui-field';
9
+ import { UiButton } from '@4sh/ui-kit/actions/ui-button';
10
+ import { UiSelect } from '@4sh/ui-kit/forms/ui-select';
11
+ import { DEFAULT_SWATCH_PALETTE, UiSwatchPicker } from '@4sh/ui-kit/forms/ui-swatch-picker';
12
+
13
+ const EDITOR_SELECT_TOOLS = [
14
+ 'fontFamily',
15
+ 'fontSize',
16
+ ];
17
+ /**
18
+ * Font key → class written into the value, token holding the family, and the
19
+ * fallback label used when the real name cannot be read (SSR, unset token).
20
+ *
21
+ * The dropdown shows the **actual** face name, resolved from the token at runtime
22
+ * (see {@link resolveFontLabel}) rather than hardcoded: a project that rebinds
23
+ * `--fontfamily-base` would otherwise see a menu naming a font it no longer uses.
24
+ */
25
+ const EDITOR_FONTS = [
26
+ { key: 'base', className: 'ui-editor-font-base', cssVar: '--fontfamily-base', label: 'Standard' },
27
+ {
28
+ key: 'title',
29
+ className: 'ui-editor-font-title',
30
+ cssVar: '--fontfamily-title',
31
+ label: 'Titre',
32
+ },
33
+ {
34
+ key: 'monospace',
35
+ className: 'ui-editor-font-monospace',
36
+ cssVar: '--fontfamily-monospace',
37
+ label: 'Monospace',
38
+ },
39
+ ];
40
+ /**
41
+ * First face named by a font token — what the family dropdown displays.
42
+ *
43
+ * `--fontfamily-base` holds a whole stack (`Inter, system-ui, …`); only the head
44
+ * of it is a name a person recognises.
45
+ */
46
+ function resolveFontLabel(cssVar, fallback) {
47
+ if (typeof document === 'undefined')
48
+ return fallback;
49
+ const raw = getComputedStyle(document.documentElement).getPropertyValue(cssVar).trim();
50
+ const first = raw
51
+ .split(',')[0]
52
+ ?.trim()
53
+ .replace(/^["']|["']$/g, '');
54
+ return first || fallback;
55
+ }
56
+ /** Size key → class written into the value + French label for the dropdown. */
57
+ const EDITOR_SIZES = [
58
+ { key: 'sm', className: 'ui-editor-size-sm', label: 'Petit' },
59
+ { key: 'default', className: 'ui-editor-size-default', label: 'Normal' },
60
+ { key: 'lg', className: 'ui-editor-size-lg', label: 'Grand' },
61
+ { key: 'xl', className: 'ui-editor-size-xl', label: 'Très grand' },
62
+ ];
63
+ const SIZE_CLASSES = new Set(EDITOR_SIZES.map((s) => s.className));
64
+ const FONT_CLASSES = new Set(EDITOR_FONTS.map((f) => f.className));
65
+ /**
66
+ * The tools enabled when the consumer does not provide a `tools` list.
67
+ *
68
+ * There is no block-level dropdown (no `blockFormat`, no headings): the editor
69
+ * only ever produces `<p>`. `fontFamily`/`fontSize` are both first-class,
70
+ * always-on tools rather than one gated behind the other.
71
+ *
72
+ * `clearFormat` is deliberately absent for now: `clearFormatMarkers()` does not
73
+ * reliably clear every marker class yet. It stays available for a project that
74
+ * explicitly adds it to `tools`, but shipping it by default would be shipping
75
+ * a broken button.
76
+ */
77
+ const DEFAULT_EDITOR_TOOLS = [
78
+ 'fontFamily',
79
+ 'fontSize',
80
+ 'separator',
81
+ 'bold',
82
+ 'italic',
83
+ 'underline',
84
+ 'separator',
85
+ 'bulletList',
86
+ 'orderedList',
87
+ 'separator',
88
+ 'alignLeft',
89
+ 'alignCenter',
90
+ 'alignRight',
91
+ 'alignJustify',
92
+ 'separator',
93
+ 'link',
94
+ 'codeBlock',
95
+ ];
96
+ /** Toolbar metadata per button tool: icon (FontAwesome) + French accessible name. */
97
+ const EDITOR_TOOL_META = {
98
+ bold: { icon: 'bold', label: 'Gras' },
99
+ italic: { icon: 'italic', label: 'Italique' },
100
+ underline: { icon: 'underline', label: 'Souligné' },
101
+ bulletList: { icon: 'list-ul', label: 'Liste à puces' },
102
+ orderedList: { icon: 'list-ol', label: 'Liste numérotée' },
103
+ codeBlock: { icon: 'code', label: 'Bloc de code' },
104
+ indent: { icon: 'indent', label: 'Augmenter le retrait' },
105
+ outdent: { icon: 'outdent', label: 'Diminuer le retrait' },
106
+ alignLeft: { icon: 'align-left', label: 'Aligner à gauche' },
107
+ alignCenter: { icon: 'align-center', label: 'Centrer' },
108
+ alignRight: { icon: 'align-right', label: 'Aligner à droite' },
109
+ alignJustify: { icon: 'align-justify', label: 'Justifier' },
110
+ textColor: { icon: 'font', label: 'Couleur du texte' },
111
+ highlightColor: { icon: 'highlighter', label: 'Couleur de surlignage' },
112
+ link: { icon: 'link', label: 'Lien' },
113
+ clearFormat: { icon: 'text-slash', label: 'Effacer le formatage' },
114
+ };
115
+ /** Tool → legacy command name. */
116
+ const NATIVE_COMMAND = {
117
+ bold: 'bold',
118
+ italic: 'italic',
119
+ underline: 'underline',
120
+ bulletList: 'insertUnorderedList',
121
+ orderedList: 'insertOrderedList',
122
+ indent: 'indent',
123
+ outdent: 'outdent',
124
+ alignLeft: 'justifyLeft',
125
+ alignCenter: 'justifyCenter',
126
+ alignRight: 'justifyRight',
127
+ alignJustify: 'justifyFull',
128
+ clearFormat: 'removeFormat',
129
+ };
130
+ const TOGGLE_TOOLS = [
131
+ 'bold',
132
+ 'italic',
133
+ 'underline',
134
+ 'bulletList',
135
+ 'orderedList',
136
+ 'alignLeft',
137
+ 'alignCenter',
138
+ 'alignRight',
139
+ 'alignJustify',
140
+ ];
141
+ /** Every state off — the value used before the first render and on SSR. */
142
+ function emptyEditorState() {
143
+ return {
144
+ bold: false,
145
+ italic: false,
146
+ underline: false,
147
+ bulletList: false,
148
+ orderedList: false,
149
+ codeBlock: false,
150
+ alignLeft: false,
151
+ alignCenter: false,
152
+ alignRight: false,
153
+ alignJustify: false,
154
+ };
155
+ }
156
+ /** Applies a formatting command to the current selection. */
157
+ function applyCommand(tool) {
158
+ document.execCommand(NATIVE_COMMAND[tool], false);
159
+ }
160
+ // --- Code block ---------------------------------------------------------
161
+ /** Toggles the block under the caret between `<pre>` and a plain paragraph. */
162
+ function toggleCodeBlock() {
163
+ document.execCommand('formatBlock', false, isInCodeBlock() ? 'p' : 'pre');
164
+ }
165
+ /** The caret sits in a code block. */
166
+ function isInCodeBlock() {
167
+ try {
168
+ return (document.queryCommandValue('formatBlock') || '').toLowerCase() === 'pre';
169
+ }
170
+ catch {
171
+ return false;
172
+ }
173
+ }
174
+ // --- Font family --------------------------------------------------------
175
+ /**
176
+ * Marker handed to `fontName`, immediately rewritten into a class.
177
+ *
178
+ * `fontName` is the only command that can apply a family to an arbitrary
179
+ * selection, but it emits `<font face="…">` — an obsolete tag carrying a raw
180
+ * family name. We let it run, then convert its output so the value only ever
181
+ * holds a class bound to a `--fontfamily-*` token.
182
+ */
183
+ const FONT_MARKER = '__ui-editor-font__';
184
+ /** Applies a type family to the selection (see {@link convertFontMarkers}). */
185
+ function applyFontFamily() {
186
+ document.execCommand('fontName', false, FONT_MARKER);
187
+ }
188
+ /** Rewrites the `<font>` elements `fontName` just produced into `<span class>`. */
189
+ function convertFontMarkers(root, className) {
190
+ convertMarkers(root, `font[face="${FONT_MARKER}"]`, className);
191
+ }
192
+ /** @internal Replaces the matched legacy `<font>` elements with a classed span. */
193
+ function convertMarkers(root, selector, className) {
194
+ for (const el of Array.from(root.querySelectorAll(selector))) {
195
+ const span = document.createElement('span');
196
+ span.className = className;
197
+ span.append(...Array.from(el.childNodes));
198
+ el.replaceWith(span);
199
+ }
200
+ }
201
+ /**
202
+ * Type family in force at the caret.
203
+ *
204
+ * Falls back to the family the text is actually rendered with when no class was
205
+ * applied: a heading carries `--fontfamily-title` from its own styling, and
206
+ * reporting the base family there would name a font the reader does not see.
207
+ * `null` only when the computed face matches none of the system families.
208
+ */
209
+ function readFontFamily(node) {
210
+ const tagged = findClassKey(node, EDITOR_FONTS);
211
+ if (tagged)
212
+ return tagged;
213
+ const el = node?.nodeType === Node.ELEMENT_NODE ? node : (node?.parentElement ?? null);
214
+ if (!el || typeof getComputedStyle !== 'function')
215
+ return null;
216
+ const rendered = firstFace(getComputedStyle(el).fontFamily);
217
+ return (EDITOR_FONTS.find((f) => firstFace(resolveFontLabel(f.cssVar, '')) === rendered)?.key ?? null);
218
+ }
219
+ /** @internal Head of a font stack, unquoted and lowercased for comparison. */
220
+ function firstFace(stack) {
221
+ return (stack.split(',')[0] ?? '')
222
+ .trim()
223
+ .replace(/^["']|["']$/g, '')
224
+ .toLowerCase();
225
+ }
226
+ // --- Font size ----------------------------------------------------------
227
+ /**
228
+ * Marker handed to `fontSize`, immediately rewritten into a class.
229
+ *
230
+ * Same trick as the family: `fontSize` is the only command that can size an
231
+ * arbitrary selection, but it emits `<font size="7">` — a legacy 1-7 scale with
232
+ * no relation to the typography tokens.
233
+ */
234
+ const SIZE_MARKER = '7';
235
+ /** Applies a text size to the selection (see {@link convertSizeMarkers}). */
236
+ function applyFontSize() {
237
+ document.execCommand('fontSize', false, SIZE_MARKER);
238
+ }
239
+ /** Rewrites the `<font>` elements `fontSize` just produced into `<span class>`. */
240
+ function convertSizeMarkers(root, className) {
241
+ convertMarkers(root, `font[size="${SIZE_MARKER}"]`, className);
242
+ }
243
+ /** Text size active at the caret, or `null` when the text uses the default. */
244
+ function readFontSize(node) {
245
+ return findClassKey(node, EDITOR_SIZES);
246
+ }
247
+ // --- Text color / highlight color ---------------------------------------
248
+ /**
249
+ * Color key → class written into the value, token holding the swatch, and
250
+ * label, derived from `ui-swatch-picker`'s default palette rather than
251
+ * hand-duplicated: the editor's color tools and the nuancier it opens must
252
+ * always offer the same token set.
253
+ */
254
+ const EDITOR_COLORS = DEFAULT_SWATCH_PALETTE.flatMap((group) => group.swatches.map((swatch) => ({
255
+ key: swatch.key,
256
+ className: `ui-editor-color-${swatch.key}`,
257
+ cssVar: swatch.cssVar,
258
+ label: swatch.label,
259
+ })));
260
+ /** Same key set as {@link EDITOR_COLORS}, classed separately for the highlight tool. */
261
+ const EDITOR_HIGHLIGHTS = DEFAULT_SWATCH_PALETTE.flatMap((group) => group.swatches.map((swatch) => ({
262
+ key: swatch.key,
263
+ className: `ui-editor-highlight-${swatch.key}`,
264
+ cssVar: swatch.cssVar,
265
+ label: swatch.label,
266
+ })));
267
+ const COLOR_CLASSES = new Set(EDITOR_COLORS.map((c) => c.className));
268
+ const HIGHLIGHT_CLASSES = new Set(EDITOR_HIGHLIGHTS.map((c) => c.className));
269
+ /**
270
+ * Marker handed to `foreColor`, immediately rewritten into a class.
271
+ *
272
+ * `foreColor` is the only command that can color an arbitrary selection, but
273
+ * it emits `<font color="…">` — same trick as the family/size markers. Must
274
+ * be a value the browser accepts as a real color (unlike `fontName`'s marker,
275
+ * which is free text): an unparseable string is silently dropped instead of
276
+ * being written to the `color` attribute. A hex triplet unlikely to collide
277
+ * with a real token value is used, and Chromium/Firefox both echo it back
278
+ * verbatim on the `<font color>` attribute (verified empirically).
279
+ */
280
+ const COLOR_MARKER = '#010203';
281
+ /** Applies a text color to the selection (see {@link convertColorMarkers}). */
282
+ function applyTextColor() {
283
+ document.execCommand('foreColor', false, COLOR_MARKER);
284
+ }
285
+ /** Rewrites the `<font>` elements `foreColor` just produced into `<span class>`. */
286
+ function convertColorMarkers(root, className) {
287
+ convertMarkers(root, `font[color="${COLOR_MARKER}"]`, className);
288
+ }
289
+ /** Text color active at the caret, or `null` when the text uses the default. */
290
+ function readTextColor(node) {
291
+ return findClassKey(node, EDITOR_COLORS);
292
+ }
293
+ /**
294
+ * Marker handed to `hiliteColor`, immediately rewritten into a class.
295
+ *
296
+ * Unlike `fontName`/`fontSize`/`foreColor`, `hiliteColor` does **not** emit a
297
+ * `<font>` element: verified empirically (Playwright, Chromium + Firefox)
298
+ * that it always produces `<span style="background-color: rgb(r, g, b);">`,
299
+ * converting whatever color is handed to it — including a hex marker — to an
300
+ * `rgb(...)` triplet in the `style` attribute. `HILITE_MARKER` is therefore
301
+ * kept as the hex value passed to the command, and `HILITE_MARKER_RGB` as the
302
+ * exact `rgb(...)` string both browsers echo back for it, used to build the
303
+ * `[style*="…"]` selector `convertHighlightMarkers` matches on.
304
+ */
305
+ const HILITE_MARKER = '#040506';
306
+ /** @internal `rgb(...)` form both Chromium and Firefox normalize `HILITE_MARKER` to. */
307
+ const HILITE_MARKER_RGB = 'rgb(4, 5, 6)';
308
+ /** Applies a highlight color to the selection (see {@link convertHighlightMarkers}). */
309
+ function applyHighlightColor() {
310
+ document.execCommand('hiliteColor', false, HILITE_MARKER);
311
+ }
312
+ /** Rewrites the `<span style>` elements `hiliteColor` just produced into `<span class>`. */
313
+ function convertHighlightMarkers(root, className) {
314
+ convertMarkers(root, `[style*="background-color: ${HILITE_MARKER_RGB}"]`, className);
315
+ }
316
+ /** Highlight color active at the caret, or `null` when the text carries none. */
317
+ function readHighlightColor(node) {
318
+ return findClassKey(node, EDITOR_HIGHLIGHTS);
319
+ }
320
+ /**
321
+ * Strips a color/highlight class from every element carrying it inside
322
+ * `range`, unwrapping the element when nothing else justifies it (a plain
323
+ * `<span>` holding only that class).
324
+ *
325
+ * Used by the pickers' "no color" swatch: `foreColor`/`hiliteColor` can only
326
+ * set a color, there is no native command to remove one, so this undoes what
327
+ * {@link convertColorMarkers}/{@link convertHighlightMarkers} previously wrote.
328
+ */
329
+ function clearMarkerClass(root, range, className) {
330
+ for (const el of Array.from(root.querySelectorAll(`.${className}`))) {
331
+ if (!range.intersectsNode(el))
332
+ continue;
333
+ el.classList.remove(className);
334
+ if (el.classList.length > 0)
335
+ continue;
336
+ el.removeAttribute('class');
337
+ if (el.tagName === 'SPAN' && el.attributes.length === 0) {
338
+ el.replaceWith(...Array.from(el.childNodes));
339
+ }
340
+ }
341
+ }
342
+ /**
343
+ * Strips every font/size/color/highlight class the editor writes, from
344
+ * whatever intersects `range`.
345
+ *
346
+ * `removeFormat` (the `clearFormat` tool's native command) only knows inline
347
+ * formatting the browser itself applies (bold, italic, underline…) — it never
348
+ * touches the `<span class="ui-editor-*">` wrappers `fontFamily`/`fontSize`/
349
+ * `textColor`/`highlightColor` write, so "Clear formatting" needs this on top
350
+ * of it to actually clear everything.
351
+ */
352
+ function clearFormatMarkers(root, range) {
353
+ for (const className of [...FONT_CLASSES, ...SIZE_CLASSES, ...COLOR_CLASSES, ...HIGHLIGHT_CLASSES]) {
354
+ clearMarkerClass(root, range, className);
355
+ }
356
+ }
357
+ /** @internal Nearest ancestor carrying one of the given classes. */
358
+ function findClassKey(node, table) {
359
+ let el = node?.nodeType === Node.ELEMENT_NODE ? node : (node?.parentElement ?? null);
360
+ while (el) {
361
+ const match = table.find((entry) => el.classList?.contains(entry.className));
362
+ if (match)
363
+ return match.key;
364
+ el = el.parentElement;
365
+ }
366
+ return null;
367
+ }
368
+ /** Wraps the current selection in a link (`removeFormat` alone cannot unlink). */
369
+ function applyLink(href) {
370
+ document.execCommand('createLink', false, href);
371
+ }
372
+ /** Removes the link around the caret. */
373
+ function removeLink() {
374
+ document.execCommand('unlink', false);
375
+ }
376
+ /** Reads the formatting active at the caret. */
377
+ function readEditorState() {
378
+ const state = emptyEditorState();
379
+ for (const tool of TOGGLE_TOOLS) {
380
+ try {
381
+ state[tool] = document.queryCommandState(NATIVE_COMMAND[tool]);
382
+ }
383
+ catch {
384
+ // queryCommandState throws when the document has no selection yet.
385
+ state[tool] = false;
386
+ }
387
+ }
388
+ state.codeBlock = isInCodeBlock();
389
+ return state;
390
+ }
391
+ /** Inserts already-sanitised markup at the caret, replacing the selection. */
392
+ function insertHtml(html) {
393
+ document.execCommand('insertHTML', false, html);
394
+ }
395
+ /** Inserts plain text at the caret, replacing the selection. */
396
+ function insertText(text) {
397
+ document.execCommand('insertText', false, text);
398
+ }
399
+ // --- Content normalisation ---------------------------------------------
400
+ /** Inline + block tags the editor is allowed to produce or to accept on paste. */
401
+ const ALLOWED_TAGS = new Set([
402
+ 'B',
403
+ 'STRONG',
404
+ 'I',
405
+ 'EM',
406
+ 'U',
407
+ 'A',
408
+ 'UL',
409
+ 'OL',
410
+ 'LI',
411
+ 'P',
412
+ 'BR',
413
+ 'DIV',
414
+ 'SPAN',
415
+ 'PRE',
416
+ 'CODE',
417
+ 'H1',
418
+ 'H2',
419
+ 'H3',
420
+ ]);
421
+ /**
422
+ * Tags dropped WITH their content, instead of being unwrapped.
423
+ *
424
+ * Unwrapping keeps the text of a rejected element, which is what we want for a
425
+ * heading or a table cell — but a script or stylesheet body would then land in
426
+ * the document as visible text.
427
+ */
428
+ const VOIDED_TAGS = 'script, style, noscript, iframe, object, embed, template, title, meta, link';
429
+ /** Only `href` survives, and only on a link. */
430
+ const ALLOWED_HREF_PROTOCOLS = ['http:', 'https:', 'mailto:', 'tel:'];
431
+ /**
432
+ * Strips everything outside the whitelist, keeping the text of dropped elements.
433
+ *
434
+ * Runs on paste, on top of Angular's `DomSanitizer`: the sanitizer removes what is
435
+ * dangerous, this removes what is merely foreign to the editor (Word spans, inline
436
+ * styles, headings, tables) so the value stays a small, predictable HTML subset.
437
+ */
438
+ function normalizeHtml(html) {
439
+ if (typeof document === 'undefined')
440
+ return html;
441
+ const template = document.createElement('template');
442
+ /* eslint-disable-next-line no-restricted-syntax -- EXCEPTION JUSTIFIÉE :
443
+ `<template>` détaché, contenu inerte — étape de parsing du scrub, pas une
444
+ injection dans le document. Registre : docs/SECURITY-PRACTICES.md. */
445
+ template.innerHTML = html;
446
+ scrubNode(template.content);
447
+ return template.innerHTML;
448
+ }
449
+ /**
450
+ * Applies the same scrubbing to a live element, in place.
451
+ *
452
+ * `insertHTML` re-decorates what it inserts (`style="background-color: transparent"`
453
+ * and friends) *after* our normalisation, so the markup has to be cleaned once more
454
+ * once it is in the document. Attributes are removed node by node rather than by
455
+ * rewriting `innerHTML`, which would drop the caret.
456
+ */
457
+ function scrubInPlace(root) {
458
+ scrubNode(root);
459
+ }
460
+ /** @internal Unwraps disallowed elements, voids the unsafe ones, drops attributes. */
461
+ function scrubNode(root) {
462
+ for (const el of Array.from(root.querySelectorAll(VOIDED_TAGS)))
463
+ el.remove();
464
+ for (const el of Array.from(root.querySelectorAll('*'))) {
465
+ if (!ALLOWED_TAGS.has(el.tagName)) {
466
+ el.replaceWith(...Array.from(el.childNodes));
467
+ continue;
468
+ }
469
+ for (const attr of Array.from(el.attributes)) {
470
+ if (attr.name === 'class') {
471
+ // Only the editor's own font/size/color classes survive — anything else
472
+ // pasted in would style the value against a foreign stylesheet.
473
+ const kept = attr.value
474
+ .split(/\s+/)
475
+ .filter((c) => FONT_CLASSES.has(c) ||
476
+ SIZE_CLASSES.has(c) ||
477
+ COLOR_CLASSES.has(c) ||
478
+ HIGHLIGHT_CLASSES.has(c));
479
+ if (kept.length)
480
+ el.setAttribute('class', kept.join(' '));
481
+ else
482
+ el.removeAttribute('class');
483
+ continue;
484
+ }
485
+ const keep = el.tagName === 'A' && attr.name === 'href' && isSafeHref(attr.value);
486
+ if (!keep)
487
+ el.removeAttribute(attr.name);
488
+ }
489
+ }
490
+ }
491
+ /** @internal Rejects `javascript:` and other non-navigational schemes. */
492
+ function isSafeHref(href) {
493
+ try {
494
+ return ALLOWED_HREF_PROTOCOLS.includes(new URL(href, document.baseURI).protocol);
495
+ }
496
+ catch {
497
+ return false;
498
+ }
499
+ }
500
+ /** Normalises a browser-produced empty document (`<br>`, empty block) to `''`. */
501
+ function isEmptyHtml(html) {
502
+ return htmlToText(html).length === 0 && !/<(img|hr)\b/i.test(html);
503
+ }
504
+ /** Plain-text projection of the value — what the character counter measures. */
505
+ function htmlToText(html) {
506
+ if (!html)
507
+ return '';
508
+ if (typeof document === 'undefined') {
509
+ // SSR fallback: good enough for a length, never rendered.
510
+ return html.replace(/<[^>]*>/g, '').trim();
511
+ }
512
+ const template = document.createElement('template');
513
+ /* eslint-disable-next-line no-restricted-syntax -- EXCEPTION JUSTIFIÉE :
514
+ `<template>` détaché, contenu inerte, jamais rendu — on n'en lit que
515
+ `textContent` pour compter les caractères. Registre :
516
+ docs/SECURITY-PRACTICES.md. */
517
+ template.innerHTML = html;
518
+ return (template.content.textContent ?? '').trim();
519
+ }
520
+
521
+ /** Keyboard shortcut → tool (the browser applies these natively; we mirror the state). */
522
+ const SHORTCUTS = { b: 'bold', i: 'italic', u: 'underline' };
523
+ /**
524
+ * ui-editor — headless rich-text field, built on the `ui-field` shell (label +
525
+ * box + helper) in **multiline** mode + a `contenteditable` area and its toolbar.
526
+ *
527
+ * Zero third-party engine: the formatting commands live in `ui-editor-commands`,
528
+ * the single place that touches the legacy editing API. The value is an HTML
529
+ * string, sanitised on the way in (`DomSanitizer`) and normalised to a small tag
530
+ * whitelist on paste.
531
+ *
532
+ * Standalone, `[(ngModel)]` or reactive forms (ControlValueAccessor via BaseFormField).
533
+ */
534
+ class UiEditor extends BaseFormField {
535
+ constructor() {
536
+ super();
537
+ /**
538
+ * Tools shown in the toolbar, in order (`separator` draws a divider).
539
+ *
540
+ * An empty or absent list falls back to the default set: a template binding an
541
+ * optional variable (`[tools]="tools"`) hands us `undefined`, which would
542
+ * otherwise leave the editor without any formatting at all.
543
+ */
544
+ this.tools = input(DEFAULT_EDITOR_TOOLS, { ...(ngDevMode ? { debugName: "tools" } : /* istanbul ignore next */ {}), transform: (value) => value?.length ? value : DEFAULT_EDITOR_TOOLS });
545
+ /** Hint shown while the editor is empty (no native placeholder on contenteditable). */
546
+ this.placeholder = input(/* @ts-ignore */
547
+ ...(ngDevMode ? [undefined, { debugName: "placeholder" }] : /* istanbul ignore next */ []));
548
+ /** Minimum height of the editing area, in lines of text. */
549
+ this.minRows = input(4, /* @ts-ignore */
550
+ ...(ngDevMode ? [{ debugName: "minRows" }] : /* istanbul ignore next */ []));
551
+ /** Maximum number of **text** characters (markup is not counted). */
552
+ this.maxlength = input(/* @ts-ignore */
553
+ ...(ngDevMode ? [undefined, { debugName: "maxlength" }] : /* istanbul ignore next */ []));
554
+ /** Shows a character counter under the field (`count` or `count / maxlength`). */
555
+ this.showCount = input(false, { ...(ngDevMode ? { debugName: "showCount" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
556
+ /** Toolbar placement relative to the editing area. */
557
+ this.toolbarPosition = input('top', /* @ts-ignore */
558
+ ...(ngDevMode ? [{ debugName: "toolbarPosition" }] : /* istanbul ignore next */ []));
559
+ /** Emitted on each edit with the new HTML value. */
560
+ this.valueChange = output();
561
+ /** Emitted when the editing area receives focus. */
562
+ this.editorFocus = output();
563
+ /** Emitted when the editing area loses focus. */
564
+ this.editorBlur = output();
565
+ /** Emitted when the formatting under the caret changes. */
566
+ this.selectionChange = output();
567
+ /** @ignore */
568
+ this.sanitizer = inject(DomSanitizer);
569
+ /** @ignore */
570
+ this.contentEl = viewChild('contentEl', /* @ts-ignore */
571
+ ...(ngDevMode ? [{ debugName: "contentEl" }] : /* istanbul ignore next */ []));
572
+ /** @ignore The rendered toolbar — holds the roving tabindex ring, in DOM order. */
573
+ this.toolbarEl = viewChild('toolbarEl', /* @ts-ignore */
574
+ ...(ngDevMode ? [{ debugName: "toolbarEl" }] : /* istanbul ignore next */ []));
575
+ /** @ignore Text color popup (see {@link onColorToolClick}). */
576
+ this.textColorPicker = viewChild('textColorPicker', /* @ts-ignore */
577
+ ...(ngDevMode ? [{ debugName: "textColorPicker" }] : /* istanbul ignore next */ []));
578
+ /** @ignore Highlight color popup (see {@link onColorToolClick}). */
579
+ this.highlightColorPicker = viewChild('highlightColorPicker', /* @ts-ignore */
580
+ ...(ngDevMode ? [{ debugName: "highlightColorPicker" }] : /* istanbul ignore next */ []));
581
+ /**
582
+ * @ignore Last HTML this component wrote out.
583
+ *
584
+ * The editing area owns its own DOM while the user types, so the value cannot be
585
+ * bound with `[innerHTML]`: re-rendering it on every keystroke would collapse the
586
+ * caret. Instead the DOM is only rewritten when the incoming value differs from
587
+ * what we last emitted — i.e. when a form writes to us.
588
+ */
589
+ this.lastEmitted = '';
590
+ /** @ignore Formatting active at the caret. */
591
+ this.state = signal(emptyEditorState(), /* @ts-ignore */
592
+ ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
593
+ /** @ignore Type family at the caret (`null` = the default family). */
594
+ this.currentFont = signal(null, /* @ts-ignore */
595
+ ...(ngDevMode ? [{ debugName: "currentFont" }] : /* istanbul ignore next */ []));
596
+ /** @ignore Text size at the caret (`null` = the default size). */
597
+ this.currentSize = signal(null, /* @ts-ignore */
598
+ ...(ngDevMode ? [{ debugName: "currentSize" }] : /* istanbul ignore next */ []));
599
+ /** @ignore Text color at the caret (`null` = the default color). */
600
+ this.currentTextColor = signal(null, /* @ts-ignore */
601
+ ...(ngDevMode ? [{ debugName: "currentTextColor" }] : /* istanbul ignore next */ []));
602
+ /** @ignore Highlight color at the caret (`null` = no highlight). */
603
+ this.currentHighlightColor = signal(null, /* @ts-ignore */
604
+ ...(ngDevMode ? [{ debugName: "currentHighlightColor" }] : /* istanbul ignore next */ []));
605
+ /** @ignore Index of the toolbar button reachable with Tab (roving tabindex). */
606
+ this.activeTool = signal(0, /* @ts-ignore */
607
+ ...(ngDevMode ? [{ debugName: "activeTool" }] : /* istanbul ignore next */ []));
608
+ /** @ignore Open state of the `textColor` popup (drives its trigger's `aria-expanded`). */
609
+ this.textColorPickerOpen = signal(false, /* @ts-ignore */
610
+ ...(ngDevMode ? [{ debugName: "textColorPickerOpen" }] : /* istanbul ignore next */ []));
611
+ /** @ignore Open state of the `highlightColor` popup (drives its trigger's `aria-expanded`). */
612
+ this.highlightColorPickerOpen = signal(false, /* @ts-ignore */
613
+ ...(ngDevMode ? [{ debugName: "highlightColorPickerOpen" }] : /* istanbul ignore next */ []));
614
+ /**
615
+ * @ignore Last selection seen inside the editing area.
616
+ *
617
+ * The buttons cancel their own mousedown and never take the focus, but opening
618
+ * the font dropdown does — and a `contenteditable` loses its selection with it.
619
+ * The range is therefore kept here and restored before the command runs.
620
+ */
621
+ this.savedRange = null;
622
+ /** @ignore Sanitised value — never inject `modelValue` into the DOM raw. */
623
+ this.safeValue = computed(() => this.sanitizer.sanitize(SecurityContext.HTML, this.modelValue() ?? '') ?? '', /* @ts-ignore */
624
+ ...(ngDevMode ? [{ debugName: "safeValue" }] : /* istanbul ignore next */ []));
625
+ /** @ignore Plain-text length, what `maxlength` and the counter measure. */
626
+ this.charCount = computed(() => htmlToText(this.safeValue()).length, /* @ts-ignore */
627
+ ...(ngDevMode ? [{ debugName: "charCount" }] : /* istanbul ignore next */ []));
628
+ /** @ignore Keeps a floating label raised once focus leaves. */
629
+ this.isFilled = computed(() => this.charCount() > 0, /* @ts-ignore */
630
+ ...(ngDevMode ? [{ debugName: "isFilled" }] : /* istanbul ignore next */ []));
631
+ /** @ignore Over the maxlength (only reachable programmatically). */
632
+ this.overLimit = computed(() => {
633
+ const max = this.maxlength();
634
+ return max != null && this.charCount() > max;
635
+ }, /* @ts-ignore */
636
+ ...(ngDevMode ? [{ debugName: "overLimit" }] : /* istanbul ignore next */ []));
637
+ /** @ignore The placeholder only shows while there is nothing to read. */
638
+ this.showPlaceholder = computed(() => !!this.placeholder() && !this.hasFloatLabel() && this.charCount() === 0, /* @ts-ignore */
639
+ ...(ngDevMode ? [{ debugName: "showPlaceholder" }] : /* istanbul ignore next */ []));
640
+ /** @ignore The area is editable (a read-only editor keeps its caret but not its edits). */
641
+ this.isEditable = computed(() => !this.isDisabled() && !this.readonly(), /* @ts-ignore */
642
+ ...(ngDevMode ? [{ debugName: "isEditable" }] : /* istanbul ignore next */ []));
643
+ /** @ignore Resolved toolbar entries (icon + accessible name + toggle state). */
644
+ this.toolbar = computed(() => this.tools().map((tool, index) => ({
645
+ tool,
646
+ index,
647
+ isSeparator: tool === 'separator',
648
+ select: (EDITOR_SELECT_TOOLS.includes(tool)
649
+ ? tool
650
+ : null),
651
+ buttonTool: (tool === 'separator' || EDITOR_SELECT_TOOLS.includes(tool)
652
+ ? null
653
+ : tool),
654
+ meta: tool === 'separator' || EDITOR_SELECT_TOOLS.includes(tool)
655
+ ? null
656
+ : EDITOR_TOOL_META[tool],
657
+ })), /* @ts-ignore */
658
+ ...(ngDevMode ? [{ debugName: "toolbar" }] : /* istanbul ignore next */ []));
659
+ /** @ignore Text sizes offered by the `fontSize` dropdown. */
660
+ this.sizes = EDITOR_SIZES;
661
+ /**
662
+ * @ignore Type families, labelled with the face each token actually resolves to.
663
+ *
664
+ * Read once the view exists, since the value comes from the computed style: a
665
+ * hardcoded "Inter" would lie as soon as a project rebinds the token.
666
+ */
667
+ this.fonts = signal(EDITOR_FONTS.map((f) => ({ ...f })), /* @ts-ignore */
668
+ ...(ngDevMode ? [{ debugName: "fonts" }] : /* istanbul ignore next */ []));
669
+ /** @ignore `fontFamily` dropdown options ({@link UiSelect} `optionLabel`/`optionValue`). */
670
+ this.fontFamilyOptions = computed(() => this.fonts().map((font) => ({ value: font.key, label: font.label })), /* @ts-ignore */
671
+ ...(ngDevMode ? [{ debugName: "fontFamilyOptions" }] : /* istanbul ignore next */ []));
672
+ /** @ignore `fontSize` dropdown options ({@link UiSelect} `optionLabel`/`optionValue`). */
673
+ this.fontSizeOptions = computed(() => this.sizes.map((size) => ({ value: size.key, label: size.label })), /* @ts-ignore */
674
+ ...(ngDevMode ? [{ debugName: "fontSizeOptions" }] : /* istanbul ignore next */ []));
675
+ /** @ignore Swatch entry backing the `textColor` button's color indicator. */
676
+ this.currentTextColorSwatch = computed(() => EDITOR_COLORS.find((c) => c.key === this.currentTextColor()), /* @ts-ignore */
677
+ ...(ngDevMode ? [{ debugName: "currentTextColorSwatch" }] : /* istanbul ignore next */ []));
678
+ /** @ignore Swatch entry backing the `highlightColor` button's color indicator. */
679
+ this.currentHighlightColorSwatch = computed(() => EDITOR_HIGHLIGHTS.find((c) => c.key === this.currentHighlightColor()), /* @ts-ignore */
680
+ ...(ngDevMode ? [{ debugName: "currentHighlightColorSwatch" }] : /* istanbul ignore next */ []));
681
+ /** @ignore The toolbar has at least one actionable entry. */
682
+ this.hasToolbar = computed(() => this.tools().some((t) => t !== 'separator'), /* @ts-ignore */
683
+ ...(ngDevMode ? [{ debugName: "hasToolbar" }] : /* istanbul ignore next */ []));
684
+ /**
685
+ * @ignore Index carrying the toolbar's single tab stop.
686
+ *
687
+ * Falls back to the first actionable tool, so a `tools` list opening on a
688
+ * separator still leaves the toolbar reachable with Tab.
689
+ */
690
+ this.tabStop = computed(() => {
691
+ const actionable = this.toolbar().filter((entry) => !entry.isSeparator);
692
+ if (!actionable.length)
693
+ return -1;
694
+ const active = this.activeTool();
695
+ return actionable.some((entry) => entry.index === active) ? active : actionable[0].index;
696
+ }, /* @ts-ignore */
697
+ ...(ngDevMode ? [{ debugName: "tabStop" }] : /* istanbul ignore next */ []));
698
+ /** @ignore id of the character counter (for `aria-describedby`). */
699
+ this.countId = computed(() => `${this.resolvedId()}-count`, /* @ts-ignore */
700
+ ...(ngDevMode ? [{ debugName: "countId" }] : /* istanbul ignore next */ []));
701
+ /** @ignore `aria-describedby` combines the message and the counter, whichever are shown. */
702
+ this.describedByIds = computed(() => {
703
+ const ids = [
704
+ this.displayMessage() ? this.messageId() : null,
705
+ this.showCount() ? this.countId() : null,
706
+ ].filter(Boolean);
707
+ return ids.length ? ids.join(' ') : null;
708
+ }, /* @ts-ignore */
709
+ ...(ngDevMode ? [{ debugName: "describedByIds" }] : /* istanbul ignore next */ []));
710
+ // Label each family with the face its token actually resolves to.
711
+ afterNextRender(() => {
712
+ this.fonts.set(EDITOR_FONTS.map((f) => ({ ...f, label: resolveFontLabel(f.cssVar, f.label) })));
713
+ });
714
+ // Sync the DOM when the value comes from outside (form write, reset).
715
+ effect(() => {
716
+ const value = this.safeValue();
717
+ const el = this.contentEl()?.nativeElement;
718
+ if (!el)
719
+ return;
720
+ // Already on screen, or the value we just read back from the user's own
721
+ // edit: rewriting would collapse the caret mid-keystroke. Comparing the
722
+ // live DOM too covers the case where sanitising reshapes the markup.
723
+ if (el.innerHTML === value || value === this.lastEmitted)
724
+ return;
725
+ /* eslint-disable-next-line no-restricted-syntax -- EXCEPTION JUSTIFIÉE :
726
+ `value` vient de `safeValue()`, donc de
727
+ `DomSanitizer.sanitize(SecurityContext.HTML, …)`. L'écriture directe est
728
+ imposée par le `contenteditable` : une liaison `[innerHTML]` réécrirait
729
+ la zone à chaque frappe et effondrerait le caret. Registre :
730
+ docs/SECURITY-PRACTICES.md. */
731
+ el.innerHTML = value;
732
+ this.lastEmitted = value;
733
+ });
734
+ }
735
+ /** @ignore Auto-generated ids read as `ui-editor-*`. */
736
+ uidPrefix() {
737
+ return 'ui-editor';
738
+ }
739
+ /** Focuses the editing area. */
740
+ focus(options) {
741
+ this.contentEl()?.nativeElement.focus(options);
742
+ }
743
+ // --- Editing ----------------------------------------------------------
744
+ /** @ignore Input: single source of the value (view → form). */
745
+ onInput() {
746
+ const el = this.contentEl()?.nativeElement;
747
+ if (!el)
748
+ return;
749
+ const html = isEmptyHtml(el.innerHTML) ? '' : el.innerHTML;
750
+ this.lastEmitted = html;
751
+ this.modelValue.set(html);
752
+ this.emitChange(html);
753
+ this.valueChange.emit(html);
754
+ this.refreshState();
755
+ }
756
+ /**
757
+ * @ignore Enforces `maxlength` on the text, not the markup.
758
+ *
759
+ * Deletions and formatting must stay available once the limit is reached, so only
760
+ * the insertion intents are cancelled.
761
+ */
762
+ onBeforeInput(event) {
763
+ const max = this.maxlength();
764
+ if (max == null || !event.inputType.startsWith('insert'))
765
+ return;
766
+ const selection = document.getSelection();
767
+ const replaced = selection && !selection.isCollapsed ? selection.toString().length : 0;
768
+ const incoming = event.data?.length ?? 1;
769
+ if (this.charCount() - replaced + incoming > max)
770
+ event.preventDefault();
771
+ }
772
+ /** @ignore Paste is reduced to the editor's own tag whitelist. */
773
+ onPaste(event) {
774
+ if (!this.isEditable())
775
+ return;
776
+ event.preventDefault();
777
+ const clipboard = event.clipboardData;
778
+ if (!clipboard)
779
+ return;
780
+ const html = clipboard.getData('text/html');
781
+ if (html) {
782
+ const safe = this.sanitizer.sanitize(SecurityContext.HTML, normalizeHtml(html)) ?? '';
783
+ insertHtml(safe);
784
+ // `insertHTML` re-decorates what it inserted; strip that back off in place.
785
+ const el = this.contentEl()?.nativeElement;
786
+ if (el)
787
+ scrubInPlace(el);
788
+ }
789
+ else {
790
+ insertText(clipboard.getData('text/plain'));
791
+ }
792
+ this.onInput();
793
+ }
794
+ /** @ignore The browser applies Ctrl/Cmd+B/I/U itself; we only mirror the state. */
795
+ onContentKeydown(event) {
796
+ if (!(event.metaKey || event.ctrlKey))
797
+ return;
798
+ if (!SHORTCUTS[event.key.toLowerCase()])
799
+ return;
800
+ // Let the native shortcut run, then read the resulting formatting back.
801
+ queueMicrotask(() => this.refreshState());
802
+ }
803
+ /** @ignore */
804
+ onBlur(event) {
805
+ this.emitTouch();
806
+ this.editorBlur.emit(event);
807
+ }
808
+ /** @ignore Recomputes the active formatting and notifies the consumer. */
809
+ refreshState() {
810
+ this.rememberSelection();
811
+ const anchor = document.getSelection()?.anchorNode ?? null;
812
+ this.currentFont.set(readFontFamily(anchor));
813
+ this.currentSize.set(readFontSize(anchor));
814
+ this.currentTextColor.set(readTextColor(anchor));
815
+ this.currentHighlightColor.set(readHighlightColor(anchor));
816
+ const next = readEditorState();
817
+ const prev = this.state();
818
+ if (Object.keys(next).every((k) => next[k] === prev[k]))
819
+ return;
820
+ this.state.set(next);
821
+ this.selectionChange.emit(next);
822
+ }
823
+ /** @ignore Keeps the caret position around for controls that steal the focus. */
824
+ rememberSelection() {
825
+ const el = this.contentEl()?.nativeElement;
826
+ const selection = document.getSelection();
827
+ if (!el || !selection?.rangeCount)
828
+ return;
829
+ const range = selection.getRangeAt(0);
830
+ if (el.contains(range.commonAncestorContainer))
831
+ this.savedRange = range.cloneRange();
832
+ }
833
+ /** @ignore Puts the remembered caret back before running a command. */
834
+ restoreSelection() {
835
+ this.focus();
836
+ const range = this.savedRange;
837
+ if (!range)
838
+ return;
839
+ const selection = document.getSelection();
840
+ selection?.removeAllRanges();
841
+ selection?.addRange(range);
842
+ }
843
+ // --- Toolbar ----------------------------------------------------------
844
+ /** @ignore Runs a button tool against the selection the mousedown handler preserved. */
845
+ runTool(tool, index, event) {
846
+ if (!this.isEditable())
847
+ return;
848
+ this.activeTool.set(index);
849
+ if (tool === 'textColor' || tool === 'highlightColor') {
850
+ this.onColorToolClick(tool, event);
851
+ return;
852
+ }
853
+ this.focus();
854
+ if (tool === 'link')
855
+ this.promptForLink();
856
+ else if (tool === 'codeBlock')
857
+ toggleCodeBlock();
858
+ else if (tool === 'clearFormat')
859
+ this.clearFormat();
860
+ else
861
+ applyCommand(tool);
862
+ this.onInput();
863
+ }
864
+ /**
865
+ * @ignore `removeFormat` (the native command behind `clearFormat`) only
866
+ * strips inline formatting the browser itself applies — bold, italic,
867
+ * underline… — never the `<span class="ui-editor-*">` wrappers `fontFamily`/
868
+ * `fontSize`/`textColor`/`highlightColor` write, so those survived
869
+ * "Effacer le formatage" untouched. Run the native command, then unwrap
870
+ * those classes too, across whatever is currently selected.
871
+ */
872
+ clearFormat() {
873
+ applyCommand('clearFormat');
874
+ const el = this.contentEl()?.nativeElement;
875
+ const selection = document.getSelection();
876
+ if (!el || !selection?.rangeCount)
877
+ return;
878
+ const range = selection.getRangeAt(0);
879
+ if (!el.contains(range.commonAncestorContainer))
880
+ return;
881
+ clearFormatMarkers(el, range);
882
+ }
883
+ /**
884
+ * @ignore Trigger click for `textColor`/`highlightColor`: opens the matching
885
+ * `ui-swatch-picker` instead of applying a command directly — same
886
+ * "picker takes the focus, the caret is restored before the real command
887
+ * runs" pattern as {@link onSelectMenuTrigger}, but these two are button
888
+ * tools (a one-shot action button, not a value dropdown), so they run
889
+ * through `runTool` rather than `onSelectChange`.
890
+ */
891
+ onColorToolClick(tool, event) {
892
+ this.rememberSelection();
893
+ const picker = tool === 'textColor' ? this.textColorPicker() : this.highlightColorPicker();
894
+ picker?.toggle(event);
895
+ }
896
+ /**
897
+ * @ignore Applies the text color chosen in the `textColor` picker.
898
+ *
899
+ * The popup took the focus, so the caret is put back first. `foreColor`
900
+ * emits a legacy `<font>` element, immediately rewritten into a class.
901
+ */
902
+ onTextColorSelect(swatch) {
903
+ if (!this.isEditable())
904
+ return;
905
+ this.restoreSelection();
906
+ const el = this.contentEl()?.nativeElement;
907
+ if (swatch) {
908
+ applyTextColor();
909
+ if (el)
910
+ convertColorMarkers(el, `ui-editor-color-${swatch.key}`);
911
+ }
912
+ else if (el && this.savedRange) {
913
+ for (const color of EDITOR_COLORS)
914
+ clearMarkerClass(el, this.savedRange, color.className);
915
+ }
916
+ this.onInput();
917
+ }
918
+ /**
919
+ * @ignore Applies the highlight color chosen in the `highlightColor` picker.
920
+ *
921
+ * The popup took the focus, so the caret is put back first. `hiliteColor`
922
+ * emits a `<span style="background-color:…">`, immediately rewritten into a
923
+ * class (see {@link convertHighlightMarkers}).
924
+ */
925
+ onHighlightColorSelect(swatch) {
926
+ if (!this.isEditable())
927
+ return;
928
+ this.restoreSelection();
929
+ const el = this.contentEl()?.nativeElement;
930
+ if (swatch) {
931
+ applyHighlightColor();
932
+ if (el)
933
+ convertHighlightMarkers(el, `ui-editor-highlight-${swatch.key}`);
934
+ }
935
+ else if (el && this.savedRange) {
936
+ for (const color of EDITOR_HIGHLIGHTS) {
937
+ clearMarkerClass(el, this.savedRange, color.className);
938
+ }
939
+ }
940
+ this.onInput();
941
+ }
942
+ /** @ignore Options for a `ui-select` dropdown ({@link UiSelect} `optionLabel`/`optionValue`). */
943
+ selectOptions(tool) {
944
+ return tool === 'fontFamily' ? this.fontFamilyOptions() : this.fontSizeOptions();
945
+ }
946
+ /**
947
+ * @ignore Current value of a `ui-select` dropdown, so it reflects the caret.
948
+ *
949
+ * Falls back to the value actually in force when no class was applied: text
950
+ * carrying no class really is rendered with `--fontfamily-base` at the
951
+ * default size, so naming it states a fact rather than a placeholder.
952
+ */
953
+ selectValue(tool) {
954
+ if (tool === 'fontFamily')
955
+ return this.currentFont() ?? 'base';
956
+ return this.currentSize() ?? 'default';
957
+ }
958
+ /** @ignore Accessible name of a dropdown — spelled out, it is never truncated. */
959
+ selectLabel(tool) {
960
+ if (tool === 'fontFamily')
961
+ return 'Police';
962
+ return 'Taille du texte';
963
+ }
964
+ /**
965
+ * @ignore Applies the value chosen in a `ui-select` dropdown.
966
+ *
967
+ * `ui-select` opens its own overlay and takes the focus, so the caret is put
968
+ * back first — same reasoning as the color pickers. `fontName`/`fontSize`
969
+ * each emit a legacy `<font>` element, immediately rewritten into a class.
970
+ */
971
+ onSelectValueChange(tool, value, index) {
972
+ this.activeTool.set(index);
973
+ if (!this.isEditable() || value == null)
974
+ return;
975
+ this.restoreSelection();
976
+ const el = this.contentEl()?.nativeElement;
977
+ if (tool === 'fontFamily') {
978
+ const choice = this.fonts().find((f) => f.key === value);
979
+ if (!choice)
980
+ return;
981
+ applyFontFamily();
982
+ if (el)
983
+ convertFontMarkers(el, choice.className);
984
+ }
985
+ else {
986
+ const choice = this.sizes.find((s) => s.key === value);
987
+ if (!choice)
988
+ return;
989
+ applyFontSize();
990
+ if (el)
991
+ convertSizeMarkers(el, choice.className);
992
+ }
993
+ this.onInput();
994
+ }
995
+ /**
996
+ * @ignore v1 link flow: the native prompt.
997
+ *
998
+ * Deliberately minimal — a popover with a `ui-input` is the planned replacement,
999
+ * and it changes the component's overlay footprint, not this call site.
1000
+ */
1001
+ promptForLink() {
1002
+ const href = window.prompt('Adresse du lien (laisser vide pour retirer le lien)');
1003
+ if (href === null)
1004
+ return;
1005
+ if (href.trim() === '')
1006
+ removeLink();
1007
+ else
1008
+ applyLink(href.trim());
1009
+ }
1010
+ /** @ignore Keeps the caret in the editing area when a tool is clicked. */
1011
+ onToolbarMousedown(event) {
1012
+ event.preventDefault();
1013
+ }
1014
+ /** @ignore Roving tabindex: the toolbar is one tab stop, arrows move within it. */
1015
+ onToolbarKeydown(event) {
1016
+ const indexes = this.toolbar()
1017
+ .filter((entry) => !entry.isSeparator)
1018
+ .map((entry) => entry.index);
1019
+ if (!indexes.length)
1020
+ return;
1021
+ const current = Math.max(0, indexes.indexOf(this.tabStop()));
1022
+ let next;
1023
+ switch (event.key) {
1024
+ case 'ArrowRight':
1025
+ next = indexes[(current + 1) % indexes.length];
1026
+ break;
1027
+ case 'ArrowLeft':
1028
+ next = indexes[(current - 1 + indexes.length) % indexes.length];
1029
+ break;
1030
+ case 'Home':
1031
+ next = indexes[0];
1032
+ break;
1033
+ case 'End':
1034
+ next = indexes[indexes.length - 1];
1035
+ break;
1036
+ case 'Escape':
1037
+ event.preventDefault();
1038
+ this.focus();
1039
+ return;
1040
+ default:
1041
+ return;
1042
+ }
1043
+ event.preventDefault();
1044
+ this.activeTool.set(next);
1045
+ this.focusTool(next);
1046
+ }
1047
+ /**
1048
+ * @ignore Moves the DOM focus onto the control now holding the tab stop.
1049
+ *
1050
+ * Queried from the live toolbar rather than from the `ui-button` children:
1051
+ * DOM order is the visual order, and every tool (buttons and select-menu
1052
+ * triggers alike) renders as a `<button>`.
1053
+ */
1054
+ focusTool(index) {
1055
+ const position = this.toolbar().filter((e) => !e.isSeparator && e.index <= index).length - 1;
1056
+ const controls = this.toolbarEl()?.nativeElement.querySelectorAll('button');
1057
+ controls?.[position]?.focus();
1058
+ }
1059
+ /**
1060
+ * @ignore `var(--primitives-…)` for the `textColor`/`highlightColor`
1061
+ * buttons' color indicator, or `null` for every other tool (no swatch
1062
+ * active, or a tool the indicator does not apply to).
1063
+ */
1064
+ colorIndicatorVar(tool) {
1065
+ const swatch = tool === 'textColor'
1066
+ ? this.currentTextColorSwatch()
1067
+ : tool === 'highlightColor'
1068
+ ? this.currentHighlightColorSwatch()
1069
+ : null;
1070
+ return swatch ? `var(${swatch.cssVar})` : null;
1071
+ }
1072
+ /**
1073
+ * @ignore Native attributes forwarded to a tool button.
1074
+ *
1075
+ * `aria-pressed` only on the toggles: `link` and `clearFormat` are one-shot
1076
+ * actions, and a permanently unpressed toggle would misreport them.
1077
+ * `textColor`/`highlightColor` forward `aria-haspopup`/`aria-expanded`
1078
+ * instead — they open a `ui-swatch-picker` popup, not a toggle.
1079
+ */
1080
+ toolProps(tool) {
1081
+ if (tool === 'textColor' || tool === 'highlightColor') {
1082
+ const open = tool === 'textColor' ? this.textColorPickerOpen() : this.highlightColorPickerOpen();
1083
+ return { 'aria-haspopup': 'true', 'aria-expanded': open ? 'true' : 'false' };
1084
+ }
1085
+ const state = this.state();
1086
+ if (!(tool in state))
1087
+ return undefined;
1088
+ return { 'aria-pressed': state[tool] ? 'true' : 'false' };
1089
+ }
1090
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.2", ngImport: i0, type: UiEditor, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1091
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.2", type: UiEditor, isStandalone: true, selector: "ui-editor", inputs: { tools: { classPropertyName: "tools", publicName: "tools", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, minRows: { classPropertyName: "minRows", publicName: "minRows", isSignal: true, isRequired: false, transformFunction: null }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, showCount: { classPropertyName: "showCount", publicName: "showCount", isSignal: true, isRequired: false, transformFunction: null }, toolbarPosition: { classPropertyName: "toolbarPosition", publicName: "toolbarPosition", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", editorFocus: "editorFocus", editorBlur: "editorBlur", selectionChange: "selectionChange" }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => UiEditor), multi: true }], viewQueries: [{ propertyName: "contentEl", first: true, predicate: ["contentEl"], descendants: true, isSignal: true }, { propertyName: "toolbarEl", first: true, predicate: ["toolbarEl"], descendants: true, isSignal: true }, { propertyName: "textColorPicker", first: true, predicate: ["textColorPicker"], descendants: true, isSignal: true }, { propertyName: "highlightColorPicker", first: true, predicate: ["highlightColorPicker"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<ui-field\n multiline\n [label]=\"label()\"\n [required]=\"required()\"\n [size]=\"size()\"\n [level]=\"effectiveLevel()\"\n [floatLabel]=\"floatLabel()\"\n [filled]=\"isFilled()\"\n [disabled]=\"isDisabled()\"\n [readonly]=\"readonly()\"\n [message]=\"displayMessage()\"\n [messageId]=\"messageId()\"\n [showMessageIcon]=\"showMessageIcon()\"\n [messageIcon]=\"messageIcon()\"\n [hasFooter]=\"showCount()\"\n>\n <div class=\"ui-editor\" [class._small]=\"size() === 'small'\" [style.--_rows]=\"minRows()\">\n @if (toolbarPosition() === 'top') {\n <ng-container [ngTemplateOutlet]=\"toolbarTpl\" />\n }\n\n <div class=\"ui-editor-area\">\n <div\n #contentEl\n class=\"ui-editor-content\"\n [class._small]=\"size() === 'small'\"\n [id]=\"resolvedId()\"\n role=\"textbox\"\n aria-multiline=\"true\"\n [attr.contenteditable]=\"isEditable() ? 'true' : 'false'\"\n [attr.tabindex]=\"isDisabled() ? -1 : (tabindex() ?? 0)\"\n [attr.aria-label]=\"ariaLabel() || label() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-describedby]=\"describedByIds()\"\n [attr.aria-required]=\"required() ? 'true' : null\"\n [attr.aria-readonly]=\"readonly() ? 'true' : null\"\n [attr.aria-disabled]=\"isDisabled() ? 'true' : null\"\n [attr.aria-invalid]=\"effectiveLevel() === 'error' ? 'true' : null\"\n (input)=\"onInput()\"\n (beforeinput)=\"onBeforeInput($any($event))\"\n (paste)=\"onPaste($event)\"\n (keydown)=\"onContentKeydown($event)\"\n (keyup)=\"refreshState()\"\n (mouseup)=\"refreshState()\"\n (focus)=\"editorFocus.emit($event)\"\n (blur)=\"onBlur($event)\"\n ></div>\n\n @if (showPlaceholder()) {\n <span class=\"ui-editor-placeholder\" aria-hidden=\"true\">{{ placeholder() }}</span>\n }\n </div>\n\n @if (toolbarPosition() === 'bottom') {\n <ng-container [ngTemplateOutlet]=\"toolbarTpl\" />\n }\n </div>\n\n @if (showCount()) {\n <span\n uiFieldFooter\n class=\"ui-editor-count\"\n [class._small]=\"size() === 'small'\"\n [class._disabled]=\"isDisabled()\"\n [class._over]=\"overLimit()\"\n [attr.id]=\"countId()\"\n >\n {{ charCount() }}\n @if (maxlength(); as max) {\n &nbsp;/&nbsp;{{ max }}\n }\n </span>\n }\n</ui-field>\n\n<ng-template #toolbarTpl>\n @if (hasToolbar()) {\n <!-- ARIA toolbar pattern: keyboard delegated to the role=\"toolbar\" container,\n focus lives on the items (roving tabindex), same as ui-menu. -->\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <div\n #toolbarEl\n class=\"ui-editor-toolbar\"\n [class._bottom]=\"toolbarPosition() === 'bottom'\"\n role=\"toolbar\"\n aria-label=\"Mise en forme\"\n aria-orientation=\"horizontal\"\n (mousedown)=\"onToolbarMousedown($event)\"\n (keydown)=\"onToolbarKeydown($event)\"\n >\n @for (entry of toolbar(); track entry.index) {\n @if (entry.isSeparator) {\n <span class=\"ui-editor-toolbar-separator\" aria-hidden=\"true\"></span>\n } @else if (entry.select; as select) {\n <!-- The dropdown takes the focus, so the command restores the caret\n before it runs (see onSelectValueChange). -->\n <ui-select\n class=\"ui-editor-tool ui-editor-select\"\n size=\"small\"\n [options]=\"selectOptions(select)\"\n optionLabel=\"label\"\n optionValue=\"value\"\n [ngModel]=\"selectValue(select)\"\n [ariaLabel]=\"selectLabel(select)\"\n [disabled]=\"!isEditable()\"\n [tabindex]=\"entry.index === tabStop() ? 0 : -1\"\n (valueChange)=\"onSelectValueChange(select, $event, entry.index)\"\n />\n } @else {\n <ui-button\n class=\"ui-editor-tool\"\n [class._colorTool]=\"\n entry.buttonTool === 'textColor' || entry.buttonTool === 'highlightColor'\n \"\n variant=\"ghost\"\n level=\"low\"\n size=\"small\"\n iconOnly\n [icon]=\"entry.meta!.icon\"\n [ariaLabel]=\"entry.meta!.label\"\n [disabled]=\"!isEditable()\"\n [tabindex]=\"entry.index === tabStop() ? 0 : -1\"\n [buttonProps]=\"toolProps(entry.buttonTool!)\"\n [style.--ui-editor-swatch-indicator-color]=\"colorIndicatorVar(entry.buttonTool)\"\n (buttonClick)=\"runTool(entry.buttonTool!, entry.index, $event)\"\n />\n }\n }\n\n <!-- `textColor`/`highlightColor` popups: no trigger of their own (same\n composition contract as `ui-menu`), opened via `runTool` ->\n `onColorToolClick` -> `toggle(event)`. -->\n <ui-swatch-picker\n #textColorPicker\n popup\n size=\"small\"\n [allowClear]=\"true\"\n [value]=\"currentTextColor()\"\n ariaLabel=\"Couleur du texte\"\n (swatchSelect)=\"onTextColorSelect($event)\"\n (opened)=\"textColorPickerOpen.set(true)\"\n (closed)=\"textColorPickerOpen.set(false)\"\n />\n <ui-swatch-picker\n #highlightColorPicker\n popup\n size=\"small\"\n [allowClear]=\"true\"\n [value]=\"currentHighlightColor()\"\n ariaLabel=\"Couleur de surlignage\"\n (swatchSelect)=\"onHighlightColorSelect($event)\"\n (opened)=\"highlightColorPickerOpen.set(true)\"\n (closed)=\"highlightColorPickerOpen.set(false)\"\n />\n </div>\n }\n</ng-template>\n", styles: [".ui-editor{display:flex;flex:1 1 auto;flex-direction:column;min-width:0;border-radius:var(--ui-editor-radius, inherit);overflow:hidden}.ui-editor-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:var(--ui-editor-toolbar-gap, var(--units-2xs));flex-shrink:0;padding:var(--ui-editor-toolbar-padding-y, var(--units-2xs)) var(--ui-editor-toolbar-padding-x, var(--units-xs));background-color:var(--ui-editor-toolbar-surface, var(--global-background-muted));border-block-end:var(--ui-editor-toolbar-stroke-width, var(--ui-control-stroke-width, var(--stroke-default))) solid var(--ui-editor-toolbar-stroke, var(--form-low-stroke-default))}.ui-editor-toolbar._bottom{border-block-end:none;border-block-start:var(--ui-editor-toolbar-stroke-width, var(--ui-control-stroke-width, var(--stroke-default))) solid var(--ui-editor-toolbar-stroke, var(--form-low-stroke-default))}.ui-editor-toolbar-separator{flex-shrink:0;inline-size:var(--ui-editor-separator-width, var(--stroke-sm));block-size:var(--ui-editor-separator-height, var(--size-typography-text-default));background-color:var(--ui-editor-separator-color, var(--form-low-stroke-default))}.ui-editor-select{display:inline-flex;flex-shrink:0;min-inline-size:var(--ui-editor-select-width, 13ch);--ui-field-stroke-width: 0}.ui-editor-select ::ng-deep .ui-select{inline-size:100%}.ui-editor-select ::ng-deep .ui-field-box{background:transparent;transition:background-color var(--ui-control-transition-duration, var(--transition-default)) var(--ui-control-transition-easing, var(--transition-easeinout))}.ui-editor-select ::ng-deep .ui-field-box:hover{background-color:var(--form-low-surface-hover)}.ui-editor-tool._colorTool{position:relative}.ui-editor-tool._colorTool:after{content:\"\";position:absolute;inset-inline:var(--ui-editor-swatch-indicator-offset-x, var(--units-2xs));inset-block-end:0;block-size:var(--ui-editor-swatch-indicator-height, var(--stroke-lg));border-radius:var(--ui-editor-swatch-indicator-height, var(--stroke-lg));background-color:var(--ui-editor-swatch-indicator-color, transparent)}.ui-editor-area{position:relative;display:flex;flex:1 1 auto;min-height:0}.ui-editor-content{flex:1 1 auto;align-self:stretch;min-width:0;margin:0;padding:0;border:none;border-radius:inherit;background:transparent;outline:none;font-family:var(--fontfamily-base);font-size:var(--size-typography-text-default);color:var(--form-high-content-default)}.ui-editor-content::placeholder{color:var(--form-low-content-default);opacity:1}.ui-editor-content:disabled{cursor:not-allowed;color:var(--form-high-content-disabled)}.ui-editor-content{box-sizing:border-box;width:100%;min-height:var(--ui-editor-min-height, calc(var(--_rows, 4) * var(--ui-editor-line-height, 1.5) * 1em));max-height:var(--ui-editor-max-height, none);padding:var(--ui-editor-padding-y, var(--ui-form-textarea-padding-y, var(--units-default))) var(--ui-editor-padding-x, var(--ui-form-field-padding-x, var(--units-md)));overflow-y:auto;line-height:var(--ui-editor-line-height, 1.5);font-size:var(--ui-editor-font-size, var(--size-typography-text-default));overflow-wrap:break-word}.ui-editor-content._small{padding-block:var(--ui-editor-padding-y-small, var(--ui-form-textarea-padding-y-small, var(--units-md)));font-size:var(--ui-editor-font-size-small, var(--size-typography-text-md))}.ui-editor-content:focus,.ui-editor-content:focus-visible{outline:none}.ui-editor-content[contenteditable=false]{cursor:default}.ui-editor-placeholder{position:absolute;inset-block-start:var(--ui-editor-padding-y, var(--ui-form-textarea-padding-y, var(--units-default)));inset-inline-start:var(--ui-editor-padding-x, var(--ui-form-field-padding-x, var(--units-md)));line-height:var(--ui-editor-line-height, 1.5);font-family:var(--fontfamily-base);font-size:var(--ui-editor-font-size, var(--size-typography-text-default));color:var(--ui-editor-placeholder-color, var(--form-low-content-default));pointer-events:none;-webkit-user-select:none;user-select:none}.ui-editor._small .ui-editor-placeholder{inset-block-start:var(--ui-editor-padding-y-small, var(--ui-form-textarea-padding-y-small, var(--units-md)));font-size:var(--ui-editor-font-size-small, var(--size-typography-text-md))}.ui-editor-content ::ng-deep p{margin-block:0 var(--ui-editor-block-gap, var(--units-sm))}.ui-editor-content ::ng-deep p:last-child{margin-block-end:0}.ui-editor-content ::ng-deep ul,.ui-editor-content ::ng-deep ol{margin-block:0 var(--ui-editor-block-gap, var(--units-sm));padding-inline-start:var(--ui-editor-list-padding-inline-start, var(--units-xl))}.ui-editor-content ::ng-deep ul:last-child,.ui-editor-content ::ng-deep ol:last-child{margin-block-end:0}.ui-editor-content ::ng-deep li+li{margin-block-start:var(--ui-editor-list-item-gap, var(--units-2xs))}.ui-editor-content ::ng-deep b,.ui-editor-content ::ng-deep strong{font-weight:var(--ui-editor-bold-weight, var(--weight-bold))}.ui-editor-content ::ng-deep a{color:var(--ui-editor-link-color, var(--global-text-brand));text-decoration:var(--ui-editor-link-text-decoration, underline)}.ui-editor-content ::ng-deep pre{margin-block:0 var(--ui-editor-block-gap, var(--units-sm));padding:var(--ui-editor-code-padding-y, var(--units-sm)) var(--ui-editor-code-padding-x, var(--units-md));border-radius:var(--ui-editor-code-radius, var(--radius-xs));background-color:var(--ui-editor-code-surface, var(--global-background-muted));color:var(--ui-editor-code-color, var(--global-text-default));font-family:var(--fontfamily-monospace);font-size:var(--ui-editor-code-font-size, var(--size-typography-text-md));white-space:pre-wrap;overflow-wrap:break-word}.ui-editor-content ::ng-deep pre:last-child{margin-block-end:0}.ui-editor-content ::ng-deep code{font-family:var(--fontfamily-monospace)}.ui-editor-content ::ng-deep h1,.ui-editor-content ::ng-deep h2,.ui-editor-content ::ng-deep h3{margin-block:0 var(--ui-editor-block-gap, var(--units-sm));font-family:var(--fontfamily-title);font-weight:var(--ui-editor-heading-weight, var(--weight-bold));line-height:var(--ui-editor-heading-line-height, 1.25)}.ui-editor-content ::ng-deep h1:last-child,.ui-editor-content ::ng-deep h2:last-child,.ui-editor-content ::ng-deep h3:last-child{margin-block-end:0}.ui-editor-content ::ng-deep h1{font-size:var(--ui-editor-heading-1-font-size, var(--size-typography-title-lg))}.ui-editor-content ::ng-deep h2{font-size:var(--ui-editor-heading-2-font-size, var(--size-typography-title-md))}.ui-editor-content ::ng-deep h3{font-size:var(--ui-editor-heading-3-font-size, var(--size-typography-title-sm))}.ui-editor-content ::ng-deep .ui-editor-font-base{font-family:var(--fontfamily-base)}.ui-editor-content ::ng-deep .ui-editor-font-title{font-family:var(--fontfamily-title)}.ui-editor-content ::ng-deep .ui-editor-font-monospace{font-family:var(--fontfamily-monospace)}.ui-editor-content ::ng-deep .ui-editor-size-sm{font-size:var(--ui-editor-size-sm-font-size, var(--size-typography-text-sm))}.ui-editor-content ::ng-deep .ui-editor-size-default{font-size:var(--ui-editor-size-default-font-size, var(--size-typography-text-default))}.ui-editor-content ::ng-deep .ui-editor-size-lg{font-size:var(--ui-editor-size-lg-font-size, var(--size-typography-text-lg))}.ui-editor-content ::ng-deep .ui-editor-size-xl{font-size:var(--ui-editor-size-xl-font-size, var(--size-typography-text-xl))}.ui-editor-content ::ng-deep .ui-editor-color-primary-900{color:var(--primitives-primary-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-primary-900{background-color:var(--primitives-primary-900)}.ui-editor-content ::ng-deep .ui-editor-color-primary-700{color:var(--primitives-primary-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-primary-700{background-color:var(--primitives-primary-700)}.ui-editor-content ::ng-deep .ui-editor-color-primary-500{color:var(--primitives-primary-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-primary-500{background-color:var(--primitives-primary-500)}.ui-editor-content ::ng-deep .ui-editor-color-primary-300{color:var(--primitives-primary-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-primary-300{background-color:var(--primitives-primary-300)}.ui-editor-content ::ng-deep .ui-editor-color-primary-100{color:var(--primitives-primary-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-primary-100{background-color:var(--primitives-primary-100)}.ui-editor-content ::ng-deep .ui-editor-color-secondary-900{color:var(--primitives-secondary-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-secondary-900{background-color:var(--primitives-secondary-900)}.ui-editor-content ::ng-deep .ui-editor-color-secondary-700{color:var(--primitives-secondary-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-secondary-700{background-color:var(--primitives-secondary-700)}.ui-editor-content ::ng-deep .ui-editor-color-secondary-500{color:var(--primitives-secondary-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-secondary-500{background-color:var(--primitives-secondary-500)}.ui-editor-content ::ng-deep .ui-editor-color-secondary-300{color:var(--primitives-secondary-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-secondary-300{background-color:var(--primitives-secondary-300)}.ui-editor-content ::ng-deep .ui-editor-color-secondary-100{color:var(--primitives-secondary-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-secondary-100{background-color:var(--primitives-secondary-100)}.ui-editor-content ::ng-deep .ui-editor-color-green-900{color:var(--primitives-green-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-green-900{background-color:var(--primitives-green-900)}.ui-editor-content ::ng-deep .ui-editor-color-green-700{color:var(--primitives-green-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-green-700{background-color:var(--primitives-green-700)}.ui-editor-content ::ng-deep .ui-editor-color-green-500{color:var(--primitives-green-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-green-500{background-color:var(--primitives-green-500)}.ui-editor-content ::ng-deep .ui-editor-color-green-300{color:var(--primitives-green-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-green-300{background-color:var(--primitives-green-300)}.ui-editor-content ::ng-deep .ui-editor-color-green-100{color:var(--primitives-green-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-green-100{background-color:var(--primitives-green-100)}.ui-editor-content ::ng-deep .ui-editor-color-orange-900{color:var(--primitives-orange-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-orange-900{background-color:var(--primitives-orange-900)}.ui-editor-content ::ng-deep .ui-editor-color-orange-700{color:var(--primitives-orange-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-orange-700{background-color:var(--primitives-orange-700)}.ui-editor-content ::ng-deep .ui-editor-color-orange-500{color:var(--primitives-orange-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-orange-500{background-color:var(--primitives-orange-500)}.ui-editor-content ::ng-deep .ui-editor-color-orange-300{color:var(--primitives-orange-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-orange-300{background-color:var(--primitives-orange-300)}.ui-editor-content ::ng-deep .ui-editor-color-orange-100{color:var(--primitives-orange-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-orange-100{background-color:var(--primitives-orange-100)}.ui-editor-content ::ng-deep .ui-editor-color-red-900{color:var(--primitives-red-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-red-900{background-color:var(--primitives-red-900)}.ui-editor-content ::ng-deep .ui-editor-color-red-700{color:var(--primitives-red-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-red-700{background-color:var(--primitives-red-700)}.ui-editor-content ::ng-deep .ui-editor-color-red-500{color:var(--primitives-red-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-red-500{background-color:var(--primitives-red-500)}.ui-editor-content ::ng-deep .ui-editor-color-red-300{color:var(--primitives-red-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-red-300{background-color:var(--primitives-red-300)}.ui-editor-content ::ng-deep .ui-editor-color-red-100{color:var(--primitives-red-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-red-100{background-color:var(--primitives-red-100)}.ui-editor-content ::ng-deep .ui-editor-color-slate-900{color:var(--primitives-slate-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-slate-900{background-color:var(--primitives-slate-900)}.ui-editor-content ::ng-deep .ui-editor-color-slate-700{color:var(--primitives-slate-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-slate-700{background-color:var(--primitives-slate-700)}.ui-editor-content ::ng-deep .ui-editor-color-slate-500{color:var(--primitives-slate-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-slate-500{background-color:var(--primitives-slate-500)}.ui-editor-content ::ng-deep .ui-editor-color-slate-300{color:var(--primitives-slate-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-slate-300{background-color:var(--primitives-slate-300)}.ui-editor-content ::ng-deep .ui-editor-color-slate-100{color:var(--primitives-slate-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-slate-100{background-color:var(--primitives-slate-100)}.ui-editor-content ::ng-deep .ui-editor-color-grey-900{color:var(--primitives-grey-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-grey-900{background-color:var(--primitives-grey-900)}.ui-editor-content ::ng-deep .ui-editor-color-grey-700{color:var(--primitives-grey-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-grey-700{background-color:var(--primitives-grey-700)}.ui-editor-content ::ng-deep .ui-editor-color-grey-500{color:var(--primitives-grey-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-grey-500{background-color:var(--primitives-grey-500)}.ui-editor-content ::ng-deep .ui-editor-color-grey-300{color:var(--primitives-grey-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-grey-300{background-color:var(--primitives-grey-300)}.ui-editor-content ::ng-deep .ui-editor-color-grey-100{color:var(--primitives-grey-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-grey-100{background-color:var(--primitives-grey-100)}.ui-editor-content ::ng-deep .ui-editor-color-black{color:var(--primitives-black-base)}.ui-editor-content ::ng-deep .ui-editor-color-white{color:var(--primitives-white-base)}.ui-editor-content ::ng-deep .ui-editor-highlight-black{background-color:var(--primitives-black-base)}.ui-editor-content ::ng-deep .ui-editor-highlight-white{background-color:var(--primitives-white-base)}.ui-editor-count{margin-left:auto;flex-shrink:0;font-family:var(--fontfamily-base);font-size:var(--ui-editor-count-font-size, var(--size-typography-text-md));color:var(--form-low-content-default);-webkit-user-select:none;user-select:none}.ui-editor-count._small{font-size:var(--ui-editor-count-font-size-small, var(--size-typography-text-sm))}.ui-editor-count._over{color:var(--form-error-content-default)}.ui-editor-count._disabled{color:var(--form-high-content-disabled)}\n"], dependencies: [{ kind: "component", type: UiField, selector: "ui-field", inputs: ["label", "for", "required", "size", "level", "floatLabel", "filled", "disabled", "readonly", "multiline", "autoHeight", "message", "messageId", "showMessageIcon", "messageIcon", "hasFooter", "hasPrefix"] }, { kind: "component", type: UiButton, selector: "ui-button", inputs: ["label", "ariaLabel", "type", "level", "variant", "onColor", "size", "icon", "iconPos", "iconOnly", "loading", "loadingIcon", "expanded", "rounded", "disabled", "ripple", "tabindex", "buttonProps", "iconTemplate", "loadingIconTemplate", "href", "routerLink", "target", "rel"], outputs: ["buttonClick", "buttonFocus", "buttonBlur"] }, { kind: "component", type: UiSwatchPicker, selector: "ui-swatch-picker", inputs: ["palette", "value", "popup", "size", "allowClear", "ariaLabel"], outputs: ["valueChange", "swatchSelect", "opened", "closed"] }, { kind: "component", type: UiSelect, selector: "ui-select", inputs: ["options", "optionLabel", "optionValue", "optionDisabled", "group", "optionGroupLabel", "optionGroupChildren", "dataKey", "multiple", "checkmark", "checkbox", "maxSelectedLabels", "overflowLabel", "placeholder", "showClear", "clearAriaLabel", "icon", "filter", "filterPlaceholder", "filterAriaLabel", "filterBy", "autofocusFilter", "resetFilterOnHide", "ripple", "emptyMessage", "emptyFilterMessage", "editable", "loading", "autoOptionFocus", "selectOnFocus", "focusOnHover", "virtualScroll", "virtualScrollItemSize", "lazy", "scrollHeight", "autoFlip", "panelStyleClass", "panelWidth"], outputs: ["valueChange", "opened", "closed", "cleared", "filterChange", "lazyLoad", "inputFocus", "inputBlur"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
1092
+ }
1093
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.2", ngImport: i0, type: UiEditor, decorators: [{
1094
+ type: Component,
1095
+ args: [{ selector: 'ui-editor', imports: [UiField, UiButton, UiSwatchPicker, UiSelect, NgTemplateOutlet, FormsModule], providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => UiEditor), multi: true }], template: "<ui-field\n multiline\n [label]=\"label()\"\n [required]=\"required()\"\n [size]=\"size()\"\n [level]=\"effectiveLevel()\"\n [floatLabel]=\"floatLabel()\"\n [filled]=\"isFilled()\"\n [disabled]=\"isDisabled()\"\n [readonly]=\"readonly()\"\n [message]=\"displayMessage()\"\n [messageId]=\"messageId()\"\n [showMessageIcon]=\"showMessageIcon()\"\n [messageIcon]=\"messageIcon()\"\n [hasFooter]=\"showCount()\"\n>\n <div class=\"ui-editor\" [class._small]=\"size() === 'small'\" [style.--_rows]=\"minRows()\">\n @if (toolbarPosition() === 'top') {\n <ng-container [ngTemplateOutlet]=\"toolbarTpl\" />\n }\n\n <div class=\"ui-editor-area\">\n <div\n #contentEl\n class=\"ui-editor-content\"\n [class._small]=\"size() === 'small'\"\n [id]=\"resolvedId()\"\n role=\"textbox\"\n aria-multiline=\"true\"\n [attr.contenteditable]=\"isEditable() ? 'true' : 'false'\"\n [attr.tabindex]=\"isDisabled() ? -1 : (tabindex() ?? 0)\"\n [attr.aria-label]=\"ariaLabel() || label() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-describedby]=\"describedByIds()\"\n [attr.aria-required]=\"required() ? 'true' : null\"\n [attr.aria-readonly]=\"readonly() ? 'true' : null\"\n [attr.aria-disabled]=\"isDisabled() ? 'true' : null\"\n [attr.aria-invalid]=\"effectiveLevel() === 'error' ? 'true' : null\"\n (input)=\"onInput()\"\n (beforeinput)=\"onBeforeInput($any($event))\"\n (paste)=\"onPaste($event)\"\n (keydown)=\"onContentKeydown($event)\"\n (keyup)=\"refreshState()\"\n (mouseup)=\"refreshState()\"\n (focus)=\"editorFocus.emit($event)\"\n (blur)=\"onBlur($event)\"\n ></div>\n\n @if (showPlaceholder()) {\n <span class=\"ui-editor-placeholder\" aria-hidden=\"true\">{{ placeholder() }}</span>\n }\n </div>\n\n @if (toolbarPosition() === 'bottom') {\n <ng-container [ngTemplateOutlet]=\"toolbarTpl\" />\n }\n </div>\n\n @if (showCount()) {\n <span\n uiFieldFooter\n class=\"ui-editor-count\"\n [class._small]=\"size() === 'small'\"\n [class._disabled]=\"isDisabled()\"\n [class._over]=\"overLimit()\"\n [attr.id]=\"countId()\"\n >\n {{ charCount() }}\n @if (maxlength(); as max) {\n &nbsp;/&nbsp;{{ max }}\n }\n </span>\n }\n</ui-field>\n\n<ng-template #toolbarTpl>\n @if (hasToolbar()) {\n <!-- ARIA toolbar pattern: keyboard delegated to the role=\"toolbar\" container,\n focus lives on the items (roving tabindex), same as ui-menu. -->\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <div\n #toolbarEl\n class=\"ui-editor-toolbar\"\n [class._bottom]=\"toolbarPosition() === 'bottom'\"\n role=\"toolbar\"\n aria-label=\"Mise en forme\"\n aria-orientation=\"horizontal\"\n (mousedown)=\"onToolbarMousedown($event)\"\n (keydown)=\"onToolbarKeydown($event)\"\n >\n @for (entry of toolbar(); track entry.index) {\n @if (entry.isSeparator) {\n <span class=\"ui-editor-toolbar-separator\" aria-hidden=\"true\"></span>\n } @else if (entry.select; as select) {\n <!-- The dropdown takes the focus, so the command restores the caret\n before it runs (see onSelectValueChange). -->\n <ui-select\n class=\"ui-editor-tool ui-editor-select\"\n size=\"small\"\n [options]=\"selectOptions(select)\"\n optionLabel=\"label\"\n optionValue=\"value\"\n [ngModel]=\"selectValue(select)\"\n [ariaLabel]=\"selectLabel(select)\"\n [disabled]=\"!isEditable()\"\n [tabindex]=\"entry.index === tabStop() ? 0 : -1\"\n (valueChange)=\"onSelectValueChange(select, $event, entry.index)\"\n />\n } @else {\n <ui-button\n class=\"ui-editor-tool\"\n [class._colorTool]=\"\n entry.buttonTool === 'textColor' || entry.buttonTool === 'highlightColor'\n \"\n variant=\"ghost\"\n level=\"low\"\n size=\"small\"\n iconOnly\n [icon]=\"entry.meta!.icon\"\n [ariaLabel]=\"entry.meta!.label\"\n [disabled]=\"!isEditable()\"\n [tabindex]=\"entry.index === tabStop() ? 0 : -1\"\n [buttonProps]=\"toolProps(entry.buttonTool!)\"\n [style.--ui-editor-swatch-indicator-color]=\"colorIndicatorVar(entry.buttonTool)\"\n (buttonClick)=\"runTool(entry.buttonTool!, entry.index, $event)\"\n />\n }\n }\n\n <!-- `textColor`/`highlightColor` popups: no trigger of their own (same\n composition contract as `ui-menu`), opened via `runTool` ->\n `onColorToolClick` -> `toggle(event)`. -->\n <ui-swatch-picker\n #textColorPicker\n popup\n size=\"small\"\n [allowClear]=\"true\"\n [value]=\"currentTextColor()\"\n ariaLabel=\"Couleur du texte\"\n (swatchSelect)=\"onTextColorSelect($event)\"\n (opened)=\"textColorPickerOpen.set(true)\"\n (closed)=\"textColorPickerOpen.set(false)\"\n />\n <ui-swatch-picker\n #highlightColorPicker\n popup\n size=\"small\"\n [allowClear]=\"true\"\n [value]=\"currentHighlightColor()\"\n ariaLabel=\"Couleur de surlignage\"\n (swatchSelect)=\"onHighlightColorSelect($event)\"\n (opened)=\"highlightColorPickerOpen.set(true)\"\n (closed)=\"highlightColorPickerOpen.set(false)\"\n />\n </div>\n }\n</ng-template>\n", styles: [".ui-editor{display:flex;flex:1 1 auto;flex-direction:column;min-width:0;border-radius:var(--ui-editor-radius, inherit);overflow:hidden}.ui-editor-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:var(--ui-editor-toolbar-gap, var(--units-2xs));flex-shrink:0;padding:var(--ui-editor-toolbar-padding-y, var(--units-2xs)) var(--ui-editor-toolbar-padding-x, var(--units-xs));background-color:var(--ui-editor-toolbar-surface, var(--global-background-muted));border-block-end:var(--ui-editor-toolbar-stroke-width, var(--ui-control-stroke-width, var(--stroke-default))) solid var(--ui-editor-toolbar-stroke, var(--form-low-stroke-default))}.ui-editor-toolbar._bottom{border-block-end:none;border-block-start:var(--ui-editor-toolbar-stroke-width, var(--ui-control-stroke-width, var(--stroke-default))) solid var(--ui-editor-toolbar-stroke, var(--form-low-stroke-default))}.ui-editor-toolbar-separator{flex-shrink:0;inline-size:var(--ui-editor-separator-width, var(--stroke-sm));block-size:var(--ui-editor-separator-height, var(--size-typography-text-default));background-color:var(--ui-editor-separator-color, var(--form-low-stroke-default))}.ui-editor-select{display:inline-flex;flex-shrink:0;min-inline-size:var(--ui-editor-select-width, 13ch);--ui-field-stroke-width: 0}.ui-editor-select ::ng-deep .ui-select{inline-size:100%}.ui-editor-select ::ng-deep .ui-field-box{background:transparent;transition:background-color var(--ui-control-transition-duration, var(--transition-default)) var(--ui-control-transition-easing, var(--transition-easeinout))}.ui-editor-select ::ng-deep .ui-field-box:hover{background-color:var(--form-low-surface-hover)}.ui-editor-tool._colorTool{position:relative}.ui-editor-tool._colorTool:after{content:\"\";position:absolute;inset-inline:var(--ui-editor-swatch-indicator-offset-x, var(--units-2xs));inset-block-end:0;block-size:var(--ui-editor-swatch-indicator-height, var(--stroke-lg));border-radius:var(--ui-editor-swatch-indicator-height, var(--stroke-lg));background-color:var(--ui-editor-swatch-indicator-color, transparent)}.ui-editor-area{position:relative;display:flex;flex:1 1 auto;min-height:0}.ui-editor-content{flex:1 1 auto;align-self:stretch;min-width:0;margin:0;padding:0;border:none;border-radius:inherit;background:transparent;outline:none;font-family:var(--fontfamily-base);font-size:var(--size-typography-text-default);color:var(--form-high-content-default)}.ui-editor-content::placeholder{color:var(--form-low-content-default);opacity:1}.ui-editor-content:disabled{cursor:not-allowed;color:var(--form-high-content-disabled)}.ui-editor-content{box-sizing:border-box;width:100%;min-height:var(--ui-editor-min-height, calc(var(--_rows, 4) * var(--ui-editor-line-height, 1.5) * 1em));max-height:var(--ui-editor-max-height, none);padding:var(--ui-editor-padding-y, var(--ui-form-textarea-padding-y, var(--units-default))) var(--ui-editor-padding-x, var(--ui-form-field-padding-x, var(--units-md)));overflow-y:auto;line-height:var(--ui-editor-line-height, 1.5);font-size:var(--ui-editor-font-size, var(--size-typography-text-default));overflow-wrap:break-word}.ui-editor-content._small{padding-block:var(--ui-editor-padding-y-small, var(--ui-form-textarea-padding-y-small, var(--units-md)));font-size:var(--ui-editor-font-size-small, var(--size-typography-text-md))}.ui-editor-content:focus,.ui-editor-content:focus-visible{outline:none}.ui-editor-content[contenteditable=false]{cursor:default}.ui-editor-placeholder{position:absolute;inset-block-start:var(--ui-editor-padding-y, var(--ui-form-textarea-padding-y, var(--units-default)));inset-inline-start:var(--ui-editor-padding-x, var(--ui-form-field-padding-x, var(--units-md)));line-height:var(--ui-editor-line-height, 1.5);font-family:var(--fontfamily-base);font-size:var(--ui-editor-font-size, var(--size-typography-text-default));color:var(--ui-editor-placeholder-color, var(--form-low-content-default));pointer-events:none;-webkit-user-select:none;user-select:none}.ui-editor._small .ui-editor-placeholder{inset-block-start:var(--ui-editor-padding-y-small, var(--ui-form-textarea-padding-y-small, var(--units-md)));font-size:var(--ui-editor-font-size-small, var(--size-typography-text-md))}.ui-editor-content ::ng-deep p{margin-block:0 var(--ui-editor-block-gap, var(--units-sm))}.ui-editor-content ::ng-deep p:last-child{margin-block-end:0}.ui-editor-content ::ng-deep ul,.ui-editor-content ::ng-deep ol{margin-block:0 var(--ui-editor-block-gap, var(--units-sm));padding-inline-start:var(--ui-editor-list-padding-inline-start, var(--units-xl))}.ui-editor-content ::ng-deep ul:last-child,.ui-editor-content ::ng-deep ol:last-child{margin-block-end:0}.ui-editor-content ::ng-deep li+li{margin-block-start:var(--ui-editor-list-item-gap, var(--units-2xs))}.ui-editor-content ::ng-deep b,.ui-editor-content ::ng-deep strong{font-weight:var(--ui-editor-bold-weight, var(--weight-bold))}.ui-editor-content ::ng-deep a{color:var(--ui-editor-link-color, var(--global-text-brand));text-decoration:var(--ui-editor-link-text-decoration, underline)}.ui-editor-content ::ng-deep pre{margin-block:0 var(--ui-editor-block-gap, var(--units-sm));padding:var(--ui-editor-code-padding-y, var(--units-sm)) var(--ui-editor-code-padding-x, var(--units-md));border-radius:var(--ui-editor-code-radius, var(--radius-xs));background-color:var(--ui-editor-code-surface, var(--global-background-muted));color:var(--ui-editor-code-color, var(--global-text-default));font-family:var(--fontfamily-monospace);font-size:var(--ui-editor-code-font-size, var(--size-typography-text-md));white-space:pre-wrap;overflow-wrap:break-word}.ui-editor-content ::ng-deep pre:last-child{margin-block-end:0}.ui-editor-content ::ng-deep code{font-family:var(--fontfamily-monospace)}.ui-editor-content ::ng-deep h1,.ui-editor-content ::ng-deep h2,.ui-editor-content ::ng-deep h3{margin-block:0 var(--ui-editor-block-gap, var(--units-sm));font-family:var(--fontfamily-title);font-weight:var(--ui-editor-heading-weight, var(--weight-bold));line-height:var(--ui-editor-heading-line-height, 1.25)}.ui-editor-content ::ng-deep h1:last-child,.ui-editor-content ::ng-deep h2:last-child,.ui-editor-content ::ng-deep h3:last-child{margin-block-end:0}.ui-editor-content ::ng-deep h1{font-size:var(--ui-editor-heading-1-font-size, var(--size-typography-title-lg))}.ui-editor-content ::ng-deep h2{font-size:var(--ui-editor-heading-2-font-size, var(--size-typography-title-md))}.ui-editor-content ::ng-deep h3{font-size:var(--ui-editor-heading-3-font-size, var(--size-typography-title-sm))}.ui-editor-content ::ng-deep .ui-editor-font-base{font-family:var(--fontfamily-base)}.ui-editor-content ::ng-deep .ui-editor-font-title{font-family:var(--fontfamily-title)}.ui-editor-content ::ng-deep .ui-editor-font-monospace{font-family:var(--fontfamily-monospace)}.ui-editor-content ::ng-deep .ui-editor-size-sm{font-size:var(--ui-editor-size-sm-font-size, var(--size-typography-text-sm))}.ui-editor-content ::ng-deep .ui-editor-size-default{font-size:var(--ui-editor-size-default-font-size, var(--size-typography-text-default))}.ui-editor-content ::ng-deep .ui-editor-size-lg{font-size:var(--ui-editor-size-lg-font-size, var(--size-typography-text-lg))}.ui-editor-content ::ng-deep .ui-editor-size-xl{font-size:var(--ui-editor-size-xl-font-size, var(--size-typography-text-xl))}.ui-editor-content ::ng-deep .ui-editor-color-primary-900{color:var(--primitives-primary-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-primary-900{background-color:var(--primitives-primary-900)}.ui-editor-content ::ng-deep .ui-editor-color-primary-700{color:var(--primitives-primary-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-primary-700{background-color:var(--primitives-primary-700)}.ui-editor-content ::ng-deep .ui-editor-color-primary-500{color:var(--primitives-primary-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-primary-500{background-color:var(--primitives-primary-500)}.ui-editor-content ::ng-deep .ui-editor-color-primary-300{color:var(--primitives-primary-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-primary-300{background-color:var(--primitives-primary-300)}.ui-editor-content ::ng-deep .ui-editor-color-primary-100{color:var(--primitives-primary-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-primary-100{background-color:var(--primitives-primary-100)}.ui-editor-content ::ng-deep .ui-editor-color-secondary-900{color:var(--primitives-secondary-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-secondary-900{background-color:var(--primitives-secondary-900)}.ui-editor-content ::ng-deep .ui-editor-color-secondary-700{color:var(--primitives-secondary-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-secondary-700{background-color:var(--primitives-secondary-700)}.ui-editor-content ::ng-deep .ui-editor-color-secondary-500{color:var(--primitives-secondary-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-secondary-500{background-color:var(--primitives-secondary-500)}.ui-editor-content ::ng-deep .ui-editor-color-secondary-300{color:var(--primitives-secondary-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-secondary-300{background-color:var(--primitives-secondary-300)}.ui-editor-content ::ng-deep .ui-editor-color-secondary-100{color:var(--primitives-secondary-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-secondary-100{background-color:var(--primitives-secondary-100)}.ui-editor-content ::ng-deep .ui-editor-color-green-900{color:var(--primitives-green-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-green-900{background-color:var(--primitives-green-900)}.ui-editor-content ::ng-deep .ui-editor-color-green-700{color:var(--primitives-green-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-green-700{background-color:var(--primitives-green-700)}.ui-editor-content ::ng-deep .ui-editor-color-green-500{color:var(--primitives-green-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-green-500{background-color:var(--primitives-green-500)}.ui-editor-content ::ng-deep .ui-editor-color-green-300{color:var(--primitives-green-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-green-300{background-color:var(--primitives-green-300)}.ui-editor-content ::ng-deep .ui-editor-color-green-100{color:var(--primitives-green-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-green-100{background-color:var(--primitives-green-100)}.ui-editor-content ::ng-deep .ui-editor-color-orange-900{color:var(--primitives-orange-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-orange-900{background-color:var(--primitives-orange-900)}.ui-editor-content ::ng-deep .ui-editor-color-orange-700{color:var(--primitives-orange-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-orange-700{background-color:var(--primitives-orange-700)}.ui-editor-content ::ng-deep .ui-editor-color-orange-500{color:var(--primitives-orange-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-orange-500{background-color:var(--primitives-orange-500)}.ui-editor-content ::ng-deep .ui-editor-color-orange-300{color:var(--primitives-orange-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-orange-300{background-color:var(--primitives-orange-300)}.ui-editor-content ::ng-deep .ui-editor-color-orange-100{color:var(--primitives-orange-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-orange-100{background-color:var(--primitives-orange-100)}.ui-editor-content ::ng-deep .ui-editor-color-red-900{color:var(--primitives-red-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-red-900{background-color:var(--primitives-red-900)}.ui-editor-content ::ng-deep .ui-editor-color-red-700{color:var(--primitives-red-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-red-700{background-color:var(--primitives-red-700)}.ui-editor-content ::ng-deep .ui-editor-color-red-500{color:var(--primitives-red-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-red-500{background-color:var(--primitives-red-500)}.ui-editor-content ::ng-deep .ui-editor-color-red-300{color:var(--primitives-red-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-red-300{background-color:var(--primitives-red-300)}.ui-editor-content ::ng-deep .ui-editor-color-red-100{color:var(--primitives-red-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-red-100{background-color:var(--primitives-red-100)}.ui-editor-content ::ng-deep .ui-editor-color-slate-900{color:var(--primitives-slate-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-slate-900{background-color:var(--primitives-slate-900)}.ui-editor-content ::ng-deep .ui-editor-color-slate-700{color:var(--primitives-slate-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-slate-700{background-color:var(--primitives-slate-700)}.ui-editor-content ::ng-deep .ui-editor-color-slate-500{color:var(--primitives-slate-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-slate-500{background-color:var(--primitives-slate-500)}.ui-editor-content ::ng-deep .ui-editor-color-slate-300{color:var(--primitives-slate-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-slate-300{background-color:var(--primitives-slate-300)}.ui-editor-content ::ng-deep .ui-editor-color-slate-100{color:var(--primitives-slate-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-slate-100{background-color:var(--primitives-slate-100)}.ui-editor-content ::ng-deep .ui-editor-color-grey-900{color:var(--primitives-grey-900)}.ui-editor-content ::ng-deep .ui-editor-highlight-grey-900{background-color:var(--primitives-grey-900)}.ui-editor-content ::ng-deep .ui-editor-color-grey-700{color:var(--primitives-grey-700)}.ui-editor-content ::ng-deep .ui-editor-highlight-grey-700{background-color:var(--primitives-grey-700)}.ui-editor-content ::ng-deep .ui-editor-color-grey-500{color:var(--primitives-grey-500)}.ui-editor-content ::ng-deep .ui-editor-highlight-grey-500{background-color:var(--primitives-grey-500)}.ui-editor-content ::ng-deep .ui-editor-color-grey-300{color:var(--primitives-grey-300)}.ui-editor-content ::ng-deep .ui-editor-highlight-grey-300{background-color:var(--primitives-grey-300)}.ui-editor-content ::ng-deep .ui-editor-color-grey-100{color:var(--primitives-grey-100)}.ui-editor-content ::ng-deep .ui-editor-highlight-grey-100{background-color:var(--primitives-grey-100)}.ui-editor-content ::ng-deep .ui-editor-color-black{color:var(--primitives-black-base)}.ui-editor-content ::ng-deep .ui-editor-color-white{color:var(--primitives-white-base)}.ui-editor-content ::ng-deep .ui-editor-highlight-black{background-color:var(--primitives-black-base)}.ui-editor-content ::ng-deep .ui-editor-highlight-white{background-color:var(--primitives-white-base)}.ui-editor-count{margin-left:auto;flex-shrink:0;font-family:var(--fontfamily-base);font-size:var(--ui-editor-count-font-size, var(--size-typography-text-md));color:var(--form-low-content-default);-webkit-user-select:none;user-select:none}.ui-editor-count._small{font-size:var(--ui-editor-count-font-size-small, var(--size-typography-text-sm))}.ui-editor-count._over{color:var(--form-error-content-default)}.ui-editor-count._disabled{color:var(--form-high-content-disabled)}\n"] }]
1096
+ }], ctorParameters: () => [], propDecorators: { tools: [{ type: i0.Input, args: [{ isSignal: true, alias: "tools", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], minRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "minRows", required: false }] }], maxlength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxlength", required: false }] }], showCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "showCount", required: false }] }], toolbarPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "toolbarPosition", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], editorFocus: [{ type: i0.Output, args: ["editorFocus"] }], editorBlur: [{ type: i0.Output, args: ["editorBlur"] }], selectionChange: [{ type: i0.Output, args: ["selectionChange"] }], contentEl: [{ type: i0.ViewChild, args: ['contentEl', { isSignal: true }] }], toolbarEl: [{ type: i0.ViewChild, args: ['toolbarEl', { isSignal: true }] }], textColorPicker: [{ type: i0.ViewChild, args: ['textColorPicker', { isSignal: true }] }], highlightColorPicker: [{ type: i0.ViewChild, args: ['highlightColorPicker', { isSignal: true }] }] } });
1097
+
1098
+ /*
1099
+ * Public API Surface of ui-kit/ui-editor
1100
+ */
1101
+
1102
+ /**
1103
+ * Generated bundle index. Do not edit.
1104
+ */
1105
+
1106
+ export { DEFAULT_EDITOR_TOOLS, EDITOR_COLORS, EDITOR_FONTS, EDITOR_HIGHLIGHTS, EDITOR_SELECT_TOOLS, EDITOR_SIZES, EDITOR_TOOL_META, UiEditor, applyCommand, applyFontFamily, applyFontSize, applyHighlightColor, applyLink, applyTextColor, clearFormatMarkers, clearMarkerClass, convertColorMarkers, convertFontMarkers, convertHighlightMarkers, convertSizeMarkers, emptyEditorState, htmlToText, insertHtml, insertText, isEmptyHtml, isInCodeBlock, normalizeHtml, readEditorState, readFontFamily, readFontSize, readHighlightColor, readTextColor, removeLink, resolveFontLabel, scrubInPlace, toggleCodeBlock };
1107
+ //# sourceMappingURL=4sh-ui-kit-forms-ui-editor.mjs.map