[Feature Request] Extend Plugin API for full ontology import/export parity in DB graphs
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- typescript
- 领域
- api
调研方向
从 issue 中列出的 @logseq/libs 入口点开始:setBlockIcon、upsertProperty、upsertBlockProperty 和 createTag。阅读 docs/api-field-reconciliation.md,并复现其中记录的 DB 图导入/导出缺口;当所请求的本体字段(包括 emoji 图标、closedValues、标题、datetime 和 position)可以通过插件 API 往返传递时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Problem Statement
The Plugin API for DB graphs does not support all fields that Logseq exports in its native EDN format. This prevents plugins from implementing complete ontology import/export functionality.
When users export ontology from a DB graph and attempt to re-import it via a plugin, some data is lost:
| Data Type | Fields in EDN Export | Fields Settable via API | Lost on Import |
|---|---|---|---|
| Properties | 14 | 10 | 4 fields (29%) |
| Classes/Tags | 7 | 6 | 1 field (14%) |
What Works (Discovered Feb 2025)
Through extensive console testing, we discovered workarounds for several fields:
System Description Field
Using the full namespaced key with upsertBlockProperty sets the system description:
// ❌ WRONG - creates a user property named "description"
await logseq.Editor.upsertBlockProperty(uuid, 'description', 'My description')
// ✅ CORRECT - sets the system logseq.property/description field
await logseq.Editor.upsertBlockProperty(uuid, ':logseq.property/description', 'My description')
The value is stored as an entity reference (Logseq creates a new entity containing the text).
Tabler Icons on Properties and Tags
setBlockIcon() works for Tabler icons on properties and tags:
// ✅ Works - Tabler icon on property
const prop = await logseq.Editor.getProperty('my-property')
await logseq.Editor.setBlockIcon(prop.uuid, 'tabler-icon', 'star')
// ✅ Works - Tabler icon on tag
const tag = await logseq.Editor.getTag('MyTag')
await logseq.Editor.setBlockIcon(tag.uuid, 'tabler-icon', 'folder')
What Doesn't Work
Emoji Icons - Lookup Table Inaccessible
setBlockIcon() fails for all emoji formats:
await logseq.Editor.setBlockIcon(uuid, 'emoji', 'rocket') // ❌ "Can't find emoji for rocket"
await logseq.Editor.setBlockIcon(uuid, 'emoji', '🚀') // ❌ "Can't find emoji for 🚀"
await logseq.Editor.setBlockIcon(uuid, 'emoji', ':rocket:') // ❌ "Can't find emoji for :rocket:"
Root cause: Logseq's emoji lookup table is internal and not accessible to plugins. The EDN export shows emojis stored with numeric IDs (e.g., {:type :emoji, :id "100"}) but there's no way for plugins to discover or use these IDs.
Class/Tag Title - Ownership Restriction
Attempting to set :logseq.class/title fails:
await logseq.Editor.upsertBlockProperty(tagUuid, ':logseq.class/title', 'My Display Title')
// ❌ Error: "Plugins can only upsert its own properties"
Unlike :logseq.property/description which works, the title field is blocked.
Remaining Fields Not Settable via Plugin API
Properties
| Missing Field | Impact |
|---|---|
| icon (emoji only) | Cannot set emoji icons (Tabler icons work) |
| closedValues | Cannot create enum/choice/select properties |
| datetime type | Must downgrade to date (loses time component) |
| position | Cannot control UI ordering |
| default | Cannot set default values |
Classes/Tags
| Missing Field | Impact |
|---|---|
| icon (emoji only) | Cannot set emoji icons (Tabler icons work) |
| title | Cannot set display name (blocked by ownership restriction) |
| position | Cannot control UI ordering |
Use Case
I'm building an ontology import plugin that allows users to:
- Export ontology definitions from one DB graph
- Share them via a marketplace/repository
- Import them into another DB graph
Currently, imported ontologies lose emoji icons, enum configurations (closedValues), and display titles. Tabler icons and descriptions now import successfully.
Proposed Solutions
1. Expose emoji lookup or accept emoji characters directly
Either:
- Option A: Accept emoji characters directly in
setBlockIcon:setBlockIcon(uuid, 'emoji', '🚀') - Option B: Accept standard emoji names:
setBlockIcon(uuid, 'emoji', 'rocket') - Option C: Document the emoji ID format so plugins can use it
2. Add closedValues support to upsertProperty
upsertProperty(key: string, schema?: {
// Existing fields...
// Requested addition
closedValues?: Array<{
value: string;
icon?: { type: "emoji" | "tabler-icon"; id: string };
description?: string;
}>;
}): Promise<IEntityID>
3. Allow setting class/tag title
Either remove the ownership restriction for :logseq.class/title or add it to the createTag options:
createTag(name: string, opts?: {
uuid?: string; // Existing
title?: string; // Requested
}): Promise<PageEntity>
4. Add datetime property type
Currently datetime must be downgraded to date, losing the time component.
Priority Ranking
- 🔴 Critical: Fix emoji icon setting (expose lookup or accept characters) - Icons are the primary visual identity of ontology elements; losing them during import significantly degrades the user experience
- 🔴 Critical: Add
closedValuessupport toupsertProperty- Required for enum/select properties - 🟡 Medium: Allow setting class/tag title
- 🟡 Medium: Add
datetimeproperty type - 🟢 Low: Add
positionto schema APIs
Environment
- Logseq version: 2.0.0 (DB graph mode)
- Platform: Windows
- Plugin API version: @logseq/libs latest
What We Learned (Testing Details)
For reference, here's what we discovered through console testing:
| Feature | Method | Status |
|---|---|---|
| System Description | upsertBlockProperty(uuid, ':logseq.property/description', text) |
✅ Works |
| Tabler Icons | setBlockIcon(uuid, 'tabler-icon', 'iconName') |
✅ Works |
| Emoji Icons | setBlockIcon(uuid, 'emoji', ...) |
❌ All formats fail |
| Class Title | upsertBlockProperty(uuid, ':logseq.class/title', text) |
❌ Ownership blocked |
| Icon via upsertBlockProperty | upsertBlockProperty(uuid, ':logseq.property/icon', {...}) |
❌ Renders "Invalid icon" |
Key insight: setBlockIcon stores icons as {type: 'tablerIcon', id: 'name'} (camelCase), but setting this format directly via upsertBlockProperty still renders as "Invalid icon" - there's internal processing in setBlockIcon that can't be replicated.
Additional Context
Full field-by-field reconciliation available here: API Field Reconciliation Document
This enhancement would enable a richer ecosystem of ontology sharing and template plugins for DB graphs.
- 主要语言
- HTML
- 星标
- 26
- 派生
- 8
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
logseq/plugins 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 35/100
-
难度 2/5 1-3 小时 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 2/5 1-3 小时 新手友好度 25/100
-
难度 2/5 1-3 小时 新手友好度 25/100
相似的 Issue
-
Area: Excel support
难度 2/5 1-3 小时 新手友好度 75/100
orbeon/orbeon-forms#7893 ·
-
essnmx good first issue
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 75/100
yeti-platform/yeti#1380 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
modelcontextprotocol/python-sdk#3566 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
griptape-ai/griptape#2353 ·