lucid-extension-sdk 0.0.79 → 0.0.81

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.79",
3
+ "version": "0.0.81",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -40,6 +40,8 @@ export declare const enum CommandName {
40
40
  DeletePage = "dp",
41
41
  DeleteShapeData = "dsd",
42
42
  Download = "d",
43
+ DragPointerMove = "dpm",
44
+ DragPointerUp = "dpu",
43
45
  ElementExists = "ee",
44
46
  ExecuteFormula = "ef",
45
47
  GetConnectedLines = "gcl",
@@ -195,6 +197,14 @@ export declare type CommandArgs = {
195
197
  query: DownloadQuery;
196
198
  result: DownloadResult;
197
199
  };
200
+ [CommandName.DragPointerMove]: {
201
+ query: DragPointerMoveQuery;
202
+ result: DragPointerMoveResult;
203
+ };
204
+ [CommandName.DragPointerUp]: {
205
+ query: DragPointerUpQuery;
206
+ result: DragPointerUpResult;
207
+ };
198
208
  [CommandName.ElementExists]: {
199
209
  query: ElementExistsQuery;
200
210
  result: ElementExistsResult;
@@ -678,6 +688,16 @@ export declare type DownloadQuery = {
678
688
  'b64': boolean;
679
689
  };
680
690
  export declare type DownloadResult = undefined;
691
+ export declare type DragPointerMoveQuery = {
692
+ 'x': number;
693
+ 'y': number;
694
+ };
695
+ export declare type DragPointerMoveResult = undefined;
696
+ export declare type DragPointerUpQuery = {
697
+ 'x': number;
698
+ 'y': number;
699
+ };
700
+ export declare type DragPointerUpResult = undefined;
681
701
  export declare type ElementExistsQuery = {
682
702
  'id'?: string | undefined;
683
703
  };
@@ -24,6 +24,8 @@ exports.commandTitles = new Map([
24
24
  ["dp" /* CommandName.DeletePage */, 'DeletePage'],
25
25
  ["dsd" /* CommandName.DeleteShapeData */, 'DeleteShapeData'],
26
26
  ["d" /* CommandName.Download */, 'Download'],
27
+ ["dpm" /* CommandName.DragPointerMove */, 'DragPointerMove'],
28
+ ["dpu" /* CommandName.DragPointerUp */, 'DragPointerUp'],
27
29
  ["ee" /* CommandName.ElementExists */, 'ElementExists'],
28
30
  ["ef" /* CommandName.ExecuteFormula */, 'ExecuteFormula'],
29
31
  ["gcl" /* CommandName.GetConnectedLines */, 'GetConnectedLines'],
@@ -32,7 +32,11 @@ export declare enum FieldDisplayType {
32
32
  * Given a date, display a small calendar icon alongside a very short version of the date
33
33
  * as a string, e.g. "Sep 9"
34
34
  */
35
- DateBadge = "DateBadge"
35
+ DateBadge = "DateBadge",
36
+ /** Given an object containing iconUrl (optional) and name (optional), determine whether
37
+ * to display as an ImageBadge or InitializedString (or nothing, if neither is present).
38
+ */
39
+ UserProfile = "UserProfile"
36
40
  }
37
41
  export declare const isFieldDisplayType: (x: unknown) => x is FieldDisplayType;
38
42
  /**
@@ -37,6 +37,10 @@ var FieldDisplayType;
37
37
  * as a string, e.g. "Sep 9"
38
38
  */
39
39
  FieldDisplayType["DateBadge"] = "DateBadge";
40
+ /** Given an object containing iconUrl (optional) and name (optional), determine whether
41
+ * to display as an ImageBadge or InitializedString (or nothing, if neither is present).
42
+ */
43
+ FieldDisplayType["UserProfile"] = "UserProfile";
40
44
  })(FieldDisplayType = exports.FieldDisplayType || (exports.FieldDisplayType = {}));
41
45
  exports.isFieldDisplayType = (0, validators_1.enumValidator)(FieldDisplayType);
42
46
  /**
@@ -4,7 +4,8 @@ import { EditorClient } from '../editorclient';
4
4
  export declare enum IncomingUIMessageType {
5
5
  Closed = 1,
6
6
  PostMessageFromFrame = 2,
7
- FrameLoaded = 3
7
+ FrameLoaded = 3,
8
+ FramePosition = 4
8
9
  }
9
10
  /** @ignore */
10
11
  export interface IncomingUIMessage {
@@ -22,7 +23,18 @@ export declare abstract class IframeUI {
22
23
  private id;
23
24
  private static uiMessageActionNamePrefix;
24
25
  protected messageActionName: string;
26
+ /** True after the iframe has fired an onload event (not all scripts are necessarily finished executing) */
25
27
  protected loaded: boolean;
28
+ /**
29
+ * The location of this frame within the top-level browser window. This is always updated immediately before
30
+ * `messageFromFrame` is called.
31
+ */
32
+ protected framePosition: {
33
+ x: number;
34
+ y: number;
35
+ w: number;
36
+ h: number;
37
+ };
26
38
  constructor(client: EditorClient);
27
39
  /** @ignore */
28
40
  static isUIMessageActionName(name: string): boolean;
@@ -7,6 +7,7 @@ var IncomingUIMessageType;
7
7
  IncomingUIMessageType[IncomingUIMessageType["Closed"] = 1] = "Closed";
8
8
  IncomingUIMessageType[IncomingUIMessageType["PostMessageFromFrame"] = 2] = "PostMessageFromFrame";
9
9
  IncomingUIMessageType[IncomingUIMessageType["FrameLoaded"] = 3] = "FrameLoaded";
10
+ IncomingUIMessageType[IncomingUIMessageType["FramePosition"] = 4] = "FramePosition";
10
11
  })(IncomingUIMessageType = exports.IncomingUIMessageType || (exports.IncomingUIMessageType = {}));
11
12
  /**
12
13
  * Base class for defining and interacting with custom UI elements whose contents are displayed
@@ -17,7 +18,13 @@ class IframeUI {
17
18
  this.client = client;
18
19
  this.id = ++IframeUI.nextId;
19
20
  this.messageActionName = IframeUI.uiMessageActionNamePrefix + this.id;
21
+ /** True after the iframe has fired an onload event (not all scripts are necessarily finished executing) */
20
22
  this.loaded = false;
23
+ /**
24
+ * The location of this frame within the top-level browser window. This is always updated immediately before
25
+ * `messageFromFrame` is called.
26
+ */
27
+ this.framePosition = { x: 0, y: 0, w: 1, h: 1 };
21
28
  }
22
29
  /** @ignore */
23
30
  static isUIMessageActionName(name) {
@@ -38,6 +45,9 @@ class IframeUI {
38
45
  case IncomingUIMessageType.PostMessageFromFrame:
39
46
  this.messageFromFrame(message['data']);
40
47
  break;
48
+ case IncomingUIMessageType.FramePosition:
49
+ this.framePosition = message['data'];
50
+ break;
41
51
  case IncomingUIMessageType.FrameLoaded:
42
52
  this.loaded = true;
43
53
  this.frameLoaded();
@@ -85,4 +85,24 @@ export declare class Viewport {
85
85
  * cancel that interaction.
86
86
  */
87
87
  cancelDraggingNewBlock(): void;
88
+ /**
89
+ * After calling startDraggingNewBlock, call this to simulate the user moving the mouse at the
90
+ * given location within the top-level browser window.
91
+ *
92
+ * This has no effect if the drag-new-block interaction is not active.
93
+ *
94
+ * To convert a position in a Panel's iframe to a position in the top-level browser window,
95
+ * add the IframeUI.framePosition.
96
+ */
97
+ dragPointerMove(x: number, y: number): void;
98
+ /**
99
+ * After calling startDraggingNewBlock, call this to simulate the user releasing the mouse
100
+ * button at the given location within the top-level browser window.
101
+ *
102
+ * This has no effect if the drag-new-block interaction is not active.
103
+ *
104
+ * To convert a position in a Panel's iframe to a position in the top-level browser window,
105
+ * add the IframeUI.framePosition.
106
+ */
107
+ dragPointerUp(x: number, y: number): void;
88
108
  }
@@ -163,6 +163,30 @@ class Viewport {
163
163
  cancelDraggingNewBlock() {
164
164
  this.client.sendCommand("cdc" /* CommandName.CancelDragBlockToCanvas */, undefined);
165
165
  }
166
+ /**
167
+ * After calling startDraggingNewBlock, call this to simulate the user moving the mouse at the
168
+ * given location within the top-level browser window.
169
+ *
170
+ * This has no effect if the drag-new-block interaction is not active.
171
+ *
172
+ * To convert a position in a Panel's iframe to a position in the top-level browser window,
173
+ * add the IframeUI.framePosition.
174
+ */
175
+ dragPointerMove(x, y) {
176
+ this.client.sendCommand("dpm" /* CommandName.DragPointerMove */, { x, y });
177
+ }
178
+ /**
179
+ * After calling startDraggingNewBlock, call this to simulate the user releasing the mouse
180
+ * button at the given location within the top-level browser window.
181
+ *
182
+ * This has no effect if the drag-new-block interaction is not active.
183
+ *
184
+ * To convert a position in a Panel's iframe to a position in the top-level browser window,
185
+ * add the IframeUI.framePosition.
186
+ */
187
+ dragPointerUp(x, y) {
188
+ this.client.sendCommand("dpu" /* CommandName.DragPointerUp */, { x, y });
189
+ }
166
190
  }
167
191
  exports.Viewport = Viewport;
168
192
  Viewport.nextHookId = 0;