lucid-extension-sdk 0.0.254 → 0.0.256

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
@@ -60,6 +60,7 @@ export declare const enum CommandName {
60
60
  Download = "d",
61
61
  DragPointerMove = "dpm",
62
62
  DragPointerUp = "dpu",
63
+ DuplicateItems = "dis",
63
64
  ElementExists = "ee",
64
65
  ExecuteFormula = "ef",
65
66
  FindAvailableSpace = "fas",
@@ -303,6 +304,10 @@ export type CommandArgs = {
303
304
  query: DragPointerUpQuery;
304
305
  result: DragPointerUpResult;
305
306
  };
307
+ [CommandName.DuplicateItems]: {
308
+ query: DuplicateItemsQuery;
309
+ result: DuplicateItemsResult;
310
+ };
306
311
  [CommandName.ElementExists]: {
307
312
  query: ElementExistsQuery;
308
313
  result: ElementExistsResult;
@@ -1039,6 +1044,10 @@ export type DragPointerUpQuery = {
1039
1044
  'y': number;
1040
1045
  };
1041
1046
  export type DragPointerUpResult = undefined;
1047
+ export type DuplicateItemsQuery = {
1048
+ 'ids': string[];
1049
+ };
1050
+ export type DuplicateItemsResult = Promise<string[]>;
1042
1051
  export type ElementExistsQuery = {
1043
1052
  'id'?: string | undefined;
1044
1053
  };
package/commandtypes.js CHANGED
@@ -36,6 +36,7 @@ exports.commandTitles = new Map([
36
36
  ["d" /* CommandName.Download */, 'Download'],
37
37
  ["dpm" /* CommandName.DragPointerMove */, 'DragPointerMove'],
38
38
  ["dpu" /* CommandName.DragPointerUp */, 'DragPointerUp'],
39
+ ["dis" /* CommandName.DuplicateItems */, 'DuplicateItems'],
39
40
  ["ee" /* CommandName.ElementExists */, 'ElementExists'],
40
41
  ["ef" /* CommandName.ExecuteFormula */, 'ExecuteFormula'],
41
42
  ["fas" /* CommandName.FindAvailableSpace */, 'FindAvailableSpace'],
@@ -1,4 +1,4 @@
1
- import { GetDocumentChunksType } from '../commandtypes';
1
+ import { DuplicateItemsResult, GetDocumentChunksType } from '../commandtypes';
2
2
  import { EditorClient } from '../editorclient';
3
3
  import { DocumentChunk } from './documentchunk';
4
4
  import { CardConfigProxy } from './documentelement/cardconfigproxy';
@@ -96,4 +96,5 @@ export declare class DocumentProxy extends ElementProxy {
96
96
  * @param handle Return value from `hookDeleteItems`
97
97
  */
98
98
  unhookDeleteItems(handle: string): void;
99
+ duplicateItems(ids: string[]): DuplicateItemsResult;
99
100
  }
@@ -177,6 +177,9 @@ class DocumentProxy extends elementproxy_1.ElementProxy {
177
177
  this.client.deleteAction(handle);
178
178
  this.client.sendCommand("udi" /* CommandName.UnhookDeleteItems */, { 'n': handle });
179
179
  }
180
+ async duplicateItems(ids) {
181
+ return await this.client.sendCommand("dis" /* CommandName.DuplicateItems */, { 'ids': ids });
182
+ }
180
183
  }
181
184
  exports.DocumentProxy = DocumentProxy;
182
185
  DocumentProxy.nextHookId = 0;
@@ -166,4 +166,12 @@ export declare class PageProxy extends ElementProxy {
166
166
  * @returns A promise resolving to an SVG string
167
167
  */
168
168
  getSvg(items?: ItemProxy[], includeBackground?: boolean, viewBox?: Box): import("../commandtypes").GetSvgResult;
169
+ /**
170
+ * @returns the page number of this page
171
+ */
172
+ getPageNumber(): number;
173
+ /**
174
+ * Duplicates the page represented by the page proxy
175
+ */
176
+ duplicate(): Promise<void>;
169
177
  }
@@ -260,5 +260,17 @@ class PageProxy extends elementproxy_1.ElementProxy {
260
260
  'i': items === null || items === void 0 ? void 0 : items.map((item) => item.id),
261
261
  });
262
262
  }
263
+ /**
264
+ * @returns the page number of this page
265
+ */
266
+ getPageNumber() {
267
+ return this.properties.get('Order');
268
+ }
269
+ /**
270
+ * Duplicates the page represented by the page proxy
271
+ */
272
+ async duplicate() {
273
+ await this.client.duplicatePages([this.getPageNumber()]);
274
+ }
263
275
  }
264
276
  exports.PageProxy = PageProxy;
package/editorclient.d.ts CHANGED
@@ -256,6 +256,14 @@ export declare class EditorClient {
256
256
  * the import failed
257
257
  */
258
258
  importPage(documentId: string, pageNums: number[]): Promise<void>;
259
+ /**
260
+ * Duplicates one or more pages of the current document as new pages.
261
+ *
262
+ * @param pageNums An array of zero-indexed page indices to duplicate from the current document
263
+ * @returns a promise that resolves to void when the pages have been duplicated or the
264
+ * the duplication failed
265
+ */
266
+ duplicatePages(pageNums: number[]): Promise<void>;
259
267
  /**
260
268
  * Load the requested shape library's content, and if it was found, return a block definition ready to be
261
269
  * created.
package/editorclient.js CHANGED
@@ -449,6 +449,19 @@ class EditorClient {
449
449
  async importPage(documentId, pageNums) {
450
450
  return await this.sendCommand("imp" /* CommandName.ImportPage */, { 'id': documentId, 'n': pageNums });
451
451
  }
452
+ /**
453
+ * Duplicates one or more pages of the current document as new pages.
454
+ *
455
+ * @param pageNums An array of zero-indexed page indices to duplicate from the current document
456
+ * @returns a promise that resolves to void when the pages have been duplicated or the
457
+ * the duplication failed
458
+ */
459
+ async duplicatePages(pageNums) {
460
+ return await this.sendCommand("imp" /* CommandName.ImportPage */, {
461
+ 'id': this.sendCommand("gdid" /* CommandName.GetDocumentId */, undefined),
462
+ 'n': pageNums,
463
+ });
464
+ }
452
465
  /**
453
466
  * Load the requested shape library's content, and if it was found, return a block definition ready to be
454
467
  * created.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.254",
3
+ "version": "0.0.256",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",