mirror of https://github.com/logseq/logseq
parent
e4e5e7254b
commit
384a0cef8b
|
@ -27,7 +27,6 @@
|
|||
"react-dom": "^16.12.0",
|
||||
"react-textarea-autosize": "^8.0.1",
|
||||
"react-transition-group": "^4.3.0",
|
||||
"tauri": "^0.8.2",
|
||||
"webdav": "^3.3.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,10 +45,18 @@
|
|||
[[:editor/input template {:last-pattern slash
|
||||
:backward-pos 2}]]))
|
||||
|
||||
(defn embed-page
|
||||
[]
|
||||
(conj
|
||||
[[:editor/input "{{{embed [[]]}}}" {:last-pattern slash
|
||||
:backward-pos 5}]]
|
||||
[:editor/search-page :embed]))
|
||||
|
||||
(defn embed-block
|
||||
[]
|
||||
(conj
|
||||
(->inline "embed")
|
||||
[[:editor/input "{{{embed (())}}}" {:last-pattern slash
|
||||
:backward-pos 5}]]
|
||||
[:editor/search-block :embed]))
|
||||
|
||||
;; Credits to roamresearch.com
|
||||
|
@ -75,6 +83,7 @@
|
|||
["Date Picker" [[:editor/show-date-picker]]]
|
||||
["Page Reference" [[:editor/input "[[]]" {:backward-pos 2}]
|
||||
[:editor/search-page]]]
|
||||
["Page Embed" (embed-page)]
|
||||
["Block Reference" [[:editor/input "(())" {:backward-pos 2}]
|
||||
[:editor/search-block :reference]]]
|
||||
["Block Embed" (embed-block)]
|
||||
|
|
|
@ -266,20 +266,12 @@
|
|||
(let [uuid-string (str (:heading/uuid chosen))
|
||||
block-type @commands/*block-type]
|
||||
;; block reference
|
||||
(case block-type
|
||||
:embed
|
||||
;; block embed
|
||||
(insert-command! id
|
||||
(str "@@embed: " uuid-string)
|
||||
format
|
||||
{:last-pattern "@@embed: "})
|
||||
:reference
|
||||
(when (= block-type :reference)
|
||||
(insert-command! id
|
||||
(util/format "((%s))" uuid-string)
|
||||
format
|
||||
{:last-pattern (str "((" q)
|
||||
:postfix-fn (fn [s] (util/replace-first "))" s ""))})
|
||||
nil)
|
||||
:postfix-fn (fn [s] (util/replace-first "))" s ""))}) )
|
||||
|
||||
;; Save it so it'll be parsed correctly in the future
|
||||
(handler/set-heading-property! (:heading/uuid chosen)
|
||||
|
|
|
@ -201,7 +201,7 @@
|
|||
|
||||
(declare headings-container)
|
||||
|
||||
(rum/defc block-embed <
|
||||
(rum/defc block-embed < rum/reactive
|
||||
(mixins/clear-query-cache
|
||||
(fn [state]
|
||||
(let [repo (state/get-current-repo)
|
||||
|
@ -209,7 +209,26 @@
|
|||
[repo :heading/block heading-id])))
|
||||
[config id]
|
||||
(let [headings (db/get-heading-and-children (state/get-current-repo) id)]
|
||||
[:div.embed-block.pt-2.px-3.bg-base-2
|
||||
[:div.embed-block.py-2.my-2.px-3.bg-base-2
|
||||
[:p
|
||||
[:code "Embed block:"]]
|
||||
(headings-container headings (assoc config :embed? true))]))
|
||||
|
||||
(rum/defc page-embed < rum/reactive
|
||||
(mixins/clear-query-cache
|
||||
(fn [state]
|
||||
(let [repo (state/get-current-repo)
|
||||
page-name (last (:rum/args state))
|
||||
page-id (:db/id (db/entity [:page/name page-name]))]
|
||||
[repo :page/headings page-id])))
|
||||
[config page-name]
|
||||
(let [page-name (string/lower-case page-name)
|
||||
headings (db/get-page-headings (state/get-current-repo) page-name)]
|
||||
[:div.embed-page.py-2.my-2.px-3.bg-base-2
|
||||
[:p
|
||||
[:code "Embed page:"]
|
||||
[:a.ml-2 {:href (str "/page/" (util/encode-str page-name))}
|
||||
(util/capitalize-all page-name)]]
|
||||
(headings-container headings (assoc config :embed? true))]))
|
||||
|
||||
(defn inline
|
||||
|
@ -359,13 +378,6 @@
|
|||
["Inline_Hiccup" s]
|
||||
(reader/read-string s)
|
||||
|
||||
["Export_Snippet" "embed" s]
|
||||
(when-let [id (and s
|
||||
(let [s (string/trim s)]
|
||||
(and (util/uuid-string? s)
|
||||
(uuid s))))]
|
||||
(block-embed config id))
|
||||
|
||||
["Break_Line"]
|
||||
[:br]
|
||||
["Hard_Break_Line"]
|
||||
|
@ -405,6 +417,33 @@
|
|||
|
||||
["Macro" options]
|
||||
(let [{:keys [name arguments]} options]
|
||||
(cond
|
||||
(= name "embed")
|
||||
(let [a (first arguments)]
|
||||
(cond
|
||||
(and (string/starts-with? a "[[")
|
||||
(string/ends-with? a "]]"))
|
||||
(let [page-name (-> (string/replace a "[[" "")
|
||||
(string/replace "]]" "")
|
||||
string/trim)]
|
||||
(when-not (string/blank? page-name)
|
||||
(page-embed config page-name)))
|
||||
|
||||
(and (string/starts-with? a "((")
|
||||
(string/ends-with? a "))"))
|
||||
(when-let [s (-> (string/replace a "((" "")
|
||||
(string/replace "))" "")
|
||||
string/trim)]
|
||||
(when-let [id (and s
|
||||
(let [s (string/trim s)]
|
||||
(and (util/uuid-string? s)
|
||||
(uuid s))))]
|
||||
(block-embed config id)))
|
||||
|
||||
:else ;TODO: maybe collections?
|
||||
nil))
|
||||
|
||||
:else
|
||||
(when-let [heading-uuid (:heading/uuid config)]
|
||||
(let [macro-content (or
|
||||
(-> (db/entity [:heading/uuid heading-uuid])
|
||||
|
@ -417,9 +456,9 @@
|
|||
(get-in (state/get-config) [:macros name])
|
||||
(get-in (state/get-config) [:macros (keyword name)]))]
|
||||
[:span
|
||||
(if (seq arguments)
|
||||
(if (and (seq arguments) macro-content)
|
||||
(block/macro-subs macro-content arguments)
|
||||
macro-content)])))
|
||||
macro-content)]))))
|
||||
|
||||
:else
|
||||
""))
|
||||
|
|
|
@ -1024,7 +1024,7 @@
|
|||
pred (fn [data meta]
|
||||
(>= (:pos meta) pos))]
|
||||
(some-> (q repo [:heading/block heading-uuid]
|
||||
{:use-cache? false
|
||||
{:use-cache? true
|
||||
:transform-fn #(heading-and-children-transform % repo heading-uuid level)}
|
||||
'[:find (pull ?heading [*])
|
||||
:in $ ?page ?pred
|
||||
|
|
|
@ -144,6 +144,8 @@
|
|||
(defn set-edit-content!
|
||||
[input-id value]
|
||||
(when input-id
|
||||
(when-let [input (gdom/getElement input-id)]
|
||||
(gobj/set input "value" value))
|
||||
(update-state! :editor/content (fn [m]
|
||||
(assoc m input-id value)))
|
||||
;; followers
|
||||
|
|
3258
web/yarn.lock
3258
web/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue