WordPress.org

Ready to get started?Download WordPress

Forums

How do I expand the selection in the TinyMCE ? (4 posts)

  1. Zambrano Sergio
    Member
    Posted 4 years ago #

    How do TinYMCE actions expand the selection to include the whole link when you are applying an H1 and how does it distinguish when the bold tag goes inside the link, instead of wrapping the link in it?

    I created a new plugin to add a sortcode wrapping the selected text, by clicking an icon in the editor's toolbar.
    It works fine as far as you select many links or text: i.e.: the shortcode wraps the links up as expected.

    BUT when the selection is a single link, the $content is returned INSIDE the link, in place of the anchor text.

    How does the H1 manages to wrap the whole link instead of the anchor text only as the bold tag does?

    Here's the original post in another forum
    http://wordpress.org/support/topic/418625?replies=1

    Thanks.

  2. Zambrano Sergio
    Member
    Posted 3 years ago #

    WordPress behaves different whether you select one link or many. If one link is selected, just the anchor text is processed. If many, the whole link tags are processed.

    I assume there's some kind of "grab as little as you can until the whole tag's content gets selected" regex…

    But it must be some javascript from TinyMCE… because the shortcode function only sees what TinyMCE sends as $content

    Does anybody know where that function/condition is?

  3. Zambrano Sergio
    Member
    Posted 3 years ago #

    Anyone?
    Expanding the selection to grab the whole link tag instead of just the anchor?

  4. Zambrano Sergio
    Member
    Posted 3 years ago #

    This is a tough one! hehe

    I'm SURE there's a function that makes sure selections get kept as small as possible while keeping no tag un-closed… but I wish to know which function that is!!

Topic Closed

This topic has been closed to new replies.

About this Topic