Add text import export for toolbox modules
This commit is contained in:
parent
a9b5ca423a
commit
117b7b79e1
27 changed files with 1430 additions and 181 deletions
|
|
@ -0,0 +1,46 @@
|
|||
// Rôle : fournit les boutons et modales d'import/export texte des outils compatibles.
|
||||
import { Icon } from "../../../components/Icon.jsx";
|
||||
import { TextImportModal } from "./TextImportModal.jsx";
|
||||
import { useTextExchange } from "./useTextExchange.js";
|
||||
|
||||
export function TextExchangeActions({ type, data, context, onImport, textContent = {}, exportLabel = "" }) {
|
||||
const exchange = useTextExchange({ type, data, context, onImport, textContent });
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="text-import-actions">
|
||||
<button type="button" onClick={exchange.openImport}>
|
||||
<Icon name="import" />
|
||||
<span>{textContent.importOpenButton || "Importer du texte"}</span>
|
||||
</button>
|
||||
<button type="button" onClick={exchange.openExport} disabled={!exchange.canExport}>
|
||||
<Icon name="export" />
|
||||
<span>{textContent.exportOpenButton || exportLabel || "Exporter en format texte"}</span>
|
||||
</button>
|
||||
</div>
|
||||
{exchange.mode === "import" && (
|
||||
<TextImportModal
|
||||
title={textContent.importModalTitle || "Importer du texte"}
|
||||
value={exchange.draft}
|
||||
onChange={exchange.updateDraft}
|
||||
error={exchange.error}
|
||||
placeholder={textContent.importPlaceholder || "Collez le contenu à importer..."}
|
||||
submitLabel={textContent.importButton || "Importer le texte"}
|
||||
onSubmit={exchange.submitImport}
|
||||
onClose={exchange.closeModal}
|
||||
/>
|
||||
)}
|
||||
{exchange.mode === "export" && (
|
||||
<TextImportModal
|
||||
title={textContent.exportModalTitle || "Exporter en format texte"}
|
||||
value={exchange.exportText}
|
||||
readOnly
|
||||
info={textContent.exportInfo || ""}
|
||||
submitLabel={textContent.exportButton || "Copier le texte"}
|
||||
onCopy={exchange.copyExport}
|
||||
onClose={exchange.closeModal}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue