aboutsummaryrefslogtreecommitdiff
path: root/editor/editor.ts
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-07-27 00:59:04 +0700
committerShulhan <ms@kilabit.info>2021-07-27 00:59:04 +0700
commit52cd98e02cdc998064cc263b008748e4fa94d269 (patch)
tree36ca838df138d629d2870f71c66f590aeb88f315 /editor/editor.ts
parent5e9c13bbd3e3f5748cee1294cb8e9831c5aa0ea7 (diff)
downloadpakakeh.ts-52cd98e02cdc998064cc263b008748e4fa94d269.tar.xz
editor: fix paste to plain text
Previously copy or cutting text on line and pasting it will generate <span> inside the line. This commit fix the paste function to paste only text.
Diffstat (limited to 'editor/editor.ts')
-rw-r--r--editor/editor.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/editor/editor.ts b/editor/editor.ts
index b428e87..880ef93 100644
--- a/editor/editor.ts
+++ b/editor/editor.ts
@@ -307,6 +307,15 @@ class EditorLine {
return ed.onKeydownText(x, this.elText, ev)
}
+ this.elText.addEventListener("paste", (ev: ClipboardEvent) => {
+ if (!ev.clipboardData) {
+ return
+ }
+ ev.preventDefault()
+ const text = ev.clipboardData.getData("text/plain")
+ document.execCommand("insertHTML", false, text)
+ })
+
this.el.appendChild(this.elNumber)
this.el.appendChild(this.elText)
}