chuijs 4.0.2 → 4.0.4

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 (292) hide show
  1. package/CHANGELOG.md +597 -0
  2. package/README.md +43 -644
  3. package/framework/appLayout/default/chui_app_layout.js +602 -496
  4. package/framework/appLayout/default/global_style.css +288 -97
  5. package/framework/appLayout/default/main_theme_style.css +188 -101
  6. package/framework/components/chui_accordion/accordion.js +38 -35
  7. package/framework/components/chui_accordion/styles.css +13 -12
  8. package/framework/components/chui_action_sheet/action_sheet.js +93 -64
  9. package/framework/components/chui_action_sheet/styles.css +12 -5
  10. package/framework/components/chui_actions_bar/actions_bar.js +338 -0
  11. package/framework/components/chui_actions_bar/styles.css +139 -0
  12. package/framework/components/chui_affix/affix.js +16 -11
  13. package/framework/components/chui_affix/styles.css +5 -0
  14. package/framework/components/chui_alert/alert.js +34 -19
  15. package/framework/components/chui_alert/styles.css +7 -0
  16. package/framework/components/chui_avatar/avatar.js +36 -35
  17. package/framework/components/chui_avatar/styles.css +1 -1
  18. package/framework/components/chui_avatar_group/avatar_group.js +25 -23
  19. package/framework/components/chui_avatar_group/styles.css +1 -1
  20. package/framework/components/chui_backtop/backtop.js +60 -21
  21. package/framework/components/chui_backtop/styles.css +21 -0
  22. package/framework/components/chui_badge/badge.js +30 -28
  23. package/framework/components/chui_badge/styles.css +6 -6
  24. package/framework/components/chui_banner/banner.js +222 -0
  25. package/framework/components/chui_banner/styles.css +170 -0
  26. package/framework/components/chui_breadcrumb/breadcrumb.js +15 -13
  27. package/framework/components/chui_breadcrumb/styles.css +1 -1
  28. package/framework/components/chui_button/button.js +52 -36
  29. package/framework/components/chui_button/styles.css +7 -7
  30. package/framework/components/chui_calendar/calendar.js +18 -16
  31. package/framework/components/chui_card/card.js +52 -32
  32. package/framework/components/chui_card_scroll/card_scroll.js +169 -0
  33. package/framework/components/chui_card_scroll/styles.css +86 -0
  34. package/framework/components/chui_chat/chat.js +140 -79
  35. package/framework/components/chui_chat/styles.css +18 -7
  36. package/framework/components/chui_clipboard_history/clipboard_history.js +53 -39
  37. package/framework/components/chui_clipboard_history/styles.css +13 -9
  38. package/framework/components/chui_code/code.js +10 -10
  39. package/framework/components/chui_code/styles.css +4 -4
  40. package/framework/components/chui_code_editor/code_editor.js +73 -57
  41. package/framework/components/chui_code_editor/styles.css +6 -5
  42. package/framework/components/chui_command_palette/command_palette.js +87 -64
  43. package/framework/components/chui_command_palette/styles.css +5 -5
  44. package/framework/components/chui_console/console.js +13 -13
  45. package/framework/components/chui_console/styles.css +6 -3
  46. package/framework/components/chui_content_block/content_block.js +35 -21
  47. package/framework/components/chui_content_block/styles.css +2 -2
  48. package/framework/components/chui_context_menu/context_menu.js +171 -58
  49. package/framework/components/chui_context_menu/styles.css +82 -8
  50. package/framework/components/chui_custom_element/custom_element.js +25 -18
  51. package/framework/components/chui_data_grid/data_grid.js +633 -471
  52. package/framework/components/chui_data_grid/styles.css +24 -22
  53. package/framework/components/chui_descriptions/descriptions.js +34 -17
  54. package/framework/components/chui_descriptions/styles.css +1 -1
  55. package/framework/components/chui_details/details.js +42 -36
  56. package/framework/components/chui_details/styles.css +12 -11
  57. package/framework/components/chui_diff_viewer/diff_viewer.js +172 -147
  58. package/framework/components/chui_diff_viewer/styles.css +10 -10
  59. package/framework/components/chui_divider/divider.js +19 -17
  60. package/framework/components/chui_divider/styles.css +2 -2
  61. package/framework/components/chui_drawer/drawer.js +63 -38
  62. package/framework/components/chui_drawer/styles.css +18 -4
  63. package/framework/components/chui_drop_zone/drop_zone.js +37 -27
  64. package/framework/components/chui_drop_zone/styles.css +10 -6
  65. package/framework/components/chui_empty_state/empty_state.js +20 -15
  66. package/framework/components/chui_fieldset/fieldset.js +40 -23
  67. package/framework/components/chui_fieldset/styles.css +6 -6
  68. package/framework/components/chui_file_explorer/file_explorer.js +260 -189
  69. package/framework/components/chui_file_explorer/styles.css +8 -7
  70. package/framework/components/chui_form/form.js +40 -28
  71. package/framework/components/chui_form/styles.css +1 -1
  72. package/framework/components/chui_gantt/gantt.js +102 -78
  73. package/framework/components/chui_gantt/styles.css +5 -5
  74. package/framework/components/chui_graphs/graphs.js +376 -239
  75. package/framework/components/chui_graphs/styles.css +27 -6
  76. package/framework/components/chui_hero/hero.js +98 -37
  77. package/framework/components/chui_hero/styles.css +176 -7
  78. package/framework/components/chui_html_block/html_block.js +8 -8
  79. package/framework/components/chui_html_block/styles.css +3 -3
  80. package/framework/components/chui_hx/hx.js +3 -3
  81. package/framework/components/chui_hx/styles.css +13 -6
  82. package/framework/components/chui_icons/icons.js +2115 -2115
  83. package/framework/components/chui_icons/styles.css +4 -3
  84. package/framework/components/chui_inputs/chui_check_box/check_box.js +31 -19
  85. package/framework/components/chui_inputs/chui_check_box/styles.css +30 -21
  86. package/framework/components/chui_inputs/chui_chips/chips.js +141 -70
  87. package/framework/components/chui_inputs/chui_chips/styles.css +32 -7
  88. package/framework/components/chui_inputs/chui_color_picker/color_picker.js +55 -38
  89. package/framework/components/chui_inputs/chui_color_picker/styles.css +7 -7
  90. package/framework/components/chui_inputs/chui_combo_box/combo_box.js +127 -109
  91. package/framework/components/chui_inputs/chui_combo_box/styles.css +23 -21
  92. package/framework/components/chui_inputs/chui_date/date.js +161 -127
  93. package/framework/components/chui_inputs/chui_date/styles.css +20 -19
  94. package/framework/components/chui_inputs/chui_date_range/date_range.js +61 -50
  95. package/framework/components/chui_inputs/chui_date_range/styles.css +3 -3
  96. package/framework/components/chui_inputs/chui_datetime/datetime.js +47 -39
  97. package/framework/components/chui_inputs/chui_datetime/styles.css +3 -3
  98. package/framework/components/chui_inputs/chui_email/email.js +48 -36
  99. package/framework/components/chui_inputs/chui_email/styles.css +11 -11
  100. package/framework/components/chui_inputs/chui_file/file.js +71 -44
  101. package/framework/components/chui_inputs/chui_file/styles.css +23 -19
  102. package/framework/components/chui_inputs/chui_hotkey/hotkey.js +101 -76
  103. package/framework/components/chui_inputs/chui_hotkey/styles.css +6 -6
  104. package/framework/components/chui_inputs/chui_masked/masked.js +83 -72
  105. package/framework/components/chui_inputs/chui_masked/styles.css +5 -5
  106. package/framework/components/chui_inputs/chui_mention/mention.js +87 -40
  107. package/framework/components/chui_inputs/chui_mention/styles.css +14 -8
  108. package/framework/components/chui_inputs/chui_multi_combo_box/multi_combo_box.js +242 -212
  109. package/framework/components/chui_inputs/chui_multi_combo_box/styles.css +23 -15
  110. package/framework/components/chui_inputs/chui_number/number.js +84 -70
  111. package/framework/components/chui_inputs/chui_number/styles.css +13 -13
  112. package/framework/components/chui_inputs/chui_otp/otp.js +71 -62
  113. package/framework/components/chui_inputs/chui_otp/styles.css +5 -5
  114. package/framework/components/chui_inputs/chui_password/password.js +72 -56
  115. package/framework/components/chui_inputs/chui_password/styles.css +15 -15
  116. package/framework/components/chui_inputs/chui_radio_button/radio_button.js +37 -25
  117. package/framework/components/chui_inputs/chui_radio_button/styles.css +22 -22
  118. package/framework/components/chui_inputs/chui_rating/rating.js +54 -50
  119. package/framework/components/chui_inputs/chui_rating/styles.css +3 -3
  120. package/framework/components/chui_inputs/chui_select_box/select_box.js +132 -108
  121. package/framework/components/chui_inputs/chui_select_box/styles.css +21 -21
  122. package/framework/components/chui_inputs/chui_slider/slider.js +41 -38
  123. package/framework/components/chui_inputs/chui_slider/styles.css +7 -5
  124. package/framework/components/chui_inputs/chui_text/styles.css +14 -14
  125. package/framework/components/chui_inputs/chui_text/text.js +69 -52
  126. package/framework/components/chui_inputs/chui_text_area/styles.css +14 -14
  127. package/framework/components/chui_inputs/chui_text_area/text_area.js +59 -36
  128. package/framework/components/chui_inputs/chui_time/styles.css +18 -20
  129. package/framework/components/chui_inputs/chui_time/time.js +71 -49
  130. package/framework/components/chui_inputs/chui_toggle/styles.css +13 -6
  131. package/framework/components/chui_inputs/chui_toggle/toggle.js +27 -27
  132. package/framework/components/chui_json_editor/json_editor.js +137 -127
  133. package/framework/components/chui_json_editor/styles.css +5 -5
  134. package/framework/components/chui_json_viewer/json_viewer.js +133 -114
  135. package/framework/components/chui_json_viewer/styles.css +9 -8
  136. package/framework/components/chui_kanban/kanban.js +78 -60
  137. package/framework/components/chui_kanban/styles.css +8 -4
  138. package/framework/components/chui_kbd/kbd.js +12 -10
  139. package/framework/components/chui_kbd/styles.css +1 -1
  140. package/framework/components/chui_label/label.js +31 -29
  141. package/framework/components/chui_label/styles.css +3 -3
  142. package/framework/components/chui_link/link.js +36 -29
  143. package/framework/components/chui_link/styles.css +11 -4
  144. package/framework/components/chui_list/list.js +42 -38
  145. package/framework/components/chui_list/styles.css +4 -3
  146. package/framework/components/chui_markdown_editor/markdown_editor.js +125 -109
  147. package/framework/components/chui_markdown_editor/styles.css +5 -5
  148. package/framework/components/chui_media/audio.js +457 -364
  149. package/framework/components/chui_media/audio_styles.css +74 -37
  150. package/framework/components/chui_media/image.js +99 -64
  151. package/framework/components/chui_media/image_compare.js +86 -55
  152. package/framework/components/chui_media/image_compare_styles.css +5 -5
  153. package/framework/components/chui_media/image_styles.css +4 -4
  154. package/framework/components/chui_media/video.js +264 -171
  155. package/framework/components/chui_media/video_styles.css +57 -24
  156. package/framework/components/chui_menu_bar/menu_bar.js +67 -65
  157. package/framework/components/chui_menu_bar/styles.css +14 -12
  158. package/framework/components/chui_message_bar/message_bar.js +551 -0
  159. package/framework/components/chui_message_bar/styles.css +248 -0
  160. package/framework/components/chui_modal/modal.js +81 -56
  161. package/framework/components/chui_modal/styles.css +3 -2
  162. package/framework/components/chui_notification/notification.js +107 -69
  163. package/framework/components/chui_notification/notification_download.js +28 -77
  164. package/framework/components/chui_notification/notification_download_card.js +115 -0
  165. package/framework/components/chui_notification/notification_download_progress.css +5 -4
  166. package/framework/components/chui_notification/notification_download_progress.js +73 -105
  167. package/framework/components/chui_notification/notification_update.js +44 -37
  168. package/framework/components/chui_notification/status_plate.css +3 -3
  169. package/framework/components/chui_notification/status_plate.js +2 -2
  170. package/framework/components/chui_notification/styles.css +6 -1
  171. package/framework/components/chui_notification/styles_download.css +2 -2
  172. package/framework/components/chui_notification/styles_update.css +3 -3
  173. package/framework/components/chui_org_chart/org_chart.js +101 -62
  174. package/framework/components/chui_org_chart/styles.css +2 -2
  175. package/framework/components/chui_pagination/pagination.js +65 -30
  176. package/framework/components/chui_pagination/styles.css +1 -1
  177. package/framework/components/chui_paragraph/paragraph.js +2 -2
  178. package/framework/components/chui_paragraph/styles.css +3 -3
  179. package/framework/components/chui_popover/popover.js +77 -50
  180. package/framework/components/chui_popover/styles.css +1 -1
  181. package/framework/components/chui_popups/popups.js +210 -181
  182. package/framework/components/chui_popups/styles.css +7 -7
  183. package/framework/components/chui_print_button/print_button.js +48 -33
  184. package/framework/components/chui_progress_bar/progress_bar.js +49 -19
  185. package/framework/components/chui_progress_bar/styles.css +6 -6
  186. package/framework/components/chui_progress_ring/progress_ring.js +32 -30
  187. package/framework/components/chui_progress_ring/styles.css +1 -1
  188. package/framework/components/chui_qrcode/qrcode.js +85 -41
  189. package/framework/components/chui_query_builder/query_builder.js +263 -170
  190. package/framework/components/chui_query_builder/styles.css +4 -4
  191. package/framework/components/chui_radio_group/radio_group.js +36 -26
  192. package/framework/components/chui_radio_group/styles.css +2 -2
  193. package/framework/components/chui_result/result.js +41 -31
  194. package/framework/components/chui_result/styles.css +3 -3
  195. package/framework/components/chui_scheduler/scheduler.js +126 -104
  196. package/framework/components/chui_scheduler/styles.css +11 -7
  197. package/framework/components/chui_screen_spinner/screen_spinner.js +167 -0
  198. package/framework/components/chui_screen_spinner/styles.css +49 -0
  199. package/framework/components/chui_segmented_control/segmented_control.js +90 -27
  200. package/framework/components/chui_segmented_control/styles.css +32 -6
  201. package/framework/components/chui_settings/settings.js +160 -87
  202. package/framework/components/chui_settings/styles.css +4 -4
  203. package/framework/components/chui_shortcut_help/shortcut_help.js +82 -61
  204. package/framework/components/chui_sidebar_nav/sidebar_nav.js +132 -53
  205. package/framework/components/chui_sidebar_nav/styles.css +9 -3
  206. package/framework/components/chui_skeleton/skeleton.js +29 -24
  207. package/framework/components/chui_slideshow/slideshow.js +122 -103
  208. package/framework/components/chui_slideshow/styles.css +22 -16
  209. package/framework/components/chui_spinner/spinner.js +17 -17
  210. package/framework/components/chui_spinner/styles.css +0 -1
  211. package/framework/components/chui_split_button/split_button.js +53 -30
  212. package/framework/components/chui_split_button/styles.css +22 -6
  213. package/framework/components/chui_splitter/splitter.js +46 -39
  214. package/framework/components/chui_splitter/styles.css +2 -2
  215. package/framework/components/chui_statistic/statistic.js +111 -84
  216. package/framework/components/chui_status_bar/status_bar.js +11 -9
  217. package/framework/components/chui_status_bar/styles.css +2 -2
  218. package/framework/components/chui_stepper/stepper.js +230 -54
  219. package/framework/components/chui_stepper/styles.css +79 -14
  220. package/framework/components/chui_sticky_bar/sticky_bar.js +53 -17
  221. package/framework/components/chui_sticky_bar/styles.css +11 -7
  222. package/framework/components/chui_tabs/chui_tabs.js +100 -46
  223. package/framework/components/chui_tabs/styles.css +43 -15
  224. package/framework/components/chui_text_editor/styles.css +24 -23
  225. package/framework/components/chui_text_editor/text_editor.js +103 -79
  226. package/framework/components/chui_text_editor/text_editor_panel.js +428 -367
  227. package/framework/components/chui_theme_toggle/theme_toggle.js +46 -25
  228. package/framework/components/chui_timeline/styles.css +3 -1
  229. package/framework/components/chui_timeline/timeline.js +14 -12
  230. package/framework/components/chui_toast_queue/styles.css +11 -11
  231. package/framework/components/chui_toast_queue/toast_queue.js +82 -73
  232. package/framework/components/chui_toolbar/styles.css +2 -2
  233. package/framework/components/chui_toolbar/toolbar.js +20 -13
  234. package/framework/components/chui_tooltip/styles.css +2 -2
  235. package/framework/components/chui_tooltip/tooltip.js +40 -27
  236. package/framework/components/chui_tour/styles.css +12 -7
  237. package/framework/components/chui_tour/tour.js +132 -98
  238. package/framework/components/chui_transfer/styles.css +8 -7
  239. package/framework/components/chui_transfer/transfer.js +143 -123
  240. package/framework/components/chui_tree_table/styles.css +4 -4
  241. package/framework/components/chui_tree_table/tree_table.js +88 -74
  242. package/framework/components/chui_tree_view/styles.css +14 -10
  243. package/framework/components/chui_tree_view/tree_view.js +298 -253
  244. package/framework/components/chui_user_bar/styles.css +145 -0
  245. package/framework/components/chui_user_bar/user_bar.js +402 -0
  246. package/framework/components/chui_user_list_bar/styles.css +173 -0
  247. package/framework/components/chui_user_list_bar/user_list_bar.js +485 -0
  248. package/framework/components/chui_watermark/watermark.js +41 -33
  249. package/framework/components/chui_webview/styles.css +2 -2
  250. package/framework/components/chui_webview/webview.js +64 -52
  251. package/framework/components/chui_write_bar/styles.css +172 -0
  252. package/framework/components/chui_write_bar/write_bar.js +320 -0
  253. package/framework/main_window.js +1234 -0
  254. package/framework/modules/chui_a11y/chui_a11y.js +153 -123
  255. package/framework/modules/chui_animations/animations.js +105 -43
  256. package/framework/modules/chui_animations/motion.js +120 -0
  257. package/framework/modules/chui_animations/styles.css +37 -4
  258. package/framework/modules/chui_bridge/preload.js +36 -25
  259. package/framework/modules/chui_functions.js +69 -63
  260. package/framework/modules/chui_highlight/chui_highlight.js +25 -22
  261. package/framework/modules/chui_highlight/styles.css +13 -10
  262. package/framework/modules/chui_i18n/chui_i18n.js +12 -10
  263. package/framework/modules/chui_i18n/locales/a11y.js +5 -5
  264. package/framework/modules/chui_i18n/locales/app_layout.js +5 -5
  265. package/framework/modules/chui_i18n/locales/calendar.js +3 -3
  266. package/framework/modules/chui_i18n/locales/common.js +3 -3
  267. package/framework/modules/chui_i18n/locales/data.js +36 -26
  268. package/framework/modules/chui_i18n/locales/editors.js +40 -13
  269. package/framework/modules/chui_i18n/locales/feedback.js +65 -3
  270. package/framework/modules/chui_i18n/locales/forms.js +8 -8
  271. package/framework/modules/chui_i18n/locales/graphics.js +8 -8
  272. package/framework/modules/chui_i18n/locales/media.js +4 -4
  273. package/framework/modules/chui_i18n/locales/navigation.js +12 -8
  274. package/framework/modules/chui_i18n/locales/validate.js +3 -3
  275. package/framework/modules/chui_json/chui_json.js +11 -11
  276. package/framework/modules/chui_layout/chui_layout.js +12 -10
  277. package/framework/modules/chui_logger/chui_logger.js +47 -28
  278. package/framework/modules/chui_page/page.js +39 -33
  279. package/framework/modules/chui_palette/palette.js +61 -0
  280. package/framework/modules/chui_qr/chui_qr.js +179 -88
  281. package/framework/modules/chui_scrollbar/chui_scrollbar.js +79 -68
  282. package/framework/modules/chui_scrollbar/styles.css +4 -2
  283. package/framework/modules/chui_services/chui_channels.js +27 -13
  284. package/framework/modules/chui_services/chui_services.js +47 -39
  285. package/framework/modules/chui_services/desktop.js +108 -101
  286. package/framework/modules/chui_sortable/chui_sortable.js +33 -28
  287. package/framework/modules/chui_validate/chui_validate.js +10 -7
  288. package/framework/tray_bar/chui_menu_items.js +136 -46
  289. package/index.d.ts +5046 -0
  290. package/index.js +199 -1254
  291. package/package.json +81 -68
  292. package/framework/components/telegram_bot/chui_telegram_bot.js +0 -184
