RyotaUshio / obsidian-pdf-plus

The most Obsidian-native PDF annotation, viewing & editing tool ever. Comes with optional Vim keybindings.
https://ryotaushio.github.io/obsidian-pdf-plus/
MIT License
752 stars 15 forks source link

[Bug] Use in secondary window, problem with application switching #93

Closed roosteer closed 7 months ago

roosteer commented 7 months ago

Steps to reproduce

  1. Open PDF++ in a new window
  2. Using the OS functionality (CTRL + TAB in windows) change the application window
  3. Go back to the obsidian window containing pdf++ and try the "Copy embed link" feature

Expected behavior

"Link copied"

Actual behavior

The focus moves to the main window and the link is not copied

Screen recordings or screenshots (sandbox vault)

https://github.com/RyotaUshio/obsidian-pdf-plus/assets/48920108/b66efa5c-fb69-404b-9e7d-20a16f54ae65

Obsidian debug info

SYSTEM INFO: Obsidian version: v1.5.8 Installer version: v1.5.3 Operating system: Windows 10 Pro 10.0.22631 Login status: logged in Catalyst license: none Insider build toggle: off Live preview: on Base theme: dark Community theme: Border v1.7.9 Snippets enabled: 11 Restricted mode: off Plugins installed: 97 Plugins enabled: 58 1: Actions URI v1.5.0 2: Admonition v10.2.0 3: Advanced URI v1.40.0 4: Auto Link Title v1.5.3 5: Better Command Palette v0.17.1 6: Dataview v0.5.64 7: Excalidraw v2.0.23 8: File Cooker v1.8.1 9: Footnote Shortcut v0.1.3 10: Hotkey Helper v0.3.18 11: Kanban v1.5.3 12: Hotkeys++ v0.2.7 13: Linter v1.23.2 14: Links v1.13.1 15: Mermaid Tools v1.1.1 16: Minimal Theme Settings v7.3.1 17: Mousewheel Image zoom v1.0.21 18: Natural Language Dates v0.6.2 19: Git v2.24.0 20: Omnisearch v1.21.1 21: Omnivore v1.9.4 22: Pane Relief v0.5.2 23: Pandoc Plugin v0.4.1 24: Periodic Notes v0.0.17 25: Plugin Groups v2.1.0 26: Plugin Update Tracker v1.5.2 27: Projects v1.17.1 28: Quick Latex v2.6.5 29: QuickAdd v1.8.1 30: Shell commands v0.21.0 31: Tag Wrangler v0.6.1 32: Style Settings v1.0.7 33: Templater v2.2.3 34: Text Extractor v0.5.1 35: Toggl Track v0.11.0 36: Importer v1.6.0 37: Bulk Rename v0.5.2 38: Persistent Links v0.2.0 39: Various Complements v9.4.0 40: Attachment Name Formatting v2.1.8 41: Commander v0.5.1 42: Homepage v3.8.0 43: Open In New Tab v1.0.9 44: Hover Editor v0.11.17 45: Modal forms v1.40.2 46: Advanced Tables v0.21.0 47: File Tree Alternative v2.4.8 48: cMenu v1.1.2 49: Automatic Table Of Contents v1.3.2 50: Meta Bind v0.12.5 51: BRAT v0.8.4 52: PDF++ v0.37.11 53: Todoist Sync v1.12.0 54: Custom Frames v2.4.7 55: CustomJS v1.0.18 56: View Sync v0.2.1 57: Settings profiles v0.5.5 58: Workspaces Plus v0.3.3

RECOMMENDATIONS: Custom theme and snippets: for cosmetic issues, please first try updating your theme and disabling your snippets. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets. Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

PDF++ debug info

