Drupal is a registered trademark of Dries Buytaert
Views Bootstrap 5.5.2 Minor update available for module views_bootstrap (5.5.2). oEmbed Providers 3.0.0 Major update available for module oembed_providers (3.0.0). amazee.ai Private AI Provider 1.3.4 Minor update available for module ai_provider_amazeeio (1.3.4). Scolta 1.1.0 Minor update available for module scolta (1.1.0). MCP Sentinel 2.3.0 Minor update available for module mcp_sentinel (2.3.0). Page Feedback Up/Down 1.0.0 Initial release available for module page_feedback (1.0.0)! oEmbed Providers 2.2.4 Module oembed_providers updated after 7 months of inactivity (2.2.4). Raw Fields Formatters 1.0.0-alpha7 New alpha version released for module raw_fields_formatters (1.0.0-alpha7). Raw Fields Formatters 1.0.0-alpha6 New alpha version released for module raw_fields_formatters (1.0.0-alpha6). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module preserves your text selection and cursor position when switching between WYSIWYG and source code modes in the CKEditor 5 editor. It also ensures the selected text stays visible by scrolling it into view in both editing modes.

CKEditor Text Selection

A Drupal module that integrates the CKEditor 5 Text Selection plugin into Drupal's CKEditor 5 editor.

Demo

This module makes the editor keep its text selection when switching between WYSIWYG and Source mode, and scrolls the selection into the viewport. It replicates the behaviour of the popular CKEditor 4 Text Selection.

How it works

When switching from WYSIWYG to Source mode, the plugin maps the current cursor position or text selection from the editor model to the corresponding position in the raw HTML source. When switching back from Source to WYSIWYG, it reads the cursor position in the source textarea and restores it in the rich text editor.

All failures are handled silently — the editor never crashes.

Features

  • Preserves cursor position when toggling between WYSIWYG and Source editing modes.
  • Preserves text selection (not just cursor) across mode switches.
  • Scrolls the viewport to show the selection in both modes.
  • Works with the CKEditor CodeMirror Source Editing plugin.
  • Inspired by the CKEditor 4 Text Selection plugin.

Requirements

  • CKEditor 5 Source Editing must be enabled in the text format configuration.

Installation

  1. Install the module as you would normally install a contributed Drupal module. See Installing modules for further information.
  2. Go to Administration > Configuration > Content authoring > Text formats and editors.
  3. Configure a text format that uses CKEditor 5.
  4. Under CKEditor 5 plugin settings, enable the Text Selection plugin.
  5. Make sure Source Editing is also enabled in the toolbar.

Configuration

No additional configuration is required. Once enabled, the plugin automatically preserves text selection when switching between editing modes.

Related projects

Maintainers

DrupalBook agency created CKEditor Text Selection for Drupal and specializes in building clean, reliable CKEditor plugins tailored to real editorial workflows. If you need a custom CKEditor feature, deeper Drupal integration, or long‑term maintenance by someone who knows both ecosystems inside out, We are happy to help. Get in touch to discuss your project: [email protected] or https://drupalbook.org/contact.

Activity

Total releases
3
First release
May 2026
Latest release
1 month ago
Releases (12 mo)
3 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Release date
1.0.1 Stable Jun 27, 2026
1.0.x-dev Dev May 3, 2026
1.0.0 Stable May 3, 2026