feat(editor): add embed doc block extension (#12090)

Closes: BS-3393

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Introduced a new "Embed Doc" block, enabling embedding and rendering of linked and synced documents within cards, including support for banners and note previews.
  - Added new toolbar and quick search options for inserting embedded linked and synced documents.

- **Improvements**
  - Updated dependencies and internal references to support the new embed doc functionality across related blocks and components.
  - Enhanced support for edgeless environments with new clipboard and configuration options for embedded docs.

- **Refactor**
  - Streamlined and reorganized embed-related code, moving linked and synced doc logic into a dedicated embed doc module.
  - Removed obsolete adapter and utility files to simplify maintenance.

- **Chores**
  - Updated project and TypeScript configuration files to include the new embed doc module in builds and references.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Saul-Mirone
2025-04-30 09:16:17 +00:00
parent 4660b41d20
commit 04531508cb
77 changed files with 496 additions and 586 deletions
@@ -2,9 +2,11 @@ import type { EdgelessTextBlockComponent } from '@blocksuite/affine-block-edgele
import {
EMBED_HTML_MIN_HEIGHT,
EMBED_HTML_MIN_WIDTH,
} from '@blocksuite/affine-block-embed';
import {
SYNCED_MIN_HEIGHT,
SYNCED_MIN_WIDTH,
} from '@blocksuite/affine-block-embed';
} from '@blocksuite/affine-block-embed-doc';
import {
EdgelessFrameManagerIdentifier,
type FrameOverlay,
@@ -10,7 +10,6 @@ export * from './edgeless/index.js';
export * from './page/page-root-block.js';
export * from './preview/preview-root-block.js';
export * from './types.js';
export * from './utils/index.js';
declare type _GLOBAL_ =
| typeof PointerEffect
@@ -1,23 +0,0 @@
import type { BlockComponent, EditorHost } from '@blocksuite/std';
import type { BlockModel } from '@blocksuite/store';
// Run the callback until a model's element updated.
// Please notice that the callback will be called **once the element itself is ready**.
// The children may be not updated.
// If you want to wait for the text elements,
// please use `onModelTextUpdated`.
export async function onModelElementUpdated(
editorHost: EditorHost,
model: BlockModel,
callback: (block: BlockComponent) => void
) {
const page = model.doc;
if (!page.root) return;
const rootComponent = editorHost.view.getBlock(page.root.id);
if (!rootComponent) return;
await rootComponent.updateComplete;
const element = editorHost.view.getBlock(model.id);
if (element) callback(element);
}
@@ -1,2 +0,0 @@
export * from './callback';
export * from './types';
@@ -1,7 +0,0 @@
import type { RootBlockComponent } from '../types.js';
export function getClosestRootBlockComponent(
el: HTMLElement
): RootBlockComponent | null {
return el.closest('affine-edgeless-root, affine-page-root');
}
@@ -1,32 +0,0 @@
import { BookmarkBlockComponent } from '@blocksuite/affine-block-bookmark';
import {
EmbedFigmaBlockComponent,
EmbedGithubBlockComponent,
EmbedHtmlBlockComponent,
EmbedLinkedDocBlockComponent,
EmbedLoomBlockComponent,
EmbedSyncedDocBlockComponent,
EmbedYoutubeBlockComponent,
type LinkableEmbedBlockComponent,
} from '@blocksuite/affine-block-embed';
import type { BlockComponent } from '@blocksuite/std';
export type BuiltInEmbedBlockComponent =
| BookmarkBlockComponent
| LinkableEmbedBlockComponent
| EmbedHtmlBlockComponent;
export function isEmbedCardBlockComponent(
block: BlockComponent
): block is BuiltInEmbedBlockComponent {
return (
block instanceof BookmarkBlockComponent ||
block instanceof EmbedFigmaBlockComponent ||
block instanceof EmbedGithubBlockComponent ||
block instanceof EmbedHtmlBlockComponent ||
block instanceof EmbedLoomBlockComponent ||
block instanceof EmbedYoutubeBlockComponent ||
block instanceof EmbedLinkedDocBlockComponent ||
block instanceof EmbedSyncedDocBlockComponent
);
}