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 () {
 | 
			
		||||
  console.log("hello world");
 | 
			
		||||
  const vscode = acquireVsCodeApi();
 | 
			
		||||
 | 
			
		||||
  const container = document.getElementById("root");
 | 
			
		||||
 | 
			
		||||
  const root = ReactDOM.createRoot(container);
 | 
			
		||||
  function updateContent(text) {
 | 
			
		||||
  function updateContent(text, showSettings) {
 | 
			
		||||
    root.render(
 | 
			
		||||
      React.createElement(squiggle_components.SquigglePlayground, {
 | 
			
		||||
        code: text,
 | 
			
		||||
        onCodeChange: (code) => {
 | 
			
		||||
          vscode.postMessage({ type: "edit", text: code });
 | 
			
		||||
        },
 | 
			
		||||
        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
 | 
			
		||||
    switch (message.type) {
 | 
			
		||||
      case "update":
 | 
			
		||||
        const text = message.text;
 | 
			
		||||
        const { text, showSettings } = message;
 | 
			
		||||
 | 
			
		||||
        // Update our webview's content
 | 
			
		||||
        updateContent(text);
 | 
			
		||||
        updateContent(text, showSettings);
 | 
			
		||||
 | 
			
		||||
        // Then persist state information.
 | 
			
		||||
        // This state is returned in the call to `vscode.getState` below when a webview is reloaded.
 | 
			
		||||
        vscode.setState({ text });
 | 
			
		||||
        vscode.setState({ text, showSettings });
 | 
			
		||||
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -38,6 +36,6 @@
 | 
			
		|||
 | 
			
		||||
  const state = vscode.getState();
 | 
			
		||||
  if (state) {
 | 
			
		||||
    updateContent(state.text);
 | 
			
		||||
    updateContent(state.text, state.showSettings);
 | 
			
		||||
  }
 | 
			
		||||
})();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -77,7 +77,27 @@
 | 
			
		|||
        "mac": "cmd+k v",
 | 
			
		||||
        "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": {
 | 
			
		||||
    "vscode:prepublish": "yarn run compile",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,6 +30,8 @@ export const registerPreviewCommand = (context: vscode.ExtensionContext) => {
 | 
			
		|||
        panel.webview.postMessage({
 | 
			
		||||
          type: "update",
 | 
			
		||||
          text: editor.document.getText(),
 | 
			
		||||
          showSettings:
 | 
			
		||||
            vscode.workspace.getConfiguration("squiggle").playground,
 | 
			
		||||
        });
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user