roosterjs 8.44.1 → 8.45.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.44.1)
1
+ // Type definitions for roosterjs (Version 8.45.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -197,13 +197,13 @@ export function addDelimiters(node: Element): Element[];
197
197
  * Adds delimiter after the element provided.
198
198
  * @param element element to use
199
199
  */
200
- export function addDelimiterAfter(element: Element): Element;
200
+ export function addDelimiterAfter(element: Element): HTMLElement;
201
201
 
202
202
  /**
203
203
  * Adds delimiter before the element provided.
204
204
  * @param element element to use
205
205
  */
206
- export function addDelimiterBefore(element: Element): Element;
206
+ export function addDelimiterBefore(element: Element): HTMLElement;
207
207
 
208
208
  /**
209
209
  * Retrieves Delimiter information from a provided element.
@@ -1948,14 +1948,26 @@ export function toArray<T>(array: readonly T[]): T[];
1948
1948
  /**
1949
1949
  * RoosterJs core editor class
1950
1950
  */
1951
- export class Editor implements IEditor {
1952
- private core;
1951
+ export class Editor extends EditorBase<EditorCore, EditorOptions> {
1953
1952
  /**
1954
- * Creates an instance of Editor
1953
+ * Creates an instance of EditorBase
1955
1954
  * @param contentDiv The DIV HTML element which will be the container element of editor
1956
1955
  * @param options An optional options object to customize the editor
1957
1956
  */
1958
1957
  constructor(contentDiv: HTMLDivElement, options?: EditorOptions);
1958
+ }
1959
+
1960
+ /**
1961
+ * Base class of editor
1962
+ */
1963
+ export class EditorBase<TEditorCore extends EditorCore, TEditorOptions extends EditorOptions> implements IEditor {
1964
+ private core;
1965
+ /**
1966
+ * Creates an instance of EditorBase
1967
+ * @param contentDiv The DIV HTML element which will be the container element of editor
1968
+ * @param options An optional options object to customize the editor
1969
+ */
1970
+ constructor(contentDiv: HTMLDivElement, options: TEditorOptions, coreCreator: CoreCreator<TEditorCore, TEditorOptions>);
1959
1971
  /**
1960
1972
  * Dispose this editor, dispose all plugins and custom data
1961
1973
  */
@@ -2049,7 +2061,7 @@ export class Editor implements IEditor {
2049
2061
  * @param applyCurrentStyle True if apply format of current selection to the pasted content,
2050
2062
  * false to keep original format. Default value is false. When pasteAsText is true, this parameter is ignored
2051
2063
  */
2052
- paste(clipboardData: ClipboardData, pasteAsText?: boolean, applyCurrentFormat?: boolean): void;
2064
+ paste(clipboardData: ClipboardData, pasteAsText?: boolean, applyCurrentFormat?: boolean, pasteAsImage?: boolean): void;
2053
2065
  /**
2054
2066
  * Get current selection range from Editor.
2055
2067
  * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.
@@ -2328,9 +2340,24 @@ export class Editor implements IEditor {
2328
2340
  * @returns the current EditorCore object
2329
2341
  * @throws a standard Error if there's no core object
2330
2342
  */
2331
- protected getCore(): EditorCore;
2343
+ protected getCore(): TEditorCore;
2332
2344
  }
2333
2345
 
2346
+ /**
2347
+ * Check if the given experimental feature is enabled
2348
+ * @param featureSet All enabled features
2349
+ * @param feature The feature to check
2350
+ * @returns True if the given feature is enabled, otherwise false
2351
+ */
2352
+ export function isFeatureEnabled(featureSet: (ExperimentalFeatures | CompatibleExperimentalFeatures)[] | undefined, feature: ExperimentalFeatures | CompatibleExperimentalFeatures): boolean;
2353
+
2354
+ /**
2355
+ * Create a new instance of Editor Core
2356
+ * @param contentDiv The DIV HTML element which will be the container element of editor
2357
+ * @param options An optional options object to customize the editor
2358
+ */
2359
+ export const createEditorCore: CoreCreator<EditorCore, EditorOptions>;
2360
+
2334
2361
  /**
2335
2362
  * Increase or decrease font size in selection
2336
2363
  * @param editor The editor instance
@@ -2724,7 +2751,7 @@ export function toggleListType(editor: IEditor, listType: ListType | CompatibleL
2724
2751
  /**
2725
2752
  * Split selection into regions, and perform a block-wise formatting action for each region.
2726
2753
  */
2727
- export function blockFormat(editor: IEditor, callback: (region: Region, start: NodePosition, end: NodePosition, chains: VListChain[]) => void, beforeRunCallback?: () => boolean, apiName?: string): void;
2754
+ export function blockFormat(editor: IEditor, callback: (region: Region, start: NodePosition | null, end: NodePosition | null, chains: VListChain[]) => void, beforeRunCallback?: () => boolean, apiName?: string): void;
2728
2755
 
2729
2756
  /**
2730
2757
  * Commit changes of all list changes when experiment features are allowed
@@ -3437,7 +3464,12 @@ export const enum ChangeSource {
3437
3464
  /**
3438
3465
  * List chain reorganized numbers of lists
3439
3466
  */
3440
- ListChain = "ListChain"
3467
+ ListChain = "ListChain",
3468
+ /**
3469
+ * Keyboard event, used by Content Model.
3470
+ * Data of this event will be the key code number
3471
+ */
3472
+ Keyboard = "Keyboard"
3441
3473
  }
3442
3474
 
3443
3475
  /**
@@ -6341,7 +6373,7 @@ export interface IEditor {
6341
6373
  * @param applyCurrentStyle True if apply format of current selection to the pasted content,
6342
6374
  * false to keep original format. Default value is false. When pasteAsText is true, this parameter is ignored
6343
6375
  */
6344
- paste(clipboardData: ClipboardData, pasteAsText?: boolean, applyCurrentFormat?: boolean): void;
6376
+ paste(clipboardData: ClipboardData, pasteAsText?: boolean, applyCurrentFormat?: boolean, pasteAsImage?: boolean): void;
6345
6377
  /**
6346
6378
  * Get current selection range from Editor.
6347
6379
  * It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.
@@ -7086,6 +7118,16 @@ export interface CoreApiMap {
7086
7118
  * @param step Steps to move, can be 0, positive or negative
7087
7119
  */
7088
7120
  restoreUndoSnapshot: RestoreUndoSnapshot;
7121
+ /**
7122
+ * Select content according to the given information.
7123
+ * There are a bunch of allowed combination of parameters. See IEditor.select for more details
7124
+ * @param core The editor core object
7125
+ * @param arg1 A DOM Range, or SelectionRangeEx, or NodePosition, or Node, or Selection Path
7126
+ * @param arg2 (optional) A NodePosition, or an offset number, or a PositionType, or a TableSelection
7127
+ * @param arg3 (optional) A Node
7128
+ * @param arg4 (optional) An offset number, or a PositionType
7129
+ */
7130
+ select: Select;
7089
7131
  /**
7090
7132
  * Change the editor selection to the given range
7091
7133
  * @param core The EditorCore object
@@ -7157,7 +7199,7 @@ export interface CoreApiMap {
7157
7199
  * @param applyCurrentStyle True if apply format of current selection to the pasted content,
7158
7200
  * false to keep original format
7159
7201
  */
7160
- export type CreatePasteFragment = (core: EditorCore, clipboardData: ClipboardData, position: NodePosition | null, pasteAsText: boolean, applyCurrentStyle: boolean) => DocumentFragment | null;
7202
+ export type CreatePasteFragment = (core: EditorCore, clipboardData: ClipboardData, position: NodePosition | null, pasteAsText: boolean, applyCurrentStyle: boolean, pasteAsImage: boolean) => DocumentFragment | null;
7161
7203
 
7162
7204
  /**
7163
7205
  * Ensure user will type into a container element rather than into the editor content DIV directly
@@ -7234,6 +7276,17 @@ export type InsertNode = (core: EditorCore, node: Node, option: InsertOption | n
7234
7276
  */
7235
7277
  export type RestoreUndoSnapshot = (core: EditorCore, step: number) => void;
7236
7278
 
7279
+ /**
7280
+ * Select content according to the given information.
7281
+ * There are a bunch of allowed combination of parameters. See IEditor.select for more details
7282
+ * @param core The editor core object
7283
+ * @param arg1 A DOM Range, or SelectionRangeEx, or NodePosition, or Node, or Selection Path
7284
+ * @param arg2 (optional) A NodePosition, or an offset number, or a PositionType, or a TableSelection
7285
+ * @param arg3 (optional) A Node
7286
+ * @param arg4 (optional) An offset number, or a PositionType
7287
+ */
7288
+ export type Select = (core: EditorCore, arg1: Range | SelectionRangeEx | NodePosition | Node | SelectionPath | null, arg2?: NodePosition | number | PositionType | TableSelection, arg3?: Node, arg4?: number | PositionType) => boolean;
7289
+
7237
7290
  /**
7238
7291
  * Change the editor selection to the given range
7239
7292
  * @param core The EditorCore object
@@ -7413,7 +7466,7 @@ export interface EditorOptions {
7413
7466
  /**
7414
7467
  * A list to specify whether each of the listed content edit features is enabled
7415
7468
  */
7416
- export interface ContentEditFeatureSettings extends ListFeatureSettings, QuoteFeatureSettings, TableFeatureSettings, StructuredNodeFeatureSettings, AutoLinkFeatureSettings, ShortcutFeatureSettings, CursorFeatureSettings, MarkdownFeatureSettings, EntityFeatureSettings, TextFeatureSettings {
7469
+ export interface ContentEditFeatureSettings extends ListFeatureSettings, QuoteFeatureSettings, TableFeatureSettings, StructuredNodeFeatureSettings, AutoLinkFeatureSettings, ShortcutFeatureSettings, CursorFeatureSettings, MarkdownFeatureSettings, EntityFeatureSettings, TextFeatureSettings, CodeFeatureSettings {
7417
7470
  }
7418
7471
 
7419
7472
  /**
@@ -7542,6 +7595,16 @@ export interface ListFeatureSettings {
7542
7595
  * @default true
7543
7596
  */
7544
7597
  mergeListOnBackspaceAfterList: boolean;
7598
+ /**
7599
+ * indentWhenAltShiftRight edit feature, provides the ability to indent or outdent current list when user press Alt+shift+Right
7600
+ * @default when browser is in Mac it is default disabled, else it is enabled
7601
+ */
7602
+ indentWhenAltShiftRight: boolean;
7603
+ /**
7604
+ * outdentWhenAltShiftLeft edit feature, provides the ability to indent or outdent current list when user press Alt+shift+Left
7605
+ * @default when browser is in Mac it is default disabled, else it is enabled
7606
+ */
7607
+ outdentWhenAltShiftLeft: boolean;
7545
7608
  }
7546
7609
 
7547
7610
  /**
@@ -7661,6 +7724,22 @@ export interface TextFeatureSettings {
7661
7724
  autoHyphen: boolean;
7662
7725
  }
7663
7726
 
7727
+ /**
7728
+ * Settings for code features
7729
+ */
7730
+ export interface CodeFeatureSettings {
7731
+ /**
7732
+ * When inside a code block, exit the code block by pressing Enter twice, or once on an empty line
7733
+ * @default true
7734
+ */
7735
+ removeCodeWhenEnterOnEmptyLine: boolean;
7736
+ /**
7737
+ * When inside an empty code block (or an empty first line), exit the code block by pressing Backspace
7738
+ * @default true
7739
+ */
7740
+ removeCodeWhenBackspaceOnEmptyFirstLine: boolean;
7741
+ }
7742
+
7664
7743
  /**
7665
7744
  * An interface to define a replacement rule for CustomReplace plugin
7666
7745
  */
@@ -8205,6 +8284,13 @@ export interface CustomizeDefinition extends DefinitionBase<DefinitionType.Custo
8205
8284
  */
8206
8285
  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);
