mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-11 05:58:56 +08:00
Merge branch 'feat/filesystem_and_search' of github.com:toeverything/AFFiNE into feat/filesystem_and_search
This commit is contained in:
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 16 KiB |
File diff suppressed because one or more lines are too long
@@ -9,8 +9,7 @@ import { config } from './config';
|
|||||||
import { useGoToPage } from '@/providers/app-state-provider/hooks';
|
import { useGoToPage } from '@/providers/app-state-provider/hooks';
|
||||||
import { usePageList } from '@/providers/app-state-provider/usePageList';
|
import { usePageList } from '@/providers/app-state-provider/usePageList';
|
||||||
import { useLoadWorkspace } from '@/providers/app-state-provider/hooks';
|
import { useLoadWorkspace } from '@/providers/app-state-provider/hooks';
|
||||||
import NextImage from 'next/image';
|
import { NoResultSVG } from './noResultSVG';
|
||||||
import noResultSVG from './noResult.svg';
|
|
||||||
import { usePageHelper } from '@/hooks/use-page-helper';
|
import { usePageHelper } from '@/hooks/use-page-helper';
|
||||||
export const Results = (props: {
|
export const Results = (props: {
|
||||||
query: string;
|
query: string;
|
||||||
@@ -76,12 +75,7 @@ export const Results = (props: {
|
|||||||
) : (
|
) : (
|
||||||
<StyledNotFound>
|
<StyledNotFound>
|
||||||
<span>Find 0 result</span>
|
<span>Find 0 result</span>
|
||||||
<NextImage
|
<NoResultSVG />
|
||||||
alt="no result"
|
|
||||||
src={noResultSVG}
|
|
||||||
width={150}
|
|
||||||
height={150}
|
|
||||||
></NextImage>
|
|
||||||
</StyledNotFound>
|
</StyledNotFound>
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Page } from '@blocksuite/store';
|
import { Page } from '@blocksuite/store';
|
||||||
import { QueryContent } from '@blocksuite/store/dist/workspace/search';
|
|
||||||
import { PageMeta } from '@/providers/editor-provider';
|
import { PageMeta } from '@/providers/editor-provider';
|
||||||
import { useAppState } from '@/providers/app-state-provider';
|
import { useAppState } from '@/providers/app-state-provider';
|
||||||
|
|
||||||
@@ -13,7 +12,7 @@ export type EditorHandlers = {
|
|||||||
toggleDeletePage: (pageId: string) => void;
|
toggleDeletePage: (pageId: string) => void;
|
||||||
toggleFavoritePage: (pageId: string) => void;
|
toggleFavoritePage: (pageId: string) => void;
|
||||||
// permanentlyDeletePage: (pageId: string) => void;
|
// permanentlyDeletePage: (pageId: string) => void;
|
||||||
search: (query: QueryContent) => Map<string, string | undefined>;
|
search: (query: string) => Map<string, string | undefined>;
|
||||||
// changeEditorMode: (pageId: string) => void;
|
// changeEditorMode: (pageId: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -45,7 +44,7 @@ export const usePageHelper = (): EditorHandlers => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
search: (query: QueryContent) => {
|
search: (query: string) => {
|
||||||
return currentWorkspace!.search(query);
|
return currentWorkspace!.search(query);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import type {
|
|||||||
Workspace as StoreWorkspace,
|
Workspace as StoreWorkspace,
|
||||||
} from '@blocksuite/store';
|
} from '@blocksuite/store';
|
||||||
import type { EditorContainer } from '@blocksuite/editor';
|
import type { EditorContainer } from '@blocksuite/editor';
|
||||||
import { QueryContent } from '@blocksuite/store/dist/workspace/search';
|
|
||||||
|
|
||||||
export type LoadWorkspaceHandler = (
|
export type LoadWorkspaceHandler = (
|
||||||
workspaceId: string
|
workspaceId: string
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { QueryContent } from '@blocksuite/store/dist/workspace/search';
|
|
||||||
import { createPage, generateDefaultPageId, initPage } from '../utils';
|
import { createPage, generateDefaultPageId, initPage } from '../utils';
|
||||||
import { Workspace, Page } from '@blocksuite/store';
|
import { Workspace, Page } from '@blocksuite/store';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
@@ -70,9 +69,6 @@ export const useEditorHandler = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
search: (query: QueryContent) => {
|
|
||||||
return workspace!.search(query);
|
|
||||||
},
|
|
||||||
changeEditorMode: (pageId: string) => {
|
changeEditorMode: (pageId: string) => {
|
||||||
editor!.mode = editor!.mode === 'page' ? 'edgeless' : 'page';
|
editor!.mode = editor!.mode === 'page' ? 'edgeless' : 'page';
|
||||||
workspace?.setPageMeta(pageId, { mode: editor!.mode });
|
workspace?.setPageMeta(pageId, { mode: editor!.mode });
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { PropsWithChildren } from 'react';
|
import { PropsWithChildren } from 'react';
|
||||||
import { Page } from '@blocksuite/store';
|
import { Page } from '@blocksuite/store';
|
||||||
import { QueryContent } from '@blocksuite/store/dist/workspace/search';
|
|
||||||
import { PageMeta as OriginalPageMeta } from '@blocksuite/store';
|
import { PageMeta as OriginalPageMeta } from '@blocksuite/store';
|
||||||
import { EditorContainer } from '@blocksuite/editor';
|
import { EditorContainer } from '@blocksuite/editor';
|
||||||
|
|
||||||
@@ -35,6 +34,5 @@ export type EditorHandlers = {
|
|||||||
toggleDeletePage: (pageId: string) => void;
|
toggleDeletePage: (pageId: string) => void;
|
||||||
toggleFavoritePage: (pageId: string) => void;
|
toggleFavoritePage: (pageId: string) => void;
|
||||||
permanentlyDeletePage: (pageId: string) => void;
|
permanentlyDeletePage: (pageId: string) => void;
|
||||||
search: (query: QueryContent) => Map<string, string | undefined>;
|
|
||||||
changeEditorMode: (pageId: string) => void;
|
changeEditorMode: (pageId: string) => void;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,10 +36,23 @@ function getToken(): { accessToken: string; refreshToken: string } | null {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function b64DecodeUnicode(str: string) {
|
||||||
|
// Going backwards: from byte stream, to percent-encoding, to original string.
|
||||||
|
return decodeURIComponent(
|
||||||
|
window
|
||||||
|
.atob(str)
|
||||||
|
.split('')
|
||||||
|
.map(function (c) {
|
||||||
|
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
||||||
|
})
|
||||||
|
.join('')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function parseAccessToken(token: string): AccessTokenMessage | null {
|
function parseAccessToken(token: string): AccessTokenMessage | null {
|
||||||
try {
|
try {
|
||||||
const message: AccessTokenMessage = JSON.parse(
|
const message: AccessTokenMessage = JSON.parse(
|
||||||
window.atob(token.split('.')[1])
|
b64DecodeUnicode(token.split('.')[1])
|
||||||
);
|
);
|
||||||
return message;
|
return message;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user