@@ -1,54 +1,52 @@
1
- const {Icon, Icons} = require("../chui_icons/icons");
2
- const {makeKeyboardButton, RovingKeyboard} = require("../../modules/chui_a11y/chui_a11y");
3
- const {optionOr} = require("../../modules/chui_functions");
4
- const {Animation} = require("../../modules/chui_animations/animations");
5
- const {Dialog} = require("../chui_modal/modal");
6
- const {Button} = require("../chui_button/button");
7
- const {TextInput} = require("../chui_inputs/chui_text/text");
8
- const {Label} = require("../chui_label/label");
9
- const {ContentBlock} = require("../chui_content_block/content_block");
10
- const {Notification} = require("../chui_notification/notification");
11
- const {NumberInput} = require("../chui_inputs/chui_number/number");
12
- const {CheckBox} = require("../chui_inputs/chui_check_box/check_box");
13
- const {FileInput, AcceptTypes} = require("../chui_inputs/chui_file/file");
14
- const {I18n} = require("../../modules/chui_i18n/chui_i18n");
15
-
16
-
1
+ const { Icon, Icons } = require("../chui_icons/icons");
2
+ const { makeKeyboardButton, RovingKeyboard } = require("../../modules/chui_a11y/chui_a11y");
3
+ const { optionOr } = require("../../modules/chui_functions");
4
+ const { Animation } = require("../../modules/chui_animations/animations");
5
+ const { Dialog } = require("../chui_modal/modal");
6
+ const { Button } = require("../chui_button/button");
7
+ const { TextInput } = require("../chui_inputs/chui_text/text");
8
+ const { Label } = require("../chui_label/label");
9
+ const { ContentBlock } = require("../chui_content_block/content_block");
10
+ const { Notification } = require("../chui_notification/notification");
11
+ const { NumberInput } = require("../chui_inputs/chui_number/number");
12
+ const { CheckBox } = require("../chui_inputs/chui_check_box/check_box");
13
+ const { FileInput, AcceptTypes } = require("../chui_inputs/chui_file/file");
14
+ const { I18n } = require("../../modules/chui_i18n/chui_i18n");
17
15
 
