Important changes to Tiny Cloud pricing > Find out more

NOTE: TinyMCE 5 reached End of Support in April 2023. No more bug fixes, security updates, or new features will be introduced to TinyMCE 5. We recommend you upgrade to TinyMCE 6 or consider TinyMCE 5 Long Term Support (LTS) if you need more time.

Anchor plugin

Insert anchors (sometimes referred to as a bookmarks).

Contribute to this page
+ toolbar button + menu item

This plugin adds an anchor/bookmark button to the toolbar that inserts an anchor at the editor’s cursor insertion point. It also adds the menu item anchor under the Insert menu.

When a user clicks on the anchor button or menu item they will be prompted via a dialog box to enter a string. The string will be inserted into the HTML as an anchor id at the location of the cursor. For example, a user places their cursor at the beginning of “Hello World” and clicks on the anchor button and enters “start” in the dialog box. The resulting HTML will take the form of <p><a id="start"></a>Hello, World!</p>.

Basic setup

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  plugins: 'anchor',
  toolbar: 'anchor',
  menubar: 'insert'
});

Toolbar buttons

The Anchor plugin provides the following toolbar buttons:

Toolbar button identifier Description
anchor Creates/Edits anchor elements.

These toolbar buttons can be added to the editor using:

Menu items

The Anchor plugin provides the following menu items:

Menu item identifier Default Menu Location Description
anchor Insert Inserts an anchor into the editor.

These menu items can be added to the editor using:

Commands

The Anchor plugin provides the following JavaScript command.

Command Description
mceAnchor Opens the insert/edit anchor dialog.

Example

tinymce.activeEditor.execCommand('mceAnchor');

Can't find what you're looking for? Let us know.

Except as otherwise noted, the content of this page is licensed under the Creative Commons BY-NC-SA 3.0 License, and code samples are licensed under the Apache 2.0 License.