diff --git a/src/main/logseq/api/db_based.cljs b/src/main/logseq/api/db_based.cljs index 59969c826d..cb3f9e23fd 100644 --- a/src/main/logseq/api/db_based.cljs +++ b/src/main/logseq/api/db_based.cljs @@ -258,23 +258,27 @@ :logseq.property.class/extends (:db/id extend)))) +(defn- resolve-tag-eid [this class-uuid-or-ident-or-title] + (let [eid (if (number? class-uuid-or-ident-or-title) + class-uuid-or-ident-or-title + (let [title-or-ident (-> (if-not (string? class-uuid-or-ident-or-title) + (str class-uuid-or-ident-or-title) + class-uuid-or-ident-or-title) + (string/replace #"^:+" ""))] + (if (text/namespace-page? title-or-ident) + (keyword title-or-ident) + (if (util/uuid-string? title-or-ident) + (when-let [id (sdk-utils/uuid-or-throw-error title-or-ident)] + [:block/uuid id]) + (keyword (api-block/resolve-class-prefix-for-db this) title-or-ident)))))] + eid)) + (defn get-tag [class-uuid-or-ident-or-title] (this-as this - (let [eid (if (number? class-uuid-or-ident-or-title) - class-uuid-or-ident-or-title - (let [title-or-ident (-> (if-not (string? class-uuid-or-ident-or-title) - (str class-uuid-or-ident-or-title) - class-uuid-or-ident-or-title) - (string/replace #"^:+" ""))] - (if (text/namespace-page? title-or-ident) - (keyword title-or-ident) - (if (util/uuid-string? title-or-ident) - (when-let [id (sdk-utils/uuid-or-throw-error title-or-ident)] - [:block/uuid id]) - (keyword (api-block/resolve-class-prefix-for-db this) title-or-ident))))) - tag (db/entity eid)] - (when (ldb/class? tag) - (sdk-utils/result->js tag))))) + (let [eid (resolve-tag-eid this class-uuid-or-ident-or-title) + tag (db/entity eid)] + (when (ldb/class? tag) + (sdk-utils/result->js tag))))) (defn get-tags-by-name [name] (when-let [tags (some->> (entity-util/get-pages-by-name (db-conn/get-db) name) @@ -304,25 +308,31 @@ (sdk-utils/result->js (db/get-case-page tag-id))))) (defn add-block-tag [id-or-name tag-id] - (p/let [repo (state/get-current-repo) - tag (db-async/emoji icon-name))) icon-name)}))) + (defn remove-block-icon [block-id] (p/let [repo (state/get-current-repo)