{
    "settings": {
        "displayTextFormats": [
            {
                "name": "Obsidian default",
                "template": "{{file.basename}}, page {{page}}"
            },
            {
                "name": "Title & page",
                "template": "{{file.basename}}, p.{{pageLabel}}"
            },
            {
                "name": "Page only",
                "template": "p.{{pageLabel}}"
            },
            {
                "name": "Text",
                "template": "{{text}}"
            }
        ],
        "defaultDisplayTextFormatIndex": 0,
        "syncDisplayTextFormat": true,
        "syncDefaultDisplayTextFormat": false,
        "copyCommands": [
            {
                "name": "Quote",
                "template": "> ({{linkWithDisplay}})\n> {{selection}}\n"
            },
            {
                "name": "Link only",
                "template": "{{linkWithDisplay}}"
            },
            {
                "name": "Embed",
                "template": "!{{link}}"
            },
            {
                "name": "Callout",
                "template": "> [!{{calloutType}}|{{colorName}}] {{linkWithDisplay}}\n> {{text}}\n"
            },
            {
                "name": "Quote in callout",
                "template": "> [!{{calloutType}}|{{colorName}}] {{linkWithDisplay}}\n> > {{text}}\n> \n> "
            },
            {
                "name": "Create new note",
                "template": "{{app.vault.create(text + \".md\", linkWithDisplay).then((file) => app.workspace.getLeaf(true).openFile(file)), \"\"}}"
            }
        ],
        "useAnotherCopyTemplateWhenNoSelection": false,
        "copyTemplateWhenNoSelection": "{{linkToPageWithDisplay}}",
        "trimSelectionEmbed": true,
        "embedMargin": 50,
        "noSidebarInEmbed": true,
        "noSpreadModeInEmbed": true,
        "embedUnscrollable": false,
        "singleTabForSinglePDF": true,
        "highlightExistingTab": true,
        "existingTabHighlightOpacity": 0.5,
        "existingTabHighlightDuration": 0.75,
        "paneTypeForFirstPDFLeaf": "tab",
        "openLinkNextToExistingPDFTab": true,
        "openPDFWithDefaultApp": false,
        "openPDFWithDefaultAppAndObsidian": true,
        "focusObsidianAfterOpenPDFWithDefaultApp": false,
        "syncWithDefaultApp": false,
        "dontActivateAfterOpenPDF": true,
        "dontActivateAfterOpenMD": false,
        "highlightDuration": 0.75,
        "noTextHighlightsInEmbed": false,
        "noAnnotationHighlightsInEmbed": true,
        "persistentTextHighlightsInEmbed": true,
        "persistentAnnotationHighlightsInEmbed": false,
        "highlightBacklinks": true,
        "selectionBacklinkVisualizeStyle": "highlight",
        "dblclickEmbedToOpenLink": true,
        "highlightBacklinksPane": true,
        "highlightOnHoverBacklinkPane": true,
        "backlinkHoverColor": "",
        "colors": {
            "Yellow": "#ffd000",
            "Red": "#ea5252",
            "Note": "#086ddd",
            "Important": "#bb61e5"
        },
        "defaultColor": "",
        "defaultColorPaletteItemIndex": 1,
        "syncColorPaletteItem": true,
        "syncDefaultColorPaletteItem": false,
        "colorPaletteInToolbar": true,
        "noColorButtonInColorPalette": true,
        "colorPaletteInEmbedToolbar": false,
        "showStatusInToolbar": true,
        "highlightColorSpecifiedOnly": false,
        "doubleClickHighlightToOpenBacklink": true,
        "hoverHighlightAction": "preview",
        "paneTypeForFirstMDLeaf": "tab",
        "singleMDLeafInSidebar": true,
        "alwaysUseSidebar": true,
        "defaultColorPaletteActionIndex": 4,
        "syncColorPaletteAction": false,
        "syncDefaultColorPaletteAction": false,
        "proxyMDProperty": "PDF",
        "hoverPDFLinkToOpen": false,
        "ignoreHeightParamInPopoverPreview": true,
        "filterBacklinksByPageDefault": true,
        "showBacklinkToPage": true,
        "enableHoverPDFInternalLink": true,
        "recordPDFInternalLinkHistory": true,
        "alwaysRecordHistory": true,
        "renderMarkdownInStickyNote": true,
        "enablePDFEdit": false,
        "author": "",
        "writeHighlightToFileOpacity": 0.2,
        "defaultWriteFileToggle": false,
        "syncWriteFileToggle": true,
        "syncDefaultWriteFileToggle": false,
        "enableAnnotationDeletion": true,
        "warnEveryAnnotationDelete": false,
        "warnBacklinkedAnnotationDelete": true,
        "enableAnnotationContentEdit": true,
        "enableEditEncryptedPDF": false,
        "pdfLinkColor": "#04a802",
        "pdfLinkBorder": false,
        "replaceContextMenu": true,
        "executeBuiltinCommandForOutline": true,
        "executeBuiltinCommandForZoom": true,
        "executeFontSizeAdjusterCommand": true,
        "closeSidebarWithShowCommandIfExist": true,
        "autoHidePDFSidebar": false,
        "outlineDrag": true,
        "outlineContextMenu": true,
        "outlineLinkDisplayTextFormat": "{{file.basename}}, {{text}}",
        "outlineLinkCopyFormat": "{{linkWithDisplay}}",
        "recordHistoryOnOutlineClick": true,
        "popoverPreviewOnOutlineHover": true,
        "thumbnailDrag": true,
        "thumbnailContextMenu": true,
        "thumbnailLinkDisplayTextFormat": "{{file.basename}}, page {{pageLabel}}",
        "thumbnailLinkCopyFormat": "{{linkWithDisplay}}",
        "recordHistoryOnThumbnailClick": true,
        "popoverPreviewOnThumbnailHover": true,
        "annotationPopupDrag": true,
        "useCallout": true,
        "calloutType": "PDF",
        "calloutIcon": "highlighter",
        "highlightBacklinksInEmbed": true,
        "highlightBacklinksInHoverPopover": true,
        "highlightBacklinksInCanvas": true,
        "clickPDFInternalLinkWithModifierKey": true,
        "clickOutlineItemWithModifierKey": true,
        "clickThumbnailWithModifierKey": true,
        "focusEditorAfterAutoPaste": true,
        "respectCursorPositionWhenAutoPaste": true,
        "autoFocus": true,
        "autoFocusTarget": "last-paste",
        "autoPasteTarget": "last-paste",
        "openAutoFocusTargetIfNotOpened": true,
        "howToOpenAutoFocusTargetIfNotOpened": "hover-editor",
        "closeHoverEditorWhenLostFocus": true,
        "closeSidebarWhenLostFocus": true,
        "openAutoFocusTargetInEditingView": true,
        "executeCommandWhenTargetNotIdentified": false,
        "commandToExecuteWhenTargetNotIdentified": "switcher:open",
        "selectToCopyToggleRibbonIcon": true,
        "autoFocusToggleRibbonIcon": true,
        "viewSyncFollowPageNumber": true,
        "viewSyncPageDebounceInterval": 0.3,
        "openAfterExtractPages": true,
        "howToOpenExtractedPDF": "tab",
        "warnEveryPageDelete": true,
        "warnBacklinkedPageDelete": true,
        "extractPageInPlace": false,
        "askExtractPageInPlace": true,
        "pageLabelUpdateWhenInsertPage": "keep",
        "pageLabelUpdateWhenDeletePage": "keep",
        "pageLabelUpdateWhenExtractPage": "keep",
        "askPageLabelUpdateWhenInsertPage": true,
        "askPageLabelUpdateWhenDeletePage": true,
        "askPageLabelUpdateWhenExtractPage": true,
        "copyOutlineAsListFormat": "{{linkWithDisplay}}",
        "copyOutlineAsListDisplayTextFormat": "{{text}}",
        "copyOutlineAsHeadingsFormat": "{{text}}\n\n{{linkWithDisplay}}",
        "copyOutlineAsHeadingsDisplayTextFormat": "p.{{pageLabel}}",
        "copyOutlineAsHeadingsMinLevel": 2,
        "newFileNameFormat": "",
        "newFileTemplatePath": "",
        "newPDFLocation": "current",
        "newPDFFolderPath": "",
        "rectEmbedStaticImage": false,
        "rectImageFormat": "file",
        "rectImageExtension": "jpg",
        "zoomToFitRect": false,
        "includeColorWhenCopyingRectLink": true,
        "backlinkIconSize": 50,
        "showBacklinkIconForSelection": true,
        "showBacklinkIconForAnnotation": true,
        "showBacklinkIconForOffset": true,
        "showBacklinkIconForRect": true,
        "showBoundingRectForBacklinkedAnnot": true,
        "hideReplyAnnotation": false,
        "pageLabelUpdateWhenDividePDFs": "keep",
        "askPageLabelUpdateWhenDividePDFs": true
    },
    "styleSettings": {},
    "styleSheet": ".pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight)[data-highlight-color=\"yellow\"],\n.pdf-embed[data-highlight-color=\"yellow\"] .textLayer .mod-focused {\n    --pdf-plus-color: #ffd000;\n    --pdf-plus-backlink-icon-color: #ffd000;\n    --pdf-plus-rect-color: #ffd000;\n}\n.pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight)[data-highlight-color=\"red\"],\n.pdf-embed[data-highlight-color=\"red\"] .textLayer .mod-focused {\n    --pdf-plus-color: #ea5252;\n    --pdf-plus-backlink-icon-color: #ea5252;\n    --pdf-plus-rect-color: #ea5252;\n}\n.pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight)[data-highlight-color=\"note\"],\n.pdf-embed[data-highlight-color=\"note\"] .textLayer .mod-focused {\n    --pdf-plus-color: #086ddd;\n    --pdf-plus-backlink-icon-color: #086ddd;\n    --pdf-plus-rect-color: #086ddd;\n}\n.pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight)[data-highlight-color=\"important\"],\n.pdf-embed[data-highlight-color=\"important\"] .textLayer .mod-focused {\n    --pdf-plus-color: #bb61e5;\n    --pdf-plus-backlink-icon-color: #bb61e5;\n    --pdf-plus-rect-color: #bb61e5;\n}\n.pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight) {\n    --pdf-plus-color: rgb(var(--text-highlight-bg-rgb));\n    --pdf-plus-backlink-icon-color: rgb(var(--text-highlight-bg-rgb));\n    --pdf-plus-rect-color: rgb(var(--text-highlight-bg-rgb));\n}\n.pdf-plus-backlink-highlight-layer .pdf-plus-backlink.hovered-highlight {\n\t--pdf-plus-color: green;\n\t--pdf-plus-backlink-icon-color: green;\n   --pdf-plus-rect-color: green;\n}\n.pdf-plus-color-palette-item[data-highlight-color=\"yellow\"] > .pdf-plus-color-palette-item-inner {\n    background-color: #ffd000;\n}\n.pdf-plus-color-palette-item[data-highlight-color=\"red\"] > .pdf-plus-color-palette-item-inner {\n    background-color: #ea5252;\n}\n.pdf-plus-color-palette-item[data-highlight-color=\"note\"] > .pdf-plus-color-palette-item-inner {\n    background-color: #086ddd;\n}\n.pdf-plus-color-palette-item[data-highlight-color=\"important\"] > .pdf-plus-color-palette-item-inner {\n    background-color: #bb61e5;\n}\n.pdf-plus-color-palette-item:not([data-highlight-color]) > .pdf-plus-color-palette-item-inner {\n    background-color: transparent;\n}\n.workspace-leaf.pdf-plus-link-opened.is-highlighted::before {\n\topacity: 0.5;\n}\nbody {\n    --pdf-plus-yellow-rgb: 255, 208, 0\n}\nbody {\n    --pdf-plus-red-rgb: 234, 82, 82\n}\nbody {\n    --pdf-plus-note-rgb: 8, 109, 221\n}\nbody {\n    --pdf-plus-important-rgb: 187, 97, 229\n}\nbody {\n    --pdf-plus-default-color-rgb: var(--text-highlight-bg-rgb)\n}\n.callout[data-callout=\"pdf\"][data-callout-metadata=\"yellow\"] {\n\t--callout-color: var(--pdf-plus-yellow-rgb);\n   background-color: rgba(var(--callout-color), var(--pdf-plus-highlight-opacity, 0.2))\n}\n.callout[data-callout=\"pdf\"][data-callout-metadata=\"red\"] {\n\t--callout-color: var(--pdf-plus-red-rgb);\n   background-color: rgba(var(--callout-color), var(--pdf-plus-highlight-opacity, 0.2))\n}\n.callout[data-callout=\"pdf\"][data-callout-metadata=\"note\"] {\n\t--callout-color: var(--pdf-plus-note-rgb);\n   background-color: rgba(var(--callout-color), var(--pdf-plus-highlight-opacity, 0.2))\n}\n.callout[data-callout=\"pdf\"][data-callout-metadata=\"important\"] {\n\t--callout-color: var(--pdf-plus-important-rgb);\n   background-color: rgba(var(--callout-color), var(--pdf-plus-highlight-opacity, 0.2))\n}\n.callout[data-callout=\"pdf\"] {\n\t--callout-color: var(--pdf-plus-default-color-rgb);\n   background-color: rgba(var(--callout-color), var(--pdf-plus-highlight-opacity, 0.2))\n}\n.callout[data-callout=\"pdf\"] {\n   --callout-icon: lucide-highlighter;\n}"
}

