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
697 stars 13 forks source link

Open annotaion note in sidebar #44

Closed programlich closed 7 months ago

programlich commented 7 months ago

Would it be possible to add a setting that allows to open the annotation note in the right sidebar when clicking on a highlight, which corresponding note is not opened yet? Having the annotation notes in the sidebar is very convenient when working on small laptop screens because this way they can be expanded an collapsed quickly.

RyotaUshio commented 7 months ago

clicking on a highlight

You mean double-clicking?

That's a nice idea. I feel you because I don't have an external display with enough space. However, opening the note in the sidebar might make it a little bit harder to work with other views in the right sidebar, e.g. backlinks etc.

How about adding a sub-option to the "How to open a markdown file by ctrl/cmd+hovering over or double-clicking highlighted text when there is no open markdown file" setting (what a long name!), where we can specify the width of new panes when the "How to open ..." option is set to "split right" or "split left"?

RyotaUshio commented 7 months ago

By the way, another way to handle the lack of space is using Hover Editor.

By hovering over a highlight with cmd/ctrl, you can open the corresponding markdown note and even directly edit it.

programlich commented 7 months ago

You mean double-clicking?

Yes, sorry.

However, opening the note in the sidebar might make it a little bit harder to work with other views in the right sidebar, e.g. backlinks etc.

I basically agree. Currently, when I pin my annotation note to the sidebar, its mainly when I read a paper for the first time. In this case I don't really care about my other annotations but only need a way to quickly write down my thoughts before focusing on the paper again. So in the case of the "first read" I think I would prefer the sidebar option, but in the case that I want to look at the paper and my thoughts I would prefer the option with the specified width of the new pane (which, regardless of this topic, I think would be a gread option anyway!).

The ultimate solution I can think of would be something like the hover editor poping up once some text is highlighted so that you can paste the annotation link and write down your thoughts. That way no extra space for a sidebar or second pane would be needed at all.

RyotaUshio commented 7 months ago

in the case of the "first read" I think I would prefer the sidebar option, but in the case that I want to look at the paper and my thoughts I would prefer the option with the specified width of the new pane

I haven't caught up with you on this point. What makes the difference between a sidebar and a new pane with a small width? To me, it seems that both of them can accomplish almost the same goal.

RyotaUshio commented 7 months ago

The ultimate solution I can think of would be something like the hover editor poping up once some text is highlighted so that you can paste the annotation link and write down your thoughts. That way no extra space for a sidebar or second pane would be needed at all.

Wow, that would be great... The problem is we have to decide which note to open in the popup before we paste the link.

programlich commented 7 months ago

I haven't caught up with you on this point. What makes the difference between a sidebar and a new pane with a small width?

