roosterjs 8.22.1 → 8.23.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.22.1)
1
+ // Type definitions for roosterjs (Version 8.23.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -391,9 +391,10 @@ export const Browser: BrowserInfo;
391
391
  * Get current browser information from user agent string
392
392
  * @param userAgent The userAgent string of a browser
393
393
  * @param appVersion The appVersion string of a browser
394
+ * @param vendor The vendor string of a browser
394
395
  * @returns The BrowserInfo object calculated from the given userAgent and appVersion
395
396
  */
396
- export function getBrowserInfo(userAgent: string, appVersion: string): BrowserInfo;
397
+ export function getBrowserInfo(userAgent: string, appVersion: string, vendor?: string): BrowserInfo;
397
398
 
398
399
  /**
399
400
  * Apply format to an HTML element
@@ -985,6 +986,12 @@ export class VList {
985
986
  * @param targetType Target list type
986
987
  */
987
988
  changeListType(start: NodePosition, end: NodePosition, targetType: ListType | CompatibleListType): void;
989
+ /**
990
+ * Change list style of the given range of this list.
991
+ * If some of the items are not real list item yet, this will make them to be list item with given style
992
+ * @param targetStyle Target list style
993
+ */
994
+ setListStyleType(targetStyle: NumberingListType | BulletListType | CompatibleBulletListType | CompatibleNumberingListType): void;
988
995
  /**
989
996
  * Append a new item to this VList
990
997
  * @param node node of the item to append. If it is not wrapped with LI tag, it will be wrapped
@@ -1123,6 +1130,12 @@ export class VListItem {
1123
1130
  * @param isDummy Whether the item is a dummy item
1124
1131
  */
1125
1132
  setNewListStart(startNumber: number): void;
1133
+ /**
1134
+ * Apply the list style type
1135
+ * @param rootList the vList that receives the style
1136
+ * @param index the list item index
1137
+ */
1138
+ applyListStyle(rootList: HTMLOListElement | HTMLUListElement, index: number): void;
1126
1139
  /**
1127
1140
  * Write the change result back into DOM
1128
1141
  * @param listStack current stack of list elements
@@ -1697,6 +1710,88 @@ export function deleteSelectedContent(root: HTMLElement, range: Range): null;
1697
1710
  */
1698
1711
  export function getTextContent(rootNode: Node): string;
1699
1712
 
1713
+ /**
1714
+ * Validate the given object with a type definition object
1715
+ * @param input The object to validate
1716
+ * @param def The type definition object used for validation
1717
+ * @returns True if the object passed the validation, otherwise false
1718
+ */
1719
+ export function validate<T>(input: any, def: Definition<T>): input is T;
1720
+
1721
+ /**
1722
+ * Create a number definition
1723
+ * @param isOptional Whether this property is optional
1724
+ * @param value Optional value of the number
1725
+ * @param minValue Optional minimum value
1726
+ * @param maxValue Optional maximum value
1727
+ * @param allowNull Allow the property to be null
1728
+ * @returns The number definition object
1729
+ */
1730
+ export function createNumberDefinition(isOptional?: boolean, value?: number, minValue?: number, maxValue?: number, allowNull?: boolean): NumberDefinition;
1731
+
1732
+ /**
1733
+ * Create a boolean definition
1734
+ * @param isOptional Whether this property is optional
1735
+ * @param value Optional expected boolean value
1736
+ * @param allowNull Allow the property to be null
1737
+ * @returns The boolean definition object
1738
+ */
1739
+ export function createBooleanDefinition(isOptional?: boolean, value?: boolean, allowNull?: boolean): BooleanDefinition;
1740
+
1741
+ /**
1742
+ * Create a string definition
1743
+ * @param isOptional Whether this property is optional
1744
+ * @param value Optional expected string value
1745
+ * @param allowNull Allow the property to be null
1746
+ * @returns The string definition object
1747
+ */
1748
+ export function createStringDefinition(isOptional?: boolean, value?: string, allowNull?: boolean): StringDefinition;
1749
+
1750
+ /**
1751
+ * Create an array definition
1752
+ * @param itemDef Definition of each item of the related array
1753
+ * @param isOptional Whether this property is optional
1754
+ * @param allowNull Allow the property to be null
1755
+ * @returns The array definition object
1756
+ */
1757
+ export function createArrayDefinition<T>(itemDef: Definition<T>, isOptional?: boolean, minLength?: number, maxLength?: number, allowNull?: boolean): ArrayDefinition<T[]>;
1758
+
1759
+ /**
1760
+ * Create an object definition
1761
+ * @param propertyDef Definition of each property of the related object
1762
+ * @param isOptional Whether this property is optional
1763
+ * @param allowNull Allow the property to be null
1764
+ * @returns The object definition object
1765
+ */
1766
+ export function createObjectDefinition<T extends Object>(propertyDef: ObjectPropertyDefinition<T>, isOptional?: boolean, allowNull?: boolean): ObjectDefinition<T>;
1767
+
1768
+ /**
1769
+ * Get metadata object from an HTML element
1770
+ * @param element The HTML element to get metadata object from
1771
+ * @param definition The type definition of this metadata used for validate this metadata object.
1772
+ * If not specified, no validation will be performed and always return whatever we get from the element
1773
+ * @param defaultValue The default value to return if the retrieved object cannot pass the validation,
1774
+ * or there is no metadata object at all
1775
+ * @returns The strong-type metadata object if it can be validated, or null
1776
+ */
1777
+ export function getMetadata<T>(element: HTMLElement, definition?: Definition<T>, defaultValue?: T): T | null;
1778
+
1779
+ /**
1780
+ * Set metadata object into an HTML element
1781
+ * @param element The HTML element to set metadata object to
1782
+ * @param metadata The metadata object to set
1783
+ * @param def An optional type definition object used for validate this metadata object.
1784
+ * If not specified, metadata will be set without validation
1785
+ * @returns True if metadata is set, otherwise false
1786
+ */
1787
+ export function setMetadata<T>(element: HTMLElement, metadata: T, def?: Definition<T>): boolean;
1788
+
1789
+ /**
1790
+ * Remove metadata from the given element if any
1791
+ * @param element The element to remove metadata from
1792
+ */
1793
+ export function removeMetadata(element: HTMLElement): void;
1794
+
1700
1795
  /**
1701
1796
  * RoosterJs core editor class
1702
1797
  */
