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