@edsis/ui 0.0.2

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 (265) hide show
  1. package/README.md +40 -0
  2. package/accordion/README.md +195 -0
  3. package/alert/README.md +177 -0
  4. package/alert-dialog/README.md +239 -0
  5. package/aspect-ratio/README.md +112 -0
  6. package/avatar/README.md +176 -0
  7. package/badge/README.md +133 -0
  8. package/breadcrumb/README.md +216 -0
  9. package/button/README.md +139 -0
  10. package/button-group/README.md +204 -0
  11. package/calendar/README.md +132 -0
  12. package/card/README.md +220 -0
  13. package/carousel/README.md +276 -0
  14. package/chart/README.md +249 -0
  15. package/checkbox/README.md +149 -0
  16. package/collapsible/README.md +191 -0
  17. package/combobox/README.md +198 -0
  18. package/command/README.md +275 -0
  19. package/composer/README.md +235 -0
  20. package/context-menu/README.md +267 -0
  21. package/date-picker/README.md +177 -0
  22. package/dialog/README.md +237 -0
  23. package/drawer/README.md +145 -0
  24. package/dropdown-menu/README.md +311 -0
  25. package/editor/README.md +136 -0
  26. package/empty/README.md +183 -0
  27. package/fesm2022/edsis-ui-accordion.mjs +174 -0
  28. package/fesm2022/edsis-ui-accordion.mjs.map +1 -0
  29. package/fesm2022/edsis-ui-alert-dialog.mjs +242 -0
  30. package/fesm2022/edsis-ui-alert-dialog.mjs.map +1 -0
  31. package/fesm2022/edsis-ui-alert.mjs +90 -0
  32. package/fesm2022/edsis-ui-alert.mjs.map +1 -0
  33. package/fesm2022/edsis-ui-aspect-ratio.mjs +33 -0
  34. package/fesm2022/edsis-ui-aspect-ratio.mjs.map +1 -0
  35. package/fesm2022/edsis-ui-avatar.mjs +123 -0
  36. package/fesm2022/edsis-ui-avatar.mjs.map +1 -0
  37. package/fesm2022/edsis-ui-badge.mjs +47 -0
  38. package/fesm2022/edsis-ui-badge.mjs.map +1 -0
  39. package/fesm2022/edsis-ui-breadcrumb.mjs +186 -0
  40. package/fesm2022/edsis-ui-breadcrumb.mjs.map +1 -0
  41. package/fesm2022/edsis-ui-button-group.mjs +95 -0
  42. package/fesm2022/edsis-ui-button-group.mjs.map +1 -0
  43. package/fesm2022/edsis-ui-button.mjs +64 -0
  44. package/fesm2022/edsis-ui-button.mjs.map +1 -0
  45. package/fesm2022/edsis-ui-calendar.mjs +78 -0
  46. package/fesm2022/edsis-ui-calendar.mjs.map +1 -0
  47. package/fesm2022/edsis-ui-card.mjs +137 -0
  48. package/fesm2022/edsis-ui-card.mjs.map +1 -0
  49. package/fesm2022/edsis-ui-carousel.mjs +310 -0
  50. package/fesm2022/edsis-ui-carousel.mjs.map +1 -0
  51. package/fesm2022/edsis-ui-chart-area.mjs +6 -0
  52. package/fesm2022/edsis-ui-chart-area.mjs.map +1 -0
  53. package/fesm2022/edsis-ui-chart-bar.mjs +6 -0
  54. package/fesm2022/edsis-ui-chart-bar.mjs.map +1 -0
  55. package/fesm2022/edsis-ui-chart-line.mjs +6 -0
  56. package/fesm2022/edsis-ui-chart-line.mjs.map +1 -0
  57. package/fesm2022/edsis-ui-chart-pie.mjs +6 -0
  58. package/fesm2022/edsis-ui-chart-pie.mjs.map +1 -0
  59. package/fesm2022/edsis-ui-chart-radar.mjs +6 -0
  60. package/fesm2022/edsis-ui-chart-radar.mjs.map +1 -0
  61. package/fesm2022/edsis-ui-chart-radial.mjs +6 -0
  62. package/fesm2022/edsis-ui-chart-radial.mjs.map +1 -0
  63. package/fesm2022/edsis-ui-chart-scatter.mjs +6 -0
  64. package/fesm2022/edsis-ui-chart-scatter.mjs.map +1 -0
  65. package/fesm2022/edsis-ui-chart.mjs +3714 -0
  66. package/fesm2022/edsis-ui-chart.mjs.map +1 -0
  67. package/fesm2022/edsis-ui-checkbox.mjs +104 -0
  68. package/fesm2022/edsis-ui-checkbox.mjs.map +1 -0
  69. package/fesm2022/edsis-ui-collapsible.mjs +116 -0
  70. package/fesm2022/edsis-ui-collapsible.mjs.map +1 -0
  71. package/fesm2022/edsis-ui-combobox.mjs +263 -0
  72. package/fesm2022/edsis-ui-combobox.mjs.map +1 -0
  73. package/fesm2022/edsis-ui-command.mjs +268 -0
  74. package/fesm2022/edsis-ui-command.mjs.map +1 -0
  75. package/fesm2022/edsis-ui-composer.mjs +329 -0
  76. package/fesm2022/edsis-ui-composer.mjs.map +1 -0
  77. package/fesm2022/edsis-ui-context-menu.mjs +100 -0
  78. package/fesm2022/edsis-ui-context-menu.mjs.map +1 -0
  79. package/fesm2022/edsis-ui-date-picker.mjs +155 -0
  80. package/fesm2022/edsis-ui-date-picker.mjs.map +1 -0
  81. package/fesm2022/edsis-ui-dialog.mjs +262 -0
  82. package/fesm2022/edsis-ui-dialog.mjs.map +1 -0
  83. package/fesm2022/edsis-ui-drawer.mjs +6 -0
  84. package/fesm2022/edsis-ui-drawer.mjs.map +1 -0
  85. package/fesm2022/edsis-ui-dropdown-menu.mjs +466 -0
  86. package/fesm2022/edsis-ui-dropdown-menu.mjs.map +1 -0
  87. package/fesm2022/edsis-ui-editor.mjs +692 -0
  88. package/fesm2022/edsis-ui-editor.mjs.map +1 -0
  89. package/fesm2022/edsis-ui-empty.mjs +132 -0
  90. package/fesm2022/edsis-ui-empty.mjs.map +1 -0
  91. package/fesm2022/edsis-ui-form.mjs +334 -0
  92. package/fesm2022/edsis-ui-form.mjs.map +1 -0
  93. package/fesm2022/edsis-ui-hover-card.mjs +284 -0
  94. package/fesm2022/edsis-ui-hover-card.mjs.map +1 -0
  95. package/fesm2022/edsis-ui-input-group.mjs +164 -0
  96. package/fesm2022/edsis-ui-input-group.mjs.map +1 -0
  97. package/fesm2022/edsis-ui-input-otp.mjs +485 -0
  98. package/fesm2022/edsis-ui-input-otp.mjs.map +1 -0
  99. package/fesm2022/edsis-ui-input.mjs +43 -0
  100. package/fesm2022/edsis-ui-input.mjs.map +1 -0
  101. package/fesm2022/edsis-ui-item.mjs +241 -0
  102. package/fesm2022/edsis-ui-item.mjs.map +1 -0
  103. package/fesm2022/edsis-ui-kanban.mjs +289 -0
  104. package/fesm2022/edsis-ui-kanban.mjs.map +1 -0
  105. package/fesm2022/edsis-ui-kbd.mjs +51 -0
  106. package/fesm2022/edsis-ui-kbd.mjs.map +1 -0
  107. package/fesm2022/edsis-ui-label.mjs +30 -0
  108. package/fesm2022/edsis-ui-label.mjs.map +1 -0
  109. package/fesm2022/edsis-ui-menubar.mjs +302 -0
  110. package/fesm2022/edsis-ui-menubar.mjs.map +1 -0
  111. package/fesm2022/edsis-ui-native-select.mjs +61 -0
  112. package/fesm2022/edsis-ui-native-select.mjs.map +1 -0
  113. package/fesm2022/edsis-ui-navigation-menu.mjs +399 -0
  114. package/fesm2022/edsis-ui-navigation-menu.mjs.map +1 -0
  115. package/fesm2022/edsis-ui-pagination.mjs +216 -0
  116. package/fesm2022/edsis-ui-pagination.mjs.map +1 -0
  117. package/fesm2022/edsis-ui-pillbox.mjs +777 -0
  118. package/fesm2022/edsis-ui-pillbox.mjs.map +1 -0
  119. package/fesm2022/edsis-ui-popover.mjs +163 -0
  120. package/fesm2022/edsis-ui-popover.mjs.map +1 -0
  121. package/fesm2022/edsis-ui-progress.mjs +53 -0
  122. package/fesm2022/edsis-ui-progress.mjs.map +1 -0
  123. package/fesm2022/edsis-ui-radio.mjs +111 -0
  124. package/fesm2022/edsis-ui-radio.mjs.map +1 -0
  125. package/fesm2022/edsis-ui-resizable.mjs +454 -0
  126. package/fesm2022/edsis-ui-resizable.mjs.map +1 -0
  127. package/fesm2022/edsis-ui-scroll-area.mjs +48 -0
  128. package/fesm2022/edsis-ui-scroll-area.mjs.map +1 -0
  129. package/fesm2022/edsis-ui-select.mjs +164 -0
  130. package/fesm2022/edsis-ui-select.mjs.map +1 -0
  131. package/fesm2022/edsis-ui-separator.mjs +33 -0
  132. package/fesm2022/edsis-ui-separator.mjs.map +1 -0
  133. package/fesm2022/edsis-ui-sheet.mjs +264 -0
  134. package/fesm2022/edsis-ui-sheet.mjs.map +1 -0
  135. package/fesm2022/edsis-ui-skeleton.mjs +29 -0
  136. package/fesm2022/edsis-ui-skeleton.mjs.map +1 -0
  137. package/fesm2022/edsis-ui-slider.mjs +405 -0
  138. package/fesm2022/edsis-ui-slider.mjs.map +1 -0
  139. package/fesm2022/edsis-ui-spinner.mjs +58 -0
  140. package/fesm2022/edsis-ui-spinner.mjs.map +1 -0
  141. package/fesm2022/edsis-ui-switch.mjs +107 -0
  142. package/fesm2022/edsis-ui-switch.mjs.map +1 -0
  143. package/fesm2022/edsis-ui-table.mjs +139 -0
  144. package/fesm2022/edsis-ui-table.mjs.map +1 -0
  145. package/fesm2022/edsis-ui-tabs.mjs +252 -0
  146. package/fesm2022/edsis-ui-tabs.mjs.map +1 -0
  147. package/fesm2022/edsis-ui-textarea.mjs +37 -0
  148. package/fesm2022/edsis-ui-textarea.mjs.map +1 -0
  149. package/fesm2022/edsis-ui-timeline.mjs +213 -0
  150. package/fesm2022/edsis-ui-timeline.mjs.map +1 -0
  151. package/fesm2022/edsis-ui-toast.mjs +71 -0
  152. package/fesm2022/edsis-ui-toast.mjs.map +1 -0
  153. package/fesm2022/edsis-ui-toggle-group.mjs +269 -0
  154. package/fesm2022/edsis-ui-toggle-group.mjs.map +1 -0
  155. package/fesm2022/edsis-ui-toggle.mjs +76 -0
  156. package/fesm2022/edsis-ui-toggle.mjs.map +1 -0
  157. package/fesm2022/edsis-ui-tooltip.mjs +339 -0
  158. package/fesm2022/edsis-ui-tooltip.mjs.map +1 -0
  159. package/fesm2022/edsis-ui-utils.mjs +13 -0
  160. package/fesm2022/edsis-ui-utils.mjs.map +1 -0
  161. package/fesm2022/edsis-ui.mjs +11 -0
  162. package/fesm2022/edsis-ui.mjs.map +1 -0
  163. package/form/README.md +210 -0
  164. package/hover-card/README.md +146 -0
  165. package/input/README.md +159 -0
  166. package/input-group/README.md +234 -0
  167. package/input-otp/README.md +273 -0
  168. package/item/README.md +247 -0
  169. package/kanban/README.md +81 -0
  170. package/kbd/README.md +139 -0
  171. package/label/README.md +136 -0
  172. package/menubar/README.md +269 -0
  173. package/native-select/README.md +176 -0
  174. package/navigation-menu/README.md +160 -0
  175. package/package.json +310 -0
  176. package/pagination/README.md +144 -0
  177. package/pillbox/README.md +67 -0
  178. package/popover/README.md +43 -0
  179. package/progress/README.md +160 -0
  180. package/radio/README.md +209 -0
  181. package/resizable/README.md +164 -0
  182. package/scroll-area/README.md +143 -0
  183. package/select/README.md +174 -0
  184. package/separator/README.md +170 -0
  185. package/sheet/README.md +183 -0
  186. package/skeleton/README.md +158 -0
  187. package/slider/README.md +207 -0
  188. package/spinner/README.md +160 -0
  189. package/switch/README.md +166 -0
  190. package/table/README.md +291 -0
  191. package/tabs/README.md +214 -0
  192. package/textarea/README.md +154 -0
  193. package/timeline/README.md +94 -0
  194. package/toast/README.md +321 -0
  195. package/toggle/README.md +131 -0
  196. package/toggle-group/README.md +206 -0
  197. package/tooltip/README.md +211 -0
  198. package/types/edsis-ui-accordion.d.ts +51 -0
  199. package/types/edsis-ui-alert-dialog.d.ts +93 -0
  200. package/types/edsis-ui-alert.d.ts +37 -0
  201. package/types/edsis-ui-aspect-ratio.d.ts +12 -0
  202. package/types/edsis-ui-avatar.d.ts +51 -0
  203. package/types/edsis-ui-badge.d.ts +19 -0
  204. package/types/edsis-ui-breadcrumb.d.ts +46 -0
  205. package/types/edsis-ui-button-group.d.ts +26 -0
  206. package/types/edsis-ui-button.d.ts +22 -0
  207. package/types/edsis-ui-calendar.d.ts +33 -0
  208. package/types/edsis-ui-card.d.ts +60 -0
  209. package/types/edsis-ui-carousel.d.ts +86 -0
  210. package/types/edsis-ui-chart-area.d.ts +1 -0
  211. package/types/edsis-ui-chart-bar.d.ts +1 -0
  212. package/types/edsis-ui-chart-line.d.ts +1 -0
  213. package/types/edsis-ui-chart-pie.d.ts +1 -0
  214. package/types/edsis-ui-chart-radar.d.ts +1 -0
  215. package/types/edsis-ui-chart-radial.d.ts +1 -0
  216. package/types/edsis-ui-chart-scatter.d.ts +1 -0
  217. package/types/edsis-ui-chart.d.ts +1094 -0
  218. package/types/edsis-ui-checkbox.d.ts +35 -0
  219. package/types/edsis-ui-collapsible.d.ts +42 -0
  220. package/types/edsis-ui-combobox.d.ts +51 -0
  221. package/types/edsis-ui-command.d.ts +99 -0
  222. package/types/edsis-ui-composer.d.ts +90 -0
  223. package/types/edsis-ui-context-menu.d.ts +35 -0
  224. package/types/edsis-ui-date-picker.d.ts +41 -0
  225. package/types/edsis-ui-dialog.d.ts +87 -0
  226. package/types/edsis-ui-drawer.d.ts +1 -0
  227. package/types/edsis-ui-dropdown-menu.d.ts +136 -0
  228. package/types/edsis-ui-editor.d.ts +123 -0
  229. package/types/edsis-ui-empty.d.ts +50 -0
  230. package/types/edsis-ui-form.d.ts +141 -0
  231. package/types/edsis-ui-hover-card.d.ts +74 -0
  232. package/types/edsis-ui-input-group.d.ts +51 -0
  233. package/types/edsis-ui-input-otp.d.ts +136 -0
  234. package/types/edsis-ui-input.d.ts +16 -0
  235. package/types/edsis-ui-item.d.ts +88 -0
  236. package/types/edsis-ui-kanban.d.ts +70 -0
  237. package/types/edsis-ui-kbd.d.ts +16 -0
  238. package/types/edsis-ui-label.d.ts +11 -0
  239. package/types/edsis-ui-menubar.d.ts +67 -0
  240. package/types/edsis-ui-native-select.d.ts +26 -0
  241. package/types/edsis-ui-navigation-menu.d.ts +96 -0
  242. package/types/edsis-ui-pagination.d.ts +34 -0
  243. package/types/edsis-ui-pillbox.d.ts +157 -0
  244. package/types/edsis-ui-popover.d.ts +43 -0
  245. package/types/edsis-ui-progress.d.ts +17 -0
  246. package/types/edsis-ui-radio.d.ts +40 -0
  247. package/types/edsis-ui-resizable.d.ts +99 -0
  248. package/types/edsis-ui-scroll-area.d.ts +19 -0
  249. package/types/edsis-ui-select.d.ts +57 -0
  250. package/types/edsis-ui-separator.d.ts +14 -0
  251. package/types/edsis-ui-sheet.d.ts +76 -0
  252. package/types/edsis-ui-skeleton.d.ts +10 -0
  253. package/types/edsis-ui-slider.d.ts +74 -0
  254. package/types/edsis-ui-spinner.d.ts +13 -0
  255. package/types/edsis-ui-switch.d.ts +40 -0
  256. package/types/edsis-ui-table.d.ts +52 -0
  257. package/types/edsis-ui-tabs.d.ts +92 -0
  258. package/types/edsis-ui-textarea.d.ts +12 -0
  259. package/types/edsis-ui-timeline.d.ts +63 -0
  260. package/types/edsis-ui-toast.d.ts +38 -0
  261. package/types/edsis-ui-toggle-group.d.ts +89 -0
  262. package/types/edsis-ui-toggle.d.ts +25 -0
  263. package/types/edsis-ui-tooltip.d.ts +89 -0
  264. package/types/edsis-ui-utils.d.ts +5 -0
  265. package/types/edsis-ui.d.ts +2 -0
