mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 14:14:55 +00:00
enhances(apis): add apis for retrieving tags by name
This commit is contained in:
@@ -771,6 +771,7 @@ export interface IEditorProxy extends Record<string, any> {
|
||||
getTagObjects: (nameOrIdent: string) => Promise<BlockEntity[] | null>
|
||||
createTag: (tagName: string, opts?: Partial<{ uuid: string }>) => Promise<PageEntity | null>
|
||||
getTag: (nameOrIdent: string | EntityID) => Promise<PageEntity | null>
|
||||
getTagsByName: (tagName: string) => Promise<Array<PageEntity> | null>
|
||||
addTagProperty: (tagId: BlockIdentity, propertyIdOrName: BlockIdentity) => Promise<void>
|
||||
removeTagProperty: (tagId: BlockIdentity, propertyIdOrName: BlockIdentity) => Promise<void>
|
||||
addTagExtends: (tagId: BlockIdentity, parentTagIdOrName: BlockIdentity) => Promise<void>
|
||||
|
||||
@@ -204,6 +204,7 @@
|
||||
(def ^:export get_tag_objects db-based-api/get-tag-objects)
|
||||
(def ^:export create_tag db-based-api/create-tag)
|
||||
(def ^:export get_tag db-based-api/get-tag)
|
||||
(def ^:export get_tags_by_name db-based-api/get-tags-by-name)
|
||||
(def ^:export add_tag_extends db-based-api/add-tag-extends)
|
||||
(def ^:export remove_tag_extends db-based-api/remove-tag-extends)
|
||||
(def ^:export add_block_tag db-based-api/add-block-tag)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
[clojure.walk :as walk]
|
||||
[datascript.core :as d]
|
||||
[frontend.db :as db]
|
||||
[frontend.db.conn :as db-conn]
|
||||
[frontend.db.async :as db-async]
|
||||
[frontend.db.model :as db-model]
|
||||
[frontend.handler.common.page :as page-common-handler]
|
||||
@@ -17,6 +18,7 @@
|
||||
[frontend.modules.layout.core]
|
||||
[frontend.state :as state]
|
||||
[frontend.util :as util]
|
||||
[logseq.db.frontend.entity-util :as entity-util]
|
||||
[goog.object :as gobj]
|
||||
[logseq.api.block :as api-block]
|
||||
[logseq.db :as ldb]
|
||||
@@ -272,6 +274,12 @@
|
||||
(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)
|
||||
(map #(some-> % (first) (db/entity)))
|
||||
(filter ldb/class?))]
|
||||
(sdk-utils/result->js tags)))
|
||||
|
||||
(defn tag-add-property [tag-id property-id-or-name]
|
||||
(p/let [tag (db/get-case-page tag-id)
|
||||
property (db/get-case-page property-id-or-name)]
|
||||
|
||||
Reference in New Issue
Block a user