|
@@ -1078,15 +1078,21 @@
|
|
|
|
|
|
(defn ^:export append_block_in_page
|
|
(defn ^:export append_block_in_page
|
|
[uuid-or-page-name content ^js opts]
|
|
[uuid-or-page-name content ^js opts]
|
|
- (p/let [_ (<ensure-page-loaded uuid-or-page-name)
|
|
|
|
- page? (not (util/uuid-string? uuid-or-page-name))
|
|
|
|
- page-not-exist? (and page? (nil? (db-model/get-page uuid-or-page-name)))
|
|
|
|
- _ (and page-not-exist? (page-handler/<create! uuid-or-page-name
|
|
|
|
- {:redirect? false
|
|
|
|
- :format (state/get-preferred-format)}))]
|
|
|
|
- (when-let [block (db-model/get-page uuid-or-page-name)]
|
|
|
|
- (let [target (str (:block/uuid block))]
|
|
|
|
- (insert_block target content opts)))))
|
|
|
|
|
|
+ (let [current-page? (or (and (nil? content) (nil? opts))
|
|
|
|
+ (and (nil? opts) (some->> content (instance? js/Object))))
|
|
|
|
+ opts (if current-page? content opts)
|
|
|
|
+ content (if current-page? uuid-or-page-name content)
|
|
|
|
+ uuid-or-page-name (if current-page? (state/get-current-page)
|
|
|
|
+ uuid-or-page-name)]
|
|
|
|
+ (p/let [_ (<ensure-page-loaded uuid-or-page-name)
|
|
|
|
+ page? (not (util/uuid-string? uuid-or-page-name))
|
|
|
|
+ page-not-exist? (and page? (nil? (db-model/get-page uuid-or-page-name)))
|
|
|
|
+ _ (and page-not-exist? (page-handler/<create! uuid-or-page-name
|
|
|
|
+ {:redirect? false
|
|
|
|
+ :format (state/get-preferred-format)}))]
|
|
|
|
+ (when-let [block (db-model/get-page uuid-or-page-name)]
|
|
|
|
+ (let [target (str (:block/uuid block))]
|
|
|
|
+ (insert_block target content opts))))))
|
|
|
|
|
|
;; plugins
|
|
;; plugins
|
|
(defn ^:export validate_external_plugins [urls]
|
|
(defn ^:export validate_external_plugins [urls]
|