@openpresentation/opf-editor 0.11.2 → 0.12.1
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/README.md +15 -2
- package/dist/block-convert.js +3 -2
- package/dist/chart-data.d.ts +2 -0
- package/dist/chart-data.js +1 -0
- package/dist/data-grid.js +177 -7
- package/dist/data.d.ts +21 -0
- package/dist/data.js +39 -0
- package/dist/dataset-refs.d.ts +17 -0
- package/dist/dataset-refs.js +45 -0
- package/dist/design-controls.js +5 -3
- package/dist/find-replace.js +14 -2
- package/dist/grid-model.d.ts +83 -6
- package/dist/grid-model.js +533 -47
- package/dist/switches.js +24 -7
- package/dist/table-options.js +13 -3
- package/dist/transfer.js +30 -0
- package/package.json +14 -8
package/dist/grid-model.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export interface PreparedGridChange {
|
|
|
32
32
|
kind: "chart" | "table";
|
|
33
33
|
/** The chart or table path. */
|
|
34
34
|
path: string;
|
|
35
|
+
/** The id of the shared dataset the edit changes, when the chart or table shows one (RR-54). */
|
|
36
|
+
dataset?: string;
|
|
35
37
|
document: unknown;
|
|
36
38
|
patches: JsonPatchOperation[];
|
|
37
39
|
changed: boolean;
|
|
@@ -41,6 +43,8 @@ export interface GridChange extends Omit<EditorChange, "document" | "patches"> {
|
|
|
41
43
|
action: string;
|
|
42
44
|
kind: "chart" | "table";
|
|
43
45
|
path: string;
|
|
46
|
+
/** The id of the shared dataset the edit changed, when the chart or table shows one. */
|
|
47
|
+
dataset?: string;
|
|
44
48
|
document: unknown;
|
|
45
49
|
patches: JsonPatchOperation[];
|
|
46
50
|
changed: boolean;
|
|
@@ -57,6 +61,8 @@ export interface GridCell {
|
|
|
57
61
|
row: number;
|
|
58
62
|
/** What the cell shows. A table cell shows what the slide draws; a chart number shows in the number format. "" for a gap or a covered cell. */
|
|
59
63
|
text: string;
|
|
64
|
+
/** A number as the slide draws it (the column's format, or a table cell's own), when a valid format changes how it reads. `text` stays the raw value: editing and copying use it. */
|
|
65
|
+
display?: string;
|
|
60
66
|
rich: boolean;
|
|
61
67
|
runs?: unknown[];
|
|
62
68
|
rowSpan: number;
|
|
@@ -65,6 +71,8 @@ export interface GridCell {
|
|
|
65
71
|
covered: boolean;
|
|
66
72
|
owner?: { line: number; column: number };
|
|
67
73
|
style?: Record<string, unknown>;
|
|
74
|
+
/** The number format of a header cell (a DataColumn `format`, or a styled header's `format`). */
|
|
75
|
+
format?: string;
|
|
68
76
|
warning?: string;
|
|
69
77
|
}
|
|
70
78
|
export interface DataGridDescription {
|
|
@@ -75,8 +83,16 @@ export interface DataGridDescription {
|
|
|
75
83
|
/** Body rows. */
|
|
76
84
|
rowCount: number;
|
|
77
85
|
columnCount: number;
|
|
78
|
-
/** For a chart: "category", "series",
|
|
86
|
+
/** For a chart: "category", "series", for scatter "label" and "x", and "other" for a column a `mapping` leaves out. Empty for a table. */
|
|
79
87
|
columnRoles: string[];
|
|
88
|
+
/** The number format of each column (from its header), or undefined. */
|
|
89
|
+
columnFormats: Array<string | undefined>;
|
|
90
|
+
/** The header texts (DataColumn names included), when the grid has a header line. */
|
|
91
|
+
columnNames?: string[];
|
|
92
|
+
/** Set when the chart or table shows a shared dataset: its id, `fields` and the paths of every item that uses it. */
|
|
93
|
+
dataset?: { id: string; fields?: string[]; items: string[] };
|
|
94
|
+
/** The chart's own `mapping`, when it has one. */
|
|
95
|
+
mapping?: ChartMappingColumns;
|
|
80
96
|
lines: GridCell[][];
|
|
81
97
|
warnings: Array<GridAddress & { message: string }>;
|
|
82
98
|
merges: Array<GridAddress & { rowSpan: number; colSpan: number }>;
|
|
@@ -84,21 +100,55 @@ export interface DataGridDescription {
|
|
|
84
100
|
export interface DataGridTarget {
|
|
85
101
|
kind: "chart" | "table";
|
|
86
102
|
path: string;
|
|
87
|
-
/** false for a chart whose data comes from a source. */
|
|
103
|
+
/** false for a chart whose data comes from a source, or from a dataset the document lacks. */
|
|
88
104
|
editable?: false;
|
|
89
105
|
reason?: string;
|
|
106
|
+
/** Set when the chart or table shows a shared dataset (RR-54): the grid edits the dataset. `count` items use it. */
|
|
107
|
+
dataset?: { id: string; fields?: string[]; count: number; items: string[] };
|
|
108
|
+
}
|
|
109
|
+
/** A chart's `mapping`: the category, X and series columns by name. */
|
|
110
|
+
export interface ChartMappingColumns {
|
|
111
|
+
category?: string;
|
|
112
|
+
x?: string;
|
|
113
|
+
series?: string[];
|
|
114
|
+
}
|
|
115
|
+
export interface ChartMappingDescription {
|
|
116
|
+
path: string;
|
|
117
|
+
/** True for a chart with an X axis (scatter). */
|
|
118
|
+
xy: boolean;
|
|
119
|
+
columns: Array<{ name: string; format?: string; role: "category" | "label" | "x" | "series" | "other" }>;
|
|
120
|
+
/** The label column's name (the mapping's, or the first column). */
|
|
121
|
+
category: string;
|
|
122
|
+
/** The X column's name, for an XY chart. */
|
|
123
|
+
x?: string;
|
|
124
|
+
/** The plotted columns, in order. */
|
|
125
|
+
series: string[];
|
|
126
|
+
/** The chart's own `mapping`, when it has one. */
|
|
127
|
+
authored?: ChartMappingColumns;
|
|
90
128
|
}
|
|
91
129
|
|
|
92
130
|
/** Spreadsheet column letters: 0 is A, 26 is AA. */
|
|
93
131
|
export declare function columnLabel(index: number): string;
|
|
94
132
|
/** "Header, column B" or "Row 3, column A". */
|
|
95
133
|
export declare function describeAddress(address: GridAddress): string;
|
|
96
|
-
/** What each chart column is for. */
|
|
97
|
-
export declare function chartColumnRoles(columnCount: number, chartType?: string): string[];
|
|
134
|
+
/** What each chart column is for. With a `mapping` and the column `names` it addresses, the roles follow it ("other" is a column nothing plots). */
|
|
135
|
+
export declare function chartColumnRoles(columnCount: number, chartType?: string, mapping?: ChartMappingColumns, names?: string[]): string[];
|
|
98
136
|
/** The text a cell shows. */
|
|
99
137
|
export declare function cellText(raw: unknown, kind: "chart" | "table", decimal?: "." | ","): string;
|
|
100
|
-
/**
|
|
101
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Find the data a path points at (`…chart`, `…chart.data`, `…table`). Throws `grid-target-not-found`, `table-not-found`, `chart-data-source` or
|
|
140
|
+
* `dataset-unavailable`. For a chart or table that shows a shared dataset, `data` is the dataset, `dataParts` is `["datasets", id]` and `dataset`
|
|
141
|
+
* says which columns `fields` selects (`indices`, into the dataset's own columns) and where the reference is (`refParts`).
|
|
142
|
+
*/
|
|
143
|
+
export declare function locateGridData(document: unknown, path: string | string[]): {
|
|
144
|
+
kind: "chart" | "table";
|
|
145
|
+
parts: string[];
|
|
146
|
+
dataParts: string[];
|
|
147
|
+
data: Record<string, unknown>;
|
|
148
|
+
chartType?: string;
|
|
149
|
+
owner: Record<string, unknown>;
|
|
150
|
+
dataset?: { id: string; fields?: string[]; indices: number[]; refParts: string[]; ref: Record<string, unknown> };
|
|
151
|
+
};
|
|
102
152
|
/** The chart or table a selection path belongs to, or undefined. */
|
|
103
153
|
export declare function resolveDataGridTarget(document: unknown, selectedPath: string): DataGridTarget | undefined;
|
|
104
154
|
/** The grid view of a chart or table: lines of cells with spans, covered positions, text, warnings. */
|
|
@@ -121,6 +171,27 @@ export declare function prepareMoveColumns(document: unknown, path: string, from
|
|
|
121
171
|
export declare function prepareSortRows(document: unknown, path: string, column: number, options?: GridSortOptions): PreparedGridChange;
|
|
122
172
|
export declare function prepareSetHeader(document: unknown, path: string, enabled: boolean, options?: { use?: "first-row" | "new" }): PreparedGridChange;
|
|
123
173
|
export declare function prepareTranspose(document: unknown, path: string): PreparedGridChange;
|
|
174
|
+
/** Why `format` is not a valid number format ("#,##0", "0.0%", "$#,##0.00"), or undefined when it is valid or empty (empty clears the format). */
|
|
175
|
+
export declare function columnFormatError(format: unknown): string | undefined;
|
|
176
|
+
/** Whether the installed core has the RR-54 chart and table data contract (number formats, datasets, strict chart numbers). An older core edits documents that use none of it. */
|
|
177
|
+
export declare const supportsChartTableData: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Set or clear (`null` or "") the number format of column `column` (its header cell). A string header becomes `{ name, format }` and returns to a string
|
|
180
|
+
* when the format is cleared. Throws `number-format-invalid` with the reason, or `grid-no-header` for a table without a header row.
|
|
181
|
+
*/
|
|
182
|
+
export declare function prepareGridColumnFormat(document: unknown, path: string, column: number, format: string | null | undefined, options?: GridOptions): PreparedGridChange;
|
|
183
|
+
/** The columns a chart plots and how they got that role (the chart's `mapping`, or core's positional default). */
|
|
184
|
+
export declare function describeChartMapping(document: unknown, path: string): ChartMappingDescription;
|
|
185
|
+
/**
|
|
186
|
+
* Set a chart's category, X and series columns by name; what `wanted` leaves out keeps its current value. A field that equals the default is not
|
|
187
|
+
* written, and `chart.mapping` is removed when nothing is left. One patch. Throws `chart-mapping-unknown-column`, `chart-mapping-x-unsupported`,
|
|
188
|
+
* `chart-mapping-conflict` or `chart-mapping-no-series`.
|
|
189
|
+
*/
|
|
190
|
+
export declare function prepareChartMapping(document: unknown, path: string, wanted?: ChartMappingColumns): PreparedGridChange;
|
|
191
|
+
/** Replace the chart's or table's dataset reference with its own inline copy of the data. The dataset stays for the other items. One patch. */
|
|
192
|
+
export declare function prepareDetachDataset(document: unknown, path: string): PreparedGridChange;
|
|
193
|
+
/** The charts and tables that use dataset `id`, in document order. */
|
|
194
|
+
export declare function datasetUsage(document: unknown, id: string): Array<{ kind: "chart" | "table"; path: string; parts: string[] }>;
|
|
124
195
|
|
|
125
196
|
export declare function setGridCells(editor: EditorSession, path: string, edits: GridCellEdit[], options?: GridOptions): GridChange;
|
|
126
197
|
export declare function pasteGridText(editor: EditorSession, path: string, anchor: GridAddress, source: string | string[][], options?: GridOptions): GridChange;
|
|
@@ -133,3 +204,9 @@ export declare function moveGridColumns(editor: EditorSession, path: string, fro
|
|
|
133
204
|
export declare function sortGridRows(editor: EditorSession, path: string, column: number, options?: GridSortOptions): GridChange;
|
|
134
205
|
export declare function setGridHeader(editor: EditorSession, path: string, enabled: boolean, options?: { use?: "first-row" | "new"; meta?: Record<string, unknown> }): GridChange;
|
|
135
206
|
export declare function transposeGridData(editor: EditorSession, path: string, options?: { meta?: Record<string, unknown> }): GridChange;
|
|
207
|
+
/** Set (or clear, with `null` or "") a column's number format as one undoable transaction. Throws `number-format-invalid` with the reason. */
|
|
208
|
+
export declare function setGridColumnFormat(editor: EditorSession, path: string, column: number, format: string | null | undefined, options?: GridOptions): GridChange;
|
|
209
|
+
/** Set a chart's category, X and series columns as one undoable transaction. */
|
|
210
|
+
export declare function setChartMapping(editor: EditorSession, path: string, wanted: ChartMappingColumns, options?: GridOptions): GridChange;
|
|
211
|
+
/** Give a chart or table its own copy of a shared dataset's data, as one undoable transaction. */
|
|
212
|
+
export declare function detachGridDataset(editor: EditorSession, path: string, options?: { meta?: Record<string, unknown> }): GridChange;
|