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

[Bug] the selected text is not highlighted #73

Closed math-feng closed 6 months ago

math-feng commented 6 months ago

Steps to reproduce

see the GIF on the above. 值得注意的是当我重启Obsidian的时候一切正常,但是过一小段时间,之前正确高亮的文本都会消失

Expected behavior

the selected text is not highlighted

Actual behavior

the selected text should be highlighted

Screen recordings or screenshots (sandbox vault)

2024_03_02_22_23_28

Obsidian debug info

SYSTEM INFO: Obsidian version: v1.5.8 Installer version: v1.5.3 Operating system: Windows 10 Home China 10.0.22635 Login status: not logged in Insider build toggle: off Live preview: on Base theme: adapt to system Community theme: none Snippets enabled: 7 Restricted mode: off Plugins installed: 54 Plugins enabled: 52 1: Dataview v0.5.64 2: Paste URL into selection v1.7.0 3: Recent Files v1.3.10 4: Tasks v6.0.0 5: Zotero Integration v3.1.7 6: Style Settings v1.0.7 7: Auto Link Title v1.5.3 8: Latex Suite v1.9.1 9: Note Refactor v1.8.2 10: Clear Unused Images v1.1.0 11: Copy Block Link v1.0.4 12: Hover Editor v0.11.17 13: Folder notes v1.7.14 14: Git v2.23.2 15: Checklist v2.2.13 16: Tasks Calendar Wrapper v0.2.9 17: Sortable v0.3.1 18: Remotely Save v0.3.40 19: Plugin Groups v2.1.0 20: Image2LaTEX v1.0.4 21: Tag Wrangler v0.6.1 22: Weread v0.9.0 23: BRAT v0.8.4 24: LaTeX-like Theorem & Equation Referencer v2.2.0 25: Auto-\displaystyle Inline Math v0.2.2 26: Better Math in Callouts & Blockquotes v0.3.7 27: Rendered Block Link Suggestions v0.5.0 28: Strange New Worlds (SNW) v1.2.5 29: No more flickering inline math v0.3.4 30: Hider v1.3.1 31: Quick Preview v0.6.0 32: File Cooker v1.8.1 33: Linter v1.23.1 34: Templater v2.2.2 35: Scroll to Top v2.1.4 36: Auto Hide v0.4.7 37: MathLinks v0.5.3 38: Share Note v0.8.7 39: Daily note creator v1.0.0 40: Status Bar Organizer v1.3.0 41: Opener v2.1.2 42: File Tree Alternative v2.4.8 43: Remember cursor position v1.0.8 44: Media Extended v3.0.4 45: Various Complements v9.4.0 46: Advanced Paste v2.7.0 47: Easy Typing v5.2.0 48: Advanced Tables v0.21.0 49: Image Context Menus v1.6.0 50: floating toc v2.4.6 51: Hypothes.is v0.1.19 52: PDF++ v0.37.0

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": true,
        "singleTabForSinglePDF": true,
        "highlightExistingTab": false,
        "existingTabHighlightOpacity": 0.5,
        "existingTabHighlightDuration": 0.75,
        "paneTypeForFirstPDFLeaf": "",
        "openLinkNextToExistingPDFTab": true,
        "openPDFWithDefaultApp": false,
        "openPDFWithDefaultAppAndObsidian": true,
        "focusObsidianAfterOpenPDFWithDefaultApp": true,
        "syncWithDefaultApp": false,
        "dontActivateAfterOpenPDF": true,
        "dontActivateAfterOpenMD": true,
        "highlightDuration": 0.75,
        "noTextHighlightsInEmbed": false,
        "noAnnotationHighlightsInEmbed": false,
        "persistentTextHighlightsInEmbed": true,
        "persistentAnnotationHighlightsInEmbed": true,
        "highlightBacklinks": true,
        "dblclickEmbedToOpenLink": true,
        "highlightBacklinksPane": true,
        "highlightOnHoverBacklinkPane": true,
        "backlinkHoverColor": "",
        "colors": {
            "Yellow": "#ffd000",
            "Red": "#ea5252",
            "Note": "#086ddd",
            "Important": "#bb61e5"
        },
        "defaultColor": "",
        "defaultColorPaletteItemIndex": 0,
        "syncColorPaletteItem": true,
        "syncDefaultColorPaletteItem": false,
        "colorPaletteInToolbar": true,
        "noColorButtonInColorPalette": true,
        "colorPaletteInEmbedToolbar": true,
        "showStatusInToolbar": true,
        "highlightColorSpecifiedOnly": false,
        "doubleClickHighlightToOpenBacklink": true,
        "hoverHighlightAction": "preview",
        "paneTypeForFirstMDLeaf": "window",
        "singleMDLeafInSidebar": true,
        "alwaysUseSidebar": true,
        "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": false,
        "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": true,
        "annotationPopupDrag": true,
        "useCallout": true,
        "calloutType": "PDF",
        "calloutIcon": "highlighter",
        "highlightBacklinksInEmbed": true,
        "highlightBacklinksInHoverPopover": true,
        "highlightBacklinksInCanvas": true,
        "clickPDFInternalLinkWithModifierKey": true,
        "clickOutlineItemWithModifierKey": true,
        "clickThumbnailWithModifierKey": true,
        "focusEditorAfterAutoPaste": true,
        "autoFocus": false,
        "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": "pdf-plus:create-new-note",
        "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": true,
        "rectImageFormat": "file",
        "rectImageExtension": "png",
        "includeColorWhenCopyingRectLink": true,
        "backlinkIconSize": 50,
        "showBacklinkIconForSelection": true,
        "showBacklinkIconForAnnotation": true,
        "showBacklinkIconForOffset": true,
        "showBacklinkIconForRect": true,
        "showBoundingRectForBacklinkedAnnot": true,
        "hideReplyAnnotation": false,
        "autoHidePDFSidebar": true,
        "respectCursorPositionWhenAutoPaste": true
    },
    "styleSettings": {
        "pdf-plus@@hide-pdf-embed-toolbar": true
    },
    "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}"
}
math-feng commented 6 months ago

