Haxe script for Ktxt2 Editor
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
-cp src
|
||||
-js bin/ktxt2editor.js
|
||||
--main KTxt2Editor
|
||||
--next
|
||||
-lib vscode
|
||||
-lib hxnodejs
|
||||
-lib kiss
|
||||
|
13
projects/kiss-vscode/src/EditorExterns.hx
Normal file
13
projects/kiss-vscode/src/EditorExterns.hx
Normal file
@@ -0,0 +1,13 @@
|
||||
import js.html.Window;
|
||||
|
||||
typedef VSCodeAPI = {
|
||||
function postMessage(message:Any):Void;
|
||||
function getState():Any;
|
||||
function setState(a:Any):Void;
|
||||
}
|
||||
|
||||
@:native("")
|
||||
extern class EditorExterns {
|
||||
static function acquireVsCodeApi():VSCodeAPI;
|
||||
static var window:Window;
|
||||
}
|
12
projects/kiss-vscode/src/KTxt2Editor.hx
Normal file
12
projects/kiss-vscode/src/KTxt2Editor.hx
Normal file
@@ -0,0 +1,12 @@
|
||||
import EditorExterns;
|
||||
|
||||
class KTxt2Editor {
|
||||
public static function main() {
|
||||
var vscode = EditorExterns.acquireVsCodeApi();
|
||||
|
||||
var document = EditorExterns.window.document;
|
||||
var pElement = document.createElement("p");
|
||||
pElement.innerHTML = "helly eah";
|
||||
document.body.appendChild(pElement);
|
||||
}
|
||||
}
|
@@ -1,9 +1,6 @@
|
||||
import kiss.Prelude;
|
||||
import kiss.List;
|
||||
import vscode.ExtensionContext;
|
||||
import vscode.TextDocument;
|
||||
import vscode.CancellationToken;
|
||||
import vscode.WebviewPanel;
|
||||
import vscode.*;
|
||||
import js.lib.Promise;
|
||||
|
||||
@:build(kiss.Kiss.build())
|
||||
|
@@ -6,6 +6,21 @@
|
||||
|
||||
(method :Promise<Void> resolveCustomTextEditor [:TextDocument document :WebviewPanel webviewPanel :CancellationToken _token]
|
||||
(set webviewPanel.webview.options (object enableScripts true))
|
||||
(set webviewPanel.webview.html "hello editor")
|
||||
(set webviewPanel.webview.html (htmlForWebview webviewPanel.webview))
|
||||
null
|
||||
)
|
||||
)
|
||||
|
||||
(method :String htmlForWebview [:Webview webview]
|
||||
(let [scriptUri
|
||||
(webview.asWebviewUri (Uri.joinPath (Uri.parse this.context.extensionUri) "bin" "ktxt2editor.js"))]
|
||||
"<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=\"UTF-8\">
|
||||
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
|
||||
<title>KTxt2</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src=\"${scriptUri}\"></script>
|
||||
</body>
|
||||
</html>"))
|
Reference in New Issue
Block a user