@sdcorejs/angular 20.3.0 → 20.3.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 (199) hide show
  1. package/README.md +2 -2
  2. package/assets/STYLE-GUIDE.md +25 -5
  3. package/assets/THEME.md +237 -5
  4. package/assets/licenses/tiptap-oss-NOTICES.txt +332 -0
  5. package/assets/scss/ckeditor5.scss +2 -88
  6. package/assets/scss/core/_control.scss +39 -0
  7. package/assets/scss/core/form.scss +156 -45
  8. package/assets/scss/core/view.scss +24 -0
  9. package/assets/scss/editor-content.scss +173 -0
  10. package/assets/scss/sd-core.scss +1 -0
  11. package/assets/scss/themes/_component-tokens.scss +93 -31
  12. package/assets/scss/themes/_material-tokens.scss +112 -0
  13. package/assets/scss/themes/_presets.scss +25 -0
  14. package/assets/scss/themes/_scales.scss +10 -0
  15. package/assets/scss/themes/_semantic.scss +13 -0
  16. package/assets/scss/themes/default.scss +8 -2
  17. package/components/avatar/index.d.ts +67 -2
  18. package/components/badge/index.d.ts +188 -6
  19. package/components/button/index.d.ts +20 -1
  20. package/components/ckeditor-styles/index.d.ts +3 -18
  21. package/components/editor/index.d.ts +20 -17
  22. package/components/editor-engine/index.d.ts +246 -0
  23. package/components/file-explorer/index.d.ts +449 -57
  24. package/components/form-generic/index.d.ts +301 -37
  25. package/components/index.d.ts +2 -0
  26. package/components/kanban/index.d.ts +179 -0
  27. package/components/mini-editor/index.d.ts +33 -70
  28. package/components/modal-resizable/index.d.ts +1 -124
  29. package/components/operator/index.d.ts +137 -8
  30. package/components/section/index.d.ts +2 -1
  31. package/components/tab/index.d.ts +3 -1
  32. package/components/tab-router/index.d.ts +31 -18
  33. package/components/table/index.d.ts +84 -6
  34. package/components/window/index.d.ts +81 -0
  35. package/configurations/index.d.ts +8 -1
  36. package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs +5 -5
  37. package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs.map +1 -1
  38. package/fesm2022/sdcorejs-angular-components-avatar.mjs +142 -11
  39. package/fesm2022/sdcorejs-angular-components-avatar.mjs.map +1 -1
  40. package/fesm2022/sdcorejs-angular-components-badge.mjs +548 -24
  41. package/fesm2022/sdcorejs-angular-components-badge.mjs.map +1 -1
  42. package/fesm2022/sdcorejs-angular-components-button.mjs +33 -3
  43. package/fesm2022/sdcorejs-angular-components-button.mjs.map +1 -1
  44. package/fesm2022/sdcorejs-angular-components-ckeditor-styles.mjs +5 -20
  45. package/fesm2022/sdcorejs-angular-components-ckeditor-styles.mjs.map +1 -1
  46. package/fesm2022/sdcorejs-angular-components-data-state.mjs +1 -1
  47. package/fesm2022/sdcorejs-angular-components-data-state.mjs.map +1 -1
  48. package/fesm2022/sdcorejs-angular-components-editor-engine.mjs +1872 -0
  49. package/fesm2022/sdcorejs-angular-components-editor-engine.mjs.map +1 -0
  50. package/fesm2022/sdcorejs-angular-components-editor.mjs +457 -756
  51. package/fesm2022/sdcorejs-angular-components-editor.mjs.map +1 -1
  52. package/fesm2022/sdcorejs-angular-components-file-explorer.mjs +2209 -106
  53. package/fesm2022/sdcorejs-angular-components-file-explorer.mjs.map +1 -1
  54. package/fesm2022/sdcorejs-angular-components-form-generic.mjs +2616 -1054
  55. package/fesm2022/sdcorejs-angular-components-form-generic.mjs.map +1 -1
  56. package/fesm2022/sdcorejs-angular-components-history.mjs +5 -2
  57. package/fesm2022/sdcorejs-angular-components-history.mjs.map +1 -1
  58. package/fesm2022/sdcorejs-angular-components-image-editor.mjs +1 -1
  59. package/fesm2022/sdcorejs-angular-components-image-editor.mjs.map +1 -1
  60. package/fesm2022/sdcorejs-angular-components-import-excel.mjs +21 -6
  61. package/fesm2022/sdcorejs-angular-components-import-excel.mjs.map +1 -1
  62. package/fesm2022/sdcorejs-angular-components-inform.mjs +1 -1
  63. package/fesm2022/sdcorejs-angular-components-inform.mjs.map +1 -1
  64. package/fesm2022/sdcorejs-angular-components-kanban.mjs +451 -0
  65. package/fesm2022/sdcorejs-angular-components-kanban.mjs.map +1 -0
  66. package/fesm2022/sdcorejs-angular-components-mini-editor.mjs +177 -283
  67. package/fesm2022/sdcorejs-angular-components-mini-editor.mjs.map +1 -1
  68. package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs +1 -308
  69. package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs.map +1 -1
  70. package/fesm2022/sdcorejs-angular-components-modal.mjs +2 -2
  71. package/fesm2022/sdcorejs-angular-components-modal.mjs.map +1 -1
  72. package/fesm2022/sdcorejs-angular-components-operator.mjs +262 -43
  73. package/fesm2022/sdcorejs-angular-components-operator.mjs.map +1 -1
  74. package/fesm2022/sdcorejs-angular-components-query-bar.mjs +12 -12
  75. package/fesm2022/sdcorejs-angular-components-query-bar.mjs.map +1 -1
  76. package/fesm2022/sdcorejs-angular-components-query-builder.mjs +1 -1
  77. package/fesm2022/sdcorejs-angular-components-query-builder.mjs.map +1 -1
  78. package/fesm2022/sdcorejs-angular-components-section.mjs +5 -4
  79. package/fesm2022/sdcorejs-angular-components-section.mjs.map +1 -1
  80. package/fesm2022/sdcorejs-angular-components-side-drawer.mjs +2 -2
  81. package/fesm2022/sdcorejs-angular-components-side-drawer.mjs.map +1 -1
  82. package/fesm2022/sdcorejs-angular-components-stepper.mjs +5 -1
  83. package/fesm2022/sdcorejs-angular-components-stepper.mjs.map +1 -1
  84. package/fesm2022/sdcorejs-angular-components-tab-router.mjs +192 -42
  85. package/fesm2022/sdcorejs-angular-components-tab-router.mjs.map +1 -1
  86. package/fesm2022/sdcorejs-angular-components-tab.mjs +12 -4
  87. package/fesm2022/sdcorejs-angular-components-tab.mjs.map +1 -1
  88. package/fesm2022/sdcorejs-angular-components-table.mjs +564 -110
  89. package/fesm2022/sdcorejs-angular-components-table.mjs.map +1 -1
  90. package/fesm2022/sdcorejs-angular-components-tree.mjs +1 -1
  91. package/fesm2022/sdcorejs-angular-components-tree.mjs.map +1 -1
  92. package/fesm2022/sdcorejs-angular-components-upload-file.mjs +1 -1
  93. package/fesm2022/sdcorejs-angular-components-upload-file.mjs.map +1 -1
  94. package/fesm2022/sdcorejs-angular-components-view.mjs +2 -2
  95. package/fesm2022/sdcorejs-angular-components-view.mjs.map +1 -1
  96. package/fesm2022/sdcorejs-angular-components-window.mjs +486 -0
  97. package/fesm2022/sdcorejs-angular-components-window.mjs.map +1 -0
  98. package/fesm2022/sdcorejs-angular-components.mjs +2 -0
  99. package/fesm2022/sdcorejs-angular-components.mjs.map +1 -1
  100. package/fesm2022/sdcorejs-angular-configurations.mjs.map +1 -1
  101. package/fesm2022/sdcorejs-angular-directives.mjs +18 -1
  102. package/fesm2022/sdcorejs-angular-directives.mjs.map +1 -1
  103. package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs +15 -2
  104. package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs.map +1 -1
  105. package/fesm2022/sdcorejs-angular-forms-checkbox.mjs +2 -2
  106. package/fesm2022/sdcorejs-angular-forms-checkbox.mjs.map +1 -1
  107. package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs +460 -125
  108. package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs.map +1 -1
  109. package/fesm2022/sdcorejs-angular-forms-date-range.mjs +75 -13
  110. package/fesm2022/sdcorejs-angular-forms-date-range.mjs.map +1 -1
  111. package/fesm2022/sdcorejs-angular-forms-date.mjs +71 -18
  112. package/fesm2022/sdcorejs-angular-forms-date.mjs.map +1 -1
  113. package/fesm2022/sdcorejs-angular-forms-datetime.mjs +75 -16
  114. package/fesm2022/sdcorejs-angular-forms-datetime.mjs.map +1 -1
  115. package/fesm2022/sdcorejs-angular-forms-directives.mjs +82 -2
  116. package/fesm2022/sdcorejs-angular-forms-directives.mjs.map +1 -1
  117. package/fesm2022/sdcorejs-angular-forms-entity-picker.mjs +2 -2
  118. package/fesm2022/sdcorejs-angular-forms-entity-picker.mjs.map +1 -1
  119. package/fesm2022/sdcorejs-angular-forms-input-color.mjs +1 -1
  120. package/fesm2022/sdcorejs-angular-forms-input-color.mjs.map +1 -1
  121. package/fesm2022/sdcorejs-angular-forms-input-number.mjs +40 -5
  122. package/fesm2022/sdcorejs-angular-forms-input-number.mjs.map +1 -1
  123. package/fesm2022/sdcorejs-angular-forms-input.mjs +50 -7
  124. package/fesm2022/sdcorejs-angular-forms-input.mjs.map +1 -1
  125. package/fesm2022/sdcorejs-angular-forms-models.mjs +88 -5
  126. package/fesm2022/sdcorejs-angular-forms-models.mjs.map +1 -1
  127. package/fesm2022/sdcorejs-angular-forms-radio.mjs +2 -2
  128. package/fesm2022/sdcorejs-angular-forms-radio.mjs.map +1 -1
  129. package/fesm2022/sdcorejs-angular-forms-segmented.mjs +245 -0
  130. package/fesm2022/sdcorejs-angular-forms-segmented.mjs.map +1 -0
  131. package/fesm2022/sdcorejs-angular-forms-select.mjs +63 -15
  132. package/fesm2022/sdcorejs-angular-forms-select.mjs.map +1 -1
  133. package/fesm2022/sdcorejs-angular-forms-switch.mjs +2 -2
  134. package/fesm2022/sdcorejs-angular-forms-switch.mjs.map +1 -1
  135. package/fesm2022/sdcorejs-angular-forms-textarea.mjs +2 -2
  136. package/fesm2022/sdcorejs-angular-forms-textarea.mjs.map +1 -1
  137. package/fesm2022/sdcorejs-angular-forms-time.mjs +2 -2
  138. package/fesm2022/sdcorejs-angular-forms-time.mjs.map +1 -1
  139. package/fesm2022/sdcorejs-angular-forms-tree-select.mjs +1 -1
  140. package/fesm2022/sdcorejs-angular-forms-tree-select.mjs.map +1 -1
  141. package/fesm2022/sdcorejs-angular-forms.mjs +8 -0
  142. package/fesm2022/sdcorejs-angular-forms.mjs.map +1 -1
  143. package/fesm2022/sdcorejs-angular-i18n.mjs +1830 -17
  144. package/fesm2022/sdcorejs-angular-i18n.mjs.map +1 -1
  145. package/fesm2022/sdcorejs-angular-interceptors.mjs +1 -1
  146. package/fesm2022/sdcorejs-angular-interceptors.mjs.map +1 -1
  147. package/fesm2022/sdcorejs-angular-modules-generic-generic-configuration.page-DnbDCdcz.mjs +478 -0
  148. package/fesm2022/sdcorejs-angular-modules-generic-generic-configuration.page-DnbDCdcz.mjs.map +1 -0
  149. package/fesm2022/sdcorejs-angular-modules-generic-generic-form-host.page-EBHM4kx2.mjs +214 -0
  150. package/fesm2022/sdcorejs-angular-modules-generic-generic-form-host.page-EBHM4kx2.mjs.map +1 -0
  151. package/fesm2022/sdcorejs-angular-modules-generic-generic-list.page-BtHe8YIW.mjs +277 -0
  152. package/fesm2022/sdcorejs-angular-modules-generic-generic-list.page-BtHe8YIW.mjs.map +1 -0
  153. package/fesm2022/sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-eFshU7ew.mjs +1556 -0
  154. package/fesm2022/sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-eFshU7ew.mjs.map +1 -0
  155. package/fesm2022/sdcorejs-angular-modules-generic.mjs +2 -0
  156. package/fesm2022/sdcorejs-angular-modules-generic.mjs.map +1 -0
  157. package/fesm2022/sdcorejs-angular-modules-icon.mjs +96 -3
  158. package/fesm2022/sdcorejs-angular-modules-icon.mjs.map +1 -1
  159. package/fesm2022/sdcorejs-angular-modules-layout.mjs +1825 -62
  160. package/fesm2022/sdcorejs-angular-modules-layout.mjs.map +1 -1
  161. package/fesm2022/sdcorejs-angular-modules.mjs +1 -0
  162. package/fesm2022/sdcorejs-angular-modules.mjs.map +1 -1
  163. package/fesm2022/sdcorejs-angular-pipes.mjs +27 -7
  164. package/fesm2022/sdcorejs-angular-pipes.mjs.map +1 -1
  165. package/fesm2022/sdcorejs-angular-services-confirm.mjs +2 -2
  166. package/fesm2022/sdcorejs-angular-services-confirm.mjs.map +1 -1
  167. package/fesm2022/sdcorejs-angular-services-date-time.mjs +143 -0
  168. package/fesm2022/sdcorejs-angular-services-date-time.mjs.map +1 -0
  169. package/fesm2022/sdcorejs-angular-services-storage.mjs +44 -8
  170. package/fesm2022/sdcorejs-angular-services-storage.mjs.map +1 -1
  171. package/fesm2022/sdcorejs-angular-services.mjs +1 -0
  172. package/fesm2022/sdcorejs-angular-services.mjs.map +1 -1
  173. package/fesm2022/sdcorejs-angular-utilities-read-state.mjs +4 -0
  174. package/fesm2022/sdcorejs-angular-utilities-read-state.mjs.map +1 -1
  175. package/fesm2022/sdcorejs-angular-utilities-theme.mjs +10 -0
  176. package/fesm2022/sdcorejs-angular-utilities-theme.mjs.map +1 -1
  177. package/forms/autocomplete/index.d.ts +5 -0
  178. package/forms/chip-calendar/index.d.ts +163 -18
  179. package/forms/date/index.d.ts +23 -2
  180. package/forms/date-range/index.d.ts +24 -2
  181. package/forms/directives/index.d.ts +47 -2
  182. package/forms/index.d.ts +8 -6
  183. package/forms/input/index.d.ts +23 -2
  184. package/forms/input-number/index.d.ts +23 -2
  185. package/forms/models/index.d.ts +38 -3
  186. package/forms/segmented/index.d.ts +90 -0
  187. package/forms/select/index.d.ts +32 -2
  188. package/i18n/index.d.ts +360 -1
  189. package/modules/generic/index.d.ts +316 -0
  190. package/modules/icon/index.d.ts +37 -6
  191. package/modules/index.d.ts +1 -0
  192. package/modules/layout/index.d.ts +536 -86
  193. package/package.json +49 -8
  194. package/pipes/index.d.ts +2 -0
  195. package/services/date-time/index.d.ts +57 -0
  196. package/services/index.d.ts +1 -0
  197. package/services/storage/index.d.ts +8 -1
  198. package/utilities/read-state/index.d.ts +2 -0
  199. package/utilities/theme/index.d.ts +1 -1
