Merge pull request #372 from toeverything/develop

chore: small adjust
This commit is contained in:
DarkSky 2022-09-05 23:45:44 +08:00 committed by GitHub
commit a79f2e0abe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 311 additions and 268 deletions

View File

@ -12,6 +12,16 @@
"contributorsPerLine": 7,
"badgeTemplate": "\n[all-contributors-badge]: https://img.shields.io/badge/all_contributors-<%= contributors.length %>-orange.svg?style=flat-square\n",
"contributors": [
{
"login": "doodlewind",
"name": "Yifeng Wang",
"avatar_url": "https://avatars.githubusercontent.com/u/7312949?v=4",
"profile": "https://github.com/doodlewind",
"contributions": [
"code",
"doc"
]
},
{
"login": "darkskygit",
"name": "DarkSky",
@ -303,6 +313,15 @@
"contributions": [
"code"
]
},
{
"login": "felixonmars",
"name": "Felix Yan",
"avatar_url": "https://avatars.githubusercontent.com/u/1006477?v=4",
"profile": "https://felixc.at/",
"contributions": [
"code"
]
}
]
}

View File

@ -19,7 +19,7 @@ See https://github.com/all-?/all-contributors/issues/361#issuecomment-637166066
-->
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[all-contributors-badge]: https://img.shields.io/badge/all_contributors-31-orange.svg?style=flat-square
[all-contributors-badge]: https://img.shields.io/badge/all_contributors-33-orange.svg?style=flat-square
<!-- ALL-CONTRIBUTORS-BADGE:END -->
@ -147,45 +147,47 @@ Thanks a lot to the community for providing such powerful and simple libraries,
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://github.com/doodlewind"><img src="https://avatars.githubusercontent.com/u/7312949?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Yifeng Wang</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=doodlewind" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=doodlewind" title="Documentation">📖</a></td>
<td align="center"><a href="https://darksky.eu.org/"><img src="https://avatars.githubusercontent.com/u/25152247?v=4?s=50" width="50px;" alt=""/><br /><sub><b>DarkSky</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=darkskygit" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=darkskygit" title="Documentation">📖</a></td>
<td align="center"><a href="http://zhangchi.page/"><img src="https://avatars.githubusercontent.com/u/5910926?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Chi Zhang</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=tzhangchi" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=tzhangchi" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/alt1o"><img src="https://avatars.githubusercontent.com/u/21084335?v=4?s=50" width="50px;" alt=""/><br /><sub><b>wang xinglong</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=alt1o" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=alt1o" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/DiamondThree"><img src="https://avatars.githubusercontent.com/u/24630517?v=4?s=50" width="50px;" alt=""/><br /><sub><b>DiamondThree</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=DiamondThree" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=DiamondThree" title="Documentation">📖</a></td>
<td align="center"><a href="https://lawvs.github.io/profile/"><img src="https://avatars.githubusercontent.com/u/18554747?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Whitewater</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=lawvs" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=lawvs" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/zuoxiaodong0815"><img src="https://avatars.githubusercontent.com/u/53252747?v=4?s=50" width="50px;" alt=""/><br /><sub><b>xiaodong zuo</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=zuoxiaodong0815" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=zuoxiaodong0815" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/SaikaSakura"><img src="https://avatars.githubusercontent.com/u/11530942?v=4?s=50" width="50px;" alt=""/><br /><sub><b>MingLIang Wang</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=SaikaSakura" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=SaikaSakura" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/SaikaSakura"><img src="https://avatars.githubusercontent.com/u/11530942?v=4?s=50" width="50px;" alt=""/><br /><sub><b>MingLIang Wang</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=SaikaSakura" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=SaikaSakura" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/QiShaoXuan"><img src="https://avatars.githubusercontent.com/u/22772830?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Qi</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=QiShaoXuan" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=QiShaoXuan" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/mitsuhatu"><img src="https://avatars.githubusercontent.com/u/110213079?v=4?s=50" width="50px;" alt=""/><br /><sub><b>mitsuhatu</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=mitsuhatu" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=mitsuhatu" title="Documentation">📖</a></td>
<td align="center"><a href="https://shockwave.me/"><img src="https://avatars.githubusercontent.com/u/15013925?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Austaras</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=Austaras" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=Austaras" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/uptonking"><img src="https://avatars.githubusercontent.com/u/11391549?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Jin Yao</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=uptonking" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=uptonking" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/HeJiachen-PM"><img src="https://avatars.githubusercontent.com/u/79301703?v=4?s=50" width="50px;" alt=""/><br /><sub><b>HeJiachen-PM</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=HeJiachen-PM" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/Yipei-Operation"><img src="https://avatars.githubusercontent.com/u/79373028?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Yipei Wei</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=Yipei-Operation" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/fanjing22"><img src="https://avatars.githubusercontent.com/u/109729699?v=4?s=50" width="50px;" alt=""/><br /><sub><b>fanjing22</b></sub></a><br /><a href="#design-fanjing22" title="Design">🎨</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/fanjing22"><img src="https://avatars.githubusercontent.com/u/109729699?v=4?s=50" width="50px;" alt=""/><br /><sub><b>fanjing22</b></sub></a><br /><a href="#design-fanjing22" title="Design">🎨</a></td>
<td align="center"><a href="https://github.com/Svaney-ssman"><img src="https://avatars.githubusercontent.com/u/110808979?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Svaney</b></sub></a><br /><a href="#design-Svaney-ssman" title="Design">🎨</a></td>
<td align="center"><a href="http://xell.me/"><img src="https://avatars.githubusercontent.com/u/132558?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Guozhu Liu</b></sub></a><br /><a href="#design-xell" title="Design">🎨</a></td>
<td align="center"><a href="https://github.com/fyZheng07"><img src="https://avatars.githubusercontent.com/u/63830919?v=4?s=50" width="50px;" alt=""/><br /><sub><b>fyZheng07</b></sub></a><br /><a href="#eventOrganizing-fyZheng07" title="Event Organizing">📋</a> <a href="#userTesting-fyZheng07" title="User Testing">📓</a></td>
<td align="center"><a href="https://github.com/CJSS"><img src="https://avatars.githubusercontent.com/u/4605025?v=4?s=50" width="50px;" alt=""/><br /><sub><b>CJSS</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=CJSS" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/clean-software"><img src="https://avatars.githubusercontent.com/u/62192072?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Carlos Rafael </b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=CarlosZoft" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/caleboleary"><img src="https://avatars.githubusercontent.com/u/12816579?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Caleb OLeary</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=caleboleary" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/JimmFly"><img src="https://avatars.githubusercontent.com/u/102217452?v=4?s=50" width="50px;" alt=""/><br /><sub><b>JimmFly</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=JimmFly" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/JimmFly"><img src="https://avatars.githubusercontent.com/u/102217452?v=4?s=50" width="50px;" alt=""/><br /><sub><b>JimmFly</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=JimmFly" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/westongraham"><img src="https://avatars.githubusercontent.com/u/89493023?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Weston Graham</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=westongraham" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/pointmax"><img src="https://avatars.githubusercontent.com/u/49361135?v=4?s=50" width="50px;" alt=""/><br /><sub><b>pointmax</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=pointmax" title="Documentation">📖</a></td>
<td align="center"><a href="https://liby.github.io/notes"><img src="https://avatars.githubusercontent.com/u/38807139?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Bryan Lee</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=liby" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/chenmoonmo"><img src="https://avatars.githubusercontent.com/u/36295999?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Simon Li</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=chenmoonmo" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/githbq"><img src="https://avatars.githubusercontent.com/u/10009709?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Bob Hu</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=githbq" title="Code">💻</a></td>
<td align="center"><a href="https://quavo.vercel.app/"><img src="https://avatars.githubusercontent.com/u/67266933?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Quavo</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=lucky-chap" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/LuciNyan"><img src="https://avatars.githubusercontent.com/u/22126563?v=4?s=50" width="50px;" alt=""/><br /><sub><b>子瞻 Luci</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=LuciNyan" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/LuciNyan"><img src="https://avatars.githubusercontent.com/u/22126563?v=4?s=50" width="50px;" alt=""/><br /><sub><b>子瞻 Luci</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=LuciNyan" title="Code">💻</a></td>
<td align="center"><a href="http://blog.ipili.me/"><img src="https://avatars.githubusercontent.com/u/4948120?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Horus</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=m1911star" title="Code">💻</a> <a href="#platform-m1911star" title="Packaging/porting to new platform">📦</a></td>
<td align="center"><a href="https://segmentfault.com/u/qzuser_584786517d31a"><img src="https://avatars.githubusercontent.com/u/15103283?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Super.x</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=fanshyiis" title="Code">💻</a></td>
<td align="center"><a href="https://wangyu-1999.github.io/"><img src="https://avatars.githubusercontent.com/u/80874770?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Wang Yu</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=wangyu-1999" title="Code">💻</a></td>
<td align="center"><a href="https://felixc.at/"><img src="https://avatars.githubusercontent.com/u/1006477?v=4?s=50" width="50px;" alt=""/><br /><sub><b>Felix Yan</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=felixonmars" title="Code">💻</a></td>
</tr>
</table>

