From 8984bedec9efcfb4998e615b892983c990919839 Mon Sep 17 00:00:00 2001 From: zuomeng wang Date: Thu, 15 Sep 2022 14:46:40 +0800 Subject: [PATCH 1/2] Fix/venus spanish (#423) (#425) fix: update venus spanish language Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> --- apps/venus/src/app/i18n/resources/es.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/venus/src/app/i18n/resources/es.json b/apps/venus/src/app/i18n/resources/es.json index 034eb54f70..29aefcd807 100644 --- a/apps/venus/src/app/i18n/resources/es.json +++ b/apps/venus/src/app/i18n/resources/es.json @@ -1,4 +1,10 @@ { + "Blog": "Blog", + "AboutUs": "Acerca de nosotros.", + "Open Source": "Código abierto", + "Docs": "Documentos", + "Feedback": "Comentarios", + "ContactUs": "Contáctenos", "Alternative": "Alternativa", "BuildFor": "Construir por un futuro abierto y semántico", "Check GitHub": "Revisar en GitHub", @@ -7,6 +13,7 @@ "Open Source": "Código abierto", "Privacy First": "La privacidad es lo primero", "Try it Online": "Prueba Online", + "language": "Idioma", "description1": { "part1": "Affine es un base de conocimiento colaborativa de próxima generación para los profesionales.", "part2": "Es más que una simple colección de Documentos, Pizarra y Tablas.", From c010e05023ed0f23f4dc272a6627da458edd2f59 Mon Sep 17 00:00:00 2001 From: zuomeng wang Date: Mon, 19 Sep 2022 15:57:48 +0800 Subject: [PATCH 2/2] Merge to master (#435) * Fix/venus spanish (#423) fix: update venus spanish language Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> * fix: can not convert url text to link after paste * fix: double link icon size error * feat(code): enhance markdown parse code * fix(code): add robust * fix: remove special menu * chore: clean code * fix: ime with command menu * fix(code): langs[lang] is not a function * fix: can't add image and delete more action button (#430) * feat: add zh_Hant for venus (#431) * fix: lang select in code block is insanity * GitHub Doc Updates (#421) * Update types-of-contributions.md * Update README.md Tidy up links section * fix: inline menu position (#433) Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> Co-authored-by: QiShaoXuan Co-authored-by: tzhangchi Co-authored-by: lawvs <18554747+lawvs@users.noreply.github.com> Co-authored-by: DiamondThree Co-authored-by: CJSS Co-authored-by: Qi <474021214@qq.com> --- README.md | 18 +- apps/venus/src/app/i18n/resources/index.ts | 7 + .../venus/src/app/i18n/resources/zh-Hant.json | 39 ++ docs/types-of-contributions.md | 4 +- .../affine-editor/src/create-editor.ts | 2 +- libs/components/common/src/lib/list/index.tsx | 12 +- .../src/lib/text/plugins/DoubleLink.tsx | 16 +- libs/components/editor-blocks/package.json | 3 +- .../src/blocks/code/CodeView.tsx | 29 +- .../editor-blocks/src/blocks/code/index.ts | 32 +- .../src/blocks/image/ImageView.tsx | 4 +- .../src/blocks/text/TextBlock.tsx | 20 +- .../src/blocks/text/TextView.tsx | 7 +- .../src/editor/clipboard/clipboardUtils.ts | 49 +- .../editor-core/src/editor/clipboard/utils.ts | 28 + .../src/menu/command-menu/CommandMenu.tsx | 3 +- .../src/menu/command-menu/Container.tsx | 104 +-- .../src/menu/command-menu/Menu.tsx | 34 +- .../src/menu/command-menu/config.ts | 40 +- .../src/menu/inline-menu/Container.tsx | 24 +- .../src/menu/inline-menu/utils.ts | 15 +- libs/components/ui/src/select/Select.tsx | 20 +- libs/components/ui/src/theme/theme.ts | 2 + pnpm-lock.yaml | 630 ++++++++---------- 24 files changed, 614 insertions(+), 528 deletions(-) create mode 100644 apps/venus/src/app/i18n/resources/zh-Hant.json diff --git a/README.md b/README.md index 0f43ad56db..f988fe60da 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,10 @@ See https://github.com/all-?/all-contributors/issues/361#issuecomment-637166066 [![affine.pro](https://img.shields.io/static/v1?label=Try%20it%20Online&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAhpJREFUWEdjZEACtnl3MxgY/0YzMjAaMzAwcCLLUYH9/T/D/7MM/5mXHp6kPANmHiOI4Zx9Xfg3C+tKBob/zlSwiAgjGPey/vkdvneq5luwA+zy7+yhn+Vwv+89NFHFhREU7IyM/6YT4WyqK/n/nymT0Tb/1mFGBkYbqptOhIH/Gf4fYbTLv/2NBgmOCOvBSr6DHPCfWNW0UEe2A2x1uRlakiXBbtpx6jND+7KXZLmPbAdURokzeJjxwi31rrzH8OX7P5IdQbYDtnUoMXBzMMEt7Fj2imH7qU/0cQBy8MNsPHL5K0P13Of0cQB68MNsJScaSI4CHk4mhq3tSnCf3n36k0FZmh3Mn7L+DcPqgx9ICgWSHeBpxsdQESUGtgRk+eqDH+H8O09/MiR3P6atA1qTJRlsdLnhPgYlPOQQCW96wPDi3R+iHUFSCKAHP8wydEeREg0kOQA9+JOgwR1qL8CQEygC9jWp0UCSA+aVysIT3JqDHxgmr38DtlRCiIVhZZ0CPNhB6QDkEGIA0Q4gZAkuxxFyBNEOQA7ml+/+MIQ1PUAxG1kelAhB6YMYQLQDCPmQUAjhcgxRDiDWcEKOxOYIohyQGyjCEGIvANaPLfhhBiNHA6hmBBXNhABRDgCV/aBQAAFQpYMrn4PUgNTCACiXEMoNRDmAkC8okR8UDhjYRumAN8sHvGMCSkAD2jUDOWDAO6ewbDQQ3XMAy/oxKownQR0AAAAASUVORK5CYII=&message=%E2%86%92&style=for-the-badge)](https://affine.pro) No installation or registration required! Head over to our website and try it out now. Want to deploy it yourself? AFFiNE can run just about anywhere.
-You can refer to our documentation which can be found from the [useful links](#useful-links) section - where you will also find ways to help contribute to the project and join our communities. + +[AFFiNE Documentation](https://docs.affine.pro/affine/) - More detailed documentation on how to use and develop with AFFiNE + +AFFiNE Communities: [Discord](https://discord.gg/yz6tGVsf5p) | [Telegram](https://t.me/affineworkos) | [Twitter](https://twitter.com/AffineOfficial)

⚠️ Please note that AFFiNE is still under active development and is not yet ready for production use. ⚠️ @@ -80,19 +83,6 @@ And when it comes to collaboration, these features are not just necessarily for ![c9e1ff46-cec2-411b-b89d-6727a5e6f6c3](https://user-images.githubusercontent.com/79301703/182366602-08e44d28-a031-4097-9904-52fb9b1e9e17.gif) -# Useful Links - -- [AFFiNE Documentation](https://docs.affine.pro/affine/) - More detailed documentation on how to use and develop with AFFiNE - -- [Feature Roadmap](https://github.com/toeverything/AFFiNE/issues/293) - Looking for a feature? It might already be planned for release - you can check here -- [Release Notes](https://github.com/toeverything/AFFiNE/wiki) - Find out what changes we are making and how we are improving AFFiNE - -- [Contributing Guide](/docs/CONTRIBUTING.md) - Want to help improve AFFiNE? You might not even need to write a line of code. Find out how you can contribute. -- [Code of Conduct](/docs/CODE_OF_CONDUCT.md) - How we promote and maintain a harassment-free experience for everyone in our community. - -- AFFiNE Communities: [Discord](https://discord.gg/yz6tGVsf5p) | [Telegram](https://t.me/affineworkos) | [Twitter](https://twitter.com/AffineOfficial) | - [Medium](https://medium.com/@affineworkos) | [AFFiNE Blog](https://blog.affine.pro) - # Contact Us Feel free to send us an email: contact@toeverything.info diff --git a/apps/venus/src/app/i18n/resources/index.ts b/apps/venus/src/app/i18n/resources/index.ts index 424560a398..fc6fb5cbde 100644 --- a/apps/venus/src/app/i18n/resources/index.ts +++ b/apps/venus/src/app/i18n/resources/index.ts @@ -1,6 +1,7 @@ import en from './en.json'; import es from './es.json'; import zh_Hans from './zh.json'; +import zh_Hant from './zh-Hant.json'; export const LOCALES = [ { @@ -15,6 +16,12 @@ export const LOCALES = [ originalName: '简体中文', res: zh_Hans, }, + { + name: 'Traditional Chinese', + tag: 'zh-Hant', + originalName: '繁體中文', + res: zh_Hant, + }, { name: 'Spanish', tag: 'es', diff --git a/apps/venus/src/app/i18n/resources/zh-Hant.json b/apps/venus/src/app/i18n/resources/zh-Hant.json new file mode 100644 index 0000000000..879e755568 --- /dev/null +++ b/apps/venus/src/app/i18n/resources/zh-Hant.json @@ -0,0 +1,39 @@ +{ + "Blog": "博客", + "AboutUs": "關於我們", + "Open Source": "開源", + "Docs": "文檔", + "Feedback": "反饋", + "ContactUs": "聯繫我們", + "Privacy First": "隱私第一", + "Alternative": "的另一種選擇", + "Check GitHub": "在 Github 中查看", + "GitHub": "GitHub", + "Try it Online": "在線嘗試", + "language": "語言", + "description1": { + "part1": "Affine 是面向專業用戶的下一代協同知識庫", + "part2": "Affine 不僅僅集合着文檔、白板和表格。", + "part3": "隨心所欲切換構塊模式。", + "part4": "告別冗余,存儲數據一次就好,放在任何您想要的位置。" + }, + "description2": { + "part1": "塑形您的頁面", + "part2": "隨時隨地,文檔、看板、數據庫都完全可用。真正“所見即所得”的數據處理環境。", + "part3": "所有頁面都配備文檔(紙張模式)和白板(無邊緣模式)視圖。" + }, + "description3": { + "part1": "計畫您的任務", + "part2": "多視圖管理不再混亂。", + "part3": "既可使用 Markdown 設置 TODO,又可無縫在看板視圖中編輯。", + "part4": "管理多維表格本當易如反掌——攜手Affine,确实易如反掌" + }, + "description4": { + "part1": "隱私第一,合作無間,毫不妥協。", + "part2": "我們不喜歡被軟件綁架,您也是。我們的任何努力雖建立在尊重用戶隱私基礎上,也游刃有餘。這解釋了為什麼我們毫不妥協。", + "part3": "您創造的數據屬於您,安全永久存儲在本地供您隨時調用。同時您也能盡享協同的便利,無需雲設置就能實時編輯、共享給他人。" + }, + "BuildFor": "構建一個開放和語義化的未來", + "KeepUpdated": "持續更新在", + "Join": "加入我們的社群" +} diff --git a/docs/types-of-contributions.md b/docs/types-of-contributions.md index fd448200e9..9e2a647a0f 100644 --- a/docs/types-of-contributions.md +++ b/docs/types-of-contributions.md @@ -26,6 +26,4 @@ You may be able to find additional help and information on our social media plat ### :earth_asia: Translations -AFFiNE is internationalized and available in multiple languages. The source content in this repository is written in English. We integrate with an external localization platform to work with the community in localizing the English content. - -**We do not currently offer this feature**, but we hope to in the future. +AFFiNE is internationalized and available in multiple languages. The source content in this repository is written in English. We integrate with an external localization platform to work with the community in localizing the English content. You can find more info in our [internationalization docs](https://docs.affine.pro/affine/internationalization/welcome). diff --git a/libs/components/affine-editor/src/create-editor.ts b/libs/components/affine-editor/src/create-editor.ts index 6075e7a9af..052cfbc317 100644 --- a/libs/components/affine-editor/src/create-editor.ts +++ b/libs/components/affine-editor/src/create-editor.ts @@ -38,13 +38,13 @@ export const createEditor = ( views: { [Protocol.Block.Type.page]: new PageBlock(), [Protocol.Block.Type.reference]: new RefLinkBlock(), + [Protocol.Block.Type.code]: new CodeBlock(), [Protocol.Block.Type.text]: new TextBlock(), [Protocol.Block.Type.heading1]: new Heading1Block(), [Protocol.Block.Type.heading2]: new Heading2Block(), [Protocol.Block.Type.heading3]: new Heading3Block(), [Protocol.Block.Type.quote]: new QuoteBlock(), [Protocol.Block.Type.todo]: new TodoBlock(), - [Protocol.Block.Type.code]: new CodeBlock(), // [Protocol.Block.Type.toc]: new TocBlock(), [Protocol.Block.Type.file]: new FileBlock(), [Protocol.Block.Type.image]: new ImageBlock(), diff --git a/libs/components/common/src/lib/list/index.tsx b/libs/components/common/src/lib/list/index.tsx index c00a4e1415..c1ec42557d 100644 --- a/libs/components/common/src/lib/list/index.tsx +++ b/libs/components/common/src/lib/list/index.tsx @@ -39,14 +39,6 @@ type MenuItemsProps = { export const CommonList = (props: MenuItemsProps) => { const { items, currentItem, setCurrentItem, onSelected } = props; - // const JSONUnsupportedBlockTypes = useFlag('JSONUnsupportedBlockTypes', [ - // 'page', - // ]); - // TODO Insert bidirectional link to be developed - const JSONUnsupportedBlockTypes = ['page']; - const usedItems = items.filter(item => { - return !JSONUnsupportedBlockTypes.includes(item?.content?.id); - }); return (
{ commonListContainer, ])} > - {usedItems?.length ? ( - usedItems.map((item, idx) => { + {items?.length ? ( + items.map((item, idx) => { if (item.renderCustom) { return item.renderCustom(item); } else if (item.block) { diff --git a/libs/components/common/src/lib/text/plugins/DoubleLink.tsx b/libs/components/common/src/lib/text/plugins/DoubleLink.tsx index 42f50740f3..aa823feb36 100644 --- a/libs/components/common/src/lib/text/plugins/DoubleLink.tsx +++ b/libs/components/common/src/lib/text/plugins/DoubleLink.tsx @@ -3,6 +3,7 @@ import React, { useCallback } from 'react'; import { useNavigate } from 'react-router-dom'; import { Descendant } from 'slate'; import { RenderElementProps } from 'slate-react'; +import { styled } from '@toeverything/components/ui'; export type DoubleLinkElement = { type: 'link'; @@ -13,6 +14,10 @@ export type DoubleLinkElement = { id: string; }; +const StyledLink = styled('a')({ + cursor: 'pointer', +}); + export const DoubleLinkComponent = (props: RenderElementProps) => { const { attributes, children, element } = props; const doubleLinkElement = element as DoubleLinkElement; @@ -32,15 +37,20 @@ export const DoubleLinkComponent = (props: RenderElementProps) => { return ( - + {children} {displayValue} - + ); }; diff --git a/libs/components/editor-blocks/package.json b/libs/components/editor-blocks/package.json index 04d8e0e544..9dce9d70c2 100644 --- a/libs/components/editor-blocks/package.json +++ b/libs/components/editor-blocks/package.json @@ -38,7 +38,8 @@ "react-window": "^1.8.7", "slate": "^0.81.1", "slate-react": "^0.81.0", - "style9": "^0.14.0" + "style9": "^0.14.0", + "html-escaper": "^3.0.3" }, "devDependencies": { "@types/codemirror": "^5.60.5", diff --git a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx b/libs/components/editor-blocks/src/blocks/code/CodeView.tsx index a6a47e261c..97f3c3bd83 100644 --- a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx +++ b/libs/components/editor-blocks/src/blocks/code/CodeView.tsx @@ -116,7 +116,7 @@ const CodeBlock = styled('div')(({ theme }) => ({ flexWrap: 'wrap', justifyContent: 'space-between', opacity: 0, - transition: 'opacity 1.5s', + transition: 'opacity .15s', }, '.copy-block': { padding: '0px 10px', @@ -139,10 +139,21 @@ const CodeBlock = styled('div')(({ theme }) => ({ outline: 'none !important', }, })); +const StyledOperationalPanel = styled('div')<{ show: boolean }>(({ show }) => { + return { + display: 'flex', + flexWrap: 'wrap', + justifyContent: 'space-between', + opacity: show ? 1 : 0, + transition: 'opacity .15s', + }; +}); export const CodeView = ({ block, editor }: CreateCodeView) => { const initValue: string = block.getProperty('text')?.value?.[0]?.text; const langType: string = block.getProperty('lang'); const [extensions, setExtensions] = useState(); + const [showOperationPanel, setShowOperationPanel] = useState(false); + const isSelecting = useRef(false); const codeMirror = useRef(); const focusCode = () => { if (codeMirror.current) { @@ -160,7 +171,7 @@ export const CodeView = ({ block, editor }: CreateCodeView) => { }; const handleLangChange = (lang: string) => { block.setProperty('lang', lang); - setExtensions([langs[lang]()]); + langs[lang] && setExtensions([langs[lang]()]); }; useEffect(() => { handleLangChange(langType ? langType : DEFAULT_LANG); @@ -181,8 +192,15 @@ export const CodeView = ({ block, editor }: CreateCodeView) => { onKeyDown={e => { e.stopPropagation(); }} + onMouseEnter={() => { + isSelecting.current = false; + setShowOperationPanel(true); + }} + onMouseLeave={() => { + !isSelecting.current && setShowOperationPanel(false); + }} > -
+