diff --git a/packages/web/src/javascripts/Components/ClipperView/ClipperView.tsx b/packages/web/src/javascripts/Components/ClipperView/ClipperView.tsx index b6a5f7724..208c5a062 100644 --- a/packages/web/src/javascripts/Components/ClipperView/ClipperView.tsx +++ b/packages/web/src/javascripts/Components/ClipperView/ClipperView.tsx @@ -1,6 +1,5 @@ import { WebApplicationGroup } from '@/Application/WebApplicationGroup' import { ViewControllerManager } from '@/Controllers/ViewControllerManager' -import { SNLogoFull } from '@standardnotes/icons' import { useCallback, useEffect, useState } from 'react' import { AccountMenuPane } from '../AccountMenu/AccountMenuPane' import MenuPaneSelector from '../AccountMenu/MenuPaneSelector' @@ -38,12 +37,6 @@ import LinkedItemBubble from '../LinkedItems/LinkedItemBubble' import StyledTooltip from '../StyledTooltip/StyledTooltip' import MenuSwitchButtonItem from '../Menu/MenuSwitchButtonItem' -const Header = () => ( -
- -
-) - const ClipperView = ({ viewControllerManager, applicationGroup, @@ -257,107 +250,73 @@ const ClipperView = ({ if (user && !isEntitledToExtension) { return ( - <> -
-
-
- -
-
Enable Advanced Features
-
- To take advantage of Web Clipper and other advanced features, upgrade - your current plan. -
- - +
+
+
- +
Enable Advanced Features
+
+ To take advantage of Web Clipper and other advanced features, upgrade + your current plan. +
+ + +
) } if (clippedNote) { return ( - <> -
- - + ) } if (!user) { - return ( - <> -
- {menuPane ? ( -
- setMenuPane(undefined)} - /> -
- ) : ( - - - - Create free account - - - - Sign in - - - )} - + return menuPane ? ( +
+ setMenuPane(undefined)} + /> +
+ ) : ( + + + + Create free account + + + + Sign in + + ) } return ( - <> -
-
- - { - const payload = await sendMessageToActiveTab({ type: RuntimeMessageTypes.GetFullPage }) - if (!payload) { - return - } - setClipPayload(payload) - }} - > - {isScreenshotMode ? 'Capture visible' : 'Clip full page'} - +
+ + {hasSelection && ( { - const payload = await sendMessageToActiveTab({ type: RuntimeMessageTypes.GetArticle }) - if (!payload) { - return - } - setClipPayload(payload) - }} - > - Clip article - - { const payload = await sendMessageToActiveTab({ type: RuntimeMessageTypes.GetSelection }) if (!payload) { @@ -366,65 +325,96 @@ const ClipperView = ({ setClipPayload(payload) }} > + Clip text selection - { - void sendMessageToActiveTab({ type: RuntimeMessageTypes.StartNodeSelection }) - window.close() - }} - > - Select elements to {isScreenshotMode ? 'capture' : 'clip'} - - - Clip as screenshot - -
-
-
Default tag
- {defaultTag && ( - - - - )} + )} + { + const payload = await sendMessageToActiveTab({ type: RuntimeMessageTypes.GetFullPage }) + if (!payload) { + return + } + setClipPayload(payload) + }} + > + + {isScreenshotMode ? 'Capture visible' : 'Clip full page'} + + { + const payload = await sendMessageToActiveTab({ type: RuntimeMessageTypes.GetArticle }) + if (!payload) { + return + } + setClipPayload(payload) + }} + > + + Clip article + + { + void sendMessageToActiveTab({ type: RuntimeMessageTypes.StartNodeSelection }) + window.close() + }} + > + + Select elements to {isScreenshotMode ? 'capture' : 'clip'} + + + Clip as screenshot + +
+ {defaultTag && ( +
+ + + +
- {defaultTag && ( -
- -
- )} - -
-
-
You're signed in as:
-
{user.email}
- {application.getHost()} -
- - - Sign out - -
-
- + )} + +
+
+ +
{user.email}
+ +
+ +
) } diff --git a/packages/web/src/javascripts/Components/ItemSelectionDropdown/ItemSelectionDropdown.tsx b/packages/web/src/javascripts/Components/ItemSelectionDropdown/ItemSelectionDropdown.tsx index 56058b922..2a995e922 100644 --- a/packages/web/src/javascripts/Components/ItemSelectionDropdown/ItemSelectionDropdown.tsx +++ b/packages/web/src/javascripts/Components/ItemSelectionDropdown/ItemSelectionDropdown.tsx @@ -1,6 +1,13 @@ import { doesItemMatchSearchQuery } from '@/Utils/Items/Search/doesItemMatchSearchQuery' -import { Combobox, ComboboxItem, ComboboxPopover, useComboboxStore, VisuallyHidden } from '@ariakit/react' -import { ContentType, DecryptedItem, naturalSort } from '@standardnotes/snjs' +import { + Combobox, + ComboboxItem, + ComboboxPopover, + ComboboxStoreProps, + useComboboxStore, + VisuallyHidden, +} from '@ariakit/react' +import { classNames, ContentType, DecryptedItem, naturalSort } from '@standardnotes/snjs' import { observer } from 'mobx-react-lite' import { useDeferredValue, useEffect, useState } from 'react' import { useApplication } from '../ApplicationProvider' @@ -10,13 +17,23 @@ type Props = { contentTypes: ContentType[] placeholder: string onSelection: (item: DecryptedItem) => void + className?: { + input?: string + popover?: string + } + comboboxProps?: ComboboxStoreProps } -const ItemSelectionDropdown = ({ contentTypes, placeholder, onSelection }: Props) => { +const ItemSelectionDropdown = ({ contentTypes, placeholder, onSelection, comboboxProps, className = {} }: Props) => { const application = useApplication() - const combobox = useComboboxStore() + const combobox = useComboboxStore(comboboxProps) const value = combobox.useState('value') + const open = combobox.useState('open') + if (value.length < 1 && open) { + combobox.setOpen(false) + } + const searchQuery = useDeferredValue(value) const [items, setItems] = useState([]) @@ -30,17 +47,21 @@ const ItemSelectionDropdown = ({ contentTypes, placeholder, onSelection }: Props return (
- + Select an item + {items.length > 0 ? ( items.map((item) => ( diff --git a/packages/web/src/javascripts/Components/Menu/MenuSwitchButtonItem.tsx b/packages/web/src/javascripts/Components/Menu/MenuSwitchButtonItem.tsx index 4658e410f..f74a28b52 100644 --- a/packages/web/src/javascripts/Components/Menu/MenuSwitchButtonItem.tsx +++ b/packages/web/src/javascripts/Components/Menu/MenuSwitchButtonItem.tsx @@ -41,7 +41,13 @@ const MenuSwitchButtonItem = forwardRef( {children}
{shortcut && } - +
diff --git a/packages/web/src/javascripts/Hooks/useListKeyboardNavigation.ts b/packages/web/src/javascripts/Hooks/useListKeyboardNavigation.ts index 6e44c2dd2..eb714daff 100644 --- a/packages/web/src/javascripts/Hooks/useListKeyboardNavigation.ts +++ b/packages/web/src/javascripts/Hooks/useListKeyboardNavigation.ts @@ -96,16 +96,16 @@ export const useListKeyboardNavigation = ( const selectedItemIndex = Array.from(items).findIndex((item) => item.dataset.selected) let indexToFocus = selectedItemIndex > -1 ? selectedItemIndex : initialFocus - indexToFocus = getNextFocusableIndex(indexToFocus, items) + indexToFocus = getNextFocusableIndex(indexToFocus - 1, items) - setTimeout(() => { - focusItemWithIndex(indexToFocus, items) - }, FIRST_ITEM_FOCUS_TIMEOUT) + focusItemWithIndex(indexToFocus, items) }, [container, focusItemWithIndex, getNextFocusableIndex, initialFocus]) useEffect(() => { if (shouldAutoFocus) { - setInitialFocus() + setTimeout(() => { + setInitialFocus() + }, FIRST_ITEM_FOCUS_TIMEOUT) } }, [setInitialFocus, shouldAutoFocus])