diff --git a/src/main/frontend/components/editor.cljs b/src/main/frontend/components/editor.cljs index d7419013d..bfd7ba86f 100644 --- a/src/main/frontend/components/editor.cljs +++ b/src/main/frontend/components/editor.cljs @@ -607,12 +607,17 @@ (editor-handler/close-autocomplete-if-outside input)))))))) {:did-mount (fn [state] (let [[{:keys [dummy? format block-parent-id]} id] (:rum/args state) - content (get-in @state/state [:editor/content id])] + content (get-in @state/state [:editor/content id]) + input (gdom/getElement id)] (when block-parent-id (state/set-editing-block-dom-id! block-parent-id)) - (editor-handler/restore-cursor-pos! id content dummy?) + (if (= :indent-outdent (state/get-editor-op)) + (when input + (when-let [pos (state/get-edit-pos)] + (util/set-caret-pos! input pos))) + (editor-handler/restore-cursor-pos! id content dummy?)) - (when-let [input (gdom/getElement id)] + (when input (dnd/subscribe! input :upload-images diff --git a/src/main/frontend/db.cljs b/src/main/frontend/db.cljs index 3eeaa4cb3..25cc5536b 100644 --- a/src/main/frontend/db.cljs +++ b/src/main/frontend/db.cljs @@ -2433,14 +2433,15 @@ ;; block/uuid and block/content (defn get-all-block-contents [] - (->> (d/datoms (get-conn) :avet :block/uuid) - (map :v) - (map (fn [id] - (let [e (entity [:block/uuid id])] - {:db/id (:db/id e) - :block/uuid id - :block/content (:block/content e) - :block/format (:block/format e)}))))) + (when-let [conn (get-conn)] + (->> (d/datoms conn :avet :block/uuid) + (map :v) + (map (fn [id] + (let [e (entity [:block/uuid id])] + {:db/id (:db/id e) + :block/uuid id + :block/content (:block/content e) + :block/format (:block/format e)})))))) (defn get-all-templates []