1.3) ? 1.5 : '',
+ direction: `${projectScriptureDir === 'RTL' ? 'rtl' : 'auto'}`,
+ }}
+ >
-
-
+ {/*
{
stateX && (
)
- }
+ } */}
);
diff --git a/renderer/src/components/EditorPage/TextEditor/index.jsx b/renderer/src/components/EditorPage/TextEditor/index.jsx
index 1c61e171..5ae4c730 100644
--- a/renderer/src/components/EditorPage/TextEditor/index.jsx
+++ b/renderer/src/components/EditorPage/TextEditor/index.jsx
@@ -1,69 +1,84 @@
import React, {
useEffect, useState, useContext, Fragment, useMemo,
} from 'react';
-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 { debounce } from 'lodash';
+import {
+ getViewOptions, DEFAULT_VIEW_MODE, immutableNoteCallerNodeName,
+} from '@biblionexus-foundation/scribe-editor';
+import { LoadingSpinner } from '@/components/LoadingSpinner';
import { useReadUsfmFile } from './hooks/useReadUsfmFile';
import EditorMenuBar from './EditorMenuBar';
import LexicalEditor from './Lexical';
import { updateCacheNSaveFile } from '../LexicalEditor/updateAndSave';
+const defaultScrRef = {
+ bookCode: 'PSA',
+ chapterNum: 1,
+ verseNum: 1,
+};
+
export default function TextEditor() {
- const { state, actions } = useContext(ScribexContext);
- const [bookChange, setBookChange] = useState(false);
const [chapterNumber, setChapterNumber] = useState(1);
const [verseNumber, setVerseNumber] = useState(1);
- const [triggerVerseInsert, setTriggerVerseInsert] = useState(false);
+ const [book, setBook] = useState();
const [usjInput, setUsjInput] = useState();
- // const [parser, setParser] = useState();
+ const [text, setText] = useState();
+ const [scrRef, setScrRef] = useState(defaultScrRef);
const [navRef, setNavRef] = useState();
+ const {
+ states: { openSideBar },
+ actions: { setOpenSideBar, setSideBarTab },
+ } = useContext(ProjectContext);
+ function closeSideBar(status) {
+ setOpenSideBar(status);
+ }
+ const [viewMode] = useState(DEFAULT_VIEW_MODE);
- // const initializeParser = async () => {
- // await USFMParser.init();
- // usfmParser = new USFMParser();
- // setParser(usfmParser);
- // };
- // useEffect(() => {
- // initializeParser();
- // }, []);
+ const nodeOptions = {
+ [immutableNoteCallerNodeName]: {
+ onClick: (e) => {
+ const callerId = e.currentTarget.getAttribute('data-caller-id');
+ setText(callerId);
+ setOpenSideBar(true);
+ setSideBarTab('footnotes');
+ },
+ },
+ };
+ const viewOptions = useMemo(() => getViewOptions(viewMode), [viewMode]);
const {
- bookAvailable, bookId, cachedData,
+ bookId, cachedData,
} = useReadUsfmFile();
+
useEffect(() => {
if (cachedData.error) {
console.error('Error parsing USFM', cachedData.error);
-
return;
}
const { usj } = cachedData;
- if (!usj && usj === {}) { return; }
- console.log({ usj });
+ if (!usj && usj?.entries(usj).length === 0) { return; }
+ console.log(usj);
setUsjInput(usj);
}, [bookId, cachedData]);
const {
- state: { selectedFont },
+ state: { selectedFont, fontSize, projectScriptureDir },
actions: { handleSelectedFont, onChangeChapter, onChangeVerse },
} = useContext(ReferenceContext);
- const {
- states: { openSideBar },
- actions: { setOpenSideBar },
- } = useContext(ProjectContext);
-
- function closeSideBar(status) {
- setOpenSideBar(status);
- }
-
useEffect(() => {
+ setScrRef({
+ bookCode: book,
+ chapterNum: chapterNumber,
+ verseNum: verseNumber,
+ });
onChangeChapter(chapterNumber, 1);
onChangeVerse(verseNumber, 1);
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [chapterNumber, verseNumber]);
+ }, [chapterNumber, verseNumber, book]);
useEffect(() => {
if (navRef) {
@@ -82,35 +97,47 @@ export default function TextEditor() {
);
const _props = {
- ...state,
- // ...perfState,
- ...actions,
- // ...perfActions,
selectedFont,
chapterNumber,
- verseNumber,
- // isLoading,
- // bookName,
- bookChange,
- bookAvailable,
- handleEditorFontSize,
- setBookChange,
setChapterNumber,
+ verseNumber,
setVerseNumber,
+ book,
+ setBook,
handleSelectedFont,
- triggerVerseInsert,
- setTriggerVerseInsert,
+ scrRef,
+ setScrRef,
+ };
+
+ const notesProps = {
+ usj: usjInput,
+ onChange: handleUsjChange,
+ viewOptions,
+ nodeOptions,
+ text,
+ };
+ const props = {
+ selectedFont,
+ fontSize,
+ projectScriptureDir,
+ usjInput,
+ onUsjChange: handleUsjChange,
+ setNavRef,
+ scrRef,
+ setScrRef,
+ book,
+ setBook,
};
return (
<>
- {usjInput && }
+ {!usjInput ? : }
>
);
diff --git a/renderer/src/modules/editorsidebar/EditorSideBar.js b/renderer/src/modules/editorsidebar/EditorSideBar.js
index 202d1fab..b0b54e12 100644
--- a/renderer/src/modules/editorsidebar/EditorSideBar.js
+++ b/renderer/src/modules/editorsidebar/EditorSideBar.js
@@ -24,9 +24,9 @@ import CrossReferenceIcon from '@/icons/crossreference.svg';
import FootNotesIcon from '@/icons/footnotes.svg';
import Search from './Search';
-import CrossReferences from './CrossReferences';
+// import CrossReferences from './CrossReferences';
// import FootNotes from './FootNotes';
-import GraftEditor from './GraftEditor';
+// import GraftEditor from './GraftEditor';
import Comments from './Comments';
import Bookmarks from '../../components/EditorPage/BookMarks/Bookmarks';
@@ -55,7 +55,7 @@ export default function EditorSideBar(props) {
const {
isOpen,
closeSideBar,
- graftProps,
+ notesProps,
} = props;
const {
@@ -193,12 +193,18 @@ export default function EditorSideBar(props) {
{state.tabIndex === 0
&& }
- {state.tabIndex === 1
- // && }
- && }
- {state.tabIndex === 2
- && }
- {/* && } */}
+ {/* {state.tabIndex === 1
+ && } */}
+ {state.tabIndex === 2 && (
+
+ )}
+ {/* && } */}
{state.tabIndex === 3
&& }
{state.tabIndex === 4
diff --git a/styles/globals.css b/styles/globals.css
index a4447008..b3f50c36 100644
--- a/styles/globals.css
+++ b/styles/globals.css
@@ -342,7 +342,7 @@ p.paragraph:has(.chapter) {
/* ChapterNode, ImmutableChapterNode */
.formatted-font .usfm_c {
- @apply m-2 block break-before-column font-medium uppercase tracking-wider before:content-['Chapter_:_'];
+ @apply text-primary block break-before-column font-medium uppercase tracking-wider before:content-['Chapter_:_'];
}
.text-spacing[dir='ltr'] .usfm_c {
@apply pl-4 text-left;
@@ -370,7 +370,7 @@ p.paragraph:has(.chapter) {
/* VerseNode, ImmutableVerseNode */
.formatted-font .usfm_v {
- @apply align-top text-xs uppercase tracking-wider text-cyan-500;
+ @apply align-top text-xs uppercase tracking-wider text-primary;
}
.text-spacing[dir='ltr'] .usfm_v {
@apply text-left;