mirror of https://github.com/logseq/logseq
Use core uuid fns where possible
No need for medley or personal util fns when core fns are available. Also upgraded nbb-logseq to be 1.11.X cljs compatible - uuid is the same as medley/uuid - random-uuid is the same as medley/random-uuid - uuid-string? and uuid is the same as parse-uuidpull/5369/head
parent
fec0b755a8
commit
6f68d985bd
|
@ -5,7 +5,8 @@
|
||||||
object
|
object
|
||||||
;; TODO: Remove parse-* when https://github.com/clj-kondo/clj-kondo/issues/1694 is done
|
;; TODO: Remove parse-* when https://github.com/clj-kondo/clj-kondo/issues/1694 is done
|
||||||
parse-long
|
parse-long
|
||||||
parse-double]}
|
parse-double
|
||||||
|
parse-uuid]}
|
||||||
;; TODO:lint: Remove node-path excludes once we have a cleaner api
|
;; TODO:lint: Remove node-path excludes once we have a cleaner api
|
||||||
:unresolved-var {:exclude [frontend.util/node-path.basename
|
:unresolved-var {:exclude [frontend.util/node-path.basename
|
||||||
frontend.util/node-path.dirname
|
frontend.util/node-path.dirname
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"main": "static/electron.js",
|
"main": "static/electron.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@capacitor/cli": "3.2.2",
|
"@capacitor/cli": "3.2.2",
|
||||||
"@logseq/nbb-logseq": "^0.3.99",
|
"@logseq/nbb-logseq": "^0.5.103",
|
||||||
"@playwright/test": "^1.19.2",
|
"@playwright/test": "^1.19.2",
|
||||||
"@tailwindcss/ui": "0.7.2",
|
"@tailwindcss/ui": "0.7.2",
|
||||||
"@types/gulp": "^4.0.7",
|
"@types/gulp": "^4.0.7",
|
||||||
|
|
|
@ -707,11 +707,8 @@
|
||||||
(rum/defc block-reference < rum/reactive
|
(rum/defc block-reference < rum/reactive
|
||||||
db-mixins/query
|
db-mixins/query
|
||||||
[config id label]
|
[config id label]
|
||||||
(when (and
|
(when-let [block-id (parse-uuid id)]
|
||||||
(not (string/blank? id))
|
(let [block (db/pull-block block-id)
|
||||||
(util/uuid-string? id))
|
|
||||||
(let [block-id (uuid id)
|
|
||||||
block (db/pull-block block-id)
|
|
||||||
block-type (keyword (get-in block [:block/properties :ls-type]))
|
block-type (keyword (get-in block [:block/properties :ls-type]))
|
||||||
hl-type (get-in block [:block/properties :hl-type])
|
hl-type (get-in block [:block/properties :hl-type])
|
||||||
repo (state/get-current-repo)]
|
repo (state/get-current-repo)]
|
||||||
|
@ -1104,10 +1101,7 @@
|
||||||
(when-let [s (-> (string/replace a "((" "")
|
(when-let [s (-> (string/replace a "((" "")
|
||||||
(string/replace "))" "")
|
(string/replace "))" "")
|
||||||
string/trim)]
|
string/trim)]
|
||||||
(when-let [id (and s
|
(when-let [id (some-> s string/trim parse-uuid)]
|
||||||
(let [s (string/trim s)]
|
|
||||||
(and (util/uuid-string? s)
|
|
||||||
(uuid s))))]
|
|
||||||
(block-embed (assoc config :link-depth (inc link-depth)) id)))
|
(block-embed (assoc config :link-depth (inc link-depth)) id)))
|
||||||
|
|
||||||
:else ;TODO: maybe collections?
|
:else ;TODO: maybe collections?
|
||||||
|
@ -2817,7 +2811,7 @@
|
||||||
:else
|
:else
|
||||||
(let [language (if (contains? #{"edn" "clj" "cljc" "cljs"} language) "clojure" language)]
|
(let [language (if (contains? #{"edn" "clj" "cljc" "cljs"} language) "clojure" language)]
|
||||||
(if (:slide? config)
|
(if (:slide? config)
|
||||||
(highlight/highlight (str (medley/random-uuid))
|
(highlight/highlight (str (random-uuid))
|
||||||
{:class (str "language-" language)
|
{:class (str "language-" language)
|
||||||
:data-lang language}
|
:data-lang language}
|
||||||
code)
|
code)
|
||||||
|
|
|
@ -363,13 +363,13 @@
|
||||||
e
|
e
|
||||||
(custom-context-menu-content))
|
(custom-context-menu-content))
|
||||||
|
|
||||||
(and block-id (util/uuid-string? block-id))
|
(and block-id (parse-uuid block-id))
|
||||||
(let [block (.closest target ".ls-block")]
|
(let [block (.closest target ".ls-block")]
|
||||||
(when block
|
(when block
|
||||||
(util/select-highlight! [block]))
|
(util/select-highlight! [block]))
|
||||||
(common-handler/show-custom-context-menu!
|
(common-handler/show-custom-context-menu!
|
||||||
e
|
e
|
||||||
(block-context-menu-content target (cljs.core/uuid block-id))))
|
(block-context-menu-content target (uuid block-id))))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
nil))))))
|
nil))))))
|
||||||
|
|
|
@ -122,8 +122,8 @@
|
||||||
(when page-e
|
(when page-e
|
||||||
(let [page-name (or (:block/name page-e)
|
(let [page-name (or (:block/name page-e)
|
||||||
(str (:block/uuid page-e)))
|
(str (:block/uuid page-e)))
|
||||||
block? (util/uuid-string? page-name)
|
block-id (parse-uuid page-name)
|
||||||
block-id (and block? (uuid page-name))
|
block? (boolean block-id)
|
||||||
page-blocks (get-blocks repo page-name block-id)]
|
page-blocks (get-blocks repo page-name block-id)]
|
||||||
(if (empty? page-blocks)
|
(if (empty? page-blocks)
|
||||||
(dummy-block page-name)
|
(dummy-block page-name)
|
||||||
|
@ -317,8 +317,8 @@
|
||||||
(let [current-repo (state/sub :git/current-repo)
|
(let [current-repo (state/sub :git/current-repo)
|
||||||
repo (or repo current-repo)
|
repo (or repo current-repo)
|
||||||
page-name (util/page-name-sanity-lc path-page-name)
|
page-name (util/page-name-sanity-lc path-page-name)
|
||||||
block? (util/uuid-string? page-name)
|
block-id (parse-uuid page-name)
|
||||||
block-id (and block? (uuid page-name))
|
block? (boolean block-id)
|
||||||
format (let [page (if block-id
|
format (let [page (if block-id
|
||||||
(:block/name (:block/page (db/entity [:block/uuid block-id])))
|
(:block/name (:block/page (db/entity [:block/uuid block-id])))
|
||||||
page-name)]
|
page-name)]
|
||||||
|
|
|
@ -82,8 +82,7 @@
|
||||||
default-collapsed? (>= (count refed-blocks-ids) threshold)
|
default-collapsed? (>= (count refed-blocks-ids) threshold)
|
||||||
filters-atom (get state ::filters)
|
filters-atom (get state ::filters)
|
||||||
filter-state (rum/react filters-atom)
|
filter-state (rum/react filters-atom)
|
||||||
block? (util/uuid-string? page-name)
|
block-id (parse-uuid page-name)
|
||||||
block-id (and block? (uuid page-name))
|
|
||||||
page-name (string/lower-case page-name)
|
page-name (string/lower-case page-name)
|
||||||
journal? (date/valid-journal-title? (string/capitalize page-name))
|
journal? (date/valid-journal-title? (string/capitalize page-name))
|
||||||
scheduled-or-deadlines (when (and journal?
|
scheduled-or-deadlines (when (and journal?
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
(ns frontend.db.debug
|
(ns frontend.db.debug
|
||||||
(:require [medley.core :as medley]
|
(:require [frontend.db.utils :as db-utils]
|
||||||
[frontend.db.utils :as db-utils]
|
|
||||||
[frontend.db :as db]
|
[frontend.db :as db]
|
||||||
[datascript.core :as d]
|
[datascript.core :as d]
|
||||||
[frontend.util :as util]))
|
[frontend.util :as util]))
|
||||||
|
@ -8,7 +7,7 @@
|
||||||
;; shortcut for query a block with string ref
|
;; shortcut for query a block with string ref
|
||||||
(defn qb
|
(defn qb
|
||||||
[string-id]
|
[string-id]
|
||||||
(db-utils/pull [:block/uuid (medley/uuid string-id)]))
|
(db-utils/pull [:block/uuid (uuid string-id)]))
|
||||||
|
|
||||||
(defn check-left-id-conflicts
|
(defn check-left-id-conflicts
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -916,8 +916,8 @@
|
||||||
|
|
||||||
(defn get-page
|
(defn get-page
|
||||||
[page-name]
|
[page-name]
|
||||||
(if (util/uuid-string? page-name)
|
(if-let [id (parse-uuid page-name)]
|
||||||
(db-utils/entity [:block/uuid (uuid page-name)])
|
(db-utils/entity [:block/uuid id])
|
||||||
(db-utils/entity [:block/name (util/page-name-sanity-lc page-name)])))
|
(db-utils/entity [:block/name (util/page-name-sanity-lc page-name)])))
|
||||||
|
|
||||||
(defn get-redirect-page-name
|
(defn get-redirect-page-name
|
||||||
|
@ -1225,9 +1225,8 @@
|
||||||
|
|
||||||
(defn get-referenced-blocks-ids
|
(defn get-referenced-blocks-ids
|
||||||
[page-name-or-block-uuid]
|
[page-name-or-block-uuid]
|
||||||
(if (util/uuid-string? (str page-name-or-block-uuid))
|
(if-let [id (parse-uuid (str page-name-or-block-uuid))]
|
||||||
(let [id (uuid page-name-or-block-uuid)]
|
(get-block-referenced-blocks-ids id)
|
||||||
(get-block-referenced-blocks-ids id))
|
|
||||||
(get-page-referenced-blocks-ids page-name-or-block-uuid)))
|
(get-page-referenced-blocks-ids page-name-or-block-uuid)))
|
||||||
|
|
||||||
(defn get-matched-blocks
|
(defn get-matched-blocks
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
(:require [cljs-bean.core :as bean]
|
(:require [cljs-bean.core :as bean]
|
||||||
[frontend.external.protocol :as protocol]
|
[frontend.external.protocol :as protocol]
|
||||||
[frontend.date :as date]
|
[frontend.date :as date]
|
||||||
[medley.core :as medley]
|
|
||||||
[clojure.walk :as walk]
|
[clojure.walk :as walk]
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[frontend.util :as util]
|
[frontend.util :as util]
|
||||||
|
@ -61,7 +60,7 @@
|
||||||
(set))]
|
(set))]
|
||||||
(reset! all-refed-uids uids)
|
(reset! all-refed-uids uids)
|
||||||
(doseq [uid uids]
|
(doseq [uid uids]
|
||||||
(swap! uid->uuid assoc uid (medley/random-uuid))))))
|
(swap! uid->uuid assoc uid (random-uuid))))))
|
||||||
|
|
||||||
(defn transform
|
(defn transform
|
||||||
[text]
|
[text]
|
||||||
|
@ -76,7 +75,7 @@
|
||||||
(defn child->text
|
(defn child->text
|
||||||
[{:keys [uid string children]} level]
|
[{:keys [uid string children]} level]
|
||||||
(when-not (and (get @uid->uuid uid) uid)
|
(when-not (and (get @uid->uuid uid) uid)
|
||||||
(swap! uid->uuid assoc uid (medley/random-uuid)))
|
(swap! uid->uuid assoc uid (random-uuid)))
|
||||||
(let [children-text (children->text children (inc level))
|
(let [children-text (children->text children (inc level))
|
||||||
level-pattern (str (apply str (repeat level "\t"))
|
level-pattern (str (apply str (repeat level "\t"))
|
||||||
(if (zero? level)
|
(if (zero? level)
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
[goog.dom.classes :as gdom-classes]
|
[goog.dom.classes :as gdom-classes]
|
||||||
[goog.object :as gobj]
|
[goog.object :as gobj]
|
||||||
[lambdaisland.glogi :as log]
|
[lambdaisland.glogi :as log]
|
||||||
[medley.core :as medley]
|
|
||||||
[promesa.core :as p]
|
[promesa.core :as p]
|
||||||
[frontend.util.keycode :as keycode]
|
[frontend.util.keycode :as keycode]
|
||||||
[logseq.graph-parser.util :as gp-util]
|
[logseq.graph-parser.util :as gp-util]
|
||||||
|
@ -256,10 +255,9 @@
|
||||||
|
|
||||||
(defn- another-block-with-same-id-exists?
|
(defn- another-block-with-same-id-exists?
|
||||||
[current-id block-id]
|
[current-id block-id]
|
||||||
(and (string? block-id)
|
(when-let [id (and (string? block-id) (parse-uuid block-id))]
|
||||||
(util/uuid-string? block-id)
|
(and (not= current-id id)
|
||||||
(not= current-id (cljs.core/uuid block-id))
|
(db/entity [:block/uuid id]))))
|
||||||
(db/entity [:block/uuid (cljs.core/uuid block-id)])))
|
|
||||||
|
|
||||||
(defn- attach-page-properties-if-exists!
|
(defn- attach-page-properties-if-exists!
|
||||||
[block]
|
[block]
|
||||||
|
@ -481,14 +479,9 @@
|
||||||
(defn- block-self-alone-when-insert?
|
(defn- block-self-alone-when-insert?
|
||||||
[config uuid]
|
[config uuid]
|
||||||
(let [current-page (state/get-current-page)
|
(let [current-page (state/get-current-page)
|
||||||
block-id (or
|
block-id (or (some-> (:id config) parse-uuid)
|
||||||
(and (:id config)
|
(some-> current-page parse-uuid))]
|
||||||
(util/uuid-string? (:id config))
|
(= uuid block-id)))
|
||||||
(:id config))
|
|
||||||
(and current-page
|
|
||||||
(util/uuid-string? current-page)
|
|
||||||
current-page))]
|
|
||||||
(= uuid (and block-id (medley/uuid block-id)))))
|
|
||||||
|
|
||||||
(defn insert-new-block-before-block-aux!
|
(defn insert-new-block-before-block-aux!
|
||||||
[config block _value {:keys [ok-handler]}]
|
[config block _value {:keys [ok-handler]}]
|
||||||
|
@ -1175,10 +1168,7 @@
|
||||||
[]
|
[]
|
||||||
(if (state/editing?)
|
(if (state/editing?)
|
||||||
(let [page (state/get-current-page)
|
(let [page (state/get-current-page)
|
||||||
block-id (and
|
block-id (and (string? page) (parse-uuid page))]
|
||||||
(string? page)
|
|
||||||
(util/uuid-string? page)
|
|
||||||
(medley/uuid page))]
|
|
||||||
(when block-id
|
(when block-id
|
||||||
(let [block-parent (db/get-block-parent block-id)]
|
(let [block-parent (db/get-block-parent block-id)]
|
||||||
(if-let [id (and
|
(if-let [id (and
|
||||||
|
@ -2042,8 +2032,8 @@
|
||||||
(defn- last-top-level-child?
|
(defn- last-top-level-child?
|
||||||
[{:keys [id]} current-node]
|
[{:keys [id]} current-node]
|
||||||
(when id
|
(when id
|
||||||
(when-let [entity (if (util/uuid-string? (str id))
|
(when-let [entity (if-let [id' (parse-uuid (str id))]
|
||||||
(db/entity [:block/uuid (uuid id)])
|
(db/entity [:block/uuid id'])
|
||||||
(db/entity [:block/name (util/page-name-sanity-lc id)]))]
|
(db/entity [:block/name (util/page-name-sanity-lc id)]))]
|
||||||
(= (:block/uuid entity) (tree/-get-parent-id current-node)))))
|
(= (:block/uuid entity) (tree/-get-parent-id current-node)))))
|
||||||
|
|
||||||
|
@ -3110,7 +3100,7 @@
|
||||||
(when-let [block-id (some-> (state/get-selection-blocks)
|
(when-let [block-id (some-> (state/get-selection-blocks)
|
||||||
first
|
first
|
||||||
(dom/attr "blockid")
|
(dom/attr "blockid")
|
||||||
medley/uuid)]
|
uuid)]
|
||||||
(util/stop e)
|
(util/stop e)
|
||||||
(let [block {:block/uuid block-id}
|
(let [block {:block/uuid block-id}
|
||||||
block-id (-> (state/get-selection-blocks)
|
block-id (-> (state/get-selection-blocks)
|
||||||
|
@ -3222,8 +3212,7 @@
|
||||||
:or {collapse? false expanded? false incremental? true root-block nil}}]
|
:or {collapse? false expanded? false incremental? true root-block nil}}]
|
||||||
(when-let [page (or (state/get-current-page)
|
(when-let [page (or (state/get-current-page)
|
||||||
(date/today))]
|
(date/today))]
|
||||||
(let [block? (util/uuid-string? page)
|
(let [block-id (or root-block (parse-uuid page))
|
||||||
block-id (or root-block (and block? (uuid page)))
|
|
||||||
blocks (if block-id
|
blocks (if block-id
|
||||||
(db/get-block-and-children (state/get-current-repo) block-id)
|
(db/get-block-and-children (state/get-current-repo) block-id)
|
||||||
(db/get-page-blocks-no-cache page))
|
(db/get-page-blocks-no-cache page))
|
||||||
|
@ -3320,7 +3309,7 @@
|
||||||
(->> (get-selected-blocks)
|
(->> (get-selected-blocks)
|
||||||
(map (fn [dom]
|
(map (fn [dom]
|
||||||
(-> (dom/attr dom "blockid")
|
(-> (dom/attr dom "blockid")
|
||||||
medley/uuid
|
uuid
|
||||||
expand-block!)))
|
expand-block!)))
|
||||||
doall)
|
doall)
|
||||||
(and clear-selection? (clear-selection!)))
|
(and clear-selection? (clear-selection!)))
|
||||||
|
@ -3353,7 +3342,7 @@
|
||||||
(->> (get-selected-blocks)
|
(->> (get-selected-blocks)
|
||||||
(map (fn [dom]
|
(map (fn [dom]
|
||||||
(-> (dom/attr dom "blockid")
|
(-> (dom/attr dom "blockid")
|
||||||
medley/uuid
|
uuid
|
||||||
collapse-block!)))
|
collapse-block!)))
|
||||||
doall)
|
doall)
|
||||||
(and clear-selection? (clear-selection!)))
|
(and clear-selection? (clear-selection!)))
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
[frontend.state :as state]
|
[frontend.state :as state]
|
||||||
[logseq.graph-parser.text :as text]
|
[logseq.graph-parser.text :as text]
|
||||||
[frontend.util :as util]
|
[frontend.util :as util]
|
||||||
[medley.core :as medley]
|
|
||||||
[reitit.frontend.easy :as rfe]))
|
[reitit.frontend.easy :as rfe]))
|
||||||
|
|
||||||
(defn redirect!
|
(defn redirect!
|
||||||
|
@ -80,7 +79,7 @@
|
||||||
(let [name (:name path-params)
|
(let [name (:name path-params)
|
||||||
block? (util/uuid-string? name)]
|
block? (util/uuid-string? name)]
|
||||||
(if block?
|
(if block?
|
||||||
(if-let [block (db/entity [:block/uuid (medley/uuid name)])]
|
(if-let [block (db/entity [:block/uuid (uuid name)])]
|
||||||
(let [content (text/remove-level-spaces (:block/content block)
|
(let [content (text/remove-level-spaces (:block/content block)
|
||||||
(:block/format block) (config/get-block-pattern (:block/format block)))]
|
(:block/format block) (config/get-block-pattern (:block/format block)))]
|
||||||
(if (> (count content) 48)
|
(if (> (count content) 48)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
(ns frontend.modules.outliner.tree
|
(ns frontend.modules.outliner.tree
|
||||||
(:require [frontend.db :as db]
|
(:require [frontend.db :as db]
|
||||||
[frontend.util :as util]
|
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[frontend.state :as state]))
|
[frontend.state :as state]))
|
||||||
|
|
||||||
|
@ -45,8 +44,8 @@
|
||||||
(defn- get-root-and-page
|
(defn- get-root-and-page
|
||||||
[repo root-id]
|
[repo root-id]
|
||||||
(if (string? root-id)
|
(if (string? root-id)
|
||||||
(if (util/uuid-string? root-id)
|
(if-let [id (parse-uuid root-id)]
|
||||||
[false (db/entity repo [:block/uuid (uuid root-id)])]
|
[false (db/entity repo [:block/uuid id])]
|
||||||
[true (db/entity repo [:block/name (string/lower-case root-id)])])
|
[true (db/entity repo [:block/name (string/lower-case root-id)])])
|
||||||
[false root-id]))
|
[false root-id]))
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
[frontend.util :as util]
|
[frontend.util :as util]
|
||||||
[goog.events :as events]
|
[goog.events :as events]
|
||||||
[goog.ui.KeyboardShortcutHandler.EventType :as EventType]
|
[goog.ui.KeyboardShortcutHandler.EventType :as EventType]
|
||||||
[lambdaisland.glogi :as log]
|
[lambdaisland.glogi :as log])
|
||||||
[medley.core :as medley])
|
|
||||||
(:import [goog.events KeyCodes KeyHandler KeyNames]
|
(:import [goog.events KeyCodes KeyHandler KeyNames]
|
||||||
[goog.ui KeyboardShortcutHandler]))
|
[goog.ui KeyboardShortcutHandler]))
|
||||||
|
|
||||||
|
@ -117,7 +116,7 @@
|
||||||
dispatch-fn (get shortcut-map (keyword (.-identifier e)))]
|
dispatch-fn (get shortcut-map (keyword (.-identifier e)))]
|
||||||
;; trigger fn
|
;; trigger fn
|
||||||
(when dispatch-fn (dispatch-fn e))))
|
(when dispatch-fn (dispatch-fn e))))
|
||||||
install-id (medley/random-uuid)
|
install-id (random-uuid)
|
||||||
data {install-id
|
data {install-id
|
||||||
{:group handler-id
|
{:group handler-id
|
||||||
:dispatch-fn f
|
:dispatch-fn f
|
||||||
|
|
|
@ -32,11 +32,9 @@
|
||||||
[frontend.loader :as loader]
|
[frontend.loader :as loader]
|
||||||
[goog.dom :as gdom]
|
[goog.dom :as gdom]
|
||||||
[lambdaisland.glogi :as log]
|
[lambdaisland.glogi :as log]
|
||||||
[medley.core :as medley]
|
|
||||||
[promesa.core :as p]
|
[promesa.core :as p]
|
||||||
[reitit.frontend.easy :as rfe]
|
[reitit.frontend.easy :as rfe]
|
||||||
[sci.core :as sci]
|
[sci.core :as sci]
|
||||||
[logseq.graph-parser.util :as gp-util]
|
|
||||||
[frontend.version :as fv]
|
[frontend.version :as fv]
|
||||||
[frontend.handler.shell :as shell]
|
[frontend.handler.shell :as shell]
|
||||||
[frontend.modules.layout.core]))
|
[frontend.modules.layout.core]))
|
||||||
|
@ -442,11 +440,11 @@
|
||||||
|
|
||||||
(defn ^:export open_in_right_sidebar
|
(defn ^:export open_in_right_sidebar
|
||||||
[block-uuid]
|
[block-uuid]
|
||||||
(editor-handler/open-block-in-sidebar! (medley/uuid block-uuid)))
|
(editor-handler/open-block-in-sidebar! (uuid block-uuid)))
|
||||||
|
|
||||||
(def ^:export edit_block
|
(def ^:export edit_block
|
||||||
(fn [block-uuid ^js opts]
|
(fn [block-uuid ^js opts]
|
||||||
(when-let [block-uuid (and block-uuid (medley/uuid block-uuid))]
|
(when-let [block-uuid (and block-uuid (uuid block-uuid))]
|
||||||
(when-let [block (db-model/query-block-by-uuid block-uuid)]
|
(when-let [block (db-model/query-block-by-uuid block-uuid)]
|
||||||
(let [{:keys [pos] :or {pos :max}} (bean/->clj opts)]
|
(let [{:keys [pos] :or {pos :max}} (bean/->clj opts)]
|
||||||
(editor-handler/edit-block! block pos block-uuid))))))
|
(editor-handler/edit-block! block pos block-uuid))))))
|
||||||
|
@ -455,7 +453,7 @@
|
||||||
(fn [block-uuid-or-page-name content ^js opts]
|
(fn [block-uuid-or-page-name content ^js opts]
|
||||||
(let [{:keys [before sibling isPageBlock properties]} (bean/->clj opts)
|
(let [{:keys [before sibling isPageBlock properties]} (bean/->clj opts)
|
||||||
page-name (and isPageBlock block-uuid-or-page-name)
|
page-name (and isPageBlock block-uuid-or-page-name)
|
||||||
block-uuid (if isPageBlock nil (medley/uuid block-uuid-or-page-name))
|
block-uuid (if isPageBlock nil (uuid block-uuid-or-page-name))
|
||||||
new-block (editor-handler/api-insert-new-block!
|
new-block (editor-handler/api-insert-new-block!
|
||||||
content
|
content
|
||||||
{:block-uuid block-uuid
|
{:block-uuid block-uuid
|
||||||
|
@ -480,7 +478,7 @@
|
||||||
(let [includeChildren true
|
(let [includeChildren true
|
||||||
repo (state/get-current-repo)]
|
repo (state/get-current-repo)]
|
||||||
(editor-handler/delete-block-aux!
|
(editor-handler/delete-block-aux!
|
||||||
{:block/uuid (medley/uuid block-uuid) :repo repo} includeChildren)
|
{:block/uuid (uuid block-uuid) :repo repo} includeChildren)
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
(def ^:export update_block
|
(def ^:export update_block
|
||||||
|
@ -490,7 +488,7 @@
|
||||||
editing? (and edit-input (string/ends-with? edit-input block-uuid))]
|
editing? (and edit-input (string/ends-with? edit-input block-uuid))]
|
||||||
(if editing?
|
(if editing?
|
||||||
(state/set-edit-content! edit-input content)
|
(state/set-edit-content! edit-input content)
|
||||||
(editor-handler/save-block! repo (medley/uuid block-uuid) content))
|
(editor-handler/save-block! repo (uuid block-uuid) content))
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
(def ^:export move_block
|
(def ^:export move_block
|
||||||
|
@ -505,8 +503,8 @@
|
||||||
|
|
||||||
:else
|
:else
|
||||||
nil)
|
nil)
|
||||||
src-block (db-model/query-block-by-uuid (medley/uuid src-block-uuid))
|
src-block (db-model/query-block-by-uuid (uuid src-block-uuid))
|
||||||
target-block (db-model/query-block-by-uuid (medley/uuid target-block-uuid))]
|
target-block (db-model/query-block-by-uuid (uuid target-block-uuid))]
|
||||||
(editor-dnd-handler/move-blocks nil [src-block] target-block move-to) nil)))
|
(editor-dnd-handler/move-blocks nil [src-block] target-block move-to) nil)))
|
||||||
|
|
||||||
(def ^:export get_block
|
(def ^:export get_block
|
||||||
|
@ -565,11 +563,11 @@
|
||||||
|
|
||||||
(def ^:export upsert_block_property
|
(def ^:export upsert_block_property
|
||||||
(fn [block-uuid key value]
|
(fn [block-uuid key value]
|
||||||
(editor-handler/set-block-property! (medley/uuid block-uuid) key value)))
|
(editor-handler/set-block-property! (uuid block-uuid) key value)))
|
||||||
|
|
||||||
(def ^:export remove_block_property
|
(def ^:export remove_block_property
|
||||||
(fn [block-uuid key]
|
(fn [block-uuid key]
|
||||||
(editor-handler/remove-block-property! (medley/uuid block-uuid) key)))
|
(editor-handler/remove-block-property! (uuid block-uuid) key)))
|
||||||
|
|
||||||
(def ^:export get_block_property
|
(def ^:export get_block_property
|
||||||
(fn [block-uuid key]
|
(fn [block-uuid key]
|
||||||
|
@ -637,7 +635,7 @@
|
||||||
|
|
||||||
(defn ^:export prepend_block_in_page
|
(defn ^:export prepend_block_in_page
|
||||||
[uuid-or-page-name content ^js opts]
|
[uuid-or-page-name content ^js opts]
|
||||||
(let [page? (not (gp-util/uuid-string? uuid-or-page-name))
|
(let [page? (not (util/uuid-string? uuid-or-page-name))
|
||||||
page-not-exist? (and page? (nil? (db-model/get-page 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
|
_ (and page-not-exist? (page-handler/create! uuid-or-page-name
|
||||||
{:redirect? false
|
{:redirect? false
|
||||||
|
@ -653,7 +651,7 @@
|
||||||
|
|
||||||
(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]
|
||||||
(let [page? (not (gp-util/uuid-string? uuid-or-page-name))
|
(let [page? (not (util/uuid-string? uuid-or-page-name))
|
||||||
page-not-exist? (and page? (nil? (db-model/get-page 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
|
_ (and page-not-exist? (page-handler/create! uuid-or-page-name
|
||||||
{:redirect? false
|
{:redirect? false
|
||||||
|
|
|
@ -129,8 +129,7 @@
|
||||||
|
|
||||||
:else
|
:else
|
||||||
nil)]
|
nil)]
|
||||||
(when (and block-id
|
(when (some-> block-id parse-uuid)
|
||||||
(gp-util/uuid-string? block-id))
|
|
||||||
block-id)))
|
block-id)))
|
||||||
|
|
||||||
(defn- paragraph-block?
|
(defn- paragraph-block?
|
||||||
|
@ -325,12 +324,10 @@
|
||||||
(swap! ref-blocks conj block))
|
(swap! ref-blocks conj block))
|
||||||
form)
|
form)
|
||||||
(concat title body))
|
(concat title body))
|
||||||
(let [ref-blocks (->> @ref-blocks
|
(let [ref-blocks (keep (fn [block]
|
||||||
(filter gp-util/uuid-string?))
|
(when-let [id (parse-uuid block)]
|
||||||
ref-blocks (map
|
[:block/uuid id]))
|
||||||
(fn [id]
|
@ref-blocks)
|
||||||
[:block/uuid (uuid id)])
|
|
||||||
ref-blocks)
|
|
||||||
refs (distinct (concat (:refs block) ref-blocks))]
|
refs (distinct (concat (:refs block) ref-blocks))]
|
||||||
(assoc block :refs refs))))
|
(assoc block :refs refs))))
|
||||||
|
|
||||||
|
@ -430,8 +427,7 @@
|
||||||
(get-in properties [:properties :custom_id])
|
(get-in properties [:properties :custom_id])
|
||||||
(get-in properties [:properties :id]))]
|
(get-in properties [:properties :id]))]
|
||||||
(let [custom-id (and (string? custom-id) (string/trim custom-id))]
|
(let [custom-id (and (string? custom-id) (string/trim custom-id))]
|
||||||
(when (and custom-id (gp-util/uuid-string? custom-id))
|
(some-> custom-id parse-uuid)))
|
||||||
(uuid custom-id))))
|
|
||||||
(d/squuid)))
|
(d/squuid)))
|
||||||
|
|
||||||
(defn get-page-refs-from-properties
|
(defn get-page-refs-from-properties
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
(:require [clojure.walk :as walk]
|
(:require [clojure.walk :as walk]
|
||||||
[clojure.string :as string]))
|
[clojure.string :as string]))
|
||||||
|
|
||||||
(def uuid-pattern "[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}")
|
|
||||||
(defonce exactly-uuid-pattern (re-pattern (str "(?i)^" uuid-pattern "$")))
|
|
||||||
|
|
||||||
(defn safe-re-find
|
(defn safe-re-find
|
||||||
"Copy of frontend.util/safe-re-find. Too basic to couple to main app"
|
"Copy of frontend.util/safe-re-find. Too basic to couple to main app"
|
||||||
[pattern s]
|
[pattern s]
|
||||||
|
@ -16,11 +13,6 @@
|
||||||
(when (string? s)
|
(when (string? s)
|
||||||
(re-find pattern s)))
|
(re-find pattern s)))
|
||||||
|
|
||||||
(defn uuid-string?
|
|
||||||
"Copy of frontend.util/uuid-string?. Too basic to couple to main app"
|
|
||||||
[s]
|
|
||||||
(safe-re-find exactly-uuid-pattern s))
|
|
||||||
|
|
||||||
(defn path-normalize
|
(defn path-normalize
|
||||||
"Normalize file path (for reading paths from FS, not required by writting)"
|
"Normalize file path (for reading paths from FS, not required by writting)"
|
||||||
[s]
|
[s]
|
||||||
|
|
|
@ -721,10 +721,10 @@
|
||||||
resolved "https://registry.yarnpkg.com/@kanru/rage-wasm/-/rage-wasm-0.2.1.tgz#dd8fdd3133992c42bf68c0086d8cad40a13bc329"
|
resolved "https://registry.yarnpkg.com/@kanru/rage-wasm/-/rage-wasm-0.2.1.tgz#dd8fdd3133992c42bf68c0086d8cad40a13bc329"
|
||||||
integrity sha512-sYi4F2mL6Mpcz7zbS4myasw11xLBEbgZkDMRVg9jNxTKt6Ct/LT7/vCHDmEzAFcPcPqixD5De6Ql3bJijAX0/w==
|
integrity sha512-sYi4F2mL6Mpcz7zbS4myasw11xLBEbgZkDMRVg9jNxTKt6Ct/LT7/vCHDmEzAFcPcPqixD5De6Ql3bJijAX0/w==
|
||||||
|
|
||||||
"@logseq/nbb-logseq@^0.3.99":
|
"@logseq/nbb-logseq@^0.5.103":
|
||||||
version "0.3.99"
|
version "0.5.103"
|
||||||
resolved "https://registry.yarnpkg.com/@logseq/nbb-logseq/-/nbb-logseq-0.3.99.tgz#cf6c05c559963e4e0fb92f214a63228972ef87d3"
|
resolved "https://registry.yarnpkg.com/@logseq/nbb-logseq/-/nbb-logseq-0.5.103.tgz#1084380cd54c92ca8cc94a8934cc777206e45cc0"
|
||||||
integrity sha512-Msa6Ck6wqt7sYGExQZgUT/uUG/z5jGaPlytVdgGkCrVogZb2yaChbWeMOCfCsCTi6kbHo15hC3aOeDAXcfnFzw==
|
integrity sha512-V9UW0XrCaaadHUc6/Hp9wfGpQqkzqzoqnDGeSVZkWR6l3QwyqGi9mkhnhVcfTwAvxIfOgrfz93GcaeepV4pYNA==
|
||||||
dependencies:
|
dependencies:
|
||||||
import-meta-resolve "^1.1.1"
|
import-meta-resolve "^1.1.1"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue