roosterjs 9.1.0 → 9.2.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 9.1.0)
1
+ // Type definitions for roosterjs (Version 9.2.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -1479,6 +1479,10 @@ export interface ContentModelEntity extends ContentModelBlockBase<'Entity', Cont
1479
1479
  * Content Model document entry point
1480
1480
  */
1481
1481
  export interface ContentModelDocument extends ContentModelBlockGroupBase<'Document'>, Partial<ContentModelWithFormat<ContentModelSegmentFormat>> {
1482
+ /**
1483
+ * Whether the selection in model (if any) is a revert selection (end is before start)
1484
+ */
1485
+ hasRevertedRangeSelection?: boolean;
1482
1486
  }
1483
1487
 
1484
1488
  /**
@@ -2863,6 +2867,11 @@ export interface IEditor {
2863
2867
  * combined with root selector together to build a separate rule.
2864
2868
  */
2865
2869
  setEditorStyle(key: string, cssRule: string | null, subSelectors?: 'before' | 'after' | string[]): void;
2870
+ /**
2871
+ * Announce the given data
2872
+ * @param announceData Data to announce
2873
+ */
2874
+ announce(announceData: AnnounceData): void;
2866
2875
  }
2867
2876
 
2868
2877
  /**
@@ -2956,6 +2965,12 @@ export interface EditorOptions {
2956
2965
  * Default paste type. By default will use the normal (as-is) paste type.
2957
2966
  */
2958
2967
  defaultPasteType?: PasteType;
2968
+ /**
2969
+ * A callback to help get string template to announce, used for accessibility
2970
+ * @param key The key of known announce data
2971
+ * @returns A template string to announce, use placeholder such as "{0}" for variables if necessary
2972
+ */
2973
+ announcerStringGetter?: (key: KnownAnnounceStrings) => string;
2959
2974
  }
2960
2975
 
2961
2976
  /**
@@ -3122,6 +3137,12 @@ export interface CoreApiMap {
3122
3137
  * combined with root selector together to build a separate rule.
3123
3138
  */
3124
3139
  setEditorStyle: SetEditorStyle;
3140
+ /**
3141
+ * Announce the given data
3142
+ * @param core The EditorCore object
3143
+ * @param announceData Data to announce
3144
+ */
3145
+ announce: Announce;
3125
3146
  }
3126
3147
 
3127
3148
  /**
@@ -3240,6 +3261,13 @@ export type GetVisibleViewport = (core: EditorCore) => Rect | null;
3240
3261
  */
3241
3262
  export type SetEditorStyle = (core: EditorCore, key: string, cssRule: string | null, subSelectors?: 'before' | 'after' | string[], maxRuleLength?: number) => void;
3242
3263
 
3264
+ /**
3265
+ * Announce the given data
3266
+ * @param core The EditorCore object
3267
+ * @param announceData Data to announce
3268
+ */
3269
+ export type Announce = (core: EditorCore, announceData: AnnounceData) => void;
3270
+
3243
3271
  /**
3244
3272
  * Core plugins for editor
3245
3273
  */
@@ -3476,6 +3504,16 @@ export interface LifecyclePluginState {
3476
3504
  * Cached document fragment for original content
3477
3505
  */
3478
3506
  shadowEditFragment: DocumentFragment | null;
3507
+ /**
3508
+ * The HTML container for announced string
3509
+ */
3510
+ announceContainer?: HTMLElement;
3511
+ /**
3512
+ * A callback to help get string template to announce, used for accessibility
3513
+ * @param key The key of known announce data
3514
+ * @returns A template string to announce, use placeholder such as "{0}" for variables if necessary
3515
+ */
3516
+ readonly announcerStringGetter?: (key: KnownAnnounceStrings) => string;
3479
3517
  /**
3480
3518
  * Style elements used for adding CSS rules for editor
3481
3519
  */
@@ -3779,6 +3817,10 @@ export interface FormatContentModelContext {
3779
3817
  * @optional Set to true if this action can be undone when user press Backspace key (aka Auto Complete).
3780
3818
  */
3781
3819
  canUndoByBackspace?: boolean;
3820
+ /**
3821
+ * @optional Set this value to tell AnnouncePlugin to announce the given information
3822
+ */
3823
+ announceData?: AnnounceData | null;
3782
3824
  }
3783
3825
 
3784
3826
  /**
@@ -4474,6 +4516,14 @@ export interface DOMHelper {
4474
4516
  * @returns True if the editor has focus, otherwise false
4475
4517
  */
4476
4518
  hasFocus(): boolean;
4519
+ /**
4520
+ * Check if the root element is in RTL mode
4521
+ */
4522
+ isRightToLeft(): boolean;
4523
+ /**
4524
+ * Get the width of the editable area of the editor content div
4525
+ */
4526
+ getClientWidth(): number;
4477
4527
  }
