niuma-ui 1.2.8 → 1.2.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 CHANGED
@@ -6,6 +6,12 @@
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.2.9] - 2026-09-01
10
+
11
+ ### 修复
12
+
13
+ - `RsCodeEditor` 切换主题只换配色,不再拆掉重建,正文不会空白
14
+
9
15
  ## [1.2.8] - 2026-09-01
10
16
 
11
17
  ### 新增
@@ -1,5 +1,5 @@
1
1
 
2
- .rs-code-editor[data-v-29cd1019] {
2
+ .rs-code-editor[data-v-edadd50f] {
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  overflow: hidden;
@@ -8,10 +8,10 @@
8
8
  background: var(--rs-input-bg);
9
9
  color: var(--rs-text);
10
10
  }
11
- .rs-code-editor--square[data-v-29cd1019] {
11
+ .rs-code-editor--square[data-v-edadd50f] {
12
12
  border-radius: 0;
13
13
  }
14
- .rs-code-editor--embedded[data-v-29cd1019] {
14
+ .rs-code-editor--embedded[data-v-edadd50f] {
15
15
  border: 0;
16
16
  border-radius: 0;
17
17
  background: transparent;
@@ -19,7 +19,7 @@
19
19
  min-height: 0;
20
20
  width: 100%;
21
21
  }
22
- .rs-code-editor__toolbar[data-v-29cd1019] {
22
+ .rs-code-editor__toolbar[data-v-edadd50f] {
23
23
  display: flex;
24
24
  align-items: center;
25
25
  justify-content: space-between;
@@ -28,23 +28,23 @@
28
28
  color: var(--rs-muted);
29
29
  font-size: var(--rs-font-size-xs);
30
30
  }
31
- .rs-code-editor__body[data-v-29cd1019] {
31
+ .rs-code-editor__body[data-v-edadd50f] {
32
32
  position: relative;
33
33
  flex: 1;
34
34
  min-height: 0;
35
35
  display: flex;
36
36
  flex-direction: column;
37
37
  }
38
- .rs-code-editor__surface[data-v-29cd1019] {
38
+ .rs-code-editor__surface[data-v-edadd50f] {
39
39
  flex: 1;
40
40
  min-height: 0;
41
41
  overflow: hidden;
42
42
  }
43
- .rs-code-editor--embedded .rs-code-editor__body[data-v-29cd1019],
44
- .rs-code-editor--embedded .rs-code-editor__surface[data-v-29cd1019] {
43
+ .rs-code-editor--embedded .rs-code-editor__body[data-v-edadd50f],
44
+ .rs-code-editor--embedded .rs-code-editor__surface[data-v-edadd50f] {
45
45
  height: 100%;
46
46
  }
47
- .rs-code-editor__inline-edit[data-v-29cd1019] {
47
+ .rs-code-editor__inline-edit[data-v-edadd50f] {
48
48
  position: absolute;
49
49
  left: 50%;
50
50
  top: 12%;
@@ -57,7 +57,7 @@
57
57
  background: var(--rs-surface-elevated);
58
58
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
59
59
  }
60
- .rs-code-editor__inline-edit-head[data-v-29cd1019] {
60
+ .rs-code-editor__inline-edit-head[data-v-edadd50f] {
61
61
  display: flex;
62
62
  align-items: center;
63
63
  justify-content: space-between;
@@ -66,14 +66,14 @@
66
66
  font-weight: var(--rs-font-weight-semibold);
67
67
  color: var(--rs-foreground);
68
68
  }
69
- .rs-code-editor__inline-edit-head kbd[data-v-29cd1019] {
69
+ .rs-code-editor__inline-edit-head kbd[data-v-edadd50f] {
70
70
  padding: 0.1rem 0.35rem;
71
71
  border-radius: 4px;
72
72
  border: 1px solid var(--rs-border-subtle);
73
73
  font-size: var(--rs-font-size-xs);
74
74
  color: var(--rs-muted);
75
75
  }
76
- .rs-code-editor__inline-preview[data-v-29cd1019] {
76
+ .rs-code-editor__inline-preview[data-v-edadd50f] {
77
77
  margin: 0 0 0.5rem;
78
78
  padding: 0.35rem 0.5rem;
79
79
  border-radius: 4px;
@@ -86,7 +86,7 @@
86
86
  max-height: 4.5rem;
87
87
  overflow: hidden;
88
88
  }
89
- .rs-code-editor__inline-input[data-v-29cd1019] {
89
+ .rs-code-editor__inline-input[data-v-edadd50f] {
90
90
  width: 100%;
91
91
  box-sizing: border-box;
92
92
  margin-bottom: 0.5rem;
@@ -97,21 +97,21 @@
97
97
  color: var(--rs-foreground);
98
98
  font-size: var(--rs-font-size-sm);
99
99
  }
100
- .rs-code-editor__inline-input[data-v-29cd1019]:focus {
100
+ .rs-code-editor__inline-input[data-v-edadd50f]:focus {
101
101
  outline: 2px solid color-mix(in srgb, var(--rs-primary) 35%, transparent);
102
102
  outline-offset: 1px;
103
103
  }
104
- .rs-code-editor__inline-error[data-v-29cd1019] {
104
+ .rs-code-editor__inline-error[data-v-edadd50f] {
105
105
  margin: -0.25rem 0 0.5rem;
106
106
  font-size: var(--rs-font-size-xs);
107
107
  color: var(--rs-danger);
108
108
  }
109
- .rs-code-editor__inline-actions[data-v-29cd1019] {
109
+ .rs-code-editor__inline-actions[data-v-edadd50f] {
110
110
  display: flex;
111
111
  justify-content: flex-end;
112
112
  gap: 0.35rem;
113
113
  }
114
- .rs-code-editor__inline-btn[data-v-29cd1019] {
114
+ .rs-code-editor__inline-btn[data-v-edadd50f] {
115
115
  padding: 0.3rem 0.65rem;
116
116
  border: 1px solid var(--rs-border);
117
117
  border-radius: var(--rs-radius-sm, 4px);
@@ -120,69 +120,69 @@
120
120
  font-size: var(--rs-font-size-xs);
121
121
  cursor: pointer;
122
122
  }
123
- .rs-code-editor__inline-btn--primary[data-v-29cd1019] {
123
+ .rs-code-editor__inline-btn--primary[data-v-edadd50f] {
124
124
  border-color: var(--rs-primary);
125
125
  background: var(--rs-primary);
126
126
  color: var(--rs-primary-foreground, #fff);
127
127
  }
128
- .rs-code-editor__inline-btn[data-v-29cd1019]:disabled {
128
+ .rs-code-editor__inline-btn[data-v-edadd50f]:disabled {
129
129
  opacity: 0.55;
130
130
  cursor: not-allowed;
131
131
  }
132
- .rs-code-editor__surface--disabled[data-v-29cd1019] {
132
+ .rs-code-editor__surface--disabled[data-v-edadd50f] {
133
133
  opacity: 0.6;
134
134
  pointer-events: none;
135
135
  }
136
- .rs-code-editor__surface[data-v-29cd1019] .cm-editor {
136
+ .rs-code-editor__surface[data-v-edadd50f] .cm-editor {
137
137
  height: 100%;
138
138
  background: var(--rs-surface-elevated) !important;
139
139
  }
140
- .rs-code-editor__surface[data-v-29cd1019] .cm-scroller {
140
+ .rs-code-editor__surface[data-v-edadd50f] .cm-scroller {
141
141
  font-family: var(--rs-code-font-family, var(--rs-font-mono));
142
142
  font-size: var(--rs-code-font-size, var(--rs-font-size-sm));
143
143
  line-height: var(--rs-code-line-height, var(--rs-line-height-relaxed));
144
144
  }
145
- .rs-code-editor__surface[data-v-29cd1019] .cm-gutters {
145
+ .rs-code-editor__surface[data-v-edadd50f] .cm-gutters {
146
146
  background: color-mix(in srgb, var(--rs-surface-elevated) 85%, var(--rs-border) 15%) !important;
147
147
  border-right-color: var(--rs-border-subtle) !important;
148
148
  color: var(--rs-muted);
149
149
  }
150
- .rs-code-editor--embedded .rs-code-editor__surface[data-v-29cd1019] .cm-editor {
150
+ .rs-code-editor--embedded .rs-code-editor__surface[data-v-edadd50f] .cm-editor {
151
151
  height: 100%;
152
152
  background: transparent !important;
153
153
  }
154
- .rs-code-editor--no-fold .rs-code-editor__surface[data-v-29cd1019] .cm-foldGutter {
154
+ .rs-code-editor--no-fold .rs-code-editor__surface[data-v-edadd50f] .cm-foldGutter {
155
155
  display: none !important;
156
156
  width: 0 !important;
157
157
  min-width: 0 !important;
158
158
  }
159
- .rs-code-editor--gutter-fixed .rs-code-editor__surface[data-v-29cd1019] .cm-gutters {
159
+ .rs-code-editor--gutter-fixed .rs-code-editor__surface[data-v-edadd50f] .cm-gutters {
160
160
  min-width: var(--rs-code-editor-gutter-width);
161
161
  }
162
- .rs-code-editor--gutter-fixed.rs-code-editor--no-fold .rs-code-editor__surface[data-v-29cd1019] .cm-lineNumbers {
162
+ .rs-code-editor--gutter-fixed.rs-code-editor--no-fold .rs-code-editor__surface[data-v-edadd50f] .cm-lineNumbers {
163
163
  min-width: var(--rs-code-editor-gutter-width);
164
164
  }
165
- .rs-code-editor--gutter-fixed.rs-code-editor--no-fold .rs-code-editor__surface[data-v-29cd1019] .cm-lineNumbers .cm-gutterElement {
165
+ .rs-code-editor--gutter-fixed.rs-code-editor--no-fold .rs-code-editor__surface[data-v-edadd50f] .cm-lineNumbers .cm-gutterElement {
166
166
  min-width: calc(var(--rs-code-editor-gutter-width) - 8px);
167
167
  }
168
- .rs-code-editor__surface[data-v-29cd1019] .cm-content {
168
+ .rs-code-editor__surface[data-v-edadd50f] .cm-content {
169
169
  color: var(--rs-foreground);
170
170
  }
171
- .rs-code-editor__surface[data-v-29cd1019] .cm-lintRange-error {
171
+ .rs-code-editor__surface[data-v-edadd50f] .cm-lintRange-error {
172
172
  background: color-mix(in srgb, var(--rs-danger) 12%, transparent);
173
173
  }
174
- .rs-code-editor__surface[data-v-29cd1019] .cm-lintRange-warning {
174
+ .rs-code-editor__surface[data-v-edadd50f] .cm-lintRange-warning {
175
175
  background: color-mix(in srgb, var(--rs-warning) 12%, transparent);
176
176
  }
177
- .rs-code-editor__surface[data-v-29cd1019] .cm-lintRange-info {
177
+ .rs-code-editor__surface[data-v-edadd50f] .cm-lintRange-info {
178
178
  background: color-mix(in srgb, var(--rs-info) 10%, transparent);
179
179
  }
180
- .rs-code-editor__surface[data-v-29cd1019] .rs-code-editor__ghost {
180
+ .rs-code-editor__surface[data-v-edadd50f] .rs-code-editor__ghost {
181
181
  color: var(--rs-muted);
182
182
  opacity: 0.55;
183
183
  pointer-events: none;
184
184
  }
185
- .rs-code-editor__surface[data-v-29cd1019] .rs-code-editor__hover {
185
+ .rs-code-editor__surface[data-v-edadd50f] .rs-code-editor__hover {
186
186
  max-width: 28rem;
187
187
  padding: 0.45rem 0.65rem;
188
188
  border-radius: var(--rs-radius-sm, 4px);
@@ -195,7 +195,7 @@
195
195
  white-space: pre-wrap;
196
196
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
197
197
  }
198
- .rs-code-editor__diagnostics[data-v-29cd1019] {
198
+ .rs-code-editor__diagnostics[data-v-edadd50f] {
199
199
  margin: 0;
200
200
  padding: var(--rs-space-sm) var(--rs-space-md);
201
201
  border-top: 1px solid var(--rs-border-subtle);
@@ -203,12 +203,12 @@
203
203
  font-size: var(--rs-font-size-xs);
204
204
  list-style: none;
205
205
  }
206
- .rs-code-editor__diagnostic--error[data-v-29cd1019] {
206
+ .rs-code-editor__diagnostic--error[data-v-edadd50f] {
207
207
  color: var(--rs-danger);
208
208
  }
209
- .rs-code-editor__diagnostic--warning[data-v-29cd1019] {
209
+ .rs-code-editor__diagnostic--warning[data-v-edadd50f] {
210
210
  color: var(--rs-warning);
211
211
  }
212
- .rs-code-editor__diagnostic--info[data-v-29cd1019] {
212
+ .rs-code-editor__diagnostic--info[data-v-edadd50f] {
213
213
  color: var(--rs-info);
214
214
  }
@@ -1,4 +1,4 @@
1
- import { codeEditorLanguageLabel, resolveCodeEditorLanguage, resolveCodeEditorSize, resolveCodeEditorTheme } from "./code-editor-utils.js";
1
+ import { codeEditorLanguageLabel, readDocumentTheme, resolveCodeEditorLanguage, resolveCodeEditorSize, resolveCodeEditorTheme } from "./code-editor-utils.js";
2
2
  import { isCodeMirrorLightTheme, resolveCodeMirrorLanguage } from "./code-mirror-lang.js";
3
3
  import { diagnosticExtensions, setEditorDiagnostics } from "./code-mirror-diagnostics.js";
4
4
  import { codeMirrorIntelExtensions, goToPosition } from "./code-mirror-intel.js";
@@ -89,10 +89,12 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
89
89
  });
90
90
  const resolvedLanguage = computed(() => resolveCodeEditorLanguage(props.language));
91
91
  const resolvedLanguageLabel = computed(() => codeEditorLanguageLabel(props.language));
92
- const resolvedTheme = computed(() => resolveCodeEditorTheme(props.theme));
92
+ const documentTheme = ref(readDocumentTheme());
93
+ const resolvedTheme = computed(() => props.theme === "auto" ? documentTheme.value : resolveCodeEditorTheme(props.theme));
93
94
  const editorEl = ref(null);
94
95
  const view = shallowRef(null);
95
96
  const editableCompartment = new Compartment();
97
+ const themeCompartment = new Compartment();
96
98
  let themeObserver = null;
97
99
  let unmounted = false;
98
100
  let syncingFromModel = false;
@@ -157,6 +159,15 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
157
159
  ghostTimer = null;
158
160
  }
159
161
  }
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
+ }
160
171
  async function initEditor() {
161
172
  if (!editorEl.value || unmounted) return;
162
173
  const seq = ++initSeq;
@@ -185,7 +196,7 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
185
196
  ...codeMirrorCompletionExtensions(() => ({ completionRequest: props.completionRequest })),
186
197
  ...codeMirrorGhostExtensions(() => ({ completionRequest: props.completionRequest }), scheduleGhostCompletion, cancelGhostCompletionSchedule),
187
198
  ...props.inlineEditRequest ? [codeMirrorInlineEditExtension(onInlineEditTrigger)] : [],
188
- ...isCodeMirrorLightTheme() ? [] : [oneDark],
199
+ themeCompartment.of(codeMirrorThemeExts()),
189
200
  EditorView.updateListener.of((update) => {
190
201
  if (!update.docChanged || syncingFromModel) return;
191
202
  const next = update.state.doc.toString();
@@ -204,7 +215,7 @@ var RsCodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
204
215
  unmounted = false;
205
216
  initEditor();
206
217
  themeObserver = new MutationObserver(() => {
207
- initEditor();
218
+ applyDocumentTheme();
208
219
  });
209
220
  themeObserver.observe(document.documentElement, {
210
221
  attributes: true,
@@ -3,6 +3,6 @@ import _plugin_vue_export_helper_default from "../_virtual/_plugin-vue_export-he
3
3
  import RsCodeEditor_vue_vue_type_script_setup_true_lang_default from "./RsCodeEditor.impl.js";
4
4
 
5
5
  //#region src/components/RsCodeEditor.vue
6
- var RsCodeEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsCodeEditor_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-29cd1019"]]);
6
+ var RsCodeEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsCodeEditor_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-edadd50f"]]);
7
7
  //#endregion
8
8
  export { RsCodeEditor_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "niuma-ui",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "Vue 3 工作台设计系统(Rs* 组件、--rs-* token;含可选编辑器 / 终端)",