roosterjs 8.46.0 → 8.47.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.47.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
 
@@ -2302,9 +2303,9 @@ export class EditorBase<TEditorCore extends EditorCore, TEditorOptions extends E
2302
2303
  */
2303
2304
  transformToDarkColor(node: Node): void;
2304
2305
  /**
2305
- * Get a darkColorHandler object for this editor. It will return null if experimental feature "VariableBasedDarkColor" is not enabled
2306
+ * Get a darkColorHandler object for this editor.
2306
2307
  */
2307
- getDarkColorHandler(): DarkColorHandler | null;
2308
+ getDarkColorHandler(): DarkColorHandler;
2308
2309
  /**
2309
2310
  * Make the editor in "Shadow Edit" mode.
2310
2311
  * In Shadow Edit mode, all format change will finally be ignored.
@@ -2455,8 +2456,11 @@ export function getElementBasedFormatState(editor: IEditor, event?: PluginEvent)
2455
2456
  * If isBlock is true, entity will be insert below this position
2456
2457
  * @param insertToRegionRoot @optional When pass true, insert the entity at the root level of current region.
2457
2458
  * Parent nodes will be split if need
2459
+ * @param focusAfterEntity @optional When pass true, focus will be moved next to the entity. For inline entity,
2460
+ * focus will be after right after the entity (and the delimiter if exist). For block entity, focus will be in
2461
+ * the new empty line below the entity
2458
2462
  */
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;
2463
+ 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
2464
 
2461
2465
  /**
2462
2466
  * Insert an image to editor at current selection
@@ -3539,6 +3543,7 @@ export const enum ContentPosition {
3539
3543
  }
3540
3544
 
3541
3545
  /**
3546
+ * @deprecated
3542
3547
  * Constants string for dataset names used by dark mode
3543
3548
  */
3544
3549
  export const enum DarkModeDatasetNames {
@@ -3757,13 +3762,21 @@ export const enum ExperimentalFeatures {
3757
3762
  */
3758
3763
  ImageSelection = "ImageSelection",
3759
3764
  /**
3760
- * Provide additional Tab Key Features. Requires Text Features Content Editable Features
3765
+ * @deprecated this feature is always enabled
3766
+ * Use variable-based dark mode solution rather than dataset-based solution.
3767
+ * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
3768
+ * if you need them work for dark mode
3761
3769
  */
3762
- TabKeyTextFeatures = "TabKeyTextFeatures",
3770
+ VariableBasedDarkColor = "VariableBasedDarkColor",
3763
3771
  /**
3772
+ * @deprecated this feature is always enabled
3764
3773
  * Align list elements elements to left, center and right using setAlignment API
3765
3774
  */
3766
3775
  ListItemAlignment = "ListItemAlignment",
3776
+ /**
3777
+ * Provide additional Tab Key Features. Requires Text Features Content Editable Features
3778
+ */
3779
+ TabKeyTextFeatures = "TabKeyTextFeatures",
3767
3780
  /**
3768
3781
  * Trigger formatting by a especial characters. Ex: (A), 1. i).
3769
3782
  */
@@ -3780,16 +3793,14 @@ export const enum ExperimentalFeatures {
3780
3793
  * the block element (In most case, the DIV element) so keep the block element clean.
3781
3794
  */
3782
3795
  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
3796
  /**
3790
3797
  * Reuse existing DOM structure if possible when convert Content Model back to DOM tree
3791
3798
  */
3792
3799
  ReusableContentModel = "ReusableContentModel",
3800
+ /**
3801
+ * Handle keyboard editing event with Content Model
3802
+ */
3803
+ EditWithContentModel = "EditWithContentModel",
3793
3804
  /**
3794
3805
  * Apply default format on editor container
3795
3806
  */
@@ -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
  /**
@@ -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
  /**
@@ -8417,13 +8482,21 @@ export enum CompatibleExperimentalFeatures {
8417
8482
  */
8418
8483
  ImageSelection = "ImageSelection",
8419
8484
  /**
8420
- * Provide additional Tab Key Features. Requires Text Features Content Editable Features
8485
+ * @deprecated this feature is always enabled
8486
+ * Use variable-based dark mode solution rather than dataset-based solution.
8487
+ * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
8488
+ * if you need them work for dark mode
8421
8489
  */
8422
- TabKeyTextFeatures = "TabKeyTextFeatures",
8490
+ VariableBasedDarkColor = "VariableBasedDarkColor",
8423
8491
  /**
8492
+ * @deprecated this feature is always enabled
8424
8493
  * Align list elements elements to left, center and right using setAlignment API
8425
8494
  */
8426
8495
  ListItemAlignment = "ListItemAlignment",
8496
+ /**
8497
+ * Provide additional Tab Key Features. Requires Text Features Content Editable Features
8498
+ */
8499
+ TabKeyTextFeatures = "TabKeyTextFeatures",
8427
8500
  /**
8428
8501
  * Trigger formatting by a especial characters. Ex: (A), 1. i).
8429
8502
  */
@@ -8440,16 +8513,14 @@ export enum CompatibleExperimentalFeatures {
8440
8513
  * the block element (In most case, the DIV element) so keep the block element clean.
8441
8514
  */
8442
8515
  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
8516
  /**
8450
8517
  * Reuse existing DOM structure if possible when convert Content Model back to DOM tree
8451
8518
  */
8452
8519
  ReusableContentModel = "ReusableContentModel",
8520
+ /**
8521
+ * Handle keyboard editing event with Content Model
8522
+ */
8523
+ EditWithContentModel = "EditWithContentModel",
8453
8524
  /**
8454
8525
  * Apply default format on editor container
8455
8526
  */
@@ -8568,7 +8639,35 @@ export enum CompatiblePluginEventType {
8568
8639
  * EXPERIMENTAL FEATURE
8569
8640
  * Editor changed the selection.
8570
8641
  */
8571
- SelectionChanged = 22
8642
+ SelectionChanged = 22,
8643
+ /**
8644
+ * EXPERIMENTAL FEATURE
8645
+ * Editor content is about to be changed by keyboard event.
8646
+ * This is only used by Content Model editing
8647
+ */
8648
+ BeforeKeyboardEditing = 23
8649
+ }
8650
+
8651
+ /**
8652
+ * Enum for paste options
8653
+ */
8654
+ export enum CompatiblePasteType {
8655
+ /**
8656
+ * Default paste behavior
8657
+ */
8658
+ Normal = 0,
8659
+ /**
8660
+ * Paste only the plain text
8661
+ */
8662
+ AsPlainText = 1,
8663
+ /**
8664
+ * Apply the current style to pasted content
8665
+ */
8666
+ MergeFormat = 2,
8667
+ /**
8668
+ * If there is a image uri in the clipboard, paste the content as image element
8669
+ */
8670
+ AsImage = 3
8572
8671
  }
8573
8672
 
8574
8673
  /**
@@ -9101,6 +9200,7 @@ export enum CompatibleContentType {
9101
9200
  }
9102
9201
 
9103
9202
  /**
9203
+ * @deprecated
9104
9204
  * Constants string for dataset names used by dark mode
9105
9205
  */
9106
9206
  export enum CompatibleDarkModeDatasetNames {