mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix: api compatibility with blocksuite
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import type { TreeViewProps } from '@affine/component';
|
import type { TreeViewProps } from '@affine/component';
|
||||||
import { DebugLogger } from '@affine/debug';
|
import { DebugLogger } from '@affine/debug';
|
||||||
|
import { initPage } from '@affine/env/blocksuite';
|
||||||
import type { PageMeta } from '@blocksuite/store';
|
import type { PageMeta } from '@blocksuite/store';
|
||||||
import { nanoid } from '@blocksuite/store';
|
import { nanoid } from '@blocksuite/store';
|
||||||
import { usePageMetaHelper } from '@toeverything/hooks/use-block-suite-page-meta';
|
import { usePageMetaHelper } from '@toeverything/hooks/use-block-suite-page-meta';
|
||||||
@@ -64,7 +65,16 @@ export function usePinboardHandler({
|
|||||||
const addPin = useCallback(
|
const addPin = useCallback(
|
||||||
(parentId: string) => {
|
(parentId: string) => {
|
||||||
const id = nanoid();
|
const id = nanoid();
|
||||||
createPage(id, parentId);
|
const page = createPage(id);
|
||||||
|
initPage(page);
|
||||||
|
page.addBlock('affine:paragraph', {
|
||||||
|
text: page.Text.fromDelta([
|
||||||
|
{
|
||||||
|
insert: ' ',
|
||||||
|
attributes: { reference: { type: 'LinkedPage', pageId: page.id } },
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
});
|
||||||
onAdd?.(id, parentId);
|
onAdd?.(id, parentId);
|
||||||
addReferenceLink(parentId, id);
|
addReferenceLink(parentId, id);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import { useMemo } from 'react';
|
|||||||
export function useBlockSuiteWorkspaceHelper(blockSuiteWorkspace: Workspace) {
|
export function useBlockSuiteWorkspaceHelper(blockSuiteWorkspace: Workspace) {
|
||||||
return useMemo(
|
return useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
createPage: (pageId: string, parentId?: string): Page => {
|
createPage: (pageId: string): Page => {
|
||||||
assertExists(blockSuiteWorkspace);
|
assertExists(blockSuiteWorkspace);
|
||||||
return blockSuiteWorkspace.createPage(pageId, parentId);
|
return blockSuiteWorkspace.createPage(pageId);
|
||||||
},
|
},
|
||||||
markMilestone: async (name: string) => {
|
markMilestone: async (name: string) => {
|
||||||
assertExists(blockSuiteWorkspace);
|
assertExists(blockSuiteWorkspace);
|
||||||
|
|||||||
Reference in New Issue
Block a user