lucid-extension-sdk 0.0.120 → 0.0.122

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.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/sdk/commandtypes.d.ts +51 -0
  3. package/sdk/commandtypes.js +3 -0
  4. package/sdk/core/checks.d.ts +6 -0
  5. package/sdk/core/checks.js +10 -1
  6. package/sdk/core/data/datasource/datasourcetype.d.ts +1 -1
  7. package/sdk/core/data/datasource/datasourcetype.js +1 -1
  8. package/sdk/core/data/datasource/metadatatypes.d.ts +1 -1
  9. package/sdk/core/data/datasource/metadatatypes.js +1 -1
  10. package/sdk/core/data/datasource/serializeddatasourceproperties.d.ts +1 -1
  11. package/sdk/core/data/datasource/serializedimporteddatasource.d.ts +3 -3
  12. package/sdk/core/data/datasource/serializedupstreamconfig.d.ts +1 -1
  13. package/sdk/core/data/datasource/upstreampatchtype.d.ts +1 -1
  14. package/sdk/core/data/datasource/upstreampatchtype.js +1 -1
  15. package/sdk/core/data/datasource/upstreamupdatetype.d.ts +1 -1
  16. package/sdk/core/data/datasource/upstreamupdatetype.js +1 -1
  17. package/sdk/core/spreadsheetintegration/lucidspreadsheetintegration.d.ts +20 -0
  18. package/sdk/core/spreadsheetintegration/lucidspreadsheetintegration.js +17 -0
  19. package/sdk/core/spreadsheetintegration/lucidspreadsheetintegrationregistry.d.ts +11 -0
  20. package/sdk/core/spreadsheetintegration/lucidspreadsheetintegrationregistry.js +53 -0
  21. package/sdk/core/validators/validators.d.ts +8 -0
  22. package/sdk/core/validators/validators.js +19 -1
  23. package/sdk/document/itemproxy.d.ts +6 -1
  24. package/sdk/document/itemproxy.js +11 -0
  25. package/sdk/document/mapproxy.d.ts +3 -3
  26. package/sdk/document/mapproxy.js +1 -1
  27. package/sdk/document/propertystoreproxy.d.ts +1 -1
  28. package/sdk/document/shapedataproxy.d.ts +1 -1
  29. package/sdk/document/text/textstyle.d.ts +28 -0
  30. package/sdk/document/text/textstyle.js +25 -0
  31. package/sdk/index.d.ts +3 -0
  32. package/sdk/index.js +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.120",
3
+ "version": "0.0.122",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -8,6 +8,7 @@ import { SerializedDataError } from './core/serializeddataerror';
8
8
  import { ShapeDataInheritance } from './core/shapedatainheritance';
9
9
  import { DocumentElementType } from './document/documentelement/documentelementtype';
10
10
  import { SerializedLineTextAreaPositioning } from './document/linetextareapositioning';
11
+ import { TextStyle } from './document/text/textstyle';
11
12
  import { Box, Point } from './math';
12
13
  import { MenuLocation, MenuType } from './ui/menu';
13
14
  import { PanelLocation } from './ui/panel';
