diff --git a/cfdraw/.web/src/hooks/usePython.ts b/cfdraw/.web/src/hooks/usePython.ts index b599f25..90bd4f1 100644 --- a/cfdraw/.web/src/hooks/usePython.ts +++ b/cfdraw/.web/src/hooks/usePython.ts @@ -17,19 +17,21 @@ export async function getPythonRequest({ getExtraRequestData, opt = {}, needExportNodeData, + exportFullImages, }: Omit & { opt?: IGetPythonRequest; }): Promise> { let exportBox: BBox | undefined; if (!opt.noExport) { - exportBox = - nodes.length === 0 - ? node?.bbox ?? BBox.unit() - : nodes.length === 1 - ? nodes[0].bbox - : nodes[argMax(nodes.map((n) => n.bbox.area))].bbox; + exportBox = exportFullImages + ? undefined + : nodes.length === 0 + ? node?.bbox ?? BBox.unit() + : nodes.length === 1 + ? nodes[0].bbox + : nodes[argMax(nodes.map((n) => n.bbox.area))].bbox; } - const getNodeDataOpt: IGetNodeData = { exportBox, ...opt }; + const getNodeDataOpt: IGetNodeData = { exportBox, forceExport: exportFullImages, ...opt }; const nodeData = needExportNodeData ? await getNodeData(node, getNodeDataOpt) : {}; const nodeDataList = !needExportNodeData || nodes.length <= 1 ? [] : await getNodeDataList(nodes, getNodeDataOpt); @@ -61,6 +63,7 @@ export function useSocketPython({ onMessage, onSocketError, needExportNodeData, + exportFullImages, }: IUseSocketPython) { const deps = [ hash, @@ -81,6 +84,7 @@ export function useSocketPython({ identifier, getExtraRequestData, needExportNodeData, + exportFullImages, }).then((req) => ({ hash: hash!, ...req })), [deps], ); diff --git a/cfdraw/.web/src/plugins/_python/PluginWithSubmit.tsx b/cfdraw/.web/src/plugins/_python/PluginWithSubmit.tsx index 4feb582..5978367 100644 --- a/cfdraw/.web/src/plugins/_python/PluginWithSubmit.tsx +++ b/cfdraw/.web/src/plugins/_python/PluginWithSubmit.tsx @@ -42,6 +42,7 @@ function PythonPluginWithSubmit({ closeOnSubmit = true, toastOnSubmit = true, toastMessageOnSubmit, + exportFullImages, } = pluginInfo; const lang = langStore.tgt; const [hash, setHash] = useState(undefined); @@ -96,6 +97,7 @@ function PythonPluginWithSubmit({ onSocketError, getExtraRequestData, needExportNodeData: hasConstraint, + exportFullImages, }); useEffect(() => { diff --git a/cfdraw/.web/src/plugins/_python/hooks.ts b/cfdraw/.web/src/plugins/_python/hooks.ts index 8d69341..0adae78 100644 --- a/cfdraw/.web/src/plugins/_python/hooks.ts +++ b/cfdraw/.web/src/plugins/_python/hooks.ts @@ -135,7 +135,7 @@ export function useTextTransfer({ key, plugin: { pluginInfo, ...props } }: IUseT id: string; text: string; } { - const { node, nodes, identifier, retryInterval, updateInterval } = pluginInfo; + const { node, nodes, identifier, retryInterval, updateInterval, exportFullImages } = pluginInfo; const id = usePluginIds(`${key}_${identifier}`).id; const needRender = usePluginNeedRender(id); const [hash, setHash] = useState(undefined); @@ -174,6 +174,7 @@ export function useTextTransfer({ key, plugin: { pluginInfo, ...props } }: IUseT updateInterval, onMessage, needExportNodeData: hasConstraint, + exportFullImages, }); return { id, text: value }; diff --git a/cfdraw/.web/src/schema/_python.ts b/cfdraw/.web/src/schema/_python.ts index bc29090..b430ee4 100644 --- a/cfdraw/.web/src/schema/_python.ts +++ b/cfdraw/.web/src/schema/_python.ts @@ -14,6 +14,7 @@ interface IPythonPluginInfo extends IPluginInfo, IPythonSocketIntervals { name?: IStr; identifier: string; noErrorToast?: boolean; + exportFullImages?: boolean; } export interface IPythonPlugin extends IPlugin { pluginInfo: IPythonPluginInfo; diff --git a/cfdraw/schema/plugins.py b/cfdraw/schema/plugins.py index 7788681..74017f8 100644 --- a/cfdraw/schema/plugins.py +++ b/cfdraw/schema/plugins.py @@ -105,6 +105,10 @@ class IPluginInfo(BaseModel): gt=0, description="If not None, the plugin will be called every `updateInterval` ms", ) + exportFullImages: Optional[bool] = Field( + None, + description="Whether to export full images when multiple images are selected", + ) class IPluginSettings(IChakra):