roosterjs 8.30.2 → 8.32.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.
package/dist/rooster.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for roosterjs (Version 8.30.2)
1
+ // Type definitions for roosterjs (Version 8.32.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -716,6 +716,33 @@ const KnownCreateElementData: Record<KnownCreateElementDataIndex, CreateElementD
716
716
  */
717
717
  function moveChildNodes(target: Node, source?: Node, keepExistingChildren?: boolean): void;
718
718
 
719
+ /**
720
+ * Get the intersected Rect of elements provided
721
+ *
722
+ * @example
723
+ * The result of the following Elements Rects would be:
724
+ {
725
+ top: Element2.top,
726
+ bottom: Element1.bottom,
727
+ left: Element2.left,
728
+ right: Element2.right
729
+ }
730
+ +-------------------------+
731
+ | Element 1 |
732
+ | +-----------------+ |
733
+ | | Element2 | |
734
+ | | | |
735
+ | | | |
736
+ +-------------------------+
737
+ | |
738
+ +-----------------+
739
+
740
+ * @param elements Elements to use.
741
+ * @param additionalRects additional rects to use
742
+ * @returns If the Rect is valid return the rect, if not, return null.
743
+ */
744
+ function getIntersectedRect(elements: HTMLElement[], additionalRects?: Rect[]): Rect | null;
745
+
719
746
  /**
720
747
  * A virtual table class, represent an HTML table, by expand all merged cells to each separated cells
721
748
  */
