There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
Merge to master (#445)
zuomeng wangef707b95efb6
diff --git a/.github/deployment/Dockerfile-affine b/.github/deployment/Dockerfile-affineindex 76c317d6c8..b3d1fb367c 100644--- a/.github/deployment/Dockerfile-affine+++ b/.github/deployment/Dockerfile-affine@@ -1,5 +1,5 @@FROM node:16-alpine as builder-ARG HUBSPOT_API_SECRET+ARG AFFINE_EMBED_HEADERWORKDIR /appRUN apk add git && npm i -g pnpm@7COPY . .diff --git a/.github/workflows/livedemo.yml b/.github/workflows/livedemo.ymlindex 432fbaf13d..9be0843454 100644--- a/.github/workflows/livedemo.yml+++ b/.github/workflows/livedemo.yml@@ -71,7 +71,7 @@ jobs:tags: ${{ env.LOCAL_CACHE }}target: AFFiNEbuild-args: |- HUBSPOT_API_SECRET=${{ secrets.HUBSPOT_API_SECRET }}+ AFFINE_EMBED_HEADER=${{ secrets.AFFINE_EMBED_HEADER }}- name: Build and push Docker image (AFFINE-Local)uses: docker/build-push-action@v3diff --git a/README.md b/README.mdindex f988fe60da..6d8a76c67c 100644--- a/README.md+++ b/README.md@@ -135,7 +135,7 @@ We use the following open source projects to help us build a better developmentThanks a lot to the community for providing such powerful and simple libraries, so that we can focus more on the implementation of the product logic, and we hope that in the future our projects will also provide a more easy-to-use knowledge base for everyone.-You enjoy AFFiNE? You are not alone. [Some amazing companies](./docs/Jobs.md) are looking for developers with some AFFiNE and/or AFFiNE technology experience.+[Some amazing companies](./docs/jobs/summary.md), including AFFiNE are looking for developers! Are you interested in helping build with AFFiNE and/or its partners? Check out some of the latest [jobs available](./docs/jobs/summary.md).# Contributorsdiff --git a/apps/ligo-virgo/src/template.html b/apps/ligo-virgo/src/template.htmlindex badce60082..56d1a90123 100644--- a/apps/ligo-virgo/src/template.html+++ b/apps/ligo-virgo/src/template.html@@ -4,7 +4,7 @@<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title><%= htmlWebpackPlugin.options.title %></title>- <%= htmlWebpackPlugin.options.hubspotScript %>+ <%= htmlWebpackPlugin.options.embedHeaderScript %></head><body><div id="root"></div>diff --git a/apps/ligo-virgo/webpack.config.js b/apps/ligo-virgo/webpack.config.jsindex 4f14dba4c7..3b0750fade 100644--- a/apps/ligo-virgo/webpack.config.js+++ b/apps/ligo-virgo/webpack.config.js@@ -11,13 +11,7 @@ const TerserPlugin = require('terser-webpack-plugin');const Style9Plugin = require('style9/webpack');const enableBundleAnalyzer = process.env.BUNDLE_ANALYZER;--function generateHubspotScript() {- const hubspotApiSecret = process.env.HUBSPOT_API_SECRET;- if (hubspotApiSecret) {- return `<script type="text/javascript" id="hs-script-loader" async defer src="//js-na1.hs-scripts.com/${hubspotApiSecret}.js"></script>`;- }-}+const embedHeaderScript = process.env.AFFINE_EMBED_HEADER;module.exports = function (webpackConfig) {const config = getNxWebpackConfig(webpackConfig);@@ -185,7 +179,7 @@ module.exports = function (webpackConfig) {), //favicon pathtemplate: path.resolve(__dirname, './src/template.html'),publicPath: '/',- hubspotScript: generateHubspotScript(),+ embedHeaderScript,}),new Style9Plugin(),isProd &&diff --git a/apps/venus/src/app/i18n/resources/de.json b/apps/venus/src/app/i18n/resources/de.jsonnew file mode 100644index 0000000000..2a3c133e48--- /dev/null+++ b/apps/venus/src/app/i18n/resources/de.json@@ -0,0 +1,39 @@+{+ "Blog": "Blog",+ "AboutUs": "Über uns",+ "Open Source": "Open Source",+ "Docs": "Dokumentation",+ "Feedback": "Feedback",+ "ContactUs": "Kontaktiere uns",+ "Privacy First": "Privatsphären-respektierend",+ "Alternative": "Alternative",+ "Check GitHub": "Weitere Informationen befinden sich auf Github",+ "GitHub": "GitHub",+ "Try it Online": "Teste es online",+ "language": "Sprache",+ "description1": {+ "part1": "Affine ist die gemeinschaftliche Wissensdatenbank der nächsten Generation für Profis.",+ "part2": "Es ist nicht nur eine Sammlung von Dokumenten, Whiteboards und Tabellen.",+ "part3": "Ändere jeden Block, wie du ihn gerne hättest.",+ "part4": "Verabschiede dich von Redundanz. Speichere deine Daten einmalig und behalte sie wie du sie gerne hättest."+ },+ "description2": {+ "part1": "Gestalte deine Seite",+ "part2": "Dokumente, Kanbans und Datenbanken sind voll funktional - immer und überall. Eine wahrhaftige \"Was du siehst, ist das, was du bekommst.\"-Umgebung,",+ "part3": "Alle Seiten können wahlweise in einer Dokumenten- (Paper Mode) und einer Whiteboard-Ansicht (Edge less Mode) angezeigt werden."+ },+ "description3": {+ "part1": "Plane deine Aufgabe",+ "part2": "Kein Chaos mehr bei der Verwaltung mehrerer Ansichten.",+ "part3": "Erstelle eine TODO Listenelement und bearbeite es nahtlos in einem Kanban.",+ "part4": "Die Verwaltung von mehrdimensionalen Tabellen sollte einfach sein - und ist es jetzt auch."+ },+ "description4": {+ "part1": "Der Respekt deiner Privatsphäre und Zusammenarbeit stehen an erster Stelle. Keine Kompromisse.",+ "part2": "Wir lassen uns nicht gerne einschränken, und das sollten Sie auch nicht. Der Schutz der Privatsphäre ist die Grundlage für alles, was wir tun, aber sie sollte uns nicht aufhalten - deshalb gibt es keine Kompromisse.",+ "part3": "Ihre Daten gehören Ihnen; sie sind immer lokal gespeichert und gesichert und stehen Ihnen jederzeit zur Verfügung. Gleichzeitig können Sie die Funktionen für die Zusammenarbeit nutzen, z. B. die Bearbeitung in Echtzeit und die gemeinsame Nutzung mit anderen, ohne dass eine Cloud eingerichtet werden muss."+ },+ "BuildFor": "Build for an open and semantic future",+ "KeepUpdated": "Keep Updated on",+ "Join": "Join Our Community"+}diff --git a/apps/venus/src/app/i18n/resources/index.ts b/apps/venus/src/app/i18n/resources/index.tsindex fc6fb5cbde..7673a1d335 100644--- a/apps/venus/src/app/i18n/resources/index.ts+++ b/apps/venus/src/app/i18n/resources/index.ts@@ -1,7 +1,9 @@+import de from './de.json';import en from './en.json';import es from './es.json';-import zh_Hans from './zh.json';+import sr from './sr.json';import zh_Hant from './zh-Hant.json';+import zh_Hans from './zh.json';export const LOCALES = [{@@ -28,4 +30,16 @@ export const LOCALES = [originalName: 'español',res: es,},+ {+ name: 'Serbian',+ tag: 'sr',+ originalName: 'српски',+ res: sr,+ },+ {+ name: 'German',+ tag: 'de',+ originalName: 'Deutsch',+ res: de,+ },] as const;diff --git a/apps/venus/src/app/i18n/resources/sr.json b/apps/venus/src/app/i18n/resources/sr.jsonnew file mode 100644index 0000000000..ff853bbc4c--- /dev/null+++ b/apps/venus/src/app/i18n/resources/sr.json@@ -0,0 +1,39 @@+{+ "Blog": "Blog",+ "AboutUs": "O nama",+ "Open Source": "Otvoreni kod",+ "Docs": "Dokumenti",+ "Feedback": "Povratne informacije",+ "ContactUs": "Kontaktirajte nas",+ "Privacy First": "Privatnost na prvom mestu",+ "Alternative": "Alternativa",+ "Check GitHub": "Proveri GitHub",+ "GitHub": "GitHub",+ "Try it Online": "Probaj onlajn",+ "language": "Jezik",+ "description1": {+ "part1": "Affine je baza znanja sledeće generacije za profesionalce koja omogućava timski rad.",+ "part2": "Nije samo zbirka dokumenata, panela i tabela.",+ "part3": "Promeni svaki elemenat po svojoj želji.",+ "part4": "Bez nepotrebnosti. Sačuvaj svoje podatke jednom, i čuvaj ih onako kako ti to želiš."+ },+ "description2": {+ "part1": "Oblikuj svoju stranicu",+ "part2": "Dokumenti, Kanban-table i baze podataka su potpuno funkcionalne bilo kad i bilo gde. Prava ovo-što-vidiš-je-ono-što-dobijaš sredina za tvoje podatke.",+ "part3": "Sve stranice dolaze sa dokument-izgledom (Papirni način rada) i panel-izgledom (Bezokvirni način rada)."+ },+ "description3": {+ "part1": "Planiraj svoje zadatke",+ "part2": "Nema više haosa nastalog pri upravljanju višestrukim izgledima.",+ "part3": "Kreiraj TODO listu u Markdown i jednostavno je prilagođavaj u Kanban prikazu.",+ "part4": "Upravljanje multidimenzionalnim tabelama bi trebalo biti jednostavno, a sada i jeste."+ },+ "description4": {+ "part1": "Privatnost i timski rad na prvom mestu. Bez kompromisa bez obzira na sve.",+ "part2": "Ne volimo biti zatvoreni, a ne bi trebali to ni Vi. Privatnost je osnova svega što radimo, ali nas ona ne bi smela ni ograničavati i zato nema kompromisa.",+ "part3": "Vaši podaci su vaši; čuvaju se lokalno na Vašem računaru i uvek su Vam dostupni. Pritom ipak možete uživati u prednostima saradnje kao što su uređivanje i deljenje dokumenata u stvarnom vremenu s drugima, bez ikakvog postavljanja onlajn oblaka."+ },+ "BuildFor": "Stvoreno za otvorenu i semantičku budućnost",+ "KeepUpdated": "Ažuriraj",+ "Join": "Pridruži se zajednici"+}diff --git a/docs/Jobs.md b/docs/Jobs.mddeleted file mode 100644index 711d8ab5d1..0000000000--- a/docs/Jobs.md+++ /dev/null@@ -1,5 +0,0 @@-# Jobs--- [<b>Full Stack Platform Engineer</b>](./mysc.app.md) @[mysc.app](https://mysc.app/)-- Rust · GWST · Remote · Shanghai, Chinadiff --git a/docs/jobs/affine.pro.md b/docs/jobs/affine.pro.mdnew file mode 100644index 0000000000..fc17640469--- /dev/null+++ b/docs/jobs/affine.pro.md@@ -0,0 +1,50 @@+## Fullstack Engineer++The **AFFiNE** 's vision is to scale 100000+ organizations' teams and businesses faster and more efficiently.+We're hiring for multiple Fullstack Engineer positions across the building-blocks sub-team. The **building-blocks** team works to create the best **block-editor** and **open-block** protocol for AFFiNE Customers. This means people can manage their businesses and teams by AFFiNE.++## The work++### Below is a selection of the initiatives that you may work on:++- Contribute to **AFFiNE Open-Source**, including documents and code+- Improve provisioning and onboarding of new sales-assisted affine.com subscribers+- Improvement to Pager Editor and Edgeless Editor+- Improvement to Billable Members+- Research feedback for future-dated amendments in Subscription Admin+ At AFFiNE, developers are independent and self-organized individual contributors who work together as a tight team in a remote and agile way.++### What will you bring++- Professional software engineering experience with **editor** or **graphics** in large production environments+- Experience and proficiency in Rust, Go, or Java+- Production experience with JavaScript+- Significant experience with **React (ideal)**, Vue, and/or Angular.+- Significant experience with CSS, HTML semantics, and accessibility+- You have strong written communication skills+- You have demonstrated the ability to onboard and integrate with an organization long-term.+- You are comfortable working in a cross-functional organization+- You are able to use AFFiNE or productivity products+- You share our values and work in accordance with those values+ It would be great if you have+- Experience with license or subscription management+- Experience with SaaS billing+- Experience or familiarity with open source+- Experience with the AFFiNE product as a user or contributor+- Experience working with **a remote team**+- Enterprise software company experience+- Experience scaling **a successful SaaS product**+- Developer platform/tool industry experience+- Experience working with **a global team**++### What we offer++- Humanized office equipment (MacBook pro + iPad Air + ergonomic chair, lift table), equipment purchase authorization of $2800+- Except for public holidays, the annual paid annual leave is 12 working days, which can be increased year by year according to the working hours;+- Statutory holidays are not commuted, and additional 7+ holidays are obtained every year;+- Free lunch with gradually increasing meal standard;+- Travel and rent subsidies are customized according to individual needs;+- Unlimited drinks and snacks;+- Free IELTS test open to all employees;+- Flexible and optional social security and provident fund payment locations+- Become a maintainer of great open source projects and use Copilot powered by Github for freediff --git a/docs/mysc.app.md b/docs/jobs/mysc.app.mdsimilarity index 100%rename from docs/mysc.app.mdrename to docs/jobs/mysc.app.mddiff --git a/docs/jobs/summary.md b/docs/jobs/summary.mdnew file mode 100644index 0000000000..903f7071e7--- /dev/null+++ b/docs/jobs/summary.md@@ -0,0 +1,9 @@+# Jobs++- [<b>Fullstack Engineer</b>](./affine.pro.md) @[affine.pro](http://affine.pro/)++ Rust ·TS · Virgo · JWST · Remote , Global++- [<b>Full Stack Platform Engineer</b>](./mysc.app.md) @[mysc.app](https://mysc.app/)++ Rust · JWST · Remote · Shanghai, Chinadiff --git a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx b/libs/components/editor-blocks/src/blocks/code/CodeView.tsxindex 97f3c3bd83..b59dd73261 100644--- a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx+++ b/libs/components/editor-blocks/src/blocks/code/CodeView.tsx@@ -153,6 +153,7 @@ export const CodeView = ({ block, editor }: CreateCodeView) => {const langType: string = block.getProperty('lang');const [extensions, setExtensions] = useState<Extension[]>();const [showOperationPanel, setShowOperationPanel] = useState(false);+ const [selectOpen, setSelectOpen] = useState(false);const isSelecting = useRef(false);const codeMirror = useRef<ReactCodeMirrorRef>();const focusCode = () => {@@ -197,6 +198,7 @@ export const CodeView = ({ block, editor }: CreateCodeView) => {setShowOperationPanel(true);}}onMouseLeave={() => {+ setSelectOpen(false);!isSelecting.current && setShowOperationPanel(false);}}>@@ -210,9 +212,11 @@ export const CodeView = ({ block, editor }: CreateCodeView) => {onChange={(selectedValue: string) => {handleLangChange(selectedValue);}}- onListboxOpenChange={() => {+ onListboxOpenChange={open => {+ setSelectOpen(open);isSelecting.current = true;}}+ open={selectOpen}>{Object.keys(langs).map(item => {return (diff --git a/libs/components/ui/src/select/Select.tsx b/libs/components/ui/src/select/Select.tsxindex f43452edea..9012e2358e 100644--- a/libs/components/ui/src/select/Select.tsx+++ b/libs/components/ui/src/select/Select.tsx@@ -5,6 +5,7 @@ import {type ForwardedRef,type ReactNode,type RefAttributes,+ useEffect,} from 'react';/* eslint-disable no-restricted-imports */import SelectUnstyled, {@@ -15,13 +16,13 @@ import SelectUnstyled, {import PopperUnstyled from '@mui/base/PopperUnstyled';import { ArrowDropDownIcon } from '@toeverything/components/icons';import { styled } from '../styled';-type ExtendSelectProps = {// Width is always used custom, it will be set to root button and popoverwidth?: number | string;style?: CSSProperties;listboxStyle?: CSSProperties;placeholder?: ReactNode;+ open?: boolean;};/**@@ -40,7 +41,6 @@ export const Select = forwardRef(function CustomSelect<TValue>(props: ExtendSelectProps & SelectUnstyledProps<TValue>,ref: ForwardedRef<HTMLUListElement>) {- const [isOpen, setIsOpen] = useState(false);const {width = '100%',style,@@ -48,7 +48,11 @@ export const Select = forwardRef(function CustomSelect<TValue>(placeholder,onListboxOpenChange,onChange,+ open: propsOpen,} = props;+ const openControlledByProps = propsOpen !== undefined;+ const [isOpen, setIsOpen] = useState(false);+const components: SelectUnstyledProps<TValue>['components'] = {// Root: generateStyledRoot({ width, ...style }),Root: forwardRef((rootProps, rootRef) => {@@ -88,13 +92,13 @@ export const Select = forwardRef(function CustomSelect<TValue>(return (<SelectUnstyled{...props}- listboxOpen={isOpen}+ listboxOpen={openControlledByProps ? propsOpen : isOpen}onListboxOpenChange={open => {- setIsOpen(open);+ !openControlledByProps && setIsOpen(open);onListboxOpenChange?.(open);}}onChange={v => {- setIsOpen(false);+ !openControlledByProps && setIsOpen(false);onChange?.(v);}}ref={ref}diff --git a/libs/datasource/db-service/src/services/database/index.ts b/libs/datasource/db-service/src/services/database/index.tsindex 8bee9f6028..700b8511b9 100644--- a/libs/datasource/db-service/src/services/database/index.ts+++ b/libs/datasource/db-service/src/services/database/index.ts@@ -8,21 +8,12 @@ import {BlockMatcher,Connectivity,} from '@toeverything/datasource/jwt';-import { sleep } from '@toeverything/utils';import type { ObserveCallback, ReturnUnobserve } from './observer';import { getObserverName, ObserverManager } from './observer';export type { ObserveCallback, ReturnUnobserve } from './observer';-const workspaces: Record<string, BlockClientInstance> = {};--const loading = new Set();--const waitLoading = async (key: string) => {- while (loading.has(key)) {- await sleep(50);- }-};+const workspaces: Record<string, Promise<BlockClientInstance>> = {};async function _getCurrentToken() {if (!process.env['NX_LOCAL']) {@@ -48,20 +39,15 @@ async function _getBlockDatabase(workspace: string,options?: BlockInitOptions) {- if (loading.has(workspace)) {- await waitLoading(workspace);- }-if (!workspaces[workspace]) {- loading.add(workspace);- workspaces[workspace] = await BlockClient.init(workspace, {- enabled: _enabled[workspace] || ['idb'],- ...options,- token: await _getCurrentToken(),- });+ workspaces[workspace] = _getCurrentToken().then(token =>+ BlockClient.init(workspace, {+ enabled: _enabled[workspace] || ['idb'],+ ...options,+ token,+ })+ );(window as any).client = workspaces[workspace];- await workspaces[workspace].buildIndex();- loading.delete(workspace);}return workspaces[workspace];}diff --git a/libs/datasource/jwt/src/index.ts b/libs/datasource/jwt/src/index.tsindex 626e6a3c89..fe4692957b 100644--- a/libs/datasource/jwt/src/index.ts+++ b/libs/datasource/jwt/src/index.ts@@ -641,7 +641,7 @@ export class BlockClient<const { importData, exportData, hasExporter, installExporter } =getDataExporter();- const instance = await YjsAdapter.init(workspace, {+ const yjsAdapter = await YjsAdapter.init(workspace, {provider: getYjsProviders({enabled: [],backend: BucketBackend.YjsWebSocketAffine,@@ -652,10 +652,17 @@ export class BlockClient<}),...options,});- return new BlockClient(instance, workspace, {- ...options,- installExporter,- });++ const blockClient: BlockClientInstance = new BlockClient(+ yjsAdapter,+ workspace,+ {+ ...options,+ installExporter,+ }+ );+ await blockClient.buildIndex();+ return blockClient;}}diff --git a/libs/datasource/jwt/src/types/index.ts b/libs/datasource/jwt/src/types/index.tsindex 7e54afc6bf..ffbe912045 100644--- a/libs/datasource/jwt/src/types/index.ts+++ b/libs/datasource/jwt/src/types/index.ts@@ -16,9 +16,7 @@ function getLocation() {function getCollaborationPoint() {const { protocol, host } = getLocation();const ws = protocol.startsWith('https') ? 'wss' : 'ws';- const isOnline = host.endsWith('affine.pro');- const site = isOnline ? host : 'localhost:3000';- return `${ws}://${site}/collaboration/`;+ return `${ws}://${host}/collaboration/`;}export const BucketBackend = {diff --git a/libs/datasource/jwt/src/yjs/provider.ts b/libs/datasource/jwt/src/yjs/provider.tsindex ad7df930e5..a444dc0a43 100644--- a/libs/datasource/jwt/src/yjs/provider.ts+++ b/libs/datasource/jwt/src/yjs/provider.ts@@ -118,7 +118,7 @@ export const getYjsProviders = (// TODO: synced will also be triggered on reconnection after losing sync// There needs to be an event mechanism to emit the synchronization state to the upper layerws.once('synced', () => resolve());- ws.once('lost-connection', () => resolve());+ ws.once('lost-connection', () => reject());ws.once('connection-error', () => reject());ws.on('synced', () => instances.emitState('connected'));ws.on('lost-connection', () =>