Install
Aa is one package, @0001-labs/aa. It brings its own styles, as a Design system 1 component does: there is nothing to import beside the script.
npm install @0001-labs/aaThe element
Section titled “The element”Define <aa-editor> once and put it on the page:
import { defineAaEditor } from '@0001-labs/aa'defineAaEditor()<aa-editor placeholder="Write" toolbar></aa-editor>The element on a page
An <aa-editor> with the toolbar, and nothing else configured.
What it stores
value is the Markdown, and input fires on each change a person makes:
const editor = document.querySelector('aa-editor')!editor.value = '# A note'editor.addEventListener('input', () => save(editor.value))| Attribute | What it does |
|---|---|
toolbar | Shows the toolbar over selected words |
placeholder | What an empty editor says |
readonly | The text can be read and selected, not changed |
correct="off" | Turns correction while writing off |
Set options before the element is connected for everything else: atoms, commands, files, AI and comments. See Methods and events.
From code
Section titled “From code”createEditor(host, options) is the same editor without an element. It draws into host and returns the editor:
import { createEditor } from '@0001-labs/aa'const editor = createEditor(host, { value: '# A note', toolbar: true, onChange: markdown => save(markdown), onFiles: files => upload(files),})Call editor.destroy() when the editor leaves the page, to release its listeners, menus and atoms. Every option is on Options.
Light DOM
Section titled “Light DOM”The editor is drawn in the page’s own DOM, never a shadow root, so the page’s rules reach it. Its look comes from aa.css, which the first editor puts first in the page’s head (or the shadow root it is in), so the page’s own rules come after it. It is drawn from Design system 1’s --ds-* tokens with their values as fallbacks: a page without Design system 1 still gets every measure. See Styling.
Aa carries two fonts: Inter Arrows, so arrows are always Inter’s, and Aa Mono for code. They come inside the script with the styles. The package keeps them as files in src/fonts/ too, for a page that imports @0001-labs/aa/aa.css itself: one that wants the rules before any script runs, or whose Content Security Policy allows no inline style or data: fonts. The editor then brings no second copy.