Another thing is strange, I guess this is a related to my PDF file, but do not know why this is, would like to ask you to help me explain.

As shown below: the content that is boxed and the content that is displayed do not match. 2024_03_02_22_33_37

RyotaUshio commented 6 months ago

Thanks for the report! As in the bug report form, I'd like you to provide screen recording and debug info in the sandbox vault.

You can open the sandbox vault by running the command "Open sandbox vault". The command name can be different in other languages than English.

Thank you for your cooperation.

A few questions:

math-feng commented 6 months ago
  1. everything's fine in sandbox valut
  2. yes
  3. yes, please.
math-feng commented 6 months ago

debug info in the sandbox valut: SYSTEM INFO: Obsidian version: v1.5.8 Installer version: v1.5.3 Operating system: Windows 10 Home China 10.0.22635 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.37.5

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.

RyotaUshio commented 6 months ago

In my environment, both the text selection and the rectangle region were highlighted properly. However, I was able to reproduce the second bug (the content of the rectangle selection embed is incorrect)

https://github.com/RyotaUshio/obsidian-pdf-plus/assets/72342591/3ea479c5-8a6f-48e7-88e9-a3ca83d9b8f3

RyotaUshio commented 6 months ago

The embed bug should be fixed in 0.37.6. Can you test it?

(please reload Obsidian after updating)

RyotaUshio commented 6 months ago

As for the first bug (text selection not highlighted), it only happens in your own vault and not in the sandbox vault, right?

In your vault, you have too many plugins enabled, which makes it extremely difficult to identify what is causing the problem. So I'd like to ask you to figure out the minimal setup where the bug takes place.

I know this is tedious but it's necessary steps. Thank you for your cooperation!

RyotaUshio commented 6 months ago

Plus, do you see any error messages in the developer console?

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

math-feng commented 6 months ago

Plus, do you see any error messages in the developer console?

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

image

Is it ok?

math-feng commented 6 months ago

The embed bug should be fixed in 0.37.6. Can you test it?

(please reload Obsidian after updating)

The problem was gone after I did what you said, but again, after a while, the PDF page seemed to refresh, and the problem was there!

RyotaUshio commented 6 months ago

Let's continue in the new issue #77.