@@ -23,6 +24,7 @@ export declare const enum CommandName {
23
24
  AddLineTextArea = "alta",
24
25
  AddMenuItem = "ami",
25
26
  AddShapeData = "asd",
27
+ AddSpreadsheetIntegration = "asi",
26
28
  Alert = "a",
27
29
  AnimateViewport = "av",
28
30
  AwaitImport = "ai",
@@ -59,6 +61,7 @@ export declare const enum CommandName {
59
61
  GetRelativeLinePosition = "grlp",
60
62
  GetSelection = "gs",
61
63
  GetShapeData = "gsd",
64
+ GetTextStyle = "gts",
62
65
  HideModal = "hm",
63
66
  HidePanel = "hp",
64
67
  HookCreateItems = "hci",
@@ -96,6 +99,7 @@ export declare const enum CommandName {
96
99
  SetReferenceKey = "srk",
97
100
  SetShapeData = "ssd",
98
101
  SetText = "st",
102
+ SetTextStyle = "sts",
99
103
  ShowModal = "sm",
100
104
  ShowPanel = "spn",
101
105
  ShowPackageSettingsModal = "spsm",
@@ -133,6 +137,10 @@ export declare type CommandArgs = {
133
137
  query: AddShapeDataQuery;
134
138
  result: AddShapeDataResult;
135
139
  };
140
+ [CommandName.AddSpreadsheetIntegration]: {
141
+ query: AddSpreadsheetIntegrationQuery;
142
+ result: AddSpreadsheetIntegrationResult;
143
+ };
136
144
  [CommandName.Alert]: {
137
145
  query: AlertQuery;
138
146
  result: AlertResult;
@@ -277,6 +285,10 @@ export declare type CommandArgs = {
277
285
  query: GetShapeDataQuery;
278
286
  result: GetShapeDataResult;
279
287
  };
288
+ [CommandName.GetTextStyle]: {
289
+ query: GetTextStyleQuery;
290
+ result: GetTextStyleResult;
291
+ };
280
292
  [CommandName.HideModal]: {
281
293
  query: HideModalQuery;
282
294
  result: HideModalResult;
@@ -425,6 +437,10 @@ export declare type CommandArgs = {
425
437
  query: SetTextQuery;
426
438
  result: SetTextResult;
427
439
  };
440
+ [CommandName.SetTextStyle]: {
441
+ query: SetTextStyleQuery;
442
+ result: SetTextStyleResult;
443
+ };
428
444
  [CommandName.ShowModal]: {
429
445
  query: ShowModalQuery;
430
446
  result: ShowModalResult;
@@ -565,6 +581,25 @@ export declare type AddShapeDataQuery = {
565
581
  'v'?: SerializedFieldType;
566
582
  };
567
583
  export declare type AddShapeDataResult = undefined;
584
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
585
+ export declare type AddSpreadsheetIntegrationQuery = {
586
+ /** name */
587
+ 'n': string;
588
+ /** label */
589
+ 'l': string;
590
+ /** iconUrl */
591
+ 'iu': string;
592
+ /** getSpreadsheetToImportDetails */
593
+ 'gd': string;
594
+ /** getSpreadsheetSheetIdsAndNames */
595
+ 'gs': string;
596
+ /** getPreviewData */
597
+ 'gp': string;
598
+ /** importSheets */
599
+ 'i': string;
600
+ };
601
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
602
+ export declare type AddSpreadsheetIntegrationResult = undefined;
568
603
  export declare type AlertQuery = {
569
604
  /** Title; defaults to extension title */
570
605
  't'?: string | undefined;
@@ -827,6 +862,13 @@ export declare type GetShapeDataQuery = {
827
862
  'n': string;
828
863
  };
829
864
  export declare type GetShapeDataResult = SerializedFieldType | SerializedDataError;
865
+ export declare type GetTextStyleQuery = {
866
+ /** ID of the element to get text style from */
867
+ 'id': string;
868
+ /** Name of the text area to get text style from */
869
+ 'n': string;
870
+ };
871
+ export declare type GetTextStyleResult = TextStyle;
830
872
  export declare type HideModalQuery = {
831
873
  /** Name of the modal's action for receiving events, i.e. ShowModalQuery['n'] */
832
874
  'n': string;
@@ -1063,6 +1105,15 @@ export declare type SetTextQuery = {
1063
1105
  'f'?: boolean | undefined;
1064
1106
  };
1065
1107
  export declare type SetTextResult = undefined;
1108
+ export declare type SetTextStyleQuery = {
1109
+ /** ID of the element to set text style on */
1110
+ 'id': string;
1111
+ /** Name of the text area to set text style on */
1112
+ 'n': string;
1113
+ /** Text styles to set */
1114
+ 's': Partial<TextStyle>;
1115
+ };
1116
+ export declare type SetTextStyleResult = Promise<undefined>;
1066
1117
  export declare type ShowModalQuery = {
1067
1118
  /** Name of the modal's action for receiving events; generated automatically by Modal base class */
1068
1119
  'n': string;
@@ -8,6 +8,7 @@ exports.commandTitles = new Map([
8
8
  ["alta" /* CommandName.AddLineTextArea */, 'AddLineTextArea'],
9
9
  ["ami" /* CommandName.AddMenuItem */, 'AddMenuItem'],
10
10
  ["asd" /* CommandName.AddShapeData */, 'AddShapeData'],
11
+ ["asi" /* CommandName.AddSpreadsheetIntegration */, 'AddSpreadsheetIntegration'],
11
12
  ["a" /* CommandName.Alert */, 'Alert'],
12
13
  ["av" /* CommandName.AnimateViewport */, 'AnimateViewport'],
13
14
  ["ai" /* CommandName.AwaitImport */, 'AwaitImport'],
@@ -42,6 +43,7 @@ exports.commandTitles = new Map([
42
43
  ["grlp" /* CommandName.GetRelativeLinePosition */, 'GetRelativeLinePosition'],
43
44
  ["gs" /* CommandName.GetSelection */, 'GetSelection'],
44
45
  ["gsd" /* CommandName.GetShapeData */, 'GetShapeData'],
46
+ ["gts" /* CommandName.GetTextStyle */, 'GetTextStyle'],
45
47
  ["hm" /* CommandName.HideModal */, 'HideModal'],
46
48
  ["hp" /* CommandName.HidePanel */, 'HidePanel'],
47
49
  ["hci" /* CommandName.HookCreateItems */, 'HookCreateItems'],
@@ -77,6 +79,7 @@ exports.commandTitles = new Map([
77
79
  ["sp" /* CommandName.SetProperty */, 'SetProperty'],
78
80
  ["srk" /* CommandName.SetReferenceKey */, 'SetReferenceKey'],
79
81
  ["ssd" /* CommandName.SetShapeData */, 'SetShapeData'],
82
+ ["sts" /* CommandName.SetTextStyle */, 'SetTextStyle'],
80
83
  ["sm" /* CommandName.ShowModal */, 'ShowModal'],
81
84
  ["spsm" /* CommandName.ShowPackageSettingsModal */, 'ShowPackageSettingsModal'],
82
85
  ["spn" /* CommandName.ShowPanel */, 'ShowPanel'],
@@ -17,6 +17,12 @@ export declare function isNull(val: unknown): val is null;
17
17
  * @return Whether variable is undefined.
18
18
  */
19
19
  export declare function isUndefined(val: unknown): val is undefined;
20
+ /**
21
+ * Returns true if the specified value is undefined.
22
+ * @param val Variable to test.
23
+ * @return Whether variable is undefined.
24
+ */
25
+ export declare function isVoid(x: unknown): x is void;
20
26
  /**
21
27
  * Returns true if the specified value is defined and not null.
22
28
  * @param val Variable to test.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isInstanceOf = exports.isLiteral = exports.isPromise = exports.isUnknown = exports.isAny = exports.isEmptyOrNullishObject = exports.isTypedArray = exports.isArray = exports.isRecord = exports.isObject = exports.isFunction = exports.isInfinite = exports.isInt = exports.isNumber = exports.isBoolean = exports.isString = exports.isNullish = exports.isDefAndNotNull = exports.isUndefined = exports.isNull = exports.isDef = void 0;
3
+ exports.isInstanceOf = exports.isLiteral = exports.isPromise = exports.isUnknown = exports.isAny = exports.isEmptyOrNullishObject = exports.isTypedArray = exports.isArray = exports.isRecord = exports.isObject = exports.isFunction = exports.isInfinite = exports.isInt = exports.isNumber = exports.isBoolean = exports.isString = exports.isNullish = exports.isDefAndNotNull = exports.isVoid = exports.isUndefined = exports.isNull = exports.isDef = void 0;
4
4
  /**
5
5
  * Returns true if the specified value is not undefined.
6
6
  *
@@ -29,6 +29,15 @@ function isUndefined(val) {
29
29
  return val === undefined;
30
30
  }
31
31
  exports.isUndefined = isUndefined;
32
+ /**
33
+ * Returns true if the specified value is undefined.
34
+ * @param val Variable to test.
35
+ * @return Whether variable is undefined.
36
+ */
37
+ function isVoid(x) {
38
+ return x === undefined;
39
+ }
40
+ exports.isVoid = isVoid;
32
41
  /**
33
42
  * Returns true if the specified value is defined and not null.
34
43
  * @param val Variable to test.
@@ -1,4 +1,4 @@
1
- /** @ignore until spreadsheet integration is ready for launch */
1
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
2
2
  export declare enum DataSourceType {
3
3
  GoogleSheets = 0,
4
4
  CSV = 1,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataSourceType = void 0;
4
- /** @ignore until spreadsheet integration is ready for launch */
4
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
5
5
  var DataSourceType;
6
6
  (function (DataSourceType) {
7
7
  DataSourceType[DataSourceType["GoogleSheets"] = 0] = "GoogleSheets";
@@ -1,4 +1,4 @@
1
- /** @ignore until spreadsheet integration is ready for launch */
1
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
2
2
  export declare enum MetadataTypes {
3
3
  Format = "Format",
4
4
  FillColor = "FillColor",
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MetadataTypes = void 0;
4
4
  // Google Sheets has both notes and comments, we store notes in the comment metadata collection. Comments are not
5
5
  // meant to be permanent in Google Sheets whereas they are in Excel, resulting in some confusion with our naming.
6
- /** @ignore until spreadsheet integration is ready for launch */
6
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
7
7
  var MetadataTypes;
8
8
  (function (MetadataTypes) {
9
9
  MetadataTypes["Format"] = "Format";
@@ -1,5 +1,5 @@
1
1
  import { SerializedUpstreamConfig } from './serializedupstreamconfig';
2
- /** @ignore until spreadsheet integration is ready for launch */
2
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
3
3
  export interface SerializedDataSourceProperties {
4
4
  'Name': string;
5
5
  'UpstreamConfig'?: SerializedUpstreamConfig | null | undefined;
@@ -1,13 +1,13 @@
1
1
  import { SerializedDataItems } from '../serializedfield/serializeddataitems';
2
2
  import { SerializedSchema } from '../serializedfield/serializedschema';
3
3
  import { SerializedDataSourceProperties } from './serializeddatasourceproperties';
4
- /** @ignore until spreadsheet integration is ready for launch */
4
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
5
5
  export interface SerializedImportedMetadataCollection {
6
6
  'Name': string;
7
7
  'Schema': SerializedSchema;
8
8
  'Items': SerializedDataItems;
9
9
  }
10
- /** @ignore until spreadsheet integration is ready for launch */
10
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
11
11
  export interface SerializedImportedCollection {
12
12
  'Name': string;
13
13
  'Schema': SerializedSchema;
@@ -19,7 +19,7 @@ export interface SerializedImportedCollection {
19
19
  [key: string]: SerializedImportedMetadataCollection;
20
20
  };
21
21
  }
22
- /** @ignore until spreadsheet integration is ready for launch */
22
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
23
23
  export interface SerializedImportedDataSource {
24
24
  'Properties': SerializedDataSourceProperties;
25
25
  'Collections': SerializedImportedCollection[];
@@ -1,7 +1,7 @@
1
1
  import { DataSourceType } from './datasourcetype';
2
2
  import { UpstreamPatchType } from './upstreampatchtype';
3
3
  import { UpstreamUpdateType } from './upstreamupdatetype';
4
- /** @ignore until spreadsheet integration is ready for launch */
4
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
5
5
  export interface SerializedUpstreamConfig {
6
6
  'SourceType': DataSourceType;
7
7
  'UpdateType': UpstreamUpdateType;
@@ -1,4 +1,4 @@
1
- /** @ignore until spreadsheet integration is ready for launch */
1
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
2
2
  export declare enum UpstreamPatchType {
3
3
  NONE = 0,
4
4
  MANUAL = 2,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UpstreamPatchType = void 0;
4
- /** @ignore until spreadsheet integration is ready for launch */
4
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
5
5
  var UpstreamPatchType;
6
6
  (function (UpstreamPatchType) {
7
7
  UpstreamPatchType[UpstreamPatchType["NONE"] = 0] = "NONE";
@@ -1,4 +1,4 @@
1
- /** @ignore until spreadsheet integration is ready for launch */
1
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
2
2
  export declare enum UpstreamUpdateType {
3
3
  NONE = 0,
4
4
  PULL = 1,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UpstreamUpdateType = void 0;
4
- /** @ignore until spreadsheet integration is ready for launch */
4
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
5
5
  var UpstreamUpdateType;
6
6
  (function (UpstreamUpdateType) {
7
7
  UpstreamUpdateType[UpstreamUpdateType["NONE"] = 0] = "NONE";
@@ -0,0 +1,20 @@
1
+ import { CollectionProxy } from '../../data/collectionproxy';
2
+ import { SerializedImportedDataSource } from '../data/datasource/serializedimporteddatasource';
3
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
4
+ export declare enum LucidSpreadsheetIntegrationFailureType {
5
+ AuthorizationFailure = "AuthorizationFailure",
6
+ GenericFailure = "GenericFailure",
7
+ UserCancelled = "UserCanceled"
8
+ }
9
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
10
+ export declare const lucidSpreadsheetIntegrationFailureTypeValidator: (x: unknown) => x is LucidSpreadsheetIntegrationFailureType;
11
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
12
+ export declare abstract class LucidSpreadsheetIntegration<CONFIG, SHEET> {
13
+ abstract name: string;
14
+ abstract label: string;
15
+ abstract iconUrl: string;
16
+ abstract getSpreadsheetToImportDetails: () => Promise<CONFIG | LucidSpreadsheetIntegrationFailureType>;
17
+ abstract getSpreadsheetSheetIdsAndNames(spreadsheetDetails: CONFIG): Promise<Map<SHEET, string> | LucidSpreadsheetIntegrationFailureType>;
18
+ abstract getPreviewData(spreadsheetDetails: CONFIG, sheetIdsToPreview: SHEET[]): Promise<SerializedImportedDataSource | LucidSpreadsheetIntegrationFailureType>;
19
+ abstract importSheets(spreadsheetDetails: CONFIG, sheetIdsToImport: SHEET[]): Promise<CollectionProxy[] | LucidSpreadsheetIntegrationFailureType>;
20
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LucidSpreadsheetIntegration = exports.lucidSpreadsheetIntegrationFailureTypeValidator = exports.LucidSpreadsheetIntegrationFailureType = void 0;
4
+ const validators_1 = require("../validators/validators");
5
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
6
+ var LucidSpreadsheetIntegrationFailureType;
7
+ (function (LucidSpreadsheetIntegrationFailureType) {
8
+ LucidSpreadsheetIntegrationFailureType["AuthorizationFailure"] = "AuthorizationFailure";
9
+ LucidSpreadsheetIntegrationFailureType["GenericFailure"] = "GenericFailure";
10
+ LucidSpreadsheetIntegrationFailureType["UserCancelled"] = "UserCanceled";
11
+ })(LucidSpreadsheetIntegrationFailureType = exports.LucidSpreadsheetIntegrationFailureType || (exports.LucidSpreadsheetIntegrationFailureType = {}));
12
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
13
+ exports.lucidSpreadsheetIntegrationFailureTypeValidator = (0, validators_1.stringEnumValidator)(LucidSpreadsheetIntegrationFailureType);
14
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
15
+ class LucidSpreadsheetIntegration {
16
+ }
17
+ exports.LucidSpreadsheetIntegration = LucidSpreadsheetIntegration;
@@ -0,0 +1,11 @@
1
+ import { EditorClient } from '../../editorclient';
2
+ import { LucidSpreadsheetIntegration } from './lucidspreadsheetintegration';
3
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
4
+ export declare class LucidSpreadsheetIntegrationRegistry {
5
+ private static nextHookId;
6
+ private static nextHookName;
7
+ /**
8
+ * Register a spreadsheet integration.
9
+ */
10
+ static addSpreadsheetIntegration<CONFIG, SHEET>(client: EditorClient, spreadsheetIntegration: LucidSpreadsheetIntegration<CONFIG, SHEET>): void;
11
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LucidSpreadsheetIntegrationRegistry = void 0;
4
+ const lucidspreadsheetintegration_1 = require("./lucidspreadsheetintegration");
5
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
6
+ class LucidSpreadsheetIntegrationRegistry {
7
+ static nextHookName() {
8
+ return '__lucidspreadsheet__hook' + this.nextHookId++;
9
+ }
10
+ /**
11
+ * Register a spreadsheet integration.
12
+ */
13
+ static addSpreadsheetIntegration(client, spreadsheetIntegration) {
14
+ const getSpreadsheetToImportDetailsActionName = LucidSpreadsheetIntegrationRegistry.nextHookName();
15
+ client.registerAction(getSpreadsheetToImportDetailsActionName, async () => {
16
+ const result = await spreadsheetIntegration.getSpreadsheetToImportDetails();
17
+ return result;
18
+ });
19
+ const getSpreadsheetSheetIdsAndNamesActionName = LucidSpreadsheetIntegrationRegistry.nextHookName();
20
+ client.registerAction(getSpreadsheetSheetIdsAndNamesActionName, async (message) => {
21
+ const result = await spreadsheetIntegration.getSpreadsheetSheetIdsAndNames(message['dataDetails']);
22
+ if ((0, lucidspreadsheetintegration_1.lucidSpreadsheetIntegrationFailureTypeValidator)(result)) {
23
+ return result;
24
+ }
25
+ else {
26
+ // Serialize the Map
27
+ return Array.from(result);
28
+ }
29
+ });
30
+ const getPreviewDataActionName = LucidSpreadsheetIntegrationRegistry.nextHookName();
31
+ client.registerAction(getPreviewDataActionName, async (message) => {
32
+ const result = await spreadsheetIntegration.getPreviewData(message['dataDetails'], message['sheetIds']);
33
+ return result;
34
+ });
35
+ const importSheetsActionName = LucidSpreadsheetIntegrationRegistry.nextHookName();
36
+ client.registerAction(importSheetsActionName, async (message) => {
37
+ const result = await spreadsheetIntegration.importSheets(message['dataDetails'], message['sheetIds']);
38
+ return result;
39
+ });
40
+ const serialized = {
41
+ 'n': spreadsheetIntegration.name,
42
+ 'l': spreadsheetIntegration.label,
43
+ 'iu': spreadsheetIntegration.iconUrl,
44
+ 'gd': getSpreadsheetToImportDetailsActionName,
45
+ 'gs': getSpreadsheetSheetIdsAndNamesActionName,
46
+ 'gp': getPreviewDataActionName,
47
+ 'i': importSheetsActionName,
48
+ };
49
+ client.sendCommand("asi" /* CommandName.AddSpreadsheetIntegration */, serialized);
50
+ }
51
+ }
52
+ exports.LucidSpreadsheetIntegrationRegistry = LucidSpreadsheetIntegrationRegistry;
53
+ LucidSpreadsheetIntegrationRegistry.nextHookId = 0;
@@ -69,6 +69,14 @@ export declare function mapValidator<T>(subValidator: (p1: unknown) => p1 is T):
69
69
  export declare function objectValidator<T extends {
70
70
  [key: string]: (p1: unknown) => p1 is unknown;
71
71
  }>(validatorStructure: T): (subject: unknown) => subject is DestructureGuardedTypeObj<T>;
72
+ /**
73
+ * Creates a validator which tests if the target is an object
74
+ * and if the structure of the object matches the structure of the passed-in
75
+ * validator object, but with every entry being optional.
76
+ */
77
+ export declare function partialObjectValidator<T extends {
78
+ [key: string]: (p1: unknown) => p1 is unknown;
79
+ }>(validatorStructure: T): (subject: unknown) => subject is Partial<DestructureGuardedTypeObj<T>>;
72
80
  /**
73
81
  * Similar to {@link objectValidator}, but if the object has any non-undefined keys, they must also be present in the validator structure.
74
82
  * This is useful for things where extra data is unwanted, like Property serialization.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asAssertion = exports.validatorWithMessage = exports.minLengthValidator = exports.maxLengthValidator = exports.isDate = exports.isPositiveNumber = exports.isSize = exports.isPanelSize = exports.isBoundingBox = exports.isPointLike = exports.isOpacity = exports.isTrue = exports.isFlag = exports.isRestrictions = exports.isStringOrNegativeOne = exports.isBooleanOrEmptyString = exports.isNumberOrEmptyString = exports.isSet = exports.propertyValidator = exports.exclude = exports.both = exports.either = exports.isNullOption = exports.nullableOption = exports.option = exports.nullable = exports.objectOfValidator = exports.recordValidator = exports.strictObjectValidator = exports.objectValidator = exports.mapValidator = exports.someValidator = exports.someValue = exports.tupleValidator = exports.arrayValidator = exports.rangeValidator = exports.enumValidator = exports.stringEnumValidator = void 0;
3
+ exports.asAssertion = exports.validatorWithMessage = exports.minLengthValidator = exports.maxLengthValidator = exports.isDate = exports.isPositiveNumber = exports.isSize = exports.isPanelSize = exports.isBoundingBox = exports.isPointLike = exports.isOpacity = exports.isTrue = exports.isFlag = exports.isRestrictions = exports.isStringOrNegativeOne = exports.isBooleanOrEmptyString = exports.isNumberOrEmptyString = exports.isSet = exports.propertyValidator = exports.exclude = exports.both = exports.either = exports.isNullOption = exports.nullableOption = exports.option = exports.nullable = exports.objectOfValidator = exports.recordValidator = exports.strictObjectValidator = exports.partialObjectValidator = exports.objectValidator = exports.mapValidator = exports.someValidator = exports.someValue = exports.tupleValidator = exports.arrayValidator = exports.rangeValidator = exports.enumValidator = exports.stringEnumValidator = void 0;
4
4
  const checks_1 = require("../checks");
5
5
  const object_1 = require("../object");
6
6
  /*********************************************************************************
@@ -145,6 +145,24 @@ function objectValidator(validatorStructure) {
145
145
  };
146
146
  }
147
147
  exports.objectValidator = objectValidator;
148
+ /**
149
+ * Creates a validator which tests if the target is an object
150
+ * and if the structure of the object matches the structure of the passed-in
151
+ * validator object, but with every entry being optional.
152
+ */
153
+ function partialObjectValidator(validatorStructure) {
154
+ return (subject) => {
155
+ if ((0, checks_1.isArray)(subject) || !(0, checks_1.isObject)(subject)) {
156
+ return false;
157
+ }
158
+ else {
159
+ return (0, object_1.objectEvery)(validatorStructure, (validator, key) => {
160
+ return subject[key] === undefined || validator(subject[key]);
161
+ });
162
+ }
163
+ };
164
+ }
165
+ exports.partialObjectValidator = partialObjectValidator;
148
166
  /**
149
167
  * Similar to {@link objectValidator}, but if the object has any non-undefined keys, they must also be present in the validator structure.
150
168
  * This is useful for things where extra data is unwanted, like Property serialization.
@@ -3,6 +3,7 @@ import { EditorClient } from '../editorclient';
3
3
  import { Box, Point } from '../math';
4
4
  import { ElementProxy } from './elementproxy';
5
5
  import { WriteableMapProxy } from './mapproxy';
6
+ import { TextStyle } from './text/textstyle';
6
7
  /**
7
8
  * A block, line, or group on a page of the current document.
8
9
  */
@@ -16,7 +17,11 @@ export declare class ItemProxy extends ElementProxy {
16
17
  /**
17
18
  * The plain text in each of the text areas on this item, organized by text area name.
18
19
  */
19
- readonly textAreas: WriteableMapProxy<string, string>;
20
+ readonly textAreas: WriteableMapProxy<string, string, undefined, string>;
21
+ /**
22
+ * The text style in each of the text areas on this item, organized by text area name.
23
+ */
24
+ readonly textStyles: WriteableMapProxy<string, TextStyle, Promise<undefined>, Partial<TextStyle>>;
20
25
  /**
21
26
  * @returns The bounding box of this item relative to its containing page. As pages may change size
22
27
  * to fit the content on them, note that these coordinates may be negative or very large.
@@ -27,6 +27,17 @@ class ItemProxy extends elementproxy_1.ElementProxy {
27
27
  't': plainText,
28
28
  'f': options === null || options === void 0 ? void 0 : options.force,
29
29
  }));
30
+ /**
31
+ * The text style in each of the text areas on this item, organized by text area name.
32
+ */
33
+ this.textStyles = new mapproxy_1.WriteableMapProxy(() => this.textAreas.keys(), (name) => this.client.sendCommand("gts" /* CommandName.GetTextStyle */, {
34
+ 'id': this.id,
35
+ 'n': name,
36
+ }), (name, style) => this.client.sendCommand("sts" /* CommandName.SetTextStyle */, {
37
+ 'id': this.id,
38
+ 'n': name,
39
+ 's': style,
40
+ }));
30
41
  }
31
42
  /**
32
43
  * @returns The bounding box of this item relative to its containing page. As pages may change size
@@ -15,10 +15,10 @@ export declare class MapProxy<KEY, VALUE> {
15
15
  get(key: KEY): VALUE;
16
16
  first(): VALUE | undefined;
17
17
  }
18
- export declare class WriteableMapProxy<KEY, VALUE> extends MapProxy<KEY, VALUE> {
18
+ export declare class WriteableMapProxy<KEY, VALUE, WRITERETURN, WRITEVALUE = VALUE> extends MapProxy<KEY, VALUE> {
19
19
  private readonly setter;
20
- constructor(getKeys: () => KEY[], getItem: (key: KEY) => VALUE, setter: (key: KEY, val: VALUE, options?: SetterOptions) => void);
21
- set(key: KEY, value: VALUE, options?: SetterOptions): void;
20
+ constructor(getKeys: () => KEY[], getItem: (key: KEY) => VALUE, setter: (key: KEY, val: WRITEVALUE, options?: SetterOptions) => WRITERETURN);
21
+ set(key: KEY, value: WRITEVALUE, options?: SetterOptions): WRITERETURN;
22
22
  }
23
23
  export interface SetterOptions {
24
24
  force?: boolean;
@@ -59,7 +59,7 @@ class WriteableMapProxy extends MapProxy {
59
59
  this.setter = setter;
60
60
  }
61
61
  set(key, value, options = {}) {
62
- this.setter(key, value, options);
62
+ return this.setter(key, value, options);
63
63
  }
64
64
  }
65
65
  exports.WriteableMapProxy = WriteableMapProxy;
@@ -11,7 +11,7 @@ export declare class PropertyStoreProxy {
11
11
  * Not all properties are writeable (e.g. "ClassName" on a block).
12
12
  * To move or resize elements, use setLocation() or setBoundingBox() or offset() instead.
13
13
  */
14
- readonly properties: WriteableMapProxy<string, import("..").JsonSerializable>;
14
+ readonly properties: WriteableMapProxy<string, import("..").JsonSerializable, void, import("..").JsonSerializable>;
15
15
  /**
16
16
  *
17
17
  * @param id ID of this element, or undefined for the document itself
@@ -6,7 +6,7 @@ import { WriteableMapProxy } from './mapproxy';
6
6
  /**
7
7
  * The shape data fields on a single element of the current document
8
8
  */
9
- export declare class ShapeDataProxy extends WriteableMapProxy<string, SerializedFieldType | SerializedDataError> {
9
+ export declare class ShapeDataProxy extends WriteableMapProxy<string, SerializedFieldType | SerializedDataError, void> {
10
10
  readonly id: string | undefined;
11
11
  protected readonly client: EditorClient;
12
12
  /**
@@ -0,0 +1,28 @@
1
+ import { isBoolean, isNumber, isString } from '../../core/checks';
2
+ /**
3
+ * Text styles that can be read and written with ItemProxy.textStyles.
4
+ */
5
+ export declare enum TextMarkupNames {
6
+ Family = "font",
7
+ Bold = "bold",
8
+ Italic = "italic",
9
+ Underline = "underline",
10
+ Size = "size",
11
+ Color = "color"
12
+ }
13
+ export interface TextStyle {
14
+ [TextMarkupNames.Family]: string;
15
+ [TextMarkupNames.Bold]: boolean;
16
+ [TextMarkupNames.Italic]: boolean;
17
+ [TextMarkupNames.Underline]: boolean;
18
+ [TextMarkupNames.Size]: number;
19
+ [TextMarkupNames.Color]: string;
20
+ }
21
+ export declare const isPartialTextStyle: (subject: unknown) => subject is Partial<import("../..").DestructureGuardedTypeObj<{
22
+ font: typeof isString;
23
+ bold: typeof isBoolean;
24
+ italic: typeof isBoolean;
25
+ underline: typeof isBoolean;
26
+ size: typeof isNumber;
27
+ color: typeof isString;
28
+ }>>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPartialTextStyle = exports.TextMarkupNames = void 0;
4
+ const checks_1 = require("../../core/checks");
5
+ const validators_1 = require("../../core/validators/validators");
6
+ /**
7
+ * Text styles that can be read and written with ItemProxy.textStyles.
8
+ */
9
+ var TextMarkupNames;
10
+ (function (TextMarkupNames) {
11
+ TextMarkupNames["Family"] = "font";
12
+ TextMarkupNames["Bold"] = "bold";
13
+ TextMarkupNames["Italic"] = "italic";
14
+ TextMarkupNames["Underline"] = "underline";
15
+ TextMarkupNames["Size"] = "size";
16
+ TextMarkupNames["Color"] = "color";
17
+ })(TextMarkupNames = exports.TextMarkupNames || (exports.TextMarkupNames = {}));
18
+ exports.isPartialTextStyle = (0, validators_1.partialObjectValidator)({
19
+ [TextMarkupNames.Family]: checks_1.isString,
20
+ [TextMarkupNames.Bold]: checks_1.isBoolean,
21
+ [TextMarkupNames.Italic]: checks_1.isBoolean,
22
+ [TextMarkupNames.Underline]: checks_1.isBoolean,
23
+ [TextMarkupNames.Size]: checks_1.isNumber,
24
+ [TextMarkupNames.Color]: checks_1.isString,
25
+ });
package/sdk/index.d.ts CHANGED
@@ -43,6 +43,8 @@ export * from './core/properties/fillcolor';
43
43
  export * from './core/properties/shadow';
44
44
  export * from './core/serializeddataerror';
45
45
  export * from './core/shapedatainheritance';
46
+ export * from './core/spreadsheetintegration/lucidspreadsheetintegration';
47
+ export * from './core/spreadsheetintegration/lucidspreadsheetintegrationregistry';
46
48
  export * from './core/unfurl/unfurlcallbacks';
47
49
  export * from './core/unfurl/unfurldetails';
48
50
  export * from './core/unfurl/unfurliframe';
@@ -87,6 +89,7 @@ export * from './document/pagedefinition';
87
89
  export * from './document/pageproxy';
88
90
  export * from './document/propertystoreproxy';
89
91
  export * from './document/shapedataproxy';
92
+ export * from './document/text/textstyle';
90
93
  export * from './editorclient';
91
94
  export * from './index';
92
95
  export * from './math';
package/sdk/index.js CHANGED
@@ -59,6 +59,8 @@ __exportStar(require("./core/properties/fillcolor"), exports);
59
59
  __exportStar(require("./core/properties/shadow"), exports);
60
60
  __exportStar(require("./core/serializeddataerror"), exports);
61
61
  __exportStar(require("./core/shapedatainheritance"), exports);
62
+ __exportStar(require("./core/spreadsheetintegration/lucidspreadsheetintegration"), exports);
63
+ __exportStar(require("./core/spreadsheetintegration/lucidspreadsheetintegrationregistry"), exports);
62
64
  __exportStar(require("./core/unfurl/unfurlcallbacks"), exports);
63
65
  __exportStar(require("./core/unfurl/unfurldetails"), exports);
64
66
  __exportStar(require("./core/unfurl/unfurliframe"), exports);
@@ -103,6 +105,7 @@ __exportStar(require("./document/pagedefinition"), exports);
103
105
  __exportStar(require("./document/pageproxy"), exports);
104
106
  __exportStar(require("./document/propertystoreproxy"), exports);
105
107
  __exportStar(require("./document/shapedataproxy"), exports);
108
+ __exportStar(require("./document/text/textstyle"), exports);
106
109
  __exportStar(require("./editorclient"), exports);
107
110
  __exportStar(require("./index"), exports);
108
111
  __exportStar(require("./math"), exports);