lucid-extension-sdk 0.0.186 → 0.0.188

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
@@ -83,6 +83,7 @@ export declare const enum CommandName {
83
83
  HookSelection = "hs",
84
84
  HookTextEdit = "hte",
85
85
  ImportCards = "ic",
86
+ ImportLinks = "il",
86
87
  ImportPage = "imp",
87
88
  KillExtension = "k",
88
89
  ListBlocks = "lb",
@@ -103,7 +104,6 @@ export declare const enum CommandName {
103
104
  OffsetItems = "oi",
104
105
  PatchDataItems = "pdi",
105
106
  Prompt = "p",
106
- RegisterLinkImporter = "rli",
107
107
  RegisterPanel = "rp",
108
108
  RegisterUnfurl = "ru",
109
109
  ReloadExtension = "r",
@@ -113,6 +113,7 @@ export declare const enum CommandName {
113
113
  SendUIMessage = "suim",
114
114
  SendXHR = "xhr",
115
115
  SetCurrentPage = "scp",
116
+ SetPackageSettings = "sps",
116
117
  SetProperty = "sp",
117
118
  SetReferenceKey = "srk",
118
119
  SetShapeData = "ssd",
@@ -395,6 +396,10 @@ export type CommandArgs = {
395
396
  query: ImportCardsQuery;
396
397
  result: ImportCardsResult;
397
398
  };
399
+ [CommandName.ImportLinks]: {
400
+ query: ImportLinksQuery;
401
+ result: ImportLinksResult;
402
+ };
398
403
  [CommandName.ImportPage]: {
399
404
  query: ImportPageQuery;
400
405
  result: ImportPageResult;
@@ -471,10 +476,6 @@ export type CommandArgs = {
471
476
  query: PromptQuery;
472
477
  result: PromptResult;
473
478
  };
474
- [CommandName.RegisterLinkImporter]: {
475
- query: RegisterLinkImporterQuery;
476
- result: RegisterLinkImporterResult;
477
- };
478
479
  [CommandName.RegisterPanel]: {
479
480
  query: RegisterPanelQuery;
480
481
  result: RegisterPanelResult;
@@ -511,6 +512,10 @@ export type CommandArgs = {
511
512
  query: SetCurrentPageQuery;
512
513
  result: SetCurrentPageResult;
513
514
  };
515
+ [CommandName.SetPackageSettings]: {
516
+ query: SetPackageSettingsQuery;
517
+ result: SetPackageSettingsResult;
518
+ };
514
519
  [CommandName.SetProperty]: {
515
520
  query: SetPropertyQuery;
516
521
  result: SetPropertyResult;
@@ -657,6 +662,8 @@ export type UnionToIntersection<T> = (T extends any ? (x: T) => unknown : never)
657
662
  export type AddMenuItemQuery = {
658
663
  /** Label to display on the menu item */
659
664
  'l': string;
665
+ /** Url of the Icon to display on the menu item */
666
+ 'i'?: string | undefined;
660
667
  /** Named action to run when the menu item is clicked */
661
668
  'a'?: string | undefined;
662
669
  /** Named action that returns whether the menu item should be visible */
@@ -1091,6 +1098,15 @@ export type HookTextEditResult = undefined;
1091
1098
  export type ImportCardsQuery = string;
1092
1099
  /** Resolves when the import dialog is closed */
1093
1100
  export type ImportCardsResult = Promise<void>;
1101
+ export type ImportLinksQuery = {
1102
+ /**
1103
+ * By default, we import the links onto the current page. If specified, the links will instead be imported onto the given page.
1104
+ */
1105
+ 'p'?: string | undefined;
1106
+ /** Links to be imported onto the canvas as link unfurl blocks*/
1107
+ 'l': string[];
1108
+ };
1109
+ export type ImportLinksResult = void;
1094
1110
  export type ImportPageQuery = {
1095
1111
  /** The ID of the document or template to import */
1096
1112
  'id': string;
@@ -1179,17 +1195,6 @@ export type PromptQuery = {
1179
1195
  'b': string;
1180
1196
  };
1181
1197
  export type PromptResult = Promise<string | undefined>;
1182
- export type RegisterLinkImporterQuery = {
1183
- /** ID of the link importer*/
1184
- 'id': string;
1185
- /** Action to call to get links for bulk import */
1186
- 'a': string;
1187
- /** Label for the menu item */
1188
- 'l': string;
1189
- /** Icon URL of the menu item, preferably a base64-encoded URL */
1190
- 'i': string;
1191
- };
1192
- export type RegisterLinkImporterResult = void;
1193
1198
  export type RegisterPanelQuery = {
1194
1199
  /** Name of the panel's action for receiving events; generated automatically by Panel base class */
1195
1200
  'n': string;
@@ -1293,6 +1298,8 @@ export type SendXHRResponse = Promise<RawSendXHRResponse>;
1293
1298
  export declare function isRawSendXHRResponse(val: any): val is RawSendXHRResponse;
1294
1299
  export type SetCurrentPageQuery = string;
1295
1300
  export type SetCurrentPageResult = Promise<void>;
1301
+ export type SetPackageSettingsQuery = Record<string, string>;
1302
+ export type SetPackageSettingsResult = Promise<undefined>;
1296
1303
  export type SetPropertyQuery = {
1297
1304
  /** ID of the element to change */
1298
1305
  'id'?: string | undefined;
package/commandtypes.js CHANGED
@@ -63,6 +63,7 @@ exports.commandTitles = new Map([
63
63
  ["hs" /* CommandName.HookSelection */, 'HookSelection'],
64
64
  ["hte" /* CommandName.HookTextEdit */, 'HookTextEdit'],
65
65
  ["ic" /* CommandName.ImportCards */, 'ImportCards'],
66
+ ["il" /* CommandName.ImportLinks */, 'ImportLinks'],
66
67
  ["imp" /* CommandName.ImportPage */, 'ImportPage'],
67
68
  ["k" /* CommandName.KillExtension */, 'KillExtension'],
68
69
  ["lb" /* CommandName.ListBlocks */, 'ListBlocks'],
@@ -83,7 +84,6 @@ exports.commandTitles = new Map([
83
84
  ["oi" /* CommandName.OffsetItems */, 'OffsetItems'],
84
85
  ["pdi" /* CommandName.PatchDataItems */, 'PatchDataItems'],
85
86
  ["p" /* CommandName.Prompt */, 'Prompt'],
86
- ["rli" /* CommandName.RegisterLinkImporter */, 'RegisterLinkImporter'],
87
87
  ["rp" /* CommandName.RegisterPanel */, 'RegisterPanel'],
88
88
  ["ru" /* CommandName.RegisterUnfurl */, 'RegisterUnfurl'],
89
89
  ["r" /* CommandName.ReloadExtension */, 'ReloadExtension'],
@@ -92,6 +92,7 @@ exports.commandTitles = new Map([
92
92
  ["suim" /* CommandName.SendUIMessage */, 'SendUIMessage'],
93
93
  ["xhr" /* CommandName.SendXHR */, 'SendXHR'],
94
94
  ["scp" /* CommandName.SetCurrentPage */, 'SetCurrentPage'],
95
+ ["sps" /* CommandName.SetPackageSettings */, 'SetPackageSettings'],
95
96
  ["sp" /* CommandName.SetProperty */, 'SetProperty'],
96
97
  ["srk" /* CommandName.SetReferenceKey */, 'SetReferenceKey'],
97
98
  ["ssd" /* CommandName.SetShapeData */, 'SetShapeData'],
@@ -92,4 +92,12 @@ export declare class PageProxy extends ElementProxy {
92
92
  * @returns Items in the given bounding box, based on the search type
93
93
  */
94
94
  findItems(boundingBox: Box, searchType: GetItemsAtSearchType): (BlockProxy | LineProxy | GroupProxy)[];
95
+ /**
96
+ * Import links onto this page as link unfurl blocks
97
+ *
98
+ * NOTE: links will be unfurled by Lucid based on extensions installed by user
99
+ *
100
+ * @param links links to be imported onto the canvas as link unfurl blocks
101
+ */
102
+ importLinks(links: string[]): Promise<void>;
95
103
  }
@@ -143,5 +143,15 @@ class PageProxy extends elementproxy_1.ElementProxy {
143
143
  .sendCommand("gia" /* CommandName.GetItemsAt */, { 'p': this.id, 'bb': boundingBox, 's': searchType })
144
144
  .map((id) => this.client.getItemProxy(id));
145
145
  }
146
+ /**
147
+ * Import links onto this page as link unfurl blocks
148
+ *
149
+ * NOTE: links will be unfurled by Lucid based on extensions installed by user
150
+ *
151
+ * @param links links to be imported onto the canvas as link unfurl blocks
152
+ */
153
+ async importLinks(links) {
154
+ return await this.client.sendCommand("il" /* CommandName.ImportLinks */, { 'p': this.id, 'l': links });
155
+ }
146
156
  }
147
157
  exports.PageProxy = PageProxy;
package/editorclient.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { CommandArgs, CommandName, HashAlgorithmEnum, TriggerAuthFlowResult, UnionToIntersection } from './commandtypes';
2
2
  import { JsonSerializable } from './core/jsonserializable';
3
- import { LinkImporter } from './core/linkimporter/linkimporter';
4
3
  import { UnfurlCallbacks } from './core/unfurl/unfurlcallbacks';
5
4
  import { BinaryXHRResponse, OAuthXHRRequest, TextXHRResponse, XHRRequest, XHRResponse } from './core/xhr';
6
5
  import { CollectionProxy } from './data/collectionproxy';
@@ -77,6 +76,15 @@ export declare class EditorClient {
77
76
  * @returns A promise that resolves when the user closes the settings modal.
78
77
  */
79
78
  showPackageSettingsModal(): Promise<void>;
79
+ /**
80
+ * If the extension package containing this editor extension has configurable settings, set the
81
+ * value of those settings for this installation of this extension. A subset of setting values
82
+ * can be provided to update those values while leaving others unchanged.
83
+ *
84
+ * If the user does not have permission to change settings on this installation of this
85
+ * extension, or if no settings exist, an error is thrown.
86
+ */
87
+ setPackageSettings(settings: Record<string, string> | Map<string, string>): Promise<undefined>;
80
88
  /**
81
89
  * If the extension package containing this editor extension has configurable settings,
82
90
  * fetch the current values of those settings for this installation of this extension.
@@ -194,11 +202,6 @@ export declare class EditorClient {
194
202
  * @param callbacks The callbacks to call when a link matching the domain is pasted.
195
203
  */
196
204
  registerUnfurlHandler(domain: string, callbacks: UnfurlCallbacks): void;
197
- /**
198
- * Registers a menu item for bulk importing links.
199
- * @param linkImporter The importer for getting URLs that will be imported onto the canvas as link unfurl blocks
200
- */
201
- registerLinkImporter(linkImporter: LinkImporter): void;
202
205
  /**
203
206
  * @ignore
204
207
  * @deprecated Use registerUnfurlHandler instead.
package/editorclient.js CHANGED
@@ -126,6 +126,26 @@ class EditorClient {
126
126
  async showPackageSettingsModal() {
127
127
  return this.sendCommand("spsm" /* CommandName.ShowPackageSettingsModal */, undefined);
128
128
  }
129
+ /**
130
+ * If the extension package containing this editor extension has configurable settings, set the
131
+ * value of those settings for this installation of this extension. A subset of setting values
132
+ * can be provided to update those values while leaving others unchanged.
133
+ *
134
+ * If the user does not have permission to change settings on this installation of this
135
+ * extension, or if no settings exist, an error is thrown.
136
+ */
137
+ async setPackageSettings(settings) {
138
+ let settingsAsRecord = {};
139
+ if (settings instanceof Map) {
140
+ for (const [key, value] of settings.entries()) {
141
+ settingsAsRecord[key] = value;
142
+ }
143
+ }
144
+ else {
145
+ settingsAsRecord = settings;
146
+ }
147
+ return this.sendCommand("sps" /* CommandName.SetPackageSettings */, settingsAsRecord);
148
+ }
129
149
  /**
130
150
  * If the extension package containing this editor extension has configurable settings,
131
151
  * fetch the current values of those settings for this installation of this extension.
@@ -318,20 +338,6 @@ class EditorClient {
318
338
  });
319
339
  this.sendCommand("ru" /* CommandName.RegisterUnfurl */, { 'd': domain, 'a': action });
320
340
  }
321
- /**
322
- * Registers a menu item for bulk importing links.
323
- * @param linkImporter The importer for getting URLs that will be imported onto the canvas as link unfurl blocks
324
- */
325
- registerLinkImporter(linkImporter) {
326
- const action = this.getUniqueActionName();
327
- this.registerAction(action, async () => { var _a; return (_a = (await linkImporter.getLinksForBulkImport())) !== null && _a !== void 0 ? _a : []; });
328
- this.sendCommand("rli" /* CommandName.RegisterLinkImporter */, {
329
- 'id': linkImporter.id,
330
- 'a': action,
331
- 'l': linkImporter.label,
332
- 'i': linkImporter.iconUrl,
333
- });
334
- }
335
341
  /**
336
342
  * @ignore
337
343
  * @deprecated Use registerUnfurlHandler instead.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.186",
3
+ "version": "0.0.188",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/ui/menu.d.ts CHANGED
@@ -2,7 +2,8 @@ import { EditorClient } from '../editorclient';
2
2
  export declare enum MenuType {
3
3
  Main = 1,
4
4
  /** The context menu that appears when the user right-clicks the canvas. */
5
- Context = 2
5
+ Context = 2,
6
+ ContentDock = 3
6
7
  }
7
8
  /**
8
9
  * Semantic locations to place a new menu item.
@@ -19,6 +20,13 @@ export declare enum MenuLocation {
19
20
  export interface CustomMenuItem {
20
21
  /** The text to display on the menu item */
21
22
  label: string;
23
+ /** The icon to display on the menu item.
24
+ * A URL (a data URI is fine) pointing to an icon representing the integration.
25
+ * This will be displayed at up to 32x32 CSS pixels in size.
26
+ *
27
+ * NOTE: Not all menuTypes support displaying an icon
28
+ */
29
+ iconUrl?: string;
22
30
  /** The registered action to run when the menu item is clicked */
23
31
  action?: string;
24
32
  /** If specified, what action's return value should determine if this menu item is visible? */
package/ui/menu.js CHANGED
@@ -6,6 +6,7 @@ var MenuType;
6
6
  MenuType[MenuType["Main"] = 1] = "Main";
7
7
  /** The context menu that appears when the user right-clicks the canvas. */
8
8
  MenuType[MenuType["Context"] = 2] = "Context";
9
+ MenuType[MenuType["ContentDock"] = 3] = "ContentDock";
9
10
  })(MenuType = exports.MenuType || (exports.MenuType = {}));
10
11
  /**
11
12
  * Semantic locations to place a new menu item.
@@ -41,8 +42,15 @@ class Menu {
41
42
  if (item.disabledAction && !this.client.actionExists(item.disabledAction)) {
42
43
  throw new Error('Unregistered action: ' + item.disabledAction);
43
44
  }
45
+ if (item.menuType == MenuType.ContentDock && !item.iconUrl) {
46
+ throw new Error('MenuType.ContentDock requires icon url');
47
+ }
48
+ if (item.menuType == MenuType.ContentDock && !item.action) {
49
+ throw new Error('MenuType.ContentDock requires action');
50
+ }
44
51
  this.client.sendCommand("ami" /* CommandName.AddMenuItem */, {
45
52
  'l': item.label,
53
+ 'i': item.iconUrl,
46
54
  'a': item.action,
47
55
  'v': item.visibleAction,
48
56
  'd': item.disabledAction,
@@ -1,16 +0,0 @@
1
- export interface LinkImporter {
2
- /** The id for this link importer */
3
- id: string;
4
- /** The text to display on the menu item */
5
- label: string;
6
- /** The icon to display on the menu item.
7
- * A URL (a data URI is fine) pointing to an icon representing the integration.
8
- * This will be displayed at up to 32x32 CSS pixels in size. */
9
- iconUrl: string;
10
- /** A method for getting URLs that will be imported onto the canvas as link unfurl blocks.
11
- * For example, this method could display a file picker, and return URLs for all of the selected files
12
- *
13
- * @return an array of urls for import
14
- * */
15
- getLinksForBulkImport: () => Promise<string[]>;
16
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });