File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -215,6 +215,8 @@ interface InspectorElement extends InspectorElementProps {
215215 type : 'inspector' ;
216216}
217217interface InspectorElementProps extends VariableControl {
218+ /** When true, displays raw JSON output without interactive elements (for copy/paste). Default is false. */
219+ raw ?: boolean ;
218220}
219221/**
220222 * Treebark
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ interface InspectorInstance {
1616}
1717
1818export interface InspectorSpec extends VariableControl {
19+ raw ?: boolean ;
1920}
2021
2122const pluginName : PluginNames = 'inspector' ;
@@ -58,6 +59,22 @@ export const inspectorPlugin: Plugin<InspectorSpec> = {
5859 const updateDisplay = ( value : unknown ) => {
5960 element . innerHTML = '' ; // Clear previous content
6061
62+ // If raw mode is enabled, always use JSON.stringify without interactivity
63+ if ( spec . raw ) {
64+ if ( value === null || value === undefined ) {
65+ element . textContent = String ( value ) ;
66+ } else if ( typeof value === 'string' ) {
67+ element . textContent = `"${ value } "` ;
68+ } else if ( typeof value === 'object' ) {
69+ // For arrays and objects, use JSON.stringify with indentation
70+ element . textContent = JSON . stringify ( value , null , 2 ) ;
71+ } else {
72+ element . textContent = String ( value ) ;
73+ }
74+ return ;
75+ }
76+
77+ // Interactive mode (default)
6178 if ( value === null || value === undefined ) {
6279 element . textContent = String ( value ) ;
6380 } else if ( typeof value === 'string' ) {
Original file line number Diff line number Diff line change @@ -145,6 +145,8 @@ export interface InspectorElement extends InspectorElementProps {
145145 type : 'inspector' ;
146146}
147147export interface InspectorElementProps extends VariableControl {
148+ /** When true, displays raw JSON output without interactive elements (for copy/paste). Default is false. */
149+ raw ?: boolean ;
148150}
149151
150152/**
Original file line number Diff line number Diff line change 119119 "size" : 5
120120 },
121121 " " ,
122- " **Inspector output:**" ,
122+ " **Inspector output (interactive) :**" ,
123123 {
124124 "type" : " inspector" ,
125125 "variableId" : " selectedItems" ,
126126 "label" : " selectedItems"
127127 },
128128 " " ,
129+ " **Inspector output (raw mode for copy/paste):**" ,
130+ {
131+ "type" : " inspector" ,
132+ "variableId" : " selectedItems" ,
133+ "label" : " selectedItems (raw)" ,
134+ "raw" : true
135+ },
136+ " " ,
129137 " ---" ,
130138 " " ,
131139 " ## Object Variable" ,
You can’t perform that action at this time.
0 commit comments