4478
4528
 
4479
4529
  /**
@@ -4855,7 +4905,7 @@ export interface ContentChangedEvent extends BasePluginEvent<'contentChanged'> {
4855
4905
  */
4856
4906
  readonly formatApiName?: string;
4857
4907
  /**
4858
- * @optional Announce data from this content changed event.
4908
+ * @deprecated Call editor.announce(announceData) directly insteaad
4859
4909
  */
4860
4910
  readonly announceData?: AnnounceData;
4861
4911
  }
@@ -5493,9 +5543,25 @@ export function addDelimiters(doc: Document, element: HTMLElement, format?: Cont
5493
5543
  /**
5494
5544
  * Checks whether the node provided is a Entity delimiter
5495
5545
  * @param node the node to check
5546
+ * @param isBefore True to match delimiter before entity only, false to match delimiter after entity, or undefined means match both
5496
5547
  * @return true if it is a delimiter
5497
5548
  */
5498
- export function isEntityDelimiter(element: HTMLElement): boolean;
5549
+ export function isEntityDelimiter(element: HTMLElement, isBefore?: boolean): boolean;
5550
+
5551
+ /**
5552
+ * Check if the given element is a container element of block entity
5553
+ * @param element The element to check
5554
+ * @returns True if the element is a block entity container, otherwise false
5555
+ */
5556
+ export function isBlockEntityContainer(element: HTMLElement): boolean;
5557
+
5558
+ /**
5559
+ * Find the closest block entity wrapper element from a given DOM node
5560
+ * @param node The node to start looking for entity container
5561
+ * @param domHelper The DOM helper
5562
+ * @returns
5563
+ */
5564
+ export function findClosestBlockEntityContainer(node: Node, domHelper: DOMHelper): HTMLElement | null;
5499
5565
 
5500
5566
  /**
5501
5567
  * When set a DOM tree into editor, reuse the existing element in editor and no need to change it
@@ -5726,6 +5792,29 @@ export function normalizeSingleSegment(segment: ContentModelSegment, ignoreTrail
5726
5792
  */
5727
5793
  export function setParagraphNotImplicit(block: ContentModelBlock): void;
5728
5794
 
5795
+ /**
5796
+ * Get the list number for a list item according to list style type and its index number
5797
+ * @param styleType The list style number, should be a value of NumberingListType type
5798
+ * @param listNumber List number, start from 1
5799
+ * @returns A string for this list item. For example, when pass in NumberingListType.LowerAlpha and 2, it returns "b"
5800
+ */
5801
+ export function getOrderedListNumberStr(styleType: number, listNumber: number): string;
5802
+
5803
+ /**
5804
+ * Get automatic list style of a list item according to its lis type and metadata.
5805
+ * @param listType The list type, either OL or UL
5806
+ * @param metadata Metadata of this list item from list item model
5807
+ * @param depth Depth of list level, start from 0
5808
+ * @param existingStyleType Existing list style type in format, if any
5809
+ * @returns A number to represent list style type.
5810
+ * This will be the value of either NumberingListType (when listType is OL) or BulletListType (when listType is UL).
5811
+ * When there is a specified list style in its metadata, return this value, otherwise
5812
+ * When specified "applyListStyleFromLevel" in metadata, calculate auto list type from its depth, otherwise
5813
+ * When there is already listStyleType in list level format, find a related style type index, otherwise
5814
+ * return undefined
5815
+ */
5816
+ export function getAutoListStyleType(listType: 'OL' | 'UL', metadata: ListMetadataFormat, depth: number, existingStyleType?: string): number | undefined;
5817
+
5729
5818
  /**
5730
5819
  * Parse unit value with its unit
5731
5820
  * @param value The source value to parse
@@ -5961,12 +6050,12 @@ export function getFirstSelectedTable(model: ContentModelDocument): [ContentMode
5961
6050
 
5962
6051
  /**
5963
6052
  * Get an array of block group - block pair that is of the expected block group type from selection
5964
- * @param model The Content Model to get selection from
6053
+ * @param group The root block group to search
5965
6054
  * @param blockGroupTypes The expected block group types
5966
6055
  * @param stopTypes Block group types that will stop searching when hit
5967
6056
  * @param deepFirst True means search in deep first, otherwise wide first
5968
6057
  */
5969
- export function getOperationalBlocks<T extends ContentModelBlockGroup>(model: ContentModelDocument, blockGroupTypes: TypeOfBlockGroup<T>[], stopTypes: ContentModelBlockGroupType[], deepFirst?: boolean): OperationalBlocks<T>[];
6058
+ export function getOperationalBlocks<T extends ContentModelBlockGroup>(group: ContentModelBlockGroup, blockGroupTypes: TypeOfBlockGroup<T>[], stopTypes: ContentModelBlockGroupType[], deepFirst?: boolean): OperationalBlocks<T>[];
5970
6059
 
5971
6060
  /**
5972
6061
  * Get any array of selected paragraphs from a content model
@@ -5986,7 +6075,7 @@ export function getSelectedSegments(model: ContentModelDocument, includingFormat
5986
6075
  * @param model The Content Model to get selection from
5987
6076
  * @param includingFormatHolder True means also include format holder as segment from list item, in that case paragraph will be null
5988
6077
  */
5989
- export function getSelectedSegmentsAndParagraphs(model: ContentModelDocument, includingFormatHolder: boolean): [ContentModelSegment, ContentModelParagraph | null][];
6078
+ export function getSelectedSegmentsAndParagraphs(model: ContentModelDocument, includingFormatHolder: boolean, includingEntity?: boolean): [ContentModelSegment, ContentModelParagraph | null, ContentModelBlockGroup[]][];
5990
6079
 
5991
6080
  /**
5992
6081
  * Get selection coordinates of a table. If there is no selection, return null
@@ -6156,7 +6245,7 @@ export function updateListMetadata(list: ContentModelWithDataset<ListMetadataFor
6156
6245
  /**
6157
6246
  * Metadata definition for List
6158
6247
  */
6159
- export const ListMetadataDefinition: import("roosterjs-content-model-types").ObjectDefinition<ListMetadataFormat>;
6248
+ export const ListMetadataDefinition: ObjectDefinition<ListMetadataFormat>;
6160
6249
 
6161
6250
  /**
6162
6251
  * Possible change sources. Here are the predefined sources.
@@ -6216,6 +6305,10 @@ export const ChangeSource: {
6216
6305
  * Data of this event will be the key code number
6217
6306
  */
6218
6307
  Keyboard: string;
6308
+ /**
6309
+ * Content changed by auto format
6310
+ */
6311
+ AutoFormat: string;
6219
6312
  };
