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.
package/dist/rooster.d.ts CHANGED
@@ -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
 
@@ -724,7 +724,8 @@ function getInnerHTML(node: HTMLElement | DocumentFragment): string;
724
724
  * @param isBackgroundColor Whether set background color or text color
725
725
  * @param isDarkMode Whether current mode is dark mode. @default false
726
726
  * @param shouldAdaptTheFontColor Whether the font color needs to be adapted to be visible in a dark or bright background color. @default false
727
- * @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
727
+ * @param darkColorHandler A dark color handler object. This is now required.
728
+ * We keep it optional only for backward compatibility. If it is not passed, color will not be set.
728
729
  */
729
730
  function setColor(element: HTMLElement, color: string | ModeIndependentColor, isBackgroundColor: boolean, isDarkMode?: boolean, shouldAdaptTheFontColor?: boolean, darkColorHandler?: DarkColorHandler | null): void;
730
731
 
@@ -2303,9 +2304,9 @@ class EditorBase<TEditorCore extends EditorCore, TEditorOptions extends EditorOp
2303
2304
  */
2304
2305
  transformToDarkColor(node: Node): void;
2305
2306
  /**
2306
- * 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.
2307
2308
  */
2308
- getDarkColorHandler(): DarkColorHandler | null;
2309
+ getDarkColorHandler(): DarkColorHandler;
2309
2310
  /**
2310
2311
  * Make the editor in "Shadow Edit" mode.
2311
2312
  * In Shadow Edit mode, all format change will finally be ignored.
@@ -2456,8 +2457,11 @@ function getElementBasedFormatState(editor: IEditor, event?: PluginEvent): Eleme
2456
2457
  * If isBlock is true, entity will be insert below this position
2457
2458
  * @param insertToRegionRoot @optional When pass true, insert the entity at the root level of current region.
2458
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
2459
2463
  */
2460
- function insertEntity(editor: IEditor, type: string, contentNode: Node, isBlock: boolean, isReadonly: boolean, position?: NodePosition | ContentPosition.Begin | ContentPosition.End | ContentPosition.DomEnd, insertToRegionRoot?: boolean): Entity;
2464
+ 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;
2461
2465
 
2462
2466
  /**
2463
2467
  * Insert an image to editor at current selection
@@ -3540,6 +3544,7 @@ const enum ContentPosition {
3540
3544
  }
3541
3545
 
3542
3546
  /**
3547
+ * @deprecated
3543
3548
  * Constants string for dataset names used by dark mode
3544
3549
  */
