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.
- package/CHANGELOG.md +597 -0
- package/README.md +43 -644
- package/framework/appLayout/default/chui_app_layout.js +602 -496
- package/framework/appLayout/default/global_style.css +288 -97
- package/framework/appLayout/default/main_theme_style.css +188 -101
- package/framework/components/chui_accordion/accordion.js +38 -35
- package/framework/components/chui_accordion/styles.css +13 -12
- package/framework/components/chui_action_sheet/action_sheet.js +93 -64
- package/framework/components/chui_action_sheet/styles.css +12 -5
- package/framework/components/chui_actions_bar/actions_bar.js +338 -0
- package/framework/components/chui_actions_bar/styles.css +139 -0
- package/framework/components/chui_affix/affix.js +16 -11
- package/framework/components/chui_affix/styles.css +5 -0
- package/framework/components/chui_alert/alert.js +34 -19
- package/framework/components/chui_alert/styles.css +7 -0
- package/framework/components/chui_avatar/avatar.js +36 -35
- package/framework/components/chui_avatar/styles.css +1 -1
- package/framework/components/chui_avatar_group/avatar_group.js +25 -23
- package/framework/components/chui_avatar_group/styles.css +1 -1
- package/framework/components/chui_backtop/backtop.js +60 -21
- package/framework/components/chui_backtop/styles.css +21 -0
- package/framework/components/chui_badge/badge.js +30 -28
- package/framework/components/chui_badge/styles.css +6 -6
- package/framework/components/chui_banner/banner.js +222 -0
- package/framework/components/chui_banner/styles.css +170 -0
- package/framework/components/chui_breadcrumb/breadcrumb.js +15 -13
- package/framework/components/chui_breadcrumb/styles.css +1 -1
- package/framework/components/chui_button/button.js +52 -36
- package/framework/components/chui_button/styles.css +7 -7
- package/framework/components/chui_calendar/calendar.js +18 -16
- package/framework/components/chui_card/card.js +52 -32
- package/framework/components/chui_card_scroll/card_scroll.js +169 -0
- package/framework/components/chui_card_scroll/styles.css +86 -0
- package/framework/components/chui_chat/chat.js +140 -79
- package/framework/components/chui_chat/styles.css +18 -7
- package/framework/components/chui_clipboard_history/clipboard_history.js +53 -39
- package/framework/components/chui_clipboard_history/styles.css +13 -9
- package/framework/components/chui_code/code.js +10 -10
- package/framework/components/chui_code/styles.css +4 -4
- package/framework/components/chui_code_editor/code_editor.js +73 -57
- package/framework/components/chui_code_editor/styles.css +6 -5
- package/framework/components/chui_command_palette/command_palette.js +87 -64
- package/framework/components/chui_command_palette/styles.css +5 -5
- package/framework/components/chui_console/console.js +13 -13
- package/framework/components/chui_console/styles.css +6 -3
- package/framework/components/chui_content_block/content_block.js +35 -21
- package/framework/components/chui_content_block/styles.css +2 -2
- package/framework/components/chui_context_menu/context_menu.js +171 -58
- package/framework/components/chui_context_menu/styles.css +82 -8
- package/framework/components/chui_custom_element/custom_element.js +25 -18
- package/framework/components/chui_data_grid/data_grid.js +633 -471
- package/framework/components/chui_data_grid/styles.css +24 -22
- package/framework/components/chui_descriptions/descriptions.js +34 -17
- package/framework/components/chui_descriptions/styles.css +1 -1
- package/framework/components/chui_details/details.js +42 -36
- package/framework/components/chui_details/styles.css +12 -11
- package/framework/components/chui_diff_viewer/diff_viewer.js +172 -147
- package/framework/components/chui_diff_viewer/styles.css +10 -10
- package/framework/components/chui_divider/divider.js +19 -17
- package/framework/components/chui_divider/styles.css +2 -2
- package/framework/components/chui_drawer/drawer.js +63 -38
- package/framework/components/chui_drawer/styles.css +18 -4
- package/framework/components/chui_drop_zone/drop_zone.js +37 -27
- package/framework/components/chui_drop_zone/styles.css +10 -6
- package/framework/components/chui_empty_state/empty_state.js +20 -15
- package/framework/components/chui_fieldset/fieldset.js +40 -23
- package/framework/components/chui_fieldset/styles.css +6 -6
- package/framework/components/chui_file_explorer/file_explorer.js +260 -189
- package/framework/components/chui_file_explorer/styles.css +8 -7
- package/framework/components/chui_form/form.js +40 -28
- package/framework/components/chui_form/styles.css +1 -1
- package/framework/components/chui_gantt/gantt.js +102 -78
- package/framework/components/chui_gantt/styles.css +5 -5
- package/framework/components/chui_graphs/graphs.js +376 -239
- package/framework/components/chui_graphs/styles.css +27 -6
- package/framework/components/chui_hero/hero.js +98 -37
- package/framework/components/chui_hero/styles.css +176 -7
- package/framework/components/chui_html_block/html_block.js +8 -8
- package/framework/components/chui_html_block/styles.css +3 -3
- package/framework/components/chui_hx/hx.js +3 -3
- package/framework/components/chui_hx/styles.css +13 -6
- package/framework/components/chui_icons/icons.js +2115 -2115
- package/framework/components/chui_icons/styles.css +4 -3
- package/framework/components/chui_inputs/chui_check_box/check_box.js +31 -19
- package/framework/components/chui_inputs/chui_check_box/styles.css +30 -21
- package/framework/components/chui_inputs/chui_chips/chips.js +141 -70
- package/framework/components/chui_inputs/chui_chips/styles.css +32 -7
- package/framework/components/chui_inputs/chui_color_picker/color_picker.js +55 -38
- package/framework/components/chui_inputs/chui_color_picker/styles.css +7 -7
- package/framework/components/chui_inputs/chui_combo_box/combo_box.js +127 -109
- package/framework/components/chui_inputs/chui_combo_box/styles.css +23 -21
- package/framework/components/chui_inputs/chui_date/date.js +161 -127
- package/framework/components/chui_inputs/chui_date/styles.css +20 -19
- package/framework/components/chui_inputs/chui_date_range/date_range.js +61 -50
- package/framework/components/chui_inputs/chui_date_range/styles.css +3 -3
- package/framework/components/chui_inputs/chui_datetime/datetime.js +47 -39
- package/framework/components/chui_inputs/chui_datetime/styles.css +3 -3
- package/framework/components/chui_inputs/chui_email/email.js +48 -36
- package/framework/components/chui_inputs/chui_email/styles.css +11 -11
- package/framework/components/chui_inputs/chui_file/file.js +71 -44
- package/framework/components/chui_inputs/chui_file/styles.css +23 -19
- package/framework/components/chui_inputs/chui_hotkey/hotkey.js +101 -76
- package/framework/components/chui_inputs/chui_hotkey/styles.css +6 -6
- package/framework/components/chui_inputs/chui_masked/masked.js +83 -72
- package/framework/components/chui_inputs/chui_masked/styles.css +5 -5
- package/framework/components/chui_inputs/chui_mention/mention.js +87 -40
- package/framework/components/chui_inputs/chui_mention/styles.css +14 -8
- package/framework/components/chui_inputs/chui_multi_combo_box/multi_combo_box.js +242 -212
- package/framework/components/chui_inputs/chui_multi_combo_box/styles.css +23 -15
- package/framework/components/chui_inputs/chui_number/number.js +84 -70
- package/framework/components/chui_inputs/chui_number/styles.css +13 -13
- package/framework/components/chui_inputs/chui_otp/otp.js +71 -62
- package/framework/components/chui_inputs/chui_otp/styles.css +5 -5
- package/framework/components/chui_inputs/chui_password/password.js +72 -56
- package/framework/components/chui_inputs/chui_password/styles.css +15 -15
- package/framework/components/chui_inputs/chui_radio_button/radio_button.js +37 -25
- package/framework/components/chui_inputs/chui_radio_button/styles.css +22 -22
- package/framework/components/chui_inputs/chui_rating/rating.js +54 -50
- package/framework/components/chui_inputs/chui_rating/styles.css +3 -3
- package/framework/components/chui_inputs/chui_select_box/select_box.js +132 -108
- package/framework/components/chui_inputs/chui_select_box/styles.css +21 -21
- package/framework/components/chui_inputs/chui_slider/slider.js +41 -38
- package/framework/components/chui_inputs/chui_slider/styles.css +7 -5
- package/framework/components/chui_inputs/chui_text/styles.css +14 -14
- package/framework/components/chui_inputs/chui_text/text.js +69 -52
- package/framework/components/chui_inputs/chui_text_area/styles.css +14 -14
- package/framework/components/chui_inputs/chui_text_area/text_area.js +59 -36
- package/framework/components/chui_inputs/chui_time/styles.css +18 -20
- package/framework/components/chui_inputs/chui_time/time.js +71 -49
- package/framework/components/chui_inputs/chui_toggle/styles.css +13 -6
- package/framework/components/chui_inputs/chui_toggle/toggle.js +27 -27
- package/framework/components/chui_json_editor/json_editor.js +137 -127
- package/framework/components/chui_json_editor/styles.css +5 -5
- package/framework/components/chui_json_viewer/json_viewer.js +133 -114
- package/framework/components/chui_json_viewer/styles.css +9 -8
- package/framework/components/chui_kanban/kanban.js +78 -60
- package/framework/components/chui_kanban/styles.css +8 -4
- package/framework/components/chui_kbd/kbd.js +12 -10
- package/framework/components/chui_kbd/styles.css +1 -1
- package/framework/components/chui_label/label.js +31 -29
- package/framework/components/chui_label/styles.css +3 -3
- package/framework/components/chui_link/link.js +36 -29
- package/framework/components/chui_link/styles.css +11 -4
- package/framework/components/chui_list/list.js +42 -38
- package/framework/components/chui_list/styles.css +4 -3
- package/framework/components/chui_markdown_editor/markdown_editor.js +125 -109
- package/framework/components/chui_markdown_editor/styles.css +5 -5
- package/framework/components/chui_media/audio.js +457 -364
- package/framework/components/chui_media/audio_styles.css +74 -37
- package/framework/components/chui_media/image.js +99 -64
- package/framework/components/chui_media/image_compare.js +86 -55
- package/framework/components/chui_media/image_compare_styles.css +5 -5
- package/framework/components/chui_media/image_styles.css +4 -4
- package/framework/components/chui_media/video.js +264 -171
- package/framework/components/chui_media/video_styles.css +57 -24
- package/framework/components/chui_menu_bar/menu_bar.js +67 -65
- package/framework/components/chui_menu_bar/styles.css +14 -12
- package/framework/components/chui_message_bar/message_bar.js +551 -0
- package/framework/components/chui_message_bar/styles.css +248 -0
- package/framework/components/chui_modal/modal.js +81 -56
- package/framework/components/chui_modal/styles.css +3 -2
- package/framework/components/chui_notification/notification.js +107 -69
- package/framework/components/chui_notification/notification_download.js +28 -77
- package/framework/components/chui_notification/notification_download_card.js +115 -0
- package/framework/components/chui_notification/notification_download_progress.css +5 -4
- package/framework/components/chui_notification/notification_download_progress.js +73 -105
- package/framework/components/chui_notification/notification_update.js +44 -37
- package/framework/components/chui_notification/status_plate.css +3 -3
- package/framework/components/chui_notification/status_plate.js +2 -2
- package/framework/components/chui_notification/styles.css +6 -1
- package/framework/components/chui_notification/styles_download.css +2 -2
- package/framework/components/chui_notification/styles_update.css +3 -3
- package/framework/components/chui_org_chart/org_chart.js +101 -62
- package/framework/components/chui_org_chart/styles.css +2 -2
- package/framework/components/chui_pagination/pagination.js +65 -30
- package/framework/components/chui_pagination/styles.css +1 -1
- package/framework/components/chui_paragraph/paragraph.js +2 -2
- package/framework/components/chui_paragraph/styles.css +3 -3
- package/framework/components/chui_popover/popover.js +77 -50
- package/framework/components/chui_popover/styles.css +1 -1
- package/framework/components/chui_popups/popups.js +210 -181
- package/framework/components/chui_popups/styles.css +7 -7
- package/framework/components/chui_print_button/print_button.js +48 -33
- package/framework/components/chui_progress_bar/progress_bar.js +49 -19
- package/framework/components/chui_progress_bar/styles.css +6 -6
- package/framework/components/chui_progress_ring/progress_ring.js +32 -30
- package/framework/components/chui_progress_ring/styles.css +1 -1
- package/framework/components/chui_qrcode/qrcode.js +85 -41
- package/framework/components/chui_query_builder/query_builder.js +263 -170
- package/framework/components/chui_query_builder/styles.css +4 -4
- package/framework/components/chui_radio_group/radio_group.js +36 -26
- package/framework/components/chui_radio_group/styles.css +2 -2
- package/framework/components/chui_result/result.js +41 -31
- package/framework/components/chui_result/styles.css +3 -3
- package/framework/components/chui_scheduler/scheduler.js +126 -104
- package/framework/components/chui_scheduler/styles.css +11 -7
- package/framework/components/chui_screen_spinner/screen_spinner.js +167 -0
- package/framework/components/chui_screen_spinner/styles.css +49 -0
- package/framework/components/chui_segmented_control/segmented_control.js +90 -27
- package/framework/components/chui_segmented_control/styles.css +32 -6
- package/framework/components/chui_settings/settings.js +160 -87
- package/framework/components/chui_settings/styles.css +4 -4
- package/framework/components/chui_shortcut_help/shortcut_help.js +82 -61
- package/framework/components/chui_sidebar_nav/sidebar_nav.js +132 -53
- package/framework/components/chui_sidebar_nav/styles.css +9 -3
- package/framework/components/chui_skeleton/skeleton.js +29 -24
- package/framework/components/chui_slideshow/slideshow.js +122 -103
- package/framework/components/chui_slideshow/styles.css +22 -16
- package/framework/components/chui_spinner/spinner.js +17 -17
- package/framework/components/chui_spinner/styles.css +0 -1
- package/framework/components/chui_split_button/split_button.js +53 -30
- package/framework/components/chui_split_button/styles.css +22 -6
- package/framework/components/chui_splitter/splitter.js +46 -39
- package/framework/components/chui_splitter/styles.css +2 -2
- package/framework/components/chui_statistic/statistic.js +111 -84
- package/framework/components/chui_status_bar/status_bar.js +11 -9
- package/framework/components/chui_status_bar/styles.css +2 -2
- package/framework/components/chui_stepper/stepper.js +230 -54
- package/framework/components/chui_stepper/styles.css +79 -14
- package/framework/components/chui_sticky_bar/sticky_bar.js +53 -17
- package/framework/components/chui_sticky_bar/styles.css +11 -7
- package/framework/components/chui_tabs/chui_tabs.js +100 -46
- package/framework/components/chui_tabs/styles.css +43 -15
- package/framework/components/chui_text_editor/styles.css +24 -23
- package/framework/components/chui_text_editor/text_editor.js +103 -79
- package/framework/components/chui_text_editor/text_editor_panel.js +428 -367
- package/framework/components/chui_theme_toggle/theme_toggle.js +46 -25
- package/framework/components/chui_timeline/styles.css +3 -1
- package/framework/components/chui_timeline/timeline.js +14 -12
- package/framework/components/chui_toast_queue/styles.css +11 -11
- package/framework/components/chui_toast_queue/toast_queue.js +82 -73
- package/framework/components/chui_toolbar/styles.css +2 -2
- package/framework/components/chui_toolbar/toolbar.js +20 -13
- package/framework/components/chui_tooltip/styles.css +2 -2
- package/framework/components/chui_tooltip/tooltip.js +40 -27
- package/framework/components/chui_tour/styles.css +12 -7
- package/framework/components/chui_tour/tour.js +132 -98
- package/framework/components/chui_transfer/styles.css +8 -7
- package/framework/components/chui_transfer/transfer.js +143 -123
- package/framework/components/chui_tree_table/styles.css +4 -4
- package/framework/components/chui_tree_table/tree_table.js +88 -74
- package/framework/components/chui_tree_view/styles.css +14 -10
- package/framework/components/chui_tree_view/tree_view.js +298 -253
- package/framework/components/chui_user_bar/styles.css +145 -0
- package/framework/components/chui_user_bar/user_bar.js +402 -0
- package/framework/components/chui_user_list_bar/styles.css +173 -0
- package/framework/components/chui_user_list_bar/user_list_bar.js +485 -0
- package/framework/components/chui_watermark/watermark.js +41 -33
- package/framework/components/chui_webview/styles.css +2 -2
- package/framework/components/chui_webview/webview.js +64 -52
- package/framework/components/chui_write_bar/styles.css +172 -0
- package/framework/components/chui_write_bar/write_bar.js +320 -0
- package/framework/main_window.js +1234 -0
- package/framework/modules/chui_a11y/chui_a11y.js +153 -123
- package/framework/modules/chui_animations/animations.js +105 -43
- package/framework/modules/chui_animations/motion.js +120 -0
- package/framework/modules/chui_animations/styles.css +37 -4
- package/framework/modules/chui_bridge/preload.js +36 -25
- package/framework/modules/chui_functions.js +69 -63
- package/framework/modules/chui_highlight/chui_highlight.js +25 -22
- package/framework/modules/chui_highlight/styles.css +13 -10
- package/framework/modules/chui_i18n/chui_i18n.js +12 -10
- package/framework/modules/chui_i18n/locales/a11y.js +5 -5
- package/framework/modules/chui_i18n/locales/app_layout.js +5 -5
- package/framework/modules/chui_i18n/locales/calendar.js +3 -3
- package/framework/modules/chui_i18n/locales/common.js +3 -3
- package/framework/modules/chui_i18n/locales/data.js +36 -26
- package/framework/modules/chui_i18n/locales/editors.js +40 -13
- package/framework/modules/chui_i18n/locales/feedback.js +65 -3
- package/framework/modules/chui_i18n/locales/forms.js +8 -8
- package/framework/modules/chui_i18n/locales/graphics.js +8 -8
- package/framework/modules/chui_i18n/locales/media.js +4 -4
- package/framework/modules/chui_i18n/locales/navigation.js +12 -8
- package/framework/modules/chui_i18n/locales/validate.js +3 -3
- package/framework/modules/chui_json/chui_json.js +11 -11
- package/framework/modules/chui_layout/chui_layout.js +12 -10
- package/framework/modules/chui_logger/chui_logger.js +47 -28
- package/framework/modules/chui_page/page.js +39 -33
- package/framework/modules/chui_palette/palette.js +61 -0
- package/framework/modules/chui_qr/chui_qr.js +179 -88
- package/framework/modules/chui_scrollbar/chui_scrollbar.js +79 -68
- package/framework/modules/chui_scrollbar/styles.css +4 -2
- package/framework/modules/chui_services/chui_channels.js +27 -13
- package/framework/modules/chui_services/chui_services.js +47 -39
- package/framework/modules/chui_services/desktop.js +108 -101
- package/framework/modules/chui_sortable/chui_sortable.js +33 -28
- package/framework/modules/chui_validate/chui_validate.js +10 -7
- package/framework/tray_bar/chui_menu_items.js +136 -46
- package/index.d.ts +5046 -0
- package/index.js +199 -1254
- package/package.json +81 -68
- 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(
|
|
86
|
-
|
|
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(
|
|
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
|
-
#
|
|
123
|
-
#
|
|
124
|
-
#
|
|
125
|
-
#input = document.createElement(
|
|
126
|
-
#
|
|
127
|
-
#
|
|
128
|
-
#dropdown = document.createElement(
|
|
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.#
|
|
141
|
+
this.#divValue.innerHTML = options.icon;
|
|
132
142
|
// Значок — украшение: имя даёт сам селект
|
|
133
|
-
this.#
|
|
143
|
+
this.#divValue.setAttribute("aria-hidden", "true");
|
|
134
144
|
}
|
|
135
|
-
if (options.label !== undefined) this.#
|
|
136
|
-
this.#input.setAttribute(
|
|
137
|
-
this.#input.classList.add(
|
|
138
|
-
this.#input.type =
|
|
139
|
-
this.#input.disabled = true
|
|
140
|
-
this.#input.style.display =
|
|
141
|
-
const
|
|
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
|
-
|
|
144
|
-
this.#
|
|
153
|
+
glyphOpen.set().setAttribute("aria-hidden", "true");
|
|
154
|
+
this.#buttonOpen.innerHTML = glyphOpen.getHTML();
|
|
145
155
|
// Раскрывающийся селект: кнопка с состоянием и списком опций
|
|
146
|
-
makeKeyboardButton(this.#
|
|
156
|
+
makeKeyboardButton(this.#buttonOpen);
|
|
147
157
|
// Имя — самой кнопке: у контейнера селекта роли нет, и aria-label на нём не читается
|
|
148
|
-
if (options.label !== undefined) this.#
|
|
149
|
-
this.#
|
|
150
|
-
this.#
|
|
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.#
|
|
154
|
-
this.#
|
|
155
|
-
this.#
|
|
156
|
-
this.#
|
|
157
|
-
this.#
|
|
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.#
|
|
161
|
-
if (event.target.parentNode === this.#
|
|
162
|
-
this.#input.focus()
|
|
163
|
-
this.#
|
|
164
|
-
new Animation(this.#dropdown).
|
|
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(
|
|
175
|
+
window.addEventListener("click", this.#windowClickEvent);
|
|
167
176
|
}
|
|
168
177
|
});
|
|
169
|
-
this.#input.addEventListener(
|
|
170
|
-
|
|
171
|
-
for (
|
|
172
|
-
if (!option.getAttribute(
|
|
173
|
-
option.style.display =
|
|
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 =
|
|
184
|
+
option.style.display = "block";
|
|
176
185
|
}
|
|
177
186
|
}
|
|
178
187
|
});
|
|
179
|
-
this.#
|
|
188
|
+
this.#SelectMain.appendChild(this.#SelectSecond);
|
|
180
189
|
}
|
|
181
|
-
#
|
|
182
|
-
if (event.target.parentNode !== this.#
|
|
183
|
-
window.removeEventListener(
|
|
184
|
-
this.#
|
|
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 (
|
|
190
|
-
|
|
191
|
-
|
|
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(
|
|
203
|
+
option.setAttribute("option_value", opt.value);
|
|
195
204
|
option.setAttribute("role", "option");
|
|
196
|
-
option.addEventListener(
|
|
197
|
-
this.#input.value = option.getAttribute(
|
|
198
|
-
this.#input.setAttribute(
|
|
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 (
|
|
206
|
-
|
|
207
|
-
|
|
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(
|
|
220
|
+
option.setAttribute("option_value", opt.value);
|
|
212
221
|
option.setAttribute("role", "option");
|
|
213
|
-
option.addEventListener(
|
|
214
|
-
this.#input.value = option.getAttribute(
|
|
215
|
-
this.#input.setAttribute(
|
|
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
|
-
|
|
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: [
|
|
239
|
+
attributeFilter: ["value"],
|
|
231
240
|
});
|
|
232
241
|
}
|
|
233
242
|
set() {
|
|
234
|
-
return this.#
|
|
243
|
+
return this.#SelectMain;
|
|
235
244
|
}
|
|
236
245
|
static #setOptionDisplay(element = new HTMLElement()) {
|
|
237
|
-
for (
|
|
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
|
-
|
|
269
|
+
const buttonUndo = new TextEditorButtons({
|
|
259
270
|
icon: Icons.CONTENT.UNDO,
|
|
260
|
-
command: Commands.UNDO
|
|
261
|
-
})
|
|
262
|
-
|
|
271
|
+
command: Commands.UNDO,
|
|
272
|
+
});
|
|
273
|
+
const buttonRedo = new TextEditorButtons({
|
|
263
274
|
icon: Icons.CONTENT.REDO,
|
|
264
|
-
command: Commands.REDO
|
|
265
|
-
})
|
|
266
|
-
this.#addBlock(
|
|
275
|
+
command: Commands.REDO,
|
|
276
|
+
});
|
|
277
|
+
this.#addBlock(buttonUndo, buttonRedo);
|
|
267
278
|
}
|
|
268
279
|
// formatBlock
|
|
269
280
|
if (controls.BLOCK_FORMAT) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
{ name: "
|
|
276
|
-
{ name: "
|
|
277
|
-
{ name: "
|
|
278
|
-
{ name: "
|
|
279
|
-
{ name: "
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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(
|
|
303
|
+
label: I18n.t("editor.quote"),
|
|
304
|
+
});
|
|
305
|
+
this.#addBlock(buttonFormatQuote);
|
|
292
306
|
}
|
|
293
307
|
if (controls.FONT_SIZE) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
{ name: "
|
|
300
|
-
{ name: "
|
|
301
|
-
{ name: "
|
|
302
|
-
{ name: "
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
327
|
+
const buttonRemoveformat = new TextEditorButtons({
|
|
311
328
|
icon: Icons.EDITOR.FORMAT_CLEAR,
|
|
312
|
-
command: Commands.REMOVE_FORMAT
|
|
313
|
-
})
|
|
314
|
-
this.#addBlock(
|
|
329
|
+
command: Commands.REMOVE_FORMAT,
|
|
330
|
+
});
|
|
331
|
+
this.#addBlock(buttonRemoveformat);
|
|
315
332
|
}
|
|
316
333
|
// FORMAT
|
|
317
334
|
if (controls.BOLD) {
|
|
318
|
-
|
|
335
|
+
const buttonBoldText = new TextEditorButtons({
|
|
319
336
|
icon: Icons.EDITOR.FORMAT_BOLD,
|
|
320
|
-
command: Commands.BOLD
|
|
321
|
-
})
|
|
322
|
-
this.#addBlock(
|
|
337
|
+
command: Commands.BOLD,
|
|
338
|
+
});
|
|
339
|
+
this.#addBlock(buttonBoldText);
|
|
323
340
|
}
|
|
324
341
|
if (controls.ITALIC) {
|
|
325
|
-
|
|
342
|
+
const buttonItalicText = new TextEditorButtons({
|
|
326
343
|
icon: Icons.EDITOR.FORMAT_ITALIC,
|
|
327
|
-
command: Commands.ITALIC
|
|
328
|
-
})
|
|
329
|
-
this.#addBlock(
|
|
344
|
+
command: Commands.ITALIC,
|
|
345
|
+
});
|
|
346
|
+
this.#addBlock(buttonItalicText);
|
|
330
347
|
}
|
|
331
348
|
if (controls.STRIKE_THROUGH) {
|
|
332
|
-
|
|
349
|
+
const buttonStrikethrough = new TextEditorButtons({
|
|
333
350
|
icon: Icons.EDITOR.FORMAT_STRIKETHROUGH,
|
|
334
|
-
command: Commands.STRIKE_THROUGH
|
|
335
|
-
})
|
|
336
|
-
this.#addBlock(
|
|
351
|
+
command: Commands.STRIKE_THROUGH,
|
|
352
|
+
});
|
|
353
|
+
this.#addBlock(buttonStrikethrough);
|
|
337
354
|
}
|
|
338
355
|
if (controls.UNDERLINE) {
|
|
339
|
-
|
|
356
|
+
const buttonUnderline = new TextEditorButtons({
|
|
340
357
|
icon: Icons.EDITOR.FORMAT_UNDERLINED,
|
|
341
|
-
command: Commands.UNDERLINE
|
|
342
|
-
})
|
|
343
|
-
this.#addBlock(
|
|
358
|
+
command: Commands.UNDERLINE,
|
|
359
|
+
});
|
|
360
|
+
this.#addBlock(buttonUnderline);
|
|
344
361
|
}
|
|
345
362
|
//
|
|
346
363
|
if (controls.SUPERSCRIPT) {
|
|
347
|
-
|
|
364
|
+
const buttonSuperscript = new TextEditorButtons({
|
|
348
365
|
icon: Icons.EDITOR.SUPERSCRIPT,
|
|
349
|
-
command: Commands.SUPER_SCRIPT
|
|
350
|
-
})
|
|
351
|
-
this.#addBlock(
|
|
366
|
+
command: Commands.SUPER_SCRIPT,
|
|
367
|
+
});
|
|
368
|
+
this.#addBlock(buttonSuperscript);
|
|
352
369
|
}
|
|
353
370
|
if (controls.SUBSCRIPT) {
|
|
354
|
-
|
|
371
|
+
const buttonSubscript = new TextEditorButtons({
|
|
355
372
|
icon: Icons.EDITOR.SUBSCRIPT,
|
|
356
|
-
command: Commands.SUB_SCRIPT
|
|
357
|
-
})
|
|
358
|
-
this.#addBlock(
|
|
373
|
+
command: Commands.SUB_SCRIPT,
|
|
374
|
+
});
|
|
375
|
+
this.#addBlock(buttonSubscript);
|
|
359
376
|
}
|
|
360
377
|
//
|
|
361
378
|
if (controls.JUSTIFY_LEFT) {
|
|
362
|
-
|
|
379
|
+
const buttonJustifyleft = new TextEditorButtons({
|
|
363
380
|
icon: Icons.EDITOR.FORMAT_ALIGN_LEFT,
|
|
364
|
-
command: Commands.JUSTIFY_LEFT
|
|
365
|
-
})
|
|
366
|
-
this.#addBlock(
|
|
381
|
+
command: Commands.JUSTIFY_LEFT,
|
|
382
|
+
});
|
|
383
|
+
this.#addBlock(buttonJustifyleft);
|
|
367
384
|
}
|
|
368
385
|
if (controls.JUSTIFY_CENTER) {
|
|
369
|
-
|
|
386
|
+
const buttonJustifycenter = new TextEditorButtons({
|
|
370
387
|
icon: Icons.EDITOR.FORMAT_ALIGN_CENTER,
|
|
371
|
-
command: Commands.JUSTIFY_CENTER
|
|
372
|
-
})
|
|
373
|
-
this.#addBlock(
|
|
388
|
+
command: Commands.JUSTIFY_CENTER,
|
|
389
|
+
});
|
|
390
|
+
this.#addBlock(buttonJustifycenter);
|
|
374
391
|
}
|
|
375
392
|
if (controls.JUSTIFY_RIGHT) {
|
|
376
|
-
|
|
393
|
+
const buttonJustifyright = new TextEditorButtons({
|
|
377
394
|
icon: Icons.EDITOR.FORMAT_ALIGN_RIGHT,
|
|
378
|
-
command: Commands.JUSTIFY_RIGHT
|
|
379
|
-
})
|
|
380
|
-
this.#addBlock(
|
|
395
|
+
command: Commands.JUSTIFY_RIGHT,
|
|
396
|
+
});
|
|
397
|
+
this.#addBlock(buttonJustifyright);
|
|
381
398
|
}
|
|
382
399
|
if (controls.JUSTIFY_FULL) {
|
|
383
|
-
|
|
400
|
+
const buttonJustifyfull = new TextEditorButtons({
|
|
384
401
|
icon: Icons.EDITOR.FORMAT_ALIGN_JUSTIFY,
|
|
385
|
-
command: Commands.JUSTIFY_FULL
|
|
386
|
-
})
|
|
387
|
-
this.#addBlock(
|
|
402
|
+
command: Commands.JUSTIFY_FULL,
|
|
403
|
+
});
|
|
404
|
+
this.#addBlock(buttonJustifyfull);
|
|
388
405
|
}
|
|
389
406
|
//
|
|
390
407
|
if (controls.LISTS) {
|
|
391
|
-
|
|
408
|
+
const buttonListOne = new TextEditorButtons({
|
|
392
409
|
icon: Icons.EDITOR.FORMAT_LIST_NUMBERED,
|
|
393
|
-
command: Commands.INSERT_ORDERED_LIST
|
|
394
|
-
})
|
|
395
|
-
|
|
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(
|
|
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
|
-
|
|
421
|
+
const buttonUnlink = new TextEditorButtons({
|
|
406
422
|
icon: Icons.CONTENT.LINK_OFF,
|
|
407
|
-
command: Commands.UNLINK
|
|
408
|
-
})
|
|
409
|
-
|
|
410
|
-
direction: "column",
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
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
|
-
|
|
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(
|
|
439
|
-
if (
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
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
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
if (
|
|
458
|
-
else
|
|
459
|
-
|
|
460
|
-
}
|
|
461
|
-
})
|
|
462
|
-
this.#addBlock(
|
|
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
|
-
|
|
468
|
-
direction: "row",
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
})
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
direction: "row",
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
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
|
-
|
|
541
|
+
contentTableHeader.add(
|
|
490
542
|
new Button({
|
|
491
543
|
icon: Icons.NAVIGATION.CLOSE,
|
|
492
544
|
label: I18n.t("common.close"),
|
|
493
545
|
clickEvent: () => {
|
|
494
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
515
|
-
table.classList.add("text_editor_table")
|
|
566
|
+
const table = document.createElement("table");
|
|
567
|
+
table.classList.add("text_editor_table");
|
|
516
568
|
// шапка
|
|
517
|
-
if (
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
for (let j = 0; j <
|
|
523
|
-
|
|
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
|
-
|
|
530
|
-
|
|
531
|
-
for (let i = 0; i <
|
|
532
|
-
|
|
533
|
-
row.classList.add("text_editor_table_row")
|
|
534
|
-
for (let j = 0; j <
|
|
535
|
-
|
|
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
|
-
|
|
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
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
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
|
-
|
|
558
|
-
}
|
|
559
|
-
})
|
|
560
|
-
this.#addBlock(
|
|
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
|
-
|
|
566
|
-
direction: "row",
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
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
|
-
|
|
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: () =>
|
|
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
|
-
|
|
589
|
-
|
|
590
|
-
reader.addEventListener(
|
|
591
|
-
|
|
592
|
-
|
|
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
|
-
|
|
595
|
-
}
|
|
652
|
+
dialogImage.close();
|
|
653
|
+
},
|
|
596
654
|
})
|
|
597
|
-
)
|
|
655
|
+
);
|
|
598
656
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
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
|
-
|
|
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
|
-
|
|
614
|
-
}
|
|
615
|
-
})
|
|
616
|
-
this.#addBlock(
|
|
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
|
-
|
|
681
|
+
const buttonLineBreak = new TextEditorButtons({
|
|
621
682
|
icon: Icons.EDITOR.INSERT_PAGE_BREAK,
|
|
622
|
-
command: Commands.INSERT_LINE_BREAK
|
|
623
|
-
})
|
|
624
|
-
this.#addBlock(
|
|
683
|
+
command: Commands.INSERT_LINE_BREAK,
|
|
684
|
+
});
|
|
685
|
+
this.#addBlock(buttonLineBreak);
|
|
625
686
|
}
|
|
626
687
|
//
|
|
627
688
|
if (controls.CONTENT_CONTROLS) {
|
|
628
|
-
|
|
689
|
+
const buttonCopy = new TextEditorButtons({
|
|
629
690
|
icon: Icons.CONTENT.CONTENT_COPY,
|
|
630
|
-
command: Commands.COPY
|
|
631
|
-
})
|
|
632
|
-
|
|
691
|
+
command: Commands.COPY,
|
|
692
|
+
});
|
|
693
|
+
const buttonCut = new TextEditorButtons({
|
|
633
694
|
icon: Icons.CONTENT.CONTENT_CUT,
|
|
634
|
-
command: Commands.CUT
|
|
635
|
-
})
|
|
636
|
-
|
|
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(
|
|
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
|
-
|
|
648
|
-
for (
|
|
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;
|