niuma-ui 2.0.4 → 2.0.9
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 +58 -0
- 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/_shared/src/reka.js +2 -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.impl.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/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/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 +34 -20
- 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 +460 -797
- package/dist/theme/brand.example.css +2 -1
- package/dist/vite-plugins/niuma-ui-host.js +1 -1
- package/package.json +2 -3
|
@@ -1,24 +1,42 @@
|
|
|
1
1
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { copyTextToClipboard } from "../../../utils/rs-clipboard.js";
|
|
3
|
+
import { resolveCodeMirrorLanguage } from "../../code-editor/src/code-mirror-lang.js";
|
|
4
|
+
import { codeBlockCopyFeedbackMs, codeBlockDownloadRevokeMs, isCodeBlockDarkTheme, mimeForDownloadFilename, readCodeBlockSelection, sanitizeDownloadFilename, subscribeCodeBlockTheme } from "./code-block-utils.js";
|
|
5
|
+
import { codeBlockHighlightExtension, highlightCodeBlockLines } from "./code-block-highlight.js";
|
|
6
|
+
import { computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeClass, normalizeStyle, onMounted, onUnmounted, openBlock, ref, renderSlot, shallowRef, toDisplayString, watch } from "vue";
|
|
4
7
|
import { basicSetup } from "codemirror";
|
|
5
|
-
import { EditorState } from "@codemirror/state";
|
|
8
|
+
import { Compartment, EditorState } from "@codemirror/state";
|
|
6
9
|
import { EditorView } from "@codemirror/view";
|
|
7
10
|
import { oneDark } from "@codemirror/theme-one-dark";
|
|
8
11
|
//#region src/components/code-block/src/RsCodeBlock.vue?vue&type=script&setup=true&lang.ts
|
|
9
|
-
var _hoisted_1 =
|
|
12
|
+
var _hoisted_1 = ["id", "aria-label"];
|
|
13
|
+
var _hoisted_2 = {
|
|
10
14
|
key: 0,
|
|
11
15
|
class: "rs-code-block__bar"
|
|
12
16
|
};
|
|
13
|
-
var
|
|
14
|
-
var
|
|
17
|
+
var _hoisted_3 = { class: "rs-code-block__meta" };
|
|
18
|
+
var _hoisted_4 = {
|
|
19
|
+
key: 0,
|
|
20
|
+
class: "rs-code-block__file"
|
|
21
|
+
};
|
|
22
|
+
var _hoisted_5 = { class: "rs-code-block__lang" };
|
|
23
|
+
var _hoisted_6 = ["aria-label"];
|
|
24
|
+
var _hoisted_7 = ["aria-label"];
|
|
25
|
+
var _hoisted_8 = { "aria-hidden": "true" };
|
|
26
|
+
var _hoisted_9 = {
|
|
27
|
+
class: "rs-code-block__sr",
|
|
28
|
+
role: "status"
|
|
29
|
+
};
|
|
15
30
|
var RsCodeBlock_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
31
|
+
name: "RsCodeBlock",
|
|
16
32
|
__name: "RsCodeBlock",
|
|
17
33
|
props: {
|
|
18
34
|
code: {},
|
|
19
35
|
lang: { default: "text" },
|
|
36
|
+
filename: {},
|
|
20
37
|
copyLabel: {},
|
|
21
38
|
copiedLabel: {},
|
|
39
|
+
copyFailedLabel: {},
|
|
22
40
|
downloadFilename: {},
|
|
23
41
|
downloadLabel: {},
|
|
24
42
|
editable: {
|
|
@@ -28,117 +46,190 @@ var RsCodeBlock_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
28
46
|
showBar: {
|
|
29
47
|
type: Boolean,
|
|
30
48
|
default: true
|
|
31
|
-
}
|
|
49
|
+
},
|
|
50
|
+
lineNumbers: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: true
|
|
53
|
+
},
|
|
54
|
+
wordWrap: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: true
|
|
57
|
+
},
|
|
58
|
+
highlightLines: {},
|
|
59
|
+
maxHeight: {},
|
|
60
|
+
ariaLabel: {},
|
|
61
|
+
id: {}
|
|
32
62
|
},
|
|
33
|
-
emits: ["update:code"],
|
|
63
|
+
emits: ["update:code", "copy"],
|
|
34
64
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
35
65
|
const props = __props;
|
|
36
66
|
const emit = __emit;
|
|
37
67
|
const { t } = useRsI18n();
|
|
38
68
|
const editorEl = ref(null);
|
|
39
69
|
const view = shallowRef(null);
|
|
40
|
-
const
|
|
70
|
+
const copyState = ref("idle");
|
|
71
|
+
const liveText = ref("");
|
|
72
|
+
const editableCompartment = new Compartment();
|
|
73
|
+
const wrapCompartment = new Compartment();
|
|
74
|
+
const themeCompartment = new Compartment();
|
|
41
75
|
let copyTimer = null;
|
|
42
|
-
let
|
|
43
|
-
|
|
76
|
+
let downloadTimer = null;
|
|
77
|
+
let downloadUrl = null;
|
|
78
|
+
let unsubscribeTheme = () => {};
|
|
44
79
|
let unmounted = false;
|
|
45
|
-
|
|
46
|
-
|
|
80
|
+
let syncingFromModel = false;
|
|
81
|
+
let themeIsDark = null;
|
|
82
|
+
let initSeq = 0;
|
|
83
|
+
const copyVisual = computed(() => {
|
|
84
|
+
if (copyState.value === "copied") return props.copiedLabel ?? t("codeBlock.copied");
|
|
85
|
+
if (copyState.value === "failed") return props.copyFailedLabel ?? t("codeBlock.copyFailed");
|
|
86
|
+
return props.copyLabel ?? t("codeBlock.copy");
|
|
87
|
+
});
|
|
88
|
+
const copyAria = computed(() => props.copyLabel ?? t("codeBlock.copy"));
|
|
89
|
+
const downloadVisual = computed(() => props.downloadLabel ?? t("codeBlock.download"));
|
|
90
|
+
const toolbarLabel = computed(() => props.ariaLabel || t("codeBlock.toolbar"));
|
|
91
|
+
const figureLabel = computed(() => props.ariaLabel || t("codeBlock.label"));
|
|
92
|
+
const rootStyle = computed(() => {
|
|
93
|
+
if (!props.maxHeight) return void 0;
|
|
94
|
+
return { "--rs-code-block-max-height": props.maxHeight };
|
|
95
|
+
});
|
|
96
|
+
function applyTheme() {
|
|
97
|
+
const dark = isCodeBlockDarkTheme(editorEl.value);
|
|
98
|
+
if (themeIsDark === dark) return;
|
|
99
|
+
themeIsDark = dark;
|
|
100
|
+
view.value?.dispatch({ effects: themeCompartment.reconfigure(dark ? [oneDark] : []) });
|
|
47
101
|
}
|
|
48
|
-
|
|
49
|
-
|
|
102
|
+
function applyHighlights() {
|
|
103
|
+
if (unmounted || !view.value) return;
|
|
104
|
+
view.value.dispatch({ effects: highlightCodeBlockLines(props.highlightLines) });
|
|
105
|
+
}
|
|
106
|
+
function replaceDocument(next) {
|
|
107
|
+
const ed = view.value;
|
|
108
|
+
if (!ed || unmounted) return;
|
|
109
|
+
if (ed.state.doc.toString() === next) return;
|
|
110
|
+
syncingFromModel = true;
|
|
111
|
+
try {
|
|
112
|
+
ed.dispatch({
|
|
113
|
+
changes: {
|
|
114
|
+
from: 0,
|
|
115
|
+
to: ed.state.doc.length,
|
|
116
|
+
insert: next
|
|
117
|
+
},
|
|
118
|
+
effects: highlightCodeBlockLines(props.highlightLines)
|
|
119
|
+
});
|
|
120
|
+
} finally {
|
|
121
|
+
syncingFromModel = false;
|
|
122
|
+
}
|
|
50
123
|
}
|
|
51
124
|
async function initEditor() {
|
|
52
125
|
if (!editorEl.value || unmounted) return;
|
|
126
|
+
const seq = ++initSeq;
|
|
53
127
|
const targetEl = editorEl.value;
|
|
54
128
|
view.value?.destroy();
|
|
55
129
|
view.value = null;
|
|
56
|
-
const langExts = await
|
|
57
|
-
if (unmounted || !targetEl.isConnected) return;
|
|
130
|
+
const langExts = await resolveCodeMirrorLanguage(props.lang ?? "");
|
|
131
|
+
if (unmounted || !targetEl.isConnected || seq !== initSeq) return;
|
|
132
|
+
const dark = isCodeBlockDarkTheme(targetEl);
|
|
133
|
+
themeIsDark = dark;
|
|
58
134
|
const state = EditorState.create({
|
|
59
135
|
doc: props.code,
|
|
60
136
|
extensions: [
|
|
61
137
|
basicSetup,
|
|
62
|
-
|
|
63
|
-
EditorView.
|
|
138
|
+
wrapCompartment.of(props.wordWrap ? EditorView.lineWrapping : []),
|
|
139
|
+
editableCompartment.of(EditorView.editable.of(props.editable)),
|
|
64
140
|
...langExts,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
141
|
+
codeBlockHighlightExtension(),
|
|
142
|
+
themeCompartment.of(dark ? [oneDark] : []),
|
|
143
|
+
EditorView.updateListener.of((update) => {
|
|
144
|
+
if (!props.editable || !update.docChanged || syncingFromModel) return;
|
|
145
|
+
emit("update:code", update.state.doc.toString());
|
|
68
146
|
})
|
|
69
147
|
]
|
|
70
148
|
});
|
|
149
|
+
if (unmounted || seq !== initSeq) return;
|
|
71
150
|
view.value = new EditorView({
|
|
72
151
|
state,
|
|
73
152
|
parent: targetEl
|
|
74
153
|
});
|
|
154
|
+
applyHighlights();
|
|
155
|
+
}
|
|
156
|
+
function clearCopyTimer() {
|
|
157
|
+
if (copyTimer !== null) {
|
|
158
|
+
clearTimeout(copyTimer);
|
|
159
|
+
copyTimer = null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function clearDownload() {
|
|
163
|
+
if (downloadTimer !== null) {
|
|
164
|
+
clearTimeout(downloadTimer);
|
|
165
|
+
downloadTimer = null;
|
|
166
|
+
}
|
|
167
|
+
if (downloadUrl) {
|
|
168
|
+
URL.revokeObjectURL(downloadUrl);
|
|
169
|
+
downloadUrl = null;
|
|
170
|
+
}
|
|
75
171
|
}
|
|
76
172
|
onMounted(() => {
|
|
77
173
|
unmounted = false;
|
|
78
174
|
initEditor();
|
|
79
|
-
|
|
80
|
-
initEditor();
|
|
81
|
-
});
|
|
82
|
-
themeObserver.observe(document.documentElement, {
|
|
83
|
-
attributes: true,
|
|
84
|
-
attributeFilter: ["data-rs-theme"]
|
|
85
|
-
});
|
|
175
|
+
unsubscribeTheme = subscribeCodeBlockTheme(() => applyTheme());
|
|
86
176
|
});
|
|
87
177
|
onUnmounted(() => {
|
|
88
178
|
unmounted = true;
|
|
179
|
+
initSeq += 1;
|
|
180
|
+
clearCopyTimer();
|
|
181
|
+
clearDownload();
|
|
182
|
+
unsubscribeTheme();
|
|
89
183
|
view.value?.destroy();
|
|
90
184
|
view.value = null;
|
|
91
|
-
themeObserver?.disconnect();
|
|
92
|
-
themeObserver = null;
|
|
93
|
-
if (copyTimer !== null) {
|
|
94
|
-
clearTimeout(copyTimer);
|
|
95
|
-
copyTimer = null;
|
|
96
|
-
}
|
|
97
185
|
});
|
|
98
|
-
watch(() =>
|
|
186
|
+
watch(() => props.lang, () => {
|
|
99
187
|
initEditor();
|
|
100
188
|
});
|
|
189
|
+
watch(() => props.editable, (editable) => {
|
|
190
|
+
view.value?.dispatch({ effects: editableCompartment.reconfigure(EditorView.editable.of(editable)) });
|
|
191
|
+
});
|
|
192
|
+
watch(() => props.wordWrap, (wrap) => {
|
|
193
|
+
view.value?.dispatch({ effects: wrapCompartment.reconfigure(wrap ? EditorView.lineWrapping : []) });
|
|
194
|
+
});
|
|
195
|
+
watch(() => props.code, (next) => replaceDocument(next));
|
|
196
|
+
watch(() => (props.highlightLines ?? []).join(","), () => applyHighlights());
|
|
101
197
|
function getSelection() {
|
|
102
198
|
const ed = view.value;
|
|
103
199
|
if (!ed) return null;
|
|
104
200
|
const range = ed.state.selection.main;
|
|
105
201
|
if (range.empty) return null;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
startLine: ed.state.doc.lineAt(range.from).number,
|
|
111
|
-
endLine: ed.state.doc.lineAt(range.to).number
|
|
112
|
-
};
|
|
202
|
+
return readCodeBlockSelection(false, ed.state.sliceDoc(range.from, range.to), ed.state.doc.lineAt(range.from).number, ed.state.doc.lineAt(range.to).number);
|
|
203
|
+
}
|
|
204
|
+
function focus() {
|
|
205
|
+
view.value?.focus();
|
|
113
206
|
}
|
|
114
|
-
__expose({
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (view.value.state.doc.toString() === newCode) return;
|
|
118
|
-
view.value.dispatch({ changes: {
|
|
119
|
-
from: 0,
|
|
120
|
-
to: view.value.state.doc.length,
|
|
121
|
-
insert: newCode
|
|
122
|
-
} });
|
|
207
|
+
__expose({
|
|
208
|
+
getSelection,
|
|
209
|
+
focus
|
|
123
210
|
});
|
|
124
211
|
async function copy() {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
212
|
+
const text = props.code;
|
|
213
|
+
const ok = await copyTextToClipboard(text);
|
|
214
|
+
if (unmounted) return;
|
|
215
|
+
copyState.value = ok ? "copied" : "failed";
|
|
216
|
+
liveText.value = ok ? props.copiedLabel ?? t("codeBlock.copied") : props.copyFailedLabel ?? t("codeBlock.copyFailed");
|
|
217
|
+
if (ok) emit("copy", text);
|
|
218
|
+
clearCopyTimer();
|
|
219
|
+
copyTimer = setTimeout(() => {
|
|
220
|
+
copyState.value = "idle";
|
|
221
|
+
liveText.value = "";
|
|
222
|
+
copyTimer = null;
|
|
223
|
+
}, codeBlockCopyFeedbackMs());
|
|
134
224
|
}
|
|
135
225
|
function download() {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
|
|
226
|
+
const raw = props.downloadFilename;
|
|
227
|
+
if (!raw || typeof document === "undefined" || typeof URL === "undefined" || typeof URL.createObjectURL !== "function") return;
|
|
228
|
+
const name = sanitizeDownloadFilename(raw);
|
|
229
|
+
const blob = new Blob([props.code], { type: mimeForDownloadFilename(name) });
|
|
230
|
+
clearDownload();
|
|
141
231
|
const url = URL.createObjectURL(blob);
|
|
232
|
+
downloadUrl = url;
|
|
142
233
|
const anchor = document.createElement("a");
|
|
143
234
|
anchor.href = url;
|
|
144
235
|
anchor.download = name;
|
|
@@ -146,26 +237,54 @@ var RsCodeBlock_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
146
237
|
document.body.appendChild(anchor);
|
|
147
238
|
anchor.click();
|
|
148
239
|
anchor.remove();
|
|
149
|
-
|
|
240
|
+
downloadTimer = setTimeout(() => {
|
|
241
|
+
if (downloadUrl === url) {
|
|
242
|
+
URL.revokeObjectURL(url);
|
|
243
|
+
downloadUrl = null;
|
|
244
|
+
}
|
|
245
|
+
downloadTimer = null;
|
|
246
|
+
}, codeBlockDownloadRevokeMs());
|
|
150
247
|
}
|
|
151
248
|
return (_ctx, _cache) => {
|
|
152
|
-
return openBlock(), createElementBlock("figure", {
|
|
153
|
-
|
|
154
|
-
"rs-code-block
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
249
|
+
return openBlock(), createElementBlock("figure", {
|
|
250
|
+
id: __props.id || void 0,
|
|
251
|
+
class: normalizeClass(["rs-code-block", {
|
|
252
|
+
"rs-code-block--editable": __props.editable,
|
|
253
|
+
"rs-code-block--plain": !__props.showBar,
|
|
254
|
+
"rs-code-block--no-lines": !__props.lineNumbers,
|
|
255
|
+
"rs-code-block--nowrap": !__props.wordWrap,
|
|
256
|
+
"rs-code-block--capped": !!__props.maxHeight
|
|
257
|
+
}]),
|
|
258
|
+
style: normalizeStyle(rootStyle.value),
|
|
259
|
+
"aria-label": __props.showBar ? void 0 : figureLabel.value
|
|
260
|
+
}, [
|
|
261
|
+
__props.showBar ? (openBlock(), createElementBlock("figcaption", _hoisted_2, [createElementVNode("div", _hoisted_3, [__props.filename ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(__props.filename), 1)) : createCommentVNode("", true), createElementVNode("span", _hoisted_5, toDisplayString(__props.lang), 1)]), createElementVNode("div", {
|
|
262
|
+
class: "rs-code-block__actions",
|
|
263
|
+
role: "toolbar",
|
|
264
|
+
"aria-label": toolbarLabel.value
|
|
265
|
+
}, [
|
|
266
|
+
renderSlot(_ctx.$slots, "actions", {}, void 0, true),
|
|
267
|
+
__props.downloadFilename ? (openBlock(), createElementBlock("button", {
|
|
268
|
+
key: 0,
|
|
269
|
+
type: "button",
|
|
270
|
+
class: "rs-code-block__copy",
|
|
271
|
+
onClick: download
|
|
272
|
+
}, toDisplayString(downloadVisual.value), 1)) : createCommentVNode("", true),
|
|
273
|
+
createElementVNode("button", {
|
|
274
|
+
type: "button",
|
|
275
|
+
class: "rs-code-block__copy",
|
|
276
|
+
"aria-label": copyAria.value,
|
|
277
|
+
onClick: copy
|
|
278
|
+
}, [createElementVNode("span", _hoisted_8, toDisplayString(copyVisual.value), 1)], 8, _hoisted_7)
|
|
279
|
+
], 8, _hoisted_6)])) : createCommentVNode("", true),
|
|
280
|
+
createElementVNode("span", _hoisted_9, toDisplayString(liveText.value), 1),
|
|
281
|
+
createElementVNode("div", {
|
|
282
|
+
ref_key: "editorEl",
|
|
283
|
+
ref: editorEl,
|
|
284
|
+
class: "rs-code-block__editor",
|
|
285
|
+
dir: "ltr"
|
|
286
|
+
}, null, 512)
|
|
287
|
+
], 14, _hoisted_1);
|
|
169
288
|
};
|
|
170
289
|
}
|
|
171
290
|
});
|
|
@@ -3,6 +3,6 @@ import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_exp
|
|
|
3
3
|
import RsCodeBlock_vue_vue_type_script_setup_true_lang_default from "./RsCodeBlock.impl.js";
|
|
4
4
|
|
|
5
5
|
//#region src/components/code-block/src/RsCodeBlock.vue
|
|
6
|
-
var RsCodeBlock_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsCodeBlock_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
6
|
+
var RsCodeBlock_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsCodeBlock_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-227d5b66"]]);
|
|
7
7
|
//#endregion
|
|
8
8
|
export { RsCodeBlock_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { StateEffect, StateField } from '@codemirror/state';
|
|
2
|
+
import { type DecorationSet } from '@codemirror/view';
|
|
3
|
+
export declare function codeBlockHighlightExtension(): StateField<DecorationSet>;
|
|
4
|
+
export declare function highlightCodeBlockLines(lines: readonly number[] | undefined): StateEffect<readonly number[]>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { normalizeHighlightLines } from "./code-block-utils.js";
|
|
2
|
+
import { RangeSetBuilder, StateEffect, StateField } from "@codemirror/state";
|
|
3
|
+
import { Decoration, EditorView } from "@codemirror/view";
|
|
4
|
+
//#region src/components/code-block/src/code-block-highlight.ts
|
|
5
|
+
var setHighlight = StateEffect.define();
|
|
6
|
+
function buildHighlight(doc, lines) {
|
|
7
|
+
const wanted = normalizeHighlightLines(lines, doc.lines);
|
|
8
|
+
if (!wanted.length) return Decoration.none;
|
|
9
|
+
const builder = new RangeSetBuilder();
|
|
10
|
+
for (const lineNo of wanted) {
|
|
11
|
+
const line = doc.line(lineNo);
|
|
12
|
+
builder.add(line.from, line.from, Decoration.line({ class: "cm-rs-code-line--highlight" }));
|
|
13
|
+
}
|
|
14
|
+
return builder.finish();
|
|
15
|
+
}
|
|
16
|
+
var highlightField = StateField.define({
|
|
17
|
+
create() {
|
|
18
|
+
return Decoration.none;
|
|
19
|
+
},
|
|
20
|
+
update(deco, tr) {
|
|
21
|
+
for (const effect of tr.effects) if (effect.is(setHighlight)) return buildHighlight(tr.state.doc, effect.value);
|
|
22
|
+
if (tr.docChanged) return deco.map(tr.changes);
|
|
23
|
+
return deco;
|
|
24
|
+
},
|
|
25
|
+
provide: (field) => EditorView.decorations.from(field)
|
|
26
|
+
});
|
|
27
|
+
function codeBlockHighlightExtension() {
|
|
28
|
+
return highlightField;
|
|
29
|
+
}
|
|
30
|
+
function highlightCodeBlockLines(lines) {
|
|
31
|
+
return setHighlight.of(lines ?? []);
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { codeBlockHighlightExtension, highlightCodeBlockLines };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface RsCodeBlockSelection {
|
|
2
|
+
text: string;
|
|
3
|
+
startLine: number;
|
|
4
|
+
endLine: number;
|
|
5
|
+
}
|
|
6
|
+
export interface RsCodeBlockExpose {
|
|
7
|
+
getSelection: () => RsCodeBlockSelection | null;
|
|
8
|
+
focus: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function codeBlockCopyFeedbackMs(): number;
|
|
11
|
+
export declare function codeBlockDownloadRevokeMs(): number;
|
|
12
|
+
/** 下载名只留最后一段,避免把目录写进 download 属性。 */
|
|
13
|
+
export declare function sanitizeDownloadFilename(name: string): string;
|
|
14
|
+
export declare function mimeForDownloadFilename(name: string): string;
|
|
15
|
+
export declare function readCodeBlockSelection(empty: boolean, text: string, startLine: number, endLine: number): RsCodeBlockSelection | null;
|
|
16
|
+
/** 行号从 1 开始,去重后升序。超出文档的行丢掉。 */
|
|
17
|
+
export declare function normalizeHighlightLines(lines: readonly number[] | undefined, lineCount: number): number[];
|
|
18
|
+
/** 最近的 data-rs-theme。没有时看 documentElement。深色岛不必改整页。 */
|
|
19
|
+
export declare function isCodeBlockDarkTheme(el: HTMLElement | null): boolean;
|
|
20
|
+
type ThemeListener = () => void;
|
|
21
|
+
/** 多个代码块共用一个主题观察器。最后一个退订时断开。 */
|
|
22
|
+
export declare function subscribeCodeBlockTheme(listener: ThemeListener): () => void;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
//#region src/components/code-block/src/code-block-utils.ts
|
|
2
|
+
var COPY_FEEDBACK_MS = 1500;
|
|
3
|
+
var DOWNLOAD_REVOKE_MS = 1500;
|
|
4
|
+
function codeBlockCopyFeedbackMs() {
|
|
5
|
+
return COPY_FEEDBACK_MS;
|
|
6
|
+
}
|
|
7
|
+
function codeBlockDownloadRevokeMs() {
|
|
8
|
+
return DOWNLOAD_REVOKE_MS;
|
|
9
|
+
}
|
|
10
|
+
/** 下载名只留最后一段,避免把目录写进 download 属性。 */
|
|
11
|
+
function sanitizeDownloadFilename(name) {
|
|
12
|
+
return name.replace(/^.*[/\\]/, "").replace(/[\u0000-\u001f]/g, "") || "download.html";
|
|
13
|
+
}
|
|
14
|
+
function mimeForDownloadFilename(name) {
|
|
15
|
+
const lower = name.toLowerCase();
|
|
16
|
+
if (lower.endsWith(".html") || lower.endsWith(".htm")) return "text/html;charset=utf-8";
|
|
17
|
+
return "text/plain;charset=utf-8";
|
|
18
|
+
}
|
|
19
|
+
function readCodeBlockSelection(empty, text, startLine, endLine) {
|
|
20
|
+
if (empty || !text.trim()) return null;
|
|
21
|
+
return {
|
|
22
|
+
text,
|
|
23
|
+
startLine,
|
|
24
|
+
endLine
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** 行号从 1 开始,去重后升序。超出文档的行丢掉。 */
|
|
28
|
+
function normalizeHighlightLines(lines, lineCount) {
|
|
29
|
+
if (!lines?.length || lineCount < 1) return [];
|
|
30
|
+
const seen = /* @__PURE__ */ new Set();
|
|
31
|
+
const out = [];
|
|
32
|
+
for (const raw of lines) {
|
|
33
|
+
if (!Number.isInteger(raw) || raw < 1 || raw > lineCount || seen.has(raw)) continue;
|
|
34
|
+
seen.add(raw);
|
|
35
|
+
out.push(raw);
|
|
36
|
+
}
|
|
37
|
+
out.sort((a, b) => a - b);
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
/** 最近的 data-rs-theme。没有时看 documentElement。深色岛不必改整页。 */
|
|
41
|
+
function isCodeBlockDarkTheme(el) {
|
|
42
|
+
if (typeof document === "undefined") return false;
|
|
43
|
+
return (el?.closest("[data-rs-theme]") ?? document.documentElement).getAttribute("data-rs-theme") === "dark";
|
|
44
|
+
}
|
|
45
|
+
var themeListeners = /* @__PURE__ */ new Set();
|
|
46
|
+
var themeObserver = null;
|
|
47
|
+
function ensureThemeObserver() {
|
|
48
|
+
if (themeObserver || typeof document === "undefined" || typeof MutationObserver === "undefined") return;
|
|
49
|
+
themeObserver = new MutationObserver(() => {
|
|
50
|
+
for (const listener of themeListeners) listener();
|
|
51
|
+
});
|
|
52
|
+
themeObserver.observe(document.documentElement, {
|
|
53
|
+
attributes: true,
|
|
54
|
+
attributeFilter: ["data-rs-theme"],
|
|
55
|
+
subtree: true
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/** 多个代码块共用一个主题观察器。最后一个退订时断开。 */
|
|
59
|
+
function subscribeCodeBlockTheme(listener) {
|
|
60
|
+
themeListeners.add(listener);
|
|
61
|
+
ensureThemeObserver();
|
|
62
|
+
return () => {
|
|
63
|
+
themeListeners.delete(listener);
|
|
64
|
+
if (themeListeners.size === 0 && themeObserver) {
|
|
65
|
+
themeObserver.disconnect();
|
|
66
|
+
themeObserver = null;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { codeBlockCopyFeedbackMs, codeBlockDownloadRevokeMs, isCodeBlockDarkTheme, mimeForDownloadFilename, normalizeHighlightLines, readCodeBlockSelection, sanitizeDownloadFilename, subscribeCodeBlockTheme };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as RsCodeEditor } from './src/RsCodeEditor.js';
|
|
2
2
|
export { resolveCodeMirrorLanguage, isCodeMirrorLightTheme, prewarmCodeMirrorEditor } from './src/code-mirror-lang';
|
|
3
|
-
export type { RsCodeEditorDiagnostic, RsCodeEditorLanguage, RsCodeEditorSqlColumn, RsCodeEditorSqlConfig, RsCodeEditorSqlDialect, RsCodeEditorSqlNamespace, RsCodeEditorTheme, RsResolvedCodeEditorTheme, } from './src/code-editor-utils';
|
|
3
|
+
export type { RsCodeEditorDiagnostic, RsCodeEditorExpose, RsCodeEditorLanguage, RsCodeEditorSqlColumn, RsCodeEditorSqlConfig, RsCodeEditorSqlDialect, RsCodeEditorSqlNamespace, RsCodeEditorTheme, RsResolvedCodeEditorTheme, } from './src/code-editor-utils';
|
|
4
4
|
export { codeEditorLanguageLabel, readDocumentTheme, resolveCodeEditorLanguage, resolveCodeEditorSize, resolveCodeEditorTheme, } from './src/code-editor-utils';
|