diff options
| author | Shulhan <ms@kilabit.info> | 2023-11-05 00:39:45 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-11-05 01:45:11 +0700 |
| commit | 65eb8e99d6dfdfdf419254cbb7e26b7afe426691 (patch) | |
| tree | e4585381101d9357e3b84f64e906d93111f10540 /editor/example.ts | |
| parent | c60be07a107a655b63dd7aa4a3bc740591f9ca54 (diff) | |
| download | pakakeh.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.ts | 20 |
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); |