8207
8286
 
8287
+ /**
8288
+ * Type of Editor Core Creator
8289
+ * @param contentDiv The DIV HTML element which will be the container element of editor
8290
+ * @param options An optional options object to customize the editor
8291
+ */
8292
+ export type CoreCreator<TEditorCore extends EditorCore, TEditorOptions extends EditorOptions> = (contentDiv: HTMLDivElement, options: TEditorOptions) => TEditorCore;
8293
+
8208
8294
  /**
8209
8295
  * Experimental feature flags
8210
8296
  */
@@ -8487,7 +8573,12 @@ export enum CompatibleChangeSource {
8487
8573
  /**
8488
8574
  * List chain reorganized numbers of lists
8489
8575
  */
8490
- ListChain = "ListChain"
8576
+ ListChain = "ListChain",
8577
+ /**
8578
+ * Keyboard event, used by Content Model.
8579
+ * Data of this event will be the key code number
8580
+ */
8581
+ Keyboard = "Keyboard"
8491
8582
  }
8492
8583
 
8493
8584
  /**
@@ -9715,7 +9806,7 @@ export class ContentEdit implements EditorPlugin {
9715
9806
  * @param settingsOverride An optional feature set to override default feature settings
9716
9807
  * @param additionalFeatures Optional. More features to add
9717
9808
  */
