From 22c6e2c56c656cdbbc9788e5e9dc9112b22a9127 Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Thu, 5 Jan 2023 15:32:18 +0530 Subject: [PATCH] feat: Added linked items container & autocomplete input to file preview modal --- .../Components/FilePreview/FilePreviewModal.tsx | 16 ++++++++++++++++ .../FileView/FileViewWithoutProtection.tsx | 2 +- .../LinkedItems/LinkedItemBubblesContainer.tsx | 15 ++++++--------- .../javascripts/Components/NoteView/NoteView.tsx | 5 ++++- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/packages/web/src/javascripts/Components/FilePreview/FilePreviewModal.tsx b/packages/web/src/javascripts/Components/FilePreview/FilePreviewModal.tsx index 63d5d3469..b862098fb 100644 --- a/packages/web/src/javascripts/Components/FilePreview/FilePreviewModal.tsx +++ b/packages/web/src/javascripts/Components/FilePreview/FilePreviewModal.tsx @@ -13,6 +13,7 @@ import { getIconForFileType } from '@/Utils/Items/Icons/getIconForFileType' import FileMenuOptions from '../FileContextMenu/FileMenuOptions' import Menu from '../Menu/Menu' import Popover from '../Popover/Popover' +import LinkedItemBubblesContainer from '../LinkedItems/LinkedItemBubblesContainer' type Props = { application: WebApplication @@ -26,6 +27,7 @@ const FilePreviewModal: FunctionComponent = observer(({ application, view return null } + const [showLinkedBubblesContainer, setShowLinkedBubblesContainer] = useState(false) const [showOptionsMenu, setShowOptionsMenu] = useState(false) const [showFileInfoPanel, setShowFileInfoPanel] = useState(false) const menuButtonRef = useRef(null) @@ -96,6 +98,12 @@ const FilePreviewModal: FunctionComponent = observer(({ application, view {currentFile.name}
+
+ {showLinkedBubblesContainer && ( +
+ +
+ )}
diff --git a/packages/web/src/javascripts/Components/FileView/FileViewWithoutProtection.tsx b/packages/web/src/javascripts/Components/FileView/FileViewWithoutProtection.tsx index 8a468a1ed..615f61424 100644 --- a/packages/web/src/javascripts/Components/FileView/FileViewWithoutProtection.tsx +++ b/packages/web/src/javascripts/Components/FileView/FileViewWithoutProtection.tsx @@ -117,7 +117,7 @@ const FileViewWithoutProtection = ({ application, viewControllerManager, file }: />
- +
diff --git a/packages/web/src/javascripts/Components/LinkedItems/LinkedItemBubblesContainer.tsx b/packages/web/src/javascripts/Components/LinkedItems/LinkedItemBubblesContainer.tsx index cc54fb2a4..55e975578 100644 --- a/packages/web/src/javascripts/Components/LinkedItems/LinkedItemBubblesContainer.tsx +++ b/packages/web/src/javascripts/Components/LinkedItems/LinkedItemBubblesContainer.tsx @@ -6,7 +6,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react' import { useResponsiveAppPane } from '../Panes/ResponsivePaneProvider' import { ElementIds } from '@/Constants/ElementIDs' import { classNames } from '@standardnotes/utils' -import { ContentType } from '@standardnotes/snjs' +import { ContentType, DecryptedItemInterface } from '@standardnotes/snjs' import { LinkableItem } from '@/Utils/Items/Search/LinkableItem' import { ItemLink } from '@/Utils/Items/Search/ItemLink' import { FOCUS_TAGS_INPUT_COMMAND, keyboardStringForShortcut } from '@standardnotes/ui-services' @@ -15,17 +15,18 @@ import { useItemLinks } from '@/Hooks/useItemLinks' type Props = { linkingController: LinkingController + item: DecryptedItemInterface } -const LinkedItemBubblesContainer = ({ linkingController }: Props) => { +const LinkedItemBubblesContainer = ({ item, linkingController }: Props) => { const { toggleAppPane } = useResponsiveAppPane() const commandService = useCommandService() - const { activeItem, unlinkItemFromSelectedItem: unlinkItem, activateItem } = linkingController + const { unlinkItemFromSelectedItem: unlinkItem, activateItem } = linkingController const { notesLinkedToItem, filesLinkedToItem, tagsLinkedToItem, notesLinkingToItem, filesLinkingToItem } = - useItemLinks(activeItem) + useItemLinks(item) const allItemsLinkedToItem: ItemLink[] = useMemo( () => new Array().concat(notesLinkedToItem, filesLinkedToItem, tagsLinkedToItem), @@ -97,10 +98,6 @@ const LinkedItemBubblesContainer = ({ linkingController }: Props) => { ) } - if (!activeItem) { - return null - } - return (
{ focusPreviousItem={focusPreviousItem} setFocusedId={setFocusedId} hoverLabel={`Focus input to add a link (${shortcut})`} - item={activeItem} + item={item} />
) diff --git a/packages/web/src/javascripts/Components/NoteView/NoteView.tsx b/packages/web/src/javascripts/Components/NoteView/NoteView.tsx index 53c074243..36b277163 100644 --- a/packages/web/src/javascripts/Components/NoteView/NoteView.tsx +++ b/packages/web/src/javascripts/Components/NoteView/NoteView.tsx @@ -905,7 +905,10 @@ class NoteView extends AbstractComponent {
)} - + )}