@@ -736,15 +763,12 @@ class VTable {
736
763
  * Current column index
737
764
  */
738
765
  col: number | undefined;
739
- /**
740
- * Selected range of cells with the coordinates of the first and last cell selected.
741
- */
742
- selection: TableSelection | null;
743
766
  /**
744
767
  * Current format of the table
745
768
  */
746
769
  formatInfo: Required<TableFormat> | null;
747
770
  private trs;
771
+ private tableSelection;
748
772
  /**
749
773
  * Create a new instance of VTable object using HTML TABLE or TD node
750
774
  * @param node The HTML Table or TD node
@@ -752,12 +776,18 @@ class VTable {
752
776
  * @param zoomScale When the table is under a zoomed container, pass in the zoom scale here
753
777
  */
754
778
  constructor(node: HTMLTableElement | HTMLTableCellElement, normalizeSize?: boolean, zoomScale?: number | SizeTransformer);
779
+ /**
780
+ * Selected range of cells with the coordinates of the first and last cell selected.
781
+ */
782
+ get selection(): TableSelection | null;
783
+ set selection(value: TableSelection | null);
755
784
  /**
756
785
  * Write the virtual table back to DOM tree to represent the change of VTable
757
786
  * @param skipApplyFormat Do not reapply table format when write back.
758
787
  * Only use this parameter when you are pretty sure there is no format or table structure change during the process.
759
788
  */
760
789
  writeBack(skipApplyFormat?: boolean): void;
790
+ private recalculateCellHeight;
761
791
  /**
762
792
  * Apply the given table format to this virtual table
763
793
  * @param format Table format to apply
@@ -775,6 +805,8 @@ class VTable {
775
805
  edit(operation: TableOperation | CompatibleTableOperation): void;
776
806
  setAlignmentToSelectedCells(firstRow: number, lastRow: number, firstColumn: number, lastColumn: number, alignmentType: string, isVertical?: boolean): void;
777
807
  private mergeCells;
808
+ private isEmptyCell;
809
+ private mergeCellContents;
778
810
  /**
779
811
  * Loop each cell of current column and invoke a callback function
780
812
  * @param callback The callback function to invoke
@@ -907,8 +939,10 @@ class VList {
907
939
  /**
908
940
  * Write the result back into DOM tree
909
941
  * After that, this VList becomes unavailable because we set this.rootList to null
942
+ *
943
+ * @param shouldReuseAllAncestorListElements Optional - defaults to false.
910
944
  */
911
- writeBack(): void;
945
+ writeBack(shouldReuseAllAncestorListElements?: boolean): void;
912
946
  /**
913
947
  * Sets the New List Start Property, that is going to be used to create a new List in the WriteBack function
914
948
  * @param separator The HTML element that indicates when to split the VList
@@ -1104,8 +1138,10 @@ class VListItem {
1104
1138
  * Write the change result back into DOM
1105
1139
  * @param listStack current stack of list elements
1106
1140
  * @param originalRoot Original list root element. It will be reused when write back if possible
1141
+ * @param shouldReuseAllAncestorListElements Optional - defaults to false. If true, only make
1142
+ * sure the direct parent of this list matches the list types when writing back.
1107
1143
  */
1108
- writeBack(listStack: Node[], originalRoot?: HTMLOListElement | HTMLUListElement): void;
1144
+ writeBack(listStack: Node[], originalRoot?: HTMLOListElement | HTMLUListElement, shouldReuseAllAncestorListElements?: boolean): void;
1109
1145
  /**
1110
1146
  * Get the index of how deep is the current node parent list inside of the original root list.
1111
1147
  * @example In the following structure this function would return 2
@@ -1167,7 +1203,7 @@ class VListChain {
1167
1203
  * After change the lists, commit the change to all lists in this chain to update the list number,
1168
1204
  * and clear the temporary dataset values added to list node
1169
1205
  */
1170
- commit(): void;
1206
+ commit(shouldReuseAllAncestorListElements?: boolean): void;
1171
1207
  /**
1172
1208
  * Construct a new instance of VListChain class
1173
1209
  * @param editor Editor object
@@ -1203,6 +1239,13 @@ function setListItemStyle(element: HTMLLIElement, styles: string[]): void;
1203
1239
  */
1204
1240
  function getTableFormatInfo(table: HTMLTableElement): Required<TableFormat> | null;
1205
1241
 
1242
+ /**
1243
+ * Add metadata to a cell
1244
+ * @param cell The table cell to add the metadata
1245
+ * @param format The format of the table
1246
+ */
1247
+ function saveTableCellMetadata(cell: HTMLTableCellElement, format: TableCellMetadataFormat): void;
1248
+
1206
1249
  /**
1207
1250
  * Get regions impacted by the given range under the root node
1208
1251
  * @param root Root node to get regions from
@@ -1613,7 +1656,7 @@ function getEntitySelector(type?: string, id?: string): string;
1613
1656
  * @param key Cache key string, need to be unique
1614
1657
  * @param getter Getter function to get the object when it is not in cache yet
1615
1658
  */
1616
- function cacheGetEventData<T>(event: PluginEvent, key: string, getter: () => T): T;
1659
+ function cacheGetEventData<T>(event: PluginEvent | null, key: string, getter: () => T): T;
1617
1660
 
1618
1661
  /**
1619
1662
  * Clear a cached object by its key from an event object
@@ -1672,7 +1715,7 @@ function adjustInsertPosition(root: HTMLElement, nodeToInsert: Node, position: N
1672
1715
  * @param core The EditorCore object.
1673
1716
  * @param range The range to delete
1674
1717
  */
1675
- function deleteSelectedContent(root: HTMLElement, range: Range): null;
1718
+ function deleteSelectedContent(root: HTMLElement, range: Range): NodePosition | null;
1676
1719
 
1677
1720
  /**
1678
1721
  * get block element's text content.
@@ -1859,7 +1902,7 @@ class Editor implements IEditor {
1859
1902
  * @param node The node to create InlineElement
1860
1903
  * @returns The BlockElement result
1861
1904
  */
1862
- getBlockElementAtNode(node: Node): BlockElement;
1905
+ getBlockElementAtNode(node: Node): BlockElement | null;
1863
1906
  contains(arg: Node | Range): boolean;
1864
1907
  queryElements(selector: string, scopeOrCallback?: QueryScope | CompatibleQueryScope | ((node: Node) => any), callback?: (node: Node) => any): HTMLElement[];
1865
1908
  /**
@@ -1905,7 +1948,7 @@ class Editor implements IEditor {
1905
1948
  /**
1906
1949
  * Delete selected content
1907
1950
  */
1908
- deleteSelectedContent(): NodePosition;
1951
+ deleteSelectedContent(): NodePosition | null;
1909
1952
  /**
1910
1953
  * Paste into editor using a clipboardData object
1911
1954
  * @param clipboardData Clipboard data retrieved from clipboard
@@ -1921,7 +1964,7 @@ class Editor implements IEditor {
1921
1964
  * Default value is true
1922
1965
  * @returns current selection range, or null if editor never got focus before
1923
1966
  */
1924
- getSelectionRange(tryGetFromCache?: boolean): Range;
1967
+ getSelectionRange(tryGetFromCache?: boolean): Range | null;
1925
1968
  /**
1926
1969
  * Get current selection range from Editor.
1927
1970
  * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.
@@ -1935,7 +1978,7 @@ class Editor implements IEditor {
1935
1978
  * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.
1936
1979
  * @returns current selection path, or null if editor never got focus before
1937
1980
  */
1938
- getSelectionPath(): SelectionPath;
1981
+ getSelectionPath(): SelectionPath | null;
1939
1982
  /**
1940
1983
  * Check if focus is in editor now
1941
1984
  * @returns true if focus is in editor, otherwise false
@@ -1945,11 +1988,11 @@ class Editor implements IEditor {
1945
1988
  * Focus to this editor, the selection was restored to where it was before, no unexpected scroll.
1946
1989
  */
1947
1990
  focus(): void;
1948
- select(arg1: any, arg2?: any, arg3?: any, arg4?: any): boolean;
1991
+ select(arg1: Range | NodePosition | Node | SelectionPath | HTMLTableElement | HTMLImageElement | null, arg2?: NodePosition | number | PositionType | TableSelection, arg3?: Node, arg4?: number | PositionType): boolean;
1949
1992
  /**
1950
1993
  * Get current focused position. Return null if editor doesn't have focus at this time.
1951
1994
  */
1952
- getFocusedPosition(): NodePosition;
1995
+ getFocusedPosition(): NodePosition | null;
1953
1996
  /**
1954
1997
  * Get an HTML element from current cursor position.
1955
1998
  * When expectedTags is not specified, return value is the current node (if it is HTML element)
@@ -1962,7 +2005,7 @@ class Editor implements IEditor {
1962
2005
  * @param event Optional, if specified, editor will try to get cached result from the event object first.
1963
2006
  * If it is not cached before, query from DOM and cache the result into the event object
1964
2007
  */
1965
- getElementAtCursor(selector?: string, startFrom?: Node, event?: PluginEvent): HTMLElement;
2008
+ getElementAtCursor(selector?: string, startFrom?: Node, event?: PluginEvent): HTMLElement | null;
1966
2009
  /**
1967
2010
  * Check if this position is at beginning of the editor.
1968
2011
  * This will return true if all nodes between the beginning of target node and the position are empty.
@@ -2009,7 +2052,7 @@ class Editor implements IEditor {
2009
2052
  * a ContentChangedEvent will be fired with change source equal to this value
2010
2053
  * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).
2011
2054
  */
2012
- addUndoSnapshot(callback?: (start: NodePosition, end: NodePosition) => any, changeSource?: ChangeSource | CompatibleChangeSource | string, canUndoByBackspace?: boolean, additionalData?: ContentChangedData): void;
2055
+ addUndoSnapshot(callback?: (start: NodePosition | null, end: NodePosition | null) => any, changeSource?: ChangeSource | CompatibleChangeSource | string, canUndoByBackspace?: boolean, additionalData?: ContentChangedData): void;
2013
2056
  /**
2014
2057
  * Whether there is an available undo/redo snapshot
2015
2058
  */
@@ -2049,19 +2092,22 @@ class Editor implements IEditor {
2049
2092
  getBodyTraverser(startNode?: Node): IContentTraverser;
2050
2093
  /**
2051
2094
  * Get a content traverser for current selection
2095
+ * @returns A content traverser, or null if editor never got focus before
2052
2096
  */
2053
- getSelectionTraverser(range?: Range): IContentTraverser;
2097
+ getSelectionTraverser(range?: Range): IContentTraverser | null;
2054
2098
  /**
2055
2099
  * Get a content traverser for current block element start from specified position
2056
2100
  * @param startFrom Start position of the traverser. Default value is ContentPosition.SelectionStart
2101
+ * @returns A content traverser, or null if editor never got focus before
2057
2102
  */
2058
- getBlockTraverser(startFrom?: ContentPosition | CompatibleContentPosition): IContentTraverser;
2103
+ getBlockTraverser(startFrom?: ContentPosition | CompatibleContentPosition): IContentTraverser | null;
2059
2104
  /**
2060
2105
  * Get a text traverser of current selection
2061
2106
  * @param event Optional, if specified, editor will try to get cached result from the event object first.
2062
2107
  * If it is not cached before, query from DOM and cache the result into the event object
2108
+ * @returns A content traverser, or null if editor never got focus before
2063
2109
  */
2064
- getContentSearcherOfCursor(event?: PluginEvent): IPositionContentSearcher;
2110
+ getContentSearcherOfCursor(event?: PluginEvent): IPositionContentSearcher | null;
2065
2111
  /**
2066
2112
  * Run a callback function asynchronously
2067
2113
  * @param callback The callback function to run
@@ -2075,18 +2121,20 @@ class Editor implements IEditor {
2075
2121
  */
2076
2122
  setEditorDomAttribute(name: string, value: string): void;
2077
2123
  /**
2078
- * get DOM attribute of editor content DIV
2124
+ * Get DOM attribute of editor content DIV, null if there is no such attribute.
2079
2125
  * @param name Name of the attribute
2080
2126
  */
2081
- getEditorDomAttribute(name: string): string;
2127
+ getEditorDomAttribute(name: string): string | null;
2082
2128
  /**
2129
+ * @deprecated Use getVisibleViewport() instead.
2130
+ *
2083
2131
  * Get current relative distance from top-left corner of the given element to top-left corner of editor content DIV.
2084
2132
  * @param element The element to calculate from. If the given element is not in editor, return value will be null
2085
2133
  * @param addScroll When pass true, The return value will also add scrollLeft and scrollTop if any. So the value
2086
2134
  * may be different than what user is seeing from the view. When pass false, scroll position will be ignored.
2087
2135
  * @returns An [x, y] array which contains the left and top distances, or null if the given element is not in editor.
2088
2136
  */
2089
- getRelativeDistanceToEditor(element: HTMLElement, addScroll?: boolean): number[];
2137
+ getRelativeDistanceToEditor(element: HTMLElement, addScroll?: boolean): number[] | null;
2090
2138
  /**
2091
2139
  * Add a Content Edit feature.
2092
2140
  * @param feature The feature to add
@@ -2170,6 +2218,15 @@ class Editor implements IEditor {
2170
2218
  * @param scale The new scale number to set. It should be positive number and no greater than 10, otherwise it will be ignored.
2171
2219
  */
2172
2220
  setZoomScale(scale: number): void;
2221
+ /**
2222
+ * Retrieves the rect of the visible viewport of the editor.
2223
+ */
2224
+ getVisibleViewport(): Rect | null;
2225
+ /**
2226
+ * @returns the current EditorCore object
2227
+ * @throws a standard Error if there's no core object
2228
+ */
2229
+ private getCore;
2173
2230
  }
2174
2231
 
2175
2232
  /**
@@ -2579,7 +2636,13 @@ function blockFormat(editor: IEditor, callback: (region: Region, start: NodePosi
2579
2636
  * @param editor The Editor object
2580
2637
  * @param chains List chains to commit
2581
2638
  */
2582
- function experimentCommitListChains(editor: IEditor, chains: VListChain[]): void;
2639
+ function commitListChains(editor: IEditor, chains: VListChain[]): void;
2640
+
2641
+ /**
2642
+ * @deprecated
2643
+ * Same with commitListChains, keep this export just for backward compatibility
2644
+ */
2645
+ const experimentCommitListChains: typeof commitListChains;
2583
2646
 
2584
2647
  /**
2585
2648
  * Get dark mode color for a given color
@@ -2695,6 +2758,10 @@ interface DOMEventPluginState {
2695
2758
  * Context menu providers, that can provide context menu items
2696
2759
  */
2697
2760
  contextMenuProviders: ContextMenuProvider<any>[];
2761
+ /**
2762
+ * Image selection range
2763
+ */
2764
+ imageSelectionRange: ImageSelectionRange | null;
2698
2765
  }
2699
2766
 
2700
2767
  /**
@@ -2771,6 +2838,10 @@ interface LifecyclePluginState {
2771
2838
  * Cached table selection path for original content
2772
2839
  */
2773
2840
  shadowEditTableSelectionPath: SelectionPath[] | null;
2841
+ /**
2842
+ * Cached image selection path for original content
2843
+ */
2844
+ shadowEditImageSelectionPath: SelectionPath[] | null;
2774
2845
  }
2775
2846
 
2776
2847
  /**
@@ -3471,7 +3542,7 @@ const enum ExperimentalFeatures {
3471
3542
  */
3472
3543
  ImageRotate = "ImageRotate",
3473
3544
  /**
3474
- * Crop an inline image (requires ImageEdit plugin)
3545
+ * @deprecated This feature is always enabled
3475
3546
  */
3476
3547
  ImageCrop = "ImageCrop",
3477
3548
  /**
@@ -3518,7 +3589,18 @@ const enum ExperimentalFeatures {
3518
3589
  * Normalize list to make sure it can be displayed correctly in other client
3519
3590
  * e.g. We will move list items with "display: block" into previous list item and change tag to be DIV
3520
3591
  */
3521
- NormalizeList = "NormalizeList"
3592
+ NormalizeList = "NormalizeList",
3593
+ /**
3594
+ * When a html image is selected, the selected image data will be stored by editor core.
3595
+ */
3596
+ ImageSelection = "ImageSelection",
3597
+ /**
3598
+ * With this feature enabled, when writing back a list item we will re-use all
3599
+ * ancestor list elements, even if they don't match the types currently in the
3600
+ * listTypes array for that item. The only list that we will ensure is correct
3601
+ * is the one closest to the item.
3602
+ */
3603
+ ReuseAllAncestorListElements = "ReuseAllAncestorListElements"
3522
3604
  }