Error messages

No response

RyotaUshio commented 7 months ago

Thanks! This seems to happen only when auto-focus image is enabled, right?

In addition to the issue you reported, your "Auto-focus target" setting seems to be ignored in your screen recording. I will look into it, too.

image
RyotaUshio commented 7 months ago

@roosteer From next time on, could you please follow the instructions in the bug report form and provide all the information in the sandbox vault? You have a lot of plugins enabled, potentially making the problem too complicated. Thanks!

roosteer commented 7 months ago

@roosteer From next time on, could you please follow the instructions in the bug report form and provide all the information in the sandbox vault? You have a lot of plugins enabled, potentially making the problem too complicated. Thanks!

I'm sorry I'll pay more attention to it

roosteer commented 7 months ago

Thanks! This seems to happen only when auto-focus image is enabled, right?

In addition to the issue you reported, your "Auto-focus target" setting seems to be ignored in your screen recording. I will look into it, too.

image

Yes, here is the same test I run in the sandbox (1:59)

https://github.com/RyotaUshio/obsidian-pdf-plus/assets/48920108/dd5ad4fc-beda-4c44-a387-8dc9bc11ff8d

RyotaUshio commented 7 months ago

Thanks, this will be fixed in the next version.

RyotaUshio commented 7 months ago

Released as 0.37.12! Let me know if it's still not working well.

roosteer commented 7 months ago

It seems to be ok, the only thing that doesn't seem to work yet is the autopaste for the rectangular area

https://github.com/RyotaUshio/obsidian-pdf-plus/assets/48920108/9c9cbb47-54ae-40cb-9d27-f8ba86339fec

RyotaUshio commented 7 months ago

Rectangular selection doesn't support auto-paste. Do you mean auto-focus?

roosteer commented 7 months ago

Ok, I didn't know that rectangular areas didn't support it, but it doesn't seem to work Not even for simple highlights. I don't know if some settings are missing, I'm re-reading the documentation

https://github.com/RyotaUshio/obsidian-pdf-plus/assets/48920108/2182b00a-f3f1-4a63-8237-2238ff878593

RyotaUshio commented 7 months ago

Auto-paste can't triggered from the context menu, and you need to execute "Copy & auto-paste link to selection or annotation" command using some hotkey.

I know it's confusing that auto-paste and auto-focus is not "symmetric" and it's something I'd like to improve.