JSPM

ckeditor5-code-snippet-plugin

1.0.7
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q24247F
  • License ISC

A simple CKEditor5 plugin that helps create preformatted text in the rich text editor.

Package Exports

  • ckeditor5-code-snippet-plugin

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ckeditor5-code-snippet-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

CKEditor5 Code Snippet Plugin

This plugin helps your create a code block or snippet in your rich text.

Demo

How to Use

  1. To make use of this plugin, you will need to setup your editor using the framework. If you have not done so, below are links to the respective frontend framework specific docs for this. I will recommend you use a custom editor rather than the build. If you are going to use the build, you will need to follow instructions found here to avoid the duplicate modules error.

    • Node
    • Angular: Please note that you cannot build a custom editor for source yet for Angular. You will need to tinker with the build to use this plugin with your Angular project. See instructions here
    • React
    • Vue
  2. Install this package using npm i ckeditor5-code-snippet-plugin. This package contains the plugin that will help create preformatted text as well as the command and toolbar button.

  3. Import the CodeSnippet plugin into the file that contains your editor like so

import CodeSnippet from 'ckeditor5-code-snippet-plugin/dist/codesnippet';
  1. In the config object, add CodeSnippet to the list of plugins.
plugins: [
  ..., CodeSnippet, ...
],
  1. Add the command to the list of toolbar elements as well.
toolbar: [..., 'codeSnippet', ...],

Styling the Preformatted Text

To add custom styles to the preformatted text, you will need to add the following class to your global style; code-snippet. You may notice that the style gets overwritten when the pre element is in focus. To modify the override, add and edit the following selector as well .ck .ck-editor__nested-editable.ck-editor__nested-editable_focused, .ck .ck-editor__nested-editable:focus.

Contributors

Opeoluwa Iyi-Kuyoro: 👨🏿Profile - WebSite