6220
6313
 
6221
6314
  /**
@@ -6619,6 +6712,11 @@ export class Editor implements IEditor {
6619
6712
  * combined with root selector together to build a separate rule.
6620
6713
  */
6621
6714
  setEditorStyle(key: string, cssRule: string | null, subSelectors?: 'before' | 'after' | string[]): void;
6715
+ /**
6716
+ * Announce the given data
6717
+ * @param announceData Data to announce
6718
+ */
6719
+ announce(announceData: AnnounceData): void;
6622
6720
  /**
6623
6721
  * @returns the current EditorCore object
6624
6722
  * @throws a standard Error if there's no core object
@@ -7062,8 +7160,9 @@ export function formatSegmentWithContentModel(editor: IEditor, apiName: string,
7062
7160
  * Invoke a callback to format the text segment before the selection marker using Content Model
7063
7161
  * @param editor The editor object
7064
7162
  * @param callback The callback to format the text segment.
7163
+ * @returns True if the segment before cursor is found and callback is called, otherwise false
7065
7164
  */
7066
- export function formatTextSegmentBeforeSelectionMarker(editor: IEditor, callback: (model: ContentModelDocument, previousSegment: ContentModelText, paragraph: ContentModelParagraph, markerFormat: ContentModelSegmentFormat, context: FormatContentModelContext) => boolean): void;
7165
+ export function formatTextSegmentBeforeSelectionMarker(editor: IEditor, callback: (model: ContentModelDocument, previousSegment: ContentModelText, paragraph: ContentModelParagraph, markerFormat: ContentModelSegmentFormat, context: FormatContentModelContext) => boolean, options?: FormatContentModelOptions): boolean;
7067
7166
 
