feat(editor): add edgeless crud extension (#9335)

This commit is contained in:
Saul-Mirone
2024-12-26 08:58:06 +00:00
parent 0de4f7abbb
commit 6afa1d542f
48 changed files with 629 additions and 423 deletions
@@ -508,7 +508,7 @@ const CREATE_AS_LINKED_DOC = {
y = viewportCenter.y - height / 2;
}
service.addBlock(
service.crud.addBlock(
'affine:embed-linked-doc',
{
xywh: `[${x}, ${y}, ${width}, ${height}]`,
@@ -174,7 +174,7 @@ export class AIChatBlockPeekView extends LitElement {
const edgelessService = this._rootService as EdgelessRootService;
const bound = calcChildBound(this.parentModel, edgelessService);
const aiChatBlockId = edgelessService.addBlock(
const aiChatBlockId = edgelessService.crud.addBlock(
'affine:embed-ai-chat' as keyof BlockSuite.BlockModels,
{
xywh: bound.serialize(),
@@ -193,7 +193,7 @@ export class AIChatBlockPeekView extends LitElement {
this.updateContext({ currentChatBlockId: aiChatBlockId });
// Connect the parent chat block to the AI chat block
edgelessService.addElement(CanvasElementType.CONNECTOR, {
edgelessService.crud.addElement(CanvasElementType.CONNECTOR, {
mode: ConnectorMode.Curve,
controllers: [],
source: { id: this.parentChatBlockId },
@@ -530,7 +530,7 @@ export function patchEdgelessClipboard() {
rootDocId,
rootWorkspaceId,
} = block.props;
const blockId = component.service.addBlock(
const blockId = component.service.crud.addBlock(
AIChatBlockFlavour,
{
xywh,
@@ -361,7 +361,7 @@ export const ShapeSettings = () => {
const { shapeType, radius } = shape;
const shapeName = getShapeName(shapeType, radius);
const props = editorSetting.get(`shape:${shapeName}`);
edgelessService.updateElement(shape.id, props);
edgelessService.crud.updateElement(shape.id, props);
});
doc.awarenessStore.setReadonly(doc.blockCollection, true);
},
@@ -79,7 +79,7 @@ export const EdgelessSnapshot = (props: Props) => {
const props = editorSetting.get(keyName) as any;
doc.awarenessStore.setReadonly(doc.blockCollection, false);
elements.forEach(element => {
edgelessService.updateElement(element.id, props);
edgelessService.crud.updateElement(element.id, props);
});
doc.awarenessStore.setReadonly(doc.blockCollection, true);
}, [editorSetting, getElements, keyName]);