Merge pull request #557 from toeverything/feat-mouse-event

feat: enable shape mode
This commit is contained in:
DarkSky
2022-12-17 22:33:18 +08:00
committed by GitHub
@@ -24,6 +24,15 @@ const toolbarList1 = [
icon: <SelectIcon />, icon: <SelectIcon />,
toolTip: 'Select', toolTip: 'Select',
disable: false, disable: false,
callback: () => {
window.dispatchEvent(
new CustomEvent('affine.switch-mouse-mode', {
detail: {
type: 'default',
},
})
);
},
}, },
{ {
flavor: 'text', flavor: 'text',
@@ -34,8 +43,19 @@ const toolbarList1 = [
{ {
flavor: 'shape', flavor: 'shape',
icon: <ShapeIcon />, icon: <ShapeIcon />,
toolTip: 'Shape (coming soon)', toolTip: 'Shape',
disable: true, disable: false,
callback: () => {
window.dispatchEvent(
new CustomEvent('affine.switch-mouse-mode', {
detail: {
type: 'shape',
color: 'black',
shape: 'rectangle',
},
})
);
},
}, },
{ {
flavor: 'sticky', flavor: 'sticky',
@@ -122,20 +142,23 @@ export const EdgelessToolbar = () => {
> >
<StyledEdgelessToolbar> <StyledEdgelessToolbar>
<StyledToolbarWrapper> <StyledToolbarWrapper>
{toolbarList1.map(({ icon, toolTip, flavor, disable }, index) => { {toolbarList1.map(
({ icon, toolTip, flavor, disable, callback }, index) => {
return ( return (
<Tooltip key={index} content={toolTip} placement="right-start"> <Tooltip key={index} content={toolTip} placement="right-start">
<StyledToolbarItem <StyledToolbarItem
disable={disable} disable={disable}
onClick={() => { onClick={() => {
console.log('flavor', flavor); console.log('click toolbar button:', flavor);
callback?.();
}} }}
> >
{icon} {icon}
</StyledToolbarItem> </StyledToolbarItem>
</Tooltip> </Tooltip>
); );
})} }
)}
</StyledToolbarWrapper> </StyledToolbarWrapper>
<UndoRedo /> <UndoRedo />
</StyledEdgelessToolbar> </StyledEdgelessToolbar>