lucid-extension-sdk 0.0.207 → 0.0.209
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 +3 -6
- package/package.json +1 -1
- package/ui/menu.d.ts +91 -1
- package/ui/menu.js +73 -1
package/README.md
CHANGED
|
@@ -23,10 +23,9 @@ client.registerAction('my-new-action', () => {
|
|
|
23
23
|
console.log('Hello world');
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
menu.
|
|
26
|
+
menu.addDropdownMenuItem({
|
|
27
27
|
label: 'Hello world',
|
|
28
28
|
action: 'my-new-action',
|
|
29
|
-
menuType: MenuType.Main,
|
|
30
29
|
});
|
|
31
30
|
```
|
|
32
31
|
|
|
@@ -67,10 +66,9 @@ client.registerAction('create-content', async () => {
|
|
|
67
66
|
}
|
|
68
67
|
});
|
|
69
68
|
|
|
70
|
-
menu.
|
|
69
|
+
menu.addDropdownMenuItem({
|
|
71
70
|
label: 'Hello world',
|
|
72
71
|
action: 'create-content',
|
|
73
|
-
menuType: MenuType.Main,
|
|
74
72
|
});
|
|
75
73
|
```
|
|
76
74
|
|
|
@@ -103,10 +101,9 @@ client.registerAction('download', async () => {
|
|
|
103
101
|
client.download('data.csv', csv.map((line) => line.join(',')).join('\n'), 'text/plain', false);
|
|
104
102
|
});
|
|
105
103
|
|
|
106
|
-
menu.
|
|
104
|
+
menu.addDropdownMenuItem({
|
|
107
105
|
label: 'Download CSV',
|
|
108
106
|
action: 'download',
|
|
109
|
-
menuType: MenuType.Main,
|
|
110
107
|
location: MenuLocation.Export, //Near File -> Export
|
|
111
108
|
});
|
|
112
109
|
```
|
package/package.json
CHANGED
package/ui/menu.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { EditorClient } from '../editorclient';
|
|
2
|
+
/**
|
|
3
|
+
* Type of menu you're adding.
|
|
4
|
+
* Consider using addDropdownMenuItem, addContextMenuItem, or addContentDockMenuItem for easier to use entrypoints and clearer requirements.
|
|
5
|
+
*/
|
|
2
6
|
export declare enum MenuType {
|
|
7
|
+
/** The main drop down menus. */
|
|
3
8
|
Main = 1,
|
|
4
9
|
/** The context menu that appears when the user right-clicks the canvas. */
|
|
5
10
|
Context = 2,
|
|
11
|
+
/** The side dock in Lucidspark and Teamspaces */
|
|
6
12
|
ContentDock = 3
|
|
7
13
|
}
|
|
8
14
|
/**
|
|
@@ -17,6 +23,56 @@ export declare enum MenuLocation {
|
|
|
17
23
|
Export = 5,
|
|
18
24
|
Import = 6
|
|
19
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Data to create a menu
|
|
28
|
+
*/
|
|
29
|
+
export interface CustomMenuConfig {
|
|
30
|
+
/** The text to display on the menu item */
|
|
31
|
+
label: string;
|
|
32
|
+
/** The registered action to run when the menu item is clicked. */
|
|
33
|
+
action?: string;
|
|
34
|
+
/** If specified, what action's return value should determine if this menu item is visible? */
|
|
35
|
+
visibleAction?: string;
|
|
36
|
+
/** If specified, what action's return value should determine if this menu item is disabled? */
|
|
37
|
+
disabledAction?: string;
|
|
38
|
+
/** If specified, this menu item should launch a file picker */
|
|
39
|
+
file?: {
|
|
40
|
+
/** An action registered with EditorClient.registerFileUploadAction */
|
|
41
|
+
action: string;
|
|
42
|
+
/** An [accept string](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) as specified for HTML file inputs */
|
|
43
|
+
accept: string;
|
|
44
|
+
/** If true, only allow a single file to be selected for upload */
|
|
45
|
+
singleFileOnly?: boolean;
|
|
46
|
+
/** If true, send the file contents to the callback action as a Uint8Array as well as a plain text string */
|
|
47
|
+
binary?: boolean;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Data to create a dropdown menu in the main top menus.
|
|
52
|
+
*/
|
|
53
|
+
export interface CustomDropdownMenu extends CustomMenuConfig {
|
|
54
|
+
/** Where in that menu to display this item in Lucidchart.
|
|
55
|
+
* Defaults to the extension menu.
|
|
56
|
+
* In Lucidspark the only valid menu is Extension, it will not appear otherwise.
|
|
57
|
+
*/
|
|
58
|
+
location?: MenuLocation;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Data to create a content dock icon in Spark + Teamspaces
|
|
62
|
+
*/
|
|
63
|
+
export interface CustomContentDockMenu extends CustomMenuConfig {
|
|
64
|
+
/** The icon to display on the menu item.
|
|
65
|
+
* A URL (a data URI is fine) pointing to an icon representing the integration.
|
|
66
|
+
* This will be displayed at up to 32x32 CSS pixels in size.
|
|
67
|
+
*/
|
|
68
|
+
iconUrl: string;
|
|
69
|
+
/** The registered action to run when the menu item is clicked */
|
|
70
|
+
action: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A generic object to contain any information creating a menu might need.
|
|
74
|
+
* It is a little easier to use CustomMenuConfig, CustomDropdownMenu, or CustomContentDockMenu.
|
|
75
|
+
*/
|
|
20
76
|
export interface CustomMenuItem {
|
|
21
77
|
/** The text to display on the menu item */
|
|
22
78
|
label: string;
|
|
@@ -58,11 +114,45 @@ export declare class Menu {
|
|
|
58
114
|
private readonly client;
|
|
59
115
|
constructor(client: EditorClient);
|
|
60
116
|
/**
|
|
61
|
-
*
|
|
117
|
+
* Generic function to create a new menu item to trigger custom code.
|
|
118
|
+
* You can use addDropdownMenuItem, addContextMenuItem, or addContentDockMenuItem for easier to use entrypoints.
|
|
119
|
+
*
|
|
120
|
+
* The action must be registered with
|
|
62
121
|
* [EditorClient.registerAction](/extension-sdk/#classes_editorclient-EditorClient_registeraction)
|
|
63
122
|
* prior to using it in the menu.
|
|
64
123
|
*
|
|
65
124
|
* @param item The definition of the new menu item
|
|
66
125
|
*/
|
|
67
126
|
addMenuItem(item: CustomMenuItem): void;
|
|
127
|
+
/**
|
|
128
|
+
* Create a menu in the basic drop down top menus. In Lucidspark this will just be under the generic menu.
|
|
129
|
+
* In Lucidchart you can configure this to be in any of the other drop down menus.
|
|
130
|
+
*
|
|
131
|
+
* The action must be registered with
|
|
132
|
+
* [EditorClient.registerAction](/extension-sdk/#classes_editorclient-EditorClient_registeraction)
|
|
133
|
+
* prior to using it in the menu.
|
|
134
|
+
*
|
|
135
|
+
* @param item The definition of the new menu item
|
|
136
|
+
*/
|
|
137
|
+
addDropdownMenuItem(item: CustomDropdownMenu): void;
|
|
138
|
+
/**
|
|
139
|
+
* Create a menu in the right click context menu. Appears in both Lucidspark and Lucidchart.
|
|
140
|
+
*
|
|
141
|
+
* The action must be registered with
|
|
142
|
+
* [EditorClient.registerAction](/extension-sdk/#classes_editorclient-EditorClient_registeraction)
|
|
143
|
+
* prior to using it in the menu.
|
|
144
|
+
*
|
|
145
|
+
* @param item The definition of the new menu item
|
|
146
|
+
*/
|
|
147
|
+
addContextMenuItem(item: CustomMenuConfig): void;
|
|
148
|
+
/**
|
|
149
|
+
* Create an icon tied to an action (required) that appears in the left toolbar in Lucidspark and Teamspaces (not in Lucidchart).
|
|
150
|
+
*
|
|
151
|
+
* The action must be registered with
|
|
152
|
+
* [EditorClient.registerAction](/extension-sdk/#classes_editorclient-EditorClient_registeraction)
|
|
153
|
+
* prior to using it in the menu.
|
|
154
|
+
*
|
|
155
|
+
* @param item The definition of the new menu item
|
|
156
|
+
*/
|
|
157
|
+
addContentDockMenuItem(item: CustomContentDockMenu): void;
|
|
68
158
|
}
|
package/ui/menu.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Menu = exports.MenuLocation = exports.MenuType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Type of menu you're adding.
|
|
6
|
+
* Consider using addDropdownMenuItem, addContextMenuItem, or addContentDockMenuItem for easier to use entrypoints and clearer requirements.
|
|
7
|
+
*/
|
|
4
8
|
var MenuType;
|
|
5
9
|
(function (MenuType) {
|
|
10
|
+
/** The main drop down menus. */
|
|
6
11
|
MenuType[MenuType["Main"] = 1] = "Main";
|
|
7
12
|
/** The context menu that appears when the user right-clicks the canvas. */
|
|
8
13
|
MenuType[MenuType["Context"] = 2] = "Context";
|
|
14
|
+
/** The side dock in Lucidspark and Teamspaces */
|
|
9
15
|
MenuType[MenuType["ContentDock"] = 3] = "ContentDock";
|
|
10
16
|
})(MenuType = exports.MenuType || (exports.MenuType = {}));
|
|
11
17
|
/**
|
|
@@ -26,7 +32,10 @@ class Menu {
|
|
|
26
32
|
this.client = client;
|
|
27
33
|
}
|
|
28
34
|
/**
|
|
29
|
-
*
|
|
35
|
+
* Generic function to create a new menu item to trigger custom code.
|
|
36
|
+
* You can use addDropdownMenuItem, addContextMenuItem, or addContentDockMenuItem for easier to use entrypoints.
|
|
37
|
+
*
|
|
38
|
+
* The action must be registered with
|
|
30
39
|
* [EditorClient.registerAction](/extension-sdk/#classes_editorclient-EditorClient_registeraction)
|
|
31
40
|
* prior to using it in the menu.
|
|
32
41
|
*
|
|
@@ -66,5 +75,68 @@ class Menu {
|
|
|
66
75
|
: undefined,
|
|
67
76
|
});
|
|
68
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Create a menu in the basic drop down top menus. In Lucidspark this will just be under the generic menu.
|
|
80
|
+
* In Lucidchart you can configure this to be in any of the other drop down menus.
|
|
81
|
+
*
|
|
82
|
+
* The action must be registered with
|
|
83
|
+
* [EditorClient.registerAction](/extension-sdk/#classes_editorclient-EditorClient_registeraction)
|
|
84
|
+
* prior to using it in the menu.
|
|
85
|
+
*
|
|
86
|
+
* @param item The definition of the new menu item
|
|
87
|
+
*/
|
|
88
|
+
addDropdownMenuItem(item) {
|
|
89
|
+
var _a;
|
|
90
|
+
this.addMenuItem({
|
|
91
|
+
label: item.label,
|
|
92
|
+
action: item.action,
|
|
93
|
+
visibleAction: item.visibleAction,
|
|
94
|
+
disabledAction: item.disabledAction,
|
|
95
|
+
menuType: MenuType.Main,
|
|
96
|
+
location: (_a = item.location) !== null && _a !== void 0 ? _a : MenuLocation.Extension,
|
|
97
|
+
file: item.file,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Create a menu in the right click context menu. Appears in both Lucidspark and Lucidchart.
|
|
102
|
+
*
|
|
103
|
+
* The action must be registered with
|
|
104
|
+
* [EditorClient.registerAction](/extension-sdk/#classes_editorclient-EditorClient_registeraction)
|
|
105
|
+
* prior to using it in the menu.
|
|
106
|
+
*
|
|
107
|
+
* @param item The definition of the new menu item
|
|
108
|
+
*/
|
|
109
|
+
addContextMenuItem(item) {
|
|
110
|
+
this.addMenuItem({
|
|
111
|
+
label: item.label,
|
|
112
|
+
action: item.action,
|
|
113
|
+
visibleAction: item.visibleAction,
|
|
114
|
+
disabledAction: item.disabledAction,
|
|
115
|
+
menuType: MenuType.Context,
|
|
116
|
+
location: MenuLocation.Extension,
|
|
117
|
+
file: item.file,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Create an icon tied to an action (required) that appears in the left toolbar in Lucidspark and Teamspaces (not in Lucidchart).
|
|
122
|
+
*
|
|
123
|
+
* The action must be registered with
|
|
124
|
+
* [EditorClient.registerAction](/extension-sdk/#classes_editorclient-EditorClient_registeraction)
|
|
125
|
+
* prior to using it in the menu.
|
|
126
|
+
*
|
|
127
|
+
* @param item The definition of the new menu item
|
|
128
|
+
*/
|
|
129
|
+
addContentDockMenuItem(item) {
|
|
130
|
+
this.addMenuItem({
|
|
131
|
+
label: item.label,
|
|
132
|
+
iconUrl: item.iconUrl,
|
|
133
|
+
action: item.action,
|
|
134
|
+
visibleAction: item.visibleAction,
|
|
135
|
+
disabledAction: item.disabledAction,
|
|
136
|
+
menuType: MenuType.ContentDock,
|
|
137
|
+
location: MenuLocation.Extension,
|
|
138
|
+
file: item.file,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
69
141
|
}
|
|
70
142
|
exports.Menu = Menu;
|