03a4410272
主要工作是共享同一套“画布内核与通用 UI 源码”,网站和 Tauri 只分别实现宿主适配层。 --------- Co-authored-by: 段舒康 <kdletters@qq.com> Co-authored-by: kdletters <kdletters@qq.com> Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/136 Co-authored-by: menghao <mh18530625731@163.com> Co-committed-by: menghao <mh18530625731@163.com>
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import type { CanvasTool } from '@genarrative/image-canvas-core';
|
|
import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
|
|
|
|
export type CanvasViewportProps = HTMLAttributes<HTMLDivElement> & {
|
|
children: ReactNode;
|
|
backgroundColor?: string;
|
|
isInteractionPaused?: boolean;
|
|
isPanning?: boolean;
|
|
tool?: CanvasTool;
|
|
};
|
|
|
|
export const CanvasViewport = forwardRef<HTMLDivElement, CanvasViewportProps>(
|
|
function CanvasViewport(
|
|
{
|
|
children,
|
|
backgroundColor,
|
|
className = '',
|
|
isInteractionPaused = false,
|
|
isPanning = false,
|
|
style,
|
|
tool = 'select',
|
|
...props
|
|
},
|
|
ref,
|
|
) {
|
|
return (
|
|
<div
|
|
{...props}
|
|
ref={ref}
|
|
className={[
|
|
'genarrative-image-canvas',
|
|
'genarrative-image-canvas__viewport',
|
|
isPanning ? 'genarrative-image-canvas__viewport--panning' : '',
|
|
`genarrative-image-canvas__viewport--tool-${tool}`,
|
|
className,
|
|
]
|
|
.filter(Boolean)
|
|
.join(' ')}
|
|
style={{
|
|
...style,
|
|
backgroundColor,
|
|
pointerEvents: isInteractionPaused ? 'none' : style?.pointerEvents,
|
|
}}
|
|
aria-disabled={isInteractionPaused || undefined}
|
|
>
|
|
{children}
|
|
</div>
|
|
);
|
|
},
|
|
);
|