7068
7167
  /**
7069
7168
  * Set a list type to content model
@@ -7092,7 +7191,7 @@ export function setModelListStartNumber(model: ContentModelDocument, value: numb
7092
7191
  * @param currentItem The current list item
7093
7192
  * Search for all list items in the same thread as the current list item
7094
7193
  */
7095
- export function findListItemsInSameThread(model: ContentModelDocument, currentItem: ContentModelListItem): ContentModelListItem[];
7194
+ export function findListItemsInSameThread(group: ContentModelBlockGroup, currentItem: ContentModelListItem): ContentModelListItem[];
7096
7195
 
7097
7196
  /**
7098
7197
  * @param model The content model to set indentation
@@ -7100,7 +7199,7 @@ export function findListItemsInSameThread(model: ContentModelDocument, currentIt
7100
7199
  * @param length The length of indentation in pixel, default value is 40
7101
7200
  * Set indentation for selected list items or paragraphs
7102
7201
  */
7103
- export function setModelIndentation(model: ContentModelDocument, indentation: 'indent' | 'outdent', length?: number): boolean;
7202
+ export function setModelIndentation(model: ContentModelDocument, indentation: 'indent' | 'outdent', length?: number, context?: FormatContentModelContext): boolean;
7104
7203
 
7105
7204
  /**
7106
7205
  * Try to match a given string with link match rules, return matched link
@@ -7114,11 +7213,19 @@ export function setModelIndentation(model: ContentModelDocument, indentation: 'i
7114
7213
  */
7115
7214
  export function matchLink(url: string): LinkData | null;
7116
7215
 
7216
+ /**
7217
+ * Get announce data for list item
7218
+ * @param path Content model path that include the list item
7219
+ * @returns Announce data of current list item if any, or null
7220
+ */
7221
+ export function getListAnnounceData(path: ContentModelBlockGroup[]): AnnounceData | null;
7222
+
7117
7223
  /**
7118
7224
  * TableEdit plugin, provides the ability to resize a table by drag-and-drop
7119
7225
  */