18
16
  class Commands {
19
- static COPY = "copy"
20
- static CUT = "cut"
21
- static PASTE = "paste"
22
- static DELETE = "delete"
23
- static UNDO = "undo"
24
- static REDO = "redo"
17
+ static COPY = "copy";
18
+ static CUT = "cut";
19
+ static PASTE = "paste";
20
+ static DELETE = "delete";
21
+ static UNDO = "undo";
22
+ static REDO = "redo";
25
23
  //
26
- static BOLD = "bold"
27
- static ITALIC = "italic"
28
- static STRIKE_THROUGH = "strikeThrough"
29
- static UNDERLINE = "underline"
24
+ static BOLD = "bold";
25
+ static ITALIC = "italic";
26
+ static STRIKE_THROUGH = "strikeThrough";
27
+ static UNDERLINE = "underline";
30
28
  //
31
- static REMOVE_FORMAT = "removeFormat"
29
+ static REMOVE_FORMAT = "removeFormat";
32
30
  //
33
- static SUPER_SCRIPT = "superscript"
34
- static SUB_SCRIPT = "subscript"
31
+ static SUPER_SCRIPT = "superscript";
32
+ static SUB_SCRIPT = "subscript";
35
33
  //
36
- static JUSTIFY_LEFT = "justifyLeft"
37
- static JUSTIFY_RIGHT = "justifyRight"
38
- static JUSTIFY_CENTER = "justifyCenter"
39
- static JUSTIFY_FULL = "justifyFull"
34
+ static JUSTIFY_LEFT = "justifyLeft";
35
+ static JUSTIFY_RIGHT = "justifyRight";
36
+ static JUSTIFY_CENTER = "justifyCenter";
37
+ static JUSTIFY_FULL = "justifyFull";
40
38
  //
41
- static FORMAT_BLOCK = "formatBlock"
42
- static NONE = "none"
39
+ static FORMAT_BLOCK = "formatBlock";
40
+ static NONE = "none";
43
41
  // ITEMS
44
- static CREATE_LINK = "createLink"
45
- static UNLINK = "unlink"
46
- static INSERT_IMAGE = "insertImage"
47
- static INSERT_LINE_BREAK = "insertLineBreak"
48
- static INSERT_HTML = "insertHTML"
42
+ static CREATE_LINK = "createLink";
43
+ static UNLINK = "unlink";
44
+ static INSERT_IMAGE = "insertImage";
45
+ static INSERT_LINE_BREAK = "insertLineBreak";
46
+ static INSERT_HTML = "insertHTML";
49
47
  // LIST
50
- static INSERT_ORDERED_LIST = "insertOrderedList"
51
- static INSERT_UNORDERED_LIST = "insertUnorderedList"
48
+ static INSERT_ORDERED_LIST = "insertOrderedList";
49
+ static INSERT_UNORDERED_LIST = "insertUnorderedList";
52
50
  }
53
51
 
