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

Support for HTML tags? #39

Open
marko-stimac opened this issue Aug 17, 2019 · 1 comment
Open

Support for HTML tags? #39

marko-stimac opened this issue Aug 17, 2019 · 1 comment

Comments

@marko-stimac
Copy link

marko-stimac commented Aug 17, 2019

If I have a column value Lorem ipsum and I change that into <a href="#">Lorem</a> ipsum <em>dolor</em> sit amet the text will be updated but with stripped html. Is it possible to have the HTML intact?
I am not sure if this is WP DB Table Editor's issue or Slick does it?

I was thinking about recreating shortcuts for HTML tags like we can do in WordPress. When I select a part of text and press CTRL+i the text should change from Lorem ipsum dolor sit amet to Lorem ipsum <em>dolor</em> sit amet.
The following code is maybe a mess but it works for surrounding text with italics.


// The popup editor doesn't exist in DOM unless user triggers editing process,
// and those divs don't even have any ID or class on them this is an improvisation to target it
jQuery("html").on("click", function() {
  jQuery("body > div > textarea").on("keydown", function(e) {
    var textarea = jQuery(this);

    if (e.ctrlKey && e.key == "i") {
      // get length of text
      var length = textarea.val().length;
      // starting text
      var start_point = textarea[0].selectionStart;
      // ending text
      var end_point = textarea[0].selectionEnd;

      // get selected text
      var selectedText = jQuery(this)
        .val()
        .substring(start_point, end_point);
      var replacement = "<em>" + selectedText + "</em>";
      // Replace text
      textarea.val(
        textarea.val().substring(0, start_point) +
          replacement +
          textarea.val().substring(end_point, length)
      );

      // Since there is a bug with double inserting <em></em>, remove those empty ones :)
      var newText = textarea.val().replace("<em></em>", "");
      textarea.val(newText);
    }
  });
});


@bobbysmith007
Copy link
Member

I guess I never saw this... not sure where the tags would be being stripped. I'll try and take a look at it soon

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

2 participants