lucid-extension-sdk 0.0.19 → 0.0.27

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.19",
3
+ "version": "0.0.27",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -23,6 +23,7 @@ export declare const enum CommandName {
23
23
  Alert = "a",
24
24
  AnimateViewport = "av",
25
25
  Bootstrap = "b",
26
+ CancelDragBlockToCanvas = "cdc",
26
27
  Confirm = "c",
27
28
  CreateBlock = "cb",
28
29
  CreateCollection = "cc",
@@ -30,6 +31,7 @@ export declare const enum CommandName {
30
31
  CreateLine = "cl",
31
32
  CreatePage = "cp",
32
33
  DataAction = "da",
34
+ DataItemExists = "die",
33
35
  DeleteItem = "di",
34
36
  DeletePage = "dp",
35
37
  DeleteShapeData = "dsd",
@@ -81,6 +83,7 @@ export declare const enum CommandName {
81
83
  ShowModal = "sm",
82
84
  ShowPanel = "spn",
83
85
  SleepForTestCase = "sleep",
86
+ StartDragBlockToCanvas = "sdc",
84
87
  ThrowForTestCase = "throw",
85
88
  UnhookCreateItems = "uci",
86
89
  UnhookSelection = "us",
@@ -118,6 +121,10 @@ export declare type CommandArgs = {
118
121
  query: BootstrapQuery;
119
122
  result: BootstrapResult;
120
123
  };
124
+ [CommandName.CancelDragBlockToCanvas]: {
125
+ query: CancelDragBlockToCanvasQuery;
126
+ result: CancelDragBlockToCanvasResult;
127
+ };
121
128
  [CommandName.Confirm]: {
122
129
  query: ConfirmQuery;
123
130
  result: ConfirmResult;
@@ -146,6 +153,10 @@ export declare type CommandArgs = {
146
153
  query: DataActionQuery;
147
154
  result: DataActionResult;
148
155
  };
156
+ [CommandName.DataItemExists]: {
157
+ query: DataItemExistsQuery;
158
+ result: DataItemExistsResult;
159
+ };
149
160
  [CommandName.DeleteItem]: {
150
161
  query: DeleteItemQuery;
151
162
  result: DeleteItemResult;
@@ -350,6 +361,10 @@ export declare type CommandArgs = {
350
361
  query: SleepForTestCaseQuery;
351
362
  result: SleepForTestCaseResult;
352
363
  };
364
+ [CommandName.StartDragBlockToCanvas]: {
365
+ query: StartDragBlockToCanvasQuery;
366
+ result: StartDragBlockToCanvasResult;
367
+ };
353
368
  [CommandName.ThrowForTestCase]: {
354
369
  query: ThrowForTestCaseQuery;
355
370
  result: ThrowForTestCaseResult;
@@ -432,8 +447,14 @@ export declare type BootstrapQuery = {
432
447
  * the result of the callback, the bootstrap data is cleared.
433
448
  */
434
449
  'c': string;
450
+ /**
451
+ * Marks a document as requiring the editor extension.
452
+ */
453
+ 'm'?: boolean;
435
454
  };
436
455
  export declare type BootstrapResult = Promise<void>;
456
+ export declare type CancelDragBlockToCanvasQuery = void;
457
+ export declare type CancelDragBlockToCanvasResult = undefined;
437
458
  export declare type ConfirmQuery = {
438
459
  /** Title; defaults to extension title */
439
460
  't'?: string;
@@ -517,6 +538,13 @@ export declare type RawDataActionResult = {
517
538
  'j': unknown;
518
539
  });
519
540
  export declare type DataActionResult = Promise<RawDataActionResult>;
541
+ export declare type DataItemExistsQuery = {
542
+ /** Collection ID to check */
543
+ 'c': string;
544
+ /** Primary key to check */
545
+ 'pk': string;
546
+ };
547
+ export declare type DataItemExistsResult = boolean;
520
548
  export declare type DeleteItemQuery = string;
521
549
  export declare type DeleteItemResult = boolean;
522
550
  export declare type DeletePageQuery = string;
@@ -830,6 +858,22 @@ export declare type ShowPanelQuery = {
830
858
  export declare type ShowPanelResult = undefined;
831
859
  export declare type SleepForTestCaseQuery = number;
832
860
  export declare type SleepForTestCaseResult = Promise<void>;
861
+ export declare type StartDragBlockToCanvasQuery = {
862
+ /** Class name of the block to create */
863
+ 'c': string;
864
+ /** Size of the block to create */
865
+ 'sz': {
866
+ 'w': number;
867
+ 'h': number;
868
+ };
869
+ /** Additional properties to set on the block being dragged */
870
+ 'p': {
871
+ [key: string]: JsonSerializable;
872
+ };
873
+ /** If specified, the stencil for a custom shape. Only valid if the class name is 'CustomBlock' */
874
+ 's'?: JsonSerializable | undefined;
875
+ };
876
+ export declare type StartDragBlockToCanvasResult = Promise<string | undefined>;
833
877
  export declare type ThrowForTestCaseQuery = number;
834
878
  export declare type ThrowForTestCaseResult = undefined | Promise<void>;
835
879
  export declare type UnhookCreateItemsQuery = {
@@ -10,12 +10,14 @@ exports.commandTitles = new Map([
10
10
  ["a" /* Alert */, 'Alert'],
11
11
  ["av" /* AnimateViewport */, 'AnimateViewport'],
12
12
  ["b" /* Bootstrap */, 'Bootstrap'],
13
+ ["cdc" /* CancelDragBlockToCanvas */, 'CancelDragBlockToCanvas'],
13
14
  ["c" /* Confirm */, 'Confirm'],
14
15
  ["cb" /* CreateBlock */, 'CreateBlock'],
15
16
  ["cc" /* CreateCollection */, 'CreateCollection'],
16
17
  ["cds" /* CreateDataSource */, 'CreateDataSource'],
17
18
  ["cl" /* CreateLine */, 'CreateLine'],
18
19
  ["cp" /* CreatePage */, 'CreatePage'],
20
+ ["die" /* DataItemExists */, 'DataItemExists'],
19
21
  ["di" /* DeleteItem */, 'DeleteItem'],
20
22
  ["dp" /* DeletePage */, 'DeletePage'],
21
23
  ["dsd" /* DeleteShapeData */, 'DeleteShapeData'],
@@ -67,6 +69,7 @@ exports.commandTitles = new Map([
67
69
  ["sm" /* ShowModal */, 'ShowModal'],
68
70
  ["spn" /* ShowPanel */, 'ShowPanel'],
69
71
  ["sleep" /* SleepForTestCase */, 'SleepForTestCase'],
72
+ ["sdc" /* StartDragBlockToCanvas */, 'StartDragBlockToCanvas'],
70
73
  ["throw" /* ThrowForTestCase */, 'ThrowForTestCase'],
71
74
  ["uci" /* UnhookCreateItems */, 'UnhookCreateItems'],
72
75
  ["us" /* UnhookSelection */, 'UnhookSelection'],
@@ -160,6 +160,6 @@ function isUnknown(val) {
160
160
  }
161
161
  exports.isUnknown = isUnknown;
162
162
  function isPromise(val) {
163
- return isObject(val) && isFunction(val.then) && isFunction(val.catch);
163
+ return isObject(val) && isFunction(val['then']) && isFunction(val['catch']);
164
164
  }
165
165
  exports.isPromise = isPromise;
@@ -7,7 +7,7 @@ function isSerializedColorObjectFieldType(value) {
7
7
  }
8
8
  exports.isSerializedColorObjectFieldType = isSerializedColorObjectFieldType;
9
9
  function isSerializedLucidDictionary(value) {
10
- return (0, checks_1.isObject)(value) && Object.values(value).every(isSerializedFieldType);
10
+ return (0, checks_1.isObject)(value) && (0, checks_1.isObject)(value['dict']) && Object.values(value['dict']).every(isSerializedFieldType);
11
11
  }
12
12
  exports.isSerializedLucidDictionary = isSerializedLucidDictionary;
13
13
  function isSerializedLucidCurrency(value) {
@@ -0,0 +1,59 @@
1
+ export declare enum HorizontalBadgePos {
2
+ LEFT = 0,
3
+ CENTER = 1,
4
+ RIGHT = 2
5
+ }
6
+ export declare enum VerticalBadgePos {
7
+ TOP = 0,
8
+ CENTER = 1,
9
+ BOTTOM = 2
10
+ }
11
+ export declare enum BadgeLayerPos {
12
+ INSIDE = 0,
13
+ EDGE = 1,
14
+ OUTSIDE = 2
15
+ }
16
+ export declare enum BadgeResponsiveness {
17
+ STATIC = 0,
18
+ STACK = 1
19
+ }
20
+ export interface BadgeEnumPosition {
21
+ horizontalPos: HorizontalBadgePos;
22
+ verticalPos: VerticalBadgePos;
23
+ layer: BadgeLayerPos;
24
+ responsive: BadgeResponsiveness;
25
+ }
26
+ export declare const BadgePositionsClockwise: {
27
+ horizontalPos: number;
28
+ verticalPos: number;
29
+ }[];
30
+ export declare type SerializedBadgeEnumPosition = {
31
+ 'horiz'?: HorizontalBadgePos;
32
+ 'vert'?: VerticalBadgePos;
33
+ 'layer'?: BadgeLayerPos;
34
+ 'responsive'?: BadgeResponsiveness;
35
+ };
36
+ export interface Badgeable {
37
+ position: SerializedBadgeEnumPosition;
38
+ }
39
+ export declare const defaultBadgePosition: {
40
+ horizontalPos: HorizontalBadgePos;
41
+ verticalPos: VerticalBadgePos;
42
+ layer: BadgeLayerPos;
43
+ responsive: BadgeResponsiveness;
44
+ };
45
+ export declare const defaultBadgePositionSerialized: {
46
+ horiz: HorizontalBadgePos;
47
+ vert: VerticalBadgePos;
48
+ layer: BadgeLayerPos;
49
+ responsive: BadgeResponsiveness;
50
+ };
51
+ export declare function badgePositionsEqual(a: BadgeEnumPosition, b: BadgeEnumPosition): boolean;
52
+ export declare function deserializeBadgeEnumPosition(serialized?: SerializedBadgeEnumPosition): BadgeEnumPosition;
53
+ export declare function deserializeBadgeEnumPosition(serialized?: SerializedBadgeEnumPosition | null): BadgeEnumPosition | undefined;
54
+ export declare function serializeBadgeEnumPosition(position?: BadgeEnumPosition | null): SerializedBadgeEnumPosition;
55
+ export declare function serializeBadgeEnumPositionAsKey(position: BadgeEnumPosition): string;
56
+ export declare function isValidSerializedBadgeEnumPosition(val: any): val is SerializedBadgeEnumPosition;
57
+ export declare function isHorizontalPos(maybePos: HorizontalBadgePos | undefined | null): maybePos is HorizontalBadgePos;
58
+ export declare function isVerticalPos(maybePos: VerticalBadgePos | undefined | null): maybePos is VerticalBadgePos;
59
+ export declare function isLayerPos(maybePos: BadgeLayerPos | undefined | null): maybePos is BadgeLayerPos;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLayerPos = exports.isVerticalPos = exports.isHorizontalPos = exports.isValidSerializedBadgeEnumPosition = exports.serializeBadgeEnumPositionAsKey = exports.serializeBadgeEnumPosition = exports.deserializeBadgeEnumPosition = exports.badgePositionsEqual = exports.defaultBadgePositionSerialized = exports.defaultBadgePosition = exports.BadgePositionsClockwise = exports.BadgeResponsiveness = exports.BadgeLayerPos = exports.VerticalBadgePos = exports.HorizontalBadgePos = void 0;
4
+ const checks_1 = require("../../checks");
5
+ var HorizontalBadgePos;
6
+ (function (HorizontalBadgePos) {
7
+ HorizontalBadgePos[HorizontalBadgePos["LEFT"] = 0] = "LEFT";
8
+ HorizontalBadgePos[HorizontalBadgePos["CENTER"] = 1] = "CENTER";
9
+ HorizontalBadgePos[HorizontalBadgePos["RIGHT"] = 2] = "RIGHT";
10
+ })(HorizontalBadgePos = exports.HorizontalBadgePos || (exports.HorizontalBadgePos = {}));
11
+ var VerticalBadgePos;
12
+ (function (VerticalBadgePos) {
13
+ VerticalBadgePos[VerticalBadgePos["TOP"] = 0] = "TOP";
14
+ VerticalBadgePos[VerticalBadgePos["CENTER"] = 1] = "CENTER";
15
+ VerticalBadgePos[VerticalBadgePos["BOTTOM"] = 2] = "BOTTOM";
16
+ })(VerticalBadgePos = exports.VerticalBadgePos || (exports.VerticalBadgePos = {}));
17
+ var BadgeLayerPos;
18
+ (function (BadgeLayerPos) {
19
+ BadgeLayerPos[BadgeLayerPos["INSIDE"] = 0] = "INSIDE";
20
+ BadgeLayerPos[BadgeLayerPos["EDGE"] = 1] = "EDGE";
21
+ BadgeLayerPos[BadgeLayerPos["OUTSIDE"] = 2] = "OUTSIDE";
22
+ })(BadgeLayerPos = exports.BadgeLayerPos || (exports.BadgeLayerPos = {}));
23
+ var BadgeResponsiveness;
24
+ (function (BadgeResponsiveness) {
25
+ BadgeResponsiveness[BadgeResponsiveness["STATIC"] = 0] = "STATIC";
26
+ BadgeResponsiveness[BadgeResponsiveness["STACK"] = 1] = "STACK";
27
+ })(BadgeResponsiveness = exports.BadgeResponsiveness || (exports.BadgeResponsiveness = {}));
28
+ /*
29
+ * The order of the badge position starting from the top-left corner and going clockwise
30
+ */
31
+ exports.BadgePositionsClockwise = [
32
+ { horizontalPos: 0, verticalPos: 0 },
33
+ { horizontalPos: 1, verticalPos: 0 },
34
+ { horizontalPos: 2, verticalPos: 0 },
35
+ { horizontalPos: 2, verticalPos: 1 },
36
+ { horizontalPos: 2, verticalPos: 2 },
37
+ { horizontalPos: 1, verticalPos: 2 },
38
+ { horizontalPos: 0, verticalPos: 2 },
39
+ { horizontalPos: 0, verticalPos: 1 }, // left-center
40
+ ];
41
+ exports.defaultBadgePosition = {
42
+ horizontalPos: HorizontalBadgePos.RIGHT,
43
+ verticalPos: VerticalBadgePos.TOP,
44
+ layer: BadgeLayerPos.EDGE,
45
+ responsive: BadgeResponsiveness.STACK,
46
+ };
47
+ exports.defaultBadgePositionSerialized = {
48
+ 'horiz': HorizontalBadgePos.RIGHT,
49
+ 'vert': VerticalBadgePos.TOP,
50
+ 'layer': BadgeLayerPos.EDGE,
51
+ 'responsive': BadgeResponsiveness.STACK,
52
+ };
53
+ function badgePositionsEqual(a, b) {
54
+ return (a.horizontalPos === b.horizontalPos &&
55
+ a.verticalPos === b.verticalPos &&
56
+ a.layer === b.layer &&
57
+ a.responsive === b.responsive);
58
+ }
59
+ exports.badgePositionsEqual = badgePositionsEqual;
60
+ function deserializeBadgeEnumPosition(serialized) {
61
+ if (serialized == null) {
62
+ return undefined;
63
+ }
64
+ return {
65
+ horizontalPos: serialized['horiz'] != null ? serialized['horiz'] : exports.defaultBadgePosition.horizontalPos,
66
+ verticalPos: serialized['vert'] != null ? serialized['vert'] : exports.defaultBadgePosition.verticalPos,
67
+ layer: serialized['layer'] != null ? serialized['layer'] : exports.defaultBadgePosition.layer,
68
+ responsive: serialized['responsive'] != null ? serialized['responsive'] : exports.defaultBadgePosition.responsive,
69
+ };
70
+ }
71
+ exports.deserializeBadgeEnumPosition = deserializeBadgeEnumPosition;
72
+ function serializeBadgeEnumPosition(position) {
73
+ if (position == null) {
74
+ return {
75
+ 'horiz': exports.defaultBadgePosition.horizontalPos,
76
+ 'vert': exports.defaultBadgePosition.verticalPos,
77
+ 'layer': exports.defaultBadgePosition.layer,
78
+ 'responsive': exports.defaultBadgePosition.responsive,
79
+ };
80
+ }
81
+ return {
82
+ 'horiz': position.horizontalPos,
83
+ 'vert': position.verticalPos,
84
+ 'layer': position.layer,
85
+ 'responsive': position.responsive,
86
+ };
87
+ }
88
+ exports.serializeBadgeEnumPosition = serializeBadgeEnumPosition;
89
+ function serializeBadgeEnumPositionAsKey(position) {
90
+ return JSON.stringify(position);
91
+ }
92
+ exports.serializeBadgeEnumPositionAsKey = serializeBadgeEnumPositionAsKey;
93
+ function isValidSerializedBadgeEnumPosition(val) {
94
+ // All fields are optional, so it's fine if they're not present
95
+ const horizValid = val['horiz'] == undefined || Object.values(HorizontalBadgePos).includes(val['horiz']);
96
+ const vertValid = val['vert'] == undefined || Object.values(VerticalBadgePos).includes(val['vert']);
97
+ const layerValid = val['layer'] == undefined || Object.values(BadgeLayerPos).includes(val['layer']);
98
+ const responsiveValid = val['responsive'] == undefined || Object.values(BadgeResponsiveness).includes(val['responsive']);
99
+ return horizValid && vertValid && layerValid && responsiveValid;
100
+ }
101
+ exports.isValidSerializedBadgeEnumPosition = isValidSerializedBadgeEnumPosition;
102
+ function isHorizontalPos(maybePos) {
103
+ if ((0, checks_1.isNumber)(maybePos)) {
104
+ return !!HorizontalBadgePos[maybePos];
105
+ }
106
+ return false;
107
+ }
108
+ exports.isHorizontalPos = isHorizontalPos;
109
+ function isVerticalPos(maybePos) {
110
+ if ((0, checks_1.isNumber)(maybePos)) {
111
+ return !!VerticalBadgePos[maybePos];
112
+ }
113
+ return false;
114
+ }
115
+ exports.isVerticalPos = isVerticalPos;
116
+ function isLayerPos(maybePos) {
117
+ if ((0, checks_1.isNumber)(maybePos)) {
118
+ return !!BadgeLayerPos[maybePos];
119
+ }
120
+ return false;
121
+ }
122
+ exports.isLayerPos = isLayerPos;
@@ -0,0 +1,24 @@
1
+ export declare enum DataGraphicIconSets {
2
+ CUSTOM_ICONS = -1,
3
+ STATUS_ICONS = 0,
4
+ STATUS_CIRCLES = 1,
5
+ STOPLIGHTS = 2,
6
+ TOGGLES = 3,
7
+ COMPLETION_PIES = 4,
8
+ TRENDING_ARROWS = 5,
9
+ STATUS_CHECK_BOXES = 6,
10
+ TRENDING_ARROWS_FLIPPED = 7
11
+ }
12
+ export declare type DataGraphicIconLibrarySets = Exclude<DataGraphicIconSets, DataGraphicIconSets.CUSTOM_ICONS>;
13
+ export declare type DataGraphicImage = {
14
+ url: string;
15
+ w: number;
16
+ h: number;
17
+ };
18
+ export declare type DataGraphicIconIndexes = {
19
+ set: DataGraphicIconSets;
20
+ index: number;
21
+ iconImage?: DataGraphicImage;
22
+ };
23
+ export declare function areDataGraphicIconIndexesEqual(a: DataGraphicIconIndexes, b: DataGraphicIconIndexes): boolean;
24
+ export declare function areDataGraphicImagesEqual(a: DataGraphicImage | undefined, b: DataGraphicImage | undefined): boolean;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.areDataGraphicImagesEqual = exports.areDataGraphicIconIndexesEqual = exports.DataGraphicIconSets = void 0;
4
+ var DataGraphicIconSets;
5
+ (function (DataGraphicIconSets) {
6
+ // Custom icons are a user-defined set of uploaded icons, not a predefined set of icons
7
+ DataGraphicIconSets[DataGraphicIconSets["CUSTOM_ICONS"] = -1] = "CUSTOM_ICONS";
8
+ DataGraphicIconSets[DataGraphicIconSets["STATUS_ICONS"] = 0] = "STATUS_ICONS";
9
+ DataGraphicIconSets[DataGraphicIconSets["STATUS_CIRCLES"] = 1] = "STATUS_CIRCLES";
10
+ DataGraphicIconSets[DataGraphicIconSets["STOPLIGHTS"] = 2] = "STOPLIGHTS";
11
+ DataGraphicIconSets[DataGraphicIconSets["TOGGLES"] = 3] = "TOGGLES";
12
+ DataGraphicIconSets[DataGraphicIconSets["COMPLETION_PIES"] = 4] = "COMPLETION_PIES";
13
+ DataGraphicIconSets[DataGraphicIconSets["TRENDING_ARROWS"] = 5] = "TRENDING_ARROWS";
14
+ DataGraphicIconSets[DataGraphicIconSets["STATUS_CHECK_BOXES"] = 6] = "STATUS_CHECK_BOXES";
15
+ DataGraphicIconSets[DataGraphicIconSets["TRENDING_ARROWS_FLIPPED"] = 7] = "TRENDING_ARROWS_FLIPPED";
16
+ })(DataGraphicIconSets = exports.DataGraphicIconSets || (exports.DataGraphicIconSets = {}));
17
+ function areDataGraphicIconIndexesEqual(a, b) {
18
+ return a.set == b.set && a.index == b.index && areDataGraphicImagesEqual(a.iconImage, b.iconImage);
19
+ }
20
+ exports.areDataGraphicIconIndexesEqual = areDataGraphicIconIndexesEqual;
21
+ function areDataGraphicImagesEqual(a, b) {
22
+ if (a == undefined || b == undefined) {
23
+ return a == b;
24
+ }
25
+ return a.w == b.w && a.h == b.h && a.url == b.url;
26
+ }
27
+ exports.areDataGraphicImagesEqual = areDataGraphicImagesEqual;
@@ -0,0 +1,15 @@
1
+ import { BadgeEnumPosition, SerializedBadgeEnumPosition } from './badgeposition';
2
+ import { DataGraphicIconIndexes } from './datagraphicindexes';
3
+ export declare type SerializedSimpleStaticDataGraphicSettings = {
4
+ 'icon': DataGraphicIconIndexes;
5
+ 'pos': SerializedBadgeEnumPosition;
6
+ 'color': string;
7
+ };
8
+ export declare type SimpleStaticDataGraphicSettings = {
9
+ icon: DataGraphicIconIndexes;
10
+ position: BadgeEnumPosition;
11
+ color: string;
12
+ };
13
+ export declare function serializeSimpleStaticDataGraphicSettings(settings: SimpleStaticDataGraphicSettings): SerializedSimpleStaticDataGraphicSettings;
14
+ export declare function deserializeSimpleStaticDataGraphicSettings(settings: SerializedSimpleStaticDataGraphicSettings): SimpleStaticDataGraphicSettings;
15
+ export declare function isSerializedSimpleStaticDataGraphicSettings(settings: unknown): settings is SerializedSimpleStaticDataGraphicSettings;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSerializedSimpleStaticDataGraphicSettings = exports.deserializeSimpleStaticDataGraphicSettings = exports.serializeSimpleStaticDataGraphicSettings = void 0;
4
+ const checks_1 = require("../../checks");
5
+ const badgeposition_1 = require("./badgeposition");
6
+ function serializeSimpleStaticDataGraphicSettings(settings) {
7
+ return {
8
+ 'icon': settings.icon,
9
+ 'pos': (0, badgeposition_1.serializeBadgeEnumPosition)(settings.position),
10
+ 'color': settings.color,
11
+ };
12
+ }
13
+ exports.serializeSimpleStaticDataGraphicSettings = serializeSimpleStaticDataGraphicSettings;
14
+ function deserializeSimpleStaticDataGraphicSettings(settings) {
15
+ return {
16
+ icon: settings['icon'],
17
+ position: (0, badgeposition_1.deserializeBadgeEnumPosition)(settings['pos']),
18
+ color: settings['color'],
19
+ };
20
+ }
21
+ exports.deserializeSimpleStaticDataGraphicSettings = deserializeSimpleStaticDataGraphicSettings;
22
+ function isSerializedSimpleStaticDataGraphicSettings(settings) {
23
+ return ((0, checks_1.isObject)(settings) &&
24
+ (0, checks_1.isString)(settings['color']) &&
25
+ (0, checks_1.isObject)(settings['icon']) &&
26
+ (0, badgeposition_1.isValidSerializedBadgeEnumPosition)(settings['pos']));
27
+ }
28
+ exports.isSerializedSimpleStaticDataGraphicSettings = isSerializedSimpleStaticDataGraphicSettings;
@@ -0,0 +1,65 @@
1
+ /** @ignore */
2
+ export declare type SerializedImageFill = {
3
+ 'pos': string;
4
+ 'url': string;
5
+ 'polys': {
6
+ 'x': number;
7
+ 'y': number;
8
+ }[][] | null;
9
+ 'w'?: number;
10
+ 'h'?: number;
11
+ 'FX'?: any[];
12
+ 'bb'?: {
13
+ 'x': number;
14
+ 'y': number;
15
+ 'w': number;
16
+ 'h': number;
17
+ };
18
+ 'location'?: string;
19
+ 'fallbackUrl'?: string;
20
+ 'rotation'?: number;
21
+ 'horizontalAlign'?: string;
22
+ 'verticalAlign'?: string;
23
+ 'FlipX'?: boolean;
24
+ 'FlipY'?: boolean;
25
+ 'isSvg'?: boolean;
26
+ };
27
+ /** @ignore */
28
+ export declare type SimpleSerializedFillStyle = string | SerializedImageFill;
29
+ /**
30
+ * Different ways of laying out the image in the background of the block.
31
+ */
32
+ export declare enum SimpleImageFillPosition {
33
+ /** The image retains its original aspect ratio, and is as large as possible while still fitting in the block */
34
+ Fit = "fit",
35
+ /** The image retains its original aspect ratio, and is as small as possible while still completely covering the block */
36
+ Fill = "fill",
37
+ /** The image is stretched to the bounding box of the block */
38
+ Stretch = "stretch",
39
+ /** The image is shown in its original size if possible */
40
+ Original = "original",
41
+ /** The image is tiled in its original size vertically and horizontally to fully cover the block */
42
+ Tile = "tile"
43
+ }
44
+ /**
45
+ * Settings for using an image as the fill style of a block.
46
+ */
47
+ export declare type SimpleImageFill = {
48
+ /**
49
+ * URL of the image to display. If a data URL is provided, the image will be uploaded
50
+ * to the current user's Lucid account and the URL replaced with a Lucid-provided one.
51
+ */
52
+ url: string;
53
+ /**
54
+ * Different ways of laying out the image in the background of the block.
55
+ */
56
+ position: SimpleImageFillPosition;
57
+ };
58
+ /**
59
+ * Settings for the fill style of a block.
60
+ *
61
+ * If a string is provided, it must be a hex color string, e.g. `'#ff00ff'` or `'#aabbcc80'`.
62
+ */
63
+ export declare type SimpleFillStyle = string | SimpleImageFill;
64
+ /** @ignore */
65
+ export declare function serializeSimpleFill(fill: SimpleFillStyle): SimpleSerializedFillStyle;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeSimpleFill = exports.SimpleImageFillPosition = void 0;
4
+ const checks_1 = require("../checks");
5
+ /**
6
+ * Different ways of laying out the image in the background of the block.
7
+ */
8
+ var SimpleImageFillPosition;
9
+ (function (SimpleImageFillPosition) {
10
+ /** The image retains its original aspect ratio, and is as large as possible while still fitting in the block */
11
+ SimpleImageFillPosition["Fit"] = "fit";
12
+ /** The image retains its original aspect ratio, and is as small as possible while still completely covering the block */
13
+ SimpleImageFillPosition["Fill"] = "fill";
14
+ /** The image is stretched to the bounding box of the block */
15
+ SimpleImageFillPosition["Stretch"] = "stretch";
16
+ /** The image is shown in its original size if possible */
17
+ SimpleImageFillPosition["Original"] = "original";
18
+ /** The image is tiled in its original size vertically and horizontally to fully cover the block */
19
+ SimpleImageFillPosition["Tile"] = "tile";
20
+ //TODO: 'mask' but mask requires additional settings
21
+ })(SimpleImageFillPosition = exports.SimpleImageFillPosition || (exports.SimpleImageFillPosition = {}));
22
+ /** @ignore */
23
+ function serializeSimpleFill(fill) {
24
+ if ((0, checks_1.isString)(fill)) {
25
+ return fill;
26
+ }
27
+ else {
28
+ return {
29
+ 'pos': fill.position,
30
+ 'url': fill.url,
31
+ 'polys': null,
32
+ };
33
+ }
34
+ }
35
+ exports.serializeSimpleFill = serializeSimpleFill;
@@ -0,0 +1,15 @@
1
+ export declare type SerializedShadow = {
2
+ 'x': number;
3
+ 'y': number;
4
+ 'b': number;
5
+ 'c': string;
6
+ 'ang'?: number;
7
+ };
8
+ export interface Shadow {
9
+ distance: number;
10
+ angle: number;
11
+ blur: number;
12
+ color: string;
13
+ }
14
+ export declare function serializeShadow(shadow: Shadow): SerializedShadow;
15
+ export declare function deserializeShadow(shadow: SerializedShadow): Shadow;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeShadow = exports.serializeShadow = void 0;
4
+ function serializeShadow(shadow) {
5
+ return {
6
+ 'x': shadow.distance * Math.cos(shadow.angle),
7
+ 'y': shadow.distance * Math.sin(shadow.angle),
8
+ 'b': shadow.blur,
9
+ 'c': shadow.color,
10
+ 'ang': shadow.angle,
11
+ };
12
+ }
13
+ exports.serializeShadow = serializeShadow;
14
+ function deserializeShadow(shadow) {
15
+ var _a;
16
+ return {
17
+ distance: Math.sqrt(shadow['x'] * shadow['x'] + shadow['y'] * shadow['y']),
18
+ angle: (_a = shadow['ang']) !== null && _a !== void 0 ? _a : Math.atan2(shadow['y'], shadow['x']),
19
+ blur: shadow['b'],
20
+ color: shadow['c'],
21
+ };
22
+ }
23
+ exports.deserializeShadow = deserializeShadow;
@@ -18,4 +18,8 @@ export declare class DataItemProxy {
18
18
  * The fields on this data item, organized by their name.
19
19
  */
20
20
  readonly fields: MapProxy<string, import("..").SerializedFieldType>;
21
+ /**
22
+ * @returns True if a data item exists in this collection at this primary key
23
+ */
24
+ exists(): boolean;
21
25
  }
@@ -24,5 +24,11 @@ class DataItemProxy {
24
24
  'f': name,
25
25
  }));
26
26
  }
27
+ /**
28
+ * @returns True if a data item exists in this collection at this primary key
29
+ */
30
+ exists() {
31
+ return this.client.sendCommand("die" /* DataItemExists */, { 'c': this.collection.id, 'pk': this.primaryKey });
32
+ }
27
33
  }
28
34
  exports.DataItemProxy = DataItemProxy;
@@ -1,4 +1,5 @@
1
1
  import { JsonObject, JsonSerializable } from '../../lucid-extension-sdk';
2
+ import { SimpleFillStyle } from '../core/properties/fillcolor';
2
3
  import { Box } from '../math';
3
4
  /**
4
5
  * The information required to create a new block on the current document
@@ -12,6 +13,14 @@ export interface BlockDefinition {
12
13
  * The initial location and size of the block on the page.
13
14
  */
14
15
  boundingBox: Box;
16
+ /**
17
+ * If specified, the initial FillColor property for the block
18
+ */
19
+ fillStyle?: SimpleFillStyle;
20
+ /**
21
+ * If specified, the initial line width for the block
22
+ */
23
+ lineWidth?: number;
15
24
  /**
16
25
  * Additional properties to set on the block immediately after creation. This is not typically
17
26
  * set directly (it's easier and safer to call `.properties.set()` after block creation) but
@@ -1,3 +1,6 @@
1
+ import { SimpleStaticDataGraphicSettings } from '../core/properties/datagraphic/staticdatagraphicsettings';
2
+ import { SimpleFillStyle } from '../core/properties/fillcolor';
3
+ import { Shadow } from '../core/properties/shadow';
1
4
  import { ItemProxy } from './itemproxy';
2
5
  /**
3
6
  * A block is a single shape on the document. A BlockProxy provides an interface to
@@ -15,10 +18,55 @@ export declare class BlockProxy extends ItemProxy {
15
18
  * @returns The amount this block is rotated around its own center, in radians.
16
19
  */
17
20
  getRotation(): number;
21
+ /**
22
+ * @param radians Angle the block should be rotated
23
+ */
24
+ setRotation(radians: number): void;
25
+ /**
26
+ * @returns The current drop shadow on this block, or undefined if no shadow is set
27
+ */
28
+ getShadow(): Shadow | undefined;
29
+ /**
30
+ * @param shadow The drop shadow to set on the block, or undefined to clear the drop shadow
31
+ */
32
+ setShadow(shadow: Shadow | undefined): void;
33
+ /**
34
+ * Set the fill style used (by most kinds of blocks) to fill in their main opaque areas.
35
+ * This can be a string color (e.g. `'#ff00ff80'`) or an image fill.
36
+ */
37
+ setFillStyle(fillStyle: SimpleFillStyle): void;
18
38
  /**
19
39
  * @returns An array of lines that have one or both endpoints connected to this block.
20
40
  */
21
41
  getConnectedLines(): import("./lineproxy").LineProxy[];
42
+ /**
43
+ * @param settings Information about the static data graphic icon to set on this block.
44
+ */
45
+ setSimpleStaticDataGraphic(settings: SimpleStaticDataGraphicSettings | undefined): void;
46
+ /**
47
+ * @returns Settings for the simple static data graphic currently set on this block, or undefined
48
+ * if no simple data graphic is currently set. Note that if a data graphic exists that is not an
49
+ * icon, this will return undefined. This function will not consider data graphics set via
50
+ * conditional formatting rules.
51
+ */
52
+ getSimpleStaticDataGraphic(): SimpleStaticDataGraphicSettings | undefined;
53
+ /**
54
+ * Lock this block's aspect ratio to its current value.
55
+ * This can be reversed with unlockAspectRatio.
56
+ */
57
+ lockAspectRatio(): void;
58
+ /**
59
+ * Unlock the aspect ratio of this block, allowing it to be stretched vertically or horizontally independently.
60
+ */
61
+ unlockAspectRatio(): void;
62
+ /**
63
+ * @returns The line width used by most kinds of blocks to render their outline.
64
+ */
65
+ getLineWidth(): number;
66
+ /**
67
+ * @param width The line width to be used (by most kinds of blocks) to render this block's outline
68
+ */
69
+ setLineWidth(width: number): void;
22
70
  /**
23
71
  * Link a text area to a data field, so that editing the text area will also update the
24
72
  * associated data, and vice versa.
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BlockProxy = void 0;
4
+ const staticdatagraphicsettings_1 = require("../core/properties/datagraphic/staticdatagraphicsettings");
5
+ const fillcolor_1 = require("../core/properties/fillcolor");
6
+ const shadow_1 = require("../core/properties/shadow");
4
7
  const itemproxy_1 = require("./itemproxy");
5
8
  /**
6
9
  * A block is a single shape on the document. A BlockProxy provides an interface to
@@ -22,6 +25,40 @@ class BlockProxy extends itemproxy_1.ItemProxy {
22
25
  getRotation() {
23
26
  return this.properties.get('Rotation');
24
27
  }
28
+ /**
29
+ * @param radians Angle the block should be rotated
30
+ */
31
+ setRotation(radians) {
32
+ this.properties.set('Rotation', radians);
33
+ }
34
+ /**
35
+ * @returns The current drop shadow on this block, or undefined if no shadow is set
36
+ */
37
+ getShadow() {
38
+ const raw = this.properties.get('Shadow');
39
+ if (!raw) {
40
+ return undefined;
41
+ }
42
+ return (0, shadow_1.deserializeShadow)(raw);
43
+ }
44
+ /**
45
+ * @param shadow The drop shadow to set on the block, or undefined to clear the drop shadow
46
+ */
47
+ setShadow(shadow) {
48
+ if (shadow) {
49
+ this.properties.set('Shadow', (0, shadow_1.serializeShadow)(shadow));
50
+ }
51
+ else {
52
+ this.properties.set('Shadow', null);
53
+ }
54
+ }
55
+ /**
56
+ * Set the fill style used (by most kinds of blocks) to fill in their main opaque areas.
57
+ * This can be a string color (e.g. `'#ff00ff80'`) or an image fill.
58
+ */
59
+ setFillStyle(fillStyle) {
60
+ this.properties.set('FillColor', (0, fillcolor_1.serializeSimpleFill)(fillStyle));
61
+ }
25
62
  /**
26
63
  * @returns An array of lines that have one or both endpoints connected to this block.
27
64
  */
@@ -29,6 +66,58 @@ class BlockProxy extends itemproxy_1.ItemProxy {
29
66
  const ids = this.client.sendCommand("gcl" /* GetConnectedLines */, this.id);
30
67
  return ids.map((id) => this.client.getLineProxy(id));
31
68
  }
69
+ /**
70
+ * @param settings Information about the static data graphic icon to set on this block.
71
+ */
72
+ setSimpleStaticDataGraphic(settings) {
73
+ if (settings) {
74
+ this.properties.set('StaticDataGraphic', (0, staticdatagraphicsettings_1.serializeSimpleStaticDataGraphicSettings)(settings));
75
+ }
76
+ else {
77
+ this.properties.set('StaticDataGraphic', undefined);
78
+ }
79
+ }
80
+ /**
81
+ * @returns Settings for the simple static data graphic currently set on this block, or undefined
82
+ * if no simple data graphic is currently set. Note that if a data graphic exists that is not an
83
+ * icon, this will return undefined. This function will not consider data graphics set via
84
+ * conditional formatting rules.
85
+ */
86
+ getSimpleStaticDataGraphic() {
87
+ const settings = this.properties.get('StaticDataGraphic');
88
+ if ((0, staticdatagraphicsettings_1.isSerializedSimpleStaticDataGraphicSettings)(settings)) {
89
+ return (0, staticdatagraphicsettings_1.deserializeSimpleStaticDataGraphicSettings)(settings);
90
+ }
91
+ else {
92
+ return undefined;
93
+ }
94
+ }
95
+ /**
96
+ * Lock this block's aspect ratio to its current value.
97
+ * This can be reversed with unlockAspectRatio.
98
+ */
99
+ lockAspectRatio() {
100
+ const bb = this.getBoundingBox();
101
+ this.properties.set('AspectRatio', bb.w / bb.h);
102
+ }
103
+ /**
104
+ * Unlock the aspect ratio of this block, allowing it to be stretched vertically or horizontally independently.
105
+ */
106
+ unlockAspectRatio() {
107
+ this.properties.set('AspectRatio', undefined);
108
+ }
109
+ /**
110
+ * @returns The line width used by most kinds of blocks to render their outline.
111
+ */
112
+ getLineWidth() {
113
+ return this.properties.get('LineWidth');
114
+ }
115
+ /**
116
+ * @param width The line width to be used (by most kinds of blocks) to render this block's outline
117
+ */
118
+ setLineWidth(width) {
119
+ this.properties.set('LineWidth', width);
120
+ }
32
121
  /**
33
122
  * Link a text area to a data field, so that editing the text area will also update the
34
123
  * associated data, and vice versa.
@@ -15,6 +15,10 @@ export declare class DocumentProxy extends ElementProxy {
15
15
  */
16
16
  readonly pages: MapProxy<string, PageProxy>;
17
17
  constructor(client: EditorClient);
18
+ /**
19
+ * An iterator over all blocks on all pages of the document
20
+ */
21
+ allBlocks(): Generator<import("./blockproxy").BlockProxy, void, unknown>;
18
22
  /**
19
23
  * Add a new page to the current document
20
24
  * @param def Definition of the page to add
@@ -18,6 +18,16 @@ class DocumentProxy extends elementproxy_1.ElementProxy {
18
18
  static getNextHookName() {
19
19
  return '__documentproxy__hook' + DocumentProxy.nextHookId++;
20
20
  }
21
+ /**
22
+ * An iterator over all blocks on all pages of the document
23
+ */
24
+ *allBlocks() {
25
+ for (const page of this.pages.values()) {
26
+ for (const block of page.blocks.values()) {
27
+ yield block;
28
+ }
29
+ }
30
+ }
21
31
  /**
22
32
  * Add a new page to the current document
23
33
  * @param def Definition of the page to add
@@ -64,6 +64,12 @@ class PageProxy extends elementproxy_1.ElementProxy {
64
64
  block.properties.set(key, def.properties[key]);
65
65
  }
66
66
  }
67
+ if (def.fillStyle !== undefined) {
68
+ block.setFillStyle(def.fillStyle);
69
+ }
70
+ if (def.lineWidth !== undefined) {
71
+ block.setLineWidth(def.lineWidth);
72
+ }
67
73
  return block;
68
74
  }
69
75
  /**
@@ -21,4 +21,9 @@ export declare class ShapeDataProxy extends WriteableMapProxy<string, Serialized
21
21
  delete(key: string): void;
22
22
  /** @ignore */
23
23
  static parseData(raw: SerializedFieldType | SerializedDataError): SerializedFieldType | DataError;
24
+ /**
25
+ * @param key Name of the shape data to read
26
+ * @returns The value if it is a string, or an empty string if it does not exist or is not a string.
27
+ */
28
+ getString(key: string): string;
24
29
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ShapeDataProxy = void 0;
4
+ const checks_1 = require("../core/checks");
4
5
  const serializeddataerror_1 = require("../core/serializeddataerror");
5
6
  const shapedatainheritance_1 = require("../core/shapedatainheritance");
6
7
  const dataerror_1 = require("../data/dataerror");
@@ -53,5 +54,16 @@ class ShapeDataProxy extends mapproxy_1.WriteableMapProxy {
53
54
  //TODO, eventually: parse these
54
55
  return raw;
55
56
  }
57
+ /**
58
+ * @param key Name of the shape data to read
59
+ * @returns The value if it is a string, or an empty string if it does not exist or is not a string.
60
+ */
61
+ getString(key) {
62
+ const val = this.get(key);
63
+ if (!(0, checks_1.isString)(val)) {
64
+ return '';
65
+ }
66
+ return val;
67
+ }
56
68
  }
57
69
  exports.ShapeDataProxy = ShapeDataProxy;
@@ -178,12 +178,17 @@ export declare class EditorClient {
178
178
  * associated with this editor extension. If this callback is async (returns a promise), then the
179
179
  * bootstrap data is not cleared off of the document until that promise resolves.
180
180
  *
181
+ * @param markExtensionAsRequired If bootstrap data is available for this editor extension, this will mark the
182
+ * document as requiring the extension. Once marked, if the extension is not installed the user will be
183
+ * notified about the extension being required on document load. The minimum extension version required by the
184
+ * document is the version provided in the request body when creating the document.
185
+ *
181
186
  * @return a promise that resolves immediately if there is no available bootstrap data, or else after
182
187
  * the callback successfully completes. This promise will reject/throw if the callback throws or
183
188
  * returns a promise that rejects, or if there is another editor session processing the same bootstrap
184
189
  * data at the same time.
185
190
  */
186
- processAndClearBootstrapData(callback: (data: JsonSerializable) => void | Promise<void>): Promise<void>;
191
+ processAndClearBootstrapData(callback: (data: JsonSerializable) => void | Promise<void>, markExtensionAsRequired?: boolean): Promise<void>;
187
192
  /**
188
193
  * @param id ID of the line to create a proxy for
189
194
  * @returns the given line
@@ -102,13 +102,14 @@ class EditorClient {
102
102
  };
103
103
  })
104
104
  .catch((error) => {
105
+ var _a, _b, _c, _d;
105
106
  const raw = (0, commandtypes_1.isRawSendXHRResponse)(error) ? error : undefined;
106
107
  throw {
107
- url: raw ? raw['url'] : '',
108
- responseText: raw ? raw['t'] : 'An unknown error occurred',
109
- status: raw ? raw['s'] : 0,
110
- headers: raw ? raw['h'] : {},
111
- timeout: raw ? raw['to'] : undefined,
108
+ url: (_a = raw === null || raw === void 0 ? void 0 : raw['url']) !== null && _a !== void 0 ? _a : '',
109
+ responseText: (_b = raw === null || raw === void 0 ? void 0 : raw['t']) !== null && _b !== void 0 ? _b : 'An unknown error occurred',
110
+ status: (_c = raw === null || raw === void 0 ? void 0 : raw['s']) !== null && _c !== void 0 ? _c : 0,
111
+ headers: (_d = raw === null || raw === void 0 ? void 0 : raw['h']) !== null && _d !== void 0 ? _d : {},
112
+ timeout: raw === null || raw === void 0 ? void 0 : raw['to'],
112
113
  };
113
114
  });
114
115
  }
@@ -131,13 +132,14 @@ class EditorClient {
131
132
  };
132
133
  })
133
134
  .catch((error) => {
134
- const raw = (0, commandtypes_1.isRawSendXHRResponse)(error) ? error : error;
135
+ var _a, _b, _c, _d;
136
+ const raw = (0, commandtypes_1.isRawSendXHRResponse)(error) ? error : undefined;
135
137
  throw {
136
- url: raw['url'],
137
- responseText: raw['t'],
138
- status: raw['s'],
139
- headers: raw['h'],
140
- timeout: raw['to'],
138
+ url: (_a = raw === null || raw === void 0 ? void 0 : raw['url']) !== null && _a !== void 0 ? _a : '',
139
+ responseText: (_b = raw === null || raw === void 0 ? void 0 : raw['t']) !== null && _b !== void 0 ? _b : 'An unknown error occurred',
140
+ status: (_c = raw === null || raw === void 0 ? void 0 : raw['s']) !== null && _c !== void 0 ? _c : 0,
141
+ headers: (_d = raw === null || raw === void 0 ? void 0 : raw['h']) !== null && _d !== void 0 ? _d : {},
142
+ timeout: raw === null || raw === void 0 ? void 0 : raw['to'],
141
143
  };
142
144
  });
143
145
  }
@@ -284,17 +286,22 @@ class EditorClient {
284
286
  * associated with this editor extension. If this callback is async (returns a promise), then the
285
287
  * bootstrap data is not cleared off of the document until that promise resolves.
286
288
  *
289
+ * @param markExtensionAsRequired If bootstrap data is available for this editor extension, this will mark the
290
+ * document as requiring the extension. Once marked, if the extension is not installed the user will be
291
+ * notified about the extension being required on document load. The minimum extension version required by the
292
+ * document is the version provided in the request body when creating the document.
293
+ *
287
294
  * @return a promise that resolves immediately if there is no available bootstrap data, or else after
288
295
  * the callback successfully completes. This promise will reject/throw if the callback throws or
289
296
  * returns a promise that rejects, or if there is another editor session processing the same bootstrap
290
297
  * data at the same time.
291
298
  */
292
- async processAndClearBootstrapData(callback) {
299
+ async processAndClearBootstrapData(callback, markExtensionAsRequired) {
293
300
  const name = this.getUniqueActionName();
294
301
  this.registerAction(name, (msg) => {
295
302
  return callback(msg['d']);
296
303
  });
297
- await this.sendCommand("b" /* Bootstrap */, { 'c': name });
304
+ await this.sendCommand("b" /* Bootstrap */, { 'c': name, 'm': markExtensionAsRequired });
298
305
  this.deleteAction(name);
299
306
  }
300
307
  /**
package/sdk/ui/panel.d.ts CHANGED
@@ -5,7 +5,9 @@ import { IframeUI } from './iframeui';
5
5
  */
6
6
  export declare enum PanelLocation {
7
7
  /** In Lucidchart, create a sibling to the Contextual Panel */
8
- RightDock = 1
8
+ RightDock = 1,
9
+ /** In Lucidchart, create a sibling to the shape toolbox */
10
+ ContentDock = 2
9
11
  }
10
12
  export interface PanelConfig {
11
13
  /** Title to display at the top of the panel */
package/sdk/ui/panel.js CHANGED
@@ -9,6 +9,8 @@ var PanelLocation;
9
9
  (function (PanelLocation) {
10
10
  /** In Lucidchart, create a sibling to the Contextual Panel */
11
11
  PanelLocation[PanelLocation["RightDock"] = 1] = "RightDock";
12
+ /** In Lucidchart, create a sibling to the shape toolbox */
13
+ PanelLocation[PanelLocation["ContentDock"] = 2] = "ContentDock";
12
14
  })(PanelLocation = exports.PanelLocation || (exports.PanelLocation = {}));
13
15
  /**
14
16
  * Extend this class to show a custom panel to the user, whose contents are displayed in a sandboxed
@@ -1,3 +1,4 @@
1
+ import { BlockDefinition } from '../../lucid-extension-sdk';
1
2
  import { ItemProxy } from '../document/itemproxy';
2
3
  import { PageProxy } from '../document/pageproxy';
3
4
  import { EditorClient } from '../editorclient';
@@ -69,4 +70,19 @@ export declare class Viewport {
69
70
  * @param handle The return value of hookSelection.
70
71
  */
71
72
  unhookSelection(handle: string): void;
73
+ /**
74
+ * Start an interaction of the current user dragging a new block onto the current page, exactly
75
+ * as if they started dragging that block out of the normal toolbox. At the time this function is
76
+ * called, the user's primary mouse button should be down (e.g. in a mousedown event handler).
77
+ *
78
+ * @param definition Definition of the block to create if and where the user drops it on-canvas
79
+ * @returns A promise resolving to a reference to the created block, if successfully dropped,
80
+ * or undefined if the user cancels the drag interaction.
81
+ */
82
+ startDraggingNewBlock(definition: BlockDefinition): Promise<import("../document/blockproxy").BlockProxy | undefined>;
83
+ /**
84
+ * If startDraggingNewBlock has been called, and the drag-new-block interaction is still active,
85
+ * cancel that interaction.
86
+ */
87
+ cancelDraggingNewBlock(): void;
72
88
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Viewport = void 0;
4
4
  const checks_1 = require("../core/checks");
5
+ const fillcolor_1 = require("../core/properties/fillcolor");
5
6
  const itemproxy_1 = require("../document/itemproxy");
6
7
  const pageproxy_1 = require("../document/pageproxy");
7
8
  const math_1 = require("../math");
@@ -126,6 +127,42 @@ class Viewport {
126
127
  this.client.deleteAction(handle);
127
128
  this.client.sendCommand("us" /* UnhookSelection */, { 'n': handle });
128
129
  }
130
+ /**
131
+ * Start an interaction of the current user dragging a new block onto the current page, exactly
132
+ * as if they started dragging that block out of the normal toolbox. At the time this function is
133
+ * called, the user's primary mouse button should be down (e.g. in a mousedown event handler).
134
+ *
135
+ * @param definition Definition of the block to create if and where the user drops it on-canvas
136
+ * @returns A promise resolving to a reference to the created block, if successfully dropped,
137
+ * or undefined if the user cancels the drag interaction.
138
+ */
139
+ async startDraggingNewBlock(definition) {
140
+ var _a;
141
+ const properties = (_a = definition.properties) !== null && _a !== void 0 ? _a : {};
142
+ if (definition.fillStyle !== undefined) {
143
+ properties['FillColor'] = (0, fillcolor_1.serializeSimpleFill)(definition.fillStyle);
144
+ }
145
+ if (definition.lineWidth !== undefined) {
146
+ properties['LineWidth'] = definition.lineWidth;
147
+ }
148
+ const maybeBlockId = await this.client.sendCommand("sdc" /* StartDragBlockToCanvas */, {
149
+ 'c': definition.className,
150
+ 'sz': {
151
+ 'w': definition.boundingBox.w,
152
+ 'h': definition.boundingBox.h,
153
+ },
154
+ 'p': properties,
155
+ 's': definition.stencil,
156
+ });
157
+ return maybeBlockId ? this.client.getBlockProxy(maybeBlockId) : undefined;
158
+ }
159
+ /**
160
+ * If startDraggingNewBlock has been called, and the drag-new-block interaction is still active,
161
+ * cancel that interaction.
162
+ */
163
+ cancelDraggingNewBlock() {
164
+ this.client.sendCommand("cdc" /* CancelDragBlockToCanvas */, undefined);
165
+ }
129
166
  }
130
167
  exports.Viewport = Viewport;
131
168
  Viewport.nextHookId = 0;