A lightweight, drop-in textarea highlighter for highlighting content blocks within publishing apps.
-
Clone the repo
-
Install dependencies:
npm install
-
Run the development server:
npm run dev
-
Access the Example editor
-
Run tests
npm run testE2E tests (using Playwright)
npm run e2e-test
The editor can be used as a "drop-in" replacement for textareas, allowing Content Block embed codes from Content Block Manager to be highlighted.
It works by overlaying a transparent textarea on top of a styled <div> that contains the highlighted content. This ensures that standard textarea behaviour is maintained while providing visual highlighting.
To initialise the editor on a textarea, add the data-module="content-block-highlight" attribute:
<textarea data-module="content-block-highlight"></textarea>Then initialise the Javascript:
import { ContentBlockEditor } from "content-block-editor";
ContentBlockEditor.initAll();You can see a demo of the work so far here
In future, we'd like to provide previews of the content blocks when the user hovers over an embed code.