lucid-extension-sdk 0.0.187 → 0.0.189

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",
@@ -396,6 +396,10 @@ export type CommandArgs = {
396
396
  query: ImportCardsQuery;
397
397
  result: ImportCardsResult;
398
398
  };
399
+ [CommandName.ImportLinks]: {
400
+ query: ImportLinksQuery;
401
+ result: ImportLinksResult;
402
+ };
399
403
  [CommandName.ImportPage]: {
400
404
  query: ImportPageQuery;
401
405
  result: ImportPageResult;
@@ -472,10 +476,6 @@ export type CommandArgs = {
472
476
  query: PromptQuery;
473
477
  result: PromptResult;
474
478
  };
475
- [CommandName.RegisterLinkImporter]: {
476
- query: RegisterLinkImporterQuery;
477
- result: RegisterLinkImporterResult;
478
- };
479
479
  [CommandName.RegisterPanel]: {
480
480
  query: RegisterPanelQuery;
481
481
  result: RegisterPanelResult;
@@ -662,6 +662,8 @@ export type UnionToIntersection<T> = (T extends any ? (x: T) => unknown : never)
662
662
  export type AddMenuItemQuery = {
663
663
  /** Label to display on the menu item */
664
664
  'l': string;
665
+ /** Url of the Icon to display on the menu item */
666
+ 'i'?: string | undefined;
665
667
  /** Named action to run when the menu item is clicked */
666
668
  'a'?: string | undefined;
667
669
  /** Named action that returns whether the menu item should be visible */
@@ -708,10 +710,6 @@ export type AddSpreadsheetIntegrationQuery = {
708
710
  'gs': string;
709
711
  /** getMultipleSheetsForSpreadsheetDetails */
710
712
  'gm': string;
711
- /** getSpreadsheetData */
712
- 'gd': string;
713
- /** importIsComplete */
714
- 'ic': string;
715
713
  };
716
714
  /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
717
715
  export type AddSpreadsheetIntegrationResult = undefined;
@@ -1096,6 +1094,15 @@ export type HookTextEditResult = undefined;
1096
1094
  export type ImportCardsQuery = string;
1097
1095
  /** Resolves when the import dialog is closed */
1098
1096
  export type ImportCardsResult = Promise<void>;
1097
+ export type ImportLinksQuery = {
1098
+ /**
1099
+ * By default, we import the links onto the current page. If specified, the links will instead be imported onto the given page.
1100
+ */
1101
+ 'p'?: string | undefined;
1102
+ /** Links to be imported onto the canvas as link unfurl blocks*/
1103
+ 'l': string[];
1104
+ };
1105
+ export type ImportLinksResult = void;
1099
1106
  export type ImportPageQuery = {
1100
1107
  /** The ID of the document or template to import */
1101
1108
  'id': string;
@@ -1184,17 +1191,6 @@ export type PromptQuery = {
1184
1191
  'b': string;
1185
1192
  };
1186
1193
  export type PromptResult = Promise<string | undefined>;
1187
- export type RegisterLinkImporterQuery = {
1188
- /** ID of the link importer*/
1189
- 'id': string;
1190
- /** Action to call to get links for bulk import */
1191
- 'a': string;
1192
- /** Label for the menu item */
1193
- 'l': string;
1194
- /** Icon URL of the menu item, preferably a base64-encoded URL */
1195
- 'i': string;
1196
- };
1197
- export type RegisterLinkImporterResult = void;
1198
1194
  export type RegisterPanelQuery = {
1199
1195
  /** Name of the panel's action for receiving events; generated automatically by Panel base class */
1200
1196
  'n': string;
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'],
@@ -0,0 +1,10 @@
1
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
2
+ export interface SerializedPreviewDataPayload<CONFIG, SHEET> {
3
+ 'SpreadsheetDetails': CONFIG;
4
+ 'Sheets': [SHEET, string][];
5
+ }
6
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
7
+ export declare function isSerializedPreviewDataPayload<CONFIG, SHEET>(configValidator: (x: unknown) => x is CONFIG, sheetValidator: (x: unknown) => x is SHEET): (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
8
+ SpreadsheetDetails: (x: unknown) => x is CONFIG;
9
+ Sheets: (p1: unknown) => p1 is [SHEET, string][];
10
+ }>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSerializedPreviewDataPayload = void 0;
4
+ const checks_1 = require("../../checks");
5
+ const validators_1 = require("../../validators/validators");
6
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
7
+ function isSerializedPreviewDataPayload(configValidator, sheetValidator) {
8
+ return (0, validators_1.strictObjectValidator)({
9
+ 'SpreadsheetDetails': configValidator,
10
+ 'Sheets': (0, validators_1.arrayValidator)((0, validators_1.tupleValidator)(sheetValidator, checks_1.isString)),
11
+ });
12
+ }
13
+ exports.isSerializedPreviewDataPayload = isSerializedPreviewDataPayload;
@@ -1,4 +1,3 @@
1
- import { SerializedImportedDataSource } from '../data/datasource/serializedimporteddatasource';
2
1
  import { SerializedUpstreamConfig } from '../data/datasource/serializedupstreamconfig';
3
2
  import { SerializedSchema } from '../data/serializedfield/serializedschema';
4
3
  import { JsonSerializable } from '../jsonserializable';
@@ -30,6 +29,4 @@ export declare abstract class LucidSpreadsheetIntegration<CONFIG extends JsonSer
30
29
  abstract dataConnectorName: string;
31
30
  abstract getSpreadsheetDetailsToImport(): Promise<CONFIG | LucidSpreadsheetIntegrationFailureType>;
32
31
  abstract getMultipleSheetsForSpreadsheetDetails(spreadsheetDetails: CONFIG): Promise<Map<SHEET, string> | LucidSpreadsheetIntegrationFailureType>;
33
- abstract getSpreadsheetData(spreadsheetDetails: CONFIG, sheets: SHEET[]): Promise<SerializedImportedDataSource | LucidSpreadsheetIntegrationFailureType>;
34
- abstract importIsComplete(syncDataSourceIdNonce: string, importedResults: ImportedResults): void;
35
32
  }
@@ -34,26 +34,12 @@ class LucidSpreadsheetIntegrationRegistry {
34
34
  catch (error) { }
35
35
  return lucidspreadsheetintegration_1.LucidSpreadsheetIntegrationFailureType.GenericFailure;
36
36
  });
37
- const getSpreadsheetDataActionName = LucidSpreadsheetIntegrationRegistry.nextHookName();
38
- client.registerAction(getSpreadsheetDataActionName, async (message) => {
39
- try {
40
- return await spreadsheetIntegration.getSpreadsheetData(message['spreadsheetDetails'], message['sheets']);
41
- }
42
- catch (error) { }
43
- return lucidspreadsheetintegration_1.LucidSpreadsheetIntegrationFailureType.GenericFailure;
44
- });
45
- const importIsCompleteActionName = LucidSpreadsheetIntegrationRegistry.nextHookName();
46
- client.registerAction(importIsCompleteActionName, async (message) => {
47
- spreadsheetIntegration.importIsComplete(message['SyncDataSourceIdNonce'], message['ImportedResults']);
48
- });
49
37
  const serialized = {
50
38
  'ld': spreadsheetIntegration.labelDescription,
51
39
  'li': spreadsheetIntegration.labelIconUrl,
52
40
  'dc': spreadsheetIntegration.dataConnectorName,
53
41
  'gs': getSpreadsheetDetailsToImportActionName,
54
42
  'gm': getMultipleSheetsForSpreadsheetDetailsActionName,
55
- 'gd': getSpreadsheetDataActionName,
56
- 'ic': importIsCompleteActionName,
57
43
  };
58
44
  client.sendCommand("asi" /* CommandName.AddSpreadsheetIntegration */, serialized);
59
45
  }
@@ -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';
@@ -203,11 +202,6 @@ export declare class EditorClient {
203
202
  * @param callbacks The callbacks to call when a link matching the domain is pasted.
204
203
  */
205
204
  registerUnfurlHandler(domain: string, callbacks: UnfurlCallbacks): void;
206
- /**
207
- * Registers a menu item for bulk importing links.
208
- * @param linkImporter The importer for getting URLs that will be imported onto the canvas as link unfurl blocks
209
- */
210
- registerLinkImporter(linkImporter: LinkImporter): void;
211
205
  /**
212
206
  * @ignore
213
207
  * @deprecated Use registerUnfurlHandler instead.
package/editorclient.js CHANGED
@@ -338,20 +338,6 @@ class EditorClient {
338
338
  });
339
339
  this.sendCommand("ru" /* CommandName.RegisterUnfurl */, { 'd': domain, 'a': action });
340
340
  }
341
- /**
342
- * Registers a menu item for bulk importing links.
343
- * @param linkImporter The importer for getting URLs that will be imported onto the canvas as link unfurl blocks
344
- */
345
- registerLinkImporter(linkImporter) {
346
- const action = this.getUniqueActionName();
347
- this.registerAction(action, async () => { var _a; return (_a = (await linkImporter.getLinksForBulkImport())) !== null && _a !== void 0 ? _a : []; });
348
- this.sendCommand("rli" /* CommandName.RegisterLinkImporter */, {
349
- 'id': linkImporter.id,
350
- 'a': action,
351
- 'l': linkImporter.label,
352
- 'i': linkImporter.iconUrl,
353
- });
354
- }
355
341
  /**
356
342
  * @ignore
357
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.187",
3
+ "version": "0.0.189",
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 });