lucid-extension-sdk 0.0.246 → 0.0.248

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
@@ -70,6 +70,7 @@ export declare const enum CommandName {
70
70
  GetCustomShape = "gcs",
71
71
  GetDataItemField = "gdif",
72
72
  GetDocumentAccessPermission = "gdap",
73
+ GetDocumentChunks = "gdc",
73
74
  GetDocumentId = "gdid",
74
75
  GetElementType = "get",
75
76
  GetEnvironmentConfig = "gec",
@@ -342,6 +343,10 @@ export type CommandArgs = {
342
343
  query: GetDocumentAccessPermissionQuery;
343
344
  result: GetDocumentAccessPermissionResult;
344
345
  };
346
+ [CommandName.GetDocumentChunks]: {
347
+ query: GetDocumentChunksQuery;
348
+ result: GetDocumentChunksResult;
349
+ };
345
350
  [CommandName.GetDocumentId]: {
346
351
  query: GetDocumentIdQuery;
347
352
  result: GetDocumentIdResult;
@@ -1112,6 +1117,29 @@ export type GetDataItemFieldQuery = {
1112
1117
  export type GetDataItemFieldResult = SerializedFieldType;
1113
1118
  export type GetDocumentAccessPermissionQuery = void;
1114
1119
  export type GetDocumentAccessPermissionResult = DocumentAccessPermission;
1120
+ export declare enum GetDocumentChunksType {
1121
+ /**
1122
+ * Breaks up a document into chunks geographically
1123
+ */
1124
+ Geographic = 0,
1125
+ /**
1126
+ * Breaks up a document into chunks by finding containing blocks
1127
+ */
1128
+ Container = 1
1129
+ }
1130
+ export type GetDocumentChunksQuery = {
1131
+ 't': GetDocumentChunksType[];
1132
+ };
1133
+ export type GetDocumentChunksResult = SerializedDocumentChunk[];
1134
+ type SerializedDocumentChunk = {
1135
+ /** Bounding box of all items combined */
1136
+ 'bb': Box;
1137
+ /** Ids of the items included in the chunk */
1138
+ 'i': string[];
1139
+ 't': string;
1140
+ /** Very brief description that helps describe the chunk */
1141
+ 'd': string;
1142
+ };
1115
1143
  export type GetDocumentIdQuery = void;
1116
1144
  export type GetDocumentIdResult = string;
1117
1145
  export type GetItemPageIdQuery = string;
@@ -1429,8 +1457,14 @@ export type RegisterPanelResult = undefined;
1429
1457
  export type RegisterUnfurlQuery = {
1430
1458
  /** Domain to unfurl, e.g. www.google.com */
1431
1459
  'd': string;
1432
- /** Action to call to configure the unfurl */
1433
- 'a': string;
1460
+ /** For backwards compatility */
1461
+ 'a'?: string | undefined;
1462
+ /** Unfurl Action name for the unfurl handler */
1463
+ 'ua'?: string | undefined;
1464
+ /** After Unfurl Action name for the unfurl handler */
1465
+ 'aua'?: string | undefined;
1466
+ /** Expand Callback Action name for the unfurl handler */
1467
+ 'e'?: string | undefined;
1434
1468
  };
1435
1469
  export type RegisterUnfurlResult = boolean;
1436
1470
  export type ReloadExtensionQuery = void;
@@ -1678,3 +1712,4 @@ export type ZOrderQuery = {
1678
1712
  'o': ZOrderOperation;
1679
1713
  };
1680
1714
  export type ZOrderResult = undefined;
1715
+ export {};
package/commandtypes.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZOrderOperation = exports.isRawSendXHRResponse = exports.MermaidDiagramType = exports.GetLLMContextType = exports.GetItemsAtSearchType = exports.HashAlgorithmEnum = exports.commandTitles = void 0;
3
+ exports.ZOrderOperation = exports.isRawSendXHRResponse = exports.MermaidDiagramType = exports.GetLLMContextType = exports.GetItemsAtSearchType = exports.GetDocumentChunksType = exports.HashAlgorithmEnum = exports.commandTitles = void 0;
4
4
  const checks_1 = require("./core/checks");
5
5
  /** @ignore */
6
6
  exports.commandTitles = new Map([
@@ -46,6 +46,7 @@ exports.commandTitles = new Map([
46
46
  ["gcs" /* CommandName.GetCustomShape */, 'GetCustomShape'],
47
47
  ["gdif" /* CommandName.GetDataItemField */, 'GetDataItemField'],
48
48
  ["gdap" /* CommandName.GetDocumentAccessPermission */, 'GetDocumentAccessPermission'],
49
+ ["gdc" /* CommandName.GetDocumentChunks */, 'GetDocumentChunks'],
49
50
  ["gdid" /* CommandName.GetDocumentId */, 'GetDocumentId'],
50
51
  ["get" /* CommandName.GetElementType */, 'GetElementType'],
51
52
  ["gec" /* CommandName.GetEnvironmentConfig */, 'GetEnvironmentConfig'],
@@ -131,6 +132,17 @@ var HashAlgorithmEnum;
131
132
  /** Use the SHA 256 hashing algorithm */
132
133
  HashAlgorithmEnum["sha256"] = "SHA256";
133
134
  })(HashAlgorithmEnum || (exports.HashAlgorithmEnum = HashAlgorithmEnum = {}));
135
+ var GetDocumentChunksType;
136
+ (function (GetDocumentChunksType) {
137
+ /**
138
+ * Breaks up a document into chunks geographically
139
+ */
140
+ GetDocumentChunksType[GetDocumentChunksType["Geographic"] = 0] = "Geographic";
141
+ /**
142
+ * Breaks up a document into chunks by finding containing blocks
143
+ */
144
+ GetDocumentChunksType[GetDocumentChunksType["Container"] = 1] = "Container";
145
+ })(GetDocumentChunksType || (exports.GetDocumentChunksType = GetDocumentChunksType = {}));
134
146
  var GetItemsAtSearchType;
135
147
  (function (GetItemsAtSearchType) {
136
148
  GetItemsAtSearchType[GetItemsAtSearchType["PossiblyOverlapping"] = 0] = "PossiblyOverlapping";
@@ -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
  */
@@ -0,0 +1,25 @@
1
+ import { Box } from '../math';
2
+ import { ItemProxy } from './itemproxy';
3
+ /**
4
+ * @ignore
5
+ * A representation of separated portions of the document
6
+ */
7
+ export interface DocumentChunk {
8
+ /**
9
+ * THe bounding box of all items combined
10
+ */
11
+ boundingBox: Box;
12
+ /**
13
+ * Items included in the chunk
14
+ */
15
+ items: ItemProxy[];
16
+ /**
17
+ * All displayed text in the chunk
18
+ */
19
+ text: string;
20
+ /**
21
+ * Very brief description that helps describe the chunk. This will be used
22
+ * as part of the page name when writing to pages.
23
+ */
24
+ description: string;
25
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,6 @@
1
+ import { GetDocumentChunksType } from '../commandtypes';
1
2
  import { EditorClient } from '../editorclient';
3
+ import { DocumentChunk } from './documentchunk';
2
4
  import { CardConfigProxy } from './documentelement/cardconfigproxy';
3
5
  import { RuleProxy } from './documentelement/ruleproxy';
4
6
  import { ElementProxy } from './elementproxy';
@@ -41,6 +43,8 @@ export declare class DocumentProxy extends ElementProxy {
41
43
  * @returns The title of this document
42
44
  */
43
45
  getTitle(): string;
46
+ /** @ignore */
47
+ getDocumentChunks(types: GetDocumentChunksType[]): DocumentChunk[];
44
48
  /**
45
49
  * Infrequently, you may need to watch for *any* changes to the document. These changes may be
46
50
  * the local user adding content, or a data integration sending updated records to a data collection,
@@ -5,6 +5,7 @@ const cardconfigproxy_1 = require("./documentelement/cardconfigproxy");
5
5
  const documentelementtype_1 = require("./documentelement/documentelementtype");
6
6
  const ruleproxy_1 = require("./documentelement/ruleproxy");
7
7
  const elementproxy_1 = require("./elementproxy");
8
+ const itemproxy_1 = require("./itemproxy");
8
9
  const mapproxy_1 = require("./mapproxy");
9
10
  const pageproxy_1 = require("./pageproxy");
10
11
  /**
@@ -70,6 +71,20 @@ class DocumentProxy extends elementproxy_1.ElementProxy {
70
71
  getTitle() {
71
72
  return this.properties.get('Title');
72
73
  }
74
+ /** @ignore */
75
+ getDocumentChunks(types) {
76
+ const chunks = this.client.sendCommand("gdc" /* CommandName.GetDocumentChunks */, { 't': types });
77
+ return chunks.map((chunk) => {
78
+ return {
79
+ boundingBox: chunk['bb'],
80
+ items: chunk['i']
81
+ .map((id) => this.client.getElementProxy(id))
82
+ .filter((element) => element instanceof itemproxy_1.ItemProxy),
83
+ text: chunk['t'],
84
+ description: chunk['d'],
85
+ };
86
+ });
87
+ }
73
88
  /**
74
89
  * Infrequently, you may need to watch for *any* changes to the document. These changes may be
75
90
  * the local user adding content, or a data integration sending updated records to a data collection,
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.246",
3
+ "version": "0.0.248",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",