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,40 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
2
|
+
import { codeEditorLanguageLabel, codeEditorModShortcut, readDocumentTheme, resolveCodeEditorLanguage, resolveCodeEditorSize, resolveCodeEditorTheme, subscribeDocumentTheme } from "./code-editor-utils.js";
|
|
3
|
+
import { resolveCodeMirrorLanguage } from "./code-mirror-lang.js";
|
|
3
4
|
import { diagnosticExtensions, setEditorDiagnostics } from "./code-mirror-diagnostics.js";
|
|
5
|
+
import { isEditorViewAlive } from "./code-mirror-session.js";
|
|
4
6
|
import { codeMirrorIntelExtensions, goToPosition } from "./code-mirror-intel.js";
|
|
5
7
|
import { clearGhostCompletion, codeMirrorGhostExtensions } from "./code-mirror-ghost.js";
|
|
6
8
|
import { codeMirrorCompletionExtensions } from "./code-mirror-completion.js";
|
|
7
9
|
import { codeMirrorInlineEditExtension, extractSurroundingContext, replaceEditorRange } from "./code-mirror-inline-edit.js";
|
|
8
|
-
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeModels, nextTick, normalizeClass, normalizeStyle, onMounted, onUnmounted, openBlock, ref, renderList, renderSlot, shallowRef, toDisplayString, useModel, vModelText, watch, withDirectives, withKeys, withModifiers } from "vue";
|
|
10
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeModels, nextTick, normalizeClass, normalizeStyle, onMounted, onUnmounted, openBlock, ref, renderList, renderSlot, shallowRef, toDisplayString, unref, useId, useModel, vModelText, watch, withDirectives, withKeys, withModifiers } from "vue";
|
|
9
11
|
import { basicSetup } from "codemirror";
|
|
10
12
|
import { Compartment, EditorState } from "@codemirror/state";
|
|
11
13
|
import { EditorView, placeholder, tooltips } from "@codemirror/view";
|
|
12
14
|
import { oneDark } from "@codemirror/theme-one-dark";
|
|
13
15
|
//#region src/components/code-editor/src/RsCodeEditor.vue?vue&type=script&setup=true&lang.ts
|
|
14
|
-
var _hoisted_1 =
|
|
16
|
+
var _hoisted_1 = [
|
|
17
|
+
"id",
|
|
18
|
+
"data-rs-theme",
|
|
19
|
+
"aria-label",
|
|
20
|
+
"aria-disabled"
|
|
21
|
+
];
|
|
22
|
+
var _hoisted_2 = {
|
|
15
23
|
key: 0,
|
|
16
24
|
class: "rs-code-editor__toolbar"
|
|
17
25
|
};
|
|
18
|
-
var
|
|
19
|
-
var
|
|
26
|
+
var _hoisted_3 = { class: "rs-code-editor__body" };
|
|
27
|
+
var _hoisted_4 = ["aria-labelledby", "aria-busy"];
|
|
28
|
+
var _hoisted_5 = { class: "rs-code-editor__inline-edit-head" };
|
|
29
|
+
var _hoisted_6 = ["id"];
|
|
30
|
+
var _hoisted_7 = { class: "rs-code-editor__inline-preview" };
|
|
31
|
+
var _hoisted_8 = [
|
|
32
|
+
"placeholder",
|
|
33
|
+
"disabled",
|
|
34
|
+
"onKeydown"
|
|
35
|
+
];
|
|
36
|
+
var _hoisted_9 = {
|
|
20
37
|
key: 0,
|
|
21
|
-
class: "rs-code-editor__inline-
|
|
38
|
+
class: "rs-code-editor__inline-error",
|
|
39
|
+
role: "alert"
|
|
22
40
|
};
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
var _hoisted_7 = { class: "rs-code-editor__inline-actions" };
|
|
30
|
-
var _hoisted_8 = ["disabled"];
|
|
31
|
-
var _hoisted_9 = ["disabled"];
|
|
32
|
-
var _hoisted_10 = {
|
|
33
|
-
key: 1,
|
|
34
|
-
class: "rs-code-editor__diagnostics"
|
|
35
|
-
};
|
|
36
|
-
var _hoisted_11 = { key: 0 };
|
|
41
|
+
var _hoisted_10 = { class: "rs-code-editor__inline-actions" };
|
|
42
|
+
var _hoisted_11 = ["disabled"];
|
|
43
|
+
var _hoisted_12 = ["disabled"];
|
|
44
|
+
var _hoisted_13 = ["aria-label"];
|
|
45
|
+
var _hoisted_14 = ["onClick"];
|
|
46
|
+
var _hoisted_15 = { key: 0 };
|
|
37
47
|
var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
48
|
+
name: "RsCodeEditor",
|
|
38
49
|
__name: "RsCodeEditor",
|
|
39
50
|
props: /*@__PURE__*/ mergeModels({
|
|
40
51
|
language: { default: "plaintext" },
|
|
@@ -72,7 +83,17 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
72
83
|
hoverRequest: {},
|
|
73
84
|
definitionRequest: {},
|
|
74
85
|
completionRequest: {},
|
|
75
|
-
inlineEditRequest: {}
|
|
86
|
+
inlineEditRequest: {},
|
|
87
|
+
wrap: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
default: true
|
|
90
|
+
},
|
|
91
|
+
autofocus: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: false
|
|
94
|
+
},
|
|
95
|
+
ariaLabel: {},
|
|
96
|
+
id: {}
|
|
76
97
|
}, {
|
|
77
98
|
"modelValue": { default: "" },
|
|
78
99
|
"modelModifiers": {}
|
|
@@ -82,6 +103,8 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
82
103
|
const model = useModel(__props, "modelValue");
|
|
83
104
|
const emit = __emit;
|
|
84
105
|
const props = __props;
|
|
106
|
+
const { t } = useRsI18n();
|
|
107
|
+
const inlineTitleId = useId();
|
|
85
108
|
const rootStyle = computed(() => {
|
|
86
109
|
const style = { height: resolveCodeEditorSize(props.height) };
|
|
87
110
|
if (props.gutterWidth != null && props.gutterWidth > 0) style["--rs-code-editor-gutter-width"] = `${props.gutterWidth}px`;
|
|
@@ -91,15 +114,25 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
91
114
|
const resolvedLanguageLabel = computed(() => codeEditorLanguageLabel(props.language));
|
|
92
115
|
const documentTheme = ref(readDocumentTheme());
|
|
93
116
|
const resolvedTheme = computed(() => props.theme === "auto" ? documentTheme.value : resolveCodeEditorTheme(props.theme));
|
|
117
|
+
/** auto 继承页面;显式 light/dark 在根上写 data-rs-theme,形成主题岛。 */
|
|
118
|
+
const themeIsland = computed(() => props.theme === "auto" ? void 0 : resolvedTheme.value);
|
|
119
|
+
const editorLabel = computed(() => props.ariaLabel?.trim() || t("codeEditor.label"));
|
|
120
|
+
const inlineShortcut = computed(() => codeEditorModShortcut("K"));
|
|
94
121
|
const editorEl = ref(null);
|
|
122
|
+
const inlineEditPanelRef = ref(null);
|
|
95
123
|
const view = shallowRef(null);
|
|
96
124
|
const editableCompartment = new Compartment();
|
|
97
125
|
const themeCompartment = new Compartment();
|
|
98
|
-
|
|
126
|
+
const wrapCompartment = new Compartment();
|
|
127
|
+
const placeholderCompartment = new Compartment();
|
|
128
|
+
const contentCompartment = new Compartment();
|
|
129
|
+
let stopTheme = null;
|
|
99
130
|
let unmounted = false;
|
|
100
131
|
let syncingFromModel = false;
|
|
101
132
|
let ghostTimer = null;
|
|
102
133
|
let initSeq = 0;
|
|
134
|
+
let didAutofocus = false;
|
|
135
|
+
let inlineAbort = null;
|
|
103
136
|
const inlineEditOpen = ref(false);
|
|
104
137
|
const inlineEditInstruction = ref("");
|
|
105
138
|
const inlineEditLoading = ref(false);
|
|
@@ -107,16 +140,57 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
107
140
|
const inlineEditError = ref("");
|
|
108
141
|
const inlineEditInputRef = ref(null);
|
|
109
142
|
let pendingInlineEdit = null;
|
|
143
|
+
function codeMirrorThemeExts(theme) {
|
|
144
|
+
return theme === "light" ? [] : [oneDark];
|
|
145
|
+
}
|
|
146
|
+
function placeholderExt() {
|
|
147
|
+
return props.placeholder ? [placeholder(props.placeholder)] : [];
|
|
148
|
+
}
|
|
149
|
+
function wrapExt() {
|
|
150
|
+
return props.wrap ? [EditorView.lineWrapping] : [];
|
|
151
|
+
}
|
|
152
|
+
function contentAttributeExt() {
|
|
153
|
+
const attrs = {
|
|
154
|
+
"aria-label": editorLabel.value,
|
|
155
|
+
spellcheck: "false"
|
|
156
|
+
};
|
|
157
|
+
if (props.disabled) {
|
|
158
|
+
attrs["aria-disabled"] = "true";
|
|
159
|
+
attrs.tabindex = "-1";
|
|
160
|
+
} else if (props.readonly) attrs["aria-readonly"] = "true";
|
|
161
|
+
return EditorView.contentAttributes.of(attrs);
|
|
162
|
+
}
|
|
163
|
+
function applyChrome() {
|
|
164
|
+
const current = view.value;
|
|
165
|
+
if (!isEditorViewAlive(current)) return;
|
|
166
|
+
const editable = !props.readonly && !props.disabled;
|
|
167
|
+
current.dispatch({ effects: [editableCompartment.reconfigure(EditorView.editable.of(editable)), contentCompartment.reconfigure(contentAttributeExt())] });
|
|
168
|
+
}
|
|
169
|
+
function applyThemeExt() {
|
|
170
|
+
const current = view.value;
|
|
171
|
+
if (!isEditorViewAlive(current)) return;
|
|
172
|
+
current.dispatch({ effects: themeCompartment.reconfigure(codeMirrorThemeExts(resolvedTheme.value)) });
|
|
173
|
+
}
|
|
174
|
+
function abortInlineEdit() {
|
|
175
|
+
inlineAbort?.abort();
|
|
176
|
+
inlineAbort = null;
|
|
177
|
+
}
|
|
110
178
|
function closeInlineEdit() {
|
|
179
|
+
const wasOpen = inlineEditOpen.value;
|
|
180
|
+
abortInlineEdit();
|
|
111
181
|
inlineEditOpen.value = false;
|
|
112
182
|
inlineEditInstruction.value = "";
|
|
113
183
|
inlineEditPreview.value = "";
|
|
114
184
|
inlineEditError.value = "";
|
|
185
|
+
inlineEditLoading.value = false;
|
|
115
186
|
pendingInlineEdit = null;
|
|
187
|
+
if (wasOpen && isEditorViewAlive(view.value) && !props.disabled) view.value.focus();
|
|
116
188
|
}
|
|
117
189
|
function onInlineEditTrigger(_view, info) {
|
|
118
190
|
if (!props.inlineEditRequest || props.readonly || props.disabled) return;
|
|
119
|
-
if (view.value) clearGhostCompletion(view.value);
|
|
191
|
+
if (isEditorViewAlive(view.value)) clearGhostCompletion(view.value);
|
|
192
|
+
abortInlineEdit();
|
|
193
|
+
inlineEditLoading.value = false;
|
|
120
194
|
pendingInlineEdit = info;
|
|
121
195
|
inlineEditPreview.value = info.selection.length > 120 ? `${info.selection.slice(0, 120)}…` : info.selection;
|
|
122
196
|
inlineEditOpen.value = true;
|
|
@@ -127,7 +201,11 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
127
201
|
async function submitInlineEdit() {
|
|
128
202
|
const range = pendingInlineEdit;
|
|
129
203
|
const instruction = inlineEditInstruction.value.trim();
|
|
130
|
-
if (!range || !instruction || !props.inlineEditRequest || !view.value || inlineEditLoading.value) return;
|
|
204
|
+
if (!range || !instruction || !props.inlineEditRequest || !isEditorViewAlive(view.value) || inlineEditLoading.value) return;
|
|
205
|
+
abortInlineEdit();
|
|
206
|
+
const controller = new AbortController();
|
|
207
|
+
inlineAbort = controller;
|
|
208
|
+
const signal = controller.signal;
|
|
131
209
|
inlineEditLoading.value = true;
|
|
132
210
|
inlineEditError.value = "";
|
|
133
211
|
try {
|
|
@@ -137,18 +215,55 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
137
215
|
instruction,
|
|
138
216
|
from: range.from,
|
|
139
217
|
to: range.to,
|
|
140
|
-
surroundingContext: extractSurroundingContext(doc, range.from, range.to)
|
|
218
|
+
surroundingContext: extractSurroundingContext(doc, range.from, range.to),
|
|
219
|
+
signal
|
|
141
220
|
});
|
|
221
|
+
if (signal.aborted || unmounted || !isEditorViewAlive(view.value)) return;
|
|
142
222
|
if (edited == null) {
|
|
143
|
-
inlineEditError.value = "
|
|
223
|
+
inlineEditError.value = t("codeEditor.inlineEditFailed");
|
|
144
224
|
return;
|
|
145
225
|
}
|
|
146
226
|
replaceEditorRange(view.value, range.from, range.to, edited);
|
|
147
227
|
closeInlineEdit();
|
|
228
|
+
} catch {
|
|
229
|
+
if (signal.aborted || unmounted) return;
|
|
230
|
+
inlineEditError.value = t("codeEditor.inlineEditFailed");
|
|
148
231
|
} finally {
|
|
149
|
-
|
|
232
|
+
if (inlineAbort === controller) inlineAbort = null;
|
|
233
|
+
if (!unmounted && inlineEditOpen.value) inlineEditLoading.value = false;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function onInlineEditKeydown(event) {
|
|
237
|
+
if (event.key === "Escape") {
|
|
238
|
+
event.preventDefault();
|
|
239
|
+
closeInlineEdit();
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (event.key !== "Tab") return;
|
|
243
|
+
const root = inlineEditPanelRef.value;
|
|
244
|
+
if (!root) return;
|
|
245
|
+
const items = [...root.querySelectorAll("input:not(:disabled), button:not(:disabled)")];
|
|
246
|
+
if (items.length === 0) return;
|
|
247
|
+
const first = items[0];
|
|
248
|
+
const last = items[items.length - 1];
|
|
249
|
+
if (!first || !last) return;
|
|
250
|
+
const active = document.activeElement;
|
|
251
|
+
if (event.shiftKey && (active === first || !root.contains(active))) {
|
|
252
|
+
event.preventDefault();
|
|
253
|
+
last.focus();
|
|
254
|
+
} else if (!event.shiftKey && active === last) {
|
|
255
|
+
event.preventDefault();
|
|
256
|
+
first.focus();
|
|
150
257
|
}
|
|
151
258
|
}
|
|
259
|
+
function jumpToDiagnostic(diagnostic) {
|
|
260
|
+
if (!isEditorViewAlive(view.value) || props.disabled) return;
|
|
261
|
+
if (diagnostic.line == null) {
|
|
262
|
+
view.value.focus();
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
goToPosition(view.value, diagnostic.line, diagnostic.column ?? 1);
|
|
266
|
+
}
|
|
152
267
|
function scheduleGhostCompletion(fn) {
|
|
153
268
|
if (ghostTimer) clearTimeout(ghostTimer);
|
|
154
269
|
ghostTimer = setTimeout(fn, 900);
|
|
@@ -159,19 +274,11 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
159
274
|
ghostTimer = null;
|
|
160
275
|
}
|
|
161
276
|
}
|
|
162
|
-
function codeMirrorThemeExts() {
|
|
163
|
-
return isCodeMirrorLightTheme() ? [] : [oneDark];
|
|
164
|
-
}
|
|
165
|
-
function applyDocumentTheme() {
|
|
166
|
-
documentTheme.value = readDocumentTheme();
|
|
167
|
-
if (!view.value) return;
|
|
168
|
-
view.value.dispatch({ effects: themeCompartment.reconfigure(codeMirrorThemeExts()) });
|
|
169
|
-
view.value.requestMeasure();
|
|
170
|
-
}
|
|
171
277
|
async function initEditor() {
|
|
172
278
|
if (!editorEl.value || unmounted) return;
|
|
173
279
|
const seq = ++initSeq;
|
|
174
280
|
const targetEl = editorEl.value;
|
|
281
|
+
const previous = isEditorViewAlive(view.value) ? view.value.state.selection.main : null;
|
|
175
282
|
view.value?.destroy();
|
|
176
283
|
view.value = null;
|
|
177
284
|
const langExts = await resolveCodeMirrorLanguage(resolvedLanguage.value, { sql: props.sqlConfig });
|
|
@@ -181,10 +288,11 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
181
288
|
doc: model.value,
|
|
182
289
|
extensions: [
|
|
183
290
|
basicSetup,
|
|
184
|
-
...props.embedded ? [tooltips({ parent: document.body })] : [],
|
|
185
|
-
|
|
291
|
+
...props.embedded && typeof document !== "undefined" ? [tooltips({ parent: document.body })] : [],
|
|
292
|
+
wrapCompartment.of(wrapExt()),
|
|
186
293
|
editableCompartment.of(EditorView.editable.of(editable)),
|
|
187
|
-
|
|
294
|
+
placeholderCompartment.of(placeholderExt()),
|
|
295
|
+
contentCompartment.of(contentAttributeExt()),
|
|
188
296
|
...langExts,
|
|
189
297
|
diagnosticExtensions(),
|
|
190
298
|
...codeMirrorIntelExtensions(() => ({
|
|
@@ -196,7 +304,7 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
196
304
|
...codeMirrorCompletionExtensions(() => ({ completionRequest: props.completionRequest })),
|
|
197
305
|
...codeMirrorGhostExtensions(() => ({ completionRequest: props.completionRequest }), scheduleGhostCompletion, cancelGhostCompletionSchedule),
|
|
198
306
|
...props.inlineEditRequest ? [codeMirrorInlineEditExtension(onInlineEditTrigger)] : [],
|
|
199
|
-
themeCompartment.of(codeMirrorThemeExts()),
|
|
307
|
+
themeCompartment.of(codeMirrorThemeExts(resolvedTheme.value)),
|
|
200
308
|
EditorView.updateListener.of((update) => {
|
|
201
309
|
if (!update.docChanged || syncingFromModel) return;
|
|
202
310
|
const next = update.state.doc.toString();
|
|
@@ -204,114 +312,173 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
204
312
|
})
|
|
205
313
|
]
|
|
206
314
|
});
|
|
207
|
-
|
|
315
|
+
if (unmounted || !targetEl.isConnected || seq !== initSeq) return;
|
|
316
|
+
const created = new EditorView({
|
|
208
317
|
state,
|
|
209
318
|
parent: targetEl
|
|
210
319
|
});
|
|
211
|
-
|
|
320
|
+
view.value = created;
|
|
321
|
+
if (previous) {
|
|
322
|
+
const length = created.state.doc.length;
|
|
323
|
+
const anchor = Math.min(previous.anchor, length);
|
|
324
|
+
const head = Math.min(previous.head, length);
|
|
325
|
+
if (anchor !== 0 || head !== 0) created.dispatch({ selection: {
|
|
326
|
+
anchor,
|
|
327
|
+
head
|
|
328
|
+
} });
|
|
329
|
+
}
|
|
330
|
+
setEditorDiagnostics(created, props.diagnostics ?? []);
|
|
331
|
+
if (props.autofocus && !didAutofocus && editable) {
|
|
332
|
+
didAutofocus = true;
|
|
333
|
+
created.focus();
|
|
334
|
+
}
|
|
212
335
|
emit("ready");
|
|
213
336
|
}
|
|
214
337
|
onMounted(() => {
|
|
215
338
|
unmounted = false;
|
|
216
339
|
initEditor();
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
});
|
|
220
|
-
themeObserver.observe(document.documentElement, {
|
|
221
|
-
attributes: true,
|
|
222
|
-
attributeFilter: ["data-rs-theme"]
|
|
340
|
+
stopTheme = subscribeDocumentTheme(() => {
|
|
341
|
+
documentTheme.value = readDocumentTheme();
|
|
223
342
|
});
|
|
224
343
|
});
|
|
225
344
|
onUnmounted(() => {
|
|
226
345
|
unmounted = true;
|
|
227
|
-
|
|
346
|
+
initSeq += 1;
|
|
347
|
+
abortInlineEdit();
|
|
348
|
+
cancelGhostCompletionSchedule();
|
|
349
|
+
stopTheme?.();
|
|
350
|
+
stopTheme = null;
|
|
228
351
|
view.value?.destroy();
|
|
229
352
|
view.value = null;
|
|
230
|
-
themeObserver?.disconnect();
|
|
231
|
-
themeObserver = null;
|
|
232
353
|
});
|
|
233
|
-
watch(() =>
|
|
354
|
+
watch(() => [
|
|
355
|
+
props.language,
|
|
356
|
+
Boolean(props.inlineEditRequest),
|
|
357
|
+
resolvedLanguage.value === "sql" ? props.sqlConfig : null
|
|
358
|
+
], () => {
|
|
234
359
|
initEditor();
|
|
360
|
+
}, { deep: true });
|
|
361
|
+
watch(resolvedTheme, () => {
|
|
362
|
+
applyThemeExt();
|
|
235
363
|
});
|
|
236
|
-
watch(() => props.
|
|
237
|
-
|
|
364
|
+
watch(() => props.wrap, () => {
|
|
365
|
+
const current = view.value;
|
|
366
|
+
if (!isEditorViewAlive(current)) return;
|
|
367
|
+
current.dispatch({ effects: wrapCompartment.reconfigure(wrapExt()) });
|
|
368
|
+
});
|
|
369
|
+
watch(() => props.placeholder, () => {
|
|
370
|
+
const current = view.value;
|
|
371
|
+
if (!isEditorViewAlive(current)) return;
|
|
372
|
+
current.dispatch({ effects: placeholderCompartment.reconfigure(placeholderExt()) });
|
|
373
|
+
});
|
|
374
|
+
watch(() => [
|
|
375
|
+
props.readonly,
|
|
376
|
+
props.disabled,
|
|
377
|
+
editorLabel.value
|
|
378
|
+
], () => {
|
|
379
|
+
applyChrome();
|
|
238
380
|
});
|
|
239
|
-
watch(() => props.sqlConfig, () => {
|
|
240
|
-
if (resolvedLanguage.value === "sql") initEditor();
|
|
241
|
-
}, { deep: true });
|
|
242
381
|
watch(() => model.value, (newCode) => {
|
|
243
|
-
if (!view.value) return;
|
|
382
|
+
if (!isEditorViewAlive(view.value)) return;
|
|
244
383
|
if (view.value.state.doc.toString() === newCode) return;
|
|
245
384
|
syncingFromModel = true;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const editable = !readonly && !disabled;
|
|
257
|
-
view.value.dispatch({ effects: editableCompartment.reconfigure(EditorView.editable.of(editable)) });
|
|
385
|
+
try {
|
|
386
|
+
clearGhostCompletion(view.value);
|
|
387
|
+
view.value.dispatch({ changes: {
|
|
388
|
+
from: 0,
|
|
389
|
+
to: view.value.state.doc.length,
|
|
390
|
+
insert: newCode
|
|
391
|
+
} });
|
|
392
|
+
} finally {
|
|
393
|
+
syncingFromModel = false;
|
|
394
|
+
}
|
|
258
395
|
});
|
|
259
396
|
watch(() => props.diagnostics, (diags) => {
|
|
260
|
-
if (!view.value) return;
|
|
397
|
+
if (!isEditorViewAlive(view.value)) return;
|
|
261
398
|
setEditorDiagnostics(view.value, diags ?? []);
|
|
262
399
|
}, { deep: true });
|
|
263
|
-
__expose({
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
400
|
+
__expose({
|
|
401
|
+
goToPosition(line, column = 1) {
|
|
402
|
+
if (!isEditorViewAlive(view.value)) return;
|
|
403
|
+
goToPosition(view.value, line, column);
|
|
404
|
+
},
|
|
405
|
+
focus() {
|
|
406
|
+
if (!isEditorViewAlive(view.value) || props.disabled) return;
|
|
407
|
+
view.value.focus();
|
|
408
|
+
}
|
|
409
|
+
});
|
|
267
410
|
return (_ctx, _cache) => {
|
|
268
411
|
return openBlock(), createElementBlock("div", {
|
|
412
|
+
id: __props.id,
|
|
269
413
|
class: normalizeClass(["rs-code-editor", [`rs-code-editor--${resolvedTheme.value}`, {
|
|
270
414
|
"rs-code-editor--embedded": __props.embedded,
|
|
271
415
|
"rs-code-editor--square": !__props.rounded || __props.embedded,
|
|
272
416
|
"rs-code-editor--no-fold": !__props.foldGutter,
|
|
273
417
|
"rs-code-editor--gutter-fixed": __props.gutterWidth != null && __props.gutterWidth > 0
|
|
274
418
|
}]]),
|
|
275
|
-
style: normalizeStyle(rootStyle.value)
|
|
419
|
+
style: normalizeStyle(rootStyle.value),
|
|
420
|
+
"data-rs-theme": themeIsland.value,
|
|
421
|
+
role: "group",
|
|
422
|
+
"aria-label": editorLabel.value,
|
|
423
|
+
"aria-disabled": __props.disabled ? "true" : void 0
|
|
276
424
|
}, [
|
|
277
|
-
__props.showToolbar ? (openBlock(), createElementBlock("div",
|
|
278
|
-
createElementVNode("div",
|
|
425
|
+
__props.showToolbar ? (openBlock(), createElementBlock("div", _hoisted_2, [createElementVNode("span", null, toDisplayString(resolvedLanguageLabel.value), 1), renderSlot(_ctx.$slots, "toolbar", {}, void 0, true)])) : createCommentVNode("", true),
|
|
426
|
+
createElementVNode("div", _hoisted_3, [createElementVNode("div", {
|
|
279
427
|
ref_key: "editorEl",
|
|
280
428
|
ref: editorEl,
|
|
281
429
|
class: normalizeClass(["rs-code-editor__surface", { "rs-code-editor__surface--disabled": __props.disabled }])
|
|
282
|
-
}, null, 2), inlineEditOpen.value ? (openBlock(), createElementBlock("div",
|
|
283
|
-
|
|
284
|
-
|
|
430
|
+
}, null, 2), inlineEditOpen.value ? (openBlock(), createElementBlock("div", {
|
|
431
|
+
key: 0,
|
|
432
|
+
ref_key: "inlineEditPanelRef",
|
|
433
|
+
ref: inlineEditPanelRef,
|
|
434
|
+
class: "rs-code-editor__inline-edit",
|
|
435
|
+
role: "dialog",
|
|
436
|
+
"aria-modal": "false",
|
|
437
|
+
"aria-labelledby": unref(inlineTitleId),
|
|
438
|
+
"aria-keyshortcuts": "Control+K Meta+K",
|
|
439
|
+
"aria-busy": inlineEditLoading.value ? "true" : void 0,
|
|
440
|
+
onKeydown: onInlineEditKeydown
|
|
441
|
+
}, [
|
|
442
|
+
createElementVNode("div", _hoisted_5, [createElementVNode("span", { id: unref(inlineTitleId) }, toDisplayString(unref(t)("codeEditor.inlineEdit")), 9, _hoisted_6), createElementVNode("kbd", null, toDisplayString(inlineShortcut.value), 1)]),
|
|
443
|
+
createElementVNode("p", _hoisted_7, toDisplayString(inlineEditPreview.value), 1),
|
|
285
444
|
withDirectives(createElementVNode("input", {
|
|
286
445
|
ref_key: "inlineEditInputRef",
|
|
287
446
|
ref: inlineEditInputRef,
|
|
288
447
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inlineEditInstruction.value = $event),
|
|
289
448
|
class: "rs-code-editor__inline-input",
|
|
290
449
|
type: "text",
|
|
291
|
-
placeholder: "
|
|
450
|
+
placeholder: unref(t)("codeEditor.inlineEditPlaceholder"),
|
|
292
451
|
disabled: inlineEditLoading.value,
|
|
293
|
-
onKeydown:
|
|
294
|
-
}, null, 40,
|
|
295
|
-
inlineEditError.value ? (openBlock(), createElementBlock("p",
|
|
296
|
-
createElementVNode("div",
|
|
452
|
+
onKeydown: withKeys(withModifiers(submitInlineEdit, ["prevent"]), ["enter"])
|
|
453
|
+
}, null, 40, _hoisted_8), [[vModelText, inlineEditInstruction.value]]),
|
|
454
|
+
inlineEditError.value ? (openBlock(), createElementBlock("p", _hoisted_9, toDisplayString(inlineEditError.value), 1)) : createCommentVNode("", true),
|
|
455
|
+
createElementVNode("div", _hoisted_10, [createElementVNode("button", {
|
|
297
456
|
type: "button",
|
|
298
457
|
class: "rs-code-editor__inline-btn",
|
|
299
458
|
disabled: inlineEditLoading.value,
|
|
300
459
|
onClick: closeInlineEdit
|
|
301
|
-
}, "
|
|
460
|
+
}, toDisplayString(unref(t)("common.cancel")), 9, _hoisted_11), createElementVNode("button", {
|
|
302
461
|
type: "button",
|
|
303
462
|
class: "rs-code-editor__inline-btn rs-code-editor__inline-btn--primary",
|
|
304
463
|
disabled: inlineEditLoading.value || !inlineEditInstruction.value.trim(),
|
|
305
464
|
onClick: submitInlineEdit
|
|
306
|
-
}, toDisplayString(inlineEditLoading.value ? "
|
|
307
|
-
])) : createCommentVNode("", true)]),
|
|
308
|
-
__props.diagnostics.length ? (openBlock(), createElementBlock("ul",
|
|
465
|
+
}, toDisplayString(inlineEditLoading.value ? unref(t)("codeEditor.inlineEditApplying") : unref(t)("codeEditor.inlineEditApply")), 9, _hoisted_12)])
|
|
466
|
+
], 40, _hoisted_4)) : createCommentVNode("", true)]),
|
|
467
|
+
__props.diagnostics.length ? (openBlock(), createElementBlock("ul", {
|
|
468
|
+
key: 1,
|
|
469
|
+
class: "rs-code-editor__diagnostics",
|
|
470
|
+
"aria-label": unref(t)("codeEditor.diagnostics")
|
|
471
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.diagnostics, (diagnostic, index) => {
|
|
309
472
|
return openBlock(), createElementBlock("li", {
|
|
310
473
|
key: index,
|
|
311
474
|
class: normalizeClass(`rs-code-editor__diagnostic--${diagnostic.severity ?? "error"}`)
|
|
312
|
-
}, [
|
|
313
|
-
|
|
314
|
-
|
|
475
|
+
}, [createElementVNode("button", {
|
|
476
|
+
type: "button",
|
|
477
|
+
class: "rs-code-editor__diagnostic-btn",
|
|
478
|
+
onClick: ($event) => jumpToDiagnostic(diagnostic)
|
|
479
|
+
}, [diagnostic.line ? (openBlock(), createElementBlock("span", _hoisted_15, toDisplayString(diagnostic.line) + ":" + toDisplayString(diagnostic.column ?? 1), 1)) : createCommentVNode("", true), createTextVNode(" " + toDisplayString(diagnostic.message), 1)], 8, _hoisted_14)], 2);
|
|
480
|
+
}), 128))], 8, _hoisted_13)) : createCommentVNode("", true)
|
|
481
|
+
], 14, _hoisted_1);
|
|
315
482
|
};
|
|
316
483
|
}
|
|
317
484
|
});
|
|
@@ -3,6 +3,6 @@ import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_exp
|
|
|
3
3
|
import RsCodeEditor_vue_vue_type_script_setup_true_lang_default from "./RsCodeEditor.impl.js";
|
|
4
4
|
|
|
5
5
|
//#region src/components/code-editor/src/RsCodeEditor.vue
|
|
6
|
-
var RsCodeEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsCodeEditor_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
6
|
+
var RsCodeEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsCodeEditor_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-3ab77c7a"]]);
|
|
7
7
|
//#endregion
|
|
8
8
|
export { RsCodeEditor_default as default };
|
|
@@ -31,3 +31,18 @@ export declare function codeEditorLanguageLabel(language?: string): string;
|
|
|
31
31
|
export declare function readDocumentTheme(): RsResolvedCodeEditorTheme;
|
|
32
32
|
export declare function resolveCodeEditorTheme(theme?: RsCodeEditorTheme): RsResolvedCodeEditorTheme;
|
|
33
33
|
export declare function resolveCodeEditorSize(height?: number | string): string;
|
|
34
|
+
/** 修饰键文案。Mac 显示 ⌘,其它显示 Ctrl。无 navigator 时按 Ctrl。 */
|
|
35
|
+
export declare function codeEditorModShortcut(key: string): string;
|
|
36
|
+
type ThemeListener = () => void;
|
|
37
|
+
/**
|
|
38
|
+
* 多个编辑器共用一个 MutationObserver。最后一个退订时断开。
|
|
39
|
+
* 无 document / MutationObserver(SSR)时返回空操作。
|
|
40
|
+
*/
|
|
41
|
+
export declare function subscribeDocumentTheme(listener: ThemeListener): () => void;
|
|
42
|
+
export interface RsCodeEditorExpose {
|
|
43
|
+
/** 跳到 1-based 行列并聚焦。编辑器未就绪时无操作。 */
|
|
44
|
+
goToPosition: (line: number, column?: number) => void;
|
|
45
|
+
/** 聚焦编辑区。禁用或未就绪时无操作。 */
|
|
46
|
+
focus: () => void;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -60,5 +60,40 @@ function resolveCodeEditorSize(height) {
|
|
|
60
60
|
if (height === void 0) return "20rem";
|
|
61
61
|
return typeof height === "number" ? `${height}px` : height;
|
|
62
62
|
}
|
|
63
|
+
/** 修饰键文案。Mac 显示 ⌘,其它显示 Ctrl。无 navigator 时按 Ctrl。 */
|
|
64
|
+
function codeEditorModShortcut(key) {
|
|
65
|
+
if (typeof navigator === "undefined") return `Ctrl+${key}`;
|
|
66
|
+
const platform = `${navigator.platform || ""} ${navigator.userAgent || ""}`;
|
|
67
|
+
return /Mac|iPhone|iPad|iPod/i.test(platform) ? `⌘${key}` : `Ctrl+${key}`;
|
|
68
|
+
}
|
|
69
|
+
var themeListeners = /* @__PURE__ */ new Set();
|
|
70
|
+
var themeObserver = null;
|
|
71
|
+
/**
|
|
72
|
+
* 多个编辑器共用一个 MutationObserver。最后一个退订时断开。
|
|
73
|
+
* 无 document / MutationObserver(SSR)时返回空操作。
|
|
74
|
+
*/
|
|
75
|
+
function subscribeDocumentTheme(listener) {
|
|
76
|
+
if (typeof document === "undefined" || typeof MutationObserver === "undefined") return () => {};
|
|
77
|
+
themeListeners.add(listener);
|
|
78
|
+
if (!themeObserver) {
|
|
79
|
+
themeObserver = new MutationObserver(() => {
|
|
80
|
+
for (const fn of themeListeners) fn();
|
|
81
|
+
});
|
|
82
|
+
themeObserver.observe(document.documentElement, {
|
|
83
|
+
attributes: true,
|
|
84
|
+
attributeFilter: ["data-rs-theme"]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
let active = true;
|
|
88
|
+
return () => {
|
|
89
|
+
if (!active) return;
|
|
90
|
+
active = false;
|
|
91
|
+
themeListeners.delete(listener);
|
|
92
|
+
if (themeListeners.size === 0 && themeObserver) {
|
|
93
|
+
themeObserver.disconnect();
|
|
94
|
+
themeObserver = null;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
63
98
|
//#endregion
|
|
64
|
-
export { codeEditorLanguageLabel, readDocumentTheme, resolveCodeEditorLanguage, resolveCodeEditorSize, resolveCodeEditorTheme };
|
|
99
|
+
export { codeEditorLanguageLabel, codeEditorModShortcut, readDocumentTheme, resolveCodeEditorLanguage, resolveCodeEditorSize, resolveCodeEditorTheme, subscribeDocumentTheme };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Extension } from '@codemirror/state';
|
|
2
2
|
export interface CodeMirrorCompletionHandlers {
|
|
3
|
-
completionRequest?: (prefix: string, suffix: string, line: number, column: number) => Promise<string | null>;
|
|
3
|
+
completionRequest?: (prefix: string, suffix: string, line: number, column: number, signal?: AbortSignal) => Promise<string | null>;
|
|
4
4
|
}
|
|
5
5
|
export declare function codeMirrorCompletionExtensions(handlers: () => CodeMirrorCompletionHandlers): Extension[];
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
+
import { editorAbortSession, isEditorViewAlive } from "./code-mirror-session.js";
|
|
1
2
|
import { posToLineColumn } from "./code-mirror-intel.js";
|
|
2
3
|
import { clearGhostCompletion, setGhostCompletion } from "./code-mirror-ghost.js";
|
|
3
4
|
import { keymap } from "@codemirror/view";
|
|
4
5
|
//#region src/components/code-editor/src/code-mirror-completion.ts
|
|
5
6
|
function codeMirrorCompletionExtensions(handlers) {
|
|
6
|
-
|
|
7
|
+
const session = editorAbortSession();
|
|
8
|
+
return [session, keymap.of([{
|
|
7
9
|
key: "Ctrl-Space",
|
|
8
10
|
mac: "Cmd-Space",
|
|
9
11
|
run: (view) => {
|
|
10
12
|
const h = handlers();
|
|
11
|
-
if (!h.completionRequest) return false;
|
|
13
|
+
if (!h.completionRequest || !isEditorViewAlive(view)) return false;
|
|
12
14
|
clearGhostCompletion(view);
|
|
13
15
|
const pos = view.state.selection.main.head;
|
|
14
16
|
const prefix = view.state.doc.sliceString(0, pos);
|
|
15
17
|
const suffix = view.state.doc.sliceString(pos);
|
|
16
18
|
const { line, column } = posToLineColumn(view, pos);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
const signal = view.plugin(session)?.nextSignal();
|
|
20
|
+
Promise.resolve(h.completionRequest(prefix, suffix, line, column, signal)).then((text) => {
|
|
21
|
+
if (signal?.aborted || !text?.trim() || !isEditorViewAlive(view)) return;
|
|
19
22
|
const latestPos = view.state.selection.main.head;
|
|
20
23
|
if (view.state.doc.sliceString(latestPos) !== suffix) return;
|
|
21
24
|
view.dispatch({
|
|
@@ -28,7 +31,7 @@ function codeMirrorCompletionExtensions(handlers) {
|
|
|
28
31
|
effects: setGhostCompletion.of(null)
|
|
29
32
|
});
|
|
30
33
|
view.focus();
|
|
31
|
-
});
|
|
34
|
+
}).catch(() => {});
|
|
32
35
|
return true;
|
|
33
36
|
}
|
|
34
37
|
}])];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StateField } from '@codemirror/state';
|
|
2
2
|
import { EditorView } from '@codemirror/view';
|
|
3
3
|
import type { RsCodeEditorDiagnostic } from './code-editor-utils';
|
|
4
|
-
export declare
|
|
5
|
-
export declare function diagnosticExtensions(): import("@codemirror/state").Extension;
|
|
4
|
+
export declare function diagnosticExtensions(): StateField<import("@codemirror/view").DecorationSet>[];
|
|
6
5
|
export declare function setEditorDiagnostics(view: EditorView, diags: RsCodeEditorDiagnostic[]): void;
|