dendronhq / dendron

The personal knowledge management (PKM) tool that grows as you do!
https://wiki.dendron.so
Apache License 2.0
6.71k stars 254 forks source link

Text copied from Preview loses formatting/styling on Paste #2367

Open SR-- opened 2 years ago

SR-- commented 2 years ago

Please select the area your bug applies to. (Multiple selections are Possible. You can leave blank if you're not sure.)

Describe the bug

It used to be possible to copy the text from Dendron Preview and have it pasted into Word, Outlook, etc. with identical appearance preserved. This no longer works.

A text that looks like this:

image

comes in like this:

image

It has different fonts, different spacing, etc.

This is pretty disabling as there is no other fast way to get the content out of Dendron with formatting unless I am missing something.

By the way, the content copied from Dendron Wiki comes in fine, so it is the question of preserving rich HTML formatting of the Preview properly.

To Reproduce

Steps to reproduce the behavior:

  1. Copy from Preview
  2. Paste into MS Word

Expected behavior

I would like the formatting preserved precicely, it used to work fine a while back.

Desktop (please complete the following information)

Additional context

The discussion on Discord is here and and ever earlier mention is here

Is this related? https://github.com/dendronhq/dendron/issues/1703

Harshita-mindfire commented 2 years ago

Thanks for reporting the issue. We will let you know once this is fixed :pray:

SeriousBug commented 2 years ago

I'm unable to reproduce this issue. Tried on both Windows and Linux, with VSCode and VSCodium. If anyone can figure out how to reproduce it, it would be greatly appreciated.

SR-- commented 2 years ago

Really? Could you record a bit to show how it looks like for you? I can do the same if useful but the screen grabs above capture what I am seeing. Fonts, spaces beween lines, table styles are all lost.

SR-- commented 2 years ago

Happy to provide any additional info that might be useful. I find this a constant nuisance because I often send bits of notes to various people and it is much faster not to have to format them.

SeriousBug commented 2 years ago

Sure, here's a video: https://www.loom.com/share/e2f994f886b143ae95175eed23788c8b

I did notice a bug when recording this, but it looks different from what you are experiencing. If I copy with "Ctrl+C", it copies correctly. If I copy by right clicking, it only seems to copy part of what I have selected. I'll investigate that issue since that's something I can reproduce.

Are you copying with Ctrl+C or right click? I'd suggest trying it both ways to see if it's the same issue. Otherwise, do you have any other programs, extensions, or anything that might change or do something to your clipboard? It would also help to have the exact version of VSCode (regular VSCode, Insiders, or VSCodium, and which version of that) you are seeing this too, maybe it only happens in that version.

Also, is this only happening with Word? Does it also happen with other programs, like gmail?

SR-- commented 2 years ago

Thanks for the video. It does not work for your either. It is jsut that Google default styles look more similar to the Dendron Preview. Fonts, gaps are all different. As an easier to notice example, observe the Level 4 heading ("STEPS TO...") rendered in all caps in the Preview and in the sentence case in Gmail. If you try with MS Word, the difference is more obvious.

SeriousBug commented 2 years ago

Sorry if I misunderstood your problem, I thought the issue was that the paste was getting broken like in your screenshot?

For the styling, I'm not sure that preserving the exact style of Dendron is always ideal. Preserving the structure (headers, list items etc.) and just using the default style of where it gets pasted to would be my preference. @kevinslin @ScriptAutomate what do you think? I think our fix to remove the background style is removing all styling, is that intentional?

SR-- commented 2 years ago

No worries, thanks for looking into this. The screenshot does show the unwanted change in the styling. Sorry if that was not clear enough.

It was working before and was very convenient. It does not look like this was a considered change, just an artefact of some other tweaking. If it is intended and there are other use cases, why not give options? E.g., three: copy with no styles, with key structure, with all styles.

The only way to know how the result will look like is the Preview. The fastest way to trasfer to others is to copy/paste knowing what the result will be.

E.g., try a table: no lines, no spacing.

To fix the styles every time is a substantial effort that is a waste if the user is already happy with the Preview styles. For me, this makes whole established workflows unfeasible so I very much hope I can convince you to giving more frictionless options to get the content out is a good idea.

kevinslin commented 2 years ago

Sorry if I misunderstood your problem, I thought the issue was that the paste was getting broken like in your screenshot?

For the styling, I'm not sure that preserving the exact style of Dendron is always ideal. Preserving the structure (headers, list items etc.) and just using the default style of where it gets pasted to would be my preference. @kevinslin @ScriptAutomate what do you think? I think our fix to remove the background style is removing all styling, is that intentional?

we currently remove all styling because it was an effective 80/20 solution. makes sense to do a followup to remove styling more selectively as a followup

SR-- commented 2 years ago

Just to confirm that it is an apparently minor but very painful regression. It was easy to paste into distributions and LMS sites and it is so slow now that we are switching to other ways.

SeriousBug commented 2 years ago

@SR-- I'm now working on a way to selectively remove the background and text colors only while keeping the other styling. Sorry for the delay on getting started on this!

SeriousBug commented 2 years ago

Here's an update on my findings: This is much harder than it seems at first. Normally, the web view seems to do some smart copying behavior to add all the styles used in the page to the actual HTML elements. The fix to remove the background colors circumvented the web views built-in copying functionality, which means we don't get this smart behavior. Replicating this behavior is extremely difficult (it would need a CSS engine), so we have to work with the web view clipboard without circumventing it. I'll continue looking into this tomorrow.

SR-- commented 2 years ago

Thanks for trying!

As Anderson would say: "I have yet to see any problem, however complicated, which, when you looked at it in the right way, did not become still more complicated."

Is supporting two or more ways to copy possible? Can be a separate command or a toggle?

SeriousBug commented 2 years ago

I'm still hopeful for an actual solution. If it comes to that we can add a config or toggle instead, but I'd prefer to actually solve the issue if possible.

SeriousBug commented 2 years ago

@SR-- I spent more time working on this issue, but it looks like it would take a lot of effort to get it to a point where we can copy the HTML while maintaining the styles, and at the same time not copying the background colors. That's not to say it is impossible or we'll never do it, but we just don't have the time to prioritize this issue right now.

For the time being one option could be to use the built-in VSCode preview when copying the text. Another would be to publish the notes just for your own use, and then copy from the published notes. In the future we can also add a HTML export pod that can add the style along with the contents to your clipboard.

SR-- commented 2 years ago

Thanks again.

What is the problem with the backgrounds? Happy to copy them. Otherwise, it is not possible to get the content out conveniently and the whole system is not viable. As a general concern, it is a form of lock-in. Easy to add content, easy to manage it inside Dendron but hard to get useable content out. Publishing is hard, frail and has a large overhead because one has to care for copyright, acknowledgements, etc. I see no way to publish privately. There is no PDF export or HTML export. Non-Dendron previews introduce lots or hard to catch artefacts: image formatting, footnotes, all custom features.

Again, it was working perfectly before and we had a reasonable workflow so this is a regression from where we stand. I might be missing some important reasoning for removing this capability, not sure...

SeriousBug commented 2 years ago

The problem is for anyone using a dark theme and pasting to a light background website, or anyone using a light theme and pasting to a dark background website. The background color stands out from the page and looks broken. Removing the style fixes that problem because the default style of the website applies instead.

I don't think it's a form of lock-in. Your notes are still markdown and not a proprietary format, and we have the markdown export pod if you wanted to get them out of Dendron. We also do have an HTML export (Dendron: Publish Pod > html), it just doesn't include the Dendron theme. We are aware of the lack of PDF export, and have plans to add that.

I understand your view, and I can see that every fix you make can break someones workflow. But our options at the moment are to either drop more important bug fixes and improvements to focus on this, or to revert the fix and break the workflow of other users (especially anyone using a dark theme). Adding a config option to go back to the old copying mode is also an option, but that again takes time and effort to add. In the meantime we're happy to accept any code contributions to solve this issue, and if no one contributes we'll get to this problem in time. This is not saying "we'll never do this", just that there are more urgent things we have to work on right now so this problem will have to wait a bit. My sincere apologies for breaking your workflow, but I hope you see my point of view that there is a lot of other problems waiting for my attention and I can't do all of them at once.

kevinslin commented 2 years ago

@SR-- to add on to what @SeriousBug has said - the reason we implemented the fix is because we had many users being adversely affected by the background. see https://github.com/dendronhq/dendron/issues/1703

ghost commented 2 years ago

@kevinslin @SeriousBug @SR--

The question would it be an option to provide a setting/config, to chose which behavior someone wants?

If cleaning is wanted it gets cleaned if it is not wanted it does not clean.

That could be a faster solution to make both sides Happy in my eyes until someone has the time and know-how, how to remove only the background.

SR-- commented 2 years ago

Most importantly, the copy operation loses images and we use a lot of images so this form or copying is very limited.