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