roosterjs 8.22.0 → 8.23.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.
@@ -1,4 +1,4 @@
1
- // Type definitions for roosterjs (Version 8.22.0)
1
+ // Type definitions for roosterjs (Version 8.23.1)
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'
@@ -2098,10 +2193,11 @@ export function clearFormat(editor: IEditor, formatType?: ClearFormatMode | Comp
2098
2193
  * When protocol is not specified, a best matched protocol will be predicted.
2099
2194
  * @param altText Optional alt text of the link, will be shown when hover on the link
2100
2195
  * @param displayText Optional display text for the link.
2196
+ * @param target Optional display target for the link ("_blank"|"_self"|"_parent"|"_top"|"{framename}")
2101
2197
  * If specified, the display text of link will be replaced with this text.
2102
2198
  * If not specified and there wasn't a link, the link url will be used as display text.
2103
2199
  */
2104
- export function createLink(editor: IEditor, link: string, altText?: string, displayText?: string): void;
2200
+ export function createLink(editor: IEditor, link: string, altText?: string, displayText?: string, target?: string): void;
2105
2201
 
2106
2202
  /**
2107
2203
  * Get format state at cursor
@@ -2142,15 +2238,17 @@ export function insertEntity(editor: IEditor, type: string, contentNode: Node, i
2142
2238
  * @param editor The editor instance
2143
2239
  * @param imageFile The image file. There are at least 3 ways to obtain the file object:
2144
2240
  * From local file, from clipboard data, from drag-and-drop
2241
+ * @param attributes Optional image element attributes
2145
2242
  */
2146
- export function insertImage(editor: IEditor, imageFile: File): void;
2243
+ export function insertImage(editor: IEditor, imageFile: File, attributes?: Record<string, string>): void;
2147
2244
 
2148
2245
  /**
2149
2246
  * Insert an image to editor at current selection
2150
2247
  * @param editor The editor instance
2151
- * @param imageFile The image link.
2248
+ * @param url The image link
2249
+ * @param attributes Optional image element attributes
2152
2250
  */
2153
- export function insertImage(editor: IEditor, url: string): void;
2251
+ export function insertImage(editor: IEditor, url: string, attributes?: Record<string, string>): void;
2154
2252
 
2155
2253
  /**
2156
2254
  * Insert table into editor at current selection
@@ -2320,8 +2418,9 @@ export function toggleBold(editor: IEditor): void;
2320
2418
  * If selection contains both bullet/numbering and normal text, the behavior is decided by corresponding
2321
2419
  * browser execCommand API
2322
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.
2323
2422
  */
2324
- export function toggleBullet(editor: IEditor): void;
2423
+ export function toggleBullet(editor: IEditor, listStyle?: BulletListType | CompatibleBulletListType): void;
2325
2424
 
2326
2425
  /**
2327
2426
  * Toggle italic at selection
@@ -2341,8 +2440,9 @@ export function toggleItalic(editor: IEditor): void;
2341
2440
  * realization of browser execCommand API
2342
2441
  * @param editor The editor instance
2343
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.
2344
2444
  */
2345
- export function toggleNumbering(editor: IEditor, startNumber?: number): void;
2445
+ export function toggleNumbering(editor: IEditor, startNumber?: number, listStyle?: NumberingListType | CompatibleNumberingListType): void;
2346
2446
 
2347
2447
  /**
2348
2448
  * Resets Ordered List Numbering back to the value of the parameter startNumber
@@ -2444,8 +2544,9 @@ export function applyCellShading(editor: IEditor, color: string | ModeIndependen
2444
2544
  * @param listType The list type to toggle
2445
2545
  * @param startNumber (Optional) Start number of the list
2446
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.
2447
2548
  */
2448
- 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;
2449
2550
 
2450
2551
  /**
2451
2552
  * Split selection into regions, and perform a block-wise formatting action for each region.
@@ -2513,6 +2614,10 @@ export interface BrowserInfo {
2513
2614
  * Whether current OS is Android
2514
2615
  */
2515
2616
  readonly isAndroid?: boolean;
2617
+ /**
2618
+ * Whether current browser is on mobile or a tablet
2619
+ */
2620
+ readonly isMobileOrTablet?: boolean;
2516
2621
  }
2517
2622
 
