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
feat: publish local workspace (#1406)
Himself65f17283173367
diff --git a/apps/web/src/components/affine/enable-affine-cloud-modal/index.tsx b/apps/web/src/components/affine/enable-affine-cloud-modal/index.tsxindex 5d3c73ae87..3b7f4fc775 100644--- a/apps/web/src/components/affine/enable-affine-cloud-modal/index.tsx+++ b/apps/web/src/components/affine/enable-affine-cloud-modal/index.tsx@@ -4,11 +4,9 @@ import { CloseIcon } from '@blocksuite/icons';import React from 'react';import { useCurrentUser } from '../../../hooks/current/use-current-user';-import { AffineWorkspace } from '../../../shared';import { Content, ContentTitle, Header, StyleButton, StyleTips } from './style';interface EnableAffineCloudModalProps {- workspace: AffineWorkspace;open: boolean;onConfirm: () => void;onClose: () => void;diff --git a/apps/web/src/components/affine/workspace-setting-detail/panel/publish/index.tsx b/apps/web/src/components/affine/workspace-setting-detail/panel/publish/index.tsxindex af1503101a..07e5b24e55 100644--- a/apps/web/src/components/affine/workspace-setting-detail/panel/publish/index.tsx+++ b/apps/web/src/components/affine/workspace-setting-detail/panel/publish/index.tsx@@ -7,24 +7,27 @@ import {Wrapper,} from '@affine/component';import { useTranslation } from '@affine/i18n';+import { Box } from '@mui/material';import React, { useCallback, useEffect, useState } from 'react';-import { lockMutex } from '../../../../../atoms';import { useToggleWorkspacePublish } from '../../../../../hooks/affine/use-toggle-workspace-publish';+import { transformWorkspace } from '../../../../../plugins';import {AffineOfficialWorkspace,AffineWorkspace,LocalWorkspace,RemWorkspaceFlavour,} from '../../../../../shared';+import { apis } from '../../../../../shared/apis';import { Unreachable } from '../../../affine-error-eoundary';import { EnableAffineCloudModal } from '../../../enable-affine-cloud-modal';+import { WorkspaceSettingDetailProps } from '../../index';-export type PublishPanelProps = {+export type PublishPanelProps = WorkspaceSettingDetailProps & {workspace: AffineOfficialWorkspace;};-export type PublishPanelAffineProps = {+export type PublishPanelAffineProps = WorkspaceSettingDetailProps & {workspace: AffineWorkspace;};@@ -70,9 +73,7 @@ const PublishPanelAffine: React.FC<PublishPanelAffineProps> = ({</FlexWrapper><ButtononClick={async () => {- lockMutex(async () => {- return publishWorkspace(false);- });+ await publishWorkspace(false);}}loading={false}type="danger"@@ -97,51 +98,76 @@ const PublishPanelAffine: React.FC<PublishPanelAffineProps> = ({{t('Publish to web')}</Button><EnableAffineCloudModal- workspace={workspace}open={open}onClose={() => {setOpen(false);}}- onConfirm={() => {- lockMutex(async () => {- return publishWorkspace(true);- }).then(() => {- setOpen(false);- });+ onConfirm={async () => {+ await publishWorkspace(true);+ setOpen(false);}}/></>);};-export type PublishPanelLocalProps = {+export type PublishPanelLocalProps = WorkspaceSettingDetailProps & {workspace: LocalWorkspace;};-const PublishPanelLocal: React.FC<PublishPanelLocalProps> = ({ workspace }) => {+const PublishPanelLocal: React.FC<PublishPanelLocalProps> = ({+ workspace,+ onTransferWorkspace,+}) => {const { t } = useTranslation();+ const [open, setOpen] = useState(false);return (<>- <Wrapper marginBottom="42px">{t('Publishing')}</Wrapper>+ <Box+ sx={{+ marginBottom: '42px',+ }}+ >+ {t('Publishing')}+ </Box><Buttontype="light"shape="circle"- onClick={async () => {- // fixme: regression- toast('You need to enable AFFiNE Cloud to use this feature.');+ onClick={() => {+ setOpen(true);}}>{t('Enable AFFiNE Cloud')}</Button>+ <EnableAffineCloudModal+ open={open}+ onClose={() => {+ setOpen(false);+ }}+ onConfirm={async () => {+ const id = await transformWorkspace(+ RemWorkspaceFlavour.LOCAL,+ RemWorkspaceFlavour.AFFINE,+ workspace+ );+ await apis.updateWorkspace({+ id,+ public: true,+ });+ // fixme: there imply that reload the whole page+ onTransferWorkspace(id);+ setOpen(false);+ }}+ /></>);};-export const PublishPanel: React.FC<PublishPanelProps> = ({ workspace }) => {- if (workspace.flavour === RemWorkspaceFlavour.AFFINE) {- return <PublishPanelAffine workspace={workspace} />;- } else if (workspace.flavour === RemWorkspaceFlavour.LOCAL) {- return <PublishPanelLocal workspace={workspace} />;+export const PublishPanel: React.FC<PublishPanelProps> = props => {+ if (props.workspace.flavour === RemWorkspaceFlavour.AFFINE) {+ return <PublishPanelAffine {...props} workspace={props.workspace} />;+ } else if (props.workspace.flavour === RemWorkspaceFlavour.LOCAL) {+ return <PublishPanelLocal {...props} workspace={props.workspace} />;}throw new Unreachable();};diff --git a/apps/web/src/components/blocksuite/block-suite-editor/index.tsx b/apps/web/src/components/blocksuite/block-suite-editor/index.tsxindex b0ab1a7239..56783564c9 100644--- a/apps/web/src/components/blocksuite/block-suite-editor/index.tsx+++ b/apps/web/src/components/blocksuite/block-suite-editor/index.tsx@@ -1,3 +1,5 @@+import '@blocksuite/editor/themes/affine.css';+import { config } from '@affine/env';import { BlockHub } from '@blocksuite/blocks';import { EditorContainer } from '@blocksuite/editor';diff --git a/apps/web/src/pages/_app.tsx b/apps/web/src/pages/_app.tsxindex 4be54dbd9e..dd52ef69af 100644--- a/apps/web/src/pages/_app.tsx+++ b/apps/web/src/pages/_app.tsx@@ -1,4 +1,3 @@-import '@blocksuite/editor/themes/affine.css';import '../styles/globals.css';import { config, setupGlobal } from '@affine/env';diff --git a/apps/web/src/pages/workspace/[workspaceId]/setting.tsx b/apps/web/src/pages/workspace/[workspaceId]/setting.tsxindex 6bf64ad03d..1485446c3f 100644--- a/apps/web/src/pages/workspace/[workspaceId]/setting.tsx+++ b/apps/web/src/pages/workspace/[workspaceId]/setting.tsx@@ -102,8 +102,9 @@ const SettingPage: NextPageWithLayout = () => {(targetWorkspaceId: string) => {router.replace({- pathname: `/workspace/[workspaceId]/all`,+ pathname: `/workspace/[workspaceId]/setting`,query: {+ ...router.query,workspaceId: targetWorkspaceId,},})diff --git a/apps/web/src/providers/ThemeProvider.tsx b/apps/web/src/providers/ThemeProvider.tsxindex 49dbd0da48..ccbddd5e75 100644--- a/apps/web/src/providers/ThemeProvider.tsx+++ b/apps/web/src/providers/ThemeProvider.tsx@@ -20,7 +20,14 @@ const ThemeInjector = React.memo<{return (<GlobalStylesstyles={{- '#__next': globalThemeVariables(themeStyle) as any,+ '#__next': {+ ...globalThemeVariables(themeStyle),+ },+ html: {+ fontFamily: themeStyle.font.family,+ fontSize: themeStyle.font.base,+ lineHeight: themeStyle.font.lineHeight,+ },}}/>);diff --git a/apps/web/src/styles/globals.css b/apps/web/src/styles/globals.cssindex 18da472e3c..c61cddde65 100644--- a/apps/web/src/styles/globals.css+++ b/apps/web/src/styles/globals.css@@ -149,7 +149,6 @@ legend {border: 0;font-size: var(--affine-font-base);line-height: var(--affine-line-height);- color: var(--affine-text-color);font-family: var(--affine-font-family);}body {