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