Support » Plugins » How do I expand the selection in the TinyMCE ?

  • Zambrano Sergio


    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


Viewing 3 replies - 1 through 3 (of 3 total)
  • 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?

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

    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!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I expand the selection in the TinyMCE ?’ is closed to new replies.