roosterjs 8.45.1 → 8.46.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.45.1)
1
+ // Type definitions for roosterjs (Version 8.46.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -402,6 +402,19 @@ function extractClipboardItems(items: DataTransferItem[], options?: ExtractClipb
402
402
  */
403
403
  function extractClipboardItemsForIE(dataTransfer: DataTransfer, callback: (data: ClipboardData) => void, options?: ExtractClipboardItemsForIEOptions): void;
404
404
 
405
+ /**
406
+ * Create a DocumentFragment for paste from a ClipboardData
407
+ * @param core The EditorCore object.
408
+ * @param clipboardData Clipboard data retrieved from clipboard
409
+ * @param position The position to paste to
410
+ * @param pasteAsText True to force use plain text as the content to paste, false to choose HTML or Image if any
411
+ * @param applyCurrentStyle True if apply format of current selection to the pasted content,
412
+ * @param pasteAsImage Whether to force paste as image
413
+ * @param event Event to trigger.
414
+ * false to keep original format
415
+ */
416
+ function createFragmentFromClipboardData(core: EditorCore, clipboardData: ClipboardData, position: NodePosition | null, pasteAsText: boolean, applyCurrentStyle: boolean, pasteAsImage: boolean, event: BeforePasteEvent): DocumentFragment;
417
+
405
418
  /**
406
419
  * Browser object contains browser and operating system information of current environment
407
420
  */
