@@ -34,22 +34,8 @@ export type Scrapbox =
3434 addSeparator : ( ) => void ;
3535 removeAllItems : ( ) => void ;
3636 } ;
37- addListener : ( type : string , listener : ( ) => void ) => void ;
38- on : ( type : string , listener : ( ) => void ) => void ;
39- removeListener : ( type : string , listener : ( ) => void ) => void ;
40- off : ( type : string , listener : ( ) => void ) => void ;
41- removeAllListeners : ( type ?: string ) => void ;
42- once : ( type : string , listener : ( ) => void ) => void ;
43- prependListener : ( type : string , listener : ( ) => void ) => void ;
44- prependOnceListener : ( type : string , listener : ( ) => void ) => void ;
45- listeners : ( type : string ) => ( ( ) => void ) [ ] ;
46- rawListeners : ( type : string ) => ( ( ) => void ) [ ] ;
47- listenerCount : ( type : string ) => number ;
48- emit : ( type : string ) => void ;
49- eventNames : ( ) => string [ ] ;
50- getMexListeners : ( ) => number ;
51- setMexListeners : ( length : number ) => void ;
5237 }
38+ & UserScriptEvents
5339 & ( {
5440 Layout :
5541 | "list"
@@ -74,6 +60,23 @@ export type Scrapbox =
7460 } ;
7561 } ) ;
7662
63+ export interface UserScriptEvents {
64+ addListener : ( type : string , listener : ( ) => void ) => void ;
65+ on : ( type : string , listener : ( ) => void ) => void ;
66+ removeListener : ( type : string , listener : ( ) => void ) => void ;
67+ off : ( type : string , listener : ( ) => void ) => void ;
68+ removeAllListeners : ( type ?: string ) => void ;
69+ once : ( type : string , listener : ( ) => void ) => void ;
70+ prependListener : ( type : string , listener : ( ) => void ) => void ;
71+ prependOnceListener : ( type : string , listener : ( ) => void ) => void ;
72+ listeners : ( type : string ) => ( ( ) => void ) [ ] ;
73+ rawListeners : ( type : string ) => ( ( ) => void ) [ ] ;
74+ listenerCount : ( type : string ) => number ;
75+ emit : ( type : string ) => void ;
76+ eventNames : ( ) => string [ ] ;
77+ getMexListeners : ( ) => number ;
78+ setMexListeners : ( length : number ) => void ;
79+ }
7780export interface PageBrief {
7881 /** true when the page has contents */ exists : boolean ;
7982 /** whether the page contains any image */ hasIcon ?: boolean ;
@@ -83,20 +86,35 @@ export interface PageBrief {
8386 /** updated time */ updated : number ;
8487}
8588
86- type TimeStamp = {
89+ export interface TimeStamp {
90+ /** Add a timestamp format to Scrapbox
91+ *
92+ * @param format a format of timestamp. this follow the moment.js format. You can set a function which returns any string
93+ */
8794 addFormat : ( format : string | ( ( ) => string ) ) => void ;
95+ /** Remove all timestamp formats from Scrapbox
96+ *
97+ * These include default formats
98+ */
8899 removeAllFormat : ( ) => void ;
89- } ;
100+ }
90101
91- type AddItemProps = {
92- title : string | ( ( ) => string ) ;
102+ export interface AddItemProps {
103+ /** the title of a menu item */ title : string | ( ( ) => string ) ;
104+ /** the URL of an image which views on the left of the title */
93105 image ?: string ;
106+ /** the event listener which is executed when the menu item is clicked */
94107 onClick : ( ) => void ;
95- } ;
96- type PageMenu = {
108+ }
109+ export interface PageMenu {
110+ /** Add a menu item to a particular Page Menu button
111+ *
112+ * @param props information used for a menu item
113+ */
97114 addItem : (
98115 props : AddItemProps ,
99116 ) => void ;
117+ /** Add a separator to a particular Page Menu button */
100118 addSeparator : ( ) => void ;
101119 removeAllItems : ( ) => void ;
102120 menuName : string ;
@@ -110,7 +128,7 @@ type PageMenu = {
110128 items : ( AddItemProps & { separator : boolean } ) [ ] ;
111129 }
112130 > ;
113- } ;
131+ }
114132
115133/** built-in UserScript events */
116134export type eventName =
0 commit comments