Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting on iOS inconsitent #120

Open
cdloh opened this issue Jun 11, 2024 · 3 comments
Open

Pasting on iOS inconsitent #120

cdloh opened this issue Jun 11, 2024 · 3 comments

Comments

@cdloh
Copy link

cdloh commented Jun 11, 2024

Hi love the plugin and regularlly use it but for some reason it's super inconsistent on iOS and for the life of me I can't figure out why. I've tracked a few things down and will note them below

  1. clipboardData.getData("text/plain"); is null or blank string sometimes
    I can't figure out why this is but swapping to navigator.clipboard.readText() fixes this and is always consistent. However if we await on the readText here it then causes the text to get over ridden on selection :( 

Steps to reproduce this

  1. Open safari and browser to a URL

  2. Click Share and then Copy

  3. Open Obsidian and Paste into a note

  4. Pasting a link appears to automatically parse it into a URL causing the shouldPreserveSelectionAsTitle option to trigger even though before the paste event we didn't have anything selected
    Adding a check to see if the selected text is the same as the paste text fixes this

if (selectedText && this.settings.shouldPreserveSelectionAsTitle && selectedText != clipboardText) {
                editor.replaceSelection(`[${selectedText}](${clipboardText})`);
                return;
            }

It's worth noting that sometimes this isn't even an issue! I don't know what causes the inconsistency at all. For example if I copy a URL within obsidian and then paste it again the clipboardData is consistent.

@byarbrough
Copy link

byarbrough commented Jun 24, 2024

On my iPhone the title is properly fetched from Safari if I tap the URL and copy, but not if I do Share>Copy. Note that I get the "Allow copy" warning which might be part of the problem.
Either way works with Firefox.

@stevedoyle
Copy link

On my iPhone the title is properly fetched from Safari if I tap the URL and copy, but not if I do Share>Copy.

Same on my iPhone and iPad.

@jowitte
Copy link

jowitte commented Dec 1, 2024

Same here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants