Skip to content

Commit

Permalink
lint fix (#348)
Browse files Browse the repository at this point in the history
* - added a Juxta mode that creates a translation burrito
- added a 'factoryCreateContent.js'  file to help factorize some code for 'createObsContent', 'createVersificationUSFM' and 'createAudioVersification' in 'saveProjetcsMeta.js'

- fixing some typos, fixing lint

* Refactorization of 'saveProjectsMeta.js'

* Scripture Burrito as a resource : added the poissibility for the user to search and download a SB as a resource in a module

* removed checkbox from the UI and query sb resource everytime

* Added a juxtalinear editor along with a new mode.
- auto load a book on the opening of a project
- auto save after a modification
- fixed a bit of typos and code

* created a juxtaBurrito creator and a function to add juxta content. Also edited the icon for Juxta mode (it's visible now) you can create a new juxta project

* ADDED juxta support for SB creation and fixed some typos

* ADDED support for usfm import for a juxta project. Now we have to change the way a juxta json is built.

* juxtalineat mode functionnal

* UPDATE : now the interface handle corectly a json juxta file and update it if needed. and layout color update

* function to update a json juxta file if needed

* checksums ok for each modifications of the juxta

* bugfix : juxta was still using a translation settings

* quick fix

* added new kewboard shortcuts : 'Tab' to navigate through line chuncks, 'double click' to modify a chunck, 'enter' to end the modification of a chunck. And added seemless navigation between Juxtalinear editor and the BibleEditorX. Navigating through verses and chapters with the menu bar will load the corresponding sentence and vice versa.

* removing a useless 'console.log'

* FIXED font size when aditing a chunck, ADDED a bit of css and added a skip for the liter for .ts files

* I put the sentences loading one layer outside the main editor, to avoid the editor to re-render everytime the juxtalinear editor module

* Many bugfixes #303 (comment)

* add a check if the folder exists

* added a little bit of secure code for OBS loading

* changed the behavior of the Snackbar. If error === 'failure' the snackbar will show up for a longer time

* changed the behavior of the Snackbar. If error === 'failure' the snackbar will show up for a longer time

* bold text 'CREATE PROJECT' for better visibility and start to check 'canonSpecification' for a juxta project

* added the feature that download resources not imported by the user for juxtalinear project

* Now the user is correctly notified when the imported books does not match the canon specification, and also, the canon specification automatically matches the file imported

* minor bugfixes and code cleaning

* changed place of the 'nprogress' by few px

* added a better user-friendly messages to nugde the user to import at least one resource for a Juxtalinear project

* FIXED : archive a Text Translation project OK.

* star/unstar a juxtalinear project works now

* FIX : bug that prevented some resources to show up. and FIX : bug that was throwing an error when a user where to search for a resource in the resource search field, and click on 'no match found'

* deleted package-lock.json and updated yarn.lock

* updated french translation

* bugfix : you can now edit a juxta project properly

* fixed bug where on book change, the sentences where wronly saved under another filename

* make 'jsonFileContent.bookCode' to upper case for safety reasons

* FIX : export/import now works properly for juxtalinear projects

* fix obs auto zipping on export

* spinner and 'create project' button css fix.

* 'create project' button reverted

* fixed most of the lint errors. It leaves the 'control label errors' and one nested ternary operation here : 'renderer/src/components/EditorPage/Reference/OBS/ObsTn.js' line 147

* lint fixes until 'labels missing'

* removed useless file

* removed a comment

---------

Co-authored-by: danielc-n <[email protected]>
  • Loading branch information
DanielC-N and danielc-n authored Jun 14, 2024
1 parent 2c83c31 commit 3a4ba4b
Show file tree
Hide file tree
Showing 21 changed files with 150 additions and 268 deletions.
82 changes: 66 additions & 16 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@
"no-underscore-dangle": "off",
"no-unused-expressions": "off",
"max-len": "off",
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
"no-plusplus": [
"error",
{
"allowForLoopAfterthoughts": true
}
],
"prefer-destructuring": "off",
"no-param-reassign": [2, { "props": false }],
"no-param-reassign": [
2,
{
"props": false
}
],
"camelcase": "off",
"consistent-return": "off",
"react/function-component-definition": [
Expand All @@ -31,13 +41,19 @@
"function-expression",
"arrow-function"
],
"unnamedComponents": ["function-expression", "arrow-function"]
"unnamedComponents": [
"function-expression",
"arrow-function"
]
}
],
"react/jsx-filename-extension": [
1,
{
"extensions": [".js", ".jsx"]
"extensions": [
".js",
".jsx"
]
}
],
"react/jsx-no-bind": [
Expand All @@ -60,14 +76,23 @@
"react/forbid-prop-types": "off",
"linebreak-style": 0,
"global-require": 0,
"eslint linebreak-style": [0, "error", "windows"],
"eslint linebreak-style": [
0,
"error",
"windows"
],
"import/no-unresolved": [
"error",
{
"ignore": [".svg"]
"ignore": [
".svg"
]
}
],
"curly": ["error", "all"],
"curly": [
"error",
"all"
],
"template-curly-spacing": "off",
"indent": "off"
},
Expand All @@ -92,18 +117,43 @@
"import/resolver": {
"alias": {
"map": [
["@/components", "./renderer/src/components/"],
["@/layouts", "./renderer/src/layouts/"],
["@/modules", "./renderer/src/modules/"],
["@/util", "./renderer/src/util/"],
["@/core", "./renderer/src/core/"],
["@/hooks", "./renderer/src/hooks/"]
[
"@/components",
"./renderer/src/components/"
],
[
"@/layouts",
"./renderer/src/layouts/"
],
[
"@/modules",
"./renderer/src/modules/"
],
[
"@/util",
"./renderer/src/util/"
],
[
"@/core",
"./renderer/src/core/"
],
[
"@/hooks",
"./renderer/src/hooks/"
]
],
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
"extensions": [
".js",
".jsx",
".ts",
".tsx"
]
}
}
}
},
"plugins": ["react"]
}
"plugins": [
"react"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const EditorPage = ({
&& (
<div
role="button"
aria-label="select verse"
tabIndex={0}
key={mainChunk.verseNumber}
className={`relative ${mainChunk.verseNumber === verse ? 'bg-light' : 'bg-gray-100'} m-3 px-3 py-4 justify-center items-center
Expand Down
62 changes: 30 additions & 32 deletions renderer/src/components/EditorPage/JuxtaTextEditor/Editor.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable no-unused-vars */
/* eslint-disable arrow-body-style */
import React, { useContext, useEffect, useState } from 'react';
import md5 from 'md5';

Expand All @@ -8,16 +9,16 @@ import { ProjectContext } from '@/components/context/ProjectContext';
import { ScribexContext } from '@/components/context/ScribexContext';
import EmptyScreen from '@/components/Loading/EmptySrceen';
// eslint-disable-next-line import/no-unresolved, import/extensions
import SentenceContextProvider from '@/components/context/SentenceContext';
import { useReadJuxtaFile } from '@/components/EditorPage/JuxtaTextEditor/hooks/useReadJuxtaFile';
import { normalizeString } from '@/components/Projects/utils/updateJsonJuxta';
import { functionMapping } from './utils/insertFunctionMap';

// import RecursiveBlock from './RecursiveBlock';
// eslint-disable-next-line import/no-unresolved, import/extensions
import { useAutoSaveIndication } from '@/hooks2/useAutoSaveIndication';
import { onIntersection } from './utils/IntersectionObserver';
import JuxtalinearEditor from '@/components/EditorPage/JuxtalinearEditor'; // eslint-disable-line
import SentenceContextProvider from '@/components/context/SentenceContext';
import { useReadJuxtaFile } from '@/components/EditorPage/JuxtaTextEditor/hooks/useReadJuxtaFile';
import { normalizeString } from '@/components/Projects/utils/updateJsonJuxta.js';
// import { readUserSettings } from '@/core/projects/userSettings';

export default function Editor(props) {
Expand Down Expand Up @@ -68,10 +69,8 @@ export default function Editor(props) {
const style = isSaving ? { cursor: 'progress' } : {};

const [fileName, setFileName] = useState('');
const [sentences, setGlobalTotalSentences] = useState(
new Array(),
);
const [originText, setOriginText] = useState([])
const [sentences, setGlobalTotalSentences] = useState([]);
const [originText, setOriginText] = useState([]);
const [itemArrays, setItemArrays] = useState([]);
const [curIndex, setCurIndex] = useState(0);

Expand All @@ -83,13 +82,13 @@ export default function Editor(props) {
newItemArrays[index] = itemArr;
setItemArrays(newItemArrays);
setLoadingSentencesInProgress(false);
}
};

const setGlobalSentences = (index, sentence) => {
const newSentences = [...sentences];
newSentences[index] = sentence;
setGlobalTotalSentences(newSentences);
}
};

useEffect(() => {
setBookChange(false);
Expand Down Expand Up @@ -129,21 +128,21 @@ export default function Editor(props) {
}
return { ...src, index: counts[src.content] };
});
currentCs = md5(normalizeString(JSON.stringify(source) + chunk.gloss)) + '';
currentCs = `${md5(normalizeString(JSON.stringify(source) + chunk.gloss))}`;
checksumChuncks += currentCs;
return {
source,
gloss: chunk.gloss,
checksum: currentCs
checksum: currentCs,
};
});
currentCs = md5(checksumChuncks) + '';
currentCs = `${md5(checksumChuncks)}`;
checksumSentences += currentCs;
return {
originalSource: stc.originalSource,
chunks,
sourceString: stc.sourceString,
checksum: checksumSentences
checksum: checksumSentences,
};
});
};
Expand All @@ -167,25 +166,24 @@ export default function Editor(props) {
};
})
.filter(({ chunk }) => chunk.length);
} else {
return sentences[curIndex].chunks
.map(({ source, gloss, checksum }, index) => {
return {
chunk: source
.filter((s) => s)
.map((s, n) => {
return {
id: `item-${index * 1000 + n}`,
content: s.content,
index: s.index
};
}),
gloss,
checksum,
};
})
.filter(({ chunk }) => chunk.length);
}
return sentences[curIndex].chunks
.map(({ source, gloss, checksum }, index) => {
return {
chunk: source
.filter((s) => s)
.map((s, n) => {
return {
id: `item-${index * 1000 + n}`,
content: s.content,
index: s.index,
};
}),
gloss,
checksum,
};
})
.filter(({ chunk }) => chunk.length);
};

const tryLoadSentences = () => {
Expand All @@ -201,7 +199,7 @@ export default function Editor(props) {
}
}
setLoadingSentencesInProgress(false);
}
};

useEffect(() => {
setLoadingSentencesInProgress(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext } from 'react';

import { ProjectContext } from '@/components/context/ProjectContext';
// import MenuDropdown from '@/components/MenuDropdown/MenuDropdown';
import { LockClosedIcon, BookmarkIcon, LockOpenIcon } from '@heroicons/react/24/outline';
import { LockClosedIcon, LockOpenIcon } from '@heroicons/react/24/outline';
// import BibleNavigationX from '@/components/EditorPage/JuxtaTextEditor/BibleNavigationX';
import BibleNavigationX from './BibleNavigationX';
// import Buttons from './Buttons';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export default function CustomNavigation({
onClick={openBooks}
role="button"
tabIndex="-2"
aria-label="open books"
>
<ChevronDownIcon className="focus:outline-none inline h-4 w-4 mx-1 text-white" aria-hidden="true" />
</span>
Expand All @@ -120,6 +121,7 @@ export default function CustomNavigation({
className="focus:outline-none bg-white py-4 bg-opacity-10"
onClick={selectBook}
role="button"
aria-label="Select books"
tabIndex="-1"
>
<ChevronDownIcon className="focus:outline-none inline h-4 w-4 mx-1 text-white" aria-hidden="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export default function SelectBook({
<>
<div className="flex flex-row text-center bg-gray-800 text-white text-sm font-bold tracking-wide uppercase">
<div className="w-40 m-auto grid grid-cols-3 gap-0 bg-primary">
<div role="button" onClick={toggle} className="p-2 bg-black hover:bg-primary backdrop-opacity-20 cursor-pointer" tabIndex={0}>{t('btn-all')}</div>
<div role="button" onClick={toggleOT} tabIndex={-1} className={openOT === false ? 'p-2 bg-black hover:bg-primary backdrop-opacity-20 cursor-pointer' : 'p-2 border-r-2 border-black hover:bg-black border-opacity-5 cursor-pointer'}>{t('btn-ot')}</div>
<div role="button" onClick={toggleNT} tabIndex={-2} className={openNT === false ? 'p-2 bg-black hover:bg-primary backdrop-opacity-20 cursor-pointer' : 'p-2 border-r-2 border-black hover:bg-black border-opacity-5 cursor-pointer'}>{t('btn-nt')}</div>
<div role="button" aria-label="toggle all books" onClick={toggle} className="p-2 bg-black hover:bg-primary backdrop-opacity-20 cursor-pointer" tabIndex={0}>{t('btn-all')}</div>
<div role="button" aria-label="toggle OT books" onClick={toggleOT} tabIndex={-1} className={openOT === false ? 'p-2 bg-black hover:bg-primary backdrop-opacity-20 cursor-pointer' : 'p-2 border-r-2 border-black hover:bg-black border-opacity-5 cursor-pointer'}>{t('btn-ot')}</div>
<div role="button" aria-label="toggle NT books" onClick={toggleNT} tabIndex={-2} className={openNT === false ? 'p-2 bg-black hover:bg-primary backdrop-opacity-20 cursor-pointer' : 'p-2 border-r-2 border-black hover:bg-black border-opacity-5 cursor-pointer'}>{t('btn-nt')}</div>
</div>
<div className="flex justify-end">
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function MultiComboBox({
<div
key={option}
role="button"
aria-label="select"
tabIndex={-2}
className="flex px-2 py-1 cursor-pointer justify-between hover:bg-gray-200 rounded-md"
onClick={() => setselectedOption(option)}
Expand Down
15 changes: 8 additions & 7 deletions renderer/src/components/EditorPage/Reference/OBS/ObsTn.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import localForage from 'localforage';
import { ReferenceContext } from '@/components/context/ReferenceContext';
import { ProjectContext } from '@/components/context/ProjectContext';
import LoadingScreen from '@/components/Loading/LoadingScreen';
import EmptyScreen from '@/components/Loading/EmptySrceen';
import { SnackBar } from '@/components/SnackBar';
import { getObsTn } from './getObsTn';
import ObsResourceCard from './ObsResourceCard';
import * as logger from '../../../../logger';
import tsvJSON from './TsvToJson';
import ObsTsvToChapterLevelMd from './ObsTsvToChapterLevel';
import packageInfo from '../../../../../../package.json';
import EmptyScreen from '@/components/Loading/EmptySrceen';
import { SnackBar } from '@/components/SnackBar';

function ObsTnCard({
resource,
Expand Down Expand Up @@ -88,12 +88,12 @@ function ObsTnCard({
if (offlineResource.data?.value?.dublin_core?.format?.toLowerCase() === 'text/tsv') {
logger.debug('inside OBS TN offline TSV resource');
let tsvFileName = offlineResource.data?.value?.projects[0]?.path;
let fullPathTsv = path.join(folder, projectName, tsvFileName);
const fullPathTsv = path.join(folder, projectName, tsvFileName);
// sometimes people put the path of the content dir instead of the name of the tsv file
if(!fs.existsSync(fullPathTsv) || fs.lstatSync(fullPathTsv).isDirectory()) {
tsvFileName = fs.readdirSync(path.join(folder, projectName)).filter(fn => fn.endsWith('.tsv'))[0];
if (!fs.existsSync(fullPathTsv) || fs.lstatSync(fullPathTsv).isDirectory()) {
tsvFileName = fs.readdirSync(path.join(folder, projectName)).filter((fn) => fn.endsWith('.tsv'))[0];
}
if(tsvFileName && fs.existsSync(path.join(folder, projectName, tsvFileName)) && fs.lstatSync(path.join(folder, projectName, tsvFileName)).isFile()) {
if (tsvFileName && fs.existsSync(path.join(folder, projectName, tsvFileName)) && fs.lstatSync(path.join(folder, projectName, tsvFileName)).isFile()) {
const obsTsvData = await fs.readFileSync(path.join(folder, projectName, tsvFileName), 'utf8');
const obsTsvJson = obsTsvData && await tsvJSON(obsTsvData);
logger.debug('inside OBS TN offline TSV resource : created TSV JSON');
Expand Down Expand Up @@ -171,7 +171,8 @@ function ObsTnCard({
setSnackText={setSnackText}
error={notify}
/>
</>)
</>
)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const TranslationHelps = ({
<>
{(() => {
switch (selectedResource) {
// Nicolas : do we add a juxta type here ?
case 'tn':
return (
<TranslationHelpsCard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default function EditorMenuBar(props) {
<div
role="button"
tabIndex="0"
aria-label="bookmark"
title="bookmark"
className="focus:outline-none border-r-2 border-l-2 border-white border-opacity-10"
>
Expand Down
3 changes: 2 additions & 1 deletion renderer/src/components/ImageSlider/SliderItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ function SliderItem({ index, activeIndex, children }) {
<div
role="button"
tabIndex={-1}
className="absolute h-full w-full overflow-hidden rounded-xl
className="absolute h-full w-full overflow-hidden rounded-xl
drop-shadow-[0_8px_30px_rgb(255,255,255,0.12)] transition-all duration-500 ease-in-out"
style={{
transform: cssTransformProperties,
opacity: cssOpacity,
display: cssDisplay,
zIndex: `${1}`,
}}
aria-label="slide image"
>
{children}
</div>
Expand Down
Loading

0 comments on commit 3a4ba4b

Please sign in to comment.