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 () => {
177177<ReactEditorJS onInitialize = { handleInitialize } defaultValue = { blocks } />
178178```
179179
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+
180203### Haven't received data from server (when use Link)
181204
182205You 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 {
2121 } )
2222 }
2323
24+ public get dangerouslyLowLevelInstance ( ) {
25+ return this . _editorJS
26+ }
27+
2428 public async clear ( ) {
2529 await this . _editorJS . clear ( )
2630 }
Original file line number Diff line number Diff line change @@ -8,4 +8,6 @@ export interface EditorCore {
88 save ( ) : Promise < OutputData >
99
1010 render ( data : OutputData ) : Promise < void >
11+
12+ get dangerouslyLowLevelInstance ( ) : any | null
1113}
Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ export class TestEditorCore implements EditorCore {
1111 return this . _data
1212 }
1313
14+ public get dangerouslyLowLevelInstance ( ) {
15+ return null
16+ }
17+
1418 public async clear ( ) { }
1519
1620 public async save ( ) {
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ export class ServerEditorCore implements EditorCore {
1010 }
1111 }
1212
13+ public get dangerouslyLowLevelInstance ( ) {
14+ return null
15+ }
16+
1317 public async clear ( ) { }
1418
1519 public async save ( ) {
You can’t perform that action at this time.
0 commit comments