lucid-extension-sdk 0.0.140 → 0.0.142
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/commandtypes.d.ts +12 -0
- package/commandtypes.js +1 -0
- package/document/blockclasses/blockproxyregistry.js +2 -0
- package/document/blockclasses/tableblockproxy.d.ts +67 -0
- package/document/blockclasses/tableblockproxy.js +120 -0
- package/editorclient.d.ts +7 -0
- package/editorclient.js +9 -0
- package/math.d.ts +1 -0
- package/package.json +1 -1
package/commandtypes.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ export declare const enum CommandName {
|
|
|
89
89
|
LogForTestCase = "log",
|
|
90
90
|
OffsetItems = "oi",
|
|
91
91
|
PatchDataItems = "pdi",
|
|
92
|
+
Prompt = "p",
|
|
92
93
|
RegisterPanel = "rp",
|
|
93
94
|
RegisterUnfurl = "ru",
|
|
94
95
|
ReloadExtension = "r",
|
|
@@ -400,6 +401,10 @@ export declare type CommandArgs = {
|
|
|
400
401
|
query: PatchDataItemsQuery;
|
|
401
402
|
result: PatchDataItemsResult;
|
|
402
403
|
};
|
|
404
|
+
[CommandName.Prompt]: {
|
|
405
|
+
query: PromptQuery;
|
|
406
|
+
result: PromptResult;
|
|
407
|
+
};
|
|
403
408
|
[CommandName.RegisterPanel]: {
|
|
404
409
|
query: RegisterPanelQuery;
|
|
405
410
|
result: RegisterPanelResult;
|
|
@@ -1005,6 +1010,13 @@ export declare type PatchDataItemsQuery = {
|
|
|
1005
1010
|
};
|
|
1006
1011
|
/** Primary keys inserted, if any */
|
|
1007
1012
|
export declare type PatchDataItemsResult = string[];
|
|
1013
|
+
export declare type PromptQuery = {
|
|
1014
|
+
/** Title; defaults to extension title */
|
|
1015
|
+
't'?: string | undefined;
|
|
1016
|
+
/** Body text */
|
|
1017
|
+
'b': string;
|
|
1018
|
+
};
|
|
1019
|
+
export declare type PromptResult = Promise<string | undefined>;
|
|
1008
1020
|
export declare type RegisterPanelQuery = {
|
|
1009
1021
|
/** Name of the panel's action for receiving events; generated automatically by Panel base class */
|
|
1010
1022
|
'n': string;
|
package/commandtypes.js
CHANGED
|
@@ -71,6 +71,7 @@ exports.commandTitles = new Map([
|
|
|
71
71
|
["log" /* CommandName.LogForTestCase */, 'LogForTestCase'],
|
|
72
72
|
["oi" /* CommandName.OffsetItems */, 'OffsetItems'],
|
|
73
73
|
["pdi" /* CommandName.PatchDataItems */, 'PatchDataItems'],
|
|
74
|
+
["p" /* CommandName.Prompt */, 'Prompt'],
|
|
74
75
|
["rp" /* CommandName.RegisterPanel */, 'RegisterPanel'],
|
|
75
76
|
["ru" /* CommandName.RegisterUnfurl */, 'RegisterUnfurl'],
|
|
76
77
|
["r" /* CommandName.ReloadExtension */, 'ReloadExtension'],
|
|
@@ -5,11 +5,13 @@ const cardblockproxy_1 = require("./cardblockproxy");
|
|
|
5
5
|
const customblockproxy_1 = require("./customblockproxy");
|
|
6
6
|
const erdblockproxy_1 = require("./erdblockproxy");
|
|
7
7
|
const linkunfurlblockproxy_1 = require("./linkunfurlblockproxy");
|
|
8
|
+
const tableblockproxy_1 = require("./tableblockproxy");
|
|
8
9
|
const allProxyClasses = [
|
|
9
10
|
erdblockproxy_1.ERDBlockProxy,
|
|
10
11
|
customblockproxy_1.CustomBlockProxy,
|
|
11
12
|
linkunfurlblockproxy_1.LinkUnfurlBlockProxy,
|
|
12
13
|
cardblockproxy_1.CardBlockProxy,
|
|
14
|
+
tableblockproxy_1.TableBlockProxy,
|
|
13
15
|
];
|
|
14
16
|
function findProxyClass(className) {
|
|
15
17
|
return allProxyClasses.find((proxy) => proxy.classNameRegex.test(className));
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { SimpleFillStyle } from '../../core/properties/fillcolor';
|
|
2
|
+
import { BlockProxy } from '../blockproxy';
|
|
3
|
+
import { TextStyle } from '../text/textstyle';
|
|
4
|
+
export declare class TableCellProxy {
|
|
5
|
+
readonly table: TableBlockProxy;
|
|
6
|
+
readonly row: number;
|
|
7
|
+
readonly column: number;
|
|
8
|
+
constructor(table: TableBlockProxy, row: number, column: number);
|
|
9
|
+
getText(): string;
|
|
10
|
+
setText(text: string): undefined;
|
|
11
|
+
getTextStyle(): TextStyle;
|
|
12
|
+
setTextStyle(style: Partial<TextStyle>): void;
|
|
13
|
+
setFill(fill: SimpleFillStyle): void;
|
|
14
|
+
/**
|
|
15
|
+
* Cells in a table can be merged together with adjacent cells into one larger cell. In this case, the upper-
|
|
16
|
+
* left cell remains visible but is enlarged to cover additional cells, and the other cells are hidden.
|
|
17
|
+
*
|
|
18
|
+
* @returns the size of this cell, in how many cells horizontally and vertically have been merged into it.
|
|
19
|
+
* For most cells, this will be {w:1, h:1}, but if it has been merged with the cell to the right of it, it
|
|
20
|
+
* would be {w:2, h:1}.
|
|
21
|
+
*/
|
|
22
|
+
getMergedCellSize(): {
|
|
23
|
+
w: number;
|
|
24
|
+
h: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
/**
|
|
28
|
+
* Cells in a table can be merged together with adjacent cells into one larger cell. In this case, the upper-
|
|
29
|
+
* left cell remains visible but is enlarged to cover additional cells, and the other cells are hidden.
|
|
30
|
+
*
|
|
31
|
+
* @param size the desired size of this cell, in how many cells horizontally and vertically are merged into it.
|
|
32
|
+
* This normally {w:1, h:1} for a normal cell, or {w:2, h:1} to merge a cell with the one to the right of it, etc.
|
|
33
|
+
*/
|
|
34
|
+
setMergedCellSize(size: {
|
|
35
|
+
w: number;
|
|
36
|
+
h: number;
|
|
37
|
+
}): void;
|
|
38
|
+
/**
|
|
39
|
+
* @returns the pixel width of the cell, including any cells it is merged with.
|
|
40
|
+
*/
|
|
41
|
+
getWidth(): number;
|
|
42
|
+
/**
|
|
43
|
+
* @returns the pixel height of the cell, including any cells it is merged with.
|
|
44
|
+
*/
|
|
45
|
+
getHeight(): number;
|
|
46
|
+
}
|
|
47
|
+
export declare class TableRowProxy {
|
|
48
|
+
readonly table: TableBlockProxy;
|
|
49
|
+
readonly row: number;
|
|
50
|
+
constructor(table: TableBlockProxy, row: number);
|
|
51
|
+
getCells(): TableCellProxy[];
|
|
52
|
+
getHeight(): number;
|
|
53
|
+
}
|
|
54
|
+
export declare class TableBlockProxy extends BlockProxy {
|
|
55
|
+
static classNameRegex: RegExp;
|
|
56
|
+
getRowCount(): number;
|
|
57
|
+
getColumnCount(): number;
|
|
58
|
+
getRows(): TableRowProxy[];
|
|
59
|
+
getRowHeights(): number[];
|
|
60
|
+
getColumnWidths(): number[];
|
|
61
|
+
setColumnWidths(widths: number[]): void;
|
|
62
|
+
setRowHeights(heights: number[]): void;
|
|
63
|
+
getAutoResizeColumns(): boolean;
|
|
64
|
+
getAutoResizeRows(): boolean;
|
|
65
|
+
setAutoResizeColumns(auto: boolean): void;
|
|
66
|
+
setAutoResizeRows(auto: boolean): void;
|
|
67
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TableBlockProxy = exports.TableRowProxy = exports.TableCellProxy = void 0;
|
|
4
|
+
const fillcolor_1 = require("../../core/properties/fillcolor");
|
|
5
|
+
const blockproxy_1 = require("../blockproxy");
|
|
6
|
+
class TableCellProxy {
|
|
7
|
+
constructor(table, row, column) {
|
|
8
|
+
this.table = table;
|
|
9
|
+
this.row = row;
|
|
10
|
+
this.column = column;
|
|
11
|
+
}
|
|
12
|
+
getText() {
|
|
13
|
+
return this.table.textAreas.get(`Cell_${this.row},${this.column}`);
|
|
14
|
+
}
|
|
15
|
+
setText(text) {
|
|
16
|
+
return this.table.textAreas.set(`Cell_${this.row},${this.column}`, text);
|
|
17
|
+
}
|
|
18
|
+
getTextStyle() {
|
|
19
|
+
return this.table.textStyles.get(`Cell_${this.row},${this.column}`);
|
|
20
|
+
}
|
|
21
|
+
setTextStyle(style) {
|
|
22
|
+
this.table.textStyles.set(`Cell_${this.row},${this.column}`, style);
|
|
23
|
+
}
|
|
24
|
+
setFill(fill) {
|
|
25
|
+
this.table.properties.set(`CellFill_${this.row},${this.column}`, (0, fillcolor_1.serializeSimpleFill)(fill));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Cells in a table can be merged together with adjacent cells into one larger cell. In this case, the upper-
|
|
29
|
+
* left cell remains visible but is enlarged to cover additional cells, and the other cells are hidden.
|
|
30
|
+
*
|
|
31
|
+
* @returns the size of this cell, in how many cells horizontally and vertically have been merged into it.
|
|
32
|
+
* For most cells, this will be {w:1, h:1}, but if it has been merged with the cell to the right of it, it
|
|
33
|
+
* would be {w:2, h:1}.
|
|
34
|
+
*/
|
|
35
|
+
getMergedCellSize() {
|
|
36
|
+
var _a;
|
|
37
|
+
return ((_a = this.table.properties.get(`CellSize_${this.row},${this.column}`)) !== null && _a !== void 0 ? _a : { w: 1, h: 1 });
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
/**
|
|
41
|
+
* Cells in a table can be merged together with adjacent cells into one larger cell. In this case, the upper-
|
|
42
|
+
* left cell remains visible but is enlarged to cover additional cells, and the other cells are hidden.
|
|
43
|
+
*
|
|
44
|
+
* @param size the desired size of this cell, in how many cells horizontally and vertically are merged into it.
|
|
45
|
+
* This normally {w:1, h:1} for a normal cell, or {w:2, h:1} to merge a cell with the one to the right of it, etc.
|
|
46
|
+
*/
|
|
47
|
+
setMergedCellSize(size) {
|
|
48
|
+
this.table.properties.set(`CellSize_${this.row},${this.column}`, size);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @returns the pixel width of the cell, including any cells it is merged with.
|
|
52
|
+
*/
|
|
53
|
+
getWidth() {
|
|
54
|
+
return this.table
|
|
55
|
+
.getColumnWidths()
|
|
56
|
+
.slice(this.column, this.column + this.getMergedCellSize().w)
|
|
57
|
+
.reduce((a, b) => a + b, 0);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @returns the pixel height of the cell, including any cells it is merged with.
|
|
61
|
+
*/
|
|
62
|
+
getHeight() {
|
|
63
|
+
return this.table
|
|
64
|
+
.getRowHeights()
|
|
65
|
+
.slice(this.row, this.row + this.getMergedCellSize().h)
|
|
66
|
+
.reduce((a, b) => a + b, 0);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.TableCellProxy = TableCellProxy;
|
|
70
|
+
class TableRowProxy {
|
|
71
|
+
constructor(table, row) {
|
|
72
|
+
this.table = table;
|
|
73
|
+
this.row = row;
|
|
74
|
+
}
|
|
75
|
+
getCells() {
|
|
76
|
+
return this.table.getColumnWidths().map((_, index) => new TableCellProxy(this.table, this.row, index));
|
|
77
|
+
}
|
|
78
|
+
getHeight() {
|
|
79
|
+
var _a;
|
|
80
|
+
return (_a = this.table.getRowHeights()[this.row]) !== null && _a !== void 0 ? _a : 1;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.TableRowProxy = TableRowProxy;
|
|
84
|
+
class TableBlockProxy extends blockproxy_1.BlockProxy {
|
|
85
|
+
getRowCount() {
|
|
86
|
+
return this.getRowHeights().length;
|
|
87
|
+
}
|
|
88
|
+
getColumnCount() {
|
|
89
|
+
return this.getColumnWidths().length;
|
|
90
|
+
}
|
|
91
|
+
getRows() {
|
|
92
|
+
return this.getRowHeights().map((_, index) => new TableRowProxy(this, index));
|
|
93
|
+
}
|
|
94
|
+
getRowHeights() {
|
|
95
|
+
return this.properties.get('RowHeights');
|
|
96
|
+
}
|
|
97
|
+
getColumnWidths() {
|
|
98
|
+
return this.properties.get('ColWidths');
|
|
99
|
+
}
|
|
100
|
+
setColumnWidths(widths) {
|
|
101
|
+
this.properties.set('ColWidths', widths);
|
|
102
|
+
}
|
|
103
|
+
setRowHeights(heights) {
|
|
104
|
+
this.properties.set('RowHeights', heights);
|
|
105
|
+
}
|
|
106
|
+
getAutoResizeColumns() {
|
|
107
|
+
return this.properties.get('AutoColWidth');
|
|
108
|
+
}
|
|
109
|
+
getAutoResizeRows() {
|
|
110
|
+
return this.properties.get('AutoRowHeight');
|
|
111
|
+
}
|
|
112
|
+
setAutoResizeColumns(auto) {
|
|
113
|
+
this.properties.set('AutoColWidth', auto);
|
|
114
|
+
}
|
|
115
|
+
setAutoResizeRows(auto) {
|
|
116
|
+
this.properties.set('AutoRowHeight', auto);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.TableBlockProxy = TableBlockProxy;
|
|
120
|
+
TableBlockProxy.classNameRegex = /^DefaultTableBlock$/;
|
package/editorclient.d.ts
CHANGED
|
@@ -308,5 +308,12 @@ export declare class EditorClient {
|
|
|
308
308
|
* @returns a Promise that resolves true if the user clicks OK, false if they click Cancel or otherwise dismiss the modal
|
|
309
309
|
*/
|
|
310
310
|
confirm(text: string, title?: string, okText?: string, cancelText?: string): import("./commandtypes").ConfirmResult;
|
|
311
|
+
/**
|
|
312
|
+
* Display a prompt modal to the user
|
|
313
|
+
* @param text Body text to display in the alert modal
|
|
314
|
+
* @param title Title of the alert modal; defaults to the extension title specified in manifest.json
|
|
315
|
+
* @returns a Promise that resolves to a string if a user enters one, or undefined if they cancel
|
|
316
|
+
*/
|
|
317
|
+
prompt(text: string, title?: string): import("./commandtypes").PromptResult;
|
|
311
318
|
constructor();
|
|
312
319
|
}
|
package/editorclient.js
CHANGED
|
@@ -520,5 +520,14 @@ class EditorClient {
|
|
|
520
520
|
confirm(text, title, okText, cancelText) {
|
|
521
521
|
return this.sendCommand("c" /* CommandName.Confirm */, { 't': title, 'b': text, 'o': okText, 'c': cancelText });
|
|
522
522
|
}
|
|
523
|
+
/**
|
|
524
|
+
* Display a prompt modal to the user
|
|
525
|
+
* @param text Body text to display in the alert modal
|
|
526
|
+
* @param title Title of the alert modal; defaults to the extension title specified in manifest.json
|
|
527
|
+
* @returns a Promise that resolves to a string if a user enters one, or undefined if they cancel
|
|
528
|
+
*/
|
|
529
|
+
prompt(text, title) {
|
|
530
|
+
return this.sendCommand("p" /* CommandName.Prompt */, { 't': title, 'b': text });
|
|
531
|
+
}
|
|
523
532
|
}
|
|
524
533
|
exports.EditorClient = EditorClient;
|
package/math.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export declare type Box = {
|
|
|
8
8
|
w: number;
|
|
9
9
|
h: number;
|
|
10
10
|
};
|
|
11
|
+
export declare function combinedBoundingBox(boxes: [Box, ...Box[]]): Box;
|
|
11
12
|
export declare function combinedBoundingBox(boxes: Box[]): Box | undefined;
|
|
12
13
|
export declare function padBox(box: Box, padding: number): Box;
|