mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 10:36:22 +08:00
refactor(page): rename pageId
This commit is contained in:
@@ -266,36 +266,33 @@ export class EditorBlock extends ServiceBaseClass {
|
||||
}
|
||||
async copyPage(
|
||||
workspaceId: string,
|
||||
source_page_id: string,
|
||||
new_page_id: string
|
||||
sourcePageId: string,
|
||||
newPageId: string
|
||||
): Promise<boolean> {
|
||||
const db = await this.database.getDatabase(workspaceId);
|
||||
|
||||
const source_page = await this.getBlock(
|
||||
const sourcePage = await this.getBlock(
|
||||
workspaceId,
|
||||
source_page_id as 'block'
|
||||
sourcePageId as 'block'
|
||||
);
|
||||
const new_page = await this.getBlock(
|
||||
workspaceId,
|
||||
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 { workspaceId, page_id: pageId } = useParams();
|
||||
const { workspaceId, pageId } = useParams();
|
||||
const { pathname } = useLocation();
|
||||
const [currentEditors, setCurrentEditors] = useAtom(_currentEditors);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user