WordPress.org

Forums

TinyMCE Advanced
Anchors using button don't stay when updated (6 posts)

  1. idamyrussell
    Member
    Posted 1 year ago #

    I use anchors a lot and went to add one to a page that already had 4 on it. It inserted and linked fine, but when I updated the page, a different anchor disappeared. I have only been able to keep 3 anchors on my page at any time, and could not tell which anchor would get deleted when trying to add in new ones.

    I went into the post code to add anchors using "name" and it saved just fine. Obviously a problem with your button.

    p.s. please bring back custom color options, I have very specific colors for my brand that I use on a daily basis and no longer can with your update.

    https://wordpress.org/plugins/tinymce-advanced/

  2. infosws
    Member
    Posted 1 year ago #

    I have seen this problem too on many customer sites since upgrading to 4.0.2.

    I think the issue is that the anchor created is

    <a id="test"></a>

    when it should be

    <a name="test"></a>

    Hope this helps.

  3. Andrew Ozz
    WordPress Dev
    Plugin Author

    Posted 1 year ago #

    This is a change in TinyMCE 4.0. The "old style" anchors <a name="test"></a> are replaced with "new style" <a id="test"></a>. The last browser requiring old style anchors was IE6. As it is completely "dead" now, finally HTML IDs can be used as anchors. Also the ID doesn't have to be on a link element, can be on any HTML element.

    As far as I see both old and new style anchors work properly. Maybe try to get the exact steps to reproduce this.

  4. infosws
    Member
    Posted 1 year ago #

    To reproduce:

    - Create a page
    - add an anchor in visual display mode
    - Switch to text display mode and the code for the a tag isn't there.

    If I edit the plugin to change it from id to name and run the same test, it works.

    In the file mce/anchor/plugin.js file I changed line 22.
    From
    id: e.data.name
    to
    name: e.data.name

    I also made the same change in the plugin.min.js file.

    (This may not be the correct change but it worked for me).

  5. The "old style" anchors are replaced with "new style" .

    Thanks for this, Andrew. I had no idea.

    Yes, the anchor link (defined in core WP Tinymce) is a little 'fuzzy'.

    1. Create some text in visual view:

    This is a test link.

    2. Select the word test and click the anchor button.
    3. Add "myTest" as the anchor name.
    4. Switch to 'text' view.

    You will see the editor has removed the word test and replaced it with <a id="myTest"></a>.

    The original word "test" (or whatever you highlight just prior to clicking the anchor button) gets removed completely.

    I think we just need to add back in the 'editor selection' when the link is created; and push it back to the WordPress editor.

    EDIT: Hey Andrew, trac ticket HERE.

  6. Andrew Ozz
    WordPress Dev
    Plugin Author

    Posted 1 year ago #

    @infosws there is probably something else that removes the <a id="test"></a> tag. Your example works properly on a clean WP install when only TinyMCE Advanced is enabled.

    @Josh this is the "standard" behavior in all editors. When something is selected and you start typing or add another element (like image), the selection is replaced.

    For anchors it would probably be better to collapse the selection, I'll make a patch and see if the TinyMCE Devs would change it.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • TinyMCE Advanced
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic