mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 05:25:53 +08:00
fix: can not copy from white board and paste in editor
This commit is contained in:
@@ -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 {
|
||||
RecastBlockProvider,
|
||||
getClipDataOfBlocksById,
|
||||
} 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(() => {
|
||||
@@ -62,6 +69,14 @@ const AffineBoard = ({ workspace, rootBlockId }: AffineBoardProps) => {
|
||||
onMount(app) {
|
||||
set_app(app);
|
||||
},
|
||||
async onCopy(e, groupIds) {
|
||||
const [mimeType, data] = await getClipDataOfBlocksById(
|
||||
editor,
|
||||
groupIds
|
||||
);
|
||||
|
||||
e.clipboardData?.setData(mimeType, data);
|
||||
},
|
||||
onChangePage(app, shapes, bindings, assets) {
|
||||
Promise.all(
|
||||
Object.entries(shapes).map(async ([id, shape]) => {
|
||||
@@ -130,7 +145,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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user