roosterjs 8.14.0 → 8.16.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.14.0)
1
+ // Type definitions for roosterjs (Version 8.16.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -1132,20 +1132,20 @@ const enum TableBorderFormat {
1132
1132
  FIRST_COLUMN_HEADER_EXTERNAL = 4,
1133
1133
  /**
1134
1134
  * The header row has no vertical border, except for the first one
1135
- * The only horizontal border of the table is the top and bottom of header row
1135
+ * The first column has no horizontal border, except for the first one
1136
1136
  * __ __ __
1137
1137
  * |__ __ __
1138
- * | | |
1139
- * | | |
1138
+ * | |__|__|
1139
+ * | |__|__|
1140
1140
  */
1141
1141
  ESPECIAL_TYPE_1 = 5,
1142
1142
  /**
1143
1143
  * The header row has no vertical border, except for the first one
1144
- * The first column has no horizontal border, except for the first one
1144
+ * The only horizontal border of the table is the top and bottom of header row
1145
1145
  * __ __ __
1146
1146
  * |__ __ __
1147
- * | |__|__|
1148
- * | |__|__|
1147
+ * | | |
1148
+ * | | |
1149
1149
  */
1150
1150
  ESPECIAL_TYPE_2 = 6,
1151
1151
  /**
@@ -1431,7 +1431,7 @@ interface PluginScrollEvent extends PluginDomEventBase<PluginEventType.Scroll, U
1431
1431
  /**
1432
1432
  * Editor plugin event interface
1433
1433
  */
1434
- type PluginEvent = BeforeCutCopyEvent | BeforePasteEvent | ContentChangedEvent | EntityOperationEvent | ExtractContentWithDomEvent | PluginDomEvent | EditorReadyEvent | BeforeDisposeEvent | PendingFormatStateChangedEvent | EnterShadowEditEvent | LeaveShadowEditEvent | EditImageEvent | BeforeSetContentEvent;
1434
+ type PluginEvent = BeforeCutCopyEvent | BeforePasteEvent | ContentChangedEvent | EntityOperationEvent | ExtractContentWithDomEvent | PluginDomEvent | EditorReadyEvent | BeforeDisposeEvent | PendingFormatStateChangedEvent | EnterShadowEditEvent | LeaveShadowEditEvent | EditImageEvent | BeforeSetContentEvent | ZoomChangedEvent;
1435
1435
 
1436
1436
  /**
1437
1437
  * Editor plugin event type
@@ -1524,7 +1524,11 @@ const enum PluginEventType {
1524
1524
  * Content of editor is about to be cleared by SetContent API, handle this event to cache anything you need
1525
1525
  * before it is gone
1526
1526
  */
1527
- BeforeSetContent = 20
1527
+ BeforeSetContent = 20,
1528
+ /**
1529
+ * Zoom scale value is changed, triggered by Editor.setZoomScale() when set a different scale number
1530
+ */
1531
+ ZoomChanged = 21
1528
1532
  }
1529
1533
 
1530
1534
  /**
@@ -1569,6 +1573,22 @@ interface EnterShadowEditEvent extends BasePluginEvent<PluginEventType.EnteredSh
1569
1573
  interface LeaveShadowEditEvent extends BasePluginEvent<PluginEventType.LeavingShadowEdit> {
1570
1574
  }
1571
1575
 
1576
+ /**
1577
+ * Represents an event object triggered from Editor.setZoomScale() API.
1578
+ * Plugins can handle this event when they need to do something for zoom changing.
1579
+ *
1580
+ */
1581
+ interface ZoomChangedEvent extends BasePluginEvent<PluginEventType.ZoomChanged> {
1582
+ /**
1583
+ * Zoom scale value before this change
1584
+ */
1585
+ oldZoomScale: number;
1586
+ /**
1587
+ * Zoom scale value after this change
1588
+ */
1589
+ newZoomScale: number;
1590
+ }
1591
+
1572
1592
  /**
1573
1593
  * This refers to a "content block" in editor that serves as a content parsing boundary
1574
1594
  * It is most those html block like tags, i.e. &lt;p&gt;, &lt;div&gt;, &lt;li&gt;, &lt;td&gt; etc.
@@ -1623,7 +1643,7 @@ interface ClipboardData {
1623
1643
  * When set to null, it means there's no HTML from clipboard event.
1624
1644
  * When set to undefined, it means there may be HTML in clipboard event, but fail to retrieve
1625
1645
  */
1626
- rawHtml: string;
1646
+ rawHtml: string | null | undefined;
1627
1647
  /**
1628
1648
  * Link Preview information provided by Edge
1629
1649
  */
