Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to use scroll groups #30

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/paratext-bible-text-collection/assets/displayData.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"icon": "",
"moreInfoUrl": "",
"supportUrl": "",
"moreInfoUrl": "https://github.com/paranext/paratext-bible-extensions/tree/main/src/paratext-bible-text-collection",
"supportUrl": "https://github.com/paranext/paratext-bible-extensions/issues",
"localizedDisplayInfo": {
"en": {
"displayName": "Paratext Text Collection",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import papi from '@papi/frontend';
import { useSetting, useDialogCallback } from '@papi/frontend/react';
import { useDialogCallback } from '@papi/frontend/react';
import { Fragment, useCallback, useEffect, useMemo } from 'react';
import { IconButton, ScriptureReference, usePromise } from 'platform-bible-react';
import { deepEqual } from 'platform-bible-utils';
Expand Down Expand Up @@ -27,13 +27,12 @@ const getResourceVerseRef = (scrRef: ScriptureReference) => {
return resourceVerseRef;
};

const defaultScrRef: ScriptureReference = { bookNum: 1, chapterNum: 1, verseNum: 1 };

globalThis.webViewComponent = function TextCollectionWebView({
// Project ID of the project that is focused or undefined if no project selected
projectId: expandedProjectId = '',
updateWebViewDefinition,
useWebViewState,
useWebViewScrollGroupScrRef,
}: WebViewProps) {
// Project IDs to show in the text collection
const [projectIds, setProjectIds] = useWebViewState<string[]>('projectIds', []);
Expand All @@ -60,7 +59,7 @@ globalThis.webViewComponent = function TextCollectionWebView({
}, [projectIds, expandedProjectId, updateWebViewDefinition]);

// Current verse reference
const [scrRef] = useSetting('platform.verseRef', defaultScrRef);
const [scrRef] = useWebViewScrollGroupScrRef();
const verseRef = useMemo(() => getResourceVerseRef(scrRef), [scrRef]);

// Keep the title up-to-date
Expand Down Expand Up @@ -101,7 +100,7 @@ globalThis.webViewComponent = function TextCollectionWebView({

const moveProjectUpDownHandler = (directionUp: boolean, projectId: string) => {
const projectIdsCopy = [...projectIds];
const index = projectIdsCopy.findIndex((id) => id === projectId);
const index = projectIdsCopy.findIndex((pid) => pid === projectId);
const newIndex = directionUp ? index - 1 : index + 1;
if (newIndex < 0 || newIndex > projectIdsCopy.length - 1) return;
[projectIdsCopy[index], projectIdsCopy[newIndex]] = [
Expand Down
4 changes: 2 additions & 2 deletions src/paratext-bible-word-list/assets/displayData.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"icon": "",
"moreInfoUrl": "",
"supportUrl": "",
"moreInfoUrl": "https://github.com/paranext/paratext-bible-extensions/tree/main/src/paratext-bible-word-list",
"supportUrl": "https://github.com/paranext/paratext-bible-extensions/issues",
"localizedDisplayInfo": {
"en": {
"displayName": "Paratext Word List",
Expand Down
5 changes: 3 additions & 2 deletions src/paratext-bible-word-list/src/word-list.web-view.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useSetting, useData } from '@papi/frontend/react';
import { useData } from '@papi/frontend/react';
import { WebViewProps } from '@papi/core';
import { ChangeEvent, useEffect, useMemo, useState } from 'react';
import { ComboBox, ScriptureReference, Switch, TextField } from 'platform-bible-react';
Expand Down Expand Up @@ -58,8 +58,9 @@ function newDataNeeded(
globalThis.webViewComponent = function WordListWebView({
projectId,
useWebViewState,
useWebViewScrollGroupScrRef,
}: WebViewProps) {
const [scrRef] = useSetting('platform.verseRef', defaultScrRef);
const [scrRef] = useWebViewScrollGroupScrRef();
const [scope, setScope] = useWebViewState<Scope>('scope', Scope.Book);
const [wordFilter, setWordFilter] = useState<string>('');
const [selectedWord, setSelectedWord] = useState<WordListEntry>();
Expand Down