@web-atoms/web-controls 2.6.5 → 2.6.6

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 (177) hide show
  1. package/dist/tsconfig.tsbuildinfo +1 -1
  2. package/dist-esm/ArrayLike.js +14 -12
  3. package/dist-esm/DataAttributes.js +18 -19
  4. package/dist-esm/Focusable.js +10 -11
  5. package/dist-esm/ModuleFiles.js +43 -42
  6. package/dist-esm/NumberFormats.js +60 -56
  7. package/dist-esm/PageNavigator.js +28 -30
  8. package/dist-esm/animations/Animations.js +36 -33
  9. package/dist-esm/basic/AtomChips.js +312 -305
  10. package/dist-esm/basic/AtomRepeater.js +1070 -1035
  11. package/dist-esm/basic/AtomSuggestions.js +97 -107
  12. package/dist-esm/basic/AttachedPopup.js +0 -1
  13. package/dist-esm/basic/Button.js +45 -19
  14. package/dist-esm/basic/ButtonBar.js +84 -64
  15. package/dist-esm/basic/Calendar.js +211 -203
  16. package/dist-esm/basic/CheckBoxList.js +90 -70
  17. package/dist-esm/basic/Checkbox.js +16 -8
  18. package/dist-esm/basic/Chip.js +36 -12
  19. package/dist-esm/basic/ComboBox.js +47 -51
  20. package/dist-esm/basic/DataGrid.js +258 -252
  21. package/dist-esm/basic/DateField.js +149 -127
  22. package/dist-esm/basic/DropDown.js +91 -103
  23. package/dist-esm/basic/DropDownInput.js +78 -106
  24. package/dist-esm/basic/Editable.js +82 -77
  25. package/dist-esm/basic/Expander.js +104 -86
  26. package/dist-esm/basic/FilesDragDrop.js +84 -80
  27. package/dist-esm/basic/Form.js +80 -52
  28. package/dist-esm/basic/FormField.js +164 -106
  29. package/dist-esm/basic/IElement.js +1 -2
  30. package/dist-esm/basic/InlinePopup.js +263 -234
  31. package/dist-esm/basic/InlinePopupButton.js +99 -88
  32. package/dist-esm/basic/InlinePopupControl.js +24 -23
  33. package/dist-esm/basic/ItemPath.js +59 -60
  34. package/dist-esm/basic/LimitedText.js +49 -38
  35. package/dist-esm/basic/ListRepeater.js +13 -14
  36. package/dist-esm/basic/MaskedInput.js +37 -29
  37. package/dist-esm/basic/MaskedInputDiv.js +55 -48
  38. package/dist-esm/basic/MergeNode.js +64 -35
  39. package/dist-esm/basic/PasswordBox.js +32 -17
  40. package/dist-esm/basic/PinchZoomView.js +221 -199
  41. package/dist-esm/basic/PopupButton.js +39 -16
  42. package/dist-esm/basic/PopupMenu.js +3 -4
  43. package/dist-esm/basic/RadioButtonList.js +35 -25
  44. package/dist-esm/basic/RefreshLock.js +41 -42
  45. package/dist-esm/basic/Resizable.js +43 -33
  46. package/dist-esm/basic/Select.js +72 -65
  47. package/dist-esm/basic/SortByButton.js +41 -31
  48. package/dist-esm/basic/Swipe.js +91 -84
  49. package/dist-esm/basic/Switch.js +22 -8
  50. package/dist-esm/basic/TableRepeater.js +29 -33
  51. package/dist-esm/basic/TimeEditor.js +97 -52
  52. package/dist-esm/basic/TitleEditor.js +115 -95
  53. package/dist-esm/basic/ToggleButtonBar.js +21 -22
  54. package/dist-esm/basic/Tooltip.js +49 -47
  55. package/dist-esm/basic/TypeWriter.js +45 -42
  56. package/dist-esm/basic/UploadEvent.js +211 -178
  57. package/dist-esm/basic/ZoomView.js +229 -198
  58. package/dist-esm/basic/combineClasses.js +2 -3
  59. package/dist-esm/basic/elements/AtomPopover.js +270 -253
  60. package/dist-esm/basic/elements/getContainingBlock.js +34 -35
  61. package/dist-esm/basic/elements/relativeRect.js +40 -21
  62. package/dist-esm/desktop-app/DesktopApp.js +65 -80
  63. package/dist-esm/desktop-app/MobileDesktopApp.js +20 -23
  64. package/dist-esm/html-editor/AtomHtmlEditor.js +243 -268
  65. package/dist-esm/html-editor/HtmlEditorCommands.js +6 -4
  66. package/dist-esm/html-editor/InlineHtmlEditor.js +174 -166
  67. package/dist-esm/html-editor/RangeEditor.js +49 -51
  68. package/dist-esm/html-editor/commands/AddImage.js +40 -35
  69. package/dist-esm/html-editor/commands/AddLink.js +56 -54
  70. package/dist-esm/html-editor/commands/Align.js +24 -7
  71. package/dist-esm/html-editor/commands/AttachFile.js +23 -13
  72. package/dist-esm/html-editor/commands/AttachImage.js +35 -25
  73. package/dist-esm/html-editor/commands/Bold.js +10 -11
  74. package/dist-esm/html-editor/commands/ChangeColor.js +31 -107
  75. package/dist-esm/html-editor/commands/ChangeFont.js +42 -42
  76. package/dist-esm/html-editor/commands/ChangeFontSize.js +15 -5
  77. package/dist-esm/html-editor/commands/Command.js +34 -16
  78. package/dist-esm/html-editor/commands/CommandButton.js +51 -32
  79. package/dist-esm/html-editor/commands/Headings.js +25 -9
  80. package/dist-esm/html-editor/commands/HorizontalRule.js +9 -10
  81. package/dist-esm/html-editor/commands/HtmlCommands.js +160 -65
  82. package/dist-esm/html-editor/commands/IndentLess.js +10 -11
  83. package/dist-esm/html-editor/commands/IndentMore.js +10 -11
  84. package/dist-esm/html-editor/commands/Italic.js +10 -11
  85. package/dist-esm/html-editor/commands/NumberedList.js +10 -11
  86. package/dist-esm/html-editor/commands/Quote.js +10 -11
  87. package/dist-esm/html-editor/commands/RemoveFormat.js +10 -11
  88. package/dist-esm/html-editor/commands/Separator.js +5 -4
  89. package/dist-esm/html-editor/commands/Source.js +29 -25
  90. package/dist-esm/html-editor/commands/StrikeThrough.js +10 -11
  91. package/dist-esm/html-editor/commands/Toolbar.js +6 -4
  92. package/dist-esm/html-editor/commands/Underline.js +10 -11
  93. package/dist-esm/html-editor/commands/Unlink.js +10 -9
  94. package/dist-esm/html-editor/commands/UnorderedList.js +10 -11
  95. package/dist-esm/mobile-app/BottomPopup.js +137 -148
  96. package/dist-esm/mobile-app/MasterDetailPage.js +153 -152
  97. package/dist-esm/mobile-app/MobileApp.js +577 -569
  98. package/dist-esm/player/AtomVideoPlayer.js +316 -270
  99. package/dist-esm/player/TrackProgress.js +11 -7
  100. package/dist-esm/player/input-range-style.js +97 -98
  101. package/dist-esm/tests/app-test/AppTestApp.js +12 -15
  102. package/dist-esm/tests/app-test/AppTestApp.pack.js +54 -0
  103. package/dist-esm/tests/app-test/commands/AppCommands.js +14 -11
  104. package/dist-esm/tests/app-test/drawer/AppDrawer.js +4 -6
  105. package/dist-esm/tests/app-test/model/model.js +1 -2
  106. package/dist-esm/tests/app-test/pages/detail/DetailPage.js +21 -15
  107. package/dist-esm/tests/app-test/pages/home/HomePage.js +7 -8
  108. package/dist-esm/tests/app-test/pages/list/ListPage.js +79 -62
  109. package/dist-esm/tests/basic/PopupTest.js +9 -7
  110. package/dist-esm/tests/basic/TimeEditorTest.js +5 -9
  111. package/dist-esm/tests/basic/TimeEditorTest.pack.js +39 -0
  112. package/dist-esm/tests/basic/TimerTest.js +27 -37
  113. package/dist-esm/tests/basic/TimerTest.pack.js +40 -0
  114. package/dist-esm/tests/basic/basic-form/BasicForm.js +47 -27
  115. package/dist-esm/tests/basic/basic-form/BasicForm.pack.js +44 -0
  116. package/dist-esm/tests/basic/calendar/BasicCalendarTest.js +5 -9
  117. package/dist-esm/tests/basic/calendar/BasicCalendarTest.pack.js +53 -0
  118. package/dist-esm/tests/basic/chips/ChipsTest.js +25 -15
  119. package/dist-esm/tests/basic/chips/ChipsTest.pack.js +56 -0
  120. package/dist-esm/tests/basic/data-grid/DataGridTest.js +55 -60
  121. package/dist-esm/tests/basic/data-grid/DataGridTest.pack.js +58 -0
  122. package/dist-esm/tests/basic/date/DateFieldTest.js +21 -96
  123. package/dist-esm/tests/basic/date/DateFieldTest.pack.js +57 -0
  124. package/dist-esm/tests/basic/drop-down/DropDownTest.js +25 -19
  125. package/dist-esm/tests/basic/drop-down/DropDownTest.pack.js +52 -0
  126. package/dist-esm/tests/basic/drop-down-input/DropDownTest.js +32 -32
  127. package/dist-esm/tests/basic/drop-down-input/DropDownTest.pack.js +54 -0
  128. package/dist-esm/tests/basic/expander/ExpanderMenuTest.js +20 -14
  129. package/dist-esm/tests/basic/expander/ExpanderMenuTest.pack.js +38 -0
  130. package/dist-esm/tests/basic/expander/ExpanderTest.js +11 -12
  131. package/dist-esm/tests/basic/expander/ExpanderTest.pack.js +38 -0
  132. package/dist-esm/tests/basic/form2/Form2Test.js +26 -24
  133. package/dist-esm/tests/basic/form2/Form2Test.pack.js +46 -0
  134. package/dist-esm/tests/basic/limited-text/LimitedTextTest.js +14 -11
  135. package/dist-esm/tests/basic/limited-text/LimitedTextTest.pack.js +38 -0
  136. package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.js +14 -14
  137. package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.pack.js +38 -0
  138. package/dist-esm/tests/basic/repeater/DragDropRepater.js +30 -12
  139. package/dist-esm/tests/basic/repeater/DragDropRepater.pack.js +51 -0
  140. package/dist-esm/tests/basic/repeater/RepeaterTest.js +45 -35
  141. package/dist-esm/tests/basic/repeater/RepeaterTest.pack.js +52 -0
  142. package/dist-esm/tests/basic/swipe/SwipeTest.js +13 -13
  143. package/dist-esm/tests/basic/swipe/SwipeTest.pack.js +52 -0
  144. package/dist-esm/tests/basic/switch-test/SwitchTest.js +8 -10
  145. package/dist-esm/tests/basic/switch-test/SwitchTest.pack.js +38 -0
  146. package/dist-esm/tests/basic/title-editor/TitleEditorTest.js +8 -9
  147. package/dist-esm/tests/basic/title-editor/TitleEditorTest.pack.js +38 -0
  148. package/dist-esm/tests/basic/tooltip/TooltipTest.js +30 -24
  149. package/dist-esm/tests/basic/tooltip/TooltipTest.pack.js +52 -0
  150. package/dist-esm/tests/basic/typewriter/TypeWriter.js +10 -9
  151. package/dist-esm/tests/basic/typewriter/TypeWriter.pack.js +39 -0
  152. package/dist-esm/tests/basic/video/AtomVideoTest.js +13 -10
  153. package/dist-esm/tests/basic/video/AtomVideoTest.pack.js +38 -0
  154. package/dist-esm/tests/basic/zoom/ZoomViewTest.js +13 -13
  155. package/dist-esm/tests/basic/zoom/ZoomViewTest.pack.js +38 -0
  156. package/dist-esm/tests/check-box-list/CheckBoxListSample.js +13 -12
  157. package/dist-esm/tests/check-box-list/CheckBoxListSample.pack.js +52 -0
  158. package/dist-esm/tests/data-grid/GridTestViewModel.js +203 -227
  159. package/dist-esm/tests/form/CustomHelp.js +6 -9
  160. package/dist-esm/tests/form/FormViewModel.js +21 -28
  161. package/dist-esm/tests/html-editor/HtmlEditorTest.js +7 -37
  162. package/dist-esm/tests/html-editor/HtmlEditorTest.pack.js +83 -0
  163. package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.js +9 -38
  164. package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.pack.js +85 -0
  165. package/dist-esm/tests/mask/MaskedInputTest.js +11 -12
  166. package/dist-esm/tests/mask/MaskedInputTest.pack.js +38 -0
  167. package/dist-esm/tests/mobile-app/DesktopAppTest.js +8 -9
  168. package/dist-esm/tests/mobile-app/DesktopAppTest.pack.js +60 -0
  169. package/dist-esm/tests/mobile-app/MobileAppTest.js +64 -53
  170. package/dist-esm/tests/mobile-app/MobileAppTest.pack.js +55 -0
  171. package/dist-esm/tests/pop-over/PopOverTest.js +37 -77
  172. package/dist-esm/tests/switch/SwitchTest.js +9 -8
  173. package/dist-esm/tests/toggle-view/ToggleViewTest.js +15 -22
  174. package/dist-esm/tests/toggle-view/ToggleViewTest.pack.js +45 -0
  175. package/dist-esm/toggle-view/AtomToggleView.js +77 -73
  176. package/dist-esm/tsconfig.esm.tsbuildinfo +1 -1
  177. package/package.json +3 -3
