@@ -5,35 +5,28 @@ import '@harbour-enterprises/superdoc/style.css';
55import { useEffect , useRef } from 'react' ;
66
77interface Props {
8- documentId : string ,
9- initialData : File | null ,
10- documentType ?: string ,
11- readOnly ?: boolean ,
12- onEditorReady : ( editor : { superdoc : SuperDoc } ) => void ;
8+ initialData : File | null ,
9+ readOnly ?: boolean ,
1310}
1411
1512const DocumentEditor = ( {
16- documentId,
17- documentType = 'docx' ,
1813 initialData = null ,
1914 readOnly = false ,
20- onEditorReady
2115} : Props ) => {
2216 const editorRef = useRef < SuperDoc > ( null ) ;
2317 useEffect ( ( ) => {
2418 const config : Config = {
2519 selector : '#superdoc' ,
26- toolbar : 'superdoc-toolbar' ,
20+ toolbar : '#superdoc-toolbar' ,
21+ document : initialData , // URL, File or document config
2722 documentMode : readOnly ? 'viewing' : 'editing' ,
28- onReady : ( activeSuperDoc : SuperDoc ) => {
29- const superEditor = activeSuperDoc . activeEditor ;
30- console . debug ( 'SuperDoc editor is ready' , superEditor ) ;
23+ pagination : true ,
24+ rulers : true ,
25+ onReady : ( event ) => {
26+ console . log ( 'SuperDoc is ready' , event ) ;
3127 } ,
32- onEditorCreate : ( editor : Editor ) => {
33- console . log ( 'Editor created' , editor ) ;
34- } ,
35- onEditorDestroy : ( ) => {
36- console . log ( 'Editor destroyed' ) ;
28+ onEditorCreate : ( event ) => {
29+ console . log ( 'Editor is created' , event ) ;
3730 } ,
3831 } ;
3932
@@ -46,7 +39,7 @@ const DocumentEditor = ({
4639 editorRef . current = null ;
4740 }
4841 } ;
49- } , [ documentId , documentType , initialData , readOnly , onEditorReady ] ) ;
42+ } , [ initialData , readOnly ] ) ;
5043
5144 return (
5245 < div className = "document-editor" >
@@ -64,6 +57,8 @@ const DocumentEditor = ({
6457 border-bottom: 1px solid #eee;
6558 }
6659 .editor {
60+ display: flex;
61+ justify-content: center;
6762 flex: 1 1 auto;
6863 overflow: auto;
6964 }
0 commit comments