etesync-notes icon indicating copy to clipboard operation
etesync-notes copied to clipboard

Feature request: Allow selection & copy/paste in preview mode

Open ghost opened this issue 5 years ago • 8 comments

Allow selection & copy/paste in preview mode

ghost avatar Dec 12 '20 17:12 ghost

I wonder if it's even possible given how the markdown rendering works. We'll have to take a look at it. Thanks!

tasn avatar Dec 13 '20 06:12 tasn

I'm guessing this requires overriding the render rules of inline elements in react-native-markdown-display. It would be easier to fix that upstream.

zecakeh avatar Jan 02 '21 11:01 zecakeh

Yeah, you are probably right, though I wonder how it works with the multiple text spans. I think we will probably need a wrapping text object so that it's all part of the same text view (and thus can be selected).

tasn avatar Jan 02 '21 13:01 tasn

The problem is you can't have a View inside a Text, if I remember correctly there's a bug on Android. I think it would work, but you wil probable lose the blocks and just have inline text.

zecakeh avatar Jan 02 '21 14:01 zecakeh

Yeah, you can't. I don't think it's a bug, just a limitation. I guess views are used for some of the things, so we can't wrap with a text object. This means that it's potentially not possible to select across text spans (e.g. lines) in the markdown preview, but it should be possible to select single words and lines I think, so at least we should have that. Just sharing what I remember, but I could be wrong.

tasn avatar Jan 02 '21 16:01 tasn

I've been looking at making a PR to add that feature at react-native-markdown-display. As you thought, you can only select by line or paragraph. As soon as you change block, you can't select anymore.

Should we have the preview as HTML in a WebView to not be limited by that ?

zecakeh avatar Jan 04 '21 17:01 zecakeh

I'm not happy about moving to using a webview because of memory consumption and performance, though I guess we will be going that direction anyway because of the rich text editor. I really don't know what to say. :\ Can you ping me again about this tomorrow and we'll have another think?

tasn avatar Jan 04 '21 17:01 tasn

Another solution might be to have everything embedded in a single Text component, that means no views. That's doable, if we change the styles a bit (except for tables and images of course). That would mean a completely different renderer. And we wouldn't be that far from a native WYSIWYG editor 😛

zecakeh avatar Jan 04 '21 17:01 zecakeh