3523
3605
 
3524
3606
  /**
@@ -4071,7 +4153,11 @@ const enum SelectionRangeTypes {
4071
4153
  /**
4072
4154
  * Selection made inside of a single table.
4073
4155
  */
4074
- TableSelection = 1
4156
+ TableSelection = 1,
4157
+ /**
4158
+ * Selection made in a image.
4159
+ */
4160
+ ImageSelection = 2
4075
4161
  }
4076
4162
 
4077
4163
  /**
@@ -4193,7 +4279,7 @@ const enum BulletListType {
4193
4279
  */
4194
4280
  ShortArrow = 4,
4195
4281
  /**
4196
- * Bullet triggered by -> or -->
4282
+ * Bullet triggered by ->
4197
4283
  */
4198
4284
  LongArrow = 5,
4199
4285
  /**
@@ -4204,10 +4290,18 @@ const enum BulletListType {
4204
4290
  * Bullet triggered by —
4205
4291
  */
4206
4292
  Hyphen = 7,
4293
+ /**
4294
+ * Bullet triggered by -->
4295
+ */
4296
+ DoubleLongArrow = 8,
4297
+ /**
4298
+ * Bullet type circle
4299
+ */
4300
+ Circle = 9,
4207
4301
  /**
4208
4302
  * Maximum value of the enum
4209
4303
  */
