mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-01 01:29:31 +08:00
388641bc89
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Unified internal data access by replacing all references from `doc` to `store` across all components, blocks, widgets, and utilities. This affects how readonly state, block operations, and service retrieval are handled throughout the application. - **Tests** - Updated all test utilities and test cases to use `store` instead of `doc` for document-related operations. - **Chores** - Updated context providers and property names to reflect the change from `doc` to `store` for improved consistency and maintainability. No user-facing features or behaviors have changed. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import { DefaultTool } from '@blocksuite/affine-block-surface';
|
|
import { toggleEmbedCardCreateModal } from '@blocksuite/affine-components/embed-card-modal';
|
|
import type { SlashMenuConfig } from '@blocksuite/affine-widget-slash-menu';
|
|
import { FigmaDuotoneIcon } from '@blocksuite/icons/lit';
|
|
import { GfxControllerIdentifier } from '@blocksuite/std/gfx';
|
|
|
|
import { FigmaTooltip } from './tooltips';
|
|
|
|
export const embedFigmaSlashMenuConfig: SlashMenuConfig = {
|
|
items: [
|
|
{
|
|
name: 'Figma',
|
|
description: 'Embed a Figma document.',
|
|
icon: FigmaDuotoneIcon(),
|
|
tooltip: {
|
|
figure: FigmaTooltip,
|
|
caption: 'Figma',
|
|
},
|
|
group: '4_Content & Media@8',
|
|
when: ({ model }) =>
|
|
model.store.schema.flavourSchemaMap.has('affine:embed-figma'),
|
|
action: ({ std, model }) => {
|
|
(async () => {
|
|
const { host } = std;
|
|
const parentModel = host.store.getParent(model);
|
|
if (!parentModel) {
|
|
return;
|
|
}
|
|
const index = parentModel.children.indexOf(model) + 1;
|
|
await toggleEmbedCardCreateModal(
|
|
host,
|
|
'Figma',
|
|
'The added Figma link will be displayed as an embed view.',
|
|
{ mode: 'page', parentModel, index },
|
|
({ mode }) => {
|
|
if (mode === 'edgeless') {
|
|
const gfx = std.get(GfxControllerIdentifier);
|
|
gfx.tool.setTool(DefaultTool);
|
|
}
|
|
}
|
|
);
|
|
if (model.text?.length === 0) std.store.deleteBlock(model);
|
|
})().catch(console.error);
|
|
},
|
|
},
|
|
],
|
|
};
|