roosterjs 8.24.0 → 8.26.1

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.24.0)
1
+ // Type definitions for roosterjs (Version 8.26.1)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -338,6 +338,7 @@ function applyTextStyle(container: Node, styler: (node: HTMLElement, isInnerNode
338
338
  * @param event The paste event
339
339
  * @param callback Callback function when data is ready
340
340
  * @param options Options to retrieve more items from the event, including HTML string and other customized items
341
+ * @param rangeBeforePaste Optional range to be removed when pasting in Android
341
342
  * @returns An object with the following properties:
342
343
  * types: Available types from the clipboard event
343
344
  * text: Plain text from the clipboard event
@@ -346,7 +347,7 @@ function applyTextStyle(container: Node, styler: (node: HTMLElement, isInnerNode
346
347
  * When set to undefined, it means can't retrieve HTML string, there may be HTML string but direct retrieving is
347
348
  * not supported by browser.
348
349
  */
349
- function extractClipboardEvent(event: ClipboardEvent, callback: (clipboardData: ClipboardData) => void, options?: ExtractClipboardEventOption): void;
350
+ function extractClipboardEvent(event: ClipboardEvent, callback: (clipboardData: ClipboardData) => void, options?: ExtractClipboardEventOption, rangeBeforePaste?: Range): void;
350
351
 
351
352
  /**
352
353
  * Extract clipboard items to be a ClipboardData object for IE
@@ -376,13 +377,6 @@ function extractClipboardItems(items: DataTransferItem[], options?: ExtractClipb
376
377
  */
377
378
  function extractClipboardItemsForIE(dataTransfer: DataTransfer, callback: (data: ClipboardData) => void, options?: ExtractClipboardItemsForIEOptions): void;
378
379
 
379
- /**
380
- * A type-safe wrapper for Array.prototype.push.apply()
381
- * @param mainArray The main array to push items into
382
- * @param itemsArray The items to push to main array
383
- */
384
- function arrayPush<T>(mainArray: T[], itemsArray: T[]): void;
385
-
386
380
  /**
387
381
  * Browser object contains browser and operating system information of current environment
388
382
  */
@@ -529,7 +523,7 @@ function isBlockElement(node: Node): node is HTMLElement;
529
523
  * Default value is false
530
524
  * @returns True if there isn't any visible element inside node, otherwise false
531
525
  */
532
- function isNodeEmpty(node: Node, trimContent?: boolean): boolean;
526
+ function isNodeEmpty(node: Node, trimContent?: boolean, shouldCountBrAsVisible?: boolean): boolean;
533
527
 
534
528
  /**
535
529
  * Check if the given node is html void element. Void element cannot have children
@@ -662,38 +656,6 @@ function splitTextNode(textNode: Text, offset: number, returnFirstPart: boolean)
662
656
  */
663
657
  function normalizeRect(clientRect: DOMRect): Rect | null;
664
658
 
665
- /**
666
- * Convert a named node map to an array
667
- * @param collection The map to convert
668
- */
669
- function toArray(collection: NamedNodeMap): Attr[];
670
-
671
- /**
672
- * Convert a named node map to an array
673
- * @param collection The map to convert
674
- */
675
- function toArray(collection: DataTransferItemList): DataTransferItem[];
676
-
677
- /**
678
- * Convert a collection to an array
679
- * @param collection The collection to convert
680
- */
681
- function toArray<T extends Node>(collection: NodeListOf<T>): T[];
682
-
683
- /**
684
- * Convert a collection to an array
685
- * @param collection The collection to convert
686
- */
687
- function toArray<T extends Element>(collection: HTMLCollectionOf<T>): T[];
688
-
689
- /**
690
- * Convert an array to an array.
691
- * This is to satisfy typescript compiler. For some cases the object can be a collection at runtime,
692
- * but the declaration is an array. e.g. ClipboardData.types
693
- * @param array The array to convert
694
- */
695
- function toArray<T>(array: readonly T[]): T[];
696
-
697
659
  /**
698
660
  * Check if the given object is instance of the target type
699
661
  * @param obj Object to check
@@ -990,9 +952,10 @@ class VList {
990
952
  /**
991
953
  * Change list style of the given range of this list.
992
954
  * If some of the items are not real list item yet, this will make them to be list item with given style
993
- * @param targetStyle Target list style
955
+ * @param orderedStyle The style of ordered list
956
+ * @param unorderedStyle The style of unordered list
994
957
  */
995
- setListStyleType(targetStyle: NumberingListType | BulletListType | CompatibleBulletListType | CompatibleNumberingListType): void;
958
+ setListStyleType(orderedStyle?: NumberingListType | CompatibleNumberingListType, unorderedStyle?: BulletListType | CompatibleBulletListType): void;
996
959
  /**
997
960
  * Append a new item to this VList
998
961
  * @param node node of the item to append. If it is not wrapped with LI tag, it will be wrapped
@@ -1793,6 +1756,52 @@ function setMetadata<T>(element: HTMLElement, metadata: T, def?: Definition<T>):
1793
1756
  */
1794
1757
  function removeMetadata(element: HTMLElement): void;
1795
1758
 
1759
+ /**
1760
+ * A type-safe wrapper for Array.prototype.push.apply()
1761
+ * @param mainArray The main array to push items into
1762
+ * @param itemsArray The items to push to main array
1763
+ */
1764
+ function arrayPush<T>(mainArray: T[], itemsArray: T[]): void;
1765
+
1766
+ /**
1767
+ * Provide a strong-typed version of Object.keys()
1768
+ * @param obj The source object
1769
+ * @returns Array of keys
1770
+ */
1771
+ function getObjectKeys<T extends string | number | symbol>(obj: Record<T, any> | Partial<Record<T, any>>): T[];
1772
+
1773
+ /**
1774
+ * Convert a named node map to an array
1775
+ * @param collection The map to convert
1776
+ */
1777
+ function toArray(collection: NamedNodeMap): Attr[];
1778
+
1779
+ /**
1780
+ * Convert a named node map to an array
1781
+ * @param collection The map to convert
1782
+ */
1783
+ function toArray(collection: DataTransferItemList): DataTransferItem[];
1784
+
1785
+ /**
1786
+ * Convert a collection to an array
1787
+ * @param collection The collection to convert
1788
+ */
1789
+ function toArray<T extends Node>(collection: NodeListOf<T>): T[];
1790
+
1791
+ /**
1792
+ * Convert a collection to an array
1793
+ * @param collection The collection to convert
1794
+ */
1795
+ function toArray<T extends Element>(collection: HTMLCollectionOf<T>): T[];
1796
+
1797
+ /**
1798
+ * Convert an array to an array.
1799
+ * This is to satisfy typescript compiler. For some cases the object can be a collection at runtime,
1800
+ * but the declaration is an array. e.g. ClipboardData.types
1801
+ * @param array The array to convert
1802
+ */
1803
+ function toArray<T>(array: readonly T[]): T[];
1804
+
1796
1805
  /**
1797
1806
  * RoosterJs core editor class
1798
1807
  */
@@ -2545,14 +2554,15 @@ function applyCellShading(editor: IEditor, color: string | ModeIndependentColor)
2545
2554
  * @param listType The list type to toggle
2546
2555
  * @param startNumber (Optional) Start number of the list
2547
2556
  * @param includeSiblingLists Sets wether the operation should include Sibling Lists, by default true
2548
- * @param listStyle (Optional) the style of an ordered or unordered list. If If not defined, the style will be set to disc or decimal.
2557
+ * @param orderedStyle (Optional) the style of an ordered. If not defined, the style will be set to decimal.
2558
+ * @param unorderedStyle (Optional) the style of an unordered list. If not defined, the style will be set to disc.
2549
2559
  */
2550
- function toggleListType(editor: IEditor, listType: ListType | CompatibleListType, startNumber?: number, includeSiblingLists?: boolean, listStyle?: BulletListType | NumberingListType | CompatibleBulletListType | CompatibleNumberingListType): void;
2560
+ function toggleListType(editor: IEditor, listType: ListType | CompatibleListType, startNumber?: number, includeSiblingLists?: boolean, orderedStyle?: NumberingListType | CompatibleNumberingListType, unorderedStyle?: BulletListType | CompatibleBulletListType): void;
2551
2561
 
2552
2562
  /**
2553
2563
  * Split selection into regions, and perform a block-wise formatting action for each region.
2554
2564
  */
2555
- function blockFormat(editor: IEditor, callback: (region: Region, start: NodePosition, end: NodePosition, chains: VListChain[]) => void, beforeRunCallback?: () => boolean): void;
2565
+ function blockFormat(editor: IEditor, callback: (region: Region, start: NodePosition, end: NodePosition, chains: VListChain[]) => void, beforeRunCallback?: () => boolean, apiName?: string): void;
2556
2566
 
2557
2567
  /**
2558
2568
  * Commit changes of all list changes when experiment features are allowed
@@ -4034,116 +4044,136 @@ const enum SelectionRangeTypes {
4034
4044
  * Enum used to control the different types of numbering list
4035
4045
  */
4036
4046
  const enum NumberingListType {
4047
+ /**
4048
+ * Minimum value of the enum
4049
+ */
4050
+ Min = 1,
4037
4051
  /**
4038
4052
  * Numbering triggered by 1.
4039
4053
  */
4040
- Decimal = 0,
4054
+ Decimal = 1,
4041
4055
  /**
4042
4056
  * Numbering triggered by 1-
4043
4057
  */
4044
- DecimalDash = 1,
4058
+ DecimalDash = 2,
4045
4059
  /**
4046
4060
  * Numbering triggered by 1)
4047
4061
  */
4048
- DecimalParenthesis = 2,
4062
+ DecimalParenthesis = 3,
4049
4063
  /**
4050
4064
  * Numbering triggered by (1)
4051
4065
  */
4052
- DecimalDoubleParenthesis = 3,
4066
+ DecimalDoubleParenthesis = 4,
4053
4067
  /**
4054
4068
  * Numbering triggered by a.
4055
4069
  */
4056
- LowerAlpha = 4,
4070
+ LowerAlpha = 5,
4057
4071
  /**
4058
4072
  * Numbering triggered by a)
4059
4073
  */
4060
- LowerAlphaParenthesis = 5,
4074
+ LowerAlphaParenthesis = 6,
4061
4075
  /**
4062
4076
  * Numbering triggered by (a)
4063
4077
  */
4064
- LowerAlphaDoubleParenthesis = 6,
4078
+ LowerAlphaDoubleParenthesis = 7,
4065
4079
  /**
4066
4080
  * Numbering triggered by a-
4067
4081
  */
4068
- LowerAlphaDash = 7,
4082
+ LowerAlphaDash = 8,
4069
4083
  /**
4070
4084
  * Numbering triggered by A.
4071
4085
  */
4072
- UpperAlpha = 8,
4086
+ UpperAlpha = 9,
4073
4087
  /**
4074
4088
  * Numbering triggered by A)
4075
4089
  */
4076
- UpperAlphaParenthesis = 9,
4090
+ UpperAlphaParenthesis = 10,
4077
4091
  /**
4078
4092
  * Numbering triggered by (A)
4079
4093
  */
4080
- UpperAlphaDoubleParenthesis = 10,
4094
+ UpperAlphaDoubleParenthesis = 11,
4081
4095
  /**
4082
4096
  * Numbering triggered by A-
4083
4097
  */
4084
- UpperAlphaDash = 11,
4098
+ UpperAlphaDash = 12,
4085
4099
  /**
4086
4100
  * Numbering triggered by i.
4087
4101
  */
4088
- LowerRoman = 12,
4102
+ LowerRoman = 13,
4089
4103
  /**
4090
4104
  * Numbering triggered by i)
4091
4105
  */
4092
- LowerRomanParenthesis = 13,
4106
+ LowerRomanParenthesis = 14,
4093
4107
  /**
4094
4108
  * Numbering triggered by (i)
4095
4109
  */
4096
- LowerRomanDoubleParenthesis = 14,
4110
+ LowerRomanDoubleParenthesis = 15,
4097
4111
  /**
4098
4112
  * Numbering triggered by i-
4099
4113
  */
4100
- LowerRomanDash = 15,
4114
+ LowerRomanDash = 16,
4101
4115
  /**
4102
4116
  * Numbering triggered by I.
4103
4117
  */
4104
- UpperRoman = 16,
4118
+ UpperRoman = 17,
4105
4119
  /**
4106
4120
  * Numbering triggered by I)
4107
4121
  */
4108
- UpperRomanParenthesis = 17,
4122
+ UpperRomanParenthesis = 18,
4109
4123
  /**
4110
4124
  * Numbering triggered by (I)
4111
4125
  */
4112
- UpperRomanDoubleParenthesis = 18,
4126
+ UpperRomanDoubleParenthesis = 19,
4113
4127
  /**
4114
4128
  * Numbering triggered by I-
4115
4129
  */
4116
- UpperRomanDash = 19
4130
+ UpperRomanDash = 20,
4131
+ /**
4132
+ * Maximum value of the enum
4133
+ */
4134
+ Max = 20
4117
4135
  }
4118
4136
 
4119
4137
  /**
4120
4138
  * Enum used to control the different types of bullet list
4121
4139
  */
4122
4140
  const enum BulletListType {
4141
+ /**
4142
+ * Minimum value of the enum
4143
+ */
4144
+ Min = 1,
4123
4145
  /**
4124
4146
  * Bullet triggered by *
4125
4147
  */
4126
- Disc = 0,
4148
+ Disc = 1,
4127
4149
  /**
4128
4150
  * Bullet triggered by -
4129
4151
  */
4130
- Dash = 1,
4152
+ Dash = 2,
4131
4153
  /**
4132
4154
  * Bullet triggered by --
4133
4155
  */
4134
- Square = 2,
4156
+ Square = 3,
4135
4157
  /**
4136
4158
  * Bullet triggered by >
4137
4159
  */
4138
- ShortArrow = 3,
4160
+ ShortArrow = 4,
4139
4161
  /**
4140
4162
  * Bullet triggered by -> or -->
4141
4163
  */
4142
- LongArrow = 4,
4164
+ LongArrow = 5,
4143
4165
  /**
4144
4166
  * Bullet triggered by =>
4145
4167
  */
4146
- UnfilledArrow = 5
4168
+ UnfilledArrow = 6,
4169
+ /**
4170
+ * Bullet triggered by —
4171
+ */
4172
+ Hyphen = 7,
4173
+ /**
4174
+ * Maximum value of the enum
4175
+ */
4176
+ Max = 7
4147
4177
  }
4148
4178
 
4149
4179
  /**
@@ -4179,7 +4209,13 @@ const enum DefinitionType {
4179
4209
  /**
4180
4210
  * Provides a chance for plugin to change the content before it is copied from editor.
4181
4211
  */
4182
- interface BeforeCutCopyEvent extends BasePluginEvent<PluginEventType.BeforeCutCopy> {
4212
+ interface BeforeCutCopyEvent extends BeforeCutCopyEventData, BasePluginEvent<PluginEventType.BeforeCutCopy> {
4213
+ }
4214
+
4215
+ /**
4216
+ * Data of BeforeCutCopyEvent
4217
+ */
4218
+ interface BeforeCutCopyEventData {
4183
4219
  /**
4184
4220
  * Raw DOM event
4185
4221
  */
@@ -4198,6 +4234,12 @@ interface BeforeCutCopyEvent extends BasePluginEvent<PluginEventType.BeforeCutCo
4198
4234
  isCut: boolean;
4199
4235
  }
4200
4236
 
4237
+ /**
4238
+ * Provides a chance for plugin to change the content before it is copied from editor.
4239
+ */
4240
+ interface CompatibleBeforeCutCopyEvent extends BeforeCutCopyEventData, BasePluginEvent<CompatiblePluginEventType.BeforeCutCopy> {
4241
+ }
4242
+
4201
4243
  /**
4202
4244
  * Editor plugin event interface
4203
4245
  */
@@ -4225,7 +4267,19 @@ interface BeforeDisposeEvent extends BasePluginEvent<PluginEventType.BeforeDispo
4225
4267
  /**
4226
4268
  * Provides a chance for plugin to change the content before it is pasted into editor.
4227
4269
  */
4228
- interface BeforePasteEvent extends BasePluginEvent<PluginEventType.BeforePaste> {
4270
+ interface CompatibleBeforeDisposeEvent extends BasePluginEvent<CompatiblePluginEventType.BeforeDispose> {
4271
+ }
4272
+
4273
+ /**
4274
+ * Provides a chance for plugin to change the content before it is pasted into editor.
4275
+ */
4276
+ interface BeforePasteEvent extends BeforePasteEventData, BasePluginEvent<PluginEventType.BeforePaste> {
4277
+ }
4278
+
4279
+ /**
4280
+ * Data of BeforePasteEvent
4281
+ */
4282
+ interface BeforePasteEventData {
4229
4283
  /**
4230
4284
  * An object contains all related data for pasting
4231
4285
  */
@@ -4252,21 +4306,46 @@ interface BeforePasteEvent extends BasePluginEvent<PluginEventType.BeforePaste>
4252
4306
  htmlAttributes: Record<string, string>;
4253
4307
  }
4254
4308
 
4309
+ /**
4310
+ * Provides a chance for plugin to change the content before it is pasted into editor.
4311
+ */
4312
+ interface CompatibleBeforePasteEvent extends BeforePasteEventData, BasePluginEvent<CompatiblePluginEventType.BeforePaste> {
4313
+ }
4314
+
4255
4315
  /**
4256
4316
  * The event to be triggered before SetContent API is called.
4257
4317
  * Handle this event to cache anything you need from editor before it is gone.
4258
4318
  */
4259
- interface BeforeSetContentEvent extends BasePluginEvent<PluginEventType.BeforeSetContent> {
4319
+ interface BeforeSetContentEvent extends BeforeSetContentEventData, BasePluginEvent<PluginEventType.BeforeSetContent> {
4320
+ }
4321
+
4322
+ /**
4323
+ * Data of BeforeSetContentEvent
4324
+ */
4325
+ interface BeforeSetContentEventData {
4260
4326
  /**
4261
4327
  * New content HTML that is about to set to editor
4262
4328
  */
4263
4329
  newContent: string;
4264
4330
  }
4265
4331
 
4332
+ /**
4333
+ * The event to be triggered before SetContent API is called.
4334
+ * Handle this event to cache anything you need from editor before it is gone.
4335
+ */
4336
+ interface CompatibleBeforeSetContentEvent extends BeforeSetContentEventData, BasePluginEvent<CompatiblePluginEventType.BeforeSetContent> {
4337
+ }
4338
+
4266
4339
  /**
4267
4340
  * Represents a change to the editor made by another plugin
4268
4341
  */
4269
- interface ContentChangedEvent extends BasePluginEvent<PluginEventType.ContentChanged> {
4342
+ interface ContentChangedEvent extends ContentChangedEventData, BasePluginEvent<PluginEventType.ContentChanged> {
4343
+ }
4344
+
4345
+ /**
4346
+ * Data of ContentChangedEvent
4347
+ */
4348
+ interface ContentChangedEventData {
4270
4349
  /**
4271
4350
  * Source of the change
4272
4351
  */
@@ -4275,13 +4354,26 @@ interface ContentChangedEvent extends BasePluginEvent<PluginEventType.ContentCha
4275
4354
  * Optional related data
4276
4355
  */
4277
4356
  data?: any;
4357
+ additionalData?: ContentChangedData;
4358
+ }
4359
+
4360
+ /**
4361
+ * Represents a change to the editor made by another plugin
4362
+ */
4363
+ interface CompatibleContentChangedEvent extends ContentChangedEventData, BasePluginEvent<CompatiblePluginEventType.ContentChanged> {
4278
4364
  }
4279
4365
 
4280
4366
  /**
4281
4367
  * Represents an event that will be fired when an inline image is edited by user, and the src
4282
4368
  * attribute of the image is about to be changed
4283
4369
  */
4284
- interface EditImageEvent extends BasePluginEvent<PluginEventType.EditImage> {
4370
+ interface EditImageEvent extends EditImageEventData, BasePluginEvent<PluginEventType.EditImage> {
4371
+ }
4372
+
4373
+ /**
4374
+ * Data of EditImageEvent
4375
+ */
4376
+ interface EditImageEventData {
4285
4377
  /**
4286
4378
  * The image element that is being changed
4287
4379
  */
@@ -4302,17 +4394,36 @@ interface EditImageEvent extends BasePluginEvent<PluginEventType.EditImage> {
4302
4394
  newSrc: string;
4303
4395
  }
4304
4396
 
4397
+ /**
4398
+ * Represents an event that will be fired when an inline image is edited by user, and the src
4399
+ * attribute of the image is about to be changed
4400
+ */
4401
+ interface CompatibleEditImageEvent extends EditImageEventData, BasePluginEvent<CompatiblePluginEventType.EditImage> {
4402
+ }
4403
+
4305
4404
  /**
4306
4405
  * Provides a chance for plugin to change the content before it is pasted into editor.
4307
4406
  */
4308
4407
  interface EditorReadyEvent extends BasePluginEvent<PluginEventType.EditorReady> {
4408
+ }
4409
+
4410
+ /**
4411
+ * Provides a chance for plugin to change the content before it is pasted into editor.
4412
+ */
4413
+ interface CompatibleEditorReadyEvent extends BasePluginEvent<CompatiblePluginEventType.EditorReady> {
4309
4414
  }
4310
4415
 
4311
4416
  /**
4312
4417
  * Provide a chance for plugins to handle entity related events.
4313
4418
  * See enum EntityOperation for more details about each operation
4314
4419
  */
4315
- interface EntityOperationEvent extends BasePluginEvent<PluginEventType.EntityOperation> {
4420
+ interface EntityOperationEvent extends EntityOperationEventData, BasePluginEvent<PluginEventType.EntityOperation> {
4421
+ }
4422
+
4423
+ /**
4424
+ * Data of EntityOperationEvent
4425
+ */
4426
+ interface EntityOperationEventData {
4316
4427
  /**
4317
4428
  * Operation to this entity
4318
4429
  */
@@ -4339,13 +4450,26 @@ interface EntityOperationEvent extends BasePluginEvent<PluginEventType.EntityOpe
4339
4450
  contentForShadowEntity?: DocumentFragment;
4340
4451
  }
4341
4452
 
4453
+ /**
4454
+ * Provide a chance for plugins to handle entity related events.
4455
+ * See enum EntityOperation for more details about each operation
4456
+ */
4457
+ interface CompatibleEntityOperationEvent extends EntityOperationEventData, BasePluginEvent<CompatiblePluginEventType.EntityOperation> {
4458
+ }
4459
+
4342
4460
  /**
4343
4461
  * Extract Content with a DOM tree event
4344
4462
  * This event is triggered when getContent() is called with triggerExtractContentEvent = true
4345
4463
  * Plugin can handle this event to remove the UI only markups to return clean HTML
4346
4464
  * by operating on a cloned DOM tree
4347
4465
  */
4348
- interface ExtractContentWithDomEvent extends BasePluginEvent<PluginEventType.ExtractContentWithDom> {
4466
+ interface ExtractContentWithDomEvent extends ExtractContentWithDomEventData, BasePluginEvent<PluginEventType.ExtractContentWithDom> {
4467
+ }
4468
+
4469
+ /**
4470
+ * Data of ExtractContentWithDomEvent
4471
+ */
4472
+ interface ExtractContentWithDomEventData {
4349
4473
  /**
4350
4474
  * Cloned root element of editor
4351
4475
  * Plugin can change this DOM tree to clean up the markups it added before
@@ -4353,6 +4477,15 @@ interface ExtractContentWithDomEvent extends BasePluginEvent<PluginEventType.Ext
4353
4477
  clonedRoot: HTMLElement;
4354
4478
  }
4355
4479
 
4480
+ /**
4481
+ * Extract Content with a DOM tree event
4482
+ * This event is triggered when getContent() is called with triggerExtractContentEvent = true
4483
+ * Plugin can handle this event to remove the UI only markups to return clean HTML
4484
+ * by operating on a cloned DOM tree
4485
+ */
4486
+ interface CompatibleExtractContentWithDomEvent extends ExtractContentWithDomEventData, BasePluginEvent<CompatiblePluginEventType.ExtractContentWithDom> {
4487
+ }
4488
+
4356
4489
  /**
4357
4490
  * An event fired when pending format state (bold, italic, underline, ... with collapsed selection) is changed
4358
4491
  */
@@ -4360,6 +4493,13 @@ interface PendingFormatStateChangedEvent extends BasePluginEvent<PluginEventType
4360
4493
  formatState: PendableFormatState;
4361
4494
  }
4362
4495
 
4496
+ /**
4497
+ * An event fired when pending format state (bold, italic, underline, ... with collapsed selection) is changed
4498
+ */
4499
+ interface CompatiblePendingFormatStateChangedEvent extends BasePluginEvent<CompatiblePluginEventType.PendingFormatStateChanged> {
4500
+ formatState: PendableFormatState;
4501
+ }
4502
+
4363
4503
  /**
4364
4504
  * This represents a PluginEvent wrapping native browser event
4365
4505
  */
@@ -4381,13 +4521,7 @@ interface PluginCompositionEvent extends PluginDomEventBase<PluginEventType.Comp
4381
4521
  /**
4382
4522
  * This interface represents a PluginEvent wrapping native ContextMenu event
4383
4523
  */
4384
- interface PluginContextMenuEvent extends PluginDomEventBase<PluginEventType.ContextMenu, MouseEvent> {
4385
- /**
4386
- * A callback array to let editor retrieve context menu item related to this event.
4387
- * Plugins can add their own getter callback to this array,
4388
- * items from each getter will be separated by a splitter item represented by null
4389
- */
4390
- items: any[];
4524
+ interface PluginContextMenuEvent extends PluginContextMenuEventData, PluginDomEventBase<PluginEventType.ContextMenu, MouseEvent> {
4391
4525
  }
4392
4526
 
4393
4527
  /**
@@ -4427,11 +4561,7 @@ interface PluginMouseDownEvent extends PluginDomEventBase<PluginEventType.MouseD
4427
4561
  /**
4428
4562
  * This interface represents a PluginEvent wrapping native MouseUp event
4429
4563
  */
4430
- interface PluginMouseUpEvent extends PluginDomEventBase<PluginEventType.MouseUp, MouseEvent> {
4431
- /**
4432
- * Whether this is a mouse click event (mouse up and down on the same position)
4433
- */
4434
- isClicking?: boolean;
4564
+ interface PluginMouseUpEvent extends PluginMouseUpEventData, PluginDomEventBase<PluginEventType.MouseUp, MouseEvent> {
4435
4565
  }
4436
4566
 
4437
4567
  /**
@@ -4443,14 +4573,114 @@ interface PluginInputEvent extends PluginDomEventBase<PluginEventType.Input, Inp
4443
4573
  /**
4444
4574
  * This interface represents a PluginEvent wrapping native scroll event
4445
4575
  */
4446
- interface PluginScrollEvent extends PluginDomEventBase<PluginEventType.Scroll, UIEvent> {
4576
+ interface PluginScrollEvent extends PluginScrollEventData, PluginDomEventBase<PluginEventType.Scroll, UIEvent> {
4577
+ }
4578
+
4579
+ /**
4580
+ * This represents a PluginEvent wrapping native browser event
4581
+ */
4582
+ type CompatiblePluginDomEvent = CompatiblePluginCompositionEvent | CompatiblePluginMouseEvent | CompatiblePluginKeyboardEvent | CompatiblePluginInputEvent | CompatiblePluginScrollEvent;
4583
+
4584
+ /**
4585
+ * This interface represents a PluginEvent wrapping native CompositionEnd event
4586
+ */
4587
+ interface CompatiblePluginCompositionEvent extends PluginDomEventBase<CompatiblePluginEventType.CompositionEnd, CompositionEvent> {
4588
+ }
4589
+
4590
+ /**
4591
+ * This interface represents a PluginEvent wrapping native ContextMenu event
4592
+ */
4593
+ interface CompatiblePluginContextMenuEvent extends PluginContextMenuEventData, PluginDomEventBase<CompatiblePluginEventType.ContextMenu, MouseEvent> {
4594
+ }
4595
+
4596
+ /**
4597
+ * The interface represents a PluginEvent wrapping native Keyboard event
4598
+ */
4599
+ type CompatiblePluginKeyboardEvent = CompatiblePluginKeyDownEvent | CompatiblePluginKeyPressEvent | CompatiblePluginKeyUpEvent;
4600
+
4601
+ /**
4602
+ * This interface represents a PluginEvent wrapping native KeyDown event
4603
+ */
4604
+ interface CompatiblePluginKeyDownEvent extends PluginDomEventBase<CompatiblePluginEventType.KeyDown, KeyboardEvent> {
4605
+ }
4606
+
4607
+ /**
4608
+ * This interface represents a PluginEvent wrapping native KeyPress event
4609
+ */
4610
+ interface CompatiblePluginKeyPressEvent extends PluginDomEventBase<CompatiblePluginEventType.KeyPress, KeyboardEvent> {
4611
+ }
4612
+
4613
+ /**
4614
+ * This interface represents a PluginEvent wrapping native KeyUp event
4615
+ */
4616
+ interface CompatiblePluginKeyUpEvent extends PluginDomEventBase<CompatiblePluginEventType.KeyUp, KeyboardEvent> {
4617
+ }
4618
+
4619
+ /**
4620
+ * This interface represents a PluginEvent wrapping native Mouse event
4621
+ */
4622
+ type CompatiblePluginMouseEvent = CompatiblePluginMouseDownEvent | CompatiblePluginMouseUpEvent | CompatiblePluginContextMenuEvent;
4623
+
4624
+ /**
4625
+ * This interface represents a PluginEvent wrapping native MouseDown event
4626
+ */
4627
+ interface CompatiblePluginMouseDownEvent extends PluginDomEventBase<CompatiblePluginEventType.MouseDown, MouseEvent> {
4628
+ }
4629
+
4630
+ /**
4631
+ * This interface represents a PluginEvent wrapping native MouseUp event
4632
+ */
4633
+ interface CompatiblePluginMouseUpEvent extends PluginMouseUpEventData, PluginDomEventBase<CompatiblePluginEventType.MouseUp, MouseEvent> {
4634
+ }
4635
+
4636
+ /**
4637
+ * This interface represents a PluginEvent wrapping native input / textinput event
4638
+ */
4639
+ interface CompatiblePluginInputEvent extends PluginDomEventBase<CompatiblePluginEventType.Input, InputEvent> {
4640
+ }
4641
+
4642
+ /**
4643
+ * This interface represents a PluginEvent wrapping native scroll event
4644
+ */
4645
+ interface CompatiblePluginScrollEvent extends PluginScrollEventData, PluginDomEventBase<CompatiblePluginEventType.Scroll, UIEvent> {
4646
+ }
4647
+
4648
+ /**
4649
+ * Data of PluginScrollEvent
4650
+ */
4651
+ interface PluginScrollEventData {
4652
+ /**
4653
+ * Current scroll container that triggers this scroll event
4654
+ */
4447
4655
  scrollContainer: HTMLElement;
4448
4656
  }
4449
4657
 
4658
+ /**
4659
+ * Data of PluginMouseUpEvent
4660
+ */
4661
+ interface PluginMouseUpEventData {
4662
+ /**
4663
+ * Whether this is a mouse click event (mouse up and down on the same position)
4664
+ */
4665
+ isClicking?: boolean;
4666
+ }
4667
+
4668
+ /**
4669
+ * Data of PluginContextMenuEvent
4670
+ */
4671
+ interface PluginContextMenuEventData {
4672
+ /**
4673
+ * A callback array to let editor retrieve context menu item related to this event.
4674
+ * Plugins can add their own getter callback to this array,
4675
+ * items from each getter will be separated by a splitter item represented by null
4676
+ */
4677
+ items: any[];
4678
+ }
4679
+
4450
4680
  /**
4451
4681
  * Editor plugin event interface
4452
4682
  */
4453
- type PluginEvent = BeforeCutCopyEvent | BeforePasteEvent | ContentChangedEvent | EntityOperationEvent | ExtractContentWithDomEvent | PluginDomEvent | EditorReadyEvent | BeforeDisposeEvent | PendingFormatStateChangedEvent | EnterShadowEditEvent | LeaveShadowEditEvent | EditImageEvent | BeforeSetContentEvent | ZoomChangedEvent;
4683
+ type PluginEvent = BeforeCutCopyEvent | BeforePasteEvent | ContentChangedEvent | EntityOperationEvent | ExtractContentWithDomEvent | PluginDomEvent | EditorReadyEvent | BeforeDisposeEvent | PendingFormatStateChangedEvent | EnterShadowEditEvent | LeaveShadowEditEvent | EditImageEvent | BeforeSetContentEvent | ZoomChangedEvent | CompatibleBeforeCutCopyEvent | CompatibleBeforeDisposeEvent | CompatibleBeforePasteEvent | CompatibleBeforeSetContentEvent | CompatibleContentChangedEvent | CompatibleEditImageEvent | CompatibleEditorReadyEvent | CompatibleEntityOperationEvent | CompatibleExtractContentWithDomEvent | CompatiblePendingFormatStateChangedEvent | CompatiblePluginDomEvent | CompatibleEnterShadowEditEvent | CompatibleLeaveShadowEditEvent | CompatibleZoomChangedEvent;
4454
4684
 
4455
4685
  /**
4456
4686
  * A type to extract data part of a plugin event type. Data part is the plugin event without eventType field.
@@ -4477,7 +4707,19 @@ type PluginEventFromTypeGeneric<E extends PluginEvent, T extends PluginEventType
4477
4707
  /**
4478
4708
  * A plugin triggered right after editor has entered Shadow Edit mode
4479
4709
  */
4480
- interface EnterShadowEditEvent extends BasePluginEvent<PluginEventType.EnteredShadowEdit> {
4710
+ interface EnterShadowEditEvent extends EnterShadowEditEventData, BasePluginEvent<PluginEventType.EnteredShadowEdit> {
4711
+ }
4712
+
4713
+ /**
4714
+ * A plugin triggered right before editor leave Shadow Edit mode
4715
+ */
4716
+ interface LeaveShadowEditEvent extends BasePluginEvent<PluginEventType.LeavingShadowEdit> {
4717
+ }
4718
+
4719
+ /**
4720
+ * Data of EnterShadowEditEvent
4721
+ */
4722
+ interface EnterShadowEditEventData {
4481
4723
  /**
4482
4724
  * The document fragment of original editor content
4483
4725
  */
@@ -4488,10 +4730,16 @@ interface EnterShadowEditEvent extends BasePluginEvent<PluginEventType.EnteredSh
4488
4730
  selectionPath: SelectionPath;
4489
4731
  }
4490
4732
 
4733
+ /**
4734
+ * A plugin triggered right after editor has entered Shadow Edit mode
4735
+ */
4736
+ interface CompatibleEnterShadowEditEvent extends EnterShadowEditEventData, BasePluginEvent<CompatiblePluginEventType.EnteredShadowEdit> {
4737
+ }
4738
+
4491
4739
  /**
4492
4740
  * A plugin triggered right before editor leave Shadow Edit mode
4493
4741
  */
4494
- interface LeaveShadowEditEvent extends BasePluginEvent<PluginEventType.LeavingShadowEdit> {
4742
+ interface CompatibleLeaveShadowEditEvent extends BasePluginEvent<CompatiblePluginEventType.LeavingShadowEdit> {
4495
4743
  }
4496
4744
 
4497
4745
  /**
@@ -4499,7 +4747,13 @@ interface LeaveShadowEditEvent extends BasePluginEvent<PluginEventType.LeavingSh
4499
4747
  * Plugins can handle this event when they need to do something for zoom changing.
4500
4748
  *
4501
4749
  */
4502
- interface ZoomChangedEvent extends BasePluginEvent<PluginEventType.ZoomChanged> {
4750
+ interface ZoomChangedEvent extends ZoomChangedEventData, BasePluginEvent<PluginEventType.ZoomChanged> {
4751
+ }
4752
+
4753
+ /**
4754
+ * Data of ZoomChangedEvent
4755
+ */
4756
+ interface ZoomChangedEventData {
4503
4757
  /**
4504
4758
  * Zoom scale value before this change
4505
4759
  */
@@ -4510,6 +4764,14 @@ interface ZoomChangedEvent extends BasePluginEvent<PluginEventType.ZoomChanged>
4510
4764
  newZoomScale: number;
4511
4765
  }
4512
4766
 
4767
+ /**
4768
+ * Represents an event object triggered from Editor.setZoomScale() API.
4769
+ * Plugins can handle this event when they need to do something for zoom changing.
4770
+ *
4771
+ */
4772
+ interface CompatibleZoomChangedEvent extends ZoomChangedEventData, BasePluginEvent<CompatiblePluginEventType.ZoomChanged> {
4773
+ }
4774
+
4513
4775
  /**
4514
4776
  * This refers to a "content block" in editor that serves as a content parsing boundary
4515
4777
  * It is most those html block like tags, i.e. &lt;p&gt;, &lt;div&gt;, &lt;li&gt;, &lt;td&gt; etc.
@@ -4622,6 +4884,16 @@ interface CustomData {
4622
4884
  disposer?: (value: any) => void;
4623
4885
  }
4624
4886
 
4887
+ /**
4888
+ * Property that is going to store additional data related to the Content Changed Event
4889
+ */
4890
+ interface ContentChangedData {
4891
+ /**
4892
+ * Optional property to store the format api name when using ChangeSource.Format
4893
+ */
4894
+ formatApiName?: string;
4895
+ }
4896
+
4625
4897
  /**
4626
4898
  * Default format settings
4627
4899
  */
@@ -5833,8 +6105,9 @@ interface IEditor {
5833
6105
  * @param changeSource The change source to use when fire ContentChangedEvent. When the value is not null,
5834
6106
  * a ContentChangedEvent will be fired with change source equal to this value
5835
6107
  * @param canUndoByBackspace True if this action can be undone when user presses Backspace key (aka Auto Complete).
6108
+ * @param additionalData Optional parameter to provide additional data related to the ContentChanged Event.
5836
6109
  */
5837
- addUndoSnapshot(callback?: (start: NodePosition, end: NodePosition) => any, changeSource?: ChangeSource | CompatibleChangeSource | string, canUndoByBackspace?: boolean): void;
6110
+ addUndoSnapshot(callback?: (start: NodePosition, end: NodePosition) => any, changeSource?: ChangeSource | CompatibleChangeSource | string, canUndoByBackspace?: boolean, additionalData?: ContentChangedData): void;
5838
6111
  /**
5839
6112
  * Whether there is an available undo/redo snapshot
5840
6113
  */
@@ -6216,8 +6489,9 @@ interface EditorCore extends PluginState {
6216
6489
  * @param callback The editing callback, accepting current selection start and end position, returns an optional object used as the data field of ContentChangedEvent.
6217
6490
  * @param changeSource The ChangeSource string of ContentChangedEvent. @default ChangeSource.Format. Set to null to avoid triggering ContentChangedEvent
6218
6491
  * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).
6492
+ * @param additionalData Optional parameter to provide additional data related to the ContentChanged Event.
6219
6493
  */
6220
- type AddUndoSnapshot = (core: EditorCore, callback: (start: NodePosition, end: NodePosition) => any, changeSource: ChangeSource | CompatibleChangeSource | string, canUndoByBackspace: boolean) => void;
6494
+ type AddUndoSnapshot = (core: EditorCore, callback: (start: NodePosition, end: NodePosition) => any, changeSource: ChangeSource | CompatibleChangeSource | string, canUndoByBackspace: boolean, additionalData?: ContentChangedData) => void;
6221
6495
 
6222
6496
  /**
6223
6497
  * Attach a DOM event to the editor content DIV
@@ -6727,6 +7001,16 @@ interface ListFeatureSettings {
6727
7001
  * When delete key is pressed before the first item, indent the correct list of numbers
6728
7002
  */
6729
7003
  maintainListChainWhenDelete: boolean;
7004
+ /**
7005
+ * When press space after *, -, --, ->, -->, >, => in an empty line, toggle bullet
7006
+ * @default true
7007
+ */
7008
+ autoBulletList: boolean;
7009
+ /**
7010
+ * When press space after an number, a letter or roman number followed by ), ., -, or between parenthesis in an empty line, toggle numbering
7011
+ * @default true
7012
+ */
7013
+ autoNumberingList: boolean;
6730
7014
  }
6731
7015
 
6732
7016
  /**
@@ -7038,7 +7322,7 @@ interface ImageEditOptions {
7038
7322
  * Color of resize/rotate border, handle and icon
7039
7323
  * @default #DB626C
7040
7324
  */
7041
- borderColor?: string;
7325
+ borderColor?: string | ModeIndependentColor;
7042
7326
  /**
7043
7327
  * Minimum resize/crop width
7044
7328
  * @default 10
@@ -7893,30 +8177,42 @@ enum CompatibleAlignment {
7893
8177
  * Enum used to control the different types of bullet list
7894
8178
  */
7895
8179
  enum CompatibleBulletListType {
8180
+ /**
8181
+ * Minimum value of the enum
8182
+ */
8183
+ Min = 1,
7896
8184
  /**
7897
8185
  * Bullet triggered by *
7898
8186
  */
7899
- Disc = 0,
8187
+ Disc = 1,
7900
8188
  /**
7901
8189
  * Bullet triggered by -
7902
8190
  */
7903
- Dash = 1,
8191
+ Dash = 2,
7904
8192
  /**
7905
8193
  * Bullet triggered by --
7906
8194
  */
7907
- Square = 2,
8195
+ Square = 3,
7908
8196
  /**
7909
8197
  * Bullet triggered by >
7910
8198
  */
7911
- ShortArrow = 3,
8199
+ ShortArrow = 4,
7912
8200
  /**
7913
8201
  * Bullet triggered by -> or -->
7914
8202
  */
7915
- LongArrow = 4,
8203
+ LongArrow = 5,
7916
8204
  /**
7917
8205
  * Bullet triggered by =>
7918
8206
  */
7919
- UnfilledArrow = 5
8207
+ UnfilledArrow = 6,
8208
+ /**
8209
+ * Bullet triggered by —
8210
+ */
8211
+ Hyphen = 7,
8212
+ /**
8213
+ * Maximum value of the enum
8214
+ */
8215
+ Max = 7
7920
8216
  }
7921
8217
 
7922
8218
  /**
@@ -8527,86 +8823,94 @@ enum CompatibleNodeType {
8527
8823
  * Enum used to control the different types of numbering list
8528
8824
  */
8529
8825
  enum CompatibleNumberingListType {
8826
+ /**
8827
+ * Minimum value of the enum
8828
+ */
8829
+ Min = 1,
8530
8830
  /**
8531
8831
  * Numbering triggered by 1.
8532
8832
  */
8533
- Decimal = 0,
8833
+ Decimal = 1,
8534
8834
  /**
8535
8835
  * Numbering triggered by 1-
8536
8836
  */
8537
- DecimalDash = 1,
8837
+ DecimalDash = 2,
8538
8838
  /**
8539
8839
  * Numbering triggered by 1)
8540
8840
  */
8541
- DecimalParenthesis = 2,
8841
+ DecimalParenthesis = 3,
8542
8842
  /**
8543
8843
  * Numbering triggered by (1)
8544
8844
  */
8545
- DecimalDoubleParenthesis = 3,
8845
+ DecimalDoubleParenthesis = 4,
8546
8846
  /**
8547
8847
  * Numbering triggered by a.
8548
8848
  */
8549
- LowerAlpha = 4,
8849
+ LowerAlpha = 5,
8550
8850
  /**
8551
8851
  * Numbering triggered by a)
8552
8852
  */
8553
- LowerAlphaParenthesis = 5,
8853
+ LowerAlphaParenthesis = 6,
8554
8854
  /**
8555
8855
  * Numbering triggered by (a)
8556
8856
  */
8557
- LowerAlphaDoubleParenthesis = 6,
8857
+ LowerAlphaDoubleParenthesis = 7,
8558
8858
  /**
8559
8859
  * Numbering triggered by a-
8560
8860
  */
8561
- LowerAlphaDash = 7,
8861
+ LowerAlphaDash = 8,
8562
8862
  /**
8563
8863
  * Numbering triggered by A.
8564
8864
  */
8565
- UpperAlpha = 8,
8865
+ UpperAlpha = 9,
8566
8866
  /**
8567
8867
  * Numbering triggered by A)
8568
8868
  */
8569
- UpperAlphaParenthesis = 9,
8869
+ UpperAlphaParenthesis = 10,
8570
8870
  /**
8571
8871
  * Numbering triggered by (A)
8572
8872
  */
8573
- UpperAlphaDoubleParenthesis = 10,
8873
+ UpperAlphaDoubleParenthesis = 11,
8574
8874
  /**
8575
8875
  * Numbering triggered by A-
8576
8876
  */
8577
- UpperAlphaDash = 11,
8877
+ UpperAlphaDash = 12,
8578
8878
  /**
8579
8879
  * Numbering triggered by i.
8580
8880
  */
8581
- LowerRoman = 12,
8881
+ LowerRoman = 13,
8582
8882
  /**
8583
8883
  * Numbering triggered by i)
8584
8884
  */
8585
- LowerRomanParenthesis = 13,
8885
+ LowerRomanParenthesis = 14,
8586
8886
  /**
8587
8887
  * Numbering triggered by (i)
8588
8888
  */
8589
- LowerRomanDoubleParenthesis = 14,
8889
+ LowerRomanDoubleParenthesis = 15,
8590
8890
  /**
8591
8891
  * Numbering triggered by i-
8592
8892
  */
8593
- LowerRomanDash = 15,
8893
+ LowerRomanDash = 16,
8594
8894
  /**
8595
8895
  * Numbering triggered by I.
8596
8896
  */
8597
- UpperRoman = 16,
8897
+ UpperRoman = 17,
8598
8898
  /**
8599
8899
  * Numbering triggered by I)
8600
8900
  */
8601
- UpperRomanParenthesis = 17,
8901
+ UpperRomanParenthesis = 18,
8602
8902
  /**
8603
8903
  * Numbering triggered by (I)
8604
8904
  */
8605
- UpperRomanDoubleParenthesis = 18,
8905
+ UpperRomanDoubleParenthesis = 19,
8606
8906
  /**
8607
8907
  * Numbering triggered by I-
8608
8908
  */
8609
- UpperRomanDash = 19
8909
+ UpperRomanDash = 20,
8910
+ /**
8911
+ * Maximum value of the enum
8912
+ */
8913
+ Max = 20
8610
8914
  }
8611
8915
 
8612
8916
  /**
@@ -9177,8 +9481,6 @@ class Paste implements EditorPlugin {
9177
9481
  * - Apply selected item in picker
9178
9482
  *
9179
9483
  * PickerPlugin doesn't provide any UI, it just wraps related DOM events and invoke callback functions.
9180
- * To show a picker UI, you need to build your own UI component. Please reference to
9181
- * https://github.com/microsoft/roosterjs/tree/master/demo/scripts/controls/samplepicker
9182
9484
  */
9183
9485
  class PickerPlugin<T extends PickerDataProvider = PickerDataProvider> implements EditorPlugin {
9184
9486
  readonly dataProvider: T;