roosterjs 8.13.0 → 8.14.0

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.13.0)
1
+ // Type definitions for roosterjs (Version 8.14.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -343,6 +343,7 @@ export const enum Keys {
343
343
  BACKSPACE = 8,
344
344
  TAB = 9,
345
345
  ENTER = 13,
346
+ SHIFT = 16,
346
347
  ESCAPE = 27,
347
348
  SPACE = 32,
348
349
  PAGEUP = 33,
@@ -1078,7 +1079,81 @@ export const enum KnownCreateElementDataIndex {
1078
1079
  TableHorizontalResizer = 7,
1079
1080
  TableVerticalResizer = 8,
1080
1081
  TableResizerLTR = 9,
1081
- TableResizerRTL = 10
1082
+ TableResizerRTL = 10,
1083
+ /**
1084
+ * Table Selector element
1085
+ */
1086
+ TableSelector = 11
1087
+ }
1088
+
1089
+ /**
1090
+ * Table format border
1091
+ */
1092
+ export const enum TableBorderFormat {
1093
+ /**
1094
+ * All border of the table are displayed
1095
+ * __ __ __
1096
+ * |__|__|__|
1097
+ * |__|__|__|
1098
+ * |__|__|__|
1099
+ */
1100
+ DEFAULT = 0,
1101
+ /**
1102
+ * Middle vertical border are not displayed
1103
+ * __ __ __
1104
+ * |__ __ __|
1105
+ * |__ __ __|
1106
+ * |__ __ __|
1107
+ */
1108
+ LIST_WITH_SIDE_BORDERS = 1,
1109
+ /**
1110
+ * All borders except header rows borders are displayed
1111
+ * __ __ __
1112
+ * __|__|__
1113
+ * __|__|__
1114
+ */
1115
+ NO_HEADER_BORDERS = 2,
1116
+ /**
1117
+ * The left and right border of the table are not displayed
1118
+ * __ __ __
1119
+ * __|__|__
1120
+ * __|__|__
1121
+ * __|__|__
1122
+ */
1123
+ NO_SIDE_BORDERS = 3,
1124
+ /**
1125
+ * Only the borders that divides the header row, first column and externals are displayed
1126
+ * __ __ __
1127
+ * |__ __ __|
1128
+ * | | |
1129
+ * |__|__ __|
1130
+ */
1131
+ FIRST_COLUMN_HEADER_EXTERNAL = 4,
1132
+ /**
1133
+ * The header row has no vertical border, except for the first one
1134
+ * The only horizontal border of the table is the top and bottom of header row
1135
+ * __ __ __
1136
+ * |__ __ __
1137
+ * | | |
1138
+ * | | |
1139
+ */
1140
+ ESPECIAL_TYPE_1 = 5,
1141
+ /**
1142
+ * The header row has no vertical border, except for the first one
1143
+ * The first column has no horizontal border, except for the first one
1144
+ * __ __ __
1145
+ * |__ __ __
1146
+ * | |__|__|
1147
+ * | |__|__|
1148
+ */
1149
+ ESPECIAL_TYPE_2 = 6,
1150
+ /**
1151
+ * The only borders are the bottom of header row and the right border of first column
1152
+ * __ __ __
1153
+ * |
1154
+ * |
1155
+ */
1156
+ ESPECIAL_TYPE_3 = 7
1082
1157
  }
1083
1158
 
1084
1159
  /**
@@ -2183,25 +2258,77 @@ export interface Snapshots {
2183
2258
  */
2184
2259
  export interface TableFormat {
2185
2260
  /**
2186
- * Background color for even rows
2261
+ * Top border color for each row
2187
2262
  */
2188
- bgColorEven: string;
2263
+ topBorderColor?: string | null;
2189
2264
  /**
2190
- * Background color for odd rows
2265
+ * Bottom border color for each row
2191
2266
  */
2192
- bgColorOdd: string;
2267
+ bottomBorderColor?: string | null;
2193
2268
  /**
2194
- * Top border color for each row
2269
+ * Vertical border color for each row
2195
2270
  */
2196
- topBorderColor: string;
2271
+ verticalBorderColor?: string | null;
2197
2272
  /**
2198
- * Bottom border color for each row
2273
+ * Set header row
2199
2274
  */
2200
- bottomBorderColor: string;
2275
+ hasHeaderRow?: boolean;
2201
2276
  /**
2202
- * Vertical border color for each row
2277
+ * Header row background color for even cells
2278
+ */
2279
+ headerRowColor?: string | null;
2280
+ /**
2281
+ * Set first column
2282
+ */
2283
+ hasFirstColumn?: boolean;
2284
+ /**
2285
+ * Set banded columns
2286
+ */
2287
+ hasBandedColumns?: boolean;
2288
+ /**
2289
+ * Set banded rows
2290
+ */
2291
+ hasBandedRows?: boolean;
2292
+ /**
2293
+ * Background color for even row or even columns
2294
+ */
2295
+ bgColorEven?: string | null;
2296
+ /**
2297
+ * Background color for odd row or odd columns
2298
+ */
2299
+ bgColorOdd?: string | null;
2300
+ /**
2301
+ * Table Borders Type
2203
2302
  */
2204
- verticalBorderColor: string;
2303
+ tableBorderFormat?: TableBorderFormat;
2304
+ }
2305
+
2306
+ /**
2307
+ * Represents a selection made inside of a table
2308
+ */
2309
+ export interface TableSelection {
2310
+ /**
2311
+ * First Cell selection x and y position in the table
2312
+ */
2313
+ firstCell: Coordinates;
2314
+ /**
2315
+ * Last Cell selection x and y position in the table
2316
+ */
2317
+ lastCell: Coordinates;
2318
+ }
2319
+
2320
+ /**
2321
+ * Represents 2D Coordinates
2322
+ */
2323
+ export interface Coordinates {
2324
+ /**
2325
+ * X position of the cell
2326
+ */
2327
+ x: number;
2328
+ /**
2329
+ * Y position of the cell
2330
+ */
2331
+ y: number;
2205
2332
  }
2206
2333
 
2207
2334
  /**
@@ -2541,6 +2668,12 @@ export interface IEditor {
2541
2668
  * @returns current selection range, or null if editor never got focus before
2542
2669
  */
2543
2670
  getSelectionRange(tryGetFromCache?: boolean): Range;
2671
+ /**
2672
+ * Get current selection range from Editor.
2673
+ * It does a live pull on the selection.
2674
+ * @returns current selection range, or null if editor never got focus before
2675
+ */
2676
+ getSelectionRangeEx(): SelectionRangeEx;
2544
2677
  /**
2545
2678
  * Get current selection in a serializable format
2546
2679
  * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.
@@ -2721,7 +2854,7 @@ export interface IEditor {
2721
2854
  /**
2722
2855
  * Get a content traverser for current selection
2723
2856
  */
2724
- getSelectionTraverser(): IContentTraverser;
2857
+ getSelectionTraverser(range?: Range): IContentTraverser;
2725
2858
  /**
2726
2859
  * Get a content traverser for current block element start from specified position
2727
2860
  * @param startFrom Start position of the traverser. Default value is ContentPosition.SelectionStart
@@ -3105,6 +3238,13 @@ export interface CoreApiMap {
3105
3238
  * @returns A Range object of the selection range
3106
3239
  */
3107
3240
  getSelectionRange: GetSelectionRange;
3241
+ /**
3242
+ * Get current or cached selection range
3243
+ * @param core The EditorCore object
3244
+ * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now
3245
+ * @returns A Range object of the selection range
3246
+ */
3247
+ getSelectionRangeEx: GetSelectionRangeEx;
3108
3248
  /**
3109
3249
  * Get style based format state from current selection, including font name/size and colors
3110
3250
  * @param core The EditorCore objects
@@ -3218,6 +3358,13 @@ export type GetContent = (core: EditorCore, mode: GetContentMode) => string;
3218
3358
  */
3219
3359
  export type GetSelectionRange = (core: EditorCore, tryGetFromCache: boolean) => Range;
3220
3360
 
3361
+ /**
3362
+ * Get current selection range
3363
+ * @param core The EditorCore object
3364
+ * @returns A Range object of the selection range
3365
+ */
3366
+ export type GetSelectionRangeEx = (core: EditorCore) => SelectionRangeEx;
3367
+
3221
3368
  /**
3222
3369
  * Get style based format state from current selection, including font name/size and colors
3223
3370
  * @param core The EditorCore objects
@@ -3761,11 +3908,13 @@ export interface VCell {
3761
3908
  */
3762
3909
  spanAbove?: boolean;
3763
3910
  /**
3764
- * The width in pixel of the actual td (including border and padding)
3911
+ * The width in pixel of the actual td (including border and padding).
3912
+ * If the table is under a zoomed container, this value is the visible pixel count after zoom.
3765
3913
  */
3766
3914
  width?: number;
3767
3915
  /**
3768
3916
  * The height in pixel of the actual td (including border and padding)
3917
+ * If the table is under a zoomed container, this value is the visible pixel count after zoom.
3769
3918
  */
3770
3919
  height?: number;
3771
3920
  }
@@ -3849,6 +3998,59 @@ export interface CreateElementData {
3849
3998
  children?: (CreateElementData | string)[];
3850
3999
  }
3851
4000
 
