cybersemics / em

A beautiful, minimalistic note-taking app for personal sensemaking.
Other
284 stars 110 forks source link

Strip external colors #2467

Open raineorshine opened 1 week ago

raineorshine commented 1 week ago

Steps to Reproduce

Copy "19th–early 20th century" from https://www.brooklynmuseum.org/opencollection/objects/124722 and paste into em.

Current Behavior

Text is black on white background.

Expected Behavior

Text should be the default white on black with no styles applied.

Notes

How will you differentiate internal from external imports? Should we do a simple regex on the format that em uses, or should we add a data-source='em' attribute?

RED-ROSE515 commented 1 day ago

@raineorshine , I think the text color will depend on current theme. So, if the current theme is black theme, text should be black background color and white text color. And if the current theme is white them, text should be white background color and black text color. What do you think?

raineorshine commented 1 day ago

The problem is a bit broader than that. In the vast majority of cases, users only want to copy the content from other websites, not the style. Colors from the source document probably only look good on the original website. This has happened to me many times when using em myself. Every time it copies colors, I wish it would have just copied the text.

For this reason, the default behavior should be to strip all colors from text that is pasted from external sources. If text with colors is copied and pasted within em, then we should preserve the colors, since we know that they were intentionally added by the user.

In the future we could potentially add the option to opt-in to copying colors from external sources, if there is demand.

RED-ROSE515 commented 1 day ago

I understand your intentions. Thanks.

raineorshine commented 1 day ago

Great :)

The main question I have right now is how we should detect internal vs external text in the clipboard. Let me know what you think would be a good approach.