diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 87fdd85ebf..91435f4ca9 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -1562,33 +1562,44 @@ (-> (p/let [buffer (.arrayBuffer file)] (fs/write-file! repo dir file-rpath buffer {:skip-compare? false})) (p/catch #(js/console.error "Debug: Writing Asset #" %))))) - insert-opts' (assoc insert-opts :page (:block/uuid asset)) + edit-block (state/get-edit-block) + insert-to-current-block-page? (and (:block/uuid edit-block) (string/blank? (state/get-edit-content))) + insert-opts' (if insert-to-current-block-page? + (assoc insert-opts + :block-uuid (:block/uuid edit-block) + :replace-empty-target? true + :sibling? true) + (assoc insert-opts :page (:block/uuid asset))) result (api-insert-new-block! file-name-without-ext insert-opts') new-entity (db/entity [:block/uuid (:block/uuid result)])] - (if (util/electron?) - new-entity - (-> - (p/do! (js/console.debug "Debug: Writing Asset #" dir file-rpath) - (cond - (mobile-util/native-platform?) - ;; capacitor fs accepts Blob, File implements Blob - (p/let [buffer (.arrayBuffer file) - content (base64/encodeByteArray (js/Uint8Array. buffer)) - fpath (path/path-join dir file-rpath)] - (capacitor-fs/ + (p/do! (js/console.debug "Debug: Writing Asset #" dir file-rpath) + (cond + (mobile-util/native-platform?) + ;; capacitor fs accepts Blob, File implements Blob + (p/let [buffer (.arrayBuffer file) + content (base64/encodeByteArray (js/Uint8Array. buffer)) + fpath (path/path-join dir file-rpath)] + (capacitor-fs/