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