diff --git a/package.json b/package.json
index 7ee66177..46ff2c09 100644
--- a/package.json
+++ b/package.json
@@ -185,7 +185,7 @@
"is-electron": "^2.2.1",
"isomorphic-git": "^1.24.0",
"js-yaml": "^4.1.0",
- "jxl-pdf": "0.6.0",
+ "jxl-pdf": "0.6.1",
"localforage": "1.10.0",
"lodash.isequal": "^4.5.0",
"markdown-translatable": "1.3.0",
diff --git a/renderer/src/layouts/editor/InnerFramePopup.js b/renderer/src/layouts/editor/InnerFramePopup.js
index 524729ad..70eef678 100644
--- a/renderer/src/layouts/editor/InnerFramePopup.js
+++ b/renderer/src/layouts/editor/InnerFramePopup.js
@@ -14,6 +14,7 @@ import { PdfPreview } from './pdfGenInterface/PdfPreview';
import { v4 as uuidv4 } from 'uuid';
import { ProjectContext } from '@/components/context/ProjectContext';
import { AutographaContext } from '@/components/context/AutographaContext';
+import { useTranslation } from 'react-i18next';
import {
TextOnlyTooltip,
StyledSwitch,
@@ -32,6 +33,7 @@ export default function InnerFramePopup() {
const jsonWithHeaderChoice = global.PdfGenStatic.pageInfo();
//use to know if we can drag or not
const [update, setUpdate] = useState(true);
+ const [doReset, setDoReset] = useState(true);
//the order Of The Selected choice
const [orderSelection, setOrderSelection] = useState([0]);
//is the json is validate or not
@@ -52,6 +54,8 @@ export default function InnerFramePopup() {
changeMetaDataToWrapperSection(selectedProject, projects),
);
+ const { t } = useTranslation();
+
//advenceMode allow adding new Wrapper
const [advanceMode, setAdvenceMode] = useState(false);
const [infoProject, setInfoProject] = useState(
@@ -71,9 +75,9 @@ export default function InnerFramePopup() {
setOpenModalAddWrapper(isOpen);
};
const handleChangeHeaderInfo = (type, value) => {
- let t = JSON.parse(headerInfo);
- t[type] = value;
- setHeaderInfo(JSON.stringify(t));
+ let data = JSON.parse(headerInfo);
+ data[type] = value;
+ setHeaderInfo(JSON.stringify(data));
};
let sortableListClassName = 'sortable-TESTWRAPPER-list';
@@ -235,10 +239,10 @@ export default function InnerFramePopup() {
useEffect(() => {
if (folder && nameFile !== '') {
setHeaderInfo((prev) => {
- let t = { ...JSON.parse(prev) };
- t['outputPath'] = folder + '/' + nameFile + '.pdf';
- t['verbose'] = false;
- return JSON.stringify(t);
+ let data = { ...JSON.parse(prev) };
+ data['outputPath'] = folder + '/' + nameFile + '.pdf';
+ data['verbose'] = false;
+ return JSON.stringify(data);
});
}
}, [nameFile, folder]);
@@ -255,9 +259,9 @@ export default function InnerFramePopup() {
console.log(err);
} else {
setHeaderInfo((prev) => {
- let t = { ...JSON.parse(prev) };
- t['workingDir'] = folder;
- return JSON.stringify(t);
+ let data = { ...JSON.parse(prev) };
+ data['workingDir'] = folder;
+ return JSON.stringify(data);
});
}
});
@@ -341,7 +345,7 @@ export default function InnerFramePopup() {
{}}>
- Reset parameters
+ onClick={() => {
+ setDoReset(!doReset);
+ }}>
+ {t('label-reset')}
{
if (isJsonValidate) {
setMessagePrint('');
- let t = new global.PdfGenStatic(
+ let pdfGen = new global.PdfGenStatic(
JSON.parse(kitchenFaucet),
pdfCallBacks,
);
- const path = t.options.global.workingDir;
- setMessagePrint(
- (prev) =>
- prev + '\n' + 'working in ' + path,
- );
-
+ const path = pdfGen.options.global.workingDir;
+ setMessagePrint('Generating Pdf ...');
try {
- await t.doPdf(); // Ensure doPdf is awaited since it's async
+ await pdfGen.doPdf();
} catch (pdfError) {
- setMessagePrint(
- 'PDF generation failed: ' +
- pdfError.message,
- );
+ setMessagePrint((prev) => prev + '\n' + 'PDF generation failed: ' + pdfError.message);
+ return;
}
+ setMessagePrint((prev) => prev + '\n' + 'Successful pdf generation.');
}
}}>
print
@@ -590,9 +593,9 @@ export default function InnerFramePopup() {
onClick={() => {
let i = Math.max(orderSelection) + 1;
setSelected((prev) => {
- let t = { ...prev };
- t[i] = { type: c, content: {} };
- return t;
+ let data = { ...prev };
+ data[i] = { type: c, content: {} };
+ return data;
});
setOrderSelection((prev) => [
...prev,
@@ -637,10 +640,10 @@ function transformPrintDataToKitchenFaucet(jsonData) {
delete elem['content'];
elem.sections = [];
if (currentWrapper.content.order) {
- for (let t = 0; t < currentWrapper.content.order.length; t++) {
+ for (let j = 0; j < currentWrapper.content.order.length; j++) {
let section = {
...currentWrapper.content.content[
- currentWrapper.content.order[t]
+ currentWrapper.content.order[j]
],
};
let source = section.source;
@@ -699,8 +702,8 @@ export function findProjectInfo(meta, autoGrapha) {
function changeMetaDataToWrapperSection(meta, autoGrapha) {
- let t = findProjectInfo(meta, autoGrapha);
- if (t.type === 'Text Translation') {
+ let projInfo = findProjectInfo(meta, autoGrapha);
+ if (projInfo.type === 'Text Translation') {
return {
0: {
type: 'bcvWrapper',
@@ -711,7 +714,7 @@ function changeMetaDataToWrapperSection(meta, autoGrapha) {
},
},
};
- } else if (t.type === 'OBS') {
+ } else if (projInfo.type === 'OBS') {
return {
0: {
type: 'obsWrapper',
@@ -722,7 +725,7 @@ function changeMetaDataToWrapperSection(meta, autoGrapha) {
},
},
};
- } else if (t.type === "Juxtalinear"){
+ } else if (projInfo.type === "Juxtalinear"){
return {
0: {
type: 'bcvWrapper',
diff --git a/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/SectionAccordion.js b/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/SectionAccordion.js
index c8b8a4b8..2e35d4fd 100644
--- a/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/SectionAccordion.js
+++ b/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/SectionAccordion.js
@@ -18,6 +18,7 @@ export function AccordionPicker({
removeButton,
advanceMode,
wrapperType,
+ doReset,
}) {
const {
states: { listResourcesForPdf },
@@ -239,6 +240,7 @@ export function AccordionPicker({
fieldInfo={f}
open={open}
lang={language}
+ doReset={doReset}
/>
))}
diff --git a/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/WrapperTemplate.js b/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/WrapperTemplate.js
index 0e8f4e3c..cc091ed3 100644
--- a/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/WrapperTemplate.js
+++ b/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/WrapperTemplate.js
@@ -10,6 +10,7 @@ import { ProjectContext } from '@/components/context/ProjectContext';
import { AutographaContext } from '@/components/context/AutographaContext';
import { findProjectInfo } from '../../InnerFramePopup';
export function WrapperTemplate({
+ doReset,
setFinalPrint,
projectInfo,
wrapperType,
@@ -242,6 +243,7 @@ export function WrapperTemplate({
display: 'flex',
}}>
{
console.log("call");
setJsonSpec((prev) => {
@@ -19,6 +19,14 @@ export function InputPicker({ fieldInfo, setJsonSpec, require,lang,open=true })
setInput(e.target.value);
};
+ const resetField = () => {
+ setInput(fieldInfo.suggestedDefault || "");
+ }
+
+ useEffect(() => {
+ resetField();
+ }, [doReset]);
+
return (
{
+ setInput(fieldInfo.suggestedDefault || '');
+ }
+
+ useEffect(() => {
+ resetField();
+ }, [doReset]);
+
const NumericFormatCustom = React.forwardRef(function NumericFormatCustom(
props,
ref,
diff --git a/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/fieldPicker/RessourcePicker.js b/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/fieldPicker/RessourcePicker.js
index 1d71d519..0e5efce9 100644
--- a/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/fieldPicker/RessourcePicker.js
+++ b/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/fieldPicker/RessourcePicker.js
@@ -4,7 +4,7 @@ import { ProjectContext } from '@/components/context/ProjectContext';
import { Button, Modal } from '@mui/material';
import ScriptureContentPicker from '@/components/ScriptureContentPicker/ScriptureContentPicker';
-export function RessourcePicker({ setJsonSpec, fieldInfo, ressourceKey, ressourceName, open=true }) {
+export function RessourcePicker({ doReset, setJsonSpec, fieldInfo, ressourceKey, ressourceName, open=true }) {
const [selected, setSelected] = useState('');
const [infoDisplay, setInfoDiplay] = useState('');
@@ -21,6 +21,15 @@ export function RessourcePicker({ setJsonSpec, fieldInfo, ressourceKey, ressourc
}, [selected]);
+ const resetField = () => {
+ setSelected('');
+ setInfoDiplay('');
+ }
+
+ useEffect(() => {
+ resetField();
+ }, [doReset]);
+
const {
states: { listResourcesForPdf },
actions: { setListResourcesForPdf },
diff --git a/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/fieldPicker/ScripturePicker.js b/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/fieldPicker/ScripturePicker.js
index a87fa735..3319110c 100644
--- a/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/fieldPicker/ScripturePicker.js
+++ b/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/fieldPicker/ScripturePicker.js
@@ -1,12 +1,10 @@
import { useState, useEffect } from 'react';
import { FieldPicker } from './FieldPicker';
import { Button } from '@mui/material';
-export function ScripturePicker({ fieldInfo, setJsonSpec, lang, open = true }) {
+export function ScripturePicker({ doReset, fieldInfo, setJsonSpec, lang, open = true }) {
const [scriptureJson, setScriptureJson] = useState('{}');
const [scriptureTable, setScriptureTable] = useState('[]');
- const [numberOfScripture, setNumberOfScripture] = useState(
- fieldInfo.nValues[0],
- );
+ const [numberOfScripture, setNumberOfScripture] = useState(fieldInfo.nValues[0]);
useEffect(() => {
setNumberOfScripture(fieldInfo.nValues[0]);
}, [fieldInfo]);
@@ -28,6 +26,16 @@ export function ScripturePicker({ fieldInfo, setJsonSpec, lang, open = true }) {
});
}, [numberOfScripture]);
+ const resetField = () => {
+ setScriptureJson('{}');
+ setScriptureTable('[]');
+ setNumberOfScripture(fieldInfo.nValues[0]);
+ }
+
+ useEffect(() => {
+ resetField();
+ }, [doReset]);
+
useEffect(() => {
setJsonSpec((prev) => {
const newState = typeof prev == "object" ? prev : JSON.parse(prev);
diff --git a/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/fieldPicker/SelectPicker.js b/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/fieldPicker/SelectPicker.js
index a210f942..4dd4edea 100644
--- a/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/fieldPicker/SelectPicker.js
+++ b/renderer/src/layouts/editor/pdfGenInterface/pdfGenWrappers/fieldPicker/SelectPicker.js
@@ -3,6 +3,7 @@ import { useEffect } from 'react';
import { v4 as uuidv4 } from 'uuid';
import '../../../../../../../styles/globals.css';
export function SelectPicker({
+ doReset,
fieldInfo,
require,
setJsonSpec,
@@ -23,6 +24,14 @@ export function SelectPicker({
setForm(event.target.value);
};
+ const resetField = () => {
+ setForm(fieldInfo.suggestedDefault || '');
+ }
+
+ useEffect(() => {
+ resetField();
+ }, [doReset]);
+
return (
{fieldInfo.label[lang]}
-
+