4001
+ /**
4002
+ * Represents normal selection
4003
+ */
4004
+ export interface SelectionRangeExBase<T extends SelectionRangeTypes> {
4005
+ /**
4006
+ * Selection Type definition
4007
+ */
4008
+ type: T;
4009
+ /**
4010
+ * Ranges
4011
+ */
4012
+ ranges: Range[];
4013
+ /**
4014
+ * Whether all the ranges are collapsed
4015
+ */
4016
+ areAllCollapsed: boolean;
4017
+ }
4018
+
4019
+ /**
4020
+ * Represents normal selection
4021
+ */
4022
+ export interface NormalSelectionRange extends SelectionRangeExBase<SelectionRangeTypes.Normal> {
4023
+ }
4024
+
4025
+ /**
4026
+ * Represents the selection made inside of a table.
4027
+ */
4028
+ export interface TableSelectionRange extends SelectionRangeExBase<SelectionRangeTypes.TableSelection> {
4029
+ /**
4030
+ * Table that has cells selected
4031
+ */
4032
+ table: HTMLTableElement;
4033
+ }
4034
+
4035
+ /**
4036
+ * Types of ranges used in editor api getSelectionRangeEx
4037
+ */
4038
+ export type SelectionRangeEx = NormalSelectionRange | TableSelectionRange;
4039
+
4040
+ /**
4041
+ * Types of Selection Ranges that the SelectionRangeEx can return
4042
+ */
4043
+ export const enum SelectionRangeTypes {
4044
+ /**
4045
+ * Normal selection range provided by browser.
4046
+ */
4047
+ Normal = 0,
4048
+ /**
4049
+ * Selection made inside of a single table.
4050
+ */
4051
+ TableSelection = 1
4052
+ }
4053
+
3852
4054
  /**
3853
4055
  * The state object for DOMEventPlugin
3854
4056
  */
@@ -4399,6 +4601,15 @@ export class PartialInlineElement implements InlineElement {
4399
4601
  applyStyle(styler: (element: HTMLElement, isInnerNode?: boolean) => any): void;
4400
4602
  }
4401
4603
 
4604
+ /**
4605
+ * Apply style using a styler function to the given container node in the given range
4606
+ * @param container The container node to apply style to
4607
+ * @param styler The styler function
4608
+ * @param from From position
4609
+ * @param to To position
4610
+ */
4611
+ export function applyTextStyle(container: Node, styler: (node: HTMLElement, isInnerNode?: boolean) => any, from?: NodePosition, to?: NodePosition): void;
4612
+
4402
4613
  /**
4403
4614
  * @deprecated Use extractClipboardItems and extractClipboardItemsForIE instead
4404
4615
  * Extract a Clipboard event
@@ -4450,15 +4661,6 @@ export function extractClipboardItemsForIE(dataTransfer: DataTransfer, callback:
4450
4661
  */
4451
4662
  export function arrayPush<T>(mainArray: T[], itemsArray: T[]): void;
4452
4663
 
4453
- /**
4454
- * Apply style using a styler function to the given container node in the given range
4455
- * @param container The container node to apply style to
4456
- * @param styler The styler function
4457
- * @param from From position
4458
- * @param to To position
4459
- */
4460
- export function applyTextStyle(container: Node, styler: (node: HTMLElement, isInnerNode?: boolean) => any, from?: NodePosition, to?: NodePosition): void;
4461
-
4462
4664
  /**
4463
4665
  * Browser object contains browser and operating system information of current environment
4464
4666
  */
