diff --git a/packages/lexical-devtools/src/components/EditorsRefreshCTA.tsx b/packages/lexical-devtools/src/components/EditorsRefreshCTA.tsx index 01986bf2b88..5f1c77bdf32 100644 --- a/packages/lexical-devtools/src/components/EditorsRefreshCTA.tsx +++ b/packages/lexical-devtools/src/components/EditorsRefreshCTA.tsx @@ -42,9 +42,10 @@ function EditorsRefreshCTA({tabID, setErrorMessage}: Props) { ); } diff --git a/packages/lexical-devtools/src/entrypoints/devtools-panel/App.tsx b/packages/lexical-devtools/src/entrypoints/devtools-panel/App.tsx index b4dda315856..b71460287b7 100644 --- a/packages/lexical-devtools/src/entrypoints/devtools-panel/App.tsx +++ b/packages/lexical-devtools/src/entrypoints/devtools-panel/App.tsx @@ -15,6 +15,7 @@ import { ButtonGroup, Flex, Spacer, + Text, } from '@chakra-ui/react'; import * as React from 'react'; import {useState} from 'react'; @@ -45,8 +46,18 @@ function App({tabID}: Props) { ) : ( <> - - + + - + {states === undefined ? ( - Loading... + Loading... ) : ( - + Found {lexicalCount} editor {lexicalCount > 1 || lexicalCount === 0 ? 's' : ''} on the page. - + )} - + Lexical logo - {errorMessage !== '' ? ( -
{errorMessage}
- ) : null} + + {errorMessage !== '' ? ( +
{errorMessage}
+ ) : null} - - {lexicalCount > 0 ? ( - - ) : ( - - - No Lexical editors found on the page. - - )} + + {lexicalCount > 0 ? ( + + ) : ( + + + No Lexical editors found on the page. + + )} + ); diff --git a/packages/lexical-devtools/src/entrypoints/devtools-panel/components/EditorsList.tsx b/packages/lexical-devtools/src/entrypoints/devtools-panel/components/EditorsList.tsx index 865062d456d..fa275fd8973 100644 --- a/packages/lexical-devtools/src/entrypoints/devtools-panel/components/EditorsList.tsx +++ b/packages/lexical-devtools/src/entrypoints/devtools-panel/components/EditorsList.tsx @@ -21,7 +21,7 @@ import { import {TreeView} from '@lexical/devtools-core'; import {getRPCService} from '@webext-pegasus/rpc'; import * as React from 'react'; -import {useEffect, useMemo, useState} from 'react'; +import {useEffect, useMemo, useRef, useState} from 'react'; import {useExtensionStore} from '../../../store'; import {SerializedRawEditorState} from '../../../types'; @@ -32,6 +32,7 @@ interface Props { } export function EditorsList({tabID, setErrorMessage}: Props) { + const tabRefs = useRef(new Map()); const [expandedItems, setExpandedItems] = useState([0]); const {lexicalState, selectedEditorKey} = useExtensionStore(); const states = lexicalState[tabID] ?? {}; @@ -42,6 +43,14 @@ export function EditorsList({tabID, setErrorMessage}: Props) { useEffect(() => { if (selectedEditorIdx !== -1) { setExpandedItems([selectedEditorIdx]); + setTimeout( + () => + tabRefs.current + .get(selectedEditorIdx) + ?.scrollIntoView({behavior: 'smooth', block: 'start'}), + // Delay scrolling to let accordion finish it's animation first + 100, + ); } }, [selectedEditorIdx]); @@ -61,8 +70,8 @@ export function EditorsList({tabID, setErrorMessage}: Props) { onChange={setExpandedItems} allowMultiple={true} allowToggle={true}> - {Object.entries(states).map(([key, state]) => ( - + {Object.entries(states).map(([key, state], idx) => ( + tabRefs.current.set(idx, el)}>

diff --git a/packages/lexical-devtools/src/entrypoints/popup/App.tsx b/packages/lexical-devtools/src/entrypoints/popup/App.tsx index 05733be0c3d..0a0b7af1983 100644 --- a/packages/lexical-devtools/src/entrypoints/popup/App.tsx +++ b/packages/lexical-devtools/src/entrypoints/popup/App.tsx @@ -7,7 +7,7 @@ */ import './App.css'; -import {Box, Flex} from '@chakra-ui/react'; +import {Box, Flex, Text} from '@chakra-ui/react'; import * as React from 'react'; import {useState} from 'react'; @@ -29,31 +29,33 @@ function App({tabID}: Props) { {errorMessage !== '' ? ( - {errorMessage} + {errorMessage} ) : null} {states === null ? ( - + This is a restricted browser page. Lexical DevTools cannot access this page. - + ) : states === undefined ? ( - Loading... + Loading... ) : ( <> - Found {lexicalCount} editor - {lexicalCount > 1 || lexicalCount === 0 ? 's' : ''} on the page - {lexicalCount > 0 ? ( - <> - {' '} - ✅ -
- Open the developer tools, and "Lexical" tab will appear to the - right. - - ) : null} + + Found {lexicalCount} editor + {lexicalCount > 1 || lexicalCount === 0 ? 's' : ''} on the page + {lexicalCount > 0 ? ( + <> + {' '} + ✅ +
+ Open the developer tools, and "Lexical" tab will appear to + the right. + + ) : null} +
diff --git a/packages/lexical-devtools/wxt.config.ts b/packages/lexical-devtools/wxt.config.ts index 9b3887ee7ee..ff2f65e64b8 100644 --- a/packages/lexical-devtools/wxt.config.ts +++ b/packages/lexical-devtools/wxt.config.ts @@ -30,7 +30,7 @@ export default defineConfig({ 48: '/icon/48.png', }, name: 'Lexical Developer Tools', - permissions: ['scripting', 'storage'], + permissions: ['scripting', 'storage', 'tabs'], web_accessible_resources: [ { extension_ids: [],