Skip to content

Extensions

One of the key features of this library is that most features are implemented by optional extensions. This is to keep the core light for those who don’t need the extra functionality.

Non-exhaustive list of extensions you can add:

Later guides will show some of the more sophisticated extensions in more detail.

The addOverlay() utility can be used to add overlays to an editor which is used by many extensions. Overlays are added to the .pce-overlays element and will get styled with position: absolute and inset: 0 by default, which will make them the same size as the textarea, including the textarea’s padding. Overlays also inherit pointer-events: none and user-select: none.

Without a z-index, the overlay will be above the textarea, but beneath the syntax highlighted code. z-index: -1 will pull it behind the textarea, while z-index: 1 pulls it in front of the code and the cursor. z-index: 3 pulls it in front of the line numbers.

You can also make a class that implements Extension if that’s preferred.

Plain functions can also be extensions. These functions won’t be called again when the editor’s options change.