Skip to content
Anjunar/ DOCS

Extensions

Everything beyond the kernel is an extension: node types, commands, transforms, rules and state fields. The resolver checks them all before a session exists.

Resolving

One list, checked up front

ExtensionResolver rejects duplicate extensions, missing dependencies, cycles, duplicate wire names and conflicting replacements before anything is built. A failed install unwinds what was installed.

scala
val generator = NodeIdGenerator.sequential("doc") val history = new History(HistoryConfig.default) val resolved = ExtensionResolver.resolve(Vector( RichText(generator), ListExtension(generator), LinkExtension(generator), CodeExtension(generator), ImageExtension(generator, MediaUrlPolicy.default), TableExtension(generator), history )).fold(errors => sys.error(errors.map(_.render).mkString("; ")), identity) val session = EditorSession.create(document, resolved, resolved.sessionConfig())

This is the configuration the live editors on these pages run with.

Features

What each extension brings

Feature modules are headless. They know nothing of HTML or Markdown; ember-standard is the one place where node types and renderers meet.

RichText(generator)
Paragraphs, headings, quotes, breaks and the five marks.
ListExtension(generator)
Ordered and unordered lists, indent and outdent.
LinkExtension(generator)
Inline links with a validated URL policy.
CodeExtension(generator)
Code blocks with typed language metadata.
ImageExtension(generator, policy)
Reference-based media as inline atoms.
TableExtension(generator)
Tables with rectangular cell selection.
History(config)
Undo and redo with explicit grouping.
Own extensions

Declarative contributions

An extension describes what it contributes and does nothing on its own. That is what lets a configuration be resolved and checked on the server.

scala
object CompositionGate extends Extension: val id = ExtensionId("app.composition-gate") override def contribute = ExtensionContributions( preCommitRules = Vector(BrowserInputController.busyRule(compositions)) )