@@ -1782,8 +1795,7 @@ function removeImportantStyleRule(element: HTMLElement, styleProperties: string[
1782
1795
  * Add global css styles
1783
1796
  * @param doc The document object
1784
1797
  * @param cssRule The css rule that must added to the selection
1785
- * @param editorId Te id of the editor
1786
- * @param styleId the ID of the style tag
1798
+ * @param styleId The id of the style tag
1787
1799
  */
1788
1800
  function setGlobalCssStyles(doc: Document, cssRule: string, styleId: string): void;
1789
1801
 
@@ -1946,6 +1958,14 @@ function toArray<T extends Element>(collection: HTMLCollectionOf<T>): T[];
1946
1958
  */
1947
1959
  function toArray<T>(array: readonly T[]): T[];
1948
1960
 
1961
+ /**
1962
+ * This function tries to get the source of the Pasted content
1963
+ * @param event the before paste event
1964
+ * @param shouldConvertSingleImage Whether convert single image is enabled.
1965
+ * @returns The Type of pasted content, if no type found will return {KnownSourceType.Default}
1966
+ */
1967
+ function getPasteSource(event: BeforePasteEvent, shouldConvertSingleImage: boolean): KnownPasteSourceType;
1968
+
1949
1969
  /**
1950
1970
  * RoosterJs core editor class
1951
1971
  */
@@ -2094,7 +2114,7 @@ class EditorBase<TEditorCore extends EditorCore, TEditorOptions extends EditorOp
2094
2114
  * Focus to this editor, the selection was restored to where it was before, no unexpected scroll.
2095
2115
  */
2096
2116
  focus(): void;
2097
- select(arg1: Range | SelectionRangeEx | NodePosition | Node | SelectionPath | null, arg2?: NodePosition | number | PositionType | TableSelection, arg3?: Node, arg4?: number | PositionType): boolean;
2117
+ select(arg1: Range | SelectionRangeEx | NodePosition | Node | SelectionPath | null, arg2?: NodePosition | number | PositionType | TableSelection | null, arg3?: Node, arg4?: number | PositionType): boolean;
2098
2118
  /**
2099
2119
  * Get current focused position. Return null if editor doesn't have focus at this time.
2100
2120
  */
@@ -3771,6 +3791,10 @@ const enum ExperimentalFeatures {
3771
3791
  * Reuse existing DOM structure if possible when convert Content Model back to DOM tree
3772
3792
  */
3773
3793
  ReusableContentModel = "ReusableContentModel",
3794
+ /**
3795
+ * Apply default format on editor container
3796
+ */
3797
+ DefaultFormatOnContainer = "DefaultFormatOnContainer",
3774
3798
  /**
3775
3799
  * Delete table with Backspace key with the whole was selected with table selector
3776
3800
  */
@@ -3778,7 +3802,11 @@ const enum ExperimentalFeatures {
3778
3802
  /**
3779
3803
  * Add entities around a Read Only Inline entity to prevent cursor to be hidden when cursor is next of it.
3780
3804
  */
3781
- InlineEntityReadOnlyDelimiters = "InlineEntityReadOnlyDelimiters"
3805
+ InlineEntityReadOnlyDelimiters = "InlineEntityReadOnlyDelimiters",
3806
+ /**
3807
+ * Paste with Content model
3808
+ */
3809
+ ContentModelPaste = "ContentModelPaste"
3782
3810
  }
3783
3811
 
3784
3812
  /**
@@ -4152,6 +4180,20 @@ const enum KnownCreateElementDataIndex {
4152
4180
  EmptyLineFormatInSpan = 12
4153
4181
  }
4154
4182
 
4183
+ /**
4184
+ * Represent the types of sources to handle in the Paste Plugin
4185
+ */
4186
+ const enum KnownPasteSourceType {
4187
+ WordDesktop = 0,
4188
+ ExcelDesktop = 1,
4189
+ ExcelOnline = 2,
4190
+ PowerPointDesktop = 3,
4191
+ GoogleSheets = 4,
4192
+ WacComponents = 5,
4193
+ Default = 6,
4194
+ SingleImage = 7
4195
+ }
4196
+
4155
4197
  /**
4156
4198
  * Table format border
4157
4199
  */
@@ -6072,7 +6114,7 @@ interface HtmlSanitizerOptions {
6072
6114
  *
6073
6115
  * For other unknown tags, we will respect the value of unknownTagReplacement with the same meaning
6074
6116
  */
6075
- additionalTagReplacements?: Record<string, string>;
6117
+ additionalTagReplacements?: Record<string, string | null>;
6076
6118
  /**
6077
6119
  * Allowed HTML attributes in addition to default attributes, in lower case
6078
6120
  */
@@ -6454,9 +6496,9 @@ interface IEditor {
6454
6496
  /**
6455
6497
  * Select content using the Table Selection
6456
6498
  * @param table to select
6457
- * @param coordinates first and last cell of the range
6499
+ * @param coordinates first and last cell of the range, if null is provided will remove the selection on the table
6458
6500
  */
6459
- select(table: HTMLTableElement, coordinates: TableSelection): boolean;
6501
+ select(table: HTMLTableElement, coordinates: TableSelection | null): boolean;
6460
6502
  /**
6461
6503
  * Select content SelectionRangeEx
6462
6504
  * @param rangeEx SelectionRangeEx object to specify what to select
@@ -7124,7 +7166,7 @@ interface CoreApiMap {
7124
7166
  * There are a bunch of allowed combination of parameters. See IEditor.select for more details
7125
7167
  * @param core The editor core object
7126
7168
  * @param arg1 A DOM Range, or SelectionRangeEx, or NodePosition, or Node, or Selection Path
7127
- * @param arg2 (optional) A NodePosition, or an offset number, or a PositionType, or a TableSelection
7169
+ * @param arg2 (optional) A NodePosition, or an offset number, or a PositionType, or a TableSelection, or null
7128
7170
  * @param arg3 (optional) A Node
7129
7171
  * @param arg4 (optional) An offset number, or a PositionType
7130
7172
  */
@@ -7282,11 +7324,11 @@ type RestoreUndoSnapshot = (core: EditorCore, step: number) => void;
7282
7324
  * There are a bunch of allowed combination of parameters. See IEditor.select for more details
7283
7325
  * @param core The editor core object
7284
7326
  * @param arg1 A DOM Range, or SelectionRangeEx, or NodePosition, or Node, or Selection Path
7285
- * @param arg2 (optional) A NodePosition, or an offset number, or a PositionType, or a TableSelection
7327
+ * @param arg2 (optional) A NodePosition, or an offset number, or a PositionType, or a TableSelection, or null
7286
7328
  * @param arg3 (optional) A Node
7287
7329
  * @param arg4 (optional) An offset number, or a PositionType
7288
7330
  */
7289
- type Select = (core: EditorCore, arg1: Range | SelectionRangeEx | NodePosition | Node | SelectionPath | null, arg2?: NodePosition | number | PositionType | TableSelection, arg3?: Node, arg4?: number | PositionType) => boolean;
7331
+ type Select = (core: EditorCore, arg1: Range | SelectionRangeEx | NodePosition | Node | SelectionPath | null, arg2?: NodePosition | number | PositionType | TableSelection | null, arg3?: Node, arg4?: number | PositionType) => boolean;
7290
7332
 
7291
7333
  /**
7292
7334
  * Change the editor selection to the given range
@@ -8409,6 +8451,10 @@ enum CompatibleExperimentalFeatures {
8409
8451
  * Reuse existing DOM structure if possible when convert Content Model back to DOM tree
8410
8452
  */
8411
8453
  ReusableContentModel = "ReusableContentModel",
8454
+ /**
8455
+ * Apply default format on editor container
8456
+ */
8457
+ DefaultFormatOnContainer = "DefaultFormatOnContainer",
8412
8458
  /**
8413
8459
  * Delete table with Backspace key with the whole was selected with table selector
8414
8460
  */
@@ -8416,7 +8462,11 @@ enum CompatibleExperimentalFeatures {
8416
8462
  /**
8417
8463
  * Add entities around a Read Only Inline entity to prevent cursor to be hidden when cursor is next of it.
8418
8464
  */
8419
- InlineEntityReadOnlyDelimiters = "InlineEntityReadOnlyDelimiters"
8465
+ InlineEntityReadOnlyDelimiters = "InlineEntityReadOnlyDelimiters",
8466
+ /**
8467
+ * Paste with Content model
8468
+ */
8469
+ ContentModelPaste = "ContentModelPaste"
8420
8470
  }
8421
8471
 
8422
8472
  /**
@@ -9510,6 +9560,20 @@ enum CompatibleKnownCreateElementDataIndex {
9510
9560
  EmptyLineFormatInSpan = 12
9511
9561
  }
9512
9562
 
9563
+ /**
9564
+ * Represent the types of sources to handle in the Paste Plugin
9565
+ */
9566
+ enum CompatibleKnownPasteSourceType {
9567
+ WordDesktop = 0,
9568
+ ExcelDesktop = 1,
9569
+ ExcelOnline = 2,
9570
+ PowerPointDesktop = 3,
9571
+ GoogleSheets = 4,
9572
+ WacComponents = 5,
9573
+ Default = 6,
9574
+ SingleImage = 7
9575
+ }
9576
+
9513
9577
  /**
9514
9578
  * Type of list (numbering or bullet)
9515
9579
  */
@@ -10405,15 +10469,8 @@ class Watermark implements EditorPlugin {
10405
10469
  */
10406
10470
  class TableCellSelection implements EditorPlugin {
10407
10471
  private editor;
10408
- private lastTarget;
10409
- private firstTarget;
10410
- private tableRange;
10411
- private tableSelection;
10412
- private startedSelection;
10413
- private vTable;
10414
- private firstTable;
10415
- private targetTable;
10416
- private preventKeyUp;
10472
+ private state;
10473
+ private shadowEditCoordinatesBackup;
10417
10474
  constructor();
10418
10475
  /**
10419
10476
  * Get a friendly name of this plugin
@@ -10433,37 +10490,8 @@ class TableCellSelection implements EditorPlugin {
10433
10490
  * @param event PluginEvent object
10434
10491
  */
10435
10492
  onPluginEvent(event: PluginEvent): void;
10436
- /**
10437
- * Handle Scroll Event and mantains the selection range,
10438
- * Since when we scroll the cursor does not trigger the on Mouse Move event
10439
- * The table selection gets removed.
10440
- */
10441
- private handleScrollEvent;
10442
- /**
10443
- * Handles the on key event.
10444
- * @param event the plugin event
10445
- */
10446
- private handleKeyDownEvent;
10447
- private handleKeyUpEvent;
10448
- private handleKeySelectionInsideTable;
10449
- private handleMouseDownEvent;
10450
- private onMouseMove;
10451
- private onMouseUp;
10452
- private restoreSelection;
10453
- /**
10454
- * @internal
10455
- * Public only for unit testing
10456
- * @param event mouse event
10457
- */
10458
- selectionInsideTableMouseMove(event: MouseEvent): void;
10459
- private removeMouseUpEventListener;
10460
- private clearState;
10461
- private getNextTD;
10462
- private prepareSelection;
10463
- private setData;
10464
- private isAfter;
10465
- private shouldConvertToTableSelection;
10466
- selectTable(): void;
10493
+ private handleLeavingShadowEdit;
10494
+ private handleEnteredShadowEdit;
10467
10495
  }
10468
10496
 
10469
10497
  /**