chore: bump bs with new extension api (#8042)
This commit is contained in:
@@ -2,6 +2,7 @@ import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
||||
import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta';
|
||||
import { useDocCollectionHelper } from '@affine/core/hooks/use-block-suite-workspace-helper';
|
||||
import { CollectionService } from '@affine/core/modules/collection';
|
||||
import type { DocMode } from '@blocksuite/blocks';
|
||||
import { DocsService, useService } from '@toeverything/infra';
|
||||
import { useCallback } from 'react';
|
||||
import { applyUpdate, encodeStateAsUpdate } from 'yjs';
|
||||
@@ -102,7 +103,7 @@ export function useBlockSuiteMetaHelper(docCollection: DocCollection) {
|
||||
|
||||
pageRecordList
|
||||
.doc$(newPage.id)
|
||||
.value?.setPrimaryMode(currentPagePrimaryMode || 'page');
|
||||
.value?.setPrimaryMode(currentPagePrimaryMode || ('page' as DocMode));
|
||||
setDocTitle(newPage.id, newPageTitle);
|
||||
openPageAfterDuplication && openPage(docCollection.id, newPage.id);
|
||||
},
|
||||
|
||||
@@ -36,7 +36,7 @@ async function exportHandler({
|
||||
const editorRoot = document.querySelector('editor-host');
|
||||
let pageService: PageRootService | null = null;
|
||||
if (editorRoot) {
|
||||
pageService = editorRoot.spec.getService<PageRootService>('affine:page');
|
||||
pageService = editorRoot.std.getService<PageRootService>('affine:page');
|
||||
}
|
||||
track.$.sharePanel.$.export({
|
||||
type,
|
||||
|
||||
@@ -7,8 +7,9 @@ import {
|
||||
revokePublicPageMutation,
|
||||
} from '@affine/graphql';
|
||||
import { type I18nKeys, useI18n } from '@affine/i18n';
|
||||
import { DocMode } from '@blocksuite/blocks';
|
||||
import { SingleSelectSelectSolidIcon } from '@blocksuite/icons/rc';
|
||||
import type { DocMode, Workspace } from '@toeverything/infra';
|
||||
import { type Workspace } from '@toeverything/infra';
|
||||
import { cssVar } from '@toeverything/theme';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
@@ -85,7 +86,9 @@ export function useIsSharedPage(
|
||||
const isPageShared = !!publicPage;
|
||||
|
||||
const currentShareMode: DocMode =
|
||||
publicPage?.mode === PublicPageMode.Edgeless ? 'edgeless' : 'page';
|
||||
publicPage?.mode === PublicPageMode.Edgeless
|
||||
? DocMode.Edgeless
|
||||
: DocMode.Page;
|
||||
|
||||
return [isPageShared, currentShareMode];
|
||||
}, [data?.workspace.publicPages, pageId]);
|
||||
@@ -210,7 +213,8 @@ export function usePublicPages(workspace: Workspace) {
|
||||
() =>
|
||||
maybeData?.workspace.publicPages.map(i => ({
|
||||
id: i.id,
|
||||
mode: i.mode === PublicPageMode.Edgeless ? 'edgeless' : 'page',
|
||||
mode:
|
||||
i.mode === PublicPageMode.Edgeless ? DocMode.Edgeless : DocMode.Page,
|
||||
})) ?? [],
|
||||
[maybeData?.workspace.publicPages]
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { track } from '@affine/core/mixpanel';
|
||||
import { getAffineCloudBaseUrl } from '@affine/core/modules/cloud/services/fetch';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import type { BaseSelection } from '@blocksuite/block-std';
|
||||
import { type DocMode } from '@toeverything/infra';
|
||||
import type { DocMode } from '@blocksuite/blocks';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { useActiveBlocksuiteEditor } from '../use-block-suite-editor';
|
||||
@@ -34,19 +34,18 @@ const generateUrl = ({
|
||||
|
||||
try {
|
||||
const url = new URL(`${baseUrl}/workspace/${workspaceId}/${pageId}`);
|
||||
const search = url.searchParams;
|
||||
if (shareMode) {
|
||||
url.searchParams.append('mode', shareMode);
|
||||
search.append('mode', shareMode);
|
||||
}
|
||||
// TODO(@JimmFly): use query string to handle blockIds
|
||||
if (blockIds && blockIds.length > 0) {
|
||||
// hash is used to store blockIds
|
||||
url.hash = blockIds.join(',');
|
||||
search.append('blockIds', blockIds.join(','));
|
||||
}
|
||||
if (elementIds && elementIds.length > 0) {
|
||||
url.searchParams.append('element', elementIds.join(','));
|
||||
search.append('elementIds', elementIds.join(','));
|
||||
}
|
||||
if (xywh) {
|
||||
url.searchParams.append('xywh', xywh);
|
||||
search.append('xywh', xywh);
|
||||
}
|
||||
return url.toString();
|
||||
} catch {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { WorkspaceSubPath } from '@affine/core/shared';
|
||||
import type { DocMode } from '@blocksuite/blocks';
|
||||
import { createContext, useCallback, useContext, useMemo } from 'react';
|
||||
import type { NavigateFunction, NavigateOptions } from 'react-router-dom';
|
||||
|
||||
@@ -40,10 +41,17 @@ export function useNavigateHelper() {
|
||||
(
|
||||
workspaceId: string,
|
||||
pageId: string,
|
||||
blockId: string,
|
||||
mode?: DocMode,
|
||||
blockIds?: string[],
|
||||
elementIds?: string[],
|
||||
logic: RouteLogic = RouteLogic.PUSH
|
||||
) => {
|
||||
return navigate(`/workspace/${workspaceId}/${pageId}#${blockId}`, {
|
||||
const search = new URLSearchParams();
|
||||
if (mode) search.append('mode', mode);
|
||||
if (blockIds?.length) search.append('blockIds', blockIds.join(','));
|
||||
if (elementIds?.length) search.append('elementIds', elementIds.join(','));
|
||||
const query = search.size > 0 ? `?${search.toString()}` : '';
|
||||
return navigate(`/workspace/${workspaceId}/${pageId}${query}`, {
|
||||
replace: logic === RouteLogic.REPLACE,
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user