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