fix: code block

pull/1572/head
Tienson Qin 2021-03-31 13:57:04 +08:00
parent b881d8dbd5
commit ada8cc6a38
1 changed files with 6 additions and 1 deletions

View File

@ -59,7 +59,12 @@
format (:block/format block)
content (:block/content block)
{:keys [start_pos end_pos]} @pos-meta
value (if (= \n (last value)) value (str value "\n"))
prev-content (utf8/substring (utf8/encode content)
0 start_pos)
value (str (if (not= "\n" (last prev-content))
"\n")
(string/trimr value)
"\n")
content' (utf8/insert! content start_pos end_pos value)]
(state/set-editor-op! :code-editor)
(editor-handler/save-block-if-changed! block content')