Skip to content
Snippets Groups Projects
Commit 8794d470 authored by chris's avatar chris
Browse files

add state context file

parent 0a3af71f
No related branches found
No related tags found
1 merge request!597Use view context
......@@ -50,14 +50,14 @@ const Editoria = () => {
}
const editorRef = useRef();
useEffect(() => {
console.log('sss');
// const configObj = config(yjsProvider, ydoc, 'christos')
setTimeout(() => {
setFirst(false);
}, 5000);
// configObj.services = [...configObj.services, new TablesService()]
}, [isFirst]);
// useEffect(() => {
// console.log('sss');
// // const configObj = config(yjsProvider, ydoc, 'christos')
// setTimeout(() => {
// setFirst(false);
// }, 5000);
// // configObj.services = [...configObj.services, new TablesService()]
// }, [isFirst]);
if (!isFirst) {
// configObj.services = [...configObj.services, new TablesService()]
......
/* eslint react/prop-types: 0 */
/* eslint react/destructuring-assignment: 0 */
import React, { useState } from 'react';
export const StateContext = React.createContext({
state: null,
});
export default props => {
const [context, setContext] = useState({
state: props.state,
});
return (
<StateContext.Provider
value={{
...context,
updateState: state => {
setContext({
...context,
state,
});
},
}}
>
{props.children}
</StateContext.Provider>
);
};
......@@ -61,7 +61,6 @@ const Wax = forwardRef((props, innerViewRef) => {
useEffect(() => {
const newApplication = createApplication(props);
setApplication(newApplication);
console.log(configHash);
const Layout = newApplication.container.get('Layout');
if (layout) Layout.setLayout(layout);
setWaxLayout(Layout.layoutComponent);
......
......@@ -24,9 +24,7 @@ const WaxView = props => {
const initialize = useCallback(() => {
if (divRef.current) {
console.log('div.current , "df');
divRef.current.replaceChildren(main?.dom);
// return node;
}
}, [main]);
......
......@@ -6,7 +6,6 @@ import { WaxContext } from '../WaxContext';
import MenuButton from './ui/MenuButton';
const Button = ({ state, item }) => {
console.log(state, 'button');
const { t, i18n } = useTranslation();
const { active, icon, label, run, select, title } = item;
const context = useContext(WaxContext);
......@@ -20,8 +19,6 @@ const Button = ({ state, item }) => {
return editable;
});
// const { state } = view;
const handleMouseDown = e => {
e.preventDefault();
run(state, activeView.dispatch, activeView, context);
......
......@@ -36,7 +36,7 @@ class Menu {
render() {
return () => {
const context = useContext(StateContext);
console.log(context);
console.log('menu context', context);
const Bar = useMemo(() => (
// eslint-disable-next-line react/no-this-in-sfc
<MenuWrapper items={this.toolGroups} state={context.state} />
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment