RyotaUshio / obsidian-pdf-plus

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

Auto-focus cannot detect the last pasted .md file on Windows #54

Closed RyotaUshio closed 8 months ago

RyotaUshio commented 8 months ago

Hey, so I did some more testing and the behaviour was consistent in the sandbox vault as well in my productive vault:

Here are the debug logs, hope they help. Let me know if I can do further testing for you.

SYSTEM INFO: Obsidian version: v1.5.3 Installer version: v1.5.3 Operating system: Windows 10 Enterprise 10.0.19045 Login status: not logged in Insider build toggle: off Live preview: on Base theme: dark Community theme: Atom v0.0.0 Snippets enabled: 4 Restricted mode: off Plugins installed: 25 Plugins enabled: 25 1: Kanban v1.5.3 2: Tag Wrangler v0.6.1 3: ProZen v0.3 4: Iconize v2.10.0 5: Projects v1.17.1 6: Paste image rename v1.6.1 7: Dataview v0.5.64 8: Citations v0.4.5 9: QuickAdd v1.7.0 10: Git v2.23.2 11: Pandoc Reference List v2.0.25 12: Pandoc Plugin v0.4.1 13: Callout Manager v1.0.1 14: Editor Syntax Highlight v0.1.3 15: BRAT v0.8.4 16: PDF++ v0.35.21 17: Style Settings v1.0.7 18: Annotator v0.2.11 19: Hotkey Helper v0.3.18 20: Zotero Integration v3.1.7 21: Better Search Views v0.2.2 22: BibNotes Formatter v0.9.219 23: Omnisearch v1.21.1 24: Text Extractor v0.5.1 25: Hover Editor v0.11.17

