+
{item.name || t('document.title.placeholder')}
{dayjs.unix(item.modifiedTime).format('MM/DD/YYYY hh:mm A')}
{dayjs.unix(item.createTime).format('MM/DD/YYYY hh:mm A')}
- onPutback(item.id)} className={'mr-2'}>
+ onPutback(item.id)} className={'mr-2'}>
- onDelete([item.id])}>
+ onDelete([item.id])}>
diff --git a/frontend/appflowy_tauri/src/appflowy_app/hooks/page.hooks.tsx b/frontend/appflowy_tauri/src/appflowy_app/hooks/page.hooks.tsx
new file mode 100644
index 0000000000..49e01e75c0
--- /dev/null
+++ b/frontend/appflowy_tauri/src/appflowy_app/hooks/page.hooks.tsx
@@ -0,0 +1,26 @@
+import { ViewLayoutPB } from '@/services/backend';
+import React from 'react';
+import { Page } from '$app_reducers/pages/slice';
+import { ReactComponent as DocumentIcon } from '$app/assets/document.svg';
+import { ReactComponent as GridIcon } from '$app/assets/grid.svg';
+import { ReactComponent as BoardIcon } from '$app/assets/board.svg';
+import { ReactComponent as CalendarIcon } from '$app/assets/date.svg';
+
+export function getPageIcon(page: Page) {
+ if (page.icon) {
+ return page.icon.value;
+ }
+
+ switch (page.layout) {
+ case ViewLayoutPB.Document:
+ return ;
+ case ViewLayoutPB.Grid:
+ return ;
+ case ViewLayoutPB.Board:
+ return ;
+ case ViewLayoutPB.Calendar:
+ return ;
+ default:
+ return null;
+ }
+}
diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/current-user/slice.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/current-user/slice.ts
index 8bb8d42b0e..13ad581175 100644
--- a/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/current-user/slice.ts
+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/current-user/slice.ts
@@ -8,6 +8,7 @@ export interface UserSetting {
theme?: Theme;
themeMode?: ThemeMode;
language?: string;
+ isDark?: boolean;
}
export enum Theme {
diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/pages/async_actions.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/pages/async_actions.ts
index 23f4d85cbc..ebb78bb7fa 100644
--- a/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/pages/async_actions.ts
+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/pages/async_actions.ts
@@ -14,7 +14,7 @@ export const movePageThunk = createAsyncThunk(
thunkAPI
) => {
const { sourceId, targetId, insertType } = payload;
- const { getState } = thunkAPI;
+ const { getState, dispatch } = thunkAPI;
const { pageMap, relationMap } = (getState() as RootState).pages;
const sourcePage = pageMap[sourceId];
const targetPage = pageMap[targetId];
@@ -51,6 +51,8 @@ export const movePageThunk = createAsyncThunk(
}
}
+ dispatch(pagesActions.movePage({ id: sourceId, newParentId: parentId, prevId }));
+
await movePage({
view_id: sourceId,
new_parent_id: parentId,
diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/pages/slice.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/pages/slice.ts
index e5b08ae095..8d3f07507e 100644
--- a/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/pages/slice.ts
+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/pages/slice.ts
@@ -89,10 +89,85 @@ export const pagesSlice = createSlice({
}
},
- removeChildPages(state, action: PayloadAction) {
- const parentId = action.payload;
+ addPage(
+ state,
+ action: PayloadAction<{
+ page: Page;
+ isLast?: boolean;
+ prevId?: string;
+ }>
+ ) {
+ const { page, prevId, isLast } = action.payload;
- delete state.relationMap[parentId];
+ state.pageMap[page.id] = page;
+ state.relationMap[page.id] = [];
+
+ const parentId = page.parentId;
+
+ if (isLast) {
+ state.relationMap[parentId]?.push(page.id);
+ } else {
+ const index = prevId ? state.relationMap[parentId]?.indexOf(prevId) ?? -1 : -1;
+
+ state.relationMap[parentId]?.splice(index + 1, 0, page.id);
+ }
+ },
+
+ deletePages(state, action: PayloadAction) {
+ const ids = action.payload;
+
+ ids.forEach((id) => {
+ const parentId = state.pageMap[id].parentId;
+ const parentChildren = state.relationMap[parentId];
+
+ state.relationMap[parentId] = parentChildren && parentChildren.filter((childId) => childId !== id);
+ delete state.relationMap[id];
+ delete state.expandedIdMap[id];
+ delete state.pageMap[id];
+ });
+ },
+
+ duplicatePage(
+ state,
+ action: PayloadAction<{
+ id: string;
+ newId: string;
+ }>
+ ) {
+ const { id, newId } = action.payload;
+ const page = state.pageMap[id];
+ const newPage = { ...page, id: newId };
+
+ state.pageMap[newPage.id] = newPage;
+
+ const index = state.relationMap[page.parentId]?.indexOf(id);
+
+ state.relationMap[page.parentId]?.splice(index ?? 0, 0, newId);
+ },
+
+ movePage(
+ state,
+ action: PayloadAction<{
+ id: string;
+ newParentId: string;
+ prevId?: string;
+ }>
+ ) {
+ const { id, newParentId, prevId } = action.payload;
+ const parentId = state.pageMap[id].parentId;
+ const parentChildren = state.relationMap[parentId];
+
+ const index = parentChildren?.indexOf(id) ?? -1;
+
+ if (index > -1) {
+ state.relationMap[parentId]?.splice(index, 1);
+ }
+
+ state.pageMap[id].parentId = newParentId;
+ const newParentChildren = state.relationMap[newParentId] || [];
+ const prevIndex = prevId ? newParentChildren.indexOf(prevId) : -1;
+
+ state.relationMap[newParentId]?.splice(prevIndex + 1, 0, id);
},
expandPage(state, action: PayloadAction) {
diff --git a/frontend/appflowy_tauri/src/appflowy_app/utils/get_modifier.ts b/frontend/appflowy_tauri/src/appflowy_app/utils/get_modifier.ts
new file mode 100644
index 0000000000..a81e5e9093
--- /dev/null
+++ b/frontend/appflowy_tauri/src/appflowy_app/utils/get_modifier.ts
@@ -0,0 +1,12 @@
+export const isMac = () => {
+ return navigator.userAgent.includes('Mac OS X');
+};
+
+const MODIFIERS = {
+ control: 'Ctrl',
+ meta: '⌘',
+};
+
+export const getModifier = () => {
+ return isMac() ? MODIFIERS.meta : MODIFIERS.control;
+};
diff --git a/frontend/appflowy_tauri/src/appflowy_app/utils/mui.ts b/frontend/appflowy_tauri/src/appflowy_app/utils/mui.ts
index 2bdf102a6e..fa2520bb7a 100644
--- a/frontend/appflowy_tauri/src/appflowy_app/utils/mui.ts
+++ b/frontend/appflowy_tauri/src/appflowy_app/utils/mui.ts
@@ -1,11 +1,8 @@
-import { ThemeMode } from '$app/stores/reducers/current-user/slice';
import { ThemeOptions } from '@mui/material';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
-export const getDesignTokens = (mode: ThemeMode): ThemeOptions => {
- const isDark = mode === ThemeMode.Dark;
-
+export const getDesignTokens = (isDark: boolean): ThemeOptions => {
return {
typography: {
fontFamily: ['Poppins'].join(','),
diff --git a/frontend/appflowy_tauri/src/styles/template.css b/frontend/appflowy_tauri/src/styles/template.css
index e8fe35e440..f17595b74a 100644
--- a/frontend/appflowy_tauri/src/styles/template.css
+++ b/frontend/appflowy_tauri/src/styles/template.css
@@ -24,10 +24,6 @@ body {
width: 8px;
}
-.MuiPopover-root::-webkit-scrollbar {
- width: 0;
- height: 0;
-}
:root[data-dark-mode=true] body {
diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.json
index 8d4f9ce4dd..93842e59c2 100644
--- a/frontend/resources/translations/en.json
+++ b/frontend/resources/translations/en.json
@@ -879,7 +879,9 @@
"page": {
"label": "Link to page",
"tooltip": "Click to open page"
- }
+ },
+ "deleted": "Deleted",
+ "deletedContent": "This content does not exist or has been deleted"
},
"toolbar": {
"resetToDefaultFont": "Reset to default"