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