lucid-extension-sdk 0.0.245 → 0.0.247

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
@@ -45,6 +45,7 @@ export declare const enum CommandName {
45
45
  CreateCollection = "cc",
46
46
  CreateDataSource = "cds",
47
47
  CreateDocumentElement = "cde",
48
+ CreateGroup = "cg",
48
49
  CreateLine = "cl",
49
50
  CreatePage = "cp",
50
51
  CreateUserImage = "cui",
@@ -241,6 +242,10 @@ export type CommandArgs = {
241
242
  query: CreateDocumentElementQuery;
242
243
  result: CreateDocumentElementResult;
243
244
  };
245
+ [CommandName.CreateGroup]: {
246
+ query: CreateGroupQuery;
247
+ result: CreateGroupResult;
248
+ };
244
249
  [CommandName.CreateLine]: {
245
250
  query: CreateLineQuery;
246
251
  result: CreateLineResult;
@@ -886,6 +891,16 @@ export type CreateBlockQuery = {
886
891
  's'?: JsonSerializable | undefined;
887
892
  };
888
893
  export type CreateBlockResult = string;
894
+ export type CreateGroupQuery = {
895
+ /**
896
+ * By default, we add the group to the current page & currently active group. If specified, the
897
+ * group will instead be created as a direct child of the given page.
898
+ */
899
+ 'p'?: string | undefined;
900
+ /** List of item IDs to group */
901
+ 'i': string[];
902
+ };
903
+ export type CreateGroupResult = string;
889
904
  export type CreateCollectionFieldDefinition = {
890
905
  /** Name of the field */
891
906
  'n': string;
@@ -1414,8 +1429,14 @@ export type RegisterPanelResult = undefined;
1414
1429
  export type RegisterUnfurlQuery = {
1415
1430
  /** Domain to unfurl, e.g. www.google.com */
1416
1431
  'd': string;
1417
- /** Action to call to configure the unfurl */
1418
- 'a': string;
1432
+ /** For backwards compatility */
1433
+ 'a'?: string | undefined;
1434
+ /** Unfurl Action name for the unfurl handler */
1435
+ 'ua'?: string | undefined;
1436
+ /** After Unfurl Action name for the unfurl handler */
1437
+ 'aua'?: string | undefined;
1438
+ /** Expand Callback Action name for the unfurl handler */
1439
+ 'e'?: string | undefined;
1419
1440
  };
1420
1441
  export type RegisterUnfurlResult = boolean;
1421
1442
  export type ReloadExtensionQuery = void;
package/commandtypes.js CHANGED
@@ -23,6 +23,7 @@ exports.commandTitles = new Map([
23
23
  ["cc" /* CommandName.CreateCollection */, 'CreateCollection'],
24
24
  ["cds" /* CommandName.CreateDataSource */, 'CreateDataSource'],
25
25
  ["cde" /* CommandName.CreateDocumentElement */, 'CreateDocumentElement'],
26
+ ["cg" /* CommandName.CreateGroup */, 'CreateGroup'],
26
27
  ["cl" /* CommandName.CreateLine */, 'CreateLine'],
27
28
  ["cp" /* CommandName.CreatePage */, 'CreatePage'],
28
29
  ["die" /* CommandName.DataItemExists */, 'DataItemExists'],
@@ -3,7 +3,8 @@ import { UnfurlDetails } from './unfurldetails';
3
3
  import { UnfurlRefreshErrorType } from './unfurlrefresherrortype';
4
4
  export declare enum UnfurlCallbackType {
5
5
  Unfurl = "u",
6
- AfterUnfurl = "a"
6
+ AfterUnfurl = "a",
7
+ ExpandCallback = "e"
7
8
  }
8
9
  /**
9
10
  * The callbacks that handle unfurls and refreshing.
@@ -33,4 +34,12 @@ export interface UnfurlCallbacks {
33
34
  * @param blockProxy The block proxy of the unfurl block
34
35
  */
35
36
  afterUnfurlCallback?: (blockProxy: LinkUnfurlBlockProxy, url: string) => Promise<void>;
37
+ /**
38
+ * Callback upon clicking expand button.
39
+ * Occurs before attempting to expand iframe.
40
+ *
41
+ * @param blockProxy The block proxy of the unfurl block
42
+ * @param url The url to unfurl
43
+ */
44
+ expandCallback?: (blockProxy: LinkUnfurlBlockProxy, url: string) => Promise<void>;
36
45
  }
@@ -5,4 +5,5 @@ var UnfurlCallbackType;
5
5
  (function (UnfurlCallbackType) {
6
6
  UnfurlCallbackType["Unfurl"] = "u";
7
7
  UnfurlCallbackType["AfterUnfurl"] = "a";
8
+ UnfurlCallbackType["ExpandCallback"] = "e";
8
9
  })(UnfurlCallbackType || (exports.UnfurlCallbackType = UnfurlCallbackType = {}));
@@ -39,6 +39,10 @@ export declare class LinkUnfurlBlockProxy extends BlockProxy {
39
39
  * Sets the URL to be loaded in an iframe when the user clicks the "Expand" action on the block.
40
40
  */
41
41
  setIframe(unfurlIframe: UnfurlIframe): void;
42
+ /**
43
+ * Returns true if there is an iframe URL already set for this unfurl block
44
+ */
45
+ hasIframe(): boolean;
42
46
  /**
43
47
  * Sets the main thumbnail on the block
44
48
  */
@@ -60,6 +60,12 @@ class LinkUnfurlBlockProxy extends blockproxy_1.BlockProxy {
60
60
  this.properties.set('LinkUnfurlIframeHeight', iframeAttributes.height);
61
61
  this.properties.set('LinkUnfurlIframeWidth', iframeAttributes.width);
62
62
  }
63
+ /**
64
+ * Returns true if there is an iframe URL already set for this unfurl block
65
+ */
66
+ hasIframe() {
67
+ return !!this.properties.get('LinkUnfurlIframeHtml');
68
+ }
63
69
  /**
64
70
  * Sets the main thumbnail on the block
65
71
  */
@@ -86,6 +86,13 @@ export declare class PageProxy extends ElementProxy {
86
86
  * @returns The added block
87
87
  */
88
88
  addBlock(def: BlockDefinition): BlockProxy;
89
+ /**
90
+ * Creates a new group from a list of items.
91
+ *
92
+ * @param blocks A non-empty array of items to group
93
+ * @returns The added group
94
+ */
95
+ groupBlocks(blocks: BlockProxy[]): GroupProxy;
89
96
  /**
90
97
  * Add a new line to this page.
91
98
  * @param def The definition of the new line to add
@@ -128,6 +128,19 @@ class PageProxy extends elementproxy_1.ElementProxy {
128
128
  }
129
129
  return block;
130
130
  }
131
+ /**
132
+ * Creates a new group from a list of items.
133
+ *
134
+ * @param blocks A non-empty array of items to group
135
+ * @returns The added group
136
+ */
137
+ groupBlocks(blocks) {
138
+ const id = this.client.sendCommand("cg" /* CommandName.CreateGroup */, {
139
+ 'p': this.id,
140
+ 'i': blocks.map((block) => block.id),
141
+ });
142
+ return new groupproxy_1.GroupProxy(id, this.client);
143
+ }
131
144
  /**
132
145
  * Add a new line to this page.
133
146
  * @param def The definition of the new line to add
package/editorclient.js CHANGED
@@ -4,7 +4,6 @@ exports.EditorClient = void 0;
4
4
  const commandtypes_1 = require("./commandtypes");
5
5
  const base64_1 = require("./core/base64");
6
6
  const checks_1 = require("./core/checks");
7
- const unfurlcallbacks_1 = require("./core/unfurl/unfurlcallbacks");
8
7
  const unfurldetails_1 = require("./core/unfurl/unfurldetails");
9
8
  const unfurlrefresherrortype_1 = require("./core/unfurl/unfurlrefresherrortype");
10
9
  const collectionproxy_1 = require("./data/collectionproxy");
@@ -318,36 +317,55 @@ class EditorClient {
318
317
  * @param callbacks The callbacks to call when a link matching the domain is pasted.
319
318
  */
320
319
  registerUnfurlHandler(domain, callbacks) {
321
- const action = this.getUniqueActionName();
322
- this.registerAction(action, async (rawMsg) => {
323
- var _a;
320
+ const unfurlAction = this.getUniqueActionName();
321
+ let afterUnfurlAction = undefined;
322
+ let expandAction = undefined;
323
+ this.registerAction(unfurlAction, async (rawMsg) => {
324
324
  const msg = (0, unfurleventmessage_1.deserializeUnfurlEventMessage)(rawMsg);
325
- switch (msg.unfurlCallbackType) {
326
- case unfurlcallbacks_1.UnfurlCallbackType.Unfurl: {
327
- try {
328
- const result = await callbacks.unfurlCallback(msg.url);
329
- if (result && !(0, unfurlrefresherrortype_1.unfurlRefreshErrorTypeValidator)(result)) {
330
- return (0, unfurldetails_1.serializeUnfurlDetails)(result);
331
- }
332
- }
333
- catch (err) {
334
- return unfurlrefresherrortype_1.UnfurlRefreshErrorType.GenericFailure;
325
+ try {
326
+ const result = await callbacks.unfurlCallback(msg.url);
327
+ if (result && !(0, unfurlrefresherrortype_1.unfurlRefreshErrorTypeValidator)(result)) {
328
+ return (0, unfurldetails_1.serializeUnfurlDetails)(result);
329
+ }
330
+ }
331
+ catch (err) {
332
+ return unfurlrefresherrortype_1.UnfurlRefreshErrorType.GenericFailure;
333
+ }
334
+ return undefined;
335
+ });
336
+ if (callbacks.afterUnfurlCallback) {
337
+ afterUnfurlAction = this.getUniqueActionName();
338
+ this.registerAction(afterUnfurlAction, async (rawMsg) => {
339
+ var _a;
340
+ const msg = (0, unfurleventmessage_1.deserializeUnfurlEventMessage)(rawMsg);
341
+ if (msg.blockId) {
342
+ const proxy = this.getBlockProxy(msg.blockId);
343
+ if (proxy instanceof linkunfurlblockproxy_1.LinkUnfurlBlockProxy) {
344
+ await ((_a = callbacks.afterUnfurlCallback) === null || _a === void 0 ? void 0 : _a.call(callbacks, proxy, msg.url));
335
345
  }
336
- break;
337
346
  }
338
- case unfurlcallbacks_1.UnfurlCallbackType.AfterUnfurl: {
339
- if (msg.blockId) {
340
- const proxy = this.getBlockProxy(msg.blockId);
341
- if (proxy instanceof linkunfurlblockproxy_1.LinkUnfurlBlockProxy) {
342
- await ((_a = callbacks.afterUnfurlCallback) === null || _a === void 0 ? void 0 : _a.call(callbacks, proxy, msg.url));
343
- }
347
+ return undefined;
348
+ });
349
+ }
350
+ if (callbacks.expandCallback) {
351
+ expandAction = this.getUniqueActionName();
352
+ this.registerAction(expandAction, async (rawMsg) => {
353
+ var _a;
354
+ const msg = (0, unfurleventmessage_1.deserializeUnfurlEventMessage)(rawMsg);
355
+ if (msg.blockId) {
356
+ const proxy = this.getBlockProxy(msg.blockId);
357
+ if (proxy instanceof linkunfurlblockproxy_1.LinkUnfurlBlockProxy) {
358
+ await ((_a = callbacks.expandCallback) === null || _a === void 0 ? void 0 : _a.call(callbacks, proxy, msg.url));
344
359
  }
345
- break;
346
360
  }
347
- }
348
- return undefined;
361
+ });
362
+ }
363
+ this.sendCommand("ru" /* CommandName.RegisterUnfurl */, {
364
+ 'd': domain,
365
+ 'ua': unfurlAction,
366
+ 'aua': afterUnfurlAction,
367
+ 'e': expandAction,
349
368
  });
350
- this.sendCommand("ru" /* CommandName.RegisterUnfurl */, { 'd': domain, 'a': action });
351
369
  }
352
370
  /**
353
371
  * @ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.245",
3
+ "version": "0.0.247",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",