Skip to content

Commit

Permalink
fix : setting theme has a delay
Browse files Browse the repository at this point in the history
  • Loading branch information
1595901624 committed Oct 26, 2023
1 parent 7dd466b commit 87e830d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Binary file modified pkg/rust_json_lib_rs_bg.wasm
Binary file not shown.
10 changes: 9 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,20 @@ export function activate(context: vscode.ExtensionContext) {
let htmlUri = vscode.Uri.joinPath(context.extensionUri, "static", 'ui.html');
console.log(htmlUri.fsPath);

// aceSrc
let aceUri = vscode.Uri.joinPath(context.extensionUri, "static", "ace", 'ace.js');
let aceSrc = webviewPanel.webview.asWebviewUri(aceUri);
console.log(aceSrc.toString());

// aceThemeMonokai
let aceThemeMonokaiUri = vscode.Uri.joinPath(context.extensionUri, "static", "ace", 'theme-monokai.js');
let aceThemeMonokai = webviewPanel.webview.asWebviewUri(aceThemeMonokaiUri);
console.log(aceThemeMonokai.toString());

let html = readFileSync(htmlUri.fsPath, "utf-8");
webviewPanel.webview.html = html.toString().replace("{{aceSrc}}", aceSrc.toString());
webviewPanel.webview.html = html.toString()
.replace("{{aceSrc}}", aceSrc.toString())
.replace("{{aceThemeMonokai}}", aceThemeMonokai.toString());
// console.log(htmlUri);

webviewPanel.webview.onDidReceiveMessage(
Expand Down
6 changes: 3 additions & 3 deletions static/ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<head>
<script src="{{aceSrc}}"></script>
<script src="{{aceThemeMonokai}}"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.5.0/ace.js"></script> -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ext-language_tools.js"></script> -->
<style>
Expand Down Expand Up @@ -86,7 +87,6 @@
const vscode = acquireVsCodeApi();
const INNPUT_DATA = "vscode.input.data";
const RESULT_DATA = "vscode.result.data";

// 初始化编辑器
window.onload = function () {
// initialize the input editor
Expand Down Expand Up @@ -220,7 +220,7 @@
* format button click
* */
function onFormatButonClick() {
var editor = ace.editor('editor');
var editor = ace.edit('input-editor');
console.log(editor.getValue())
editor.setValue(formatJSON(editor.getValue()));
}
Expand All @@ -239,7 +239,7 @@ <h1>Please Input Json</h1>
<label for="checkbox1" class="checkbox-label">Add Option</label>
</div> -->
<button class="ok" onclick="onGenerateButtonClick()">Generate</button>
<button class="ok" onclick="onFormatButonClick()">Format</button>
<button class="ok" style="margin: 16px;" onclick="onFormatButonClick()">Format</button>

<div>
<h1>Result</h1>
Expand Down

0 comments on commit 87e830d

Please sign in to comment.