roosterjs 8.46.0 → 8.48.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.46.0)
1
+ // Type definitions for roosterjs (Version 8.48.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -723,7 +723,8 @@ export function getInnerHTML(node: HTMLElement | DocumentFragment): string;
723
723
  * @param isBackgroundColor Whether set background color or text color
724
724
  * @param isDarkMode Whether current mode is dark mode. @default false
725
725
  * @param shouldAdaptTheFontColor Whether the font color needs to be adapted to be visible in a dark or bright background color. @default false
726
- * @param darkColorHandler An optional dark color handler object. When it is passed, we will use this handler to do variable-based dark color instead of original dataset base dark color
726
+ * @param darkColorHandler A dark color handler object. This is now required.
727
+ * We keep it optional only for backward compatibility. If it is not passed, color will not be set.
727
728
  */
728
729
  export function setColor(element: HTMLElement, color: string | ModeIndependentColor, isBackgroundColor: boolean, isDarkMode?: boolean, shouldAdaptTheFontColor?: boolean, darkColorHandler?: DarkColorHandler | null): void;
729
730
 
@@ -1314,8 +1315,9 @@ export function getRegionsFromRange(root: HTMLElement, range: Range, type: Regio
1314
1315
  * @param regionBase The region to get block elements from
1315
1316
  * @param createBlockIfEmpty When set to true, a new empty block element will be created if there is not
1316
1317
  * any blocks in the region. Default value is false
1318
+ * @param deprecated Deprecated parameter, not used
1317
1319
  */
1318
- export function getSelectedBlockElementsInRegion(regionBase: RegionBase, createBlockIfEmpty?: boolean, shouldApplyFormatToSpan?: boolean): BlockElement[];
1320
+ export function getSelectedBlockElementsInRegion(regionBase: RegionBase, createBlockIfEmpty?: boolean, deprecated?: boolean): BlockElement[];
1319
1321
 
1320
1322
  /**
1321
1323
  * Collapse nodes within this region to their common ancestor node under this region
@@ -2302,9 +2304,9 @@ export class EditorBase<TEditorCore extends EditorCore, TEditorOptions extends E
2302
2304
  */
2303
2305
  transformToDarkColor(node: Node): void;
2304
2306
  /**
2305
- * Get a darkColorHandler object for this editor. It will return null if experimental feature "VariableBasedDarkColor" is not enabled
2307
+ * Get a darkColorHandler object for this editor.
2306
2308
  */
2307
- getDarkColorHandler(): DarkColorHandler | null;
2309
+ getDarkColorHandler(): DarkColorHandler;
2308
2310
  /**
2309
2311
  * Make the editor in "Shadow Edit" mode.
2310
2312
  * In Shadow Edit mode, all format change will finally be ignored.
@@ -2455,8 +2457,11 @@ export function getElementBasedFormatState(editor: IEditor, event?: PluginEvent)
2455
2457
  * If isBlock is true, entity will be insert below this position
2456
2458
  * @param insertToRegionRoot @optional When pass true, insert the entity at the root level of current region.
2457
2459
  * Parent nodes will be split if need
2460
+ * @param focusAfterEntity @optional When pass true, focus will be moved next to the entity. For inline entity,
2461
+ * focus will be after right after the entity (and the delimiter if exist). For block entity, focus will be in
2462
+ * the new empty line below the entity
2458
2463
  */
2459
- export function insertEntity(editor: IEditor, type: string, contentNode: Node, isBlock: boolean, isReadonly: boolean, position?: NodePosition | ContentPosition.Begin | ContentPosition.End | ContentPosition.DomEnd, insertToRegionRoot?: boolean): Entity;
2464
+ export function insertEntity(editor: IEditor, type: string, contentNode: Node, isBlock: boolean, isReadonly: boolean, position?: NodePosition | ContentPosition.Begin | ContentPosition.End | ContentPosition.DomEnd | CompatibleContentPosition.Begin | CompatibleContentPosition.End | CompatibleContentPosition.DomEnd, insertToRegionRoot?: boolean, focusAfterEntity?: boolean): Entity;
2460
2465
 
2461
2466
  /**
2462
2467
  * Insert an image to editor at current selection
@@ -3539,6 +3544,7 @@ export const enum ContentPosition {
3539
3544
  }
3540
3545
 
3541
3546
  /**
3547
+ * @deprecated
3542
3548
  * Constants string for dataset names used by dark mode
3543
3549
  */
3544
3550
  export const enum DarkModeDatasetNames {
@@ -3757,13 +3763,29 @@ export const enum ExperimentalFeatures {
3757
3763
  */
3758
3764
  ImageSelection = "ImageSelection",
3759
3765
  /**
3760
- * Provide additional Tab Key Features. Requires Text Features Content Editable Features
3766
+ * @deprecated this feature is always enabled
3767
+ * Use variable-based dark mode solution rather than dataset-based solution.
3768
+ * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
3769
+ * if you need them work for dark mode
3761
3770
  */
3762
- TabKeyTextFeatures = "TabKeyTextFeatures",
3771
+ VariableBasedDarkColor = "VariableBasedDarkColor",
3763
3772
  /**
3773
+ * @deprecated this feature is always enabled
3764
3774
  * Align list elements elements to left, center and right using setAlignment API
3765
3775
  */
3766
3776
  ListItemAlignment = "ListItemAlignment",
3777
+ /**
3778
+ * @deprecated
3779
+ */
3780
+ DefaultFormatInSpan = "DefaultFormatInSpan",
3781
+ /**
3782
+ * @deprecated
3783
+ */
3784
+ DefaultFormatOnContainer = "DefaultFormatOnContainer",
3785
+ /**
3786
+ * Provide additional Tab Key Features. Requires Text Features Content Editable Features
3787
+ */
3788
+ TabKeyTextFeatures = "TabKeyTextFeatures",
3767
3789
  /**
3768
3790
  * Trigger formatting by a especial characters. Ex: (A), 1. i).
3769
3791
  */
@@ -3775,25 +3797,14 @@ export const enum ExperimentalFeatures {
3775
3797
  * is the one closest to the item.
3776
3798
  */
3777
3799
  ReuseAllAncestorListElements = "ReuseAllAncestorListElements",
3778
- /**
3779
- * When apply default format when initialize or user type, apply the format on a SPAN element rather than
3780
- * the block element (In most case, the DIV element) so keep the block element clean.
3781
- */
3782
- DefaultFormatInSpan = "DefaultFormatInSpan",
3783
- /**
3784
- * Use variable-based dark mode solution rather than dataset-based solution.
3785
- * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
3786
- * if you need them work for dark mode
3787
- */
3788
- VariableBasedDarkColor = "VariableBasedDarkColor",
3789
3800
  /**
3790
3801
  * Reuse existing DOM structure if possible when convert Content Model back to DOM tree
3791
3802
  */
3792
3803
  ReusableContentModel = "ReusableContentModel",
3793
3804
  /**
3794
- * Apply default format on editor container
3805
+ * Handle keyboard editing event with Content Model
3795
3806
  */
3796
- DefaultFormatOnContainer = "DefaultFormatOnContainer",
3807
+ EditWithContentModel = "EditWithContentModel",
3797
3808
  /**
3798
3809
  * Delete table with Backspace key with the whole was selected with table selector
3799
3810
  */
@@ -4174,7 +4185,7 @@ export const enum KnownCreateElementDataIndex {
4174
4185
  */
4175
4186
  TableSelector = 11,
4176
4187
  /**
4177
- * An empty line without format with span inside of it.
4188
+ * @deprecated
4178
4189
  */
4179
4190
  EmptyLineFormatInSpan = 12
4180
4191
  }
@@ -4367,7 +4378,13 @@ export const enum PluginEventType {
4367
4378
  * EXPERIMENTAL FEATURE
4368
4379
  * Editor changed the selection.
4369
4380
  */
4370
- SelectionChanged = 22
4381
+ SelectionChanged = 22,
4382
+ /**
4383
+ * EXPERIMENTAL FEATURE
4384
+ * Editor content is about to be changed by keyboard event.
4385
+ * This is only used by Content Model editing
4386
+ */
4387
+ BeforeKeyboardEditing = 23
4371
4388
  }
4372
4389
 
4373
4390
  /**
@@ -4562,6 +4579,28 @@ export const enum DefinitionType {
4562
4579
  Customize = 5
4563
4580
  }
4564
4581
 
4582
+ /**
4583
+ * Enum for paste options
4584
+ */
4585
+ export const enum PasteType {
4586
+ /**
4587
+ * Default paste behavior
4588
+ */
4589
+ Normal = 0,
4590
+ /**
4591
+ * Paste only the plain text
4592
+ */
4593
+ AsPlainText = 1,
4594
+ /**
4595
+ * Apply the current style to pasted content
4596
+ */
4597
+ MergeFormat = 2,
4598
+ /**
4599
+ * If there is a image uri in the clipboard, paste the content as image element
4600
+ */
4601
+ AsImage = 3
4602
+ }
4603
+
4565
4604
  /**
4566
4605
  * Provides a chance for plugin to change the content before it is copied from editor.
4567
4606
  */
@@ -4660,6 +4699,10 @@ export interface BeforePasteEventData {
4660
4699
  * Attributes of the root "HTML" tag
4661
4700
  */
4662
4701
  htmlAttributes: Record<string, string>;
4702
+ /**
4703
+ * Paste type option (as plain text, merge format, normal, as image)
4704
+ */
4705
+ readonly pasteType: PasteType | CompatiblePasteType;
4663
4706
  }
4664
4707
 
4665
4708
  /**
@@ -5050,7 +5093,7 @@ export interface PluginContextMenuEventData {
5050
5093
  /**
5051
5094
  * Editor plugin event interface
5052
5095
  */
5053
- export type PluginEvent = BeforeCutCopyEvent | BeforePasteEvent | ContentChangedEvent | EntityOperationEvent | ExtractContentWithDomEvent | PluginDomEvent | EditorReadyEvent | BeforeDisposeEvent | PendingFormatStateChangedEvent | EnterShadowEditEvent | LeaveShadowEditEvent | EditImageEvent | BeforeSetContentEvent | ZoomChangedEvent | SelectionChangedEvent | CompatibleBeforeCutCopyEvent | CompatibleBeforeDisposeEvent | CompatibleBeforePasteEvent | CompatibleBeforeSetContentEvent | CompatibleContentChangedEvent | CompatibleEditImageEvent | CompatibleEditorReadyEvent | CompatibleEntityOperationEvent | CompatibleExtractContentWithDomEvent | CompatiblePendingFormatStateChangedEvent | CompatiblePluginDomEvent | CompatibleEnterShadowEditEvent | CompatibleLeaveShadowEditEvent | CompatibleZoomChangedEvent | CompatibleSelectionChangedEvent;
5096
+ export type PluginEvent = BeforeCutCopyEvent | BeforePasteEvent | ContentChangedEvent | EntityOperationEvent | ExtractContentWithDomEvent | PluginDomEvent | EditorReadyEvent | BeforeDisposeEvent | PendingFormatStateChangedEvent | EnterShadowEditEvent | LeaveShadowEditEvent | EditImageEvent | BeforeSetContentEvent | ZoomChangedEvent | SelectionChangedEvent | BeforeKeyboardEditingEvent | CompatibleBeforeCutCopyEvent | CompatibleBeforeDisposeEvent | CompatibleBeforePasteEvent | CompatibleBeforeSetContentEvent | CompatibleContentChangedEvent | CompatibleEditImageEvent | CompatibleEditorReadyEvent | CompatibleEntityOperationEvent | CompatibleExtractContentWithDomEvent | CompatiblePendingFormatStateChangedEvent | CompatiblePluginDomEvent | CompatibleEnterShadowEditEvent | CompatibleLeaveShadowEditEvent | CompatibleZoomChangedEvent | CompatibleSelectionChangedEvent | CompatibleBeforeKeyboardEditingEvent;
5054
5097
 
5055
5098
  /**
5056
5099
  * A type to extract data part of a plugin event type. Data part is the plugin event without eventType field.
@@ -5164,6 +5207,28 @@ export interface SelectionChangedEventData {
5164
5207
  export interface CompatibleSelectionChangedEvent extends SelectionChangedEventData, BasePluginEvent<CompatiblePluginEventType.SelectionChanged> {
5165
5208
  }
5166
5209
 
5210
+ /**
5211
+ * Provides a chance for plugin to change the content before it is copied from editor.
5212
+ */
5213
+ export interface BeforeKeyboardEditingEvent extends BeforeKeyboardEditingData, BasePluginEvent<PluginEventType.BeforeKeyboardEditing> {
5214
+ }
5215
+
5216
+ /**
5217
+ * Data of BeforeKeyboardEditing
5218
+ */
5219
+ export interface BeforeKeyboardEditingData {
5220
+ /**
5221
+ * Raw DOM event
5222
+ */
5223
+ rawEvent: KeyboardEvent;
5224
+ }
5225
+
5226
+ /**
5227
+ * Provides a chance for plugin to change the content before it is copied from editor.
5228
+ */
5229
+ export interface CompatibleBeforeKeyboardEditingEvent extends BeforeKeyboardEditingData, BasePluginEvent<CompatiblePluginEventType.BeforeKeyboardEditing> {
5230
+ }
5231
+
5167
5232
  /**
5168
5233
  * This refers to a "content block" in editor that serves as a content parsing boundary
5169
5234
  * It is most those html block like tags, i.e. &lt;p&gt;, &lt;div&gt;, &lt;li&gt;, &lt;td&gt; etc.
@@ -5679,7 +5744,7 @@ export interface InsertOptionBase {
5679
5744
  * The "basic" insertNode related ContentPositions that require no additional parameters to use.
5680
5745
  */
5681
5746
  export interface InsertOptionBasic extends InsertOptionBase {
5682
- position: ContentPosition.Begin | ContentPosition.End | ContentPosition.DomEnd | ContentPosition.Outside | ContentPosition.SelectionStart;
5747
+ position: ContentPosition.Begin | ContentPosition.End | ContentPosition.DomEnd | ContentPosition.Outside | ContentPosition.SelectionStart | CompatibleContentPosition.Begin | CompatibleContentPosition.End | CompatibleContentPosition.DomEnd | CompatibleContentPosition.Outside | CompatibleContentPosition.SelectionStart;
5683
5748
  }
5684
5749
 
5685
5750
  /**
@@ -6636,7 +6701,7 @@ export interface IEditor {
6636
6701
  * If it is not cached before, query from DOM and cache the result into the event object
6637
6702
  * @returns A content traverser, or null if editor never got focus before
6638
6703
  */
6639
- getContentSearcherOfCursor(event?: PluginEvent): IPositionContentSearcher | null;
6704
+ getContentSearcherOfCursor(event?: PluginEvent | null): IPositionContentSearcher | null;
6640
6705
  /**
6641
6706
  * Run a callback function asynchronously
6642
6707
  * @param callback The callback function to run
@@ -6706,9 +6771,9 @@ export interface IEditor {
6706
6771
  */
6707
6772
  transformToDarkColor(node: Node): void;
6708
6773
  /**
6709
- * Get a darkColorHandler object for this editor. It will return null if experimental feature "VariableBasedDarkColor" is not enabled
6774
+ * Get a darkColorHandler object for this editor.
6710
6775
  */
6711
- getDarkColorHandler(): DarkColorHandler | null;
6776
+ getDarkColorHandler(): DarkColorHandler;
6712
6777
  /**
6713
6778
  * Make the editor in "Shadow Edit" mode.
6714
6779
  * In Shadow Edit mode, all format change will finally be ignored.
@@ -7041,7 +7106,7 @@ export interface EditorCore extends PluginState {
7041
7106
  * Dark model handler for the editor, used for variable-based solution.
7042
7107
  * If keep it null, editor will still use original dataset-based dark mode solution.
7043
7108
  */
7044
- darkColorHandler?: DarkColorHandler;
7109
+ darkColorHandler: DarkColorHandler;
7045
7110
  }
7046
7111
 
7047
7112
  /**
@@ -7099,8 +7164,7 @@ export interface CoreApiMap {
7099
7164
  * @param core The EditorCore object.
7100
7165
  * @param position The position that user is about to type to
7101
7166
  * @param keyboardEvent Optional keyboard event object
7102
- * @param applyFormatToSpan Optional When set to true, default format (if any) will be applied to
7103
- * a SPAN element inside the block element instead of the block element itself.
7167
+ * @param deprecated Deprecated parameter, not used
7104
7168
  */
7105
7169
  ensureTypeInContainer: EnsureTypeInContainer;
7106
7170
  /**
@@ -7248,10 +7312,9 @@ export type CreatePasteFragment = (core: EditorCore, clipboardData: ClipboardDat
7248
7312
  * @param core The EditorCore object.
7249
7313
  * @param position The position that user is about to type to
7250
7314
  * @param keyboardEvent Optional keyboard event object
7251
- * @param applyFormatToSpan Optional When set to true, default format (if any) will be applied to
7252
- * a SPAN element inside the block element instead of the block element itself.
7315
+ * @param deprecated Deprecated parameter, not used
7253
7316
  */
7254
- export type EnsureTypeInContainer = (core: EditorCore, position: NodePosition, keyboardEvent?: KeyboardEvent, applyFormatToSpan?: boolean) => void;
7317
+ export type EnsureTypeInContainer = (core: EditorCore, position: NodePosition, keyboardEvent?: KeyboardEvent, deprecated?: boolean) => void;
7255
7318
 
7256
7319
  /**
7257
7320
  * Focus to editor. If there is a cached selection range, use it as current selection
@@ -8417,13 +8480,29 @@ export enum CompatibleExperimentalFeatures {
8417
8480
  */
8418
8481
  ImageSelection = "ImageSelection",
8419
8482
  /**
8420
- * Provide additional Tab Key Features. Requires Text Features Content Editable Features
8483
+ * @deprecated this feature is always enabled
8484
+ * Use variable-based dark mode solution rather than dataset-based solution.
8485
+ * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
8486
+ * if you need them work for dark mode
8421
8487
  */
8422
- TabKeyTextFeatures = "TabKeyTextFeatures",
8488
+ VariableBasedDarkColor = "VariableBasedDarkColor",
8423
8489
  /**
8490
+ * @deprecated this feature is always enabled
8424
8491
  * Align list elements elements to left, center and right using setAlignment API
8425
8492
  */
8426
8493
  ListItemAlignment = "ListItemAlignment",
8494
+ /**
8495
+ * @deprecated
8496
+ */
8497
+ DefaultFormatInSpan = "DefaultFormatInSpan",
8498
+ /**
8499
+ * @deprecated
8500
+ */
8501
+ DefaultFormatOnContainer = "DefaultFormatOnContainer",
8502
+ /**
8503
+ * Provide additional Tab Key Features. Requires Text Features Content Editable Features
8504
+ */
8505
+ TabKeyTextFeatures = "TabKeyTextFeatures",
8427
8506
  /**
8428
8507
  * Trigger formatting by a especial characters. Ex: (A), 1. i).
8429
8508
  */
@@ -8435,25 +8514,14 @@ export enum CompatibleExperimentalFeatures {
8435
8514
  * is the one closest to the item.
8436
8515
  */
8437
8516
  ReuseAllAncestorListElements = "ReuseAllAncestorListElements",
8438
- /**
8439
- * When apply default format when initialize or user type, apply the format on a SPAN element rather than
8440
- * the block element (In most case, the DIV element) so keep the block element clean.
8441
- */
8442
- DefaultFormatInSpan = "DefaultFormatInSpan",
8443
- /**
8444
- * Use variable-based dark mode solution rather than dataset-based solution.
8445
- * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
8446
- * if you need them work for dark mode
8447
- */
8448
- VariableBasedDarkColor = "VariableBasedDarkColor",
8449
8517
  /**
8450
8518
  * Reuse existing DOM structure if possible when convert Content Model back to DOM tree
8451
8519
  */
8452
8520
  ReusableContentModel = "ReusableContentModel",
8453
8521
  /**
8454
- * Apply default format on editor container
8522
+ * Handle keyboard editing event with Content Model
8455
8523
  */
8456
- DefaultFormatOnContainer = "DefaultFormatOnContainer",
8524
+ EditWithContentModel = "EditWithContentModel",
8457
8525
  /**
8458
8526
  * Delete table with Backspace key with the whole was selected with table selector
8459
8527
  */
@@ -8568,7 +8636,35 @@ export enum CompatiblePluginEventType {
8568
8636
  * EXPERIMENTAL FEATURE
8569
8637
  * Editor changed the selection.
8570
8638
  */
8571
- SelectionChanged = 22
8639
+ SelectionChanged = 22,
8640
+ /**
8641
+ * EXPERIMENTAL FEATURE
8642
+ * Editor content is about to be changed by keyboard event.
8643
+ * This is only used by Content Model editing
8644
+ */
8645
+ BeforeKeyboardEditing = 23
8646
+ }
8647
+
8648
+ /**
8649
+ * Enum for paste options
8650
+ */
8651
+ export enum CompatiblePasteType {
8652
+ /**
8653
+ * Default paste behavior
8654
+ */
8655
+ Normal = 0,
8656
+ /**
8657
+ * Paste only the plain text
8658
+ */
8659
+ AsPlainText = 1,
8660
+ /**
8661
+ * Apply the current style to pasted content
8662
+ */
8663
+ MergeFormat = 2,
8664
+ /**
8665
+ * If there is a image uri in the clipboard, paste the content as image element
8666
+ */
8667
+ AsImage = 3
8572
8668
  }
8573
8669
 
8574
8670
  /**
@@ -9101,6 +9197,7 @@ export enum CompatibleContentType {
9101
9197
  }
9102
9198
 
9103
9199
  /**
9200
+ * @deprecated
9104
9201
  * Constants string for dataset names used by dark mode
9105
9202
  */
9106
9203
  export enum CompatibleDarkModeDatasetNames {
@@ -9554,7 +9651,7 @@ export enum CompatibleKnownCreateElementDataIndex {
9554
9651
  */
9555
9652
  TableSelector = 11,
9556
9653
  /**
9557
- * An empty line without format with span inside of it.
9654
+ * @deprecated
9558
9655
  */
9559
9656
  EmptyLineFormatInSpan = 12
9560
9657
  }