lucid-extension-sdk 0.0.341 → 0.0.343

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.
@@ -0,0 +1,18 @@
1
+ import { EditorClient } from '../../editorclient';
2
+ import { CustomQuickAction } from './customquickaction';
3
+ /**
4
+ * Wrapper class for accessing Quick Tools in your extension.
5
+ * Each extension (not package) uses its own QuickToolsRegistry.
6
+ */
7
+ export declare class QuickToolsRegistry {
8
+ private static readonly actionTypesSet;
9
+ private static nextHookId;
10
+ private static nextHookName;
11
+ private static registerActionAndReturnHook;
12
+ private static registerActionIfExistsAndReturnHook;
13
+ /**
14
+ * Adds the specified quick action to the quick action toolbar.
15
+ * @param quickAction object that represents the quick action to add.
16
+ */
17
+ static addQuickActionToToolbar(client: EditorClient, quickAction: CustomQuickAction): void;
18
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuickToolsRegistry = void 0;
4
+ const checks_1 = require("../checks");
5
+ /**
6
+ * Wrapper class for accessing Quick Tools in your extension.
7
+ * Each extension (not package) uses its own QuickToolsRegistry.
8
+ */
9
+ class QuickToolsRegistry {
10
+ static nextHookName() {
11
+ return '__quicktools__hook' + QuickToolsRegistry.nextHookId++;
12
+ }
13
+ static registerActionAndReturnHook(client, callback) {
14
+ const hookname = QuickToolsRegistry.nextHookName();
15
+ client.registerAction(hookname, callback);
16
+ return hookname;
17
+ }
18
+ static registerActionIfExistsAndReturnHook(client, callback) {
19
+ if ((0, checks_1.isDef)(callback)) {
20
+ return this.registerActionAndReturnHook(client, callback);
21
+ }
22
+ return undefined;
23
+ }
24
+ /**
25
+ * Adds the specified quick action to the quick action toolbar.
26
+ * @param quickAction object that represents the quick action to add.
27
+ */
28
+ static addQuickActionToToolbar(client, quickAction) {
29
+ var _a;
30
+ if (this.actionTypesSet.has(quickAction.quickActionType)) {
31
+ throw new Error('This action type already exists in this extension:' + quickAction.quickActionType);
32
+ }
33
+ this.actionTypesSet.add(quickAction.quickActionType);
34
+ client.sendCommand("aqa" /* CommandName.AddQuickAction */, {
35
+ 'qat': quickAction.quickActionType,
36
+ 'l': quickAction.label,
37
+ 'a': this.registerActionAndReturnHook(client, quickAction.action),
38
+ 'i': quickAction.iconUrl,
39
+ 'ea': this.registerActionIfExistsAndReturnHook(client, quickAction.enabledAction),
40
+ 'va': this.registerActionIfExistsAndReturnHook(client, quickAction.visibleAction),
41
+ 'tt': (_a = quickAction.tooltips) === null || _a === void 0 ? void 0 : _a.map((tooltip) => {
42
+ return {
43
+ 'a': this.registerActionIfExistsAndReturnHook(client, tooltip.action),
44
+ 'l': tooltip.label,
45
+ };
46
+ }),
47
+ });
48
+ }
49
+ }
50
+ exports.QuickToolsRegistry = QuickToolsRegistry;
51
+ QuickToolsRegistry.actionTypesSet = new Set();
52
+ QuickToolsRegistry.nextHookId = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.341",
3
+ "version": "0.0.343",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,19 +0,0 @@
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
- }
@@ -1,54 +0,0 @@
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;