File tree Expand file tree Collapse file tree 5 files changed +37
-0
lines changed
packages/@react-editor-js Expand file tree Collapse file tree 5 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,29 @@ const handleSave = React.useCallback(async () => {
177
177
<ReactEditorJS onInitialize = { handleInitialize } defaultValue = { blocks } />
178
178
```
179
179
180
+ If you want to access low-level instance, you can use ` dangerouslyLowLevelInstance `
181
+
182
+ ⚠️ dangerouslyLowLevelInstance depends on the execution environment.
183
+
184
+ | Environment | Instnace Type |
185
+ | - | - |
186
+ | Browser | EditorJS instance|
187
+ | NodeJS | null |
188
+
189
+ ``` tsx
190
+ const editorCore = React .useRef (null )
191
+
192
+ const handleInitialize = React .useCallback ((instance ) => {
193
+ editorCore .current = instance
194
+ }, [])
195
+
196
+ const handleSave = React .useCallback (async () => {
197
+ const savedData = await editorCore .current .dangerouslyLowLevelInstance ?.save ();
198
+ }, [])
199
+
200
+ <ReactEditorJS onInitialize = { handleInitialize } defaultValue = { blocks } />
201
+ ```
202
+
180
203
### Haven't received data from server (when use Link)
181
204
182
205
You should set linkTool [ config] ( https://github.com/editor-js/link#usage ) . 💪🏻
Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ export class ClientEditorCore implements EditorCore {
21
21
} )
22
22
}
23
23
24
+ public get dangerouslyLowLevelInstance ( ) {
25
+ return this . _editorJS
26
+ }
27
+
24
28
public async clear ( ) {
25
29
await this . _editorJS . clear ( )
26
30
}
Original file line number Diff line number Diff line change @@ -8,4 +8,6 @@ export interface EditorCore {
8
8
save ( ) : Promise < OutputData >
9
9
10
10
render ( data : OutputData ) : Promise < void >
11
+
12
+ get dangerouslyLowLevelInstance ( ) : any | null
11
13
}
Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ export class TestEditorCore implements EditorCore {
11
11
return this . _data
12
12
}
13
13
14
+ public get dangerouslyLowLevelInstance ( ) {
15
+ return null
16
+ }
17
+
14
18
public async clear ( ) { }
15
19
16
20
public async save ( ) {
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ export class ServerEditorCore implements EditorCore {
10
10
}
11
11
}
12
12
13
+ public get dangerouslyLowLevelInstance ( ) {
14
+ return null
15
+ }
16
+
13
17
public async clear ( ) { }
14
18
15
19
public async save ( ) {
You can’t perform that action at this time.
0 commit comments