lucid-extension-sdk 0.0.206 → 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/document/imagedefinition.d.ts +25 -0
- package/document/pageproxy.d.ts +3 -3
- package/document/pageproxy.js +16 -4
- 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
|
```
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SimpleImageFill } from '../core/properties/fillcolor';
|
|
2
|
+
import { StrokeStyle } from '../core/properties/strokestyle';
|
|
2
3
|
import { Box } from '../math';
|
|
3
4
|
/**
|
|
4
5
|
* The information required to create a new image block on the current document
|
|
@@ -12,4 +13,28 @@ export interface ImageDefinition {
|
|
|
12
13
|
* Settings for using an image as the fill style of a block.
|
|
13
14
|
*/
|
|
14
15
|
fillStyle: SimpleImageFill;
|
|
16
|
+
/**
|
|
17
|
+
* The opacity (0 - 1) for this image (default is 1).
|
|
18
|
+
*/
|
|
19
|
+
opacity?: number;
|
|
20
|
+
/**
|
|
21
|
+
* the border color for this image (default is black, #000000).
|
|
22
|
+
*/
|
|
23
|
+
lineColor?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The border width in pixels for this image (default is 1).
|
|
26
|
+
*/
|
|
27
|
+
lineWidth?: number;
|
|
28
|
+
/**
|
|
29
|
+
* The stroke style for the border of this image (default is Solid).
|
|
30
|
+
*/
|
|
31
|
+
strokeStyle?: StrokeStyle;
|
|
32
|
+
/**
|
|
33
|
+
* The rounding for this image (default is 0).
|
|
34
|
+
*/
|
|
35
|
+
rounding?: number;
|
|
36
|
+
/**
|
|
37
|
+
* The rotation for this image (deafult is 0).
|
|
38
|
+
*/
|
|
39
|
+
rotation?: number;
|
|
15
40
|
}
|
package/document/pageproxy.d.ts
CHANGED
|
@@ -69,15 +69,15 @@ export declare class PageProxy extends ElementProxy {
|
|
|
69
69
|
*/
|
|
70
70
|
addBlock(def: BlockDefinition): BlockProxy;
|
|
71
71
|
/**
|
|
72
|
-
* Add a new line to this page
|
|
72
|
+
* Add a new line to this page.
|
|
73
73
|
* @param def The definition of the new line to add
|
|
74
74
|
* @returns The added line
|
|
75
75
|
*/
|
|
76
76
|
addLine(def: LineDefinition): LineProxy;
|
|
77
77
|
/**
|
|
78
|
-
* Add a new image to this page
|
|
78
|
+
* Add a new image to this page.
|
|
79
79
|
* @param def The definition of the new image to add
|
|
80
|
-
* @returns The added image
|
|
80
|
+
* @returns The added image
|
|
81
81
|
*/
|
|
82
82
|
addImage(def: ImageDefinition): Promise<BlockProxy>;
|
|
83
83
|
/**
|
package/document/pageproxy.js
CHANGED
|
@@ -100,7 +100,7 @@ class PageProxy extends elementproxy_1.ElementProxy {
|
|
|
100
100
|
return block;
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
|
-
* Add a new line to this page
|
|
103
|
+
* Add a new line to this page.
|
|
104
104
|
* @param def The definition of the new line to add
|
|
105
105
|
* @returns The added line
|
|
106
106
|
*/
|
|
@@ -114,13 +114,25 @@ class PageProxy extends elementproxy_1.ElementProxy {
|
|
|
114
114
|
return line;
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
|
-
* Add a new image to this page
|
|
117
|
+
* Add a new image to this page.
|
|
118
118
|
* @param def The definition of the new image to add
|
|
119
|
-
* @returns The added image
|
|
119
|
+
* @returns The added image
|
|
120
120
|
*/
|
|
121
121
|
async addImage(def) {
|
|
122
122
|
await this.client.loadBlockClasses(['UserImage2Block']);
|
|
123
|
-
return this.addBlock(
|
|
123
|
+
return this.addBlock({
|
|
124
|
+
className: 'UserImage2Block',
|
|
125
|
+
boundingBox: def.boundingBox,
|
|
126
|
+
fillStyle: def.fillStyle,
|
|
127
|
+
properties: {
|
|
128
|
+
opactiy: def.opacity,
|
|
129
|
+
lineColor: def.lineColor,
|
|
130
|
+
lineWidth: def.lineWidth,
|
|
131
|
+
strokeStyle: def.strokeStyle,
|
|
132
|
+
rounding: def.rounding,
|
|
133
|
+
rotation: def.rotation,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
124
136
|
}
|
|
125
137
|
/**
|
|
126
138
|
* Updates the page of this page
|
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;
|