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(
return ( ({ icon, toolTip, flavor, disable, callback }, index) => {
<Tooltip key={index} content={toolTip} placement="right-start"> return (
<StyledToolbarItem <Tooltip key={index} content={toolTip} placement="right-start">
disable={disable} <StyledToolbarItem
onClick={() => { disable={disable}
console.log('flavor', flavor); onClick={() => {
}} console.log('click toolbar button:', flavor);
> callback?.();
{icon} }}
</StyledToolbarItem> >
</Tooltip> {icon}
); </StyledToolbarItem>
})} </Tooltip>
);
}
)}
</StyledToolbarWrapper> </StyledToolbarWrapper>
<UndoRedo /> <UndoRedo />
</StyledEdgelessToolbar> </StyledEdgelessToolbar>