Skip to content

Commit f57ef6a

Browse files
authored
fix: output css error when preflight selection (#4483)
1 parent f84abd7 commit f57ef6a

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

packages-integrations/inspector/client/composables/codemirror.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,20 @@ export function useCodeMirror(
116116
(v) => {
117117
if (v !== cm.state.doc.toString()) {
118118
skip = true
119+
119120
const selections = cm.state.selection.ranges
121+
const newContent = v
122+
const newLength = newContent.length
123+
124+
const validSelections = selections.map((range) => {
125+
const from = Math.min(range.from, newLength)
126+
const to = Math.min(range.to, newLength)
127+
return EditorSelection.range(from, to)
128+
})
129+
120130
cm.dispatch({
121-
changes: { from: 0, to: cm.state.doc.length, insert: v },
122-
selection: EditorSelection.create(selections),
131+
changes: { from: 0, to: cm.state.doc.length, insert: newContent },
132+
selection: EditorSelection.create(validSelections),
123133
})
124134
}
125135
},

playground/src/auto-imports.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ declare global {
8787
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
8888
const onClickOutside: typeof import('@vueuse/core')['onClickOutside']
8989
const onDeactivated: typeof import('vue')['onDeactivated']
90+
const onElementRemoval: typeof import('@vueuse/core')['onElementRemoval']
9091
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
9192
const onKeyStroke: typeof import('@vueuse/core')['onKeyStroke']
9293
const onLongPress: typeof import('@vueuse/core')['onLongPress']
@@ -186,6 +187,7 @@ declare global {
186187
const useCloned: typeof import('@vueuse/core')['useCloned']
187188
const useColorMode: typeof import('@vueuse/core')['useColorMode']
188189
const useConfirmDialog: typeof import('@vueuse/core')['useConfirmDialog']
190+
const useCountdown: typeof import('@vueuse/core')['useCountdown']
189191
const useCounter: typeof import('@vueuse/core')['useCounter']
190192
const useCssModule: typeof import('vue')['useCssModule']
191193
const useCssVar: typeof import('@vueuse/core')['useCssVar']
@@ -442,6 +444,7 @@ declare module 'vue' {
442444
readonly onBeforeUpdate: UnwrapRef<typeof import('vue')['onBeforeUpdate']>
443445
readonly onClickOutside: UnwrapRef<typeof import('@vueuse/core')['onClickOutside']>
444446
readonly onDeactivated: UnwrapRef<typeof import('vue')['onDeactivated']>
447+
readonly onElementRemoval: UnwrapRef<typeof import('@vueuse/core')['onElementRemoval']>
445448
readonly onErrorCaptured: UnwrapRef<typeof import('vue')['onErrorCaptured']>
446449
readonly onKeyStroke: UnwrapRef<typeof import('@vueuse/core')['onKeyStroke']>
447450
readonly onLongPress: UnwrapRef<typeof import('@vueuse/core')['onLongPress']>
@@ -540,6 +543,7 @@ declare module 'vue' {
540543
readonly useCloned: UnwrapRef<typeof import('@vueuse/core')['useCloned']>
541544
readonly useColorMode: UnwrapRef<typeof import('@vueuse/core')['useColorMode']>
542545
readonly useConfirmDialog: UnwrapRef<typeof import('@vueuse/core')['useConfirmDialog']>
546+
readonly useCountdown: UnwrapRef<typeof import('@vueuse/core')['useCountdown']>
543547
readonly useCounter: UnwrapRef<typeof import('@vueuse/core')['useCounter']>
544548
readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']>
545549
readonly useCssVar: UnwrapRef<typeof import('@vueuse/core')['useCssVar']>

playground/src/components.d.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,32 @@ export {}
77
/* prettier-ignore */
88
declare module 'vue' {
99
export interface GlobalComponents {
10-
Analyzer: typeof import('./../../packages-engine/inspector/client/components/Analyzer.vue')['default']
11-
AnalyzerItem: typeof import('./../../packages-engine/inspector/client/components/AnalyzerItem.vue')['default']
12-
CodeMirror: typeof import('./../../packages-engine/inspector/client/components/CodeMirror.vue')['default']
13-
Copy: typeof import('./../../packages-engine/inspector/client/components/Copy.vue')['default']
10+
Analyzer: typeof import('./../../packages-integrations/inspector/client/components/Analyzer.vue')['default']
11+
AnalyzerItem: typeof import('./../../packages-integrations/inspector/client/components/AnalyzerItem.vue')['default']
12+
CodeMirror: typeof import('./../../packages-integrations/inspector/client/components/CodeMirror.vue')['default']
13+
Copy: typeof import('./../../packages-integrations/inspector/client/components/Copy.vue')['default']
1414
Editor: typeof import('./components/Editor.vue')['default']
15-
FileIcon: typeof import('./../../packages-engine/inspector/client/components/FileIcon.vue')['default']
15+
FileIcon: typeof import('./../../packages-integrations/inspector/client/components/FileIcon.vue')['default']
1616
HeaderBar: typeof import('./components/HeaderBar.vue')['default']
17-
ModuleId: typeof import('./../../packages-engine/inspector/client/components/ModuleId.vue')['default']
18-
ModuleInfo: typeof import('./../../packages-engine/inspector/client/components/ModuleInfo.vue')['default']
19-
ModuleTreeNode: typeof import('./../../packages-engine/inspector/client/components/ModuleTreeNode.vue')['default']
20-
NarBar: typeof import('./../../packages-engine/inspector/client/components/NarBar.vue')['default']
21-
Overview: typeof import('./../../packages-engine/inspector/client/components/Overview.vue')['default']
22-
OverviewTabs: typeof import('./../../packages-engine/inspector/client/components/OverviewTabs.vue')['default']
17+
ModuleId: typeof import('./../../packages-integrations/inspector/client/components/ModuleId.vue')['default']
18+
ModuleInfo: typeof import('./../../packages-integrations/inspector/client/components/ModuleInfo.vue')['default']
19+
ModuleTreeNode: typeof import('./../../packages-integrations/inspector/client/components/ModuleTreeNode.vue')['default']
20+
NarBar: typeof import('./../../packages-integrations/inspector/client/components/NarBar.vue')['default']
21+
Overview: typeof import('./../../packages-integrations/inspector/client/components/Overview.vue')['default']
22+
OverviewTabs: typeof import('./../../packages-integrations/inspector/client/components/OverviewTabs.vue')['default']
2323
PanelConfig: typeof import('./components/panel/PanelConfig.vue')['default']
2424
PanelCustomCss: typeof import('./components/panel/PanelCustomCss.vue')['default']
2525
PanelHtml: typeof import('./components/panel/PanelHtml.vue')['default']
2626
PanelOutputCss: typeof import('./components/panel/PanelOutputCss.vue')['default']
2727
Playground: typeof import('./components/Playground.vue')['default']
2828
Preview: typeof import('./components/Preview.vue')['default']
29-
ReplPlayground: typeof import('./../../packages-engine/inspector/client/components/ReplPlayground.vue')['default']
29+
ReplPlayground: typeof import('./../../packages-integrations/inspector/client/components/ReplPlayground.vue')['default']
3030
RouterLink: typeof import('vue-router')['RouterLink']
3131
RouterView: typeof import('vue-router')['RouterView']
3232
SelectVersion: typeof import('./components/SelectVersion.vue')['default']
33-
Sidebar: typeof import('./../../packages-engine/inspector/client/components/Sidebar.vue')['default']
34-
StatusBar: typeof import('./../../packages-engine/inspector/client/components/StatusBar.vue')['default']
35-
Tabs: typeof import('./../../packages-engine/inspector/client/components/Tabs.vue')['default']
36-
TitleBar: typeof import('./../../packages-engine/inspector/client/components/TitleBar.vue')['default']
33+
Sidebar: typeof import('./../../packages-integrations/inspector/client/components/Sidebar.vue')['default']
34+
StatusBar: typeof import('./../../packages-integrations/inspector/client/components/StatusBar.vue')['default']
35+
Tabs: typeof import('./../../packages-integrations/inspector/client/components/Tabs.vue')['default']
36+
TitleBar: typeof import('./../../packages-integrations/inspector/client/components/TitleBar.vue')['default']
3737
}
3838
}

0 commit comments

Comments
 (0)