@@ -1631,7 +1651,7 @@ interface ClipboardData {
1631
1651
  /**
1632
1652
  * Image file from clipboard event
1633
1653
  */
1634
- image: File;
1654
+ image: File | null;
1635
1655
  /**
1636
1656
  * Html extracted from raw html string and remove content before and after fragment tag
1637
1657
  */
@@ -1643,7 +1663,7 @@ interface ClipboardData {
1643
1663
  /**
1644
1664
  * BASE64 encoded data uri of the image if any
1645
1665
  */
1646
- imageDataUri?: string;
1666
+ imageDataUri?: string | null;
1647
1667
  /**
1648
1668
  * Array of tag names of the first level child nodes
1649
1669
  */
@@ -2387,10 +2407,10 @@ interface HtmlSanitizerOptions {
2387
2407
  * Define a replacement tag name of unknown tags.
2388
2408
  * A star "*" means keep as it is, no replacement
2389
2409
  * Other valid string means replace the tag name with this string.
2390
- * Empty string, undefined or null means drop such elements and all its children
2410
+ * Empty string, undefined means drop such elements and all its children
2391
2411
  * @default undefined
2392
2412
  */
2393
- unknownTagReplacement?: string;
2413
+ unknownTagReplacement?: string | null;
2394
2414
  }
2395
2415
 
2396
2416
  /**
@@ -2737,6 +2757,12 @@ interface IEditor {
2737
2757
  * @returns True if content is selected, otherwise false
2738
2758
  */
2739
2759
  select(path: SelectionPath): boolean;
2760
+ /**
2761
+ * Select content using the Table Selection
2762
+ * @param table to select
2763
+ * @param coordinates first and last cell of the range
2764
+ */
2765
+ select(table: HTMLTableElement, coordinates: TableSelection): boolean;
2740
2766
  /**
2741
2767
  * Get current focused position. Return null if editor doesn't have focus at this time.
2742
2768
  */
@@ -2953,7 +2979,20 @@ interface IEditor {
2953
2979
  */
2954
2980
  getTrustedHTMLHandler(): TrustedHTMLHandler;
2955
2981
  /**
2956
- * Get a transformer function. It transform the size changes according to current situation.
2982
+ * Get current zoom scale, default value is 1
2983
+ * When editor is put under a zoomed container, need to pass the zoom scale number using EditorOptions.zoomScale
2984
+ * to let editor behave correctly especially for those mouse drag/drop behaviors
2985
+ * @returns current zoom scale number
2986
+ */
2987
+ getZoomScale(): number;
2988
+ /**
2989
+ * Set current zoom scale, default value is 1
2990
+ * When editor is put under a zoomed container, need to pass the zoom scale number using EditorOptions.zoomScale
2991
+ * to let editor behave correctly especially for those mouse drag/drop behaviors
2992
+ */
2993
+ setZoomScale(scale: number): void;
2994
+ /**
2995
+ * @deprecated Use getZoomScale() instead
2957
2996
  */
2958
2997
  getSizeTransformer(): SizeTransformer;
2959
2998
  }
@@ -3156,10 +3195,9 @@ interface EditorCore extends PluginState {
3156
3195
  * To override, pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler
3157
3196
  */
3158
3197
  readonly trustedHTMLHandler: TrustedHTMLHandler;
3198
+ zoomScale: number;
3159
3199
  /**
3160
- * A transformer function. It transform the size changes according to current situation.
3161
- * A typical scenario to use this function is when editor is located under a scaled container, so we need to
3162
- * calculate the scaled size change according to current zoom rate.
3200
+ * @deprecated Use zoomScale instead
3163
3201
  */
3164
3202
  sizeTransformer: SizeTransformer;
3165
3203
  }
@@ -3316,6 +3354,16 @@ interface CoreApiMap {
3316
3354
  * @param broadcast Set to true to skip the shouldHandleEventExclusively check
3317
3355
  */
3318
3356
  triggerEvent: TriggerEvent;
3357
+ /**
3358
+ * Select a table and save data of the selected range
3359
+ * @param core The EditorCore object
3360
+ * @param table table to select
3361
+ * @param coordinates first and last cell of the selection, if this parameter is null, instead of
3362
+ * selecting, will unselect the table.
3363
+ * @param shouldAddStyles Whether need to update the style elements
3364
+ * @returns true if successful
3365
+ */
3366
+ selectTable: SelectTable;
3319
3367
  }
3320
3368
 
3321
3369
  /**
@@ -3446,6 +3494,16 @@ type TransformColor = (core: EditorCore, rootNode: Node, includeSelf: boolean, c
3446
3494
  */
3447
3495
  type TriggerEvent = (core: EditorCore, pluginEvent: PluginEvent, broadcast: boolean) => void;
3448
3496
 
3497
+ /**
3498
+ * Select a table and save data of the selected range
3499
+ * @param core The EditorCore object
3500
+ * @param table table to select
3501
+ * @param coordinates first and last cell of the selection, if this parameter is null, instead of
3502
+ * selecting, will unselect the table.
3503
+ * @returns true if successful
3504
+ */
3505
+ type SelectTable = (core: EditorCore, table: HTMLTableElement, coordinates?: TableSelection) => TableSelectionRange;
3506
+
3449
3507
  /**
3450
3508
  * The options to specify parameters customizing an editor, used by ctor of Editor class
3451
3509
  */
@@ -3532,9 +3590,13 @@ interface EditorOptions {
3532
3590
  */
3533
3591
  trustedHTMLHandler?: TrustedHTMLHandler;
3534
3592
  /**
3535
- * A transformer function. It transform the size changes according to current situation.
3536
- * A typical scenario to use this function is when editor is located under a scaled container, so we need to
3537
- * calculate the scaled size change according to current zoom rate.
3593
+ * Current zoom scale, @default value is 1
3594
+ * When editor is put under a zoomed container, need to pass the zoom scale number using this property
3595
+ * to let editor behave correctly especially for those mouse drag/drop behaviors
3596
+ */
3597
+ zoomScale?: number;
3598
+ /**
3599
+ * @deprecated Use zoomScale instead
3538
3600
  */
3539
3601
  sizeTransformer?: SizeTransformer;
3540
3602
  }
@@ -4031,6 +4093,10 @@ interface TableSelectionRange extends SelectionRangeExBase<SelectionRangeTypes.T
4031
4093
  * Table that has cells selected
4032
4094
  */
4033
4095
  table: HTMLTableElement;
4096
+ /**
4097
+ * Coordinates of first and last Cell
4098
+ */
4099
+ coordinates: TableSelection;
4034
4100
  }
4035
4101
 
4036
4102
  /**
@@ -4068,6 +4134,10 @@ interface DOMEventPluginState {
4068
4134
  * Cached selection range
4069
4135
  */
4070
4136
  selectionRange: Range;
4137
+ /**
4138
+ * Table selection range
4139
+ */
4140
+ tableSelectionRange: TableSelectionRange;
4071
4141
  /**
4072
4142
  * stop propagation of a printable keyboard event
4073
4143
  */
@@ -4148,6 +4218,10 @@ interface LifecyclePluginState {
4148
4218
  * Cached selection path for original content
4149
4219
  */
4150
4220
  shadowEditSelectionPath: SelectionPath;
4221
+ /**
4222
+ * Cached table selection path for original content
4223
+ */
4224
+ shadowEditTableSelectionPath: SelectionPath[];
4151
4225
  }
4152
4226
 
4153
4227
  /**
@@ -4653,7 +4727,7 @@ function extractClipboardItems(items: DataTransferItem[], options?: ExtractClipb
4653
4727
  * When set to undefined, it means can't retrieve HTML string, there may be HTML string but direct retrieving is
4654
4728
  * not supported by browser.
4655
4729
  */
4656
- function extractClipboardItemsForIE(dataTransfer: DataTransfer, callback: (data: ClipboardData) => void, options: ExtractClipboardItemsForIEOptions): void;
4730
+ function extractClipboardItemsForIE(dataTransfer: DataTransfer, callback: (data: ClipboardData) => void, options?: ExtractClipboardItemsForIEOptions): void;
4657
4731
 
4658
4732
  /**
4659
4733
  * A type-safe wrapper for Array.prototype.push.apply()
@@ -5050,22 +5124,22 @@ class VTable {
5050
5124
  * Current column index
5051
5125
  */
5052
5126
  col: number;
5053
- /**
5054
- * Current format of the table
5055
- */
5056
- formatInfo: TableFormat;
5057
5127
  /**
5058
5128
  * Selected range of cells with the coordinates of the first and last cell selected.
5059
5129
  */
5060
5130
  selection: TableSelection;
5131
+ /**
5132
+ * Current format of the table
5133
+ */
5134
+ formatInfo: TableFormat;
5061
5135
  private trs;
5062
5136
  /**
5063
5137
  * Create a new instance of VTable object using HTML TABLE or TD node
5064
5138
  * @param node The HTML Table or TD node
5065
5139
  * @param normalizeSize Whether table size needs to be normalized
5066
- * @param sizeTransformer A size transformer function used for normalize table size
5140
+ * @param zoomScale When the table is under a zoomed container, pass in the zoom scale here
5067
5141
  */
5068
- constructor(node: HTMLTableElement | HTMLTableCellElement, normalizeSize?: boolean, sizeTransformer?: SizeTransformer);
5142
+ constructor(node: HTMLTableElement | HTMLTableCellElement, normalizeSize?: boolean, zoomScale?: number | SizeTransformer);
5069
5143
  /**
5070
5144
  * Write the virtual table back to DOM tree to represent the change of VTable
5071
5145
  */
@@ -5076,39 +5150,10 @@ class VTable {
5076
5150
  */
5077
5151
  applyFormat(format: Partial<TableFormat>): void;
5078
5152
  /**
5079
- * Set color to the table
5080
- * @param format
5081
- */
5082
- private setColor;
5083
- /**
5084
- * Set color to borders of an table
5085
- * @param format
5086
- * @returns
5087
- */
5088
- private setBorderColors;
5089
- /**
5090
- * Format the border type
5091
- * @returns
5092
- */
5093
- private formatBorders;
5094
- /**
5095
- * Organize the borders of table according to a border type
5096
- * @param format
5097
- * @returns
5153
+ * Remove the cellshade dataset to apply a new style format at the cell.
5154
+ * @param cells
5098
5155
  */
5099
- private setBordersType;
5100
- /**
5101
- * Apply custom design to the first table column
5102
- * @param format
5103
- * @returns
5104
- */
5105
- private setFirstColumnFormat;
5106
- /**
5107
- * Apply custom design to the Header Row
5108
- * @param format
5109
- * @returns
5110
- */
5111
- private setHeaderRowFormat;
5156
+ private deleteCellShadeDataset;
5112
5157
  /**
5113
5158
  * Edit table with given operation.
5114
5159
  * @param operation Table operation
@@ -5172,7 +5217,7 @@ class VTable {
5172
5217
  private countSpanLeft;
5173
5218
  private countSpanAbove;
5174
5219
  private normalizeEmptyTableCells;
5175
- normalizeTableCellSize(sizeTransformer?: SizeTransformer): void;
5220
+ normalizeTableCellSize(zoomScale?: number | SizeTransformer): void;
5176
5221
  private normalizeSize;
5177
5222
  }
5178
5223
 
@@ -5758,7 +5803,7 @@ class HtmlSanitizer {
5758
5803
  * @param currentStyles Current CSS styles. Inheritable styles in the given node which has
5759
5804
  * the same value with current styles will be ignored.
5760
5805
  */
5761
- sanitize(rootNode: Node, currentStyles?: StringMap): string;
5806
+ sanitize(rootNode: Node, currentStyles?: StringMap): "" | undefined;
5762
5807
  /**
5763
5808
  * Convert global CSS into inline CSS
5764
5809
  * @param rootNode The HTML Document
@@ -5775,7 +5820,7 @@ class HtmlSanitizer {
5775
5820
  * Get inheritable CSS style values from the given element
5776
5821
  * @param element The element to get style from
5777
5822
  */
5778
- function getInheritableStyles(element: HTMLElement): StringMap;
5823
+ function getInheritableStyles(element: HTMLElement | null): StringMap;
5779
5824
 
5780
5825
  /**
5781
5826
  * Create default value of HtmlSanitizerOptions with every property set
@@ -6229,9 +6274,23 @@ class Editor implements IEditor {
6229
6274
  */
6230
6275
  getTrustedHTMLHandler(): TrustedHTMLHandler;
6231
6276
  /**
6232
- * Get a transformer function. It transform the size changes according to current situation.
6277
+ * @deprecated Use getZoomScale() instead
6233
6278
  */
6234
6279
  getSizeTransformer(): SizeTransformer;
6280
+ /**
6281
+ * Get current zoom scale, default value is 1
6282
+ * When editor is put under a zoomed container, need to pass the zoom scale number using EditorOptions.zoomScale
6283
+ * to let editor behave correctly especially for those mouse drag/drop behaviors
6284
+ * @returns current zoom scale number
6285
+ */
6286
+ getZoomScale(): number;
6287
+ /**
6288
+ * Set current zoom scale, default value is 1
6289
+ * When editor is put under a zoomed container, need to pass the zoom scale number using EditorOptions.zoomScale
6290
+ * to let editor behave correctly especially for those mouse drag/drop behaviors
6291
+ * @param scale The new scale number to set. It should be positive number and no greater than 10, otherwise it will be ignored.
6292
+ */
6293
+ setZoomScale(scale: number): void;
6235
6294
  }
6236
6295
 
6237
6296
  /**
@@ -7260,13 +7319,13 @@ class TableCellSelection implements EditorPlugin {
7260
7319
  * When press Backspace, delete the contents inside of the selection, if it is Table Selection
7261
7320
  */
7262
7321
  DeleteTableContents: BuildInEditFeature<PluginKeyboardEvent>;
7263
- private clearTableCellSelection;
7264
7322
  private clearState;
7265
7323
  private getNextTD;
7266
7324
  private prepareSelection;
7267
7325
  private setData;
7268
7326
  private isAfter;
7269
7327
  private shouldConvertToTableSelection;
7328
+ selectTable(): void;
7270
7329
  }
7271
7330
 
7272
7331
  }