mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 19:16:29 +08:00
Feat/land page (#391)
* feat: update landing page * feat: update landing page * fix: react warning * feat(route): rename variables * feat(route): better refresh * fix: update logo and i18n * feat(code): remove unused comment * refactor(workspace): rename workspaceId * refactor(page): rename pageId * feat(edit): more robust editing experience * fix: landing page mobile * fix: landing page mobile Co-authored-by: tzhangchi <terry.zhangchi@outlook.com> Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com>
This commit is contained in:
@@ -265,37 +265,34 @@ export class EditorBlock extends ServiceBaseClass {
|
||||
}
|
||||
}
|
||||
async copyPage(
|
||||
workspace_id: string,
|
||||
source_page_id: string,
|
||||
new_page_id: string
|
||||
workspaceId: string,
|
||||
sourcePageId: string,
|
||||
newPageId: string
|
||||
): Promise<boolean> {
|
||||
const db = await this.database.getDatabase(workspace_id);
|
||||
const db = await this.database.getDatabase(workspaceId);
|
||||
|
||||
const source_page = await this.getBlock(
|
||||
workspace_id,
|
||||
source_page_id as 'block'
|
||||
const sourcePage = await this.getBlock(
|
||||
workspaceId,
|
||||
sourcePageId as 'block'
|
||||
);
|
||||
const new_page = await this.getBlock(
|
||||
workspace_id,
|
||||
new_page_id as 'block'
|
||||
);
|
||||
if (!source_page) {
|
||||
const newPage = await this.getBlock(workspaceId, newPageId as 'block');
|
||||
if (!sourcePage) {
|
||||
return false;
|
||||
}
|
||||
const source_page_children = source_page.children;
|
||||
const decorations = source_page.getDecorations();
|
||||
const sourcePageChildren = sourcePage.children;
|
||||
const decorations = sourcePage.getDecorations();
|
||||
Object.entries(decorations).forEach(([key, value]) => {
|
||||
new_page?.setDecoration(key, source_page.getDecoration(key));
|
||||
newPage?.setDecoration(key, sourcePage.getDecoration(key));
|
||||
});
|
||||
|
||||
//@ts-ignore
|
||||
this.decorate_page_title(new_page, 'copy from ');
|
||||
this.decorate_page_title(newPage, 'copy from ');
|
||||
|
||||
for (let i = 0; i < source_page_children.length; i++) {
|
||||
const source_page_child = await db.get(
|
||||
source_page_children[i] as 'block'
|
||||
for (let i = 0; i < sourcePageChildren.length; i++) {
|
||||
const sourcePageChild = await db.get(
|
||||
sourcePageChildren[i] as 'block'
|
||||
);
|
||||
new_page?.insertChildren(source_page_child);
|
||||
newPage?.insertChildren(sourcePageChild);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ export class YjsAdapter implements AsyncDatabaseAdapter<YjsContentOperation> {
|
||||
const [file] = (await fromEvent(handles)) as File[];
|
||||
const binary = await file?.arrayBuffer();
|
||||
console.log(this._provider.providers);
|
||||
let { indexeddb } = (
|
||||
const { indexeddb } = (
|
||||
this._provider.providers as any[]
|
||||
).find(p => p.indexeddb);
|
||||
await indexeddb?.idb?.clearData();
|
||||
@@ -391,9 +391,9 @@ export class YjsAdapter implements AsyncDatabaseAdapter<YjsContentOperation> {
|
||||
},
|
||||
parse: () => this._doc.toJSON(),
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
parse_page: (page_id: string) => {
|
||||
parse_page: (pageId: string) => {
|
||||
const blocks = this._blocks.toJSON();
|
||||
return resolve_block(blocks, page_id);
|
||||
return resolve_block(blocks, pageId);
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
parse_pages: (resolve = false) => {
|
||||
|
||||
@@ -9,7 +9,7 @@ const _currentEditors = atom<EditorsMap>({} as EditorsMap);
|
||||
|
||||
/** hook for using editors outside page */
|
||||
export const useCurrentEditors = () => {
|
||||
const { workspace_id: workspaceId, page_id: pageId } = useParams();
|
||||
const { workspaceId, pageId } = useParams();
|
||||
const { pathname } = useLocation();
|
||||
const [currentEditors, setCurrentEditors] = useAtom(_currentEditors);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
} from 'firebase/auth';
|
||||
import { atom, useAtom } from 'jotai';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { useLocation, useNavigate } from 'react-router';
|
||||
|
||||
import { useIdentifyUser } from '@toeverything/datasource/feature-flags';
|
||||
import { UserInfo } from '@toeverything/utils';
|
||||
@@ -63,15 +62,11 @@ const BRAND_ID = 'AFFiNE';
|
||||
|
||||
const _localTrigger = atom<boolean>(false);
|
||||
const _useUserAndSpacesForFreeLogin = () => {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const [user, setUser] = useAtom(_userAtom);
|
||||
const [loading, setLoading] = useAtom(_loadingAtom);
|
||||
const [localTrigger] = useAtom(_localTrigger);
|
||||
|
||||
useEffect(() => {
|
||||
if (loading) {
|
||||
navigate(`/${BRAND_ID}`);
|
||||
setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user