diff --git a/editors/demo/src/Editoria/Editoria.js b/editors/demo/src/Editoria/Editoria.js index 6a3bd45c78957e27de39b01cbb7f8202e6fd72f5..d78339fb32b49056d8f4c1095f253c99d6e457ee 100644 --- a/editors/demo/src/Editoria/Editoria.js +++ b/editors/demo/src/Editoria/Editoria.js @@ -77,9 +77,9 @@ const Editoria = () => { // readonly layout={layout} name={myName} - // onChange={debounce(source => { - // console.log(JSON.stringify(source)); - // }, 200)} + onChange={debounce(source => { + console.log(JSON.stringify(source)); + }, 200)} user={user} scrollMargin={200} scrollThreshold={200} diff --git a/editors/demo/src/Editors.js b/editors/demo/src/Editors.js index 9227cb24d058f05235db4ac16201367105dbd3d8..02c1e2bd0d8523adee16c870bfcf727ade1e0919 100644 --- a/editors/demo/src/Editors.js +++ b/editors/demo/src/Editors.js @@ -91,7 +91,7 @@ const Editors = () => { case 'oen': return <OEN />; default: - return <HHMI />; + return <Editoria />; } }; diff --git a/wax-prosemirror-core/src/config/defaultServices/LayoutService/components/LayoutFactory.js b/wax-prosemirror-core/src/config/defaultServices/LayoutService/components/LayoutFactory.js index b7011ad965fc495abcabbd8afdbc71280b2e2c8e..9e43e79f3d5bb119a119a2ef37a03ec03f2f2e53 100644 --- a/wax-prosemirror-core/src/config/defaultServices/LayoutService/components/LayoutFactory.js +++ b/wax-prosemirror-core/src/config/defaultServices/LayoutService/components/LayoutFactory.js @@ -1,4 +1,4 @@ /* eslint-disable react/jsx-props-no-spreading */ import React from 'react'; -export default Component => props => <Component {...props} />; +export default Component => props => Component; diff --git a/wax-prosemirror-core/src/useWaxView.js b/wax-prosemirror-core/src/useWaxView.js index 42f187b37c5df83a1fd363dc41cbeed86ab38e2f..d3ee0c30e32cf4eb47b20428eff399dccdf0b376 100644 --- a/wax-prosemirror-core/src/useWaxView.js +++ b/wax-prosemirror-core/src/useWaxView.js @@ -1,6 +1,6 @@ /* eslint-disable consistent-return */ /* eslint-disable react/prop-types */ -import { useContext, useEffect, useImperativeHandle } from 'react'; +import { useContext, useEffect, useImperativeHandle, useState } from 'react'; import { EditorState } from 'prosemirror-state'; import { EditorView } from 'prosemirror-view'; import trackedTransaction from './utilities/track-changes/trackedTransaction'; @@ -11,7 +11,7 @@ import helpers from './helpers/helpers'; import './styles/styles.css'; let previousDoc; -let view; + const useWaxView = props => { const { browserSpellCheck, @@ -24,19 +24,21 @@ const useWaxView = props => { serializer, scrollMargin, scrollThreshold, + onChange, } = props; - const context = useContext(WaxContext); + const [WaxView, setWaxView] = useState(null); const { createPortal } = useContext(PortalContext); context.app.setContext({ ...context, createPortal }); const schema = context.app.getSchema(); - + let view; useEffect(() => { context.app.bootServices(); context.app.getShortCuts(); context.app.getRules(); + console.log('all props', props); const options = WaxOptions({ ...props, schema, @@ -57,12 +59,15 @@ const useWaxView = props => { }, }); + setWaxView(view); + context.updateView( { main: view, }, 'main', ); + setTimeout(() => { if (autoFocus && view) { view.focus(); @@ -96,7 +101,7 @@ const useWaxView = props => { const docContent = targetFormat === 'JSON' ? state.doc.toJSON() : state.doc.content; if (!previousDoc.eq(view.state.doc) || tr.getMeta('forceUpdate')) - props.onChange(docContent); + if (onChange) onChange(docContent); /* when a transaction comes from a view other than main don't keep updating the view ,as this is @@ -114,7 +119,7 @@ const useWaxView = props => { } }; - return view; + return WaxView; }; export default useWaxView;