levmyshkin/ckeditor5-textselection

A plugin that makes CKEditor 5 keep its text selection when switching between Visual and Source mode.

Maintainers

Package info

github.com/levmyshkin/ckeditor5-textselection

Language:JavaScript

Type:drupal-library

pkg:composer/levmyshkin/ckeditor5-textselection

Statistics

Installs: 8

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.1 2026-05-02 18:02 UTC

This package is auto-updated.

Last update: 2026-05-02 18:03:02 UTC


README

A plugin that makes the editor keep its text selection when switching between WYSIWYG and Source mode, and scrolls the selection into the viewport.

Inspired by the CKEditor Text Selection plugin.

This plugin also works with the CKEditor 5 CodeMirror Source Editing plugin.

Demo

Open demo/index.html in a browser to try the plugin with CKEditor 5 loaded from CDN. Select text, toggle Source mode, and see the selection preserved.

Demo CKEditor TextSelection

License

Licensed under the terms of the GPL-2.0 License.

Structure

ckeditor5-textselection/
├── build/                   # Compiled JS bundle (output of webpack)
│   └── textSelection.js
├── src/                     # Plugin source code
│   ├── index.js             # Plugin entry point (exports default object)
│   └── textselection.js     # Plugin implementation
├── package.json
└── webpack.config.js

Building

The webpack build uses the CKEditor 5 DLL Reference Plugin to integrate with Drupal's CKEditor 5 DLL system. Instead of bundling CKEditor 5 core modules, the built file delegates to CKEditor5.dll at runtime — the shared library that Drupal core provides on every page with a CKEditor 5 instance.

The DLL manifest (ckeditor5-dll.manifest.json) is sourced from the ckeditor5 npm package which is included as a dev dependency.

npm install
npm run build        # production (minified)
npm run build:dev    # development (unminified)
npm run watch        # watch mode