@ojiepermana/angular-component 22.0.27

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