@@ -0,0 +1,692 @@
1
+ import { DOCUMENT } from '@angular/common';
2
+ import * as i0 from '@angular/core';
3
+ import { input, booleanAttribute, output, computed, ChangeDetectionStrategy, Component, inject, ElementRef, signal, forwardRef } from '@angular/core';
4
+ import { NG_VALUE_ACCESSOR } from '@angular/forms';
5
+ import { cn } from '@edsis/ui/utils';
6
+
7
+ const DEFAULT_EDITOR_TOOLBAR = 'heading | bold italic underline strike | bullet ordered blockquote link align ~ undo redo';
8
+ const EDITOR_BASE = 'block w-full min-w-0 text-sm text-foreground';
9
+ const EDITOR_SHELL_BASE = [
10
+ 'relative min-w-0 overflow-hidden rounded-md border border-input bg-background shadow-sm',
11
+ 'transition-[border-color,box-shadow] focus-within:border-ring focus-within:ring-1 focus-within:ring-ring',
12
+ 'aria-[invalid=true]:border-destructive aria-[invalid=true]:focus-within:ring-destructive',
13
+ 'data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50',
14
+ ].join(' ');
15
+ const EDITOR_TOOLBAR_BASE = [
16
+ 'flex min-h-11 min-w-0 flex-wrap items-center gap-1 border-b border-border/70 bg-muted/30 px-2 py-1.5',
17
+ 'data-[disabled=true]:pointer-events-none',
18
+ ].join(' ');
19
+ const EDITOR_TOOL_BUTTON_BASE = [
20
+ 'inline-flex size-8 shrink-0 items-center justify-center rounded-md text-sm font-medium text-muted-foreground',
21
+ 'transition-colors hover:bg-accent hover:text-accent-foreground',
22
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
23
+ 'disabled:pointer-events-none disabled:opacity-50',
24
+ 'aria-pressed:bg-accent aria-pressed:text-accent-foreground',
25
+ ].join(' ');
26
+ const EDITOR_SELECT_BASE = [
27
+ 'h-8 rounded-md border border-transparent bg-transparent px-2 text-sm font-medium text-muted-foreground outline-none',
28
+ 'transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 focus-visible:ring-ring',
29
+ 'disabled:pointer-events-none disabled:opacity-50',
30
+ ].join(' ');
31
+ const EDITOR_CONTENT_BASE = [
32
+ 'block min-h-[200px] max-h-[500px] w-full overflow-y-auto px-4 py-3 text-sm leading-6 outline-none',
33
+ '[&_p]:my-2 [&_h1]:mb-2 [&_h1]:mt-4 [&_h1]:text-2xl [&_h1]:font-semibold [&_h2]:mb-2 [&_h2]:mt-4 [&_h2]:text-xl [&_h2]:font-semibold [&_h3]:mb-2 [&_h3]:mt-4 [&_h3]:text-lg [&_h3]:font-semibold',
34
+ '[&_blockquote]:my-3 [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-3 [&_blockquote]:text-muted-foreground [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-6 [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-6 [&_pre]:my-3 [&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:bg-muted [&_pre]:p-3 [&_pre]:font-mono [&_pre]:text-xs',
35
+ 'data-[empty=true]:before:pointer-events-none data-[empty=true]:before:text-muted-foreground data-[empty=true]:before:content-[attr(data-placeholder)]',
36
+ 'data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50',
37
+ ].join(' ');
38
+ const toolbarButtons = {
39
+ bold: { label: 'B', ariaLabel: 'Bold' },
40
+ italic: { label: 'I', ariaLabel: 'Italic' },
41
+ underline: { label: 'U', ariaLabel: 'Underline' },
42
+ strike: { label: 'S', ariaLabel: 'Strikethrough' },
43
+ bullet: { label: 'UL', ariaLabel: 'Bulleted list' },
44
+ ordered: { label: '1.', ariaLabel: 'Numbered list' },
45
+ blockquote: { label: 'Q', ariaLabel: 'Block quote' },
46
+ subscript: { label: 'Sub', ariaLabel: 'Subscript' },
47
+ superscript: { label: 'Sup', ariaLabel: 'Superscript' },
48
+ highlight: { label: 'H', ariaLabel: 'Highlight' },
49
+ link: { label: 'Link', ariaLabel: 'Insert link' },
50
+ code: { label: '</>', ariaLabel: 'Code block' },
51
+ undo: { label: 'Undo', ariaLabel: 'Undo' },
52
+ redo: { label: 'Redo', ariaLabel: 'Redo' },
53
+ };
54
+ const toolbarItemAliases = {
55
+ bold: 'bold',
56
+ italic: 'italic',
57
+ strike: 'strike',
58
+ underline: 'underline',
59
+ bullet: 'bullet',
60
+ ordered: 'ordered',
61
+ blockquote: 'blockquote',
62
+ subscript: 'subscript',
63
+ superscript: 'superscript',
64
+ highlight: 'highlight',
65
+ link: 'link',
66
+ code: 'code',
67
+ undo: 'undo',
68
+ redo: 'redo',
69
+ };
70
+ const parseToolbarItems = (items) => {
71
+ const tokens = items.split(/\s+/).filter(Boolean);
72
+ return tokens.flatMap((token, index) => {
73
+ if (token === '|') {
74
+ return [{ type: 'separator', track: `separator-${index}` }];
75
+ }
76
+ if (token === '~') {
77
+ return [{ type: 'spacer', track: `spacer-${index}` }];
78
+ }
79
+ if (token === 'heading') {
80
+ return [{ type: 'heading', track: `heading-${index}` }];
81
+ }
82
+ if (token === 'align') {
83
+ return [{ type: 'align', track: `align-${index}` }];
84
+ }
85
+ const command = toolbarItemAliases[token];
86
+ const button = command ? toolbarButtons[command] : undefined;
87
+ if (!command || !button) {
88
+ return [];
89
+ }
90
+ return [{ type: 'button', command, label: button.label, ariaLabel: button.ariaLabel }];
91
+ });
92
+ };
93
+ class EditorComponent {
94
+ disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
95
+ invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
96
+ class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
97
+ commandSelected = output();
98
+ content = null;
99
+ classes = computed(() => cn(EDITOR_BASE, this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
100
+ shellClasses = computed(() => cn(EDITOR_SHELL_BASE), ...(ngDevMode ? [{ debugName: "shellClasses" }] : /* istanbul ignore next */ []));
101
+ execute(command, source = 'api', originalEvent) {
102
+ if (this.disabled()) {
103
+ return;
104
+ }
105
+ this.content?.execute(command);
106
+ this.commandSelected.emit({ command, source, originalEvent });
107
+ }
108
+ registerContent(content) {
109
+ this.content = content;
110
+ }
111
+ unregisterContent(content) {
112
+ if (this.content === content) {
113
+ this.content = null;
114
+ }
115
+ }
116
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: EditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
117
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: EditorComponent, isStandalone: true, selector: "ui-editor", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { commandSelected: "commandSelected" }, host: { properties: { "class": "classes()", "attr.data-slot": "\"editor\"", "attr.data-disabled": "disabled() ? \"true\" : null", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-invalid": "invalid() ? \"true\" : null", "attr.inert": "disabled() ? \"\" : null" } }, ngImport: i0, template: `
118
+ <div
119
+ data-slot="editor-shell"
120
+ [class]="shellClasses()"
121
+ [attr.data-disabled]="disabled() ? 'true' : null"
122
+ [attr.aria-invalid]="invalid() ? 'true' : null">
123
+ <ng-content select="ui-editor-toolbar" />
124
+ <ng-content select="ui-editor-content" />
125
+ </div>
126
+ `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
127
+ }
128
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: EditorComponent, decorators: [{
129
+ type: Component,
130
+ args: [{
131
+ selector: 'ui-editor',
132
+ changeDetection: ChangeDetectionStrategy.OnPush,
133
+ host: {
134
+ '[class]': 'classes()',
135
+ '[attr.data-slot]': '"editor"',
136
+ '[attr.data-disabled]': 'disabled() ? "true" : null',
137
+ '[attr.aria-disabled]': 'disabled() ? "true" : null',
138
+ '[attr.aria-invalid]': 'invalid() ? "true" : null',
139
+ '[attr.inert]': 'disabled() ? "" : null',
140
+ },
141
+ template: `
142
+ <div
143
+ data-slot="editor-shell"
144
+ [class]="shellClasses()"
145
+ [attr.data-disabled]="disabled() ? 'true' : null"
146
+ [attr.aria-invalid]="invalid() ? 'true' : null">
147
+ <ng-content select="ui-editor-toolbar" />
148
+ <ng-content select="ui-editor-content" />
149
+ </div>
150
+ `,
151
+ }]
152
+ }], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], commandSelected: [{ type: i0.Output, args: ["commandSelected"] }] } });
153
+ class EditorToolbarComponent {
154
+ editor = inject(EditorComponent, { optional: true });
155
+ items = input(DEFAULT_EDITOR_TOOLBAR, ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
156
+ disabledInput = input(false, { ...(ngDevMode ? { debugName: "disabledInput" } : /* istanbul ignore next */ {}), alias: 'disabled', transform: booleanAttribute });
157
+ ariaLabel = input('Formatting', { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
158
+ class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
159
+ buttonClasses = EDITOR_TOOL_BUTTON_BASE;
160
+ selectClasses = EDITOR_SELECT_BASE;
161
+ disabled = computed(() => this.disabledInput() || this.editor?.disabled() === true, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
162
+ parts = computed(() => parseToolbarItems(this.items()), ...(ngDevMode ? [{ debugName: "parts" }] : /* istanbul ignore next */ []));
163
+ classes = computed(() => cn(EDITOR_TOOLBAR_BASE, this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
164
+ execute(command, event) {
165
+ this.editor?.execute(command, 'toolbar', event);
166
+ }
167
+ handleSelect(event) {
168
+ const select = event.target;
169
+ this.editor?.execute(select.value, 'toolbar', event);
170
+ select.selectedIndex = 0;
171
+ }
172
+ preserveSelection(event) {
173
+ event.preventDefault();
174
+ }
175
+ trackPart(part, index) {
176
+ if (part.type === 'button') {
177
+ return `${part.command}-${index}`;
178
+ }
179
+ return part.track;
180
+ }
181
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: EditorToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
182
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.14", type: EditorToolbarComponent, isStandalone: true, selector: "ui-editor-toolbar", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, disabledInput: { classPropertyName: "disabledInput", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "toolbar" }, properties: { "class": "classes()", "attr.data-slot": "\"editor-toolbar\"", "attr.aria-label": "ariaLabel()", "attr.data-disabled": "disabled() ? \"true\" : null" } }, ngImport: i0, template: `
183
+ @for (part of parts(); track trackPart(part, $index)) {
184
+ @switch (part.type) {
185
+ @case ('heading') {
186
+ <select
187
+ [class]="selectClasses"
188
+ [disabled]="disabled()"
189
+ aria-label="Text style"
190
+ (change)="handleSelect($event)">
191
+ <option value="paragraph">Text</option>
192
+ <option value="heading-1">Heading 1</option>
193
+ <option value="heading-2">Heading 2</option>
194
+ <option value="heading-3">Heading 3</option>
195
+ </select>
196
+ }
197
+ @case ('align') {
198
+ <select
199
+ [class]="selectClasses"
200
+ [disabled]="disabled()"
201
+ aria-label="Text alignment"
202
+ (change)="handleSelect($event)">
203
+ <option value="align-left">Left</option>
204
+ <option value="align-center">Center</option>
205
+ <option value="align-right">Right</option>
206
+ </select>
207
+ }
208
+ @case ('separator') {
209
+ <span
210
+ data-slot="editor-separator"
211
+ class="mx-1 h-6 w-px shrink-0 bg-border"
212
+ role="separator"
213
+ aria-orientation="vertical"></span>
214
+ }
215
+ @case ('spacer') {
216
+ <span data-slot="editor-spacer" class="min-w-2 flex-1"></span>
217
+ }
218
+ @case ('button') {
219
+ <button
220
+ type="button"
221
+ data-slot="editor-button"
222
+ [class]="buttonClasses"
223
+ [disabled]="disabled()"
224
+ [attr.aria-label]="part.ariaLabel"
225
+ [attr.title]="part.ariaLabel"
226
+ (mousedown)="preserveSelection($event)"
227
+ (click)="execute(part.command, $event)">
228
+ @if (part.command === 'undo') {
229
+ <svg
230
+ aria-hidden="true"
231
+ class="size-4"
232
+ viewBox="0 0 24 24"
233
+ fill="none"
234
+ stroke="currentColor"
235
+ stroke-width="1.75"
236
+ stroke-linecap="round"
237
+ stroke-linejoin="round">
238
+ <path d="M9 14 4 9l5-5" />
239
+ <path d="M4 9h10a6 6 0 0 1 0 12h-2" />
240
+ </svg>
241
+ } @else if (part.command === 'redo') {
242
+ <svg
243
+ aria-hidden="true"
244
+ class="size-4"
245
+ viewBox="0 0 24 24"
246
+ fill="none"
247
+ stroke="currentColor"
248
+ stroke-width="1.75"
249
+ stroke-linecap="round"
250
+ stroke-linejoin="round">
251
+ <path d="m15 14 5-5-5-5" />
252
+ <path d="M20 9H10a6 6 0 0 0 0 12h2" />
253
+ </svg>
254
+ } @else {
255
+ <span aria-hidden="true">{{ part.label }}</span>
256
+ }
257
+ </button>
258
+ }
259
+ }
260
+ }
261
+ <ng-content />
262
+ `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
263
+ }
264
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: EditorToolbarComponent, decorators: [{
265
+ type: Component,
266
+ args: [{
267
+ selector: 'ui-editor-toolbar',
268
+ changeDetection: ChangeDetectionStrategy.OnPush,
269
+ host: {
270
+ '[class]': 'classes()',
271
+ '[attr.data-slot]': '"editor-toolbar"',
272
+ role: 'toolbar',
273
+ '[attr.aria-label]': 'ariaLabel()',
274
+ '[attr.data-disabled]': 'disabled() ? "true" : null',
275
+ },
276
+ template: `
277
+ @for (part of parts(); track trackPart(part, $index)) {
278
+ @switch (part.type) {
279
+ @case ('heading') {
280
+ <select
281
+ [class]="selectClasses"
282
+ [disabled]="disabled()"
283
+ aria-label="Text style"
284
+ (change)="handleSelect($event)">
285
+ <option value="paragraph">Text</option>
286
+ <option value="heading-1">Heading 1</option>
287
+ <option value="heading-2">Heading 2</option>
288
+ <option value="heading-3">Heading 3</option>
289
+ </select>
290
+ }
291
+ @case ('align') {
292
+ <select
293
+ [class]="selectClasses"
294
+ [disabled]="disabled()"
295
+ aria-label="Text alignment"
296
+ (change)="handleSelect($event)">
297
+ <option value="align-left">Left</option>
298
+ <option value="align-center">Center</option>
299
+ <option value="align-right">Right</option>
300
+ </select>
301
+ }
302
+ @case ('separator') {
303
+ <span
304
+ data-slot="editor-separator"
305
+ class="mx-1 h-6 w-px shrink-0 bg-border"
306
+ role="separator"
307
+ aria-orientation="vertical"></span>
308
+ }
309
+ @case ('spacer') {
310
+ <span data-slot="editor-spacer" class="min-w-2 flex-1"></span>
311
+ }
312
+ @case ('button') {
313
+ <button
314
+ type="button"
315
+ data-slot="editor-button"
316
+ [class]="buttonClasses"
317
+ [disabled]="disabled()"
318
+ [attr.aria-label]="part.ariaLabel"
319
+ [attr.title]="part.ariaLabel"
320
+ (mousedown)="preserveSelection($event)"
321
+ (click)="execute(part.command, $event)">
322
+ @if (part.command === 'undo') {
323
+ <svg
324
+ aria-hidden="true"
325
+ class="size-4"
326
+ viewBox="0 0 24 24"
327
+ fill="none"
328
+ stroke="currentColor"
329
+ stroke-width="1.75"
330
+ stroke-linecap="round"
331
+ stroke-linejoin="round">
332
+ <path d="M9 14 4 9l5-5" />
333
+ <path d="M4 9h10a6 6 0 0 1 0 12h-2" />
334
+ </svg>
335
+ } @else if (part.command === 'redo') {
336
+ <svg
337
+ aria-hidden="true"
338
+ class="size-4"
339
+ viewBox="0 0 24 24"
340
+ fill="none"
341
+ stroke="currentColor"
342
+ stroke-width="1.75"
343
+ stroke-linecap="round"
344
+ stroke-linejoin="round">
345
+ <path d="m15 14 5-5-5-5" />
346
+ <path d="M20 9H10a6 6 0 0 0 0 12h2" />
347
+ </svg>
348
+ } @else {
349
+ <span aria-hidden="true">{{ part.label }}</span>
350
+ }
351
+ </button>
352
+ }
353
+ }
354
+ }
355
+ <ng-content />
356
+ `,
357
+ }]
358
+ }], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], disabledInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
359
+ class EditorButtonComponent {
360
+ editor = inject(EditorComponent, { optional: true });
361
+ command = input(null, ...(ngDevMode ? [{ debugName: "command" }] : /* istanbul ignore next */ []));
362
+ pressed = input(null, ...(ngDevMode ? [{ debugName: "pressed" }] : /* istanbul ignore next */ []));
363
+ disabledInput = input(false, { ...(ngDevMode ? { debugName: "disabledInput" } : /* istanbul ignore next */ {}), alias: 'disabled', transform: booleanAttribute });
364
+ tooltip = input('', ...(ngDevMode ? [{ debugName: "tooltip" }] : /* istanbul ignore next */ []));
365
+ class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
366
+ disabled = computed(() => this.disabledInput() || this.editor?.disabled() === true, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
367
+ classes = computed(() => cn(EDITOR_TOOL_BUTTON_BASE, this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
368
+ handleClick(event) {
369
+ const command = this.command();
370
+ if (!command) {
371
+ return;
372
+ }
373
+ this.editor?.execute(command, 'toolbar', event);
374
+ }
375
+ preserveSelection(event) {
376
+ event.preventDefault();
377
+ }
378
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: EditorButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
379
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: EditorButtonComponent, isStandalone: true, selector: "button[ui-editor-button]", inputs: { command: { classPropertyName: "command", publicName: "command", isSignal: true, isRequired: false, transformFunction: null }, pressed: { classPropertyName: "pressed", publicName: "pressed", isSignal: true, isRequired: false, transformFunction: null }, disabledInput: { classPropertyName: "disabledInput", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, tooltip: { classPropertyName: "tooltip", publicName: "tooltip", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "type": "button" }, listeners: { "mousedown": "preserveSelection($event)", "click": "handleClick($event)" }, properties: { "class": "classes()", "attr.data-slot": "\"editor-button\"", "attr.title": "tooltip() || null", "attr.aria-pressed": "pressed() === null ? null : pressed()", "disabled": "disabled() || null" } }, ngImport: i0, template: `<ng-content />`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
380
+ }
381
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: EditorButtonComponent, decorators: [{
382
+ type: Component,
383
+ args: [{
384
+ selector: 'button[ui-editor-button]',
385
+ changeDetection: ChangeDetectionStrategy.OnPush,
386
+ host: {
387
+ '[class]': 'classes()',
388
+ '[attr.data-slot]': '"editor-button"',
389
+ '[attr.title]': 'tooltip() || null',
390
+ '[attr.aria-pressed]': 'pressed() === null ? null : pressed()',
391
+ '[disabled]': 'disabled() || null',
392
+ type: 'button',
393
+ '(mousedown)': 'preserveSelection($event)',
394
+ '(click)': 'handleClick($event)',
395
+ },
396
+ template: `<ng-content />`,
397
+ }]
398
+ }], propDecorators: { command: [{ type: i0.Input, args: [{ isSignal: true, alias: "command", required: false }] }], pressed: [{ type: i0.Input, args: [{ isSignal: true, alias: "pressed", required: false }] }], disabledInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], tooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltip", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
399
+ class EditorSeparatorComponent {
400
+ class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
401
+ classes = computed(() => cn('mx-1 h-6 w-px shrink-0 bg-border', this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
402
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: EditorSeparatorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
403
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: EditorSeparatorComponent, isStandalone: true, selector: "ui-editor-separator", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "separator", "aria-orientation": "vertical" }, properties: { "class": "classes()", "attr.data-slot": "\"editor-separator\"" } }, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
404
+ }
405
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: EditorSeparatorComponent, decorators: [{
406
+ type: Component,
407
+ args: [{
408
+ selector: 'ui-editor-separator',
409
+ changeDetection: ChangeDetectionStrategy.OnPush,
410
+ host: {
411
+ '[class]': 'classes()',
412
+ '[attr.data-slot]': '"editor-separator"',
413
+ role: 'separator',
414
+ 'aria-orientation': 'vertical',
415
+ },
416
+ template: '',
417
+ }]
418
+ }], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
419
+ class EditorSpacerComponent {
420
+ class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
421
+ classes = computed(() => cn('min-w-2 flex-1', this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
422
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: EditorSpacerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
423
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: EditorSpacerComponent, isStandalone: true, selector: "ui-editor-spacer", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()", "attr.data-slot": "\"editor-spacer\"" } }, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
424
+ }
425
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: EditorSpacerComponent, decorators: [{
426
+ type: Component,
427
+ args: [{
428
+ selector: 'ui-editor-spacer',
429
+ changeDetection: ChangeDetectionStrategy.OnPush,
430
+ host: {
431
+ '[class]': 'classes()',
432
+ '[attr.data-slot]': '"editor-spacer"',
433
+ },
434
+ template: '',
435
+ }]
436
+ }], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
437
+ class EditorContentComponent {
438
+ el = inject(ElementRef);
439
+ editor = inject(EditorComponent, { optional: true });
440
+ document = inject(DOCUMENT);
441
+ placeholder = input('Write something...', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
442
+ ariaLabel = input('Rich text editor', { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
443
+ disabledInput = input(false, { ...(ngDevMode ? { debugName: "disabledInput" } : /* istanbul ignore next */ {}), alias: 'disabled', transform: booleanAttribute });
444
+ invalidInput = input(false, { ...(ngDevMode ? { debugName: "invalidInput" } : /* istanbul ignore next */ {}), alias: 'aria-invalid', transform: booleanAttribute });
445
+ class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
446
+ disabledState = signal(false, ...(ngDevMode ? [{ debugName: "disabledState" }] : /* istanbul ignore next */ []));
447
+ empty = signal(true, ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
448
+ disabled = computed(() => this.disabledInput() || this.disabledState() || this.editor?.disabled() === true, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
449
+ invalid = computed(() => this.invalidInput() || this.editor?.invalid() === true, ...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
450
+ classes = computed(() => cn(EDITOR_CONTENT_BASE, this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
451
+ onChange = () => { };
452
+ onTouched = () => { };
453
+ ngAfterViewInit() {
454
+ this.editor?.registerContent(this);
455
+ queueMicrotask(() => this.syncEmptyState());
456
+ }
457
+ ngOnDestroy() {
458
+ this.editor?.unregisterContent(this);
459
+ }
460
+ writeValue(value) {
461
+ this.el.nativeElement.innerHTML = value ?? '';
462
+ queueMicrotask(() => this.syncEmptyState());
463
+ }
464
+ registerOnChange(fn) {
465
+ this.onChange = fn;
466
+ }
467
+ registerOnTouched(fn) {
468
+ this.onTouched = fn;
469
+ }
470
+ setDisabledState(isDisabled) {
471
+ this.disabledState.set(isDisabled);
472
+ }
473
+ execute(command) {
474
+ if (this.disabled()) {
475
+ return;
476
+ }
477
+ this.el.nativeElement.focus();
478
+ switch (command) {
479
+ case 'paragraph':
480
+ this.exec('formatBlock', 'p');
481
+ break;
482
+ case 'heading-1':
483
+ this.exec('formatBlock', 'h1');
484
+ break;
485
+ case 'heading-2':
486
+ this.exec('formatBlock', 'h2');
487
+ break;
488
+ case 'heading-3':
489
+ this.exec('formatBlock', 'h3');
490
+ break;
491
+ case 'bold':
492
+ this.exec('bold');
493
+ break;
494
+ case 'italic':
495
+ this.exec('italic');
496
+ break;
497
+ case 'underline':
498
+ this.exec('underline');
499
+ break;
500
+ case 'strike':
501
+ this.exec('strikeThrough');
502
+ break;
503
+ case 'bullet':
504
+ this.exec('insertUnorderedList');
505
+ break;
506
+ case 'ordered':
507
+ this.exec('insertOrderedList');
508
+ break;
509
+ case 'blockquote':
510
+ this.exec('formatBlock', 'blockquote');
511
+ break;
512
+ case 'subscript':
513
+ this.exec('subscript');
514
+ break;
515
+ case 'superscript':
516
+ this.exec('superscript');
517
+ break;
518
+ case 'highlight':
519
+ this.exec('backColor', '#fef08a');
520
+ break;
521
+ case 'link':
522
+ this.exec('createLink', '#');
523
+ break;
524
+ case 'code':
525
+ this.exec('formatBlock', 'pre');
526
+ break;
527
+ case 'align-left':
528
+ this.exec('justifyLeft');
529
+ break;
530
+ case 'align-center':
531
+ this.exec('justifyCenter');
532
+ break;
533
+ case 'align-right':
534
+ this.exec('justifyRight');
535
+ break;
536
+ case 'undo':
537
+ this.exec('undo');
538
+ break;
539
+ case 'redo':
540
+ this.exec('redo');
541
+ break;
542
+ }
543
+ this.handleInput();
544
+ }
545
+ focus() {
546
+ this.el.nativeElement.focus();
547
+ }
548
+ handleInput() {
549
+ this.syncEmptyState();
550
+ this.onChange(this.el.nativeElement.innerHTML);
551
+ }
552
+ handleBlur() {
553
+ this.onTouched();
554
+ }
555
+ handleKeydown(event) {
556
+ if (this.disabled()) {
557
+ return;
558
+ }
559
+ const command = this.shortcutCommand(event);
560
+ if (!command) {
561
+ return;
562
+ }
563
+ event.preventDefault();
564
+ if (this.editor) {
565
+ this.editor.execute(command, 'shortcut', event);
566
+ return;
567
+ }
568
+ this.execute(command);
569
+ }
570
+ exec(command, value) {
571
+ if (typeof this.document.execCommand !== 'function') {
572
+ return;
573
+ }
574
+ this.document.execCommand(command, false, value);
575
+ }
576
+ syncEmptyState() {
577
+ const element = this.el.nativeElement;
578
+ const html = element.innerHTML
579
+ .replace(/<br\s*\/?\>/gi, '')
580
+ .replace(/&nbsp;/g, '')
581
+ .trim();
582
+ const text = element.textContent?.replace(/\u00a0/g, '').trim() ?? '';
583
+ this.empty.set(html.length === 0 && text.length === 0);
584
+ }
585
+ shortcutCommand(event) {
586
+ const modifier = event.metaKey || event.ctrlKey;
587
+ if (!modifier) {
588
+ return null;
589
+ }
590
+ const key = event.key.toLowerCase();
591
+ if (event.altKey && !event.shiftKey) {
592
+ if (key === '0') {
593
+ return 'paragraph';
594
+ }
595
+ if (key === '1') {
596
+ return 'heading-1';
597
+ }
598
+ if (key === '2') {
599
+ return 'heading-2';
600
+ }
601
+ if (key === '3') {
602
+ return 'heading-3';
603
+ }
604
+ }
605
+ if (event.shiftKey && !event.altKey) {
606
+ switch (key) {
607
+ case 'x':
608
+ return 'strike';
609
+ case '7':
610
+ return 'ordered';
611
+ case '8':
612
+ return 'bullet';
613
+ case 'b':
614
+ return 'blockquote';
615
+ case 'h':
616
+ return 'highlight';
617
+ case 'l':
618
+ return 'align-left';
619
+ case 'e':
620
+ return 'align-center';
621
+ case 'r':
622
+ return 'align-right';
623
+ case 'z':
624
+ return 'redo';
625
+ }
626
+ }
627
+ if (event.altKey || event.shiftKey) {
628
+ return null;
629
+ }
630
+ switch (key) {
631
+ case 'b':
632
+ return 'bold';
633
+ case 'i':
634
+ return 'italic';
635
+ case 'u':
636
+ return 'underline';
637
+ case 'e':
638
+ return 'code';
639
+ case 'z':
640
+ return 'undo';
641
+ default:
642
+ return null;
643
+ }
644
+ }
645
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: EditorContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
646
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: EditorContentComponent, isStandalone: true, selector: "ui-editor-content", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, disabledInput: { classPropertyName: "disabledInput", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalidInput: { classPropertyName: "invalidInput", publicName: "aria-invalid", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "input": "handleInput()", "blur": "handleBlur()", "keydown": "handleKeydown($event)" }, properties: { "class": "classes()", "attr.data-slot": "\"editor-content\"", "attr.contenteditable": "disabled() ? \"false\" : \"true\"", "attr.role": "\"textbox\"", "attr.aria-multiline": "\"true\"", "attr.aria-label": "ariaLabel()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-invalid": "invalid() ? \"true\" : null", "attr.data-disabled": "disabled() ? \"true\" : null", "attr.data-empty": "empty() ? \"true\" : null", "attr.data-placeholder": "placeholder()", "attr.tabindex": "disabled() ? null : \"0\"" } }, providers: [
647
+ {
648
+ provide: NG_VALUE_ACCESSOR,
649
+ useExisting: forwardRef(() => EditorContentComponent),
650
+ multi: true,
651
+ },
652
+ ], ngImport: i0, template: `<ng-content />`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
653
+ }
654
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: EditorContentComponent, decorators: [{
655
+ type: Component,
656
+ args: [{
657
+ selector: 'ui-editor-content',
658
+ changeDetection: ChangeDetectionStrategy.OnPush,
659
+ providers: [
660
+ {
661
+ provide: NG_VALUE_ACCESSOR,
662
+ useExisting: forwardRef(() => EditorContentComponent),
663
+ multi: true,
664
+ },
665
+ ],
666
+ host: {
667
+ '[class]': 'classes()',
668
+ '[attr.data-slot]': '"editor-content"',
669
+ '[attr.contenteditable]': 'disabled() ? "false" : "true"',
670
+ '[attr.role]': '"textbox"',
671
+ '[attr.aria-multiline]': '"true"',
672
+ '[attr.aria-label]': 'ariaLabel()',
673
+ '[attr.aria-disabled]': 'disabled() ? "true" : null',
674
+ '[attr.aria-invalid]': 'invalid() ? "true" : null',
675
+ '[attr.data-disabled]': 'disabled() ? "true" : null',
676
+ '[attr.data-empty]': 'empty() ? "true" : null',
677
+ '[attr.data-placeholder]': 'placeholder()',
678
+ '[attr.tabindex]': 'disabled() ? null : "0"',
679
+ '(input)': 'handleInput()',
680
+ '(blur)': 'handleBlur()',
681
+ '(keydown)': 'handleKeydown($event)',
682
+ },
683
+ template: `<ng-content />`,
684
+ }]
685
+ }], propDecorators: { placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], disabledInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalidInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-invalid", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
686
+
687
+ /**
688
+ * Generated bundle index. Do not edit.
689
+ */
690
+
691
+ export { EditorButtonComponent, EditorComponent, EditorContentComponent, EditorSeparatorComponent, EditorSpacerComponent, EditorToolbarComponent };
692
+ //# sourceMappingURL=edsis-ui-editor.mjs.map