File tree 3 files changed +23
-0
lines changed
applet/src/modules/components
3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,13 @@ function scrollToComponent() {
234
234
rpc .value .scrollToComponent (activeComponentId .value )
235
235
}
236
236
237
+ function inspectDOM() {
238
+ rpc .value .inspectDOM (activeComponentId .value ).then (() => {
239
+ // @ts-expect-error skip type check
240
+ chrome .devtools .inspectedWindow .eval (' inspect(window.__VUE_DEVTOOLS_INSPECT_DOM_TARGET__)' )
241
+ })
242
+ }
243
+
237
244
function getComponentRenderCode() {
238
245
rpc .value .getComponentRenderCode (activeComponentId .value ).then ((data ) => {
239
246
componentRenderCode .value = data !
@@ -297,6 +304,7 @@ function closeComponentRenderCode() {
297
304
<div class =" flex items-center gap-2 px-1" >
298
305
<i v-tooltip.bottom =" 'Scroll to component'" class =" i-material-symbols-light:eye-tracking-outline h-4 w-4 cursor-pointer hover:(op-70)" @click =" scrollToComponent" />
299
306
<i v-tooltip.bottom =" 'Show render code'" class =" i-material-symbols-light:code h-5 w-5 cursor-pointer hover:(op-70)" @click =" getComponentRenderCode" />
307
+ <i v-if =" isInChromePanel" v-tooltip.bottom =" 'Inspect DOM'" class =" i-material-symbols-light:menu-open h-5 w-5 cursor-pointer hover:(op-70)" @click =" inspectDOM" />
300
308
<i v-if =" activeTreeNodeFilePath && !isInChromePanel" v-tooltip.bottom =" 'Open in Editor'" class =" i-carbon-launch h-4 w-4 cursor-pointer hover:(op-70)" @click =" openInEditor" />
301
309
</div >
302
310
</div >
Original file line number Diff line number Diff line change @@ -84,6 +84,9 @@ export const functions = {
84
84
scrollToComponent ( id : string ) {
85
85
return devtools . ctx . api . scrollToComponent ( id )
86
86
} ,
87
+ inspectDOM ( id : string ) {
88
+ return devtools . ctx . api . inspectDOM ( id )
89
+ } ,
87
90
getInspectorNodeActions ( id : string ) {
88
91
return getInspectorNodeActions ( id )
89
92
} ,
Original file line number Diff line number Diff line change 1
1
import type { HookKeys , Hookable } from 'hookable'
2
+ import { target } from '@vue/devtools-shared'
2
3
import type { CustomInspectorState } from '../types'
3
4
import { StateEditor } from '../core/component/state/editor'
4
5
import { cancelInspectComponentHighLighter , inspectComponentHighLighter , scrollToComponent } from '../core/component-highlighter'
5
6
import { getComponentInstance } from '../core/component/utils'
7
+ import { getRootElementsFromComponentInstance } from '../core/component/tree/el'
6
8
import { openInEditor } from '../core/open-in-editor'
7
9
import { normalizeRouterInfo } from '../core/router'
8
10
import { getComponentInspector } from '../core/component-inspector'
@@ -108,6 +110,16 @@ export function createDevToolsApi(hooks: Hookable<DevToolsContextHooks & DevTool
108
110
callInspectorUpdatedHook ( )
109
111
}
110
112
} ,
113
+ // inspect dom
114
+ inspectDOM ( instanceId : string ) {
115
+ const instance = getComponentInstance ( activeAppRecord . value , instanceId )
116
+ if ( instance ) {
117
+ const [ el ] = getRootElementsFromComponentInstance ( instance )
118
+ if ( el ) {
119
+ target . __VUE_DEVTOOLS_INSPECT_DOM_TARGET__ = el
120
+ }
121
+ }
122
+ } ,
111
123
}
112
124
}
113
125
You can’t perform that action at this time.
0 commit comments