@odoo/o-spreadsheet 16.3.0-alpha.4 → 16.3.0-alpha.5
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/dist/o-spreadsheet.cjs.js +543 -176
- package/dist/o-spreadsheet.d.ts +535 -515
- package/dist/o-spreadsheet.esm.js +544 -177
- package/dist/o-spreadsheet.iife.js +543 -176
- package/dist/o-spreadsheet.iife.min.js +242 -242
- package/package.json +1 -1
package/dist/o-spreadsheet.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _odoo_owl from '@odoo/owl';
|
|
2
|
-
import { ComponentConstructor,
|
|
2
|
+
import { ComponentConstructor, Component } from '@odoo/owl';
|
|
3
3
|
import { ChartConfiguration, ChartData, ChartDataSets, ChartOptions } from 'chart.js';
|
|
4
4
|
|
|
5
5
|
declare enum CellErrorLevel {
|
|
@@ -160,195 +160,129 @@ interface Subscription {
|
|
|
160
160
|
callback: Callback;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
*/
|
|
172
|
-
declare function colorToRGBA(color: Color): RGBA;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Convert a (col) number to the corresponding letter.
|
|
176
|
-
*
|
|
177
|
-
* Examples:
|
|
178
|
-
* 0 => 'A'
|
|
179
|
-
* 25 => 'Z'
|
|
180
|
-
* 26 => 'AA'
|
|
181
|
-
* 27 => 'AB'
|
|
182
|
-
*/
|
|
183
|
-
declare function numberToLetters(n: number): string;
|
|
184
|
-
/**
|
|
185
|
-
* Convert a "XC" coordinate to cartesian coordinates.
|
|
186
|
-
*
|
|
187
|
-
* Examples:
|
|
188
|
-
* A1 => [0,0]
|
|
189
|
-
* B3 => [1,2]
|
|
190
|
-
*
|
|
191
|
-
* Note: it also accepts lowercase coordinates, but not fixed references
|
|
192
|
-
*/
|
|
193
|
-
declare function toCartesian(xc: string): Position$1;
|
|
194
|
-
/**
|
|
195
|
-
* Convert from cartesian coordinate to the "XC" coordinate system.
|
|
196
|
-
*
|
|
197
|
-
* Examples:
|
|
198
|
-
* - 0,0 => A1
|
|
199
|
-
* - 1,2 => B3
|
|
200
|
-
* - 0,0, {colFixed: false, rowFixed: true} => A$1
|
|
201
|
-
* - 1,2, {colFixed: true, rowFixed: false} => $B3
|
|
202
|
-
*/
|
|
203
|
-
declare function toXC(col: HeaderIndex, row: HeaderIndex, rangePart?: RangePart): string;
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Formats a cell value with its format.
|
|
207
|
-
*/
|
|
208
|
-
declare function formatValue(value: CellValue, format?: Format): FormattedValue;
|
|
209
|
-
|
|
210
|
-
declare function computeTextWidth(context: CanvasRenderingContext2D, text: string, style: Style): number;
|
|
211
|
-
declare function isMarkdownLink(str: string): boolean;
|
|
212
|
-
/**
|
|
213
|
-
* Build a markdown link from a label and an url
|
|
214
|
-
*/
|
|
215
|
-
declare function markdownLink(label: string, url: string): string;
|
|
216
|
-
declare function parseMarkdownLink(str: string): {
|
|
217
|
-
url: string;
|
|
218
|
-
label: string;
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* This helper function can be used as a type guard when filtering arrays.
|
|
222
|
-
* const foo: number[] = [1, 2, undefined, 4].filter(isDefined)
|
|
223
|
-
*/
|
|
224
|
-
declare function isDefined<T>(argument: T | undefined): argument is T;
|
|
225
|
-
/**
|
|
226
|
-
* Lazy value computed by the provided function.
|
|
227
|
-
*/
|
|
228
|
-
declare function lazy<T>(fn: (() => T) | T): Lazy<T>;
|
|
229
|
-
|
|
230
|
-
interface ConstructorArgs {
|
|
231
|
-
readonly zone: Readonly<Zone | UnboundedZone>;
|
|
232
|
-
readonly parts: readonly RangePart[];
|
|
233
|
-
readonly invalidXc?: string;
|
|
234
|
-
/** true if the user provided the range with the sheet name */
|
|
235
|
-
readonly prefixSheet: boolean;
|
|
236
|
-
/** the name of any sheet that is invalid */
|
|
237
|
-
readonly invalidSheetName?: string;
|
|
238
|
-
/** the sheet on which the range is defined */
|
|
239
|
-
readonly sheetId: UID;
|
|
240
|
-
}
|
|
241
|
-
declare class RangeImpl implements Range {
|
|
242
|
-
private getSheetSize;
|
|
243
|
-
private readonly _zone;
|
|
244
|
-
readonly parts: Range["parts"];
|
|
245
|
-
readonly invalidXc?: string;
|
|
246
|
-
readonly prefixSheet: boolean;
|
|
247
|
-
readonly sheetId: UID;
|
|
248
|
-
readonly invalidSheetName?: string;
|
|
249
|
-
constructor(args: ConstructorArgs, getSheetSize: (sheetId: UID) => ZoneDimension);
|
|
250
|
-
static fromRange(range: Range, getters: CoreGetters): RangeImpl;
|
|
251
|
-
get unboundedZone(): UnboundedZone;
|
|
252
|
-
get zone(): Zone;
|
|
253
|
-
static getRangeParts(xc: string, zone: UnboundedZone): RangePart[];
|
|
254
|
-
get isFullCol(): boolean;
|
|
255
|
-
get isFullRow(): boolean;
|
|
256
|
-
get rangeData(): RangeData;
|
|
163
|
+
declare class SelectiveHistory<T = unknown> {
|
|
164
|
+
private applyOperation;
|
|
165
|
+
private revertOperation;
|
|
166
|
+
private buildEmpty;
|
|
167
|
+
private readonly buildTransformation;
|
|
168
|
+
private HEAD_BRANCH;
|
|
169
|
+
private HEAD_OPERATION;
|
|
170
|
+
private tree;
|
|
257
171
|
/**
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
172
|
+
* The selective history is a data structure used to register changes/updates of a state.
|
|
173
|
+
* Each change/update is called an "operation".
|
|
174
|
+
* The data structure allows to easily cancel (and redo) any operation individually.
|
|
175
|
+
* An operation can be represented by any data structure. It can be a "command", a "diff", etc.
|
|
176
|
+
* However it must have the following properties:
|
|
177
|
+
* - it can be applied to modify the state
|
|
178
|
+
* - it can be reverted on the state such that it was never executed.
|
|
179
|
+
* - it can be transformed given other operation (Operational Transformation)
|
|
180
|
+
*
|
|
181
|
+
* Since this data structure doesn't know anything about the state nor the structure of
|
|
182
|
+
* operations, the actual work must be performed by external functions given as parameters.
|
|
183
|
+
* @param initialOperationId
|
|
184
|
+
* @param applyOperation a function which can apply an operation to the state
|
|
185
|
+
* @param revertOperation a function which can revert an operation from the state
|
|
186
|
+
* @param buildEmpty a function returning an "empty" operation.
|
|
187
|
+
* i.e an operation that leaves the state unmodified once applied or reverted
|
|
188
|
+
* (used for internal implementation)
|
|
189
|
+
* @param buildTransformation Factory used to build transformations
|
|
261
190
|
*/
|
|
262
|
-
|
|
191
|
+
constructor(initialOperationId: UID, applyOperation: (data: T) => void, revertOperation: (data: T) => void, buildEmpty: (id: UID) => T, buildTransformation: TransformationFactory<T>);
|
|
263
192
|
/**
|
|
264
|
-
*
|
|
265
|
-
* @param rangeParams optional, values to put in the cloned range instead of the current values of the range
|
|
193
|
+
* Return the operation identified by its id.
|
|
266
194
|
*/
|
|
267
|
-
|
|
195
|
+
get(operationId: UID): T;
|
|
196
|
+
/**
|
|
197
|
+
* Append a new operation as the last one
|
|
198
|
+
*/
|
|
199
|
+
append(operationId: UID, data: T): void;
|
|
200
|
+
/**
|
|
201
|
+
* Insert a new operation after a specific operation (may not be the last operation).
|
|
202
|
+
* Following operations will be transformed according
|
|
203
|
+
* to the new operation.
|
|
204
|
+
*/
|
|
205
|
+
insert(operationId: UID, data: T, insertAfter: UID): void;
|
|
206
|
+
/**
|
|
207
|
+
* @param operationId operation to undo
|
|
208
|
+
* @param undoId the id of the "undo operation"
|
|
209
|
+
* @param insertAfter the id of the operation after which to insert the undo
|
|
210
|
+
*/
|
|
211
|
+
undo(operationId: UID, undoId: UID, insertAfter: UID): void;
|
|
212
|
+
/**
|
|
213
|
+
* @param operationId operation to redo
|
|
214
|
+
* @param redoId the if of the "redo operation"
|
|
215
|
+
* @param insertAfter the id of the operation after which to insert the redo
|
|
216
|
+
*/
|
|
217
|
+
redo(operationId: UID, redoId: UID, insertAfter: UID): void;
|
|
218
|
+
drop(operationId: UID): void;
|
|
219
|
+
getRevertedExecution(): T[];
|
|
220
|
+
/**
|
|
221
|
+
* Revert the state as it was *before* the given operation was executed.
|
|
222
|
+
*/
|
|
223
|
+
private revertBefore;
|
|
224
|
+
/**
|
|
225
|
+
* Revert the state as it was *after* the given operation was executed.
|
|
226
|
+
*/
|
|
227
|
+
private revertTo;
|
|
228
|
+
/**
|
|
229
|
+
* Revert an execution
|
|
230
|
+
*/
|
|
231
|
+
private revert;
|
|
232
|
+
/**
|
|
233
|
+
* Replay the operations between the current HEAD_BRANCH and the end of the tree
|
|
234
|
+
*/
|
|
235
|
+
private fastForward;
|
|
268
236
|
}
|
|
269
237
|
|
|
270
|
-
declare
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
238
|
+
declare type ClientId = string;
|
|
239
|
+
interface Client {
|
|
240
|
+
id: ClientId;
|
|
241
|
+
name: string;
|
|
242
|
+
position?: ClientPosition;
|
|
275
243
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
*
|
|
281
|
-
* Examples:
|
|
282
|
-
* "A1" ==> Top 0, Bottom 0, Left: 0, Right: 0
|
|
283
|
-
* "B1:B3" ==> Top 0, Bottom 3, Left: 1, Right: 1
|
|
284
|
-
* "Sheet1!A1" ==> Top 0, Bottom 0, Left: 0, Right: 0
|
|
285
|
-
* "Sheet1!B1:B3" ==> Top 0, Bottom 3, Left: 1, Right: 1
|
|
286
|
-
*
|
|
287
|
-
* @param xc the string reference to convert
|
|
288
|
-
*
|
|
289
|
-
*/
|
|
290
|
-
declare function toZone(xc: string): Zone;
|
|
291
|
-
/**
|
|
292
|
-
* This function will compare the modifications of selection to determine
|
|
293
|
-
* a cell that is part of the new zone and not the previous one.
|
|
294
|
-
*/
|
|
295
|
-
declare function findCellInNewZone(oldZone: Zone, currentZone: Zone): Position$1;
|
|
296
|
-
declare function positionToZone(position: Position$1): {
|
|
297
|
-
left: HeaderIndex;
|
|
298
|
-
right: HeaderIndex;
|
|
299
|
-
top: HeaderIndex;
|
|
300
|
-
bottom: HeaderIndex;
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
interface SelectionEventPayload {
|
|
304
|
-
anchor: AnchorZone;
|
|
305
|
-
previousAnchor: AnchorZone;
|
|
306
|
-
mode: "newAnchor" | "overrideSelection" | "updateAnchor";
|
|
244
|
+
interface ClientPosition {
|
|
245
|
+
sheetId: UID;
|
|
246
|
+
col: HeaderIndex;
|
|
247
|
+
row: HeaderIndex;
|
|
307
248
|
}
|
|
308
|
-
interface
|
|
309
|
-
type: "
|
|
249
|
+
interface RemoteRevisionReceivedEvent {
|
|
250
|
+
type: "remote-revision-received";
|
|
251
|
+
commands: readonly CoreCommand[];
|
|
310
252
|
}
|
|
311
|
-
interface
|
|
312
|
-
type: "
|
|
253
|
+
interface RevisionAcknowledgedEvent {
|
|
254
|
+
type: "revision-acknowledged";
|
|
255
|
+
revisionId: UID;
|
|
313
256
|
}
|
|
314
|
-
interface
|
|
315
|
-
type: "
|
|
257
|
+
interface RevisionUndone {
|
|
258
|
+
type: "revision-undone";
|
|
259
|
+
revisionId: UID;
|
|
260
|
+
commands: readonly CoreCommand[];
|
|
316
261
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
/** this callback will only be called when another consumer captures the stream,
|
|
322
|
-
* not when the current consumer decides to release itself */
|
|
323
|
-
release?: () => void;
|
|
262
|
+
interface RevisionRedone {
|
|
263
|
+
type: "revision-redone";
|
|
264
|
+
revisionId: UID;
|
|
265
|
+
commands: readonly CoreCommand[];
|
|
324
266
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
capture(owner: unknown, state: State, callbacks: StreamCallbacks<Event>): void;
|
|
328
|
-
registerAsDefault: (owner: unknown, state: State, callbacks: StreamCallbacks<Event>) => void;
|
|
329
|
-
resetDefaultAnchor: (owner: unknown, state: State) => void;
|
|
330
|
-
resetAnchor: (owner: unknown, state: State) => void;
|
|
331
|
-
observe: (owner: unknown, callbacks: StreamCallbacks<Event>) => void;
|
|
332
|
-
release: (owner: unknown) => void;
|
|
333
|
-
getBackToDefault(): void;
|
|
334
|
-
};
|
|
335
|
-
/**
|
|
336
|
-
* Allows to select cells in the grid and update the selection
|
|
337
|
-
*/
|
|
338
|
-
interface SelectionProcessor {
|
|
339
|
-
selectZone(anchor: AnchorZone): DispatchResult;
|
|
340
|
-
selectCell(col: number, row: number): DispatchResult;
|
|
341
|
-
moveAnchorCell(direction: SelectionDirection, step: SelectionStep): DispatchResult;
|
|
342
|
-
setAnchorCorner(col: number, row: number): DispatchResult;
|
|
343
|
-
addCellToSelection(col: number, row: number): DispatchResult;
|
|
344
|
-
resizeAnchorZone(direction: SelectionDirection, step: SelectionStep): DispatchResult;
|
|
345
|
-
selectColumn(index: number, mode: SelectionEvent["mode"]): DispatchResult;
|
|
346
|
-
selectRow(index: number, mode: SelectionEvent["mode"]): DispatchResult;
|
|
347
|
-
selectAll(): DispatchResult;
|
|
348
|
-
loopSelection(): DispatchResult;
|
|
349
|
-
selectTableAroundSelection(): DispatchResult;
|
|
267
|
+
interface CollaborativeEventReceived {
|
|
268
|
+
type: "collaborative-event-received";
|
|
350
269
|
}
|
|
351
|
-
|
|
270
|
+
interface UnexpectedRevisionIdEvent {
|
|
271
|
+
type: "unexpected-revision-id";
|
|
272
|
+
revisionId: UID;
|
|
273
|
+
}
|
|
274
|
+
interface NewLocalStateUpdateEvent {
|
|
275
|
+
type: "new-local-state-update";
|
|
276
|
+
id: UID;
|
|
277
|
+
}
|
|
278
|
+
interface RevisionsDroppedEvent {
|
|
279
|
+
type: "pending-revisions-dropped";
|
|
280
|
+
revisionIds: UID[];
|
|
281
|
+
}
|
|
282
|
+
interface SnapshotEvent {
|
|
283
|
+
type: "snapshot";
|
|
284
|
+
}
|
|
285
|
+
declare type CollaborativeEvent = NewLocalStateUpdateEvent | UnexpectedRevisionIdEvent | RemoteRevisionReceivedEvent | RevisionAcknowledgedEvent | RevisionUndone | RevisionRedone | RevisionsDroppedEvent | SnapshotEvent | CollaborativeEventReceived;
|
|
352
286
|
|
|
353
287
|
declare type XLSXExportFile = XLSXExportImageFile | XLSXExportXMLFile;
|
|
354
288
|
interface XLSXExportXMLFile {
|
|
@@ -725,140 +659,392 @@ interface ExcelFilterData {
|
|
|
725
659
|
filteredValues: string[];
|
|
726
660
|
}
|
|
727
661
|
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
id: ClientId;
|
|
731
|
-
name: string;
|
|
732
|
-
position?: ClientPosition;
|
|
733
|
-
}
|
|
734
|
-
interface ClientPosition {
|
|
735
|
-
sheetId: UID;
|
|
736
|
-
col: HeaderIndex;
|
|
737
|
-
row: HeaderIndex;
|
|
662
|
+
interface AbstractMessage {
|
|
663
|
+
version: number;
|
|
738
664
|
}
|
|
739
|
-
interface
|
|
740
|
-
type: "
|
|
665
|
+
interface RemoteRevisionMessage extends AbstractMessage {
|
|
666
|
+
type: "REMOTE_REVISION";
|
|
667
|
+
clientId: ClientId;
|
|
741
668
|
commands: readonly CoreCommand[];
|
|
669
|
+
nextRevisionId: UID;
|
|
670
|
+
serverRevisionId: UID;
|
|
742
671
|
}
|
|
743
|
-
interface
|
|
744
|
-
type: "
|
|
745
|
-
|
|
672
|
+
interface RevisionUndoneMessage extends AbstractMessage {
|
|
673
|
+
type: "REVISION_UNDONE";
|
|
674
|
+
undoneRevisionId: UID;
|
|
675
|
+
nextRevisionId: UID;
|
|
676
|
+
serverRevisionId: UID;
|
|
746
677
|
}
|
|
747
|
-
interface
|
|
748
|
-
type: "
|
|
749
|
-
|
|
750
|
-
|
|
678
|
+
interface RevisionRedoneMessage extends AbstractMessage {
|
|
679
|
+
type: "REVISION_REDONE";
|
|
680
|
+
redoneRevisionId: UID;
|
|
681
|
+
nextRevisionId: UID;
|
|
682
|
+
serverRevisionId: UID;
|
|
751
683
|
}
|
|
752
|
-
interface
|
|
753
|
-
type: "
|
|
754
|
-
|
|
755
|
-
commands: readonly CoreCommand[];
|
|
684
|
+
interface ClientJoinedMessage extends AbstractMessage {
|
|
685
|
+
type: "CLIENT_JOINED";
|
|
686
|
+
client: Required<Client>;
|
|
756
687
|
}
|
|
757
|
-
interface
|
|
758
|
-
type: "
|
|
688
|
+
interface ClientLeftMessage extends AbstractMessage {
|
|
689
|
+
type: "CLIENT_LEFT";
|
|
690
|
+
clientId: ClientId;
|
|
759
691
|
}
|
|
760
|
-
interface
|
|
761
|
-
type: "
|
|
762
|
-
|
|
692
|
+
interface ClientMovedMessage extends AbstractMessage {
|
|
693
|
+
type: "CLIENT_MOVED";
|
|
694
|
+
client: Required<Client>;
|
|
763
695
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
696
|
+
/**
|
|
697
|
+
* Send a snapshot of the spreadsheet to the collaborative server
|
|
698
|
+
*/
|
|
699
|
+
interface SnapshotMessage extends AbstractMessage {
|
|
700
|
+
type: "SNAPSHOT";
|
|
701
|
+
data: WorkbookData;
|
|
702
|
+
serverRevisionId: UID;
|
|
703
|
+
nextRevisionId: UID;
|
|
767
704
|
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
705
|
+
/**
|
|
706
|
+
* Notify all clients that the server has a new snapshot of the
|
|
707
|
+
* spreadsheet and that the previous history may be lost.
|
|
708
|
+
*/
|
|
709
|
+
interface SnapshotCreatedMessage extends AbstractMessage {
|
|
710
|
+
type: "SNAPSHOT_CREATED";
|
|
711
|
+
serverRevisionId: UID;
|
|
712
|
+
nextRevisionId: UID;
|
|
771
713
|
}
|
|
772
|
-
|
|
773
|
-
|
|
714
|
+
declare type CollaborationMessage = RevisionUndoneMessage | RevisionRedoneMessage | RemoteRevisionMessage | SnapshotMessage | SnapshotCreatedMessage | ClientMovedMessage | ClientJoinedMessage | ClientLeftMessage;
|
|
715
|
+
declare type StateUpdateMessage = Extract<CollaborationMessage, {
|
|
716
|
+
nextRevisionId: UID;
|
|
717
|
+
}>;
|
|
718
|
+
declare type NewMessageCallback<T = any> = (message: T) => void;
|
|
719
|
+
/**
|
|
720
|
+
* The transport service allows to communicate between multiple clients.
|
|
721
|
+
* A client can send any message to others.
|
|
722
|
+
* The service will handle all networking details internally.
|
|
723
|
+
*/
|
|
724
|
+
interface TransportService<T = any> {
|
|
725
|
+
/**
|
|
726
|
+
* Send a message to all clients
|
|
727
|
+
*/
|
|
728
|
+
sendMessage: (message: T) => void;
|
|
729
|
+
/**
|
|
730
|
+
* Register a callback function which will be called each time
|
|
731
|
+
* a new message is received.
|
|
732
|
+
* The new message is given to the callback.
|
|
733
|
+
*
|
|
734
|
+
* ```js
|
|
735
|
+
* transportService.onNewMessage(id, (message) => {
|
|
736
|
+
* // ... handle the new message
|
|
737
|
+
* })
|
|
738
|
+
* ```
|
|
739
|
+
* The `id` is used to unregister this callback when the session is closed.
|
|
740
|
+
*/
|
|
741
|
+
onNewMessage: (id: UID, callback: NewMessageCallback<T>) => void;
|
|
742
|
+
/**
|
|
743
|
+
* Unregister a callback linked to the given id
|
|
744
|
+
*/
|
|
745
|
+
leave: (id: UID) => void;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
declare class Revision implements RevisionData {
|
|
749
|
+
readonly rootCommand?: "SNAPSHOT" | Command | "REMOTE" | undefined;
|
|
750
|
+
readonly id: UID;
|
|
751
|
+
readonly clientId: ClientId;
|
|
752
|
+
private _commands;
|
|
753
|
+
private _changes;
|
|
754
|
+
/**
|
|
755
|
+
* A revision represents a whole client action (Create a sheet, merge a Zone, Undo, ...).
|
|
756
|
+
* A revision contains the following information:
|
|
757
|
+
* - id: ID of the revision
|
|
758
|
+
* - commands: CoreCommands that are linked to the action, and should be
|
|
759
|
+
* dispatched in other clients
|
|
760
|
+
* - clientId: Client who initiated the action
|
|
761
|
+
* - changes: List of changes applied on the state.
|
|
762
|
+
*/
|
|
763
|
+
constructor(id: UID, clientId: ClientId, commands: readonly CoreCommand[], rootCommand?: "SNAPSHOT" | Command | "REMOTE" | undefined, changes?: readonly HistoryChange[]);
|
|
764
|
+
setChanges(changes: readonly HistoryChange[]): void;
|
|
765
|
+
get commands(): readonly CoreCommand[];
|
|
766
|
+
get changes(): readonly HistoryChange[];
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
declare class Session extends EventBus<CollaborativeEvent> {
|
|
770
|
+
private revisions;
|
|
771
|
+
private transportService;
|
|
772
|
+
private serverRevisionId;
|
|
773
|
+
/**
|
|
774
|
+
* Positions of the others client.
|
|
775
|
+
*/
|
|
776
|
+
private clients;
|
|
777
|
+
private clientId;
|
|
778
|
+
/**
|
|
779
|
+
* Id of the server revision
|
|
780
|
+
*/
|
|
781
|
+
private debouncedMove;
|
|
782
|
+
private pendingMessages;
|
|
783
|
+
private waitingAck;
|
|
784
|
+
/**
|
|
785
|
+
* Flag used to block all commands when an undo or redo is triggered, until
|
|
786
|
+
* it is accepted on the server
|
|
787
|
+
*/
|
|
788
|
+
private waitingUndoRedoAck;
|
|
789
|
+
private isReplayingInitialRevisions;
|
|
790
|
+
private processedRevisions;
|
|
791
|
+
private uuidGenerator;
|
|
792
|
+
/**
|
|
793
|
+
* Manages the collaboration between multiple users on the same spreadsheet.
|
|
794
|
+
* It can forward local state changes to other users to ensure they all eventually
|
|
795
|
+
* reach the same state.
|
|
796
|
+
* It also manages the positions of each clients in the spreadsheet to provide
|
|
797
|
+
* a visual indication of what other users are doing in the spreadsheet.
|
|
798
|
+
*
|
|
799
|
+
* @param revisions
|
|
800
|
+
* @param transportService communication channel used to send and receive messages
|
|
801
|
+
* between all connected clients
|
|
802
|
+
* @param client the client connected locally
|
|
803
|
+
* @param serverRevisionId
|
|
804
|
+
*/
|
|
805
|
+
constructor(revisions: SelectiveHistory<Revision>, transportService: TransportService<CollaborationMessage>, serverRevisionId?: UID);
|
|
806
|
+
canApplyOptimisticUpdate(): boolean;
|
|
807
|
+
/**
|
|
808
|
+
* Add a new revision to the collaborative session.
|
|
809
|
+
* It will be transmitted to all other connected clients.
|
|
810
|
+
*/
|
|
811
|
+
save(rootCommand: Command, commands: CoreCommand[], changes: HistoryChange[]): void;
|
|
812
|
+
undo(revisionId: UID): void;
|
|
813
|
+
redo(revisionId: UID): void;
|
|
814
|
+
/**
|
|
815
|
+
* Notify that the position of the client has changed
|
|
816
|
+
*/
|
|
817
|
+
move(position: ClientPosition): void;
|
|
818
|
+
join(client?: Client): void;
|
|
819
|
+
loadInitialMessages(messages: StateUpdateMessage[]): void;
|
|
820
|
+
/**
|
|
821
|
+
* Notify the server that the user client left the collaborative session
|
|
822
|
+
*/
|
|
823
|
+
leave(): void;
|
|
824
|
+
/**
|
|
825
|
+
* Send a snapshot of the spreadsheet to the collaboration server
|
|
826
|
+
*/
|
|
827
|
+
snapshot(data: WorkbookData): void;
|
|
828
|
+
getClient(): Client;
|
|
829
|
+
getConnectedClients(): Set<Client>;
|
|
830
|
+
getRevisionId(): UID;
|
|
831
|
+
isFullySynchronized(): boolean;
|
|
832
|
+
/**
|
|
833
|
+
* Get the last local revision whose root command isn't in the given list of ignored commands
|
|
834
|
+
* */
|
|
835
|
+
getLastLocalNonEmptyRevision(ignoredRootCommands: CommandTypes[]): Revision | undefined;
|
|
836
|
+
private _move;
|
|
837
|
+
/**
|
|
838
|
+
* Handles messages received from other clients in the collaborative
|
|
839
|
+
* session.
|
|
840
|
+
*/
|
|
841
|
+
private onMessageReceived;
|
|
842
|
+
private onClientMoved;
|
|
843
|
+
/**
|
|
844
|
+
* Register the new client and send your
|
|
845
|
+
* own position back.
|
|
846
|
+
*/
|
|
847
|
+
private onClientJoined;
|
|
848
|
+
private onClientLeft;
|
|
849
|
+
private sendUpdateMessage;
|
|
850
|
+
/**
|
|
851
|
+
* Send the next pending message
|
|
852
|
+
*/
|
|
853
|
+
private sendPendingMessage;
|
|
854
|
+
private acknowledge;
|
|
855
|
+
private isAlreadyProcessed;
|
|
856
|
+
private dropPendingHistoryMessages;
|
|
774
857
|
}
|
|
775
|
-
declare type CollaborativeEvent = NewLocalStateUpdateEvent | UnexpectedRevisionIdEvent | RemoteRevisionReceivedEvent | RevisionAcknowledgedEvent | RevisionUndone | RevisionRedone | RevisionsDroppedEvent | SnapshotEvent | CollaborativeEventReceived;
|
|
776
858
|
|
|
777
|
-
interface AbstractMessage {
|
|
778
|
-
version: number;
|
|
779
|
-
}
|
|
780
|
-
interface RemoteRevisionMessage extends AbstractMessage {
|
|
781
|
-
type: "REMOTE_REVISION";
|
|
782
|
-
clientId: ClientId;
|
|
783
|
-
commands: readonly CoreCommand[];
|
|
784
|
-
nextRevisionId: UID;
|
|
785
|
-
serverRevisionId: UID;
|
|
786
|
-
}
|
|
787
|
-
interface RevisionUndoneMessage extends AbstractMessage {
|
|
788
|
-
type: "REVISION_UNDONE";
|
|
789
|
-
undoneRevisionId: UID;
|
|
790
|
-
nextRevisionId: UID;
|
|
791
|
-
serverRevisionId: UID;
|
|
792
|
-
}
|
|
793
|
-
interface RevisionRedoneMessage extends AbstractMessage {
|
|
794
|
-
type: "REVISION_REDONE";
|
|
795
|
-
redoneRevisionId: UID;
|
|
796
|
-
nextRevisionId: UID;
|
|
797
|
-
serverRevisionId: UID;
|
|
798
|
-
}
|
|
799
|
-
interface ClientJoinedMessage extends AbstractMessage {
|
|
800
|
-
type: "CLIENT_JOINED";
|
|
801
|
-
client: Required<Client>;
|
|
802
|
-
}
|
|
803
|
-
interface ClientLeftMessage extends AbstractMessage {
|
|
804
|
-
type: "CLIENT_LEFT";
|
|
805
|
-
clientId: ClientId;
|
|
806
|
-
}
|
|
807
|
-
interface ClientMovedMessage extends AbstractMessage {
|
|
808
|
-
type: "CLIENT_MOVED";
|
|
809
|
-
client: Required<Client>;
|
|
810
|
-
}
|
|
811
859
|
/**
|
|
812
|
-
*
|
|
860
|
+
* RGBA to HEX representation (#RRGGBBAA).
|
|
861
|
+
*
|
|
862
|
+
* https://css-tricks.com/converting-color-spaces-in-javascript/
|
|
813
863
|
*/
|
|
814
|
-
|
|
815
|
-
type: "SNAPSHOT";
|
|
816
|
-
data: WorkbookData;
|
|
817
|
-
serverRevisionId: UID;
|
|
818
|
-
nextRevisionId: UID;
|
|
819
|
-
}
|
|
864
|
+
declare function rgbaToHex(rgba: RGBA): Color;
|
|
820
865
|
/**
|
|
821
|
-
*
|
|
822
|
-
* spreadsheet and that the previous history may be lost.
|
|
866
|
+
* Color string to RGBA representation
|
|
823
867
|
*/
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
serverRevisionId: UID;
|
|
827
|
-
nextRevisionId: UID;
|
|
828
|
-
}
|
|
829
|
-
declare type CollaborationMessage = RevisionUndoneMessage | RevisionRedoneMessage | RemoteRevisionMessage | SnapshotMessage | SnapshotCreatedMessage | ClientMovedMessage | ClientJoinedMessage | ClientLeftMessage;
|
|
830
|
-
declare type StateUpdateMessage = Extract<CollaborationMessage, {
|
|
831
|
-
nextRevisionId: UID;
|
|
832
|
-
}>;
|
|
833
|
-
declare type NewMessageCallback<T = any> = (message: T) => void;
|
|
868
|
+
declare function colorToRGBA(color: Color): RGBA;
|
|
869
|
+
|
|
834
870
|
/**
|
|
835
|
-
*
|
|
836
|
-
*
|
|
837
|
-
*
|
|
871
|
+
* Convert a (col) number to the corresponding letter.
|
|
872
|
+
*
|
|
873
|
+
* Examples:
|
|
874
|
+
* 0 => 'A'
|
|
875
|
+
* 25 => 'Z'
|
|
876
|
+
* 26 => 'AA'
|
|
877
|
+
* 27 => 'AB'
|
|
838
878
|
*/
|
|
839
|
-
|
|
879
|
+
declare function numberToLetters(n: number): string;
|
|
880
|
+
/**
|
|
881
|
+
* Convert a "XC" coordinate to cartesian coordinates.
|
|
882
|
+
*
|
|
883
|
+
* Examples:
|
|
884
|
+
* A1 => [0,0]
|
|
885
|
+
* B3 => [1,2]
|
|
886
|
+
*
|
|
887
|
+
* Note: it also accepts lowercase coordinates, but not fixed references
|
|
888
|
+
*/
|
|
889
|
+
declare function toCartesian(xc: string): Position$1;
|
|
890
|
+
/**
|
|
891
|
+
* Convert from cartesian coordinate to the "XC" coordinate system.
|
|
892
|
+
*
|
|
893
|
+
* Examples:
|
|
894
|
+
* - 0,0 => A1
|
|
895
|
+
* - 1,2 => B3
|
|
896
|
+
* - 0,0, {colFixed: false, rowFixed: true} => A$1
|
|
897
|
+
* - 1,2, {colFixed: true, rowFixed: false} => $B3
|
|
898
|
+
*/
|
|
899
|
+
declare function toXC(col: HeaderIndex, row: HeaderIndex, rangePart?: RangePart): string;
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Formats a cell value with its format.
|
|
903
|
+
*/
|
|
904
|
+
declare function formatValue(value: CellValue, format?: Format): FormattedValue;
|
|
905
|
+
|
|
906
|
+
declare function computeTextWidth(context: CanvasRenderingContext2D, text: string, style: Style): number;
|
|
907
|
+
declare function isMarkdownLink(str: string): boolean;
|
|
908
|
+
/**
|
|
909
|
+
* Build a markdown link from a label and an url
|
|
910
|
+
*/
|
|
911
|
+
declare function markdownLink(label: string, url: string): string;
|
|
912
|
+
declare function parseMarkdownLink(str: string): {
|
|
913
|
+
url: string;
|
|
914
|
+
label: string;
|
|
915
|
+
};
|
|
916
|
+
/**
|
|
917
|
+
* This helper function can be used as a type guard when filtering arrays.
|
|
918
|
+
* const foo: number[] = [1, 2, undefined, 4].filter(isDefined)
|
|
919
|
+
*/
|
|
920
|
+
declare function isDefined<T>(argument: T | undefined): argument is T;
|
|
921
|
+
/**
|
|
922
|
+
* Lazy value computed by the provided function.
|
|
923
|
+
*/
|
|
924
|
+
declare function lazy<T>(fn: (() => T) | T): Lazy<T>;
|
|
925
|
+
|
|
926
|
+
interface ConstructorArgs {
|
|
927
|
+
readonly zone: Readonly<Zone | UnboundedZone>;
|
|
928
|
+
readonly parts: readonly RangePart[];
|
|
929
|
+
readonly invalidXc?: string;
|
|
930
|
+
/** true if the user provided the range with the sheet name */
|
|
931
|
+
readonly prefixSheet: boolean;
|
|
932
|
+
/** the name of any sheet that is invalid */
|
|
933
|
+
readonly invalidSheetName?: string;
|
|
934
|
+
/** the sheet on which the range is defined */
|
|
935
|
+
readonly sheetId: UID;
|
|
936
|
+
}
|
|
937
|
+
declare class RangeImpl implements Range {
|
|
938
|
+
private getSheetSize;
|
|
939
|
+
private readonly _zone;
|
|
940
|
+
readonly parts: Range["parts"];
|
|
941
|
+
readonly invalidXc?: string;
|
|
942
|
+
readonly prefixSheet: boolean;
|
|
943
|
+
readonly sheetId: UID;
|
|
944
|
+
readonly invalidSheetName?: string;
|
|
945
|
+
constructor(args: ConstructorArgs, getSheetSize: (sheetId: UID) => ZoneDimension);
|
|
946
|
+
static fromRange(range: Range, getters: CoreGetters): RangeImpl;
|
|
947
|
+
get unboundedZone(): UnboundedZone;
|
|
948
|
+
get zone(): Zone;
|
|
949
|
+
static getRangeParts(xc: string, zone: UnboundedZone): RangePart[];
|
|
950
|
+
get isFullCol(): boolean;
|
|
951
|
+
get isFullRow(): boolean;
|
|
952
|
+
get rangeData(): RangeData;
|
|
840
953
|
/**
|
|
841
|
-
*
|
|
954
|
+
* Check that a zone is valid regarding the order of top-bottom and left-right.
|
|
955
|
+
* Left should be smaller than right, top should be smaller than bottom.
|
|
956
|
+
* If it's not the case, simply invert them, and invert the linked parts
|
|
842
957
|
*/
|
|
843
|
-
|
|
958
|
+
orderZone(): RangeImpl;
|
|
844
959
|
/**
|
|
845
|
-
* Register a callback function which will be called each time
|
|
846
|
-
* a new message is received.
|
|
847
|
-
* The new message is given to the callback.
|
|
848
960
|
*
|
|
849
|
-
*
|
|
850
|
-
* transportService.onNewMessage(id, (message) => {
|
|
851
|
-
* // ... handle the new message
|
|
852
|
-
* })
|
|
853
|
-
* ```
|
|
854
|
-
* The `id` is used to unregister this callback when the session is closed.
|
|
855
|
-
*/
|
|
856
|
-
onNewMessage: (id: UID, callback: NewMessageCallback<T>) => void;
|
|
857
|
-
/**
|
|
858
|
-
* Unregister a callback linked to the given id
|
|
961
|
+
* @param rangeParams optional, values to put in the cloned range instead of the current values of the range
|
|
859
962
|
*/
|
|
860
|
-
|
|
963
|
+
clone(rangeParams?: Partial<ConstructorArgs>): RangeImpl;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
declare class UuidGenerator {
|
|
967
|
+
private isFastIdStrategy;
|
|
968
|
+
private fastIdStart;
|
|
969
|
+
setIsFastStrategy(isFast: boolean): void;
|
|
970
|
+
uuidv4(): string;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* Convert from a cartesian reference to a Zone.
|
|
975
|
+
* Will return throw an error if given a unbounded zone (eg : A:A).
|
|
976
|
+
*
|
|
977
|
+
* Examples:
|
|
978
|
+
* "A1" ==> Top 0, Bottom 0, Left: 0, Right: 0
|
|
979
|
+
* "B1:B3" ==> Top 0, Bottom 3, Left: 1, Right: 1
|
|
980
|
+
* "Sheet1!A1" ==> Top 0, Bottom 0, Left: 0, Right: 0
|
|
981
|
+
* "Sheet1!B1:B3" ==> Top 0, Bottom 3, Left: 1, Right: 1
|
|
982
|
+
*
|
|
983
|
+
* @param xc the string reference to convert
|
|
984
|
+
*
|
|
985
|
+
*/
|
|
986
|
+
declare function toZone(xc: string): Zone;
|
|
987
|
+
/**
|
|
988
|
+
* This function will compare the modifications of selection to determine
|
|
989
|
+
* a cell that is part of the new zone and not the previous one.
|
|
990
|
+
*/
|
|
991
|
+
declare function findCellInNewZone(oldZone: Zone, currentZone: Zone): Position$1;
|
|
992
|
+
declare function positionToZone(position: Position$1): {
|
|
993
|
+
left: HeaderIndex;
|
|
994
|
+
right: HeaderIndex;
|
|
995
|
+
top: HeaderIndex;
|
|
996
|
+
bottom: HeaderIndex;
|
|
997
|
+
};
|
|
998
|
+
|
|
999
|
+
interface SelectionEventPayload {
|
|
1000
|
+
anchor: AnchorZone;
|
|
1001
|
+
previousAnchor: AnchorZone;
|
|
1002
|
+
mode: "newAnchor" | "overrideSelection" | "updateAnchor";
|
|
1003
|
+
}
|
|
1004
|
+
interface ZonesSelected extends SelectionEventPayload {
|
|
1005
|
+
type: "ZonesSelected";
|
|
1006
|
+
}
|
|
1007
|
+
interface HeadersSelected extends SelectionEventPayload {
|
|
1008
|
+
type: "HeadersSelected";
|
|
1009
|
+
}
|
|
1010
|
+
interface AlterZone extends SelectionEventPayload {
|
|
1011
|
+
type: "AlterZone";
|
|
1012
|
+
}
|
|
1013
|
+
declare type SelectionEvent = Readonly<ZonesSelected | HeadersSelected | AlterZone>;
|
|
1014
|
+
|
|
1015
|
+
interface StreamCallbacks<Event> {
|
|
1016
|
+
handleEvent: (event: Event) => void;
|
|
1017
|
+
/** this callback will only be called when another consumer captures the stream,
|
|
1018
|
+
* not when the current consumer decides to release itself */
|
|
1019
|
+
release?: () => void;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
declare type StatefulStream<Event, State> = {
|
|
1023
|
+
capture(owner: unknown, state: State, callbacks: StreamCallbacks<Event>): void;
|
|
1024
|
+
registerAsDefault: (owner: unknown, state: State, callbacks: StreamCallbacks<Event>) => void;
|
|
1025
|
+
resetDefaultAnchor: (owner: unknown, state: State) => void;
|
|
1026
|
+
resetAnchor: (owner: unknown, state: State) => void;
|
|
1027
|
+
observe: (owner: unknown, callbacks: StreamCallbacks<Event>) => void;
|
|
1028
|
+
release: (owner: unknown) => void;
|
|
1029
|
+
getBackToDefault(): void;
|
|
1030
|
+
};
|
|
1031
|
+
/**
|
|
1032
|
+
* Allows to select cells in the grid and update the selection
|
|
1033
|
+
*/
|
|
1034
|
+
interface SelectionProcessor {
|
|
1035
|
+
selectZone(anchor: AnchorZone): DispatchResult;
|
|
1036
|
+
selectCell(col: number, row: number): DispatchResult;
|
|
1037
|
+
moveAnchorCell(direction: SelectionDirection, step: SelectionStep): DispatchResult;
|
|
1038
|
+
setAnchorCorner(col: number, row: number): DispatchResult;
|
|
1039
|
+
addCellToSelection(col: number, row: number): DispatchResult;
|
|
1040
|
+
resizeAnchorZone(direction: SelectionDirection, step: SelectionStep): DispatchResult;
|
|
1041
|
+
selectColumn(index: number, mode: SelectionEvent["mode"]): DispatchResult;
|
|
1042
|
+
selectRow(index: number, mode: SelectionEvent["mode"]): DispatchResult;
|
|
1043
|
+
selectAll(): DispatchResult;
|
|
1044
|
+
loopSelection(): DispatchResult;
|
|
1045
|
+
selectTableAroundSelection(): DispatchResult;
|
|
861
1046
|
}
|
|
1047
|
+
declare type SelectionStreamProcessor = SelectionProcessor & StatefulStream<SelectionEvent, AnchorZone>;
|
|
862
1048
|
|
|
863
1049
|
declare type FilePath = string;
|
|
864
1050
|
/**
|
|
@@ -944,7 +1130,6 @@ declare class Model extends EventBus<any> implements CommandDispatcher {
|
|
|
944
1130
|
private featurePlugins;
|
|
945
1131
|
private statefulUIPlugins;
|
|
946
1132
|
private coreViewsPlugins;
|
|
947
|
-
private history;
|
|
948
1133
|
private range;
|
|
949
1134
|
private session;
|
|
950
1135
|
/**
|
|
@@ -984,10 +1169,9 @@ declare class Model extends EventBus<any> implements CommandDispatcher {
|
|
|
984
1169
|
*/
|
|
985
1170
|
private coreGetters;
|
|
986
1171
|
uuidGenerator: UuidGenerator;
|
|
1172
|
+
private readonly handlers;
|
|
1173
|
+
private readonly coreHandlers;
|
|
987
1174
|
constructor(data?: any, config?: Partial<ModelConfig>, stateUpdateMessages?: StateUpdateMessage[], uuidGenerator?: UuidGenerator, verboseImport?: boolean);
|
|
988
|
-
get handlers(): CommandHandler<Command>[];
|
|
989
|
-
get coreHandlers(): CommandHandler<Command>[];
|
|
990
|
-
get allUIPlugins(): UIPlugin[];
|
|
991
1175
|
joinSession(): void;
|
|
992
1176
|
leaveSession(): void;
|
|
993
1177
|
private setupUiPlugin;
|
|
@@ -1172,6 +1356,7 @@ interface UIPluginConfig {
|
|
|
1172
1356
|
readonly uiActions: UIActions;
|
|
1173
1357
|
readonly custom: ModelConfig["custom"];
|
|
1174
1358
|
readonly lazyEvaluation: boolean;
|
|
1359
|
+
readonly session: Session;
|
|
1175
1360
|
}
|
|
1176
1361
|
interface UIPluginConstructor {
|
|
1177
1362
|
new (config: UIPluginConfig): UIPlugin;
|
|
@@ -1476,8 +1661,8 @@ interface PositionDependentCommand {
|
|
|
1476
1661
|
col: number;
|
|
1477
1662
|
row: number;
|
|
1478
1663
|
}
|
|
1479
|
-
declare const invalidateEvaluationCommands: Set<"UPDATE_CELL" | "UPDATE_CELL_POSITION" | "CLEAR_CELL" | "DELETE_CONTENT" | "ADD_COLUMNS_ROWS" | "REMOVE_COLUMNS_ROWS" | "RESIZE_COLUMNS_ROWS" | "HIDE_COLUMNS_ROWS" | "UNHIDE_COLUMNS_ROWS" | "SET_GRID_LINES_VISIBILITY" | "FREEZE_COLUMNS" | "FREEZE_ROWS" | "UNFREEZE_COLUMNS_ROWS" | "UNFREEZE_COLUMNS" | "UNFREEZE_ROWS" | "ADD_MERGE" | "REMOVE_MERGE" | "CREATE_SHEET" | "DELETE_SHEET" | "DUPLICATE_SHEET" | "MOVE_SHEET" | "RENAME_SHEET" | "HIDE_SHEET" | "SHOW_SHEET" | "MOVE_RANGES" | "ADD_CONDITIONAL_FORMAT" | "REMOVE_CONDITIONAL_FORMAT" | "MOVE_CONDITIONAL_FORMAT" | "CREATE_FIGURE" | "DELETE_FIGURE" | "UPDATE_FIGURE" | "SET_FORMATTING" | "CLEAR_FORMATTING" | "SET_BORDER" | "CREATE_CHART" | "UPDATE_CHART" | "CREATE_IMAGE" | "CREATE_FILTER_TABLE" | "REMOVE_FILTER_TABLE" | "REQUEST_UNDO" | "REQUEST_REDO" | "UNDO" | "REDO" | "ENABLE_NEW_SELECTION_INPUT" | "DISABLE_SELECTION_INPUT" | "UNFOCUS_SELECTION_INPUT" | "FOCUS_RANGE" | "ADD_EMPTY_RANGE" | "REMOVE_RANGE" | "CHANGE_RANGE" | "COPY" | "CUT" | "PASTE" | "CLEAN_CLIPBOARD_HIGHLIGHT" | "AUTOFILL_CELL" | "PASTE_FROM_OS_CLIPBOARD" | "ACTIVATE_PAINT_FORMAT" | "PASTE_CONDITIONAL_FORMAT" | "AUTORESIZE_COLUMNS" | "AUTORESIZE_ROWS" | "MOVE_COLUMNS_ROWS" | "ACTIVATE_SHEET" | "PREPARE_SELECTION_INPUT_EXPANSION" | "STOP_SELECTION_INPUT" | "EVALUATE_CELLS" | "CHANGE_HIGHLIGHT" | "START_CHANGE_HIGHLIGHT" | "SET_HIGHLIGHT_COLOR" | "STOP_COMPOSER_RANGE_SELECTION" | "START_EDITION" | "STOP_EDITION" | "SET_CURRENT_CONTENT" | "CHANGE_COMPOSER_CURSOR_SELECTION" | "REPLACE_COMPOSER_CURSOR_SELECTION" | "CYCLE_EDITION_REFERENCES" | "START" | "AUTOFILL" | "AUTOFILL_SELECT" | "SET_FORMULA_VISIBILITY" | "AUTOFILL_AUTO" | "SELECT_FIGURE" | "UPDATE_SEARCH" | "REFRESH_SEARCH" | "CLEAR_SEARCH" | "SELECT_SEARCH_PREVIOUS_MATCH" | "SELECT_SEARCH_NEXT_MATCH" | "REPLACE_SEARCH" | "REPLACE_ALL_SEARCH" | "
|
|
1480
|
-
declare const readonlyAllowedCommands: Set<"UPDATE_CELL" | "UPDATE_CELL_POSITION" | "CLEAR_CELL" | "DELETE_CONTENT" | "ADD_COLUMNS_ROWS" | "REMOVE_COLUMNS_ROWS" | "RESIZE_COLUMNS_ROWS" | "HIDE_COLUMNS_ROWS" | "UNHIDE_COLUMNS_ROWS" | "SET_GRID_LINES_VISIBILITY" | "FREEZE_COLUMNS" | "FREEZE_ROWS" | "UNFREEZE_COLUMNS_ROWS" | "UNFREEZE_COLUMNS" | "UNFREEZE_ROWS" | "ADD_MERGE" | "REMOVE_MERGE" | "CREATE_SHEET" | "DELETE_SHEET" | "DUPLICATE_SHEET" | "MOVE_SHEET" | "RENAME_SHEET" | "HIDE_SHEET" | "SHOW_SHEET" | "MOVE_RANGES" | "ADD_CONDITIONAL_FORMAT" | "REMOVE_CONDITIONAL_FORMAT" | "MOVE_CONDITIONAL_FORMAT" | "CREATE_FIGURE" | "DELETE_FIGURE" | "UPDATE_FIGURE" | "SET_FORMATTING" | "CLEAR_FORMATTING" | "SET_BORDER" | "CREATE_CHART" | "UPDATE_CHART" | "CREATE_IMAGE" | "CREATE_FILTER_TABLE" | "REMOVE_FILTER_TABLE" | "REQUEST_UNDO" | "REQUEST_REDO" | "UNDO" | "REDO" | "ENABLE_NEW_SELECTION_INPUT" | "DISABLE_SELECTION_INPUT" | "UNFOCUS_SELECTION_INPUT" | "FOCUS_RANGE" | "ADD_EMPTY_RANGE" | "REMOVE_RANGE" | "CHANGE_RANGE" | "COPY" | "CUT" | "PASTE" | "CLEAN_CLIPBOARD_HIGHLIGHT" | "AUTOFILL_CELL" | "PASTE_FROM_OS_CLIPBOARD" | "ACTIVATE_PAINT_FORMAT" | "PASTE_CONDITIONAL_FORMAT" | "AUTORESIZE_COLUMNS" | "AUTORESIZE_ROWS" | "MOVE_COLUMNS_ROWS" | "ACTIVATE_SHEET" | "PREPARE_SELECTION_INPUT_EXPANSION" | "STOP_SELECTION_INPUT" | "EVALUATE_CELLS" | "CHANGE_HIGHLIGHT" | "START_CHANGE_HIGHLIGHT" | "SET_HIGHLIGHT_COLOR" | "STOP_COMPOSER_RANGE_SELECTION" | "START_EDITION" | "STOP_EDITION" | "SET_CURRENT_CONTENT" | "CHANGE_COMPOSER_CURSOR_SELECTION" | "REPLACE_COMPOSER_CURSOR_SELECTION" | "CYCLE_EDITION_REFERENCES" | "START" | "AUTOFILL" | "AUTOFILL_SELECT" | "SET_FORMULA_VISIBILITY" | "AUTOFILL_AUTO" | "SELECT_FIGURE" | "UPDATE_SEARCH" | "REFRESH_SEARCH" | "CLEAR_SEARCH" | "SELECT_SEARCH_PREVIOUS_MATCH" | "SELECT_SEARCH_NEXT_MATCH" | "REPLACE_SEARCH" | "REPLACE_ALL_SEARCH" | "
|
|
1664
|
+
declare const invalidateEvaluationCommands: Set<"UPDATE_CELL" | "UPDATE_CELL_POSITION" | "CLEAR_CELL" | "DELETE_CONTENT" | "ADD_COLUMNS_ROWS" | "REMOVE_COLUMNS_ROWS" | "RESIZE_COLUMNS_ROWS" | "HIDE_COLUMNS_ROWS" | "UNHIDE_COLUMNS_ROWS" | "SET_GRID_LINES_VISIBILITY" | "FREEZE_COLUMNS" | "FREEZE_ROWS" | "UNFREEZE_COLUMNS_ROWS" | "UNFREEZE_COLUMNS" | "UNFREEZE_ROWS" | "ADD_MERGE" | "REMOVE_MERGE" | "CREATE_SHEET" | "DELETE_SHEET" | "DUPLICATE_SHEET" | "MOVE_SHEET" | "RENAME_SHEET" | "HIDE_SHEET" | "SHOW_SHEET" | "MOVE_RANGES" | "ADD_CONDITIONAL_FORMAT" | "REMOVE_CONDITIONAL_FORMAT" | "MOVE_CONDITIONAL_FORMAT" | "CREATE_FIGURE" | "DELETE_FIGURE" | "UPDATE_FIGURE" | "SET_FORMATTING" | "CLEAR_FORMATTING" | "SET_BORDER" | "CREATE_CHART" | "UPDATE_CHART" | "CREATE_IMAGE" | "CREATE_FILTER_TABLE" | "REMOVE_FILTER_TABLE" | "SORT_CELLS" | "SET_DECIMAL" | "REQUEST_UNDO" | "REQUEST_REDO" | "UNDO" | "REDO" | "ENABLE_NEW_SELECTION_INPUT" | "DISABLE_SELECTION_INPUT" | "UNFOCUS_SELECTION_INPUT" | "FOCUS_RANGE" | "ADD_EMPTY_RANGE" | "REMOVE_RANGE" | "CHANGE_RANGE" | "COPY" | "CUT" | "PASTE" | "REPEAT_PASTE" | "CLEAN_CLIPBOARD_HIGHLIGHT" | "AUTOFILL_CELL" | "PASTE_FROM_OS_CLIPBOARD" | "ACTIVATE_PAINT_FORMAT" | "PASTE_CONDITIONAL_FORMAT" | "AUTORESIZE_COLUMNS" | "AUTORESIZE_ROWS" | "MOVE_COLUMNS_ROWS" | "ACTIVATE_SHEET" | "PREPARE_SELECTION_INPUT_EXPANSION" | "STOP_SELECTION_INPUT" | "EVALUATE_CELLS" | "CHANGE_HIGHLIGHT" | "START_CHANGE_HIGHLIGHT" | "SET_HIGHLIGHT_COLOR" | "STOP_COMPOSER_RANGE_SELECTION" | "START_EDITION" | "STOP_EDITION" | "SET_CURRENT_CONTENT" | "CHANGE_COMPOSER_CURSOR_SELECTION" | "REPLACE_COMPOSER_CURSOR_SELECTION" | "CYCLE_EDITION_REFERENCES" | "START" | "AUTOFILL" | "AUTOFILL_SELECT" | "SET_FORMULA_VISIBILITY" | "AUTOFILL_AUTO" | "SELECT_FIGURE" | "UPDATE_SEARCH" | "REFRESH_SEARCH" | "CLEAR_SEARCH" | "SELECT_SEARCH_PREVIOUS_MATCH" | "SELECT_SEARCH_NEXT_MATCH" | "REPLACE_SEARCH" | "REPLACE_ALL_SEARCH" | "RESIZE_SHEETVIEW" | "SUM_SELECTION" | "DELETE_CELL" | "INSERT_CELL" | "SET_VIEWPORT_OFFSET" | "SHIFT_VIEWPORT_DOWN" | "SHIFT_VIEWPORT_UP" | "OPEN_CELL_POPOVER" | "CLOSE_CELL_POPOVER" | "ACTIVATE_NEXT_SHEET" | "ACTIVATE_PREVIOUS_SHEET" | "UPDATE_FILTER">;
|
|
1665
|
+
declare const readonlyAllowedCommands: Set<"UPDATE_CELL" | "UPDATE_CELL_POSITION" | "CLEAR_CELL" | "DELETE_CONTENT" | "ADD_COLUMNS_ROWS" | "REMOVE_COLUMNS_ROWS" | "RESIZE_COLUMNS_ROWS" | "HIDE_COLUMNS_ROWS" | "UNHIDE_COLUMNS_ROWS" | "SET_GRID_LINES_VISIBILITY" | "FREEZE_COLUMNS" | "FREEZE_ROWS" | "UNFREEZE_COLUMNS_ROWS" | "UNFREEZE_COLUMNS" | "UNFREEZE_ROWS" | "ADD_MERGE" | "REMOVE_MERGE" | "CREATE_SHEET" | "DELETE_SHEET" | "DUPLICATE_SHEET" | "MOVE_SHEET" | "RENAME_SHEET" | "HIDE_SHEET" | "SHOW_SHEET" | "MOVE_RANGES" | "ADD_CONDITIONAL_FORMAT" | "REMOVE_CONDITIONAL_FORMAT" | "MOVE_CONDITIONAL_FORMAT" | "CREATE_FIGURE" | "DELETE_FIGURE" | "UPDATE_FIGURE" | "SET_FORMATTING" | "CLEAR_FORMATTING" | "SET_BORDER" | "CREATE_CHART" | "UPDATE_CHART" | "CREATE_IMAGE" | "CREATE_FILTER_TABLE" | "REMOVE_FILTER_TABLE" | "SORT_CELLS" | "SET_DECIMAL" | "REQUEST_UNDO" | "REQUEST_REDO" | "UNDO" | "REDO" | "ENABLE_NEW_SELECTION_INPUT" | "DISABLE_SELECTION_INPUT" | "UNFOCUS_SELECTION_INPUT" | "FOCUS_RANGE" | "ADD_EMPTY_RANGE" | "REMOVE_RANGE" | "CHANGE_RANGE" | "COPY" | "CUT" | "PASTE" | "REPEAT_PASTE" | "CLEAN_CLIPBOARD_HIGHLIGHT" | "AUTOFILL_CELL" | "PASTE_FROM_OS_CLIPBOARD" | "ACTIVATE_PAINT_FORMAT" | "PASTE_CONDITIONAL_FORMAT" | "AUTORESIZE_COLUMNS" | "AUTORESIZE_ROWS" | "MOVE_COLUMNS_ROWS" | "ACTIVATE_SHEET" | "PREPARE_SELECTION_INPUT_EXPANSION" | "STOP_SELECTION_INPUT" | "EVALUATE_CELLS" | "CHANGE_HIGHLIGHT" | "START_CHANGE_HIGHLIGHT" | "SET_HIGHLIGHT_COLOR" | "STOP_COMPOSER_RANGE_SELECTION" | "START_EDITION" | "STOP_EDITION" | "SET_CURRENT_CONTENT" | "CHANGE_COMPOSER_CURSOR_SELECTION" | "REPLACE_COMPOSER_CURSOR_SELECTION" | "CYCLE_EDITION_REFERENCES" | "START" | "AUTOFILL" | "AUTOFILL_SELECT" | "SET_FORMULA_VISIBILITY" | "AUTOFILL_AUTO" | "SELECT_FIGURE" | "UPDATE_SEARCH" | "REFRESH_SEARCH" | "CLEAR_SEARCH" | "SELECT_SEARCH_PREVIOUS_MATCH" | "SELECT_SEARCH_NEXT_MATCH" | "REPLACE_SEARCH" | "REPLACE_ALL_SEARCH" | "RESIZE_SHEETVIEW" | "SUM_SELECTION" | "DELETE_CELL" | "INSERT_CELL" | "SET_VIEWPORT_OFFSET" | "SHIFT_VIEWPORT_DOWN" | "SHIFT_VIEWPORT_UP" | "OPEN_CELL_POPOVER" | "CLOSE_CELL_POPOVER" | "ACTIVATE_NEXT_SHEET" | "ACTIVATE_PREVIOUS_SHEET" | "UPDATE_FILTER">;
|
|
1481
1666
|
declare const coreTypes: Set<"UPDATE_CELL" | "UPDATE_CELL_POSITION" | "CLEAR_CELL" | "DELETE_CONTENT" | "ADD_COLUMNS_ROWS" | "REMOVE_COLUMNS_ROWS" | "RESIZE_COLUMNS_ROWS" | "HIDE_COLUMNS_ROWS" | "UNHIDE_COLUMNS_ROWS" | "SET_GRID_LINES_VISIBILITY" | "FREEZE_COLUMNS" | "FREEZE_ROWS" | "UNFREEZE_COLUMNS_ROWS" | "UNFREEZE_COLUMNS" | "UNFREEZE_ROWS" | "ADD_MERGE" | "REMOVE_MERGE" | "CREATE_SHEET" | "DELETE_SHEET" | "DUPLICATE_SHEET" | "MOVE_SHEET" | "RENAME_SHEET" | "HIDE_SHEET" | "SHOW_SHEET" | "MOVE_RANGES" | "ADD_CONDITIONAL_FORMAT" | "REMOVE_CONDITIONAL_FORMAT" | "MOVE_CONDITIONAL_FORMAT" | "CREATE_FIGURE" | "DELETE_FIGURE" | "UPDATE_FIGURE" | "SET_FORMATTING" | "CLEAR_FORMATTING" | "SET_BORDER" | "CREATE_CHART" | "UPDATE_CHART" | "CREATE_IMAGE" | "CREATE_FILTER_TABLE" | "REMOVE_FILTER_TABLE">;
|
|
1482
1667
|
interface UpdateCellCommand extends PositionDependentCommand {
|
|
1483
1668
|
type: "UPDATE_CELL";
|
|
@@ -1690,6 +1875,11 @@ interface PasteCommand {
|
|
|
1690
1875
|
target: Zone[];
|
|
1691
1876
|
pasteOption?: ClipboardPasteOptions;
|
|
1692
1877
|
}
|
|
1878
|
+
interface RepeatPasteCommand {
|
|
1879
|
+
type: "REPEAT_PASTE";
|
|
1880
|
+
target: Zone[];
|
|
1881
|
+
pasteOption?: ClipboardPasteOptions;
|
|
1882
|
+
}
|
|
1693
1883
|
interface CleanClipBoardHighlightCommand {
|
|
1694
1884
|
type: "CLEAN_CLIPBOARD_HIGHLIGHT";
|
|
1695
1885
|
}
|
|
@@ -1800,11 +1990,8 @@ interface DeleteContentCommand {
|
|
|
1800
1990
|
sheetId: UID;
|
|
1801
1991
|
target: Zone[];
|
|
1802
1992
|
}
|
|
1803
|
-
interface ClearCellCommand {
|
|
1993
|
+
interface ClearCellCommand extends PositionDependentCommand {
|
|
1804
1994
|
type: "CLEAR_CELL";
|
|
1805
|
-
sheetId: UID;
|
|
1806
|
-
col: HeaderIndex;
|
|
1807
|
-
row: HeaderIndex;
|
|
1808
1995
|
}
|
|
1809
1996
|
interface UndoCommand {
|
|
1810
1997
|
type: "UNDO";
|
|
@@ -2034,7 +2221,7 @@ UpdateCellCommand | UpdateCellPositionCommand | ClearCellCommand | DeleteContent
|
|
|
2034
2221
|
| CreateImageOverCommand
|
|
2035
2222
|
/** FILTERS */
|
|
2036
2223
|
| CreateFilterTableCommand | RemoveFilterTableCommand;
|
|
2037
|
-
declare type LocalCommand = RequestUndoCommand | RequestRedoCommand | UndoCommand | RedoCommand | NewInputCommand | RemoveInputCommand | UnfocusInputCommand | FocusInputCommand | AddEmptyRangeCommand | RemoveRangeCommand | ChangeRangeCommand | CopyCommand | CutCommand | PasteCommand | CleanClipBoardHighlightCommand | AutoFillCellCommand | PasteFromOSClipboardCommand | ActivatePaintFormatCommand | PasteCFCommand | AutoresizeColumnsCommand | AutoresizeRowsCommand | MoveColumnsRowsCommand | ActivateSheetCommand | PrepareExpansionCommand | StopSelectionCommand | EvaluateCellsCommand | ChangeHighlightCommand | StartChangeHighlightCommand | SetColorCommand | StopComposerSelectionCommand | StartEditionCommand | StopEditionCommand | SetCurrentContentCommand | ChangeComposerSelectionCommand | ReplaceComposerSelectionCommand | CycleEditionReferencesCommand | StartCommand | AutofillCommand | AutofillSelectCommand | ShowFormulaCommand | AutofillAutoCommand | SelectFigureCommand | UpdateSearchCommand | RefreshSearchCommand | ClearSearchCommand | SelectSearchPreviousCommand | SelectSearchNextCommand | ReplaceSearchCommand | ReplaceAllSearchCommand | SortCommand | SetDecimalCommand | ResizeViewportCommand | SumSelectionCommand | DeleteCellCommand | InsertCellCommand | SetViewportOffsetCommand | MoveViewportDownCommand | MoveViewportUpCommand | OpenCellPopoverCommand | CloseCellPopoverCommand | ActivateNextSheetCommand | ActivatePreviousSheetCommand | UpdateFilterCommand;
|
|
2224
|
+
declare type LocalCommand = RequestUndoCommand | RequestRedoCommand | UndoCommand | RedoCommand | NewInputCommand | RemoveInputCommand | UnfocusInputCommand | FocusInputCommand | AddEmptyRangeCommand | RemoveRangeCommand | ChangeRangeCommand | CopyCommand | CutCommand | PasteCommand | RepeatPasteCommand | CleanClipBoardHighlightCommand | AutoFillCellCommand | PasteFromOSClipboardCommand | ActivatePaintFormatCommand | PasteCFCommand | AutoresizeColumnsCommand | AutoresizeRowsCommand | MoveColumnsRowsCommand | ActivateSheetCommand | PrepareExpansionCommand | StopSelectionCommand | EvaluateCellsCommand | ChangeHighlightCommand | StartChangeHighlightCommand | SetColorCommand | StopComposerSelectionCommand | StartEditionCommand | StopEditionCommand | SetCurrentContentCommand | ChangeComposerSelectionCommand | ReplaceComposerSelectionCommand | CycleEditionReferencesCommand | StartCommand | AutofillCommand | AutofillSelectCommand | ShowFormulaCommand | AutofillAutoCommand | SelectFigureCommand | UpdateSearchCommand | RefreshSearchCommand | ClearSearchCommand | SelectSearchPreviousCommand | SelectSearchNextCommand | ReplaceSearchCommand | ReplaceAllSearchCommand | SortCommand | SetDecimalCommand | ResizeViewportCommand | SumSelectionCommand | DeleteCellCommand | InsertCellCommand | SetViewportOffsetCommand | MoveViewportDownCommand | MoveViewportUpCommand | OpenCellPopoverCommand | CloseCellPopoverCommand | ActivateNextSheetCommand | ActivatePreviousSheetCommand | UpdateFilterCommand;
|
|
2038
2225
|
declare type Command = CoreCommand | LocalCommand;
|
|
2039
2226
|
/**
|
|
2040
2227
|
* Holds the result of a command dispatch.
|
|
@@ -2619,218 +2806,6 @@ declare type EvalContext = {
|
|
|
2619
2806
|
[key: string]: any;
|
|
2620
2807
|
};
|
|
2621
2808
|
|
|
2622
|
-
declare class SelectiveHistory<T = unknown> {
|
|
2623
|
-
private applyOperation;
|
|
2624
|
-
private revertOperation;
|
|
2625
|
-
private buildEmpty;
|
|
2626
|
-
private readonly buildTransformation;
|
|
2627
|
-
private HEAD_BRANCH;
|
|
2628
|
-
private HEAD_OPERATION;
|
|
2629
|
-
private tree;
|
|
2630
|
-
/**
|
|
2631
|
-
* The selective history is a data structure used to register changes/updates of a state.
|
|
2632
|
-
* Each change/update is called an "operation".
|
|
2633
|
-
* The data structure allows to easily cancel (and redo) any operation individually.
|
|
2634
|
-
* An operation can be represented by any data structure. It can be a "command", a "diff", etc.
|
|
2635
|
-
* However it must have the following properties:
|
|
2636
|
-
* - it can be applied to modify the state
|
|
2637
|
-
* - it can be reverted on the state such that it was never executed.
|
|
2638
|
-
* - it can be transformed given other operation (Operational Transformation)
|
|
2639
|
-
*
|
|
2640
|
-
* Since this data structure doesn't know anything about the state nor the structure of
|
|
2641
|
-
* operations, the actual work must be performed by external functions given as parameters.
|
|
2642
|
-
* @param initialOperationId
|
|
2643
|
-
* @param applyOperation a function which can apply an operation to the state
|
|
2644
|
-
* @param revertOperation a function which can revert an operation from the state
|
|
2645
|
-
* @param buildEmpty a function returning an "empty" operation.
|
|
2646
|
-
* i.e an operation that leaves the state unmodified once applied or reverted
|
|
2647
|
-
* (used for internal implementation)
|
|
2648
|
-
* @param buildTransformation Factory used to build transformations
|
|
2649
|
-
*/
|
|
2650
|
-
constructor(initialOperationId: UID, applyOperation: (data: T) => void, revertOperation: (data: T) => void, buildEmpty: (id: UID) => T, buildTransformation: TransformationFactory<T>);
|
|
2651
|
-
/**
|
|
2652
|
-
* Return the operation identified by its id.
|
|
2653
|
-
*/
|
|
2654
|
-
get(operationId: UID): T;
|
|
2655
|
-
/**
|
|
2656
|
-
* Append a new operation as the last one
|
|
2657
|
-
*/
|
|
2658
|
-
append(operationId: UID, data: T): void;
|
|
2659
|
-
/**
|
|
2660
|
-
* Insert a new operation after a specific operation (may not be the last operation).
|
|
2661
|
-
* Following operations will be transformed according
|
|
2662
|
-
* to the new operation.
|
|
2663
|
-
*/
|
|
2664
|
-
insert(operationId: UID, data: T, insertAfter: UID): void;
|
|
2665
|
-
/**
|
|
2666
|
-
* @param operationId operation to undo
|
|
2667
|
-
* @param undoId the id of the "undo operation"
|
|
2668
|
-
* @param insertAfter the id of the operation after which to insert the undo
|
|
2669
|
-
*/
|
|
2670
|
-
undo(operationId: UID, undoId: UID, insertAfter: UID): void;
|
|
2671
|
-
/**
|
|
2672
|
-
* @param operationId operation to redo
|
|
2673
|
-
* @param redoId the if of the "redo operation"
|
|
2674
|
-
* @param insertAfter the id of the operation after which to insert the redo
|
|
2675
|
-
*/
|
|
2676
|
-
redo(operationId: UID, redoId: UID, insertAfter: UID): void;
|
|
2677
|
-
drop(operationId: UID): void;
|
|
2678
|
-
/**
|
|
2679
|
-
* Revert the state as it was *before* the given operation was executed.
|
|
2680
|
-
*/
|
|
2681
|
-
private revertBefore;
|
|
2682
|
-
/**
|
|
2683
|
-
* Revert the state as it was *after* the given operation was executed.
|
|
2684
|
-
*/
|
|
2685
|
-
private revertTo;
|
|
2686
|
-
/**
|
|
2687
|
-
* Revert an execution
|
|
2688
|
-
*/
|
|
2689
|
-
private revert;
|
|
2690
|
-
/**
|
|
2691
|
-
* Replay the operations between the current HEAD_BRANCH and the end of the tree
|
|
2692
|
-
*/
|
|
2693
|
-
private fastForward;
|
|
2694
|
-
}
|
|
2695
|
-
|
|
2696
|
-
declare class Revision implements RevisionData {
|
|
2697
|
-
readonly id: UID;
|
|
2698
|
-
readonly clientId: ClientId;
|
|
2699
|
-
private _commands;
|
|
2700
|
-
private _changes;
|
|
2701
|
-
/**
|
|
2702
|
-
* A revision represents a whole client action (Create a sheet, merge a Zone, Undo, ...).
|
|
2703
|
-
* A revision contains the following information:
|
|
2704
|
-
* - id: ID of the revision
|
|
2705
|
-
* - commands: CoreCommands that are linked to the action, and should be
|
|
2706
|
-
* dispatched in other clients
|
|
2707
|
-
* - clientId: Client who initiated the action
|
|
2708
|
-
* - changes: List of changes applied on the state.
|
|
2709
|
-
*/
|
|
2710
|
-
constructor(id: UID, clientId: ClientId, commands: readonly CoreCommand[], changes?: readonly HistoryChange[]);
|
|
2711
|
-
setChanges(changes: readonly HistoryChange[]): void;
|
|
2712
|
-
get commands(): readonly CoreCommand[];
|
|
2713
|
-
get changes(): readonly HistoryChange[];
|
|
2714
|
-
}
|
|
2715
|
-
|
|
2716
|
-
declare class Session extends EventBus<CollaborativeEvent> {
|
|
2717
|
-
private revisions;
|
|
2718
|
-
private transportService;
|
|
2719
|
-
private serverRevisionId;
|
|
2720
|
-
/**
|
|
2721
|
-
* Positions of the others client.
|
|
2722
|
-
*/
|
|
2723
|
-
private clients;
|
|
2724
|
-
private clientId;
|
|
2725
|
-
/**
|
|
2726
|
-
* Id of the server revision
|
|
2727
|
-
*/
|
|
2728
|
-
private debouncedMove;
|
|
2729
|
-
private pendingMessages;
|
|
2730
|
-
private waitingAck;
|
|
2731
|
-
/**
|
|
2732
|
-
* Flag used to block all commands when an undo or redo is triggered, until
|
|
2733
|
-
* it is accepted on the server
|
|
2734
|
-
*/
|
|
2735
|
-
private waitingUndoRedoAck;
|
|
2736
|
-
private isReplayingInitialRevisions;
|
|
2737
|
-
private processedRevisions;
|
|
2738
|
-
private uuidGenerator;
|
|
2739
|
-
/**
|
|
2740
|
-
* Manages the collaboration between multiple users on the same spreadsheet.
|
|
2741
|
-
* It can forward local state changes to other users to ensure they all eventually
|
|
2742
|
-
* reach the same state.
|
|
2743
|
-
* It also manages the positions of each clients in the spreadsheet to provide
|
|
2744
|
-
* a visual indication of what other users are doing in the spreadsheet.
|
|
2745
|
-
*
|
|
2746
|
-
* @param revisions
|
|
2747
|
-
* @param transportService communication channel used to send and receive messages
|
|
2748
|
-
* between all connected clients
|
|
2749
|
-
* @param client the client connected locally
|
|
2750
|
-
* @param serverRevisionId
|
|
2751
|
-
*/
|
|
2752
|
-
constructor(revisions: SelectiveHistory<Revision>, transportService: TransportService<CollaborationMessage>, serverRevisionId?: UID);
|
|
2753
|
-
canApplyOptimisticUpdate(): boolean;
|
|
2754
|
-
/**
|
|
2755
|
-
* Add a new revision to the collaborative session.
|
|
2756
|
-
* It will be transmitted to all other connected clients.
|
|
2757
|
-
*/
|
|
2758
|
-
save(commands: CoreCommand[], changes: HistoryChange[]): void;
|
|
2759
|
-
undo(revisionId: UID): void;
|
|
2760
|
-
redo(revisionId: UID): void;
|
|
2761
|
-
/**
|
|
2762
|
-
* Notify that the position of the client has changed
|
|
2763
|
-
*/
|
|
2764
|
-
move(position: ClientPosition): void;
|
|
2765
|
-
join(client?: Client): void;
|
|
2766
|
-
loadInitialMessages(messages: StateUpdateMessage[]): void;
|
|
2767
|
-
/**
|
|
2768
|
-
* Notify the server that the user client left the collaborative session
|
|
2769
|
-
*/
|
|
2770
|
-
leave(): void;
|
|
2771
|
-
/**
|
|
2772
|
-
* Send a snapshot of the spreadsheet to the collaboration server
|
|
2773
|
-
*/
|
|
2774
|
-
snapshot(data: WorkbookData): void;
|
|
2775
|
-
getClient(): Client;
|
|
2776
|
-
getConnectedClients(): Set<Client>;
|
|
2777
|
-
getRevisionId(): UID;
|
|
2778
|
-
isFullySynchronized(): boolean;
|
|
2779
|
-
private _move;
|
|
2780
|
-
/**
|
|
2781
|
-
* Handles messages received from other clients in the collaborative
|
|
2782
|
-
* session.
|
|
2783
|
-
*/
|
|
2784
|
-
private onMessageReceived;
|
|
2785
|
-
private onClientMoved;
|
|
2786
|
-
/**
|
|
2787
|
-
* Register the new client and send your
|
|
2788
|
-
* own position back.
|
|
2789
|
-
*/
|
|
2790
|
-
private onClientJoined;
|
|
2791
|
-
private onClientLeft;
|
|
2792
|
-
private sendUpdateMessage;
|
|
2793
|
-
/**
|
|
2794
|
-
* Send the next pending message
|
|
2795
|
-
*/
|
|
2796
|
-
private sendPendingMessage;
|
|
2797
|
-
private acknowledge;
|
|
2798
|
-
private isAlreadyProcessed;
|
|
2799
|
-
private dropPendingHistoryMessages;
|
|
2800
|
-
}
|
|
2801
|
-
|
|
2802
|
-
/**
|
|
2803
|
-
* Local History
|
|
2804
|
-
*
|
|
2805
|
-
* The local history is responsible of tracking the locally state updates
|
|
2806
|
-
* It maintains the local undo and redo stack to allow to undo/redo only local
|
|
2807
|
-
* changes
|
|
2808
|
-
*/
|
|
2809
|
-
declare class LocalHistory extends EventBus$1 implements CommandHandler<Command> {
|
|
2810
|
-
protected dispatch: CommandDispatcher["dispatch"];
|
|
2811
|
-
private session;
|
|
2812
|
-
/**
|
|
2813
|
-
* Ids of the revisions which can be undone
|
|
2814
|
-
*/
|
|
2815
|
-
private undoStack;
|
|
2816
|
-
/**
|
|
2817
|
-
* Ids of the revisions which can be redone
|
|
2818
|
-
*/
|
|
2819
|
-
private redoStack;
|
|
2820
|
-
constructor(dispatch: CommandDispatcher["dispatch"], session: Session);
|
|
2821
|
-
allowDispatch(cmd: Command): CommandResult;
|
|
2822
|
-
beforeHandle(cmd: Command): void;
|
|
2823
|
-
handle(cmd: Command): void;
|
|
2824
|
-
finalize(): void;
|
|
2825
|
-
private requestHistoryChange;
|
|
2826
|
-
canUndo(): boolean;
|
|
2827
|
-
canRedo(): boolean;
|
|
2828
|
-
private drop;
|
|
2829
|
-
private onNewLocalStateUpdate;
|
|
2830
|
-
private selectiveUndo;
|
|
2831
|
-
private selectiveRedo;
|
|
2832
|
-
}
|
|
2833
|
-
|
|
2834
2809
|
declare class RangeAdapter implements CommandHandler<CoreCommand> {
|
|
2835
2810
|
private getters;
|
|
2836
2811
|
private providers;
|
|
@@ -4220,7 +4195,12 @@ declare class HeaderVisibilityUIPlugin extends UIPlugin {
|
|
|
4220
4195
|
isColHidden(sheetId: UID, index: number): boolean;
|
|
4221
4196
|
isHeaderHidden(sheetId: UID, dimension: Dimension, index: number): boolean;
|
|
4222
4197
|
getNextVisibleCellPosition({ sheetId, col, row }: CellPosition): CellPosition;
|
|
4223
|
-
|
|
4198
|
+
/**
|
|
4199
|
+
* Find the first visible header in the range [`from` => `to`].
|
|
4200
|
+
*
|
|
4201
|
+
* Both `from` and `to` are inclusive.
|
|
4202
|
+
*/
|
|
4203
|
+
findVisibleHeader(sheetId: UID, dimension: Dimension, from: number, to: number): number | undefined;
|
|
4224
4204
|
findLastVisibleColRowIndex(sheetId: UID, dimension: Dimension, { last, first }: {
|
|
4225
4205
|
first: HeaderIndex;
|
|
4226
4206
|
last: HeaderIndex;
|
|
@@ -4240,6 +4220,42 @@ declare class HighlightPlugin extends UIPlugin {
|
|
|
4240
4220
|
drawGrid(renderingContext: GridRenderingContext): void;
|
|
4241
4221
|
}
|
|
4242
4222
|
|
|
4223
|
+
/**
|
|
4224
|
+
* Local History
|
|
4225
|
+
*
|
|
4226
|
+
* The local history is responsible of tracking the locally state updates
|
|
4227
|
+
* It maintains the local undo and redo stack to allow to undo/redo only local
|
|
4228
|
+
* changes
|
|
4229
|
+
*/
|
|
4230
|
+
declare class HistoryPlugin extends UIPlugin {
|
|
4231
|
+
static getters: readonly ["canUndo", "canRedo"];
|
|
4232
|
+
/**
|
|
4233
|
+
* Ids of the revisions which can be undone
|
|
4234
|
+
*/
|
|
4235
|
+
private undoStack;
|
|
4236
|
+
/**
|
|
4237
|
+
* Ids of the revisions which can be redone
|
|
4238
|
+
*/
|
|
4239
|
+
private redoStack;
|
|
4240
|
+
private session;
|
|
4241
|
+
constructor(config: UIPluginConfig);
|
|
4242
|
+
allowDispatch(cmd: Command): CommandResult;
|
|
4243
|
+
handle(cmd: Command): void;
|
|
4244
|
+
finalize(): void;
|
|
4245
|
+
private requestHistoryChange;
|
|
4246
|
+
canUndo(): boolean;
|
|
4247
|
+
canRedo(): boolean;
|
|
4248
|
+
private drop;
|
|
4249
|
+
private onNewLocalStateUpdate;
|
|
4250
|
+
/**
|
|
4251
|
+
* Fetch the last revision which is not empty and not a repeated command
|
|
4252
|
+
*
|
|
4253
|
+
* Ignore repeated commands (REQUEST_REDO command as root command)
|
|
4254
|
+
* Ignore standard undo/redo revisions (that are empty)
|
|
4255
|
+
*/
|
|
4256
|
+
private getPossibleRevisionToRepeat;
|
|
4257
|
+
}
|
|
4258
|
+
|
|
4243
4259
|
declare class RendererPlugin extends UIPlugin {
|
|
4244
4260
|
static layers: LAYERS[];
|
|
4245
4261
|
static getters: readonly ["getColDimensionsInViewport", "getRowDimensionsInViewport"];
|
|
@@ -4523,6 +4539,7 @@ declare class ClipboardPlugin extends UIPlugin {
|
|
|
4523
4539
|
static getters: readonly ["getClipboardContent", "getClipboardTextContent", "isCutOperation", "isPaintingFormat"];
|
|
4524
4540
|
private status;
|
|
4525
4541
|
private state?;
|
|
4542
|
+
private lastPasteState?;
|
|
4526
4543
|
private _isPaintingFormat;
|
|
4527
4544
|
allowDispatch(cmd: LocalCommand): CommandResult;
|
|
4528
4545
|
handle(cmd: Command): void;
|
|
@@ -4663,10 +4680,7 @@ declare type ImageGetters = Pick<ImagePlugin, GetterNames<typeof ImagePlugin>>;
|
|
|
4663
4680
|
declare type FigureGetters = Pick<FigurePlugin, GetterNames<typeof FigurePlugin>>;
|
|
4664
4681
|
declare type RangeAdapterGetters = Pick<RangeAdapter, GetterNames<typeof RangeAdapter>>;
|
|
4665
4682
|
declare type ConditionalFormatGetters = Pick<ConditionalFormatPlugin, GetterNames<typeof ConditionalFormatPlugin>>;
|
|
4666
|
-
declare type LocalHistoryGetters =
|
|
4667
|
-
canUndo: LocalHistory["canUndo"];
|
|
4668
|
-
canRedo: LocalHistory["canRedo"];
|
|
4669
|
-
};
|
|
4683
|
+
declare type LocalHistoryGetters = Pick<HistoryPlugin, GetterNames<typeof HistoryPlugin>>;
|
|
4670
4684
|
declare type FiltersGetters = Pick<FiltersPlugin, GetterNames<typeof FiltersPlugin>>;
|
|
4671
4685
|
declare type CoreGetters = SheetGetters & HeaderSizeGetters & HeaderVisibilityGetters & CellGetters & MergeGetters & BordersGetters & ChartGetters & ImageGetters & ConditionalFormatGetters & FigureGetters & RangeAdapterGetters & FiltersGetters;
|
|
4672
4686
|
declare type AutofillGetters = Pick<AutofillPlugin, GetterNames<typeof AutofillPlugin>>;
|
|
@@ -5702,6 +5716,7 @@ declare class FilterIconsOverlay extends Component<Props$k, SpreadsheetChildEnv>
|
|
|
5702
5716
|
};
|
|
5703
5717
|
getVisibleFilterHeaders(): Position$1[];
|
|
5704
5718
|
getFilterHeaderPosition(position: Position$1): DOMCoordinates;
|
|
5719
|
+
private getIconVerticalPosition;
|
|
5705
5720
|
isFilterActive(position: Position$1): boolean;
|
|
5706
5721
|
toggleFilterMenu(position: Position$1): void;
|
|
5707
5722
|
private isPositionVisible;
|
|
@@ -6918,6 +6933,8 @@ declare function createEmptySheet(sheetId: UID, name: string): SheetData;
|
|
|
6918
6933
|
declare function createEmptyWorkbookData(sheetName?: string): WorkbookData;
|
|
6919
6934
|
declare function createEmptyExcelSheet(sheetId: UID, name: string): ExcelSheetData;
|
|
6920
6935
|
|
|
6936
|
+
declare function genericRepeat<T extends Command>(getters: Getters, command: T): T;
|
|
6937
|
+
|
|
6921
6938
|
/**
|
|
6922
6939
|
* We export here all entities that needs to be accessed publicly by Odoo.
|
|
6923
6940
|
*
|
|
@@ -6989,6 +7006,8 @@ declare const registries: {
|
|
|
6989
7006
|
urlRegistry: Registry<LinkSpec>;
|
|
6990
7007
|
cellPopoverRegistry: Registry<PopoverBuilders>;
|
|
6991
7008
|
numberFormatMenuRegistry: MenuItemRegistry;
|
|
7009
|
+
repeatLocalCommandTransformRegistry: Registry<(getters: Getters, cmd: LocalCommand, childCommands: readonly CoreCommand[]) => LocalCommand | CoreCommand[] | undefined>;
|
|
7010
|
+
repeatCommandTransformRegistry: Registry<(getters: Getters, cmd: CoreCommand) => CoreCommand | undefined>;
|
|
6992
7011
|
};
|
|
6993
7012
|
declare const helpers: {
|
|
6994
7013
|
arg: typeof arg;
|
|
@@ -7017,6 +7036,7 @@ declare const helpers: {
|
|
|
7017
7036
|
positionToZone: typeof positionToZone;
|
|
7018
7037
|
isDefined: typeof isDefined;
|
|
7019
7038
|
lazy: typeof lazy;
|
|
7039
|
+
genericRepeat: typeof genericRepeat;
|
|
7020
7040
|
};
|
|
7021
7041
|
declare const links: {
|
|
7022
7042
|
isMarkdownLink: typeof isMarkdownLink;
|