mirror of https://github.com/logseq/logseq
Merge branch 'master' of github.com:tiensonqin/gitnotes
commit
8ad4097987
|
@ -158,7 +158,7 @@
|
|||
(string/replace-first (subs edit-content pos)
|
||||
marker-pattern
|
||||
(str marker " ")))]
|
||||
(state/set-edit-content! input-id new-value)))))
|
||||
(state/set-edit-content! input-id new-value true)))))
|
||||
|
||||
(defmethod handle-step :editor/search-page [[_]]
|
||||
(state/set-editor-show-page-search true))
|
||||
|
|
|
@ -519,14 +519,14 @@
|
|||
(reset! *matched-commands matched-commands)))
|
||||
(reset! *show-commands false)
|
||||
)))))))))
|
||||
{:init (fn [state _props]
|
||||
{:after (fn [state _props]
|
||||
(let [[content {:keys [dummy? heading heading-id]} id] (:rum/args state)]
|
||||
(state/set-edit-content! id (string/trim (or content "")))
|
||||
(reset! *should-delete? false))
|
||||
state)
|
||||
:did-mount (fn [state]
|
||||
(let [[content {:keys [heading format dummy? format]} id] (:rum/args state)]
|
||||
(let [content (handler/remove-level-spaces content format)]
|
||||
(state/set-edit-content! id (string/trim (or content "")) true)
|
||||
(handler/restore-cursor-pos! id content dummy?))
|
||||
(when-let [input (gdom/getElement id)]
|
||||
(dnd/subscribe!
|
||||
|
@ -563,56 +563,52 @@
|
|||
[content {:keys [on-hide dummy? node format heading]
|
||||
:or {dummy? false}
|
||||
:as option} id]
|
||||
(let [value (state/sub [:editor/content id])
|
||||
value (if heading
|
||||
(handler/remove-level-spaces value format)
|
||||
value)]
|
||||
[:div.editor {:style {:position "relative"
|
||||
:display "flex"
|
||||
:flex "1 1 0%"}
|
||||
:class (if heading "heading-editor" "non-heading-editor")}
|
||||
(ui/textarea
|
||||
{:id id
|
||||
:on-change (fn [e]
|
||||
(let [value (util/evalue e)]
|
||||
(state/set-edit-content! id value)
|
||||
(reset! *should-delete? false)))
|
||||
:value (or value "")
|
||||
:auto-focus true})
|
||||
(transition-cp
|
||||
(commands id format)
|
||||
true)
|
||||
[:div.editor {:style {:position "relative"
|
||||
:display "flex"
|
||||
:flex "1 1 0%"}
|
||||
:class (if heading "heading-editor" "non-heading-editor")}
|
||||
(ui/textarea
|
||||
{:id id
|
||||
:default-value content
|
||||
:on-change (fn [e]
|
||||
(let [value (util/evalue e)]
|
||||
(state/set-edit-content! id value false)
|
||||
(reset! *should-delete? false)))
|
||||
:auto-focus true})
|
||||
(transition-cp
|
||||
(commands id format)
|
||||
true)
|
||||
|
||||
(transition-cp
|
||||
(page-search id format)
|
||||
true)
|
||||
(transition-cp
|
||||
(page-search id format)
|
||||
true)
|
||||
|
||||
(transition-cp
|
||||
(block-search id format)
|
||||
true)
|
||||
(transition-cp
|
||||
(block-search id format)
|
||||
true)
|
||||
|
||||
(transition-cp
|
||||
(date-picker id format)
|
||||
false)
|
||||
(transition-cp
|
||||
(date-picker id format)
|
||||
false)
|
||||
|
||||
(transition-cp
|
||||
(input id
|
||||
(fn [{:keys [link label]} pos]
|
||||
(if (and (string/blank? link)
|
||||
(string/blank? label))
|
||||
nil
|
||||
(insert-command! id
|
||||
(util/format "[[%s][%s]]"
|
||||
(or link "")
|
||||
(or label ""))
|
||||
format
|
||||
{:last-pattern "/link"}))
|
||||
(state/set-editor-show-input nil)
|
||||
(when-let [saved-cursor (get @state/state :editor/last-saved-cursor)]
|
||||
(when-let [input (gdom/getElement id)]
|
||||
(.focus input)
|
||||
(util/move-cursor-to input saved-cursor)))))
|
||||
true)
|
||||
(transition-cp
|
||||
(input id
|
||||
(fn [{:keys [link label]} pos]
|
||||
(if (and (string/blank? link)
|
||||
(string/blank? label))
|
||||
nil
|
||||
(insert-command! id
|
||||
(util/format "[[%s][%s]]"
|
||||
(or link "")
|
||||
(or label ""))
|
||||
format
|
||||
{:last-pattern "/link"}))
|
||||
(state/set-editor-show-input nil)
|
||||
(when-let [saved-cursor (get @state/state :editor/last-saved-cursor)]
|
||||
(when-let [input (gdom/getElement id)]
|
||||
(.focus input)
|
||||
(util/move-cursor-to input saved-cursor)))))
|
||||
true)
|
||||
|
||||
(when format
|
||||
(image-uploader id format))]))
|
||||
(when format
|
||||
(image-uploader id format))])
|
||||
|
|
|
@ -281,10 +281,10 @@
|
|||
{:title "Settings"
|
||||
:options {:href (str "/file/" (util/url-encode config/config-file))}}
|
||||
{:title "Bug report"
|
||||
:options {:href "https://github.com/logseq/issues/issues/new"
|
||||
:options {:href "https://github.com/logseq/logseq/issues/new"
|
||||
:target "_blank"}}
|
||||
{:title "Feature request"
|
||||
:options {:href "https://github.com/logseq/issues/issues/new"
|
||||
:options {:href "https://github.com/logseq/logseq/issues/new"
|
||||
:target "_blank"}}
|
||||
{:title "Logseq documentation"
|
||||
:options {:href "/docs"}}
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
[rum.core :as rum]
|
||||
[frontend.util :as util]
|
||||
[clojure.string :as string]
|
||||
[medley.core :as medley]))
|
||||
[medley.core :as medley]
|
||||
[goog.object :as gobj]
|
||||
[goog.dom :as gdom]))
|
||||
|
||||
(defonce state
|
||||
(atom
|
||||
|
@ -119,8 +121,11 @@
|
|||
(get-in @state [:editor/content input-id]))
|
||||
|
||||
(defn set-edit-content!
|
||||
[input-id value]
|
||||
[input-id value set-input-value?]
|
||||
(when input-id
|
||||
(when set-input-value?
|
||||
(when-let [input (gdom/getElement input-id)]
|
||||
(gobj/set input "value" value)))
|
||||
(update-state! :editor/content (fn [m]
|
||||
(assoc m input-id value)))))
|
||||
|
||||
|
@ -308,10 +313,8 @@
|
|||
(defn set-heading-content-and-last-pos!
|
||||
[edit-input-id content new-pos]
|
||||
(when edit-input-id
|
||||
(reset! state
|
||||
(-> @state
|
||||
(assoc-in [:editor/content edit-input-id] content)
|
||||
(assoc :editor/last-saved-cursor new-pos)))))
|
||||
(set-edit-content! edit-input-id content true)
|
||||
(reset! state (assoc @state :editor/last-saved-cursor new-pos))))
|
||||
|
||||
(defn set-theme!
|
||||
[theme]
|
||||
|
|
Loading…
Reference in New Issue