@@ -4493,7 +4695,7 @@ export function changeElementTag<K extends keyof HTMLElementTagNameMap>(element:
4493
4695
  * @param newTag New tag to change to
4494
4696
  * @returns The new element with new tag
4495
4697
  */
4496
- export function changeElementTag(element: HTMLElement, newTag: string): HTMLElement;
4698
+ export function changeElementTag(element: HTMLElement, newTag: string): HTMLElement | null;
4497
4699
 
4498
4700
  /**
4499
4701
  * Collapse nodes within the given start and end nodes to their common ancestor node,
@@ -4518,7 +4720,7 @@ export function collapseNodes(root: Node, start: Node, end: Node, canSplitParent
4518
4720
  * @returns True if contained is inside container, or they are the same node when treatSameNodeAsContain is true.
4519
4721
  * Otherwise false.
4520
4722
  */
4521
- export function contains(container: Node, contained: Node, treatSameNodeAsContain?: boolean): boolean;
4723
+ export function contains(container: Node | null, contained: Node | null, treatSameNodeAsContain?: boolean): boolean;
4522
4724
 
4523
4725
  /**
4524
4726
  * Test if a node contains a given range
@@ -4526,7 +4728,7 @@ export function contains(container: Node, contained: Node, treatSameNodeAsContai
4526
4728
  * @param contained The range to check if it is inside container
4527
4729
  * @returns True if contained is inside container, otherwise false
4528
4730
  */
4529
- export function contains(container: Node, contained: Range): boolean;
4731
+ export function contains(container: Node | null, contained: Range | null): boolean;
4530
4732
 
4531
4733
  /**
4532
4734
  * Find closest element ancestor start from the given node which matches the given selector
@@ -4536,7 +4738,7 @@ export function contains(container: Node, contained: Range): boolean;
4536
4738
  * @returns An HTML element which matches the given selector. If the given start node matches the selector,
4537
4739
  * returns the given node
4538
4740
  */
4539
- export function findClosestElementAncestor(node: Node, root?: Node, selector?: string): HTMLElement;
4741
+ export function findClosestElementAncestor(node: Node | null, root?: Node, selector?: string): HTMLElement | null;
4540
4742
 
4541
4743
  /**
4542
4744
  * @deprecated
@@ -4622,7 +4824,7 @@ export function isVoidHtmlElement(node: Node): boolean;
4622
4824
  * @returns The matched link data, or null if no match found.
4623
4825
  * The link data includes an original url and a normalized url
4624
4826
  */
4625
- export function matchLink(url: string): LinkData;
4827
+ export function matchLink(url: string): LinkData | null;
4626
4828
 
4627
4829
  /**
4628
4830
  * Query HTML elements in the container by a selector string
@@ -4646,7 +4848,7 @@ export function queryElements(container: ParentNode, selector: string, forEachCa
4646
4848
  * we remove it. @default false
4647
4849
  * @returns The new parent node
4648
4850
  */
4649
- export function splitParentNode(node: Node, splitBefore: boolean): Node;
4851
+ export function splitParentNode(node: Node, splitBefore: boolean): Node | null;
4650
4852
 
4651
4853
  /**
4652
4854
  * Split parent node by a balanced node range
@@ -4660,7 +4862,7 @@ export function splitBalancedNodeRange(nodes: Node | Node[]): HTMLElement;
4660
4862
  * Removes the node and keep all children in place, return the parentNode where the children are attached
4661
4863
  * @param node the node to remove
4662
4864
  */
4663
- export function unwrap(node: Node): Node;
4865
+ export function unwrap(node: Node): Node | null;
4664
4866
 
4665
4867
  /**
4666
4868
  * Wrap all the node with html and return the wrapped node, and put the wrapper node under the parent of the first node
@@ -4700,7 +4902,7 @@ export function wrap(nodes: Node | Node[], wrapper?: CreateElementData | KnownCr
4700
4902
  * @param startNode current node to get sibling node from
4701
4903
  * @param skipTags (Optional) tags that child elements will be skipped
4702
4904
  */
4703
- export function getNextLeafSibling(rootNode: Node, startNode: Node, skipTags?: string[]): Node;
4905
+ export function getNextLeafSibling(rootNode: Node, startNode: Node, skipTags?: string[]): Node | null;
4704
4906
 
4705
4907
  /**
4706
4908
  * This walks backwards DOM tree to get next meaningful node
@@ -4708,26 +4910,19 @@ export function getNextLeafSibling(rootNode: Node, startNode: Node, skipTags?: s
4708
4910
  * @param startNode current node to get sibling node from
4709
4911
  * @param skipTags (Optional) tags that child elements will be skipped
4710
4912
  */
4711
- export function getPreviousLeafSibling(rootNode: Node, startNode: Node, skipTags?: string[]): Node;
4913
+ export function getPreviousLeafSibling(rootNode: Node, startNode: Node, skipTags?: string[]): Node | null;
4712
4914
 
4713
4915
  /**
4714
4916
  * Get the first meaningful leaf node
4715
4917
  * @param rootNode Root node to get leaf node from
4716
4918
  */
4717
- export function getFirstLeafNode(rootNode: Node): Node;
4919
+ export function getFirstLeafNode(rootNode: Node): Node | null;
4718
4920
 
4719
4921
  /**
4720
4922
  * Get the last meaningful leaf node
4721
4923
  * @param rootNode Root node to get leaf node from
4722
4924
  */
4723
- export function getLastLeafNode(rootNode: Node): Node;
4724
-
4725
- /**
4726
- * get block element's text content.
4727
- * @param rootNode Root node that the get the textContent of.
4728
- * @returns text content of given text content.
4729
- */
4730
- export function getTextContent(rootNode: Node): string;
4925
+ export function getLastLeafNode(rootNode: Node): Node | null;
4731
4926
 
4732
4927
  /**
4733
4928
  * Split a text node into two parts by an offset number, and return one of them
@@ -4742,7 +4937,7 @@ export function splitTextNode(textNode: Text, offset: number, returnFirstPart: b
4742
4937
  * A ClientRect of all 0 is possible. i.e. chrome returns a ClientRect of 0 when the cursor is on an empty p
4743
4938
  * We validate that and only return a rect when the passed in ClientRect is valid
4744
4939
  */
4745
- export function normalizeRect(clientRect: ClientRect): Rect;
4940
+ export function normalizeRect(clientRect: DOMRect): Rect | null;
4746
4941
 
4747
4942
  /**
4748
4943
  * Convert a named node map to an array
@@ -4789,7 +4984,7 @@ export function safeInstanceOf<T extends keyof W, W extends TargetWindow = Targe
4789
4984
  * @param callback the callback to invoke with data url of the file.
4790
4985
  * If fail to read, dataUrl will be null
4791
4986
  */
4792
- export function readFile(file: File, callback: (dataUrl: string) => void): void;
4987
+ export function readFile(file: File, callback: (dataUrl: string | null) => void): void;
4793
4988
 
4794
4989
  /**
4795
4990
  * Get innerHTML of the given node
@@ -4813,23 +5008,13 @@ export function setColor(element: HTMLElement, color: string | ModeIndependentCo
4813
5008
  */
4814
5009
  export function matchesSelector(element: Node, selector: string): boolean;
4815
5010
 
4816
- /**
4817
- *
4818
- * @param root the contentDiv of the ditor
4819
- * @param nodeToInsert the node to be inserted
4820
- * @param position the position of the node to be inserted
4821
- * @param range the range current or cached range of the editor
4822
- * @returns the adjusted position of the inserted node
4823
- */
4824
- export function adjustInsertPosition(root: HTMLElement, nodeToInsert: Node, position: NodePosition, range: Range): NodePosition;
4825
-
4826
5011
  /**
4827
5012
  * Create DOM element from the given CreateElementData
4828
5013
  * @param elementData The CreateElementData or an index of a known CreateElementData used for creating this element
4829
5014
  * @param document The document to create the element from
4830
5015
  * @returns The root DOM element just created
4831
5016
  */
4832
- export function createElement(elementData: CreateElementData | KnownCreateElementDataIndex, document: Document): Element;
5017
+ export function createElement(elementData: CreateElementData | KnownCreateElementDataIndex, document: Document): Element | null;
4833
5018
 
4834
5019
  /**
4835
5020
  * All known CreateElementData used by roosterjs to create elements
@@ -4844,14 +5029,6 @@ export const KnownCreateElementData: Record<KnownCreateElementDataIndex, CreateE
4844
5029
  */
4845
5030
  export function moveChildNodes(target: Node, source?: Node, keepExistingChildren?: boolean): void;
4846
5031
 
4847
- /**
4848
- * Set the Style of a List Item provided, with the styles that the inline child elements have
4849
- * If the child inline elements have different styles, it will not modify the styles of the list item
4850
- * @param element the LI Element to set the styles
4851
- * @param styles The styles that should be applied to the element.
4852
- */
4853
- export function setListItemStyle(element: HTMLLIElement, styles: string[]): void;
4854
-
4855
5032
  /**
4856
5033
  * A virtual table class, represent an HTML table, by expand all merged cells to each separated cells
4857
5034
  */
@@ -4872,12 +5049,22 @@ export class VTable {
4872
5049
  * Current column index
4873
5050
  */
4874
5051
  col: number;
5052
+ /**
5053
+ * Current format of the table
5054
+ */
5055
+ formatInfo: TableFormat;
5056
+ /**
5057
+ * Selected range of cells with the coordinates of the first and last cell selected.
5058
+ */
5059
+ selection: TableSelection;
4875
5060
  private trs;
4876
5061
  /**
4877
5062
  * Create a new instance of VTable object using HTML TABLE or TD node
4878
5063
  * @param node The HTML Table or TD node
5064
+ * @param normalizeSize Whether table size needs to be normalized
5065
+ * @param sizeTransformer A size transformer function used for normalize table size
4879
5066
  */
4880
- constructor(node: HTMLTableElement | HTMLTableCellElement, normalizeSize?: boolean);
5067
+ constructor(node: HTMLTableElement | HTMLTableCellElement, normalizeSize?: boolean, sizeTransformer?: SizeTransformer);
4881
5068
  /**
4882
5069
  * Write the virtual table back to DOM tree to represent the change of VTable
4883
5070
  */
@@ -4887,6 +5074,40 @@ export class VTable {
4887
5074
  * @param format Table format to apply
4888
5075
  */
4889
5076
  applyFormat(format: Partial<TableFormat>): void;
5077
+ /**
5078
+ * Set color to the table
5079
+ * @param format
5080
+ */
5081
+ private setColor;
5082
+ /**
5083
+ * Set color to borders of an table
5084
+ * @param format
5085
+ * @returns
5086
+ */
5087
+ private setBorderColors;
5088
+ /**
5089
+ * Format the border type
5090
+ * @returns
5091
+ */
5092
+ private formatBorders;
5093
+ /**
5094
+ * Organize the borders of table according to a border type
5095
+ * @param format
5096
+ * @returns
5097
+ */
5098
+ private setBordersType;
5099
+ /**
5100
+ * Apply custom design to the first table column
5101
+ * @param format
5102
+ * @returns
5103
+ */
5104
+ private setFirstColumnFormat;
5105
+ /**
5106
+ * Apply custom design to the Header Row
5107
+ * @param format
5108
+ * @returns
5109
+ */
5110
+ private setHeaderRowFormat;
4890
5111
  /**
4891
5112
  * Edit table with given operation.
4892
5113
  * @param operation Table operation
@@ -4938,14 +5159,19 @@ export class VTable {
4938
5159
  * Get current HTML table cell object. If the current table cell is a virtual expanded cell, return its root cell
4939
5160
  */
4940
5161
  getCurrentTd(): HTMLTableCellElement;
4941
- private getTd;
5162
+ /**
5163
+ * Get the Table Cell in a provided coordinate
5164
+ * @param row row of the cell
5165
+ * @param col column of the cell
5166
+ */
5167
+ getTd(row: number, col: number): HTMLTableCellElement;
4942
5168
  private forEachCellOfColumn;
4943
5169
  private forEachCellOfRow;
4944
5170
  private recalculateSpans;
4945
5171
  private countSpanLeft;
4946
5172
  private countSpanAbove;
4947
5173
  private normalizeEmptyTableCells;
4948
- normalizeTableCellSize(): void;
5174
+ normalizeTableCellSize(sizeTransformer?: SizeTransformer): void;
4949
5175
  private normalizeSize;
4950
5176
  }
4951
5177
 
@@ -5219,6 +5445,14 @@ export class VListChain {
5219
5445
  private getLists;
5220
5446
  }
5221
5447
 
5448
+ /**
5449
+ * Set the Style of a List Item provided, with the styles that the inline child elements have
5450
+ * If the child inline elements have different styles, it will not modify the styles of the list item
5451
+ * @param element the LI Element to set the styles
5452
+ * @param styles The styles that should be applied to the element.
5453
+ */
5454
+ export function setListItemStyle(element: HTMLLIElement, styles: string[]): void;
5455
+
5222
5456
  /**
5223
5457
  * Get regions impacted by the given range under the root node
5224
5458
  * @param root Root node to get regions from
@@ -5377,7 +5611,7 @@ export function createRange(startPosition: NodePosition, endPosition?: NodePosit
5377
5611
  * Get bounding rect of this position
5378
5612
  * @param position The position to get rect from
5379
5613
  */
5380
- export function getPositionRect(position: NodePosition): Rect;
5614
+ export function getPositionRect(position: NodePosition): Rect | null;
5381
5615
 
5382
5616
  /**
5383
5617
  * Check if this position is at beginning of the given node.
@@ -5393,7 +5627,7 @@ export function isPositionAtBeginningOf(position: NodePosition, targetNode: Node
5393
5627
  * @param rootNode The root node where the path start from
5394
5628
  * @param range The range of selection
5395
5629
  */
5396
- export function getSelectionPath(rootNode: Node, range: Range): SelectionPath;
5630
+ export function getSelectionPath(rootNode: Node, range: Range | null): SelectionPath | null;
5397
5631
 
5398
5632
  /**
5399
5633
  * Get inner Html of a root node with a selection path which can be used for restore selection.
@@ -5411,7 +5645,7 @@ export function getHtmlWithSelectionPath(rootNode: HTMLElement | DocumentFragmen
5411
5645
  * @param html The html to restore
5412
5646
  * @returns A selection range if the html contains a valid selection path, otherwise null
5413
5647
  */
5414
- export function setHtmlWithSelectionPath(rootNode: HTMLElement, html: string, trustedHTMLHandler?: TrustedHTMLHandler): Range;
5648
+ export function setHtmlWithSelectionPath(rootNode: HTMLElement, html: string, trustedHTMLHandler?: TrustedHTMLHandler): Range | null;
5415
5649
 
5416
5650
  /**
5417
5651
  * Add the given range into selection of the given document
@@ -5422,13 +5656,6 @@ export function setHtmlWithSelectionPath(rootNode: HTMLElement, html: string, tr
5422
5656
  */
5423
5657
  export function addRangeToSelection(range: Range, skipSameRange?: boolean): void;
5424
5658
 
5425
- /**
5426
- * Delete selected content, and return the new position to select
5427
- * @param core The EditorCore object.
5428
- * @param range The range to delete
5429
- */
5430
- export function deleteSelectedContent(root: HTMLElement, range: Range): Position;
5431
-
5432
5659
  /**
5433
5660
  * Add a new snapshot to the given snapshots data structure
5434
5661
  * @param snapshots The snapshots data structure to add new snapshot into
@@ -5457,7 +5684,7 @@ export function clearProceedingSnapshots(snapshots: Snapshots): void;
5457
5684
  * @param step The step to move
5458
5685
  * @returns If can move with the given step, returns the snapshot after move, otherwise null
5459
5686
  */
5460
- export function moveCurrentSnapshot(snapshots: Snapshots, step: number): string;
5687
+ export function moveCurrentSnapshot(snapshots: Snapshots, step: number): string | null;
5461
5688
 
5462
5689
  /**
5463
5690
  * @deprecated
@@ -5578,7 +5805,7 @@ export function commitEntity(wrapper: HTMLElement, type: string, isReadonly: boo
5578
5805
  * @param element The entity root element. If this element is not an entity root element,
5579
5806
  * it will return null
5580
5807
  */
5581
- export function getEntityFromElement(element: HTMLElement): Entity;
5808
+ export function getEntityFromElement(element: HTMLElement): Entity | null;
5582
5809
 
5583
5810
  /**
5584
5811
  * Get a selector string for specified entity type and id
@@ -5638,6 +5865,30 @@ export function getStyles(element: HTMLElement): Record<string, string>;
5638
5865
  */
5639
5866
  export function setStyles(element: HTMLElement, styles: Record<string, string>): void;
5640
5867
 
5868
+ /**
5869
+ *
5870
+ * @param root the contentDiv of the ditor
5871
+ * @param nodeToInsert the node to be inserted
5872
+ * @param position the position of the node to be inserted
5873
+ * @param range the range current or cached range of the editor
5874
+ * @returns the adjusted position of the inserted node
5875
+ */
5876
+ export function adjustInsertPosition(root: HTMLElement, nodeToInsert: Node, position: NodePosition, range: Range): NodePosition;
5877
+
5878
+ /**
5879
+ * Delete selected content, and return the new position to select
5880
+ * @param core The EditorCore object.
5881
+ * @param range The range to delete
5882
+ */
5883
+ export function deleteSelectedContent(root: HTMLElement, range: Range): Position;
5884
+
5885
+ /**
5886
+ * get block element's text content.
5887
+ * @param rootNode Root node that the get the textContent of.
5888
+ * @returns text content of given text content.
5889
+ */
5890
+ export function getTextContent(rootNode: Node): string;
5891
+
5641
5892
  /**
5642
5893
  * RoosterJs core editor class
5643
5894
  */
@@ -5751,6 +6002,14 @@ export class Editor implements IEditor {
5751
6002
  * @returns current selection range, or null if editor never got focus before
5752
6003
  */
5753
6004
  getSelectionRange(tryGetFromCache?: boolean): Range;
6005
+ /**
6006
+ * Get current selection range from Editor.
6007
+ * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.
6008
+ * @param tryGetFromCache Set to true to retrieve the selection range from cache if editor doesn't own the focus now.
6009
+ * Default value is true
6010
+ * @returns current selection range, or null if editor never got focus before
6011
+ */
6012
+ getSelectionRangeEx(): SelectionRangeEx;
5754
6013
  /**
5755
6014
  * Get current selection in a serializable format
5756
6015
  * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.
@@ -5871,7 +6130,7 @@ export class Editor implements IEditor {
5871
6130
  /**
5872
6131
  * Get a content traverser for current selection
5873
6132
  */
5874
- getSelectionTraverser(): IContentTraverser;
6133
+ getSelectionTraverser(range?: Range): IContentTraverser;
5875
6134
  /**
5876
6135
  * Get a content traverser for current block element start from specified position
5877
6136
  * @param startFrom Start position of the traverser. Default value is ContentPosition.SelectionStart
@@ -6090,7 +6349,7 @@ export function editTable(editor: IEditor, operation: TableOperation): void;
6090
6349
  * @param format A TableFormat object contains format information we want to apply to the table
6091
6350
  * @param table The table to format. This is optional. When not passed, the current table (if any) will be formatted
6092
6351
  */
6093
- export function formatTable(editor: IEditor, format: Partial<TableFormat>, table?: HTMLTableElement): void;
6352
+ export function formatTable(editor: IEditor, format: TableFormat, table?: HTMLTableElement): void;
6094
6353
 
6095
6354
  /**
6096
6355
  * Remove link at selection. If no links at selection, do nothing.
@@ -6335,6 +6594,13 @@ export function toggleUnderline(editor: IEditor): void;
6335
6594
  */
6336
6595
  export function toggleHeader(editor: IEditor, level: number): void;
6337
6596
 
6597
+ /**
6598
+ * Set background color of cells.
6599
+ * @param editor The editor instance
6600
+ * @param color One of two options:
6601
+ **/
6602
+ export function applyCellShading(editor: IEditor, color: string | ModeIndependentColor): void;
6603
+
6338
6604
  /**
6339
6605
  * Toggle List Type at selection
6340
6606
  * If ListType Provided is Ordered:
@@ -6867,23 +7133,7 @@ export class TableResize implements EditorPlugin {
6867
7133
  private editor;
6868
7134
  private onMouseMoveDisposer;
6869
7135
  private tableRectMap;
6870
- private resizerContainer;
6871
- private tableResizerContainer;
6872
- private currentTable;
6873
- private currentTd;
6874
- private currentCellsToResize;
6875
- private nextCellsToResize;
6876
- private horizontalResizer;
6877
- private verticalResizer;
6878
- private tableResizer;
6879
- private resizingState;
6880
- private currentInsertTd;
6881
- private insertingState;
6882
- private inserter;
6883
- private isRTL;
6884
- private currentTableVerticalBorder;
6885
- private currentTableHorizontalBorder;
6886
- private resizingVtable;
7136
+ private tableEditor;
6887
7137
  /**
6888
7138
  * Get a friendly name of this plugin
6889
7139
  */
@@ -6902,36 +7152,10 @@ export class TableResize implements EditorPlugin {
6902
7152
  * @param event PluginEvent object
6903
7153
  */
6904
7154
  onPluginEvent(e: PluginEvent): void;
6905
- private setupResizerContainer;
6906
- private removeResizerContainer;
6907
- private onMouseOutInserter;
6908
7155
  private onMouseMove;
6909
- private setCurrentInsertTd;
6910
- private createInserter;
6911
- private insertTd;
6912
- private setCurrentTable;
6913
- private setCurrentTd;
6914
- private setTableResizer;
6915
- private createTableResizer;
6916
- private createCellsResizer;
6917
- private startResizingTable;
6918
- private startHorizontalResizeCells;
6919
- private startVerticalResizeCells;
6920
- private startResizeCells;
6921
- private frameAnimateResizeCells;
6922
- private resizeTable;
6923
- private resizeRows;
6924
- /**
6925
- *
6926
- * @param newPos The position to where we want to move the vertical border
6927
- * @returns if the move is allowed, or, if any of the cells on either side of the vertical border is smaller than
6928
- * the minimum width, such move is not allowed
6929
- */
6930
- private canResizeColumns;
6931
- private resizeColumns;
6932
- private resizeCells;
6933
- private endResizeCells;
6934
- private cacheRects;
7156
+ private setTableEditor;
7157
+ private invalidateTableRects;
7158
+ private ensureTableRects;
6935
7159
  }
6936
7160
 
6937
7161
  /**
@@ -6969,3 +7193,78 @@ export class Watermark implements EditorPlugin {
6969
7193
  private removeWatermark;
6970
7194
  }
6971
7195
 
7196
+ /**
7197
+ * TableCellSelectionPlugin help highlight table cells
7198
+ */
7199
+ export class TableCellSelection implements EditorPlugin {
7200
+ private editor;
7201
+ private lastTarget;
7202
+ private firstTarget;
7203
+ private tableRange;
7204
+ private tableSelection;
7205
+ private startedSelection;
7206
+ private vTable;
7207
+ private firstTable;
7208
+ private targetTable;
7209
+ constructor();
7210
+ /**
7211
+ * Get a friendly name of this plugin
7212
+ */
7213
+ getName(): string;
7214
+ /**
7215
+ * Initialize this plugin. This should only be called from Editor
7216
+ * @param editor Editor instance
7217
+ */
7218
+ initialize(editor: IEditor): void;
7219
+ /**
7220
+ * Dispose this plugin
7221
+ */
7222
+ dispose(): void;
7223
+ /**
7224
+ * Handle events triggered from editor
7225
+ * @param event PluginEvent object
7226
+ */
7227
+ onPluginEvent(event: PluginEvent): void;
7228
+ /**
7229
+ * Handle Scroll Event and mantains the selection range,
7230
+ * Since when we scroll the cursor does not trigger the on Mouse Move event
7231
+ * The table selection gets removed.
7232
+ */
7233
+ private handleScrollEvent;
7234
+ /**
7235
+ * Handles the Before Copy Event.
7236
+ * Clear the selection range from the cloned Root.
7237
+ * @param event plugin event
7238
+ */
7239
+ private handleBeforeCutCopy;
7240
+ /**
7241
+ * Handles the on key event.
7242
+ * @param event the plugin event
7243
+ */
7244
+ private handleKeyDownEvent;
7245
+ private handleKeyUpEvent;
7246
+ private handleKeySelectionInsideTable;
7247
+ private handleMouseDownEvent;
7248
+ private onMouseMove;
7249
+ private onMouseUp;
7250
+ private restoreSelection;
7251
+ /**
7252
+ * @internal
7253
+ * Public only for unit testing
7254
+ * @param event mouse event
7255
+ */
7256
+ selectionInsideTableMouseMove(event: MouseEvent): void;
7257
+ private removeMouseUpEventListener;
7258
+ /**
7259
+ * When press Backspace, delete the contents inside of the selection, if it is Table Selection
7260
+ */
7261
+ DeleteTableContents: BuildInEditFeature<PluginKeyboardEvent>;
7262
+ private clearTableCellSelection;
7263
+ private clearState;
7264
+ private getNextTD;
7265
+ private prepareSelection;
7266
+ private setData;
7267
+ private isAfter;
7268
+ private shouldConvertToTableSelection;
7269
+ }
7270
+