mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
chore: cleanup useless path
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
import { displayFlex, styled } from '@affine/component';
|
||||
import Loading from '@/components/loading';
|
||||
import { Modal } from '@affine/component';
|
||||
import { useState } from 'react';
|
||||
import { Button } from '@affine/component';
|
||||
import { FavouritedIcon } from '@blocksuite/icons';
|
||||
import { toast } from '@affine/component';
|
||||
export const StyledHeader = styled('div')({
|
||||
height: '60px',
|
||||
width: '100vw',
|
||||
...displayFlex('space-between', 'center'),
|
||||
position: 'relative',
|
||||
padding: '0 22px',
|
||||
borderBottom: '1px solid #e5e5e5',
|
||||
});
|
||||
|
||||
const Affine = () => {
|
||||
const [show, setShow] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<StyledHeader>
|
||||
<button
|
||||
onClick={() => {
|
||||
setShow(true);
|
||||
}}
|
||||
>
|
||||
click me!
|
||||
</button>
|
||||
</StyledHeader>
|
||||
<Modal
|
||||
open={show}
|
||||
onClose={() => {
|
||||
setShow(false);
|
||||
}}
|
||||
>
|
||||
<div>hi</div>
|
||||
</Modal>
|
||||
<Loading />
|
||||
<Button
|
||||
icon={<FavouritedIcon />}
|
||||
onClick={() => {
|
||||
toast('hello, world!!');
|
||||
}}
|
||||
>
|
||||
click me!
|
||||
</Button>
|
||||
<Button icon={<FavouritedIcon />} type={'primary'}>
|
||||
click me!
|
||||
</Button>
|
||||
<Button icon={<FavouritedIcon />} type={'light'}>
|
||||
click me!
|
||||
</Button>
|
||||
<Button icon={<FavouritedIcon />} type={'warning'}>
|
||||
click me!
|
||||
</Button>
|
||||
<Button icon={<FavouritedIcon />} type={'danger'}>
|
||||
click me!
|
||||
</Button>
|
||||
<Button icon={<FavouritedIcon />}></Button>
|
||||
<Button icon={<FavouritedIcon />} shape="round"></Button>
|
||||
<Button loading={true}></Button>
|
||||
<Button loading={true} type="primary"></Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Affine;
|
||||
@@ -1,20 +0,0 @@
|
||||
// for dynamic route get workspace id maybe path will change
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
const Post = () => {
|
||||
const router = useRouter();
|
||||
const { workspace_id } = router.query;
|
||||
|
||||
return (
|
||||
<p
|
||||
style={{
|
||||
height: 'calc(100vh)',
|
||||
color: 'gray',
|
||||
}}
|
||||
>
|
||||
workspace_id: {workspace_id},
|
||||
</p>
|
||||
);
|
||||
};
|
||||
|
||||
export default Post;
|
||||
@@ -1,123 +0,0 @@
|
||||
import { ReactElement } from 'react';
|
||||
import WorkspaceLayout from '@/components/workspace-layout';
|
||||
import exampleMarkdown1 from '@/templates/Welcome-to-the-AFFiNE-Alpha.md';
|
||||
import exampleMarkdown2 from '@/templates/AFFiNE-Docs.md';
|
||||
|
||||
import { usePageHelper } from '@/hooks/use-page-helper';
|
||||
import { useAppState } from '@/providers/app-state-provider';
|
||||
import { Button } from '@affine/component';
|
||||
interface Template {
|
||||
name: string;
|
||||
source: string;
|
||||
}
|
||||
const TemplateItemContainer = styled('div')(() => {
|
||||
return {
|
||||
color: 'blue',
|
||||
padding: '10px 15px',
|
||||
borderBottom: '1px solid #eee',
|
||||
cursor: 'pointer',
|
||||
'&:hover': {
|
||||
background: '#eee',
|
||||
},
|
||||
};
|
||||
});
|
||||
import { styled } from '@affine/component';
|
||||
const TEMPLATES: Template[] = [
|
||||
{
|
||||
name: 'Welcome-to-the-AFFiNE-Alpha.md',
|
||||
source: exampleMarkdown1,
|
||||
},
|
||||
{
|
||||
name: 'AFFiNE-Docs.md',
|
||||
source: exampleMarkdown2,
|
||||
},
|
||||
];
|
||||
|
||||
const All = () => {
|
||||
const { openPage, createPage } = usePageHelper();
|
||||
const { currentWorkspace } = useAppState();
|
||||
const _applyTemplate = function (pageId: string, template: Template) {
|
||||
const page = currentWorkspace?.blocksuiteWorkspace?.getPage(pageId);
|
||||
|
||||
const title = template.name;
|
||||
if (page) {
|
||||
currentWorkspace?.blocksuiteWorkspace?.setPageMeta(page.id, { title });
|
||||
if (page && page.root === null) {
|
||||
setTimeout(async () => {
|
||||
const editor = document.querySelector('editor-container');
|
||||
if (editor) {
|
||||
page.addBlock({ flavour: 'affine:surface' }, null);
|
||||
const frameId = page.addBlock({ flavour: 'affine:frame' }, pageId);
|
||||
// TODO blocksuite should offer a method to import markdown from store
|
||||
await editor.clipboard.importMarkdown(
|
||||
template.source,
|
||||
`${frameId}`
|
||||
);
|
||||
page.resetHistory();
|
||||
editor.requestUpdate();
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
};
|
||||
const _handleAppleTemplate = async function (template: Template) {
|
||||
const pageId = await createPage();
|
||||
if (pageId) {
|
||||
openPage(pageId);
|
||||
_applyTemplate(pageId, template);
|
||||
}
|
||||
};
|
||||
const _handleAppleTemplateFromFilePicker = async () => {
|
||||
if (!window.showOpenFilePicker) {
|
||||
return;
|
||||
}
|
||||
const arrFileHandle = await window.showOpenFilePicker({
|
||||
types: [
|
||||
{
|
||||
accept: {
|
||||
'image/*': ['.md'],
|
||||
},
|
||||
},
|
||||
],
|
||||
multiple: false,
|
||||
});
|
||||
for (const fileHandle of arrFileHandle) {
|
||||
const file = await fileHandle.getFile();
|
||||
const text = await file.text();
|
||||
_handleAppleTemplate({
|
||||
name: file.name,
|
||||
source: text,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ padding: '50px' }}>
|
||||
<div>
|
||||
<h2>Templates</h2>
|
||||
{TEMPLATES.map(template => {
|
||||
return (
|
||||
<TemplateItemContainer
|
||||
key={template.name}
|
||||
onClick={() => _handleAppleTemplate(template)}
|
||||
>
|
||||
{template.name}
|
||||
<Button style={{ marginLeft: '20px' }}> Apply Template</Button>
|
||||
</TemplateItemContainer>
|
||||
);
|
||||
})}
|
||||
<br />
|
||||
<h2>Import Markdown</h2>
|
||||
<Button onClick={() => _handleAppleTemplateFromFilePicker()}>
|
||||
<a style={{ marginLeft: '20px' }}>Select File To Import Markdown</a>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
All.getLayout = function getLayout(page: ReactElement) {
|
||||
return <WorkspaceLayout>{page}</WorkspaceLayout>;
|
||||
};
|
||||
|
||||
export default All;
|
||||
@@ -1,18 +0,0 @@
|
||||
import { useEffect } from 'react';
|
||||
import { getDataCenter } from '@affine/datacenter';
|
||||
/**
|
||||
* testing only when development
|
||||
*/
|
||||
|
||||
const Page = () => {
|
||||
useEffect(() => {
|
||||
getDataCenter().then(dc => {
|
||||
// @ts-expect-error global variable
|
||||
window.dc = dc;
|
||||
});
|
||||
}, []);
|
||||
|
||||
return <div>Testing only</div>;
|
||||
};
|
||||
|
||||
export default Page;
|
||||
Reference in New Issue
Block a user