chuijs 4.0.2 → 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 +61 -0
- package/README.md +43 -644
- package/framework/appLayout/default/chui_app_layout.js +308 -260
- package/framework/appLayout/default/global_style.css +85 -48
- 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 +36 -25
- 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_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 +27 -13
- package/framework/modules/chui_services/chui_services.js +39 -31
- package/framework/modules/chui_services/desktop.js +32 -31
- 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 +385 -292
- package/package.json +79 -68
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
const {setStyles, htmlToMarkdown, markdownToHtml, optionOr} = require(
|
|
1
|
+
const { setStyles, htmlToMarkdown, markdownToHtml, optionOr } = require("../../modules/chui_functions");
|
|
2
2
|
|
|
3
3
|
class Label {
|
|
4
4
|
#chui_label = document.createElement(`chui_label`);
|
|
5
|
-
constructor(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
constructor(
|
|
6
|
+
options = {
|
|
7
|
+
id: String(),
|
|
8
|
+
text: String(),
|
|
9
|
+
markdownText: String(),
|
|
10
|
+
textAlign: String(),
|
|
11
|
+
wordBreak: String(),
|
|
12
|
+
width: String(),
|
|
13
|
+
fontSize: String(),
|
|
14
|
+
}
|
|
15
|
+
) {
|
|
16
|
+
setStyles(__dirname + "/styles.css", "chUiJS_Label");
|
|
15
17
|
// Стили текста лейбла: пустая заготовка опции равносильна отсутствующей
|
|
16
18
|
const text = optionOr(options.text, undefined);
|
|
17
19
|
const markdown_text = optionOr(options.markdownText, undefined);
|
|
@@ -54,4 +56,4 @@ class Label {
|
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
exports.Label = Label
|
|
59
|
+
exports.Label = Label;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const {setStyles} = require(
|
|
2
|
-
const {Desktop} = require(
|
|
3
|
-
const {Icon} = require(
|
|
1
|
+
const { setStyles } = require("../../modules/chui_functions");
|
|
2
|
+
const { Desktop } = require("../../modules/chui_services/desktop");
|
|
3
|
+
const { Icon } = require("../chui_icons/icons");
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Ссылка: текст, который открывает адрес во внешнем браузере или вызывает свой обработчик.
|
|
@@ -34,18 +34,20 @@ class Link {
|
|
|
34
34
|
#disabled = false;
|
|
35
35
|
#external = undefined;
|
|
36
36
|
|
|
37
|
-
constructor(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
constructor(
|
|
38
|
+
options = {
|
|
39
|
+
id: String(),
|
|
40
|
+
text: String(),
|
|
41
|
+
href: String(),
|
|
42
|
+
icon: String(),
|
|
43
|
+
external: Boolean(),
|
|
44
|
+
disabled: Boolean(),
|
|
45
|
+
width: String(),
|
|
46
|
+
title: String(),
|
|
47
|
+
clickEvent: undefined,
|
|
48
|
+
clickListener: undefined,
|
|
49
|
+
}
|
|
50
|
+
) {
|
|
49
51
|
setStyles(__dirname + "/styles.css", "chUiJS_Link");
|
|
50
52
|
Link.#counter += 1;
|
|
51
53
|
this.#id = options.id === undefined ? `chui_link_${Link.#counter}` : options.id;
|
|
@@ -120,9 +122,12 @@ class Link {
|
|
|
120
122
|
if (this.#icon !== undefined) this.#icon.remove();
|
|
121
123
|
this.#icon = undefined;
|
|
122
124
|
if (icon === undefined) return this;
|
|
123
|
-
this.#icon =
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
this.#icon =
|
|
126
|
+
typeof icon === "string"
|
|
127
|
+
? new Icon(icon, "14px").set()
|
|
128
|
+
: typeof icon.set === "function"
|
|
129
|
+
? icon.set()
|
|
130
|
+
: icon;
|
|
126
131
|
this.#icon.setAttribute("aria-hidden", "true");
|
|
127
132
|
this.#root.appendChild(this.#icon);
|
|
128
133
|
return this;
|
|
@@ -192,9 +197,11 @@ class Link {
|
|
|
192
197
|
// Своё окно Electron для внешней ссылки не открываем: отдаём адрес системе
|
|
193
198
|
event.preventDefault();
|
|
194
199
|
Desktop.shell.openExternal(this.#href).catch((error) => {
|
|
195
|
-
require(
|
|
200
|
+
require("../../modules/chui_logger/chui_logger").Log.error(
|
|
201
|
+
`Link: не удалось открыть «${this.#href}»: ${error}`
|
|
202
|
+
);
|
|
196
203
|
});
|
|
197
204
|
};
|
|
198
205
|
}
|
|
199
206
|
|
|
200
|
-
exports.Link = Link
|
|
207
|
+
exports.Link = Link;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const {setStyles, optionOr} = require("../../modules/chui_functions");
|
|
2
|
-
const {Icon} = require("../chui_icons/icons");
|
|
3
|
-
const {makeKeyboardButton, RovingKeyboard} = require("../../modules/chui_a11y/chui_a11y");
|
|
4
|
-
const {I18n} = require("../../modules/chui_i18n/chui_i18n");
|
|
1
|
+
const { setStyles, optionOr } = require("../../modules/chui_functions");
|
|
2
|
+
const { Icon } = require("../chui_icons/icons");
|
|
3
|
+
const { makeKeyboardButton, RovingKeyboard } = require("../../modules/chui_a11y/chui_a11y");
|
|
4
|
+
const { I18n } = require("../../modules/chui_i18n/chui_i18n");
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Список: строки с подписью, пояснением, значком и хвостовым значением.
|
|
@@ -22,8 +22,8 @@ const {I18n} = require("../../modules/chui_i18n/chui_i18n");
|
|
|
22
22
|
* new List({ selectable: true, label: 'Сортировка', items: ['Имя', 'Дата', 'Размер'] });
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
25
|
-
* Слушателей вне своих узлов нет, поэтому `destroy()` не нужен.
|
|
26
|
-
*/
|
|
25
|
+
* Слушателей вне своих узлов нет, поэтому `destroy()` не нужен.
|
|
26
|
+
*/
|
|
27
27
|
class List {
|
|
28
28
|
static #counter = 0;
|
|
29
29
|
|
|
@@ -37,14 +37,16 @@ class List {
|
|
|
37
37
|
#listeners = [];
|
|
38
38
|
#roving = undefined;
|
|
39
39
|
|
|
40
|
-
constructor(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
constructor(
|
|
41
|
+
options = {
|
|
42
|
+
id: String(),
|
|
43
|
+
label: String(),
|
|
44
|
+
selectable: Boolean(),
|
|
45
|
+
items: [],
|
|
46
|
+
onSelect: undefined,
|
|
47
|
+
changeEvent: undefined,
|
|
48
|
+
}
|
|
49
|
+
) {
|
|
48
50
|
setStyles(__dirname + "/styles.css", "chUiJS_List");
|
|
49
51
|
List.#counter += 1;
|
|
50
52
|
this.#id = options.id === undefined ? `chui_list_${List.#counter}` : options.id;
|
|
@@ -55,7 +57,7 @@ class List {
|
|
|
55
57
|
this.#on_select = options.onSelect;
|
|
56
58
|
if (options.changeEvent !== undefined) this.addChangeListener(options.changeEvent);
|
|
57
59
|
// Клавиатура списка выборов: одна остановка Tab на список
|
|
58
|
-
if (this.#selectable) this.#roving = new RovingKeyboard(this.#root, {itemSelector: "chui_list_item"});
|
|
60
|
+
if (this.#selectable) this.#roving = new RovingKeyboard(this.#root, { itemSelector: "chui_list_item" });
|
|
59
61
|
this.setItems(options.items);
|
|
60
62
|
}
|
|
61
63
|
|
|
@@ -165,7 +167,7 @@ class List {
|
|
|
165
167
|
|
|
166
168
|
static #toItem(item) {
|
|
167
169
|
if (item instanceof ListItem) return item;
|
|
168
|
-
return new ListItem(typeof item === "string" ? {title: item} : item);
|
|
170
|
+
return new ListItem(typeof item === "string" ? { title: item } : item);
|
|
169
171
|
}
|
|
170
172
|
}
|
|
171
173
|
|
|
@@ -186,15 +188,17 @@ class ListItem {
|
|
|
186
188
|
#click_event = undefined;
|
|
187
189
|
#disabled = false;
|
|
188
190
|
|
|
189
|
-
constructor(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
191
|
+
constructor(
|
|
192
|
+
options = {
|
|
193
|
+
id: String(),
|
|
194
|
+
title: String(),
|
|
195
|
+
subtitle: String(),
|
|
196
|
+
icon: String(),
|
|
197
|
+
meta: String(),
|
|
198
|
+
disabled: Boolean(),
|
|
199
|
+
clickEvent: undefined,
|
|
200
|
+
}
|
|
201
|
+
) {
|
|
198
202
|
ListItem.#counter += 1;
|
|
199
203
|
this.#root.id = options.id === undefined ? `chui_list_item_${ListItem.#counter}` : options.id;
|
|
200
204
|
this.#click_event = options.clickEvent;
|
|
@@ -318,5 +322,5 @@ class ListItem {
|
|
|
318
322
|
static ICON_SIZE = "18px";
|
|
319
323
|
}
|
|
320
324
|
|
|
321
|
-
exports.List = List
|
|
322
|
-
exports.ListItem = ListItem
|
|
325
|
+
exports.List = List;
|
|
326
|
+
exports.ListItem = ListItem;
|
|
@@ -98,7 +98,8 @@ chui_list_item:has(.list_item_button):active {
|
|
|
98
98
|
color: var(--text_color_hover);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
.list_item_button:focus-visible,
|
|
101
|
+
.list_item_button:focus-visible,
|
|
102
|
+
chui_list_item:focus-visible {
|
|
102
103
|
outline: var(--focus_outline);
|
|
103
104
|
outline-offset: var(--focus_outline_offset);
|
|
104
105
|
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
const {setStyles, markdownToHtml} = require("../../modules/chui_functions");
|
|
2
|
-
const {Icon, Icons} = require("../chui_icons/icons");
|
|
3
|
-
const {RovingKeyboard} = require("../../modules/chui_a11y/chui_a11y");
|
|
4
|
-
const {Validate} = require("../../modules/chui_validate/chui_validate");
|
|
5
|
-
const {I18n} = require("../../modules/chui_i18n/chui_i18n");
|
|
1
|
+
const { setStyles, markdownToHtml } = require("../../modules/chui_functions");
|
|
2
|
+
const { Icon, Icons } = require("../chui_icons/icons");
|
|
3
|
+
const { RovingKeyboard } = require("../../modules/chui_a11y/chui_a11y");
|
|
4
|
+
const { Validate } = require("../../modules/chui_validate/chui_validate");
|
|
5
|
+
const { I18n } = require("../../modules/chui_i18n/chui_i18n");
|
|
6
6
|
|
|
7
7
|
/** Действия панели разметки: ключ подписи, значок, сочетание и правка */
|
|
8
8
|
const ACTIONS = [
|
|
9
|
-
{id: "bold", labelKey: "editor.bold", icon: Icons.EDITOR.FORMAT_BOLD, shortcut: "Control+B"},
|
|
10
|
-
{id: "italic", labelKey: "editor.italic", icon: Icons.EDITOR.FORMAT_ITALIC, shortcut: "Control+I"},
|
|
11
|
-
{id: "strike", labelKey: "editor.strikethrough", icon: Icons.EDITOR.STRIKETHROUGH_S},
|
|
12
|
-
{id: "heading", labelKey: "editor.heading", icon: Icons.EDITOR.TITLE},
|
|
13
|
-
{id: "quote", labelKey: "editor.quote", icon: Icons.EDITOR.FORMAT_QUOTE},
|
|
14
|
-
{id: "bullets", labelKey: "editor.list", icon: Icons.EDITOR.FORMAT_LIST_BULLETED},
|
|
15
|
-
{id: "numbers", labelKey: "editor.orderedList", icon: Icons.EDITOR.FORMAT_LIST_NUMBERED},
|
|
16
|
-
{id: "checklist", labelKey: "editor.checklist", icon: Icons.EDITOR.CHECKLIST},
|
|
17
|
-
{id: "code", labelKey: "editor.code", icon: Icons.ACTIONS.CODE},
|
|
18
|
-
{id: "codeblock", labelKey: "editor.codeBlock", icon: Icons.ACTIONS.TERMINAL},
|
|
19
|
-
{id: "link", labelKey: "editor.link", icon: Icons.EDITOR.INSERT_LINK, shortcut: "Control+K"},
|
|
9
|
+
{ id: "bold", labelKey: "editor.bold", icon: Icons.EDITOR.FORMAT_BOLD, shortcut: "Control+B" },
|
|
10
|
+
{ id: "italic", labelKey: "editor.italic", icon: Icons.EDITOR.FORMAT_ITALIC, shortcut: "Control+I" },
|
|
11
|
+
{ id: "strike", labelKey: "editor.strikethrough", icon: Icons.EDITOR.STRIKETHROUGH_S },
|
|
12
|
+
{ id: "heading", labelKey: "editor.heading", icon: Icons.EDITOR.TITLE },
|
|
13
|
+
{ id: "quote", labelKey: "editor.quote", icon: Icons.EDITOR.FORMAT_QUOTE },
|
|
14
|
+
{ id: "bullets", labelKey: "editor.list", icon: Icons.EDITOR.FORMAT_LIST_BULLETED },
|
|
15
|
+
{ id: "numbers", labelKey: "editor.orderedList", icon: Icons.EDITOR.FORMAT_LIST_NUMBERED },
|
|
16
|
+
{ id: "checklist", labelKey: "editor.checklist", icon: Icons.EDITOR.CHECKLIST },
|
|
17
|
+
{ id: "code", labelKey: "editor.code", icon: Icons.ACTIONS.CODE },
|
|
18
|
+
{ id: "codeblock", labelKey: "editor.codeBlock", icon: Icons.ACTIONS.TERMINAL },
|
|
19
|
+
{ id: "link", labelKey: "editor.link", icon: Icons.EDITOR.INSERT_LINK, shortcut: "Control+K" },
|
|
20
20
|
];
|
|
21
21
|
|
|
22
22
|
/** Что делает каждое действие: обёртка вокруг выделения или приставка к строкам */
|
|
23
23
|
const WRAPS = {
|
|
24
|
-
bold: {before: "**", after: "**", placeholderKey: "editor.placeholderText"},
|
|
25
|
-
italic: {before: "*", after: "*", placeholderKey: "editor.placeholderText"},
|
|
26
|
-
strike: {before: "~~", after: "~~", placeholderKey: "editor.placeholderText"},
|
|
27
|
-
code: {before: "`", after: "`", placeholderKey: "editor.placeholderCode"},
|
|
28
|
-
codeblock: {before: "```\n", after: "\n```", placeholderKey: "editor.placeholderCode"},
|
|
29
|
-
link: {before: "[", after: "](url)", placeholderKey: "editor.placeholderText"},
|
|
24
|
+
bold: { before: "**", after: "**", placeholderKey: "editor.placeholderText" },
|
|
25
|
+
italic: { before: "*", after: "*", placeholderKey: "editor.placeholderText" },
|
|
26
|
+
strike: { before: "~~", after: "~~", placeholderKey: "editor.placeholderText" },
|
|
27
|
+
code: { before: "`", after: "`", placeholderKey: "editor.placeholderCode" },
|
|
28
|
+
codeblock: { before: "```\n", after: "\n```", placeholderKey: "editor.placeholderCode" },
|
|
29
|
+
link: { before: "[", after: "](url)", placeholderKey: "editor.placeholderText" },
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
/**
|
|
@@ -95,22 +95,24 @@ class MarkdownEditor {
|
|
|
95
95
|
#listeners = [];
|
|
96
96
|
#on_change = undefined;
|
|
97
97
|
|
|
98
|
-
constructor(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
98
|
+
constructor(
|
|
99
|
+
options = {
|
|
100
|
+
id: String(),
|
|
101
|
+
name: String(),
|
|
102
|
+
title: String(),
|
|
103
|
+
label: String(),
|
|
104
|
+
hint: String(),
|
|
105
|
+
value: String(),
|
|
106
|
+
rows: Number(),
|
|
107
|
+
preview: Boolean(),
|
|
108
|
+
maxLength: Number(),
|
|
109
|
+
width: String(),
|
|
110
|
+
disabled: Boolean(),
|
|
111
|
+
readOnly: Boolean(),
|
|
112
|
+
changeListener: undefined,
|
|
113
|
+
onChange: undefined,
|
|
114
|
+
}
|
|
115
|
+
) {
|
|
114
116
|
setStyles(__dirname + "/styles.css", "chUiJS_MarkdownEditor");
|
|
115
117
|
MarkdownEditor.#counter += 1;
|
|
116
118
|
this.#id = options.id === undefined ? `chui_markdown_editor_${MarkdownEditor.#counter}` : options.id;
|
|
@@ -145,7 +147,7 @@ class MarkdownEditor {
|
|
|
145
147
|
this.#buildToolbar();
|
|
146
148
|
// Панель — одна остановка обхода: по кнопкам ходят стрелки/Home/End (tabindex переходящий).
|
|
147
149
|
// Слушатели слоя стоят на самой панели, поэтому destroy() за ним не нужен (как у TextEditorPanel)
|
|
148
|
-
new RovingKeyboard(this.#toolbar, {itemSelector: "button"});
|
|
150
|
+
new RovingKeyboard(this.#toolbar, { itemSelector: "button" });
|
|
149
151
|
this.#panes.appendChild(this.#textarea);
|
|
150
152
|
this.#panes.appendChild(this.#preview);
|
|
151
153
|
this.#footer.appendChild(this.#count);
|
|
@@ -327,7 +329,10 @@ class MarkdownEditor {
|
|
|
327
329
|
if (this.#preview_on) this.#preview.innerHTML = this.getPreviewHtml();
|
|
328
330
|
if (this.#preview_button !== undefined) {
|
|
329
331
|
this.#preview_button.setAttribute("aria-pressed", this.#preview_on ? "true" : "false");
|
|
330
|
-
this.#preview_button.setAttribute(
|
|
332
|
+
this.#preview_button.setAttribute(
|
|
333
|
+
"aria-label",
|
|
334
|
+
this.#preview_on ? I18n.t("editor.showMarkup") : I18n.t("editor.showPreview")
|
|
335
|
+
);
|
|
331
336
|
}
|
|
332
337
|
return this;
|
|
333
338
|
}
|
|
@@ -409,7 +414,12 @@ class MarkdownEditor {
|
|
|
409
414
|
button.type = "button";
|
|
410
415
|
button.className = "markdown_editor_action";
|
|
411
416
|
button.dataset.action = action.id;
|
|
412
|
-
button.setAttribute(
|
|
417
|
+
button.setAttribute(
|
|
418
|
+
"aria-label",
|
|
419
|
+
action.shortcut === undefined
|
|
420
|
+
? I18n.t(action.labelKey)
|
|
421
|
+
: `${I18n.t(action.labelKey)} (${action.shortcut.replace("Control", "Ctrl")})`
|
|
422
|
+
);
|
|
413
423
|
if (action.shortcut !== undefined) button.setAttribute("aria-keyshortcuts", action.shortcut);
|
|
414
424
|
const glyph = new Icon(action.icon, "18px").set();
|
|
415
425
|
glyph.setAttribute("aria-hidden", "true");
|
|
@@ -501,7 +511,13 @@ class MarkdownEditor {
|
|
|
501
511
|
const from = start + before.length;
|
|
502
512
|
const to = from + inner.length;
|
|
503
513
|
// С выделением остаётся выделен весь результат, без него каретка встаёт внутрь разметки
|
|
504
|
-
return this.#replaceRange(
|
|
514
|
+
return this.#replaceRange(
|
|
515
|
+
start,
|
|
516
|
+
end,
|
|
517
|
+
text,
|
|
518
|
+
selected === "" && placeholder !== "" ? from : start,
|
|
519
|
+
selected === "" && placeholder !== "" ? to : start + text.length
|
|
520
|
+
);
|
|
505
521
|
}
|
|
506
522
|
|
|
507
523
|
#eachLine(marker = undefined) {
|
|
@@ -528,7 +544,7 @@ class MarkdownEditor {
|
|
|
528
544
|
else if (id === "bullets") this.#eachLine("- ");
|
|
529
545
|
else if (id === "checklist") this.#eachLine("- [ ] ");
|
|
530
546
|
else if (id === "numbers") this.#eachLine((line, index) => `${index + 1}. ${line}`);
|
|
531
|
-
if (action !== undefined) this.#announce(I18n.t("editor.applied", {action: I18n.t(action.labelKey)}));
|
|
547
|
+
if (action !== undefined) this.#announce(I18n.t("editor.applied", { action: I18n.t(action.labelKey) }));
|
|
532
548
|
return this;
|
|
533
549
|
}
|
|
534
550
|
|
|
@@ -567,4 +583,4 @@ class MarkdownEditor {
|
|
|
567
583
|
};
|
|
568
584
|
}
|
|
569
585
|
|
|
570
|
-
exports.MarkdownEditor = MarkdownEditor
|
|
586
|
+
exports.MarkdownEditor = MarkdownEditor;
|