moving editorFunc to Editor.jsx

This commit is contained in:
arpitnath 2023-10-27 03:26:02 +05:30
parent 601cb74f53
commit c0e991720f
5 changed files with 1627 additions and 3435 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,7 @@ import React from 'react';
import config from 'config';
import { RoomProvider } from '@y-presence/react';
import Spinner from '@/_ui/Spinner';
import { EditorFunc } from '@/Editor'; //!Update: EditorFunc to Editor.jsx
import { Editor } from '@/Editor';
const Y = require('yjs');
const psl = require('psl');
const { WebsocketProvider } = require('y-websocket');
@ -65,7 +65,7 @@ export const RealtimeEditor = (props) => {
return (
<RoomProvider awareness={provider.awareness} initialPresence={initialPresence}>
<EditorFunc provider={provider} ymap={ydoc.getMap('appDef')} {...props} />
<Editor provider={provider} ymap={ydoc.getMap('appDef')} {...props} />
</RoomProvider>
);
};

View file

@ -2,4 +2,3 @@
export * from './Editor';
export * from './Viewer';
export * from './DataSourceManager';
export * from './EditorFunc';

View file

@ -1471,6 +1471,35 @@ export const cloneComponents = (
});
};
// const getAllChildComponents = (allComponents, parentId) => {
// const childComponents = [];
// Object.keys(allComponents).forEach((componentId) => {
// const componentParentId = allComponents[componentId].component?.parent;
// const isParentTabORCalendar =
// allComponents[parentId]?.component?.component === 'Tabs' ||
// allComponents[parentId]?.component?.component === 'Calendar';
// if (componentParentId && isParentTabORCalendar) {
// const childComponent = allComponents[componentId];
// const childTabId = componentParentId.split('-').at(-1);
// if (componentParentId === `${parentId}-${childTabId}`) {
// childComponent.componentId = componentId;
// childComponents.push(childComponent);
// }
// }
// if (componentParentId === parentId) {
// const childComponent = allComponents[componentId];
// childComponent.componentId = componentId;
// childComponents.push(childComponent);
// }
// });
// return childComponents;
// };
const getAllChildComponents = (allComponents, parentId) => {
const childComponents = [];
@ -1487,6 +1516,10 @@ const getAllChildComponents = (allComponents, parentId) => {
if (componentParentId === `${parentId}-${childTabId}`) {
childComponent.componentId = componentId;
childComponents.push(childComponent);
// Recursively find children of the current child component
const childrenOfChild = getAllChildComponents(allComponents, componentId);
childComponents.push(...childrenOfChild);
}
}
@ -1494,6 +1527,10 @@ const getAllChildComponents = (allComponents, parentId) => {
const childComponent = allComponents[componentId];
childComponent.componentId = componentId;
childComponents.push(childComponent);
// Recursively find children of the current child component
const childrenOfChild = getAllChildComponents(allComponents, componentId);
childComponents.push(...childrenOfChild);
}
});
@ -1598,6 +1635,8 @@ export const addComponents = (
};
finalComponents[newComponentId] = newComponent;
// const doesComponentHaveChildren = getAllChildComponents
});
if (currentPageId === pageId) {