-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: import and export suika format file
- Loading branch information
Showing
28 changed files
with
311 additions
and
133 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
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './dropdown'; |
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
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,3 +1,4 @@ | ||
export * from './components/select'; | ||
export * from './components/popover'; | ||
export * from './components/icon-button'; | ||
export * from './components/dropdown'; |
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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
|
||
export const MenuOutlined = React.memo(() => { | ||
return ( | ||
<svg | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
fill="currentColor" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path fillRule="evenodd" clipRule="evenodd" d="M17 12H6V11H17V12Z" /> | ||
<path fillRule="evenodd" clipRule="evenodd" d="M17 16H6V15H17V16Z" /> | ||
<path fillRule="evenodd" clipRule="evenodd" d="M17 8H6V7H17V8Z" /> | ||
</svg> | ||
); | ||
}); |
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
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
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
display: flex; | ||
align-items: center; | ||
|
||
margin-left: 24px; | ||
margin-left: 8px; | ||
height: 48px; | ||
} | ||
} | ||
} |
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
40 changes: 40 additions & 0 deletions
40
packages/suika/src/components/Header/components/Toolbar/menu/Menu.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Dropdown } from '@suika/components'; | ||
import { FC, useContext } from 'react'; | ||
import { useIntl } from 'react-intl'; | ||
import { exportService, importService } from '../../../../../editor'; | ||
import { EditorContext } from '../../../../../context'; | ||
import { MenuOutlined } from '@suika/icons'; | ||
import './menu.scss'; | ||
|
||
export const Menu: FC = () => { | ||
const intl = useIntl(); | ||
const editor = useContext(EditorContext); | ||
|
||
const items = [ | ||
{ | ||
key: 'import', | ||
label: intl.formatMessage({ id: 'import.originFile' }), | ||
}, | ||
{ | ||
key: 'export', | ||
label: intl.formatMessage({ id: 'export.originFile' }), | ||
}, | ||
]; | ||
|
||
const handleClick = ({ key }: { key: string }) => { | ||
if (!editor) return; | ||
if (key === 'import') { | ||
importService.importOriginFile(editor); | ||
} else if (key === 'export') { | ||
exportService.exportOriginFile(editor); | ||
} | ||
}; | ||
|
||
return ( | ||
<Dropdown items={items} onClick={handleClick}> | ||
<div className="sk-ed-menu-btn"> | ||
<MenuOutlined /> | ||
</div> | ||
</Dropdown> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/suika/src/components/Header/components/Toolbar/menu/index.ts
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './Menu'; |
13 changes: 13 additions & 0 deletions
13
packages/suika/src/components/Header/components/Toolbar/menu/menu.scss
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.sk-ed-menu-btn { | ||
margin-right: 8px; | ||
border-radius: 4px; | ||
width: 32px; | ||
height: 32px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
&:hover { | ||
background-color: #eee; | ||
} | ||
} |
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
Oops, something went wrong.