mirror of https://github.com/logseq/logseq
parent
4ea881afaa
commit
8bd278ea44
|
@ -2043,9 +2043,12 @@
|
|||
(db/entity [:block/name (util/page-name-sanity-lc id)]))]
|
||||
(= (:block/uuid entity) (tree/-get-parent-id current-node)))))
|
||||
|
||||
(defn- insert
|
||||
[insertion]
|
||||
(when-not (auto-complete?)
|
||||
(defn insert
|
||||
([insertion]
|
||||
(insert insertion false))
|
||||
([insertion auto-complete-enabled?]
|
||||
(when (or auto-complete-enabled?
|
||||
(not (auto-complete?)))
|
||||
(let [^js input (state/get-input)
|
||||
selected-start (util/get-selection-start input)
|
||||
selected-end (util/get-selection-end input)
|
||||
|
@ -2054,7 +2057,7 @@
|
|||
s2 (subs value selected-end)]
|
||||
(state/set-edit-content! (state/get-edit-input-id)
|
||||
(str s1 insertion s2))
|
||||
(cursor/move-cursor-to input (+ selected-start (count insertion))))))
|
||||
(cursor/move-cursor-to input (+ selected-start (count insertion)))))))
|
||||
|
||||
(defn- keydown-new-line
|
||||
[]
|
||||
|
@ -2949,7 +2952,7 @@
|
|||
(let [data (if (gp-util/url? clipboard-data)
|
||||
(wrap-macro-url clipboard-data)
|
||||
clipboard-data)]
|
||||
(state/append-current-edit-content! data))))
|
||||
(insert data true))))
|
||||
(fn [error]
|
||||
(js/console.error error))))
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
(string/replace "{text}" (or text ""))
|
||||
(string/replace "{url}" (or url "")))]
|
||||
(if (state/get-edit-block)
|
||||
(state/append-current-edit-content! values)
|
||||
(editor-handler/insert values)
|
||||
(editor-handler/api-insert-new-block! values {:page page
|
||||
:edit-block? false
|
||||
:replace-empty-target? true}))))
|
||||
|
@ -102,7 +102,7 @@
|
|||
format (db/get-page-format page)
|
||||
content (embed-asset-file url format)]
|
||||
(if (state/get-edit-block)
|
||||
(state/append-current-edit-content! content)
|
||||
(editor-handler/insert content)
|
||||
(editor-handler/api-insert-new-block! content {:page page
|
||||
:edit-block? false
|
||||
:replace-empty-target? true}))))
|
||||
|
@ -129,7 +129,7 @@
|
|||
". We will look into it soon."]
|
||||
:warning false))]
|
||||
(if (state/get-edit-block)
|
||||
(state/append-current-edit-content! content)
|
||||
(editor-handler/insert content)
|
||||
(editor-handler/api-insert-new-block! content {:page page
|
||||
:edit-block? false
|
||||
:replace-empty-target? true}))))
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
{:edit-block? false
|
||||
:replace-empty-target? true})]
|
||||
(if edit-block
|
||||
(state/append-current-edit-content! file-link)
|
||||
(editor-handler/insert file-link)
|
||||
(editor-handler/api-insert-new-block! file-link args))))
|
||||
|
||||
(defn stop-recording []
|
||||
|
|
|
@ -567,21 +567,6 @@
|
|||
[]
|
||||
(sub [:editor/content (get-edit-input-id)]))
|
||||
|
||||
(defn append-current-edit-content!
|
||||
[append-text]
|
||||
(when-not (string/blank? append-text)
|
||||
(when-let [input-id (get-edit-input-id)]
|
||||
(when-let [input (gdom/getElement input-id)]
|
||||
(let [value (gobj/get input "value")
|
||||
new-value (if (or (string/blank? value)
|
||||
(= (last value) " ")
|
||||
(= (last value) "\n"))
|
||||
(str value append-text)
|
||||
(str value "\n" append-text))]
|
||||
(util/set-change-value input new-value)
|
||||
(update-state! :editor/content (fn [m]
|
||||
(assoc m input-id new-value))))))))
|
||||
|
||||
(defn get-cursor-range
|
||||
[]
|
||||
(:cursor-range @state))
|
||||
|
|
Loading…
Reference in New Issue