After headings should be sorted by pos

pull/645/head
Tienson Qin 2020-05-10 07:57:49 +08:00
parent 1d78d7bdcb
commit cc6d3d9b87
3 changed files with 11 additions and 8 deletions

View File

@ -239,6 +239,12 @@
(get-conn repo-url) path)
seq-flatten))
(defn sort-by-pos
[headings]
(sort-by (fn [heading]
(get-in heading [:heading/meta :pos]))
headings))
(defn get-file-after-headings
[repo-url file-id end-pos]
(when end-pos
@ -251,7 +257,8 @@
[?heading :heading/meta ?meta]
[(?pred $ ?meta)]]
(get-conn repo-url) file-id pred)
seq-flatten))))
seq-flatten
sort-by-pos))))
(defn delete-file-headings!
[repo-url path]
@ -322,12 +329,6 @@
:git/error (get-key-value repo :git/error)})
repos)))
(defn sort-by-pos
[headings]
(sort-by (fn [heading]
(get-in heading [:heading/meta :pos]))
headings))
(defn get-file-by-concat-headings
([file]
(get-file-by-concat-headings

View File

@ -163,7 +163,8 @@
(fn [idx {:heading/keys [ref-pages meta] :as heading}]
(let [heading (merge
heading
{:heading/file file
{:heading/meta meta
:heading/file file
:heading/page page
:heading/content (utf8/substring encoded-content
(:pos meta)

View File

@ -722,6 +722,7 @@
(db/transact!
(concat
pages
[[:db.fn/retractEntity [:heading/uuid uuid]]]
headings
after-headings
[{:file/path file-path