Add "Anchor" button

Created on 17 October 2015, over 8 years ago
Updated 8 November 2023, 8 months ago

This came up when I wanted to insert an anchor tag (i.e. <a name="foo"></a>) button. I looked in the "Available buttons" list but even in the Full HTML format, it wasn't available:

After searching through a lot of issues around the addition of CKEditor to core and Drupal's tweaks to it, it appears that many of CKEditor's more advanced buttons aren't being included in order to keep the library light. That's all fine. (Although I might quibble with an anchor button as not being standard enough to include.)

But after reading through the help text on the format configuration page, as well as the CKEditor and Text Editor help pages, I couldn't find any information about how to selectively download and add some of those other buttons full CKEditor provides. There are oblique references to adding CKEditor plugins (though no real instructions on doing so) but this isn't really a plugin, just a button.

I expect documentation suggestions will be much lower priority than bugfixing during the RC phase, but if buttons as simple as anchor tags are being excluded I think many people will be wondering how to do this when they're configuring Drupal 8.

I'm happy to contribute documentation patches, e.g. to the CKEditor help page, or update the CKEditor module documentation page → if someone can point me to raw material somewhere that describes in some form how to do this.

✨ Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

🇺🇸United States rootwork 🇺🇸 US-Pacific 🌎 Chinook (Multnomah, Clackamas) & Cowlitz lands 🌹 Portland, OR

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States rosemarystanley

    I appreciate this patch. We've tried using the anchor_link module but there's some conflicts with the drupal link ckeditor button. I did want to note while patch #54 does work well, I wanted to report a small bug. When you double click on an existing anchor the drupal link dialog popups up, not the anchor form. A workaround is right clicking to select "Edit anchor" to get the correct dialog box.

  • Status changed to Needs work about 1 year ago
  • 🇦🇺Australia gordon Melbourne

    I just got very excited but then disappointed since there is no CKEditor 5 support.

    I assume that this works great in CKEditor 4, but version 2.x adds support for CKEditor 5 so this needs work in both 4 and 5.

    Changed back to needs work.

  • 🇱🇻Latvia biguzis

    Updated #54 with change from drupal_get_path('module', 'editor_advanced_link') to $this->getModulePath( 'editor_advanced_link') for D10 support.

  • 🇱🇻Latvia biguzis

    Dont use patch from #57. It was wrong since binary was messed up. Edited #54 with http://hexfiend.com/ but still want to know how to do it properly with git. git diff --binary > patch.patch didn't worked for me.

  • 🇺🇸United States generalredneck

    A note on the PNG problems... maybe use as SVG instead?

  • 🇺🇸United States generalredneck

    So a few things... the latest patch only works with the patch command. git apply complains of

    $ git apply editor_advanced_link-add_anchor_button-2595337-58.patch
    editor_advanced_link-add_anchor_button-2595337-58.patch:22: trailing whitespace.
    �PNG
    editor_advanced_link-add_anchor_button-2595337-58.patch:32: trailing whitespace.
    �PNG
    editor_advanced_link-add_anchor_button-2595337-58.patch:41: trailing whitespace.
    �PNG
    editor_advanced_link-add_anchor_button-2595337-58.patch:52: trailing whitespace.
    �PNG
    error: cannot apply binary patch to 'editor_advanced_link-add_anchor_button-2595337-54.patch' without full index line
    error: editor_advanced_link-add_anchor_button-2595337-54.patch: patch does not apply
    

    Additionally, this patch includes another patch in it

    $ patch -p1 < editor_advanced_link-add_anchor_button-2595337-58.patch
    patching file editor_advanced_link.routing.yml
    patching file js/plugins/anchor/icons/anchor-rtl.png
    patching file js/plugins/anchor/icons/anchor.png
    patching file js/plugins/anchor/icons/hidpi/anchor-rtl.png
    patching file js/plugins/anchor/icons/hidpi/anchor.png
    patching file js/plugins/anchor/plugin.js
    patching file src/Form/EditorAnchorDialog.php
    patching file src/Plugin/CKEditorPlugin/AnchorLink.php
    patching file editor_advanced_link-add_anchor_button-2595337-54.patch
    

    Lastly, the images don't load in the browser or in the OS.

  • 🇺🇸United States generalredneck

    Rerolling#58 with svg icons to make for a better patching experience. Removes the extraneous patch file also.

  • 🇺🇸United States DamienMcKenna NH, USA

    I think it might be easier to write an update script to convert existing data and train people to use the "id" attribute.

Production build 0.69.0 2024