lucid-extension-sdk 0.0.176 → 0.0.178

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
@@ -52,6 +52,7 @@ export declare const enum CommandName {
52
52
  DragPointerUp = "dpu",
53
53
  ElementExists = "ee",
54
54
  ExecuteFormula = "ef",
55
+ FindAvailableSpace = "fas",
55
56
  GetConnectedLines = "gcl",
56
57
  GetCurrentPage = "gcp",
57
58
  GetCustomShape = "gcs",
@@ -267,6 +268,10 @@ export type CommandArgs = {
267
268
  query: ExecuteFormulaQuery;
268
269
  result: ExecuteFormulaResult;
269
270
  };
271
+ [CommandName.FindAvailableSpace]: {
272
+ query: FindAvailableSpaceQuery;
273
+ result: FindAvailableSpaceResult;
274
+ };
270
275
  [CommandName.GetConnectedLines]: {
271
276
  query: GetConnectedLinesQuery;
272
277
  result: GetConnectedLinesResult;
@@ -905,6 +910,20 @@ export type ExecuteFormulaQuery = {
905
910
  'f': string;
906
911
  };
907
912
  export type ExecuteFormulaResult = SerializedFieldType | SerializedDataError;
913
+ export type FindAvailableSpaceQuery = {
914
+ /** Width */
915
+ 'w': number;
916
+ /** Height */
917
+ 'h': number;
918
+ };
919
+ export type FindAvailableSpaceResult = {
920
+ /** ID of the page you should add content to */
921
+ 'p': string;
922
+ /** Origin of the rectangle of empty space */
923
+ 'x': number;
924
+ /** Origin of the rectangle of empty space */
925
+ 'y': number;
926
+ };
908
927
  export type AnimateViewportQuery = {
909
928
  /** ID of the page to view */
910
929
  'p': string;
package/commandtypes.js CHANGED
@@ -33,6 +33,7 @@ exports.commandTitles = new Map([
33
33
  ["dpu" /* CommandName.DragPointerUp */, 'DragPointerUp'],
34
34
  ["ee" /* CommandName.ElementExists */, 'ElementExists'],
35
35
  ["ef" /* CommandName.ExecuteFormula */, 'ExecuteFormula'],
36
+ ["fas" /* CommandName.FindAvailableSpace */, 'FindAvailableSpace'],
36
37
  ["gcl" /* CommandName.GetConnectedLines */, 'GetConnectedLines'],
37
38
  ["gcp" /* CommandName.GetCurrentPage */, 'GetCurrentPage'],
38
39
  ["gcs" /* CommandName.GetCustomShape */, 'GetCustomShape'],
@@ -10,13 +10,13 @@ export interface SerializedReferenceKey {
10
10
  'f'?: {
11
11
  'ts': number;
12
12
  'pd': TypedSerializedFlattenedReference;
13
- 'md'?: SerializedFields;
14
- 'e'?: string;
13
+ 'md'?: SerializedFields | undefined;
14
+ 'e'?: string | undefined;
15
15
  } | undefined;
16
16
  }
17
17
  export type TypedSerializedFlattenedReference = {
18
18
  'sc': SerializedSchema;
19
- 'n'?: string;
19
+ 'n'?: string | undefined;
20
20
  'd': {
21
21
  [index: string]: SerializedFieldType;
22
22
  };
@@ -22,6 +22,10 @@ export declare class DocumentProxy extends ElementProxy {
22
22
  * An iterator over all blocks on all pages of the document
23
23
  */
24
24
  allBlocks(): Generator<import("./blockproxy").BlockProxy, void, unknown>;
25
+ /**
26
+ * An iterator over all lines on all pages of the document
27
+ */
28
+ allLines(): Generator<import("./lineproxy").LineProxy, void, unknown>;
25
29
  /**
26
30
  * Add a new page to the current document
27
31
  * @param def Definition of the page to add
@@ -36,6 +36,16 @@ class DocumentProxy extends elementproxy_1.ElementProxy {
36
36
  }
37
37
  }
38
38
  }
39
+ /**
40
+ * An iterator over all lines on all pages of the document
41
+ */
42
+ *allLines() {
43
+ for (const page of this.pages.values()) {
44
+ for (const line of page.lines.values()) {
45
+ yield line;
46
+ }
47
+ }
48
+ }
39
49
  /**
40
50
  * Add a new page to the current document
41
51
  * @param def Definition of the page to add
@@ -6,7 +6,7 @@ import { LineTextAreaPositioning } from './linetextareapositioning';
6
6
  export declare enum LineShape {
7
7
  Curve = "curve",
8
8
  Elbow = "elbow",
9
- Straight = "straight"
9
+ Diagonal = "diagonal"
10
10
  }
11
11
  /**
12
12
  * A line on the current Lucid document
@@ -9,7 +9,7 @@ var LineShape;
9
9
  (function (LineShape) {
10
10
  LineShape["Curve"] = "curve";
11
11
  LineShape["Elbow"] = "elbow";
12
- LineShape["Straight"] = "straight";
12
+ LineShape["Diagonal"] = "diagonal";
13
13
  })(LineShape = exports.LineShape || (exports.LineShape = {}));
14
14
  /**
15
15
  * A line on the current Lucid document
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.176",
3
+ "version": "0.0.178",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/ui/modal.js CHANGED
@@ -19,6 +19,7 @@ class Modal extends iframeui_1.IframeUI {
19
19
  this.visible = false;
20
20
  }
21
21
  frameClosed() {
22
+ this.visible = false;
22
23
  this.unhookMessages();
23
24
  }
24
25
  show() {
package/ui/viewport.d.ts CHANGED
@@ -21,6 +21,18 @@ export declare class Viewport {
21
21
  * @returns An array of currently-selected items on the currently-visible page
22
22
  */
23
23
  getSelectedItems(deep?: boolean): ItemProxy[];
24
+ /**
25
+ * Find available space on the current page for adding new content.
26
+ * @param width
27
+ * @param height
28
+ * @returns a reference to the page and origin (upper-left point) of the space you can add new
29
+ * content of the given size to.
30
+ */
31
+ findAvailableSpace(width: number, height: number): {
32
+ page: PageProxy;
33
+ x: number;
34
+ y: number;
35
+ };
24
36
  /**
25
37
  * @returns the page currently being viewed
26
38
  */
package/ui/viewport.js CHANGED
@@ -23,6 +23,21 @@ class Viewport {
23
23
  .map((id) => this.client.getElementProxy(id))
24
24
  .filter((proxy) => proxy instanceof itemproxy_1.ItemProxy);
25
25
  }
26
+ /**
27
+ * Find available space on the current page for adding new content.
28
+ * @param width
29
+ * @param height
30
+ * @returns a reference to the page and origin (upper-left point) of the space you can add new
31
+ * content of the given size to.
32
+ */
33
+ findAvailableSpace(width, height) {
34
+ const result = this.client.sendCommand("fas" /* CommandName.FindAvailableSpace */, { 'w': width, 'h': height });
35
+ return {
36
+ page: new pageproxy_1.PageProxy(result['p'], this.client),
37
+ x: result['x'],
38
+ y: result['y'],
39
+ };
40
+ }
26
41
  /**
27
42
  * @returns the page currently being viewed
28
43
  */