7120
7226
  export class TableEditPlugin implements EditorPlugin {
7121
7227
  private anchorContainerSelector?;
7228
+ private onTableEditorCreated?;
7122
7229
  private editor;
7123
7230
  private onMouseMoveDisposer;
7124
7231
  private tableRectMap;
@@ -7128,8 +7235,9 @@ export class TableEditPlugin implements EditorPlugin {
7128
7235
  * @param anchorContainerSelector An optional selector string to specify the container to host the plugin.
7129
7236
  * The container must not be affected by transform: scale(), otherwise the position calculation will be wrong.
7130
7237
  * If not specified, the plugin will be inserted in document.body
7238
+ * @param onTableEditorCreated An optional callback to customize the Table Editors elements when created.
7131
7239
  */
7132
- constructor(anchorContainerSelector?: string | undefined);
7240
+ constructor(anchorContainerSelector?: string | undefined, onTableEditorCreated?: OnTableEditorCreatedCallback | undefined);
7133
7241
  /**
7134
7242
  * Get a friendly name of this plugin
7135
7243
  */
@@ -7161,6 +7269,11 @@ export class TableEditPlugin implements EditorPlugin {
7161
7269
  private ensureTableRects;
7162
7270
  }
7163
7271
 
7272
+ /**
7273
+ * Optional callback when creating a TableEditPlugin, allows to customize the Selectors element as required.
7274
+ */
7275
+ export type OnTableEditorCreatedCallback = (editorType: 'HorizontalTableInserter' | 'VerticalTableInserter' | 'TableMover' | 'TableResizer', element: HTMLElement) => () => void;
7276
+
7164
7277
  /**
7165
7278
  * Paste plugin, handles BeforePaste event and reformat some special content, including:
7166
7279
  * 1. Content copied from Word
@@ -7256,6 +7369,8 @@ export class AutoFormatPlugin implements EditorPlugin {
7256
7369
  * - autoLink: A boolean that enables or disables automatic hyperlink creation when pasting or typing content. Defaults to false.
7257
7370
  * - autoUnlink: A boolean that enables or disables automatic hyperlink removal when pressing backspace. Defaults to false.
7258
7371
  * - autoHyphen: A boolean that enables or disables automatic hyphen transformation. Defaults to false.
7372
+ * - autoFraction: A boolean that enables or disables automatic fraction transformation. Defaults to false.
7373
+ * - autoOrdinals: A boolean that enables or disables automatic ordinal number transformation. Defaults to false.
7259
7374
  */
7260
7375
  constructor(options?: AutoFormatOptions);
7261
7376
  /**
@@ -7294,23 +7409,31 @@ export type AutoFormatOptions = {
7294
7409
  /**
7295
7410
  * When true, after type *, ->, -, --, => , —, > and space key a type of bullet list will be triggered. @default true
7296
7411
  */
7297
- autoBullet: boolean;
7412
+ autoBullet?: boolean;
7298
7413
  /**
7299
7414
  * When true, after type 1, A, a, i, I followed by ., ), - or between () and space key a type of numbering list will be triggered. @default true
7300
7415
  */
7301
- autoNumbering: boolean;
7416
+ autoNumbering?: boolean;
7302
7417
  /**
7303
7418
  * When press backspace before a link, remove the hyperlink
7304
7419
  */
7305
- autoUnlink: boolean;
7420
+ autoUnlink?: boolean;
7306
7421
  /**
7307
7422
  * When paste content, create hyperlink for the pasted link
7308
7423
  */
7309
- autoLink: boolean;
7424
+ autoLink?: boolean;
7310
7425
  /**
7311
7426
  * Transform -- into hyphen, if typed between two words
7312
7427
  */
7313
- autoHyphen: boolean;
7428
+ autoHyphen?: boolean;
7429
+ /**
7430
+ * Transform 1/2, 1/4, 3/4 into fraction character
7431
+ */
7432
+ autoFraction?: boolean;
7433
+ /**
7434
+ * Transform ordinal numbers into superscript
7435
+ */
7436
+ autoOrdinals?: boolean;
7314
7437
  };
7315
7438
 
7316
7439
  /**
@@ -7363,6 +7486,14 @@ export const ShortcutUndo2: ShortcutCommand;
7363
7486
  export const ShortcutRedo: ShortcutCommand;
7364
7487
 
7365
7488
  /**
7489
+ * Shortcut command for Redo 3
7490
+ * Windows: Ctrl + Shift + Z
7491
+ * MacOS: Meta + Shift + Z
7492
+ */
7493
+ export const ShortcutRedoAlt: ShortcutCommand;
7494
+
7495
+ /**
7496
+ * @deprecated
7366
7497
  * Shortcut command for Redo 2
7367
7498
  * Windows: N/A
7368
7499
  * MacOS: Meta + Shift + Z
@@ -7726,6 +7857,261 @@ export class HyperlinkPlugin implements EditorPlugin {
7726
7857
  */
7727
7858
  export type HyperlinkToolTip = string | null | ((url: string, anchor: HTMLAnchorElement) => string);
7728
7859
 
7860
+ /**
7861
+ * PickerPlugin represents a plugin of editor which can handle picker related behaviors, including
7862
+ * - Show picker when special trigger key is pressed
7863
+ * - Hide picker
7864
+ * - Change selection in picker by Up/Down/Left/Right
7865
+ * - Apply selected item in picker
7866
+ *
7867
+ * PickerPlugin doesn't provide any UI, it just wraps related DOM events and invoke callback functions.
7868
+ */
7869
+ export class PickerPlugin implements EditorPlugin {
7870
+ private triggerCharacter;
7871
+ private readonly handler;
7872
+ private isMac;
7873
+ private lastQueryString;
7874
+ private helper;
7875
+ /**
7876
+ * Construct a new instance of PickerPlugin class
7877
+ * @param triggerCharacter The character to trigger a picker to be shown
7878
+ * @param handler Picker handler for receiving picker state change events
7879
+ */
7880
+ constructor(triggerCharacter: string, handler: PickerHandler);
7881
+ /**
7882
+ * Get a friendly name
7883
+ */
7884
+ getName(): string;
7885
+ /**
7886
+ * Initialize this plugin. This should only be called from Editor
7887
+ * @param editor Editor instance
7888
+ */
7889
+ initialize(editor: IEditor): void;
7890
+ /**
7891
+ * Dispose this plugin
7892
+ */
7893
+ dispose(): void;
7894
+ /**
7895
+ * Check if the plugin should handle the given event exclusively.
7896
+ * Handle an event exclusively means other plugin will not receive this event in
7897
+ * onPluginEvent method.
7898
+ * If two plugins will return true in willHandleEventExclusively() for the same event,
7899
+ * the final result depends on the order of the plugins are added into editor
7900
+ * @param event The event to check
7901
+ */
7902
+ willHandleEventExclusively(event: PluginEvent): boolean;
7903
+ /**
7904
+ * Handle events triggered from editor
7905
+ * @param event PluginEvent object
7906
+ */
7907
+ onPluginEvent(event: PluginEvent): void;
7908
+ private onSuggestingKeyDown;
7909
+ private onSuggestingInput;
7910
+ private onInput;
7911
+ }
7912
+
7913
+ /**
7914
+ * Represents the interface of picker plugin, provides necessary utility functions for pickers
7915
+ */
7916
+ export interface PickerHelper {
7917
+ /**
7918
+ * The editor instance
7919
+ */
7920
+ readonly editor: IEditor;
7921
+ /**
7922
+ * Replace the query string with a given Content Model.
7923
+ * This is used for commit a change from picker and insert the committed content into editor.
7924
+ * @param model The Content Model to insert
7925
+ * @param options Options for formatting content model
7926
+ * @param canUndoByBackspace Whether this change can be undone using Backspace key
7927
+ */
7928
+ replaceQueryString: (model: ContentModelDocument, options?: FormatContentModelOptions, canUndoByBackspace?: boolean) => void;
7929
+ /**
7930
+ * Notify Picker Plugin that picker is closed from the handler code, so picker plugin can quit the suggesting state
7931
+ */
7932
+ closePicker: () => void;
7933
+ }
7934
+
7935
+ /**
7936
+ * Change mode that PickerPlugin will pass to child class
7937
+ */
7938
+ export type PickerSelectionChangMode = /**
7939
+ * When user press Right ("horizontal" mode or "both" mode) (Left in RTL) or Down ("vertical" mode),
7940
+ * select the next option
7941
+ */
7942
+ 'next'
7943
+ /**
7944
+ * When user press Left ("horizontal" mode or "both" mode) (Right in RTL) or Up ("vertical" mode),
7945
+ * select the previous option
7946
+ */
7947
+ | 'previous'
7948
+ /**
7949
+ * When user press Down ("both" mode),
7950
+ * select the next row
7951
+ */
7952
+ | 'nextRow'
7953
+ /**
7954
+ * When user press Up ("both" mode),
7955
+ * select the previous row
7956
+ */
7957
+ | 'previousRow'
7958
+ /**
7959
+ * When user press PageDown,
7960
+ * switch to next page
7961
+ */
7962
+ | 'nextPage'
7963
+ /**
7964
+ * When user press PageUp,
7965
+ * switch to previous page
7966
+ */
7967
+ | 'previousPage'
7968
+ /**
7969
+ * When user press Home,
7970
+ * Select the first item in current row
7971
+ */
7972
+ | 'firstInRow'
7973
+ /**
7974
+ * When user press End,
7975
+ * Select the last item in current row
7976
+ */
7977
+ | 'lastInRow'
7978
+ /**
7979
+ * When user press CTRL (or META on Mac) + Home,
7980
+ * Select the very first item
7981
+ */
7982
+ | 'first'
7983
+ /**
7984
+ * When user press CTRL (or META on Mac) + End,
7985
+ * Select the very last item
7986
+ */
7987
+ | 'last';
7988
+
7989
+ /**
7990
+ * Direction option for picker
7991
+ */
7992
+ export type PickerDirection = /**
7993
+ * Show options horizontally
7994
+ */
7995
+ 'horizontal'
7996
+ /**
7997
+ * Show options vertically
7998
+ */
7999
+ | 'vertical'
8000
+ /**
8001
+ * Show options in both direction (2-D picker)
8002
+ */
8003
+ | 'both';
8004
+
8005
+ /**
8006
+ * Represents the interface a handler for picker plugin. Developer need to implement this interface to create a new type of picker
8007
+ */
8008
+ export interface PickerHandler {
8009
+ /**
8010
+ * Initialize the picker handler, pass in editor and PickerPlugin instance so that the handler can save them
8011
+ * @param editor The editor instance
8012
+ * @param pickerPlugin The PickerPlugin instance
8013
+ */
8014
+ onInitialize: (helper: PickerHelper) => void;
8015
+ /**
8016
+ * Dispose the picker handler
8017
+ */
8018
+ onDispose: () => void;
8019
+ /**
8020
+ * Notify the picker handler that user has typed trigger character so handler should show picker now
8021
+ * @param queryString Current query string
8022
+ * @param insertPoint Insert point where user is typing, can be used for calculating picker position
8023
+ * @returns A picker direction to let picker plugin know what kind of picker is opened. Picker plugin will use this value
8024
+ * to decide how to handle keyboard event to change selection. Return null means picker is not actually opened
8025
+ */
8026
+ onTrigger: (queryString: string, insertPoint: DOMInsertPoint) => PickerDirection | null;
8027
+ /**
8028
+ * Notify the picker handler that picker should be closed now
8029
+ */
8030
+ onClosePicker?(): void;
8031
+ /**
8032
+ * Notify the picker handler that user has changed current typed query string
8033
+ */
8034
+ onQueryStringChanged?(queryString: string): void;
8035
+ /**
8036
+ * Notify the picker handler that user has decide to select the current option in picker
8037
+ */
8038
+ onSelect?(): void;
8039
+ /**
8040
+ * Notify the picker handler that user is using keyboard to change current selection
8041
+ * @param mode The moving mode. Handler code can use this value to decide which item need to be selected
8042
+ */
8043
+ onSelectionChanged?(mode: PickerSelectionChangMode): void;
8044
+ }
8045
+
8046
+ /**
8047
+ * CustomReplacePlugin is a plugin that allows you to replace a string with another string in the editor.
8048
+ */
8049
+ export class CustomReplacePlugin implements EditorPlugin {
8050
+ private customReplacements;
8051
+ private editor;
8052
+ private triggerKeys;
8053
+ /**
8054
+ * @param customReplacements Custom replacement rules.
8055
+ * Ex: [{ stringToReplace: ':)', replacementString: '🙂', replacementHandler: replaceEmojis }]
8056
+ */
8057
+ constructor(customReplacements: CustomReplace[]);
8058
+ /**
8059
+ * Get name of this plugin
8060
+ */
8061
+ getName(): string;
8062
+ /**
8063
+ * The first method that editor will call to a plugin when editor is initializing.
8064
+ * It will pass in the editor instance, plugin should take this chance to save the
8065
+ * editor reference so that it can call to any editor method or format API later.
8066
+ * @param editor The editor object
8067
+ */
8068
+ initialize(editor: IEditor): void;
8069
+ /**
8070
+ * The last method that editor will call to a plugin before it is disposed.
8071
+ * Plugin can take this chance to clear the reference to editor. After this method is
8072
+ * called, plugin should not call to any editor method since it will result in error.
8073
+ */
8074
+ dispose(): void;
8075
+ /**
8076
+ * Core method for a plugin. Once an event happens in editor, editor will call this
8077
+ * method of each plugin to handle the event as long as the event is not handled
8078
+ * exclusively by another plugin.
8079
+ * @param event The event to handle:
8080
+ */
8081
+ onPluginEvent(event: PluginEvent): void;
8082
+ private handleEditorInputEvent;
8083
+ }
8084
+
8085
+ /**
8086
+ * The CustomReplace interface defines a custom replacement that can be used in CustomReplacePlugin.
8087
+ */
8088
+ export interface CustomReplace {
8089
+ /**
8090
+ * The string to replace in the editor.
8091
+ */
8092
+ stringToReplace: string;
8093
+ /**
8094
+ * The string to replace with.
8095
+ */
8096
+ replacementString: string;
8097
+ /**
8098
+ * The handler to replace the string.
8099
+ * @param previousSegment The text segment to replace.
8100
+ * @param stringToReplace The string to replace.
8101
+ * @param replacementString The string to replace with.
8102
+ * @param paragraph The paragraph that contains the text segment.
8103
+ * @returns True if the string is replaced successfully, otherwise false.
8104
+ */
8105
+ replacementHandler: (previousSegment: ContentModelText, stringToReplace: string, replacementString: string, paragraph?: ContentModelParagraph) => boolean;
8106
+ }
8107
+
8108
+ /**
8109
+ * Get bounding rect of the given DOM insert point
8110
+ * @param doc The document object
8111
+ * @param pos The input DOM insert point
8112
+ */
8113
+ export function getDOMInsertPointRect(doc: Document, pos: DOMInsertPoint): Rect | null;
8114
+
7729
8115
  /**
7730
8116
  * Get dark mode color for a given color
7731
8117
  * @param color The color to calculate from