roosterjs 8.18.0 → 8.19.2

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/rooster.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for roosterjs (Version 8.18.0)
1
+ // Type definitions for roosterjs (Version 8.19.2)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -948,50 +948,54 @@ const enum TableOperation {
948
948
  * Merge current column with the column on the right
949
949
  */
950
950
  MergeRight = 10,
951
+ /**
952
+ * Merge all selected cells
953
+ */
954
+ MergeCells = 11,
951
955
  /**
952
956
  * Split current table cell horizontally
953
957
  */
954
- SplitHorizontally = 11,
958
+ SplitHorizontally = 12,
955
959
  /**
956
960
  * Split current table cell vertically
957
961
  */
958
- SplitVertically = 12,
962
+ SplitVertically = 13,
959
963
  /**
960
964
  * Align current table at the center
961
965
  */
962
- AlignCenter = 13,
966
+ AlignCenter = 14,
963
967
  /**
964
968
  * Align current table at the left
965
969
  */
966
- AlignLeft = 14,
970
+ AlignLeft = 15,
967
971
  /**
968
972
  * Align current table at the right
969
973
  */
970
- AlignRight = 15,
974
+ AlignRight = 16,
971
975
  /**
972
976
  * Align current content table cell at the left
973
977
  */
974
- AlignCellLeft = 16,
978
+ AlignCellLeft = 17,
975
979
  /**
976
980
  * Align current content table cell at the center
977
981
  */
978
- AlignCellCenter = 17,
982
+ AlignCellCenter = 18,
979
983
  /**
980
984
  * Align current content table cell at the right
981
985
  */
982
- AlignCellRight = 18,
986
+ AlignCellRight = 19,
983
987
  /**
984
988
  * Align current content table cell at the top
985
989
  */
986
- AlignCellTop = 19,
990
+ AlignCellTop = 20,
987
991
  /**
988
992
  * Align current table cell at the middle
989
993
  */
990
- AlignCellMiddle = 20,
994
+ AlignCellMiddle = 21,
991
995
  /**
992
996
  * Align current table cell at the bottom
993
997
  */
994
- AlignCellBottom = 21
998
+ AlignCellBottom = 22
995
999
  }
996
1000
 
997
1001
  /**
@@ -1660,6 +1664,10 @@ interface ClipboardData {
1660
1664
  * Image file from clipboard event
1661
1665
  */
1662
1666
  image: File | null;
1667
+ /**
1668
+ * General file from clipboard event
1669
+ */
1670
+ files?: File[];
1663
1671
  /**
1664
1672
  * Html extracted from raw html string and remove content before and after fragment tag
1665
1673
  */
@@ -1943,27 +1951,27 @@ interface IContentTraverser {
1943
1951
  /**
1944
1952
  * Get current block
1945
1953
  */
1946
- currentBlockElement: BlockElement;
1954
+ currentBlockElement: BlockElement | null;
1947
1955
  /**
1948
1956
  * Get next block element
1949
1957
  */
1950
- getNextBlockElement(): BlockElement;
1958
+ getNextBlockElement(): BlockElement | null;
1951
1959
  /**
1952
1960
  * Get previous block element
1953
1961
  */
1954
- getPreviousBlockElement(): BlockElement;
1962
+ getPreviousBlockElement(): BlockElement | null;
1955
1963
  /**
1956
1964
  * Current inline element getter
1957
1965
  */
1958
- currentInlineElement: InlineElement;
1966
+ currentInlineElement: InlineElement | null;
1959
1967
  /**
1960
1968
  * Get next inline element
1961
1969
  */
1962
- getNextInlineElement(): InlineElement;
1970
+ getNextInlineElement(): InlineElement | null;
1963
1971
  /**
1964
1972
  * Get previous inline element
1965
1973
  */
1966
- getPreviousInlineElement(): InlineElement;
1974
+ getPreviousInlineElement(): InlineElement | null;
1967
1975
  }
1968
1976
 
1969
1977
  /**
@@ -2076,12 +2084,12 @@ interface IPositionContentSearcher {
2076
2084
  * Get the inline element before position
2077
2085
  * @returns The inlineElement before position
2078
2086
  */
2079
- getInlineElementBefore(): InlineElement;
2087
+ getInlineElementBefore(): InlineElement | null;
2080
2088
  /**
2081
2089
  * Get the inline element after position
2082
2090
  * @returns The inline element after position
2083
2091
  */
2084
- getInlineElementAfter(): InlineElement;
2092
+ getInlineElementAfter(): InlineElement | null;
2085
2093
  /**
2086
2094
  * Get X number of chars before position
2087
2095
  * The actual returned chars may be less than what is requested.
@@ -2097,7 +2105,7 @@ interface IPositionContentSearcher {
2097
2105
  * @param exactMatch Whether it is an exact match
2098
2106
  * @returns The range for the matched text, null if unable to find a match
2099
2107
  */
