File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ interface SidebarTabComponent {
2626interface EditorViewProps {
2727 onUpdate ?: ( pageContent : PageContentWithNavigation ) => void ;
2828 initialUrl : string ;
29+ initialContent ?: PageContentWithNavigation ;
2930 disableUrlField ?: boolean ;
3031 componentsConfig ?: {
3132 middleTop ?: React . ElementType ;
@@ -36,11 +37,11 @@ interface EditorViewProps {
3637 } ;
3738}
3839
39- const EditorView = ( { componentsConfig = { } } : EditorViewProps ) => {
40+ const EditorView = ( { componentsConfig = { } , initialContent } : EditorViewProps ) => {
4041 const store = useMainEditorStore ( ) ;
4142 const { manipulateOverlayMode, disableMode} = store ;
4243
43- useMainEditorInitialize ( ) ;
44+ useMainEditorInitialize ( initialContent ) ;
4445
4546 // Disable insert mode on any MouseUp event
4647 // Maybe should be attached to body
Original file line number Diff line number Diff line change 1+ import * as React from 'react' ;
12import { usePostMessageAPIListener } from '../../common/postMessage' ;
3+ import { PageContentWithNavigation } from '../../models' ;
24
35import { useMainEditorStore } from './useMainEditorStore' ;
46import { usePostMessageEvents } from './usePostMessageEvents' ;
57
6- const useMainEditorInitialize = ( ) => {
8+ const useMainEditorInitialize = ( initialContent ?: PageContentWithNavigation ) => {
79 const { requestPostMessage} = usePostMessageEvents ( ) ;
810 const {
911 initialize,
@@ -22,11 +24,20 @@ const useMainEditorInitialize = () => {
2224 ( ) => {
2325 initialize ( ) ;
2426 requestPostMessage ( 'GET_SUPPORTED_BLOCKS' , { } ) ;
25- requestPostMessage ( 'GET_INITIAL_CONTENT' , { } ) ;
27+
28+ if ( ! initialContent ) {
29+ requestPostMessage ( 'GET_INITIAL_CONTENT' , { } ) ;
30+ }
2631 } ,
2732 [ requestPostMessage ] ,
2833 ) ;
2934
35+ React . useEffect ( ( ) => {
36+ if ( initialContent ) {
37+ setContent ( initialContent ) ;
38+ }
39+ } , [ initialContent ] ) ;
40+
3041 usePostMessageAPIListener ( 'ON_INITIAL_CONTENT' , ( data ) => {
3142 setContent ( data ) ;
3243 } ) ;
You can’t perform that action at this time.
0 commit comments