View File

@ -2,7 +2,7 @@
Thank you for investing your time in contributing to our project! Any contribution you make will be reflected on our GitHub :sparkles:.
Read our [Code of Conduct](./CODE_OF_CONDUCT.md) to keep our community approachable and respectable.
Read our [Code of Conduct](./CODE_OF_CONDUCT.md) to keep our community approachable and respectable. Join our [Discord](https://discord.com/invite/yz6tGVsf5p) server for more.
In this guide you will get an overview of the contribution workflow from opening an issue, creating a PR, reviewing, and merging the PR.
@ -63,6 +63,8 @@ For more information about using a codespace for working on GitHub documentation
Commit the changes once you are happy with them.
Reach out the community members for necessary help.
Once your changes are ready, don't forget to self-review to speed up the review process:zap:.
### Pull Request
@ -81,6 +83,6 @@ When you're finished with the changes, create a pull request, also known as a PR
Congratulations :tada::tada: The AFFiNE team thanks you :sparkles:.
Once your PR is merged, your contributions will be publicly visible on the our GitHub.
Once your PR is merged, your contributions will be publicly visible on our GitHub.
Now that you are part of the AFFiNE community, see how else you can join and help over at [Gitbook](https://docs.affine.pro/affine/)

View File

@ -82,7 +82,7 @@ const GroupMenuWrapper = ({
content={
<GroupPanel>
<ViewsMenu />
<AddViewMenu />
{/*<AddViewMenu />*/}
{
// // Closed beta period temporarily
// filterSorterFlag && (

View File

@ -13,5 +13,8 @@
"nanoid": "^4.0.0",
"slate": "^0.81.0",
"style9": "^0.14.0"
},
"devDependencies": {
"@types/html-escaper": "^3.0.0"
}
}

View File

@ -1,24 +1,24 @@
import React, { useState, useCallback } from 'react';
import style9 from 'style9';
import {
Popover,
styled,
type SvgIconProps,
Tooltip,
} from '@toeverything/components/ui';
import {
fontBgColorPalette,
fontColorPalette,
} from '@toeverything/components/common';
import { ArrowDropDownIcon } from '@toeverything/components/icons';
import type { DropdownItemType, WithEditorSelectionType } from '../types';
import { uaHelper } from '@toeverything/utils';
import {
inlineMenuNamesKeys,
Popover,
styled,
Tooltip,
type SvgIconProps,
} from '@toeverything/components/ui';
import { uaHelper } from '@toeverything/utils';
import { useCallback, useState } from 'react';
import style9 from 'style9';
import {
inlineMenuNamesForFontColor,
inlineMenuNamesKeys,
MacInlineMenuShortcuts,
WinInlineMenuShortcuts
WinInlineMenuShortcuts,
} from '../config';
import type { DropdownItemType, WithEditorSelectionType } from '../types';
type MenuDropdownItemProps = DropdownItemType & WithEditorSelectionType;
@ -38,102 +38,100 @@ export const MenuDropdownItem = ({
set_anchor_ele(null);
}, []);
//@ts-ignore
const shortcut = uaHelper.isMacOs ? MacInlineMenuShortcuts[nameKey] : WinInlineMenuShortcuts[nameKey];
const shortcut = uaHelper.isMacOs
? //@ts-ignore
MacInlineMenuShortcuts[nameKey]
: //@ts-ignore
WinInlineMenuShortcuts[nameKey];
return (
<>
<Popover
trigger="click"
placement="bottom-start"
<Popover
trigger="click"
placement="bottom-start"
content={
<div className={styles('dropdownContainer')}>
{children.map(item => {
const {
name,
icon: ItemIcon,
onClick,
nameKey: itemNameKey,
} = item;
const StyledIcon = withStylesForIcon(ItemIcon);
return (
<button
className={styles('dropdownItem')}
key={name}
onClick={() => {
if (
onClick &&
selectionInfo?.anchorNode?.id
) {
onClick({
editor,
type: itemNameKey,
anchorNodeId:
selectionInfo?.anchorNode?.id,
});
}
handle_close_dropdown_menu();
}}
>
<StyledIcon
fontColor={
nameKey ===
inlineMenuNamesKeys.currentFontColor
? fontColorPalette[
inlineMenuNamesForFontColor[
itemNameKey as keyof typeof inlineMenuNamesForFontColor
]
]
: nameKey ===
inlineMenuNamesKeys.currentFontBackground
? fontBgColorPalette[
inlineMenuNamesForFontColor[
itemNameKey as keyof typeof inlineMenuNamesForFontColor
]
]
: ''
}
// fontBgColor={
// nameKey=== inlineMenuNamesKeys.currentFontBackground ? fontBgColorPalette[
// inlineMenuNamesForFontColor[itemNameKey] as keyof typeof fontBgColorPalette
// ]:''
// }
/>
{/* <ItemIcon sx={{ width: 20, height: 20 }} /> */}
<span className={styles('dropdownItemItext')}>
{name}
</span>
</button>
);
})}
</div>
}
>
<Tooltip
content={
<div className={styles('dropdownContainer')}>
{children.map(item => {
const {
name,
icon: ItemIcon,
onClick,
nameKey: itemNameKey,
} = item;
const StyledIcon = withStylesForIcon(ItemIcon);
return (
<button
className={styles('dropdownItem')}
key={name}
onClick={() => {
if (
onClick &&
selectionInfo?.anchorNode?.id
) {
onClick({
editor,
type: itemNameKey,
anchorNodeId:
selectionInfo?.anchorNode
?.id,
});
}
handle_close_dropdown_menu();
}}
>
<StyledIcon
fontColor={
nameKey ===
inlineMenuNamesKeys.currentFontColor
? fontColorPalette[
inlineMenuNamesForFontColor[
itemNameKey as keyof typeof inlineMenuNamesForFontColor
]
]
: nameKey ===
inlineMenuNamesKeys.currentFontBackground
? fontBgColorPalette[
inlineMenuNamesForFontColor[
itemNameKey as keyof typeof inlineMenuNamesForFontColor
]
]
: ''
}
// fontBgColor={
// nameKey=== inlineMenuNamesKeys.currentFontBackground ? fontBgColorPalette[
// inlineMenuNamesForFontColor[itemNameKey] as keyof typeof fontBgColorPalette
// ]:''
// }
/>
{/* <ItemIcon sx={{ width: 20, height: 20 }} /> */}
<span
className={styles('dropdownItemItext')}
>
{name}
</span>
</button>
);
})}
<div style={{ padding: '2px 4px' }}>
<p>{name}</p>
{shortcut && <p>{shortcut}</p>}
</div>
}
placement="top"
trigger="hover"
>
<Tooltip
content={
<div style={{ padding: '2px 4px' }}>
<p>{name}</p>
{shortcut && <p>{shortcut}</p>}
</div>
}
placement="top"
trigger="hover"
<button
className={styles('currentDropdownButton')}
aria-label={name}
>
<button
className={styles('currentDropdownButton')}
aria-label={name}
>
<MenuIcon sx={{ width: 20, height: 20 }} />
<ArrowDropDownIcon sx={{ width: 20, height: 20 }} />
</button>
</Tooltip>
</Popover>
</>
<MenuIcon sx={{ width: 20, height: 20 }} />
<ArrowDropDownIcon sx={{ width: 20, height: 20 }} />
</button>
</Tooltip>
</Popover>
);
};

View File

@ -1,10 +1,14 @@
import React, { useCallback } from 'react';
import style9 from 'style9';
import type { IconItemType, WithEditorSelectionType } from '../types';
import { inlineMenuNamesKeys, MacInlineMenuShortcuts, WinInlineMenuShortcuts } from '../config';
import { Tooltip } from '@toeverything/components/ui';
import { uaHelper } from '@toeverything/utils';
import {
inlineMenuNamesKeys,
MacInlineMenuShortcuts,
WinInlineMenuShortcuts,
} from '../config';
import type { IconItemType, WithEditorSelectionType } from '../types';
type MenuIconItemProps = IconItemType & WithEditorSelectionType;
export const MenuIconItem = ({
@ -36,7 +40,11 @@ export const MenuIconItem = ({
);
//@ts-ignore
const shortcut = uaHelper.isMacOs ? MacInlineMenuShortcuts[nameKey] : WinInlineMenuShortcuts[nameKey];
const shortcut = uaHelper.isMacOs
? //@ts-ignore
MacInlineMenuShortcuts[nameKey]
: //@ts-ignore
WinInlineMenuShortcuts[nameKey];
return (
<Tooltip

View File

@ -14,7 +14,7 @@ import {
import { useTranslation } from 'react-i18next';
import { EditorBoardSwitcher } from './EditorBoardSwitcher';
import { FileSystem, fsApiSupported } from './FileSystem';
import { fsApiSupported } from './FileSystem';
import { CurrentPageTitle } from './Title';
export const LayoutHeader = () => {
@ -44,7 +44,6 @@ export const LayoutHeader = () => {
</FlexContainer>
<FlexContainer>
<StyledHelper>
<FileSystem />
<StyledShare disabled={true}>{t('Share')}</StyledShare>
<div style={{ margin: '0px 12px' }}>
<IconButton
@ -70,9 +69,6 @@ export const LayoutHeader = () => {
<EditorBoardSwitcher />
</StyledContainerForEditorBoardSwitcher>
</StyledHeaderRoot>
<StyledUnstableTips>
<StyledUnstableTipsText>{warningTips}</StyledUnstableTipsText>
</StyledUnstableTips>
</StyledContainerForHeaderRoot>
);
};

View File

@ -58,8 +58,6 @@ function PageSettingPortal() {
const navigate = useNavigate();
const { user } = useUserAndSpaces();
const BooleanFullWidthChecked = useFlag('BooleanFullWidthChecked', false);
const BooleanExportWorkspace = useFlag('BooleanExportWorkspace', false);
const BooleanImportWorkspace = useFlag('BooleanImportWorkspace', false);
const BooleanExportHtml = useFlag('BooleanExportHtml', false);
const BooleanExportPdf = useFlag('BooleanExportPdf', false);
const BooleanExportMarkdown = useFlag('BooleanExportMarkdown', false);
@ -217,18 +215,14 @@ function PageSettingPortal() {
/>
)}
<Divider />
{BooleanImportWorkspace && (
<ListButton
content="Import Workspace"
onClick={handleImportWorkspace}
/>
)}
{BooleanExportWorkspace && (
<ListButton
content="Export Workspace"
onClick={handleExportWorkspace}
/>
)}
<ListButton
content="Import Workspace"
onClick={handleImportWorkspace}
/>
<ListButton
content="Export Workspace"
onClick={handleExportWorkspace}
/>
<p className="textDescription">
Last edited by {user && user.nickname}

View File

@ -49,7 +49,7 @@ export const SettingsList = () => {
{item.key === 'Language' ? (
<div style={{ marginLeft: '12em' }}>
<Select
defaultValue={options[0].value}
defaultValue={i18n.language}
onChange={changeLanguage}
>
{options.map(option => (

View File

@ -2,8 +2,6 @@ import { useFlag } from '@toeverything/datasource/feature-flags';
export const useSettingFlags = () => {
const booleanFullWidthChecked = useFlag('BooleanFullWidthChecked', false);
const booleanExportWorkspace = useFlag('BooleanExportWorkspace', false);
const booleanImportWorkspace = useFlag('BooleanImportWorkspace', false);
const booleanExportHtml = useFlag('BooleanExportHtml', false);
const booleanExportPdf = useFlag('BooleanExportPdf', false);
const booleanExportMarkdown = useFlag('BooleanExportMarkdown', false);
@ -11,8 +9,6 @@ export const useSettingFlags = () => {
return {
booleanFullWidthChecked,
booleanExportWorkspace,
booleanImportWorkspace,
booleanExportHtml,
booleanExportPdf,
booleanExportMarkdown,

View File

@ -145,26 +145,24 @@ export const useSettings = (): SettingItem[] => {
type: 'separator',
key: 'separator2',
},
{
type: 'button',
name: t('Clear Workspace'),
key: 'Clear Workspace',
onClick: () => clearWorkspace(workspaceId),
flag: 'booleanClearWorkspace',
},
{
type: 'button',
name: t('Import Workspace'),
key: 'Import Workspace',
onClick: () => importWorkspace(workspaceId),
flag: 'booleanImportWorkspace',
onClick: () => importWorkspace(),
},
{
type: 'button',
name: t('Export Workspace'),
key: 'Export Workspace',
onClick: () => exportWorkspace(),
flag: 'booleanExportWorkspace',
},
{
type: 'button',
name: t('Clear Workspace'),
key: 'Clear Workspace',
onClick: () => clearWorkspace(workspaceId),
flag: 'booleanClearWorkspace',
},
];

View File

@ -1,14 +1,15 @@
/**
* @deprecated debugging method, deprecated
*/
export const importWorkspace = (workspaceId: string) => {
//@ts-ignore
window.client
.inspector()
.load()
.then(() => {
window.location.href = `/${workspaceId}/`;
});
export const importWorkspace = async () => {
if (window.confirm('Your currently open data will be lost.')) {
//@ts-ignore
const status = await window.client.inspector().load();
if (status) {
window.location.reload();
}
}
};
/**

View File

@ -32,4 +32,5 @@ const Container = styled(Clickable)({
display: 'flex',
alignItems: 'center',
padding: '6px 12px',
whiteSpace: 'nowrap',
});

View File

@ -39,7 +39,7 @@ async function _getCurrentToken() {
const _enabled = {
demo: [],
AFFiNE: ['sqlite'],
AFFiNE: ['idb'],
} as any;
async function _getBlockDatabase(

View File

@ -111,7 +111,9 @@
"type": "text",
"properties": {
"text": {
"value": [{ "text": "Type to mention people" }]
"value": [
{ "text": " Open Tag App`AFFiNE` to mention people" }
]
},
"recastValues": {
"bNjVwBq8YLxvmvr7": {

View File

@ -36,7 +36,7 @@ export class UserConfig extends ServiceBaseClass {
}
const db = await this.database.getDatabase(workspace);
const newPage = await db.get('page');
const newPage = await db.getNamedBlock('start-page');
await this.get_dependency(PageTree).addPage(workspace, newPage.id);
await this.addRecentPage(workspace, userId, newPage.id);

View File

@ -357,7 +357,7 @@ export class BlockClient<
* @param name block name
* @returns block instance
*/
private async get_named_block(
public async getNamedBlock(
name: string,
options?: { workspace?: boolean }
): Promise<BaseBlock<B, C>> {
@ -376,7 +376,7 @@ export class BlockClient<
*/
public async getWorkspace() {
if (!this._root.node) {
this._root.node = await this.get_named_block(this._workspace, {
this._root.node = await this.getNamedBlock(this._workspace, {
workspace: true,
});
}

View File

@ -56,6 +56,7 @@ type YjsProviders = {
connListener: { listeners?: ConnectivityListener };
userId: string;
remoteToken: string | undefined; // remote storage token
providers: unknown[];
};
const _yjsDatabaseInstance = new Map<string, YjsProviders>();
@ -107,19 +108,25 @@ async function _initYjsDatabase(
);
const connListener: { listeners?: ConnectivityListener } = {};
let providers: unknown[] = [];
if (options.provider) {
const emitState = (c: Connectivity) =>
connListener.listeners?.(workspace, c);
await Promise.all(
Object.entries(options.provider).flatMap(([, p]) => [
p({ awareness, doc, token, workspace, emitState }),
providers = await Promise.all(
Object.entries(options.provider).flatMap(([name, p]) => [
p({ awareness, doc, token, workspace, emitState }).then(p => {
console.log(p);
return {
[name]: p,
};
}),
p({
awareness,
doc: binaries,
token,
workspace: `${workspace}_binaries`,
emitState,
}),
}).then(p => ({ [`${name}_binaries`]: p })),
])
);
}
@ -128,7 +135,7 @@ async function _initYjsDatabase(
binaries,
doc,
gatekeeper,
providers,
connListener,
userId,
remoteToken: token,
@ -324,53 +331,63 @@ export class YjsAdapter implements AsyncDatabaseAdapter<YjsContentOperation> {
const binary = encodeStateAsUpdate(this._doc);
saveAs(
new Blob([binary]),
`affine_workspace_${new Date().toDateString()}.apk`
`affine_workspace_${new Date().toDateString()}.affine`
);
},
load: async () => {
const handles = await window.showOpenFilePicker({
types: [
{
description: 'AFFiNE Package',
accept: {
// eslint-disable-next-line @typescript-eslint/naming-convention
'application/affine': ['.apk'],
try {
const handles = await window.showOpenFilePicker({
types: [
{
description: 'AFFiNE Package',
accept: {
// eslint-disable-next-line @typescript-eslint/naming-convention
'application/affine': ['.affine'],
},
},
},
],
});
const [file] = (await fromEvent(handles)) as File[];
const binary = await file?.arrayBuffer();
// await this._provider.idb.clearData();
const doc = new Doc({ autoLoad: true, shouldLoad: true });
let updated = 0;
let isUpdated = false;
doc.on('update', () => {
isUpdated = true;
updated += 1;
});
setInterval(() => {
if (updated > 0) {
updated -= 1;
}
}, 500);
const update_check = new Promise<void>(resolve => {
const check = async () => {
while (!isUpdated || updated > 0) {
await sleep();
],
});
const [file] = (await fromEvent(handles)) as File[];
const binary = await file?.arrayBuffer();
console.log(this._provider.providers);
let { indexeddb } = (
this._provider.providers as any[]
).find(p => p.indexeddb);
await indexeddb?.idb?.clearData();
const doc = new Doc({ autoLoad: true, shouldLoad: true });
let updated = 0;
let isUpdated = false;
doc.on('update', () => {
isUpdated = true;
updated += 1;
});
setInterval(() => {
if (updated > 0) {
updated -= 1;
}
resolve();
};
check();
});
// await new IndexedDBProvider(this._provider.idb.name, doc)
// .whenSynced;
if (binary) {
applyUpdate(doc, new Uint8Array(binary));
await update_check;
}, 500);
const update_check = new Promise<void>(resolve => {
const check = async () => {
while (!isUpdated || updated > 0) {
await sleep();
}
resolve();
};
check();
});
await new indexeddb.ctor(indexeddb.idb.name, doc)
.whenSynced;
if (binary) {
applyUpdate(doc, new Uint8Array(binary));
await update_check;
}
return true;
} catch (err) {
console.log(err);
return false;
}
console.log('load success');
},
parse: () => this._doc.toJSON(),
// eslint-disable-next-line @typescript-eslint/naming-convention

View File

@ -18,7 +18,9 @@ type YjsDefaultInstances = {
emitState: (connectivity: Connectivity) => void;
};
export type YjsProvider = (instances: YjsDefaultInstances) => Promise<void>;
export type YjsProvider = (
instances: YjsDefaultInstances
) => Promise<unknown | undefined>;
type ProviderType = 'idb' | 'sqlite' | 'ws';
@ -38,9 +40,12 @@ export const getYjsProviders = (
return {
indexeddb: async (instances: YjsDefaultInstances) => {
if (options.enabled.includes('idb')) {
await new IndexedDBProvider(instances.workspace, instances.doc)
.whenSynced;
return new IndexedDBProvider(
instances.workspace,
instances.doc
).whenSynced.then(idb => ({ idb, ctor: IndexedDBProvider }));
}
return undefined;
},
sqlite: async (instances: YjsDefaultInstances) => {
if (options.enabled.includes('sqlite')) {

View File

@ -71,44 +71,20 @@ const _useUserAndSpacesForFreeLogin = () => {
useEffect(() => {
if (loading) {
if (location.pathname.startsWith('/local')) {
navigate('/local');
} else {
navigate('/demo');
}
navigate(`/${BRAND_ID}`);
setLoading(false);
}
}, []);
useEffect(() => {
if (localTrigger) {
setUser({
photo: '',
id: BRAND_ID,
username: BRAND_ID,
nickname: BRAND_ID,
email: '',
});
} else {
if (location.pathname.startsWith('/local')) {
setUser({
photo: '',
id: 'local',
username: 'local',
nickname: 'local',
email: '',
});
} else {
setUser({
photo: '',
id: 'demo',
username: 'demo',
nickname: 'demo',
email: '',
});
}
}
}, [localTrigger, location, setLoading, setUser]);
setUser({
photo: '',
id: BRAND_ID,
username: BRAND_ID,
nickname: BRAND_ID,
email: '',
});
}, [setUser]);
const currentSpaceId: string | undefined = useMemo(() => user?.id, [user]);

View File

@ -413,18 +413,18 @@ importers:
dependencies:
'@codemirror/commands': 6.0.1
'@codemirror/lang-cpp': 6.0.1
'@codemirror/lang-css': 6.0.0
'@codemirror/lang-html': 6.1.0
'@codemirror/lang-css': 6.0.0_bmjizg7gr5ieupmvn5u62mbipm
'@codemirror/lang-html': 6.1.0_@codemirror+view@6.2.0
'@codemirror/lang-java': 6.0.0
'@codemirror/lang-javascript': 6.0.2
'@codemirror/lang-json': 6.0.0
'@codemirror/lang-lezer': 6.0.0
'@codemirror/lang-markdown': 6.0.1
'@codemirror/lang-php': 6.0.0
'@codemirror/lang-php': 6.0.0_@codemirror+view@6.2.0
'@codemirror/lang-python': 6.0.1
'@codemirror/lang-rust': 6.0.0
'@codemirror/lang-sql': 6.1.0
'@codemirror/lang-xml': 6.0.0
'@codemirror/lang-sql': 6.1.0_bmjizg7gr5ieupmvn5u62mbipm
'@codemirror/lang-xml': 6.0.0_@codemirror+view@6.2.0
'@codemirror/language': 6.2.1
'@codemirror/legacy-modes': 6.1.0
'@codemirror/next': 0.16.0
@ -438,7 +438,7 @@ importers:
'@emotion/styled': 11.9.3_dc5dh2wp562rsjxvguwi2i3yzq
'@mui/system': 5.8.7_d6menda4vqwq6peqnkbe7mkj4i
code-example: 3.3.6
codemirror: 6.0.1
codemirror: 6.0.1_@lezer+common@1.0.0
codemirror-lang-elixir: 3.0.0_@codemirror+language@6.2.1
keymap: link:@codemirror/next/keymap
nanoid: 4.0.0
@ -455,6 +455,7 @@ importers:
libs/components/editor-core:
specifiers:
'@mui/icons-material': ^5.8.4
'@types/html-escaper': ^3.0.0
date-fns: ^2.29.2
eventemitter3: ^4.0.7
hotkeys-js: ^3.9.4
@ -475,6 +476,8 @@ importers:
nanoid: 4.0.0
slate: 0.81.1
style9: 0.14.0
devDependencies:
'@types/html-escaper': 3.0.0
libs/components/editor-plugins:
specifiers:
@ -574,9 +577,6 @@ importers:
dependencies:
ffc-js-client-side-sdk: 1.1.5
libs/datasource/jwst/pkg:
specifiers: {}
libs/datasource/jwt:
specifiers:
'@types/debug': ^4.1.7
@ -2265,8 +2265,13 @@ packages:
resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==}
dev: true
/@codemirror/autocomplete/6.0.3:
/@codemirror/autocomplete/6.0.3_nq4pwfkqi5icglf26kczcr4s2i:
resolution: {integrity: sha512-JTSBDC4tUyR8iRmCwQJaYpTXtOZmRn4gKjw1Fu4xIatFPqTJ7m0QRCdkdbzlvMovzjTiuHp4a8WUEB1c/LtiHg==}
peerDependencies:
'@codemirror/language': ^6.0.0
'@codemirror/state': ^6.0.0
'@codemirror/view': ^6.0.0
'@lezer/common': ^1.0.0
dependencies:
'@codemirror/language': 6.2.1
'@codemirror/state': 6.1.1
@ -2290,25 +2295,30 @@ packages:
'@lezer/cpp': 1.0.0
dev: false
/@codemirror/lang-css/6.0.0:
/@codemirror/lang-css/6.0.0_bmjizg7gr5ieupmvn5u62mbipm:
resolution: {integrity: sha512-jBqc+BTuwhNOTlrimFghLlSrN6iFuE44HULKWoR4qKYObhOIl9Lci1iYj6zMIte1XTQmZguNvjXMyr43LUKwSw==}
dependencies:
'@codemirror/autocomplete': 6.0.3
'@codemirror/autocomplete': 6.0.3_nq4pwfkqi5icglf26kczcr4s2i
'@codemirror/language': 6.2.1
'@codemirror/state': 6.1.1
'@lezer/css': 1.0.0
transitivePeerDependencies:
- '@codemirror/view'
- '@lezer/common'
dev: false
/@codemirror/lang-html/6.1.0:
/@codemirror/lang-html/6.1.0_@codemirror+view@6.2.0:
resolution: {integrity: sha512-gA7NmJxqvnhwza05CvR7W/39Ap9r/4Vs9uiC0IeFYo1hSlJzc/8N6Evviz6vTW1x8SpHcRYyqKOf6rpl6LfWtg==}
dependencies:
'@codemirror/autocomplete': 6.0.3
'@codemirror/lang-css': 6.0.0
'@codemirror/autocomplete': 6.0.3_nq4pwfkqi5icglf26kczcr4s2i
'@codemirror/lang-css': 6.0.0_bmjizg7gr5ieupmvn5u62mbipm
'@codemirror/lang-javascript': 6.0.2
'@codemirror/language': 6.2.1
'@codemirror/state': 6.1.1
'@lezer/common': 1.0.0
'@lezer/html': 1.0.0
transitivePeerDependencies:
- '@codemirror/view'
dev: false
/@codemirror/lang-java/6.0.0:
@ -2321,7 +2331,7 @@ packages:
/@codemirror/lang-javascript/6.0.2:
resolution: {integrity: sha512-BZRJ9u/zl16hLkSpDAWm73mrfIR7HJrr0lvnhoSOCQVea5BglguWI/slxexhvUb0CB5cXgKWuo2bM+N9EhIaZw==}
dependencies:
'@codemirror/autocomplete': 6.0.3
'@codemirror/autocomplete': 6.0.3_nq4pwfkqi5icglf26kczcr4s2i
'@codemirror/language': 6.2.1
'@codemirror/lint': 6.0.0
'@codemirror/state': 6.1.1
@ -2349,7 +2359,7 @@ packages:
/@codemirror/lang-markdown/6.0.1:
resolution: {integrity: sha512-pHPQuRwf9cUrmkmsTHRjtS9ZnGu3fA9YzAdh2++d+L9wbfnC2XbKh0Xvm/0YiUjdCnoCx9wDFEoCuAnkqKWLIw==}
dependencies:
'@codemirror/lang-html': 6.1.0
'@codemirror/lang-html': 6.1.0_@codemirror+view@6.2.0
'@codemirror/language': 6.2.1
'@codemirror/state': 6.1.1
'@codemirror/view': 6.2.0
@ -2357,14 +2367,16 @@ packages:
'@lezer/markdown': 1.0.1
dev: false
/@codemirror/lang-php/6.0.0:
/@codemirror/lang-php/6.0.0_@codemirror+view@6.2.0:
resolution: {integrity: sha512-96CEjq0xEgbzc6bdFPwILPfZ6m8917JRbh2oPszZJABlYxG4Y+eYjtYkUTDb4yuyjQKyigHoeGC6zoIOYA1NWA==}
dependencies:
'@codemirror/lang-html': 6.1.0
'@codemirror/lang-html': 6.1.0_@codemirror+view@6.2.0
'@codemirror/language': 6.2.1
'@codemirror/state': 6.1.1
'@lezer/common': 1.0.0
'@lezer/php': 1.0.0
transitivePeerDependencies:
- '@codemirror/view'
dev: false
/@codemirror/lang-python/6.0.1:
@ -2381,24 +2393,29 @@ packages:
'@lezer/rust': 1.0.0
dev: false
/@codemirror/lang-sql/6.1.0:
/@codemirror/lang-sql/6.1.0_bmjizg7gr5ieupmvn5u62mbipm:
resolution: {integrity: sha512-eTNTP0+uNHqYClCvJ3QGE7mn1S96QJFNsK76dB4c1pYAQjbgVVjy5DqtD3//A44rp2kuRkgBccRaPKrWDzBdNQ==}
dependencies:
'@codemirror/autocomplete': 6.0.3
'@codemirror/autocomplete': 6.0.3_nq4pwfkqi5icglf26kczcr4s2i
'@codemirror/language': 6.2.1
'@codemirror/state': 6.1.1
'@lezer/highlight': 1.0.0
'@lezer/lr': 1.2.0
transitivePeerDependencies:
- '@codemirror/view'
- '@lezer/common'
dev: false
/@codemirror/lang-xml/6.0.0:
/@codemirror/lang-xml/6.0.0_@codemirror+view@6.2.0:
resolution: {integrity: sha512-M/HLWxIiP956xGjtrxkeHkCmDGVQGKu782x8pOH5CLJIMkWtiB1DWfDoDHqpFjdEE9dkfcqPWvYfVi6GbhuXEg==}
dependencies:
'@codemirror/autocomplete': 6.0.3
'@codemirror/autocomplete': 6.0.3_nq4pwfkqi5icglf26kczcr4s2i
'@codemirror/language': 6.2.1
'@codemirror/state': 6.1.1
'@lezer/common': 1.0.0
'@lezer/xml': 1.0.0
transitivePeerDependencies:
- '@codemirror/view'
dev: false
/@codemirror/language/6.2.1:
@ -6746,6 +6763,10 @@ packages:
resolution: {integrity: sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==}
dev: true
/@types/html-escaper/3.0.0:
resolution: {integrity: sha512-OcJcvP3Yk8mjYwf/IdXZtTE1tb/u0WF0qa29ER07ZHCYUBZXSN29Z1mBS+/96+kNMGTFUAbSz9X+pHmHpZrTCw==}
dev: true
/@types/html-minifier-terser/6.1.0:
resolution: {integrity: sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg==}
dev: true
@ -7396,8 +7417,10 @@ packages:
indent-string: 4.0.0
dev: true
/ajv-formats/2.1.1:
/ajv-formats/2.1.1_ajv@8.11.0:
resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==}
peerDependencies:
ajv: ^8.0.0
peerDependenciesMeta:
ajv:
optional: true
@ -8605,16 +8628,18 @@ packages:
'@codemirror/language': 6.2.1
dev: false
/codemirror/6.0.1:
/codemirror/6.0.1_@lezer+common@1.0.0:
resolution: {integrity: sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==}
dependencies:
'@codemirror/autocomplete': 6.0.3
'@codemirror/autocomplete': 6.0.3_nq4pwfkqi5icglf26kczcr4s2i
'@codemirror/commands': 6.0.1
'@codemirror/language': 6.2.1
'@codemirror/lint': 6.0.0
'@codemirror/search': 6.0.0
'@codemirror/state': 6.1.1
'@codemirror/view': 6.2.0
transitivePeerDependencies:
- '@lezer/common'
dev: false
/collect-v8-coverage/1.0.1:
@ -16962,7 +16987,7 @@ packages:
dependencies:
'@types/json-schema': 7.0.11
ajv: 8.11.0
ajv-formats: 2.1.1
ajv-formats: 2.1.1_ajv@8.11.0
ajv-keywords: 5.1.0_ajv@8.11.0
dev: true