@@ -1872,7 +1967,7 @@ export class Editor implements IEditor {
1872
1967
  * @returns the event object which is really passed into plugins. Some plugin may modify the event object so
1873
1968
  * the result of this function provides a chance to read the modified result
1874
1969
  */
1875
- triggerPluginEvent<T extends PluginEventType>(eventType: T, data: PluginEventData<T>, broadcast?: boolean): PluginEventFromType<T>;
1970
+ triggerPluginEvent<T extends PluginEventType | CompatiblePluginEventType>(eventType: T, data: PluginEventData<T>, broadcast?: boolean): PluginEventFromType<T>;
1876
1971
  /**
1877
1972
  * Trigger a ContentChangedEvent
1878
1973
  * @param source Source of this event, by default is 'SetContent'
@@ -2143,15 +2238,17 @@ export function insertEntity(editor: IEditor, type: string, contentNode: Node, i
2143
2238
  * @param editor The editor instance
2144
2239
  * @param imageFile The image file. There are at least 3 ways to obtain the file object:
2145
2240
  * From local file, from clipboard data, from drag-and-drop
2241
+ * @param attributes Optional image element attributes
2146
2242
  */
2147
- export function insertImage(editor: IEditor, imageFile: File): void;
2243
+ export function insertImage(editor: IEditor, imageFile: File, attributes?: Record<string, string>): void;
2148
2244
 
2149
2245
  /**
2150
2246
  * Insert an image to editor at current selection
2151
2247
  * @param editor The editor instance
2152
- * @param imageFile The image link.
2248
+ * @param url The image link
2249
+ * @param attributes Optional image element attributes
2153
2250
  */
2154
- export function insertImage(editor: IEditor, url: string): void;
2251
+ export function insertImage(editor: IEditor, url: string, attributes?: Record<string, string>): void;
2155
2252
 
2156
2253
  /**
2157
2254
  * Insert table into editor at current selection
@@ -2321,8 +2418,9 @@ export function toggleBold(editor: IEditor): void;
2321
2418
  * If selection contains both bullet/numbering and normal text, the behavior is decided by corresponding
2322
2419
  * browser execCommand API
2323
2420
  * @param editor The editor instance
2421
+ * @param listStyle (Optional) the style of the bullet list. If not defined, the style will be set to disc.
2324
2422
  */
2325
- export function toggleBullet(editor: IEditor): void;
2423
+ export function toggleBullet(editor: IEditor, listStyle?: BulletListType | CompatibleBulletListType): void;
2326
2424
 
2327
2425
  /**
2328
2426
  * Toggle italic at selection
@@ -2342,8 +2440,9 @@ export function toggleItalic(editor: IEditor): void;
2342
2440
  * realization of browser execCommand API
2343
2441
  * @param editor The editor instance
2344
2442
  * @param startNumber (Optional) Start number of the list
2443
+ * @param listStyle (Optional) The style of the numbering list. If not defined, the style will be set to decimal.
2345
2444
  */
2346
- export function toggleNumbering(editor: IEditor, startNumber?: number): void;
2445
+ export function toggleNumbering(editor: IEditor, startNumber?: number, listStyle?: NumberingListType | CompatibleNumberingListType): void;
2347
2446
 
2348
2447
  /**
2349
2448
  * Resets Ordered List Numbering back to the value of the parameter startNumber
@@ -2445,8 +2544,9 @@ export function applyCellShading(editor: IEditor, color: string | ModeIndependen
2445
2544
  * @param listType The list type to toggle
2446
2545
  * @param startNumber (Optional) Start number of the list
2447
2546
  * @param includeSiblingLists Sets wether the operation should include Sibling Lists, by default true
2547
+ * @param listStyle (Optional) the style of an ordered or unordered list. If If not defined, the style will be set to disc or decimal.
2448
2548
  */
2449
- export function toggleListType(editor: IEditor, listType: ListType | CompatibleListType, startNumber?: number, includeSiblingLists?: boolean): void;
2549
+ export function toggleListType(editor: IEditor, listType: ListType | CompatibleListType, startNumber?: number, includeSiblingLists?: boolean, listStyle?: BulletListType | NumberingListType | CompatibleBulletListType | CompatibleNumberingListType): void;
2450
2550
 
2451
2551
  /**
2452
2552
  * Split selection into regions, and perform a block-wise formatting action for each region.
@@ -2514,6 +2614,10 @@ export interface BrowserInfo {
2514
2614
  * Whether current OS is Android
2515
2615
  */
2516
2616
  readonly isAndroid?: boolean;
2617
+ /**
2618
+ * Whether current browser is on mobile or a tablet
2619
+ */
2620
+ readonly isMobileOrTablet?: boolean;
2517
2621
  }
