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 vscode
|
||||||
-lib hxnodejs
|
-lib hxnodejs
|
||||||
-lib kiss
|
-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.Prelude;
|
||||||
import kiss.List;
|
import kiss.List;
|
||||||
import vscode.ExtensionContext;
|
import vscode.*;
|
||||||
import vscode.TextDocument;
|
|
||||||
import vscode.CancellationToken;
|
|
||||||
import vscode.WebviewPanel;
|
|
||||||
import js.lib.Promise;
|
import js.lib.Promise;
|
||||||
|
|
||||||
@:build(kiss.Kiss.build())
|
@:build(kiss.Kiss.build())
|
||||||
|
@@ -6,6 +6,21 @@
|
|||||||
|
|
||||||
(method :Promise<Void> resolveCustomTextEditor [:TextDocument document :WebviewPanel webviewPanel :CancellationToken _token]
|
(method :Promise<Void> resolveCustomTextEditor [:TextDocument document :WebviewPanel webviewPanel :CancellationToken _token]
|
||||||
(set webviewPanel.webview.options (object enableScripts true))
|
(set webviewPanel.webview.options (object enableScripts true))
|
||||||
(set webviewPanel.webview.html "hello editor")
|
(set webviewPanel.webview.html (htmlForWebview webviewPanel.webview))
|
||||||
null
|
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