54
52
  /**
@@ -77,18 +75,30 @@ const COMMAND_LABELS = {
77
75
  copy: "editor.copy",
78
76
  cut: "editor.cut",
79
77
  paste: "editor.paste",
80
- delete: "editor.delete"
78
+ delete: "editor.delete",
81
79
  };
82
80
 
83
81
  class TextEditorButtons {
84
82
  #button = undefined;
85
- constructor(options = { icon: undefined, command: undefined, value: undefined, disableFocus: false, listener: () => {}, label: undefined }) {
86
- this.#button = document.createElement('chui_button_format');
83
+ constructor(
84
+ options = {
85
+ icon: undefined,
86
+ command: undefined,
87
+ value: undefined,
88
+ disableFocus: false,
89
+ listener: () => {},
90
+ label: undefined,
91
+ }
92
+ ) {
93
+ this.#button = document.createElement("chui_button_format");
87
94
  const glyph = new Icon(options.icon);
88
95
  // Иконка-лигатура — украшение: имя кнопки задаёт label или таблица команд
89
96
  glyph.set().setAttribute("aria-hidden", "true");
90
97
  this.#button.innerHTML = glyph.getHTML();
91
- const label = optionOr(options.label, COMMAND_LABELS[options.command] === undefined ? undefined : I18n.t(COMMAND_LABELS[options.command]));
98
+ const label = optionOr(
99
+ options.label,
100
+ COMMAND_LABELS[options.command] === undefined ? undefined : I18n.t(COMMAND_LABELS[options.command])
101
+ );
92
102
  if (label !== undefined) {
93
103
  this.#button.setAttribute("aria-label", label);
94
104
  this.#button.setAttribute("title", label);
@@ -97,11 +107,11 @@ class TextEditorButtons {
97
107
  makeKeyboardButton(this.#button);
98
108
  if (options.disableFocus) {
99
109
  this.#button.addEventListener("mousedown", () => {
100
- return false
101
- })
110
+ return false;
111
+ });
102
112
  }
103
113
  if (options.listener !== undefined) {
104
- this.#button.addEventListener("click", options.listener)
114
+ this.#button.addEventListener("click", options.listener);
105
115
  } else {
106
116
  this.#button.addEventListener("click", () => {
107
117
  if (options.value !== undefined) {
@@ -109,7 +119,7 @@ class TextEditorButtons {
109
119
  } else {
110
120
  document.execCommand(options.command, false);
111
121
  }
112
- })
122
+ });
113
123
  }
114
124
  }
115
125
  set() {
@@ -119,107 +129,106 @@ class TextEditorButtons {
119
129
 
120
130
  class TextEditorSelects {
121
131
  #id = require("randomstring").generate();
122
- #id_sb = require("randomstring").generate();
123
- #Select_main = document.createElement('chui_text_editor_select_box');
124
- #Select_second = document.createElement('text_editor_select_box');
125
- #input = document.createElement('input');
126
- #div_value = document.createElement("text_editor_div_value")
127
- #button_open = document.createElement('text_editor_select_button_open');
128
- #dropdown = document.createElement('text_editor_selectbox_dropdown');
132
+ #idSb = require("randomstring").generate();
133
+ #SelectMain = document.createElement("chui_text_editor_select_box");
134
+ #SelectSecond = document.createElement("text_editor_select_box");
135
+ #input = document.createElement("input");
136
+ #divValue = document.createElement("text_editor_div_value");
137
+ #buttonOpen = document.createElement("text_editor_select_button_open");
138
+ #dropdown = document.createElement("text_editor_selectbox_dropdown");
129
139
  constructor(options = { icon: String(), label: String() }) {
130
140
  if (options.icon !== undefined) {
131
- this.#div_value.innerHTML = options.icon;
141
+ this.#divValue.innerHTML = options.icon;
132
142
  // Значок — украшение: имя даёт сам селект
133
- this.#div_value.setAttribute("aria-hidden", "true");
143
+ this.#divValue.setAttribute("aria-hidden", "true");
134
144
  }
135
- if (options.label !== undefined) this.#Select_main.setAttribute("aria-label", options.label);
136
- this.#input.setAttribute('id', this.#id_sb);
137
- this.#input.classList.add('text_editor_selectbox_input');
138
- this.#input.type = 'text';
139
- this.#input.disabled = true
140
- this.#input.style.display = 'none'
141
- const glyph_open = new Icon(Icons.HARDWARE.KEYBOARD_ARROW_DOWN);
145
+ if (options.label !== undefined) this.#SelectMain.setAttribute("aria-label", options.label);
146
+ this.#input.setAttribute("id", this.#idSb);
147
+ this.#input.classList.add("text_editor_selectbox_input");
148
+ this.#input.type = "text";
149
+ this.#input.disabled = true;
150
+ this.#input.style.display = "none";
151
+ const glyphOpen = new Icon(Icons.HARDWARE.KEYBOARD_ARROW_DOWN);
142
152
  // Глиф-лигатура — украшение: без этого именем кнопки было бы «keyboard_arrow_down»
143
- glyph_open.set().setAttribute("aria-hidden", "true");
144
- this.#button_open.innerHTML = glyph_open.getHTML();
153
+ glyphOpen.set().setAttribute("aria-hidden", "true");
154
+ this.#buttonOpen.innerHTML = glyphOpen.getHTML();
145
155
  // Раскрывающийся селект: кнопка с состоянием и списком опций
146
- makeKeyboardButton(this.#button_open);
156
+ makeKeyboardButton(this.#buttonOpen);
147
157
  // Имя — самой кнопке: у контейнера селекта роли нет, и aria-label на нём не читается
148
- if (options.label !== undefined) this.#button_open.setAttribute("aria-label", options.label);
149
- this.#button_open.setAttribute("aria-haspopup", "listbox");
150
- this.#button_open.setAttribute("aria-expanded", "false");
158
+ if (options.label !== undefined) this.#buttonOpen.setAttribute("aria-label", options.label);
159
+ this.#buttonOpen.setAttribute("aria-haspopup", "listbox");
160
+ this.#buttonOpen.setAttribute("aria-expanded", "false");
151
161
  this.#dropdown.setAttribute("role", "listbox");
152
162
  this.#dropdown.setAttribute("id", this.#id);
153
- this.#button_open.setAttribute("aria-controls", this.#id);
154
- this.#dropdown.setAttribute('id', this.#id);
155
- this.#Select_second.appendChild(this.#input)
156
- this.#Select_second.appendChild(this.#div_value)
157
- this.#Select_second.appendChild(this.#button_open)
158
- this.#Select_second.appendChild(this.#dropdown)
163
+ this.#buttonOpen.setAttribute("aria-controls", this.#id);
164
+ this.#SelectSecond.appendChild(this.#input);
165
+ this.#SelectSecond.appendChild(this.#divValue);
166
+ this.#SelectSecond.appendChild(this.#buttonOpen);
167
+ this.#SelectSecond.appendChild(this.#dropdown);
159
168
  //LISTENERS
160
- this.#Select_second.addEventListener('click', (event) => {
161
- if (event.target.parentNode === this.#Select_second) {
162
- this.#input.focus()
163
- this.#button_open.setAttribute("aria-expanded", "true");
164
- new Animation(this.#dropdown).fadeIn();
169
+ this.#SelectSecond.addEventListener("click", (event) => {
170
+ if (event.target.parentNode === this.#SelectSecond) {
171
+ this.#input.focus();
172
+ this.#buttonOpen.setAttribute("aria-expanded", "true");
173
+ new Animation(this.#dropdown).panelIn();
165
174
  TextEditorSelects.#setOptionDisplay(this.#dropdown);
166
- window.addEventListener('click', this.#window_click_event);
175
+ window.addEventListener("click", this.#windowClickEvent);
167
176
  }
168
177
  });
169
- this.#input.addEventListener('input', (event) => {
170
- let dropdown = this.#dropdown;
171
- for (let option of dropdown.childNodes) {
172
- if (!option.getAttribute('option_value').includes(event.target.value)) {
173
- option.style.display = 'none'
178
+ this.#input.addEventListener("input", (event) => {
179
+ const dropdown = this.#dropdown;
180
+ for (const option of dropdown.childNodes) {
181
+ if (!option.getAttribute("option_value").includes(event.target.value)) {
182
+ option.style.display = "none";
174
183
  } else {
175
- option.style.display = 'block'
184
+ option.style.display = "block";
176
185
  }
177
186
  }
178
187
  });
179
- this.#Select_main.appendChild(this.#Select_second)
188
+ this.#SelectMain.appendChild(this.#SelectSecond);
180
189
  }
181
- #window_click_event = (event) => {
182
- if (event.target.parentNode !== this.#Select_second) {
183
- window.removeEventListener('click', this.#window_click_event);
184
- this.#button_open.setAttribute("aria-expanded", "false");
190
+ #windowClickEvent = (event) => {
191
+ if (event.target.parentNode !== this.#SelectSecond) {
192
+ window.removeEventListener("click", this.#windowClickEvent);
193
+ this.#buttonOpen.setAttribute("aria-expanded", "false");
185
194
  new Animation(this.#dropdown).fadeOut();
186
195
  }
187
- }
196
+ };
188
197
  addOptionsFontSize(...options) {
189
- for (let opt of options) {
190
- let option = document.createElement(`text_editor_selectbox_option`);
191
- let fontSize = document.createElement("font");
192
- fontSize.setAttribute("size", opt.value)
198
+ for (const opt of options) {
199
+ const option = document.createElement(`text_editor_selectbox_option`);
200
+ const fontSize = document.createElement("font");
201
+ fontSize.setAttribute("size", opt.value);
193
202
  fontSize.innerHTML = opt.name;
194
- option.setAttribute('option_value', opt.value);
203
+ option.setAttribute("option_value", opt.value);
195
204
  option.setAttribute("role", "option");
196
- option.addEventListener('click', () => {
197
- this.#input.value = option.getAttribute('option_value');
198
- this.#input.setAttribute('value', option.getAttribute('option_value'));
205
+ option.addEventListener("click", () => {
206
+ this.#input.value = option.getAttribute("option_value");
207
+ this.#input.setAttribute("value", option.getAttribute("option_value"));
199
208
  });
200
- option.appendChild(fontSize)
209
+ option.appendChild(fontSize);
201
210
  this.#dropdown.appendChild(option);
202
211
  }
203
212
  }
204
213
  addOptionsHeader(...options) {
205
- for (let opt of options) {
206
- let option = document.createElement(`text_editor_selectbox_option`);
207
- let header = document.createElement(`${opt.value.replace("<", "").replace(">", "")}`);
214
+ for (const opt of options) {
215
+ const option = document.createElement(`text_editor_selectbox_option`);
216
+ const header = document.createElement(`${opt.value.replace("<", "").replace(">", "")}`);
208
217
  header.innerHTML = opt.name;
209
218
  // Отступы снимает CSS по классу: прежде они ставились инлайном
210
219
  header.classList.add("text_editor_selectbox_option_header");
211
- option.setAttribute('option_value', opt.value);
220
+ option.setAttribute("option_value", opt.value);
212
221
  option.setAttribute("role", "option");
213
- option.addEventListener('click', () => {
214
- this.#input.value = option.getAttribute('option_value');
215
- this.#input.setAttribute('value', option.getAttribute('option_value'));
222
+ option.addEventListener("click", () => {
223
+ this.#input.value = option.getAttribute("option_value");
224
+ this.#input.setAttribute("value", option.getAttribute("option_value"));
216
225
  });
217
- option.appendChild(header)
226
+ option.appendChild(header);
218
227
  this.#dropdown.appendChild(option);
219
228
  }
220
229
  }
221
230
  addValueChangeListener(listener = () => {}) {
222
- let observer = new MutationObserver((mutations) => {
231
+ const observer = new MutationObserver((mutations) => {
223
232
  mutations.forEach(listener);
224
233
  });
225
234
  observer.observe(this.#input, {
@@ -227,14 +236,16 @@ class TextEditorSelects {
227
236
  childList: false,
228
237
  subtree: false,
229
238
  characterData: false,
230
- attributeFilter: ['value']
239
+ attributeFilter: ["value"],
231
240
  });
232
241
  }
233
242
  set() {
234
- return this.#Select_main;
243
+ return this.#SelectMain;
235
244
  }
236
245
  static #setOptionDisplay(element = new HTMLElement()) {
237
- for (let option of element.childNodes) { option.style.display = 'block'; }
246
+ for (const option of element.childNodes) {
247
+ option.style.display = "block";
248
+ }
238
249
  }
239
250
  }
240
251
 
@@ -246,7 +257,7 @@ class TextEditorSelects {
246
257
  const PANEL_ITEM_SELECTOR = "chui_button_format, text_editor_select_button_open";
247
258
 
248
259
  class TextEditorPanel {
249
- #panel = document.createElement("text_editor_panel")
260
+ #panel = document.createElement("text_editor_panel");
250
261
  // Редактор, к которому возвращается фокус: панель держит сам узел, а не его id
251
262
  #editor = undefined;
252
263
  // Заготовка `{ UNDO_REDO: Boolean() }` вызывала Boolean() и давала false: редактор
@@ -255,244 +266,285 @@ class TextEditorPanel {
255
266
  this.#editor = editor;
256
267
  // Управление
257
268
  if (controls.UNDO_REDO) {
258
- let button_undo = new TextEditorButtons({
269
+ const buttonUndo = new TextEditorButtons({
259
270
  icon: Icons.CONTENT.UNDO,
260
- command: Commands.UNDO
261
- })
262
- let button_redo = new TextEditorButtons({
271
+ command: Commands.UNDO,
272
+ });
273
+ const buttonRedo = new TextEditorButtons({
263
274
  icon: Icons.CONTENT.REDO,
264
- command: Commands.REDO
265
- })
266
- this.#addBlock(button_undo, button_redo)
275
+ command: Commands.REDO,
276
+ });
277
+ this.#addBlock(buttonUndo, buttonRedo);
267
278
  }
268
279
  // formatBlock
269
280
  if (controls.BLOCK_FORMAT) {
270
- let select_headers = new TextEditorSelects({ icon: new Icon(Icons.EDITOR.TITLE).getHTML(), label: I18n.t("editor.paragraphAndHeading") })
271
- select_headers.addOptionsHeader(
272
- { name: "H1", value: "<h1>" },
273
- { name: "H2", value: "<h2>" },
274
- { name: "H3", value: "<h3>" },
275
- { name: "H4", value: "<h4>" },
276
- { name: "H5", value: "<h5>" },
277
- { name: "H6", value: "<h6>" },
278
- { name: "Code", value: "<pre>" },
279
- { name: "Paragraph", value: "<P>" }
280
- )
281
- select_headers.addValueChangeListener((e) => {
282
- document.execCommand('formatBlock', false, e.target.value);
283
- })
284
- this.#addBlock(select_headers)
285
- let button_format_quote = new TextEditorButtons({
281
+ const selectHeaders = new TextEditorSelects({
282
+ icon: new Icon(Icons.EDITOR.TITLE).getHTML(),
283
+ label: I18n.t("editor.paragraphAndHeading"),
284
+ });
285
+ selectHeaders.addOptionsHeader(
286
+ { name: "H1", value: "<h1>" },
287
+ { name: "H2", value: "<h2>" },
288
+ { name: "H3", value: "<h3>" },
289
+ { name: "H4", value: "<h4>" },
290
+ { name: "H5", value: "<h5>" },
291
+ { name: "H6", value: "<h6>" },
292
+ { name: "Code", value: "<pre>" },
293
+ { name: "Paragraph", value: "<P>" }
294
+ );
295
+ selectHeaders.addValueChangeListener((e) => {
296
+ document.execCommand("formatBlock", false, e.target.value);
297
+ });
298
+ this.#addBlock(selectHeaders);
299
+ const buttonFormatQuote = new TextEditorButtons({
286
300
  icon: Icons.EDITOR.FORMAT_QUOTE,
287
301
  command: Commands.FORMAT_BLOCK,
288
302
  value: "<BLOCKQUOTE>",
289
- label: I18n.t("editor.quote")
290
- })
291
- this.#addBlock(button_format_quote)
303
+ label: I18n.t("editor.quote"),
304
+ });
305
+ this.#addBlock(buttonFormatQuote);
292
306
  }
293
307
  if (controls.FONT_SIZE) {
294
- let select_font_size = new TextEditorSelects({ icon: new Icon(Icons.EDITOR.FORMAT_SIZE).getHTML(), label: I18n.t("editor.fontSize") })
295
- select_font_size.addOptionsFontSize(
296
- { name: "xx_small", value: "1" },
297
- { name: "x_small", value: "2" },
298
- { name: "small", value: "3" },
299
- { name: "medium", value: "4" },
300
- { name: "large", value: "5" },
301
- { name: "x_large", value: "6" },
302
- { name: "xx_large", value: "7" },
303
- )
304
- select_font_size.addValueChangeListener((e) => {
305
- document.execCommand('fontSize', false, e.target.value);
306
- })
307
- this.#addBlock(select_font_size)
308
+ const selectFontSize = new TextEditorSelects({
309
+ icon: new Icon(Icons.EDITOR.FORMAT_SIZE).getHTML(),
310
+ label: I18n.t("editor.fontSize"),
311
+ });
312
+ selectFontSize.addOptionsFontSize(
313
+ { name: "xx_small", value: "1" },
314
+ { name: "x_small", value: "2" },
315
+ { name: "small", value: "3" },
316
+ { name: "medium", value: "4" },
317
+ { name: "large", value: "5" },
318
+ { name: "x_large", value: "6" },
319
+ { name: "xx_large", value: "7" }
320
+ );
321
+ selectFontSize.addValueChangeListener((e) => {
322
+ document.execCommand("fontSize", false, e.target.value);
323
+ });
324
+ this.#addBlock(selectFontSize);
308
325
  }
309
326
  if (controls.REMOVE_FORMAT) {
310
- let button_removeFormat = new TextEditorButtons({
327
+ const buttonRemoveformat = new TextEditorButtons({
311
328
  icon: Icons.EDITOR.FORMAT_CLEAR,
312
- command: Commands.REMOVE_FORMAT
313
- })
314
- this.#addBlock(button_removeFormat)
329
+ command: Commands.REMOVE_FORMAT,
330
+ });
331
+ this.#addBlock(buttonRemoveformat);
315
332
  }
316
333
  // FORMAT
317
334
  if (controls.BOLD) {
318
- let button_bold_text = new TextEditorButtons({
335
+ const buttonBoldText = new TextEditorButtons({
319
336
  icon: Icons.EDITOR.FORMAT_BOLD,
320
- command: Commands.BOLD
321
- })
322
- this.#addBlock(button_bold_text)
337
+ command: Commands.BOLD,
338
+ });
339
+ this.#addBlock(buttonBoldText);
323
340
  }
324
341
  if (controls.ITALIC) {
325
- let button_italic_text = new TextEditorButtons({
342
+ const buttonItalicText = new TextEditorButtons({
326
343
  icon: Icons.EDITOR.FORMAT_ITALIC,
327
- command: Commands.ITALIC
328
- })
329
- this.#addBlock(button_italic_text)
344
+ command: Commands.ITALIC,
345
+ });
346
+ this.#addBlock(buttonItalicText);
330
347
  }
331
348
  if (controls.STRIKE_THROUGH) {
332
- let button_strikeThrough = new TextEditorButtons({
349
+ const buttonStrikethrough = new TextEditorButtons({
333
350
  icon: Icons.EDITOR.FORMAT_STRIKETHROUGH,
334
- command: Commands.STRIKE_THROUGH
335
- })
336
- this.#addBlock(button_strikeThrough)
351
+ command: Commands.STRIKE_THROUGH,
352
+ });
353
+ this.#addBlock(buttonStrikethrough);
337
354
  }
338
355
  if (controls.UNDERLINE) {
339
- let button_underline = new TextEditorButtons({
356
+ const buttonUnderline = new TextEditorButtons({
340
357
  icon: Icons.EDITOR.FORMAT_UNDERLINED,
341
- command: Commands.UNDERLINE
342
- })
343
- this.#addBlock(button_underline)
358
+ command: Commands.UNDERLINE,
359
+ });
360
+ this.#addBlock(buttonUnderline);
344
361
  }
345
362
  //
346
363
  if (controls.SUPERSCRIPT) {
347
- let button_superscript = new TextEditorButtons({
364
+ const buttonSuperscript = new TextEditorButtons({
348
365
  icon: Icons.EDITOR.SUPERSCRIPT,
349
- command: Commands.SUPER_SCRIPT
350
- })
351
- this.#addBlock(button_superscript)
366
+ command: Commands.SUPER_SCRIPT,
367
+ });
368
+ this.#addBlock(buttonSuperscript);
352
369
  }
353
370
  if (controls.SUBSCRIPT) {
354
- let button_subscript = new TextEditorButtons({
371
+ const buttonSubscript = new TextEditorButtons({
355
372
  icon: Icons.EDITOR.SUBSCRIPT,
356
- command: Commands.SUB_SCRIPT
357
- })
358
- this.#addBlock(button_subscript)
373
+ command: Commands.SUB_SCRIPT,
374
+ });
375
+ this.#addBlock(buttonSubscript);
359
376
  }
360
377
  //
361
378
  if (controls.JUSTIFY_LEFT) {
362
- let button_justifyLeft = new TextEditorButtons({
379
+ const buttonJustifyleft = new TextEditorButtons({
363
380
  icon: Icons.EDITOR.FORMAT_ALIGN_LEFT,
364
- command: Commands.JUSTIFY_LEFT
365
- })
366
- this.#addBlock(button_justifyLeft)
381
+ command: Commands.JUSTIFY_LEFT,
382
+ });
383
+ this.#addBlock(buttonJustifyleft);
367
384
  }
368
385
  if (controls.JUSTIFY_CENTER) {
369
- let button_justifyCenter = new TextEditorButtons({
386
+ const buttonJustifycenter = new TextEditorButtons({
370
387
  icon: Icons.EDITOR.FORMAT_ALIGN_CENTER,
371
- command: Commands.JUSTIFY_CENTER
372
- })
373
- this.#addBlock(button_justifyCenter)
388
+ command: Commands.JUSTIFY_CENTER,
389
+ });
390
+ this.#addBlock(buttonJustifycenter);
374
391
  }
375
392
  if (controls.JUSTIFY_RIGHT) {
376
- let button_justifyRight = new TextEditorButtons({
393
+ const buttonJustifyright = new TextEditorButtons({
377
394
  icon: Icons.EDITOR.FORMAT_ALIGN_RIGHT,
378
- command: Commands.JUSTIFY_RIGHT
379
- })
380
- this.#addBlock(button_justifyRight)
395
+ command: Commands.JUSTIFY_RIGHT,
396
+ });
397
+ this.#addBlock(buttonJustifyright);
381
398
  }
382
399
  if (controls.JUSTIFY_FULL) {
383
- let button_justifyFull = new TextEditorButtons({
400
+ const buttonJustifyfull = new TextEditorButtons({
384
401
  icon: Icons.EDITOR.FORMAT_ALIGN_JUSTIFY,
385
- command: Commands.JUSTIFY_FULL
386
- })
387
- this.#addBlock(button_justifyFull)
402
+ command: Commands.JUSTIFY_FULL,
403
+ });
404
+ this.#addBlock(buttonJustifyfull);
388
405
  }
389
406
  //
390
407
  if (controls.LISTS) {
391
- let button_list_one = new TextEditorButtons({
408
+ const buttonListOne = new TextEditorButtons({
392
409
  icon: Icons.EDITOR.FORMAT_LIST_NUMBERED,
393
- command: Commands.INSERT_ORDERED_LIST
394
- })
395
- let button_list_two = new TextEditorButtons({
410
+ command: Commands.INSERT_ORDERED_LIST,
411
+ });
412
+ const buttonListTwo = new TextEditorButtons({
396
413
  icon: Icons.EDITOR.FORMAT_LIST_BULLETED,
397
- command: Commands.INSERT_UNORDERED_LIST
398
- })
399
- this.#addBlock(button_list_one, button_list_two)
400
-
414
+ command: Commands.INSERT_UNORDERED_LIST,
415
+ });
416
+ this.#addBlock(buttonListOne, buttonListTwo);
401
417
  }
402
418
  //
403
419
  // Создание ссылки
404
420
  if (controls.INSERT_LINK) {
405
- let button_unlink = new TextEditorButtons({
421
+ const buttonUnlink = new TextEditorButtons({
406
422
  icon: Icons.CONTENT.LINK_OFF,
407
- command: Commands.UNLINK
408
- })
409
- let content_link = new ContentBlock({
410
- direction: "column", wrap: "wrap", align: "center", justify: "flex-end"
411
- })
412
- content_link.setWidth("-webkit-fill-available")
413
- let content_link_header = new ContentBlock({
414
- direction: "row", wrap: "wrap", align: "center", justify: "space-between", disableMarginChild: true
415
- })
416
- content_link_header.setWidth("-webkit-fill-available")
417
- let dialog_link = new Dialog({ width: "500px", height: "max-content", closeOutSideClick: true })
418
- let input_link_text = new TextInput({ title: I18n.t("editor.name"), placeholder: I18n.t("editor.name"), width: "-webkit-fill-available", disableFocus: false })
419
- let input_link = new TextInput({ title: I18n.t("editor.link"), placeholder: "https://", width: "-webkit-fill-available", value: "https://example.ru", disableFocus: false })
420
- content_link.add(input_link_text, input_link)
421
- dialog_link.addToBody(content_link)
422
- content_link_header.add(
423
+ command: Commands.UNLINK,
424
+ });
425
+ const contentLink = new ContentBlock({
426
+ direction: "column",
427
+ wrap: "wrap",
428
+ align: "center",
429
+ justify: "flex-end",
430
+ });
431
+ contentLink.setWidth("-webkit-fill-available");
432
+ const contentLinkHeader = new ContentBlock({
433
+ direction: "row",
434
+ wrap: "wrap",
435
+ align: "center",
436
+ justify: "space-between",
437
+ disableMarginChild: true,
438
+ });
439
+ contentLinkHeader.setWidth("-webkit-fill-available");
440
+ const dialogLink = new Dialog({ width: "500px", height: "max-content", closeOutSideClick: true });
441
+ const inputLinkText = new TextInput({
442
+ title: I18n.t("editor.name"),
443
+ placeholder: I18n.t("editor.name"),
444
+ width: "-webkit-fill-available",
445
+ disableFocus: false,
446
+ });
447
+ const inputLink = new TextInput({
448
+ title: I18n.t("editor.link"),
449
+ placeholder: "https://",
450
+ width: "-webkit-fill-available",
451
+ value: "https://example.ru",
452
+ disableFocus: false,
453
+ });
454
+ contentLink.add(inputLinkText, inputLink);
455
+ dialogLink.addToBody(contentLink);
456
+ contentLinkHeader.add(
423
457
  new Button({
424
458
  icon: Icons.NAVIGATION.CLOSE,
425
459
  label: I18n.t("common.close"),
426
460
  clickEvent: () => {
427
- this.#editor.focus()
428
- dialog_link.close()
429
- }
461
+ this.#editor.focus();
462
+ dialogLink.close();
463
+ },
430
464
  }),
431
465
  new Label({ text: I18n.t("editor.addLink") }),
432
466
  new Button({
433
467
  icon: Icons.CONTENT.ADD,
434
468
  label: I18n.t("editor.addLink"),
435
469
  clickEvent: () => {
436
- this.#editor.focus()
470
+ this.#editor.focus();
437
471
  document.getSelection().removeAllRanges();
438
- document.getSelection().addRange(range_link);
439
- if (selection_link.toString() === "") document.execCommand('insertHTML', false, `<a href="${input_link.getValue()}">${input_link_text.getValue()}</a>`);
440
- else document.execCommand(Commands.CREATE_LINK, false, input_link.getValue())
441
- dialog_link.close()
442
- }
443
- }),
444
- )
445
- dialog_link.addToHeader(content_link_header)
446
- let selection_link = undefined;
447
- let range_link = undefined;
448
- let button_link = new TextEditorButtons({
472
+ document.getSelection().addRange(rangeLink);
473
+ if (selectionLink.toString() === "")
474
+ document.execCommand(
475
+ "insertHTML",
476
+ false,
477
+ `<a href="${inputLink.getValue()}">${inputLinkText.getValue()}</a>`
478
+ );
479
+ else document.execCommand(Commands.CREATE_LINK, false, inputLink.getValue());
480
+ dialogLink.close();
481
+ },
482
+ })
483
+ );
484
+ dialogLink.addToHeader(contentLinkHeader);
485
+ let selectionLink = undefined;
486
+ let rangeLink = undefined;
487
+ const buttonLink = new TextEditorButtons({
449
488
  icon: Icons.CONTENT.LINK,
450
489
  disableFocus: true,
451
490
  label: I18n.t("editor.insertLink"),
452
491
  listener: () => {
453
- this.#editor.focus()
454
- selection_link = document.getSelection();
455
- range_link = selection_link.getRangeAt(0)
456
- input_link_text.setValue(selection_link.toString())
457
- if (selection_link.toString() === "") input_link_text.setDisabled(false);
458
- else input_link_text.setDisabled(true);
459
- dialog_link.open()
460
- }
461
- })
462
- this.#addBlock(button_unlink, button_link, dialog_link)
492
+ this.#editor.focus();
493
+ selectionLink = document.getSelection();
494
+ rangeLink = selectionLink.getRangeAt(0);
495
+ inputLinkText.setValue(selectionLink.toString());
496
+ if (selectionLink.toString() === "") inputLinkText.setDisabled(false);
497
+ else inputLinkText.setDisabled(true);
498
+ dialogLink.open();
499
+ },
500
+ });
501
+ this.#addBlock(buttonUnlink, buttonLink, dialogLink);
463
502
  }
464
503
  // ================
465
504
  // Создание таблицы
466
505
  if (controls.INSERT_TABLE) {
467
- let content_table_header = new ContentBlock({
468
- direction: "row", wrap: "wrap", align: "center", justify: "space-between", disableMarginChild: true
469
- })
470
- content_table_header.setWidth("-webkit-fill-available")
471
- let content_table_2 = new ContentBlock({
472
- direction: "row", wrap: "wrap", align: "center", justify: "space-around"
473
- })
474
- content_table_2.setWidth("-webkit-fill-available")
475
- let content_table = new ContentBlock({
476
- direction: "row", wrap: "wrap", align: "center", justify: "space-around"
477
- })
478
- content_table.setWidth("-webkit-fill-available")
479
- let content_table_main = new ContentBlock({
480
- direction: "column", wrap: "wrap", align: "center", justify: "space-around"
481
- })
482
- content_table_main.setWidth("-webkit-fill-available")
483
- let checkBox_header = new CheckBox({ title: I18n.t("editor.addThead") })
484
- content_table_2.add(checkBox_header)
485
- let table_rows = new NumberInput({ title: I18n.t("editor.rows") });
486
- let table_cols = new NumberInput({ title: I18n.t("editor.columns") });
487
- content_table.add(table_rows, new Label("X"), table_cols)
506
+ const contentTableHeader = new ContentBlock({
507
+ direction: "row",
508
+ wrap: "wrap",
509
+ align: "center",
510
+ justify: "space-between",
511
+ disableMarginChild: true,
512
+ });
513
+ contentTableHeader.setWidth("-webkit-fill-available");
514
+ const contentTable2 = new ContentBlock({
515
+ direction: "row",
516
+ wrap: "wrap",
517
+ align: "center",
518
+ justify: "space-around",
519
+ });
520
+ contentTable2.setWidth("-webkit-fill-available");
521
+ const contentTable = new ContentBlock({
522
+ direction: "row",
523
+ wrap: "wrap",
524
+ align: "center",
525
+ justify: "space-around",
526
+ });
527
+ contentTable.setWidth("-webkit-fill-available");
528
+ const contentTableMain = new ContentBlock({
529
+ direction: "column",
530
+ wrap: "wrap",
531
+ align: "center",
532
+ justify: "space-around",
533
+ });
534
+ contentTableMain.setWidth("-webkit-fill-available");
535
+ const checkboxHeader = new CheckBox({ title: I18n.t("editor.addThead") });
536
+ contentTable2.add(checkboxHeader);
537
+ const tableRows = new NumberInput({ title: I18n.t("editor.rows") });
538
+ const tableColumns = new NumberInput({ title: I18n.t("editor.columns") });
539
+ contentTable.add(tableRows, new Label("X"), tableColumns);
488
540
 
489
- content_table_header.add(
541
+ contentTableHeader.add(
490
542
  new Button({
491
543
  icon: Icons.NAVIGATION.CLOSE,
492
544
  label: I18n.t("common.close"),
493
545
  clickEvent: () => {
494
- dialog_table.close()
495
- }
546
+ dialogTable.close();
547
+ },
496
548
  }),
497
549
  new Label({ text: I18n.t("editor.addTable") }),
498
550
  new Button({
@@ -500,153 +552,162 @@ class TextEditorPanel {
500
552
  label: I18n.t("editor.addTable"),
501
553
  clickEvent: () => {
502
554
  let error = false;
503
- if (Number(table_rows.getValue()) === 0 && Number(table_cols.getValue()) === 0) {
555
+ if (Number(tableRows.getValue()) === 0 && Number(tableColumns.getValue()) === 0) {
504
556
  new Notification(I18n.t("editor.setColumnsAndRows"), Notification.STYLE.ERROR).show();
505
557
  error = true;
506
- } else if (Number(table_cols.getValue()) === 0) {
558
+ } else if (Number(tableColumns.getValue()) === 0) {
507
559
  new Notification(I18n.t("editor.setColumns"), Notification.STYLE.ERROR).show();
508
560
  error = true;
509
- } else if (Number(table_rows.getValue()) === 0) {
561
+ } else if (Number(tableRows.getValue()) === 0) {
510
562
  new Notification(I18n.t("editor.setRows"), Notification.STYLE.ERROR).show();
511
563
  error = true;
512
564
  }
513
565
  if (!error) {
514
- let table = document.createElement("table")
515
- table.classList.add("text_editor_table")
566
+ const table = document.createElement("table");
567
+ table.classList.add("text_editor_table");
516
568
  // шапка
517
- if (checkBox_header.getValue()) {
518
- let head_table = table.createTHead()
519
- head_table.classList.add("text_editor_table_body")
520
- let head_row = head_table.insertRow(0)
521
- head_row.classList.add("text_editor_table_row")
522
- for (let j = 0; j < table_cols.getValue(); j++) {
523
- let cell = head_row.insertCell(j)
524
- cell.classList.add("text_editor_table_cell")
525
- cell.innerText = `TH`
569
+ if (checkboxHeader.getValue()) {
570
+ const headTable = table.createTHead();
571
+ headTable.classList.add("text_editor_table_body");
572
+ const headRow = headTable.insertRow(0);
573
+ headRow.classList.add("text_editor_table_row");
574
+ for (let j = 0; j < tableColumns.getValue(); j++) {
575
+ const cell = headRow.insertCell(j);
576
+ cell.classList.add("text_editor_table_cell");
577
+ cell.innerText = `TH`;
526
578
  }
527
579
  }
528
580
  // тело таблицы
529
- let body_table = table.createTBody()
530
- body_table.classList.add("text_editor_table_body")
531
- for (let i = 0; i < table_rows.getValue(); i++) {
532
- let row = body_table.insertRow(i)
533
- row.classList.add("text_editor_table_row")
534
- for (let j = 0; j < table_cols.getValue(); j++) {
535
- let cell = row.insertCell(j)
536
- cell.classList.add("text_editor_table_cell")
537
- cell.innerText = `TB`
581
+ const bodyTable = table.createTBody();
582
+ bodyTable.classList.add("text_editor_table_body");
583
+ for (let i = 0; i < tableRows.getValue(); i++) {
584
+ const row = bodyTable.insertRow(i);
585
+ row.classList.add("text_editor_table_row");
586
+ for (let j = 0; j < tableColumns.getValue(); j++) {
587
+ const cell = row.insertCell(j);
588
+ cell.classList.add("text_editor_table_cell");
589
+ cell.innerText = `TB`;
538
590
  }
539
591
  }
540
- this.#editor.focus()
541
- document.execCommand(Commands.INSERT_HTML, false, table.outerHTML)
542
- dialog_table.close()
592
+ this.#editor.focus();
593
+ document.execCommand(Commands.INSERT_HTML, false, table.outerHTML);
594
+ dialogTable.close();
543
595
  }
544
- }
596
+ },
545
597
  })
546
- )
598
+ );
547
599
 
548
- let dialog_table = new Dialog({ width: "500px", height: "max-content", closeOutSideClick: true })
549
- dialog_table.addToHeader(content_table_header)
550
- content_table_main.add(content_table_2, content_table)
551
- dialog_table.addToBody(content_table_main)
552
- let button_table = new TextEditorButtons({
600
+ const dialogTable = new Dialog({ width: "500px", height: "max-content", closeOutSideClick: true });
601
+ dialogTable.addToHeader(contentTableHeader);
602
+ contentTableMain.add(contentTable2, contentTable);
603
+ dialogTable.addToBody(contentTableMain);
604
+ const buttonTable = new TextEditorButtons({
553
605
  icon: Icons.EDITOR.TABLE_CHART,
554
606
  label: I18n.t("editor.insertTable"),
555
607
  listener: () => {
556
- this.#editor.focus()
557
- dialog_table.open()
558
- }
559
- })
560
- this.#addBlock(button_table, dialog_table)
608
+ this.#editor.focus();
609
+ dialogTable.open();
610
+ },
611
+ });
612
+ this.#addBlock(buttonTable, dialogTable);
561
613
  }
562
614
  // ================
563
615
  // Добавление изображения
564
616
  if (controls.INSERT_IMAGE) {
565
- let content_image_header = new ContentBlock({
566
- direction: "row", wrap: "wrap", align: "center", justify: "space-between", disableMarginChild: true
567
- })
568
- content_image_header.setWidth("-webkit-fill-available")
569
- let file = new FileInput({
617
+ const contentImageHeader = new ContentBlock({
618
+ direction: "row",
619
+ wrap: "wrap",
620
+ align: "center",
621
+ justify: "space-between",
622
+ disableMarginChild: true,
623
+ });
624
+ contentImageHeader.setWidth("-webkit-fill-available");
625
+ const file = new FileInput({
570
626
  title: I18n.t("editor.selectImage"),
571
627
  multiple: false,
572
- accept: [
573
- AcceptTypes.ALL_IMAGE
574
- ]
575
- })
576
- content_image_header.add(
628
+ accept: [AcceptTypes.ALL_IMAGE],
629
+ });
630
+ contentImageHeader.add(
577
631
  new Button({
578
632
  icon: Icons.NAVIGATION.CLOSE,
579
633
  label: I18n.t("common.close"),
580
- clickEvent: () => dialog_image.close()
634
+ clickEvent: () => dialogImage.close(),
581
635
  }),
582
636
  new Label({ text: I18n.t("editor.addImage") }),
583
637
  new Button({
584
638
  icon: Icons.CONTENT.ADD,
585
639
  label: I18n.t("editor.addImage"),
586
640
  clickEvent: () => {
587
- this.#editor.focus()
588
- let image = file.getFile(0)
589
- let reader = new FileReader();
590
- reader.addEventListener("load", () => {
591
- document.execCommand('insertImage', false, reader.result);
592
- }, false);
641
+ this.#editor.focus();
642
+ const image = file.getFile(0);
643
+ const reader = new FileReader();
644
+ reader.addEventListener(
645
+ "load",
646
+ () => {
647
+ document.execCommand("insertImage", false, reader.result);
648
+ },
649
+ false
650
+ );
593
651
  if (image) reader.readAsDataURL(image);
594
- dialog_image.close()
595
- }
652
+ dialogImage.close();
653
+ },
596
654
  })
597
- )
655
+ );
598
656
 
599
- let content_image = new ContentBlock({
600
- direction: "column", wrap: "wrap", align: "center", justify: "flex-end"
601
- })
602
- content_image.setWidth("-webkit-fill-available")
603
- content_image.add(file)
604
- let dialog_image = new Dialog({ width: "500px", height: "max-content", closeOutSideClick: true })
605
- dialog_image.addToHeader(content_image_header)
606
- dialog_image.addToBody(content_image)
657
+ const contentImage = new ContentBlock({
658
+ direction: "column",
659
+ wrap: "wrap",
660
+ align: "center",
661
+ justify: "flex-end",
662
+ });
663
+ contentImage.setWidth("-webkit-fill-available");
664
+ contentImage.add(file);
665
+ const dialogImage = new Dialog({ width: "500px", height: "max-content", closeOutSideClick: true });
666
+ dialogImage.addToHeader(contentImageHeader);
667
+ dialogImage.addToBody(contentImage);
607
668
 
608
- let button_image = new TextEditorButtons({
669
+ const buttonImage = new TextEditorButtons({
609
670
  icon: Icons.EDITOR.INSERT_PHOTO,
610
671
  label: I18n.t("editor.insertImage"),
611
672
  listener: () => {
612
- this.#editor.focus()
613
- dialog_image.open()
614
- }
615
- })
616
- this.#addBlock(button_image, dialog_image)
673
+ this.#editor.focus();
674
+ dialogImage.open();
675
+ },
676
+ });
677
+ this.#addBlock(buttonImage, dialogImage);
617
678
  }
618
679
  // ======================
619
680
  if (controls.LINE_BREAK) {
620
- let button_line_break = new TextEditorButtons({
681
+ const buttonLineBreak = new TextEditorButtons({
621
682
  icon: Icons.EDITOR.INSERT_PAGE_BREAK,
622
- command: Commands.INSERT_LINE_BREAK
623
- })
624
- this.#addBlock(button_line_break)
683
+ command: Commands.INSERT_LINE_BREAK,
684
+ });
685
+ this.#addBlock(buttonLineBreak);
625
686
  }
626
687
  //
627
688
  if (controls.CONTENT_CONTROLS) {
628
- let button_COPY = new TextEditorButtons({
689
+ const buttonCopy = new TextEditorButtons({
629
690
  icon: Icons.CONTENT.CONTENT_COPY,
630
- command: Commands.COPY
631
- })
632
- let button_CUT = new TextEditorButtons({
691
+ command: Commands.COPY,
692
+ });
693
+ const buttonCut = new TextEditorButtons({
633
694
  icon: Icons.CONTENT.CONTENT_CUT,
634
- command: Commands.CUT
635
- })
636
- let button_PASTE = new TextEditorButtons({
695
+ command: Commands.CUT,
696
+ });
697
+ const buttonPaste = new TextEditorButtons({
637
698
  icon: Icons.CONTENT.CONTENT_PASTE,
638
- command: Commands.PASTE
639
- })
640
- this.#addBlock(button_COPY, button_CUT, button_PASTE)
699
+ command: Commands.PASTE,
700
+ });
701
+ this.#addBlock(buttonCopy, buttonCut, buttonPaste);
641
702
  }
642
703
  // Панель — одна остановка Tab: стрелки и Home/End водят фокус по её пунктам,
643
704
  // иначе все кнопки и раскрывающиеся списки стояли бы в обходе Tab подряд
644
- new RovingKeyboard(this.#panel, {itemSelector: PANEL_ITEM_SELECTOR});
705
+ new RovingKeyboard(this.#panel, { itemSelector: PANEL_ITEM_SELECTOR });
645
706
  }
646
707
  #addBlock(...childs) {
647
- let elem = document.createElement("text_editor_block")
648
- for (let child of childs) elem.appendChild(child.set())
649
- this.#panel.appendChild(elem)
708
+ const elem = document.createElement("text_editor_block");
709
+ for (const child of childs) elem.appendChild(child.set());
710
+ this.#panel.appendChild(elem);
650
711
  }
651
712
  set() {
652
713
  return this.#panel;
@@ -654,4 +715,4 @@ class TextEditorPanel {
654
715
  }
655
716
 
656
717
  exports.TextEditorPanel = TextEditorPanel;
657
- exports.Commands = Commands;
718
+ exports.Commands = Commands;