2518
2622
 
2519
2623
  /**
@@ -3364,7 +3468,15 @@ export const enum ExperimentalFeatures {
3364
3468
  /**
3365
3469
  * Align list elements elements to left, center and right using setAlignment API
3366
3470
  */
3367
- ListItemAlignment = "ListItemAlignment"
3471
+ ListItemAlignment = "ListItemAlignment",
3472
+ /**
3473
+ * Trigger formatting by a especial characters. Ex: (A), 1. i).
3474
+ */
3475
+ AutoFormatList = "AutoFormatList",
3476
+ /**
3477
+ * Automatically transform -- into hyphen, if typed between two words.
3478
+ */
3479
+ AutoHyphen = "AutoHyphen"
3368
3480
  }
3369
3481
 
3370
3482
  /**
@@ -3916,6 +4028,152 @@ export const enum SelectionRangeTypes {
3916
4028
  TableSelection = 1
3917
4029
  }
3918
4030
 
4031
+ /**
4032
+ * Enum used to control the different types of numbering list
4033
+ */
4034
+ export const enum NumberingListType {
4035
+ /**
4036
+ * Numbering triggered by 1.
4037
+ */
4038
+ Decimal = 0,
4039
+ /**
4040
+ * Numbering triggered by 1-
4041
+ */
4042
+ DecimalDash = 1,
4043
+ /**
4044
+ * Numbering triggered by 1)
4045
+ */
4046
+ DecimalParenthesis = 2,
4047
+ /**
4048
+ * Numbering triggered by (1)
4049
+ */
4050
+ DecimalDoubleParenthesis = 3,
4051
+ /**
4052
+ * Numbering triggered by a.
4053
+ */
4054
+ LowerAlpha = 4,
4055
+ /**
4056
+ * Numbering triggered by a)
4057
+ */
4058
+ LowerAlphaParenthesis = 5,
4059
+ /**
4060
+ * Numbering triggered by (a)
4061
+ */
4062
+ LowerAlphaDoubleParenthesis = 6,
4063
+ /**
4064
+ * Numbering triggered by a-
4065
+ */
4066
+ LowerAlphaDash = 7,
4067
+ /**
4068
+ * Numbering triggered by A.
4069
+ */
4070
+ UpperAlpha = 8,
4071
+ /**
4072
+ * Numbering triggered by A)
4073
+ */
4074
+ UpperAlphaParenthesis = 9,
4075
+ /**
4076
+ * Numbering triggered by (A)
4077
+ */
4078
+ UpperAlphaDoubleParenthesis = 10,
4079
+ /**
4080
+ * Numbering triggered by A-
4081
+ */
4082
+ UpperAlphaDash = 11,
4083
+ /**
4084
+ * Numbering triggered by i.
4085
+ */
4086
+ LowerRoman = 12,
4087
+ /**
4088
+ * Numbering triggered by i)
4089
+ */
4090
+ LowerRomanParenthesis = 13,
4091
+ /**
4092
+ * Numbering triggered by (i)
4093
+ */
4094
+ LowerRomanDoubleParenthesis = 14,
4095
+ /**
4096
+ * Numbering triggered by i-
4097
+ */
4098
+ LowerRomanDash = 15,
4099
+ /**
4100
+ * Numbering triggered by I.
4101
+ */
4102
+ UpperRoman = 16,
4103
+ /**
4104
+ * Numbering triggered by I)
4105
+ */
4106
+ UpperRomanParenthesis = 17,
4107
+ /**
4108
+ * Numbering triggered by (I)
4109
+ */
4110
+ UpperRomanDoubleParenthesis = 18,
4111
+ /**
4112
+ * Numbering triggered by I-
4113
+ */
4114
+ UpperRomanDash = 19
4115
+ }
4116
+
4117
+ /**
4118
+ * Enum used to control the different types of bullet list
4119
+ */
4120
+ export const enum BulletListType {
4121
+ /**
4122
+ * Bullet triggered by *
4123
+ */
4124
+ Disc = 0,
4125
+ /**
4126
+ * Bullet triggered by -
4127
+ */
4128
+ Dash = 1,
4129
+ /**
4130
+ * Bullet triggered by --
4131
+ */
4132
+ Square = 2,
4133
+ /**
4134
+ * Bullet triggered by >
4135
+ */
4136
+ ShortArrow = 3,
4137
+ /**
4138
+ * Bullet triggered by -> or -->
4139
+ */
4140
+ LongArrow = 4,
4141
+ /**
4142
+ * Bullet triggered by =>
4143
+ */
4144
+ UnfilledArrow = 5
4145
+ }
4146
+
4147
+ /**
4148
+ * Types of definitions, used by Definition type
4149
+ */
4150
+ export const enum DefinitionType {
4151
+ /**
4152
+ * Boolean type definition, represents a boolean type value
4153
+ */
4154
+ Boolean = 0,
4155
+ /**
4156
+ * Number type definition, represents a number type value
4157
+ */
4158
+ Number = 1,
4159
+ /**
4160
+ * String type definition, represents a string type value
4161
+ */
4162
+ String = 2,
4163
+ /**
4164
+ * Array type definition, represents an array with a given item type
4165
+ */
4166
+ Array = 3,
4167
+ /**
4168
+ * Object type definition, represents an object with the given property types
4169
+ */
4170
+ Object = 4,
4171
+ /**
4172
+ * Customize type definition, represents a customized type with a validator function
4173
+ */
4174
+ Customize = 5
4175
+ }
4176
+
3919
4177
  /**
3920
4178
  * Provides a chance for plugin to change the content before it is copied from editor.
3921
4179
  */
