Skip to content

Commit f2659a9

Browse files
Copilotdanmarshall
andcommitted
Add raw option to inspector for copy/paste use case
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
1 parent 855d484 commit f2659a9

4 files changed

Lines changed: 30 additions & 1 deletion

File tree

docs/schema/idoc_v1.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ interface InspectorElement extends InspectorElementProps {
215215
type: 'inspector';
216216
}
217217
interface 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

packages/markdown/src/plugins/inspector.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface InspectorInstance {
1616
}
1717

1818
export interface InspectorSpec extends VariableControl {
19+
raw?: boolean;
1920
}
2021

2122
const 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') {

packages/schema-doc/src/interactive.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ export interface InspectorElement extends InspectorElementProps {
145145
type: 'inspector';
146146
}
147147
export 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
/**

packages/web-deploy/json/features/12.inspector.idoc.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,21 @@
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",

0 commit comments

Comments
 (0)