refactor(editor): rename block-std to std (#11250)

Closes: BS-2946
This commit is contained in:
Saul-Mirone
2025-03-28 07:20:34 +00:00
parent 4498676a96
commit 205cd7a86d
1029 changed files with 1580 additions and 1698 deletions
+32
View File
@@ -0,0 +1,32 @@
import type { Store } from '@blocksuite/store';
import { effect } from '@preact/signals-core';
import { SurfaceBlockModel } from '../gfx/model/surface/surface-model.js';
export function onSurfaceAdded(
doc: Store,
callback: (model: SurfaceBlockModel | null) => void
) {
let found = false;
let foundId = '';
const dispose = effect(() => {
// if the surface is already found, no need to search again
if (found && doc.getBlock(foundId)) {
return;
}
for (const block of Object.values(doc.blocks.value)) {
if (block.model instanceof SurfaceBlockModel) {
callback(block.model);
found = true;
foundId = block.id;
return;
}
}
callback(null);
});
return dispose;
}