4210
- Max = 7
4304
+ Max = 9
4211
4305
  }
4212
4306
 
4213
4307
  /**
@@ -5650,6 +5744,16 @@ interface TableFormat {
5650
5744
  keepCellShade?: boolean;
5651
5745
  }
5652
5746
 
5747
+ /**
5748
+ * Format of table cell that stored as metadata
5749
+ */
5750
+ interface TableCellMetadataFormat {
5751
+ /**
5752
+ * Override default background color
5753
+ */
5754
+ bgColorOverride?: boolean;
5755
+ }
5756
+
5653
5757
  /**
5654
5758
  * Represents a selection made inside of a table
5655
5759
  */
@@ -5912,7 +6016,7 @@ interface IEditor {
5912
6016
  * @param node The node to create InlineElement
5913
6017
  * @returns The BlockElement result
5914
6018
  */
5915
- getBlockElementAtNode(node: Node): BlockElement;
6019
+ getBlockElementAtNode(node: Node): BlockElement | null;
5916
6020
  /**
5917
6021
  * Check if the node falls in the editor content
5918
6022
  * @param node The node to check
@@ -5998,7 +6102,7 @@ interface IEditor {
5998
6102
  /**
5999
6103
  * Delete selected content
6000
6104
  */
6001
- deleteSelectedContent(): NodePosition;
6105
+ deleteSelectedContent(): NodePosition | null;
6002
6106
  /**
6003
6107
  * Paste into editor using a clipboardData object
6004
6108
  * @param clipboardData Clipboard data retrieved from clipboard
@@ -6014,7 +6118,7 @@ interface IEditor {
6014
6118
  * Default value is true
6015
6119
  * @returns current selection range, or null if editor never got focus before
6016
6120
  */
6017
- getSelectionRange(tryGetFromCache?: boolean): Range;
6121
+ getSelectionRange(tryGetFromCache?: boolean): Range | null;
6018
6122
  /**
6019
6123
  * Get current selection range from Editor.
6020
6124
  * It does a live pull on the selection.
@@ -6026,7 +6130,7 @@ interface IEditor {
6026
6130
  * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.
6027
6131
  * @returns current selection path, or null if editor never got focus before
6028
6132
  */
6029
- getSelectionPath(): SelectionPath;
6133
+ getSelectionPath(): SelectionPath | null;
6030
6134
  /**
6031
6135
  * Check if focus is in editor now
6032
6136
  * @returns true if focus is in editor, otherwise false
@@ -6092,7 +6196,7 @@ interface IEditor {
6092
6196
  /**
6093
6197
  * Get current focused position. Return null if editor doesn't have focus at this time.
6094
6198
  */
6095
- getFocusedPosition(): NodePosition;
6199
+ getFocusedPosition(): NodePosition | null;
6096
6200
  /**
6097
6201
  * Get an HTML element from current cursor position.
6098
6202
  * When expectedTags is not specified, return value is the current node (if it is HTML element)
@@ -6105,7 +6209,7 @@ interface IEditor {
6105
6209
  * @param event Optional, if specified, editor will try to get cached result from the event object first.
6106
6210
  * If it is not cached before, query from DOM and cache the result into the event object
6107
6211
  */
6108
- getElementAtCursor(selector?: string, startFrom?: Node, event?: PluginEvent): HTMLElement;
6212
+ getElementAtCursor(selector?: string, startFrom?: Node, event?: PluginEvent): HTMLElement | null;
6109
6213
  /**
6110
6214
  * Check if this position is at beginning of the editor.
6111
6215
  * This will return true if all nodes between the beginning of target node and the position are empty.
@@ -6207,19 +6311,22 @@ interface IEditor {
6207
6311
  getBodyTraverser(startNode?: Node): IContentTraverser;
6208
6312
  /**
6209
6313
  * Get a content traverser for current selection
6314
+ * @returns A content traverser, or null if editor never got focus before and no range is provided
6210
6315
  */
6211
- getSelectionTraverser(range?: Range): IContentTraverser;
6316
+ getSelectionTraverser(range?: Range): IContentTraverser | null;
6212
6317
  /**
6213
6318
  * Get a content traverser for current block element start from specified position
6214
6319
  * @param startFrom Start position of the traverser. Default value is ContentPosition.SelectionStart
6320
+ * @returns A content traverser, or null if editor never got focus before
6215
6321
  */
6216
- getBlockTraverser(startFrom?: ContentPosition | CompatibleContentPosition): IContentTraverser;
6322
+ getBlockTraverser(startFrom?: ContentPosition | CompatibleContentPosition): IContentTraverser | null;
6217
6323
  /**
6218
6324
  * Get a text traverser of current selection
6219
6325
  * @param event Optional, if specified, editor will try to get cached result from the event object first.
6220
6326
  * If it is not cached before, query from DOM and cache the result into the event object
6327
+ * @returns A content traverser, or null if editor never got focus before
6221
6328
  */
6222
- getContentSearcherOfCursor(event?: PluginEvent): IPositionContentSearcher;
6329
+ getContentSearcherOfCursor(event?: PluginEvent): IPositionContentSearcher | null;
6223
6330
  /**
6224
6331
  * Run a callback function asynchronously
6225
6332
  * @param callback The callback function to run
@@ -6233,18 +6340,20 @@ interface IEditor {
6233
6340
  */
6234
6341
  setEditorDomAttribute(name: string, value: string): void;
6235
6342
  /**
6236
- * Get DOM attribute of editor content DIV
6343
+ * Get DOM attribute of editor content DIV, null if there is no such attribute.
6237
6344
  * @param name Name of the attribute
6238
6345
  */
6239
- getEditorDomAttribute(name: string): string;
6346
+ getEditorDomAttribute(name: string): string | null;
6240
6347
  /**
6348
+ * @deprecated Use getVisibleViewport() instead
6349
+ *
6241
6350
  * Get current relative distance from top-left corner of the given element to top-left corner of editor content DIV.
6242
6351
  * @param element The element to calculate from. If the given element is not in editor, return value will be null
6243
6352
  * @param addScroll When pass true, The return value will also add scrollLeft and scrollTop if any. So the value
6244
6353
  * may be different than what user is seeing from the view. When pass false, scroll position will be ignored.
6245
6354
  * @returns An [x, y] array which contains the left and top distances, or null if the given element is not in editor.
6246
6355
  */
6247
- getRelativeDistanceToEditor(element: HTMLElement, addScroll?: boolean): number[];
6356
+ getRelativeDistanceToEditor(element: HTMLElement, addScroll?: boolean): number[] | null;
6248
6357
  /**
6249
6358
  * Add a Content Edit feature.
6250
6359
  * @param feature The feature to add
@@ -6327,6 +6436,10 @@ interface IEditor {
6327
6436
  * @deprecated Use getZoomScale() instead
6328
6437
  */
6329
6438
  getSizeTransformer(): SizeTransformer;
6439
+ /**
6440
+ * Retrieves the rect of the visible viewport of the editor.
6441
+ */
6442
+ getVisibleViewport(): Rect | null;
6330
6443
  }
