From e10019e4b936e680a1acb048e4b1fab8c730d5e7 Mon Sep 17 00:00:00 2001 From: vipinpaul Date: Fri, 11 Aug 2023 12:38:53 +0530 Subject: [PATCH] Fixed lint and build issue --- package.json | 8 +-- renderer/pages/home.js | 6 +- .../components/EditorPage/Scribex/Buttons.jsx | 1 - .../components/EditorPage/Scribex/Editor.jsx | 15 ++--- .../EditorPage/Scribex/InsertMenu.jsx | 8 +-- .../components/EditorPage/Scribex/Popup.jsx | 17 +++-- .../EditorPage/Scribex/PopupButton.jsx | 15 +++-- .../EditorPage/Scribex/RecursiveBlock.jsx | 63 +++++++++---------- .../EditorPage/Scribex/ReferenceScribex.jsx | 22 +++---- .../components/EditorPage/Scribex/Scribex.jsx | 9 +-- .../Sync/hooks/useGetCurrentProjectMeta.js | 5 +- .../src/modules/editorsidebar/GraftEditor.jsx | 8 +-- 12 files changed, 88 insertions(+), 89 deletions(-) diff --git a/package.json b/package.json index 293380fd3..f70d4af80 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "clean": "rimraf dist renderer/.next renderer/out", "start": "electron .", "dev": "next dev", - "prod": "npm run build && next start", + "prod": "yarn build && next start", "test": "jest", "e2e": "npx playwright test", "report": "npx playwright test --reporter=html && npx playwright show-report", @@ -25,9 +25,9 @@ "maxmemory-allocation": "NODE_OPTIONS=--max_old_space_size=4096", "eslint:github-action": "node ./node_modules/eslint/bin/eslint . --ignore-path .gitignore --max-warnings 0", "build": "next build renderer && next export renderer", - "pack-app": "npm run build && electron-builder --dir", - "dist": "npm run build && electron-builder -p never", - "deploy": "npm run build && electron-builder -p always" + "pack-app": "yarn build && electron-builder --dir", + "dist": "yarn build && electron-builder -p never", + "deploy": "yarn build && electron-builder -p always" }, "eslintIgnore": [ "*.test.js" diff --git a/renderer/pages/home.js b/renderer/pages/home.js index 84810d27f..25a19f23c 100644 --- a/renderer/pages/home.js +++ b/renderer/pages/home.js @@ -14,9 +14,9 @@ export default function ReferenceSelector() { - - - + + + diff --git a/renderer/src/components/EditorPage/Scribex/Buttons.jsx b/renderer/src/components/EditorPage/Scribex/Buttons.jsx index 7967885cf..057559e40 100644 --- a/renderer/src/components/EditorPage/Scribex/Buttons.jsx +++ b/renderer/src/components/EditorPage/Scribex/Buttons.jsx @@ -10,7 +10,6 @@ import ArrowUturnRightIcon from '@/icons/Xelah/ArrowUturnRight.svg'; import PencilIcon from '@/icons/Common/Pencil.svg'; import Copy from '@/icons/Xelah/Copy.svg'; import Paste from '@/icons/Xelah/Paste.svg'; -import { copyText, pasteText } from '@/util/cursorUtils'; export const classNames = (...classes) => classes.filter(Boolean).join(' '); diff --git a/renderer/src/components/EditorPage/Scribex/Editor.jsx b/renderer/src/components/EditorPage/Scribex/Editor.jsx index 34741d0ca..dc4f6d011 100644 --- a/renderer/src/components/EditorPage/Scribex/Editor.jsx +++ b/renderer/src/components/EditorPage/Scribex/Editor.jsx @@ -8,10 +8,11 @@ import SaveIndicator from '@/components/Loading/SaveIndicator'; import { ReferenceContext } from '@/components/context/ReferenceContext'; import { ProjectContext } from '@/components/context/ProjectContext'; import EmptyScreen from '@/components/Loading/EmptySrceen'; -import { insertVerseNumber, insertChapterNumber, insertFootnote, insertXRef } from '@/util/cursorUtils'; +import { + insertVerseNumber, insertChapterNumber, insertFootnote, insertXRef, +} from '@/util/cursorUtils'; import RecursiveBlock from './RecursiveBlock'; - export default function Editor(props) { const { chapterNumber, @@ -109,19 +110,17 @@ export default function Editor(props) { function getSelectedText() { let selectedText = ''; if (window.getSelection) { - let selection = window.getSelection(); + const selection = window.getSelection(); selectedText = selection.toString(); setSelectedText(selectedText); - } else if (document.selection && document.selection.type != 'Control') { + } else if (document.selection && document.selection.type !== 'Control') { selectedText = document.selection.createRange().text; setSelectedText(selectedText); } - console.log(selectedText); } useEffect(() => { - if (insertVerseRChapter === 'Verse') { insertVerseNumber(caretPosition, newVerChapNumber); } @@ -135,6 +134,7 @@ export default function Editor(props) { if (insertVerseRChapter === 'Cross Reference') { insertXRef(caretPosition, newVerChapNumber, selectedText); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [triggerVerseInsert]); // useEffect(() => { @@ -185,6 +185,7 @@ export default function Editor(props) { }; const onIntersection = (entries) => { + // eslint-disable-next-line no-restricted-syntax for (const entry of entries) { if (entry.isIntersecting) { setChapterNumber(entry.target.dataset.attsNumber); @@ -230,7 +231,7 @@ export default function Editor(props) { }; return ( -
+
{!bookAvailable && } {bookAvailable && (!sequenceId || bookChange) && } {bookAvailable && sequenceId && !bookChange && ( diff --git a/renderer/src/components/EditorPage/Scribex/InsertMenu.jsx b/renderer/src/components/EditorPage/Scribex/InsertMenu.jsx index 3c6092fd6..aa7f518cd 100644 --- a/renderer/src/components/EditorPage/Scribex/InsertMenu.jsx +++ b/renderer/src/components/EditorPage/Scribex/InsertMenu.jsx @@ -1,5 +1,5 @@ -import { Fragment, useState } from 'react' -import { Menu, Transition } from '@headlessui/react' +import { Fragment, useState } from 'react'; +import { Menu, Transition } from '@headlessui/react'; import PopupButton from './PopupButton'; import PlusIcon from '@/icons/Xelah/Plus.svg'; @@ -8,7 +8,7 @@ export default function InsertMenu({ handleClick: handleButtonClick, selectedTex const handleClick = (number, title) => { handleButtonClick(number, title); setIsOpen(false); - } + }; return (
@@ -53,5 +53,5 @@ export default function InsertMenu({ handleClick: handleButtonClick, selectedTex
- ) + ); } diff --git a/renderer/src/components/EditorPage/Scribex/Popup.jsx b/renderer/src/components/EditorPage/Scribex/Popup.jsx index 536cd1742..498401eee 100644 --- a/renderer/src/components/EditorPage/Scribex/Popup.jsx +++ b/renderer/src/components/EditorPage/Scribex/Popup.jsx @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { Dialog, Transition } from '@headlessui/react'; const Popup = ({ - handleClose, handleButtonClick, title, isPopupOpen, selectedText + handleClose, handleButtonClick, title, isPopupOpen, selectedText, }) => { const [number, setNumber] = useState(''); // console.log({ title }, "title"); @@ -12,8 +12,8 @@ const Popup = ({ }; const handleNumberInputChange = (e) => { - setNumber(e.target.value.replace(/[^0-9]/g, "")) - } + setNumber(e.target.value.replace(/[^0-9]/g, '')); + }; const handleSubmit = () => { handleButtonClick(number, title); handleClose(); @@ -64,9 +64,14 @@ const Popup = ({
{selectedText && selectedText.length > 0 - ? ( -
Selected Text : {selectedText}
- ) : <>} + && ( +
+ Selected Text : + {' '} + {selectedText} + {' '} +
+ )}
diff --git a/renderer/src/components/EditorPage/Scribex/PopupButton.jsx b/renderer/src/components/EditorPage/Scribex/PopupButton.jsx index 778fccfd4..c0a6e24e5 100644 --- a/renderer/src/components/EditorPage/Scribex/PopupButton.jsx +++ b/renderer/src/components/EditorPage/Scribex/PopupButton.jsx @@ -1,7 +1,9 @@ import React, { useState } from 'react'; import Popup from './Popup'; -const PopupButton = ({ handleClick, title, roundedHover, selectedText }) => { +const PopupButton = ({ + handleClick, title, roundedHover, selectedText, +}) => { const [isPopupOpen, setIsPopupOpen] = useState(false); const handlePopupOpen = () => { @@ -18,10 +20,13 @@ const PopupButton = ({ handleClick, title, roundedHover, selectedText }) => { return (
e.stopPropagation()} - onClick={e => e.stopPropagation()} - onFocus={e => e.stopPropagation()} - onMouseOver={e => e.stopPropagation()}> + role="button" + tabIndex={-1} + onKeyDown={(e) => e.stopPropagation()} + onClick={(e) => e.stopPropagation()} + onFocus={(e) => e.stopPropagation()} + onMouseOver={(e) => e.stopPropagation()} + >
- +
diff --git a/renderer/src/components/Sync/hooks/useGetCurrentProjectMeta.js b/renderer/src/components/Sync/hooks/useGetCurrentProjectMeta.js index 9d500e170..93364d3b8 100644 --- a/renderer/src/components/Sync/hooks/useGetCurrentProjectMeta.js +++ b/renderer/src/components/Sync/hooks/useGetCurrentProjectMeta.js @@ -1,6 +1,7 @@ import fetchProjectsMeta from '@/core/projects/fetchProjectsMeta'; import localforage from 'localforage'; import { useState } from 'react'; +import packageInfo from '../../../../../package.json'; export default function useGetCurrentProjectMeta() { let meta; @@ -10,8 +11,10 @@ export default function useGetCurrentProjectMeta() { localforage.getItem('userProfile').then((user) => { fetchProjectsMeta({ currentUser: user?.username }) .then((value) => { + const projectId = currentProjectName?.split('_')[1]; const projectName = (currentProjectName.slice(0, currentProjectName.lastIndexOf('_'))).toLowerCase(); - meta = value.projects.filter((val) => val.identification.name.en.toLowerCase() === projectName.toLowerCase()); + meta = value.projects.filter((val) => val.identification.name.en.toLowerCase() === projectName.toLowerCase() + && Object.keys(val.identification.primary[packageInfo.name])[0] === projectId); }).finally(() => { if (meta && meta?.length > 0) { setCurrentProjectMeta(meta[0]); diff --git a/renderer/src/modules/editorsidebar/GraftEditor.jsx b/renderer/src/modules/editorsidebar/GraftEditor.jsx index 16df46229..3cb9d0b8b 100644 --- a/renderer/src/modules/editorsidebar/GraftEditor.jsx +++ b/renderer/src/modules/editorsidebar/GraftEditor.jsx @@ -21,13 +21,9 @@ export default function GraftEditor(props) { const style = isLoading || !sequenceId ? { cursor: 'progress' } : {}; const handlers = { - onBlockClick: ({ content: _content, element }) => { - console.log({ element }) + onBlockClick: ({ element }) => { const _sequenceId = element.dataset.target; - const { tagName } = element; - const isInline = tagName === 'SPAN'; - // // if (_sequenceId && !isInline) addSequenceId(_sequenceId); - // if (_sequenceId) { setGraftSequenceId(_sequenceId); } + if (_sequenceId) { setGraftSequenceId(_sequenceId); } }, };