Skip to content

Commit

Permalink
Fixing build (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
cohitre authored Feb 29, 2024
1 parent d93e317 commit 46e6165
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ jobs:
- run: npx eslint .
- run: npx prettier . --check
- run: npm test
- run: ./node_modules/.bin/tsc --noEmit
14 changes: 8 additions & 6 deletions packages/editor-sample/src/App/InspectorDrawer/StylesPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import React from 'react';

import { TEditorBlock } from '../../documents/editor/core';
import { setEditorState, useDocument } from '../../documents/editor/EditorContext';

import EmailLayoutSidebarPanel from './ConfigurationPanel/input-panels/EmailLayoutSidebarPanel';

export default function StylesPanel() {
const block = useDocument().root;
const document = useDocument();
if (!block) {
return <p>Block not found</p>;
}

const setBlock = (conf: TEditorBlock) =>
setEditorState({
document: { ...document, root: conf },
});
const { data, type } = block;
if (type !== 'EmailLayout') {
throw new Error('Expected "root" element to be of type EmailLayout');
}
return <EmailLayoutSidebarPanel key="root" data={data} setData={(data) => setBlock({ type, data })} />;
return (
<EmailLayoutSidebarPanel
key="root"
data={data}
setData={(data) => setEditorState({ document: { ...document, root: { type, data } } })}
/>
);
}
4 changes: 2 additions & 2 deletions packages/editor-sample/src/App/TemplatePanel/JsonPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useMemo } from 'react';

import { useEditorState } from '../../documents/editor/EditorContext';
import { useDocument } from '../../documents/editor/EditorContext';

import TextEditorPanel from './helper/TextEditorPanel';

export default function JsonPanel() {
const [{ document }] = useEditorState();
const document = useDocument();
const string = useMemo(() => JSON.stringify(document, null, ' '), [document]);
return <TextEditorPanel value={string} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ export default function TuneMenu({ blockId }: Props) {
...block.data,
props: {
...block.data.props,
childrenIds: block.data.props.childrenIds.filter((f) => f !== blockId),
childrenIds: (block.data.props?.childrenIds ?? []).filter((f) => f !== blockId),
},
},
};
break;
case 'ColumnsContainer':
nDocument[id] = {
...block,
type: 'ColumnsContainer',
data: {
...block.data,
style: block.data.style,
props: {
...block.data.props,
columns: block.data.props.columns.map((c) => ({
columns: block.data.props?.columns?.map((c) => ({
childrenIds: c.childrenIds.filter((f) => f !== blockId),
})) as ColumnsContainerProps['props']['columns'],
})),
},
},
} as ColumnsContainerProps,
};
break;
default:
Expand Down

0 comments on commit 46e6165

Please sign in to comment.