9718
- constructor(settingsOverride?: Partial<ContentEditFeatureSettings>, additionalFeatures?: GenericContentEditFeature<PluginEvent>[]);
9809
+ constructor(settingsOverride?: Partial<ContentEditFeatureSettings> | undefined, additionalFeatures?: GenericContentEditFeature<PluginEvent>[] | undefined);
9719
9810
  /**
9720
9811
  * Get a friendly name of this plugin
9721
9812
  */
@@ -10006,6 +10097,18 @@ export class ImageEdit implements EditorPlugin {
10006
10097
  * @param selectImage True to select this image after quit editing mode
10007
10098
  */
10008
10099
  setEditingImage(image: null, selectImage?: boolean): void;
10100
+ /**
10101
+ * Flip the image.
10102
+ * @param image The image to be flipped
10103
+ * @param direction
10104
+ */
10105
+ flipImage(image: HTMLImageElement, direction: 'vertical' | 'horizontal'): void;
10106
+ /**
10107
+ * Rotate the image in radian angle.
10108
+ * @param image The image to be rotated
10109
+ * @param angleRad The angle in radian that the image must be rotated.
10110
+ */
10111
+ rotateImage(image: HTMLImageElement, angleRad: number): void;
10009
10112
  /**
10010
10113
  * quit editing mode when editor lose focus
10011
10114
  */