Contribute to this guide

guideSelect all

The select all feature allows selecting the entire content of the WYSIWYG editor using the Ctrl/Cmd+A keystroke or the toolbar button. It is mostly useful when you need to copy all the content to another document or want to clear the editor area easily.

This feature is enabled by default in all predefined builds as a keyboard shortcut. See the installation section for information on adding a toolbar button to your editor.

# Demo

Press Ctrl/Cmd+A or use the toolbar button Select all to select the entire content of the editor.

When the selection is inside the image caption, it will only expand to the boundaries of the caption. Use the keystroke or the toolbar button again to include more content until the entire content of the editor is selected. The same rule applies, for instance, when the selection is inside a table cell or any self–contained (nested) editable region in the content.

This demo only presents a limited set of features. Visit the full-featured editor example to see more in action.

# Installation

This feature is enabled by default in all builds (loaded by the Essentials plugin) as a keyboard shortcut. The installation instructions are for developers interested in building their own, custom rich text editor or willing to configure the toolbar button.

To add this feature to your editor, install the @ckeditor/ckeditor5-select-all package:

npm install --save @ckeditor/ckeditor5-select-all

Then add the SelectAll plugin to your plugin list and to the toolbar:

import SelectAll from '@ckeditor/ckeditor5-select-all/src/selectall';

ClassicEditor
    .create( document.querySelector( '#editor' ), {
        // Load the plugin.
        plugins: [ SelectAll, ... ],

        // Display the "Select all" button in the toolbar.
        toolbar: [ 'selectAll', ... ],
    } )
    .then( ... )
    .catch( ... );

# Common API

The SelectAll plugin registers the 'selectAll' UI button component and the 'selectAll' command implemented by SelectAllCommand.

The command can be executed using the editor.execute() method:

// Select the entire content of the editor.
editor.execute( 'selectAll' );

We recommend using the official CKEditor 5 inspector for development and debugging. It will give you tons of useful information about the state of the editor such as internal data structures, selection, commands, and many more.

# Contribute

The source code of the feature is available on GitHub in https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-select-all.