Skip to content

Commit

Permalink
fix(editor): properties save and clearing content when backspace
Browse files Browse the repository at this point in the history
Closed logseq#542
  • Loading branch information
tiensonqin committed Oct 28, 2020
1 parent 0d05b84 commit 51dfe14
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/frontend/handler/editor.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@
(assoc new-properties :old_permalink (:permalink old-properties))
new-properties)
value (cond
custom-properties
(seq custom-properties)
(text/re-construct-block-properties block value custom-properties)

(and (seq (:block/properties block))
Expand Down
15 changes: 11 additions & 4 deletions src/main/frontend/text.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,17 @@
(let [lines (string/split-lines content)
[title-lines properties-and-body] (split-with (fn [l] (not (string/starts-with? (string/upper-case (string/triml l)) ":PROPERTIES:"))) lines)
body (drop-while (fn [l]
(or
(string/starts-with? (string/triml l) ":") ; kv
(string/starts-with? (string/upper-case (string/triml l)) ":end:")))
properties-and-body)]
(let [l' (string/lower-case (string/trim l))]
(and (string/starts-with? l' ":")
(not (string/starts-with? l' ":end:")))))
properties-and-body)
body (if (and (seq body)
(string/starts-with? (string/lower-case (string/triml (first body))) ":end:"))
(let [line (string/replace (first body) #"(?i):end:\s?" "")]
(if (string/blank? line)
(rest body)
(cons line (rest body))))
body)]
(->> (concat title-lines body)
(string/join "\n"))))

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3643,10 +3643,10 @@ xtend@^4.0.0, xtend@^4.0.2:
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==

yargs-parser@^11.1.1:
version "11.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4"
integrity sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==
yargs-parser@^13.1.2:
version "13.1.2"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38"
integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==
dependencies:
camelcase "^5.0.0"
decamelize "^1.2.0"
Expand Down

0 comments on commit 51dfe14

Please sign in to comment.