-
Notifications
You must be signed in to change notification settings - Fork 146
/
EditorOptions.ts
154 lines (133 loc) · 5.48 KB
/
EditorOptions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import type CorePlugins from './CorePlugins';
import type DarkColorHandler from './DarkColorHandler';
import type DefaultFormat from './DefaultFormat';
import type EditorPlugin from './EditorPlugin';
import type Rect from './Rect';
import type Snapshot from './Snapshot';
import type UndoSnapshotsService from './UndoSnapshotsService';
import type { CoreApiMap } from './EditorCore';
import type { ExperimentalFeatures } from '../enum/ExperimentalFeatures';
import type { SizeTransformer } from '../type/SizeTransformer';
import type { TrustedHTMLHandler } from '../type/TrustedHTMLHandler';
import type { CompatibleExperimentalFeatures } from '../compatibleEnum/ExperimentalFeatures';
/**
* The options to specify parameters customizing an editor, used by ctor of Editor class
*/
export default interface EditorOptions {
/**
* List of plugins.
* The order of plugins here determines in what order each event will be dispatched.
* Plugins not appear in this list will not be added to editor, including built-in plugins.
* Default value is empty array.
*/
plugins?: EditorPlugin[];
/**
* Default format of editor content. This will be applied to empty content.
* If there is already content inside editor, format of existing content will not be changed.
* Default value is the computed style of editor content DIV
*/
defaultFormat?: DefaultFormat;
/**
* @deprecated Use undoMetadataSnapshotService instead
* Undo snapshot service. Use this parameter to customize the undo snapshot service.
*/
undoSnapshotService?: UndoSnapshotsService<string>;
/**
* Undo snapshot service based on content metadata. Use this parameter to customize the undo snapshot service.
* When this property is set, value of undoSnapshotService will be ignored.
*/
undoMetadataSnapshotService?: UndoSnapshotsService<Snapshot>;
/**
* Initial HTML content
* Default value is whatever already inside the editor content DIV
*/
initialContent?: string;
/**
* A function map to override default core API implementation
* Default value is null
*/
coreApiOverride?: Partial<CoreApiMap>;
/**
* A plugin map to override default core Plugin implementation
* Default value is null
*/
corePluginOverride?: Partial<CorePlugins>;
/**
* If the editor is currently in dark mode
*/
inDarkMode?: boolean;
/**
* @deprecated
* RoosterJS provides an experimental "external content handler" that transforms text
* This is used when content is pasted or inserted via a method we can hook into.
* This transform is currently "lossy" and will eliminate color information.
* If you want to change this behavior, you may define a different function here.
* It takes in the impacted HTMLElement
*/
onExternalContentTransform?: (
element: HTMLElement,
fromDarkMode: boolean,
toDarkMode: boolean,
darkColorHandler: DarkColorHandler
) => void;
/**
* A util function to transform light mode color to dark mode color
* Default value is to return the original light color
*/
getDarkColor?: (lightColor: string) => string;
/**
* Whether to skip the adjust editor process when for light/dark mode
*/
doNotAdjustEditorColor?: boolean;
/**
* The scroll container to get scroll event from.
* By default, the scroll container will be the same with editor content DIV
*/
scrollContainer?: HTMLElement;
/**
* Specify the enabled experimental features
*/
experimentalFeatures?: (ExperimentalFeatures | CompatibleExperimentalFeatures)[];
/**
* By default, we will stop propagation of a printable keyboard event
* (a keyboard event which is caused by printable char input).
* Set this option to true to override this behavior in case you still need the event
* to be handled by ancestor nodes of editor.
*/
allowKeyboardEventPropagation?: boolean;
/**
* Allowed custom content type when paste besides text/plain, text/html and images
* Only text types are supported, and do not add "text/" prefix to the type values
*/
allowedCustomPasteType?: string[];
/**
* Customized trusted type handler used for sanitizing HTML string before assign to DOM tree
* This is required when trusted-type Content-Security-Policy (CSP) is enabled.
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
*/
trustedHTMLHandler?: TrustedHTMLHandler;
/**
* Current zoom scale, @default value is 1
* When editor is put under a zoomed container, need to pass the zoom scale number using this property
* to let editor behave correctly especially for those mouse drag/drop behaviors
*/
zoomScale?: number;
/**
* @deprecated Use zoomScale instead
*/
sizeTransformer?: SizeTransformer;
/**
* Retrieves the visible viewport of the Editor. The default viewport is the Rect of the scrollContainer.
*/
getVisibleViewport?: () => Rect | null;
/**
* Color of the border of a selectedImage. Default color: '#DB626C'
*/
imageSelectionBorderColor?: string;
/**
* A callback to be invoked when any exception is thrown during disposing editor
* @param plugin The plugin that causes exception
* @param error The error object we got
*/
disposeErrorHandler?: (plugin: EditorPlugin, error: Error) => void;
}