roosterjs 8.6.1 → 8.10.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/README.md +1 -1
- package/dist/rooster-amd-min.js +1 -1
- package/dist/rooster-amd-min.js.map +1 -1
- package/dist/rooster-amd.d.ts +468 -34
- package/dist/rooster-amd.js +1757 -881
- 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 +472 -38
- package/dist/rooster.js +1757 -881
- package/dist/rooster.js.map +1 -1
- package/lib/createEditor.js +2 -4
- package/lib/createEditor.js.map +1 -1
- package/lib-amd/createEditor.js +2 -2
- package/lib-amd/createEditor.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 8.
|
|
1
|
+
// Type definitions for roosterjs (Version 8.10.0)
|
|
2
2
|
// Generated by dts tool from roosterjs
|
|
3
3
|
// Project: https://github.com/Microsoft/roosterjs
|
|
4
4
|
|
|
@@ -61,7 +61,8 @@ interface BrowserInfo {
|
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Command strings for Document.execCommand() API
|
|
64
|
-
* https
|
|
64
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
|
|
65
|
+
*/
|
|
65
66
|
const enum DocumentCommand {
|
|
66
67
|
/**
|
|
67
68
|
* Changes the browser auto-link behavior (Internet Explorer only)
|
|
@@ -276,7 +277,8 @@ const enum DocumentCommand {
|
|
|
276
277
|
|
|
277
278
|
/**
|
|
278
279
|
* The is essentially an enum representing result from browser compareDocumentPosition API
|
|
279
|
-
* https
|
|
280
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
|
|
281
|
+
*/
|
|
280
282
|
const enum DocumentPosition {
|
|
281
283
|
/**
|
|
282
284
|
* Same node
|
|
@@ -304,12 +306,29 @@ const enum DocumentPosition {
|
|
|
304
306
|
ContainedBy = 16
|
|
305
307
|
}
|
|
306
308
|
|
|
307
|
-
/**
|
|
309
|
+
/**
|
|
310
|
+
* The link preview pasted info provided by Edge
|
|
311
|
+
*/
|
|
308
312
|
interface EdgeLinkPreview {
|
|
313
|
+
/**
|
|
314
|
+
* Domain of the source page
|
|
315
|
+
*/
|
|
309
316
|
domain: string;
|
|
317
|
+
/**
|
|
318
|
+
* Preferred paste format
|
|
319
|
+
*/
|
|
310
320
|
preferred_format: string;
|
|
321
|
+
/**
|
|
322
|
+
* Title of the source page
|
|
323
|
+
*/
|
|
311
324
|
title: string;
|
|
325
|
+
/**
|
|
326
|
+
* Type of the paste content
|
|
327
|
+
*/
|
|
312
328
|
type: string;
|
|
329
|
+
/**
|
|
330
|
+
* Url of the source page
|
|
331
|
+
*/
|
|
313
332
|
url: string;
|
|
314
333
|
}
|
|
315
334
|
|
|
@@ -349,7 +368,8 @@ const enum Keys {
|
|
|
349
368
|
|
|
350
369
|
/**
|
|
351
370
|
* The is essentially an enum represents the type of the node
|
|
352
|
-
* https
|
|
371
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
|
372
|
+
* Values not listed here are deprecated.
|
|
353
373
|
*/
|
|
354
374
|
const enum NodeType {
|
|
355
375
|
/**
|
|
@@ -637,7 +657,17 @@ const enum EntityOperation {
|
|
|
637
657
|
* This event will provide a cloned DOM tree for each entity, do NOT compare the DOM nodes with cached nodes
|
|
638
658
|
* because it will always return false.
|
|
639
659
|
*/
|
|
640
|
-
ReplaceTemporaryContent = 8
|
|
660
|
+
ReplaceTemporaryContent = 8,
|
|
661
|
+
/**
|
|
662
|
+
* Notify plugins that editor has attached shadow root for an entity.
|
|
663
|
+
* Plugins can handle this event to do extra operations to the shadow root
|
|
664
|
+
*/
|
|
665
|
+
AddShadowRoot = 9,
|
|
666
|
+
/**
|
|
667
|
+
* Notify plugins that editor has removed the shadow root of an entity
|
|
668
|
+
* Plugins can handle this event to do any necessary clean up for shadow root
|
|
669
|
+
*/
|
|
670
|
+
RemoveShadowRoot = 10
|
|
641
671
|
}
|
|
642
672
|
|
|
643
673
|
/**
|
|
@@ -679,7 +709,15 @@ const enum ExperimentalFeatures {
|
|
|
679
709
|
/**
|
|
680
710
|
* Crop an inline image (requires ImageEdit plugin)
|
|
681
711
|
*/
|
|
682
|
-
ImageCrop = "ImageCrop"
|
|
712
|
+
ImageCrop = "ImageCrop",
|
|
713
|
+
/**
|
|
714
|
+
* Check if the element has a style attribute, if not, apply the default format
|
|
715
|
+
*/
|
|
716
|
+
AlwaysApplyDefaultFormat = "AlwaysApplyDefaultFormat",
|
|
717
|
+
/**
|
|
718
|
+
* Paste the Html instead of the Img when the Html Body only have one IMG Child node
|
|
719
|
+
*/
|
|
720
|
+
ConvertSingleImageBody = "ConvertSingleImageBody"
|
|
683
721
|
}
|
|
684
722
|
|
|
685
723
|
/**
|
|
@@ -890,7 +928,43 @@ const enum TableOperation {
|
|
|
890
928
|
/**
|
|
891
929
|
* Split current table cell vertically
|
|
892
930
|
*/
|
|
893
|
-
SplitVertically = 12
|
|
931
|
+
SplitVertically = 12,
|
|
932
|
+
/**
|
|
933
|
+
* Align current table at the center
|
|
934
|
+
*/
|
|
935
|
+
AlignCenter = 13,
|
|
936
|
+
/**
|
|
937
|
+
* Align current table at the left
|
|
938
|
+
*/
|
|
939
|
+
AlignLeft = 14,
|
|
940
|
+
/**
|
|
941
|
+
* Align current table at the right
|
|
942
|
+
*/
|
|
943
|
+
AlignRight = 15,
|
|
944
|
+
/**
|
|
945
|
+
* Align current content table cell at the left
|
|
946
|
+
*/
|
|
947
|
+
AlignCellLeft = 16,
|
|
948
|
+
/**
|
|
949
|
+
* Align current content table cell at the center
|
|
950
|
+
*/
|
|
951
|
+
AlignCellCenter = 17,
|
|
952
|
+
/**
|
|
953
|
+
* Align current content table cell at the right
|
|
954
|
+
*/
|
|
955
|
+
AlignCellRight = 18,
|
|
956
|
+
/**
|
|
957
|
+
* Align current content table cell at the top
|
|
958
|
+
*/
|
|
959
|
+
AlignCellTop = 19,
|
|
960
|
+
/**
|
|
961
|
+
* Align current table cell at the middle
|
|
962
|
+
*/
|
|
963
|
+
AlignCellMiddle = 20,
|
|
964
|
+
/**
|
|
965
|
+
* Align current table cell at the bottom
|
|
966
|
+
*/
|
|
967
|
+
AlignCellBottom = 21
|
|
894
968
|
}
|
|
895
969
|
|
|
896
970
|
/**
|
|
@@ -931,6 +1005,65 @@ const enum ImageEditOperation {
|
|
|
931
1005
|
All = 15
|
|
932
1006
|
}
|
|
933
1007
|
|
|
1008
|
+
/**
|
|
1009
|
+
* Represents the strategy to clear the format of the current editor selection
|
|
1010
|
+
*/
|
|
1011
|
+
const enum ClearFormatMode {
|
|
1012
|
+
/**
|
|
1013
|
+
* Inline format. Remove text format.
|
|
1014
|
+
*/
|
|
1015
|
+
Inline = 0,
|
|
1016
|
+
/**
|
|
1017
|
+
* BLock format. Remove text and structure format of the block.
|
|
1018
|
+
*/
|
|
1019
|
+
Block = 1,
|
|
1020
|
+
/**
|
|
1021
|
+
* Detect Inline or Block format based on the current editor selectior.
|
|
1022
|
+
*/
|
|
1023
|
+
AutoDetect = 2
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
/**
|
|
1027
|
+
* Index of known CreateElementData used by createElement function
|
|
1028
|
+
*/
|
|
1029
|
+
const enum KnownCreateElementDataIndex {
|
|
1030
|
+
/**
|
|
1031
|
+
* Set a none value to help createElement funciton ignore falsy value
|
|
1032
|
+
*/
|
|
1033
|
+
None = 0,
|
|
1034
|
+
/**
|
|
1035
|
+
* An empty line without format
|
|
1036
|
+
*/
|
|
1037
|
+
EmptyLine = 1,
|
|
1038
|
+
/**
|
|
1039
|
+
* Wrapper for blockquote
|
|
1040
|
+
*/
|
|
1041
|
+
BlockquoteWrapper = 2,
|
|
1042
|
+
/**
|
|
1043
|
+
* Temp DIV for copy/paste
|
|
1044
|
+
*/
|
|
1045
|
+
CopyPasteTempDiv = 3,
|
|
1046
|
+
/**
|
|
1047
|
+
* ListItem with block style
|
|
1048
|
+
*/
|
|
1049
|
+
BlockListItem = 4,
|
|
1050
|
+
/**
|
|
1051
|
+
* Wrapper element for context menu
|
|
1052
|
+
*/
|
|
1053
|
+
ContextMenuWrapper = 5,
|
|
1054
|
+
/**
|
|
1055
|
+
* Wrapper element for image edit
|
|
1056
|
+
*/
|
|
1057
|
+
ImageEditWrapper = 6,
|
|
1058
|
+
/**
|
|
1059
|
+
* Table resizers
|
|
1060
|
+
*/
|
|
1061
|
+
TableHorizontalResizer = 7,
|
|
1062
|
+
TableVerticalResizer = 8,
|
|
1063
|
+
TableResizerLTR = 9,
|
|
1064
|
+
TableResizerRTL = 10
|
|
1065
|
+
}
|
|
1066
|
+
|
|
934
1067
|
/**
|
|
935
1068
|
* Provides a chance for plugin to change the content before it is copied from editor.
|
|
936
1069
|
*/
|
|
@@ -1007,6 +1140,17 @@ interface BeforePasteEvent extends BasePluginEvent<PluginEventType.BeforePaste>
|
|
|
1007
1140
|
htmlAttributes: Record<string, string>;
|
|
1008
1141
|
}
|
|
1009
1142
|
|
|
1143
|
+
/**
|
|
1144
|
+
* The event to be triggered before SetContent API is called.
|
|
1145
|
+
* Handle this event to cache anything you need from editor before it is gone.
|
|
1146
|
+
*/
|
|
1147
|
+
interface BeforeSetContentEvent extends BasePluginEvent<PluginEventType.BeforeSetContent> {
|
|
1148
|
+
/**
|
|
1149
|
+
* New content HTML that is about to set to editor
|
|
1150
|
+
*/
|
|
1151
|
+
newContent: string;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1010
1154
|
/**
|
|
1011
1155
|
* Represents a change to the editor made by another plugin
|
|
1012
1156
|
*/
|
|
@@ -1069,6 +1213,18 @@ interface EntityOperationEvent extends BasePluginEvent<PluginEventType.EntityOpe
|
|
|
1069
1213
|
* Optional raw event. Need to do null check before use its value
|
|
1070
1214
|
*/
|
|
1071
1215
|
rawEvent?: Event;
|
|
1216
|
+
/**
|
|
1217
|
+
* A document fragment for entity based on Shadow DOM. This property is only available for NewEntity operation.
|
|
1218
|
+
* Putting DOM nodes under this fragment will cause a shadow root to be attached to the entity wrapper
|
|
1219
|
+
* with these DOM nodes under it.
|
|
1220
|
+
*
|
|
1221
|
+
* If there is already cached DOM nodes, they will also be put under this fragment.
|
|
1222
|
+
* Plugin need to decide:
|
|
1223
|
+
* 1. Apply the cache: do nothing and the DOM nodes will be appended as shadow DOM entity content
|
|
1224
|
+
* 2. Discard the cache and use new content instead: clear the fragment and append new DOM nodes, then new DOM nodes will be used
|
|
1225
|
+
* 3. Dehydrate this entity: clear the fragment, and leave it empty
|
|
1226
|
+
*/
|
|
1227
|
+
contentForShadowEntity?: DocumentFragment;
|
|
1072
1228
|
}
|
|
1073
1229
|
|
|
1074
1230
|
/**
|
|
@@ -1182,7 +1338,7 @@ interface PluginScrollEvent extends PluginDomEventBase<PluginEventType.Scroll, U
|
|
|
1182
1338
|
/**
|
|
1183
1339
|
* Editor plugin event interface
|
|
1184
1340
|
*/
|
|
1185
|
-
type PluginEvent = BeforeCutCopyEvent | BeforePasteEvent | ContentChangedEvent | EntityOperationEvent | ExtractContentWithDomEvent | PluginDomEvent | EditorReadyEvent | BeforeDisposeEvent | PendingFormatStateChangedEvent | EnterShadowEditEvent | LeaveShadowEditEvent | EditImageEvent;
|
|
1341
|
+
type PluginEvent = BeforeCutCopyEvent | BeforePasteEvent | ContentChangedEvent | EntityOperationEvent | ExtractContentWithDomEvent | PluginDomEvent | EditorReadyEvent | BeforeDisposeEvent | PendingFormatStateChangedEvent | EnterShadowEditEvent | LeaveShadowEditEvent | EditImageEvent | BeforeSetContentEvent;
|
|
1186
1342
|
|
|
1187
1343
|
/**
|
|
1188
1344
|
* Editor plugin event type
|
|
@@ -1270,7 +1426,12 @@ const enum PluginEventType {
|
|
|
1270
1426
|
/**
|
|
1271
1427
|
* Content of image is being changed from client side
|
|
1272
1428
|
*/
|
|
1273
|
-
EditImage = 19
|
|
1429
|
+
EditImage = 19,
|
|
1430
|
+
/**
|
|
1431
|
+
* Content of editor is about to be cleared by SetContent API, handle this event to cache anything you need
|
|
1432
|
+
* before it is gone
|
|
1433
|
+
*/
|
|
1434
|
+
BeforeSetContent = 20
|
|
1274
1435
|
}
|
|
1275
1436
|
|
|
1276
1437
|
/**
|
|
@@ -1390,6 +1551,10 @@ interface ClipboardData {
|
|
|
1390
1551
|
* BASE64 encoded data uri of the image if any
|
|
1391
1552
|
*/
|
|
1392
1553
|
imageDataUri?: string;
|
|
1554
|
+
/**
|
|
1555
|
+
* Array of tag names of the first level child nodes
|
|
1556
|
+
*/
|
|
1557
|
+
htmlFirstLevelChildTags?: string[];
|
|
1393
1558
|
/**
|
|
1394
1559
|
* Value of custom paste type. By default it is always empty.
|
|
1395
1560
|
* To allow custom paste type, pass the allowed types to EditorOptions.allowedCustomPasteType
|
|
@@ -1834,7 +1999,10 @@ interface LinkData {
|
|
|
1834
1999
|
normalizedUrl: string;
|
|
1835
2000
|
}
|
|
1836
2001
|
|
|
1837
|
-
|
|
2002
|
+
/**
|
|
2003
|
+
* A color object contains both light mode and dark mode color
|
|
2004
|
+
*/
|
|
2005
|
+
interface ModeIndependentColor {
|
|
1838
2006
|
/**
|
|
1839
2007
|
* The color to be used in dark mode, if enabled.
|
|
1840
2008
|
*/
|
|
@@ -2605,8 +2773,9 @@ interface IEditor {
|
|
|
2605
2773
|
/**
|
|
2606
2774
|
* Run a callback function asynchronously
|
|
2607
2775
|
* @param callback The callback function to run
|
|
2776
|
+
* @returns a function to cancel this async run
|
|
2608
2777
|
*/
|
|
2609
|
-
runAsync(callback: (editor: IEditor) => void): void;
|
|
2778
|
+
runAsync(callback: (editor: IEditor) => void): () => void;
|
|
2610
2779
|
/**
|
|
2611
2780
|
* Set DOM attribute of editor content DIV
|
|
2612
2781
|
* @param name Name of the attribute
|
|
@@ -2635,6 +2804,12 @@ interface IEditor {
|
|
|
2635
2804
|
* Get style based format state from current selection, including font name/size and colors
|
|
2636
2805
|
*/
|
|
2637
2806
|
getStyleBasedFormatState(node?: Node): StyleBasedFormatState;
|
|
2807
|
+
/**
|
|
2808
|
+
* Get the pendable format state from the current selection, incluing formats as underline, bold, italics
|
|
2809
|
+
* @param forceGetStateFromDOM If set to true, will not consider the cached format and will get the format state directly from DOM tree
|
|
2810
|
+
* @return The pending format state of editor.
|
|
2811
|
+
*/
|
|
2812
|
+
getPendableFormatState(forceGetStateFromDOM?: boolean): PendableFormatState;
|
|
2638
2813
|
/**
|
|
2639
2814
|
* Ensure user will type into a container element rather than into the editor content DIV directly
|
|
2640
2815
|
* @param position The position that user is about to type to
|
|
@@ -2673,6 +2848,13 @@ interface IEditor {
|
|
|
2673
2848
|
* @param feature The feature to check
|
|
2674
2849
|
*/
|
|
2675
2850
|
isFeatureEnabled(feature: ExperimentalFeatures): boolean;
|
|
2851
|
+
/**
|
|
2852
|
+
* Get a function to convert HTML string to trusted HTML string.
|
|
2853
|
+
* By default it will just return the input HTML directly. To override this behavior,
|
|
2854
|
+
* pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler
|
|
2855
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
|
|
2856
|
+
*/
|
|
2857
|
+
getTrustedHTMLHandler(): TrustedHTMLHandler;
|
|
2676
2858
|
}
|
|
2677
2859
|
|
|
2678
2860
|
/**
|
|
@@ -2799,6 +2981,7 @@ interface CorePlugins {
|
|
|
2799
2981
|
*/
|
|
2800
2982
|
readonly mouseUp: EditorPlugin;
|
|
2801
2983
|
/**
|
|
2984
|
+
* @deprecated after Firefox update
|
|
2802
2985
|
* TypeAfterLinkPlugin plugin helps workaround a Firefox bug to allow type outside a hyperlink
|
|
2803
2986
|
*/
|
|
2804
2987
|
readonly typeAfterLink: EditorPlugin;
|
|
@@ -2817,17 +3000,17 @@ interface CorePlugins {
|
|
|
2817
3000
|
}
|
|
2818
3001
|
|
|
2819
3002
|
/**
|
|
2820
|
-
*
|
|
3003
|
+
* Names of core plugins
|
|
2821
3004
|
*/
|
|
2822
3005
|
type PluginKey = keyof CorePlugins;
|
|
2823
3006
|
|
|
2824
3007
|
/**
|
|
2825
|
-
*
|
|
3008
|
+
* Names of the core plugins that have plugin state
|
|
2826
3009
|
*/
|
|
2827
3010
|
type KeyOfStatePlugin<Key extends PluginKey> = CorePlugins[Key] extends PluginWithState<infer U> ? Key : never;
|
|
2828
3011
|
|
|
2829
3012
|
/**
|
|
2830
|
-
*
|
|
3013
|
+
* A type map from name of plugin with state to its plugin type
|
|
2831
3014
|
*/
|
|
2832
3015
|
type GenericPluginState<Key extends PluginKey> = {
|
|
2833
3016
|
[P in StatePluginKeys<Key>]: TypeOfStatePlugin<P>;
|
|
@@ -2839,14 +3022,14 @@ type GenericPluginState<Key extends PluginKey> = {
|
|
|
2839
3022
|
type PluginState = GenericPluginState<PluginKey>;
|
|
2840
3023
|
|
|
2841
3024
|
/**
|
|
2842
|
-
*
|
|
3025
|
+
* All names of plugins with plugin state
|
|
2843
3026
|
*/
|
|
2844
3027
|
type StatePluginKeys<Key extends PluginKey> = {
|
|
2845
3028
|
[P in Key]: KeyOfStatePlugin<P>;
|
|
2846
3029
|
}[Key];
|
|
2847
3030
|
|
|
2848
3031
|
/**
|
|
2849
|
-
*
|
|
3032
|
+
* Get type of a plugin with state
|
|
2850
3033
|
*/
|
|
2851
3034
|
type TypeOfStatePlugin<Key extends PluginKey> = CorePlugins[Key] extends PluginWithState<infer U> ? U : never;
|
|
2852
3035
|
|
|
@@ -2866,6 +3049,12 @@ interface EditorCore extends PluginState {
|
|
|
2866
3049
|
* Core API map of this editor
|
|
2867
3050
|
*/
|
|
2868
3051
|
readonly api: CoreApiMap;
|
|
3052
|
+
/**
|
|
3053
|
+
* A handler to convert HTML string to a trust HTML string.
|
|
3054
|
+
* By default it will just return the original HTML string directly.
|
|
3055
|
+
* To override, pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler
|
|
3056
|
+
*/
|
|
3057
|
+
readonly trustedHTMLHandler: TrustedHTMLHandler;
|
|
2869
3058
|
}
|
|
2870
3059
|
|
|
2871
3060
|
/**
|
|
@@ -2885,7 +3074,11 @@ type AddUndoSnapshot = (core: EditorCore, callback: (start: NodePosition, end: N
|
|
|
2885
3074
|
*/
|
|
2886
3075
|
type AttachDomEvent = (core: EditorCore, eventMap: Record<string, DOMEventHandler>) => () => void;
|
|
2887
3076
|
|
|
2888
|
-
|
|
3077
|
+
/**
|
|
3078
|
+
* The interface for the map of core API.
|
|
3079
|
+
* Editor can call call API from this map under EditorCore object
|
|
3080
|
+
*/
|
|
3081
|
+
interface CoreApiMap {
|
|
2889
3082
|
/**
|
|
2890
3083
|
* Call an editing callback with adding undo snapshots around, and trigger a ContentChanged event if change source is specified.
|
|
2891
3084
|
* Undo snapshot will not be added if this call is nested inside another addUndoSnapshot() call.
|
|
@@ -2945,6 +3138,13 @@ type AttachDomEvent = (core: EditorCore, eventMap: Record<string, DOMEventHandle
|
|
|
2945
3138
|
* @param node The node to get style from
|
|
2946
3139
|
*/
|
|
2947
3140
|
getStyleBasedFormatState: GetStyleBasedFormatState;
|
|
3141
|
+
/**
|
|
3142
|
+
* Get the pendable format such as underline and bold
|
|
3143
|
+
* @param core The EditorCore object
|
|
3144
|
+
*@param forceGetStateFromDOM If set to true, will force get the format state from DOM tree.
|
|
3145
|
+
* @return The pending format state of editor.
|
|
3146
|
+
*/
|
|
3147
|
+
getPendableFormatState: GetPendableFormatState;
|
|
2948
3148
|
/**
|
|
2949
3149
|
* Check if the editor has focus now
|
|
2950
3150
|
* @param core The EditorCore object
|
|
@@ -3052,6 +3252,14 @@ type GetSelectionRange = (core: EditorCore, tryGetFromCache: boolean) => Range;
|
|
|
3052
3252
|
*/
|
|
3053
3253
|
type GetStyleBasedFormatState = (core: EditorCore, node: Node) => StyleBasedFormatState;
|
|
3054
3254
|
|
|
3255
|
+
/**
|
|
3256
|
+
* Get the pendable format such as underline and bold
|
|
3257
|
+
* @param core The EditorCore object
|
|
3258
|
+
* @param forceGetStateFromDOM If set to true, will force get the format state from DOM tree.
|
|
3259
|
+
* @return The pending format state of editor.
|
|
3260
|
+
*/
|
|
3261
|
+
type GetPendableFormatState = (core: EditorCore, forceGetStateFromDOM: boolean) => PendableFormatState;
|
|
3262
|
+
|
|
3055
3263
|
/**
|
|
3056
3264
|
* Check if the editor has focus now
|
|
3057
3265
|
* @param core The EditorCore object
|
|
@@ -3196,6 +3404,12 @@ interface EditorOptions {
|
|
|
3196
3404
|
* Only text types are supported, and do not add "text/" prefix to the type values
|
|
3197
3405
|
*/
|
|
3198
3406
|
allowedCustomPasteType?: string[];
|
|
3407
|
+
/**
|
|
3408
|
+
* Customized trusted type handler used for sanitizing HTML string before assign to DOM tree
|
|
3409
|
+
* This is required when trusted-type Content-Security-Policy (CSP) is enabled.
|
|
3410
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
|
|
3411
|
+
*/
|
|
3412
|
+
trustedHTMLHandler?: TrustedHTMLHandler;
|
|
3199
3413
|
}
|
|
3200
3414
|
|
|
3201
3415
|
/**
|
|
@@ -3406,6 +3620,13 @@ interface CustomReplacement {
|
|
|
3406
3620
|
* Whether the matching should be case sensitive
|
|
3407
3621
|
*/
|
|
3408
3622
|
matchSourceCaseSensitive: boolean;
|
|
3623
|
+
/**
|
|
3624
|
+
* A callback to check if the string should be replaced
|
|
3625
|
+
* @param content the content where the string is
|
|
3626
|
+
* @param sourceString string to be replaced
|
|
3627
|
+
* @return true, if the string should be replaced, else return false
|
|
3628
|
+
*/
|
|
3629
|
+
shouldReplace?: (replacement: CustomReplacement, content: string) => boolean;
|
|
3409
3630
|
}
|
|
3410
3631
|
|
|
3411
3632
|
/**
|
|
@@ -3607,12 +3828,48 @@ interface ImageEditOptions {
|
|
|
3607
3828
|
*/
|
|
3608
3829
|
imageSelector?: string;
|
|
3609
3830
|
/**
|
|
3831
|
+
* @deprecated
|
|
3610
3832
|
* HTML for the rotate icon
|
|
3611
3833
|
* @default A predefined SVG icon
|
|
3612
3834
|
*/
|
|
3613
3835
|
rotateIconHTML?: string;
|
|
3614
3836
|
}
|
|
3615
3837
|
|
|
3838
|
+
/**
|
|
3839
|
+
* An interface represents the data for creating element used by createElemnet()
|
|
3840
|
+
*/
|
|
3841
|
+
interface CreateElementData {
|
|
3842
|
+
/**
|
|
3843
|
+
* Tag name of this element.
|
|
3844
|
+
* It can be just a tag, or in format "namespace:tag"
|
|
3845
|
+
*/
|
|
3846
|
+
tag: string;
|
|
3847
|
+
/**
|
|
3848
|
+
* Namespace of this tag
|
|
3849
|
+
*/
|
|
3850
|
+
namespace?: string;
|
|
3851
|
+
/**
|
|
3852
|
+
* CSS class name
|
|
3853
|
+
*/
|
|
3854
|
+
className?: string;
|
|
3855
|
+
/**
|
|
3856
|
+
* CSS style
|
|
3857
|
+
*/
|
|
3858
|
+
style?: string;
|
|
3859
|
+
/**
|
|
3860
|
+
* Dataset of this element
|
|
3861
|
+
*/
|
|
3862
|
+
dataset?: Record<string, string>;
|
|
3863
|
+
/**
|
|
3864
|
+
* Additional attributes of this element
|
|
3865
|
+
*/
|
|
3866
|
+
attributes?: Record<string, string>;
|
|
3867
|
+
/**
|
|
3868
|
+
* Child nodes of this element, can be another CreateElementData, or a string which represents a text node
|
|
3869
|
+
*/
|
|
3870
|
+
children?: (CreateElementData | string)[];
|
|
3871
|
+
}
|
|
3872
|
+
|
|
3616
3873
|
/**
|
|
3617
3874
|
* The state object for DOMEventPlugin
|
|
3618
3875
|
*/
|
|
@@ -3654,9 +3911,10 @@ interface EditPluginState {
|
|
|
3654
3911
|
*/
|
|
3655
3912
|
interface EntityPluginState {
|
|
3656
3913
|
/**
|
|
3914
|
+
* @deprecated
|
|
3657
3915
|
* Last clicking point when mouse down event happens
|
|
3658
3916
|
*/
|
|
3659
|
-
clickingPoint
|
|
3917
|
+
clickingPoint?: {
|
|
3660
3918
|
pageX: number;
|
|
3661
3919
|
pageY: number;
|
|
3662
3920
|
};
|
|
@@ -3664,6 +3922,12 @@ interface EntityPluginState {
|
|
|
3664
3922
|
* All known entity elements
|
|
3665
3923
|
*/
|
|
3666
3924
|
knownEntityElements: HTMLElement[];
|
|
3925
|
+
/**
|
|
3926
|
+
* Cache for the hydrated content of shadow DOM entity.
|
|
3927
|
+
* When set content to replace the whole editor, we will cache the hydrated content
|
|
3928
|
+
* before it is gone, then after that we can use the cached content to rehydrate entity
|
|
3929
|
+
*/
|
|
3930
|
+
shadowEntityCache: Record<string, HTMLElement>;
|
|
3667
3931
|
}
|
|
3668
3932
|
|
|
3669
3933
|
/**
|
|
@@ -3832,6 +4096,11 @@ interface DOMEventHandlerObject {
|
|
|
3832
4096
|
*/
|
|
3833
4097
|
type DOMEventHandler = PluginEventType | DOMEventHandlerFunction | DOMEventHandlerObject;
|
|
3834
4098
|
|
|
4099
|
+
/**
|
|
4100
|
+
* A handler type to convert HTML string to a trust HTML string
|
|
4101
|
+
*/
|
|
4102
|
+
type TrustedHTMLHandler = (html: string) => string;
|
|
4103
|
+
|
|
3835
4104
|
/**
|
|
3836
4105
|
* This produces a block element from a a node
|
|
3837
4106
|
* It needs to account for various HTML structure. Examples:
|
|
@@ -4282,6 +4551,7 @@ function contains(container: Node, contained: Range): boolean;
|
|
|
4282
4551
|
function findClosestElementAncestor(node: Node, root?: Node, selector?: string): HTMLElement;
|
|
4283
4552
|
|
|
4284
4553
|
/**
|
|
4554
|
+
* @deprecated
|
|
4285
4555
|
* Creates an HTML node array from html
|
|
4286
4556
|
* @param html the html string to create HTML elements from
|
|
4287
4557
|
* @param ownerDocument Owner document of the result HTML elements
|
|
@@ -4413,7 +4683,8 @@ function unwrap(node: Node): Node;
|
|
|
4413
4683
|
function wrap<T extends keyof HTMLElementTagNameMap>(nodes: Node | Node[], wrapper?: T): HTMLElementTagNameMap[T];
|
|
4414
4684
|
|
|
4415
4685
|
/**
|
|
4416
|
-
*
|
|
4686
|
+
* @deprecated
|
|
4687
|
+
* Wrap all the nodes with html and return the wrapped node, and put the wrapper node under the parent of the first node
|
|
4417
4688
|
* @param nodes The node or node array to wrap
|
|
4418
4689
|
* @param wrapper The wrapper HTML string, default value is DIV
|
|
4419
4690
|
* @returns The wrapper element
|
|
@@ -4421,13 +4692,20 @@ function wrap<T extends keyof HTMLElementTagNameMap>(nodes: Node | Node[], wrapp
|
|
|
4421
4692
|
function wrap(nodes: Node | Node[], wrapper?: string): HTMLElement;
|
|
4422
4693
|
|
|
4423
4694
|
/**
|
|
4424
|
-
* Wrap all the
|
|
4695
|
+
* Wrap all the nodes with html and return the wrapped node, and put the wrapper node under the parent of the first node
|
|
4425
4696
|
* @param nodes The node or node array to wrap
|
|
4426
4697
|
* @param wrapper The wrapper HTML element, default value is a new DIV element
|
|
4427
4698
|
* @returns The wrapper element
|
|
4428
4699
|
*/
|
|
4429
4700
|
function wrap(nodes: Node | Node[], wrapper?: HTMLElement): HTMLElement;
|
|
4430
4701
|
|
|
4702
|
+
/**
|
|
4703
|
+
* Wrapp all the nodes with CreateElementData or an index of a known CreateElementData
|
|
4704
|
+
* @param nodes The nodes to wrap
|
|
4705
|
+
* @param wrapper The CreateElementData or an index of a known CreateElementData
|
|
4706
|
+
*/
|
|
4707
|
+
function wrap(nodes: Node | Node[], wrapper?: CreateElementData | KnownCreateElementDataIndex): HTMLElement;
|
|
4708
|
+
|
|
4431
4709
|
/**
|
|
4432
4710
|
* This walks forwards DOM tree to get next meaningful node
|
|
4433
4711
|
* @param rootNode Root node to scope the leaf sibling node
|
|
@@ -4531,7 +4809,14 @@ function readFile(file: File, callback: (dataUrl: string) => void): void;
|
|
|
4531
4809
|
*/
|
|
4532
4810
|
function getInnerHTML(node: HTMLElement | DocumentFragment): string;
|
|
4533
4811
|
|
|
4534
|
-
|
|
4812
|
+
/**
|
|
4813
|
+
* Set text color or background color to the given element
|
|
4814
|
+
* @param element The element to set color to
|
|
4815
|
+
* @param color The color to set, it can be a string of color name/value or a ModeIndependentColor object
|
|
4816
|
+
* @param isBackgroundColor Whether set background color or text color
|
|
4817
|
+
* @param isDarkMode Whether current mode is dark mode. @default false
|
|
4818
|
+
*/
|
|
4819
|
+
function setColor(element: HTMLElement, color: string | ModeIndependentColor, isBackgroundColor: boolean, isDarkMode?: boolean): void;
|
|
4535
4820
|
|
|
4536
4821
|
/**
|
|
4537
4822
|
* A wrapper function of Element.matches
|
|
@@ -4540,6 +4825,45 @@ function getInnerHTML(node: HTMLElement | DocumentFragment): string;
|
|
|
4540
4825
|
*/
|
|
4541
4826
|
function matchesSelector(element: Node, selector: string): boolean;
|
|
4542
4827
|
|
|
4828
|
+
/**
|
|
4829
|
+
*
|
|
4830
|
+
* @param root the contentDiv of the ditor
|
|
4831
|
+
* @param nodeToInsert the node to be inserted
|
|
4832
|
+
* @param position the position of the node to be inserted
|
|
4833
|
+
* @param range the range current or cached range of the editor
|
|
4834
|
+
* @returns the adjusted position of the inserted node
|
|
4835
|
+
*/
|
|
4836
|
+
function adjustInsertPosition(root: HTMLElement, nodeToInsert: Node, position: NodePosition, range: Range): NodePosition;
|
|
4837
|
+
|
|
4838
|
+
/**
|
|
4839
|
+
* Create DOM element from the given CreateElementData
|
|
4840
|
+
* @param elementData The CreateElementData or an index of a known CreateElementData used for creating this element
|
|
4841
|
+
* @param document The document to create the element from
|
|
4842
|
+
* @returns The root DOM element just created
|
|
4843
|
+
*/
|
|
4844
|
+
function createElement(elementData: CreateElementData | KnownCreateElementDataIndex, document: Document): Element;
|
|
4845
|
+
|
|
4846
|
+
/**
|
|
4847
|
+
* All known CreateElementData used by roosterjs to create elements
|
|
4848
|
+
*/
|
|
4849
|
+
const KnownCreateElementData: Record<KnownCreateElementDataIndex, CreateElementData>;
|
|
4850
|
+
|
|
4851
|
+
/**
|
|
4852
|
+
* Replace all child nodes of the given target node to the child nodes of source node.
|
|
4853
|
+
* @param target Target node, all child nodes of this node will be removed if keepExistingChildren is not set to true
|
|
4854
|
+
* @param source (Optional) source node, all child nodes of this node will be move to target node
|
|
4855
|
+
* @param keepExistingChildren (Optional) When set to true, all existing child nodes of target will be kept
|
|
4856
|
+
*/
|
|
4857
|
+
function moveChildNodes(target: Node, source?: Node, keepExistingChildren?: boolean): void;
|
|
4858
|
+
|
|
4859
|
+
/**
|
|
4860
|
+
* Set the Style of a List Item provided, with the styles that the inline child elements have
|
|
4861
|
+
* If the child inline elements have different styles, it will not modify the styles of the list item
|
|
4862
|
+
* @param element the LI Element to set the styles
|
|
4863
|
+
* @param styles The styles that should be applied to the element.
|
|
4864
|
+
*/
|
|
4865
|
+
function setListItemStyle(element: HTMLLIElement, styles: string[]): void;
|
|
4866
|
+
|
|
4543
4867
|
/**
|
|
4544
4868
|
* A virtual table class, represent an HTML table, by expand all merged cells to each separated cells
|
|
4545
4869
|
*/
|
|
@@ -4701,6 +5025,12 @@ class VList {
|
|
|
4701
5025
|
* After that, this VList becomes unavailable because we set this.rootList to null
|
|
4702
5026
|
*/
|
|
4703
5027
|
writeBack(): void;
|
|
5028
|
+
/**
|
|
5029
|
+
* Sets the New List Start Property, that is going to be used to create a new List in the WriteBack function
|
|
5030
|
+
* @param separator The HTML element that indicates when to split the VList
|
|
5031
|
+
* @param startNumber The start number of the new List
|
|
5032
|
+
*/
|
|
5033
|
+
split(separator: HTMLElement, startNumber: number): void;
|
|
4704
5034
|
/**
|
|
4705
5035
|
* Set indentation of the given range of this list
|
|
4706
5036
|
* @param start Start position to operate from
|
|
@@ -4746,7 +5076,6 @@ class VList {
|
|
|
4746
5076
|
}
|
|
4747
5077
|
|
|
4748
5078
|
/**
|
|
4749
|
-
* @internal
|
|
4750
5079
|
* !!! Never directly create instance of this class. It should be created within VList class !!!
|
|
4751
5080
|
*
|
|
4752
5081
|
* Represent a list item.
|
|
@@ -4754,12 +5083,12 @@ class VList {
|
|
|
4754
5083
|
* A list item is normally wrapped using a LI tag. But this class is only a logical item,
|
|
4755
5084
|
* it can be a LI tag, or another other type of node which means it is actually not a list item.
|
|
4756
5085
|
* That can happen after we do "outdent" on a 1-level list item, then it becomes not a list item.
|
|
4757
|
-
* @internal
|
|
4758
5086
|
*/
|
|
4759
5087
|
class VListItem {
|
|
4760
5088
|
private listTypes;
|
|
4761
5089
|
private node;
|
|
4762
5090
|
private dummy;
|
|
5091
|
+
private newListStart;
|
|
4763
5092
|
/**
|
|
4764
5093
|
* Construct a new instance of VListItem class
|
|
4765
5094
|
* @param node The DOM node for this item
|
|
@@ -4779,6 +5108,10 @@ class VListItem {
|
|
|
4779
5108
|
* Get DOM node of this list item
|
|
4780
5109
|
*/
|
|
4781
5110
|
getNode(): HTMLLIElement;
|
|
5111
|
+
/**
|
|
5112
|
+
* Get the Start Number of the new List
|
|
5113
|
+
*/
|
|
5114
|
+
getNewListStart(): number | undefined;
|
|
4782
5115
|
/**
|
|
4783
5116
|
* Check if a given node is contained by this list item
|
|
4784
5117
|
* @param node The node to check
|
|
@@ -4822,6 +5155,11 @@ class VListItem {
|
|
|
4822
5155
|
* @param isDummy Whether the item is a dummy item
|
|
4823
5156
|
*/
|
|
4824
5157
|
setIsDummy(isDummy: boolean): void;
|
|
5158
|
+
/**
|
|
5159
|
+
* Set the start Number of the new list
|
|
5160
|
+
* @param isDummy Whether the item is a dummy item
|
|
5161
|
+
*/
|
|
5162
|
+
setNewListStart(startNumber: number): void;
|
|
4825
5163
|
/**
|
|
4826
5164
|
* Write the change result back into DOM
|
|
4827
5165
|
* @param listStack current stack of list elements
|
|
@@ -4831,7 +5169,7 @@ class VListItem {
|
|
|
4831
5169
|
}
|
|
4832
5170
|
|
|
4833
5171
|
/**
|
|
4834
|
-
*
|
|
5172
|
+
* Create a VList object from the given region.
|
|
4835
5173
|
* @param region The region to get VList from
|
|
4836
5174
|
* @param includeSiblingLists True to also try get lists before and after the selection and merge them together,
|
|
4837
5175
|
* false to only include the list for the selected blocks
|
|
@@ -5085,7 +5423,7 @@ function getHtmlWithSelectionPath(rootNode: HTMLElement | DocumentFragment, rang
|
|
|
5085
5423
|
* @param html The html to restore
|
|
5086
5424
|
* @returns A selection range if the html contains a valid selection path, otherwise null
|
|
5087
5425
|
*/
|
|
5088
|
-
function setHtmlWithSelectionPath(rootNode: HTMLElement, html: string): Range;
|
|
5426
|
+
function setHtmlWithSelectionPath(rootNode: HTMLElement, html: string, trustedHTMLHandler?: TrustedHTMLHandler): Range;
|
|
5089
5427
|
|
|
5090
5428
|
/**
|
|
5091
5429
|
* Add the given range into selection of the given document
|
|
@@ -5233,7 +5571,7 @@ function createDefaultHtmlSanitizerOptions(): Required<HtmlSanitizerOptions>;
|
|
|
5233
5571
|
* If the same property got multiple callbacks, the final return value will be the return
|
|
5234
5572
|
* value of the latest callback
|
|
5235
5573
|
*/
|
|
5236
|
-
function chainSanitizerCallback<
|
|
5574
|
+
function chainSanitizerCallback<TOriginalArgs extends any[], TChainedFn extends (...args: TOriginalArgs) => R, R>(map: Record<string, (...args: TOriginalArgs) => R>, name: string, newCallback: TChainedFn): void;
|
|
5237
5575
|
|
|
5238
5576
|
/**
|
|
5239
5577
|
* Commit information of an entity (type, isReadonly, id) into the wrapper node as CSS Classes
|
|
@@ -5252,7 +5590,7 @@ function commitEntity(wrapper: HTMLElement, type: string, isReadonly: boolean, i
|
|
|
5252
5590
|
function getEntityFromElement(element: HTMLElement): Entity;
|
|
5253
5591
|
|
|
5254
5592
|
/**
|
|
5255
|
-
*
|
|
5593
|
+
* Get a selector string for specified entity type and id
|
|
5256
5594
|
* @param type (Optional) Type of entity
|
|
5257
5595
|
* @param id (Optional) Id of entity
|
|
5258
5596
|
*/
|
|
@@ -5294,7 +5632,7 @@ function isCharacterValue(event: KeyboardEvent): boolean;
|
|
|
5294
5632
|
* @param event A Keyboard event or Mouse event object
|
|
5295
5633
|
* @returns True if Ctrl key is pressed on Windows or Meta key is pressed on Mac
|
|
5296
5634
|
*/
|
|
5297
|
-
|
|
5635
|
+
function isCtrlOrMetaPressed(event: KeyboardEvent | MouseEvent): boolean;
|
|
5298
5636
|
|
|
5299
5637
|
/**
|
|
5300
5638
|
* Get CSS styles of a given element in name-value pair format
|
|
@@ -5557,8 +5895,9 @@ class Editor implements IEditor {
|
|
|
5557
5895
|
/**
|
|
5558
5896
|
* Run a callback function asynchronously
|
|
5559
5897
|
* @param callback The callback function to run
|
|
5898
|
+
* @returns a function to cancel this async run
|
|
5560
5899
|
*/
|
|
5561
|
-
runAsync(callback: (editor: IEditor) => void): void;
|
|
5900
|
+
runAsync(callback: (editor: IEditor) => void): () => void;
|
|
5562
5901
|
/**
|
|
5563
5902
|
* Set DOM attribute of editor content DIV
|
|
5564
5903
|
* @param name Name of the attribute
|
|
@@ -5587,6 +5926,12 @@ class Editor implements IEditor {
|
|
|
5587
5926
|
* Get style based format state from current selection, including font name/size and colors
|
|
5588
5927
|
*/
|
|
5589
5928
|
getStyleBasedFormatState(node?: Node): StyleBasedFormatState;
|
|
5929
|
+
/**
|
|
5930
|
+
* Get the pendable format such as underline and bold
|
|
5931
|
+
* @param forceGetStateFromDOM If set to true, will force get the format state from DOM tree.
|
|
5932
|
+
* @returns The pending format state
|
|
5933
|
+
*/
|
|
5934
|
+
getPendableFormatState(forceGetStateFromDOM?: boolean): PendableFormatState;
|
|
5590
5935
|
/**
|
|
5591
5936
|
* Ensure user will type into a container element rather than into the editor content DIV directly
|
|
5592
5937
|
* @param position The position that user is about to type to
|
|
@@ -5625,6 +5970,13 @@ class Editor implements IEditor {
|
|
|
5625
5970
|
* @param feature The feature to check
|
|
5626
5971
|
*/
|
|
5627
5972
|
isFeatureEnabled(feature: ExperimentalFeatures): boolean;
|
|
5973
|
+
/**
|
|
5974
|
+
* Get a function to convert HTML string to trusted HTML string.
|
|
5975
|
+
* By default it will just return the input HTML directly. To override this behavior,
|
|
5976
|
+
* pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler
|
|
5977
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
|
|
5978
|
+
*/
|
|
5979
|
+
getTrustedHTMLHandler(): TrustedHTMLHandler;
|
|
5628
5980
|
}
|
|
5629
5981
|
|
|
5630
5982
|
/**
|
|
@@ -5642,8 +5994,7 @@ function changeFontSize(editor: IEditor, change: FontSizeChange, fontSizes?: num
|
|
|
5642
5994
|
const FONT_SIZES: number[];
|
|
5643
5995
|
|
|
5644
5996
|
/**
|
|
5645
|
-
*
|
|
5646
|
-
* When selection is collapsed, only clear format of current block.
|
|
5997
|
+
* @deprecated Use clearFormat instead and pass the ClearFormatMode.Block as parameter
|
|
5647
5998
|
* @param editor The editor instance
|
|
5648
5999
|
*/
|
|
5649
6000
|
function clearBlockFormat(editor: IEditor): void;
|
|
@@ -5653,8 +6004,9 @@ function clearBlockFormat(editor: IEditor): void;
|
|
|
5653
6004
|
* changed to default format. The format that get cleaned include B/I/U/font name/
|
|
5654
6005
|
* font size/text color/background color/align left/align right/align center/superscript/subscript
|
|
5655
6006
|
* @param editor The editor instance
|
|
6007
|
+
* @param formatType type of format to apply
|
|
5656
6008
|
*/
|
|
5657
|
-
function clearFormat(editor: IEditor): void;
|
|
6009
|
+
function clearFormat(editor: IEditor, formatType?: ClearFormatMode): void;
|
|
5658
6010
|
|
|
5659
6011
|
/**
|
|
5660
6012
|
* Insert a hyperlink at cursor.
|
|
@@ -5811,8 +6163,9 @@ function setBackgroundColor(editor: IEditor, color: string | ModeIndependentColo
|
|
|
5811
6163
|
* Currently there's no validation to the string, if the passed string is invalid, it won't take affect
|
|
5812
6164
|
* Alternatively, you can pass a @typedef ModeIndependentColor. If in light mode, the lightModeColor property will be used.
|
|
5813
6165
|
* If in dark mode, the darkModeColor will be used and the lightModeColor will be used when converting back to light mode.
|
|
6166
|
+
* @param shouldApplyInlineStyle Optional callback function to be invoked to verify if the current element should have the inline Style applied
|
|
5814
6167
|
*/
|
|
5815
|
-
function setTextColor(editor: IEditor, color: string | ModeIndependentColor): void;
|
|
6168
|
+
function setTextColor(editor: IEditor, color: string | ModeIndependentColor, shouldApplyInlineStyle?: (element: HTMLElement) => boolean): void;
|
|
5816
6169
|
|
|
5817
6170
|
/**
|
|
5818
6171
|
* Change direction for the blocks/paragraph at selection
|
|
@@ -5843,7 +6196,8 @@ function setFontSize(editor: IEditor, fontSize: string): void;
|
|
|
5843
6196
|
* in selection, do nothing.
|
|
5844
6197
|
* The alt attribute provides alternative information for an image if a user for some reason
|
|
5845
6198
|
* cannot view it (because of slow connection, an error in the src attribute, or if the user
|
|
5846
|
-
* uses a screen reader). See https
|
|
6199
|
+
* uses a screen reader). See https://www.w3schools.com/tags/att_img_alt.asp
|
|
6200
|
+
* @param editor The editor instance
|
|
5847
6201
|
* @param altText The image alt text
|
|
5848
6202
|
*/
|
|
5849
6203
|
function setImageAltText(editor: IEditor, altText: string): void;
|
|
@@ -5909,6 +6263,14 @@ function toggleItalic(editor: IEditor): void;
|
|
|
5909
6263
|
*/
|
|
5910
6264
|
function toggleNumbering(editor: IEditor, startNumber?: number): void;
|
|
5911
6265
|
|
|
6266
|
+
/**
|
|
6267
|
+
* Resets Ordered List Numbering back to the value of the parameter startNumber
|
|
6268
|
+
* @param editor The editor instance
|
|
6269
|
+
* @param separator The HTML element that indicates when to split the VList
|
|
6270
|
+
* @param startNumber The number of that the splitted list should start
|
|
6271
|
+
*/
|
|
6272
|
+
function setOrderedListNumbering(editor: IEditor, separator: HTMLLIElement, startNumber?: number): void;
|
|
6273
|
+
|
|
5912
6274
|
/**
|
|
5913
6275
|
* Toggle blockquote at selection, if selection already contains any blockquote elements,
|
|
5914
6276
|
* the blockquote elements will be unquote and other elements will take no effect
|
|
@@ -5978,6 +6340,30 @@ function toggleUnderline(editor: IEditor): void;
|
|
|
5978
6340
|
*/
|
|
5979
6341
|
function toggleHeader(editor: IEditor, level: number): void;
|
|
5980
6342
|
|
|
6343
|
+
/**
|
|
6344
|
+
* Toggle List Type at selection
|
|
6345
|
+
* If ListType Provided is Ordered:
|
|
6346
|
+
* If selection contains numbering in deep level, toggle numbering will decrease the numbering level by one
|
|
6347
|
+
* If selection contains bullet list, toggle numbering will convert the bullet list into number list
|
|
6348
|
+
* If selection contains both bullet/numbering and normal text, the behavior is decided by corresponding
|
|
6349
|
+
* realization of browser execCommand API
|
|
6350
|
+
* If ListType Provided is Unordered:
|
|
6351
|
+
* If selection contains bullet in deep level, toggle bullet will decrease the bullet level by one
|
|
6352
|
+
* If selection contains number list, toggle bullet will convert the number list into bullet list
|
|
6353
|
+
* If selection contains both bullet/numbering and normal text, the behavior is decided by corresponding
|
|
6354
|
+
* browser execCommand API
|
|
6355
|
+
* @param editor The editor instance
|
|
6356
|
+
* @param listType The list type to toggle
|
|
6357
|
+
* @param startNumber (Optional) Start number of the list
|
|
6358
|
+
* @param includeSiblingLists Sets wether the operation should include Sibling Lists, by default true
|
|
6359
|
+
*/
|
|
6360
|
+
function toggleListType(editor: IEditor, listType: ListType, startNumber?: number, includeSiblingLists?: boolean): void;
|
|
6361
|
+
|
|
6362
|
+
/**
|
|
6363
|
+
* Split selection into regions, and perform a block-wise formatting action for each region.
|
|
6364
|
+
*/
|
|
6365
|
+
function blockFormat(editor: IEditor, callback: (region: Region, start: NodePosition, end: NodePosition, chains: VListChain[]) => void, beforeRunCallback?: () => boolean): void;
|
|
6366
|
+
|
|
5981
6367
|
/**
|
|
5982
6368
|
* Commit changes of all list changes when experiment features are allowed
|
|
5983
6369
|
* @param editor The Editor object
|
|
@@ -6067,9 +6453,27 @@ class ContextMenu<T> implements EditorPlugin {
|
|
|
6067
6453
|
private onDismiss;
|
|
6068
6454
|
}
|
|
6069
6455
|
|
|
6070
|
-
|
|
6456
|
+
/**
|
|
6457
|
+
* Context Menu options for ContextMenu plugin
|
|
6458
|
+
*/
|
|
6459
|
+
interface ContextMenuOptions<T> {
|
|
6460
|
+
/**
|
|
6461
|
+
* Render function for the context menu
|
|
6462
|
+
* @param container The container HTML element, it will be located at the mouse click position,
|
|
6463
|
+
* so the callback just need to render menu content into this container
|
|
6464
|
+
* @param onDismiss The onDismiss callback, some menu render need to know this callback so that
|
|
6465
|
+
* it can handle the dismiss event
|
|
6466
|
+
*/
|
|
6071
6467
|
render: (container: HTMLElement, items: (T | null)[], onDismiss: () => void) => void;
|
|
6468
|
+
/**
|
|
6469
|
+
* Dismiss function for the context menu, it will be called when user wants to dismiss this context menu
|
|
6470
|
+
* e.g. user click away so the menu should be dismissed
|
|
6471
|
+
* @param container The container HTML element
|
|
6472
|
+
*/
|
|
6072
6473
|
dismiss?: (container: HTMLElement) => void;
|
|
6474
|
+
/**
|
|
6475
|
+
* Whether the default context menu is allowed. @default false
|
|
6476
|
+
*/
|
|
6073
6477
|
allowDefaultMenu?: boolean;
|
|
6074
6478
|
}
|
|
6075
6479
|
|
|
@@ -6222,6 +6626,10 @@ class ImageEdit implements EditorPlugin {
|
|
|
6222
6626
|
private editInfo;
|
|
6223
6627
|
private lastSrc;
|
|
6224
6628
|
private dndHelpers;
|
|
6629
|
+
/**
|
|
6630
|
+
* Identify if the image was resized by the user.
|
|
6631
|
+
*/
|
|
6632
|
+
private wasResized;
|
|
6225
6633
|
/**
|
|
6226
6634
|
* Create a new instance of ImageEdit
|
|
6227
6635
|
* @param options Image editing options
|
|
@@ -6328,6 +6736,30 @@ function isResizedTo(image: HTMLImageElement, percentage: number): boolean;
|
|
|
6328
6736
|
*/
|
|
6329
6737
|
function resetImage(editor: IEditor, image: HTMLImageElement): void;
|
|
6330
6738
|
|
|
6739
|
+
/**
|
|
6740
|
+
* @deprecated Use ImageEdit plugin instead
|
|
6741
|
+
*/
|
|
6742
|
+
class ImageResize extends ImageEdit {
|
|
6743
|
+
/**
|
|
6744
|
+
* Create a new instance of ImageResize
|
|
6745
|
+
* @param minWidth Minimum width of image when resize in pixel, default value is 10
|
|
6746
|
+
* @param minHeight Minimum height of image when resize in pixel, default value is 10
|
|
6747
|
+
* @param selectionBorderColor Color of resize border and handles, default value is #DB626C
|
|
6748
|
+
* @param forcePreserveRatio Whether always preserve width/height ratio when resize, default value is false
|
|
6749
|
+
* @param resizableImageSelector Selector for picking which image is resizable (e.g. for all images not placeholders), note
|
|
6750
|
+
* that the tag must be IMG regardless what the selector is
|
|
6751
|
+
*/
|
|
6752
|
+
constructor(minWidth?: number, minHeight?: number, selectionBorderColor?: string, forcePreserveRatio?: boolean, resizableImageSelector?: string);
|
|
6753
|
+
/**
|
|
6754
|
+
* @deprecated
|
|
6755
|
+
*/
|
|
6756
|
+
showResizeHandle(img: HTMLImageElement): void;
|
|
6757
|
+
/**
|
|
6758
|
+
* @deprecated
|
|
6759
|
+
*/
|
|
6760
|
+
hideResizeHandle(selectImageAfterUnSelect?: boolean): void;
|
|
6761
|
+
}
|
|
6762
|
+
|
|
6331
6763
|
/**
|
|
6332
6764
|
* Paste plugin, handles BeforePaste event and reformat some special content, including:
|
|
6333
6765
|
* 1. Content copied from Word
|
|
@@ -6336,6 +6768,7 @@ function resetImage(editor: IEditor, image: HTMLImageElement): void;
|
|
|
6336
6768
|
*/
|
|
6337
6769
|
class Paste implements EditorPlugin {
|
|
6338
6770
|
private unknownTagReplacement;
|
|
6771
|
+
private editor;
|
|
6339
6772
|
/**
|
|
6340
6773
|
* Construct a new instance of Paste class
|
|
6341
6774
|
* @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN
|
|
@@ -6349,7 +6782,7 @@ class Paste implements EditorPlugin {
|
|
|
6349
6782
|
* Initialize this plugin. This should only be called from Editor
|
|
6350
6783
|
* @param editor Editor instance
|
|
6351
6784
|
*/
|
|
6352
|
-
initialize(): void;
|
|
6785
|
+
initialize(editor: IEditor): void;
|
|
6353
6786
|
/**
|
|
6354
6787
|
* Dispose this plugin
|
|
6355
6788
|
*/
|
|
@@ -6370,7 +6803,8 @@ class Paste implements EditorPlugin {
|
|
|
6370
6803
|
*
|
|
6371
6804
|
* PickerPlugin doesn't provide any UI, it just wraps related DOM events and invoke callback functions.
|
|
6372
6805
|
* To show a picker UI, you need to build your own UI component. Please reference to
|
|
6373
|
-
* https
|
|
6806
|
+
* https://github.com/microsoft/roosterjs/tree/master/demo/scripts/controls/samplepicker
|
|
6807
|
+
*/
|
|
6374
6808
|
class PickerPlugin<T extends PickerDataProvider = PickerDataProvider> implements EditorPlugin {
|
|
6375
6809
|
readonly dataProvider: T;
|
|
6376
6810
|
private pickerOptions;
|