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
712 stars 15 forks source link

[FR] Auto-clear text selection after auto-pasting #134

Closed N3C2L closed 6 months ago

N3C2L commented 6 months ago

Steps to reproduce

  1. Enable auto-paste.
  2. Disable "focus editor after pasting" in the pdf++ settings.
  3. Highlight some text in the PDF and auto-paste it to the annotation file.
  4. Problem now: in the pdf viewer the text is now double highlighted, and the doubled highlights go away with a left mouse click only.

Expected behavior

No doubled highlights after auto-paste in the pdf viewer.

Actual behavior

Doubled highlights which don't disappear by itself.

Screen recordings or screenshots (sandbox vault)

Doubled highlights:

2024-03-30 08_01_29-Lorem Ipsum - Obsidian Sandbox - Obsidian v1 5 11

Without doubled highlights:

2024-03-30 08_01_52-Lorem Ipsum - Obsidian Sandbox - Obsidian v1 5 11

Obsidian debug info

SYSTEM INFO: Obsidian version: v1.5.11 Installer version: v1.5.3 Operating system: Windows 10 Pro 10.0.19042 Login status: not logged in Insider build toggle: off Live preview: on Base theme: adapt to system Community theme: none Snippets enabled: 0 Restricted mode: off Plugins installed: 1 Plugins enabled: 1 1: PDF++ v0.39.6

