fix: lint

This commit is contained in:
DiamondThree
2022-08-19 16:46:04 +08:00
26 changed files with 412 additions and 412 deletions
+27 -4
View File
@@ -5,7 +5,10 @@ import { getSession } from '@toeverything/components/board-sessions';
import { deepCopy, TldrawApp } from '@toeverything/components/board-state';
import { tools } from '@toeverything/components/board-tools';
import { TDShapeType } from '@toeverything/components/board-types';
import { RecastBlockProvider } from '@toeverything/components/editor-core';
import {
getClipDataOfBlocksById,
RecastBlockProvider,
} from '@toeverything/components/editor-core';
import { services } from '@toeverything/datasource/db-service';
import { AsyncBlock, BlockEditor } from '@toeverything/framework/virgo';
import { useEffect, useState } from 'react';
@@ -16,7 +19,11 @@ interface AffineBoardProps {
rootBlockId: string;
}
const AffineBoard = ({ workspace, rootBlockId }: AffineBoardProps) => {
const AffineBoard = ({
workspace,
rootBlockId,
editor,
}: AffineBoardProps & { editor: BlockEditor }) => {
const [app, set_app] = useState<TldrawApp>();
const [document] = useState(() => {
return {
@@ -61,8 +68,20 @@ const AffineBoard = ({ workspace, rootBlockId }: AffineBoardProps) => {
onMount(app) {
set_app(app);
},
async onCopy(e, groupIds) {
const clip = await getClipDataOfBlocksById(
editor,
groupIds
);
e.clipboardData?.setData(
clip.getMimeType(),
clip.getData()
);
},
async onChangePage(app, shapes, bindings, assets) {
await Promise.all(
Promise.all(
Object.entries(shapes).map(async ([id, shape]) => {
if (shape === undefined) {
return services.api.editorBlock.delete({
@@ -167,7 +186,11 @@ export const AffineBoardWitchContext = ({
}, [editor, rootBlockId]);
return page ? (
<RecastBlockProvider block={page}>
<AffineBoard workspace={workspace} rootBlockId={rootBlockId} />
<AffineBoard
workspace={workspace}
rootBlockId={rootBlockId}
editor={editor}
/>
</RecastBlockProvider>
) : null;
};