A framework-agnostic WYSIWYG / Markdown editor, shipped as a
<km-editor>Web Component on ProseMirror.
@keenmate/web-editor is a custom element (<km-editor>) that gives you one
editable document with Markdown, HTML, and JSON as import/export formats at the
edges. It's built on ProseMirror and the shared
@keenmate/web-components-core runtime (shadow DOM, adopted styles) — the same
model as the rest of the Keenmate component line. Works in React, Vue, Svelte,
Blazor, or plain HTML.
Headline features:
- Single document model — Markdown / HTML / JSON are just the I/O lens, switchable without rebuilding the content.
- Four view modes —
edit,split(editor + live output),preview(read-only), andinline(a floating card that can anchor to a page element). - A command-driven toolbar that docks to any edge, a floating selection toolbar, a right-click context menu, and a status bar with live word/char counts.
- Plugin-assembled — links, images, tables, and code highlighting are first-party plugins; you can add your own.
- Framework-agnostic: declarative attributes for the simple case, a small imperative API for dynamic content and events.
Upgrade guide: the 1.0.0-rc01 release notes; full list: the CHANGELOG 1.0.0-rc01 section.
- First release — one document, three lenses — This is the first version of
@keenmate/web-editoron npm, so there is nothing to migrate.<km-editor>holds one ProseMirror document;content-format(markdown|html|json) only picks the lens for I/O, so switching it never rebuilds the content. Thevalueattribute is the initial content and thevalueproperty the live content, like a native input;getMarkdown()/getHTML()/getJSON()read a fixed format. HTML and JSON round-trip losslessly; Markdown import does not parse tables back (export writes them as raw HTML). - View modes — edit, split, preview, inline —
view-modeswitches between the editor, the editor next to a live Markdown / HTML / JSON output (a tab list), a read-only preview, and a floating card that tracks the page element named byanchor. The document, selection and undo history survive a mode switch and a DOM move, because the engine is built once and only its live resources pause on disconnect.setViewMode()and the toolbar's Edit / Split / Preview group fireview-mode-changewith asource; assigningviewModeis silent. The split view stacks by the editor's own width (a container query), not the viewport. - Toolbars and menus — core action items — A static toolbar docks to any edge (
toolbar), a selection toolbar floats over a selection, and the right-click menu is coreopenMenu()(a bottom sheet on a phone throughmenu-presentation). Every entry is a core action item, so a click runsbeforeActionCallback→ the item'sonClick→ the command → theactionevent. Tooltips are corecreateTooltip, shortcuts display through coreformatShortcut, and prompts are core/dialogmodals instead ofwindow.prompt. - Plugins and pipelines — commands ARE pipelines —
definePlugin()contributes schema, commands, keymaps, Markdown I/O and toolbar / menu / status items; the first-party set isdefaultPlugins()(links, images, tables, code highlighting) plus the cloud-imageimageBrowserPlugin/imageBase64Plugin. A toolbar button, a key binding andcontroller.runCommand()all fire the same named pipeline, and a plugin can splice stages into any pipeline by anchor. Deferred pipelines get abort / supersede, a pending loader (renderLoadingCallback) and an optional lock (lock-change). - Forms, localization, icons — the suite conventions —
namesubmits the live content through a light-DOM hidden input, andgetValueFormatCallbackformats (e.g. sanitizes) only the submitted value, marking the field invalid when it throws.requiredblocks the submit while the document has no content (validity.valueMissing,errors.required), like a native control. Every UI string is a flatlabelskey (tooltips.bold,headers.linkUrl, …) over English, with the page-widewindow.components.localedictionary,translateCallbackand alocalefor the status-bar counts. Built-in icons are inline SVGs (EDITOR_ICONS); item icons go through corerenderIconandrenderIconCallback. - Theming and accessibility — the shared contracts — Every colour is a
--we-*variable chained to the--base-*contract withlight-dark()fallbacks, dark mode follows the page (ordata-themeon the element), andcustom-stylesinjects CSS into the shadow root;component-variables.manifest.jsonlists every variable. The surface is a named WAI-ARIA textbox, the toolbars are one tab stop with arrow keys, Alt+F10 jumps into the toolbar and Shift+F10 opens the context menu at the caret, and view-mode switches are announced.readonlystays focusable and copyable;disabled(or a<fieldset disabled>) makes the surface inert. - Headless
EditorEngine— build your own UI — The engine behind<km-editor>is exported: ProseMirror view and state, schema, commands, pipelines, serialization and a typed event bus, without any chrome. It takes the element's settings with the element's defaults:new EditorEngine(mount, options), thensetOptions()appliesisReadonly,labels,locale,translateCallbackandinteractionHostin place (document, selection and undo history kept) andgetOptions()reads them back. docs/usage.md → Build your own UI has a minimal own-toolbar example.
Earlier releases: CHANGELOG.
- 🧪 Live examples — the hosted example site (basic usage, rich content, plugins, the pipeline lab, and the playground).
- 📘 Pipelines guide — how pipelines work, with diagrams.
- 🛠 Usage — the full API: attributes, events, methods, labels, forms, extending,
the headless
EditorEngine. - 🎨 Theming · ♿ Accessibility · 🧩 Examples — every example page and section.
- 📝 Changelog — every change, per version.
- 📚 Examples guide — the example-site convention.
npm install @keenmate/web-editorDeclarative — just attributes:
<script type="module">
import '@keenmate/web-editor';
</script>
<link rel="stylesheet" href="@keenmate/web-editor/style.css" />
<km-editor value="# Hello" content-format="markdown" toolbar="top"></km-editor>Programmatic — dynamic content + events:
import '@keenmate/web-editor';
const editor = document.querySelector('km-editor');
editor.addEventListener('ready', () => editor.focus());
editor.addEventListener('change', (e) => {
console.log(e.detail.value, e.detail.contentFormat);
});
// …or the camelCase twin, called with the same detail:
editor.onChange = ({ value, contentFormat, controller }) => console.log(value, contentFormat);
editor.setValue('## New heading', 'markdown');
editor.value; // live content in the active `contentFormat` (the `value` attribute is only the initial content)
editor.getMarkdown(); // live content as markdown, whatever `contentFormat` is
editor.controller.runCommand('bold'); // the public facade (also on every event detail)Every attribute is also a property (view-mode ↔ el.viewMode); every event bubbles and has a
camelCase twin (change ↔ el.onChange, called with the same detail). The full reference is
docs/usage.md:
- Attributes and properties —
value,content-format,view-mode,toolbar,statusbar,readonly,disabled,labels,locale,name, … - Events —
change,ready,view-mode-change,lock-change,value-format-error,action - Methods —
getMarkdown()/getHTML()/getJSON(),setValue(),setViewMode(),focus(),controller,plugins - Labels (UI strings, i18n) · Forms · Responsive rules
- Extending — plugins, toolbar / menu items, icons;
Build your own UI — the headless
EditorEngine
Shadow-DOM scoped; dark mode follows the page (or <km-editor data-theme="dark">). Re-theme with
--base-* on :root (every Keenmate component follows) or --we-* on the element:
km-editor { --we-accent: #7c3aed; --we-min-height: 320px; }Variables, dark mode, custom CSS in the shadow root, the loader, motion: docs/theming.md.
Modern evergreen browsers: Chrome/Edge 123+, Firefox 128+, Safari 18+ — the floor of the stylesheet's
light-dark() and relative-colour (oklch(from …)) fallbacks. No polyfills are shipped.
npm install
npm run dev # examples hub + pages on http://localhost:12700
npm run build # CEM analyze + library build (dist/)
npm test # unit tests (Vitest)
npm run test:e2e # e2e tests (Playwright)The example site (hub + per-feature pages) runs on
@keenmate/web-components-devkit:
npm run build:examples produces the static dist-examples/ site, and make image-build packages it with nginx. make lists every target.
Authored and maintained by Keenmate s.r.o..
The component ships standalone with sensible light/dark defaults;
when mounted inside Pure Admin — or any
host that publishes the --base-* taxonomy via
@keenmate/theme-designer — it adopts the host's colors,
typography, and sizing automatically. There is no runtime
dependency on Pure Admin; the integration is opt-in via CSS
variables.
Follows the BlissFramework component guidelines for structure, theming, color-scheme, and accessibility.
MIT © Keenmate s.r.o. — see LICENSE.