lucid-extension-sdk 0.0.13 → 0.0.19
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 +1 -1
- package/sdk/commandtypes.d.ts +81 -1
- package/sdk/commandtypes.js +71 -1
- package/sdk/core/base64.d.ts +1 -0
- package/sdk/core/base64.js +45 -0
- package/sdk/core/data/serializedfield/serializedfielddefinition.d.ts +2 -1
- package/sdk/core/data/serializedfield/serializedfielddefinition.js +1 -0
- package/sdk/data/datasourceproxy.js +3 -1
- package/sdk/data/schemadefinition.js +12 -8
- package/sdk/editorclient.d.ts +46 -0
- package/sdk/editorclient.js +69 -0
- package/sdk/ui/menu.d.ts +19 -2
- package/sdk/ui/menu.js +11 -2
package/package.json
CHANGED
package/sdk/commandtypes.d.ts
CHANGED
|
@@ -20,13 +20,16 @@ export declare const enum CommandName {
|
|
|
20
20
|
AddLineTextArea = "alta",
|
|
21
21
|
AddMenuItem = "ami",
|
|
22
22
|
AddShapeData = "asd",
|
|
23
|
+
Alert = "a",
|
|
23
24
|
AnimateViewport = "av",
|
|
24
25
|
Bootstrap = "b",
|
|
26
|
+
Confirm = "c",
|
|
25
27
|
CreateBlock = "cb",
|
|
26
28
|
CreateCollection = "cc",
|
|
27
29
|
CreateDataSource = "cds",
|
|
28
30
|
CreateLine = "cl",
|
|
29
31
|
CreatePage = "cp",
|
|
32
|
+
DataAction = "da",
|
|
30
33
|
DeleteItem = "di",
|
|
31
34
|
DeletePage = "dp",
|
|
32
35
|
DeleteShapeData = "dsd",
|
|
@@ -78,10 +81,13 @@ export declare const enum CommandName {
|
|
|
78
81
|
ShowModal = "sm",
|
|
79
82
|
ShowPanel = "spn",
|
|
80
83
|
SleepForTestCase = "sleep",
|
|
84
|
+
ThrowForTestCase = "throw",
|
|
81
85
|
UnhookCreateItems = "uci",
|
|
82
86
|
UnhookSelection = "us",
|
|
83
87
|
UnhookTextEdit = "ute"
|
|
84
88
|
}
|
|
89
|
+
/** @ignore */
|
|
90
|
+
export declare const commandTitles: Map<CommandName, string>;
|
|
85
91
|
/**
|
|
86
92
|
* This is a type declaration whose purpose is to allow TypeScript to enforce the correct parameter and
|
|
87
93
|
* return types from [EditorClient.sendCommand](#classes_editorclient-EditorClient_sendcommand) based on
|
|
@@ -100,6 +106,10 @@ export declare type CommandArgs = {
|
|
|
100
106
|
query: AddShapeDataQuery;
|
|
101
107
|
result: AddShapeDataResult;
|
|
102
108
|
};
|
|
109
|
+
[CommandName.Alert]: {
|
|
110
|
+
query: AlertQuery;
|
|
111
|
+
result: AlertResult;
|
|
112
|
+
};
|
|
103
113
|
[CommandName.AnimateViewport]: {
|
|
104
114
|
query: AnimateViewportQuery;
|
|
105
115
|
result: AnimateViewportResult;
|
|
@@ -108,6 +118,10 @@ export declare type CommandArgs = {
|
|
|
108
118
|
query: BootstrapQuery;
|
|
109
119
|
result: BootstrapResult;
|
|
110
120
|
};
|
|
121
|
+
[CommandName.Confirm]: {
|
|
122
|
+
query: ConfirmQuery;
|
|
123
|
+
result: ConfirmResult;
|
|
124
|
+
};
|
|
111
125
|
[CommandName.CreateBlock]: {
|
|
112
126
|
query: CreateBlockQuery;
|
|
113
127
|
result: CreateBlockResult;
|
|
@@ -128,6 +142,10 @@ export declare type CommandArgs = {
|
|
|
128
142
|
query: CreatePageQuery;
|
|
129
143
|
result: CreatePageResult;
|
|
130
144
|
};
|
|
145
|
+
[CommandName.DataAction]: {
|
|
146
|
+
query: DataActionQuery;
|
|
147
|
+
result: DataActionResult;
|
|
148
|
+
};
|
|
131
149
|
[CommandName.DeleteItem]: {
|
|
132
150
|
query: DeleteItemQuery;
|
|
133
151
|
result: DeleteItemResult;
|
|
@@ -332,6 +350,10 @@ export declare type CommandArgs = {
|
|
|
332
350
|
query: SleepForTestCaseQuery;
|
|
333
351
|
result: SleepForTestCaseResult;
|
|
334
352
|
};
|
|
353
|
+
[CommandName.ThrowForTestCase]: {
|
|
354
|
+
query: ThrowForTestCaseQuery;
|
|
355
|
+
result: ThrowForTestCaseResult;
|
|
356
|
+
};
|
|
335
357
|
[CommandName.UnhookCreateItems]: {
|
|
336
358
|
query: UnhookCreateItemsQuery;
|
|
337
359
|
result: UnhookCreateItemsResult;
|
|
@@ -361,7 +383,7 @@ export declare type AddMenuItemQuery = {
|
|
|
361
383
|
/** Label to display on the menu item */
|
|
362
384
|
'l': string;
|
|
363
385
|
/** Named action to run when the menu item is clicked */
|
|
364
|
-
'a'
|
|
386
|
+
'a'?: string;
|
|
365
387
|
/** Named action that returns whether the menu item should be visible */
|
|
366
388
|
'v'?: string;
|
|
367
389
|
/** Named action that returns whether the menu item should be disabled */
|
|
@@ -370,6 +392,17 @@ export declare type AddMenuItemQuery = {
|
|
|
370
392
|
't': MenuType;
|
|
371
393
|
/** If specified, where to place the menu item; defaults to MenuLocation.Extension */
|
|
372
394
|
'loc'?: MenuLocation;
|
|
395
|
+
/** If specified, this menu item should launch a file picker */
|
|
396
|
+
'f'?: {
|
|
397
|
+
/** Action to call when files are selected */
|
|
398
|
+
'a': string;
|
|
399
|
+
/** File types to accept */
|
|
400
|
+
'ac': string;
|
|
401
|
+
/** Single file only */
|
|
402
|
+
's'?: boolean;
|
|
403
|
+
/** Return content in a binary ArrayBuffer instead of as text */
|
|
404
|
+
'b'?: boolean;
|
|
405
|
+
};
|
|
373
406
|
};
|
|
374
407
|
export declare type AddMenuItemResult = undefined;
|
|
375
408
|
export declare type AddShapeDataQuery = {
|
|
@@ -383,6 +416,16 @@ export declare type AddShapeDataQuery = {
|
|
|
383
416
|
'v'?: SerializedFieldType;
|
|
384
417
|
};
|
|
385
418
|
export declare type AddShapeDataResult = undefined;
|
|
419
|
+
export declare type AlertQuery = {
|
|
420
|
+
/** Title; defaults to extension title */
|
|
421
|
+
't'?: string;
|
|
422
|
+
/** Body text */
|
|
423
|
+
'b': string;
|
|
424
|
+
/** Button text; defaults to i18n'ed "OK" */
|
|
425
|
+
'bt'?: string;
|
|
426
|
+
};
|
|
427
|
+
/** True if they click OK, false otherwise */
|
|
428
|
+
export declare type AlertResult = Promise<boolean>;
|
|
386
429
|
export declare type BootstrapQuery = {
|
|
387
430
|
/**
|
|
388
431
|
* Named action that accepts the bootstrap data, and which may return a Promise or void. After awaiting\
|
|
@@ -391,6 +434,18 @@ export declare type BootstrapQuery = {
|
|
|
391
434
|
'c': string;
|
|
392
435
|
};
|
|
393
436
|
export declare type BootstrapResult = Promise<void>;
|
|
437
|
+
export declare type ConfirmQuery = {
|
|
438
|
+
/** Title; defaults to extension title */
|
|
439
|
+
't'?: string;
|
|
440
|
+
/** Body text */
|
|
441
|
+
'b': string;
|
|
442
|
+
/** OK button text; defaults to i18n'ed "OK" */
|
|
443
|
+
'o'?: string;
|
|
444
|
+
/** Cancel button text; defaults to i18n'ed "Cancel" */
|
|
445
|
+
'c'?: string;
|
|
446
|
+
};
|
|
447
|
+
/** True if they click OK, false otherwise */
|
|
448
|
+
export declare type ConfirmResult = Promise<boolean>;
|
|
394
449
|
export declare type CreateBlockQuery = {
|
|
395
450
|
/**
|
|
396
451
|
* By default, we add the block to the current page & currently active group. If specified, the
|
|
@@ -439,6 +494,29 @@ export declare type CreateLineQuery = {
|
|
|
439
494
|
export declare type CreateLineResult = string;
|
|
440
495
|
export declare type CreatePageQuery = void;
|
|
441
496
|
export declare type CreatePageResult = string;
|
|
497
|
+
export declare type DataActionQuery = {
|
|
498
|
+
/** Flow Name */
|
|
499
|
+
'fn': string;
|
|
500
|
+
/** Is Async */
|
|
501
|
+
'a': boolean;
|
|
502
|
+
/** Flow Data */
|
|
503
|
+
'fd'?: unknown;
|
|
504
|
+
/** Sync data source ID Nonce */
|
|
505
|
+
's'?: string;
|
|
506
|
+
/** Data Connector Name */
|
|
507
|
+
'n': string;
|
|
508
|
+
};
|
|
509
|
+
export declare type RawDataActionResult = {
|
|
510
|
+
/** The external service responded with this code */
|
|
511
|
+
'c': number;
|
|
512
|
+
} & ({
|
|
513
|
+
/** And this text */
|
|
514
|
+
't': string;
|
|
515
|
+
} | {
|
|
516
|
+
/** Or this JSON */
|
|
517
|
+
'j': unknown;
|
|
518
|
+
});
|
|
519
|
+
export declare type DataActionResult = Promise<RawDataActionResult>;
|
|
442
520
|
export declare type DeleteItemQuery = string;
|
|
443
521
|
export declare type DeleteItemResult = boolean;
|
|
444
522
|
export declare type DeletePageQuery = string;
|
|
@@ -752,6 +830,8 @@ export declare type ShowPanelQuery = {
|
|
|
752
830
|
export declare type ShowPanelResult = undefined;
|
|
753
831
|
export declare type SleepForTestCaseQuery = number;
|
|
754
832
|
export declare type SleepForTestCaseResult = Promise<void>;
|
|
833
|
+
export declare type ThrowForTestCaseQuery = number;
|
|
834
|
+
export declare type ThrowForTestCaseResult = undefined | Promise<void>;
|
|
755
835
|
export declare type UnhookCreateItemsQuery = {
|
|
756
836
|
/** Name of the action passed to HookCreateItems */
|
|
757
837
|
'n': string;
|
package/sdk/commandtypes.js
CHANGED
|
@@ -1,7 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRawSendXHRResponse = void 0;
|
|
3
|
+
exports.isRawSendXHRResponse = exports.commandTitles = void 0;
|
|
4
4
|
const checks_1 = require("./core/checks");
|
|
5
|
+
/** @ignore */
|
|
6
|
+
exports.commandTitles = new Map([
|
|
7
|
+
["alta" /* AddLineTextArea */, 'AddLineTextArea'],
|
|
8
|
+
["ami" /* AddMenuItem */, 'AddMenuItem'],
|
|
9
|
+
["asd" /* AddShapeData */, 'AddShapeData'],
|
|
10
|
+
["a" /* Alert */, 'Alert'],
|
|
11
|
+
["av" /* AnimateViewport */, 'AnimateViewport'],
|
|
12
|
+
["b" /* Bootstrap */, 'Bootstrap'],
|
|
13
|
+
["c" /* Confirm */, 'Confirm'],
|
|
14
|
+
["cb" /* CreateBlock */, 'CreateBlock'],
|
|
15
|
+
["cc" /* CreateCollection */, 'CreateCollection'],
|
|
16
|
+
["cds" /* CreateDataSource */, 'CreateDataSource'],
|
|
17
|
+
["cl" /* CreateLine */, 'CreateLine'],
|
|
18
|
+
["cp" /* CreatePage */, 'CreatePage'],
|
|
19
|
+
["di" /* DeleteItem */, 'DeleteItem'],
|
|
20
|
+
["dp" /* DeletePage */, 'DeletePage'],
|
|
21
|
+
["dsd" /* DeleteShapeData */, 'DeleteShapeData'],
|
|
22
|
+
["d" /* Download */, 'Download'],
|
|
23
|
+
["ee" /* ElementExists */, 'ElementExists'],
|
|
24
|
+
["ef" /* ExecuteFormula */, 'ExecuteFormula'],
|
|
25
|
+
["gcl" /* GetConnectedLines */, 'GetConnectedLines'],
|
|
26
|
+
["gcp" /* GetCurrentPage */, 'GetCurrentPage'],
|
|
27
|
+
["gcs" /* GetCustomShape */, 'GetCustomShape'],
|
|
28
|
+
["gdif" /* GetDataItemField */, 'GetDataItemField'],
|
|
29
|
+
["get" /* GetElementType */, 'GetElementType'],
|
|
30
|
+
["gip" /* GetItemPageId */, 'GetItemPageId'],
|
|
31
|
+
["gp" /* GetProperty */, 'GetProperty'],
|
|
32
|
+
["grk" /* GetReferenceKey */, 'GetReferenceKey'],
|
|
33
|
+
["grlp" /* GetRelativeLinePosition */, 'GetRelativeLinePosition'],
|
|
34
|
+
["gs" /* GetSelection */, 'GetSelection'],
|
|
35
|
+
["gsd" /* GetShapeData */, 'GetShapeData'],
|
|
36
|
+
["hm" /* HideModal */, 'HideModal'],
|
|
37
|
+
["hp" /* HidePanel */, 'HidePanel'],
|
|
38
|
+
["hci" /* HookCreateItems */, 'HookCreateItems'],
|
|
39
|
+
["hs" /* HookSelection */, 'HookSelection'],
|
|
40
|
+
["hte" /* HookTextEdit */, 'HookTextEdit'],
|
|
41
|
+
["k" /* KillExtension */, 'KillExtension'],
|
|
42
|
+
["lb" /* ListBlocks */, 'ListBlocks'],
|
|
43
|
+
["lcf" /* ListCollectionFields */, 'ListCollectionFields'],
|
|
44
|
+
["lc" /* ListCollections */, 'ListCollections'],
|
|
45
|
+
["ldi" /* ListDataItems */, 'ListDataItems'],
|
|
46
|
+
["lds" /* ListDataSources */, 'ListDataSources'],
|
|
47
|
+
["lg" /* ListGroups */, 'ListGroups'],
|
|
48
|
+
["ll" /* ListLines */, 'ListLines'],
|
|
49
|
+
["lp" /* ListPages */, 'ListPages'],
|
|
50
|
+
["lpr" /* ListProperties */, 'ListProperties'],
|
|
51
|
+
["lrk" /* ListReferenceKeys */, 'ListReferenceKeys'],
|
|
52
|
+
["lsd" /* ListShapeData */, 'ListShapeData'],
|
|
53
|
+
["lta" /* ListTextAreas */, 'ListTextAreas'],
|
|
54
|
+
["lbc" /* LoadBlockClasses */, 'LoadBlockClasses'],
|
|
55
|
+
["log" /* LogForTestCase */, 'LogForTestCase'],
|
|
56
|
+
["oi" /* OffsetItems */, 'OffsetItems'],
|
|
57
|
+
["pdi" /* PatchDataItems */, 'PatchDataItems'],
|
|
58
|
+
["rp" /* RegisterPanel */, 'RegisterPanel'],
|
|
59
|
+
["r" /* ReloadExtension */, 'ReloadExtension'],
|
|
60
|
+
["oauth" /* SendOAuthRequest */, 'SendOAuthRequest'],
|
|
61
|
+
["suim" /* SendUIMessage */, 'SendUIMessage'],
|
|
62
|
+
["xhr" /* SendXHR */, 'SendXHR'],
|
|
63
|
+
["scp" /* SetCurrentPage */, 'SetCurrentPage'],
|
|
64
|
+
["sp" /* SetProperty */, 'SetProperty'],
|
|
65
|
+
["srk" /* SetReferenceKey */, 'SetReferenceKey'],
|
|
66
|
+
["ssd" /* SetShapeData */, 'SetShapeData'],
|
|
67
|
+
["sm" /* ShowModal */, 'ShowModal'],
|
|
68
|
+
["spn" /* ShowPanel */, 'ShowPanel'],
|
|
69
|
+
["sleep" /* SleepForTestCase */, 'SleepForTestCase'],
|
|
70
|
+
["throw" /* ThrowForTestCase */, 'ThrowForTestCase'],
|
|
71
|
+
["uci" /* UnhookCreateItems */, 'UnhookCreateItems'],
|
|
72
|
+
["us" /* UnhookSelection */, 'UnhookSelection'],
|
|
73
|
+
["ute" /* UnhookTextEdit */, 'UnhookTextEdit'],
|
|
74
|
+
]);
|
|
5
75
|
function isRawSendXHRResponse(val) {
|
|
6
76
|
return (0, checks_1.isString)(val['url']) && (0, checks_1.isString)(val['t']) && (0, checks_1.isNumber)(val['s']) && (0, checks_1.isObject)(val['h']);
|
|
7
77
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function decodeBase64(base64String: string): Uint8Array;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeBase64 = void 0;
|
|
4
|
+
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
5
|
+
//This gives a ~8x speedup vs. using alphabet.indexOf() in the main decode loop.
|
|
6
|
+
const charCodeToEncodedInt = [];
|
|
7
|
+
for (let i = 0; i < alphabet.length; i++) {
|
|
8
|
+
charCodeToEncodedInt[alphabet.charCodeAt(i)] = i;
|
|
9
|
+
}
|
|
10
|
+
function decodeBase64(base64String) {
|
|
11
|
+
//Filter out whitespace, etc
|
|
12
|
+
base64String = base64String.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
|
13
|
+
if (base64String.length % 4 !== 0) {
|
|
14
|
+
throw new Error('Invalid base64 input; length must be a multiple of 4');
|
|
15
|
+
}
|
|
16
|
+
//4 characters of input turns into 3 bytes of output
|
|
17
|
+
let bytes = (base64String.length / 4) * 3;
|
|
18
|
+
//But each trailing = (up to 2) is one fewer byte of output
|
|
19
|
+
if (base64String.endsWith('==')) {
|
|
20
|
+
bytes -= 2;
|
|
21
|
+
}
|
|
22
|
+
else if (base64String.endsWith('=')) {
|
|
23
|
+
bytes -= 1;
|
|
24
|
+
}
|
|
25
|
+
const output = new Uint8Array(bytes);
|
|
26
|
+
let inputIndex = 0;
|
|
27
|
+
for (let outputIndex = 0; outputIndex < bytes; outputIndex += 3) {
|
|
28
|
+
//Get the 4 numbers 0-63 encoded in the next 4 characters
|
|
29
|
+
const enc1 = charCodeToEncodedInt[base64String.charCodeAt(inputIndex++)];
|
|
30
|
+
const enc2 = charCodeToEncodedInt[base64String.charCodeAt(inputIndex++)];
|
|
31
|
+
const enc3 = charCodeToEncodedInt[base64String.charCodeAt(inputIndex++)];
|
|
32
|
+
const enc4 = charCodeToEncodedInt[base64String.charCodeAt(inputIndex++)];
|
|
33
|
+
//Read 8 total bits into each of the output values. Skip one byte
|
|
34
|
+
//for each padding = at the end of the string
|
|
35
|
+
output[outputIndex] = (enc1 << 2) | (enc2 >> 4);
|
|
36
|
+
if (enc3 != 64) {
|
|
37
|
+
output[outputIndex + 1] = ((enc2 & 15) << 4) | (enc3 >> 2);
|
|
38
|
+
}
|
|
39
|
+
if (enc4 != 64) {
|
|
40
|
+
output[outputIndex + 2] = ((enc3 & 3) << 6) | enc4;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return output;
|
|
44
|
+
}
|
|
45
|
+
exports.decodeBase64 = decodeBase64;
|
|
@@ -11,7 +11,8 @@ export declare enum FieldConstraintType {
|
|
|
11
11
|
LOCKED = "locked",
|
|
12
12
|
MIN_VALUE = "minValue",
|
|
13
13
|
MAX_VALUE = "maxValue",
|
|
14
|
-
SINGLE_LINE_ONLY = "singleLineOnly"
|
|
14
|
+
SINGLE_LINE_ONLY = "singleLineOnly",
|
|
15
|
+
NO_WHITESPACE = "noWhitespace"
|
|
15
16
|
}
|
|
16
17
|
export declare type SerializedFieldConstraint = {
|
|
17
18
|
'Type': FieldConstraintType;
|
|
@@ -9,4 +9,5 @@ var FieldConstraintType;
|
|
|
9
9
|
FieldConstraintType["MIN_VALUE"] = "minValue";
|
|
10
10
|
FieldConstraintType["MAX_VALUE"] = "maxValue";
|
|
11
11
|
FieldConstraintType["SINGLE_LINE_ONLY"] = "singleLineOnly";
|
|
12
|
+
FieldConstraintType["NO_WHITESPACE"] = "noWhitespace";
|
|
12
13
|
})(FieldConstraintType = exports.FieldConstraintType || (exports.FieldConstraintType = {}));
|
|
@@ -35,7 +35,9 @@ class DataSourceProxy extends propertystoreproxy_1.PropertyStoreProxy {
|
|
|
35
35
|
return new collectionproxy_1.CollectionProxy(this.client.sendCommand("cc" /* CreateCollection */, {
|
|
36
36
|
's': this.id,
|
|
37
37
|
'n': name,
|
|
38
|
-
'f': schema.fields.map((field) =>
|
|
38
|
+
'f': schema.fields.map((field) => {
|
|
39
|
+
return { 'n': field.name, 't': (0, fieldtypedefinition_1.serializeFieldTypeDefinition)(field.type) };
|
|
40
|
+
}),
|
|
39
41
|
'p': schema.primaryKey,
|
|
40
42
|
}), this.client);
|
|
41
43
|
}
|
|
@@ -5,10 +5,12 @@ const fieldtypedefinition_1 = require("../core/data/fieldtypedefinition/fieldtyp
|
|
|
5
5
|
/** @ignore */
|
|
6
6
|
function serializeSchemaDefinition(def) {
|
|
7
7
|
return {
|
|
8
|
-
'Fields': def.fields.map((field) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
'Fields': def.fields.map((field) => {
|
|
9
|
+
return {
|
|
10
|
+
'Name': field.name,
|
|
11
|
+
'Type': (0, fieldtypedefinition_1.serializeFieldTypeDefinition)(field.type),
|
|
12
|
+
};
|
|
13
|
+
}),
|
|
12
14
|
'PrimaryKey': def.primaryKey,
|
|
13
15
|
};
|
|
14
16
|
}
|
|
@@ -16,10 +18,12 @@ exports.serializeSchemaDefinition = serializeSchemaDefinition;
|
|
|
16
18
|
/** @ignore */
|
|
17
19
|
function parseSchemaDefinition(def) {
|
|
18
20
|
return {
|
|
19
|
-
fields: def['Fields'].map((field) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
fields: def['Fields'].map((field) => {
|
|
22
|
+
return {
|
|
23
|
+
name: field['Name'],
|
|
24
|
+
type: (0, fieldtypedefinition_1.deserializeFieldTypeDefinition)(field['Type']),
|
|
25
|
+
};
|
|
26
|
+
}),
|
|
23
27
|
primaryKey: def['PrimaryKey'],
|
|
24
28
|
};
|
|
25
29
|
}
|
package/sdk/editorclient.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ElementProxy } from './document/elementproxy';
|
|
|
6
6
|
import { GroupProxy } from './document/groupproxy';
|
|
7
7
|
import { LineProxy } from './document/lineproxy';
|
|
8
8
|
import { PageProxy } from './document/pageproxy';
|
|
9
|
+
import { FileUploadData } from './ui/menu';
|
|
9
10
|
export interface XHRRequest {
|
|
10
11
|
/** URL to request */
|
|
11
12
|
url: string;
|
|
@@ -34,6 +35,16 @@ export interface XHRResponse {
|
|
|
34
35
|
/** True if this request failed due to a timeout */
|
|
35
36
|
timeout?: boolean;
|
|
36
37
|
}
|
|
38
|
+
export declare type DataActionResult = {
|
|
39
|
+
/** The HTTP Status Code from the Extension Data Sync endpoint */
|
|
40
|
+
'status': number;
|
|
41
|
+
} & ({
|
|
42
|
+
/** The body of the HTTP Response (if Content-Type: application/json) */
|
|
43
|
+
'json': unknown;
|
|
44
|
+
} | {
|
|
45
|
+
/** The body of the HTTP Response (otherwise) */
|
|
46
|
+
'text': string;
|
|
47
|
+
});
|
|
37
48
|
export declare class EditorClient {
|
|
38
49
|
private nextId;
|
|
39
50
|
private readonly callbacks;
|
|
@@ -54,6 +65,17 @@ export declare class EditorClient {
|
|
|
54
65
|
* @param base64 If true, base64 decode the data before downloading it
|
|
55
66
|
*/
|
|
56
67
|
download(filename: string, data: string, mime: string, base64: boolean): void;
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @param flowName
|
|
71
|
+
* @param dataConnectorName
|
|
72
|
+
* @param syncDataSourceId
|
|
73
|
+
* @param flowData
|
|
74
|
+
* @param async
|
|
75
|
+
* @returns
|
|
76
|
+
* @throws A string with an error from the data sync server
|
|
77
|
+
*/
|
|
78
|
+
performDataAction(flowName: string, dataConnectorName: string, syncDataSourceId?: undefined | string, flowData?: unknown, async?: boolean): Promise<DataActionResult>;
|
|
57
79
|
/**
|
|
58
80
|
* Make a network request
|
|
59
81
|
* @param request Settings for the network request
|
|
@@ -77,6 +99,13 @@ export declare class EditorClient {
|
|
|
77
99
|
* @param callback function to execute when this action is invoked
|
|
78
100
|
*/
|
|
79
101
|
registerAction(name: string, callback: (value: any) => JsonSerializable | void | Promise<any>): void;
|
|
102
|
+
/**
|
|
103
|
+
* Register a named action that receives file upload data. These callbacks can be used in
|
|
104
|
+
* Menu.addMenuItem as the file action.
|
|
105
|
+
* @param name The name of the action
|
|
106
|
+
* @param callback Function to execute when this action is invoked
|
|
107
|
+
*/
|
|
108
|
+
registerFileUploadAction(name: string, callback: (files: FileUploadData[]) => void): void;
|
|
80
109
|
/**
|
|
81
110
|
* Remove the callback for a given action. If the action is later invoked, nothing will happen.
|
|
82
111
|
* @param name name of the action to unregister
|
|
@@ -179,5 +208,22 @@ export declare class EditorClient {
|
|
|
179
208
|
* @hidden
|
|
180
209
|
*/
|
|
181
210
|
protected listenToEditor(): void;
|
|
211
|
+
/**
|
|
212
|
+
* Display an alert modal to the user
|
|
213
|
+
* @param text Body text to display in the alert modal
|
|
214
|
+
* @param title Title of the alert modal; defaults to the extension title specified in manifest.json
|
|
215
|
+
* @param buttonText Text for the OK button; defaults to "OK" (or a translation)
|
|
216
|
+
* @returns a Promise that resolves true if the user clicks OK, false if they otherwise dismiss the modal
|
|
217
|
+
*/
|
|
218
|
+
alert(text: string, title?: string, buttonText?: string): import("./commandtypes").AlertResult;
|
|
219
|
+
/**
|
|
220
|
+
* Display a confirm modal to the user
|
|
221
|
+
* @param text Body text to display in the alert modal
|
|
222
|
+
* @param title Title of the alert modal; defaults to the extension title specified in manifest.json
|
|
223
|
+
* @param okText Text for the OK button; defaults to "OK" (or a translation)
|
|
224
|
+
* @param cancelText Text for the Cancel button; defaults to "Cancel" (or a translation)
|
|
225
|
+
* @returns a Promise that resolves true if the user clicks OK, false if they click Cancel or otherwise dismiss the modal
|
|
226
|
+
*/
|
|
227
|
+
confirm(text: string, title?: string, okText?: string, cancelText?: string): import("./commandtypes").ConfirmResult;
|
|
182
228
|
constructor();
|
|
183
229
|
}
|
package/sdk/editorclient.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EditorClient = void 0;
|
|
4
4
|
const commandtypes_1 = require("./commandtypes");
|
|
5
|
+
const base64_1 = require("./core/base64");
|
|
5
6
|
const blockproxyregistry_1 = require("./document/blockclasses/blockproxyregistry");
|
|
6
7
|
const blockproxy_1 = require("./document/blockproxy");
|
|
7
8
|
const documentproxy_1 = require("./document/documentproxy");
|
|
@@ -48,6 +49,35 @@ class EditorClient {
|
|
|
48
49
|
'b64': base64,
|
|
49
50
|
});
|
|
50
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @param flowName
|
|
55
|
+
* @param dataConnectorName
|
|
56
|
+
* @param syncDataSourceId
|
|
57
|
+
* @param flowData
|
|
58
|
+
* @param async
|
|
59
|
+
* @returns
|
|
60
|
+
* @throws A string with an error from the data sync server
|
|
61
|
+
*/
|
|
62
|
+
async performDataAction(flowName, dataConnectorName, syncDataSourceId = undefined, flowData = undefined, async = true) {
|
|
63
|
+
const result = await this.sendCommand("da" /* DataAction */, {
|
|
64
|
+
'fn': flowName,
|
|
65
|
+
'a': async,
|
|
66
|
+
's': syncDataSourceId,
|
|
67
|
+
'fd': flowData,
|
|
68
|
+
'n': dataConnectorName,
|
|
69
|
+
});
|
|
70
|
+
if ('t' in result) {
|
|
71
|
+
return {
|
|
72
|
+
'status': result['c'],
|
|
73
|
+
'text': result['t'],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
'status': result['c'],
|
|
78
|
+
'json': result['j'],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
51
81
|
/**
|
|
52
82
|
* Make a network request
|
|
53
83
|
* @param request Settings for the network request
|
|
@@ -131,6 +161,24 @@ class EditorClient {
|
|
|
131
161
|
}
|
|
132
162
|
this.callbacks.set(name, callback);
|
|
133
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Register a named action that receives file upload data. These callbacks can be used in
|
|
166
|
+
* Menu.addMenuItem as the file action.
|
|
167
|
+
* @param name The name of the action
|
|
168
|
+
* @param callback Function to execute when this action is invoked
|
|
169
|
+
*/
|
|
170
|
+
registerFileUploadAction(name, callback) {
|
|
171
|
+
this.registerAction(name, (msg) => {
|
|
172
|
+
callback(msg['f'].map((rawFile) => {
|
|
173
|
+
if (rawFile['b']) {
|
|
174
|
+
return { fileName: rawFile['n'], text: rawFile['t'], binary: (0, base64_1.decodeBase64)(rawFile['b']) };
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
return { fileName: rawFile['n'], text: rawFile['t'] };
|
|
178
|
+
}
|
|
179
|
+
}));
|
|
180
|
+
});
|
|
181
|
+
}
|
|
134
182
|
/**
|
|
135
183
|
* Remove the callback for a given action. If the action is later invoked, nothing will happen.
|
|
136
184
|
* @param name name of the action to unregister
|
|
@@ -310,5 +358,26 @@ class EditorClient {
|
|
|
310
358
|
return (_a = this.callbacks.get(msg['id'])) === null || _a === void 0 ? void 0 : _a(msg);
|
|
311
359
|
});
|
|
312
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Display an alert modal to the user
|
|
363
|
+
* @param text Body text to display in the alert modal
|
|
364
|
+
* @param title Title of the alert modal; defaults to the extension title specified in manifest.json
|
|
365
|
+
* @param buttonText Text for the OK button; defaults to "OK" (or a translation)
|
|
366
|
+
* @returns a Promise that resolves true if the user clicks OK, false if they otherwise dismiss the modal
|
|
367
|
+
*/
|
|
368
|
+
alert(text, title, buttonText) {
|
|
369
|
+
return this.sendCommand("a" /* Alert */, { 't': title, 'b': text, 'bt': buttonText });
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Display a confirm modal to the user
|
|
373
|
+
* @param text Body text to display in the alert modal
|
|
374
|
+
* @param title Title of the alert modal; defaults to the extension title specified in manifest.json
|
|
375
|
+
* @param okText Text for the OK button; defaults to "OK" (or a translation)
|
|
376
|
+
* @param cancelText Text for the Cancel button; defaults to "Cancel" (or a translation)
|
|
377
|
+
* @returns a Promise that resolves true if the user clicks OK, false if they click Cancel or otherwise dismiss the modal
|
|
378
|
+
*/
|
|
379
|
+
confirm(text, title, okText, cancelText) {
|
|
380
|
+
return this.sendCommand("c" /* Confirm */, { 't': title, 'b': text, 'o': okText, 'c': cancelText });
|
|
381
|
+
}
|
|
313
382
|
}
|
|
314
383
|
exports.EditorClient = EditorClient;
|
package/sdk/ui/menu.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface CustomMenuItem {
|
|
|
20
20
|
/** The text to display on the menu item */
|
|
21
21
|
label: string;
|
|
22
22
|
/** The registered action to run when the menu item is clicked */
|
|
23
|
-
action
|
|
23
|
+
action?: string;
|
|
24
24
|
/** If specified, what action's return value should determine if this menu item is visible? */
|
|
25
25
|
visibleAction?: string;
|
|
26
26
|
/** If specified, what action's return value should determine if this menu item is disabled? */
|
|
@@ -29,13 +29,30 @@ export interface CustomMenuItem {
|
|
|
29
29
|
menuType: MenuType;
|
|
30
30
|
/** Where in that menu to display this item */
|
|
31
31
|
location?: MenuLocation;
|
|
32
|
+
/** If specified, this menu item should launch a file picker */
|
|
33
|
+
file?: {
|
|
34
|
+
/** An action registered with EditorClient.registerFileUploadAction */
|
|
35
|
+
action: string;
|
|
36
|
+
/** An [accept string](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) as specified for HTML file inputs */
|
|
37
|
+
accept: string;
|
|
38
|
+
/** If true, only allow a single file to be selected for upload */
|
|
39
|
+
singleFileOnly?: boolean;
|
|
40
|
+
/** If true, send the file contents to the callback action as a Uint8Array as well as a plain text string */
|
|
41
|
+
binary?: boolean;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export interface FileUploadData {
|
|
45
|
+
fileName: string;
|
|
46
|
+
text: string;
|
|
47
|
+
binary?: Uint8Array;
|
|
32
48
|
}
|
|
33
49
|
export declare class Menu {
|
|
34
50
|
private readonly client;
|
|
35
51
|
constructor(client: EditorClient);
|
|
36
52
|
/**
|
|
37
53
|
* Add a new menu item to execute custom code. The action must be registered with
|
|
38
|
-
* EditorClient.registerAction
|
|
54
|
+
* [EditorClient.registerAction](/extension-sdk/#classes_editorclient-EditorClient_registeraction)
|
|
55
|
+
* prior to using it in the menu.
|
|
39
56
|
*
|
|
40
57
|
* @param item The definition of the new menu item
|
|
41
58
|
*/
|
package/sdk/ui/menu.js
CHANGED
|
@@ -26,12 +26,13 @@ class Menu {
|
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Add a new menu item to execute custom code. The action must be registered with
|
|
29
|
-
* EditorClient.registerAction
|
|
29
|
+
* [EditorClient.registerAction](/extension-sdk/#classes_editorclient-EditorClient_registeraction)
|
|
30
|
+
* prior to using it in the menu.
|
|
30
31
|
*
|
|
31
32
|
* @param item The definition of the new menu item
|
|
32
33
|
*/
|
|
33
34
|
addMenuItem(item) {
|
|
34
|
-
if (!this.client.actionExists(item.action)) {
|
|
35
|
+
if (item.action && !this.client.actionExists(item.action)) {
|
|
35
36
|
throw new Error('Unregistered action: ' + item.action);
|
|
36
37
|
}
|
|
37
38
|
if (item.visibleAction && !this.client.actionExists(item.visibleAction)) {
|
|
@@ -47,6 +48,14 @@ class Menu {
|
|
|
47
48
|
'd': item.disabledAction,
|
|
48
49
|
't': item.menuType,
|
|
49
50
|
'loc': item.location,
|
|
51
|
+
'f': item.file
|
|
52
|
+
? {
|
|
53
|
+
'a': item.file.action,
|
|
54
|
+
'ac': item.file.accept,
|
|
55
|
+
's': item.file.singleFileOnly,
|
|
56
|
+
'b': item.file.binary,
|
|
57
|
+
}
|
|
58
|
+
: undefined,
|
|
50
59
|
});
|
|
51
60
|
}
|
|
52
61
|
}
|