6331
6444
 
6332
6445
  /**
@@ -6540,6 +6653,14 @@ interface EditorCore extends PluginState {
6540
6653
  * @deprecated Use zoomScale instead
6541
6654
  */
6542
6655
  sizeTransformer: SizeTransformer;
6656
+ /**
6657
+ * Retrieves the Visible Viewport of the editor.
6658
+ */
6659
+ getVisibleViewport: () => Rect | null;
6660
+ /**
6661
+ * Color of the border of a selectedImage. Default color: '#DB626C'
6662
+ */
6663
+ imageSelectionBorderColor?: string;
6543
6664
  }
6544
6665
 
6545
6666
  /**
@@ -6707,6 +6828,14 @@ interface CoreApiMap {
6707
6828
  * @returns true if successful
6708
6829
  */
6709
6830
  selectTable: SelectTable;
6831
+ /**
6832
+ * Select a image and save data of the selected range
6833
+ * @param core The EditorCore object
6834
+ * @param image image to select
6835
+ * @param imageId the id of the image element
6836
+ * @returns true if successful
6837
+ */
6838
+ selectImage: SelectImage;
6710
6839
  }
6711
6840
 
6712
6841
  /**
@@ -6718,7 +6847,7 @@ interface CoreApiMap {
6718
6847
  * @param applyCurrentStyle True if apply format of current selection to the pasted content,
6719
6848
  * false to keep original format
6720
6849
  */
6721
- type CreatePasteFragment = (core: EditorCore, clipboardData: ClipboardData, position: NodePosition, pasteAsText: boolean, applyCurrentStyle: boolean) => DocumentFragment | null;
6850
+ type CreatePasteFragment = (core: EditorCore, clipboardData: ClipboardData, position: NodePosition | null, pasteAsText: boolean, applyCurrentStyle: boolean) => DocumentFragment | null;
6722
6851
 
6723
6852
  /**
6724
6853
  * Ensure user will type into a container element rather than into the editor content DIV directly
@@ -6762,7 +6891,7 @@ type GetSelectionRangeEx = (core: EditorCore) => SelectionRangeEx;
6762
6891
  * @param core The EditorCore objects
6763
6892
  * @param node The node to get style from
6764
6893
  */
6765
- type GetStyleBasedFormatState = (core: EditorCore, node: Node) => StyleBasedFormatState;
6894
+ type GetStyleBasedFormatState = (core: EditorCore, node: Node | null) => StyleBasedFormatState;
6766
6895
 
