From a5839fc7cf982f03cc00a52e27f18bd417796a32 Mon Sep 17 00:00:00 2001
From: VIPIN PAUL <37212471+vipinpaul@users.noreply.github.com>
Date: Mon, 20 Nov 2023 11:23:38 +0530
Subject: [PATCH] Saving font in the backend (#215)
* Saving font for Text editor
* Enabling font selector for reference pane and saving it in the backend
* Saving font for OBS editor and Audio in the backend
* Fixing the conflict
---
renderer/environment.js | 2 +-
.../EditorPage/ObsEditor/ReferenceObs.js | 5 +-
.../Reference/OBS/ObsResourceCard.js | 27 +--
.../EditorPage/Reference/OBS/ObsTn.js | 2 +
.../EditorPage/Reference/OBS/ObsTwlCard.js | 2 +
.../EditorPage/Reference/ReferenceCard.js | 28 +--
.../EditorPage/Reference/TranslationHelps.js | 13 +-
.../Reference/TranslationHelpsCard.js | 2 +
.../components/EditorPage/Scribex/Scribex.jsx | 201 ++++++++++++++++++
.../EditorPage/TextEditor/EditorMenuBar.jsx | 4 +-
.../EditorPage/TextEditor/index.jsx | 7 +-
.../createDownloadedResourceSB.js | 1 +
renderer/src/components/SnackBar/SnackBar.js | 2 +-
.../Sync/Gitea/SyncFromGiteaUtils.js | 12 +-
renderer/src/components/Sync/GridRow.jsx | 2 +-
.../components/context/ReferenceContext.js | 11 +
renderer/src/core/burrito/importBurrito.js | 12 +-
.../editor/fetchSettingsResourceHistory.js | 4 +
.../editor/saveSettingsResourceHistory.js | 5 +
.../src/core/projects/updateAgSettings.js | 18 +-
renderer/src/layouts/editor/EditorSection.js | 2 +-
.../src/layouts/editor/SectionPlaceholder1.js | 25 ++-
.../src/layouts/editor/SectionPlaceholder2.js | 20 ++
renderer/src/modules/editor/Editor.js | 6 +
renderer/src/util/createAudioVersification.js | 1 +
renderer/src/util/createObsContent.js | 2 +
renderer/src/util/createVersificationUSFM.js | 2 +
27 files changed, 370 insertions(+), 48 deletions(-)
create mode 100644 renderer/src/components/EditorPage/Scribex/Scribex.jsx
diff --git a/renderer/environment.js b/renderer/environment.js
index 30bdb97fe..f855a8e7b 100644
--- a/renderer/environment.js
+++ b/renderer/environment.js
@@ -2,7 +2,7 @@ export const environment = {
PROJECT_SETTING_FILE: 'scribe-settings.json',
USER_SETTING_FILE: 'scribe-user-settings.json',
production: false,
- AG_SETTING_VERSION: '1.2.1',
+ AG_SETTING_VERSION: '1.2.2',
AG_USER_SETTING_VERSION: '1.2.0',
APPLICATION_ID: 'AutographaEditor',
JAVASCRIPT_KEY: 'C3925DFBCF06DF5291AC',
diff --git a/renderer/src/components/EditorPage/ObsEditor/ReferenceObs.js b/renderer/src/components/EditorPage/ObsEditor/ReferenceObs.js
index 43fe2b1ac..7c82932b8 100644
--- a/renderer/src/components/EditorPage/ObsEditor/ReferenceObs.js
+++ b/renderer/src/components/EditorPage/ObsEditor/ReferenceObs.js
@@ -17,13 +17,12 @@ const style = {
fontStyle: 'italic',
},
};
-const ReferenceObs = ({ stories }) => {
+const ReferenceObs = ({ stories, font }) => {
const [isLoading, setIsLoading] = useState(true);
const [networkState, setNetworkState] = useState({ online: true });
const {
state: {
selectedStory,
- selectedFont,
fontSize,
},
actions: {
@@ -104,7 +103,7 @@ const { t } = useTranslation();
1.3) ? 1.5 : '',
}}
diff --git a/renderer/src/components/EditorPage/Reference/OBS/ObsResourceCard.js b/renderer/src/components/EditorPage/Reference/OBS/ObsResourceCard.js
index 799337d53..5890d1168 100644
--- a/renderer/src/components/EditorPage/Reference/OBS/ObsResourceCard.js
+++ b/renderer/src/components/EditorPage/Reference/OBS/ObsResourceCard.js
@@ -16,6 +16,7 @@ function ObsResourceCard({
languageId,
isLoading,
setIndex,
+ font,
}) {
const {
state: { filters, markdownView },
@@ -35,18 +36,20 @@ function ObsResourceCard({
itemIndex={index}
setItemIndex={setIndex}
/>
-
+
+
+
>
);
}
diff --git a/renderer/src/components/EditorPage/Reference/OBS/ObsTn.js b/renderer/src/components/EditorPage/Reference/OBS/ObsTn.js
index 41ce41b7d..2899e2f7a 100644
--- a/renderer/src/components/EditorPage/Reference/OBS/ObsTn.js
+++ b/renderer/src/components/EditorPage/Reference/OBS/ObsTn.js
@@ -26,6 +26,7 @@ function ObsTnCard({
owner,
resourceId,
offlineResource,
+ font,
...props
}) {
const [index, setIndex] = useState(0);
@@ -141,6 +142,7 @@ function ObsTnCard({
shouldSetQuoteOnClick
index={index}
setIndex={(v) => setIndex(v)}
+ font={font}
/>
) :
);
diff --git a/renderer/src/components/EditorPage/Reference/OBS/ObsTwlCard.js b/renderer/src/components/EditorPage/Reference/OBS/ObsTwlCard.js
index b1fc6e096..8c226d1f5 100644
--- a/renderer/src/components/EditorPage/Reference/OBS/ObsTwlCard.js
+++ b/renderer/src/components/EditorPage/Reference/OBS/ObsTwlCard.js
@@ -22,6 +22,7 @@ function ObsTwlCard({
owner,
resourceId,
offlineResource,
+ font,
...props
}) {
const [index, setIndex] = useState(1);
@@ -102,6 +103,7 @@ function ObsTwlCard({
shouldSetQuoteOnClick
index={index}
setIndex={(v) => setIndex(v)}
+ font={font}
/>
) : (
diff --git a/renderer/src/components/EditorPage/Reference/ReferenceCard.js b/renderer/src/components/EditorPage/Reference/ReferenceCard.js
index db99b4e57..8efd82418 100644
--- a/renderer/src/components/EditorPage/Reference/ReferenceCard.js
+++ b/renderer/src/components/EditorPage/Reference/ReferenceCard.js
@@ -14,19 +14,23 @@ const ReferenceCard = ({
setQuote,
viewMode,
isLoading,
+ font,
}) => (
-
+
+
+
+
);
export default ReferenceCard;
diff --git a/renderer/src/components/EditorPage/Reference/TranslationHelps.js b/renderer/src/components/EditorPage/Reference/TranslationHelps.js
index c35f497ec..fcbac2c0f 100644
--- a/renderer/src/components/EditorPage/Reference/TranslationHelps.js
+++ b/renderer/src/components/EditorPage/Reference/TranslationHelps.js
@@ -7,7 +7,7 @@ import ObsTnCard from './OBS/ObsTn';
import ObsTwlCard from './OBS/ObsTwlCard';
const TranslationHelps = ({
- selectedResource, languageId, refName, bookId, chapter, verse, owner, story, offlineResource,
+ selectedResource, languageId, refName, bookId, chapter, verse, owner, story, offlineResource, font,
}) => {
const {
state: {
@@ -39,6 +39,7 @@ const TranslationHelps = ({
owner={owner}
server="https://git.door43.org"
offlineResource={offlineResource}
+ font={font}
/>
);
case 'twl':
@@ -54,6 +55,7 @@ const TranslationHelps = ({
resourceId="twl"
owner="test_org"
server="https://git.door43.org"
+ font={font}
/>
);
case 'twlm':
@@ -69,6 +71,7 @@ const TranslationHelps = ({
resourceId="twl"
owner={owner}
server="https://git.door43.org"
+ font={font}
/>
);
case 'tq':
@@ -86,6 +89,7 @@ const TranslationHelps = ({
owner={owner}
server="https://git.door43.org"
offlineResource={offlineResource}
+ font={font}
/>
);
case 'tw':
@@ -101,6 +105,7 @@ const TranslationHelps = ({
filePath={offlineResource?.twSelected?.folder}
server="https://git.door43.org"
offlineResource={offlineResource}
+ font={font}
/>
);
case 'ta':
@@ -117,6 +122,7 @@ const TranslationHelps = ({
filePath={filePathTa}
server="https://git.door43.org"
offlineResource={offlineResource}
+ font={font}
/>
);
case 'bible':
@@ -128,6 +134,7 @@ const TranslationHelps = ({
bookId={bookId}
chapter={chapter}
verse={verse}
+ font={font}
/>
);
case 'obs':
@@ -139,6 +146,7 @@ const TranslationHelps = ({
bookId={bookId}
chapter={chapter}
verse={verse}
+ font={font}
/>
);
case 'obs-tn':
@@ -154,6 +162,7 @@ const TranslationHelps = ({
owner={owner}
server="https://git.door43.org"
offlineResource={offlineResource}
+ font={font}
/>
);
case 'obs-tq':
@@ -169,6 +178,7 @@ const TranslationHelps = ({
owner={owner}
server="https://git.door43.org"
offlineResource={offlineResource}
+ font={font}
/>
);
case 'obs-twlm':
@@ -184,6 +194,7 @@ const TranslationHelps = ({
owner={owner}
server="https://git.door43.org"
offlineResource={offlineResource}
+ font={font}
/>
);
default:
diff --git a/renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js b/renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js
index aa0b49d4a..fd6c18090 100644
--- a/renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js
+++ b/renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js
@@ -25,6 +25,7 @@ export default function TranslationHelpsCard({
selectedQuote,
viewMode,
offlineResource,
+ font,
}) {
const [offlineItems, setOfflineItems] = useState([]);
const [offlineItemsDisable, setOfflineItemsDisable] = useState(false);
@@ -182,6 +183,7 @@ export default function TranslationHelpsCard({
viewMode={viewMode}
selectedQuote={selectedQuote}
setQuote={setQuote}
+ font={font}
/>
>
);
diff --git a/renderer/src/components/EditorPage/Scribex/Scribex.jsx b/renderer/src/components/EditorPage/Scribex/Scribex.jsx
new file mode 100644
index 000000000..d410f6254
--- /dev/null
+++ b/renderer/src/components/EditorPage/Scribex/Scribex.jsx
@@ -0,0 +1,201 @@
+import {
+ useEffect, useState, useContext, Fragment,
+} from 'react';
+import { useProskomma, useImport, useCatalog } from 'proskomma-react-hooks';
+import { useDeepCompareEffect } from 'use-deep-compare';
+import { LockClosedIcon, BookmarkIcon, LockOpenIcon } from '@heroicons/react/24/outline';
+import BibleNavigationX from '@/modules/biblenavigation/BibleNavigationX';
+import usePerf from '@/components/hooks/scribex/usePerf';
+import htmlMap from '@/components/hooks/scribex/htmlmap';
+import { ScribexContext } from '@/components/context/ScribexContext';
+import { ReferenceContext } from '@/components/context/ReferenceContext';
+import { ProjectContext } from '@/components/context/ProjectContext';
+import EditorSideBar from '@/modules/editorsidebar/EditorSideBar';
+import MenuDropdown from '@/components/MenuDropdown/MenuDropdown';
+import Buttons from './Buttons';
+import Editor from './Editor';
+import InsertMenu from './InsertMenu';
+
+export default function Scribex(props) {
+ const { state, actions } = useContext(ScribexContext);
+ const { verbose } = state;
+ const { usfmData, bookAvailable } = props;
+ const [selectedBook, setSelectedBook] = useState();
+ const [bookChange, setBookChange] = useState(false);
+ const [chapterNumber, setChapterNumber] = useState(1);
+ const [verseNumber, setVerseNumber] = useState(1);
+ const [triggerVerseInsert, setTriggerVerseInsert] = useState(false);
+ const [newVerChapNumber, setInsertNumber] = useState('');
+ const [insertVerseRChapter, setInsertVerseRChapter] = useState('');
+ const [selectedText, setSelectedText] = useState();
+
+ const handleClick = (number, title) => {
+ setInsertNumber(number);
+ setInsertVerseRChapter(title);
+ setTriggerVerseInsert(!triggerVerseInsert);
+ };
+
+ let selectedDocument;
+
+ const { proskomma, stateId, newStateId } = useProskomma({ verbose });
+ const { done } = useImport({
+ proskomma,
+ stateId,
+ newStateId,
+ documents: usfmData,
+ });
+
+ const {
+ state: {
+ bookId, selectedFont, fontSize, projectScriptureDir,
+ },
+ actions: { handleSelectedFont },
+ } = useContext(ReferenceContext);
+
+ const {
+ states: { scrollLock },
+ actions: { setScrollLock },
+ } = useContext(ProjectContext);
+
+ const {
+ states: { openSideBar },
+ actions: { setOpenSideBar },
+ } = useContext(ProjectContext);
+
+ function closeSideBar(open) {
+ setOpenSideBar(open);
+ }
+
+ useEffect(() => {
+ setSelectedBook(bookId.toUpperCase());
+ setBookChange(true);
+ }, [bookId]);
+
+ const { catalog } = useCatalog({ proskomma, stateId, verbose });
+ const { id: docSetId, documents } = (done && catalog.docSets[0]) || {};
+ if (done) {
+ selectedDocument = documents?.find(
+ (doc) => doc.bookCode === selectedBook,
+ );
+ }
+
+ const { bookCode, h: bookName } = selectedDocument || {};
+ const ready = (docSetId && bookCode) || false;
+ const isLoading = !done || !ready;
+ const { state: perfState, actions: perfActions } = usePerf({
+ proskomma,
+ ready,
+ docSetId,
+ bookCode,
+ verbose,
+ htmlMap,
+ });
+ const { htmlPerf } = perfState;
+
+ useDeepCompareEffect(() => {
+ if (htmlPerf && htmlPerf.mainSequenceId !== state.sequenceIds[0]) {
+ actions.setSequenceIds([htmlPerf?.mainSequenceId]);
+ }
+ }, [htmlPerf, state.sequenceIds, perfState]);
+ const _props = {
+ ...state,
+ ...perfState,
+ ...actions,
+ ...perfActions,
+ triggerVerseInsert,
+ chapterNumber,
+ verseNumber,
+ isLoading,
+ bookName,
+ bookChange,
+ bookAvailable,
+ setBookChange,
+ setChapterNumber,
+ setVerseNumber,
+ newVerChapNumber,
+ insertVerseRChapter,
+ selectedText,
+ setSelectedText,
+ };
+ return (
+ <>
+
+
+
+
+
+
+ Editor
+
+
+
+ {scrollLock === true ? (
+ setScrollLock(!scrollLock)}
+ />
+ ) : (
+ setScrollLock(!scrollLock)}
+ />
+ )}
+
+
+
+
+
+
+
+
+
+
1.3) ? 1.5 : '',
+ direction: `${projectScriptureDir === 'RTL' ? 'rtl' : 'auto'}`,
+ }}
+ className="border-l-2 border-r-2 border-secondary pb-16 overflow-auto h-full scrollbars-width leading-8"
+ >
+
+
+
+ >
+ );
+}
diff --git a/renderer/src/components/EditorPage/TextEditor/EditorMenuBar.jsx b/renderer/src/components/EditorPage/TextEditor/EditorMenuBar.jsx
index a6cb2478e..6cbaf96b7 100644
--- a/renderer/src/components/EditorPage/TextEditor/EditorMenuBar.jsx
+++ b/renderer/src/components/EditorPage/TextEditor/EditorMenuBar.jsx
@@ -15,7 +15,7 @@ export default function EditorMenuBar(props) {
setChapterNumber,
verseNumber,
setVerseNumber,
- setSelectedFont,
+ handleSelectedFont,
setTriggerVerseInsert,
} = props;
@@ -78,7 +78,7 @@ export default function EditorMenuBar(props) {
-
+
diff --git a/renderer/src/components/EditorPage/TextEditor/index.jsx b/renderer/src/components/EditorPage/TextEditor/index.jsx
index 797c9d875..954ad361a 100644
--- a/renderer/src/components/EditorPage/TextEditor/index.jsx
+++ b/renderer/src/components/EditorPage/TextEditor/index.jsx
@@ -28,8 +28,8 @@ export default function TextEditor() {
const { usfmData, bookAvailable } = useReadUsfmFile();
const {
- state: { bookId },
- actions: { setSelectedFont },
+ state: { bookId, selectedFont },
+ actions: { handleSelectedFont },
} = useContext(ReferenceContext);
const {
@@ -88,6 +88,7 @@ export default function TextEditor() {
...perfState,
...actions,
...perfActions,
+ selectedFont,
chapterNumber,
verseNumber,
isLoading,
@@ -97,7 +98,7 @@ export default function TextEditor() {
setBookChange,
setChapterNumber,
setVerseNumber,
- setSelectedFont,
+ handleSelectedFont,
triggerVerseInsert,
setTriggerVerseInsert,
};
diff --git a/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js b/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js
index b80746412..70c1f07c4 100644
--- a/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js
+++ b/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js
@@ -140,6 +140,7 @@ export const generateAgSettings = async (metaData, currentResourceMeta, selectRe
lastSeen: moment().format(),
refResources: [],
bookMarks: [],
+ font: '',
},
},
sync: { services: { door43: [] } },
diff --git a/renderer/src/components/SnackBar/SnackBar.js b/renderer/src/components/SnackBar/SnackBar.js
index 7fd91db13..78ed8f29e 100644
--- a/renderer/src/components/SnackBar/SnackBar.js
+++ b/renderer/src/components/SnackBar/SnackBar.js
@@ -58,7 +58,7 @@ const SnackBar = ({
leaveTo="opacity-0 translate-y-1"
>
-
+