@@ -3941,7 +4199,7 @@ export interface BeforeCutCopyEvent extends BasePluginEvent<PluginEventType.Befo
3941
4199
  /**
3942
4200
  * Editor plugin event interface
3943
4201
  */
3944
- export interface BasePluginEvent<T extends PluginEventType> {
4202
+ export interface BasePluginEvent<T extends PluginEventType | CompatiblePluginEventType> {
3945
4203
  /**
3946
4204
  * Type of this event
3947
4205
  */
@@ -4108,7 +4366,7 @@ export type PluginDomEvent = PluginCompositionEvent | PluginMouseEvent | PluginK
4108
4366
  /**
4109
4367
  * A base interface of all DOM events
4110
4368
  */
4111
- export interface PluginDomEventBase<TEventType extends PluginEventType, TRawEvent extends Event> extends BasePluginEvent<TEventType> {
4369
+ export interface PluginDomEventBase<TEventType extends PluginEventType | CompatiblePluginEventType, TRawEvent extends Event> extends BasePluginEvent<TEventType> {
4112
4370
  rawEvent: TRawEvent;
4113
4371
  }
4114
4372
 
@@ -4195,24 +4453,24 @@ export type PluginEvent = BeforeCutCopyEvent | BeforePasteEvent | ContentChanged
4195
4453
  /**
4196
4454
  * A type to extract data part of a plugin event type. Data part is the plugin event without eventType field.
4197
4455
  */
4198
- export type PluginEventData<T extends PluginEventType> = PluginEventDataGeneric<PluginEvent, T>;
4456
+ export type PluginEventData<T extends PluginEventType | CompatiblePluginEventType> = PluginEventDataGeneric<PluginEvent, T>;
4199
4457
 
4200
4458
  /**
4201
4459
  * A type to extract data part of a plugin event type. Data part is the plugin event without eventType field.
4202
4460
  * This type is a middle result and only used by PluginEventData type
4203
4461
  */
4204
- export type PluginEventDataGeneric<E extends PluginEvent, T extends PluginEventType> = E extends BasePluginEvent<T> ? Pick<E, Exclude<keyof E, 'eventType'>> : never;
4462
+ export type PluginEventDataGeneric<E extends PluginEvent, T extends PluginEventType | CompatiblePluginEventType> = E extends BasePluginEvent<T> ? Pick<E, Exclude<keyof E, 'eventType'>> : never;
4205
4463
 
4206
4464
  /**
4207
4465
  * A type to get specify plugin event type from eventType parameter.
4208
4466
  */
4209
- export type PluginEventFromType<T extends PluginEventType> = PluginEventFromTypeGeneric<PluginEvent, T>;
4467
+ export type PluginEventFromType<T extends PluginEventType | CompatiblePluginEventType> = PluginEventFromTypeGeneric<PluginEvent, T>;
4210
4468
 
4211
4469
  /**
4212
4470
  * A type to get specify plugin event type from eventType parameter.
4213
4471
  * This type is a middle result and only used by PluginEventFromType type
4214
4472
  */
4215
- export type PluginEventFromTypeGeneric<E extends PluginEvent, T extends PluginEventType> = E extends BasePluginEvent<T> ? E : never;
4473
+ export type PluginEventFromTypeGeneric<E extends PluginEvent, T extends PluginEventType | CompatiblePluginEventType> = E extends BasePluginEvent<T> ? E : never;
4216
4474
 
4217
4475
  /**
4218
4476
  * A plugin triggered right after editor has entered Shadow Edit mode
@@ -5549,7 +5807,7 @@ export interface IEditor {
5549
5807
  * @returns the event object which is really passed into plugins. Some plugin may modify the event object so
5550
5808
  * the result of this function provides a chance to read the modified result
5551
5809
  */
5552
- triggerPluginEvent<T extends PluginEventType>(eventType: T, data: PluginEventData<T>, broadcast?: boolean): PluginEventFromType<T>;
5810
+ triggerPluginEvent<T extends PluginEventType | CompatiblePluginEventType>(eventType: T, data: PluginEventData<T>, broadcast?: boolean): PluginEventFromType<T>;
5553
5811
  /**
5554
5812
  * Trigger a ContentChangedEvent
5555
5813
  * @param source Source of this event, by default is 'SetContent'
@@ -6573,6 +6831,11 @@ export interface TextFeatureSettings {
6573
6831
  * If Whole Paragraph selected, outdent paragraph
6574
6832
  */
6575
6833
  outdentWhenTabText: boolean;
6834
+ /**
6835
+ * Requires @see ExperimentalFeatures.AutoHyphen to be enabled
6836
+ * Automatically transform -- into hyphen, if typed between two words.
6837
+ */
6838
+ autoHyphen: boolean;
6576
6839
  }
6577
6840
 
6578
6841
  /**
@@ -6615,7 +6878,7 @@ export interface UndoSnapshotsService<T = string> {
6615
6878
  * @param step The step to move
6616
6879
  * @returns If can move with the given step, returns the snapshot after move, otherwise null
6617
6880
  */
6618
- move(step: number): T;
6881
+ move(step: number): T | null;
6619
6882
  /**
6620
6883
  * Add a new undo snapshot
6621
6884
  * @param snapshot The snapshot to add
@@ -6961,7 +7224,7 @@ export interface DOMEventHandlerObject {
6961
7224
  /**
6962
7225
  * Combined event handler type with all 3 possibilities
6963
7226
  */
6964
- export type DOMEventHandler = PluginEventType | DOMEventHandlerFunction | DOMEventHandlerObject;
7227
+ export type DOMEventHandler = PluginEventType | CompatiblePluginEventType | DOMEventHandlerFunction | DOMEventHandlerObject;
6965
7228
 
6966
7229
  /**
6967
7230
  * A handler type to convert HTML string to a trust HTML string
@@ -6977,6 +7240,120 @@ export type TrustedHTMLHandler = (html: string) => string;
6977
7240
  */
6978
7241
  export type SizeTransformer = (size: number) => number;
6979
7242
 
7243
+ /**
7244
+ * A type template to get item type of an array
7245
+ */
7246
+ export type ArrayItemType<T extends any[]> = T extends (infer U)[] ? U : never;
7247
+
7248
+ /**
7249
+ * Base interface of property definition
7250
+ */
7251
+ export interface DefinitionBase<T extends DefinitionType | CompatibleDefinitionType> {
7252
+ /**
7253
+ * Type of this property
7254
+ */
7255
+ type: T;
7256
+ /**
7257
+ * Whether this property is optional
7258
+ */
7259
+ isOptional?: boolean;
7260
+ /**
7261
+ * Whether this property is allowed to be null
7262
+ */
7263
+ allowNull?: boolean;
7264
+ }
7265
+
7266
+ /**
7267
+ * String property definition. This definition can also be used for string based enum property
7268
+ */
7269
+ export interface StringDefinition extends DefinitionBase<DefinitionType.String | CompatibleDefinitionType.String> {
7270
+ /**
7271
+ * An optional value of this property. When specified, the given property must have exactly same value of this value
7272
+ */
7273
+ value?: string;
7274
+ }
7275
+
7276
+ /**
7277
+ * Number property definition. This definition can also be used for number based enum property
7278
+ */
7279
+ export interface NumberDefinition extends DefinitionBase<DefinitionType.Number | CompatibleDefinitionType.Number> {
7280
+ /**
7281
+ * An optional value of this property. When specified, the given property must have same value of this value
7282
+ */
7283
+ value?: number;
7284
+ /**
7285
+ * An optional minimum value of this property. When specified, the given property must be greater or equal to this value
7286
+ */
7287
+ minValue?: number;
7288
+ /**
7289
+ * An optional maximum value of this property. When specified, the given property must be less or equal to this value
7290
+ */
7291
+ maxValue?: number;
7292
+ }
7293
+
7294
+ /**
7295
+ * Boolean property definition
7296
+ */
7297
+ export interface BooleanDefinition extends DefinitionBase<DefinitionType.Boolean | CompatibleDefinitionType.Boolean> {
7298
+ /**
7299
+ * An optional value of this property. When specified, the given property must have same value of this value
7300
+ */
7301
+ value?: boolean;
7302
+ }
7303
+
7304
+ /**
7305
+ * Array property definition.
7306
+ */
7307
+ export interface ArrayDefinition<T extends any[]> extends DefinitionBase<DefinitionType.Array | CompatibleDefinitionType.Array> {
7308
+ /**
7309
+ * Definition of each item of this array. All items of the given array must have the same type. Otherwise, use CustomizeDefinition instead.
7310
+ */
7311
+ itemDef: Definition<ArrayItemType<T>>;
7312
+ /**
7313
+ * An optional minimum length of this array. When specified, the given array must have at least this value of items
7314
+ */
7315
+ minLength?: number;
7316
+ /**
7317
+ * An optional maximum length of this array. When specified, the given array must have at most this value of items
7318
+ */
7319
+ maxLength?: number;
7320
+ }
7321
+
7322
+ /**
7323
+ * Object property definition.
7324
+ */
7325
+ export interface ObjectDefinition<T extends Object> extends DefinitionBase<DefinitionType.Object | CompatibleDefinitionType.Object> {
7326
+ /**
7327
+ * A key-value map to specify the definition of each possible property of this object
7328
+ */
7329
+ propertyDef: ObjectPropertyDefinition<T>;
7330
+ }
7331
+
7332
+ /**
7333
+ * Object property definition type used by Object Definition
7334
+ */
7335
+ export type ObjectPropertyDefinition<T extends Object> = {
7336
+ [Key in keyof T]: Definition<T[Key]>;
7337
+ };
7338
+
7339
+ /**
7340
+ * Customize property definition. When all other property definition type cannot satisfy your requirement,
7341
+ * use this definition with a customized validator function to do property validation.
7342
+ */
7343
+ export interface CustomizeDefinition extends DefinitionBase<DefinitionType.Customize | CompatibleDefinitionType.Customize> {
7344
+ /**
7345
+ * The customized validator function to do customized validation
7346
+ * @param input The value to validate
7347
+ * @returns True means the given value is of the specified type, otherwise false
7348
+ */
7349
+ validator: (input: any) => boolean;
7350
+ }
7351
+
7352
+ /**
7353
+ * A combination of all definition types
7354
+ */
7355
+ export type Definition<T> = CustomizeDefinition | (T extends any[] ? ArrayDefinition<T> : T extends Record<string, any> ? ObjectDefinition<T> : T extends String ? StringDefinition : T extends Number ? NumberDefinition : T extends Boolean ? BooleanDefinition : never);
7356
+
6980
7357
  /**
6981
7358
  * Experimental feature flags
6982
7359
  */
@@ -7041,7 +7418,113 @@ export enum CompatibleExperimentalFeatures {
7041
7418
  /**
7042
7419
  * Align list elements elements to left, center and right using setAlignment API
7043
7420
  */
7044
- ListItemAlignment = "ListItemAlignment"
7421
+ ListItemAlignment = "ListItemAlignment",
7422
+ /**
7423
+ * Trigger formatting by a especial characters. Ex: (A), 1. i).
7424
+ */
7425
+ AutoFormatList = "AutoFormatList",
7426
+ /**
7427
+ * Automatically transform -- into hyphen, if typed between two words.
7428
+ */
7429
+ AutoHyphen = "AutoHyphen"
7430
+ }
7431
+
7432
+ /**
7433
+ * Editor plugin event type
7434
+ */
7435
+ export enum CompatiblePluginEventType {
7436
+ /**
7437
+ * HTML KeyDown event
7438
+ */
7439
+ KeyDown = 0,
7440
+ /**
7441
+ * HTML KeyPress event
7442
+ */
7443
+ KeyPress = 1,
7444
+ /**
7445
+ * HTML KeyUp event
7446
+ */
7447
+ KeyUp = 2,
7448
+ /**
7449
+ * HTML Input / TextInput event
7450
+ */
7451
+ Input = 3,
7452
+ /**
7453
+ * HTML CompositionEnd event
7454
+ */
7455
+ CompositionEnd = 4,
7456
+ /**
7457
+ * HTML MouseDown event
7458
+ */
7459
+ MouseDown = 5,
7460
+ /**
7461
+ * HTML MouseUp event
7462
+ */
7463
+ MouseUp = 6,
7464
+ /**
7465
+ * Content changed event
7466
+ */
7467
+ ContentChanged = 7,
7468
+ /**
7469
+ * Extract Content with a DOM tree event
7470
+ * This event is triggered when getContent() is called with triggerExtractContentEvent = true
7471
+ * Plugin can handle this event to remove the UI only markups to return clean HTML
7472
+ * by operating on a cloned DOM tree
7473
+ */
7474
+ ExtractContentWithDom = 8,
7475
+ /**
7476
+ * Before Paste event, provide a chance to change copied content
7477
+ */
7478
+ BeforeCutCopy = 9,
7479
+ /**
7480
+ * Before Paste event, provide a chance to change paste content
7481
+ */
7482
+ BeforePaste = 10,
7483
+ /**
7484
+ * Let plugin know editor is ready now
7485
+ */
7486
+ EditorReady = 11,
7487
+ /**
7488
+ * Let plugin know editor is about to dispose
7489
+ */
7490
+ BeforeDispose = 12,
7491
+ /**
7492
+ * Pending format state (bold, italic, underline, ... with collapsed selection) is changed
7493
+ */
7494
+ PendingFormatStateChanged = 13,
7495
+ /**
7496
+ * Scroll event triggered by scroll container
7497
+ */
7498
+ Scroll = 14,
7499
+ /**
7500
+ * Operating on an entity. See enum EntityOperation for more details about each operation
7501
+ */
7502
+ EntityOperation = 15,
7503
+ /**
7504
+ * HTML ContextMenu event
7505
+ */
7506
+ ContextMenu = 16,
7507
+ /**
7508
+ * Editor has entered shadow edit mode
7509
+ */
7510
+ EnteredShadowEdit = 17,
7511
+ /**
7512
+ * Editor is about to leave shadow edit mode
7513
+ */
7514
+ LeavingShadowEdit = 18,
7515
+ /**
7516
+ * Content of image is being changed from client side
7517
+ */
7518
+ EditImage = 19,
7519
+ /**
7520
+ * Content of editor is about to be cleared by SetContent API, handle this event to cache anything you need
7521
+ * before it is gone
7522
+ */
7523
+ BeforeSetContent = 20,
7524
+ /**
7525
+ * Zoom scale value is changed, triggered by Editor.setZoomScale() when set a different scale number
7526
+ */
7527
+ ZoomChanged = 21
7045
7528
  }
7046
7529
 
7047
7530
  /**
@@ -7355,101 +7838,33 @@ export enum CompatibleSelectionRangeTypes {
7355
7838
  }
7356
7839
 
7357
7840
  /**
7358
- * Editor plugin event type
7841
+ * Types of definitions, used by Definition type
7359
7842
  */
7360
- export enum CompatiblePluginEventType {
7361
- /**
7362
- * HTML KeyDown event
7363
- */
7364
- KeyDown = 0,
7365
- /**
7366
- * HTML KeyPress event
7367
- */
7368
- KeyPress = 1,
7369
- /**
7370
- * HTML KeyUp event
7371
- */
7372
- KeyUp = 2,
7373
- /**
7374
- * HTML Input / TextInput event
7375
- */
7376
- Input = 3,
7843
+ export enum CompatibleDefinitionType {
7377
7844
  /**
7378
- * HTML CompositionEnd event
7845
+ * Boolean type definition, represents a boolean type value
7379
7846
  */
7380
- CompositionEnd = 4,
7847
+ Boolean = 0,
7381
7848
  /**
7382
- * HTML MouseDown event
7849
+ * Number type definition, represents a number type value
7383
7850
  */
7384
- MouseDown = 5,
7851
+ Number = 1,
7385
7852
  /**
7386
- * HTML MouseUp event
7853
+ * String type definition, represents a string type value
7387
7854
  */
7388
- MouseUp = 6,
7855
+ String = 2,
7389
7856
  /**
7390
- * Content changed event
7857
+ * Array type definition, represents an array with a given item type
7391
7858
  */
7392
- ContentChanged = 7,
7859
+ Array = 3,
7393
7860
  /**
7394
- * Extract Content with a DOM tree event
7395
- * This event is triggered when getContent() is called with triggerExtractContentEvent = true
7396
- * Plugin can handle this event to remove the UI only markups to return clean HTML
7397
- * by operating on a cloned DOM tree
7861
+ * Object type definition, represents an object with the given property types
7398
7862
  */
7399
- ExtractContentWithDom = 8,
7863
+ Object = 4,
7400
7864
  /**
7401
- * Before Paste event, provide a chance to change copied content
7402
- */
7403
- BeforeCutCopy = 9,
7404
- /**
7405
- * Before Paste event, provide a chance to change paste content
7406
- */
7407
- BeforePaste = 10,
7408
- /**
7409
- * Let plugin know editor is ready now
7410
- */
7411
- EditorReady = 11,
7412
- /**
7413
- * Let plugin know editor is about to dispose
7865
+ * Customize type definition, represents a customized type with a validator function
7414
7866
  */
7415
- BeforeDispose = 12,
7416
- /**
7417
- * Pending format state (bold, italic, underline, ... with collapsed selection) is changed
7418
- */
7419
- PendingFormatStateChanged = 13,
7420
- /**
7421
- * Scroll event triggered by scroll container
7422
- */
7423
- Scroll = 14,
7424
- /**
7425
- * Operating on an entity. See enum EntityOperation for more details about each operation
7426
- */
7427
- EntityOperation = 15,
7428
- /**
7429
- * HTML ContextMenu event
7430
- */
7431
- ContextMenu = 16,
7432
- /**
7433
- * Editor has entered shadow edit mode
7434
- */
7435
- EnteredShadowEdit = 17,
7436
- /**
7437
- * Editor is about to leave shadow edit mode
7438
- */
7439
- LeavingShadowEdit = 18,
7440
- /**
7441
- * Content of image is being changed from client side
7442
- */
7443
- EditImage = 19,
7444
- /**
7445
- * Content of editor is about to be cleared by SetContent API, handle this event to cache anything you need
7446
- * before it is gone
7447
- */
7448
- BeforeSetContent = 20,
7449
- /**
7450
- * Zoom scale value is changed, triggered by Editor.setZoomScale() when set a different scale number
7451
- */
7452
- ZoomChanged = 21
7867
+ Customize = 5
7453
7868
  }
7454
7869
 
7455
7870
  /**
@@ -7470,6 +7885,36 @@ export enum CompatibleAlignment {
7470
7885
  Right = 2
7471
7886
  }
7472
7887
 
7888
+ /**
7889
+ * Enum used to control the different types of bullet list
7890
+ */
7891
+ export enum CompatibleBulletListType {
7892
+ /**
7893
+ * Bullet triggered by *
7894
+ */
7895
+ Disc = 0,
7896
+ /**
7897
+ * Bullet triggered by -
7898
+ */
7899
+ Dash = 1,
7900
+ /**
7901
+ * Bullet triggered by --
7902
+ */
7903
+ Square = 2,
7904
+ /**
7905
+ * Bullet triggered by >
7906
+ */
7907
+ ShortArrow = 3,
7908
+ /**
7909
+ * Bullet triggered by -> or -->
7910
+ */
7911
+ LongArrow = 4,
7912
+ /**
7913
+ * Bullet triggered by =>
7914
+ */
7915
+ UnfilledArrow = 5
7916
+ }
7917
+
7473
7918
  /**
7474
7919
  * The enum used for controlling the capitalization of text.
7475
7920
  * Used by changeCapitalization API
@@ -8074,6 +8519,92 @@ export enum CompatibleNodeType {
8074
8519
  DocumentFragment = 11
8075
8520
  }
8076
8521
 
8522
+ /**
8523
+ * Enum used to control the different types of numbering list
8524
+ */
8525
+ export enum CompatibleNumberingListType {
8526
+ /**
8527
+ * Numbering triggered by 1.
8528
+ */
8529
+ Decimal = 0,
8530
+ /**
8531
+ * Numbering triggered by 1-
8532
+ */
8533
+ DecimalDash = 1,
8534
+ /**
8535
+ * Numbering triggered by 1)
8536
+ */
8537
+ DecimalParenthesis = 2,
8538
+ /**
8539
+ * Numbering triggered by (1)
8540
+ */
8541
+ DecimalDoubleParenthesis = 3,
8542
+ /**
8543
+ * Numbering triggered by a.
8544
+ */
8545
+ LowerAlpha = 4,
8546
+ /**
8547
+ * Numbering triggered by a)
8548
+ */
8549
+ LowerAlphaParenthesis = 5,
8550
+ /**
8551
+ * Numbering triggered by (a)
8552
+ */
8553
+ LowerAlphaDoubleParenthesis = 6,
8554
+ /**
8555
+ * Numbering triggered by a-
8556
+ */
8557
+ LowerAlphaDash = 7,
8558
+ /**
8559
+ * Numbering triggered by A.
8560
+ */
8561
+ UpperAlpha = 8,
8562
+ /**
8563
+ * Numbering triggered by A)
8564
+ */
8565
+ UpperAlphaParenthesis = 9,
8566
+ /**
8567
+ * Numbering triggered by (A)
8568
+ */
8569
+ UpperAlphaDoubleParenthesis = 10,
8570
+ /**
8571
+ * Numbering triggered by A-
8572
+ */
8573
+ UpperAlphaDash = 11,
8574
+ /**
8575
+ * Numbering triggered by i.
8576
+ */
8577
+ LowerRoman = 12,
8578
+ /**
8579
+ * Numbering triggered by i)
8580
+ */
8581
+ LowerRomanParenthesis = 13,
8582
+ /**
8583
+ * Numbering triggered by (i)
8584
+ */
8585
+ LowerRomanDoubleParenthesis = 14,
8586
+ /**
8587
+ * Numbering triggered by i-
8588
+ */
8589
+ LowerRomanDash = 15,
8590
+ /**
8591
+ * Numbering triggered by I.
8592
+ */
8593
+ UpperRoman = 16,
8594
+ /**
8595
+ * Numbering triggered by I)
8596
+ */
8597
+ UpperRomanParenthesis = 17,
8598
+ /**
8599
+ * Numbering triggered by (I)
8600
+ */
8601
+ UpperRomanDoubleParenthesis = 18,
8602
+ /**
8603
+ * Numbering triggered by I-
8604
+ */
8605
+ UpperRomanDash = 19
8606
+ }
8607
+
8077
8608
  /**
8078
8609
  * Represent the type of a position
8079
8610
  */
@@ -8435,6 +8966,7 @@ export class HyperLink implements EditorPlugin {
8435
8966
  * ImageEdit plugin provides the ability to edit an inline image in editor, including image resizing, rotation and cropping
8436
8967
  */
8437
8968
  export class ImageEdit implements EditorPlugin {
8969
+ private onShowResizeHandle?;
8438
8970
  protected editor: IEditor;
8439
8971
  protected options: ImageEditOptions;
8440
8972
  private disposer;
@@ -8450,8 +8982,11 @@ export class ImageEdit implements EditorPlugin {
8450
8982
  /**
8451
8983
  * Create a new instance of ImageEdit
8452
8984
  * @param options Image editing options
8985
+ * @param onShowResizeHandle An optional callback to allow customize resize handle element of image resizing.
8986
+ * To customize the resize handle element, add this callback and change the attributes of elementData then it
8987
+ * will be picked up by ImageEdit code
8453
8988
  */
8454
- constructor(options?: ImageEditOptions);
8989
+ constructor(options?: ImageEditOptions, onShowResizeHandle?: OnShowResizeHandle);
8455
8990
  /**
8456
8991
  * Get a friendly name of this plugin
8457
8992
  */
@@ -8553,6 +9088,25 @@ export function isResizedTo(image: HTMLImageElement, percentage: number): boolea
8553
9088
  */
8554
9089
  export function resetImage(editor: IEditor, image: HTMLImageElement): void;
8555
9090
 
9091
+ /**
9092
+ * An optional callback to allow customize resize handle element of image resizing.
9093
+ * To customize the resize handle element, add this callback and change the attributes of elementData then it
9094
+ * will be picked up by ImageEdit code
9095
+ */
9096
+ export interface OnShowResizeHandle {
9097
+ (elementData: CreateElementData, x: DNDDirectionX, y: DnDDirectionY): void;
9098
+ }
9099
+
9100
+ /**
9101
+ * Horizontal direction types for image edit
9102
+ */
9103
+ export type DNDDirectionX = 'w' | '' | 'e';
9104
+
9105
+ /**
9106
+ * Vertical direction types for image edit
9107
+ */
9108
+ export type DnDDirectionY = 'n' | '' | 's';
9109
+
8556
9110
  /**
8557
9111
  * @deprecated Use ImageEdit plugin instead
8558
9112
  */