Browse Source

enhance(zotero): put abstract note into a separate block

Tienson Qin 4 years ago
parent
commit
61131ba1eb

+ 14 - 2
src/main/frontend/extensions/zotero/handler.cljs

@@ -43,6 +43,15 @@
   (state/set-editor-show-zotero! false)
   (editor-handler/insert-command! id (str "[[" page-name "]]") nil {}))
 
+(defn- create-abstract-note!
+  [page-name abstract-note]
+  (when-not (str/blank? abstract-note)
+    (let [block (editor-handler/api-insert-new-block!
+                 "[[Abstract]]" {:page page-name})]
+      (editor-handler/api-insert-new-block!
+       abstract-note {:block-uuid (:block/uuid block)
+                      :sibling? false}))))
+
 (defn create-zotero-page
   ([item]
    (create-zotero-page item {}))
@@ -50,8 +59,9 @@
           :or {insert-command? true notification? true}
           :as opt}]
    (go
-     (let [{:keys [page-name properties]} (extractor/extract item)]
-
+     (let [{:keys [page-name properties]} (extractor/extract item)
+           abstract-note (get properties :abstract-note)
+           properties (dissoc properties :abstract-note)]
        (when insert-command?
          (handle-command-zotero block-dom-id page-name)
          (editor-handler/save-current-block!))
@@ -68,6 +78,8 @@
            :create-first-block? false
            :properties properties}))
 
+       (create-abstract-note! page-name abstract-note)
+
        (<! (add page-name :attachments item))
 
        (<! (add page-name :notes item))

+ 2 - 2
src/main/frontend/extensions/zotero/setting.cljs

@@ -7,9 +7,9 @@
 (def default-settings
   {:type                   :user
    :include-attachments?   true
-   :attachments-block-text "[[attachments]]"
+   :attachments-block-text "[[Attachments]]"
    :include-notes?         true
-   :notes-block-text       "[[notes]]"
+   :notes-block-text       "[[Notes]]"
    :page-insert-prefix     "@"})
 
 (defn api-key []