niuma-ui 2.0.4 → 2.1.0
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 +67 -0
- package/NOTICE +0 -1
- package/README.md +3 -3
- package/README.zh-CN.md +3 -3
- package/dist/components/_shared/index.d.ts +2 -2
- package/dist/components/_shared/src/overlay-utils.d.ts +44 -1
- package/dist/components/_shared/src/overlay-utils.js +87 -2
- package/dist/components/alert/index.d.ts +1 -0
- package/dist/components/alert/src/RsAlert.css +120 -65
- package/dist/components/alert/src/RsAlert.d.ts +24 -5
- package/dist/components/alert/src/RsAlert.impl.js +108 -36
- package/dist/components/alert/src/RsAlert.js +1 -1
- package/dist/components/alert/src/alert-utils.d.ts +37 -0
- package/dist/components/alert/src/alert-utils.js +71 -0
- package/dist/components/auto-complete/src/RsAutoComplete.d.ts +1 -1
- package/dist/components/button/src/RsButton.css +75 -72
- package/dist/components/button/src/RsButton.d.ts +1 -4
- package/dist/components/button/src/RsButton.impl.js +3 -7
- package/dist/components/button/src/RsButton.js +1 -1
- package/dist/components/card/src/RsCard.d.ts +1 -1
- package/dist/components/code-block/index.d.ts +1 -0
- package/dist/components/code-block/src/RsCodeBlock.css +93 -52
- package/dist/components/code-block/src/RsCodeBlock.d.ts +36 -9
- package/dist/components/code-block/src/RsCodeBlock.impl.js +203 -84
- package/dist/components/code-block/src/RsCodeBlock.js +1 -1
- package/dist/components/code-block/src/code-block-highlight.d.ts +4 -0
- package/dist/components/code-block/src/code-block-highlight.js +34 -0
- package/dist/components/code-block/src/code-block-utils.d.ts +23 -0
- package/dist/components/code-block/src/code-block-utils.js +71 -0
- package/dist/components/code-editor/index.d.ts +1 -1
- package/dist/components/code-editor/src/RsCodeEditor.css +118 -92
- package/dist/components/code-editor/src/RsCodeEditor.d.ts +14 -3
- package/dist/components/code-editor/src/RsCodeEditor.impl.js +261 -94
- package/dist/components/code-editor/src/RsCodeEditor.js +1 -1
- package/dist/components/code-editor/src/code-editor-utils.d.ts +15 -0
- package/dist/components/code-editor/src/code-editor-utils.js +36 -1
- package/dist/components/code-editor/src/code-mirror-completion.d.ts +1 -1
- package/dist/components/code-editor/src/code-mirror-completion.js +8 -5
- package/dist/components/code-editor/src/code-mirror-diagnostics.d.ts +2 -3
- package/dist/components/code-editor/src/code-mirror-diagnostics.js +3 -4
- package/dist/components/code-editor/src/code-mirror-ghost.d.ts +1 -1
- package/dist/components/code-editor/src/code-mirror-ghost.js +12 -3
- package/dist/components/code-editor/src/code-mirror-inline-edit.js +8 -3
- package/dist/components/code-editor/src/code-mirror-intel.d.ts +2 -2
- package/dist/components/code-editor/src/code-mirror-intel.js +50 -39
- package/dist/components/code-editor/src/code-mirror-lang.js +4 -0
- package/dist/components/code-editor/src/code-mirror-session.d.ts +13 -0
- package/dist/components/code-editor/src/code-mirror-session.js +30 -0
- package/dist/components/config-provider/src/RsConfigProvider.css +1 -1
- package/dist/components/config-provider/src/RsConfigProvider.d.ts +2 -2
- package/dist/components/config-provider/src/RsConfigProvider.impl.js +7 -16
- package/dist/components/config-provider/src/RsConfigProvider.js +1 -1
- package/dist/components/context-menu/index.d.ts +1 -1
- package/dist/components/context-menu/src/RsContextMenu.css +115 -89
- package/dist/components/context-menu/src/RsContextMenu.d.ts +32 -11
- package/dist/components/context-menu/src/RsContextMenu.impl.js +795 -48
- package/dist/components/context-menu/src/RsContextMenuItems.d.ts +25 -1
- package/dist/components/context-menu/src/RsContextMenuItems.impl.js +110 -61
- package/dist/components/context-menu/src/context-menu-utils.d.ts +89 -3
- package/dist/components/context-menu/src/context-menu-utils.js +168 -3
- package/dist/components/date-picker/src/RsDatePicker.d.ts +2 -2
- package/dist/components/date-picker/src/RsDateTimePicker.d.ts +2 -2
- package/dist/components/descriptions/index.d.ts +1 -1
- package/dist/components/descriptions/src/RsDescriptions.css +38 -11
- package/dist/components/descriptions/src/RsDescriptions.d.ts +20 -4
- package/dist/components/descriptions/src/RsDescriptions.impl.js +89 -19
- package/dist/components/descriptions/src/RsDescriptionsItem.impl.js +13 -6
- package/dist/components/descriptions/src/descriptions-utils.d.ts +19 -0
- package/dist/components/descriptions/src/descriptions-utils.js +39 -1
- package/dist/components/dialog/index.d.ts +1 -1
- package/dist/components/dialog/src/RsConfirmDialog.css +47 -21
- package/dist/components/dialog/src/RsConfirmDialog.d.ts +19 -7
- package/dist/components/dialog/src/RsConfirmDialog.impl.js +349 -119
- package/dist/components/dialog/src/RsConfirmDialog.js +2 -1
- package/dist/components/dialog/src/RsDialog.css +102 -109
- package/dist/components/dialog/src/RsDialog.d.ts +34 -24
- package/dist/components/dialog/src/RsDialog.impl.js +410 -177
- package/dist/components/dialog/src/RsDialog.js +2 -1
- package/dist/components/dialog/src/dialog-utils.d.ts +40 -1
- package/dist/components/dialog/src/dialog-utils.js +152 -1
- package/dist/components/dialog/src/dialog-window.js +29 -8
- package/dist/components/drawer/index.d.ts +1 -1
- package/dist/components/drawer/src/RsDrawer.css +61 -29
- package/dist/components/drawer/src/RsDrawer.d.ts +37 -21
- package/dist/components/drawer/src/RsDrawer.impl.js +441 -223
- package/dist/components/drawer/src/drawer-utils.d.ts +35 -0
- package/dist/components/drawer/src/drawer-utils.js +131 -1
- package/dist/components/dropdown/index.d.ts +1 -1
- package/dist/components/dropdown/src/RsDropdown.css +140 -61
- package/dist/components/dropdown/src/RsDropdown.d.ts +39 -6
- package/dist/components/dropdown/src/RsDropdown.impl.js +693 -63
- package/dist/components/dropdown/src/RsDropdownItemView.impl.js +17 -7
- package/dist/components/dropdown/src/RsDropdownItems.d.ts +32 -3
- package/dist/components/dropdown/src/RsDropdownItems.impl.js +171 -59
- package/dist/components/dropdown/src/dropdown-utils.d.ts +50 -0
- package/dist/components/dropdown/src/dropdown-utils.js +103 -3
- package/dist/components/empty/index.d.ts +1 -0
- package/dist/components/empty/src/RsEmpty.css +105 -23
- package/dist/components/empty/src/RsEmpty.d.ts +27 -4
- package/dist/components/empty/src/RsEmpty.impl.js +154 -11
- package/dist/components/empty/src/RsEmpty.js +2 -1
- package/dist/components/empty/src/empty-utils.d.ts +28 -0
- package/dist/components/empty/src/empty-utils.js +55 -0
- package/dist/components/form/src/RsForm.d.ts +1 -1
- package/dist/components/input-number/src/RsInputNumber.d.ts +1 -1
- package/dist/components/label/src/RsLabel.d.ts +1 -1
- package/dist/components/loading/index.d.ts +1 -0
- package/dist/components/loading/src/RsLoading.css +13 -97
- package/dist/components/loading/src/RsLoading.d.ts +52 -2
- package/dist/components/loading/src/RsLoading.impl.js +216 -33
- package/dist/components/loading/src/RsLoading.js +2 -1
- package/dist/components/loading/src/loading-status.css +210 -0
- package/dist/components/loading/src/loading-status.d.ts +34 -0
- package/dist/components/loading/src/loading-status.impl.js +84 -0
- package/dist/components/loading/src/loading-status.js +8 -0
- package/dist/components/loading/src/loading-utils.d.ts +51 -4
- package/dist/components/loading/src/loading-utils.js +122 -0
- package/dist/components/loading-bar/index.d.ts +1 -0
- package/dist/components/loading-bar/src/RsLoadingBar.css +72 -8
- package/dist/components/loading-bar/src/RsLoadingBar.d.ts +55 -11
- package/dist/components/loading-bar/src/RsLoadingBar.impl.js +298 -57
- package/dist/components/loading-bar/src/RsLoadingBar.js +1 -1
- package/dist/components/loading-bar/src/loading-bar-utils.d.ts +69 -0
- package/dist/components/loading-bar/src/loading-bar-utils.js +97 -0
- package/dist/components/log/src/RsLog.css +52 -144
- package/dist/components/log/src/RsLog.d.ts +12 -11
- package/dist/components/log/src/RsLog.impl.js +181 -148
- package/dist/components/log/src/RsLog.js +1 -1
- package/dist/components/log/src/RsLogRow.css +152 -0
- package/dist/components/log/src/RsLogRow.d.ts +35 -0
- package/dist/components/log/src/RsLogRow.impl.js +91 -0
- package/dist/components/log/src/RsLogRow.js +8 -0
- package/dist/components/log/src/log-utils.d.ts +8 -0
- package/dist/components/log/src/log-utils.js +71 -10
- package/dist/components/markdown/index.d.ts +1 -1
- package/dist/components/markdown/src/RsMarkdown.css +75 -32
- package/dist/components/markdown/src/RsMarkdown.d.ts +6 -2
- package/dist/components/markdown/src/RsMarkdown.impl.js +185 -17
- package/dist/components/markdown/src/markdown-utils.d.ts +26 -0
- package/dist/components/markdown/src/markdown-utils.js +114 -12
- package/dist/components/mentions/src/RsMentions.d.ts +2 -2
- package/dist/components/menu/index.d.ts +1 -1
- package/dist/components/menu/src/RsMenu.css +70 -29
- package/dist/components/menu/src/RsMenu.d.ts +58 -4
- package/dist/components/menu/src/RsMenu.impl.js +93 -46
- package/dist/components/menu/src/RsMenuItems.d.ts +22 -5
- package/dist/components/menu/src/RsMenuItems.impl.js +506 -154
- package/dist/components/menu/src/menu-utils.d.ts +56 -0
- package/dist/components/menu/src/menu-utils.js +139 -6
- package/dist/components/monaco-editor/index.d.ts +1 -1
- package/dist/components/monaco-editor/src/RsMonacoEditor.css +28 -16
- package/dist/components/monaco-editor/src/RsMonacoEditor.d.ts +39 -41
- package/dist/components/monaco-editor/src/RsMonacoEditor.impl.js +212 -133
- package/dist/components/monaco-editor/src/RsMonacoEditor.js +1 -1
- package/dist/components/monaco-editor/src/monaco-editor-utils.d.ts +126 -0
- package/dist/components/monaco-editor/src/monaco-editor-utils.js +302 -0
- package/dist/components/pagination/index.d.ts +2 -2
- package/dist/components/pagination/src/RsPagination.css +93 -46
- package/dist/components/pagination/src/RsPagination.d.ts +68 -8
- package/dist/components/pagination/src/RsPagination.impl.js +229 -86
- package/dist/components/pagination/src/RsPagination.js +1 -1
- package/dist/components/pagination/src/pagination-utils.d.ts +59 -0
- package/dist/components/pagination/src/pagination-utils.js +105 -1
- package/dist/components/popover/index.d.ts +1 -0
- package/dist/components/popover/src/RsPopover.css +124 -14
- package/dist/components/popover/src/RsPopover.d.ts +38 -7
- package/dist/components/popover/src/RsPopover.impl.js +546 -35
- package/dist/components/popover/src/RsPopover.js +2 -1
- package/dist/components/popover/src/popover-utils.d.ts +24 -2
- package/dist/components/popover/src/popover-utils.js +55 -0
- package/dist/components/sidebar/index.d.ts +1 -0
- package/dist/components/sidebar/src/RsSidebar.css +91 -33
- package/dist/components/sidebar/src/RsSidebar.d.ts +17 -9
- package/dist/components/sidebar/src/RsSidebar.impl.js +124 -22
- package/dist/components/sidebar/src/RsSidebar.js +1 -1
- package/dist/components/sidebar/src/RsSidebarGroup.css +23 -6
- package/dist/components/sidebar/src/RsSidebarGroup.d.ts +6 -2
- package/dist/components/sidebar/src/RsSidebarGroup.impl.js +17 -4
- package/dist/components/sidebar/src/RsSidebarGroup.js +1 -1
- package/dist/components/sidebar/src/RsSidebarItem.css +50 -20
- package/dist/components/sidebar/src/RsSidebarItem.d.ts +21 -3
- package/dist/components/sidebar/src/RsSidebarItem.impl.js +71 -20
- package/dist/components/sidebar/src/RsSidebarItem.js +1 -1
- package/dist/components/sidebar/src/sidebar-utils.d.ts +47 -0
- package/dist/components/sidebar/src/sidebar-utils.js +72 -0
- package/dist/components/split-pane/index.d.ts +2 -2
- package/dist/components/split-pane/src/RsSplitPane.css +41 -30
- package/dist/components/split-pane/src/RsSplitPane.d.ts +6 -2
- package/dist/components/split-pane/src/RsSplitPane.impl.js +153 -45
- package/dist/components/split-pane/src/split-pane-utils.d.ts +23 -0
- package/dist/components/split-pane/src/split-pane-utils.js +18 -1
- package/dist/components/stat-card/index.d.ts +1 -0
- package/dist/components/stat-card/src/RsStatCard.css +129 -25
- package/dist/components/stat-card/src/RsStatCard.d.ts +40 -4
- package/dist/components/stat-card/src/RsStatCard.impl.js +106 -12
- package/dist/components/stat-card/src/RsStatCard.js +1 -1
- package/dist/components/stat-card/src/stat-card-utils.d.ts +39 -0
- package/dist/components/stat-card/src/stat-card-utils.js +113 -0
- package/dist/components/steps/index.d.ts +1 -1
- package/dist/components/steps/src/RsSteps.css +158 -37
- package/dist/components/steps/src/RsSteps.d.ts +69 -5
- package/dist/components/steps/src/RsSteps.impl.js +168 -28
- package/dist/components/steps/src/RsSteps.js +1 -1
- package/dist/components/steps/src/steps-utils.d.ts +51 -1
- package/dist/components/steps/src/steps-utils.js +67 -1
- package/dist/components/table/src/RsTable.impl.js +4 -2
- package/dist/components/table/src/composables/useRsTableContextMenu.d.ts +16 -0
- package/dist/components/table/src/composables/useRsTableContextMenu.js +1 -1
- package/dist/components/table/src/composables/useRsTableEngine.js +6 -2
- package/dist/components/table/src/composables/useRsTableScrollLayout.js +2 -0
- package/dist/components/table/src/composables/useRsTableShell.d.ts +16 -0
- package/dist/components/table/src/rs-table-props.d.ts +1 -1
- package/dist/components/table/src/rs-table-props.js +0 -1
- package/dist/components/table/src/table-body/RsTableBody.impl.js +1 -0
- package/dist/components/table/src/table-body/RsTableCell.impl.js +1 -1
- package/dist/components/table/src/table-body/RsTableCellEditor.impl.js +10 -2
- package/dist/components/table/src/table-body/RsTableColGroup.impl.js +1 -0
- package/dist/components/table/src/table-footer/RsTableSummaryRow.impl.js +1 -0
- package/dist/components/table/src/table-header/RsTableHeader.impl.js +1 -0
- package/dist/components/table/src/utils/table-utils.d.ts +10 -6
- package/dist/components/table/src/utils/table-utils.js +27 -25
- package/dist/components/table/style/rs-table.css +86 -28
- package/dist/components/tabs/index.d.ts +2 -2
- package/dist/components/tabs/src/RsTabs.css +225 -101
- package/dist/components/tabs/src/RsTabs.d.ts +37 -8
- package/dist/components/tabs/src/RsTabs.impl.js +400 -270
- package/dist/components/tabs/src/tabs-utils.d.ts +41 -2
- package/dist/components/tabs/src/tabs-utils.js +55 -1
- package/dist/components/terminal/index.d.ts +1 -1
- package/dist/components/terminal/src/RsTerminal.css +60 -37
- package/dist/components/terminal/src/RsTerminal.d.ts +36 -4
- package/dist/components/terminal/src/RsTerminal.impl.js +288 -68
- package/dist/components/terminal/src/RsTerminal.js +1 -1
- package/dist/components/terminal/src/terminal-utils.d.ts +42 -4
- package/dist/components/terminal/src/terminal-utils.js +113 -10
- package/dist/components/textarea/src/RsTextarea.d.ts +1 -1
- package/dist/components/time-picker/src/RsTimePicker.d.ts +2 -2
- package/dist/components/toaster/src/RsToaster.css +156 -203
- package/dist/components/toaster/src/RsToaster.d.ts +32 -2
- package/dist/components/toaster/src/RsToaster.impl.js +309 -34
- package/dist/components/toaster/src/toast-store.d.ts +95 -0
- package/dist/components/toaster/src/toast-store.js +177 -0
- package/dist/components/toaster/src/toast-utils.d.ts +60 -0
- package/dist/components/toaster/src/toast-utils.js +86 -0
- package/dist/components/toolbar/index.d.ts +1 -1
- package/dist/components/toolbar/src/RsToolbar.css +206 -32
- package/dist/components/toolbar/src/RsToolbar.d.ts +41 -16
- package/dist/components/toolbar/src/RsToolbar.impl.js +146 -18
- package/dist/components/toolbar/src/RsToolbar.js +2 -1
- package/dist/components/toolbar/src/toolbar-utils.d.ts +20 -0
- package/dist/components/toolbar/src/toolbar-utils.js +105 -0
- package/dist/components/tooltip/index.d.ts +1 -0
- package/dist/components/tooltip/src/RsTooltip.css +104 -26
- package/dist/components/tooltip/src/RsTooltip.d.ts +38 -16
- package/dist/components/tooltip/src/RsTooltip.impl.js +420 -51
- package/dist/components/tooltip/src/RsTooltip.js +2 -1
- package/dist/components/tooltip/src/RsTooltipProvider.d.ts +4 -4
- package/dist/components/tooltip/src/RsTooltipProvider.impl.js +51 -14
- package/dist/components/tooltip/src/tooltip-utils.d.ts +30 -0
- package/dist/components/tooltip/src/tooltip-utils.js +23 -0
- package/dist/components/tree/index.d.ts +2 -2
- package/dist/components/tree/src/RsTree.css +84 -75
- package/dist/components/tree/src/RsTree.d.ts +20 -20
- package/dist/components/tree/src/RsTree.impl.js +292 -66
- package/dist/components/tree/src/RsTree.js +1 -1
- package/dist/components/tree/src/tree-utils.d.ts +22 -0
- package/dist/components/tree/src/tree-utils.js +18 -4
- package/dist/components/tree-select/src/RsTreeSelect.d.ts +1 -1
- package/dist/components/virtual-list/index.d.ts +1 -1
- package/dist/components/virtual-list/src/RsVirtualList.css +64 -9
- package/dist/components/virtual-list/src/RsVirtualList.d.ts +31 -5
- package/dist/components/virtual-list/src/RsVirtualList.impl.js +425 -76
- package/dist/components/virtual-list/src/RsVirtualList.js +1 -1
- package/dist/components/virtual-list/src/virtual-list-utils.d.ts +64 -1
- package/dist/components/virtual-list/src/virtual-list-utils.js +215 -1
- package/dist/composables/useRsLoadingBar.d.ts +2 -5
- package/dist/composables/useRsLoadingBar.js +21 -5
- package/dist/composables/useRsTabsNav.d.ts +3 -1
- package/dist/composables/useRsTabsNav.js +96 -28
- package/dist/composables/useRsToast.d.ts +11 -13
- package/dist/composables/useRsToast.js +66 -17
- package/dist/index.d.ts +30 -21
- package/dist/index.js +14 -0
- package/dist/locale/apply.js +6 -1
- package/dist/locale/messages.js +128 -2
- package/dist/styles.css +465 -808
- package/dist/theme/brand.example.css +3 -2
- package/dist/vite-plugins/niuma-ui-host.js +1 -1
- package/package.json +2 -5
- package/dist/components/_shared/src/reka.d.ts +0 -2
- package/dist/components/_shared/src/reka.js +0 -2
|
@@ -1,21 +1,36 @@
|
|
|
1
|
+
import { readResolvedTheme } from "../../../theme/apply.js";
|
|
1
2
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
2
3
|
import RsButton_default from "../../button/src/RsButton.js";
|
|
3
4
|
import RsCodeEditor_default from "../../code-editor/src/RsCodeEditor.js";
|
|
4
|
-
import { renderMarkdown, resolveMarkdownHeight, resolveMarkdownMode } from "./markdown-utils.js";
|
|
5
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, normalizeClass, normalizeStyle, openBlock, renderList, toDisplayString, unref, useModel, withCtx } from "vue";
|
|
5
|
+
import { applyMarkdownTabMove, isMarkdownRtl, nearestMarkdownThemeHost, renderMarkdown, resolveMarkdownEditorTheme, resolveMarkdownHeight, resolveMarkdownMode, resolveMarkdownTabMove } from "./markdown-utils.js";
|
|
6
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, nextTick, normalizeClass, normalizeStyle, onActivated, onDeactivated, onMounted, onUnmounted, openBlock, ref, renderList, toDisplayString, unref, useId, useModel, watch, withCtx } from "vue";
|
|
6
7
|
//#region src/components/markdown/src/RsMarkdown.vue?vue&type=script&setup=true&lang.ts
|
|
7
|
-
var _hoisted_1 = [
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
var _hoisted_1 = [
|
|
9
|
+
"id",
|
|
10
|
+
"data-rs-theme",
|
|
11
|
+
"aria-label",
|
|
12
|
+
"aria-disabled"
|
|
13
|
+
];
|
|
14
|
+
var _hoisted_2 = ["aria-label"];
|
|
15
|
+
var _hoisted_3 = [
|
|
16
|
+
"id",
|
|
17
|
+
"role",
|
|
18
|
+
"aria-labelledby",
|
|
19
|
+
"aria-label",
|
|
20
|
+
"tabindex"
|
|
21
|
+
];
|
|
22
|
+
var _hoisted_4 = {
|
|
10
23
|
key: 0,
|
|
11
|
-
class: "rs-markdown__editor"
|
|
24
|
+
class: "rs-markdown__editor",
|
|
25
|
+
dir: "ltr"
|
|
12
26
|
};
|
|
13
|
-
var
|
|
14
|
-
var
|
|
27
|
+
var _hoisted_5 = ["innerHTML"];
|
|
28
|
+
var _hoisted_6 = {
|
|
15
29
|
key: 1,
|
|
16
30
|
class: "rs-markdown__empty"
|
|
17
31
|
};
|
|
18
32
|
var RsMarkdown_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
33
|
+
name: "RsMarkdown",
|
|
19
34
|
__name: "RsMarkdown",
|
|
20
35
|
props: /*@__PURE__*/ mergeModels({
|
|
21
36
|
readonly: {
|
|
@@ -40,7 +55,9 @@ var RsMarkdown_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
40
55
|
disabled: {
|
|
41
56
|
type: Boolean,
|
|
42
57
|
default: false
|
|
43
|
-
}
|
|
58
|
+
},
|
|
59
|
+
ariaLabel: {},
|
|
60
|
+
id: {}
|
|
44
61
|
}, {
|
|
45
62
|
"modelValue": { default: "" },
|
|
46
63
|
"modelModifiers": {},
|
|
@@ -48,15 +65,33 @@ var RsMarkdown_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
48
65
|
"modeModifiers": {}
|
|
49
66
|
}),
|
|
50
67
|
emits: ["update:modelValue", "update:mode"],
|
|
51
|
-
setup(__props) {
|
|
68
|
+
setup(__props, { expose: __expose }) {
|
|
52
69
|
const model = useModel(__props, "modelValue");
|
|
53
70
|
const mode = useModel(__props, "mode");
|
|
54
71
|
const props = __props;
|
|
55
72
|
const { t } = useRsI18n();
|
|
73
|
+
const autoId = useId();
|
|
74
|
+
const rootRef = ref(null);
|
|
75
|
+
const panelRef = ref(null);
|
|
76
|
+
const editorRef = ref(null);
|
|
77
|
+
const previewHtml = ref("");
|
|
78
|
+
const editorTheme = ref(props.theme === "auto" ? "auto" : props.theme);
|
|
79
|
+
let previewTimer = null;
|
|
80
|
+
let unobserveTheme = () => {};
|
|
81
|
+
let alive = true;
|
|
56
82
|
const activeMode = computed(() => resolveMarkdownMode(mode.value, props.readonly));
|
|
57
83
|
const showToggle = computed(() => props.showModeToggle && !props.readonly && !props.disabled);
|
|
84
|
+
const rootId = computed(() => props.id?.trim() || autoId);
|
|
85
|
+
const panelDomId = computed(() => `${rootId.value}-panel`);
|
|
86
|
+
const surfaceTheme = computed(() => props.theme === "auto" ? void 0 : props.theme);
|
|
87
|
+
const regionLabel = computed(() => props.ariaLabel?.trim() || t("markdown.label"));
|
|
58
88
|
const rootStyle = computed(() => ({ height: resolveMarkdownHeight(props.height) }));
|
|
59
|
-
const
|
|
89
|
+
const renderOptions = computed(() => ({
|
|
90
|
+
breaks: props.breaks,
|
|
91
|
+
taskDoneLabel: t("markdown.taskDone"),
|
|
92
|
+
taskOpenLabel: t("markdown.taskOpen"),
|
|
93
|
+
externalLabel: t("markdown.external")
|
|
94
|
+
}));
|
|
60
95
|
const editorPlaceholder = computed(() => props.placeholder ?? t("markdown.placeholder"));
|
|
61
96
|
const modeItems = computed(() => [
|
|
62
97
|
{
|
|
@@ -72,45 +107,177 @@ var RsMarkdown_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
72
107
|
label: t("markdown.split")
|
|
73
108
|
}
|
|
74
109
|
]);
|
|
110
|
+
function tabDomId(value) {
|
|
111
|
+
return `${rootId.value}-tab-${value}`;
|
|
112
|
+
}
|
|
113
|
+
function clearPreviewTimer() {
|
|
114
|
+
if (previewTimer == null) return;
|
|
115
|
+
clearTimeout(previewTimer);
|
|
116
|
+
previewTimer = null;
|
|
117
|
+
}
|
|
118
|
+
function stopThemeWatch() {
|
|
119
|
+
unobserveTheme();
|
|
120
|
+
unobserveTheme = () => {};
|
|
121
|
+
}
|
|
122
|
+
function paintPreview() {
|
|
123
|
+
if (!alive) return;
|
|
124
|
+
if (activeMode.value === "edit") {
|
|
125
|
+
previewHtml.value = "";
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
previewHtml.value = renderMarkdown(model.value, renderOptions.value);
|
|
129
|
+
}
|
|
130
|
+
function schedulePreview(immediate) {
|
|
131
|
+
clearPreviewTimer();
|
|
132
|
+
if (!alive) return;
|
|
133
|
+
if (immediate || activeMode.value === "edit") {
|
|
134
|
+
paintPreview();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
previewTimer = setTimeout(() => {
|
|
138
|
+
previewTimer = null;
|
|
139
|
+
paintPreview();
|
|
140
|
+
}, 32);
|
|
141
|
+
}
|
|
142
|
+
function syncEditorTheme() {
|
|
143
|
+
stopThemeWatch();
|
|
144
|
+
if (!alive) return;
|
|
145
|
+
if (props.theme === "light" || props.theme === "dark") {
|
|
146
|
+
editorTheme.value = props.theme;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const host = nearestMarkdownThemeHost(rootRef.value);
|
|
150
|
+
if (!host) {
|
|
151
|
+
editorTheme.value = "auto";
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const apply = () => {
|
|
155
|
+
if (!alive || props.theme !== "auto") return;
|
|
156
|
+
const resolved = readResolvedTheme(host);
|
|
157
|
+
editorTheme.value = resolveMarkdownEditorTheme("auto", resolved);
|
|
158
|
+
};
|
|
159
|
+
apply();
|
|
160
|
+
if (typeof MutationObserver === "undefined") return;
|
|
161
|
+
const observer = new MutationObserver(apply);
|
|
162
|
+
observer.observe(host, {
|
|
163
|
+
attributes: true,
|
|
164
|
+
attributeFilter: ["data-rs-theme"]
|
|
165
|
+
});
|
|
166
|
+
unobserveTheme = () => observer.disconnect();
|
|
167
|
+
}
|
|
75
168
|
function setMode(next) {
|
|
76
169
|
if (props.readonly || props.disabled) return;
|
|
77
170
|
mode.value = next;
|
|
78
171
|
}
|
|
172
|
+
function onToolbarKeydown(event) {
|
|
173
|
+
if (props.readonly || props.disabled) return;
|
|
174
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
|
|
175
|
+
const move = resolveMarkdownTabMove(event.key, isMarkdownRtl(event.currentTarget));
|
|
176
|
+
if (move == null) return;
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
const next = applyMarkdownTabMove(activeMode.value, move);
|
|
179
|
+
if (next === activeMode.value) return;
|
|
180
|
+
setMode(next);
|
|
181
|
+
nextTick(() => {
|
|
182
|
+
const id = tabDomId(next);
|
|
183
|
+
const esc = typeof CSS !== "undefined" && typeof CSS.escape === "function" ? CSS.escape(id) : id;
|
|
184
|
+
rootRef.value?.querySelector(`#${esc}`)?.focus();
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function focus() {
|
|
188
|
+
if (props.disabled) return;
|
|
189
|
+
if (activeMode.value === "preview" || !editorRef.value) {
|
|
190
|
+
panelRef.value?.focus();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
editorRef.value.focus();
|
|
194
|
+
}
|
|
195
|
+
watch([
|
|
196
|
+
model,
|
|
197
|
+
renderOptions,
|
|
198
|
+
activeMode
|
|
199
|
+
], (next, prev) => {
|
|
200
|
+
const modeChanged = !prev || next[2] !== prev[2];
|
|
201
|
+
const optionsChanged = !prev || next[1] !== prev[1];
|
|
202
|
+
schedulePreview(!prev || modeChanged || optionsChanged || activeMode.value === "edit");
|
|
203
|
+
}, { immediate: true });
|
|
204
|
+
watch(() => props.theme, () => syncEditorTheme());
|
|
205
|
+
onMounted(syncEditorTheme);
|
|
206
|
+
onActivated(() => {
|
|
207
|
+
syncEditorTheme();
|
|
208
|
+
schedulePreview(true);
|
|
209
|
+
});
|
|
210
|
+
onDeactivated(() => {
|
|
211
|
+
clearPreviewTimer();
|
|
212
|
+
stopThemeWatch();
|
|
213
|
+
});
|
|
214
|
+
onUnmounted(() => {
|
|
215
|
+
alive = false;
|
|
216
|
+
clearPreviewTimer();
|
|
217
|
+
stopThemeWatch();
|
|
218
|
+
});
|
|
219
|
+
__expose({ focus });
|
|
79
220
|
return (_ctx, _cache) => {
|
|
80
|
-
return openBlock(), createElementBlock("
|
|
221
|
+
return openBlock(), createElementBlock("section", {
|
|
222
|
+
id: rootId.value,
|
|
223
|
+
ref_key: "rootRef",
|
|
224
|
+
ref: rootRef,
|
|
81
225
|
class: normalizeClass(["rs-markdown", [`rs-markdown--${activeMode.value}`, {
|
|
82
226
|
"rs-markdown--rounded": __props.rounded,
|
|
83
227
|
"rs-markdown--readonly": __props.readonly,
|
|
84
228
|
"rs-markdown--disabled": __props.disabled,
|
|
85
229
|
"rs-markdown--with-toggle": showToggle.value
|
|
86
230
|
}]]),
|
|
87
|
-
style: normalizeStyle(rootStyle.value)
|
|
231
|
+
style: normalizeStyle(rootStyle.value),
|
|
232
|
+
"data-rs-theme": surfaceTheme.value,
|
|
233
|
+
"aria-label": regionLabel.value,
|
|
234
|
+
"aria-disabled": __props.disabled || void 0
|
|
88
235
|
}, [showToggle.value ? (openBlock(), createElementBlock("div", {
|
|
89
236
|
key: 0,
|
|
90
237
|
class: "rs-markdown__toolbar",
|
|
91
238
|
role: "tablist",
|
|
92
|
-
"aria-
|
|
239
|
+
"aria-orientation": "horizontal",
|
|
240
|
+
"aria-label": unref(t)("markdown.modes"),
|
|
241
|
+
onKeydown: onToolbarKeydown
|
|
93
242
|
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(modeItems.value, (item) => {
|
|
94
243
|
return openBlock(), createBlock(RsButton_default, {
|
|
244
|
+
id: tabDomId(item.value),
|
|
95
245
|
key: item.value,
|
|
96
246
|
size: "sm",
|
|
247
|
+
type: "button",
|
|
97
248
|
variant: activeMode.value === item.value ? "secondary" : "ghost",
|
|
98
249
|
"aria-selected": activeMode.value === item.value,
|
|
250
|
+
"aria-controls": panelDomId.value,
|
|
251
|
+
tabindex: activeMode.value === item.value ? 0 : -1,
|
|
99
252
|
role: "tab",
|
|
100
253
|
onClick: ($event) => setMode(item.value)
|
|
101
254
|
}, {
|
|
102
255
|
default: withCtx(() => [createTextVNode(toDisplayString(item.label), 1)]),
|
|
103
256
|
_: 2
|
|
104
257
|
}, 1032, [
|
|
258
|
+
"id",
|
|
105
259
|
"variant",
|
|
106
260
|
"aria-selected",
|
|
261
|
+
"aria-controls",
|
|
262
|
+
"tabindex",
|
|
107
263
|
"onClick"
|
|
108
264
|
]);
|
|
109
|
-
}), 128))],
|
|
265
|
+
}), 128))], 40, _hoisted_2)) : createCommentVNode("", true), createElementVNode("div", {
|
|
266
|
+
id: panelDomId.value,
|
|
267
|
+
ref_key: "panelRef",
|
|
268
|
+
ref: panelRef,
|
|
269
|
+
class: "rs-markdown__body",
|
|
270
|
+
role: showToggle.value ? "tabpanel" : activeMode.value === "preview" ? "group" : void 0,
|
|
271
|
+
"aria-labelledby": showToggle.value ? tabDomId(activeMode.value) : void 0,
|
|
272
|
+
"aria-label": !showToggle.value && activeMode.value === "preview" ? regionLabel.value : void 0,
|
|
273
|
+
tabindex: activeMode.value === "preview" ? -1 : void 0
|
|
274
|
+
}, [activeMode.value === "edit" || activeMode.value === "split" ? (openBlock(), createElementBlock("div", _hoisted_4, [createVNode(RsCodeEditor_default, {
|
|
275
|
+
ref_key: "editorRef",
|
|
276
|
+
ref: editorRef,
|
|
110
277
|
modelValue: model.value,
|
|
111
278
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
|
|
112
279
|
language: "markdown",
|
|
113
|
-
theme:
|
|
280
|
+
theme: editorTheme.value,
|
|
114
281
|
placeholder: editorPlaceholder.value,
|
|
115
282
|
readonly: __props.readonly || __props.disabled,
|
|
116
283
|
disabled: __props.disabled,
|
|
@@ -130,8 +297,9 @@ var RsMarkdown_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
130
297
|
}, [previewHtml.value ? (openBlock(), createElementBlock("div", {
|
|
131
298
|
key: 0,
|
|
132
299
|
class: "rs-markdown__prose",
|
|
300
|
+
dir: "auto",
|
|
133
301
|
innerHTML: previewHtml.value
|
|
134
|
-
}, null, 8,
|
|
302
|
+
}, null, 8, _hoisted_5)) : (openBlock(), createElementBlock("p", _hoisted_6, toDisplayString(unref(t)("markdown.empty")), 1))], 2)) : createCommentVNode("", true)], 8, _hoisted_3)], 14, _hoisted_1);
|
|
135
303
|
};
|
|
136
304
|
}
|
|
137
305
|
});
|
|
@@ -1,16 +1,42 @@
|
|
|
1
|
+
import type { RsCodeEditorTheme } from '../../code-editor/src/code-editor-utils';
|
|
1
2
|
export type RsMarkdownMode = 'edit' | 'preview' | 'split';
|
|
2
3
|
export type RsMarkdownRenderOptions = {
|
|
3
4
|
/** GFM 换行(单个换行转 <br>),默认 true */
|
|
4
5
|
breaks?: boolean;
|
|
6
|
+
/** 任务列表已完成的读屏文案。未传为英文 completed */
|
|
7
|
+
taskDoneLabel?: string;
|
|
8
|
+
/** 任务列表未完成的读屏文案。未传为英文 not completed */
|
|
9
|
+
taskOpenLabel?: string;
|
|
10
|
+
/** 新标签页链接的读屏后缀。未传为英文 opens in a new tab */
|
|
11
|
+
externalLabel?: string;
|
|
5
12
|
};
|
|
13
|
+
export interface RsMarkdownExpose {
|
|
14
|
+
/** 编辑或分栏时聚焦源码;预览时聚焦预览面。禁用时无操作。 */
|
|
15
|
+
focus: () => void;
|
|
16
|
+
}
|
|
17
|
+
/** 预览跟手的合并间隔。切模式和首次绘制不走这段等待。 */
|
|
18
|
+
export declare const markdownPreviewDelayMs = 32;
|
|
6
19
|
export declare function escapeHtml(text: string): string;
|
|
7
20
|
export declare function isSafeHref(href: string): boolean;
|
|
8
21
|
export declare function isSafeImageSrc(src: string): boolean;
|
|
22
|
+
export declare function slugMarkdownHeading(text: string, used: Set<string>): string;
|
|
9
23
|
/**
|
|
10
24
|
* 将 Markdown 转为可安全注入的 HTML(必须配合 v-html 使用消毒结果)。
|
|
25
|
+
* 无 window 时返回空字符串,不抛错。
|
|
11
26
|
*/
|
|
12
27
|
export declare function renderMarkdown(source?: string, options?: RsMarkdownRenderOptions): string;
|
|
13
28
|
/** 行内 Markdown(不包 <p>),供对话里夹杂公式的片段使用。 */
|
|
14
29
|
export declare function renderMarkdownInline(source?: string): string;
|
|
15
30
|
export declare function resolveMarkdownHeight(height?: number | string): string;
|
|
16
31
|
export declare function resolveMarkdownMode(mode: RsMarkdownMode | undefined, readonly: boolean): RsMarkdownMode;
|
|
32
|
+
/** 横向标签栏。左右键在 RTL 下对调。不处理的键返回 null。 */
|
|
33
|
+
export declare function resolveMarkdownTabMove(key: string, rtl?: boolean): number | 'start' | 'end' | null;
|
|
34
|
+
export declare function applyMarkdownTabMove(current: RsMarkdownMode, move: number | 'start' | 'end'): RsMarkdownMode;
|
|
35
|
+
export declare function isMarkdownRtl(node: EventTarget | null): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* 最近的主题岛。documentElement 交给编辑器的 auto,避免再观察一遍。
|
|
38
|
+
* 组件自己写上 data-rs-theme 时从父级继续找。
|
|
39
|
+
*/
|
|
40
|
+
export declare function nearestMarkdownThemeHost(el: HTMLElement | null): HTMLElement | null;
|
|
41
|
+
/** auto 且落在主题岛里时,把岛的明暗交给编辑器;否则保持 auto 或显式值。 */
|
|
42
|
+
export declare function resolveMarkdownEditorTheme(theme: RsCodeEditorTheme | undefined, nearestIsland: 'light' | 'dark' | null): RsCodeEditorTheme;
|
|
@@ -2,17 +2,36 @@ import { Marked } from "marked";
|
|
|
2
2
|
import DOMPurify from "dompurify";
|
|
3
3
|
//#region src/components/markdown/src/markdown-utils.ts
|
|
4
4
|
/**
|
|
5
|
-
* Markdown
|
|
6
|
-
*
|
|
5
|
+
* Markdown 渲染:GFM + 安全链接/图片 + DOMPurify。
|
|
6
|
+
* 面向说明、变更记录和表单。不含公式、图表和流式拼接。
|
|
7
|
+
* renderMarkdown 是同步的,同一调用栈里不要重入。
|
|
7
8
|
*/
|
|
9
|
+
var MODES = [
|
|
10
|
+
"edit",
|
|
11
|
+
"preview",
|
|
12
|
+
"split"
|
|
13
|
+
];
|
|
14
|
+
var session = {
|
|
15
|
+
headings: /* @__PURE__ */ new Set(),
|
|
16
|
+
taskDone: "completed",
|
|
17
|
+
taskOpen: "not completed",
|
|
18
|
+
external: "opens in a new tab"
|
|
19
|
+
};
|
|
8
20
|
function escapeHtml(text) {
|
|
9
21
|
return text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
10
22
|
}
|
|
23
|
+
function hasControlChar(value) {
|
|
24
|
+
return /[\u0000-\u001F\u007F]/.test(value);
|
|
25
|
+
}
|
|
11
26
|
function isSafeHref(href) {
|
|
12
27
|
const value = href.trim();
|
|
13
|
-
if (!value) return false;
|
|
14
|
-
if (value.startsWith("#")
|
|
15
|
-
return /^(https?:|mailto:)/i.test(value);
|
|
28
|
+
if (!value || hasControlChar(value) || value.includes("\\") || value.startsWith("//")) return false;
|
|
29
|
+
if (value.startsWith("#")) return true;
|
|
30
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(value)) return /^(https?:|mailto:|tel:)/i.test(value);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
function opensInNewTab(href) {
|
|
34
|
+
return /^(https?:|mailto:|tel:)/i.test(href.trim());
|
|
16
35
|
}
|
|
17
36
|
/** 行内代码整段就是 http(s) 地址时,转成可点击链接(模型常用反引号包 URL)。 */
|
|
18
37
|
function isStandaloneHttpUrl(text) {
|
|
@@ -25,22 +44,39 @@ function renderSafeLink(href, innerHtml, title) {
|
|
|
25
44
|
const url = href.trim();
|
|
26
45
|
if (!isSafeHref(url)) return innerHtml;
|
|
27
46
|
const titleAttr = title ? ` title="${escapeHtml(title)}"` : "";
|
|
28
|
-
|
|
47
|
+
const external = opensInNewTab(url);
|
|
48
|
+
const target = external ? " target=\"_blank\" rel=\"noopener noreferrer\"" : "";
|
|
49
|
+
const hint = external ? `<span class="rs-markdown__sr"> ${escapeHtml(session.external)}</span>` : "";
|
|
50
|
+
return `<a href="${escapeHtml(url)}"${titleAttr}${target}>${innerHtml}${hint}</a>`;
|
|
29
51
|
}
|
|
52
|
+
var SAFE_RASTER_DATA = /^data:image\/(?:png|jpe?g|gif|webp|avif|bmp)(?:[;,])/i;
|
|
30
53
|
function isSafeImageSrc(src) {
|
|
31
54
|
const value = src.trim();
|
|
32
|
-
if (!value) return false;
|
|
33
|
-
if (
|
|
34
|
-
return /^
|
|
55
|
+
if (!value || hasControlChar(value) || value.includes("\\") || value.startsWith("//")) return false;
|
|
56
|
+
if (/^data:/i.test(value)) return SAFE_RASTER_DATA.test(value);
|
|
57
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(value)) return /^https?:/i.test(value);
|
|
58
|
+
return true;
|
|
35
59
|
}
|
|
36
60
|
function sanitizeLang(lang) {
|
|
37
61
|
return ((lang ?? "text").trim().split(/\s+/)[0] ?? "text").replace(/[^\w.+#-]/g, "") || "text";
|
|
38
62
|
}
|
|
63
|
+
function slugMarkdownHeading(text, used) {
|
|
64
|
+
let slug = text.replace(/<[^>]+>/g, "").trim().normalize("NFKC").toLowerCase().replace(/[\s_]+/g, "-").replace(/[^\p{L}\p{N}-]+/gu, "").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
65
|
+
if (!slug) slug = "section";
|
|
66
|
+
const base = slug;
|
|
67
|
+
let n = 2;
|
|
68
|
+
while (used.has(slug)) {
|
|
69
|
+
slug = `${base}-${n}`;
|
|
70
|
+
n += 1;
|
|
71
|
+
}
|
|
72
|
+
used.add(slug);
|
|
73
|
+
return slug;
|
|
74
|
+
}
|
|
39
75
|
function renderCodeBlock(text, lang) {
|
|
40
76
|
const language = sanitizeLang(lang);
|
|
41
77
|
const code = text.replace(/\n$/, "");
|
|
42
78
|
return [
|
|
43
|
-
`<div class="rs-markdown__codeblock" data-rs-md-lang="${escapeHtml(language)}">`,
|
|
79
|
+
`<div class="rs-markdown__codeblock" dir="ltr" data-rs-md-lang="${escapeHtml(language)}">`,
|
|
44
80
|
`<div class="rs-markdown__code-head">`,
|
|
45
81
|
`<span class="rs-markdown__code-lang">${escapeHtml(language)}</span>`,
|
|
46
82
|
`</div>`,
|
|
@@ -54,7 +90,7 @@ function wrapTables(html) {
|
|
|
54
90
|
});
|
|
55
91
|
}
|
|
56
92
|
function renderTaskMarker(checked) {
|
|
57
|
-
return `<span class="rs-markdown__task${checked ? " rs-markdown__task--on" : ""}" aria-hidden="true"></span> `;
|
|
93
|
+
return `<span class="rs-markdown__task${checked ? " rs-markdown__task--on" : ""}" aria-hidden="true"></span><span class="rs-markdown__sr">${escapeHtml(checked ? session.taskDone : session.taskOpen)}</span> `;
|
|
58
94
|
}
|
|
59
95
|
function createMarked(breaks) {
|
|
60
96
|
return new Marked({
|
|
@@ -67,6 +103,12 @@ function createMarked(breaks) {
|
|
|
67
103
|
code({ text, lang }) {
|
|
68
104
|
return renderCodeBlock(text, lang);
|
|
69
105
|
},
|
|
106
|
+
heading(token) {
|
|
107
|
+
const text = this.parser.parseInline(token.tokens);
|
|
108
|
+
const id = slugMarkdownHeading(token.text, session.headings);
|
|
109
|
+
const depth = token.depth;
|
|
110
|
+
return `<h${depth} id="${escapeHtml(id)}">${text}</h${depth}>`;
|
|
111
|
+
},
|
|
70
112
|
link(token) {
|
|
71
113
|
const text = this.parser.parseInline(token.tokens);
|
|
72
114
|
return renderSafeLink(token.href ?? "", text, token.title ?? void 0);
|
|
@@ -94,19 +136,36 @@ function getMarked(breaks) {
|
|
|
94
136
|
markedCache.set(breaks, instance);
|
|
95
137
|
return instance;
|
|
96
138
|
}
|
|
139
|
+
function beginSession(options) {
|
|
140
|
+
session = {
|
|
141
|
+
headings: /* @__PURE__ */ new Set(),
|
|
142
|
+
taskDone: options?.taskDoneLabel?.trim() || "completed",
|
|
143
|
+
taskOpen: options?.taskOpenLabel?.trim() || "not completed",
|
|
144
|
+
external: options?.externalLabel?.trim() || "opens in a new tab"
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function canSanitizeMarkdown() {
|
|
148
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
149
|
+
}
|
|
97
150
|
/**
|
|
98
151
|
* 将 Markdown 转为可安全注入的 HTML(必须配合 v-html 使用消毒结果)。
|
|
152
|
+
* 无 window 时返回空字符串,不抛错。
|
|
99
153
|
*/
|
|
100
154
|
function renderMarkdown(source = "", options) {
|
|
101
155
|
if (!source.trim()) return "";
|
|
156
|
+
if (!canSanitizeMarkdown()) return "";
|
|
157
|
+
beginSession(options);
|
|
102
158
|
return sanitizeMarkdownHtml(wrapTables(getMarked(options?.breaks !== false).parse(source, { async: false })));
|
|
103
159
|
}
|
|
104
160
|
/** 行内 Markdown(不包 <p>),供对话里夹杂公式的片段使用。 */
|
|
105
161
|
function renderMarkdownInline(source = "") {
|
|
106
162
|
if (!source) return "";
|
|
163
|
+
if (!canSanitizeMarkdown()) return "";
|
|
164
|
+
beginSession();
|
|
107
165
|
return sanitizeMarkdownHtml(getMarked(true).parseInline(source, { async: false }));
|
|
108
166
|
}
|
|
109
167
|
function sanitizeMarkdownHtml(dirty) {
|
|
168
|
+
if (!dirty || !canSanitizeMarkdown()) return "";
|
|
110
169
|
return DOMPurify.sanitize(dirty, {
|
|
111
170
|
USE_PROFILES: { html: true },
|
|
112
171
|
FORBID_TAGS: [
|
|
@@ -125,6 +184,7 @@ function sanitizeMarkdownHtml(dirty) {
|
|
|
125
184
|
"decoding",
|
|
126
185
|
"alt",
|
|
127
186
|
"src",
|
|
187
|
+
"dir",
|
|
128
188
|
"data-rs-md-lang",
|
|
129
189
|
"align",
|
|
130
190
|
"start"
|
|
@@ -139,5 +199,47 @@ function resolveMarkdownMode(mode, readonly) {
|
|
|
139
199
|
if (readonly) return "preview";
|
|
140
200
|
return mode ?? "edit";
|
|
141
201
|
}
|
|
202
|
+
/** 横向标签栏。左右键在 RTL 下对调。不处理的键返回 null。 */
|
|
203
|
+
function resolveMarkdownTabMove(key, rtl = false) {
|
|
204
|
+
if (key === "Home") return "start";
|
|
205
|
+
if (key === "End") return "end";
|
|
206
|
+
if (key === "ArrowLeft") return rtl ? 1 : -1;
|
|
207
|
+
if (key === "ArrowRight") return rtl ? -1 : 1;
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
function applyMarkdownTabMove(current, move) {
|
|
211
|
+
if (move === "start") return "edit";
|
|
212
|
+
if (move === "end") return "split";
|
|
213
|
+
return MODES[(Math.max(0, MODES.indexOf(current)) + move + MODES.length) % MODES.length];
|
|
214
|
+
}
|
|
215
|
+
function isMarkdownRtl(node) {
|
|
216
|
+
if (typeof document === "undefined") return false;
|
|
217
|
+
const host = (node instanceof HTMLElement ? node : null)?.closest("[dir], [data-rs-dir]") ?? document.documentElement;
|
|
218
|
+
if (!(host instanceof Element)) return false;
|
|
219
|
+
return (host.getAttribute("dir") || host.getAttribute("data-rs-dir") || "") === "rtl";
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* 最近的主题岛。documentElement 交给编辑器的 auto,避免再观察一遍。
|
|
223
|
+
* 组件自己写上 data-rs-theme 时从父级继续找。
|
|
224
|
+
*/
|
|
225
|
+
function nearestMarkdownThemeHost(el) {
|
|
226
|
+
if (!el || typeof document === "undefined") return null;
|
|
227
|
+
let node = el.parentElement;
|
|
228
|
+
while (node) {
|
|
229
|
+
const raw = node.getAttribute("data-rs-theme");
|
|
230
|
+
if (raw === "light" || raw === "dark" || raw === "system") {
|
|
231
|
+
if (node === document.documentElement) return null;
|
|
232
|
+
return node;
|
|
233
|
+
}
|
|
234
|
+
node = node.parentElement;
|
|
235
|
+
}
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
/** auto 且落在主题岛里时,把岛的明暗交给编辑器;否则保持 auto 或显式值。 */
|
|
239
|
+
function resolveMarkdownEditorTheme(theme, nearestIsland) {
|
|
240
|
+
if (theme === "light" || theme === "dark") return theme;
|
|
241
|
+
if (nearestIsland) return nearestIsland;
|
|
242
|
+
return "auto";
|
|
243
|
+
}
|
|
142
244
|
//#endregion
|
|
143
|
-
export { escapeHtml, isSafeHref, isSafeImageSrc, renderMarkdown, renderMarkdownInline, resolveMarkdownHeight, resolveMarkdownMode };
|
|
245
|
+
export { applyMarkdownTabMove, escapeHtml, isMarkdownRtl, isSafeHref, isSafeImageSrc, nearestMarkdownThemeHost, renderMarkdown, renderMarkdownInline, resolveMarkdownEditorTheme, resolveMarkdownHeight, resolveMarkdownMode, resolveMarkdownTabMove, slugMarkdownHeading };
|
|
@@ -67,10 +67,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, RsMen
|
|
|
67
67
|
loading: boolean;
|
|
68
68
|
readonly: boolean;
|
|
69
69
|
allowClear: boolean;
|
|
70
|
+
emptyText: string;
|
|
71
|
+
rows: number;
|
|
70
72
|
options: ReadonlyArray<RsMentionOptionInput>;
|
|
71
73
|
prefix: string | string[];
|
|
72
|
-
rows: number;
|
|
73
|
-
emptyText: string;
|
|
74
74
|
filterOption: RsMentionFilterOption;
|
|
75
75
|
debounce: number;
|
|
76
76
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as RsMenu } from './src/RsMenu.js';
|
|
2
|
-
export type { RsMenuItem, RsMenuItemGroup, RsMenuItems } from './src/menu-utils';
|
|
2
|
+
export type { RsMenuExpose, RsMenuGetPopupContainer, RsMenuItem, RsMenuItemGroup, RsMenuItemSlot, RsMenuItems, RsMenuInstance, RsMenuMode, RsMenuTriggerAction, } from './src/menu-utils';
|