6767
6896
  /**
6768
6897
  * Get the pendable format such as underline and bold
@@ -6784,7 +6913,7 @@ type HasFocus = (core: EditorCore) => boolean;
6784
6913
  * @param core The EditorCore object. No op if null.
6785
6914
  * @param option An insert option object to specify how to insert the node
6786
6915
  */
6787
- type InsertNode = (core: EditorCore, node: Node, option: InsertOption) => boolean;
6916
+ type InsertNode = (core: EditorCore, node: Node, option: InsertOption | null) => boolean;
6788
6917
 
6789
6918
  /**
6790
6919
  * Restore an undo snapshot into editor
@@ -6829,7 +6958,7 @@ type SwitchShadowEdit = (core: EditorCore, isOn: boolean) => void;
6829
6958
  * @param forceTransform By default this function will only work when editor core is in dark mode.
6830
6959
  * Pass true to this value to force do color transformation even editor core is in light mode
6831
6960
  */
6832
- type TransformColor = (core: EditorCore, rootNode: Node, includeSelf: boolean, callback: (() => void) | null, direction: ColorTransformDirection | CompatibleColorTransformDirection, forceTransform?: boolean) => void;
6961
+ type TransformColor = (core: EditorCore, rootNode: Node | null, includeSelf: boolean, callback: (() => void) | null, direction: ColorTransformDirection | CompatibleColorTransformDirection, forceTransform?: boolean) => void;
6833
6962
 
6834
6963
  /**
6835
6964
  * Trigger a plugin event
@@ -6847,7 +6976,15 @@ type TriggerEvent = (core: EditorCore, pluginEvent: PluginEvent, broadcast: bool
6847
6976
  * selecting, will unselect the table.
6848
6977
  * @returns true if successful
6849
6978
  */
6850
- type SelectTable = (core: EditorCore, table: HTMLTableElement, coordinates?: TableSelection) => TableSelectionRange | null;
6979
+ type SelectTable = (core: EditorCore, table: HTMLTableElement | null, coordinates?: TableSelection) => TableSelectionRange | null;
6980
+
6981
+ /**
6982
+ * Select a table and save data of the selected range
6983
+ * @param core The EditorCore object
6984
+ * @param image image to select
6985
+ * @returns true if successful
6986
+ */
6987
+ type SelectImage = (core: EditorCore, image: HTMLImageElement | null) => ImageSelectionRange | null;
6851
6988
 
6852
6989
  /**
6853
6990
  * The options to specify parameters customizing an editor, used by ctor of Editor class
@@ -6950,6 +7087,14 @@ interface EditorOptions {
6950
7087
  * @deprecated Use zoomScale instead
6951
7088
  */
6952
7089
  sizeTransformer?: SizeTransformer;
7090
+ /**
7091
+ * Retrieves the visible viewport of the Editor. The default viewport is the Rect of the scrollContainer.
7092
+ */
7093
+ getVisibleViewport?: () => Rect | null;
7094
+ /**
7095
+ * Color of the border of a selectedImage. Default color: '#DB626C'
7096
+ */
7097
+ imageSelectionBorderColor?: string;
6953
7098
  }
6954
7099
 
6955
7100
  /**
@@ -7504,10 +7649,20 @@ interface TableSelectionRange extends SelectionRangeExBase<SelectionRangeTypes.T
7504
7649
  coordinates: TableSelection | undefined;
7505
7650
  }
7506
7651
 
7652
+ /**
7653
+ * Represents a selected image.
7654
+ */
7655
+ interface ImageSelectionRange extends SelectionRangeExBase<SelectionRangeTypes.ImageSelection | CompatibleSelectionRangeTypes.ImageSelection> {
7656
+ /**
7657
+ * Selected Image
7658
+ */
7659
+ image: HTMLImageElement;
7660
+ }
7661
+
7507
7662
  /**
7508
7663
  * Types of ranges used in editor api getSelectionRangeEx
7509
7664
  */
7510
- type SelectionRangeEx = NormalSelectionRange | TableSelectionRange;
7665
+ type SelectionRangeEx = NormalSelectionRange | TableSelectionRange | ImageSelectionRange;
7511
7666
 
7512
7667
  /**
7513
7668
  * Attribute callback, will be called when HtmlSanitizer process an attribute with given name
@@ -7751,7 +7906,7 @@ enum CompatibleExperimentalFeatures {
7751
7906
  */
7752
7907
  ImageRotate = "ImageRotate",
7753
7908
  /**
7754
- * Crop an inline image (requires ImageEdit plugin)
7909
+ * @deprecated This feature is always enabled
7755
7910
  */
7756
7911
  ImageCrop = "ImageCrop",
7757
7912
  /**
@@ -7798,7 +7953,18 @@ enum CompatibleExperimentalFeatures {
7798
7953
  * Normalize list to make sure it can be displayed correctly in other client
7799
7954
  * e.g. We will move list items with "display: block" into previous list item and change tag to be DIV
7800
7955
  */
