aboutsummaryrefslogtreecommitdiff
path: root/editor/example.ts
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-11-05 00:39:45 +0700
committerShulhan <ms@kilabit.info>2023-11-05 01:45:11 +0700
commit65eb8e99d6dfdfdf419254cbb7e26b7afe426691 (patch)
treee4585381101d9357e3b84f64e906d93111f10540 /editor/example.ts
parentc60be07a107a655b63dd7aa4a3bc740591f9ca54 (diff)
downloadpakakeh.ts-65eb8e99d6dfdfdf419254cbb7e26b7afe426691.tar.xz
editor: simplify using one contenteditable
Using multiple lines of content editable is hard, especially when involving selection, deletion, and managing undo-redo history.
Diffstat (limited to 'editor/example.ts')
-rw-r--r--editor/example.ts20
1 files changed, 15 insertions, 5 deletions
diff --git a/editor/example.ts b/editor/example.ts
index a967045..39efb4c 100644
--- a/editor/example.ts
+++ b/editor/example.ts
@@ -48,13 +48,23 @@ sudo systemctl status telegraf
const opts = {
id: "editor",
- is_editable: true,
- onSelection: (begin: number, end: number) => {
- console.log("OnSelection: ", begin, end);
- },
+ isEditable: true,
onSave: (content: string) => {
- console.log("OnSave: ", content);
+ const lines = content.split("\n");
+ lines.forEach((line: string, x: number) => {
+ console.log(`${x}: ${line}`);
+ });
},
};
const wuiEditor = new WuiEditor(opts);
wuiEditor.open(nodeFile);
+
+const optsro = {
+ id: "editor-readonly",
+ isEditable: false,
+ onSave: (content: string) => {
+ console.log("OnSave: ", content);
+ },
+};
+const edro = new WuiEditor(optsro);
+edro.open(nodeFile);