Skip to content

Commit e40ddbe

Browse files
committed
✨ Add the type of scrapbox.PageMenu
1 parent 726edf9 commit e40ddbe

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

scrapbox.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ export type Scrapbox =
2323
},
2424
) => void;
2525
};
26+
PageMenu: ((name: string) => PageMenu) & {
27+
addMenu: (
28+
props: { title: string; image: string; onClick?: () => void },
29+
) => void;
30+
addItem: (props: AddItemProps) => void;
31+
addSeparator: () => void;
32+
removeAllItems: () => void;
33+
};
2634
addListener: (type: string, listener: () => void) => void;
2735
on: (type: string, listener: () => void) => void;
2836
removeListener: (type: string, listener: () => void) => void;
@@ -91,6 +99,30 @@ type TimeStamp = {
9199
removeAllFormat: () => void;
92100
};
93101

102+
type AddItemProps = {
103+
title: string | (() => string);
104+
image?: string;
105+
onClick: () => void;
106+
};
107+
type PageMenu = {
108+
addItem: (
109+
props: AddItemProps,
110+
) => void;
111+
addSeparator: () => void;
112+
removeAllItems: () => void;
113+
menuName: string;
114+
reset: () => void;
115+
emitChange: () => void;
116+
menus: Map<
117+
string,
118+
{
119+
image: string | null;
120+
onClick?: () => void;
121+
items: (AddItemProps & { separator: boolean })[];
122+
}
123+
>;
124+
};
125+
94126
export type eventName =
95127
| "lines:changed"
96128
| "page:changed"

0 commit comments

Comments
 (0)