lucid-extension-sdk 0.0.321 → 0.0.322
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/commandtypes.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export declare const enum CommandName {
|
|
|
31
31
|
AddDiagramFromText = "adft",
|
|
32
32
|
AddLineTextArea = "alta",
|
|
33
33
|
AddMenuItem = "ami",
|
|
34
|
+
AddQuickAction = "aqa",
|
|
34
35
|
AddShapeData = "asd",
|
|
35
36
|
AddSpreadsheetIntegration = "asi",
|
|
36
37
|
AddTableColumn = "atc",
|
|
@@ -191,6 +192,10 @@ export type CommandArgs = {
|
|
|
191
192
|
query: AddMenuItemQuery;
|
|
192
193
|
result: AddMenuItemResult;
|
|
193
194
|
};
|
|
195
|
+
[CommandName.AddQuickAction]: {
|
|
196
|
+
query: AddQuickActionQuery;
|
|
197
|
+
result: AddQuickActionResult;
|
|
198
|
+
};
|
|
194
199
|
[CommandName.AddShapeData]: {
|
|
195
200
|
query: AddShapeDataQuery;
|
|
196
201
|
result: AddShapeDataResult;
|
|
@@ -881,6 +886,54 @@ export type AddMenuItemQuery = {
|
|
|
881
886
|
} | undefined;
|
|
882
887
|
};
|
|
883
888
|
export type AddMenuItemResult = undefined;
|
|
889
|
+
export type AddQuickActionQuery = {
|
|
890
|
+
/**
|
|
891
|
+
* The type of the quick action
|
|
892
|
+
*/
|
|
893
|
+
'qat': string;
|
|
894
|
+
/**
|
|
895
|
+
* The text to display on the quick action. The maximum length supported is 30 characters
|
|
896
|
+
*/
|
|
897
|
+
'l': string;
|
|
898
|
+
/**
|
|
899
|
+
* Named action to run when the quick action is clicked, takes the block id as parameter.
|
|
900
|
+
* @returns true if the action was handled.
|
|
901
|
+
*/
|
|
902
|
+
'a': string;
|
|
903
|
+
/**
|
|
904
|
+
* The icon to display on the quick action.
|
|
905
|
+
*/
|
|
906
|
+
'i'?: string | undefined;
|
|
907
|
+
/**
|
|
908
|
+
* Named action that returns whether the quick action is enabled, takes the block id as parameter.
|
|
909
|
+
* @returns true if the Quick Action is enabled.
|
|
910
|
+
* Quick Action defaults to disabled if callback is not provided
|
|
911
|
+
*/
|
|
912
|
+
'ea'?: string | undefined;
|
|
913
|
+
/**
|
|
914
|
+
* Named action that returns whether the quick action is visble in the toolbar.
|
|
915
|
+
* @returns true if the Quick Action is visible.
|
|
916
|
+
* Quick action defaults to visible in the panel if callback is not provided
|
|
917
|
+
*/
|
|
918
|
+
'va'?: string | undefined;
|
|
919
|
+
/**
|
|
920
|
+
* Information on when to display tooltips and what they should say
|
|
921
|
+
*/
|
|
922
|
+
'tt'?: QuickActionTooltipQuery[] | undefined;
|
|
923
|
+
};
|
|
924
|
+
export type QuickActionTooltipQuery = {
|
|
925
|
+
/**
|
|
926
|
+
* Named action thatreturns whether the tooltip is shown, takes the block id as parameter.
|
|
927
|
+
* @returns true if the tooltip should show
|
|
928
|
+
* Tooltip is always shown if the callback is not provided
|
|
929
|
+
*/
|
|
930
|
+
'a'?: string | undefined;
|
|
931
|
+
/**
|
|
932
|
+
* The text to display on the tooltip
|
|
933
|
+
*/
|
|
934
|
+
'l': string;
|
|
935
|
+
};
|
|
936
|
+
export type AddQuickActionResult = undefined;
|
|
884
937
|
export type AddShapeDataQuery = {
|
|
885
938
|
/** ID of the element to add this shape data to */
|
|
886
939
|
'id'?: string | undefined;
|
package/commandtypes.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.commandTitles = new Map([
|
|
|
10
10
|
["adft" /* CommandName.AddDiagramFromText */, 'AddDiagramFromText'],
|
|
11
11
|
["alta" /* CommandName.AddLineTextArea */, 'AddLineTextArea'],
|
|
12
12
|
["ami" /* CommandName.AddMenuItem */, 'AddMenuItem'],
|
|
13
|
+
["aqa" /* CommandName.AddQuickAction */, 'AddQuickAction'],
|
|
13
14
|
["asd" /* CommandName.AddShapeData */, 'AddShapeData'],
|
|
14
15
|
["asi" /* CommandName.AddSpreadsheetIntegration */, 'AddSpreadsheetIntegration'],
|
|
15
16
|
["atc" /* CommandName.AddTableColumn */, 'AddTableColumn'],
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object that represesnts the parameters on a Custom Quick Action's callbacks
|
|
3
|
+
* @param 'id' is the id of the hooked callback
|
|
4
|
+
* @param 'bid' is the id of the block that is being interacted with
|
|
5
|
+
*/
|
|
6
|
+
export type CustomQuickActionCallbackParams = {
|
|
7
|
+
'id': string;
|
|
8
|
+
'bid': string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Function that represents a callback to be used by the Custom Quick Action
|
|
12
|
+
*/
|
|
13
|
+
export type CustomQuickActionCallbackWithParams = (params: CustomQuickActionCallbackParams) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Function that represents a callback to be used by the Custom Quick Action
|
|
16
|
+
*/
|
|
17
|
+
export type CustomQuickActionCallback = () => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* A generic object to contain any information creating a quick action might need.
|
|
20
|
+
*/
|
|
21
|
+
export interface CustomQuickAction {
|
|
22
|
+
/**
|
|
23
|
+
* Each quick action needs a type so that we can differentiate them from the others
|
|
24
|
+
*/
|
|
25
|
+
quickActionType: string;
|
|
26
|
+
/**
|
|
27
|
+
* The text to display on the quick action. The maximum length supported is 30 characters
|
|
28
|
+
*/
|
|
29
|
+
label: string;
|
|
30
|
+
/**
|
|
31
|
+
* The callback to run when the quick action is clicked.
|
|
32
|
+
* @returns true if the action was handled.
|
|
33
|
+
*/
|
|
34
|
+
action: CustomQuickActionCallbackWithParams;
|
|
35
|
+
/**
|
|
36
|
+
* The icon to display on the quick action.
|
|
37
|
+
* A URL (a data URI is fine) pointing to an icon representing the integration.
|
|
38
|
+
* This will be displayed at up to 24x24 pixels in size.
|
|
39
|
+
*/
|
|
40
|
+
iconUrl?: string;
|
|
41
|
+
/**
|
|
42
|
+
* If specified, a callback that determines if this quick action is enabled.
|
|
43
|
+
* @returns true if the Quick Action is enabled.
|
|
44
|
+
* Quick Action defaults to disabled if callback is not provided
|
|
45
|
+
*/
|
|
46
|
+
enabledAction?: CustomQuickActionCallbackWithParams | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* If specified, a calback that determines if this Quick Action is visible in the menu.
|
|
49
|
+
* @returns true if the Quick Action is visible.
|
|
50
|
+
* Quick action defaults to visible in the panel if callback is not provided
|
|
51
|
+
*/
|
|
52
|
+
visibleAction?: CustomQuickActionCallback | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Information on when to display tooltips and what they should say
|
|
55
|
+
*/
|
|
56
|
+
tooltips?: QuickActionTooltip[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A generic object to contain any information displaying a Custom Quick Action tooltip might need.
|
|
60
|
+
*/
|
|
61
|
+
export interface QuickActionTooltip {
|
|
62
|
+
/**
|
|
63
|
+
* If specified, a calback that determines if the tooltip should show.
|
|
64
|
+
* @returns true if the tooltip should show
|
|
65
|
+
* Tooltip is always shown if the call is not provided
|
|
66
|
+
*/
|
|
67
|
+
action?: CustomQuickActionCallbackWithParams | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* The text to display on the tooltip
|
|
70
|
+
*/
|
|
71
|
+
label: string;
|
|
72
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EditorClient } from '../../editorclient';
|
|
2
|
+
import { CustomQuickAction } from './customquickaction';
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper for Quick Tools
|
|
5
|
+
*/
|
|
6
|
+
export declare class QuickTools {
|
|
7
|
+
private readonly client;
|
|
8
|
+
private readonly actionTypesSet;
|
|
9
|
+
private static nextHookId;
|
|
10
|
+
private static nextHookName;
|
|
11
|
+
constructor(client: EditorClient);
|
|
12
|
+
private registerActionAndReturnHook;
|
|
13
|
+
private registerActionIfExistsAndReturnHook;
|
|
14
|
+
/**
|
|
15
|
+
* Adds the specified quick action to the quick action toolbar.
|
|
16
|
+
* @param quickAction object that represents the quick action to add.
|
|
17
|
+
*/
|
|
18
|
+
addQuickActionToToolbar(quickAction: CustomQuickAction): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuickTools = void 0;
|
|
4
|
+
const checks_1 = require("../checks");
|
|
5
|
+
/**
|
|
6
|
+
* Wrapper for Quick Tools
|
|
7
|
+
*/
|
|
8
|
+
class QuickTools {
|
|
9
|
+
static nextHookName() {
|
|
10
|
+
return '__quicktools__hook' + QuickTools.nextHookId++;
|
|
11
|
+
}
|
|
12
|
+
constructor(client) {
|
|
13
|
+
this.client = client;
|
|
14
|
+
this.actionTypesSet = new Set();
|
|
15
|
+
}
|
|
16
|
+
registerActionAndReturnHook(callback) {
|
|
17
|
+
const hookname = QuickTools.nextHookName();
|
|
18
|
+
this.client.registerAction(hookname, callback);
|
|
19
|
+
return hookname;
|
|
20
|
+
}
|
|
21
|
+
registerActionIfExistsAndReturnHook(callback) {
|
|
22
|
+
if ((0, checks_1.isDef)(callback)) {
|
|
23
|
+
return this.registerActionAndReturnHook(callback);
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Adds the specified quick action to the quick action toolbar.
|
|
29
|
+
* @param quickAction object that represents the quick action to add.
|
|
30
|
+
*/
|
|
31
|
+
addQuickActionToToolbar(quickAction) {
|
|
32
|
+
var _a;
|
|
33
|
+
if (this.actionTypesSet.has(quickAction.quickActionType)) {
|
|
34
|
+
throw new Error('This action type already exist in this extension:' + quickAction.quickActionType);
|
|
35
|
+
}
|
|
36
|
+
this.actionTypesSet.add(quickAction.quickActionType);
|
|
37
|
+
this.client.sendCommand("aqa" /* CommandName.AddQuickAction */, {
|
|
38
|
+
'qat': quickAction.quickActionType,
|
|
39
|
+
'l': quickAction.label,
|
|
40
|
+
'a': this.registerActionAndReturnHook(quickAction.action),
|
|
41
|
+
'i': quickAction.iconUrl,
|
|
42
|
+
'ea': this.registerActionIfExistsAndReturnHook(quickAction.enabledAction),
|
|
43
|
+
'va': this.registerActionIfExistsAndReturnHook(quickAction.visibleAction),
|
|
44
|
+
'tt': (_a = quickAction.tooltips) === null || _a === void 0 ? void 0 : _a.map((tooltip) => {
|
|
45
|
+
return {
|
|
46
|
+
'a': this.registerActionIfExistsAndReturnHook(tooltip.action),
|
|
47
|
+
'l': tooltip.label,
|
|
48
|
+
};
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.QuickTools = QuickTools;
|
|
54
|
+
QuickTools.nextHookId = 0;
|