Merge pull request #61 from toeverything/fix/template-error
fix: check error
This commit is contained in:
@@ -141,8 +141,7 @@ export const PlaceholderPanel = (props: PlaceholderPanelProps) => {
|
|||||||
setOpen(false);
|
setOpen(false);
|
||||||
props.onClickTips();
|
props.onClickTips();
|
||||||
};
|
};
|
||||||
const templateList: Array<TemplateMeta> =
|
const templateList = TemplateFactory.defaultTemplateList;
|
||||||
TemplateFactory.defaultTemplateList;
|
|
||||||
const handleNewFromTemplate = async (template: TemplateMeta) => {
|
const handleNewFromTemplate = async (template: TemplateMeta) => {
|
||||||
const pageId = await editor.getRootBlockId();
|
const pageId = await editor.getRootBlockId();
|
||||||
const newPage = await services.api.editorBlock.getBlock(
|
const newPage = await services.api.editorBlock.getBlock(
|
||||||
@@ -162,33 +161,30 @@ export const PlaceholderPanel = (props: PlaceholderPanelProps) => {
|
|||||||
setOpen(false);
|
setOpen(false);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<PlaceholderPanelContainer
|
||||||
<PlaceholderPanelContainer
|
style={{
|
||||||
style={{
|
top: point.y + 'px',
|
||||||
top: point.y + 'px',
|
left: point.x + 'px',
|
||||||
left: point.x + 'px',
|
display: open ? 'block' : 'none',
|
||||||
display: open ? 'block' : 'none',
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<EmptyPageTipContainer onClick={handleClickEmptyPage}>
|
||||||
<EmptyPageTipContainer onClick={handleClickEmptyPage}>
|
Press Enter to continue with an empty page, or pick a template
|
||||||
Press Enter to continue with an empty page, or pick a
|
</EmptyPageTipContainer>
|
||||||
template
|
<div style={{ marginTop: '4px', marginLeft: '-8px' }}>
|
||||||
</EmptyPageTipContainer>
|
{templateList.map((template, index) => {
|
||||||
<div style={{ marginTop: '4px', marginLeft: '-8px' }}>
|
return (
|
||||||
{templateList.map((template, index) => {
|
<TemplateItemContainer
|
||||||
return (
|
key={index}
|
||||||
<TemplateItemContainer
|
onClick={() => {
|
||||||
key={index}
|
handleNewFromTemplate(template);
|
||||||
onClick={() => {
|
}}
|
||||||
handleNewFromTemplate(template);
|
>
|
||||||
}}
|
<BaseButton>{template.name}</BaseButton>
|
||||||
>
|
</TemplateItemContainer>
|
||||||
<BaseButton>{template.name}</BaseButton>
|
);
|
||||||
</TemplateItemContainer>
|
})}
|
||||||
);
|
</div>
|
||||||
})}
|
</PlaceholderPanelContainer>
|
||||||
</div>
|
|
||||||
</PlaceholderPanelContainer>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const groupTemplateMap = {
|
|||||||
grid: gridTemplate,
|
grid: gridTemplate,
|
||||||
} as GroupTemplateMap;
|
} as GroupTemplateMap;
|
||||||
|
|
||||||
const defaultTemplateList = [
|
const defaultTemplateList: Array<TemplateMeta> = [
|
||||||
{
|
{
|
||||||
name: 'New From Quick Start',
|
name: 'New From Quick Start',
|
||||||
groupKeys: ['todolist'],
|
groupKeys: ['todolist'],
|
||||||
@@ -22,10 +22,10 @@ const defaultTemplateList = [
|
|||||||
{ name: 'New From Blog', groupKeys: ['blog'] },
|
{ name: 'New From Blog', groupKeys: ['blog'] },
|
||||||
{ name: ' New Todolist', groupKeys: ['todolist'] },
|
{ name: ' New Todolist', groupKeys: ['todolist'] },
|
||||||
{ name: ' New Empty Page', groupKeys: ['empty'] },
|
{ name: ' New Empty Page', groupKeys: ['empty'] },
|
||||||
] as const;
|
];
|
||||||
|
|
||||||
const TemplateFactory = {
|
const TemplateFactory = {
|
||||||
defaultTemplateList: defaultTemplateList,
|
defaultTemplateList,
|
||||||
generatePageTemplateByGroupKeys(props: TemplateMeta): Template {
|
generatePageTemplateByGroupKeys(props: TemplateMeta): Template {
|
||||||
const newTitle = props.name || 'Get Started with AFFiNE';
|
const newTitle = props.name || 'Get Started with AFFiNE';
|
||||||
const keys: GroupTemplateKeys[] = props.groupKeys || [];
|
const keys: GroupTemplateKeys[] = props.groupKeys || [];
|
||||||
|
|||||||
Reference in New Issue
Block a user