@@ -0,0 +1,1872 @@
1
+ import { Extension, Node, mergeAttributes, Editor } from '@tiptap/core';
2
+ import { DOMSerializer, DOMParser as DOMParser$1 } from '@tiptap/pm/model';
3
+ import { Plugin, PluginKey, EditorState, NodeSelection } from '@tiptap/pm/state';
4
+ import Suggestion from '@tiptap/suggestion';
5
+ import { computePosition, offset, flip, shift } from '@floating-ui/dom';
6
+ import StarterKit from '@tiptap/starter-kit';
7
+ import Image from '@tiptap/extension-image';
8
+ import { Table, TableRow, TableCell, TableHeader } from '@tiptap/extension-table';
9
+ import Subscript from '@tiptap/extension-subscript';
10
+ import Superscript from '@tiptap/extension-superscript';
11
+ import { Markdown } from '@tiptap/markdown';
12
+ import { TextStyle, Color, BackgroundColor, FontFamily, FontSize } from '@tiptap/extension-text-style';
13
+ import TextAlign from '@tiptap/extension-text-align';
14
+ import { Placeholder } from '@tiptap/extensions';
15
+ import { sdSanitizeEditorHtml } from '@sdcorejs/angular/utilities/extensions';
16
+ import { Tokenizer, TokenizerMode } from 'parse5';
17
+ import { DOCUMENT, isPlatformBrowser } from '@angular/common';
18
+ import * as i0 from '@angular/core';
19
+ import { inject, input, output, afterRenderEffect, Directive, ElementRef, viewChild, signal, effect, untracked, DestroyRef, ChangeDetectionStrategy, Component, PLATFORM_ID, afterNextRender } from '@angular/core';
20
+ import { I18nService } from '@sdcorejs/angular/i18n';
21
+ import { SdCKEditorStyles } from '@sdcorejs/angular/components/ckeditor-styles';
22
+ import { SdButton, SdButtonItem, SdButtonItemDivider } from '@sdcorejs/angular/components/button';
23
+
24
+ class SdEditorImportError extends Error {
25
+ diagnostics;
26
+ constructor(diagnostics) {
27
+ super('Editor content cannot be exported without data loss or unsafe HTML.');
28
+ this.diagnostics = diagnostics;
29
+ this.name = 'SdEditorImportError';
30
+ }
31
+ }
32
+
33
+ const PRESERVED = /^(id|title|dir|lang|class|style|data-.+|aria-.+|cite|type|reversed|loading|width|height|srcset|sizes|headers|scope)$/;
34
+ function renderPreserved(attrs, nativeStyles = []) {
35
+ const preserved = { ...attrs['sdAttributes'] };
36
+ if (preserved['style'] && nativeStyles.length) {
37
+ const element = document.createElement('span');
38
+ element.setAttribute('style', preserved['style']);
39
+ for (const property of nativeStyles)
40
+ element.style.removeProperty(property);
41
+ const style = element.getAttribute('style');
42
+ if (style)
43
+ preserved['style'] = style;
44
+ else
45
+ delete preserved['style'];
46
+ }
47
+ return preserved;
48
+ }
49
+ const preservedAttribute = (nativeStyles = []) => ({
50
+ sdAttributes: {
51
+ default: {},
52
+ parseHTML: (element) => Object.fromEntries(Array.from(element.attributes)
53
+ .filter(attr => PRESERVED.test(attr.name))
54
+ .map(attr => [attr.name, attr.value])),
55
+ renderHTML: (attrs) => renderPreserved(attrs, nativeStyles),
56
+ },
57
+ });
58
+ const attributes = Extension.create({
59
+ name: 'sdPreservedAttributes',
60
+ addGlobalAttributes() {
61
+ return [
62
+ { types: ['paragraph', 'heading'], attributes: preservedAttribute(['text-align']) },
63
+ { types: ['textStyle'], attributes: preservedAttribute(['color', 'background-color', 'font-family', 'font-size']) },
64
+ {
65
+ types: [
66
+ 'blockquote',
67
+ 'codeBlock',
68
+ 'horizontalRule',
69
+ 'hardBreak',
70
+ 'bulletList',
71
+ 'orderedList',
72
+ 'listItem',
73
+ 'table',
74
+ 'tableRow',
75
+ 'tableCell',
76
+ 'tableHeader',
77
+ 'image',
78
+ 'inlineImage',
79
+ 'figure',
80
+ 'figcaption',
81
+ 'sdMention',
82
+ 'bold',
83
+ 'italic',
84
+ 'underline',
85
+ 'strike',
86
+ 'code',
87
+ 'subscript',
88
+ 'superscript',
89
+ 'link',
90
+ ],
91
+ attributes: preservedAttribute(),
92
+ },
93
+ ];
94
+ },
95
+ });
96
+ const span = TextStyle.extend({
97
+ parseHTML: () => [{ tag: 'span', getAttrs: el => (el.hasAttribute('data-id') ? false : null) }],
98
+ });
99
+ const figure = Node.create({
100
+ name: 'figure',
101
+ group: 'block',
102
+ content: '(image | table | figcaption)+',
103
+ defining: true,
104
+ parseHTML: () => [{ tag: 'figure' }],
105
+ renderHTML: ({ HTMLAttributes }) => ['figure', HTMLAttributes, 0],
106
+ });
107
+ const caption = Node.create({
108
+ name: 'figcaption',
109
+ group: 'block',
110
+ content: 'inline*',
111
+ parseHTML: () => [{ tag: 'figcaption' }],
112
+ renderHTML: ({ HTMLAttributes }) => ['figcaption', HTMLAttributes, 0],
113
+ });
114
+ const inlineImage = Image.extend({
115
+ name: 'inlineImage',
116
+ priority: 110,
117
+ parseHTML: () => [
118
+ { tag: 'img[src]', context: 'paragraph/' },
119
+ { tag: 'img[src]', context: 'heading/' },
120
+ { tag: 'img[src]', context: 'figcaption/' },
121
+ ],
122
+ }).configure({ inline: true, allowBase64: true });
123
+ const sdMentionNode = Node.create({
124
+ name: 'sdMention',
125
+ group: 'inline',
126
+ inline: true,
127
+ atom: true,
128
+ addAttributes: () => ({
129
+ id: { default: '', parseHTML: el => el.getAttribute('data-id'), renderHTML: attrs => ({ 'data-id': attrs['id'] }) },
130
+ name: {
131
+ default: '',
132
+ parseHTML: el => {
133
+ const marker = el.getAttribute('data-marker') ?? '@';
134
+ const text = el.textContent ?? '';
135
+ return text.startsWith(marker) ? text.slice(marker.length) : text;
136
+ },
137
+ renderHTML: () => ({}),
138
+ },
139
+ marker: {
140
+ default: '@',
141
+ parseHTML: el => el.getAttribute('data-marker') ?? '@',
142
+ renderHTML: attrs => ({ 'data-marker': attrs['marker'] }),
143
+ },
144
+ }),
145
+ parseHTML: () => [{ tag: 'span[data-id]', priority: 110 }],
146
+ renderHTML: ({ node, HTMLAttributes }) => [
147
+ 'span',
148
+ mergeAttributes(HTMLAttributes, { contenteditable: 'false' }),
149
+ `${node.attrs['marker']}${node.attrs['name']}`,
150
+ ],
151
+ renderText: ({ node }) => `${node.attrs['marker']}${node.attrs['name']}`,
152
+ });
153
+ function sdEditorExtensions(placeholder) {
154
+ const table = Table.extend({ renderHTML: ({ HTMLAttributes }) => ['table', HTMLAttributes, ['tbody', 0]] }).configure({
155
+ resizable: false,
156
+ });
157
+ return [
158
+ StarterKit.configure({
159
+ trailingNode: false,
160
+ link: { openOnClick: false, autolink: false, linkOnPaste: false, HTMLAttributes: { target: null, rel: null, class: null } },
161
+ }),
162
+ Image.configure({ allowBase64: true }),
163
+ inlineImage,
164
+ table,
165
+ TableRow,
166
+ TableCell,
167
+ TableHeader,
168
+ Subscript,
169
+ Superscript,
170
+ span,
171
+ Color,
172
+ BackgroundColor,
173
+ FontFamily,
174
+ FontSize,
175
+ TextAlign.configure({ types: ['paragraph', 'heading'], defaultAlignment: null }),
176
+ Placeholder.configure({ placeholder }),
177
+ figure,
178
+ caption,
179
+ sdMentionNode,
180
+ attributes,
181
+ Markdown,
182
+ ];
183
+ }
184
+
185
+ const SAFE_CSS = new Set([
186
+ 'text-align',
187
+ 'color',
188
+ 'background-color',
189
+ 'font-family',
190
+ 'font-size',
191
+ 'font-weight',
192
+ 'font-style',
193
+ 'text-decoration',
194
+ 'vertical-align',
195
+ 'white-space',
196
+ 'border',
197
+ 'border-width',
198
+ 'border-style',
199
+ 'border-color',
200
+ 'border-collapse',
201
+ 'table-layout',
202
+ 'padding',
203
+ 'padding-top',
204
+ 'padding-right',
205
+ 'padding-bottom',
206
+ 'padding-left',
207
+ 'width',
208
+ 'height',
209
+ 'max-width',
210
+ 'float',
211
+ 'display',
212
+ 'margin',
213
+ 'margin-top',
214
+ 'margin-right',
215
+ 'margin-bottom',
216
+ 'margin-left',
217
+ ]);
218
+ // Includes Core sanitizer DROP_WITH_CONTENT categories, document metadata and
219
+ // foreign namespaces. Safe unsupported wrappers remain original-preserving.
220
+ const ACTIVE_TAGS = 'animate,animatecolor,animatemotion,animatetransform,applet,base,button,datalist,embed,form,frame,frameset,iframe,input,keygen,link,meta,noembed,noframes,noscript,object,optgroup,option,output,plaintext,script,select,set,foreignobject,style,template,textarea,title,use,xmp,svg,math';
221
+ const ACTIVE_TAG_NAMES = new Set(ACTIVE_TAGS.split(','));
222
+ function sdEditorSemanticHtml(html) {
223
+ const root = new DOMParser().parseFromString(html, 'text/html').documentElement;
224
+ const aliases = { b: 'strong', i: 'em' };
225
+ const blocks = new Set([
226
+ 'p',
227
+ 'h1',
228
+ 'h2',
229
+ 'h3',
230
+ 'h4',
231
+ 'h5',
232
+ 'h6',
233
+ 'blockquote',
234
+ 'pre',
235
+ 'hr',
236
+ 'ul',
237
+ 'ol',
238
+ 'li',
239
+ 'table',
240
+ 'tbody',
241
+ 'thead',
242
+ 'tfoot',
243
+ 'tr',
244
+ 'td',
245
+ 'th',
246
+ 'figure',
247
+ 'figcaption',
248
+ 'caption',
249
+ 'colgroup',
250
+ 'div',
251
+ 'dl',
252
+ 'dt',
253
+ 'dd',
254
+ ]);
255
+ const contentNodes = (el) => Array.from(el.childNodes).filter(node => {
256
+ if (node.nodeType !== 3 ||
257
+ node.textContent?.trim() ||
258
+ ['pre', 'code', 'p', 'span', 'figcaption'].includes(el.localName) ||
259
+ /^(pre|pre-wrap|break-spaces)$/.test(el.style?.whiteSpace ?? ''))
260
+ return true;
261
+ const previous = node.previousSibling;
262
+ const next = node.nextSibling;
263
+ const isBlock = (sibling) => sibling?.nodeType === 1 && blocks.has(sibling.localName);
264
+ return !((!previous || isBlock(previous)) && (!next || isBlock(next)) && (previous || next));
265
+ });
266
+ const walk = (node) => {
267
+ if (node.nodeType === 3)
268
+ return ['text', node.textContent];
269
+ if (node.nodeType !== 1)
270
+ return null;
271
+ const el = node;
272
+ const tag = aliases[el.localName] ?? el.localName;
273
+ const attrs = Array.from(el.attributes)
274
+ .filter(attr => !(['colspan', 'rowspan'].includes(attr.name) && attr.value === '1'))
275
+ .map(attr => {
276
+ if (attr.name !== 'style')
277
+ return [attr.name, attr.value];
278
+ const style = Array.from(el.style)
279
+ .sort()
280
+ .map(key => `${key}:${el.style.getPropertyValue(key).trim()}:${el.style.getPropertyPriority(key)}`)
281
+ .join(';');
282
+ return ['style', style];
283
+ })
284
+ .filter(attr => attr[0] !== 'style' || attr[1] !== '')
285
+ .sort((a, b) => a[0].localeCompare(b[0]));
286
+ let children = contentNodes(el)
287
+ .map(walk)
288
+ .filter(item => item !== null);
289
+ // Browser inserts tbody; a cell/list item's sole unstyled paragraph is the same inline flow.
290
+ if (tag === 'table')
291
+ children = contentNodes(el)
292
+ .flatMap(child => (child.nodeName === 'TBODY' && !child.attributes.length ? contentNodes(child) : [child]))
293
+ .map(walk)
294
+ .filter(item => item !== null);
295
+ if (['td', 'th', 'li'].includes(tag) &&
296
+ el.children.length === 1 &&
297
+ el.childNodes.length === 1 &&
298
+ el.firstElementChild?.localName === 'p' &&
299
+ !el.firstElementChild.attributes.length)
300
+ children = Array.from(el.firstElementChild.childNodes)
301
+ .map(walk)
302
+ .filter(item => item !== null);
303
+ if (tag === 'li' &&
304
+ el.firstElementChild?.localName === 'p' &&
305
+ !el.firstElementChild.attributes.length &&
306
+ Array.from(el.children)
307
+ .slice(1)
308
+ .every(child => ['ul', 'ol'].includes(child.localName)) &&
309
+ el.firstChild === el.firstElementChild)
310
+ children = [...Array.from(el.firstElementChild.childNodes), ...Array.from(el.childNodes).slice(1)]
311
+ .map(walk)
312
+ .filter(item => item !== null);
313
+ return [tag, attrs, children];
314
+ };
315
+ return JSON.stringify(walk(root));
316
+ }
317
+ function sdEditorHtmlBoundary(source) {
318
+ const diagnostics = [];
319
+ const original = new DOMParser().parseFromString(source, 'text/html');
320
+ let html = sdSanitizeEditorHtml(source);
321
+ const safe = new DOMParser().parseFromString(html, 'text/html');
322
+ const add = (code, detail, path = '/', tag, attribute) => diagnostics.push({ code, detail, path, tag, attribute });
323
+ const sourcePath = (el) => {
324
+ if (el === original.documentElement)
325
+ return '/html';
326
+ if (el === original.head)
327
+ return '/html/head';
328
+ if (el === original.body)
329
+ return '/html/body';
330
+ const siblings = Array.from(el.parentElement?.children ?? []).filter(sibling => sibling.localName === el.localName);
331
+ return `${el.parentElement ? sourcePath(el.parentElement) : ''}/${el.localName}[${siblings.indexOf(el) + 1}]`;
332
+ };
333
+ for (const el of [original.documentElement, original.head, original.body])
334
+ for (const attribute of Array.from(el.attributes))
335
+ add('unsupported-html', 'Document envelope attributes are not represented by the editor schema.', `${sourcePath(el)}/@${attribute.name}`, el.localName, attribute.name);
336
+ for (const el of Array.from(original.querySelectorAll(ACTIVE_TAGS)))
337
+ add('unsafe-html', 'Active or raw-text elements were removed before mounting.', sourcePath(el), el.localName);
338
+ // Inspect actual parsed attributes. Raw pattern matching also catches harmless
339
+ // handler spelling inside quoted title values and comments.
340
+ for (const el of Array.from(original.querySelectorAll('*')))
341
+ for (const attribute of Array.from(el.attributes))
342
+ if (/^on|^(srcdoc|formaction|xlink:href)$/i.test(attribute.name))
343
+ add('unsafe-html', 'Active attributes are prohibited.', `${sourcePath(el)}/@${attribute.name}`, el.localName, attribute.name);
344
+ // Diagnose tokens DOMParser discards without treating comment/attribute text
345
+ // as markup. The pinned HTML tokenizer handles ordinary and bogus comments,
346
+ // end-tag attributes and raw-text states. DOMParser and Core's sanitizer own
347
+ // all mounted markup; tokens only classify the unchanged source contract.
348
+ let sourceComment = false;
349
+ const sourceTokens = new Tokenizer({}, {
350
+ onComment: () => {
351
+ sourceComment = true;
352
+ },
353
+ onDoctype: () => add('unsupported-html', 'Document types are not represented by the editor schema.'),
354
+ onStartTag: token => {
355
+ const name = token.tagName.toLowerCase();
356
+ if (!original.getElementsByTagName(name).length) {
357
+ const active = ACTIVE_TAG_NAMES.has(name);
358
+ add(active ? 'unsafe-html' : 'unsupported-html', active ? 'The browser parser discarded an active source element.' : 'The browser parser discarded a source element.', '/', name);
359
+ }
360
+ if (name === 'script')
361
+ sourceTokens.state = TokenizerMode.SCRIPT_DATA;
362
+ else if (name === 'title' || name === 'textarea')
363
+ sourceTokens.state = TokenizerMode.RCDATA;
364
+ else if (name === 'plaintext')
365
+ sourceTokens.state = TokenizerMode.PLAINTEXT;
366
+ else if (['style', 'xmp', 'iframe', 'noembed', 'noframes', 'noscript'].includes(name))
367
+ sourceTokens.state = TokenizerMode.RAWTEXT;
368
+ },
369
+ onEndTag: token => {
370
+ if (token.attrs.length)
371
+ add('unsupported-html', 'Closing-tag attributes are not represented by the editor schema.', '/', token.tagName);
372
+ },
373
+ onEof: () => { },
374
+ onCharacter: () => { },
375
+ onNullCharacter: () => { },
376
+ onWhitespaceCharacter: () => { },
377
+ });
378
+ sourceTokens.write(source, true);
379
+ // Reuse Core's URL policy on a known allowed probe, independently of wrapper survival.
380
+ for (const el of Array.from(original.querySelectorAll('*')))
381
+ for (const name of ['href', 'cite', 'src', 'srcset']) {
382
+ const value = el.getAttribute(name);
383
+ if (value == null)
384
+ continue;
385
+ const probe = original.createElement(name === 'src' || name === 'srcset' ? 'img' : 'a');
386
+ probe.setAttribute(name, value);
387
+ const checked = new DOMParser().parseFromString(sdSanitizeEditorHtml(probe.outerHTML), 'text/html').body.firstElementChild;
388
+ if (checked?.getAttribute(name) !== value)
389
+ add('unsafe-html', 'The source URL violates the Core sanitizer URL policy.', `${sourcePath(el)}/@${name}`, el.localName, name);
390
+ }
391
+ if (sdEditorSemanticHtml(source) !== sdEditorSemanticHtml(html))
392
+ add('unsupported-html', 'The sanitizer changed source elements, attributes or text.');
393
+ if (sourceComment || original.createTreeWalker(original, NodeFilter.SHOW_COMMENT).nextNode())
394
+ add('unsupported-html', 'Comments are not represented by the editor schema.');
395
+ const inspectCss = (el, path, sanitize) => {
396
+ const css = el.getAttribute('style');
397
+ if (css != null) {
398
+ const active = /url\s*\(|expression\s*\(|var\s*\(|@|\\|[<>]/i.test(css);
399
+ if (active) {
400
+ add('unsafe-html', 'Active or escaped CSS values are prohibited.', path, el.localName, 'style');
401
+ if (sanitize)
402
+ el.removeAttribute('style');
403
+ return;
404
+ }
405
+ const declared = css
406
+ .split(';')
407
+ .filter(part => part.trim())
408
+ .map(part => part.split(':')[0].trim().toLowerCase());
409
+ for (const name of declared) {
410
+ if (!SAFE_CSS.has(name) || !el.style.getPropertyValue(name)) {
411
+ add('unsupported-html', `Unsupported CSS property or value: ${name}.`, path, el.localName, 'style');
412
+ if (sanitize)
413
+ el.style.removeProperty(name);
414
+ }
415
+ }
416
+ for (const name of Array.from(el.style)) {
417
+ const value = el.style.getPropertyValue(name);
418
+ if (/[a-z-]+\s*\(/i.test(value) && !/^(?:rgba?|hsla?)\([\d\s.,%+-]+\)$/i.test(value.trim())) {
419
+ add('unsafe-html', 'CSS functions are not supported.', path, el.localName, 'style');
420
+ if (sanitize)
421
+ el.style.removeProperty(name);
422
+ }
423
+ }
424
+ }
425
+ };
426
+ // Inspect source CSS before sanitization can discard envelope or unknown-element styles.
427
+ for (const el of Array.from(original.querySelectorAll('[style]')))
428
+ inspectCss(el, `${sourcePath(el)}/@style`, false);
429
+ for (const [index, el] of Array.from(safe.body.querySelectorAll('[style]')).entries())
430
+ inspectCss(el, `/html/body/${el.localName}[${index + 1}]/@style`, true);
431
+ html = safe.body.innerHTML;
432
+ return { html, diagnostics };
433
+ }
434
+
435
+ let nextEngineId = 0;
436
+ class SdEditorEngine {
437
+ editor;
438
+ source = '';
439
+ sourceHtml = '';
440
+ markdownSourceSnapshot;
441
+ changed = false;
442
+ requestedEditable;
443
+ composing = false;
444
+ pendingCompositionChange = false;
445
+ queuedSource;
446
+ queuedFormat;
447
+ applying = false;
448
+ destroyed = false;
449
+ sourceGeneration = 0;
450
+ warnings = [];
451
+ editorHost;
452
+ preview;
453
+ mentionKeys = [];
454
+ suggestionPopups = new Set();
455
+ mentionGeneration = 0;
456
+ popupId = `sd-editor-mention-${++nextEngineId}`;
457
+ placeholder = '';
458
+ get diagnostics() {
459
+ return this.warnings;
460
+ }
461
+ get generation() {
462
+ return this.sourceGeneration;
463
+ }
464
+ get format() {
465
+ return this.options.format ?? 'html';
466
+ }
467
+ options;
468
+ constructor(element, options = {}) {
469
+ this.options = { ...options };
470
+ this.requestedEditable = options.editable !== false;
471
+ this.editorHost = document.createElement('div');
472
+ this.preview = document.createElement('div');
473
+ this.preview.className = 'sd-editor-import-preview';
474
+ this.preview.hidden = true;
475
+ element.append(this.editorHost, this.preview);
476
+ this.editor = new Editor({
477
+ element: this.editorHost,
478
+ extensions: sdEditorExtensions(() => this.placeholder),
479
+ content: '',
480
+ editable: false,
481
+ editorProps: {
482
+ handlePaste: (_view, event) => {
483
+ if (!this.editor.isEditable)
484
+ return true;
485
+ const html = event.clipboardData?.getData('text/html');
486
+ if (!html)
487
+ return false;
488
+ const imported = this.inspectHtml(html);
489
+ if (imported.diagnostics.length) {
490
+ this.options.onDiagnostics?.(imported.diagnostics);
491
+ return true;
492
+ }
493
+ return false;
494
+ },
495
+ },
496
+ onUpdate: () => {
497
+ if (this.applying || this.destroyed || this.queuedSource !== undefined)
498
+ return;
499
+ this.changed = true;
500
+ if (this.composing)
501
+ this.pendingCompositionChange = true;
502
+ else
503
+ this.emitChange();
504
+ },
505
+ onTransaction: () => this.options.onStateChange?.(),
506
+ });
507
+ this.editor.registerPlugin(new Plugin({
508
+ key: new PluginKey('sdEditorSafeTransactions'),
509
+ filterTransaction: transaction => {
510
+ if (this.applying || !transaction.docChanged)
511
+ return true;
512
+ if (!this.editor.isEditable || this.destroyed)
513
+ return false;
514
+ const html = this.serialize(transaction.doc);
515
+ const boundary = sdEditorHtmlBoundary(html);
516
+ if (boundary.diagnostics.length) {
517
+ this.options.onDiagnostics?.(boundary.diagnostics);
518
+ return false;
519
+ }
520
+ if (this.options.format === 'markdown' && !this.markdownRoundTrip(transaction.doc).safe) {
521
+ this.options.onDiagnostics?.([
522
+ { code: 'markdown-loss', path: '/', detail: 'This edit cannot be represented losslessly in Markdown.' },
523
+ ]);
524
+ return false;
525
+ }
526
+ return true;
527
+ },
528
+ }));
529
+ this.editor.view.dom.addEventListener('focus', this.onFocus);
530
+ this.editor.view.dom.addEventListener('blur', this.onBlur);
531
+ this.editor.view.dom.addEventListener('compositionstart', this.onCompositionStart);
532
+ this.editor.view.dom.addEventListener('compositionend', this.onCompositionEnd);
533
+ this.editor.view.dom.tabIndex = 0;
534
+ this.setPlaceholder(options.placeholder);
535
+ this.setMentionFeeds(options.mentionFeeds);
536
+ this.applySource(options.content ?? '');
537
+ }
538
+ onFocus = (event) => {
539
+ this.options.onFocus?.(event);
540
+ };
541
+ onBlur = (event) => {
542
+ this.options.onBlur?.(event);
543
+ };
544
+ onCompositionStart = () => {
545
+ this.composing = true;
546
+ this.options.onCompositionStateChange?.(true);
547
+ };
548
+ onCompositionEnd = () => {
549
+ this.composing = false;
550
+ const format = this.queuedFormat;
551
+ this.queuedFormat = undefined;
552
+ try {
553
+ if (this.queuedSource !== undefined) {
554
+ const value = this.queuedSource;
555
+ this.queuedSource = undefined;
556
+ this.pendingCompositionChange = false;
557
+ if (format)
558
+ this.options.format = format;
559
+ this.applySource(value);
560
+ }
561
+ else if (format) {
562
+ this.pendingCompositionChange = false;
563
+ this.convertCurrentFormat(format);
564
+ }
565
+ else if (this.pendingCompositionChange) {
566
+ this.pendingCompositionChange = false;
567
+ if (this.editor.isEditable)
568
+ this.emitChange();
569
+ }
570
+ }
571
+ finally {
572
+ this.options.onCompositionStateChange?.(false);
573
+ }
574
+ };
575
+ serialize(doc) {
576
+ const target = document.createElement('div');
577
+ target.append(DOMSerializer.fromSchema(this.editor.schema).serializeFragment(doc.content));
578
+ return target.innerHTML;
579
+ }
580
+ parseHtml(html) {
581
+ const target = document.createElement('template');
582
+ target.innerHTML = html;
583
+ return DOMParser$1.fromSchema(this.editor.schema).parse(target.content);
584
+ }
585
+ inspectHtml(html) {
586
+ const boundary = sdEditorHtmlBoundary(html);
587
+ const doc = this.parseHtml(boundary.html);
588
+ if (boundary.html && sdEditorSemanticHtml(boundary.html) !== sdEditorSemanticHtml(this.serialize(doc)))
589
+ boundary.diagnostics.push({
590
+ code: 'unsupported-html',
591
+ path: '/',
592
+ detail: 'The schema cannot preserve all source nodes, attributes or text.',
593
+ });
594
+ return { ...boundary, doc };
595
+ }
596
+ applySource(value) {
597
+ this.source = value;
598
+ this.changed = false;
599
+ this.applying = true;
600
+ try {
601
+ const manager = this.editor.storage.markdown.manager;
602
+ const html = this.options.format === 'markdown' ? manager.instance.parse(value, { async: false }) : value;
603
+ const imported = this.inspectHtml(html);
604
+ if (this.options.format === 'markdown' && !imported.diagnostics.length) {
605
+ if (!this.preservesMarkdownSource(value, imported.doc))
606
+ imported.diagnostics.push({
607
+ code: 'markdown-loss',
608
+ path: '/',
609
+ detail: 'Markdown source cannot preserve its HTML semantics through import and export.',
610
+ });
611
+ }
612
+ this.warnings = imported.diagnostics;
613
+ const unsafe = imported.diagnostics.some(item => item.code === 'unsafe-html');
614
+ // The sanitized preview must never replace the raw safe source used by unchanged getters.
615
+ this.sourceHtml = unsafe ? imported.html : html;
616
+ this.markdownSourceSnapshot = this.options.format === 'markdown' && !unsafe ? { value, html } : undefined;
617
+ this.editor.commands.setContent(imported.doc.toJSON(), { emitUpdate: false });
618
+ // Authoritative imports establish a new document baseline. Suppressing the
619
+ // update event alone still records the import and the superseded document
620
+ // in native history. Keep the same editor and plugins, with fresh state.
621
+ const importedState = this.editor.state;
622
+ this.editor.view.updateState(EditorState.create({
623
+ schema: importedState.schema,
624
+ doc: importedState.doc,
625
+ selection: importedState.selection,
626
+ plugins: importedState.plugins,
627
+ }));
628
+ if (imported.html &&
629
+ sdEditorSemanticHtml(imported.html) !== sdEditorSemanticHtml(this.serialize(this.editor.state.doc)) &&
630
+ !imported.diagnostics.some(item => item.code === 'unsupported-html'))
631
+ imported.diagnostics.push({
632
+ code: 'unsupported-html',
633
+ path: '/',
634
+ detail: 'Editor plugins would repair or normalize the source document geometry.',
635
+ });
636
+ this.preview.innerHTML = imported.html;
637
+ this.preview.hidden = !this.warnings.length;
638
+ this.editorHost.hidden = !!this.warnings.length;
639
+ this.refreshEditable();
640
+ this.options.onDiagnostics?.(this.warnings);
641
+ }
642
+ finally {
643
+ this.applying = false;
644
+ }
645
+ }
646
+ refreshEditable() {
647
+ this.editor.setEditable(this.requestedEditable && !this.warnings.length && this.queuedSource === undefined && !this.destroyed, false);
648
+ }
649
+ setContent(value, format) {
650
+ if (this.destroyed)
651
+ return;
652
+ const formatChanged = format !== undefined && format !== (this.queuedFormat ?? this.format);
653
+ if (!formatChanged && ((!this.changed && value === this.source && this.queuedSource === undefined) || value === this.queuedSource))
654
+ return;
655
+ if (!formatChanged && !this.warnings.length && this.changed && value === this.getContent()) {
656
+ this.sourceHtml = this.getHtml();
657
+ this.source = value;
658
+ this.changed = false;
659
+ return;
660
+ }
661
+ if (formatChanged) {
662
+ if (this.composing)
663
+ this.queuedFormat = format;
664
+ else
665
+ this.options.format = format;
666
+ }
667
+ this.sourceGeneration++;
668
+ this.options.onSourceChange?.('source');
669
+ this.clearPopups();
670
+ if (this.composing) {
671
+ this.queuedSource = value;
672
+ this.pendingCompositionChange = false;
673
+ this.refreshEditable();
674
+ }
675
+ else
676
+ this.applySource(value);
677
+ }
678
+ assertSafe() {
679
+ if (this.warnings.some(item => item.code === 'unsafe-html'))
680
+ throw new SdEditorImportError(this.warnings);
681
+ }
682
+ getContent() {
683
+ this.assertSafe();
684
+ if (this.options.format === 'markdown' && this.warnings.some(item => item.code === 'markdown-loss'))
685
+ throw new SdEditorImportError(this.warnings);
686
+ if (!this.changed)
687
+ return this.source;
688
+ if (this.options.format === 'markdown') {
689
+ const result = this.markdownRoundTrip(this.editor.state.doc);
690
+ if (!result.safe)
691
+ throw new SdEditorImportError([{ code: 'markdown-loss', path: '/', detail: 'Markdown export would lose document semantics.' }]);
692
+ return result.markdown;
693
+ }
694
+ return this.getHtml();
695
+ }
696
+ getHtml() {
697
+ this.assertSafe();
698
+ if (!this.changed && this.options.format !== 'markdown')
699
+ return this.source;
700
+ if (!this.changed)
701
+ return this.sourceHtml;
702
+ const html = this.editor.getHTML();
703
+ const boundary = sdEditorHtmlBoundary(html);
704
+ if (boundary.diagnostics.length)
705
+ throw new SdEditorImportError(boundary.diagnostics);
706
+ return html;
707
+ }
708
+ markdownRoundTrip(doc) {
709
+ const manager = this.editor.storage.markdown.manager;
710
+ try {
711
+ const markdown = manager.serialize(doc.toJSON());
712
+ const restored = this.editor.schema.nodeFromJSON(manager.parse(markdown));
713
+ return { markdown, safe: sdEditorSemanticHtml(this.serialize(doc)) === sdEditorSemanticHtml(this.serialize(restored)) };
714
+ }
715
+ catch {
716
+ return { safe: false, markdown: '' };
717
+ }
718
+ }
719
+ preservesMarkdownSource(value, doc) {
720
+ try {
721
+ const parsed = this.editor.schema.nodeFromJSON(this.editor.storage.markdown.manager.parse(value));
722
+ return sdEditorSemanticHtml(this.serialize(doc)) === sdEditorSemanticHtml(this.serialize(parsed)) && this.markdownRoundTrip(doc).safe;
723
+ }
724
+ catch {
725
+ return false;
726
+ }
727
+ }
728
+ emitChange() {
729
+ try {
730
+ this.options.onChange?.(this.getContent());
731
+ }
732
+ catch (error) {
733
+ if (error instanceof SdEditorImportError)
734
+ this.options.onDiagnostics?.(error.diagnostics);
735
+ else
736
+ throw error;
737
+ }
738
+ }
739
+ setEditable(value) {
740
+ this.requestedEditable = value;
741
+ if (!value) {
742
+ this.sourceGeneration++;
743
+ this.pendingCompositionChange = false;
744
+ this.clearPopups();
745
+ this.options.onSourceChange?.('editable');
746
+ }
747
+ this.refreshEditable();
748
+ }
749
+ setPlaceholder(value) {
750
+ this.placeholder = value ?? '';
751
+ this.editor.view.dom.setAttribute('data-placeholder', value ?? '');
752
+ this.editor.view.dom.setAttribute('aria-label', value || 'Rich text editor');
753
+ this.editor.view.dispatch(this.editor.state.tr);
754
+ }
755
+ setFormat(value) {
756
+ if (this.destroyed || this.queuedFormat === value || (this.queuedFormat === undefined && (this.options.format ?? 'html') === value))
757
+ return;
758
+ this.sourceGeneration++;
759
+ this.options.onSourceChange?.('format');
760
+ this.clearPopups();
761
+ if (this.composing) {
762
+ this.queuedFormat = value;
763
+ this.pendingCompositionChange = false;
764
+ }
765
+ else
766
+ this.convertCurrentFormat(value);
767
+ }
768
+ convertCurrentFormat(value) {
769
+ if (this.warnings.some(item => item.code === 'unsafe-html')) {
770
+ this.options.format = value;
771
+ this.options.onDiagnostics?.(this.warnings);
772
+ this.options.onFormatChange?.(undefined);
773
+ return;
774
+ }
775
+ // Change representation of the current document, without replacing its selection/history.
776
+ const html = this.getHtml();
777
+ const remaining = this.warnings.filter(item => item.code !== 'markdown-loss');
778
+ this.options.format = value;
779
+ this.sourceHtml = html;
780
+ this.source = html;
781
+ this.changed = false;
782
+ if (value === 'markdown') {
783
+ const original = this.markdownSourceSnapshot;
784
+ if (original && sdEditorSemanticHtml(original.html) === sdEditorSemanticHtml(html)) {
785
+ this.source = original.value;
786
+ // Restoring source bytes must also restore the original loss decision.
787
+ // Safe unsupported snapshots remain read-only and original-preserving.
788
+ if (!remaining.length && !this.preservesMarkdownSource(original.value, this.editor.state.doc))
789
+ remaining.push({ code: 'markdown-loss', path: '/', detail: 'The restored Markdown source cannot preserve its HTML semantics.' });
790
+ }
791
+ else {
792
+ const conversion = this.markdownRoundTrip(this.editor.state.doc);
793
+ if (remaining.length || !conversion.safe)
794
+ remaining.push({
795
+ code: 'markdown-loss',
796
+ path: '/',
797
+ detail: 'The current document cannot be converted to Markdown without losing semantics.',
798
+ });
799
+ else {
800
+ this.source = conversion.markdown;
801
+ this.markdownSourceSnapshot = { value: conversion.markdown, html };
802
+ }
803
+ }
804
+ }
805
+ this.warnings = remaining;
806
+ this.preview.innerHTML = sdEditorHtmlBoundary(html).html;
807
+ this.preview.hidden = !this.warnings.length;
808
+ this.editorHost.hidden = !!this.warnings.length;
809
+ this.refreshEditable();
810
+ this.options.onDiagnostics?.(this.warnings);
811
+ this.notifyFormatChange();
812
+ }
813
+ notifyFormatChange() {
814
+ if (!this.options.onFormatChange)
815
+ return;
816
+ let value;
817
+ try {
818
+ value = this.getContent();
819
+ }
820
+ catch (error) {
821
+ if (!(error instanceof SdEditorImportError))
822
+ throw error;
823
+ }
824
+ this.options.onFormatChange(value);
825
+ }
826
+ focus() {
827
+ if (!this.destroyed && !this.editorHost.hidden) {
828
+ this.editor.commands.focus();
829
+ this.editor.view.dom.focus({ preventScroll: true });
830
+ }
831
+ }
832
+ insertMention(item) {
833
+ if (!this.editor.isEditable || !item.id)
834
+ return;
835
+ this.editor.commands.insertContent({ type: 'sdMention', attrs: { id: item.id, name: item.name, marker: item.marker ?? '@' } });
836
+ }
837
+ getMentions() {
838
+ const items = [];
839
+ this.editor.state.doc.descendants(node => {
840
+ if (node.type.name === 'sdMention')
841
+ items.push({ id: node.attrs['id'], name: node.attrs['name'], marker: node.attrs['marker'] });
842
+ });
843
+ return items;
844
+ }
845
+ insertImage(attributes) {
846
+ this.assertSafe();
847
+ if (!this.editor.isEditable)
848
+ return;
849
+ const image = document.createElement('img');
850
+ for (const [key, value] of Object.entries(attributes))
851
+ if (value != null)
852
+ image.setAttribute(key, String(value));
853
+ const checked = sdEditorHtmlBoundary(image.outerHTML);
854
+ if (checked.diagnostics.length)
855
+ throw new SdEditorImportError(checked.diagnostics);
856
+ this.editor.commands.insertContent({
857
+ type: 'image',
858
+ attrs: {
859
+ src: attributes.src,
860
+ alt: attributes.alt ?? null,
861
+ sdAttributes: Object.fromEntries(Object.entries(attributes).filter(([key, value]) => key !== 'src' && key !== 'alt' && value != null)),
862
+ },
863
+ });
864
+ }
865
+ activeImageSources() {
866
+ const result = new Set();
867
+ this.editor.state.doc.descendants(node => {
868
+ if (['image', 'inlineImage'].includes(node.type.name))
869
+ result.add(node.attrs['src']);
870
+ });
871
+ return result;
872
+ }
873
+ replaceImage(oldSrc, attributes) {
874
+ this.assertSafe();
875
+ if (!this.editor.isEditable || this.destroyed)
876
+ return false;
877
+ const probe = document.createElement('img');
878
+ for (const [key, value] of Object.entries(attributes))
879
+ if (value != null)
880
+ probe.setAttribute(key, String(value));
881
+ const checked = sdEditorHtmlBoundary(probe.outerHTML);
882
+ if (checked.diagnostics.length)
883
+ throw new SdEditorImportError(checked.diagnostics);
884
+ const transaction = this.editor.state.tr;
885
+ let replaced = false;
886
+ this.editor.state.doc.descendants((node, pos) => {
887
+ if (['image', 'inlineImage'].includes(node.type.name) && node.attrs['src'] === oldSrc) {
888
+ transaction.setNodeMarkup(pos, undefined, {
889
+ ...node.attrs,
890
+ src: attributes.src,
891
+ alt: attributes.alt ?? node.attrs['alt'],
892
+ sdAttributes: {
893
+ ...node.attrs['sdAttributes'],
894
+ ...Object.fromEntries(Object.entries(attributes).filter(([key, value]) => key !== 'src' && key !== 'alt' && value != null)),
895
+ },
896
+ });
897
+ replaced = true;
898
+ }
899
+ });
900
+ if (replaced)
901
+ this.editor.view.dispatch(transaction);
902
+ return replaced;
903
+ }
904
+ setMentionFeeds(feeds) {
905
+ this.mentionGeneration++;
906
+ for (const key of this.mentionKeys)
907
+ this.editor.unregisterPlugin(key);
908
+ this.mentionKeys = [];
909
+ this.clearPopups();
910
+ for (const [index, feed] of (feeds ?? []).entries()) {
911
+ if (!feed.marker || feed.itemRenderer) {
912
+ this.options.onDiagnostics?.([
913
+ { code: 'invalid-option', path: `/mentionFeeds/${index}`, detail: 'A marker is required; CK itemRenderer is unsupported.' },
914
+ ]);
915
+ continue;
916
+ }
917
+ const key = `sdMentionFeed${index}`;
918
+ this.mentionKeys.push(key);
919
+ let popup;
920
+ let selected = 0;
921
+ let choose;
922
+ const remove = () => {
923
+ if (popup && this.editor.view.dom.getAttribute('aria-controls') === popup.id) {
924
+ this.editor.view.dom.removeAttribute('aria-controls');
925
+ this.editor.view.dom.removeAttribute('aria-activedescendant');
926
+ }
927
+ popup?.remove();
928
+ if (popup)
929
+ this.suggestionPopups.delete(popup);
930
+ popup = undefined;
931
+ };
932
+ this.editor.registerPlugin(Suggestion({
933
+ editor: this.editor,
934
+ pluginKey: new PluginKey(key),
935
+ char: feed.marker,
936
+ allow: ({ state, range }) => this.editor.isEditable && range.to - range.from - feed.marker.length >= (feed.minimumCharacters ?? 0),
937
+ items: async ({ query }) => {
938
+ const generation = this.sourceGeneration;
939
+ const mentionGeneration = this.mentionGeneration;
940
+ let supplied;
941
+ try {
942
+ supplied = typeof feed.feed === 'function' ? await feed.feed(query) : feed.feed;
943
+ }
944
+ catch {
945
+ if (!this.destroyed && generation === this.sourceGeneration && mentionGeneration === this.mentionGeneration)
946
+ this.options.onDiagnostics?.([{ code: 'invalid-option', path: `/mentionFeeds/${index}`, detail: 'Mention feed failed.' }]);
947
+ return [];
948
+ }
949
+ if (this.destroyed || generation !== this.sourceGeneration || mentionGeneration !== this.mentionGeneration)
950
+ return [];
951
+ return supplied
952
+ .map(item => (typeof item === 'string' ? { id: item, name: item } : item))
953
+ .filter(item => item.id && (item.name ?? item.text ?? item.id).toLowerCase().includes(query.toLowerCase()))
954
+ .slice(0, feed.dropdownLimit ?? 10);
955
+ },
956
+ command: ({ editor, range, props }) => {
957
+ if (editor
958
+ .chain()
959
+ .focus()
960
+ .insertContentAt(range, [
961
+ { type: 'sdMention', attrs: { id: props.id, name: props.name ?? props.text ?? props.id, marker: feed.marker } },
962
+ { type: 'text', text: ' ' },
963
+ ])
964
+ .run())
965
+ this.options.onMentionSelect?.(props);
966
+ },
967
+ render: () => {
968
+ const render = (props) => {
969
+ remove();
970
+ if (!props.items.length)
971
+ return;
972
+ popup = document.createElement('div');
973
+ popup.id = `${this.popupId}-${key}-${this.sourceGeneration}`;
974
+ popup.setAttribute('role', 'listbox');
975
+ popup.setAttribute('aria-label', this.options.mentionLabel?.() ?? 'Mention suggestions');
976
+ popup.className = 'sd-editor-mention-list';
977
+ this.editor.view.dom.setAttribute('aria-controls', popup.id);
978
+ selected = 0;
979
+ choose = position => {
980
+ const item = props.items[position];
981
+ if (item)
982
+ props.command(item);
983
+ remove();
984
+ };
985
+ props.items.forEach((item, position) => {
986
+ const option = document.createElement('div');
987
+ option.id = `${popup.id}-option-${position}`;
988
+ option.setAttribute('role', 'option');
989
+ option.setAttribute('aria-selected', String(position === selected));
990
+ option.textContent = item.name ?? item.text ?? item.id;
991
+ option.addEventListener('pointerdown', event => {
992
+ event.preventDefault();
993
+ choose?.(position);
994
+ });
995
+ popup.append(option);
996
+ });
997
+ this.editor.view.dom.setAttribute('aria-activedescendant', `${popup.id}-option-0`);
998
+ document.body.append(popup);
999
+ this.suggestionPopups.add(popup);
1000
+ const rect = props.clientRect?.();
1001
+ if (rect) {
1002
+ const currentPopup = popup;
1003
+ const generation = this.sourceGeneration;
1004
+ void computePosition({ getBoundingClientRect: () => rect }, popup, {
1005
+ placement: 'bottom-start',
1006
+ strategy: 'fixed',
1007
+ middleware: [offset(4), flip(), shift({ padding: 12 })],
1008
+ })
1009
+ .then(({ x, y }) => {
1010
+ if (!this.destroyed && generation === this.sourceGeneration && popup === currentPopup && currentPopup.isConnected) {
1011
+ currentPopup.style.position = 'fixed';
1012
+ currentPopup.style.left = `${x}px`;
1013
+ currentPopup.style.top = `${y}px`;
1014
+ }
1015
+ })
1016
+ .catch(() => remove());
1017
+ }
1018
+ };
1019
+ return {
1020
+ onStart: render,
1021
+ onUpdate: render,
1022
+ onExit: remove,
1023
+ onKeyDown: ({ event }) => {
1024
+ if (event.key === 'Escape') {
1025
+ remove();
1026
+ return true;
1027
+ }
1028
+ if (!popup)
1029
+ return false;
1030
+ if (event.key === 'Enter') {
1031
+ choose?.(selected);
1032
+ return true;
1033
+ }
1034
+ if (['ArrowUp', 'ArrowDown'].includes(event.key)) {
1035
+ selected = (selected + (event.key === 'ArrowDown' ? 1 : -1) + popup.children.length) % popup.children.length;
1036
+ Array.from(popup.children).forEach((child, position) => child.setAttribute('aria-selected', String(position === selected)));
1037
+ this.editor.view.dom.setAttribute('aria-activedescendant', `${popup.id}-option-${selected}`);
1038
+ return true;
1039
+ }
1040
+ if (event.key === 'Tab')
1041
+ remove();
1042
+ return false;
1043
+ },
1044
+ };
1045
+ },
1046
+ }), (plugin, plugins) => [plugin, ...plugins]);
1047
+ }
1048
+ }
1049
+ clearPopups() {
1050
+ for (const popup of this.suggestionPopups)
1051
+ popup.remove();
1052
+ this.suggestionPopups.clear();
1053
+ this.editor.view.dom.removeAttribute('aria-controls');
1054
+ this.editor.view.dom.removeAttribute('aria-activedescendant');
1055
+ }
1056
+ destroy() {
1057
+ if (this.destroyed)
1058
+ return;
1059
+ this.destroyed = true;
1060
+ this.sourceGeneration++;
1061
+ this.queuedSource = undefined;
1062
+ this.queuedFormat = undefined;
1063
+ this.pendingCompositionChange = false;
1064
+ this.clearPopups();
1065
+ this.editor.view.dom.removeEventListener('focus', this.onFocus);
1066
+ this.editor.view.dom.removeEventListener('blur', this.onBlur);
1067
+ this.editor.view.dom.removeEventListener('compositionstart', this.onCompositionStart);
1068
+ this.editor.view.dom.removeEventListener('compositionend', this.onCompositionEnd);
1069
+ this.editor.destroy();
1070
+ this.editorHost.remove();
1071
+ this.preview.remove();
1072
+ }
1073
+ }
1074
+
1075
+ /** Private editor adapter: semantics and activation belong to the native Core button. */
1076
+ class SdEditorButtonDirective {
1077
+ button = inject(SdButton);
1078
+ controlId = input.required(...(ngDevMode ? [{ debugName: "controlId", alias: 'sdEditorButton' }] : [{ alias: 'sdEditorButton' }]));
1079
+ pressed = input(undefined, ...(ngDevMode ? [{ debugName: "pressed", alias: 'sdEditorPressed' }] : [{ alias: 'sdEditorPressed' }]));
1080
+ tabIndex = input(0, ...(ngDevMode ? [{ debugName: "tabIndex", alias: 'sdEditorTabIndex' }] : [{ alias: 'sdEditorTabIndex' }]));
1081
+ allowed = input(true, ...(ngDevMode ? [{ debugName: "allowed", alias: 'sdEditorAllowed' }] : [{ alias: 'sdEditorAllowed' }]));
1082
+ label = input(undefined, ...(ngDevMode ? [{ debugName: "label", alias: 'sdEditorLabel' }] : [{ alias: 'sdEditorLabel' }]));
1083
+ sdEditorActivate = output();
1084
+ sdEditorBeforeFocus = output();
1085
+ sdEditorFocused = output();
1086
+ constructor() {
1087
+ afterRenderEffect(() => {
1088
+ const native = this.button.trigger()?.nativeElement;
1089
+ if (!native)
1090
+ return;
1091
+ native.dataset['editorControl'] = this.controlId();
1092
+ native.tabIndex = this.tabIndex();
1093
+ const pressed = this.pressed();
1094
+ if (pressed === undefined)
1095
+ native.removeAttribute('aria-pressed');
1096
+ else
1097
+ native.setAttribute('aria-pressed', String(pressed));
1098
+ const label = this.label();
1099
+ if (label)
1100
+ native.setAttribute('aria-label', label);
1101
+ });
1102
+ afterRenderEffect(onCleanup => {
1103
+ const native = this.button.trigger()?.nativeElement;
1104
+ if (!native)
1105
+ return;
1106
+ const activate = (event) => {
1107
+ if (!this.button.hasActions() && this.allowed() && !this.button.disabled() && !this.button.loading())
1108
+ this.sdEditorActivate.emit(event);
1109
+ };
1110
+ const before = (event) => this.sdEditorBeforeFocus.emit(event);
1111
+ const focus = () => this.sdEditorFocused.emit();
1112
+ native.addEventListener('click', activate);
1113
+ native.addEventListener('pointerdown', before);
1114
+ native.addEventListener('focus', focus);
1115
+ onCleanup(() => {
1116
+ native.removeEventListener('click', activate);
1117
+ native.removeEventListener('pointerdown', before);
1118
+ native.removeEventListener('focus', focus);
1119
+ });
1120
+ });
1121
+ }
1122
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdEditorButtonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1123
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.25", type: SdEditorButtonDirective, isStandalone: true, selector: "sd-button[sdEditorButton]", inputs: { controlId: { classPropertyName: "controlId", publicName: "sdEditorButton", isSignal: true, isRequired: true, transformFunction: null }, pressed: { classPropertyName: "pressed", publicName: "sdEditorPressed", isSignal: true, isRequired: false, transformFunction: null }, tabIndex: { classPropertyName: "tabIndex", publicName: "sdEditorTabIndex", isSignal: true, isRequired: false, transformFunction: null }, allowed: { classPropertyName: "allowed", publicName: "sdEditorAllowed", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "sdEditorLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { sdEditorActivate: "sdEditorActivate", sdEditorBeforeFocus: "sdEditorBeforeFocus", sdEditorFocused: "sdEditorFocused" }, ngImport: i0 });
1124
+ }
1125
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdEditorButtonDirective, decorators: [{
1126
+ type: Directive,
1127
+ args: [{ selector: 'sd-button[sdEditorButton]', standalone: true }]
1128
+ }], ctorParameters: () => [], propDecorators: { controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "sdEditorButton", required: true }] }], pressed: [{ type: i0.Input, args: [{ isSignal: true, alias: "sdEditorPressed", required: false }] }], tabIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "sdEditorTabIndex", required: false }] }], allowed: [{ type: i0.Input, args: [{ isSignal: true, alias: "sdEditorAllowed", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "sdEditorLabel", required: false }] }], sdEditorActivate: [{ type: i0.Output, args: ["sdEditorActivate"] }], sdEditorBeforeFocus: [{ type: i0.Output, args: ["sdEditorBeforeFocus"] }], sdEditorFocused: [{ type: i0.Output, args: ["sdEditorFocused"] }] } });
1129
+
1130
+ class SdEditorToolbar {
1131
+ engine = input(null, ...(ngDevMode ? [{ debugName: "engine" }] : []));
1132
+ variant = input('full', ...(ngDevMode ? [{ debugName: "variant" }] : []));
1133
+ revision = input(0, ...(ngDevMode ? [{ debugName: "revision" }] : []));
1134
+ sourceVersion = input(0, ...(ngDevMode ? [{ debugName: "sourceVersion" }] : []));
1135
+ uploadEnabled = input(false, ...(ngDevMode ? [{ debugName: "uploadEnabled" }] : []));
1136
+ requestFiles = output();
1137
+ #i18n = inject(I18nService);
1138
+ #element = inject(ElementRef);
1139
+ #document = inject(DOCUMENT);
1140
+ static nextPopupId = 0;
1141
+ popupErrorId = `sd-editor-popup-error-${SdEditorToolbar.nextPopupId++}`;
1142
+ popupElement = viewChild('popup', ...(ngDevMode ? [{ debugName: "popupElement" }] : []));
1143
+ popupField = viewChild('popupField', ...(ngDevMode ? [{ debugName: "popupField" }] : []));
1144
+ focusedId = signal('bold', ...(ngDevMode ? [{ debugName: "focusedId" }] : []));
1145
+ popup = signal(null, ...(ngDevMode ? [{ debugName: "popup" }] : []));
1146
+ popupValue = signal('', ...(ngDevMode ? [{ debugName: "popupValue" }] : []));
1147
+ popupError = signal('', ...(ngDevMode ? [{ debugName: "popupError" }] : []));
1148
+ popupComposing = signal(false, ...(ngDevMode ? [{ debugName: "popupComposing" }] : []));
1149
+ marks = ['bold', 'italic', 'underline'];
1150
+ additionalMarks = ['strike', 'code', 'subscript', 'superscript'];
1151
+ icons = {
1152
+ bold: 'format_bold',
1153
+ italic: 'format_italic',
1154
+ underline: 'format_underlined',
1155
+ strike: 'strikethrough_s',
1156
+ code: 'code',
1157
+ subscript: 'subscript',
1158
+ superscript: 'superscript',
1159
+ undo: 'undo',
1160
+ redo: 'redo',
1161
+ bullet: 'format_list_bulleted',
1162
+ ordered: 'format_list_numbered',
1163
+ left: 'format_align_left',
1164
+ center: 'format_align_center',
1165
+ right: 'format_align_right',
1166
+ justify: 'format_align_justify',
1167
+ };
1168
+ levels = [1, 2, 3, 4, 5, 6];
1169
+ sizes = ['10', '11', '12', '14', '16', '18', '20'];
1170
+ alignments = ['left', 'center', 'right', 'justify'];
1171
+ tableActions = [
1172
+ 'insert-table',
1173
+ 'row-before',
1174
+ 'row-after',
1175
+ 'delete-row',
1176
+ 'column-before',
1177
+ 'column-after',
1178
+ 'delete-column',
1179
+ 'merge-cells',
1180
+ 'split-cell',
1181
+ 'delete-table',
1182
+ ];
1183
+ imageWidths = ['25%', '50%', '75%', '100%'];
1184
+ #bookmark = null;
1185
+ #storedMarks = null;
1186
+ #range = null;
1187
+ #trigger = null;
1188
+ #bookmarkGeneration = null;
1189
+ constructor() {
1190
+ effect(onCleanup => {
1191
+ const engine = this.engine();
1192
+ if (!engine)
1193
+ return;
1194
+ const transaction = ({ transaction: tr }) => {
1195
+ if (!this.#bookmark || !this.#range || !tr.docChanged)
1196
+ return;
1197
+ const from = tr.mapping.mapResult(this.#range.from, 1);
1198
+ const to = tr.mapping.mapResult(this.#range.to, -1);
1199
+ if (from.deletedAcross || to.deletedAcross) {
1200
+ this.close(false);
1201
+ return;
1202
+ }
1203
+ this.#range = { from: from.pos, to: to.pos };
1204
+ this.#bookmark = this.#bookmark.map(tr.mapping);
1205
+ };
1206
+ engine.editor.on('transaction', transaction);
1207
+ onCleanup(() => engine.editor.off('transaction', transaction));
1208
+ });
1209
+ effect(() => {
1210
+ this.sourceVersion();
1211
+ untracked(() => this.close(false));
1212
+ });
1213
+ effect(() => {
1214
+ this.revision();
1215
+ const editable = this.engine()?.editor.isEditable;
1216
+ if (!editable)
1217
+ untracked(() => this.close(false));
1218
+ });
1219
+ afterRenderEffect(() => {
1220
+ if (this.popup())
1221
+ this.popupField()?.nativeElement.focus();
1222
+ });
1223
+ afterRenderEffect(() => {
1224
+ this.revision();
1225
+ this.variant();
1226
+ this.reconcileNavigation();
1227
+ });
1228
+ afterRenderEffect(onCleanup => {
1229
+ const win = this.#document.defaultView;
1230
+ if (!win || typeof ResizeObserver === 'undefined')
1231
+ return;
1232
+ const observer = new ResizeObserver(() => this.reconcileNavigation());
1233
+ observer.observe(this.#element.nativeElement);
1234
+ onCleanup(() => observer.disconnect());
1235
+ });
1236
+ const outside = (event) => {
1237
+ if (!this.popup())
1238
+ return;
1239
+ const target = event.target;
1240
+ if (target && !this.popupElement()?.nativeElement.contains(target) && !this.#trigger?.contains(target))
1241
+ this.close(false);
1242
+ };
1243
+ this.#document.addEventListener?.('pointerdown', outside);
1244
+ inject(DestroyRef).onDestroy(() => {
1245
+ this.#document.removeEventListener?.('pointerdown', outside);
1246
+ this.close(false);
1247
+ });
1248
+ }
1249
+ t(key, params) {
1250
+ return this.#i18n.t(`core.component.editor.toolbar.${key}`, params);
1251
+ }
1252
+ cancelLabel() {
1253
+ return this.#i18n.t('core.common.cancel');
1254
+ }
1255
+ alignmentIcon() {
1256
+ this.revision();
1257
+ const editor = this.engine()?.editor;
1258
+ return this.icons[this.alignments.find(alignment => editor?.isActive({ textAlign: alignment })) ?? 'left'];
1259
+ }
1260
+ choiceTooltip(key, attribute) {
1261
+ const value = this.choiceValue(attribute);
1262
+ return value ? `${this.t(key)}: ${value}` : this.t(key);
1263
+ }
1264
+ available() {
1265
+ this.revision();
1266
+ return !!this.engine()?.editor.isEditable && !this.engine()?.editor.view.composing;
1267
+ }
1268
+ active(action) {
1269
+ this.revision();
1270
+ const editor = this.engine()?.editor;
1271
+ if (!editor || !['bold', 'italic', 'underline', 'strike', 'code', 'subscript', 'superscript', 'bullet', 'ordered'].includes(action))
1272
+ return undefined;
1273
+ const name = action === 'bullet' ? 'bulletList' : action === 'ordered' ? 'orderedList' : action;
1274
+ if (editor.isActive(name))
1275
+ return true;
1276
+ if (editor.state.selection.empty || action === 'bullet' || action === 'ordered')
1277
+ return false;
1278
+ let has = false;
1279
+ let lacks = false;
1280
+ editor.state.doc.nodesBetween(editor.state.selection.from, editor.state.selection.to, node => {
1281
+ if (node.isText) {
1282
+ if (node.marks.some(mark => mark.type.name === name))
1283
+ has = true;
1284
+ else
1285
+ lacks = true;
1286
+ }
1287
+ });
1288
+ return has && lacks ? 'mixed' : false;
1289
+ }
1290
+ can(action, value) {
1291
+ if (!this.available())
1292
+ return false;
1293
+ try {
1294
+ return this.command(this.engine().editor.can().chain(), action, value).run();
1295
+ }
1296
+ catch {
1297
+ return false;
1298
+ }
1299
+ }
1300
+ canStyle(kind) {
1301
+ if (!this.available())
1302
+ return false;
1303
+ const chain = this.engine().editor.can().chain();
1304
+ if (kind === 'link')
1305
+ return chain.setLink({ href: 'https://example.invalid' }).run();
1306
+ if (kind === 'font')
1307
+ return chain.setFontFamily('serif').run();
1308
+ return chain.setColor('black').run();
1309
+ }
1310
+ canSize(size) {
1311
+ return this.available() && this.engine().editor.can().setFontSize(`${size}px`);
1312
+ }
1313
+ execute(action, value) {
1314
+ if (!this.can(action, value))
1315
+ return;
1316
+ if (!this.restore())
1317
+ return;
1318
+ this.command(this.engine().editor.chain().focus(), action, value).run();
1319
+ this.#bookmark = null;
1320
+ }
1321
+ command(chain, action, value) {
1322
+ switch (action) {
1323
+ case 'bold':
1324
+ return chain.toggleBold();
1325
+ case 'italic':
1326
+ return chain.toggleItalic();
1327
+ case 'underline':
1328
+ return chain.toggleUnderline();
1329
+ case 'strike':
1330
+ return chain.toggleStrike();
1331
+ case 'code':
1332
+ return chain.toggleCode();
1333
+ case 'subscript':
1334
+ return chain.toggleSubscript();
1335
+ case 'superscript':
1336
+ return chain.toggleSuperscript();
1337
+ case 'undo':
1338
+ return chain.undo();
1339
+ case 'redo':
1340
+ return chain.redo();
1341
+ case 'paragraph':
1342
+ return chain.setParagraph();
1343
+ case 'heading':
1344
+ return chain.toggleHeading({ level: value });
1345
+ case 'bullet':
1346
+ return chain.toggleBulletList();
1347
+ case 'ordered':
1348
+ return chain.toggleOrderedList();
1349
+ case 'left':
1350
+ case 'center':
1351
+ case 'right':
1352
+ case 'justify':
1353
+ return chain.setTextAlign(action);
1354
+ case 'insert-table':
1355
+ return chain.insertTable({ rows: 3, cols: 3, withHeaderRow: true });
1356
+ case 'row-before':
1357
+ return chain.addRowBefore();
1358
+ case 'row-after':
1359
+ return chain.addRowAfter();
1360
+ case 'delete-row':
1361
+ return chain.deleteRow();
1362
+ case 'column-before':
1363
+ return chain.addColumnBefore();
1364
+ case 'column-after':
1365
+ return chain.addColumnAfter();
1366
+ case 'delete-column':
1367
+ return chain.deleteColumn();
1368
+ case 'merge-cells':
1369
+ return chain.mergeCells();
1370
+ case 'split-cell':
1371
+ return chain.splitCell();
1372
+ case 'delete-table':
1373
+ return chain.deleteTable();
1374
+ }
1375
+ }
1376
+ capture() {
1377
+ const editor = this.engine()?.editor;
1378
+ if (!editor || !editor.isEditable || this.popup())
1379
+ return;
1380
+ this.#bookmark = editor.state.selection.getBookmark();
1381
+ this.#bookmarkGeneration = this.engine().generation;
1382
+ this.#storedMarks = editor.state.storedMarks;
1383
+ this.#range = { from: editor.state.selection.from, to: editor.state.selection.to };
1384
+ }
1385
+ restore() {
1386
+ const editor = this.engine()?.editor;
1387
+ if (!editor?.isEditable || editor.view.composing)
1388
+ return false;
1389
+ if (this.#bookmark && this.#bookmarkGeneration !== this.engine().generation) {
1390
+ this.close(false);
1391
+ return false;
1392
+ }
1393
+ if (this.#bookmark) {
1394
+ try {
1395
+ editor.view.dispatch(editor.state.tr.setSelection(this.#bookmark.resolve(editor.state.doc)).setStoredMarks(this.#storedMarks));
1396
+ }
1397
+ catch {
1398
+ this.close(false);
1399
+ return false;
1400
+ }
1401
+ }
1402
+ return true;
1403
+ }
1404
+ rememberFocus(id) {
1405
+ this.focusedId.set(id);
1406
+ if (!this.popup())
1407
+ this.capture();
1408
+ }
1409
+ reconcileNavigation() {
1410
+ const controls = Array.from(this.#element.nativeElement.querySelectorAll('button[data-editor-control]:not(:disabled)')).filter(button => button.getClientRects().length > 0);
1411
+ const current = controls.find(button => button.dataset['editorControl'] === this.focusedId());
1412
+ if (!current && controls[0])
1413
+ this.focusedId.set(controls[0].dataset['editorControl']);
1414
+ }
1415
+ navigate(event) {
1416
+ if (event.defaultPrevented || event.isComposing || this.popupElement()?.nativeElement.contains(event.target))
1417
+ return;
1418
+ if (!['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key))
1419
+ return;
1420
+ const controls = Array.from(this.#element.nativeElement.querySelectorAll('button[data-editor-control]:not(:disabled)')).filter(button => button.getClientRects().length > 0);
1421
+ const current = controls.indexOf(event.target);
1422
+ if (current < 0 || !controls.length)
1423
+ return;
1424
+ const index = event.key === 'Home'
1425
+ ? 0
1426
+ : event.key === 'End'
1427
+ ? controls.length - 1
1428
+ : (current + (event.key === 'ArrowRight' ? 1 : -1) + controls.length) % controls.length;
1429
+ event.preventDefault();
1430
+ controls[index].focus();
1431
+ }
1432
+ choiceValue(attribute) {
1433
+ this.revision();
1434
+ const editor = this.engine()?.editor;
1435
+ if (!editor)
1436
+ return '';
1437
+ if (!editor.state.selection.empty) {
1438
+ const values = new Set();
1439
+ editor.state.doc.nodesBetween(editor.state.selection.from, editor.state.selection.to, node => {
1440
+ if (node.isText)
1441
+ values.add(String(node.marks.find(mark => mark.type.name === 'textStyle')?.attrs[attribute] ?? ''));
1442
+ });
1443
+ if (values.size > 1)
1444
+ return this.t('mixed');
1445
+ }
1446
+ return String(editor.getAttributes('textStyle')[attribute] ?? '');
1447
+ }
1448
+ setSize(size) {
1449
+ if (!this.canSize(size) || !this.restore())
1450
+ return;
1451
+ this.engine().editor.chain().focus().setFontSize(`${size}px`).run();
1452
+ this.#bookmark = null;
1453
+ }
1454
+ open(kind, triggerId) {
1455
+ if (!this.canStyle(kind))
1456
+ return;
1457
+ if (!this.#bookmark)
1458
+ this.capture();
1459
+ this.#trigger = this.#element.nativeElement.querySelector(`button[data-editor-control="${triggerId}"]`);
1460
+ const editor = this.engine().editor;
1461
+ const value = kind === 'link' ? editor.getAttributes('link')['href'] : editor.getAttributes('textStyle')[kind === 'font' ? 'fontFamily' : 'color'];
1462
+ this.popupValue.set(String(value ?? ''));
1463
+ this.popupError.set('');
1464
+ this.popupComposing.set(false);
1465
+ this.popup.set(kind);
1466
+ }
1467
+ apply(event) {
1468
+ event?.preventDefault();
1469
+ const kind = this.popup();
1470
+ if (!kind || !this.available() || this.popupComposing())
1471
+ return;
1472
+ let value = this.popupValue().trim();
1473
+ if (kind === 'link' && value) {
1474
+ if (!/^[a-z][a-z\d+.-]*:/i.test(value))
1475
+ value = `https://${value}`;
1476
+ try {
1477
+ if (!['https:', 'http:', 'mailto:', 'tel:'].includes(new URL(value).protocol))
1478
+ throw new Error();
1479
+ }
1480
+ catch {
1481
+ this.popupError.set(this.t('invalid-link'));
1482
+ return;
1483
+ }
1484
+ }
1485
+ if (kind === 'font' && value && !/^[\p{L}\p{N}\s,'".-]+$/u.test(value)) {
1486
+ this.popupError.set(this.t('invalid-style'));
1487
+ return;
1488
+ }
1489
+ if (kind === 'color' &&
1490
+ value &&
1491
+ (typeof CSS === 'undefined' || !CSS.supports('color', value) || /[();@\\]|url|var\s*\(/i.test(value))) {
1492
+ // rgb() is legitimate CSS, but custom color entry deliberately accepts plain named/hex values only.
1493
+ this.popupError.set(this.t('invalid-style'));
1494
+ return;
1495
+ }
1496
+ if (!this.restore())
1497
+ return;
1498
+ const chain = this.engine().editor.chain().focus();
1499
+ if (kind === 'link') {
1500
+ if (this.engine().editor.isActive('link'))
1501
+ chain.extendMarkRange('link');
1502
+ if (value)
1503
+ chain.setLink({ href: value, target: '_blank', rel: 'noopener noreferrer' });
1504
+ else
1505
+ chain.unsetLink();
1506
+ }
1507
+ if (kind === 'font') {
1508
+ if (value)
1509
+ chain.setFontFamily(value);
1510
+ else
1511
+ chain.unsetFontFamily();
1512
+ }
1513
+ if (kind === 'color') {
1514
+ if (value)
1515
+ chain.setColor(value);
1516
+ else
1517
+ chain.unsetColor();
1518
+ }
1519
+ chain.run();
1520
+ this.close(false);
1521
+ }
1522
+ close(restoreFocus) {
1523
+ const trigger = this.#trigger;
1524
+ this.popup.set(null);
1525
+ this.popupComposing.set(false);
1526
+ this.popupError.set('');
1527
+ this.#bookmark = null;
1528
+ this.#storedMarks = null;
1529
+ this.#range = null;
1530
+ this.#trigger = null;
1531
+ this.#bookmarkGeneration = null;
1532
+ if (restoreFocus && this.engine()?.editor.isEditable) {
1533
+ const destination = trigger?.isConnected && !trigger.disabled && trigger.getClientRects().length
1534
+ ? trigger
1535
+ : this.#element.nativeElement.querySelector('button[data-editor-control="more"]:not(:disabled)');
1536
+ destination?.focus();
1537
+ }
1538
+ }
1539
+ popupKeydown(event) {
1540
+ if (event.isComposing || this.popupComposing())
1541
+ return;
1542
+ if (event.key === 'Escape') {
1543
+ event.preventDefault();
1544
+ event.stopPropagation();
1545
+ this.close(true);
1546
+ }
1547
+ }
1548
+ chooseFiles() {
1549
+ if (this.available() && this.uploadEnabled() && this.restore()) {
1550
+ this.requestFiles.emit();
1551
+ this.#bookmark = null;
1552
+ }
1553
+ }
1554
+ selectedImage() {
1555
+ this.revision();
1556
+ const selection = this.engine()?.editor.state.selection;
1557
+ return selection instanceof NodeSelection && ['image', 'inlineImage'].includes(selection.node.type.name);
1558
+ }
1559
+ resizeImage(width) {
1560
+ if (width !== null && !this.imageWidths.includes(width))
1561
+ return false;
1562
+ return this.imageGeometry((image, imageAttributes, figure) => {
1563
+ if (width === null) {
1564
+ // Explicit user reset to intrinsic dimensions, rather than a cached prior resize.
1565
+ image.removeProperty('width');
1566
+ image.removeProperty('height');
1567
+ delete imageAttributes['width'];
1568
+ delete imageAttributes['height'];
1569
+ if (figure) {
1570
+ figure.width = 'fit-content';
1571
+ figure.maxWidth = '100%';
1572
+ }
1573
+ }
1574
+ else {
1575
+ image.width = figure ? '100%' : width;
1576
+ image.height = 'auto';
1577
+ if (figure) {
1578
+ figure.width = width;
1579
+ figure.maxWidth = '100%';
1580
+ }
1581
+ }
1582
+ }, width === null);
1583
+ }
1584
+ alignImage(alignment) {
1585
+ if (!['left', 'center', 'right'].includes(alignment))
1586
+ return false;
1587
+ return this.imageGeometry((image, _attributes, figure) => {
1588
+ const style = figure ?? image;
1589
+ style.display = 'block';
1590
+ style.cssFloat = 'none';
1591
+ style.marginLeft = alignment === 'left' ? '0' : 'auto';
1592
+ style.marginRight = alignment === 'right' ? '0' : 'auto';
1593
+ });
1594
+ }
1595
+ imageGeometry(change, resetDimensions = false) {
1596
+ if (!this.available() || !this.restore())
1597
+ return false;
1598
+ const editor = this.engine().editor;
1599
+ const selection = editor.state.selection;
1600
+ if (!(selection instanceof NodeSelection) || !['image', 'inlineImage'].includes(selection.node.type.name))
1601
+ return false;
1602
+ let figure = null;
1603
+ const parent = selection.$from.parent;
1604
+ if (parent.type.name === 'figure') {
1605
+ let images = 0;
1606
+ let otherContent = false;
1607
+ parent.forEach(node => {
1608
+ if (node.type.name === 'image')
1609
+ images++;
1610
+ else if (node.type.name !== 'figcaption')
1611
+ otherContent = true;
1612
+ });
1613
+ if (images === 1 && !otherContent)
1614
+ figure = { node: parent, position: selection.$from.before(selection.$from.depth) };
1615
+ }
1616
+ const imageAttributes = { ...selection.node.attrs['sdAttributes'] };
1617
+ const imageStyle = this.#document.createElement('span').style;
1618
+ imageStyle.cssText = imageAttributes['style'] ?? '';
1619
+ const figureAttributes = figure ? { ...figure.node.attrs['sdAttributes'] } : null;
1620
+ const figureStyle = figure ? this.#document.createElement('span').style : null;
1621
+ if (figureStyle)
1622
+ figureStyle.cssText = figureAttributes['style'] ?? '';
1623
+ change(imageStyle, imageAttributes, figureStyle);
1624
+ if (imageStyle.cssText)
1625
+ imageAttributes['style'] = imageStyle.cssText;
1626
+ else
1627
+ delete imageAttributes['style'];
1628
+ const nodeAttributes = { ...selection.node.attrs, sdAttributes: imageAttributes };
1629
+ if (resetDimensions) {
1630
+ // The installed image schema may declare native dimensions as well as preserved HTML attrs.
1631
+ for (const key of ['width', 'height'])
1632
+ if (Object.prototype.hasOwnProperty.call(nodeAttributes, key))
1633
+ nodeAttributes[key] = null;
1634
+ }
1635
+ const transaction = editor.state.tr.setNodeMarkup(selection.from, undefined, nodeAttributes);
1636
+ if (figure && figureStyle && figureAttributes) {
1637
+ if (figureStyle.cssText)
1638
+ figureAttributes['style'] = figureStyle.cssText;
1639
+ else
1640
+ delete figureAttributes['style'];
1641
+ transaction.setNodeMarkup(figure.position, undefined, { ...figure.node.attrs, sdAttributes: figureAttributes });
1642
+ }
1643
+ transaction.setSelection(NodeSelection.create(transaction.doc, selection.from));
1644
+ const expected = transaction.doc;
1645
+ editor.view.dispatch(transaction);
1646
+ const applied = editor.state.doc.eq(expected);
1647
+ this.#bookmark = null;
1648
+ if (applied)
1649
+ this.engine().focus();
1650
+ return applied;
1651
+ }
1652
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdEditorToolbar, deps: [], target: i0.ɵɵFactoryTarget.Component });
1653
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: SdEditorToolbar, isStandalone: true, selector: "sd-editor-toolbar", inputs: { engine: { classPropertyName: "engine", publicName: "engine", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, revision: { classPropertyName: "revision", publicName: "revision", isSignal: true, isRequired: false, transformFunction: null }, sourceVersion: { classPropertyName: "sourceVersion", publicName: "sourceVersion", isSignal: true, isRequired: false, transformFunction: null }, uploadEnabled: { classPropertyName: "uploadEnabled", publicName: "uploadEnabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { requestFiles: "requestFiles" }, viewQueries: [{ propertyName: "popupElement", first: true, predicate: ["popup"], descendants: true, isSignal: true }, { propertyName: "popupField", first: true, predicate: ["popupField"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"sd-editor-toolbar\" role=\"toolbar\" tabindex=\"-1\" [attr.aria-label]=\"t('tools')\" (keydown)=\"navigate($event)\">\n <div class=\"sd-editor-toolbar-group\">\n @for (mark of marks; track mark) {\n <sd-button\n [sdEditorButton]=\"mark\"\n [prefixIcon]=\"icons[mark]\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n [tooltip]=\"t(mark)\"\n [sdEditorLabel]=\"t(mark)\"\n type=\"text\"\n color=\"secondary\"\n [class.sd-editor-active]=\"active(mark) === true\"\n [class.sd-editor-mixed]=\"active(mark) === 'mixed'\"\n [sdEditorPressed]=\"active(mark)\"\n [sdEditorTabIndex]=\"focusedId() === mark ? 0 : -1\"\n [disabled]=\"!can(mark)\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus(mark)\"\n (sdEditorActivate)=\"execute(mark)\" />\n }\n </div>\n @if (variant() === 'full') {\n <div class=\"sd-editor-toolbar-group sd-editor-secondary\">\n <sd-button\n sdEditorButton=\"heading\"\n [title]=\"t('heading')\"\n [tooltip]=\"t('heading')\"\n [sdEditorLabel]=\"t('heading')\"\n type=\"text\"\n [disabled]=\"!available()\"\n [sdEditorTabIndex]=\"focusedId() === 'heading' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('heading')\">\n <sd-button-item [disabled]=\"!can('paragraph')\" (click)=\"execute('paragraph')\">{{ t('paragraph') }}</sd-button-item>\n @for (level of levels; track level) {\n <sd-button-item [disabled]=\"!can('heading', level)\" (click)=\"execute('heading', level)\">{{\n t('heading-level', { level })\n }}</sd-button-item>\n }\n </sd-button>\n <sd-button\n sdEditorButton=\"font\"\n [title]=\"t('font')\"\n [tooltip]=\"choiceTooltip('font', 'fontFamily')\"\n [sdEditorLabel]=\"t('font')\"\n type=\"text\"\n [disabled]=\"!canStyle('font')\"\n [sdEditorTabIndex]=\"focusedId() === 'font' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('font')\"\n (sdEditorActivate)=\"open('font', 'font')\" />\n <sd-button\n sdEditorButton=\"size\"\n [title]=\"choiceValue('fontSize') || t('size')\"\n [sdEditorLabel]=\"t('size')\"\n [tooltip]=\"choiceTooltip('size', 'fontSize')\"\n type=\"text\"\n [disabled]=\"!canSize('14')\"\n [sdEditorTabIndex]=\"focusedId() === 'size' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('size')\">\n @for (size of sizes; track size) {\n <sd-button-item [disabled]=\"!canSize(size)\" (click)=\"setSize(size)\">{{ size }}px</sd-button-item>\n }\n </sd-button>\n <sd-button\n sdEditorButton=\"color\"\n prefixIcon=\"format_color_text\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"choiceTooltip('color', 'color')\"\n [sdEditorLabel]=\"t('color')\"\n type=\"text\"\n [disabled]=\"!canStyle('color')\"\n [sdEditorTabIndex]=\"focusedId() === 'color' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('color')\"\n (sdEditorActivate)=\"open('color', 'color')\" />\n <sd-button\n sdEditorButton=\"alignment\"\n class=\"sd-editor-icon-menu\"\n [prefixIcon]=\"alignmentIcon()\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('alignment')\"\n [sdEditorLabel]=\"t('alignment')\"\n type=\"text\"\n [disabled]=\"!available()\"\n [sdEditorTabIndex]=\"focusedId() === 'alignment' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('alignment')\">\n @for (alignment of alignments; track alignment) {\n <sd-button-item\n [prefixIcon]=\"icons[alignment]\"\n fontSet=\"material-icons-outlined\"\n [disabled]=\"!can(alignment)\"\n (click)=\"execute(alignment)\"\n >{{ t(alignment) }}</sd-button-item\n >\n }\n </sd-button>\n </div>\n }\n <div class=\"sd-editor-toolbar-group sd-editor-secondary\">\n <sd-button\n sdEditorButton=\"bullet\"\n [prefixIcon]=\"icons.bullet\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('bullet')\"\n [sdEditorLabel]=\"t('bullet')\"\n type=\"text\"\n [disabled]=\"!can('bullet')\"\n [sdEditorPressed]=\"active('bullet')\"\n [sdEditorTabIndex]=\"focusedId() === 'bullet' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('bullet')\"\n (sdEditorActivate)=\"execute('bullet')\" />\n <sd-button\n sdEditorButton=\"ordered\"\n [prefixIcon]=\"icons.ordered\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('ordered')\"\n [sdEditorLabel]=\"t('ordered')\"\n type=\"text\"\n [disabled]=\"!can('ordered')\"\n [sdEditorPressed]=\"active('ordered')\"\n [sdEditorTabIndex]=\"focusedId() === 'ordered' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('ordered')\"\n (sdEditorActivate)=\"execute('ordered')\" />\n </div>\n <sd-button\n sdEditorButton=\"link\"\n prefixIcon=\"link\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('link')\"\n [sdEditorLabel]=\"t('link')\"\n type=\"text\"\n [disabled]=\"!canStyle('link')\"\n [sdEditorTabIndex]=\"focusedId() === 'link' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('link')\"\n (sdEditorActivate)=\"open('link', 'link')\" />\n @if (variant() === 'full') {\n <sd-button\n sdEditorButton=\"table\"\n class=\"sd-editor-secondary sd-editor-icon-menu\"\n prefixIcon=\"table_chart\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('table')\"\n [sdEditorLabel]=\"t('table')\"\n type=\"text\"\n [disabled]=\"!available()\"\n [sdEditorTabIndex]=\"focusedId() === 'table' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('table')\">\n @for (action of tableActions; track action) {\n <sd-button-item [disabled]=\"!can(action)\" (click)=\"execute(action)\">{{ t(action) }}</sd-button-item>\n }\n </sd-button>\n @if (uploadEnabled()) {\n <sd-button\n sdEditorButton=\"image\"\n class=\"sd-editor-secondary\"\n prefixIcon=\"image\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('image')\"\n [sdEditorLabel]=\"t('image')\"\n type=\"text\"\n [disabled]=\"!available()\"\n [sdEditorTabIndex]=\"focusedId() === 'image' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('image')\"\n (sdEditorActivate)=\"chooseFiles()\" />\n }\n }\n <sd-button\n sdEditorButton=\"more\"\n class=\"sd-editor-icon-menu\"\n prefixIcon=\"more_horiz\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('more')\"\n [sdEditorLabel]=\"t('more')\"\n type=\"text\"\n [disabled]=\"!available()\"\n [sdEditorTabIndex]=\"focusedId() === 'more' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('more')\">\n <sd-button-item [prefixIcon]=\"icons.undo\" fontSet=\"material-icons-outlined\" [disabled]=\"!can('undo')\" (click)=\"execute('undo')\">{{\n t('undo')\n }}</sd-button-item>\n <sd-button-item [prefixIcon]=\"icons.redo\" fontSet=\"material-icons-outlined\" [disabled]=\"!can('redo')\" (click)=\"execute('redo')\">{{\n t('redo')\n }}</sd-button-item>\n <sd-button-item-divider />\n @for (mark of additionalMarks; track mark) {\n <sd-button-item [prefixIcon]=\"icons[mark]\" fontSet=\"material-icons-outlined\" [disabled]=\"!can(mark)\" (click)=\"execute(mark)\">{{\n t(mark)\n }}</sd-button-item>\n }\n <sd-button-item-divider />\n <sd-button-item [prefixIcon]=\"icons.bullet\" fontSet=\"material-icons-outlined\" [disabled]=\"!can('bullet')\" (click)=\"execute('bullet')\">{{\n t('bullet')\n }}</sd-button-item>\n <sd-button-item\n [prefixIcon]=\"icons.ordered\"\n fontSet=\"material-icons-outlined\"\n [disabled]=\"!can('ordered')\"\n (click)=\"execute('ordered')\"\n >{{ t('ordered') }}</sd-button-item\n >\n <sd-button-item [disabled]=\"!can('paragraph')\" (click)=\"execute('paragraph')\">{{ t('paragraph') }}</sd-button-item>\n @for (level of levels; track level) {\n <sd-button-item [disabled]=\"!can('heading', level)\" (click)=\"execute('heading', level)\">{{\n t('heading-level', { level })\n }}</sd-button-item>\n }\n <sd-button-item-divider />\n <sd-button-item [disabled]=\"!canStyle('color')\" (click)=\"open('color', 'more')\">{{ t('color') }}</sd-button-item>\n <sd-button-item [disabled]=\"!canStyle('font')\" (click)=\"open('font', 'more')\">{{ t('font') }}</sd-button-item>\n @for (size of sizes; track size) {\n <sd-button-item [disabled]=\"!canSize(size)\" (click)=\"setSize(size)\">{{ t('size') }} {{ size }}px</sd-button-item>\n }\n @for (alignment of alignments; track alignment) {\n <sd-button-item\n [prefixIcon]=\"icons[alignment]\"\n fontSet=\"material-icons-outlined\"\n [disabled]=\"!can(alignment)\"\n (click)=\"execute(alignment)\"\n >{{ t(alignment) }}</sd-button-item\n >\n }\n <sd-button-item-divider />\n @for (action of tableActions; track action) {\n <sd-button-item [disabled]=\"!can(action)\" (click)=\"execute(action)\">{{ t(action) }}</sd-button-item>\n }\n @if (selectedImage()) {\n <sd-button-item-divider [title]=\"t('image-size')\" />\n @for (width of imageWidths; track width) {\n <sd-button-item (click)=\"resizeImage(width)\">{{ width }}</sd-button-item>\n }\n <sd-button-item (click)=\"resizeImage(null)\">{{ t('image-original') }}</sd-button-item>\n <sd-button-item (click)=\"alignImage('left')\">{{ t('image-left') }}</sd-button-item>\n <sd-button-item (click)=\"alignImage('center')\">{{ t('image-center') }}</sd-button-item>\n <sd-button-item (click)=\"alignImage('right')\">{{ t('image-right') }}</sd-button-item>\n }\n @if (uploadEnabled()) {\n <sd-button-item prefixIcon=\"image\" fontSet=\"material-icons-outlined\" (click)=\"chooseFiles()\">{{ t('image') }}</sd-button-item>\n }\n </sd-button>\n</div>\n\n@if (popup(); as kind) {\n <form\n #popup\n class=\"sd-editor-popup\"\n role=\"dialog\"\n novalidate\n [attr.aria-label]=\"t(kind)\"\n (submit)=\"apply($event)\"\n (keydown)=\"popupKeydown($event)\">\n <label>\n <span>{{ t(kind === 'link' ? 'link-address' : kind) }}</span>\n <input\n #popupField\n [type]=\"kind === 'link' ? 'url' : 'text'\"\n [value]=\"popupValue()\"\n [attr.aria-invalid]=\"!!popupError()\"\n [attr.aria-describedby]=\"popupError() ? popupErrorId : null\"\n (input)=\"popupValue.set($any($event.target).value); popupError.set('')\"\n (compositionstart)=\"popupComposing.set(true)\"\n (compositionend)=\"popupComposing.set(false)\" />\n </label>\n @if (popupError()) {\n <p class=\"sd-editor-popup-error\" [id]=\"popupErrorId\" role=\"status\">{{ popupError() }}</p>\n }\n <div class=\"sd-editor-popup-actions\">\n <sd-button [title]=\"cancelLabel()\" type=\"text\" (click)=\"close(true)\" />\n <sd-button [title]=\"t('apply')\" type=\"fill\" color=\"primary\" htmlType=\"submit\" [disabled]=\"!available() || popupComposing()\" />\n </div>\n </form>\n}\n", styles: [":host{display:block;position:relative}.sd-editor-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:var(--sd-space-2, 2px);padding:var(--sd-space-4, 4px);background:var(--sd-surface);border-bottom:1px solid var(--sd-border)}.sd-editor-toolbar-group{display:flex;align-items:center;gap:var(--sd-space-2, 2px)}.sd-editor-toolbar-group+.sd-editor-toolbar-group{border-inline-start:1px solid var(--sd-border);padding-inline-start:var(--sd-space-4, 4px)}:host ::ng-deep .sd-editor-toolbar .sd-editor-icon-menu button.c-button.c-square{width:48px!important}:host ::ng-deep .sd-editor-toolbar button.c-button[aria-pressed=true]:not(:disabled),:host ::ng-deep .sd-editor-active button.c-button:not(:disabled){background:var(--sd-primary-light)!important;color:var(--sd-primary)!important;box-shadow:inset 0 -2px var(--sd-primary)}:host ::ng-deep .sd-editor-mixed button.c-button:not(:disabled){border-bottom:2px dashed var(--sd-primary)}.sd-editor-popup{position:absolute;inset-inline-end:0;top:100%;z-index:var(--sd-z-popover, 40);box-sizing:border-box;width:min(360px,100%);max-width:calc(100vw - 24px);padding:var(--sd-space-12, 12px);background:var(--sd-surface);color:var(--sd-text);border:1px solid var(--sd-border-strong);border-radius:var(--sd-radius-4, 4px);box-shadow:var(--sd-shadow-sm)}.sd-editor-popup label{display:flex;flex-direction:column;gap:var(--sd-space-6, 6px)}.sd-editor-popup input{box-sizing:border-box;width:100%;min-height:40px;color:var(--sd-text);background:var(--sd-surface);padding:var(--sd-space-8, 8px);font:inherit;border:1px solid var(--sd-control-border, var(--sd-border));border-radius:var(--sd-control-radius, 8px)}.sd-editor-popup input:hover{border-color:var(--sd-control-border-hover, var(--sd-border-strong))}.sd-editor-popup input:focus-visible{border-color:var(--sd-control-border-focus, var(--sd-primary));box-shadow:var(--sd-control-ring, none);outline:none}@media(forced-colors:active){.sd-editor-popup input:focus-visible{--sd-control-focus-ring: Highlight;outline:2px solid var(--sd-control-focus-ring);outline-offset:2px}}.sd-editor-popup-error{color:var(--sd-status-error-fg);margin-block:var(--sd-space-8, 8px)}.sd-editor-popup-actions{display:flex;justify-content:flex-end;gap:var(--sd-space-4, 4px);padding-top:var(--sd-space-8, 8px)}@container sd-editor (max-width: 620px){.sd-editor-secondary{display:none}}@media(pointer:coarse){:host ::ng-deep .sd-editor-toolbar button.c-button[data-editor-control]{min-width:48px!important;min-height:48px}}\n"], dependencies: [{ kind: "component", type: SdButton, selector: "sd-button", inputs: ["autoId", "type", "color", "size", "fontSet", "title", "width", "tooltip", "prefixIcon", "suffixIcon", "disabled", "openOnHover", "loading", "block", "htmlType", "indicator", "indicatorColor", "indicatorMax", "indicatorLabel"], outputs: ["click"] }, { kind: "component", type: SdButtonItem, selector: "sd-button-item", inputs: ["color", "prefixIcon", "suffixIcon", "fontSet", "disabled", "tooltip", "autoId"], outputs: ["click"] }, { kind: "component", type: SdButtonItemDivider, selector: "sd-button-item-divider", inputs: ["title"] }, { kind: "directive", type: SdEditorButtonDirective, selector: "sd-button[sdEditorButton]", inputs: ["sdEditorButton", "sdEditorPressed", "sdEditorTabIndex", "sdEditorAllowed", "sdEditorLabel"], outputs: ["sdEditorActivate", "sdEditorBeforeFocus", "sdEditorFocused"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1654
+ }
1655
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdEditorToolbar, decorators: [{
1656
+ type: Component,
1657
+ args: [{ selector: 'sd-editor-toolbar', standalone: true, imports: [SdButton, SdButtonItem, SdButtonItemDivider, SdEditorButtonDirective], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"sd-editor-toolbar\" role=\"toolbar\" tabindex=\"-1\" [attr.aria-label]=\"t('tools')\" (keydown)=\"navigate($event)\">\n <div class=\"sd-editor-toolbar-group\">\n @for (mark of marks; track mark) {\n <sd-button\n [sdEditorButton]=\"mark\"\n [prefixIcon]=\"icons[mark]\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n [tooltip]=\"t(mark)\"\n [sdEditorLabel]=\"t(mark)\"\n type=\"text\"\n color=\"secondary\"\n [class.sd-editor-active]=\"active(mark) === true\"\n [class.sd-editor-mixed]=\"active(mark) === 'mixed'\"\n [sdEditorPressed]=\"active(mark)\"\n [sdEditorTabIndex]=\"focusedId() === mark ? 0 : -1\"\n [disabled]=\"!can(mark)\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus(mark)\"\n (sdEditorActivate)=\"execute(mark)\" />\n }\n </div>\n @if (variant() === 'full') {\n <div class=\"sd-editor-toolbar-group sd-editor-secondary\">\n <sd-button\n sdEditorButton=\"heading\"\n [title]=\"t('heading')\"\n [tooltip]=\"t('heading')\"\n [sdEditorLabel]=\"t('heading')\"\n type=\"text\"\n [disabled]=\"!available()\"\n [sdEditorTabIndex]=\"focusedId() === 'heading' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('heading')\">\n <sd-button-item [disabled]=\"!can('paragraph')\" (click)=\"execute('paragraph')\">{{ t('paragraph') }}</sd-button-item>\n @for (level of levels; track level) {\n <sd-button-item [disabled]=\"!can('heading', level)\" (click)=\"execute('heading', level)\">{{\n t('heading-level', { level })\n }}</sd-button-item>\n }\n </sd-button>\n <sd-button\n sdEditorButton=\"font\"\n [title]=\"t('font')\"\n [tooltip]=\"choiceTooltip('font', 'fontFamily')\"\n [sdEditorLabel]=\"t('font')\"\n type=\"text\"\n [disabled]=\"!canStyle('font')\"\n [sdEditorTabIndex]=\"focusedId() === 'font' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('font')\"\n (sdEditorActivate)=\"open('font', 'font')\" />\n <sd-button\n sdEditorButton=\"size\"\n [title]=\"choiceValue('fontSize') || t('size')\"\n [sdEditorLabel]=\"t('size')\"\n [tooltip]=\"choiceTooltip('size', 'fontSize')\"\n type=\"text\"\n [disabled]=\"!canSize('14')\"\n [sdEditorTabIndex]=\"focusedId() === 'size' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('size')\">\n @for (size of sizes; track size) {\n <sd-button-item [disabled]=\"!canSize(size)\" (click)=\"setSize(size)\">{{ size }}px</sd-button-item>\n }\n </sd-button>\n <sd-button\n sdEditorButton=\"color\"\n prefixIcon=\"format_color_text\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"choiceTooltip('color', 'color')\"\n [sdEditorLabel]=\"t('color')\"\n type=\"text\"\n [disabled]=\"!canStyle('color')\"\n [sdEditorTabIndex]=\"focusedId() === 'color' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('color')\"\n (sdEditorActivate)=\"open('color', 'color')\" />\n <sd-button\n sdEditorButton=\"alignment\"\n class=\"sd-editor-icon-menu\"\n [prefixIcon]=\"alignmentIcon()\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('alignment')\"\n [sdEditorLabel]=\"t('alignment')\"\n type=\"text\"\n [disabled]=\"!available()\"\n [sdEditorTabIndex]=\"focusedId() === 'alignment' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('alignment')\">\n @for (alignment of alignments; track alignment) {\n <sd-button-item\n [prefixIcon]=\"icons[alignment]\"\n fontSet=\"material-icons-outlined\"\n [disabled]=\"!can(alignment)\"\n (click)=\"execute(alignment)\"\n >{{ t(alignment) }}</sd-button-item\n >\n }\n </sd-button>\n </div>\n }\n <div class=\"sd-editor-toolbar-group sd-editor-secondary\">\n <sd-button\n sdEditorButton=\"bullet\"\n [prefixIcon]=\"icons.bullet\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('bullet')\"\n [sdEditorLabel]=\"t('bullet')\"\n type=\"text\"\n [disabled]=\"!can('bullet')\"\n [sdEditorPressed]=\"active('bullet')\"\n [sdEditorTabIndex]=\"focusedId() === 'bullet' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('bullet')\"\n (sdEditorActivate)=\"execute('bullet')\" />\n <sd-button\n sdEditorButton=\"ordered\"\n [prefixIcon]=\"icons.ordered\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('ordered')\"\n [sdEditorLabel]=\"t('ordered')\"\n type=\"text\"\n [disabled]=\"!can('ordered')\"\n [sdEditorPressed]=\"active('ordered')\"\n [sdEditorTabIndex]=\"focusedId() === 'ordered' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('ordered')\"\n (sdEditorActivate)=\"execute('ordered')\" />\n </div>\n <sd-button\n sdEditorButton=\"link\"\n prefixIcon=\"link\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('link')\"\n [sdEditorLabel]=\"t('link')\"\n type=\"text\"\n [disabled]=\"!canStyle('link')\"\n [sdEditorTabIndex]=\"focusedId() === 'link' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('link')\"\n (sdEditorActivate)=\"open('link', 'link')\" />\n @if (variant() === 'full') {\n <sd-button\n sdEditorButton=\"table\"\n class=\"sd-editor-secondary sd-editor-icon-menu\"\n prefixIcon=\"table_chart\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('table')\"\n [sdEditorLabel]=\"t('table')\"\n type=\"text\"\n [disabled]=\"!available()\"\n [sdEditorTabIndex]=\"focusedId() === 'table' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('table')\">\n @for (action of tableActions; track action) {\n <sd-button-item [disabled]=\"!can(action)\" (click)=\"execute(action)\">{{ t(action) }}</sd-button-item>\n }\n </sd-button>\n @if (uploadEnabled()) {\n <sd-button\n sdEditorButton=\"image\"\n class=\"sd-editor-secondary\"\n prefixIcon=\"image\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('image')\"\n [sdEditorLabel]=\"t('image')\"\n type=\"text\"\n [disabled]=\"!available()\"\n [sdEditorTabIndex]=\"focusedId() === 'image' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('image')\"\n (sdEditorActivate)=\"chooseFiles()\" />\n }\n }\n <sd-button\n sdEditorButton=\"more\"\n class=\"sd-editor-icon-menu\"\n prefixIcon=\"more_horiz\"\n fontSet=\"material-icons-outlined\"\n size=\"md\"\n color=\"secondary\"\n [tooltip]=\"t('more')\"\n [sdEditorLabel]=\"t('more')\"\n type=\"text\"\n [disabled]=\"!available()\"\n [sdEditorTabIndex]=\"focusedId() === 'more' ? 0 : -1\"\n (sdEditorBeforeFocus)=\"capture()\"\n (sdEditorFocused)=\"rememberFocus('more')\">\n <sd-button-item [prefixIcon]=\"icons.undo\" fontSet=\"material-icons-outlined\" [disabled]=\"!can('undo')\" (click)=\"execute('undo')\">{{\n t('undo')\n }}</sd-button-item>\n <sd-button-item [prefixIcon]=\"icons.redo\" fontSet=\"material-icons-outlined\" [disabled]=\"!can('redo')\" (click)=\"execute('redo')\">{{\n t('redo')\n }}</sd-button-item>\n <sd-button-item-divider />\n @for (mark of additionalMarks; track mark) {\n <sd-button-item [prefixIcon]=\"icons[mark]\" fontSet=\"material-icons-outlined\" [disabled]=\"!can(mark)\" (click)=\"execute(mark)\">{{\n t(mark)\n }}</sd-button-item>\n }\n <sd-button-item-divider />\n <sd-button-item [prefixIcon]=\"icons.bullet\" fontSet=\"material-icons-outlined\" [disabled]=\"!can('bullet')\" (click)=\"execute('bullet')\">{{\n t('bullet')\n }}</sd-button-item>\n <sd-button-item\n [prefixIcon]=\"icons.ordered\"\n fontSet=\"material-icons-outlined\"\n [disabled]=\"!can('ordered')\"\n (click)=\"execute('ordered')\"\n >{{ t('ordered') }}</sd-button-item\n >\n <sd-button-item [disabled]=\"!can('paragraph')\" (click)=\"execute('paragraph')\">{{ t('paragraph') }}</sd-button-item>\n @for (level of levels; track level) {\n <sd-button-item [disabled]=\"!can('heading', level)\" (click)=\"execute('heading', level)\">{{\n t('heading-level', { level })\n }}</sd-button-item>\n }\n <sd-button-item-divider />\n <sd-button-item [disabled]=\"!canStyle('color')\" (click)=\"open('color', 'more')\">{{ t('color') }}</sd-button-item>\n <sd-button-item [disabled]=\"!canStyle('font')\" (click)=\"open('font', 'more')\">{{ t('font') }}</sd-button-item>\n @for (size of sizes; track size) {\n <sd-button-item [disabled]=\"!canSize(size)\" (click)=\"setSize(size)\">{{ t('size') }} {{ size }}px</sd-button-item>\n }\n @for (alignment of alignments; track alignment) {\n <sd-button-item\n [prefixIcon]=\"icons[alignment]\"\n fontSet=\"material-icons-outlined\"\n [disabled]=\"!can(alignment)\"\n (click)=\"execute(alignment)\"\n >{{ t(alignment) }}</sd-button-item\n >\n }\n <sd-button-item-divider />\n @for (action of tableActions; track action) {\n <sd-button-item [disabled]=\"!can(action)\" (click)=\"execute(action)\">{{ t(action) }}</sd-button-item>\n }\n @if (selectedImage()) {\n <sd-button-item-divider [title]=\"t('image-size')\" />\n @for (width of imageWidths; track width) {\n <sd-button-item (click)=\"resizeImage(width)\">{{ width }}</sd-button-item>\n }\n <sd-button-item (click)=\"resizeImage(null)\">{{ t('image-original') }}</sd-button-item>\n <sd-button-item (click)=\"alignImage('left')\">{{ t('image-left') }}</sd-button-item>\n <sd-button-item (click)=\"alignImage('center')\">{{ t('image-center') }}</sd-button-item>\n <sd-button-item (click)=\"alignImage('right')\">{{ t('image-right') }}</sd-button-item>\n }\n @if (uploadEnabled()) {\n <sd-button-item prefixIcon=\"image\" fontSet=\"material-icons-outlined\" (click)=\"chooseFiles()\">{{ t('image') }}</sd-button-item>\n }\n </sd-button>\n</div>\n\n@if (popup(); as kind) {\n <form\n #popup\n class=\"sd-editor-popup\"\n role=\"dialog\"\n novalidate\n [attr.aria-label]=\"t(kind)\"\n (submit)=\"apply($event)\"\n (keydown)=\"popupKeydown($event)\">\n <label>\n <span>{{ t(kind === 'link' ? 'link-address' : kind) }}</span>\n <input\n #popupField\n [type]=\"kind === 'link' ? 'url' : 'text'\"\n [value]=\"popupValue()\"\n [attr.aria-invalid]=\"!!popupError()\"\n [attr.aria-describedby]=\"popupError() ? popupErrorId : null\"\n (input)=\"popupValue.set($any($event.target).value); popupError.set('')\"\n (compositionstart)=\"popupComposing.set(true)\"\n (compositionend)=\"popupComposing.set(false)\" />\n </label>\n @if (popupError()) {\n <p class=\"sd-editor-popup-error\" [id]=\"popupErrorId\" role=\"status\">{{ popupError() }}</p>\n }\n <div class=\"sd-editor-popup-actions\">\n <sd-button [title]=\"cancelLabel()\" type=\"text\" (click)=\"close(true)\" />\n <sd-button [title]=\"t('apply')\" type=\"fill\" color=\"primary\" htmlType=\"submit\" [disabled]=\"!available() || popupComposing()\" />\n </div>\n </form>\n}\n", styles: [":host{display:block;position:relative}.sd-editor-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:var(--sd-space-2, 2px);padding:var(--sd-space-4, 4px);background:var(--sd-surface);border-bottom:1px solid var(--sd-border)}.sd-editor-toolbar-group{display:flex;align-items:center;gap:var(--sd-space-2, 2px)}.sd-editor-toolbar-group+.sd-editor-toolbar-group{border-inline-start:1px solid var(--sd-border);padding-inline-start:var(--sd-space-4, 4px)}:host ::ng-deep .sd-editor-toolbar .sd-editor-icon-menu button.c-button.c-square{width:48px!important}:host ::ng-deep .sd-editor-toolbar button.c-button[aria-pressed=true]:not(:disabled),:host ::ng-deep .sd-editor-active button.c-button:not(:disabled){background:var(--sd-primary-light)!important;color:var(--sd-primary)!important;box-shadow:inset 0 -2px var(--sd-primary)}:host ::ng-deep .sd-editor-mixed button.c-button:not(:disabled){border-bottom:2px dashed var(--sd-primary)}.sd-editor-popup{position:absolute;inset-inline-end:0;top:100%;z-index:var(--sd-z-popover, 40);box-sizing:border-box;width:min(360px,100%);max-width:calc(100vw - 24px);padding:var(--sd-space-12, 12px);background:var(--sd-surface);color:var(--sd-text);border:1px solid var(--sd-border-strong);border-radius:var(--sd-radius-4, 4px);box-shadow:var(--sd-shadow-sm)}.sd-editor-popup label{display:flex;flex-direction:column;gap:var(--sd-space-6, 6px)}.sd-editor-popup input{box-sizing:border-box;width:100%;min-height:40px;color:var(--sd-text);background:var(--sd-surface);padding:var(--sd-space-8, 8px);font:inherit;border:1px solid var(--sd-control-border, var(--sd-border));border-radius:var(--sd-control-radius, 8px)}.sd-editor-popup input:hover{border-color:var(--sd-control-border-hover, var(--sd-border-strong))}.sd-editor-popup input:focus-visible{border-color:var(--sd-control-border-focus, var(--sd-primary));box-shadow:var(--sd-control-ring, none);outline:none}@media(forced-colors:active){.sd-editor-popup input:focus-visible{--sd-control-focus-ring: Highlight;outline:2px solid var(--sd-control-focus-ring);outline-offset:2px}}.sd-editor-popup-error{color:var(--sd-status-error-fg);margin-block:var(--sd-space-8, 8px)}.sd-editor-popup-actions{display:flex;justify-content:flex-end;gap:var(--sd-space-4, 4px);padding-top:var(--sd-space-8, 8px)}@container sd-editor (max-width: 620px){.sd-editor-secondary{display:none}}@media(pointer:coarse){:host ::ng-deep .sd-editor-toolbar button.c-button[data-editor-control]{min-width:48px!important;min-height:48px}}\n"] }]
1658
+ }], ctorParameters: () => [], propDecorators: { engine: [{ type: i0.Input, args: [{ isSignal: true, alias: "engine", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], revision: [{ type: i0.Input, args: [{ isSignal: true, alias: "revision", required: false }] }], sourceVersion: [{ type: i0.Input, args: [{ isSignal: true, alias: "sourceVersion", required: false }] }], uploadEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "uploadEnabled", required: false }] }], requestFiles: [{ type: i0.Output, args: ["requestFiles"] }], popupElement: [{ type: i0.ViewChild, args: ['popup', { isSignal: true }] }], popupField: [{ type: i0.ViewChild, args: ['popupField', { isSignal: true }] }] } });
1659
+
1660
+ /** Internal composition surface. It alone owns the browser editor lifecycle. */
1661
+ class SdEditorSurface {
1662
+ content = input('', ...(ngDevMode ? [{ debugName: "content" }] : []));
1663
+ format = input('html', ...(ngDevMode ? [{ debugName: "format" }] : []));
1664
+ variant = input('full', ...(ngDevMode ? [{ debugName: "variant" }] : []));
1665
+ editable = input(true, ...(ngDevMode ? [{ debugName: "editable" }] : []));
1666
+ disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
1667
+ readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly" }] : []));
1668
+ placeholder = input(...(ngDevMode ? [undefined, { debugName: "placeholder" }] : []));
1669
+ mentionFeeds = input(...(ngDevMode ? [undefined, { debugName: "mentionFeeds" }] : []));
1670
+ uploadEnabled = input(false, ...(ngDevMode ? [{ debugName: "uploadEnabled" }] : []));
1671
+ height = input(...(ngDevMode ? [undefined, { debugName: "height" }] : []));
1672
+ maxHeight = input(...(ngDevMode ? [undefined, { debugName: "maxHeight" }] : []));
1673
+ label = input(...(ngDevMode ? [undefined, { debugName: "label" }] : []));
1674
+ describedBy = input(...(ngDevMode ? [undefined, { debugName: "describedBy" }] : []));
1675
+ invalid = input(false, ...(ngDevMode ? [{ debugName: "invalid" }] : []));
1676
+ id = input(...(ngDevMode ? [undefined, { debugName: "id" }] : []));
1677
+ engineReady = output();
1678
+ change = output();
1679
+ focus = output();
1680
+ blur = output();
1681
+ diagnostics = output();
1682
+ sourceChange = output();
1683
+ formatChange = output();
1684
+ compositionChange = output();
1685
+ mentionSelected = output();
1686
+ filesSelected = output();
1687
+ hostElement = viewChild.required('contentHost');
1688
+ fileInput = viewChild('fileInput', ...(ngDevMode ? [{ debugName: "fileInput" }] : []));
1689
+ toolbar = viewChild(SdEditorToolbar, ...(ngDevMode ? [{ debugName: "toolbar" }] : []));
1690
+ engine = signal(null, ...(ngDevMode ? [{ debugName: "engine" }] : []));
1691
+ revision = signal(0, ...(ngDevMode ? [{ debugName: "revision" }] : []));
1692
+ sourceVersion = signal(0, ...(ngDevMode ? [{ debugName: "sourceVersion" }] : []));
1693
+ importDiagnostics = signal([], ...(ngDevMode ? [{ debugName: "importDiagnostics" }] : []));
1694
+ #i18n = inject(I18nService);
1695
+ #browser = isPlatformBrowser(inject(PLATFORM_ID));
1696
+ #lastContent = '';
1697
+ #lastFormat = 'html';
1698
+ #destroyed = false;
1699
+ constructor() {
1700
+ afterNextRender(() => {
1701
+ if (!this.#browser || this.#destroyed)
1702
+ return;
1703
+ this.#lastContent = this.content();
1704
+ this.#lastFormat = this.format();
1705
+ const engine = new SdEditorEngine(this.hostElement().nativeElement, {
1706
+ content: this.content(),
1707
+ format: this.format(),
1708
+ editable: this.editable() && !this.disabled() && !this.readonly(),
1709
+ placeholder: this.placeholder(),
1710
+ mentionFeeds: this.mentionFeeds(),
1711
+ onChange: value => {
1712
+ if (!this.#destroyed)
1713
+ this.change.emit(value);
1714
+ },
1715
+ onFocus: event => {
1716
+ if (!this.#destroyed)
1717
+ this.focus.emit(event);
1718
+ },
1719
+ onBlur: event => {
1720
+ if (!this.#destroyed)
1721
+ this.blur.emit(event);
1722
+ },
1723
+ onDiagnostics: values => {
1724
+ if (!this.#destroyed) {
1725
+ this.importDiagnostics.set(values);
1726
+ this.diagnostics.emit(values);
1727
+ }
1728
+ },
1729
+ onStateChange: () => {
1730
+ if (!this.#destroyed)
1731
+ this.revision.update(value => value + 1);
1732
+ },
1733
+ onSourceChange: reason => {
1734
+ if (!this.#destroyed) {
1735
+ this.toolbar()?.close(false);
1736
+ this.sourceVersion.update(value => value + 1);
1737
+ this.sourceChange.emit(reason);
1738
+ }
1739
+ },
1740
+ onFormatChange: value => {
1741
+ if (!this.#destroyed)
1742
+ this.formatChange.emit(value);
1743
+ },
1744
+ onCompositionStateChange: composing => {
1745
+ if (!this.#destroyed)
1746
+ this.compositionChange.emit(composing);
1747
+ },
1748
+ onMentionSelect: item => {
1749
+ if (!this.#destroyed)
1750
+ this.mentionSelected.emit(item);
1751
+ },
1752
+ mentionLabel: () => this.#i18n.t('core.component.editor.mentions'),
1753
+ });
1754
+ this.engine.set(engine);
1755
+ this.engineReady.emit(engine);
1756
+ });
1757
+ effect(() => {
1758
+ const content = this.content();
1759
+ const format = this.format();
1760
+ const engine = this.engine();
1761
+ if (!engine || this.#destroyed)
1762
+ return;
1763
+ if (content !== this.#lastContent) {
1764
+ this.#lastContent = content;
1765
+ this.#lastFormat = format;
1766
+ engine.setContent(content, format);
1767
+ }
1768
+ else if (format !== this.#lastFormat) {
1769
+ this.#lastFormat = format;
1770
+ engine.setFormat(format);
1771
+ }
1772
+ });
1773
+ effect(() => {
1774
+ const editable = this.editable() && !this.disabled() && !this.readonly();
1775
+ const placeholder = this.placeholder();
1776
+ const feeds = this.mentionFeeds();
1777
+ const engine = this.engine();
1778
+ if (!engine || this.#destroyed)
1779
+ return;
1780
+ engine.setEditable(editable);
1781
+ engine.setPlaceholder(placeholder);
1782
+ engine.setMentionFeeds(feeds);
1783
+ });
1784
+ effect(() => {
1785
+ const engine = this.engine();
1786
+ this.revision();
1787
+ const label = this.label() || this.#i18n.t('core.component.editor.content');
1788
+ const describedBy = this.describedBy();
1789
+ const invalid = this.invalid();
1790
+ const id = this.id();
1791
+ const height = this.height();
1792
+ const maxHeight = this.maxHeight();
1793
+ const disabled = this.disabled();
1794
+ const readonly = this.readonly();
1795
+ if (!engine || this.#destroyed)
1796
+ return;
1797
+ const native = engine.editor.view.dom;
1798
+ native.setAttribute('role', 'textbox');
1799
+ native.setAttribute('aria-multiline', 'true');
1800
+ native.setAttribute('aria-label', label);
1801
+ native.setAttribute('aria-invalid', String(invalid));
1802
+ native.setAttribute('aria-readonly', String(readonly || (!engine.editor.isEditable && !disabled)));
1803
+ native.setAttribute('aria-disabled', String(disabled));
1804
+ native.tabIndex = disabled ? -1 : 0;
1805
+ if (describedBy)
1806
+ native.setAttribute('aria-describedby', describedBy);
1807
+ else
1808
+ native.removeAttribute('aria-describedby');
1809
+ if (id)
1810
+ native.id = id;
1811
+ else
1812
+ native.removeAttribute('id');
1813
+ native.style.minHeight = height ?? '';
1814
+ native.style.maxHeight = maxHeight ?? '';
1815
+ native.style.overflowY = 'auto';
1816
+ const preview = this.hostElement().nativeElement.querySelector('.sd-editor-import-preview');
1817
+ if (preview) {
1818
+ preview.setAttribute('role', 'region');
1819
+ preview.setAttribute('aria-label', label);
1820
+ preview.tabIndex = disabled ? -1 : 0;
1821
+ if (describedBy)
1822
+ preview.setAttribute('aria-describedby', describedBy);
1823
+ else
1824
+ preview.removeAttribute('aria-describedby');
1825
+ preview.style.minHeight = height ?? '';
1826
+ preview.style.maxHeight = maxHeight ?? '';
1827
+ preview.style.overflowY = 'auto';
1828
+ preview.style.boxSizing = 'border-box';
1829
+ }
1830
+ });
1831
+ inject(DestroyRef).onDestroy(() => {
1832
+ this.#destroyed = true;
1833
+ this.engine()?.destroy();
1834
+ });
1835
+ }
1836
+ preview() {
1837
+ return this.content();
1838
+ }
1839
+ warning(code) {
1840
+ return this.#i18n.t(`core.component.editor.import.${code}`);
1841
+ }
1842
+ warningCodes() {
1843
+ return [...new Set(this.importDiagnostics().map(value => value.code))];
1844
+ }
1845
+ detailsLabel() {
1846
+ return this.#i18n.t('core.component.editor.import.details');
1847
+ }
1848
+ chooseFiles() {
1849
+ if (!this.#destroyed && this.uploadEnabled() && this.engine()?.editor.isEditable)
1850
+ this.fileInput()?.nativeElement.click();
1851
+ }
1852
+ selectedFiles(event) {
1853
+ const input = event.target;
1854
+ const files = Array.from(input.files ?? []);
1855
+ input.value = '';
1856
+ if (files.length && !this.#destroyed && this.uploadEnabled() && this.engine()?.editor.isEditable)
1857
+ this.filesSelected.emit(files);
1858
+ }
1859
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdEditorSurface, deps: [], target: i0.ɵɵFactoryTarget.Component });
1860
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: SdEditorSurface, isStandalone: true, selector: "sd-editor-surface", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, mentionFeeds: { classPropertyName: "mentionFeeds", publicName: "mentionFeeds", isSignal: true, isRequired: false, transformFunction: null }, uploadEnabled: { classPropertyName: "uploadEnabled", publicName: "uploadEnabled", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, describedBy: { classPropertyName: "describedBy", publicName: "describedBy", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { engineReady: "engineReady", change: "change", focus: "focus", blur: "blur", diagnostics: "diagnostics", sourceChange: "sourceChange", formatChange: "formatChange", compositionChange: "compositionChange", mentionSelected: "mentionSelected", filesSelected: "filesSelected" }, host: { properties: { "attr.data-variant": "variant()" } }, viewQueries: [{ propertyName: "hostElement", first: true, predicate: ["contentHost"], descendants: true, isSignal: true }, { propertyName: "fileInput", first: true, predicate: ["fileInput"], descendants: true, isSignal: true }, { propertyName: "toolbar", first: true, predicate: SdEditorToolbar, descendants: true, isSignal: true }], ngImport: i0, template: "<sd-ckeditor-styles />\n<div class=\"sd-editor-surface\" [class.sd-editor-surface-compact]=\"variant() === 'compact'\" (change)=\"$event.stopPropagation()\">\n @if (engine(); as activeEngine) {\n <sd-editor-toolbar\n [engine]=\"activeEngine\"\n [variant]=\"variant()\"\n [revision]=\"revision()\"\n [sourceVersion]=\"sourceVersion()\"\n [uploadEnabled]=\"uploadEnabled()\"\n (requestFiles)=\"chooseFiles()\" />\n }\n <div #contentHost class=\"sd-editor-content-host\" [style.min-height]=\"height()\" [style.max-height]=\"maxHeight()\">\n @if (!engine()) {\n <pre class=\"sd-editor-escaped-preview\">{{ preview() }}</pre>\n }\n </div>\n <input\n #fileInput\n type=\"file\"\n accept=\"image/*\"\n multiple\n hidden\n [disabled]=\"!uploadEnabled() || !editable() || disabled() || readonly()\"\n (change)=\"selectedFiles($event)\" />\n @if (importDiagnostics().length) {\n <div class=\"sd-editor-import-warning\" role=\"status\">\n @for (code of warningCodes(); track code) {\n <p>{{ warning(code) }}</p>\n }\n <details>\n <summary>{{ detailsLabel() }}</summary>\n <ul>\n @for (diagnostic of importDiagnostics(); track $index) {\n <li>{{ diagnostic.path }}: {{ diagnostic.detail }}</li>\n }\n </ul>\n </details>\n </div>\n }\n</div>\n", styles: [":host{display:block;min-width:0;container-name:sd-editor;container-type:inline-size}.sd-editor-surface{color:var(--sd-text);background:var(--sd-surface);border:1px solid var(--sd-border);border-radius:var(--sd-radius-4, 4px)}.sd-editor-content-host{box-sizing:border-box;overflow:auto}.sd-editor-content-host:focus-within{outline:var(--sd-focus-ring-width, 2px) solid var(--sd-focus-ring-color);outline-offset:var(--sd-focus-ring-offset, 2px)}.sd-editor-escaped-preview{white-space:pre-wrap;overflow-wrap:anywhere;margin:0;padding:var(--sd-space-12, 12px);font:inherit}.sd-editor-import-warning{padding:var(--sd-space-8, 8px) var(--sd-space-12, 12px);color:var(--sd-status-warning-fg);background:var(--sd-status-warning-bg);border-top:1px solid var(--sd-border)}.sd-editor-import-warning p{margin-block:var(--sd-space-4, 4px)}.sd-editor-import-warning summary{cursor:pointer}.sd-editor-import-warning li{overflow-wrap:anywhere}\n"], dependencies: [{ kind: "component", type: SdEditorToolbar, selector: "sd-editor-toolbar", inputs: ["engine", "variant", "revision", "sourceVersion", "uploadEnabled"], outputs: ["requestFiles"] }, { kind: "component", type: SdCKEditorStyles, selector: "sd-ckeditor-styles" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1861
+ }
1862
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdEditorSurface, decorators: [{
1863
+ type: Component,
1864
+ args: [{ selector: 'sd-editor-surface', standalone: true, imports: [SdEditorToolbar, SdCKEditorStyles], changeDetection: ChangeDetectionStrategy.OnPush, host: { '[attr.data-variant]': 'variant()' }, template: "<sd-ckeditor-styles />\n<div class=\"sd-editor-surface\" [class.sd-editor-surface-compact]=\"variant() === 'compact'\" (change)=\"$event.stopPropagation()\">\n @if (engine(); as activeEngine) {\n <sd-editor-toolbar\n [engine]=\"activeEngine\"\n [variant]=\"variant()\"\n [revision]=\"revision()\"\n [sourceVersion]=\"sourceVersion()\"\n [uploadEnabled]=\"uploadEnabled()\"\n (requestFiles)=\"chooseFiles()\" />\n }\n <div #contentHost class=\"sd-editor-content-host\" [style.min-height]=\"height()\" [style.max-height]=\"maxHeight()\">\n @if (!engine()) {\n <pre class=\"sd-editor-escaped-preview\">{{ preview() }}</pre>\n }\n </div>\n <input\n #fileInput\n type=\"file\"\n accept=\"image/*\"\n multiple\n hidden\n [disabled]=\"!uploadEnabled() || !editable() || disabled() || readonly()\"\n (change)=\"selectedFiles($event)\" />\n @if (importDiagnostics().length) {\n <div class=\"sd-editor-import-warning\" role=\"status\">\n @for (code of warningCodes(); track code) {\n <p>{{ warning(code) }}</p>\n }\n <details>\n <summary>{{ detailsLabel() }}</summary>\n <ul>\n @for (diagnostic of importDiagnostics(); track $index) {\n <li>{{ diagnostic.path }}: {{ diagnostic.detail }}</li>\n }\n </ul>\n </details>\n </div>\n }\n</div>\n", styles: [":host{display:block;min-width:0;container-name:sd-editor;container-type:inline-size}.sd-editor-surface{color:var(--sd-text);background:var(--sd-surface);border:1px solid var(--sd-border);border-radius:var(--sd-radius-4, 4px)}.sd-editor-content-host{box-sizing:border-box;overflow:auto}.sd-editor-content-host:focus-within{outline:var(--sd-focus-ring-width, 2px) solid var(--sd-focus-ring-color);outline-offset:var(--sd-focus-ring-offset, 2px)}.sd-editor-escaped-preview{white-space:pre-wrap;overflow-wrap:anywhere;margin:0;padding:var(--sd-space-12, 12px);font:inherit}.sd-editor-import-warning{padding:var(--sd-space-8, 8px) var(--sd-space-12, 12px);color:var(--sd-status-warning-fg);background:var(--sd-status-warning-bg);border-top:1px solid var(--sd-border)}.sd-editor-import-warning p{margin-block:var(--sd-space-4, 4px)}.sd-editor-import-warning summary{cursor:pointer}.sd-editor-import-warning li{overflow-wrap:anywhere}\n"] }]
1865
+ }], ctorParameters: () => [], propDecorators: { content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], editable: [{ type: i0.Input, args: [{ isSignal: true, alias: "editable", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], mentionFeeds: [{ type: i0.Input, args: [{ isSignal: true, alias: "mentionFeeds", required: false }] }], uploadEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "uploadEnabled", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], maxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxHeight", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], describedBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "describedBy", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], engineReady: [{ type: i0.Output, args: ["engineReady"] }], change: [{ type: i0.Output, args: ["change"] }], focus: [{ type: i0.Output, args: ["focus"] }], blur: [{ type: i0.Output, args: ["blur"] }], diagnostics: [{ type: i0.Output, args: ["diagnostics"] }], sourceChange: [{ type: i0.Output, args: ["sourceChange"] }], formatChange: [{ type: i0.Output, args: ["formatChange"] }], compositionChange: [{ type: i0.Output, args: ["compositionChange"] }], mentionSelected: [{ type: i0.Output, args: ["mentionSelected"] }], filesSelected: [{ type: i0.Output, args: ["filesSelected"] }], hostElement: [{ type: i0.ViewChild, args: ['contentHost', { isSignal: true }] }], fileInput: [{ type: i0.ViewChild, args: ['fileInput', { isSignal: true }] }], toolbar: [{ type: i0.ViewChild, args: [i0.forwardRef(() => SdEditorToolbar), { isSignal: true }] }] } });
1866
+
1867
+ /**
1868
+ * Generated bundle index. Do not edit.
1869
+ */
1870
+
1871
+ export { SdEditorEngine, SdEditorImportError, SdEditorSurface };
1872
+ //# sourceMappingURL=sdcorejs-angular-components-editor-engine.mjs.map