lucid-extension-sdk 0.0.52 → 0.0.54

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.52",
3
+ "version": "0.0.54",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -18,8 +18,19 @@ export interface ExtensionCardFieldDefinition extends FieldDefinition {
18
18
  default?: SerializedFieldType;
19
19
  /** Additional information we can provide to users, e.g. as a hover tooltip */
20
20
  description?: string;
21
- /** If specified, the list of options available to choose from */
22
- options?: ExtensionCardFieldOption[];
21
+ /**
22
+ * If specified, the list of options available to choose from, or the name
23
+ * of a registered action that returns the list of options (either directly
24
+ * or as a Promise).
25
+ */
26
+ options?: ExtensionCardFieldOption[] | string;
27
+ /**
28
+ * If specified, an action that takes the search text and input so far, and
29
+ * returns the list of options that should be displayed. This is useful when
30
+ * there are too many possible options to reasonably use the "options"
31
+ * option for options.
32
+ */
33
+ search?: string;
23
34
  }
24
35
  /** @ignore */
25
36
  export declare type SerializedCardFieldOption = {
@@ -33,7 +44,8 @@ export declare type SerializedExtensionCardFieldDefinition = SerializedFieldDefi
33
44
  'l': string;
34
45
  'def'?: SerializedFieldType;
35
46
  'd'?: string;
36
- 'op'?: SerializedCardFieldOption[];
47
+ 'op'?: SerializedCardFieldOption[] | string;
48
+ 's'?: string;
37
49
  };
38
50
  /** @ignore */
39
51
  export declare function serializeCardFieldDefinition(field: ExtensionCardFieldDefinition): SerializedExtensionCardFieldDefinition;
@@ -64,10 +76,11 @@ export declare const isSerializedExtensionCardFieldDefinition: (subject: unknown
64
76
  l: typeof isString;
65
77
  d: (x: unknown) => x is string | undefined;
66
78
  def: (x: unknown) => x is SerializedFieldType;
67
- op: (x: unknown) => x is import("../guards").DestructureGuardedTypeObj<{
79
+ op: (x: unknown) => x is string | import("../guards").DestructureGuardedTypeObj<{
68
80
  l: typeof isString;
69
81
  v: typeof isSerializedFieldType;
70
82
  }>[] | undefined;
83
+ s: (x: unknown) => x is string | undefined;
71
84
  }>;
72
85
  /** @ignore */
73
86
  export declare function deserializeCardFieldDefinition(field: SerializedExtensionCardFieldDefinition): ExtensionCardFieldDefinition;
@@ -18,7 +18,7 @@ exports.serializeCardFieldOption = serializeCardFieldOption;
18
18
  /** @ignore */
19
19
  function serializeCardFieldDefinition(field) {
20
20
  var _a;
21
- return Object.assign(Object.assign({}, (0, schemadefinition_1.serializeFieldDefinition)(field)), { 'l': field.label, 'def': field.default, 'd': field.description, 'op': (_a = field.options) === null || _a === void 0 ? void 0 : _a.map(serializeCardFieldOption) });
21
+ return Object.assign(Object.assign({}, (0, schemadefinition_1.serializeFieldDefinition)(field)), { 'l': field.label, 'def': field.default, 'd': field.description, 'op': (0, checks_1.isString)(field.options) ? field.options : (_a = field.options) === null || _a === void 0 ? void 0 : _a.map(serializeCardFieldOption), 's': field.search });
22
22
  }
23
23
  exports.serializeCardFieldDefinition = serializeCardFieldDefinition;
24
24
  /** @ignore */
@@ -51,12 +51,13 @@ exports.isSerializedExtensionCardFieldDefinition = (0, validators_1.objectValida
51
51
  'l': checks_1.isString,
52
52
  'd': (0, validators_1.option)(checks_1.isString),
53
53
  'def': (0, validators_1.option)(serializedfields_1.isSerializedFieldType),
54
- 'op': (0, validators_1.option)((0, validators_1.arrayValidator)(exports.isSerializedFieldOption)),
54
+ 'op': (0, validators_1.option)((0, validators_1.either)(checks_1.isString, (0, validators_1.arrayValidator)(exports.isSerializedFieldOption))),
55
+ 's': (0, validators_1.option)(checks_1.isString),
55
56
  });
56
57
  /** @ignore */