3545
3550
  const enum DarkModeDatasetNames {
@@ -3758,13 +3763,21 @@ const enum ExperimentalFeatures {
3758
3763
  */
3759
3764
  ImageSelection = "ImageSelection",
3760
3765
  /**
3761
- * 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
3762
3770
  */
3763
- TabKeyTextFeatures = "TabKeyTextFeatures",
3771
+ VariableBasedDarkColor = "VariableBasedDarkColor",
3764
3772
  /**
3773
+ * @deprecated this feature is always enabled
3765
3774
  * Align list elements elements to left, center and right using setAlignment API
3766
3775
  */
3767
3776
  ListItemAlignment = "ListItemAlignment",
3777
+ /**
3778
+ * Provide additional Tab Key Features. Requires Text Features Content Editable Features
3779
+ */
3780
+ TabKeyTextFeatures = "TabKeyTextFeatures",
3768
3781
  /**
3769
3782
  * Trigger formatting by a especial characters. Ex: (A), 1. i).
3770
3783
  */
@@ -3781,16 +3794,14 @@ const enum ExperimentalFeatures {
3781
3794
  * the block element (In most case, the DIV element) so keep the block element clean.
3782
3795
  */
3783
3796
  DefaultFormatInSpan = "DefaultFormatInSpan",
3784
- /**
3785
- * Use variable-based dark mode solution rather than dataset-based solution.
3786
- * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
3787
- * if you need them work for dark mode
3788
- */
3789
- VariableBasedDarkColor = "VariableBasedDarkColor",
3790
3797
  /**
3791
3798
  * Reuse existing DOM structure if possible when convert Content Model back to DOM tree
3792
3799
  */
3793
3800
  ReusableContentModel = "ReusableContentModel",
3801
+ /**
3802
+ * Handle keyboard editing event with Content Model
3803
+ */
3804
+ EditWithContentModel = "EditWithContentModel",
3794
3805
  /**
3795
3806
  * Apply default format on editor container
3796
3807
  */
@@ -4368,7 +4379,13 @@ const enum PluginEventType {
4368
4379
  * EXPERIMENTAL FEATURE
4369
4380
  * Editor changed the selection.
4370
4381
  */
4371
- SelectionChanged = 22
4382
+ SelectionChanged = 22,
4383
+ /**
4384
+ * EXPERIMENTAL FEATURE
4385
+ * Editor content is about to be changed by keyboard event.
4386
+ * This is only used by Content Model editing
4387
+ */
4388
+ BeforeKeyboardEditing = 23
4372
4389
  }
4373
4390
 
4374
4391
  /**
@@ -4563,6 +4580,28 @@ const enum DefinitionType {
4563
4580
  Customize = 5
4564
4581
  }
4565
4582
 
4583
+ /**
4584
+ * Enum for paste options
4585
+ */
4586
+ const enum PasteType {
4587
+ /**
4588
+ * Default paste behavior
4589
+ */
4590
+ Normal = 0,
4591
+ /**
4592
+ * Paste only the plain text
4593
+ */
4594
+ AsPlainText = 1,
4595
+ /**
4596
+ * Apply the current style to pasted content
4597
+ */
4598
+ MergeFormat = 2,
4599
+ /**
4600
+ * If there is a image uri in the clipboard, paste the content as image element
4601
+ */
4602
+ AsImage = 3
4603
+ }
4604
+
4566
4605
  /**
4567
4606
  * Provides a chance for plugin to change the content before it is copied from editor.
4568
4607
  */
@@ -4661,6 +4700,10 @@ interface BeforePasteEventData {
4661
4700
  * Attributes of the root "HTML" tag
4662
4701
  */
4663
4702
  htmlAttributes: Record<string, string>;
4703
+ /**
4704
+ * Paste type option (as plain text, merge format, normal, as image)
4705
+ */
4706
+ readonly pasteType: PasteType | CompatiblePasteType;
4664
4707
  }
4665
4708
 
4666
4709
  /**
@@ -5051,7 +5094,7 @@ interface PluginContextMenuEventData {
5051
5094
  /**
5052
5095
  * Editor plugin event interface
5053
5096
  */
5054
- 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;
5097
+ 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;
5055
5098
 
5056
5099
  /**
5057
5100
  * A type to extract data part of a plugin event type. Data part is the plugin event without eventType field.
@@ -5163,6 +5206,28 @@ interface SelectionChangedEventData {
5163
5206
  * Represents an event that will be fired when the user changed the selection
5164
5207
  */
5165
5208
  interface CompatibleSelectionChangedEvent extends SelectionChangedEventData, BasePluginEvent<CompatiblePluginEventType.SelectionChanged> {
5209
+ }
5210
+
5211
+ /**
5212
+ * Provides a chance for plugin to change the content before it is copied from editor.
5213
+ */
5214
+ interface BeforeKeyboardEditingEvent extends BeforeKeyboardEditingData, BasePluginEvent<PluginEventType.BeforeKeyboardEditing> {
5215
+ }
5216
+
5217
+ /**
5218
+ * Data of BeforeKeyboardEditing
5219
+ */
5220
+ interface BeforeKeyboardEditingData {
5221
+ /**
5222
+ * Raw DOM event
5223
+ */
5224
+ rawEvent: KeyboardEvent;
5225
+ }
5226
+
5227
+ /**
5228
+ * Provides a chance for plugin to change the content before it is copied from editor.
5229
+ */
5230
+ interface CompatibleBeforeKeyboardEditingEvent extends BeforeKeyboardEditingData, BasePluginEvent<CompatiblePluginEventType.BeforeKeyboardEditing> {
5166
5231
  }
5167
5232
 
5168
5233
  /**
@@ -5680,7 +5745,7 @@ interface InsertOptionBase {
5680
5745
  * The "basic" insertNode related ContentPositions that require no additional parameters to use.
5681
5746
  */
5682
5747
  interface InsertOptionBasic extends InsertOptionBase {
5683
- position: ContentPosition.Begin | ContentPosition.End | ContentPosition.DomEnd | ContentPosition.Outside | ContentPosition.SelectionStart;
5748
+ position: ContentPosition.Begin | ContentPosition.End | ContentPosition.DomEnd | ContentPosition.Outside | ContentPosition.SelectionStart | CompatibleContentPosition.Begin | CompatibleContentPosition.End | CompatibleContentPosition.DomEnd | CompatibleContentPosition.Outside | CompatibleContentPosition.SelectionStart;
5684
5749
  }
5685
5750
 
5686
5751
  /**
@@ -6707,9 +6772,9 @@ interface IEditor {
6707
6772
  */
6708
6773
  transformToDarkColor(node: Node): void;
6709
6774
  /**
6710
- * Get a darkColorHandler object for this editor. It will return null if experimental feature "VariableBasedDarkColor" is not enabled
6775
+ * Get a darkColorHandler object for this editor.
6711
6776
  */
6712
- getDarkColorHandler(): DarkColorHandler | null;
6777
+ getDarkColorHandler(): DarkColorHandler;
6713
6778
  /**
6714
6779
  * Make the editor in "Shadow Edit" mode.
6715
6780
  * In Shadow Edit mode, all format change will finally be ignored.
@@ -7042,7 +7107,7 @@ interface EditorCore extends PluginState {
7042
7107
  * Dark model handler for the editor, used for variable-based solution.
7043
7108
  * If keep it null, editor will still use original dataset-based dark mode solution.
7044
7109
  */
7045
- darkColorHandler?: DarkColorHandler;
7110
+ darkColorHandler: DarkColorHandler;
7046
7111
  }
7047
7112
 
7048
7113
  /**
@@ -8418,13 +8483,21 @@ enum CompatibleExperimentalFeatures {
8418
8483
  */
8419
8484
  ImageSelection = "ImageSelection",
8420
8485
  /**
8421
- * Provide additional Tab Key Features. Requires Text Features Content Editable Features
8486
+ * @deprecated this feature is always enabled
8487
+ * Use variable-based dark mode solution rather than dataset-based solution.
8488
+ * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
8489
+ * if you need them work for dark mode
8422
8490
  */
8423
- TabKeyTextFeatures = "TabKeyTextFeatures",
8491
+ VariableBasedDarkColor = "VariableBasedDarkColor",
8424
8492
  /**
8493
+ * @deprecated this feature is always enabled
8425
8494
  * Align list elements elements to left, center and right using setAlignment API
8426
8495
  */
8427
8496
  ListItemAlignment = "ListItemAlignment",
8497
+ /**
8498
+ * Provide additional Tab Key Features. Requires Text Features Content Editable Features
8499
+ */
8500
+ TabKeyTextFeatures = "TabKeyTextFeatures",
8428
8501
  /**
8429
8502
  * Trigger formatting by a especial characters. Ex: (A), 1. i).
8430
8503
  */
@@ -8441,16 +8514,14 @@ enum CompatibleExperimentalFeatures {
8441
8514
  * the block element (In most case, the DIV element) so keep the block element clean.
8442
8515
  */
8443
8516
  DefaultFormatInSpan = "DefaultFormatInSpan",
8444
- /**
8445
- * Use variable-based dark mode solution rather than dataset-based solution.
8446
- * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
8447
- * if you need them work for dark mode
8448
- */
8449
- VariableBasedDarkColor = "VariableBasedDarkColor",
8450
8517
  /**
8451
8518
  * Reuse existing DOM structure if possible when convert Content Model back to DOM tree
8452
8519
  */
8453
8520
  ReusableContentModel = "ReusableContentModel",
8521
+ /**
8522
+ * Handle keyboard editing event with Content Model
8523
+ */
8524
+ EditWithContentModel = "EditWithContentModel",
8454
8525
  /**
8455
8526
  * Apply default format on editor container
8456
8527
  */
@@ -8569,7 +8640,35 @@ enum CompatiblePluginEventType {
8569
8640
  * EXPERIMENTAL FEATURE
8570
8641
  * Editor changed the selection.
8571
8642
  */
8572
- SelectionChanged = 22
8643
+ SelectionChanged = 22,
8644
+ /**
8645
+ * EXPERIMENTAL FEATURE
8646
+ * Editor content is about to be changed by keyboard event.
8647
+ * This is only used by Content Model editing
8648
+ */
8649
+ BeforeKeyboardEditing = 23
8650
+ }
8651
+
8652
+ /**
8653
+ * Enum for paste options
8654
+ */
8655
+ enum CompatiblePasteType {
8656
+ /**
8657
+ * Default paste behavior
8658
+ */
8659
+ Normal = 0,
8660
+ /**
8661
+ * Paste only the plain text
8662
+ */
8663
+ AsPlainText = 1,
8664
+ /**
8665
+ * Apply the current style to pasted content
8666
+ */
8667
+ MergeFormat = 2,
8668
+ /**
8669
+ * If there is a image uri in the clipboard, paste the content as image element
8670
+ */
8671
+ AsImage = 3
8573
8672
  }
8574
8673
 
8575
8674
  /**
@@ -9102,6 +9201,7 @@ enum CompatibleContentType {
9102
9201
  }
9103
9202
 
9104
9203
  /**
9204
+ * @deprecated
9105
9205
  * Constants string for dataset names used by dark mode
9106
9206
  */
9107
9207
  enum CompatibleDarkModeDatasetNames {