diff options
| author | Shulhan <ms@kilabit.info> | 2021-09-05 20:24:50 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-09-05 20:24:50 +0700 |
| commit | caf0f69ed09d01ff6053cf095b720606077e442c (patch) | |
| tree | 8f249561fb176e263674ec7a32f19565f798b7f9 /editor | |
| parent | 897d8bbdd89034d8a9bdc781de07c5492b340f1f (diff) | |
| download | pakakeh.ts-caf0f69ed09d01ff6053cf095b720606077e442c.tar.xz | |
editor: convert the example to TypeScript and loaded as module
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/example.d.ts | 1 | ||||
| -rw-r--r-- | editor/example.ts (renamed from editor/example.html) | 55 | ||||
| -rw-r--r-- | editor/index.html | 11 |
3 files changed, 37 insertions, 30 deletions
diff --git a/editor/example.d.ts b/editor/example.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/editor/example.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/editor/example.html b/editor/example.ts index 8763dbc..f953f06 100644 --- a/editor/example.html +++ b/editor/example.ts @@ -1,22 +1,16 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset="UTF-8" /> - <title>WUI - editor</title> - </head> - <body onload="main()"> - <div id="editor"></div> +import { WuiEditor, WuiEditorOptions } from "./editor.js" +import { WuiVfsNodeInterface } from "../vfs/vfs.js" - <script> - var exports = {} - let wuiEditor = null - </script> - <script src="editor.js"></script> - <script> - let nodeFile = { - name: "Test", - path: "/test", - content: btoa(`mkdir -p \${HOME}/aur/stackdriver-collectd +let nodeFile: WuiVfsNodeInterface = { + name: "Test", + path: "/test", + is_dir: false, + content_type: "text/plain", + mod_time: 0, + size: 0, + mode: "", + childs: [], + content: btoa(`mkdir -p \${HOME}/aur/stackdriver-collectd git -C \${HOME}/aur/stackdriver-collectd clone \\ ssh://aur@aur.archlinux.org/stackdriver-collectd.git . @@ -47,16 +41,17 @@ sudo systemctl status stackdriver-collectd sudo systemctl restart telegraf sudo systemctl status telegraf `), - } +} - function main() { - let opts = { - id: "editor", - is_editable: true, - } - wuiEditor = new WuiEditor(opts) - wuiEditor.Open(nodeFile) - } - </script> - </body> -</html> +let opts = { + id: "editor", + is_editable: true, + OnSelection: (begin: number, end: number) => { + console.log("OnSelection: ", begin, end) + }, + OnSave: (content: string) => { + console.log("OnSave: ", content) + } +} +let wuiEditor = new WuiEditor(opts) +wuiEditor.Open(nodeFile) diff --git a/editor/index.html b/editor/index.html new file mode 100644 index 0000000..53947a7 --- /dev/null +++ b/editor/index.html @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="UTF-8" /> + <title>WUI - editor</title> + </head> + <body> + <div id="editor"></div> + <script type="module" src="/editor/example.js"></script> + </body> +</html> |