57
58
  function deserializeCardFieldDefinition(field) {
58
59
  var _a;
59
- return Object.assign(Object.assign({}, (0, schemadefinition_1.parseFieldDefinition)(field)), { label: field['l'], description: field['d'], default: field['def'], options: (_a = field['op']) === null || _a === void 0 ? void 0 : _a.map(deserializeFieldOption) });
60
+ return Object.assign(Object.assign({}, (0, schemadefinition_1.parseFieldDefinition)(field)), { label: field['l'], description: field['d'], default: field['def'], options: (0, checks_1.isString)(field['op']) ? field['op'] : (_a = field['op']) === null || _a === void 0 ? void 0 : _a.map(deserializeFieldOption), search: field['s'] });
60
61
  }
61
62
  exports.deserializeCardFieldDefinition = deserializeCardFieldDefinition;
62
63
  /** @ignore */
@@ -1,10 +1,13 @@
1
- import { CardIntegration } from '../core/cardintegration/cardintegration';
1
+ import { CardIntegration, ExtensionCardFieldOption } from '../core/cardintegration/cardintegration';
2
+ import { SerializedFieldType } from '../core/data/serializedfield/serializedfields';
2
3
  import { EditorClient } from '../editorclient';
3
4
  export declare class TaskManagementCardIntegration {
4
5
  private readonly client;
5
6
  constructor(client: EditorClient);
6
7
  private static nextHookId;
7
8
  private static nextHookName;
9
+ registerFieldOptionsCallback(callback: (inputSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldOption[]>): string;
10
+ registerFieldSearchCallback(callback: (searchText: string, inputSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldOption[]>): string;
8
11
  /**
9
12
  * Register a new card integration.
10
13
  * @param card The definition of the new card integration
@@ -12,6 +12,22 @@ class TaskManagementCardIntegration {
12
12
  static nextHookName() {
13
13
  return '__taskmanagementcard__hook' + TaskManagementCardIntegration.nextHookId++;
14
14
  }
15
+ registerFieldOptionsCallback(callback) {
16
+ const name = TaskManagementCardIntegration.nextHookName();
17
+ this.client.registerAction(name, async ({ 'i': inputSoFar }) => {
18
+ const result = await callback(new Map(inputSoFar));
19
+ return result.map((option) => (0, cardintegration_1.serializeCardFieldOption)(option));
20
+ });
21
+ return name;
22
+ }
23
+ registerFieldSearchCallback(callback) {
24
+ const name = TaskManagementCardIntegration.nextHookName();
25
+ this.client.registerAction(name, async ({ 'i': inputSoFar, 's': searchText }) => {
26
+ const result = await callback(searchText, new Map(inputSoFar));
27
+ return result.map((option) => (0, cardintegration_1.serializeCardFieldOption)(option));
28
+ });
29
+ return name;
30
+ }
15
31
  /**
16
32
  * Register a new card integration.
17
33
  * @param card The definition of the new card integration
package/sdk/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './core/cardintegration/cardintegration';
1
2
  export * from './core/data/serializedfield/serializedfields';
2
3
  export * from './core/dataerrortype';
3
4
  export * from './core/jsonserializable';
@@ -23,6 +24,7 @@ export * from './document/mapproxy';
23
24
  export * from './document/pagedefinition';
24
25
  export * from './document/pageproxy';
25
26
  export * from './document/shapedataproxy';
27
+ export * from './document/taskmanagementcardintegration';
26
28
  export * from './editorclient';
27
29
  export * from './math';
28
30
  export * from './ui/alertmodal';
package/sdk/index.js CHANGED
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./core/cardintegration/cardintegration"), exports);
17
18
  __exportStar(require("./core/data/serializedfield/serializedfields"), exports);
18
19
  __exportStar(require("./core/dataerrortype"), exports);
19
20
  __exportStar(require("./core/jsonserializable"), exports);
@@ -39,6 +40,7 @@ __exportStar(require("./document/mapproxy"), exports);
39
40
  __exportStar(require("./document/pagedefinition"), exports);
40
41
  __exportStar(require("./document/pageproxy"), exports);
41
42
  __exportStar(require("./document/shapedataproxy"), exports);
43
+ __exportStar(require("./document/taskmanagementcardintegration"), exports);
42
44
  __exportStar(require("./editorclient"), exports);
43
45
  __exportStar(require("./math"), exports);
44
46
  __exportStar(require("./ui/alertmodal"), exports);