@wetoria/siyuan-sdk 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -7
- package/dist/api/attr/index.d.ts +17 -12
- package/dist/api/attr/index.d.ts.map +1 -1
- package/dist/api/attr/index.js.map +1 -1
- package/dist/api/block/index.d.ts +57 -10
- package/dist/api/block/index.d.ts.map +1 -1
- package/dist/api/block/index.js +9 -6
- package/dist/api/block/index.js.map +1 -1
- package/dist/api/file/index.d.ts +11 -2
- package/dist/api/file/index.d.ts.map +1 -1
- package/dist/api/file/index.js.map +1 -1
- package/dist/api/notebook/index.d.ts +7 -3
- package/dist/api/notebook/index.d.ts.map +1 -1
- package/dist/api/notebook/index.js.map +1 -1
- package/dist/core/index.d.ts +23 -4
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +34 -0
- package/dist/core/index.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +54 -24
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/transaction/index.d.ts +39 -0
- package/dist/types/transaction/index.d.ts.map +1 -0
- package/dist/types/transaction/index.js +8 -0
- package/dist/types/transaction/index.js.map +1 -0
- package/package.json +1 -1
- package/src/api/attr/index.ts +24 -11
- package/src/api/block/index.ts +79 -20
- package/src/api/file/index.ts +11 -1
- package/src/api/notebook/index.ts +12 -3
- package/src/core/index.ts +57 -7
- package/src/index.ts +7 -0
- package/src/types/index.ts +85 -24
- package/src/types/transaction/index.ts +45 -0
package/src/types/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './transaction'
|
|
1
2
|
/**
|
|
2
3
|
* Frequently used data structures in SiYuan
|
|
3
4
|
*/
|
|
@@ -6,6 +7,7 @@ export type BlockId = string
|
|
|
6
7
|
export type NotebookId = string
|
|
7
8
|
export type PreviousID = BlockId
|
|
8
9
|
export type ParentID = BlockId | DocumentId
|
|
10
|
+
export type DataType = "markdown" | "dom"
|
|
9
11
|
|
|
10
12
|
export interface Notebook {
|
|
11
13
|
id: NotebookId
|
|
@@ -71,6 +73,70 @@ export type BlockSubType =
|
|
|
71
73
|
| "video"
|
|
72
74
|
| "other"
|
|
73
75
|
|
|
76
|
+
/**
|
|
77
|
+
* 块属性接口 - 可以手动修改的属性
|
|
78
|
+
* 注释掉的内容也存在,这里用于展示全部字段类型,但禁止手动修改
|
|
79
|
+
*/
|
|
80
|
+
export interface IBlockAttrs {
|
|
81
|
+
// 基础元数据属性
|
|
82
|
+
"name"?: string // 块名称
|
|
83
|
+
"alias"?: string // 块别名
|
|
84
|
+
"memo"?: string // 块备注
|
|
85
|
+
"bookmark"?: string // 书签
|
|
86
|
+
"tags"?: string // 标签(多个用逗号分隔)
|
|
87
|
+
|
|
88
|
+
// 显示控制属性
|
|
89
|
+
"fold"?: "1" | "" // 折叠状态
|
|
90
|
+
"heading-fold"?: "1" | "" // 标题折叠状态
|
|
91
|
+
"style"?: string // CSS 样式字符串
|
|
92
|
+
"scroll"?: string // 滚动位置(JSON 格式)
|
|
93
|
+
|
|
94
|
+
// 系统属性(通常不应手动修改,但可以设置)
|
|
95
|
+
"id"?: string // 块 ID(系统自动生成)
|
|
96
|
+
"title"?: string // 块标题(文档块使用)
|
|
97
|
+
"updated"?: string // 更新时间(系统自动维护)
|
|
98
|
+
"type"?: string // 块类型
|
|
99
|
+
"icon"?: string // 图标
|
|
100
|
+
"status"?: string // 状态
|
|
101
|
+
|
|
102
|
+
// 其他系统属性
|
|
103
|
+
"refcount"?: string // 引用计数
|
|
104
|
+
"parent-heading"?: string // 父标题 ID
|
|
105
|
+
"embed-content"?: string // 嵌入内容
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
// 属性视图相关
|
|
109
|
+
"custom-avs"?: string // 属性视图 ID 列表(逗号分隔)
|
|
110
|
+
"custom-avs-names"?: string // 属性视图名称
|
|
111
|
+
"data-av-type"?: string // 属性视图类型
|
|
112
|
+
|
|
113
|
+
// 闪卡相关
|
|
114
|
+
"custom-riff-decks"?: string // 闪卡牌组
|
|
115
|
+
|
|
116
|
+
// 日记相关
|
|
117
|
+
[key: `custom-dailynote-${string}`]: string
|
|
118
|
+
|
|
119
|
+
// 自定义属性(必须以 custom- 开头)
|
|
120
|
+
[key: `custom-${string}`]: string
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 允许设置的块属性类型
|
|
126
|
+
* 排除了系统自动维护的属性:id、updated、type、status、refcount、parent-heading、embed-content、scroll
|
|
127
|
+
*/
|
|
128
|
+
export type ISettableBlockAttrs = Omit<
|
|
129
|
+
IBlockAttrs,
|
|
130
|
+
"id"
|
|
131
|
+
| "updated"
|
|
132
|
+
| "type"
|
|
133
|
+
| "status"
|
|
134
|
+
| "refcount"
|
|
135
|
+
| "parent-heading"
|
|
136
|
+
| "embed-content"
|
|
137
|
+
| "scroll"
|
|
138
|
+
>
|
|
139
|
+
|
|
74
140
|
export interface Block {
|
|
75
141
|
id: BlockId
|
|
76
142
|
parent_id?: BlockId
|
|
@@ -90,7 +156,7 @@ export interface Block {
|
|
|
90
156
|
type: BlockType
|
|
91
157
|
subtype: BlockSubType
|
|
92
158
|
/**
|
|
93
|
-
*
|
|
159
|
+
* 块属性(Inline Attributes List)
|
|
94
160
|
* For instance: "{: custom-type=\"query-code\" id=\"20230613234017-zkw3pr0\" updated=\"20230613234509\"}"
|
|
95
161
|
*/
|
|
96
162
|
ial?: string
|
|
@@ -99,30 +165,7 @@ export interface Block {
|
|
|
99
165
|
updated: string
|
|
100
166
|
}
|
|
101
167
|
|
|
102
|
-
export interface doOperation {
|
|
103
|
-
action: string
|
|
104
|
-
data: string
|
|
105
|
-
id: BlockId
|
|
106
|
-
parentID: BlockId | DocumentId
|
|
107
|
-
previousID: BlockId
|
|
108
|
-
retData: null
|
|
109
|
-
}
|
|
110
168
|
|
|
111
|
-
declare global {
|
|
112
|
-
interface Window {
|
|
113
|
-
siyuan: {
|
|
114
|
-
notebooks: any
|
|
115
|
-
menus: any
|
|
116
|
-
dialogs: any
|
|
117
|
-
blockPanels: any
|
|
118
|
-
storage: any
|
|
119
|
-
user: any
|
|
120
|
-
ws: any
|
|
121
|
-
languages: any
|
|
122
|
-
config: import('siyuan').Config.IConf
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
169
|
|
|
127
170
|
export interface IBreadcrumb {
|
|
128
171
|
id: string
|
|
@@ -138,3 +181,21 @@ export interface backlinkData {
|
|
|
138
181
|
expand: boolean
|
|
139
182
|
}
|
|
140
183
|
|
|
184
|
+
/**
|
|
185
|
+
* 子块信息(用于 getChildBlocks 返回值)
|
|
186
|
+
*/
|
|
187
|
+
export interface ChildBlock {
|
|
188
|
+
id: BlockId
|
|
189
|
+
type: BlockType
|
|
190
|
+
content?: string
|
|
191
|
+
markdown?: string
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 块的 DOM 结构(用于 getBlockDOM 返回值)
|
|
196
|
+
*/
|
|
197
|
+
export interface BlockDOM {
|
|
198
|
+
dom: string
|
|
199
|
+
id: BlockId
|
|
200
|
+
}
|
|
201
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BlockId,
|
|
3
|
+
DocumentId,
|
|
4
|
+
} from '../index'
|
|
5
|
+
|
|
6
|
+
export enum ActionTypes {
|
|
7
|
+
insert = 'insert',
|
|
8
|
+
update = 'update',
|
|
9
|
+
delete = 'delete',
|
|
10
|
+
move = 'move',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface doOperation {
|
|
14
|
+
action: ActionTypes
|
|
15
|
+
data: string
|
|
16
|
+
id: BlockId
|
|
17
|
+
parentID: BlockId | DocumentId
|
|
18
|
+
previousID: BlockId
|
|
19
|
+
nextID?: string
|
|
20
|
+
retData: null
|
|
21
|
+
blockIDs?: string[] | null
|
|
22
|
+
blockID?: string
|
|
23
|
+
deckID?: string
|
|
24
|
+
avID?: string
|
|
25
|
+
srcIDs?: string[] | null
|
|
26
|
+
srcs?: string[] | null
|
|
27
|
+
isDetached?: boolean
|
|
28
|
+
ignoreFillFilter?: boolean
|
|
29
|
+
name?: string
|
|
30
|
+
type?: string
|
|
31
|
+
format?: string
|
|
32
|
+
keyID?: string
|
|
33
|
+
rowID?: string
|
|
34
|
+
isTwoWay?: boolean
|
|
35
|
+
backRelationKeyID?: string
|
|
36
|
+
removeDest?: boolean
|
|
37
|
+
layout?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
export interface TransactionItem {
|
|
42
|
+
timestamp: string
|
|
43
|
+
doOperations: doOperation[]
|
|
44
|
+
undoOperations: doOperation[] | null
|
|
45
|
+
}
|