refactor(editor): edgeless external embed card toolbar config extension (#10712)

This commit is contained in:
fundon
2025-03-19 04:05:36 +00:00
parent 284aae9b52
commit 7f4b56e05c
11 changed files with 415 additions and 160 deletions
@@ -397,23 +397,30 @@ export class AffineToolbarWidget extends WidgetComponent {
// `card view` or `embed view`
disposables.add(
std.view.viewUpdated.subscribe(record => {
if (record.type !== 'block') return;
if (!flags.isBlock()) return;
const hasAddedBlock =
record.type === 'block' && record.method === 'add';
if (!hasAddedBlock) return;
const blockIds = std.selection
.filter$(BlockSelection)
.peek()
.map(s => s.blockId);
if (flags.isBlock()) {
const blockIds = std.selection
.filter$(BlockSelection)
.peek()
.map(s => s.blockId);
if (blockIds.includes(record.id)) {
batch(() => {
this.setReferenceElementWithBlocks(
blockIds
.map(id => std.view.getBlock(id))
.filter(block => block !== null)
);
flags.refresh(Flag.Block);
});
}
return;
}
if (record.method === 'add' && blockIds.includes(record.id)) {
batch(() => {
this.setReferenceElementWithBlocks(
blockIds
.map(id => std.view.getBlock(id))
.filter(block => block !== null)
);
flags.refresh(Flag.Block);
});
if (flags.isSurface()) {
flags.refresh(Flag.Surface);
return;
}
})