-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
17 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
14
packages/editor-sample/src/App/InspectorDrawer/StylesPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } } })} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters