The mishka_cms_builder package
v0.0.3
mishka_cms_builder is the visual editor of Mishka CMS: a package that edits pages, layouts, components and error pages on a live canvas. It was split out of mishka_cms_core in core version 0.0.3 and it is optional. This page says what the package does, how a host or an extension adds it and what works without it.
What the package does
The package holds the editor itself, the admin pages that open it and the records it keeps.
- The editor. A canvas, a palette of blocks and components, a Layers tree and the Studio panels. It places a block by drag and drop and edits text in place. See Build a page in the visual editor.
- Studio. Design tokens that export as Tailwind, CSS variables, JSON or Elixir, component presets and the UI kit registry. See Reuse work with snippets and design tokens.
- History. Undo and redo, and a timeline of every edit with restore points.
- Review notes. Notes pinned to a node, with
@mentionsthat notify the person named. See Share a draft and collect comments. - Snippets. Save a selection and insert it again. An extension can ship a snippet that is installed with it.
- The Assistant rail. A tab that sends a request to a model you connect. See Connect a model to the editor's Assistant.
The package keeps its records in four tables: page_builder_events, page_builder_snapshots, page_comments and builder_snippets. The editor's history also appears in the activity log of the CMS.
Add it to a host
A project cloned from the Mishka CMS repository already has the editor. To add it to a host of your own, four things change:
- The package, in
mix.exs:{:mishka_cms_builder, "~> 0.0.3"}. MishkaCmsBuilderWebinconfig :mishka_cms_core, extensions:, andMishkaCmsBuilderin the host'sash_domains. Addconfig :mishka_cms_core, builder_strict: config_env() != :prodtoo, so the editor's strict checks run in development and test.- The JavaScript import in the admin's
app.js:import BuilderHooks from "mishka_cms_builder", spread beside the core's hooks. - The tables:
mix ash.codegen add_cms_builderandmix ash.migrate.
The host adds no supervision child and no route. The package starts its own processes, and its routes come from extension_routes(:admin_standalone) inside the admin session of the Mishka CMS router. Add the visual editor to your own host walks through each step.
The package needs Elixir 1.20 or later and mishka_cms_core 0.0.6 or later.
Permissions
The package adds no permission of its own. A person opens the editor with the permission for the kind of document they edit: admin:dashboard:runtime:page, admin:dashboard:runtime:layout, admin:dashboard:runtime:component or admin:dashboard:runtime:error_page. The permission admin:dashboard:code opens every kind. Any one of these also lets the person write the editor's own settings, so a page editor needs no admin:dashboard:setting.
The editor opens from the Pages, Layouts, Components and Error pages dashboards, under /admin/dashboard/runtime/builder/:section.
Settings and events
These settings belong to the package:
| Key | What it holds |
|---|---|
cms_builder.studio.* | The Studio switches: registry_source, sync_tokens, lock_tokens, license_token, dark_pair and applied_preset. |
cms_builder.preset.<component> | The presets of one component, for one site. |
notify.cms_builder.page_comment.mentioned | The site's switch for the notification sent to a person named in a review note. |
notify.pref.cms_builder.page_comment.mentioned | The same switch for one person, in their notification preferences. |
An extension can tell the author about one placed component on the builder:component:notes event: a product block whose product was archived, a list pointed at a category that is gone. The editor draws the notes on the component's frame, in the Inspector and in the Audit rail. A published page never asks.
The package answers these events of the core: runtime:document:editor_url, runtime:provision:snippets, activity:sources, settings:register, sidebar:menus and runtime:after_module_compile. It fires cms_builder:page_comment:after_<action> and cms_builder:snippet:after_<action> for review notes and snippets, and the builder:* events a plugin for the editor listens on. See Plugin events and Visual editor keys, commands, blocks and starters.
What works without it
Pages, layouts, components and error pages are written, checked and compiled the same way with or without this package, because the core owns the model of a page and the rules every page must meet. A CMS that does not install the builder has no visual editor:
- The admin keeps the code editor, and a create menu opens the form.
- The dashboards draw no button that opens the editor.
- History, review notes, snippets and the Assistant belong to the editor, so they are not there.