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.
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.48.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
 
@@ -1315,8 +1316,9 @@ function getRegionsFromRange(root: HTMLElement, range: Range, type: RegionType |
1315
1316
  * @param regionBase The region to get block elements from
1316
1317
  * @param createBlockIfEmpty When set to true, a new empty block element will be created if there is not
1317
1318
  * any blocks in the region. Default value is false
1319
+ * @param deprecated Deprecated parameter, not used
1318
1320
  */
1319
- function getSelectedBlockElementsInRegion(regionBase: RegionBase, createBlockIfEmpty?: boolean, shouldApplyFormatToSpan?: boolean): BlockElement[];
1321
+ function getSelectedBlockElementsInRegion(regionBase: RegionBase, createBlockIfEmpty?: boolean, deprecated?: boolean): BlockElement[];
1320
1322
 
1321
1323
  /**
1322
1324
  * Collapse nodes within this region to their common ancestor node under this region
@@ -2303,9 +2305,9 @@ class EditorBase<TEditorCore extends EditorCore, TEditorOptions extends EditorOp
2303
2305
  */
2304
2306
  transformToDarkColor(node: Node): void;
2305
2307
  /**
2306
- * Get a darkColorHandler object for this editor. It will return null if experimental feature "VariableBasedDarkColor" is not enabled
2308
+ * Get a darkColorHandler object for this editor.
2307
2309
  */
2308
- getDarkColorHandler(): DarkColorHandler | null;
2310
+ getDarkColorHandler(): DarkColorHandler;
2309
2311
  /**
2310
2312
  * Make the editor in "Shadow Edit" mode.
2311
2313
  * In Shadow Edit mode, all format change will finally be ignored.
@@ -2456,8 +2458,11 @@ function getElementBasedFormatState(editor: IEditor, event?: PluginEvent): Eleme
2456
2458
  * If isBlock is true, entity will be insert below this position
2457
2459
  * @param insertToRegionRoot @optional When pass true, insert the entity at the root level of current region.
2458
2460
  * Parent nodes will be split if need
2461
+ * @param focusAfterEntity @optional When pass true, focus will be moved next to the entity. For inline entity,
2462
+ * focus will be after right after the entity (and the delimiter if exist). For block entity, focus will be in
2463
+ * the new empty line below the entity
2459
2464
  */
2460
- function insertEntity(editor: IEditor, type: string, contentNode: Node, isBlock: boolean, isReadonly: boolean, position?: NodePosition | ContentPosition.Begin | ContentPosition.End | ContentPosition.DomEnd, insertToRegionRoot?: boolean): Entity;
2465
+ 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
2466
 
2462
2467
  /**
2463
2468
  * Insert an image to editor at current selection
@@ -3540,6 +3545,7 @@ const enum ContentPosition {
3540
3545
  }
3541
3546
 
3542
3547
  /**
3548
+ * @deprecated
3543
3549
  * Constants string for dataset names used by dark mode
3544
3550
  */
3545
3551
  const enum DarkModeDatasetNames {
@@ -3758,13 +3764,29 @@ const enum ExperimentalFeatures {
3758
3764
  */
3759
3765
  ImageSelection = "ImageSelection",
3760
3766
  /**
3761
- * Provide additional Tab Key Features. Requires Text Features Content Editable Features
3767
+ * @deprecated this feature is always enabled
3768
+ * Use variable-based dark mode solution rather than dataset-based solution.
3769
+ * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
3770
+ * if you need them work for dark mode
3762
3771
  */
3763
- TabKeyTextFeatures = "TabKeyTextFeatures",
3772
+ VariableBasedDarkColor = "VariableBasedDarkColor",
3764
3773
  /**
3774
+ * @deprecated this feature is always enabled
3765
3775
  * Align list elements elements to left, center and right using setAlignment API
3766
3776
  */
3767
3777
  ListItemAlignment = "ListItemAlignment",
3778
+ /**
3779
+ * @deprecated
3780
+ */
3781
+ DefaultFormatInSpan = "DefaultFormatInSpan",
3782
+ /**
3783
+ * @deprecated
3784
+ */
3785
+ DefaultFormatOnContainer = "DefaultFormatOnContainer",
3786
+ /**
3787
+ * Provide additional Tab Key Features. Requires Text Features Content Editable Features
3788
+ */
3789
+ TabKeyTextFeatures = "TabKeyTextFeatures",
3768
3790
  /**
3769
3791
  * Trigger formatting by a especial characters. Ex: (A), 1. i).
3770
3792
  */
@@ -3776,25 +3798,14 @@ const enum ExperimentalFeatures {
3776
3798
  * is the one closest to the item.
3777
3799
  */
3778
3800
  ReuseAllAncestorListElements = "ReuseAllAncestorListElements",
3779
- /**
3780
- * When apply default format when initialize or user type, apply the format on a SPAN element rather than
3781
- * the block element (In most case, the DIV element) so keep the block element clean.
3782
- */
3783
- 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
3801
  /**
3791
3802
  * Reuse existing DOM structure if possible when convert Content Model back to DOM tree
3792
3803
  */
3793
3804
  ReusableContentModel = "ReusableContentModel",
3794
3805
  /**
3795
- * Apply default format on editor container
3806
+ * Handle keyboard editing event with Content Model
3796
3807
  */
3797
- DefaultFormatOnContainer = "DefaultFormatOnContainer",
3808
+ EditWithContentModel = "EditWithContentModel",
3798
3809
  /**
3799
3810
  * Delete table with Backspace key with the whole was selected with table selector
3800
3811
  */
@@ -4175,7 +4186,7 @@ const enum KnownCreateElementDataIndex {
4175
4186
  */
4176
4187
  TableSelector = 11,
4177
4188
  /**
4178
- * An empty line without format with span inside of it.
4189
+ * @deprecated
4179
4190
  */
4180
4191
  EmptyLineFormatInSpan = 12
4181
4192
  }
@@ -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
  /**
@@ -6637,7 +6702,7 @@ interface IEditor {
6637
6702
  * If it is not cached before, query from DOM and cache the result into the event object
6638
6703
  * @returns A content traverser, or null if editor never got focus before
6639
6704
  */
6640
- getContentSearcherOfCursor(event?: PluginEvent): IPositionContentSearcher | null;
6705
+ getContentSearcherOfCursor(event?: PluginEvent | null): IPositionContentSearcher | null;
6641
6706
  /**
6642
6707
  * Run a callback function asynchronously
6643
6708
  * @param callback The callback function to run
@@ -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
  /**
@@ -7100,8 +7165,7 @@ interface CoreApiMap {
7100
7165
  * @param core The EditorCore object.
7101
7166
  * @param position The position that user is about to type to
7102
7167
  * @param keyboardEvent Optional keyboard event object
7103
- * @param applyFormatToSpan Optional When set to true, default format (if any) will be applied to
7104
- * a SPAN element inside the block element instead of the block element itself.
7168
+ * @param deprecated Deprecated parameter, not used
7105
7169
  */
7106
7170
  ensureTypeInContainer: EnsureTypeInContainer;
7107
7171
  /**
@@ -7249,10 +7313,9 @@ type CreatePasteFragment = (core: EditorCore, clipboardData: ClipboardData, posi
7249
7313
  * @param core The EditorCore object.
7250
7314
  * @param position The position that user is about to type to
7251
7315
  * @param keyboardEvent Optional keyboard event object
7252
- * @param applyFormatToSpan Optional When set to true, default format (if any) will be applied to
7253
- * a SPAN element inside the block element instead of the block element itself.
7316
+ * @param deprecated Deprecated parameter, not used
7254
7317
  */
7255
- type EnsureTypeInContainer = (core: EditorCore, position: NodePosition, keyboardEvent?: KeyboardEvent, applyFormatToSpan?: boolean) => void;
7318
+ type EnsureTypeInContainer = (core: EditorCore, position: NodePosition, keyboardEvent?: KeyboardEvent, deprecated?: boolean) => void;
7256
7319
 
7257
7320
  /**
7258
7321
  * Focus to editor. If there is a cached selection range, use it as current selection
@@ -8418,13 +8481,29 @@ enum CompatibleExperimentalFeatures {
8418
8481
  */
8419
8482
  ImageSelection = "ImageSelection",
8420
8483
  /**
8421
- * Provide additional Tab Key Features. Requires Text Features Content Editable Features
8484
+ * @deprecated this feature is always enabled
8485
+ * Use variable-based dark mode solution rather than dataset-based solution.
8486
+ * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
8487
+ * if you need them work for dark mode
8422
8488
  */
8423
- TabKeyTextFeatures = "TabKeyTextFeatures",
8489
+ VariableBasedDarkColor = "VariableBasedDarkColor",
8424
8490
  /**
8491
+ * @deprecated this feature is always enabled
8425
8492
  * Align list elements elements to left, center and right using setAlignment API
8426
8493
  */
8427
8494
  ListItemAlignment = "ListItemAlignment",
8495
+ /**
8496
+ * @deprecated
8497
+ */
8498
+ DefaultFormatInSpan = "DefaultFormatInSpan",
8499
+ /**
8500
+ * @deprecated
8501
+ */
8502
+ DefaultFormatOnContainer = "DefaultFormatOnContainer",
8503
+ /**
8504
+ * Provide additional Tab Key Features. Requires Text Features Content Editable Features
8505
+ */
8506
+ TabKeyTextFeatures = "TabKeyTextFeatures",
8428
8507
  /**
8429
8508
  * Trigger formatting by a especial characters. Ex: (A), 1. i).
8430
8509
  */
@@ -8436,25 +8515,14 @@ enum CompatibleExperimentalFeatures {
8436
8515
  * is the one closest to the item.
8437
8516
  */
8438
8517
  ReuseAllAncestorListElements = "ReuseAllAncestorListElements",
8439
- /**
8440
- * When apply default format when initialize or user type, apply the format on a SPAN element rather than
8441
- * the block element (In most case, the DIV element) so keep the block element clean.
8442
- */
8443
- 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
8518
  /**
8451
8519
  * Reuse existing DOM structure if possible when convert Content Model back to DOM tree
8452
8520
  */
8453
8521
  ReusableContentModel = "ReusableContentModel",
8454
8522
  /**
8455
- * Apply default format on editor container
8523
+ * Handle keyboard editing event with Content Model
8456
8524
  */
8457
- DefaultFormatOnContainer = "DefaultFormatOnContainer",
8525
+ EditWithContentModel = "EditWithContentModel",
8458
8526
  /**
8459
8527
  * Delete table with Backspace key with the whole was selected with table selector
8460
8528
  */
@@ -8569,7 +8637,35 @@ enum CompatiblePluginEventType {
8569
8637
  * EXPERIMENTAL FEATURE
8570
8638
  * Editor changed the selection.
8571
8639
  */
8572
- SelectionChanged = 22
8640
+ SelectionChanged = 22,
8641
+ /**
8642
+ * EXPERIMENTAL FEATURE
8643
+ * Editor content is about to be changed by keyboard event.
8644
+ * This is only used by Content Model editing
8645
+ */
8646
+ BeforeKeyboardEditing = 23
8647
+ }
8648
+
8649
+ /**
8650
+ * Enum for paste options
8651
+ */
8652
+ enum CompatiblePasteType {
8653
+ /**
8654
+ * Default paste behavior
8655
+ */
8656
+ Normal = 0,
8657
+ /**
8658
+ * Paste only the plain text
8659
+ */
8660
+ AsPlainText = 1,
8661
+ /**
8662
+ * Apply the current style to pasted content
8663
+ */
8664
+ MergeFormat = 2,
8665
+ /**
8666
+ * If there is a image uri in the clipboard, paste the content as image element
8667
+ */
8668
+ AsImage = 3
8573
8669
  }
8574
8670
 
8575
8671
  /**
@@ -9102,6 +9198,7 @@ enum CompatibleContentType {
9102
9198
  }
9103
9199
 
9104
9200
  /**
9201
+ * @deprecated
9105
9202
  * Constants string for dataset names used by dark mode
9106
9203
  */
9107
9204
  enum CompatibleDarkModeDatasetNames {
@@ -9555,7 +9652,7 @@ enum CompatibleKnownCreateElementDataIndex {
9555
9652
  */
9556
9653
  TableSelector = 11,
9557
9654
  /**
9558
- * An empty line without format with span inside of it.
9655
+ * @deprecated
9559
9656
  */
9560
9657
  EmptyLineFormatInSpan = 12
9561
9658
  }