@@ -28,176 +28,176 @@ import Unlink from "./commands/Unlink.js";
28
28
  import UnorderedList from "./commands/UnorderedList.js";
29
29
  import Toolbar from "./commands/Toolbar.js";
30
30
  export { default as Toolbar } from "./commands/Toolbar.js";
31
- import "../styles/atom-html-editor.global.css";
31
+ ESMPack.installStyleSheet(import.meta.resolve("../styles/atom-html-editor.global.css"));
32
32
  const link = document.createElement("link");
33
33
  link.href = "https://cdn.jsdelivr.net/npm/remixicon@2.5.0/fonts/remixicon.css";
34
34
  link.rel = "preload";
35
35
  link.as = "style";
36
36
  link.onload = () => {
37
- link.onload = null;
38
- link.rel = "stylesheet";
37
+ link.onload = null;
38
+ link.rel = "stylesheet";
39
39
  };
40
40
  document.head.appendChild(link);
41
41
  function preventLinkClick(e, editor, doc) {
42
- let target = e.target;
43
- const body = doc.body;
44
- while (target) {
45
- if (target.getAttribute("data-prompt")) {
46
- break;
47
- }
48
- if (target === body) {
49
- break;
50
- }
51
- if (target.isContentEditable) {
52
- editor.dispatchEvent(new MouseEvent("click", {
53
- bubbles: true,
54
- cancelable: true
55
- }));
56
- return;
57
- }
58
- if (target.tagName === "A") {
59
- e.preventDefault();
60
- }
61
- target = target.parentElement;
42
+ let target = e.target;
43
+ const body = doc.body;
44
+ while (target) {
45
+ if (target.getAttribute("data-prompt")) {
46
+ break;
62
47
  }
63
- target = e.target;
64
- const originalTarget = target;
65
- const data = new Proxy(originalTarget, {
66
- get(target, p) {
67
- if (typeof p !== "string") {
68
- return;
69
- }
70
- while (target) {
71
- const value = target.dataset[p];
72
- if (value !== void 0) {
73
- return value;
74
- }
75
- target = target.parentElement;
76
- }
77
- }
78
- });
79
- editor.dispatchEvent(new CustomEvent("editorClick", {
80
- detail: {
81
- target,
82
- data
83
- },
84
- bubbles: true,
85
- cancelable: true
86
- }));
87
- editor.dispatchEvent(new MouseEvent("click", {
48
+ if (target === body) {
49
+ break;
50
+ }
51
+ if (target.isContentEditable) {
52
+ editor.dispatchEvent(new MouseEvent("click", {
88
53
  bubbles: true,
89
54
  cancelable: true
90
- }));
91
- }
92
- export default class AtomHtmlEditor extends AtomControl {
93
- get htmlContent() {
94
- try {
95
- return this.editor?.innerHTML ?? this.initialContent;
96
- }
97
- catch (ex) {
98
- console.warn(ex);
99
- }
55
+ }));
56
+ return;
100
57
  }
101
- set htmlContent(v) {
102
- if (this.editor) {
103
- this.editor.innerHTML = v;
104
- }
105
- else {
106
- this.initialContent = v;
58
+ if (target.tagName === "A") {
59
+ e.preventDefault();
60
+ }
61
+ target = target.parentElement;
62
+ }
63
+ target = e.target;
64
+ const originalTarget = target;
65
+ const data = new Proxy(originalTarget, {
66
+ get(target, p) {
67
+ if (typeof p !== "string") {
68
+ return;
69
+ }
70
+ while (target) {
71
+ const value = target.dataset[p];
72
+ if (value !== void 0) {
73
+ return value;
107
74
  }
108
- AtomBinder.refreshValue(this, "htmlContent");
75
+ target = target.parentElement;
76
+ }
109
77
  }
110
- insertImage(s, e) {
111
- return showImageDialog(s, e);
78
+ });
79
+ editor.dispatchEvent(new CustomEvent("editorClick", {
80
+ detail: {
81
+ target,
82
+ data
83
+ },
84
+ bubbles: true,
85
+ cancelable: true
86
+ }));
87
+ editor.dispatchEvent(new MouseEvent("click", {
88
+ bubbles: true,
89
+ cancelable: true
90
+ }));
91
+ }
92
+ export default class AtomHtmlEditor extends AtomControl {
93
+ get htmlContent() {
94
+ try {
95
+ return this.editor?.innerHTML ?? this.initialContent;
96
+ } catch (ex) {
97
+ console.warn(ex);
112
98
  }
113
- executeCommand(cmd, showUI, value) {
114
- const r = this.editorDocument.execCommand(cmd, showUI, value);
115
- setTimeout(() => this.version++, 1);
116
- return r;
99
+ }
100
+ set htmlContent(v) {
101
+ if (this.editor) {
102
+ this.editor.innerHTML = v;
103
+ } else {
104
+ this.initialContent = v;
117
105
  }
118
- queryCommandState(cmd, ...a) {
119
- return this.editorDocument.queryCommandState(cmd);
106
+ AtomBinder.refreshValue(this, "htmlContent");
107
+ }
108
+ insertImage(s, e) {
109
+ return showImageDialog(s, e);
110
+ }
111
+ executeCommand(cmd, showUI, value) {
112
+ const r = this.editorDocument.execCommand(cmd, showUI, value);
113
+ setTimeout(() => this.version++, 1);
114
+ return r;
115
+ }
116
+ queryCommandState(cmd, ...a) {
117
+ return this.editorDocument.queryCommandState(cmd);
118
+ }
119
+ getStyle(name, v) {
120
+ try {
121
+ const node = this.editorWindow.getSelection().getRangeAt(0);
122
+ const e = node.startContainer.parentElement;
123
+ return this.editorWindow.getComputedStyle(e)[name];
124
+ } catch (ex) {
125
+ return null;
120
126
  }
121
- getStyle(name, v) {
122
- try {
123
- const node = this.editorWindow.getSelection().getRangeAt(0);
124
- const e = node.startContainer.parentElement;
125
- return this.editorWindow.getComputedStyle(e)[name];
126
- }
127
- catch (ex) {
128
- return null;
129
- }
127
+ }
128
+ onPropertyChanged(name) {
129
+ super.onPropertyChanged(name);
130
+ if (name === "tags") {
131
+ this.setupTags();
130
132
  }
131
- onPropertyChanged(name) {
132
- super.onPropertyChanged(name);
133
- if (name === "tags") {
134
- this.setupTags();
135
- }
133
+ }
134
+ setupTags() {
135
+ const doc = this.editorDocument;
136
+ if (!doc) {
137
+ return;
136
138
  }
137
- setupTags() {
138
- const doc = this.editorDocument;
139
- if (!doc) {
140
- return;
141
- }
142
- if (Array.isArray(this.tags)) {
143
- for (const { name, style } of this.tags) {
144
- if (style) {
145
- const styleElement = doc.createElement("style");
146
- styleElement.textContent = `*[data-command=${name}] {
139
+ if (Array.isArray(this.tags)) {
140
+ for (const {
141
+ name,
142
+ style
143
+ } of this.tags) {
144
+ if (style) {
145
+ const styleElement = doc.createElement("style");
146
+ styleElement.textContent = `*[data-command=${name}] {
147
147
  ${style.toStyleSheet()}
148
148
  }`;
149
- doc.head.appendChild(styleElement);
150
- }
151
- }
149
+ doc.head.appendChild(styleElement);
152
150
  }
151
+ }
153
152
  }
154
- preCreate() {
155
- this.version = 1;
156
- this.files = [];
157
- this.runAfterInit(() => {
158
- this.setup();
159
- });
160
- this.element.classList.add("atom-control-html-editor");
161
- this.element.classList.add("html-editor");
153
+ }
154
+ preCreate() {
155
+ this.version = 1;
156
+ this.files = [];
157
+ this.runAfterInit(() => {
158
+ this.setup();
159
+ });
160
+ this.element.classList.add("atom-control-html-editor");
161
+ this.element.classList.add("html-editor");
162
+ }
163
+ onPasteEvent(e) {
164
+ if (!e.clipboardData.types.find(x => x === "text/html")) {
165
+ return;
162
166
  }
163
- onPasteEvent(e) {
164
- if (!e.clipboardData.types.find((x) => x === "text/html")) {
165
- return;
167
+ const d = e.clipboardData.getData("text/plain");
168
+ if (d) {
169
+ const s = window.getSelection();
170
+ const r = s.getRangeAt(0);
171
+ let last;
172
+ const tags = [];
173
+ for (const iterator of d.split("\n")) {
174
+ const text = iterator.trim();
175
+ if (!text) {
176
+ continue;
166
177
  }
167
- const d = e.clipboardData.getData("text/plain");
168
- if (d) {
169
- const s = window.getSelection();
170
- const r = s.getRangeAt(0);
171
- let last;
172
- const tags = [];
173
- for (const iterator of d.split("\n")) {
174
- const text = iterator.trim();
175
- if (!text) {
176
- continue;
177
- }
178
- last = document.createElement("p");
179
- last.innerText = iterator;
180
- tags.push(last);
181
- }
182
- while (tags.length) {
183
- r.insertNode(tags.pop());
184
- }
185
- r.setStartAfter(last);
186
- }
187
- e.preventDefault();
188
- }
189
- onInputEvent(e) {
190
- console.log(e);
178
+ last = document.createElement("p");
179
+ last.innerText = iterator;
180
+ tags.push(last);
181
+ }
182
+ while (tags.length) {
183
+ r.insertNode(tags.pop());
184
+ }
185
+ r.setStartAfter(last);
191
186
  }
192
- setup() {
193
- const frame = this.element.getElementsByTagName("iframe")[0];
194
- const doc = frame.contentWindow.document;
195
- doc.open();
196
- const baseUrl = `${location.protocol}//${location.host}`;
197
- doc.writeln(`<base href="${baseUrl}"></base><div id="editor"><p>&nbsp;</p></div>`);
198
- doc.close();
199
- const style = doc.createElement("style");
200
- style.textContent = `body {
187
+ e.preventDefault();
188
+ }
189
+ onInputEvent(e) {
190
+ console.log(e);
191
+ }
192
+ setup() {
193
+ const frame = this.element.getElementsByTagName("iframe")[0];
194
+ const doc = frame.contentWindow.document;
195
+ doc.open();
196
+ const baseUrl = `${location.protocol}//${location.host}`;
197
+ doc.writeln(`<base href="${baseUrl}"></base><div id="editor"><p>&nbsp;</p></div>`);
198
+ doc.close();
199
+ const style = doc.createElement("style");
200
+ style.textContent = `body {
201
201
  font-family: arial,sans-serif
202
202
  }
203
203
  #editor {
@@ -207,131 +207,106 @@ export default class AtomHtmlEditor extends AtomControl {
207
207
  background: yellow
208
208
  }
209
209
  `;
210
- doc.head.appendChild(style);
211
- doc.body.addEventListener("click", (e) => preventLinkClick(e, this.element, doc));
212
- this.editor = doc.getElementById("editor");
213
- this.editor.contentEditable = "true";
214
- this.editor.innerHTML = this.initialContent ?? "";
215
- doc.execCommand("styleWithCSS");
216
- doc.execCommand("insertBrOnReturn");
217
- const updateVersion = () => setTimeout(() => {
218
- this.version++;
219
- AtomBinder.refreshValue(this, "htmlContent");
220
- this.element.dispatchEvent(new CustomEvent("documentUpdated", {
221
- detail: this.editor
222
- }));
223
- this.documentUpdated(this.editor);
224
- }, 1);
225
- this.editor.addEventListener("click", updateVersion);
226
- this.editor.addEventListener("keydown", updateVersion);
227
- this.editor.addEventListener("keypress", updateVersion);
228
- this.editor.addEventListener("input", updateVersion);
229
- this.editorWindow = frame.contentWindow;
230
- this.editorDocument = doc;
231
- updateVersion();
232
- this.documentCreated(this.editor);
233
- this.element.dispatchEvent(new CustomEvent("documentCreated", {
234
- detail: this.editor
235
- }));
236
- this.registerDisposable({
237
- dispose: () => {
238
- this.editor.removeEventListener("click", updateVersion);
239
- this.editor.removeEventListener("keydown", updateVersion);
240
- this.editor.removeEventListener("keypress", updateVersion);
241
- this.editor.removeEventListener("input", updateVersion);
242
- }
243
- });
244
- this.bindEvent(this.element, "editorClick", (ce) => {
245
- const { detail: { data, target } } = ce;
246
- if (data.prompt) {
247
- const element = target;
248
- const result = prompt("Enter " + (data.promptTitle ?? data.prompt), data.promptDefault);
249
- if (result) {
250
- const replace = (data.replace ?? "textContent").split(",").map((x) => x.trim());
251
- for (const iterator of replace) {
252
- const template = element.getAttribute("data-" + iterator + "-template") || element.getAttribute("data-template");
253
- if (template) {
254
- element[iterator] = template.replace(data.prompt, result);
255
- }
256
- else {
257
- element[iterator] = result;
258
- }
259
- }
260
- }
261
- return;
262
- }
263
- if (this.tags) {
264
- for (const { name, handler } of this.tags) {
265
- if (name === data.command || name === data.clickEvent) {
266
- handler(ce);
267
- }
268
- }
210
+ doc.head.appendChild(style);
211
+ doc.body.addEventListener("click", e => preventLinkClick(e, this.element, doc));
212
+ this.editor = doc.getElementById("editor");
213
+ this.editor.contentEditable = "true";
214
+ this.editor.innerHTML = this.initialContent ?? "";
215
+ doc.execCommand("styleWithCSS");
216
+ doc.execCommand("insertBrOnReturn");
217
+ const updateVersion = () => setTimeout(() => {
218
+ this.version++;
219
+ AtomBinder.refreshValue(this, "htmlContent");
220
+ this.element.dispatchEvent(new CustomEvent("documentUpdated", {
221
+ detail: this.editor
222
+ }));
223
+ this.documentUpdated(this.editor);
224
+ }, 1);
225
+ this.editor.addEventListener("click", updateVersion);
226
+ this.editor.addEventListener("keydown", updateVersion);
227
+ this.editor.addEventListener("keypress", updateVersion);
228
+ this.editor.addEventListener("input", updateVersion);
229
+ this.editorWindow = frame.contentWindow;
230
+ this.editorDocument = doc;
231
+ updateVersion();
232
+ this.documentCreated(this.editor);
233
+ this.element.dispatchEvent(new CustomEvent("documentCreated", {
234
+ detail: this.editor
235
+ }));
236
+ this.registerDisposable({
237
+ dispose: () => {
238
+ this.editor.removeEventListener("click", updateVersion);
239
+ this.editor.removeEventListener("keydown", updateVersion);
240
+ this.editor.removeEventListener("keypress", updateVersion);
241
+ this.editor.removeEventListener("input", updateVersion);
242
+ }
243
+ });
244
+ this.bindEvent(this.element, "editorClick", ce => {
245
+ const {
246
+ detail: {
247
+ data,
248
+ target
249
+ }
250
+ } = ce;
251
+ if (data.prompt) {
252
+ const element = target;
253
+ const result = prompt("Enter " + (data.promptTitle ?? data.prompt), data.promptDefault);
254
+ if (result) {
255
+ const replace = (data.replace ?? "textContent").split(",").map(x => x.trim());
256
+ for (const iterator of replace) {
257
+ const template = element.getAttribute("data-" + iterator + "-template") || element.getAttribute("data-template");
258
+ if (template) {
259
+ element[iterator] = template.replace(data.prompt, result);
260
+ } else {
261
+ element[iterator] = result;
269
262
  }
270
- });
271
- this.setupTags();
272
- }
273
- documentCreated(e) {
274
- }
275
- documentUpdated(e) {
276
- }
277
- render(node, e, creator) {
278
- this.render = super.render;
279
- if (!node.children || node.children.length === 0) {
280
- node.children[0] = XNode.create(Toolbar, null,
281
- XNode.create(Bold, null),
282
- XNode.create(Italic, null),
283
- XNode.create(Underline, null),
284
- XNode.create(StrikeThrough, null),
285
- XNode.create(Align, null),
286
- XNode.create(Separator, null),
287
- XNode.create(Headings, null),
288
- XNode.create(ChangeColor, null),
289
- XNode.create(HorizontalRule, null),
290
- XNode.create(Separator, null),
291
- XNode.create(ChangeFont, null),
292
- XNode.create(ChangeFontSize, null),
293
- XNode.create(Separator, null),
294
- XNode.create(NumberedList, null),
295
- XNode.create(UnorderedList, null),
296
- XNode.create(IndentLess, null),
297
- XNode.create(IndentMore, null),
298
- XNode.create(Separator, null),
299
- XNode.create(AddImage, null),
300
- XNode.create(AttachFile, null),
301
- XNode.create(Separator, null),
302
- XNode.create(AddLink, null),
303
- XNode.create(Unlink, null),
304
- XNode.create(RemoveFormat, null),
305
- XNode.create(Separator, null),
306
- XNode.create(Source, null));
263
+ }
307
264
  }
308
- super.render(XNode.create("div", { ...node.attributes },
309
- ...node.children,
310
- XNode.create(AtomRepeater, { class: "files", "event-item-delete": (ce) => this.files.remove(ce.detail), items: Bind.oneWay(() => this.files), itemRenderer: (file) => XNode.create("div", { class: "file" },
311
- XNode.create("i", { class: "ri-attachment-2" }),
312
- XNode.create("label", { text: file.name }),
313
- XNode.create("i", { "data-click-event": "item-delete", class: "ri-close-circle-fill" })) }),
314
- XNode.create("iframe", { class: "editor-frame" })));
265
+ return;
266
+ }
267
+ if (this.tags) {
268
+ for (const {
269
+ name,
270
+ handler
271
+ } of this.tags) {
272
+ if (name === data.command || name === data.clickEvent) {
273
+ handler(ce);
274
+ }
275
+ }
276
+ }
277
+ });
278
+ this.setupTags();
279
+ }
280
+ documentCreated(e) {}
281
+ documentUpdated(e) {}
282
+ render(node, e, creator) {
283
+ this.render = super.render;
284
+ if (!node.children || node.children.length === 0) {
285
+ node.children[0] = XNode.create(Toolbar, null, XNode.create(Bold, null), XNode.create(Italic, null), XNode.create(Underline, null), XNode.create(StrikeThrough, null), XNode.create(Align, null), XNode.create(Separator, null), XNode.create(Headings, null), XNode.create(ChangeColor, null), XNode.create(HorizontalRule, null), XNode.create(Separator, null), XNode.create(ChangeFont, null), XNode.create(ChangeFontSize, null), XNode.create(Separator, null), XNode.create(NumberedList, null), XNode.create(UnorderedList, null), XNode.create(IndentLess, null), XNode.create(IndentMore, null), XNode.create(Separator, null), XNode.create(AddImage, null), XNode.create(AttachFile, null), XNode.create(Separator, null), XNode.create(AddLink, null), XNode.create(Unlink, null), XNode.create(RemoveFormat, null), XNode.create(Separator, null), XNode.create(Source, null));
315
286
  }
287
+ super.render(XNode.create("div", {
288
+ ...node.attributes
289
+ }, ...node.children, XNode.create(AtomRepeater, {
290
+ class: "files",
291
+ "event-item-delete": ce => this.files.remove(ce.detail),
292
+ items: Bind.oneWay(() => this.files),
293
+ itemRenderer: file => XNode.create("div", {
294
+ class: "file"
295
+ }, XNode.create("i", {
296
+ class: "ri-attachment-2"
297
+ }), XNode.create("label", {
298
+ text: file.name
299
+ }), XNode.create("i", {
300
+ "data-click-event": "item-delete",
301
+ class: "ri-close-circle-fill"
302
+ }))
303
+ }), XNode.create("iframe", {
304
+ class: "editor-frame"
305
+ })));
306
+ }
316
307
  }
317
- __decorate([
318
- BindableProperty,
319
- __metadata("design:type", String)
320
- ], AtomHtmlEditor.prototype, "content", void 0);
321
- __decorate([
322
- BindableProperty,
323
- __metadata("design:type", Array)
324
- ], AtomHtmlEditor.prototype, "header", void 0);
325
- __decorate([
326
- BindableProperty,
327
- __metadata("design:type", Number)
328
- ], AtomHtmlEditor.prototype, "version", void 0);
329
- __decorate([
330
- BindableProperty,
331
- __metadata("design:type", Array)
332
- ], AtomHtmlEditor.prototype, "files", void 0);
333
- __decorate([
334
- BindableProperty,
335
- __metadata("design:type", Array)
336
- ], AtomHtmlEditor.prototype, "tags", void 0);
337
- //# sourceMappingURL=AtomHtmlEditor.js.map
308
+ __decorate([BindableProperty, __metadata("design:type", String)], AtomHtmlEditor.prototype, "content", void 0);
309
+ __decorate([BindableProperty, __metadata("design:type", Array)], AtomHtmlEditor.prototype, "header", void 0);
310
+ __decorate([BindableProperty, __metadata("design:type", Number)], AtomHtmlEditor.prototype, "version", void 0);
311
+ __decorate([BindableProperty, __metadata("design:type", Array)], AtomHtmlEditor.prototype, "files", void 0);
312
+ __decorate([BindableProperty, __metadata("design:type", Array)], AtomHtmlEditor.prototype, "tags", void 0);
@@ -1,6 +1,8 @@
1
1
  const HtmlEditorCommands = {
2
- bold({ range, check, update }) {
3
- }
2
+ bold({
3
+ range,
4
+ check,
5
+ update
6
+ }) {}
4
7
  };
5
- export default HtmlEditorCommands;
6
- //# sourceMappingURL=HtmlEditorCommands.js.map
8
+ export default HtmlEditorCommands;