Compare commits
5 Commits
9916afc768
...
7e0b57c2e4
Author | SHA1 | Date |
---|---|---|
jordi fita mas | 7e0b57c2e4 | |
jordi fita mas | fadb56f06b | |
jordi fita mas | 6fa048cf62 | |
jordi fita mas | e39ee28b9f | |
jordi fita mas | b6665b67ba |
|
@ -1,37 +1,27 @@
|
||||||
import { useSelect, useDispatch } from '@wordpress/data';
|
import { useSelect } from '@wordpress/data';
|
||||||
import { useEffect } from '@wordpress/element';
|
import { InterfaceSkeleton, FullscreenMode, ComplementaryArea } from '@wordpress/interface';
|
||||||
import { InterfaceSkeleton, FullscreenMode, ComplementaryArea, store as interfaceStore } from '@wordpress/interface';
|
|
||||||
import { BlockBreadcrumb, BlockCanvas, store as blockEditorStore } from '@wordpress/block-editor';
|
import { BlockBreadcrumb, BlockCanvas, store as blockEditorStore } from '@wordpress/block-editor';
|
||||||
|
|
||||||
|
import Header from './Header';
|
||||||
import Sidebar from './Sidebar';
|
import Sidebar from './Sidebar';
|
||||||
|
import { scope } from './constants';
|
||||||
|
|
||||||
export default function BlockEditor() {
|
export default function BlockEditor() {
|
||||||
const { styles, sidebarIsOpen, hasBlockSelected } = useSelect(( select ) => {
|
const { styles } = useSelect(( select ) => {
|
||||||
const { getSettings, getBlockSelectionStart } = select( blockEditorStore );
|
const { getSettings, getBlockSelectionStart } = select( blockEditorStore );
|
||||||
const { getActiveComplementaryArea } = select( interfaceStore );
|
|
||||||
return {
|
return {
|
||||||
styles: getSettings().styles,
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<FullscreenMode isActive={ true } />
|
<FullscreenMode isActive={ true } />
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
<InterfaceSkeleton
|
<InterfaceSkeleton
|
||||||
|
header={ <Header /> }
|
||||||
content={ <BlockCanvas height="100%" styles={styles} /> }
|
content={ <BlockCanvas height="100%" styles={styles} /> }
|
||||||
sidebar={ sidebarIsOpen && <ComplementaryArea.Slot scope="tipus/editor" /> }
|
sidebar={ <ComplementaryArea.Slot scope={ scope } /> }
|
||||||
footer={ <BlockBreadcrumb /> }
|
footer={ <BlockBreadcrumb /> }
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
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,13 +1,19 @@
|
||||||
import { useSelect } from '@wordpress/data';
|
import { useSelect } from '@wordpress/data';
|
||||||
import { ComplementaryArea, store as interfaceStore } from '@wordpress/interface';
|
import { useEffect } from '@wordpress/element';
|
||||||
|
import { ComplementaryArea } from '@wordpress/interface';
|
||||||
import { Panel } from '@wordpress/components';
|
import { Panel } from '@wordpress/components';
|
||||||
import { BlockInspector } from '@wordpress/block-editor';
|
import { BlockInspector } from '@wordpress/block-editor';
|
||||||
|
import { drawerRight } from '@wordpress/icons';
|
||||||
|
|
||||||
|
import { scope } from './constants';
|
||||||
|
|
||||||
export default function Sidebar () {
|
export default function Sidebar () {
|
||||||
return (
|
return (
|
||||||
<ComplementaryArea
|
<ComplementaryArea
|
||||||
scope="tipus/editor"
|
scope={ scope }
|
||||||
identifier="edit-post/block"
|
identifier="tipus/block"
|
||||||
|
isActiveByDefault={ true }
|
||||||
|
icon={ drawerRight }
|
||||||
>
|
>
|
||||||
<Panel>
|
<Panel>
|
||||||
<BlockInspector />
|
<BlockInspector />
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
export const scope = 'tipus/editor';
|
|
@ -15,3 +15,19 @@ main {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
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,6 +15,7 @@
|
||||||
"@wordpress/data": "^10.0.0",
|
"@wordpress/data": "^10.0.0",
|
||||||
"@wordpress/element": "6.0.0",
|
"@wordpress/element": "6.0.0",
|
||||||
"@wordpress/format-library": "5.0.0",
|
"@wordpress/format-library": "5.0.0",
|
||||||
|
"@wordpress/icons": "10.0.0",
|
||||||
"@wordpress/interface": "6.0.0"
|
"@wordpress/interface": "6.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
"@wordpress/data": "^10.0.0",
|
"@wordpress/data": "^10.0.0",
|
||||||
"@wordpress/element": "6.0.0",
|
"@wordpress/element": "6.0.0",
|
||||||
"@wordpress/format-library": "5.0.0",
|
"@wordpress/format-library": "5.0.0",
|
||||||
|
"@wordpress/icons": "10.0.0",
|
||||||
"@wordpress/interface": "6.0.0"
|
"@wordpress/interface": "6.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
Loading…
Reference in New Issue