lucid-extension-sdk 0.0.6 → 0.0.13

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 (55) hide show
  1. package/interop.d.ts +4 -0
  2. package/package.json +3 -3
  3. package/sdk/commandtypes.d.ts +241 -5
  4. package/sdk/commandtypes.js +6 -0
  5. package/sdk/core/data/referencekeys/serializedreferencekey.d.ts +6 -0
  6. package/sdk/core/data/referencekeys/serializedreferencekey.js +17 -1
  7. package/sdk/core/jsonserializable.d.ts +4 -0
  8. package/sdk/data/collectionproxy.d.ts +2 -2
  9. package/sdk/data/collectionproxy.js +2 -2
  10. package/sdk/data/datasourceproxy.d.ts +9 -3
  11. package/sdk/data/datasourceproxy.js +9 -3
  12. package/sdk/data/referencekeydefinition.d.ts +30 -2
  13. package/sdk/data/referencekeydefinition.js +26 -1
  14. package/sdk/data/referencekeyproxy.d.ts +4 -0
  15. package/sdk/data/referencekeyproxy.js +25 -0
  16. package/sdk/data/schemadefinition.d.ts +13 -0
  17. package/sdk/data/schemadefinition.js +13 -1
  18. package/sdk/document/blockclasses/blockproxyregistry.js +2 -1
  19. package/sdk/document/blockclasses/customblockproxy.d.ts +6 -0
  20. package/sdk/document/blockclasses/customblockproxy.js +24 -0
  21. package/sdk/document/blockdefinition.d.ts +4 -2
  22. package/sdk/document/blockproxy.d.ts +20 -4
  23. package/sdk/document/blockproxy.js +31 -4
  24. package/sdk/document/documentproxy.d.ts +22 -2
  25. package/sdk/document/documentproxy.js +33 -2
  26. package/sdk/document/elementproxy.d.ts +26 -18
  27. package/sdk/document/elementproxy.js +26 -29
  28. package/sdk/document/groupproxy.d.ts +1 -1
  29. package/sdk/document/groupproxy.js +1 -1
  30. package/sdk/document/itemproxy.d.ts +5 -5
  31. package/sdk/document/itemproxy.js +5 -5
  32. package/sdk/document/lineproxy.d.ts +32 -6
  33. package/sdk/document/lineproxy.js +52 -6
  34. package/sdk/document/linetextareapositioning.d.ts +31 -0
  35. package/sdk/document/linetextareapositioning.js +30 -0
  36. package/sdk/document/mapproxy.d.ts +7 -1
  37. package/sdk/document/mapproxy.js +8 -0
  38. package/sdk/document/propertystoreproxy.d.ts +21 -0
  39. package/sdk/document/propertystoreproxy.js +37 -0
  40. package/sdk/document/shapedataproxy.d.ts +5 -0
  41. package/sdk/document/shapedataproxy.js +5 -0
  42. package/sdk/editorclient.d.ts +8 -2
  43. package/sdk/editorclient.js +51 -9
  44. package/sdk/index.d.ts +1 -0
  45. package/sdk/index.js +1 -0
  46. package/sdk/ui/alertmodal.d.ts +2 -3
  47. package/sdk/ui/alertmodal.js +2 -3
  48. package/sdk/ui/iframeui.d.ts +57 -0
  49. package/sdk/ui/iframeui.js +82 -0
  50. package/sdk/ui/modal.d.ts +11 -33
  51. package/sdk/ui/modal.js +9 -46
  52. package/sdk/ui/panel.d.ts +43 -0
  53. package/sdk/ui/panel.js +50 -0
  54. package/sdk/ui/viewport.d.ts +45 -0
  55. package/sdk/ui/viewport.js +80 -0
@@ -4,42 +4,24 @@ exports.ElementProxy = void 0;
4
4
  const referencekeydefinition_1 = require("../data/referencekeydefinition");
5
5
  const referencekeyproxy_1 = require("../data/referencekeyproxy");
6
6
  const mapproxy_1 = require("./mapproxy");
7
+ const propertystoreproxy_1 = require("./propertystoreproxy");
7
8
  const shapedataproxy_1 = require("./shapedataproxy");
8
9
  /**
9
10
  * An element is anything on a Lucid document that can have properties and shape data:
10
- * * The document itself
11
- * * Pages
12
- * * Blocks
13
- * * Lines
14
- * * Groups
11
+ * * [The document itself](#classes_document_documentproxy-DocumentProxy)
12
+ * * [Pages](#classes_document_pageproxy-PageProxy)
13
+ * * [Blocks](#classes_document_blockproxy-BlockProxy)
14
+ * * [Lines](#classes_document_lineproxy-LineProxy)
15
+ * * [Groups](#classes_document_groupproxy-GroupProxy)
15
16
  */
16
- class ElementProxy {
17
+ class ElementProxy extends propertystoreproxy_1.PropertyStoreProxy {
17
18
  /**
18
19
  *
19
- * @param id ID of this element, or undefined for the document itself
20
+ * @param id ID of this element, or `undefined` for the document itself
20
21
  * @param client
21
22
  */
22
23
  constructor(id, client) {
23
- this.id = id;
24
- this.client = client;
25
- /**
26
- * All properties available on this element, organized by name.
27
- * Not all properties are writeable (e.g. "ClassName" on a block).
28
- * To move or resize elements, use setLocation() or setBoundingBox() or offset() instead.
29
- */
30
- this.properties = new mapproxy_1.WriteableMapProxy(() => this.client.sendCommand("lpr" /* ListProperties */, { 'id': this.id }), (name) => this.client.sendCommand("gp" /* GetProperty */, {
31
- 'id': this.id,
32
- 'p': name,
33
- }), (name, value) => {
34
- if (name === 'BoundingBox') {
35
- throw new Error('Do not use properties.set() to move or resize items; use setLocation() or setBoundingBox() or offset()');
36
- }
37
- this.client.sendCommand("sp" /* SetProperty */, {
38
- 'id': this.id,
39
- 'p': name,
40
- 'v': value,
41
- });
42
- });
24
+ super(id, client);
43
25
  /**
44
26
  * The shape data set directly on this element (not including any shape data inherited from the page or a containing group).
45
27
  */
@@ -52,8 +34,19 @@ class ElementProxy {
52
34
  'id': this.id,
53
35
  'n': name,
54
36
  })));
37
+ /**
38
+ * The set of reference keys, organized by their ID, which can be either a string or number.
39
+ *
40
+ * For more information, see the [Developer Guide](/extension-api#guide-reference-keys).
41
+ */
55
42
  this.referenceKeys = new mapproxy_1.MapProxy(() => this.client.sendCommand("lrk" /* ListReferenceKeys */, { 'id': this.id }), (key) => new referencekeyproxy_1.ReferenceKeyProxy(this.id, key, this.client, this.client.sendCommand("grk" /* GetReferenceKey */, { 'id': this.id, 'k': key })));
56
43
  }
44
+ /**
45
+ * Set a reference key on this element, replacing any existing reference at the specified key.
46
+ *
47
+ * @param key
48
+ * @param settings
49
+ */
57
50
  setReferenceKey(key, settings) {
58
51
  this.client.sendCommand("srk" /* SetReferenceKey */, {
59
52
  'id': this.id,
@@ -61,11 +54,15 @@ class ElementProxy {
61
54
  'v': (0, referencekeydefinition_1.serializeReferenceKeyDefinition)(settings),
62
55
  });
63
56
  }
57
+ /**
58
+ * Remove the specified reference key from this element.
59
+ * @param key
60
+ */
64
61
  removeReferenceKey(key) {
65
62
  this.client.sendCommand("srk" /* SetReferenceKey */, { 'id': this.id, 'k': key });
66
63
  }
67
64
  /**
68
- * @returns true if this element still exists on the document, or false otherwise
65
+ * @returns `true` if this element still exists on the document, or `false` otherwise
69
66
  */
70
67
  exists() {
71
68
  return this.client.sendCommand("ee" /* ElementExists */, { 'id': this.id });
@@ -73,7 +70,7 @@ class ElementProxy {
73
70
  /**
74
71
  * Execute a formula in the context of this element
75
72
  * @param formula The formula text, e.g. "@a + @b" to add together the shape data values a and b.
76
- * @returns the result of the formula, or an error.
73
+ * @returns The result of the formula, or an error.
77
74
  */
78
75
  executeFormula(formula) {
79
76
  return shapedataproxy_1.ShapeDataProxy.parseData(this.client.sendCommand("ef" /* ExecuteFormula */, { 'id': this.id || '', 'f': formula }));
@@ -2,7 +2,7 @@ import { ItemProxy } from './itemproxy';
2
2
  import { LineProxy } from './lineproxy';
3
3
  import { MapProxy } from './mapproxy';
4
4
  /**
5
- * A group of items on a page
5
+ * A group of items on a page.
6
6
  */
7
7
  export declare class GroupProxy extends ItemProxy {
8
8
  /**
@@ -5,7 +5,7 @@ const itemproxy_1 = require("./itemproxy");
5
5
  const lineproxy_1 = require("./lineproxy");
6
6
  const mapproxy_1 = require("./mapproxy");
7
7
  /**
8
- * A group of items on a page
8
+ * A group of items on a page.
9
9
  */
10
10
  class GroupProxy extends itemproxy_1.ItemProxy {
11
11
  constructor() {
@@ -18,7 +18,7 @@ export declare class ItemProxy extends ElementProxy {
18
18
  */
19
19
  readonly textAreas: WriteableMapProxy<string, string>;
20
20
  /**
21
- * @returns the bounding box of this item relative to its containing page. As pages may change size
21
+ * @returns The bounding box of this item relative to its containing page. As pages may change size
22
22
  * to fit the content on them, note that these coordinates may be negative or very large.
23
23
  *
24
24
  * If this is a rotated block, the bounding box returned here is where the block would be if it were
@@ -37,11 +37,11 @@ export declare class ItemProxy extends ElementProxy {
37
37
  */
38
38
  setBoundingBox(bb: Box): void;
39
39
  /**
40
- * @returns the page containing this item
40
+ * @returns The page containing this item
41
41
  */
42
42
  getPage(): import("./pageproxy").PageProxy;
43
43
  /**
44
- * @returns the x/y location of this item
44
+ * @returns The x/y location of this item
45
45
  */
46
46
  getLocation(): {
47
47
  x: number;
@@ -49,7 +49,7 @@ export declare class ItemProxy extends ElementProxy {
49
49
  };
50
50
  /**
51
51
  * Moves this item so that its upper-left corner is positioned at the given location (prior to any rotation)
52
- * @param location the target location
52
+ * @param location The target location
53
53
  */
54
54
  setLocation(location: Point): void;
55
55
  /**
@@ -63,7 +63,7 @@ export declare class ItemProxy extends ElementProxy {
63
63
  */
64
64
  delete(): void;
65
65
  /**
66
- * @returns an array of blocks whose bounding boxes contain this item's upper-left corner
66
+ * @returns An array of blocks whose bounding boxes contain this item's upper-left corner
67
67
  */
68
68
  getContainers(): import("./blockproxy").BlockProxy[];
69
69
  }
@@ -28,7 +28,7 @@ class ItemProxy extends elementproxy_1.ElementProxy {
28
28
  }));
29
29
  }
30
30
  /**
31
- * @returns the bounding box of this item relative to its containing page. As pages may change size
31
+ * @returns The bounding box of this item relative to its containing page. As pages may change size
32
32
  * to fit the content on them, note that these coordinates may be negative or very large.
33
33
  *
34
34
  * If this is a rotated block, the bounding box returned here is where the block would be if it were
@@ -60,13 +60,13 @@ class ItemProxy extends elementproxy_1.ElementProxy {
60
60
  }
61
61
  }
62
62
  /**
63
- * @returns the page containing this item
63
+ * @returns The page containing this item
64
64
  */
65
65
  getPage() {
66
66
  return this.client.getPageProxy(this.client.sendCommand("gip" /* GetItemPageId */, this.id));
67
67
  }
68
68
  /**
69
- * @returns the x/y location of this item
69
+ * @returns The x/y location of this item
70
70
  */
71
71
  getLocation() {
72
72
  const bb = this.getBoundingBox();
@@ -74,7 +74,7 @@ class ItemProxy extends elementproxy_1.ElementProxy {
74
74
  }
75
75
  /**
76
76
  * Moves this item so that its upper-left corner is positioned at the given location (prior to any rotation)
77
- * @param location the target location
77
+ * @param location The target location
78
78
  */
79
79
  setLocation(location) {
80
80
  const current = this.getBoundingBox();
@@ -97,7 +97,7 @@ class ItemProxy extends elementproxy_1.ElementProxy {
97
97
  this.client.sendCommand("di" /* DeleteItem */, this.id);
98
98
  }
99
99
  /**
100
- * @returns an array of blocks whose bounding boxes contain this item's upper-left corner
100
+ * @returns An array of blocks whose bounding boxes contain this item's upper-left corner
101
101
  */
102
102
  getContainers() {
103
103
  const containers = this.executeFormula('LABEL(CONTAINEDBY)');
@@ -2,6 +2,7 @@ import { Point } from '../math';
2
2
  import { BlockProxy } from './blockproxy';
3
3
  import { ItemProxy } from './itemproxy';
4
4
  import { EndpointDefinition } from './linedefinition';
5
+ import { LineTextAreaPositioning } from './linetextareapositioning';
5
6
  /**
6
7
  * A line on the current Lucid document
7
8
  */
@@ -12,14 +13,14 @@ export declare class LineProxy extends ItemProxy {
12
13
  private parseLineEndpointDefinition;
13
14
  private serializeLineEndpointDefinition;
14
15
  /**
15
- * @returns the definition of the first endpoint of this line
16
+ * @returns The definition of the first endpoint of this line
16
17
  */
17
18
  getEndpoint1(): EndpointDefinition & {
18
19
  x: number;
19
20
  y: number;
20
21
  };
21
22
  /**
22
- * @returns the definition of the second endpoint of this line
23
+ * @returns The definition of the second endpoint of this line
23
24
  */
24
25
  getEndpoint2(): EndpointDefinition & {
25
26
  x: number;
@@ -36,20 +37,45 @@ export declare class LineProxy extends ItemProxy {
36
37
  */
37
38
  setEndpoint2(endpoint: EndpointDefinition): void;
38
39
  /**
39
- * @returns the block or line connected to the first endpoint of this line, or undefined if none
40
+ * @returns The block or line connected to the first endpoint of this line, or `undefined` if none
40
41
  */
41
42
  getUpstreamConnection(): void | BlockProxy | LineProxy | undefined;
42
43
  /**
43
- * @returns the block or line connected to the second endpoint of this line, or undefined if none
44
+ * @returns The block or line connected to the second endpoint of this line, or `undefined` if none
44
45
  */
45
46
  getDownstreamConnection(): void | BlockProxy | LineProxy | undefined;
46
47
  /**
47
- * @returns a list of lines whose endpoints are connected to this line
48
+ * @returns A list of lines whose endpoints are connected to this line
48
49
  */
49
50
  getConnectedLines(): LineProxy[];
50
51
  /**
51
52
  * @param relative A distance, between 0 and 1, between the first and second endpoint of this line
52
- * @returns the coordinate of that relative position, relative to the containing page
53
+ * @returns The coordinate of that relative position, relative to the containing page
53
54
  */
54
55
  getRelativePosition(relative: number): Point;
56
+ /**
57
+ *
58
+ * @param name
59
+ * @returns The position of the given text area on this line, if it exists, or undefined if it does not exist.
60
+ */
61
+ getTextAreaPosition(name: string): LineTextAreaPositioning | undefined;
62
+ /**
63
+ * Updates the position of the given text area, if it exists. If not, an error is thrown.
64
+ * @param name
65
+ * @param position
66
+ */
67
+ setTextAreaPosition(name: string, position: LineTextAreaPositioning): void;
68
+ /**
69
+ * Adds a new text area to this line at the given location with the given initial plain text.
70
+ * The text will be styled with the document theme, if any.
71
+ * @param text
72
+ * @param position
73
+ * @returns The name of the text area added
74
+ */
75
+ addTextArea(text: string, position: LineTextAreaPositioning): string;
76
+ /**
77
+ * Deletes the given text area from the line, if it exists.
78
+ * @param name
79
+ */
80
+ deleteTextArea(name: string): void;
55
81
  }
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LineProxy = void 0;
4
+ const checks_1 = require("../core/checks");
4
5
  const blockproxy_1 = require("./blockproxy");
5
6
  const itemproxy_1 = require("./itemproxy");
7
+ const linetextareapositioning_1 = require("./linetextareapositioning");
6
8
  /**
7
9
  * A line on the current Lucid document
8
10
  */
@@ -85,13 +87,13 @@ class LineProxy extends itemproxy_1.ItemProxy {
85
87
  }
86
88
  }
87
89
  /**
88
- * @returns the definition of the first endpoint of this line
90
+ * @returns The definition of the first endpoint of this line
89
91
  */
90
92
  getEndpoint1() {
91
93
  return this.parseLineEndpointDefinition(this.properties.get('Endpoint1'));
92
94
  }
93
95
  /**
94
- * @returns the definition of the second endpoint of this line
96
+ * @returns The definition of the second endpoint of this line
95
97
  */
96
98
  getEndpoint2() {
97
99
  return this.parseLineEndpointDefinition(this.properties.get('Endpoint2'));
@@ -111,19 +113,19 @@ class LineProxy extends itemproxy_1.ItemProxy {
111
113
  this.properties.set('Endpoint2', this.serializeLineEndpointDefinition(endpoint));
112
114
  }
113
115
  /**
114
- * @returns the block or line connected to the first endpoint of this line, or undefined if none
116
+ * @returns The block or line connected to the first endpoint of this line, or `undefined` if none
115
117
  */
116
118
  getUpstreamConnection() {
117
119
  return this.getEndpoint1().connection;
118
120
  }
119
121
  /**
120
- * @returns the block or line connected to the second endpoint of this line, or undefined if none
122
+ * @returns The block or line connected to the second endpoint of this line, or `undefined` if none
121
123
  */
122
124
  getDownstreamConnection() {
123
125
  return this.getEndpoint2().connection;
124
126
  }
125
127
  /**
126
- * @returns a list of lines whose endpoints are connected to this line
128
+ * @returns A list of lines whose endpoints are connected to this line
127
129
  */
128
130
  getConnectedLines() {
129
131
  const ids = this.client.sendCommand("gcl" /* GetConnectedLines */, this.id);
@@ -131,10 +133,54 @@ class LineProxy extends itemproxy_1.ItemProxy {
131
133
  }
132
134
  /**
133
135
  * @param relative A distance, between 0 and 1, between the first and second endpoint of this line
134
- * @returns the coordinate of that relative position, relative to the containing page
136
+ * @returns The coordinate of that relative position, relative to the containing page
135
137
  */
136
138
  getRelativePosition(relative) {
137
139
  return this.client.sendCommand("grlp" /* GetRelativeLinePosition */, { 'id': this.id, 'p': relative });
138
140
  }
141
+ /**
142
+ *
143
+ * @param name
144
+ * @returns The position of the given text area on this line, if it exists, or undefined if it does not exist.
145
+ */
146
+ getTextAreaPosition(name) {
147
+ const serializedTextAreas = this.properties.get('TextAreas');
148
+ if ((0, checks_1.isObject)(serializedTextAreas)) {
149
+ const rawEntry = serializedTextAreas[name];
150
+ if ((0, linetextareapositioning_1.isSerializedLineTextAreaPositioning)(rawEntry)) {
151
+ return (0, linetextareapositioning_1.deserializeLineTextAreaPositioning)(rawEntry);
152
+ }
153
+ }
154
+ return undefined;
155
+ }
156
+ /**
157
+ * Updates the position of the given text area, if it exists. If not, an error is thrown.
158
+ * @param name
159
+ * @param position
160
+ */
161
+ setTextAreaPosition(name, position) {
162
+ this.properties.set('TextAreas', { [name]: (0, linetextareapositioning_1.serializeLineTextAreaPositioning)(position) });
163
+ }
164
+ /**
165
+ * Adds a new text area to this line at the given location with the given initial plain text.
166
+ * The text will be styled with the document theme, if any.
167
+ * @param text
168
+ * @param position
169
+ * @returns The name of the text area added
170
+ */
171
+ addTextArea(text, position) {
172
+ return this.client.sendCommand("alta" /* AddLineTextArea */, {
173
+ 'id': this.id,
174
+ 'p': (0, linetextareapositioning_1.serializeLineTextAreaPositioning)(position),
175
+ 't': text,
176
+ });
177
+ }
178
+ /**
179
+ * Deletes the given text area from the line, if it exists.
180
+ * @param name
181
+ */
182
+ deleteTextArea(name) {
183
+ this.properties.set('TextAreas', { [name]: null });
184
+ }
139
185
  }
140
186
  exports.LineProxy = LineProxy;
@@ -0,0 +1,31 @@
1
+ export interface LineTextAreaPositioning {
2
+ /**
3
+ * A number between 0 and 1 representing how far this text lies along the line, where 0 puts the text
4
+ * at the same location as the first endpoint, and 1 puts the text at the same location as the second
5
+ * endpoint.
6
+ */
7
+ location: number;
8
+ /**
9
+ * Which side of the line the text is displayed on. If zero, the text is on top of the line. If -1,
10
+ * the text is to the left of the line as you travel from the first to second endpoints. If 1, the
11
+ * text is to the right of the line as you travel from the first to second endpoints.
12
+ */
13
+ side: -1 | 0 | 1;
14
+ /**
15
+ * Normally text on a line is not allowed to overlap a block that is connected to either end of the
16
+ * line. If `allowOverBlock` is true, then the text is allowed to overlap an attached block.
17
+ */
18
+ allowOverBlock?: boolean;
19
+ }
20
+ /** @ignore */
21
+ export declare type SerializedLineTextAreaPositioning = {
22
+ 'Location': number;
23
+ 'Side': -1 | 0 | 1;
24
+ 'AllowOverBlock'?: boolean;
25
+ };
26
+ /** @ignore */
27
+ export declare function isSerializedLineTextAreaPositioning(raw: unknown): raw is SerializedLineTextAreaPositioning;
28
+ /** @ignore */
29
+ export declare function deserializeLineTextAreaPositioning(raw: SerializedLineTextAreaPositioning): LineTextAreaPositioning;
30
+ /** @ignore */
31
+ export declare function serializeLineTextAreaPositioning(data: LineTextAreaPositioning): SerializedLineTextAreaPositioning;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeLineTextAreaPositioning = exports.deserializeLineTextAreaPositioning = exports.isSerializedLineTextAreaPositioning = void 0;
4
+ const checks_1 = require("../core/checks");
5
+ /** @ignore */
6
+ function isSerializedLineTextAreaPositioning(raw) {
7
+ return ((0, checks_1.isObject)(raw) &&
8
+ (0, checks_1.isNumber)(raw['Location']) &&
9
+ (0, checks_1.isNumber)(raw['Side']) &&
10
+ ((0, checks_1.isBoolean)(raw['AllowOverBlock']) || (0, checks_1.isUndefined)(raw['AllowOverBlock'])));
11
+ }
12
+ exports.isSerializedLineTextAreaPositioning = isSerializedLineTextAreaPositioning;
13
+ /** @ignore */
14
+ function deserializeLineTextAreaPositioning(raw) {
15
+ return {
16
+ location: raw['Location'],
17
+ side: raw['Side'],
18
+ allowOverBlock: raw['AllowOverBlock'],
19
+ };
20
+ }
21
+ exports.deserializeLineTextAreaPositioning = deserializeLineTextAreaPositioning;
22
+ /** @ignore */
23
+ function serializeLineTextAreaPositioning(data) {
24
+ return {
25
+ 'Location': data.location,
26
+ 'Side': data.side,
27
+ 'AllowOverBlock': data.allowOverBlock,
28
+ };
29
+ }
30
+ exports.serializeLineTextAreaPositioning = serializeLineTextAreaPositioning;
@@ -1,10 +1,16 @@
1
+ /**
2
+ * A data structure similar to a normal Map which accesses its data through API
3
+ * commands to the Lucid app. This structure is iterable with `for...of`.
4
+ */
1
5
  export declare class MapProxy<KEY, VALUE> {
2
6
  private readonly getKeys;
3
7
  private readonly getItem;
4
8
  constructor(getKeys: () => KEY[], getItem: (key: KEY) => VALUE);
9
+ /** @ignore */
5
10
  [Symbol.iterator](): Iterator<[KEY, VALUE]>;
6
- values(): Iterator<VALUE>;
11
+ values(): Generator<VALUE, void, unknown>;
7
12
  keys(): KEY[];
13
+ get size(): number;
8
14
  get(key: KEY): VALUE;
9
15
  first(): VALUE | undefined;
10
16
  }
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WriteableMapProxy = exports.MapProxy = void 0;
4
+ /**
5
+ * A data structure similar to a normal Map which accesses its data through API
6
+ * commands to the Lucid app. This structure is iterable with `for...of`.
7
+ */
4
8
  class MapProxy {
5
9
  constructor(getKeys, getItem) {
6
10
  this.getKeys = getKeys;
7
11
  this.getItem = getItem;
8
12
  }
13
+ /** @ignore */
9
14
  *[Symbol.iterator]() {
10
15
  for (const key of this.keys()) {
11
16
  const value = this.get(key);
@@ -25,6 +30,9 @@ class MapProxy {
25
30
  keys() {
26
31
  return this.getKeys();
27
32
  }
33
+ get size() {
34
+ return this.keys().length;
35
+ }
28
36
  get(key) {
29
37
  return this.getItem(key);
30
38
  }
@@ -0,0 +1,21 @@
1
+ import { EditorClient } from '../editorclient';
2
+ import { WriteableMapProxy } from './mapproxy';
3
+ /**
4
+ * Base class for anything on a Lucid document that has an ID and properties.
5
+ */
6
+ export declare class PropertyStoreProxy {
7
+ readonly id: string | undefined;
8
+ protected readonly client: EditorClient;
9
+ /**
10
+ * All properties available on this element, organized by name.
11
+ * Not all properties are writeable (e.g. "ClassName" on a block).
12
+ * To move or resize elements, use setLocation() or setBoundingBox() or offset() instead.
13
+ */
14
+ readonly properties: WriteableMapProxy<string, import("..").JsonSerializable>;
15
+ /**
16
+ *
17
+ * @param id ID of this element, or undefined for the document itself
18
+ * @param client
19
+ */
20
+ constructor(id: string | undefined, client: EditorClient);
21
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PropertyStoreProxy = void 0;
4
+ const mapproxy_1 = require("./mapproxy");
5
+ /**
6
+ * Base class for anything on a Lucid document that has an ID and properties.
7
+ */
8
+ class PropertyStoreProxy {
9
+ /**
10
+ *
11
+ * @param id ID of this element, or undefined for the document itself
12
+ * @param client
13
+ */
14
+ constructor(id, client) {
15
+ this.id = id;
16
+ this.client = client;
17
+ /**
18
+ * All properties available on this element, organized by name.
19
+ * Not all properties are writeable (e.g. "ClassName" on a block).
20
+ * To move or resize elements, use setLocation() or setBoundingBox() or offset() instead.
21
+ */
22
+ this.properties = new mapproxy_1.WriteableMapProxy(() => this.client.sendCommand("lpr" /* ListProperties */, { 'id': this.id }), (name) => this.client.sendCommand("gp" /* GetProperty */, {
23
+ 'id': this.id,
24
+ 'p': name,
25
+ }), (name, value) => {
26
+ if (name === 'BoundingBox') {
27
+ throw new Error('Do not use properties.set() to move or resize items; use setLocation() or setBoundingBox() or offset()');
28
+ }
29
+ this.client.sendCommand("sp" /* SetProperty */, {
30
+ 'id': this.id,
31
+ 'p': name,
32
+ 'v': value,
33
+ });
34
+ });
35
+ }
36
+ }
37
+ exports.PropertyStoreProxy = PropertyStoreProxy;
@@ -14,6 +14,11 @@ export declare class ShapeDataProxy extends WriteableMapProxy<string, Serialized
14
14
  * @param client
15
15
  */
16
16
  constructor(id: string | undefined, client: EditorClient);
17
+ /**
18
+ * Delete the specified shape data from this element
19
+ * @param key
20
+ */
17
21
  delete(key: string): void;
22
+ /** @ignore */
18
23
  static parseData(raw: SerializedFieldType | SerializedDataError): SerializedFieldType | DataError;
19
24
  }
@@ -36,11 +36,16 @@ class ShapeDataProxy extends mapproxy_1.WriteableMapProxy {
36
36
  this.id = id;
37
37
  this.client = client;
38
38
  }
39
+ /**
40
+ * Delete the specified shape data from this element
41
+ * @param key
42
+ */
39
43
  delete(key) {
40
44
  if (this.keys().includes(key)) {
41
45
  this.client.sendCommand("dsd" /* DeleteShapeData */, { 'id': this.id, 'n': key });
42
46
  }
43
47
  }
48
+ /** @ignore */
44
49
  static parseData(raw) {
45
50
  if ((0, serializeddataerror_1.isSerializedDataError)(raw)) {
46
51
  return new dataerror_1.DataError(raw['error'], raw['type']);
@@ -3,6 +3,7 @@ import { JsonSerializable } from './core/jsonserializable';
3
3
  import { BlockDefinition } from './document/blockdefinition';
4
4
  import { BlockProxy } from './document/blockproxy';
5
5
  import { ElementProxy } from './document/elementproxy';
6
+ import { GroupProxy } from './document/groupproxy';
6
7
  import { LineProxy } from './document/lineproxy';
7
8
  import { PageProxy } from './document/pageproxy';
8
9
  export interface XHRRequest {
@@ -60,6 +61,7 @@ export declare class EditorClient {
60
61
  * code is not 2xx, the promise will reject.
61
62
  */
62
63
  xhr(request: XHRRequest): Promise<XHRResponse>;
64
+ oauthXhr(providerName: string, request: XHRRequest): Promise<XHRResponse>;
63
65
  /**
64
66
  * Register a named action. These actions can be triggered from custom UI, for example as the action of a
65
67
  * custom menu item.
@@ -89,7 +91,6 @@ export declare class EditorClient {
89
91
  * Execute an API command. This is the low-level API that most of this SDK wraps. It is not expected that you should
90
92
  * ever need to use this directly.
91
93
  *
92
- * @hidden
93
94
  * @param name name of the API command to execute
94
95
  * @param params data to pass to the API command
95
96
  * @returns the output of the given API command
@@ -118,7 +119,7 @@ export declare class EditorClient {
118
119
  * created.
119
120
  *
120
121
  * Example usage:
121
- * ```
122
+ * ```inline:typescript
122
123
  * const client = new EditorClient();
123
124
  * const viewport = new Viewport(client);
124
125
  *
@@ -164,6 +165,11 @@ export declare class EditorClient {
164
165
  * @returns the given page
165
166
  */
166
167
  getPageProxy(id: string): PageProxy;
168
+ /**
169
+ * @param id ID of the item to create a proxy for
170
+ * @returns the given item
171
+ */
172
+ getItemProxy(id: string): BlockProxy | LineProxy | GroupProxy;
167
173
  /**
168
174
  * @param id ID of the element to create a proxy for
169
175
  * @returns the given element