Skip to content

Commit ecea61a

Browse files
committed
1 parent 8dc4d88 commit ecea61a

File tree

4 files changed

+78
-7
lines changed

4 files changed

+78
-7
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## 0.8.4 2023-09
44

5+
* [Add plugin function `transaction`](https://github.com/siyuan-note/siyuan/issues/9172)
6+
* [Add `CustomEvent` type definition](https://github.com/siyuan-note/petal/pull/15)
7+
58
## 0.8.3 2023-09-05
69

710
* [Plugin API add openWindow and command.globalCallback](https://github.com/siyuan-note/siyuan/issues/9032)

siyuan.d.ts

+69-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import type * as types from "./types";
2+
import {IProtyle} from "./types/protyle";
23

34
declare global {
4-
interface Window extends Global { }
5+
interface Window extends Global {
6+
}
57
}
68

79
type TEventBus = keyof IEventBusMap
@@ -23,6 +25,51 @@ type TProtyleAction = "cb-get-append" | // 向下滚动加载
2325
"cb-get-html" | // 直接渲染,不需要再 /api/block/getDocInfo,否则搜索表格无法定位
2426
"cb-get-history" // 历史渲染
2527

28+
type TOperation =
29+
"insert"
30+
| "update"
31+
| "delete"
32+
| "move"
33+
| "foldHeading"
34+
| "unfoldHeading"
35+
| "setAttrs"
36+
| "updateAttrs"
37+
| "append"
38+
| "insertAttrViewBlock"
39+
| "removeAttrViewBlock"
40+
| "addAttrViewCol"
41+
| "removeAttrViewCol"
42+
| "addFlashcards"
43+
| "removeFlashcards"
44+
| "updateAttrViewCell"
45+
| "updateAttrViewCol"
46+
| "sortAttrViewRow"
47+
| "sortAttrViewCol"
48+
| "setAttrViewColHidden"
49+
| "setAttrViewColWrap"
50+
| "setAttrViewColWidth"
51+
| "updateAttrViewColOptions"
52+
| "removeAttrViewColOption"
53+
| "updateAttrViewColOption"
54+
| "setAttrViewName"
55+
| "setAttrViewFilters"
56+
| "setAttrViewSorts"
57+
| "setAttrViewColCalc"
58+
| "updateAttrViewColNumberFormat"
59+
60+
type TAVCol =
61+
"text"
62+
| "date"
63+
| "number"
64+
| "relation"
65+
| "rollup"
66+
| "select"
67+
| "block"
68+
| "mSelect"
69+
| "url"
70+
| "email"
71+
| "phone"
72+
2673
interface Global {
2774
Lute: Lute;
2875
}
@@ -227,6 +274,25 @@ interface IProtyleOption {
227274
after?(protyle: Protyle): void;
228275
}
229276

277+
interface IOperation {
278+
action: TOperation, // move, delete 不需要传 data
279+
id?: string,
280+
avID?: string, // av
281+
format?: string // updateAttrViewColNumberFormat 专享
282+
keyID?: string // updateAttrViewCell 专享
283+
rowID?: string // updateAttrViewCell 专享
284+
data?: any, // updateAttr 时为 { old: IObject, new: IObject }, updateAttrViewCell 时为 {TAVCol: {content: string}}
285+
parentID?: string
286+
previousID?: string
287+
retData?: any
288+
nextID?: string // insert 专享
289+
srcIDs?: string[] // insertAttrViewBlock 专享
290+
name?: string // addAttrViewCol 专享
291+
type?: TAVCol // addAttrViewCol 专享
292+
deckID?: string // add/removeFlashcards 专享
293+
blockIDs?: string[] // add/removeFlashcards 专享
294+
}
295+
230296
export function fetchPost(url: string, data?: any, callback?: (response: IWebSocketData) => void, headers?: IObject): void;
231297

232298
export function fetchSyncPost(url: string, data?: any): Promise<IWebSocketData>;
@@ -293,6 +359,8 @@ export function confirm(title: string, text: string, confirmCallback?: (dialog:
293359
*/
294360
export function showMessage(text: string, timeout?: number, type?: "info" | "error", id?: string): void;
295361

362+
export function transaction(protyle: IProtyle, doOperations: IOperation[], undoOperations: IOperation[]): void;
363+
296364
export class App {
297365
plugins: Plugin[];
298366
}

types/events.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type siyuan from "./../siyuan";
21
import type { IProtyle } from "./protyle";
2+
import {Menu} from "./../siyuan";
33

44
//#region click-block-icon
55
interface IBlockIconDetail {
6-
menu: InstanceType<typeof siyuan.Menu>;
6+
menu: InstanceType<typeof Menu>;
77
protyle: IProtyle;
88
data?: IDocumentData;
99
blockElements?: HTMLElement[];
@@ -121,7 +121,7 @@ export interface IInputSearchDetail {
121121

122122
//#region open-menu
123123
interface IMenuBaseDetail {
124-
menu: InstanceType<typeof siyuan.Menu>;
124+
menu: InstanceType<typeof Menu>;
125125
protyle: IProtyle;
126126
}
127127

types/protyle.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type siyuan from "./../siyuan";
1+
import {App, Lute} from "./../siyuan";
22

33
// REF: https://github.com/siyuan-note/siyuan/blob/dev/app/src/types/protyle.d.ts
44
export interface IProtyle {
5-
app: any;
5+
app: App;
66
transactionTime: number;
77
id: string;
88
block: {
@@ -44,7 +44,7 @@ export interface IProtyle {
4444
};
4545
contentElement?: HTMLElement;
4646
options: any;
47-
lute?: siyuan.Lute;
47+
lute?: Lute;
4848
toolbar?: any;
4949
preview?: any;
5050
hint?: any;

0 commit comments

Comments
 (0)