feat(core): support block or element reference links (#7946)

Upstreams: https://github.com/toeverything/blocksuite/pull/8021

* open doc with mode
* monitor mode changes in query string
* scroll anchoring

https://github.com/user-attachments/assets/681abff8-e51b-47ea-bb71-447e8b312142

https://github.com/user-attachments/assets/e73ed4c0-4e33-45f8-9db4-d8eed3525d05
This commit is contained in:
fundon
2024-09-03 09:49:14 +00:00
parent e7b53641d7
commit 98d9295259
6 changed files with 37 additions and 37 deletions
@@ -29,23 +29,23 @@ import * as styles from './styles.css';
import { scrollAnchoring } from './utils';
export interface PageReferenceRendererOptions {
docMode: DocMode | null;
pageId: string;
docCollection: DocCollection;
pageMetaHelper: ReturnType<typeof useDocMetaHelper>;
journalHelper: ReturnType<typeof useJournalHelper>;
t: ReturnType<typeof useI18n>;
docMode?: DocMode;
// linking doc with block or element
blockIds?: string[];
elementIds?: string[];
}
// use a function to be rendered in the lit renderer
export function pageReferenceRenderer({
docMode,
pageId,
pageMetaHelper,
journalHelper,
t,
docMode,
blockIds,
elementIds,
}: PageReferenceRendererOptions) {
@@ -93,8 +93,8 @@ export function AffinePageReference({
isSameDoc = false,
std,
}: {
docCollection: DocCollection;
pageId: string;
docCollection: DocCollection;
wrapper?: React.ComponentType<PropsWithChildren>;
mode?: DocMode;
params?: {
@@ -8,7 +8,7 @@ import { EditorService } from '@affine/core/modules/editor';
import { I18n } from '@affine/i18n';
import type { DatabaseBlockModel, MenuOptions } from '@blocksuite/blocks';
import { LinkIcon } from '@blocksuite/icons/lit';
import { type FrameworkProvider } from '@toeverything/infra';
import type { FrameworkProvider } from '@toeverything/infra';
import type { TemplateResult } from 'lit';
export function createDatabaseOptionsConfig(framework: FrameworkProvider) {
@@ -54,12 +54,12 @@ function createCopyLinkToBlockMenuItem(
const baseUrl = getAffineCloudBaseUrl();
if (!baseUrl) return;
const pageId = model.doc.id;
const { editor } = framework.get(EditorService);
const mode = editor.mode$.value;
if (mode === 'edgeless') return;
const pageId = editor.doc.id;
const workspaceId = editor.doc.workspace.id;
const options: UseSharingUrl = {
workspaceId,