Compare commits
No commits in common. "7e0b57c2e44d1c8d1007113a016f9323346d7b13" and "9916afc768e8272a075125f071bbf5a246159b46" have entirely different histories.
7e0b57c2e4
...
9916afc768
|
@ -1,27 +1,37 @@
|
|||
import { useSelect } from '@wordpress/data';
|
||||
import { InterfaceSkeleton, FullscreenMode, ComplementaryArea } from '@wordpress/interface';
|
||||
import { useSelect, useDispatch } from '@wordpress/data';
|
||||
import { useEffect } from '@wordpress/element';
|
||||
import { InterfaceSkeleton, FullscreenMode, ComplementaryArea, store as interfaceStore } from '@wordpress/interface';
|
||||
import { BlockBreadcrumb, BlockCanvas, store as blockEditorStore } from '@wordpress/block-editor';
|
||||
|
||||
import Header from './Header';
|
||||
import Sidebar from './Sidebar';
|
||||
import { scope } from './constants';
|
||||
|
||||
export default function BlockEditor() {
|
||||
const { styles } = useSelect(( select ) => {
|
||||
const { styles, sidebarIsOpen, hasBlockSelected } = useSelect(( select ) => {
|
||||
const { getSettings, getBlockSelectionStart } = select( blockEditorStore );
|
||||
const { getActiveComplementaryArea } = select( interfaceStore );
|
||||
return {
|
||||
styles: getSettings().styles,
|
||||
hasBlockSelected: !!getBlockSelectionStart(),
|
||||
sidebarIsOpen: !!getActiveComplementaryArea( 'tipus/editor' )
|
||||
};
|
||||
}, []);
|
||||
|
||||
const { enableComplementaryArea, disableComplementaryArea } = useDispatch( interfaceStore );
|
||||
useEffect(() => {
|
||||
if (hasBlockSelected) {
|
||||
enableComplementaryArea( 'tipus/editor', 'edit-post/block' );
|
||||
} else {
|
||||
disableComplementaryArea( 'tipus/editor' );
|
||||
}
|
||||
}, [ hasBlockSelected ]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<FullscreenMode isActive={ true } />
|
||||
<Sidebar />
|
||||
<InterfaceSkeleton
|
||||
header={ <Header /> }
|
||||
content={ <BlockCanvas height="100%" styles={styles} /> }
|
||||
sidebar={ <ComplementaryArea.Slot scope={ scope } /> }
|
||||
sidebar={ sidebarIsOpen && <ComplementaryArea.Slot scope="tipus/editor" /> }
|
||||
footer={ <BlockBreadcrumb /> }
|
||||
/>
|
||||
</>
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
import { PinnedItems } from '@wordpress/interface';
|
||||
|
||||
import { scope } from './constants';
|
||||
|
||||
export default function Header() {
|
||||
return (
|
||||
<div className="tipus-header">
|
||||
<div>
|
||||
</div>
|
||||
<div className="tipus-header__settings">
|
||||
<PinnedItems.Slot scope={ scope } />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -1,19 +1,13 @@
|
|||
import { useSelect } from '@wordpress/data';
|
||||
import { useEffect } from '@wordpress/element';
|
||||
import { ComplementaryArea } from '@wordpress/interface';
|
||||
import { ComplementaryArea, store as interfaceStore } from '@wordpress/interface';
|
||||
import { Panel } from '@wordpress/components';
|
||||
import { BlockInspector } from '@wordpress/block-editor';
|
||||
import { drawerRight } from '@wordpress/icons';
|
||||
|
||||
import { scope } from './constants';
|
||||
|
||||
export default function Sidebar () {
|
||||
return (
|
||||
<ComplementaryArea
|
||||
scope={ scope }
|
||||
identifier="tipus/block"
|
||||
isActiveByDefault={ true }
|
||||
icon={ drawerRight }
|
||||
scope="tipus/editor"
|
||||
identifier="edit-post/block"
|
||||
>
|
||||
<Panel>
|
||||
<BlockInspector />
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export const scope = 'tipus/editor';
|
|
@ -15,19 +15,3 @@ main {
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.tipus-header {
|
||||
height: 3.75rem;
|
||||
background: white;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
max-width: 100vw;
|
||||
}
|
||||
|
||||
.tipus-header__settings {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: .5rem;
|
||||
padding-right: .5rem;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
"@wordpress/data": "^10.0.0",
|
||||
"@wordpress/element": "6.0.0",
|
||||
"@wordpress/format-library": "5.0.0",
|
||||
"@wordpress/icons": "10.0.0",
|
||||
"@wordpress/interface": "6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
"@wordpress/data": "^10.0.0",
|
||||
"@wordpress/element": "6.0.0",
|
||||
"@wordpress/format-library": "5.0.0",
|
||||
"@wordpress/icons": "10.0.0",
|
||||
"@wordpress/interface": "6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Reference in New Issue