Merged in bugfix/add-hook-to-webapp (pull request #76)

fix: add custom hook useEditor to webapp package

* fix: add custom hook useEditor to webapp package
This commit is contained in:
Clément CREUSAT 2023-11-24 18:39:11 +00:00 committed by Paulo Veiga
parent 7434277373
commit 7a4b5212d9

View File

@ -16,7 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import Editor, { EditorOptions } from '@wisemapping/editor'; import Editor, { useEditor, EditorOptions } from '@wisemapping/editor';
import { import {
EditorRenderMode, EditorRenderMode,
PersistenceManager, PersistenceManager,
@ -173,6 +173,12 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => {
} }
}, [mapInfo?.getTitle()]); }, [mapInfo?.getTitle()]);
const editor = useEditor({
mapInfo,
options,
persistenceManager: persistence,
});
return loadCompleted ? ( return loadCompleted ? (
<IntlProvider <IntlProvider
locale={userLocale.code} locale={userLocale.code}
@ -181,10 +187,8 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => {
> >
<ClientHealthSentinel /> <ClientHealthSentinel />
<Editor <Editor
editor={editor}
onAction={setActiveDialog} onAction={setActiveDialog}
options={options}
persistenceManager={persistence}
mapInfo={mapInfo}
theme={theme} theme={theme}
accountConfiguration={ accountConfiguration={
// Prevent load on non-authenticated. // Prevent load on non-authenticated.