lucid-extension-sdk 0.0.134 → 0.0.136

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.134",
3
+ "version": "0.0.136",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -63,6 +63,7 @@ export declare const enum CommandName {
63
63
  GetSelection = "gs",
64
64
  GetShapeData = "gsd",
65
65
  GetTextStyle = "gts",
66
+ GetVisibleRect = "gvr",
66
67
  HideModal = "hm",
67
68
  HidePanel = "hp",
68
69
  HookCreateItems = "hci",
@@ -295,6 +296,10 @@ export declare type CommandArgs = {
295
296
  query: GetTextStyleQuery;
296
297
  result: GetTextStyleResult;
297
298
  };
299
+ [CommandName.GetVisibleRect]: {
300
+ query: GetVisibleRectQuery;
301
+ result: GetVisibleRectResult;
302
+ };
298
303
  [CommandName.HideModal]: {
299
304
  query: HideModalQuery;
300
305
  result: HideModalResult;
@@ -534,6 +539,8 @@ export declare type AddCardIntegrationQuery = {
534
539
  's': string;
535
540
  /** Import action */
536
541
  'i': string;
542
+ /** OnSetup action */
543
+ 'os'?: string | undefined;
537
544
  } | undefined;
538
545
  /** If specified, add-card settings */
539
546
  'ac'?: {
@@ -889,6 +896,8 @@ export declare type GetTextStyleQuery = {
889
896
  'n': string;
890
897
  };
891
898
  export declare type GetTextStyleResult = TextStyle;
899
+ export declare type GetVisibleRectQuery = void;
900
+ export declare type GetVisibleRectResult = Box;
892
901
  export declare type HideModalQuery = {
893
902
  /** Name of the modal's action for receiving events, i.e. ShowModalQuery['n'] */
894
903
  'n': string;
@@ -45,6 +45,7 @@ exports.commandTitles = new Map([
45
45
  ["gs" /* CommandName.GetSelection */, 'GetSelection'],
46
46
  ["gsd" /* CommandName.GetShapeData */, 'GetShapeData'],
47
47
  ["gts" /* CommandName.GetTextStyle */, 'GetTextStyle'],
48
+ ["gvr" /* CommandName.GetVisibleRect */, 'GetVisibleRect'],
48
49
  ["hm" /* CommandName.HideModal */, 'HideModal'],
49
50
  ["hp" /* CommandName.HidePanel */, 'HidePanel'],
50
51
  ["hci" /* CommandName.HookCreateItems */, 'HookCreateItems'],
@@ -91,6 +91,10 @@ export declare abstract class LucidCardIntegration {
91
91
  * The user checked the boxes beside the given list of items in the collection returned from search().
92
92
  * Import them, and return the collection and primary keys in that final collection that were imported.
93
93
  *
94
+ * onSetup:
95
+ * If specified, it's going to be called everytime the modal is setting up, right after the modal is displayed
96
+ * and before the initial form fields are shown to the user.
97
+ *
94
98
  * The config provided here is only used on the first import from a given source; on subsequent imports,
95
99
  * the existing config will remain unchanged to preserve any customizations by the user.
96
100
  */
@@ -108,6 +112,7 @@ export declare abstract class LucidCardIntegration {
108
112
  collection: CollectionProxy;
109
113
  primaryKeys: string[];
110
114
  }>;
115
+ onSetup?: () => Promise<void>;
111
116
  };
112
117
  /**
113
118
  * If specified, allow the user to create new cards and convert other shapes to cards
@@ -77,6 +77,7 @@ class LucidCardIntegrationRegistry {
77
77
  'gsf': LucidCardIntegrationRegistry.nextHookName(),
78
78
  's': LucidCardIntegrationRegistry.nextHookName(),
79
79
  'i': LucidCardIntegrationRegistry.nextHookName(),
80
+ 'os': importModal.onSetup ? LucidCardIntegrationRegistry.nextHookName() : undefined,
80
81
  };
81
82
  client.registerAction(serialized['im']['gsf'], async ({ 's': searchSoFar }) => {
82
83
  const result = await importModal.getSearchFields(new Map(searchSoFar));
@@ -100,6 +101,12 @@ class LucidCardIntegrationRegistry {
100
101
  'pks': result.primaryKeys,
101
102
  };
102
103
  });
104
+ if (serialized['im']['os']) {
105
+ client.registerAction(serialized['im']['os'], async () => {
106
+ var _a;
107
+ await ((_a = importModal.onSetup) === null || _a === void 0 ? void 0 : _a.call(importModal));
108
+ });
109
+ }
103
110
  }
104
111
  if (cardIntegration.addCard) {
105
112
  const addCard = cardIntegration.addCard;
@@ -30,6 +30,10 @@ export declare class Viewport {
30
30
  * @param page The page to view
31
31
  */
32
32
  setCurrentPage(page: PageProxy): void;
33
+ /**
34
+ * @returns the box for the current viewport location
35
+ */
36
+ getVisibleRect(): import("../math").Box;
33
37
  /**
34
38
  * Switch to the page containing these items, if necessary, and then animate the viewport
35
39
  * to zoom in and focus on these items.
@@ -37,6 +37,12 @@ class Viewport {
37
37
  setCurrentPage(page) {
38
38
  this.client.sendCommand("scp" /* CommandName.SetCurrentPage */, page.id);
39
39
  }
40
+ /**
41
+ * @returns the box for the current viewport location
42
+ */
43
+ getVisibleRect() {
44
+ return this.client.sendCommand("gvr" /* CommandName.GetVisibleRect */, undefined);
45
+ }
40
46
  /**
41
47
  * Switch to the page containing these items, if necessary, and then animate the viewport
42
48
  * to zoom in and focus on these items.