vscode: configuration for show*
This commit is contained in:
parent
24f4143cda
commit
a2a6ff8ad0
|
@ -1,19 +1,17 @@
|
||||||
// based on https://github.com/microsoft/vscode-extension-samples/blob/main/custom-editor-sample/media/catScratch.js
|
|
||||||
(function () {
|
(function () {
|
||||||
console.log("hello world");
|
|
||||||
const vscode = acquireVsCodeApi();
|
const vscode = acquireVsCodeApi();
|
||||||
|
|
||||||
const container = document.getElementById("root");
|
const container = document.getElementById("root");
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(container);
|
const root = ReactDOM.createRoot(container);
|
||||||
function updateContent(text) {
|
function updateContent(text, showSettings) {
|
||||||
root.render(
|
root.render(
|
||||||
React.createElement(squiggle_components.SquigglePlayground, {
|
React.createElement(squiggle_components.SquigglePlayground, {
|
||||||
code: text,
|
code: text,
|
||||||
onCodeChange: (code) => {
|
|
||||||
vscode.postMessage({ type: "edit", text: code });
|
|
||||||
},
|
|
||||||
showEditor: false,
|
showEditor: false,
|
||||||
|
showTypes: Boolean(showSettings.showTypes),
|
||||||
|
showControls: Boolean(showSettings.showControls),
|
||||||
|
showSummary: Boolean(showSettings.showSummary),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -23,14 +21,14 @@
|
||||||
const message = event.data; // The json data that the extension sent
|
const message = event.data; // The json data that the extension sent
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case "update":
|
case "update":
|
||||||
const text = message.text;
|
const { text, showSettings } = message;
|
||||||
|
|
||||||
// Update our webview's content
|
// Update our webview's content
|
||||||
updateContent(text);
|
updateContent(text, showSettings);
|
||||||
|
|
||||||
// Then persist state information.
|
// Then persist state information.
|
||||||
// This state is returned in the call to `vscode.getState` below when a webview is reloaded.
|
// This state is returned in the call to `vscode.getState` below when a webview is reloaded.
|
||||||
vscode.setState({ text });
|
vscode.setState({ text, showSettings });
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -38,6 +36,6 @@
|
||||||
|
|
||||||
const state = vscode.getState();
|
const state = vscode.getState();
|
||||||
if (state) {
|
if (state) {
|
||||||
updateContent(state.text);
|
updateContent(state.text, state.showSettings);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -77,7 +77,27 @@
|
||||||
"mac": "cmd+k v",
|
"mac": "cmd+k v",
|
||||||
"when": "editorLangId == squiggle"
|
"when": "editorLangId == squiggle"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"configuration": {
|
||||||
|
"title": "Squiggle",
|
||||||
|
"properties": {
|
||||||
|
"squiggle.playground.showTypes": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Whether to show the types of outputs in the playground"
|
||||||
|
},
|
||||||
|
"squiggle.playground.showControls": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Whether to show the log scale controls in the playground"
|
||||||
|
},
|
||||||
|
"squiggle.playground.showSummary": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Whether to show the summary table in the playground"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"vscode:prepublish": "yarn run compile",
|
"vscode:prepublish": "yarn run compile",
|
||||||
|
|
|
@ -30,6 +30,8 @@ export const registerPreviewCommand = (context: vscode.ExtensionContext) => {
|
||||||
panel.webview.postMessage({
|
panel.webview.postMessage({
|
||||||
type: "update",
|
type: "update",
|
||||||
text: editor.document.getText(),
|
text: editor.document.getText(),
|
||||||
|
showSettings:
|
||||||
|
vscode.workspace.getConfiguration("squiggle").playground,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user