{ "settings": { "displayTextFormats": [ { "name": "Title & page", "template": "{{file.basename}}, p.{{page}}" }, { "name": "Page only", "template": "p.{{pageLabel}}" } ], "defaultDisplayTextFormatIndex": 0, "syncDisplayTextFormat": true, "syncDefaultDisplayTextFormat": false, "copyCommands": [ { "name": "Copy as quote", "template": "> {{selection}}\n\n{{linkWithDisplay}}" }, { "name": "Copy link to selection", "template": "{{linkWithDisplay}}" }, { "name": "Copy embed of selection", "template": "!{{link}}" }, { "name": "citation allout", "template": "> [!{{calloutType}}|{{colorName}}] {{selection}} {{linkWithDisplay}}\n>" }, { "name": "highlight callout ", "template": "> [!{{calloutType}}|{{colorName}}] {{linkWithDisplay}}\n>" }, { "name": "nw", "template": "> [!{{calloutType}}|{{colorName}}] {{linkWithDisplay}}\n>" } ], "useAnotherCopyTemplateWhenNoSelection": false, "copyTemplateWhenNoSelection": "{{linkToPageWithDisplay}}", "trimSelectionEmbed": true, "embedMargin": 18, "noSidebarInEmbed": true, "noSpreadModeInEmbed": true, "embedUnscrollable": false, "singleTabForSinglePDF": true, "highlightExistingTab": true, "existingTabHighlightOpacity": 0.5, "existingTabHighlightDuration": 1, "paneTypeForFirstPDFLeaf": "left", "openLinkNextToExistingPDFTab": true, "openPDFWithDefaultApp": false, "openPDFWithDefaultAppAndObsidian": true, "focusObsidianAfterOpenPDFWithDefaultApp": true, "syncWithDefaultApp": false, "dontActivateAfterOpenPDF": true, "dontActivateAfterOpenMD": true, "highlightDuration": 0, "noTextHighlightsInEmbed": false, "noAnnotationHighlightsInEmbed": true, "persistentTextHighlightsInEmbed": true, "persistentAnnotationHighlightsInEmbed": false, "highlightBacklinks": true, "dblclickEmbedToOpenLink": true, "highlightBacklinksPane": true, "highlightOnHoverBacklinkPane": true, "backlinkHoverColor": "", "colors": { "info": "#ffd000", "method": "#346aea", "disagree": "#f04242", "agree": "#2ebf2b" }, "defaultColor": "info", "defaultColorPaletteItemIndex": 1, "syncColorPaletteItem": true, "syncDefaultColorPaletteItem": false, "colorPaletteInToolbar": true, "noColorButtonInColorPalette": false, "colorPaletteInEmbedToolbar": false, "showStatusInToolbar": true, "highlightColorSpecifiedOnly": false, "doubleClickHighlightToOpenBacklink": true, "hoverHighlightAction": "preview", "paneTypeForFirstMDLeaf": "right-sidebar", "singleMDLeafInSidebar": true, "alwaysUseSidebar": true, "defaultColorPaletteActionIndex": 4, "syncColorPaletteAction": true, "syncDefaultColorPaletteAction": false, "proxyMDProperty": "PDF", "hoverPDFLinkToOpen": false, "ignoreHeightParamInPopoverPreview": true, "filterBacklinksByPageDefault": true, "enableHoverPDFInternalLink": true, "recordPDFInternalLinkHistory": true, "alwaysRecordHistory": true, "renderMarkdownInStickyNote": true, "enalbeWriteHighlightToFile": false, "author": "", "writeHighlightToFileOpacity": 0.5, "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, "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": false, "annotationPopupDrag": true, "useCallout": true, "calloutType": "PDF", "calloutIcon": "highlighter", "highlightBacklinksInEmbed": false, "highlightBacklinksInHoverPopover": false, "highlightBacklinksInCanvas": true, "clickPDFInternalLinkWithModifierKey": true, "clickOutlineItemWithModifierKey": true, "clickThumbnailWithModifierKey": true, "focusEditorAfterAutoPaste": true, "autoFocus": true, "autoFocusTarget": "last-active-and-open-then-last-paste", "autoPasteTarget": "last-active-and-open-then-last-paste", "openAutoFocusTargetIfNotOpened": true, "howToOpenAutoFocusTargetIfNotOpened": "hover-editor", "closeHoverEditorWhenLostFocus": true, "closeSidebarWhenLostFocus": true, "openAutoFocusTargetInEditingView": true, "executeCommandWhenTargetNotIdentified": true, "commandToExecuteWhenTargetNotIdentified": "obsidian-hover-editor:open-new-popover", "selectToCopyToggleRibbonIcon": true, "autoFocusToggleRibbonIcon": true, "viewSyncFollowPageNumber": true, "viewSyncPageDebounceInterval": 0.3, "openAfterExtractPages": true, "howToOpenExtractedPDF": "tab", "warnEveryPageDelete": false, "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": "", "pageLabelUpdateWhenDividePDFs": "keep", "askPageLabelUpdateWhenDividePDFs": true, "alias": true, "writeFileLibrary": "pdfAnnotate", "auther": "", "clickEmbedToOpenLink": true }, "styleSheet": ".pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight)[data-highlight-color=\"info\"],\n.pdf-embed[data-highlight-color=\"info\"] .textLayer .mod-focused {\n background-color: #ffd000;\n}\n.pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight)[data-highlight-color=\"method\"],\n.pdf-embed[data-highlight-color=\"method\"] .textLayer .mod-focused {\n background-color: #346aea;\n}\n.pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight)[data-highlight-color=\"disagree\"],\n.pdf-embed[data-highlight-color=\"disagree\"] .textLayer .mod-focused {\n background-color: #f04242;\n}\n.pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight)[data-highlight-color=\"agree\"],\n.pdf-embed[data-highlight-color=\"agree\"] .textLayer .mod-focused {\n background-color: #2ebf2b;\n}\n.pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight) {\n background-color: #ffd000;\n}\n.pdf-plus-backlink-highlight-layer .pdf-plus-backlink.hovered-highlight {\n\tbackground-color: green;\n}\n.pdf-plus-color-palette-item[data-highlight-color=\"info\"] > .pdf-plus-color-palette-item-inner {\n background-color: #ffd000;\n}\n.pdf-plus-color-palette-item[data-highlight-color=\"method\"] > .pdf-plus-color-palette-item-inner {\n background-color: #346aea;\n}\n.pdf-plus-color-palette-item[data-highlight-color=\"disagree\"] > .pdf-plus-color-palette-item-inner {\n background-color: #f04242;\n}\n.pdf-plus-color-palette-item[data-highlight-color=\"agree\"] > .pdf-plus-color-palette-item-inner {\n background-color: #2ebf2b;\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-info-rgb: 255, 208, 0\n}\nbody {\n --pdf-plus-method-rgb: 52, 106, 234\n}\nbody {\n --pdf-plus-disagree-rgb: 240, 66, 66\n}\nbody {\n --pdf-plus-agree-rgb: 46, 191, 43\n}\nbody {\n --pdf-plus-default-color-rgb: var(--pdf-plus-info-rgb)\n}\n.pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight) {\n background-color: #ffd000;\n}\n.callout[data-callout=\"pdf\"][data-callout-metadata=\"info\"] {\n\t--callout-color: var(--pdf-plus-info-rgb);\n background-color: rgba(var(--callout-color), var(--pdf-plus-highlight-opacity, 0.2))\n}\n.callout[data-callout=\"pdf\"][data-callout-metadata=\"method\"] {\n\t--callout-color: var(--pdf-plus-method-rgb);\n background-color: rgba(var(--callout-color), var(--pdf-plus-highlight-opacity, 0.2))\n}\n.callout[data-callout=\"pdf\"][data-callout-metadata=\"disagree\"] {\n\t--callout-color: var(--pdf-plus-disagree-rgb);\n background-color: rgba(var(--callout-color), var(--pdf-plus-highlight-opacity, 0.2))\n}\n.callout[data-callout=\"pdf\"][data-callout-metadata=\"agree\"] {\n\t--callout-color: var(--pdf-plus-agree-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}" }

Originally posted by @programlich in https://github.com/RyotaUshio/obsidian-pdf-plus/issues/44#issuecomment-1958882676

RyotaUshio commented 8 months ago

@programlich Just to confirm, when you say "hover editor opens a new window", do you mean this "No file is open" window pops up?

image

I still can't reproduce this in my environment (macOS & iOS). It might be a Windows-specific issue.

(One of my rough guesses is that the line break characters are doing something evil.)

Can you install the following main.js (put it under .obsidiain/plugins/pdf-plus and reload the app), and send a screen recording of the situation where the hover editor bug is happening, with the developer console open?

https://github.com/RyotaUshio/obsidian-pdf-plus/releases/tag/0.35.21-debug

You can open the dev console by ctrl+shift+I.

Thanks!

programlich commented 8 months ago

hey there,

thanks a lot for your effort and sorry for my late reply.

I would absolutely not be surprised if your feeling about the line break characters is right. Woudn´t be the first time, that Windows specific formats mess everything up^^. Sadly I am not free to choose my OS at work. Sorry for you having to fiddle around with Windows now.

Anyway, I did what you asked for and moved the debug main.js to the specified location and proceeded as specified by you. Sadly I cannot share a screencast with you, because its a buisness laptop (IT rules, etc.) but I took screenshots which I hope will also help.

I opened one single pdf and reloaded the obsidian app. Then I selected some text with auto focus and select text to copy mode turned on and the popup showed up, that you showed in your last post (No file is open). In this window I selected the desired md file and pasted the annotation. Here is how the console looked right after executing the pasting:

console_after_pasting

Then I selected some other text and again the same window (No file is open) popped up. Again I selected the desired md file and pasted the annotation. Heres the console after the second paste command. I think it´s exactly the same as after the first time as far as I can see:

console_after_pasting_no2

Let me know what kind of further information I can get to you.

RyotaUshio commented 8 months ago

@programlich Thank you, this helps me a lot!

Sorry for you having to fiddle around with Windows now.

No worries. Not having a Windows machine, I can't check this plugin's Windows compatibility without the help of Windows users. So I really appreciate your cooperation.

So from your screenshots, the line-ending characters indeed seem to be causing the problem. I guess I was able to fix it; can you try updating PDF++ to 0.35.24?

programlich commented 8 months ago

Nice work, @RyotaUshio! Selecting text with "auto focus" and "select text to copy" now works as expected. The first time the "No file is open" window pops up but the second time PDF++ correctly remembers the last pasted file and opens the hover editor correspondingly. Well done!

Here are a few things that I still noted when testing:

pdf-plus-console
RyotaUshio commented 8 months ago

@programlich Glad it worked!

The hotkey for "Copy link to selection or annotation" and "Copy & auto-paste link to selection or annotation" do not seem to have an effect. In the top menu bar the corresponding note appears (e.g., link copied) but the hover editor does not open. When there is no last pasted file to find, the hover editor correctly opens the "No file is open" window. The next time the command gets executed without opening hover editor, even though "Copy & auto-paste link to selection or annotation" correctly pastes into the right file.

So you mean

right?

I have a few things to confirm:

  1. Is the behavior observed also in the sandbox vault where only PDF++ and Hover Editor are enabled?
  2. Does this problem also happen when you set the "how to open target markdown file when not opened" option to values other than Hover Editor, e.g. split right or right sidebar?
  3. When the same option is set to Hover Editor, the command "PDF++: Create new note for auto-focus or auto-paste" is expected to open a newly created note in a hover editor window. Does it work as expected?
image

Another minor issue that I noted is when I open a new file from the hover editor the cursor is set to the start of the opened md file. If it could be placed at the end it would be even more comfortable.

This would be a nice addition. I will consider adding this in a future release.

RyotaUshio commented 8 months ago

Sorry, I just recalled that I have a very old Windows 10 machine, and I turned it on for the first time in these 2 years or so. I installed Obsidian v1.5.8, PDF++, and Hover Editor. And then it turned out PDF++ & Hover Editor works without any problems. So I guess this is not Windows-specific.

programlich commented 8 months ago

when copying a PDF selection link for the first time and hence there is no specific markdown file to paste into, everything works as expected. from the next time on, using hotkeys won't open a hover editor whereas "select to copy" properly opens the last pasted file in a hover editor window

Yes, thats exactly the behavior, I observe.

Does this problem also happen when you set the "how to open target markdown file when not opened" option to values other than Hover Editor, e.g. split right or right sidebar?

No, in this case everything works as expected, including the hotkey shortcuts for auto copy and focus/paste.

When the same option is set to Hover Editor, the command "PDF++: Create new note for auto-focus or auto-paste" is expected to open a newly created note in a hover editor window. Does it work as expected?

Yes, this works as expected

And then it turned out PDF++ & Hover Editor works without any problems. So I guess this is not Windows-specific.

Hmm, thats strange. However as I am totally fine with the current status of the plugin, I guess it´s not too important to dig further into this. I will try out the plugin on another machine and report back. Does that sound good to you?

RyotaUshio commented 8 months ago

I will try out the plugin on another machine and report back. Does that sound good to you?

Thanks, let's go with it if you're okay with it.

RyotaUshio commented 8 months ago

@programlich Hi, I will close this issue since the original problem has already been resolved and it's been a while since the last comment. But feel free to open a new issue if necessary. Thanks again for the reports!

programlich commented 8 months ago

hey, thats totally fine for me. If anything pops up on my side regarding this issue again, I will let you know