mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-20 11:36:25 +08:00
fix:while bord group error (#258)
* fix:while bord group error * fix:while bord group error * fix lint
This commit is contained in:
@@ -100,6 +100,7 @@ export function groupShapes(
|
|||||||
|
|
||||||
afterShapes[groupId] = TLDR.get_shape_util(TDShapeType.Group).create({
|
afterShapes[groupId] = TLDR.get_shape_util(TDShapeType.Group).create({
|
||||||
id: groupId,
|
id: groupId,
|
||||||
|
affineId: groupId,
|
||||||
childIndex: groupChildIndex,
|
childIndex: groupChildIndex,
|
||||||
parentId: groupParentId,
|
parentId: groupParentId,
|
||||||
point: [groupBounds.minX, groupBounds.minY],
|
point: [groupBounds.minX, groupBounds.minY],
|
||||||
@@ -217,7 +218,6 @@ export function groupShapes(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: 'group',
|
id: 'group',
|
||||||
before: {
|
before: {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import type { TldrawApp } from '@toeverything/components/board-state';
|
import { TLDR, TldrawApp } from '@toeverything/components/board-state';
|
||||||
import type { TDShape } from '@toeverything/components/board-types';
|
import { TDShape, TDShapeType } from '@toeverything/components/board-types';
|
||||||
import { GroupIcon, UngroupIcon } from '@toeverything/components/icons';
|
import { GroupIcon, UngroupIcon } from '@toeverything/components/icons';
|
||||||
import { IconButton, Tooltip } from '@toeverything/components/ui';
|
import { IconButton, Tooltip } from '@toeverything/components/ui';
|
||||||
|
import { services } from '@toeverything/datasource/db-service';
|
||||||
import { getShapeIds } from './utils';
|
import { getShapeIds } from './utils';
|
||||||
|
|
||||||
interface GroupAndUnGroupProps {
|
interface GroupAndUnGroupProps {
|
||||||
@@ -10,8 +11,38 @@ interface GroupAndUnGroupProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Group = ({ app, shapes }: GroupAndUnGroupProps) => {
|
export const Group = ({ app, shapes }: GroupAndUnGroupProps) => {
|
||||||
const group = () => {
|
const group = async () => {
|
||||||
app.group(getShapeIds(shapes));
|
let groupShape = await services.api.editorBlock.create({
|
||||||
|
workspace: app.document.id,
|
||||||
|
parentId: app.appState.currentPageId,
|
||||||
|
type: 'shape',
|
||||||
|
});
|
||||||
|
await services.api.editorBlock.update({
|
||||||
|
workspace: groupShape.workspace,
|
||||||
|
id: groupShape.id,
|
||||||
|
properties: {
|
||||||
|
shapeProps: {
|
||||||
|
value: JSON.stringify(
|
||||||
|
TLDR.get_shape_util(TDShapeType.Group).create({
|
||||||
|
id: groupShape.id,
|
||||||
|
affineId: groupShape.id,
|
||||||
|
childIndex: 1,
|
||||||
|
parentId: app.appState.currentPageId,
|
||||||
|
point: [0, 0],
|
||||||
|
size: [0, 0],
|
||||||
|
children: getShapeIds(shapes),
|
||||||
|
workspace: app.document.id,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
app.group(
|
||||||
|
getShapeIds(shapes),
|
||||||
|
groupShape.id,
|
||||||
|
app.appState.currentPageId
|
||||||
|
);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Tooltip content="Group">
|
<Tooltip content="Group">
|
||||||
|
|||||||
Reference in New Issue
Block a user