2100
- getRangeFromText(text: string, exactMatch: boolean): Range;
2108
+ getRangeFromText(text: string, exactMatch: boolean): Range | null;
2101
2109
  /**
2102
2110
  * Get text section before position till stop condition is met.
2103
2111
  * This offers consumers to retrieve text section by section
@@ -2111,7 +2119,7 @@ interface IPositionContentSearcher {
2111
2119
  * Get first non textual inline element before position
2112
2120
  * @returns First non textual inline element before position or null if no such element exists
2113
2121
  */
2114
- getNearestNonTextInlineElement(): InlineElement;
2122
+ getNearestNonTextInlineElement(): InlineElement | null;
2115
2123
  }
2116
2124
 
2117
2125
  /**
@@ -2271,11 +2279,11 @@ interface SelectionPath {
2271
2279
  /**
2272
2280
  * Represents a data structure of snapshots, this is usually used for undo snapshots
2273
2281
  */
2274
- interface Snapshots {
2282
+ interface Snapshots<T = string> {
2275
2283
  /**
2276
2284
  * The snapshot array
2277
2285
  */
2278
- snapshots: string[];
2286
+ snapshots: T[];
2279
2287
  /**
2280
2288
  * Size of all snapshots
2281
2289
  */
@@ -2294,6 +2302,59 @@ interface Snapshots {
2294
2302
  readonly maxSize: number;
2295
2303
  }
2296
2304
 
2305
+ /**
2306
+ * Common part of NormalContentMetadata and TableContentMetadata
2307
+ */
2308
+ interface ContentMetadataBase<T extends SelectionRangeTypes> {
2309
+ isDarkMode: boolean;
2310
+ type: T;
2311
+ }
2312
+
2313
+ /**
2314
+ * A content metadata is a data structure storing information other than HTML content,
2315
+ * such as dark mode info, selection info, ...
2316
+ *
2317
+ * NormalContentMetadata is content metadata for normal selection with a start and end selection path.
2318
+ *
2319
+ * When do any change to this type, also need to fix function isUndoMetadata to make sure
2320
+ * the check is correct
2321
+ */
2322
+ interface NormalContentMetadata extends SelectionPath, ContentMetadataBase<SelectionRangeTypes.Normal> {
2323
+ }
2324
+
2325
+ /**
2326
+ * A content metadata is a data structure storing information other than HTML content,
2327
+ * such as dark mode info, selection info, ...
2328
+ *
2329
+ * TableContentMetadata is content metadata for table selection with table id and start and end coordinates
2330
+ *
2331
+ * When do any change to this type, also need to fix function isUndoMetadata to make sure
2332
+ * the check is correct
2333
+ */
2334
+ interface TableContentMetadata extends TableSelection, ContentMetadataBase<SelectionRangeTypes.TableSelection> {
2335
+ tableId: string;
2336
+ }
2337
+
2338
+ /**
2339
+ * A content metadata is a data structure storing information other than HTML content,
2340
+ * such as dark mode info, selection info, ...
2341
+ */
2342
+ type ContentMetadata = NormalContentMetadata | TableContentMetadata;
2343
+
2344
+ /**
2345
+ * A serializable snapshot of editor content, including the html content and metadata
2346
+ */
2347
+ interface Snapshot {
2348
+ /**
2349
+ * HTML content string
2350
+ */
2351
+ html: string;
2352
+ /**
2353
+ * Metadata of the editor content state
2354
+ */
2355
+ metadata: ContentMetadata | null;
2356
+ }
2357
+
2297
2358
  /**
2298
2359
  * Table format
2299
2360
  */
@@ -2973,6 +3034,11 @@ interface IEditor {
2973
3034
  * @returns True if the editor is in dark mode, otherwise false
2974
3035
  */
2975
3036
  isDarkMode(): boolean;
3037
+ /**
3038
+ * Transform the given node and all its child nodes to dark mode color if editor is in dark mode
3039
+ * @param node The node to transform
3040
+ */
3041
+ transformToDarkColor(node: Node): void;
2976
3042
  /**
2977
3043
  * Make the editor in "Shadow Edit" mode.
2978
3044
  * In Shadow Edit mode, all format change will finally be ignored.
@@ -3157,6 +3223,10 @@ interface CorePlugins {
3157
3223
  * Entity Plugin handles all operations related to an entity and generate entity specified events
3158
3224
  */
3159
3225
  readonly entity: PluginWithState<EntityPluginState>;
3226
+ /**
3227
+ * NormalizeTable plugin makes sure each table in editor has TBODY/THEAD/TFOOT tag around TR tags
3228
+ */
3229
+ readonly normalizeTable: EditorPlugin;
3160
3230
  /**
3161
3231
  * Lifecycle plugin handles editor initialization and disposing
3162
3232
  */
@@ -3369,6 +3439,8 @@ interface CoreApiMap {
3369
3439
  * @param includeSelf True to transform the root node as well, otherwise false
3370
3440
  * @param callback The callback function to invoke before do color transformation
3371
3441
  * @param direction To specify the transform direction, light to dark, or dark to light
3442
+ * @param forceTransform By default this function will only work when editor core is in dark mode.
3443
+ * Pass true to this value to force do color transformation even editor core is in light mode
3372
3444
  */
3373
3445
  transformColor: TransformColor;
3374
3446
  /**
@@ -3491,7 +3563,7 @@ type SelectRange = (core: EditorCore, range: Range, skipSameRange?: boolean) =>
3491
3563
  * @param content HTML content to set in
3492
3564
  * @param triggerContentChangedEvent True to trigger a ContentChanged event. Default value is true
3493
3565
  */
3494
- type SetContent = (core: EditorCore, content: string, triggerContentChangedEvent: boolean) => void;
3566
+ type SetContent = (core: EditorCore, content: string, triggerContentChangedEvent: boolean, metadata?: ContentMetadata) => void;
3495
3567
 
3496
3568
  /**
3497
3569
  * Switch the Shadow Edit mode of editor On/Off
@@ -3507,8 +3579,10 @@ type SwitchShadowEdit = (core: EditorCore, isOn: boolean) => void;
3507
3579
  * @param includeSelf True to transform the root node as well, otherwise false
3508
3580
  * @param callback The callback function to invoke before do color transformation
3509
3581
  * @param direction To specify the transform direction, light to dark, or dark to light
3582
+ * @param forceTransform By default this function will only work when editor core is in dark mode.
3583
+ * Pass true to this value to force do color transformation even editor core is in light mode
3510
3584
  */
3511
- type TransformColor = (core: EditorCore, rootNode: Node, includeSelf: boolean, callback: () => void, direction: ColorTransformDirection) => void;
3585
+ type TransformColor = (core: EditorCore, rootNode: Node, includeSelf: boolean, callback: () => void, direction: ColorTransformDirection, forceTransform?: boolean) => void;
3512
3586
 
3513
3587
  /**
3514
3588
  * Trigger a plugin event
@@ -3546,9 +3620,15 @@ interface EditorOptions {
3546
3620
  */
3547
3621
  defaultFormat?: DefaultFormat;
3548
3622
  /**
3623
+ * @deprecated Use undoMetadataSnapshotService instead
3549
3624
  * Undo snapshot service. Use this parameter to customize the undo snapshot service.
3550
3625
  */
3551
- undoSnapshotService?: UndoSnapshotsService;
3626
+ undoSnapshotService?: UndoSnapshotsService<string>;
3627
+ /**
3628
+ * Undo snapshot service based on content metadata. Use this parameter to customize the undo snapshot service.
3629
+ * When this property is set, value of undoSnapshotService will be ignored.
3630
+ */
3631
+ undoMetadataSnapshotService?: UndoSnapshotsService<Snapshot>;
3552
3632
  /**
3553
3633
  * Initial HTML content
3554
3634
  * Default value is whatever already inside the editor content DIV
@@ -3815,6 +3895,10 @@ interface TableFeatureSettings {
3815
3895
  * @default true for Chrome and safari, false for other browsers since they already have correct behavior
3816
3896
  */
3817
3897
  upDownInTable: boolean;
3898
+ /**
3899
+ * IndentTableOnTab edit feature, provides the ability to indent the table if it is all cells are selected.
3900
+ */
3901
+ indentTableOnTab: boolean;
3818
3902
  }
3819
3903
 
3820
3904
  /**
@@ -3866,7 +3950,7 @@ interface CustomReplacement {
3866
3950
  /**
3867
3951
  * Represent an interface to provide functionalities for Undo Snapshots
3868
3952
  */
3869
- interface UndoSnapshotsService {
3953
+ interface UndoSnapshotsService<T = string> {
3870
3954
  /**
3871
3955
  * Check whether can move current undo snapshot with the given step
3872
3956
  * @param step The step to check, can be positive, negative or 0
@@ -3878,12 +3962,12 @@ interface UndoSnapshotsService {
3878
3962
  * @param step The step to move
3879
3963
  * @returns If can move with the given step, returns the snapshot after move, otherwise null
3880
3964
  */
3881
- move(step: number): string;
3965
+ move(step: number): T;
3882
3966
  /**
3883
3967
  * Add a new undo snapshot
3884
3968
  * @param snapshot The snapshot to add
3885
3969
  */
3886
- addSnapshot(snapshot: string, isAutoCompleteSnapshot: boolean): void;
3970
+ addSnapshot(snapshot: T, isAutoCompleteSnapshot: boolean): void;
3887
3971
  /**
3888
3972
  * Clear all undo snapshots after the current one
3889
3973
  */
@@ -4006,7 +4090,7 @@ interface VCell {
4006
4090
  /**
4007
4091
  * The table cell object. The value will be null if this is an expanded virtual cell
4008
4092
  */
4009
- td?: HTMLTableCellElement;
4093
+ td?: HTMLTableCellElement | null;
4010
4094
  /**
4011
4095
  * Whether this cell is spanned from left
4012
4096
  */
@@ -4290,7 +4374,7 @@ interface UndoPluginState {
4290
4374
  /**
4291
4375
  * Snapshot service for undo, it helps handle snapshot add, remove and retrieve
4292
4376
  */
4293
- snapshotsService: UndoSnapshotsService;
4377
+ snapshotsService: UndoSnapshotsService<Snapshot>;
4294
4378
  /**
4295
4379
  * Whether restoring of undo snapshot is in progress.
4296
4380
  */
@@ -4436,7 +4520,7 @@ type SizeTransformer = (size: number) => number;
4436
4520
  * @param rootNode Root node of the scope, the block element will be inside of this node
4437
4521
  * @param node The node to get BlockElement start from
4438
4522
  */
4439
- function getBlockElementAtNode(rootNode: Node, node: Node): BlockElement;
4523
+ function getBlockElementAtNode(rootNode: Node, node: Node | null): BlockElement | null;
4440
4524
 
4441
4525
  /**
4442
4526
  * Get the first/last BlockElement of under the root node.
@@ -4444,7 +4528,7 @@ function getBlockElementAtNode(rootNode: Node, node: Node): BlockElement;
4444
4528
  * @param rootNode The root node to get BlockElement from
4445
4529
  * @param isFirst True to get first BlockElement, false to get last BlockElement
4446
4530
  */
4447
- function getFirstLastBlockElement(rootNode: Node, isFirst: boolean): BlockElement;
4531
+ function getFirstLastBlockElement(rootNode: Node, isFirst: boolean): BlockElement | null;
4448
4532
 
4449
4533
  /**
4450
4534
  * The provides traversing of content inside editor.
@@ -4489,28 +4573,28 @@ class ContentTraverser implements IContentTraverser {
4489
4573
  /**
4490
4574
  * Get current block
4491
4575
  */
4492
- get currentBlockElement(): BlockElement;
4576
+ get currentBlockElement(): BlockElement | null;
4493
4577
  /**
4494
4578
  * Get next block element
4495
4579
  */
4496
- getNextBlockElement(): BlockElement;
4580
+ getNextBlockElement(): BlockElement | null;
4497
4581
  /**
4498
4582
  * Get previous block element
4499
4583
  */
4500
- getPreviousBlockElement(): BlockElement;
4584
+ getPreviousBlockElement(): BlockElement | null;
4501
4585
  private getPreviousNextBlockElement;
4502
4586
  /**
4503
4587
  * Current inline element getter
4504
4588
  */
4505
- get currentInlineElement(): InlineElement;
4589
+ get currentInlineElement(): InlineElement | null;
4506
4590
  /**
4507
4591
  * Get next inline element
4508
4592
  */
4509
- getNextInlineElement(): InlineElement;
4593
+ getNextInlineElement(): InlineElement | null;
4510
4594
  /**
4511
4595
  * Get previous inline element
4512
4596
  */
4513
- getPreviousInlineElement(): InlineElement;
4597
+ getPreviousInlineElement(): InlineElement | null;
4514
4598
  private getPreviousNextInlineElement;
4515
4599
  }
4516
4600
 
@@ -4544,12 +4628,12 @@ class PositionContentSearcher implements IPositionContentSearcher {
4544
4628
  * Get the inline element before position
4545
4629
  * @returns The inlineElement before position
4546
4630
  */
4547
- getInlineElementBefore(): InlineElement;
4631
+ getInlineElementBefore(): InlineElement | null;
4548
4632
  /**
4549
4633
  * Get the inline element after position
4550
4634
  * @returns The inline element after position
4551
4635
  */
4552
- getInlineElementAfter(): InlineElement;
4636
+ getInlineElementAfter(): InlineElement | null;
4553
4637
  /**
4554
4638
  * Get X number of chars before position
4555
4639
  * The actual returned chars may be less than what is requested.
@@ -4565,7 +4649,7 @@ class PositionContentSearcher implements IPositionContentSearcher {
4565
4649
  * @param exactMatch Whether it is an exact match
4566
4650
  * @returns The range for the matched text, null if unable to find a match
4567
4651
  */
4568
- getRangeFromText(text: string, exactMatch: boolean): Range;
4652
+ getRangeFromText(text: string, exactMatch: boolean): Range | null;
4569
4653
  /**
4570
4654
  * Get text section before position till stop condition is met.
4571
4655
  * This offers consumers to retrieve text section by section
@@ -4579,7 +4663,7 @@ class PositionContentSearcher implements IPositionContentSearcher {
4579
4663
  * Get first non textual inline element before position
4580
4664
  * @returns First non textual inline element before position or null if no such element exists
4581
4665
  */
4582
- getNearestNonTextInlineElement(): InlineElement;
4666
+ getNearestNonTextInlineElement(): InlineElement | null;
4583
4667
  /**
4584
4668
  * Continue traversing backward till stop condition is met or begin of block is reached
4585
4669
  */
@@ -4591,14 +4675,14 @@ class PositionContentSearcher implements IPositionContentSearcher {
4591
4675
  * @param rootNode The root node of current scope
4592
4676
  * @param node The node to get InlineElement from
4593
4677
  */
4594
- function getInlineElementAtNode(rootNode: Node, node: Node): InlineElement;
4678
+ function getInlineElementAtNode(rootNode: Node, node: Node | null): InlineElement;
4595
4679
 
4596
4680
  /**
4597
4681
  * Get the inline element at a node
4598
4682
  * @param parentBlock Parent BlockElement of this node
4599
4683
  * @param node The node to get InlineElement from
4600
4684
  */
4601
- function getInlineElementAtNode(parentBlock: BlockElement, node: Node): InlineElement;
4685
+ function getInlineElementAtNode(parentBlock: BlockElement, node: Node | null): InlineElement;
4602
4686
 
4603
4687
  /**
4604
4688
  * This is an inline element representing an Html image
@@ -4668,9 +4752,9 @@ class NodeInlineElement implements InlineElement {
4668
4752
  */
4669
4753
  class PartialInlineElement implements InlineElement {
4670
4754
  private inlineElement;
4671
- private start?;
4672
- private end?;
4673
- constructor(inlineElement: InlineElement, start?: NodePosition, end?: NodePosition);
4755
+ private start;
4756
+ private end;
4757
+ constructor(inlineElement: InlineElement, start?: NodePosition | null, end?: NodePosition | null);
4674
4758
  /**
4675
4759
  * Get the full inline element that this partial inline decorates
4676
4760
  */
@@ -4698,11 +4782,11 @@ class PartialInlineElement implements InlineElement {
4698
4782
  /**
4699
4783
  * Get next partial inline element if it is not at the end boundary yet
4700
4784
  */
4701
- get nextInlineElement(): PartialInlineElement;
4785
+ get nextInlineElement(): PartialInlineElement | null;
4702
4786
  /**
4703
4787
  * Get previous partial inline element if it is not at the begin boundary yet
4704
4788
  */
4705
- get previousInlineElement(): PartialInlineElement;
4789
+ get previousInlineElement(): PartialInlineElement | null;
4706
4790
  /**
4707
4791
  * Checks if it contains a position
4708
4792
  */
@@ -4725,8 +4809,8 @@ class PartialInlineElement implements InlineElement {
4725
4809
  * Apply style using a styler function to the given container node in the given range
4726
4810
  * @param container The container node to apply style to
4727
4811
  * @param styler The styler function
4728
- * @param from From position
4729
- * @param to To position
4812
+ * @param fromPosition From position
4813
+ * @param toPosition To position
4730
4814
  */
4731
4815
  function applyTextStyle(container: Node, styler: (node: HTMLElement, isInnerNode?: boolean) => any, from?: NodePosition, to?: NodePosition): void;
4732
4816
 
@@ -4840,7 +4924,7 @@ function collapseNodes(root: Node, start: Node, end: Node, canSplitParent: boole
4840
4924
  * @returns True if contained is inside container, or they are the same node when treatSameNodeAsContain is true.
4841
4925
  * Otherwise false.
4842
4926
  */
4843
- function contains(container: Node | null, contained: Node | null, treatSameNodeAsContain?: boolean): boolean;
4927
+ function contains(container: Node | null | undefined, contained: Node | null | undefined, treatSameNodeAsContain?: boolean): boolean;
4844
4928
 
4845
4929
  /**
4846
4930
  * Test if a node contains a given range
@@ -4848,7 +4932,7 @@ function contains(container: Node | null, contained: Node | null, treatSameNodeA
4848
4932
  * @param contained The range to check if it is inside container
4849
4933
  * @returns True if contained is inside container, otherwise false
4850
4934
  */
4851
- function contains(container: Node | null, contained: Range | null): boolean;
4935
+ function contains(container: Node | null | undefined, contained: Range | null | undefined): boolean;
4852
4936
 
4853
4937
  /**
4854
4938
  * Find closest element ancestor start from the given node which matches the given selector
@@ -4910,7 +4994,7 @@ type PendableFormatNames = keyof PendableFormatState;
4910
4994
  * @param node The node to get tag of
4911
4995
  * @returns Tag name in upper case if the given node is an Element, or empty string otherwise
4912
4996
  */
4913
- function getTagOfNode(node: Node): string;
4997
+ function getTagOfNode(node: Node | null): string;
4914
4998
 
4915
4999
  /**
4916
5000
  * Checks if the node is a block like element. Block like element are usually those P, DIV, LI, TD etc.
@@ -4955,7 +5039,7 @@ function matchLink(url: string): LinkData | null;
4955
5039
  * @param range The selection range to query with. This is required when scope is not Body
4956
5040
  * @returns HTML Element array of the query result
4957
5041
  */
4958
- function queryElements(container: ParentNode, selector: string, forEachCallback?: (node: HTMLElement) => any, scope?: QueryScope, range?: Range): HTMLElement[];
5042
+ function queryElements(container: ParentNode, selector: string, forEachCallback?: ((node: HTMLElement) => any) | null, scope?: QueryScope, range?: Range): HTMLElement[];
4959
5043
 
4960
5044
  /**
4961
5045
  * Split parent node of the given node before/after the given node.
@@ -5162,23 +5246,23 @@ class VTable {
5162
5246
  /**
5163
5247
  * Virtual cells
5164
5248
  */
5165
- cells: VCell[][];
5249
+ cells: VCell[][] | null;
5166
5250
  /**
5167
5251
  * Current row index
5168
5252
  */
5169
- row: number;
5253
+ row: number | undefined;
5170
5254
  /**
5171
5255
  * Current column index
5172
5256
  */
5173
- col: number;
5257
+ col: number | undefined;
5174
5258
  /**
5175
5259
  * Selected range of cells with the coordinates of the first and last cell selected.
5176
5260
  */
5177
- selection: TableSelection;
5261
+ selection: TableSelection | null;
5178
5262
  /**
5179
5263
  * Current format of the table
5180
5264
  */
5181
- formatInfo: Required<TableFormat>;
5265
+ formatInfo: Required<TableFormat> | null;
5182
5266
  private trs;
5183
5267
  /**
5184
5268
  * Create a new instance of VTable object using HTML TABLE or TD node
@@ -5208,6 +5292,8 @@ class VTable {
5208
5292
  * @param operation Table operation
5209
5293
  */
5210
5294
  edit(operation: TableOperation): void;
5295
+ setAlignmentToSelectedCells(firstRow: number, lastRow: number, firstColumn: number, lastColumn: number, alignmentType: string, isVertical?: boolean): void;
5296
+ private mergeCells;
5211
5297
  /**
5212
5298
  * Loop each cell of current column and invoke a callback function
5213
5299
  * @param callback The callback function to invoke
@@ -5253,13 +5339,13 @@ class VTable {
5253
5339
  /**
5254
5340
  * Get current HTML table cell object. If the current table cell is a virtual expanded cell, return its root cell
5255
5341
  */
5256
- getCurrentTd(): HTMLTableCellElement;
5342
+ getCurrentTd(): HTMLTableCellElement | null;
5257
5343
  /**
5258
5344
  * Get the Table Cell in a provided coordinate
5259
5345
  * @param row row of the cell
5260
5346
  * @param col column of the cell
5261
5347
  */
5262
- getTd(row: number, col: number): HTMLTableCellElement;
5348
+ getTd(row: number | undefined, col: number | undefined): HTMLTableCellElement | null;
5263
5349
  private forEachCellOfColumn;
5264
5350
  private forEachCellOfRow;
5265
5351
  private recalculateSpans;
@@ -5270,6 +5356,14 @@ class VTable {
5270
5356
  private normalizeSize;
5271
5357
  }
5272
5358
 
5359
+ /**
5360
+ * Check if the whole table is selected
5361
+ * @param vTable VTable to check whether all cells are selected
5362
+ * @param selection Table selection with first cell selected and last cell selected coordinates.
5363
+ * @returns
5364
+ */
5365
+ function isWholeTableSelected(vTable: VTable, selection: TableSelection): boolean;
5366
+
5273
5367
  /**
5274
5368
  * Represent a bullet or a numbering list
5275
5369
  *
@@ -5354,8 +5448,10 @@ class VList {
5354
5448
  * @param indentation Specify to outdent
5355
5449
  * @param softOutdent (Optional) True to make the item to by dummy (no bullet or number) if the item is not dummy,
5356
5450
  * otherwise outdent the item
5451
+ * @param preventItemRemoval (Optional) True to prevent the indentation to remove the bullet when outdenting a first
5452
+ * level list item, by default is false
5357
5453
  */
5358
- setIndentation(start: NodePosition, end: NodePosition, indentation: Indentation.Decrease, softOutdent?: boolean): void;
5454
+ setIndentation(start: NodePosition, end: NodePosition, indentation: Indentation.Decrease, softOutdent?: boolean, preventItemRemoval?: boolean): void;
5359
5455
  /**
5360
5456
  * Change list type of the given range of this list.
5361
5457
  * If some of the items are not real list item yet, this will make them to be list item with given type
@@ -5382,6 +5478,25 @@ class VList {
5382
5478
  mergeVList(list: VList): void;
5383
5479
  /**
5384
5480
  * Get the index of the List Item in the current List
5481
+ * If the root list is:
5482
+ * Ordered list, the listIndex start count is going to be the start property of the OL - 1,
5483
+ * @example For example if we want to find the index of Item 2 in the list below, the returned index is going to be 6
5484
+ * * ```html
5485
+ * <ol start="5">
5486
+ * <li>item 1</li>
5487
+ * <li>item 2</li> <!-- Node to find -->
5488
+ * <li>item 3</li>
5489
+ * </ol>
5490
+ * ```
5491
+ * Unordered list, the listIndex start count starts from 0
5492
+ * @example For example if we want to find the index of Item 2 in the list below, the returned index is going to be 2
5493
+ * ```html
5494
+ * <ul>
5495
+ * <li>item 1</li>
5496
+ * <li>item 2</li> <!-- Node to find -->
5497
+ * <li>item 3</li>
5498
+ * </ul>
5499
+ * ```
5385
5500
  * @param input List item to find in the root list
5386
5501
  */
5387
5502
  getListItemIndex(input: Node): number;
@@ -5462,8 +5577,13 @@ class VListItem {
5462
5577
  /**
5463
5578
  * Outdent this item
5464
5579
  * If this item is already not an list item, it will be no op
5580
+ * @param preventItemRemoval Whether prevent the list item to be removed for the listItem by default false
5465
5581
  */
5466
- outdent(): void;
5582
+ outdent(preventItemRemoval?: boolean): void;
5583
+ /**
5584
+ * Add negative margin to the List item
5585
+ */
5586
+ addNegativeMargins(): void;
5467
5587
  /**
5468
5588
  * Change list type of this item
5469
5589
  * @param targetType The target list type to change to
@@ -5495,7 +5615,7 @@ class VListItem {
5495
5615
  * @param startNode (Optional) When specified, try get VList which will contain this node.
5496
5616
  * If not specified, get VList from selection of this region
5497
5617
  */
5498
- function createVListFromRegion(region: Region, includeSiblingLists?: boolean, startNode?: Node): VList;
5618
+ function createVListFromRegion(region: Region, includeSiblingLists?: boolean, startNode?: Node): VList | null;
5499
5619
 
5500
5620
  /**
5501
5621
  * Represent a chain of list nodes.
@@ -5524,7 +5644,7 @@ class VListChain {
5524
5644
  * @param container The container node to create list at
5525
5645
  * @param startNumber Start number of the new list
5526
5646
  */
5527
- createVListAtBlock(container: Node, startNumber: number): VList;
5647
+ createVListAtBlock(container: Node, startNumber: number): VList | null;
5528
5648
  /**
5529
5649
  * After change the lists, commit the change to all lists in this chain to update the list number,
5530
5650
  * and clear the temporary dataset values added to list node
@@ -5725,7 +5845,7 @@ function getPositionRect(position: NodePosition): Rect | null;
5725
5845
  * @param targetNode The node to check
5726
5846
  * @returns True if position is at beginning of the node, otherwise false
5727
5847
  */
5728
- function isPositionAtBeginningOf(position: NodePosition, targetNode: Node): boolean;
5848
+ function isPositionAtBeginningOf(position: NodePosition, targetNode: Node | null): boolean;
5729
5849
 
5730
5850
  /**
5731
5851
  * Get path of the given selection range related to the given rootNode
@@ -5744,14 +5864,26 @@ function getSelectionPath(rootNode: Node, range: Range | null): SelectionPath |
5744
5864
  function getHtmlWithSelectionPath(rootNode: HTMLElement | DocumentFragment, range: Range): string;
5745
5865
 
5746
5866
  /**
5747
- * Restore inner Html of a root element from given html string. If the string contains selection path,
5867
+ * @deprecated Use setHtmlWithMetadata instead
5868
+ * Restore inner HTML of a root element from given html string. If the string contains selection path,
5748
5869
  * remove the selection path and return a range represented by the path
5749
5870
  * @param root The root element
5750
- * @param html The html to restore
5871
+ * @param html The HTML to restore
5872
+ * @param trustedHTMLHandler An optional trusted HTML handler to convert HTML string to security string
5751
5873
  * @returns A selection range if the html contains a valid selection path, otherwise null
5752
5874
  */
5753
5875
  function setHtmlWithSelectionPath(rootNode: HTMLElement, html: string, trustedHTMLHandler?: TrustedHTMLHandler): Range | null;
5754
5876
 
5877
+ /**
5878
+ * Restore inner HTML of a root element from given html string. If the string contains metadata,
5879
+ * remove it from DOM tree and return the metadata
5880
+ * @param root The root element
5881
+ * @param html The HTML to restore
5882
+ * @param trustedHTMLHandler An optional trusted HTML handler to convert HTML string to security string
5883
+ * @returns Content metadata if any, or undefined
5884
+ */
5885
+ function setHtmlWithMetadata(rootNode: HTMLElement, html: string, trustedHTMLHandler?: TrustedHTMLHandler): ContentMetadata | undefined;
5886
+
5755
5887
  /**
5756
5888
  * Add the given range into selection of the given document
5757
5889
  * @param range The range to select
@@ -5764,10 +5896,28 @@ function addRangeToSelection(range: Range, skipSameRange?: boolean): void;
5764
5896
  /**
5765
5897
  * Add a new snapshot to the given snapshots data structure
5766
5898
  * @param snapshots The snapshots data structure to add new snapshot into
5767
- * @param snapshot The snapshot to add
5899
+ * @param html The snapshot HTML to add
5900
+ * @param isAutoCompleteSnapshot Whether this is a snapshot before auto complete action
5901
+ */
5902
+ function addSnapshot(snapshots: Snapshots<string>, html: string, isAutoCompleteSnapshot: boolean): void;
5903
+
5904
+ /**
5905
+ * Add a new snapshot to the given snapshots data structure
5906
+ * @param snapshots The snapshots data structure to add new snapshot into
5907
+ * @param snapshot The generic snapshot object to add
5768
5908
  * @param isAutoCompleteSnapshot Whether this is a snapshot before auto complete action
5909
+ * @param getLength A callback function to calculate length of the snapshot
5910
+ * @param isSame A callback function to check if the given snapshots are the same
5769
5911
  */
5770
- function addSnapshot(snapshots: Snapshots, snapshot: string, isAutoCompleteSnapshot: boolean): void;
5912
+ function addSnapshot<T>(snapshots: Snapshots<T>, snapshot: T, isAutoCompleteSnapshot: boolean, getLength: (snapshot: T) => number, isSame: (snapshot1: T, snapshot2: T) => boolean): void;
5913
+
5914
+ /**
5915
+ * Add a new snapshot to the given snapshots data structure
5916
+ * @param snapshots The snapshots data structure to add new snapshot into
5917
+ * @param snapshot The snapshot object to add
5918
+ * @param isAutoCompleteSnapshot Whether this is a snapshot before auto complete action
5919
+ */
5920
+ function addSnapshotV2(snapshots: Snapshots<Snapshot>, snapshot: Snapshot, isAutoCompleteSnapshot: boolean): void;
5771
5921
 
5772
5922
  /**
5773
5923
  * Check whether can move current snapshot with the given step
@@ -5775,13 +5925,25 @@ function addSnapshot(snapshots: Snapshots, snapshot: string, isAutoCompleteSnaps
5775
5925
  * @param step The step to check, can be positive, negative or 0
5776
5926
  * @returns True if can move current snapshot with the given step, otherwise false
5777
5927
  */
5778
- function canMoveCurrentSnapshot(snapshots: Snapshots, step: number): boolean;
5928
+ function canMoveCurrentSnapshot<T = string>(snapshots: Snapshots<T>, step: number): boolean;
5929
+
5930
+ /**
5931
+ * Clear all snapshots after the current one
5932
+ * @param snapshots The snapshots data structure to clear
5933
+ */
5934
+ function clearProceedingSnapshots(snapshots: Snapshots<string>): void;
5779
5935
 
5780
5936
  /**
5781
5937
  * Clear all snapshots after the current one
5782
5938
  * @param snapshots The snapshots data structure to clear
5783
5939
  */
5784
- function clearProceedingSnapshots(snapshots: Snapshots): void;
5940
+ function clearProceedingSnapshots<T>(snapshots: Snapshots<T>, getLength: (snapshot: T) => number): void;
5941
+
5942
+ /**
5943
+ * Clear all snapshots after the current one
5944
+ * @param snapshots The snapshots data structure to clear
5945
+ */
5946
+ function clearProceedingSnapshotsV2(snapshots: Snapshots<Snapshot>): void;
5785
5947
 
5786
5948
  /**
5787
5949
  * Move current snapshot with the given step if can move this step. Otherwise no action and return null
@@ -5789,7 +5951,7 @@ function clearProceedingSnapshots(snapshots: Snapshots): void;
5789
5951
  * @param step The step to move
5790
5952
  * @returns If can move with the given step, returns the snapshot after move, otherwise null
5791
5953
  */
5792
- function moveCurrentSnapshot(snapshots: Snapshots, step: number): string | null;
5954
+ function moveCurrentSnapshot<T = string>(snapshots: Snapshots<T>, step: number): T | null;
5793
5955
 
5794
5956
  /**
5795
5957
  * @deprecated
@@ -5801,12 +5963,12 @@ const moveCurrentSnapsnot: typeof moveCurrentSnapshot;
5801
5963
  * Create initial snapshots
5802
5964
  * @param maxSize max size of all snapshots
5803
5965
  */
5804
- function createSnapshots(maxSize: number): Snapshots;
5966
+ function createSnapshots<T = string>(maxSize: number): Snapshots<T>;
5805
5967
 
5806
5968
  /**
5807
5969
  * Whether there is a snapshot added before auto complete and it can be undone now
5808
5970
  */
5809
- function canUndoAutoComplete(snapshots: Snapshots): boolean;
5971
+ function canUndoAutoComplete<T = string>(snapshots: Snapshots<T>): boolean;
5810
5972
 
5811
5973
  /**
5812
5974
  * HTML sanitizer class provides two features:
@@ -5985,7 +6147,7 @@ function adjustInsertPosition(root: HTMLElement, nodeToInsert: Node, position: N
5985
6147
  * @param core The EditorCore object.
5986
6148
  * @param range The range to delete
5987
6149
  */
5988
- function deleteSelectedContent(root: HTMLElement, range: Range): Position;
6150
+ function deleteSelectedContent(root: HTMLElement, range: Range): null;
5989
6151
 
5990
6152
  /**
5991
6153
  * get block element's text content.
@@ -6303,6 +6465,11 @@ class Editor implements IEditor {
6303
6465
  * @returns True if the editor is in dark mode, otherwise false
6304
6466
  */
6305
6467
  isDarkMode(): boolean;
6468
+ /**
6469
+ * Transform the given node and all its child nodes to dark mode color if editor is in dark mode
6470
+ * @param node The node to transform
6471
+ */
6472
+ transformToDarkColor(node: Node): void;
6306
6473
  /**
6307
6474
  * Make the editor in "Shadow Edit" mode.
6308
6475
  * In Shadow Edit mode, all format change will finally be ignored.
@@ -7325,6 +7492,7 @@ class TableCellSelection implements EditorPlugin {
7325
7492
  private vTable;
7326
7493
  private firstTable;
7327
7494
  private targetTable;
7495
+ private preventKeyUp;
7328
7496
  constructor();
7329
7497
  /**
7330
7498
  * Get a friendly name of this plugin