lucid-extension-sdk 0.0.213 → 0.0.214

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
@@ -77,6 +77,7 @@ export declare const enum CommandName {
77
77
  GetRelativeLinePosition = "grlp",
78
78
  GetSelection = "gs",
79
79
  GetShapeData = "gsd",
80
+ GetSvg = "gsvg",
80
81
  GetTextStyle = "gts",
81
82
  GetUserId = "guid",
82
83
  GetVisibleRect = "gvr",
@@ -369,6 +370,10 @@ export type CommandArgs = {
369
370
  query: GetShapeDataQuery;
370
371
  result: GetShapeDataResult;
371
372
  };
373
+ [CommandName.GetSvg]: {
374
+ query: GetSvgQuery;
375
+ result: GetSvgResult;
376
+ };
372
377
  [CommandName.GetTextStyle]: {
373
378
  query: GetTextStyleQuery;
374
379
  result: GetTextStyleResult;
@@ -1097,6 +1102,17 @@ export type GetShapeDataQuery = {
1097
1102
  'n': string;
1098
1103
  };
1099
1104
  export type GetShapeDataResult = SerializedFieldType | SerializedDataError;
1105
+ export type GetSvgQuery = {
1106
+ /** Page ID to get an image of */
1107
+ 'p': string;
1108
+ /** True to include the background of the page */
1109
+ 'bg': boolean;
1110
+ /** If specified, the bounding box specifying what portion of the page to show */
1111
+ 'bb'?: Box | undefined;
1112
+ /** If specified, only include these item IDs */
1113
+ 'i'?: string[] | undefined;
1114
+ };
1115
+ export type GetSvgResult = Promise<string>;
1100
1116
  export type GetTextStyleQuery = {
1101
1117
  /** ID of the element to get text style from */
1102
1118
  'id': string;
package/commandtypes.js CHANGED
@@ -55,6 +55,7 @@ exports.commandTitles = new Map([
55
55
  ["grlp" /* CommandName.GetRelativeLinePosition */, 'GetRelativeLinePosition'],
56
56
  ["gs" /* CommandName.GetSelection */, 'GetSelection'],
57
57
  ["gsd" /* CommandName.GetShapeData */, 'GetShapeData'],
58
+ ["gsvg" /* CommandName.GetSvg */, 'GetSvg'],
58
59
  ["gts" /* CommandName.GetTextStyle */, 'GetTextStyle'],
59
60
  ["guid" /* CommandName.GetUserId */, 'GetUserId'],
60
61
  ["gvr" /* CommandName.GetVisibleRect */, 'GetVisibleRect'],
@@ -43,6 +43,10 @@ export declare class ItemProxy extends ElementProxy {
43
43
  * @param bb The bounding box to attempt to make this item fill
44
44
  */
45
45
  setBoundingBox(bb: Box): void;
46
+ /**
47
+ * @returns The ID of the page containing this item
48
+ */
49
+ getPageId(): string;
46
50
  /**
47
51
  * @returns The page containing this item
48
52
  */
@@ -71,11 +71,17 @@ class ItemProxy extends elementproxy_1.ElementProxy {
71
71
  });
72
72
  }
73
73
  }
74
+ /**
75
+ * @returns The ID of the page containing this item
76
+ */
77
+ getPageId() {
78
+ return this.client.sendCommand("gip" /* CommandName.GetItemPageId */, this.id);
79
+ }
74
80
  /**
75
81
  * @returns The page containing this item
76
82
  */
77
83
  getPage() {
78
- return this.client.getPageProxy(this.client.sendCommand("gip" /* CommandName.GetItemPageId */, this.id));
84
+ return this.client.getPageProxy(this.getPageId());
79
85
  }
80
86
  /**
81
87
  * @returns The x/y location of this item
@@ -118,4 +118,12 @@ export declare class PageProxy extends ElementProxy {
118
118
  prompt: string;
119
119
  idToLucidId: Map<string, string>;
120
120
  };
121
+ /**
122
+ *
123
+ * @param items If specified, only include these items in the resulting SVG
124
+ * @param includeBackground If true, include the background of the page in the SVG. Otherwise the background is transparent.
125
+ * @param viewBox If specified, crop the resulting SVG to the specified bounding box in page coordinates
126
+ * @returns A promise resolving to an SVG string
127
+ */
128
+ getSvg(items?: ItemProxy[], includeBackground?: boolean, viewBox?: Box): import("../commandtypes").GetSvgResult;
121
129
  }
@@ -192,5 +192,20 @@ class PageProxy extends elementproxy_1.ElementProxy {
192
192
  idToLucidId: new Map(Object.entries(result['id'])),
193
193
  };
194
194
  }
195
+ /**
196
+ *
197
+ * @param items If specified, only include these items in the resulting SVG
198
+ * @param includeBackground If true, include the background of the page in the SVG. Otherwise the background is transparent.
199
+ * @param viewBox If specified, crop the resulting SVG to the specified bounding box in page coordinates
200
+ * @returns A promise resolving to an SVG string
201
+ */
202
+ getSvg(items, includeBackground = false, viewBox) {
203
+ return this.client.sendCommand("gsvg" /* CommandName.GetSvg */, {
204
+ 'p': this.id,
205
+ 'bb': viewBox,
206
+ 'bg': includeBackground,
207
+ 'i': items === null || items === void 0 ? void 0 : items.map((item) => item.id),
208
+ });
209
+ }
195
210
  }
196
211
  exports.PageProxy = PageProxy;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.213",
3
+ "version": "0.0.214",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",