+ ${OpenInNewIcon()} ${ArrowDownSmallIcon()}
+ `}
+ >
+
+ ${repeat(
+ actions,
+ action => action.id,
+ ({ label, icon, run, disabled }) => html`
+ {
+ run?.(ctx);
+ }}
+ >
+ ${icon}${label}
+
+ `
+ )}
+
+ `
+ )}`;
+ },
+ },
+ {
+ id: 'a.clipboard',
+ placement: ActionPlacement.More,
+ actions: [
+ {
+ id: 'copy-link-to-surface-ref',
+ label: 'Copy original link',
+ icon: LinkIcon(),
+ when: ctx =>
+ !!ctx.getCurrentBlockByType(SurfaceRefBlockComponent)
+ ?.referenceModel,
+ run: ctx => {
+ const surfaceRefBlock = ctx.getCurrentBlockByType(
+ SurfaceRefBlockComponent
+ );
+ if (!surfaceRefBlock) return;
+
+ const refModel = surfaceRefBlock.referenceModel;
+ if (!refModel) return;
+
+ const { store, workspace, std } = ctx;
+ const pageId = store.doc.id;
+ const workspaceId = workspace.id;
+ const options: UseSharingUrl = {
+ workspaceId,
+ pageId,
+ mode: 'edgeless',
+ };
+
+ let type = '';
+ if (refModel instanceof GfxPrimitiveElementModel) {
+ options.elementIds = [refModel.id];
+ type = refModel.type;
+ } else if (refModel instanceof GfxBlockElementModel) {
+ options.blockIds = [refModel.id];
+ type = refModel.flavour;
+ }
+
+ const str = generateUrl({
+ ...options,
+ baseUrl: baseUrl ?? location.origin,
+ });
+ if (!str) return;
+
+ copyLinkToBlockStdScopeClipboard(str, std.clipboard)
+ .then(ok => {
+ if (!ok) return;
+
+ notify.success({ title: I18n['Copied link to clipboard']() });
+ })
+ .catch(console.error);
+
+ track.doc.editor.toolbar.copyBlockToLink({ type });
+ },
+ },
+ ],
+ },
+ ],
+ };
+}
+
function renderOpenDocMenu(
settings: EditorSettingExt,
ctx: ToolbarContext,
@@ -877,11 +1006,11 @@ const embedIframeToolbarConfig = {
},
actions: [
{
- id: 'b.copy-link',
+ id: 'a.copy-link-and-edit',
actions: [
{
id: 'copy-link',
- tooltip: 'Copy original link',
+ tooltip: 'Copy link',
icon: CopyIcon(),
run(ctx) {
const model = ctx.getCurrentBlockByType(
@@ -895,14 +1024,52 @@ const embedIframeToolbarConfig = {
toast(ctx.host, 'Copied link to clipboard');
ctx.track('CopiedLink', {
- category: matchModels(model, [EmbedIframeBlockModel])
- ? 'embed iframe block'
+ category: matchModels(model, [BookmarkBlockModel])
+ ? 'bookmark'
: 'link',
type: 'card view',
control: 'copy link',
});
},
},
+ {
+ id: 'edit',
+ tooltip: 'Edit',
+ icon: EditIcon(),
+ run(ctx) {
+ const component = ctx.getCurrentBlockByType(
+ EmbedIframeBlockComponent
+ );
+ if (!component) return;
+
+ ctx.hide();
+
+ const model = component.model;
+ const abortController = new AbortController();
+ abortController.signal.onabort = () => ctx.show();
+
+ toggleEmbedCardEditModal(
+ ctx.host,
+ model,
+ 'card',
+ undefined,
+ undefined,
+ (_std, _component, props) => {
+ ctx.store.updateBlock(model, props);
+ component.requestUpdate();
+ },
+ abortController
+ );
+
+ ctx.track('OpenedAliasPopup', {
+ category: matchModels(model, [BookmarkBlockModel])
+ ? 'bookmark'
+ : 'link',
+ type: 'card view',
+ control: 'edit',
+ });
+ },
+ },
],
},
],
@@ -1052,5 +1219,12 @@ export const createCustomToolbarExtension = (
when: ctx => ctx.getSurfaceModels().length === 1,
},
}),
+
+ ToolbarModuleExtension({
+ id: BlockFlavourIdentifier(
+ `custom:${SurfaceRefBlockSchema.model.flavour}`
+ ),
+ config: createSurfaceRefToolbarConfig(baseUrl),
+ }),
];
};
diff --git a/packages/frontend/core/src/blocksuite/extensions/entry/enable-mobile.ts b/packages/frontend/core/src/blocksuite/extensions/entry/enable-mobile.ts
index 090530220..36d9799c1 100644
--- a/packages/frontend/core/src/blocksuite/extensions/entry/enable-mobile.ts
+++ b/packages/frontend/core/src/blocksuite/extensions/entry/enable-mobile.ts
@@ -10,7 +10,6 @@ import {
} from '@blocksuite/affine/blocks/code';
import { imageToolbarWidget } from '@blocksuite/affine/blocks/image';
import { ParagraphBlockConfigExtension } from '@blocksuite/affine/blocks/paragraph';
-import { surfaceRefToolbarWidget } from '@blocksuite/affine/blocks/surface-ref';
import type {
Container,
ServiceIdentifier,
@@ -136,7 +135,6 @@ export function enableMobileExtension(
): void {
specBuilder.omit(codeToolbarWidget);
specBuilder.omit(imageToolbarWidget);
- specBuilder.omit(surfaceRefToolbarWidget);
specBuilder.omit(toolbarWidget);
specBuilder.omit(SlashMenuExtension);
specBuilder.extend([
diff --git a/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page.tsx b/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page.tsx
index 399b614ae..79248d11b 100644
--- a/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page.tsx
+++ b/packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page.tsx
@@ -204,6 +204,7 @@ const DetailPageImpl = memo(function DetailPageImpl() {
workbench.openDoc(
{
docId: pageId,
+ mode: params?.mode,
blockIds: params?.blockIds,
elementIds: params?.elementIds,
},
diff --git a/packages/frontend/i18n/src/i18n.gen.ts b/packages/frontend/i18n/src/i18n.gen.ts
index cfce617cf..51be910a8 100644
--- a/packages/frontend/i18n/src/i18n.gen.ts
+++ b/packages/frontend/i18n/src/i18n.gen.ts
@@ -4351,6 +4351,10 @@ export function useAFFiNEI18N(): {
* `Open this doc`
*/
["com.affine.peek-view-controls.open-doc"](): string;
+ /**
+ * `Open in edgeless`
+ */
+ ["com.affine.peek-view-controls.open-doc-in-edgeless"](): string;
/**
* `Open in new tab`
*/
diff --git a/packages/frontend/i18n/src/resources/en.json b/packages/frontend/i18n/src/resources/en.json
index 66dcaa5b9..378346301 100644
--- a/packages/frontend/i18n/src/resources/en.json
+++ b/packages/frontend/i18n/src/resources/en.json
@@ -1079,6 +1079,7 @@
"com.affine.payment.license-success.copy": "Copied key to clipboard",
"com.affine.peek-view-controls.close": "Close",
"com.affine.peek-view-controls.open-doc": "Open this doc",
+ "com.affine.peek-view-controls.open-doc-in-edgeless": "Open in edgeless",
"com.affine.peek-view-controls.open-doc-in-new-tab": "Open in new tab",
"com.affine.peek-view-controls.open-doc-in-split-view": "Open in split view",
"com.affine.peek-view-controls.open-info": "Open doc info",
diff --git a/tests/affine-local/e2e/peek-view.spec.ts b/tests/affine-local/e2e/peek-view.spec.ts
index 5888efb67..4124a5f3a 100644
--- a/tests/affine-local/e2e/peek-view.spec.ts
+++ b/tests/affine-local/e2e/peek-view.spec.ts
@@ -134,11 +134,11 @@ test('can open peek view for embedded frames', async ({ page }) => {
await expect(surfaceRef).toBeVisible();
await surfaceRef.hover();
await page
- .locator('affine-surface-ref-toolbar editor-menu-button[aria-label="Open"]')
+ .locator('affine-toolbar-widget editor-menu-button[aria-label="Open"]')
.click();
await page
.locator(
- 'affine-surface-ref-toolbar editor-menu-action[aria-label="Open in center peek"]'
+ 'affine-toolbar-widget editor-menu-action[aria-label="Open in center peek"]'
)
.click();
diff --git a/tools/utils/src/workspace.gen.ts b/tools/utils/src/workspace.gen.ts
index d56a19040..df89a694c 100644
--- a/tools/utils/src/workspace.gen.ts
+++ b/tools/utils/src/workspace.gen.ts
@@ -361,6 +361,7 @@ export const PackageList = [
'blocksuite/affine/blocks/block-frame',
'blocksuite/affine/blocks/block-surface',
'blocksuite/affine/components',
+ 'blocksuite/affine/inlines/reference',
'blocksuite/affine/model',
'blocksuite/affine/shared',
'blocksuite/affine/widgets/widget-slash-menu',
diff --git a/yarn.lock b/yarn.lock
index ec24728f0..0c3b060b1 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2792,6 +2792,7 @@ __metadata:
"@blocksuite/affine-block-frame": "workspace:*"
"@blocksuite/affine-block-surface": "workspace:*"
"@blocksuite/affine-components": "workspace:*"
+ "@blocksuite/affine-inline-reference": "workspace:*"
"@blocksuite/affine-model": "workspace:*"
"@blocksuite/affine-shared": "workspace:*"
"@blocksuite/affine-widget-slash-menu": "workspace:*"