2518
2623
  /**
@@ -2954,6 +3059,8 @@ export const enum Keys {
2954
3059
  TAB = 9,
2955
3060
  ENTER = 13,
2956
3061
  SHIFT = 16,
3062
+ CTRL_LEFT = 17,
3063
+ ALT = 18,
2957
3064
  ESCAPE = 27,
2958
3065
  SPACE = 32,
2959
3066
  PAGEUP = 33,
@@ -2961,6 +3068,7 @@ export const enum Keys {
2961
3068
  UP = 38,
2962
3069
  RIGHT = 39,
2963
3070
  DOWN = 40,
3071
+ PRINT_SCREEN = 44,
2964
3072
  DELETE = 46,
2965
3073
  /**
2966
3074
  * @deprecated Just for backward compatibility
@@ -2972,6 +3080,7 @@ export const enum Keys {
2972
3080
  U = 85,
2973
3081
  Y = 89,
2974
3082
  Z = 90,
3083
+ META_LEFT = 91,
2975
3084
  COMMA = 188,
2976
3085
  DASH_UNDERSCORE = 189,
2977
3086
  PERIOD = 190,
@@ -3359,7 +3468,15 @@ export const enum ExperimentalFeatures {
3359
3468
  /**
3360
3469
  * Align list elements elements to left, center and right using setAlignment API
3361
3470
  */
3362
- 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"
3363
3480
  }
3364
3481
 
3365
3482
  /**
@@ -3911,6 +4028,152 @@ export const enum SelectionRangeTypes {
3911
4028
  TableSelection = 1
3912
4029
  }
3913
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
+
3914
4177
  /**
3915
4178
  * Provides a chance for plugin to change the content before it is copied from editor.
3916
4179
  */
@@ -3936,7 +4199,7 @@ export interface BeforeCutCopyEvent extends BasePluginEvent<PluginEventType.Befo
3936
4199
  /**
3937
4200
  * Editor plugin event interface
3938
4201
  */
3939
- export interface BasePluginEvent<T extends PluginEventType> {
4202
+ export interface BasePluginEvent<T extends PluginEventType | CompatiblePluginEventType> {
3940
4203
  /**
3941
4204
  * Type of this event
3942
4205
  */
@@ -4103,7 +4366,7 @@ export type PluginDomEvent = PluginCompositionEvent | PluginMouseEvent | PluginK
4103
4366
  /**
4104
4367
  * A base interface of all DOM events
4105
4368
  */
4106
- 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> {
4107
4370
  rawEvent: TRawEvent;
4108
4371
  }
4109
4372
 
@@ -4190,24 +4453,24 @@ export type PluginEvent = BeforeCutCopyEvent | BeforePasteEvent | ContentChanged
4190
4453
  /**
4191
4454
  * A type to extract data part of a plugin event type. Data part is the plugin event without eventType field.
4192
4455
  */
4193
- export type PluginEventData<T extends PluginEventType> = PluginEventDataGeneric<PluginEvent, T>;
4456
+ export type PluginEventData<T extends PluginEventType | CompatiblePluginEventType> = PluginEventDataGeneric<PluginEvent, T>;
4194
4457
 
4195
4458
  /**
4196
4459
  * A type to extract data part of a plugin event type. Data part is the plugin event without eventType field.
4197
4460
  * This type is a middle result and only used by PluginEventData type
4198
4461
  */
4199
- 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;
4200
4463
 
4201
4464
  /**
4202
4465
  * A type to get specify plugin event type from eventType parameter.
4203
4466
  */
4204
- export type PluginEventFromType<T extends PluginEventType> = PluginEventFromTypeGeneric<PluginEvent, T>;
4467
+ export type PluginEventFromType<T extends PluginEventType | CompatiblePluginEventType> = PluginEventFromTypeGeneric<PluginEvent, T>;
4205
4468
 
4206
4469
  /**
4207
4470
  * A type to get specify plugin event type from eventType parameter.
4208
4471
  * This type is a middle result and only used by PluginEventFromType type
4209
4472
  */
4210
- 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;
4211
4474
 
4212
4475
  /**
4213
4476
  * A plugin triggered right after editor has entered Shadow Edit mode
@@ -5544,7 +5807,7 @@ export interface IEditor {
5544
5807
  * @returns the event object which is really passed into plugins. Some plugin may modify the event object so
5545
5808
  * the result of this function provides a chance to read the modified result
5546
5809
  */
5547
- 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>;
5548
5811
  /**
5549
5812
  * Trigger a ContentChangedEvent
5550
5813
  * @param source Source of this event, by default is 'SetContent'
@@ -6568,6 +6831,11 @@ export interface TextFeatureSettings {
6568
6831
  * If Whole Paragraph selected, outdent paragraph
6569
6832
  */
6570
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;
6571
6839
  }
6572
6840
 
6573
6841
  /**
@@ -6610,7 +6878,7 @@ export interface UndoSnapshotsService<T = string> {
6610
6878
  * @param step The step to move
6611
6879
  * @returns If can move with the given step, returns the snapshot after move, otherwise null
6612
6880
  */
6613
- move(step: number): T;
6881
+ move(step: number): T | null;
6614
6882
  /**
6615
6883
  * Add a new undo snapshot
6616
6884
  * @param snapshot The snapshot to add
@@ -6956,7 +7224,7 @@ export interface DOMEventHandlerObject {
6956
7224
  /**
6957
7225
  * Combined event handler type with all 3 possibilities
6958
7226
  */
6959
- export type DOMEventHandler = PluginEventType | DOMEventHandlerFunction | DOMEventHandlerObject;
7227
+ export type DOMEventHandler = PluginEventType | CompatiblePluginEventType | DOMEventHandlerFunction | DOMEventHandlerObject;
6960
7228
 
6961
7229
  /**
6962
7230
  * A handler type to convert HTML string to a trust HTML string
@@ -6972,6 +7240,120 @@ export type TrustedHTMLHandler = (html: string) => string;
6972
7240
  */
6973
7241
  export type SizeTransformer = (size: number) => number;
6974
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
+
6975
7357
  /**
6976
7358
  * Experimental feature flags
6977
7359
  */
@@ -7036,7 +7418,113 @@ export enum CompatibleExperimentalFeatures {
7036
7418
  /**
7037
7419
  * Align list elements elements to left, center and right using setAlignment API
7038
7420
  */
7039
- 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
7040
7528
  }
7041
7529
 
7042
7530
  /**
@@ -7350,101 +7838,33 @@ export enum CompatibleSelectionRangeTypes {
7350
7838
  }
7351
7839
 
7352
7840
  /**
7353
- * Editor plugin event type
7841
+ * Types of definitions, used by Definition type
7354
7842
  */
7355
- export enum CompatiblePluginEventType {
7356
- /**
7357
- * HTML KeyDown event
7358
- */
7359
- KeyDown = 0,
7360
- /**
7361
- * HTML KeyPress event
7362
- */
7363
- KeyPress = 1,
7364
- /**
7365
- * HTML KeyUp event
7366
- */
7367
- KeyUp = 2,
7368
- /**
7369
- * HTML Input / TextInput event
7370
- */
7371
- Input = 3,
7843
+ export enum CompatibleDefinitionType {
7372
7844
  /**
7373
- * HTML CompositionEnd event
7845
+ * Boolean type definition, represents a boolean type value
7374
7846
  */
7375
- CompositionEnd = 4,
7847
+ Boolean = 0,
7376
7848
  /**
7377
- * HTML MouseDown event
7849
+ * Number type definition, represents a number type value
7378
7850
  */
7379
- MouseDown = 5,
7851
+ Number = 1,
7380
7852
  /**
7381
- * HTML MouseUp event
7853
+ * String type definition, represents a string type value
7382
7854
  */
7383
- MouseUp = 6,
7855
+ String = 2,
7384
7856
  /**
7385
- * Content changed event
7857
+ * Array type definition, represents an array with a given item type
7386
7858
  */
7387
- ContentChanged = 7,
7859
+ Array = 3,
7388
7860
  /**
7389
- * Extract Content with a DOM tree event
7390
- * This event is triggered when getContent() is called with triggerExtractContentEvent = true
7391
- * Plugin can handle this event to remove the UI only markups to return clean HTML
7392
- * by operating on a cloned DOM tree
7861
+ * Object type definition, represents an object with the given property types
7393
7862
  */
7394
- ExtractContentWithDom = 8,
7863
+ Object = 4,
7395
7864
  /**
7396
- * Before Paste event, provide a chance to change copied content
7397
- */
7398
- BeforeCutCopy = 9,
7399
- /**
7400
- * Before Paste event, provide a chance to change paste content
7401
- */
7402
- BeforePaste = 10,
7403
- /**
7404
- * Let plugin know editor is ready now
7405
- */
7406
- EditorReady = 11,
7407
- /**
7408
- * Let plugin know editor is about to dispose
7865
+ * Customize type definition, represents a customized type with a validator function
7409
7866
  */
7410
- BeforeDispose = 12,
7411
- /**
7412
- * Pending format state (bold, italic, underline, ... with collapsed selection) is changed
7413
- */
7414
- PendingFormatStateChanged = 13,
7415
- /**
7416
- * Scroll event triggered by scroll container
7417
- */
7418
- Scroll = 14,
7419
- /**
7420
- * Operating on an entity. See enum EntityOperation for more details about each operation
7421
- */
7422
- EntityOperation = 15,
7423
- /**
7424
- * HTML ContextMenu event
7425
- */
7426
- ContextMenu = 16,
7427
- /**
7428
- * Editor has entered shadow edit mode
7429
- */
7430
- EnteredShadowEdit = 17,
7431
- /**
7432
- * Editor is about to leave shadow edit mode
7433
- */
7434
- LeavingShadowEdit = 18,
7435
- /**
7436
- * Content of image is being changed from client side
7437
- */
7438
- EditImage = 19,
7439
- /**
7440
- * Content of editor is about to be cleared by SetContent API, handle this event to cache anything you need
7441
- * before it is gone
7442
- */
7443
- BeforeSetContent = 20,
7444
- /**
7445
- * Zoom scale value is changed, triggered by Editor.setZoomScale() when set a different scale number
7446
- */
7447
- ZoomChanged = 21
7867
+ Customize = 5
7448
7868
  }
7449
7869
 
7450
7870
  /**
@@ -7465,6 +7885,36 @@ export enum CompatibleAlignment {
7465
7885
  Right = 2
7466
7886
  }
7467
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
+
7468
7918
  /**
7469
7919
  * The enum used for controlling the capitalization of text.
7470
7920
  * Used by changeCapitalization API
@@ -7917,6 +8367,8 @@ export enum CompatibleKeys {
7917
8367
  TAB = 9,
7918
8368
  ENTER = 13,
7919
8369
  SHIFT = 16,
8370
+ CTRL_LEFT = 17,
8371
+ ALT = 18,
7920
8372
  ESCAPE = 27,
7921
8373
  SPACE = 32,
7922
8374
  PAGEUP = 33,
@@ -7924,6 +8376,7 @@ export enum CompatibleKeys {
7924
8376
  UP = 38,
7925
8377
  RIGHT = 39,
7926
8378
  DOWN = 40,
8379
+ PRINT_SCREEN = 44,
7927
8380
  DELETE = 46,
7928
8381
  /**
7929
8382
  * @deprecated Just for backward compatibility
@@ -7935,6 +8388,7 @@ export enum CompatibleKeys {
7935
8388
  U = 85,
7936
8389
  Y = 89,
7937
8390
  Z = 90,
8391
+ META_LEFT = 91,
7938
8392
  COMMA = 188,
7939
8393
  DASH_UNDERSCORE = 189,
7940
8394
  PERIOD = 190,
@@ -8065,6 +8519,92 @@ export enum CompatibleNodeType {
8065
8519
  DocumentFragment = 11
8066
8520
  }
8067
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
+
8068
8608
  /**
8069
8609
  * Represent the type of a position
8070
8610
  */
@@ -8426,6 +8966,7 @@ export class HyperLink implements EditorPlugin {
8426
8966
  * ImageEdit plugin provides the ability to edit an inline image in editor, including image resizing, rotation and cropping
8427
8967
  */
8428
8968
  export class ImageEdit implements EditorPlugin {
8969
+ private onShowResizeHandle?;
8429
8970
  protected editor: IEditor;
8430
8971
  protected options: ImageEditOptions;
8431
8972
  private disposer;
@@ -8441,8 +8982,11 @@ export class ImageEdit implements EditorPlugin {
8441
8982
  /**
8442
8983
  * Create a new instance of ImageEdit
8443
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
8444
8988
  */
8445
- constructor(options?: ImageEditOptions);
8989
+ constructor(options?: ImageEditOptions, onShowResizeHandle?: OnShowResizeHandle);
8446
8990
  /**
8447
8991
  * Get a friendly name of this plugin
8448
8992
  */
@@ -8544,6 +9088,25 @@ export function isResizedTo(image: HTMLImageElement, percentage: number): boolea
8544
9088
  */
8545
9089
  export function resetImage(editor: IEditor, image: HTMLImageElement): void;
8546
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
+
8547
9110
  /**
8548
9111
  * @deprecated Use ImageEdit plugin instead
8549
9112
  */