RECOMMENDATIONS: 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": "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}}|{{color}}] {{linkWithDisplay}}\n> {{text}}\n"
            },
            {
                "name": "Quote in callout",
                "template": "> [!{{calloutType}}|{{color}}] {{linkWithDisplay}}\n> > {{text}}\n> \n> "
            }
        ],
        "useAnotherCopyTemplateWhenNoSelection": false,
        "copyTemplateWhenNoSelection": "{{linkToPageWithDisplay}}",
        "trimSelectionEmbed": false,
        "embedMargin": 50,
        "noSidebarInEmbed": true,
        "noSpreadModeInEmbed": true,
        "embedUnscrollable": false,
        "singleTabForSinglePDF": true,
        "highlightExistingTab": false,
        "existingTabHighlightOpacity": 0.5,
        "existingTabHighlightDuration": 0.75,
        "paneTypeForFirstPDFLeaf": "left",
        "openLinkNextToExistingPDFTab": true,
        "openPDFWithDefaultApp": false,
        "openPDFWithDefaultAppAndObsidian": true,
        "focusObsidianAfterOpenPDFWithDefaultApp": true,
        "syncWithDefaultApp": false,
        "dontActivateAfterOpenPDF": true,
        "dontActivateAfterOpenMD": true,
        "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",
            "gdfgdfg": "#d12323"
        },
        "defaultColor": "gdfgdfg",
        "defaultColorPaletteItemIndex": 0,
        "syncColorPaletteItem": true,
        "syncDefaultColorPaletteItem": false,
        "colorPaletteInToolbar": true,
        "noColorButtonInColorPalette": false,
        "colorPaletteInEmbedToolbar": false,
        "showStatusInToolbar": true,
        "highlightColorSpecifiedOnly": false,
        "doubleClickHighlightToOpenBacklink": true,
        "hoverHighlightAction": "preview",
        "paneTypeForFirstMDLeaf": "right",
        "singleMDLeafInSidebar": true,
        "alwaysUseSidebar": true,
        "ignoreExistingMarkdownTabIn": [],
        "defaultColorPaletteActionIndex": 4,
        "syncColorPaletteAction": true,
        "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,
        "showContextMenuOnMouseUpIf": "Mod",
        "contextMenuConfig": [
            {
                "id": "action",
                "visible": true
            },
            {
                "id": "selection",
                "visible": true
            },
            {
                "id": "write-file",
                "visible": true
            },
            {
                "id": "annotation",
                "visible": true
            },
            {
                "id": "modify-annotation",
                "visible": true
            },
            {
                "id": "link",
                "visible": true
            },
            {
                "id": "text",
                "visible": true
            },
            {
                "id": "search",
                "visible": true
            },
            {
                "id": "page",
                "visible": true
            },
            {
                "id": "settings",
                "visible": true
            }
        ],
        "selectionProductMenuConfig": [
            "color",
            "copy-format",
            "display"
        ],
        "writeFileProductMenuConfig": [
            "color",
            "copy-format",
            "display"
        ],
        "annotationProductMenuConfig": [
            "copy-format",
            "display"
        ],
        "updateColorPaletteStateFromContextMenu": 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": false,
        "highlightBacklinksInHoverPopover": false,
        "highlightBacklinksInCanvas": true,
        "clickPDFInternalLinkWithModifierKey": true,
        "clickOutlineItemWithModifierKey": true,
        "clickThumbnailWithModifierKey": true,
        "focusEditorAfterAutoPaste": false,
        "respectCursorPositionWhenAutoPaste": true,
        "autoCopy": false,
        "autoFocus": false,
        "autoPaste": true,
        "autoFocusTarget": "last-active-and-open-then-last-paste",
        "autoPasteTarget": "last-active-and-open-then-last-paste",
        "openAutoFocusTargetIfNotOpened": true,
        "howToOpenAutoFocusTargetIfNotOpened": "right",
        "closeHoverEditorWhenLostFocus": true,
        "closeSidebarWhenLostFocus": true,
        "openAutoFocusTargetInEditingView": true,
        "executeCommandWhenTargetNotIdentified": true,
        "commandToExecuteWhenTargetNotIdentified": "switcher:open",
        "autoPasteTargetDialogTimeoutSec": 20,
        "autoCopyToggleRibbonIcon": true,
        "autoCopyIconName": "highlighter",
        "autoFocusToggleRibbonIcon": true,
        "autoFocusIconName": "zap",
        "autoPasteToggleRibbonIcon": true,
        "autoPasteIconName": "clipboard-paste",
        "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": "",
        "rectEmbedStaticImage": false,
        "rectImageFormat": "file",
        "rectImageExtension": "webp",
        "zoomToFitRect": false,
        "rectEmbedResolution": 100,
        "includeColorWhenCopyingRectLink": true,
        "backlinkIconSize": 50,
        "showBacklinkIconForSelection": false,
        "showBacklinkIconForAnnotation": false,
        "showBacklinkIconForOffset": true,
        "showBacklinkIconForRect": false,
        "showBoundingRectForBacklinkedAnnot": false,
        "hideReplyAnnotation": false,
        "searchLinkHighlightAll": "true",
        "searchLinkCaseSensitive": "true",
        "searchLinkMatchDiacritics": "default",
        "searchLinkEntireWord": "false",
        "dontFitWidthWhenOpenPDFLink": true,
        "preserveCurrentLeftOffsetWhenOpenPDFLink": false,
        "defaultZoomValue": "page-width",
        "scrollModeOnLoad": 0,
        "spreadModeOnLoad": 0,
        "hoverableDropdownMenuInToolbar": true,
        "zoomLevelInputBoxInToolbar": true,
        "popoverPreviewOnExternalLinkHover": true,
        "actionOnCitationHover": "pdf-plus-bib-popover",
        "anystylePath": "",
        "enableBibInEmbed": false,
        "enableBibInHoverPopover": false,
        "enableBibInCanvas": true
    },
    "styleSettings": null,
    "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)[data-highlight-color=\"gdfgdfg\"],\n.pdf-embed[data-highlight-color=\"gdfgdfg\"] .textLayer .mod-focused {\n    --pdf-plus-color: #d12323;\n    --pdf-plus-backlink-icon-color: #d12323;\n    --pdf-plus-rect-color: #d12323;\n}\n.pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight) {\n    --pdf-plus-color: #d12323;\n    --pdf-plus-backlink-icon-color: #d12323;\n    --pdf-plus-rect-color: #d12323;\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[data-highlight-color=\"gdfgdfg\"] > .pdf-plus-color-palette-item-inner {\n    background-color: #d12323;\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-gdfgdfg-rgb: 209, 35, 35\n}\nbody {\n    --pdf-plus-default-color-rgb: var(--pdf-plus-gdfgdfg-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\"][data-callout-metadata=\"gdfgdfg\"] {\n\t--callout-color: var(--pdf-plus-gdfgdfg-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 6 months ago

Out of the two highlights, one is the backlink highlight rendered by PDF++, and the other is just a text selection. The latter disappears when clicking on the viewer because it's a normal text selection. Does it make sense or am I misunderstanding something?

N3C2L commented 6 months ago

Yes, it makes sense, thanks. But there is another option in the pdf++ settings which clears the text selection after clicking the backlink (after some time). Maybe something similar could be introduced here. I don't know how, but maybe simulate another mouse click after auto-pasting, so that this text selection goes away automatically?

RyotaUshio commented 6 months ago

So it's not a bug and it's a feature request, right? I guess nothing unexpected is happening here.

RyotaUshio commented 6 months ago

Adding an option to clear text selection after auto-pasting (or pasting in general) is doable.

N3C2L commented 6 months ago

Yeah, I am sorry for false labeling this thread as a bug. I would appreciate such an option your described. Because if the text selection is not cleared automatically, you can't read the highlighted text so easy afterwards.

RyotaUshio commented 6 months ago

Done, thanks for the idea! https://github.com/RyotaUshio/obsidian-pdf-plus/releases/tag/0.39.8

Auto-paste now works much more user-friendly than before 🔥

N3C2L commented 6 months ago

Excellent, thanks.