7801
- NormalizeList = "NormalizeList"
7956
+ NormalizeList = "NormalizeList",
7957
+ /**
7958
+ * When a html image is selected, the selected image data will be stored by editor core.
7959
+ */
7960
+ ImageSelection = "ImageSelection",
7961
+ /**
7962
+ * With this feature enabled, when writing back a list item we will re-use all
7963
+ * ancestor list elements, even if they don't match the types currently in the
7964
+ * listTypes array for that item. The only list that we will ensure is correct
7965
+ * is the one closest to the item.
7966
+ */
7967
+ ReuseAllAncestorListElements = "ReuseAllAncestorListElements"
7802
7968
  }
7803
7969
 
7804
7970
  /**
@@ -8210,7 +8376,11 @@ enum CompatibleSelectionRangeTypes {
8210
8376
  /**
8211
8377
  * Selection made inside of a single table.
8212
8378
  */
8213
- TableSelection = 1
8379
+ TableSelection = 1,
8380
+ /**
8381
+ * Selection made in a image.
8382
+ */
8383
+ ImageSelection = 2
8214
8384
  }
8215
8385
 
8216
8386
  /**
@@ -8286,7 +8456,7 @@ enum CompatibleBulletListType {
8286
8456
  */
8287
8457
  ShortArrow = 4,
8288
8458
  /**
8289
- * Bullet triggered by -> or -->
8459
+ * Bullet triggered by ->
8290
8460
  */
8291
8461
  LongArrow = 5,
8292
8462
  /**
@@ -8297,10 +8467,18 @@ enum CompatibleBulletListType {
8297
8467
  * Bullet triggered by —
8298
8468
  */
8299
8469
  Hyphen = 7,
8470
+ /**
8471
+ * Bullet triggered by -->
8472
+ */
8473
+ DoubleLongArrow = 8,
8474
+ /**
8475
+ * Bullet type circle
8476
+ */
8477
+ Circle = 9,
8300
8478
  /**
8301
8479
  * Maximum value of the enum
8302
8480
  */
8303
- Max = 7
8481
+ Max = 9
8304
8482
  }
8305
8483
 
8306
8484
  /**
@@ -9687,13 +9865,14 @@ class TableResize implements EditorPlugin {
9687
9865
  class Watermark implements EditorPlugin {
9688
9866
  private watermark;
9689
9867
  private format?;
9868
+ private customClass?;
9690
9869
  private editor;
9691
9870
  private disposer;
9692
9871
  /**
9693
9872
  * Create an instance of Watermark plugin
9694
9873
  * @param watermark The watermark string
9695
9874
  */
9696
- constructor(watermark: string, format?: DefaultFormat);
9875
+ constructor(watermark: string, format?: DefaultFormat, customClass?: string);
9697
9876
  /**
9698
9877
  * Get a friendly name of this plugin
9699
9878
  */
@@ -9755,12 +9934,6 @@ class TableCellSelection implements EditorPlugin {
9755
9934
  * The table selection gets removed.
9756
9935
  */
9757
9936
  private handleScrollEvent;
9758
- /**
9759
- * Handles the Before Copy Event.
9760
- * Clear the selection range from the cloned Root.
9761
- * @param event plugin event
9762
- */
9763
- private handleBeforeCutCopy;
9764
9937
  /**
9765
9938
  * Handles the on key event.
9766
9939
  * @param event the plugin event
@@ -9779,10 +9952,6 @@ class TableCellSelection implements EditorPlugin {
9779
9952
  */
9780
9953
  selectionInsideTableMouseMove(event: MouseEvent): void;
9781
9954
  private removeMouseUpEventListener;
9782
- /**
9783
- * When press Backspace, delete the contents inside of the selection, if it is Table Selection
9784
- */
9785
- DeleteTableContents: BuildInEditFeature<PluginKeyboardEvent>;
9786
9955
  private clearState;
9787
9956
  private getNextTD;
9788
9957
  private prepareSelection;
@@ -9818,4 +9987,27 @@ class AutoFormat implements EditorPlugin {
9818
9987
  onPluginEvent(event: PluginEvent): void;
9819
9988
  }
9820
9989
 
9990
+ /**
9991
+ * Detect image selection and help highlight the image
9992
+ */
9993
+ class ImageSelection implements EditorPlugin {
9994
+ private editor;
9995
+ private imageId;
9996
+ constructor();
9997
+ /**
9998
+ * Get a friendly name of this plugin
9999
+ */
10000
+ getName(): string;
10001
+ /**
10002
+ * Initialize this plugin. This should only be called from Editor
10003
+ * @param editor Editor instance
10004
+ */
10005
+ initialize(editor: IEditor): void;
10006
+ /**
10007
+ * Dispose this plugin
10008
+ */
10009
+ dispose(): void;
10010
+ onPluginEvent(event: PluginEvent): void;
10011
+ }
10012
+
9821
10013
  }