From 8bea62f44194be746e6dc9600fc5e4cc57bcfc4f Mon Sep 17 00:00:00 2001
From: VIPIN PAUL <37212471+vipinpaul@users.noreply.github.com>
Date: Fri, 19 Jan 2024 15:52:40 +0530
Subject: [PATCH 11/15] Updated the metadata URL to scribe web site (#305)
---
renderer/src/components/Sync/Gitea/SyncFromGiteaUtils.js | 2 +-
renderer/src/core/burrito/createAudioSB.js | 2 ++
renderer/src/core/burrito/createObsSB.js | 2 ++
renderer/src/core/burrito/createTranslationSB.js | 2 ++
renderer/src/core/burrito/importBurrito.js | 2 +-
renderer/src/layouts/projects/Export/ExportProjectPopUp.js | 2 ++
renderer/src/lib/AudioBurritoTemplete.json | 2 +-
renderer/src/lib/BurritoTemplete.json | 2 +-
renderer/src/lib/OBSTemplete.json | 2 +-
9 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/renderer/src/components/Sync/Gitea/SyncFromGiteaUtils.js b/renderer/src/components/Sync/Gitea/SyncFromGiteaUtils.js
index df6177a3d..3b1bd1109 100644
--- a/renderer/src/components/Sync/Gitea/SyncFromGiteaUtils.js
+++ b/renderer/src/components/Sync/Gitea/SyncFromGiteaUtils.js
@@ -211,7 +211,7 @@ export const importServerProject = async (updateBurrito, repo, sbData, auth, use
});
sbDataObject.idAuthorities = {
scribe: {
- id: 'http://www.autographa.org',
+ id: 'http://www.scribe.bible',
name: {
en: 'Scribe application',
},
diff --git a/renderer/src/core/burrito/createAudioSB.js b/renderer/src/core/burrito/createAudioSB.js
index cf4b33d11..4f75fc5bc 100644
--- a/renderer/src/core/burrito/createAudioSB.js
+++ b/renderer/src/core/burrito/createAudioSB.js
@@ -49,6 +49,8 @@ update,
json.identification.name.en = projectFields.projectName;
json.identification.abbreviation.en = projectFields.abbreviation;
json.languages[0].name.en = language;
+ // Adding the below line in 0.5.8 version, since the id in the previous versions is autographa.org
+ json.idAuthorities.scribe.id = 'http://www.scribe.bible';
if (call === 'edit' && project?.copyright?.shortStatements && (copyright.licence).length <= 500) {
json.copyright.shortStatements[0].statement = copyright.licence;
} else {
diff --git a/renderer/src/core/burrito/createObsSB.js b/renderer/src/core/burrito/createObsSB.js
index ec6a27e72..5335ff5a3 100644
--- a/renderer/src/core/burrito/createObsSB.js
+++ b/renderer/src/core/burrito/createObsSB.js
@@ -47,6 +47,8 @@ update,
json.identification.name.en = projectFields.projectName;
json.identification.abbreviation.en = projectFields.abbreviation;
json.languages[0].name.en = language;
+ // Adding the below line in 0.5.8 version, since the id in the previous versions is autographa.org
+ json.idAuthorities.scribe.id = 'http://www.scribe.bible';
if (call === 'edit' && project?.copyright?.shortStatements && (copyright.licence).length <= 500) {
json.copyright.shortStatements[0].statement = copyright.licence;
} else {
diff --git a/renderer/src/core/burrito/createTranslationSB.js b/renderer/src/core/burrito/createTranslationSB.js
index 3fe19c45c..fbaef9c6c 100644
--- a/renderer/src/core/burrito/createTranslationSB.js
+++ b/renderer/src/core/burrito/createTranslationSB.js
@@ -49,6 +49,8 @@ update,
json.identification.name.en = projectFields.projectName;
json.identification.abbreviation.en = projectFields.abbreviation;
json.languages[0].name.en = language;
+ // Adding the below line in 0.5.8 version, since the id in the previous versions is autographa.org
+ json.idAuthorities.scribe.id = 'http://www.scribe.bible';
if (call === 'edit' && project?.copyright?.shortStatements && (copyright.licence).length <= 500) {
json.copyright.shortStatements[0].statement = copyright.licence;
} else {
diff --git a/renderer/src/core/burrito/importBurrito.js b/renderer/src/core/burrito/importBurrito.js
index 50d0d565c..c85f14110 100644
--- a/renderer/src/core/burrito/importBurrito.js
+++ b/renderer/src/core/burrito/importBurrito.js
@@ -234,7 +234,7 @@ const importBurrito = async (filePath, currentUser, updateBurritoVersion, concat
});
metadata.idAuthorities = {
scribe: {
- id: 'http://www.autographa.org',
+ id: 'http://www.scribe.bible',
name: {
en: 'Scribe application',
},
diff --git a/renderer/src/layouts/projects/Export/ExportProjectPopUp.js b/renderer/src/layouts/projects/Export/ExportProjectPopUp.js
index e1e072a7c..71c2dc477 100644
--- a/renderer/src/layouts/projects/Export/ExportProjectPopUp.js
+++ b/renderer/src/layouts/projects/Export/ExportProjectPopUp.js
@@ -89,6 +89,8 @@ export default function ExportProjectPopUp(props) {
logger.debug('ExportProjectPopUp.js', 'Updated Scripture burrito');
let data = fs.readFileSync(path.join(folder, 'metadata.json'), 'utf-8');
const sb = JSON.parse(data);
+ // Adding the below line in 0.5.8 version, since the id in the previous versions is autographa.org
+ sb.idAuthorities.scribe.id = 'http://www.scribe.bible';
if (!sb.copyright?.shortStatements && sb.copyright?.licenses) {
delete sb.copyright.publicDomain;
data = JSON.stringify(sb);
diff --git a/renderer/src/lib/AudioBurritoTemplete.json b/renderer/src/lib/AudioBurritoTemplete.json
index 1107fedac..7bd58f9e2 100644
--- a/renderer/src/lib/AudioBurritoTemplete.json
+++ b/renderer/src/lib/AudioBurritoTemplete.json
@@ -14,7 +14,7 @@
},
"idAuthorities": {
"scribe": {
- "id": "http://www.autographa.org",
+ "id": "http://www.scribe.bible",
"name": {
"en": "Scribe application"
}
diff --git a/renderer/src/lib/BurritoTemplete.json b/renderer/src/lib/BurritoTemplete.json
index c3f45fa47..18d3961b9 100644
--- a/renderer/src/lib/BurritoTemplete.json
+++ b/renderer/src/lib/BurritoTemplete.json
@@ -14,7 +14,7 @@
},
"idAuthorities": {
"scribe": {
- "id": "http://www.autographa.org",
+ "id": "http://www.scribe.bible",
"name": {
"en": "Scribe application"
}
diff --git a/renderer/src/lib/OBSTemplete.json b/renderer/src/lib/OBSTemplete.json
index 94fdb1c5b..a8e5bea0c 100644
--- a/renderer/src/lib/OBSTemplete.json
+++ b/renderer/src/lib/OBSTemplete.json
@@ -13,7 +13,7 @@
},
"idAuthorities": {
"scribe": {
- "id": "http://www.autographa.org",
+ "id": "http://www.scribe.bible",
"name": {
"en": "Scribe application"
}
From 327a013bff1f6a82b988a33eac0ecb96a07e711e Mon Sep 17 00:00:00 2001
From: Samuel John <40059405+samueljd@users.noreply.github.com>
Date: Fri, 19 Jan 2024 16:02:53 +0530
Subject: [PATCH 12/15] versewise navigation with arrow keys. (#300)
* versewise navigation with arrow keys.
* highlight text, navigate on same verse multi click
* fixed scroll lock issue
* removed highlight text
---
.../EditorPage/TextEditor/Editor.jsx | 6 +-
.../EditorPage/TextEditor/RecursiveBlock.jsx | 59 +++++++++--------
.../TextEditor/utils/IntersectionObserver.js | 31 ++++++---
.../TextEditor/utils/getReferences.js | 64 ++++++++++++++-----
styles/globals.css | 4 ++
5 files changed, 109 insertions(+), 55 deletions(-)
diff --git a/renderer/src/components/EditorPage/TextEditor/Editor.jsx b/renderer/src/components/EditorPage/TextEditor/Editor.jsx
index 03c1ad86e..9423e062c 100644
--- a/renderer/src/components/EditorPage/TextEditor/Editor.jsx
+++ b/renderer/src/components/EditorPage/TextEditor/Editor.jsx
@@ -1,5 +1,5 @@
import React, {
- useContext, useEffect, useLayoutEffect, useRef,
+ useContext, useEffect, useLayoutEffect, useRef,
} from 'react';
import { HtmlPerfEditor } from '@xelah/type-perf-html';
@@ -123,7 +123,7 @@ export default function Editor(props) {
function onReferenceSelected({ chapter, verse }) {
chapter && setChapterNumber(chapter);
verse && setVerseNumber(verse);
- scrollReference(chapter);
+ !scrollLock && scrollReference(chapter, verse);
}
const observer = new IntersectionObserver((entries) => onIntersection({
@@ -147,7 +147,7 @@ export default function Editor(props) {
addSequenceId,
components: {
block: (__props) => RecursiveBlock({
- htmlPerf, onHtmlPerf: saveHtmlPerf, sequenceIds, addSequenceId, onReferenceSelected, setCaretPosition, setSelectedText, ...__props,
+ htmlPerf, onHtmlPerf: saveHtmlPerf, sequenceIds, addSequenceId, onReferenceSelected, setCaretPosition, setSelectedText, scrollLock, ...__props,
}),
},
options: {
diff --git a/renderer/src/components/EditorPage/TextEditor/RecursiveBlock.jsx b/renderer/src/components/EditorPage/TextEditor/RecursiveBlock.jsx
index 17e7f36f3..ce97f24a2 100644
--- a/renderer/src/components/EditorPage/TextEditor/RecursiveBlock.jsx
+++ b/renderer/src/components/EditorPage/TextEditor/RecursiveBlock.jsx
@@ -3,7 +3,9 @@
import React, { useEffect, useState } from 'react';
import { HtmlPerfEditor } from '@xelah/type-perf-html';
import { getCurrentCursorPosition, pasteTextAtCursorPosition } from '@/util/cursorUtils';
-import { getCurrentVerse, getCurrentChapter } from '@/components/EditorPage/TextEditor/utils/getReferences';
+import {
+ getCurrentVerse, getCurrentChapter,
+} from '@/components/EditorPage/TextEditor/utils/getReferences';
import { on } from 'ws';
const getTarget = ({ content }) => {
@@ -31,6 +33,7 @@ export default function RecursiveBlock({
onReferenceSelected,
setCaretPosition,
setSelectedText,
+ scrollLock,
...props
}) {
const [currentVerse, setCurrentVerse] = useState(null);
@@ -40,27 +43,6 @@ export default function RecursiveBlock({
setCaretPosition(cursorPosition);
};
- const checkReturnKeyPress = (event) => {
- const activeTextArea = document.activeElement;
- if (event.key === 'Enter') {
- if (activeTextArea.children.length > 1) {
- const lineBreak = activeTextArea.children[1]?.outerHTML;
- activeTextArea.children[1].outerHTML = lineBreak.replace(/
/gi, ' ');
- }
- }
- // BACKSPACE DISABLE
- if (event.keyCode === 8) {
- const range = document.getSelection().getRangeAt(0);
- const selectedNode = range.startContainer;
- const prevNode = selectedNode.previousSibling;
- if (prevNode && prevNode.dataset.attsNumber !== currentVerse) {
- event.preventDefault();
- }
- prevNode ? setCurrentVerse(prevNode.dataset.attsNumber) : {};
- }
- updateCursorPosition();
- };
-
function handleSelection() {
let selectedText = '';
if (window.getSelection) {
@@ -72,19 +54,44 @@ export default function RecursiveBlock({
setSelectedText(selectedText);
}
}
-
const checkCurrentVerse = () => {
if (document.getSelection().rangeCount >= 1 && onReferenceSelected) {
const range = document.getSelection().getRangeAt(0);
const selectedNode = range.startContainer;
- const verse = getCurrentVerse(selectedNode);
+ const { verse } = getCurrentVerse(selectedNode);
const chapter = getCurrentChapter(selectedNode);
onReferenceSelected({ bookId, chapter, verse });
+ // !scrollLock && hightlightRefVerse(chapter, verse);
}
updateCursorPosition();
handleSelection();
};
+ const keyStrokeHandler = (event) => {
+ const activeTextArea = document.activeElement;
+ // Replace line break with space
+ if (event.key === 'Enter') {
+ if (activeTextArea.children.length > 1) {
+ const lineBreak = activeTextArea.children[1]?.outerHTML;
+ activeTextArea.children[1].outerHTML = lineBreak.replace(/
/gi, ' ');
+ }
+ }
+ // Disable backspace if the previous node is not the same verse
+ if (event.keyCode === 8) {
+ const range = document.getSelection().getRangeAt(0);
+ const selectedNode = range.startContainer;
+ const prevNode = selectedNode.previousSibling;
+ if (prevNode && prevNode.dataset.attsNumber !== currentVerse) {
+ event.preventDefault();
+ }
+ prevNode ? setCurrentVerse(prevNode.dataset.attsNumber) : {};
+ }
+ if ([37, 38, 39, 40].includes(event.keyCode)) {
+ checkCurrentVerse();
+ updateCursorPosition();
+ }
+ };
+
function onPasteHandler(event) {
const cursorPosition = getCurrentCursorPosition('editor');
const paste = (event.clipboardData || window.clipboardData).getData('text');
@@ -101,11 +108,11 @@ export default function RecursiveBlock({
{ event.preventDefault(); onPasteHandler(event); }}
+ {...props}
/>
);
}
diff --git a/renderer/src/components/EditorPage/TextEditor/utils/IntersectionObserver.js b/renderer/src/components/EditorPage/TextEditor/utils/IntersectionObserver.js
index dafa7eaf2..7ba0957aa 100644
--- a/renderer/src/components/EditorPage/TextEditor/utils/IntersectionObserver.js
+++ b/renderer/src/components/EditorPage/TextEditor/utils/IntersectionObserver.js
@@ -1,13 +1,24 @@
-export const scrollReference = (chapterNumber) => {
- const refEditors = document.getElementsByClassName('ref-editor');
- refEditors.length > 0 && Array.prototype.filter.call(refEditors, (refEditor) => {
- const editorInView = refEditor.querySelector(`#ch-${chapterNumber}`);
- if (editorInView) {
- editorInView.scrollIntoView();
- editorInView.classList.add('scroll-mt-10');
- }
- });
-};
+export const scrollReference = (() => {
+ let prevCV;
+ return (c, v) => {
+ const refEditors = document.getElementsByClassName('ref-editor');
+ refEditors.length > 0 && Array.prototype.filter.call(refEditors, (refEditor) => {
+ if (!prevCV || prevCV.c !== c) {
+ const chapterInView = refEditor.querySelector(`#ch-${c}`);
+ if (chapterInView) {
+ chapterInView.scrollIntoView();
+ chapterInView.classList.add('scroll-mt-10');
+ }
+ } else {
+ const verseInView = refEditor.querySelector(`#ch${c}v${v}`);
+ if (verseInView) {
+ verseInView.scrollIntoView();
+ }
+ }
+ });
+ prevCV = { c, v };
+ };
+})();
export const onIntersection = ({
scroll, entries, setChapterNumber, scrollLock, setVerseNumber,
diff --git a/renderer/src/components/EditorPage/TextEditor/utils/getReferences.js b/renderer/src/components/EditorPage/TextEditor/utils/getReferences.js
index fe6cb92f2..b923fa370 100644
--- a/renderer/src/components/EditorPage/TextEditor/utils/getReferences.js
+++ b/renderer/src/components/EditorPage/TextEditor/utils/getReferences.js
@@ -1,17 +1,49 @@
export const getCurrentVerse = (currentNode) => {
- let currentVerse;
- let prev = currentNode.previousElementSibling;
- while (prev) {
- if (prev.dataset.type === 'mark' && prev.dataset.subtype === 'verses') {
- currentVerse = prev.dataset.attsNumber;
+ let verse;
+ let previousElement = currentNode?.previousElementSibling;
+ const verseText = currentNode?.nextSibling;
+ while (previousElement) {
+ if (previousElement.dataset.type === 'mark' && previousElement.dataset.subtype === 'verses') {
+ verse = previousElement.dataset.attsNumber;
break;
}
- // Get the previous sibling
- prev = prev.previousElementSibling;
+ previousElement = previousElement?.previousElementSibling;
}
- return currentVerse;
+ return { verse, verseText };
};
+export const removeHighlightFromRefVerse = ({ c, v }) => {
+ const refEditors = document.getElementsByClassName('ref-editor');
+ refEditors.length > 0 && Array.prototype.filter.call(refEditors, (refEditor) => {
+ const prevHighlight = refEditor.querySelector(`#ch${c}v${v}`)?.nextElementSibling;
+ const hightlightText = prevHighlight && prevHighlight.innerHTML;
+ prevHighlight && prevHighlight.replaceWith(hightlightText);
+ });
+};
+
+export const hightlightRefVerse = (() => {
+ let prevCV;
+ return (c, v) => {
+ const refEditors = document.getElementsByClassName('ref-editor');
+ refEditors.length > 0 && Array.prototype.filter.call(refEditors, (refEditor) => {
+ if (!(prevCV && prevCV.c !== c)) {
+ const verseInView = refEditor.querySelector(`#ch${c}v${v}`);
+ const { verseText } = getCurrentVerse(verseInView);
+ // highlight verse
+ const range = document.createRange();
+ range.setStart(verseText, 0);
+ range.setEnd(verseText, verseText.textContent.length);
+ const newSpan = document.createElement('span');
+ newSpan.classList.add('bg-primary-50');
+ range.surroundContents(newSpan);
+ // remove highlight from previous verse
+ prevCV && removeHighlightFromRefVerse({ ...prevCV });
+ }
+ });
+ prevCV = { c, v };
+ };
+})();
+
export const getCurrentChapter = (currentNode) => {
let currentChapter;
const closestParaDiv = currentNode.parentNode.parentNode;
@@ -20,13 +52,13 @@ export const getCurrentChapter = (currentNode) => {
return currentChapter;
}
- let prevParaDiv = closestParaDiv.previousElementSibling;
- while (prevParaDiv) {
- if (prevParaDiv.firstElementChild?.firstElementChild?.classList.contains('chapter')) {
- currentChapter = prevParaDiv.firstElementChild.firstElementChild.dataset.attsNumber;
- break;
- }
- prevParaDiv = prevParaDiv.previousElementSibling;
+ let prevParaDiv = closestParaDiv.previousElementSibling;
+ while (prevParaDiv) {
+ if (prevParaDiv.firstElementChild?.firstElementChild?.classList.contains('chapter')) {
+ currentChapter = prevParaDiv.firstElementChild.firstElementChild.dataset.attsNumber;
+ break;
}
- return currentChapter;
+ prevParaDiv = prevParaDiv.previousElementSibling;
+ }
+ return currentChapter;
};
diff --git a/styles/globals.css b/styles/globals.css
index c544797b6..f716ddc74 100644
--- a/styles/globals.css
+++ b/styles/globals.css
@@ -103,6 +103,10 @@ p.paragraph:has(.chapter) {
@apply text-primary text-sm;
}
+.ref-editor ::selection {
+ @apply bg-primary-50;
+}
+
/* .perf .verse:after {
visibility: visible;
position: absolute;
From 8d1e760e984bff1156f790bac26d996183f6ef5c Mon Sep 17 00:00:00 2001
From: VIPIN PAUL <37212471+vipinpaul@users.noreply.github.com>
Date: Fri, 19 Jan 2024 16:14:53 +0530
Subject: [PATCH 13/15] Updating the version to 0.5.8 (#307)
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 1af3c153f..fd859be4e 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"productName": "scribe-scripture-editor",
"description": "A friendly assistant for Bible Translators.",
"author": "Bible Technology ",
- "version": "0.5.7",
+ "version": "0.5.8",
"license": "MIT",
"private": true,
"main": "main/index.js",
From f77dfd3ac79b65c9d2d49c793f268b8b57dd74a7 Mon Sep 17 00:00:00 2001
From: danielc-n
Date: Fri, 2 Feb 2024 10:26:24 +0100
Subject: [PATCH 14/15] Scripture Burrito as a resource : added the
poissibility for the user to search and download a SB as a resource in a
module
---
.../ResourceUtils/DownloadResourcePopUp.js | 16 ++-
.../createDownloadedResourceSB.js | 102 ++++++++++--------
.../Resources/useFetchTranslationResource.js | 6 +-
renderer/src/translations/en.js | 2 +-
renderer/src/translations/fa.js | 2 +-
5 files changed, 81 insertions(+), 47 deletions(-)
diff --git a/renderer/src/components/Resources/ResourceUtils/DownloadResourcePopUp.js b/renderer/src/components/Resources/ResourceUtils/DownloadResourcePopUp.js
index 8a9f889e9..b9edc54a4 100644
--- a/renderer/src/components/Resources/ResourceUtils/DownloadResourcePopUp.js
+++ b/renderer/src/components/Resources/ResourceUtils/DownloadResourcePopUp.js
@@ -46,6 +46,7 @@ function DownloadResourcePopUp({ selectResource, isOpenDonwloadPopUp, setIsOpenD
const [selectedLangFilter, setSelectedLangFilter] = useState([]);
const [selectedTypeFilter, setSelectedTypeFilter] = useState([]);
const [selectedPreProd, setSelectedPreProd] = useState(false);
+ const [selectedScriptureBurrito, setselectedScriptureBurrito] = useState(false);
// resource Download
const [downloadStarted, setDownloadStarted] = useState(false);
const [totalDownload, setTotalDownload] = useState(0);
@@ -79,7 +80,8 @@ function DownloadResourcePopUp({ selectResource, isOpenDonwloadPopUp, setIsOpenD
setLoading(true);
// subject = bible and lang = en - if not custom filter or initial loading
// const baseUrl = 'https://git.door43.org/api/catalog/v5/search';
- const baseUrl = `${environment.GITEA_API_ENDPOINT}/catalog/search?metadataType=rc`;
+ const metadataType = selectedScriptureBurrito ? 'sb' : 'rc';
+ const baseUrl = `${environment.GITEA_API_ENDPOINT}/catalog/search?metadataType=${metadataType}`;
let url = '';
if (filter) {
url = `${baseUrl}`;
@@ -372,6 +374,18 @@ function DownloadResourcePopUp({ selectResource, isOpenDonwloadPopUp, setIsOpenD
/>
+ {/* NicolasEdits : add scripture burrito check */}
+
+
+ setselectedScriptureBurrito(e.target.checked)}
+ />
+
+
- {/* NicolasEdits : add scripture burrito check */}
-
-
- setselectedScriptureBurrito(e.target.checked)}
- />
-
-