Sorry, my message wasn't really specific. Let me clarify. The Laptop my institute provides has such a small screen that when I read a PDF I can't afford any space for annotations because when I do the fontsize of the PDF becomes too small to conveniently read it. So when I work without an external screen (in the train, that's where I use to read new papers) I have my annotations pinned to the sidebar so I can quickly blend them in and out.

However with any larger screen, I am fully on your side. Having a small second pane for the annotations will completely do the job.

programlich commented 7 months ago

Wow, that would be great... The problem is we have to decide which note to open in the popup before we paste the link.

Could we use the property PDF in the annotation note for this? So when there is a markdown file linking to the currently open PDF in its properties, the hover editor knows which file to open. I'm not sure if this way of backlinking is technically doable but its the only solution that I have in mind.

RyotaUshio commented 7 months ago

so I can quickly blend them in and out.

I see! Now I've got it. That will be only achievable by the sidebar. I will try to implement your idea.

Could we use the property PDF in the annotation note for this?

Yeah, it's totally doable, and most of the existing PDF-related plugins adopt such a method. However, I'm not a big fan of the idea of binding a single markdown file to each PDF. To me, it seems not to make the best of Obsidian's flexibility. That's why I designed PDF++ in such a way that:

Annotations for a single PDF are no longer confined to a single file and can be distributed across the whole vault. It establishes a novel, Obsidianic way of PDF annotation. (from README)

So I have an idea:

1.

When opening (and pasting a link to) a popup for the first time, copying a link to text selection (either via a hotkey or a color palette) triggers an Obsidian command that is pre-specified in the PDF++ setting.

For example, this command could be

and we could add new commands to PDF++ for this purpose, like:

(associated = the PDF property is a link pointing to the current PDF)

2.

From the second time on, copying a link simply opens the same note as the first time in the same way as the first time.

This approach includes the traditional approach of using a specified property as a part but also offers more flexible options.

RyotaUshio commented 7 months ago

Your idea has come true in v0.31.0. Thanks for the great suggestion!

https://github.com/RyotaUshio/obsidian-pdf-plus?tab=readme-ov-file#blazingly-fast-workflow-with-hover-editor

programlich commented 7 months ago

Dude, what an awsome job! It's incredible how fast you get the new features done. Love the way you implemented this one. I'll extensively test it on Monday (sorry, cant' to it earlier) and report back to you, but from what I see right now, it seems to be perfect. Thanks again for your great work.

programlich commented 7 months ago

Just tested out the new functionality with the hover editor. Awsome job, mate! This is an incredibly huge step forward and now PDF++ has definetely left Annotator way behind. If I have "select text to copy" and "toggle auto focus" both active I only have to press Ctrl + V and the annotation is pasted into the hover editor. This makes annotating extremly handy and at the same time solves any issues with small screens.

The only thing I noticed was, that I had to change the setting "Default Mode" from "Reading view" to "Editing view" in the hover editor plugin. Befor, when running the auto paste command I was not able to edit my annotations in the hover editor after pasting. Might be interesting to you.

Please keep going like this. Your work is highly appreciated!

RyotaUshio commented 7 months ago

@programlich Thanks for the feedback! Yeah, this addition was a big one...

I had to change the setting "Default Mode" from "Reading view" to "Editing view" in the hover editor plugin. Befor, when running the auto paste command I was not able to edit my annotations in the hover editor after pasting.

There is an option called "Always open in editing view", which is supposed to work regardless of the Hover Editor setting. If this option is turned on, it should be okay to set Hover Editor's "default mode" setting to reading view. Let me know f it's not working for you!

image

Also make sure that in the Obsidian settings, the default view for new tabs is set to editing view.

image

Also, how about the sidebar options that you requested originally? Does it work as expected?

image
programlich commented 7 months ago

Also, how about the sidebar options that you requested originally? Does it work as expected?

Yep, this one works like expected. Opening the md note in the sidebar seems to run stable to me. Thanks for adding this option!

What I have been fiddeling arount a bit is the behaviour of the hover editor which does not always work as expetect. In some cases it does exactly what it should, like described in my previous post. In other cases however, selecting text with auto focus and auto copy enabled does not seem to have any effect and so doesn´t copy & auto focus/ auto paste. I am a bit puzzled because until now I was not able to find any consistency in this behaviour. Do you have any ideas how to debug?

Also I saw that for some reason the automatic coloring of the callouts stopped working even though I have not changed any settings (knowingly). Could this be related to the previously described irregular behaviour?

I tried reload without saving.

EDIT: Maybe the behaviour could be related to the way I open the pdf. I see that when I I open the pdf by clicking on a link in a md file, the described irregular behaviour appears. Things seem to work, when I open the pdf directly from the quick switcher.

programlich commented 7 months ago

One more think I noted. The "default color selected in color palette" is mirrored with the selection of the color in the pdf color palette. Intuitively I would have expected these settings to be independend from each other. Is the behaviour intended?

RyotaUshio commented 7 months ago

@programlich Hi, sorry for the late reply.

selecting text with auto focus and auto copy enabled does not seem to have any effect and so doesn´t copy & auto focus/ auto paste.

Probably, I was able to identify the cause of this and I have included a potential fix in v0.35.6. I'm still not 100% sure if the problem has gone or not, though. Can you try it?

The "default color selected in color palette" is mirrored with the selection of the color in the pdf color palette. Intuitively I would have expected these settings to be independend from each other. Is the behaviour intended?

This is because the "Share a single color among all color palettes" option is turned on. And it was, in fact, an intended behavior. The idea was that if I turned on that option, I would also like a color palette that would be newly created in the future to be initialized with the same color. However, I've realized this behavior could be counter-intuitive and added a new option "Share the color with newly opened color palettes as well", which is disabled by default.

Also I saw that for some reason the automatic coloring of the callouts stopped working even though I have not changed any settings (knowingly).

Unfortunately, I don't have any idea about this.

  1. Does that problem also happen in the sandbox vault with only PDF++ enabled and no custom CSS snippets?
  2. If not, how about your (non-sandbox) vault with all CSS snippets disabled?
RyotaUshio commented 7 months ago

Providing the following information might help me identify the cause of the problem:

  1. From the command palette, run Obsidian's built-in command "Show debug info" and copy & paste the debug info here.
  2. Again from the command palette, run the PDF++ command "Copy debug info" (requires PDF++ v0.35.7 or higher) and paste the result here.
    • This includes all the PDF++ settings (except for the annotation author name).
programlich commented 6 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}" }

RyotaUshio commented 6 months ago

Thank you! I'm tracking this in a new issue #54.