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

Splice data-urls out of rich text module textarea and offer link and guidance #182

Closed
jywarren opened this issue Dec 13, 2018 · 4 comments · Fixed by #200
Closed

Splice data-urls out of rich text module textarea and offer link and guidance #182

jywarren opened this issue Dec 13, 2018 · 4 comments · Fixed by #200

Comments

@jywarren
Copy link
Member

After #175, we should instead of just warning about a data-url, we should actually splice it out along with showing a warning. This would mean using similar regex to in #175 but actually removing the entire data-URL from the Rich Text Editor textarea.

We should also insert a link in the message shown that allows the person to open the data-url image in a new window, save it, and drag it back in, and guidance to tell them to take these steps, maybe in Step 1, Step 2, Step 3 format and a message like:

"Sorry, this editor can't handle images of this format. Please open it in a new window, save it, and drag it back into the editor."

@rexagod
Copy link
Member

rexagod commented Dec 18, 2018

@jywarren Here's a preview.

dec 18 2018 10_54 am

Major changes

  • DURIs are recognized by regex pattern, reducing redundant string matching code, thus better readability.
  • 'keydown' required another key to be pressed after pasting the DURI. Fixed that by triggering events on 'keyup'.
  • DURI is 'spliced' and replaced by a reasonable message, thus preventing users to think that this maybe some uncontrolled behaviour.
  • Instead of opening a new tab and then saving the file, the user can straightaway download the file in one step only. Also, Google has restricted hrefs and even some srcs to open up DURIs from a security point of view, google it.
  • <ul> display of instructions, and I think that's pretty much it.

@jywarren
Copy link
Member Author

This is FANTASTIC -- very very exciting work! Tremendous building upon #178 as well.

Great holistic approach to solving this!

Two things I wonder:

  1. if whether we might not want to splice in the warning message into the actual post text, as some people might forget to remove it. We might in parallel think about a future feature to be able to show alerts inline which are only displayed in edit mode, perhaps using the HTML comment syntax like <!-- comment here --> -- but that would be a separate project.
  2. I definitely appreciate the goal of not making people confused when their image disappears. I think we need potentially to be sure their attention is captured by /something/. Some ideas:
    a. we could make the text more compact so it's a little less confusing when text of this type ends up in the final published post -- maybe (Image not saved due to data-url format; see message below or [click here](https://publiclab.org/data-url-error) for help.) -- i'm thinking if someone doesn't notice and it gets published, it should offer useful help in that context too.
    b. could we use a JavaScript alert() message as well to be sure we get the user's attention, or is that going too far?
    c. mainly, i wonder in really long posts, if the message at the bottom is too far to find.

But generally this is fantastic. Just offering a few more ideas to refine it slightly, but we could almost certainly go ahead with this PR if you'd like.

Thank you so much!

@rexagod
Copy link
Member

rexagod commented Dec 19, 2018

@jywarren I thought on this for a while and implemented an idea of my own while keeping all your aforementioned points in mind which, I hope, would satisfy all the concerns.

publiclab editor

Now instead of the warning message nothing pops up, this is, the DURI is replaced by a null string as soon as it is pasted and along with this, the page automatically moves down to the instructions message (yellow box). In my opinion, this seems to be a cleaner solution for short as well as long texts.

So should I submit a new PR reflecting this change, or are you content with the previous one, or maybe even something else? Do let me know!

@jywarren
Copy link
Member Author

jywarren commented Dec 19, 2018 via email

@rexagod rexagod mentioned this issue Dec 21, 2018
5 tasks
rexagod added a commit to rexagod/PublicLab.Editor that referenced this issue Jan 2, 2019
jywarren pushed a commit that referenced this issue Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants