The editing model and architecture of the editor. Status: draft, 2026-10-18. Items marked (open) are still to be decided here.
Engineers, finance people and other knowledge workers who do their work in
Word and Excel, not programmers. The editor must be as approachable as Word
and Excel. Writing raw Texl with <% %> tags stays possible for power users,
but nobody has to.
A document is a vertical stack of cells, the way an Excel sheet is a grid
of cells. It looks like lined paper: each line is a cell, ruled below by a
soft gray line (--texl-line), at least one line high and taller when its
content needs it.
The sheet has a fixed number of lines (rows, 100 by default), or more if
the document has more cells. Lines below the last cell are empty and not
stored. Writing in one adds it to the document as a rich cell,
together with empty rich cells for the empty lines above it, so it
stays where it was written. Inserted cells are rich too (S9). Later, a
configuration file may let the user choose this default type.
--texl-margin-line) rule a margin on each
side of the cells, as on legal paper. The cells fill the middle column.
<!--[ ... ]-->) in a cell’s source is
a comment of that cell, so comments follow the cell when it moves.
Other HTML comments are ignored. To the editor a comment is just a string; a host
may give it a structure (author, date, thread) with a syntax of its
own. The right margin shows a comment icon with their number; a click
on it fires comments-click with the line number and the comments as
a list of strings; Shift+F2 does the same for the selected line, also
when it has none. Showing them is up to the page (the demo lists them
beside the sheet until another line is selected: the editor fires
selection-change with the selected line). In the text editors,
comments are written as <!--[ ... ]-->; Shift+F2 inserts one. In a
rich cell Shift+F2 opens a field and adds the comment at the end of the
cell. (open) Editing a comment outside the source.cell-menu (cancelable) with the line, its cell’s name and the point
to open a menu at; the page shows the menu (Stilo: editor/cell,
S29). A cell being edited keeps the browser’s menu (spelling, paste).
In read-only mode the name of a cell read without one is not given
(selection neither): the editor’s name for it is random and never
written, so a host could not anchor anything to it.--texl-margin wide (6rem); they are the CSS parts
left-margin and right-margin.
(open) The layout on narrow screens.Revisions, releases and permissions belong to Papiro (the platform), not to Stilo. Comments are stored in the document (see above); how they are shown, and any structure they have, is up to the platform.
| Type | Edit mode | Status |
|---|---|---|
text |
Texl template shown as HTML; Swan highlighted in <% %> tags, Mod+E inserts one |
Boilerplate |
markdown |
text with Markdown: highlighted in the editor, turned into HTML for display |
Boilerplate |
table |
A grid where each table cell’s Texl source is edited in its own field; shown as the rendered table | Ready for the MVP (2026-10-31): a Markdown pipe table (O5) edited as a grid of fields |
formula |
One tag, edited as its expression without the <% %>, shown as its output |
First version |
data |
“Data table”: a table of values (stilo.dataframe), edited as a name and a grid of Swan expressions, shown as the table the library renders |
First version (2026-11-09); replaces the dropped spreadsheet idea |
chart |
“Chart”: a chart drawn by the Stilo library (stilo.charts.line), edited as a form: chart type, X and Y values (formulas giving lists), axis labels and title (plain text) |
First version (2026-11-10) |
figure |
A parametric figure | Idea |
ai |
A prompt from which AI writes the cell’s Texl | Idea |
rich |
WYSIWYG, with a toolbar; formulas as chips that show their value (see Rich text below) | Default type of new cells; first version |
Other formats for raw templates (e.g. LaTeX) are possible later as cell
types built on text, as markdown is.
Formulas are <% %> tags inside a text or markdown cell, inserted
with Mod+E, as fields in Word (parent D11). A cell that is one tag and
nothing else can also be a formula cell (2026-10-30): its source stays
that plain tag, edited without the delimiters. The reasons D11
dropped the older expression cell are answered by the shape rule (see
Editing model): the type is offered only for a source that is one tag, and
an expression containing %>, which would split the tag, is not
committed. Files with <!--% expression %--> still open, as text with
their type kept, like any unknown type.
Decided 2026-11-07 (S9). The rich cell is what a Word user expects: bold is
bold, a title is a title. It shows its output as a markdown cell does, and in
edit mode a ProseMirror editor takes CodeMirror’s place, with the same typography.
markdown cell, so changing between the two
types converts nothing. Underline, sub- and superscripts are inline HTML (<u>,
<sub>, <sup>); <strong>, <em> and <del> are written where Markdown’s
delimiters would not work (x<strong>"q"</strong>y).table cell does that). Repeated empty paragraphs collapse: Markdown has
none, and empty lines of the sheet make the room.<% L = 6 %>, shows a small
ƒ; a new or changed one shows its expression until the cell is committed. A
click, or Enter when it is selected, opens a field for the expression; Mod+E or
typing <% inserts one. A tag whose output is Markdown shows as one chip.$ makes one.rich cell with such a source (edited by hand) is edited as Markdown and must be
accepted to commit. Text the user types cannot become a tag or a marker: <% is
written <%.# , - , 1. , > and three backticks
format the line. Arrow keys stay in the cell; Mod+Enter commits, Escape discards.preventDefault on Escape and
Enter, so the cell handles the keys that leave edit mode itself.The rendered document reads like a well-set engineering report
(2026-11-09, chosen among five fonts, three table and three caption
styles, after an engineering report set in Verdana; it replaces the
Literata choice of 2026-10-30): Atkinson Hyperlegible Next for text,
headings and table headers alike, a wide, open sans with a large x-height
like Verdana and unambiguous shapes (1 l I, 0 O), at 15.5 px with line
height 1.6. Paragraphs and list items are justified, with automatic
hyphenation where the browser has it for the page’s language. Tables span
the full width less a small margin on each side (--texl-table-inset,
1em), columns sized by their content; they are ruled as in print (a strong
rule above and below, a thin one under the header, hairlines between
rows) with
tabular figures, so numbers line up. A table’s caption is an HTML
<caption> element, with no Markdown syntax of its own: written on its own
line right after a Markdown table (or right before it), it is moved into
the table when the cell renders (captionTables in markdown-cell.js;
the HTML parser would otherwise drop it). It shows below the table,
left-aligned with it, in the text colour. For now only markdown cells
accept such a source: table and rich cells refuse it. Sub- and
superscripts do not open up the line. Equations are set at 1.08 times the
text size (--texl-math-size), not KaTeX’s 1.21: the text font’s x-height
is larger than KaTeX’s, so its letters and digits stay close to the
text’s.
The styles are the cells’ (.view in TexlCell), so every cell type
shares them; a host changes the fonts with --texl-font,
--texl-heading-font (defaults to --texl-font) and --texl-font-size,
and loads the font files itself (Stilo bundles them, so it works
offline). Edit mode keeps the
monospace font (--texl-mono).
A document is still one Texl text file. Each cell starts with a marker line, an HTML comment that the editor recognises:
<!--{ bek4 : markdown }-->
# Beam check
<% L = 6, q = 12.5 %>
<!--{ mom3 : markdown }-->
<% q * L ^ 2 / 8 %>
<!--[ Anna: check the load combination. ]-->
<!--{ name : type }--> on its own line. The cell body is
everything up to the next marker line.<% to the first
%>; a <% with no %> after it is text. A line that a tag touches at all
is not a marker either. So a <% left open in a file merges the cells down
to the first %>: the file is unchanged, the types of the merged cells do
not apply until the tag is closed, and the source shows where the problem
is. Before this, the marker still started a cell whose output went missing.<% left open above a %>, and a new %> below a lone <%. A lone <%
with no %> below it stays valid text.#bek4): four lowercase letters and digits, compared without case. The
editor gives one to every cell with a marker that has none (new cells,
markers written as <!--{ type }-->), unique in the document: a
syllable and a digit (bek4), easy to remember, without the look-alikes
l, 0 and 1. Pasted cells whose names are in use get new ones, so a
copy never clashes, while a cut and paste keeps them. The name is not
shown in the editor.name-conflict with the clashing names and their lines.text cell without marker, so any plain
Texl file opens in the editor. It has no name until it gets a marker
(when its type changes or a cell is inserted above it).<!--[ ... ]-->, are the comments of the cell they are
in. Other HTML comments (<!-- ... -->) are neither markers nor
comments: they are part of the source like any other text.text and their type is kept on save.texl.import) without
the editor. The markers pass through rendering as HTML comments: invisible
in Markdown/HTML output, visible in other output formats.<!--% type %--> (or <!--% name | type %-->), open
too: they are saved in the new form with a new name.<!--{ bek4 : formula | hidden }-->. hidden is the first (2026-11-09,
S13); options the editor does not know are kept as written.<!--{ bek4 : table | header=1 }-->).After every committed edit the editor renders the whole document, as the
document at its URL (url), with one engine.render(url, source): exactly
what any other Texl host renders, imports included. Imports resolve against
the document URL and are fetched again on every rendering, so a changed
library shows on the next one. The names of earlier cells are in scope,
since Texl evaluates the document top to bottom in one scope.
The rendering is then split into the cells’ outputs at the places of the cells’ markers, which render to themselves (HTML comments without tags):
texl.import(...) ~> (lib -> lib.text). Searching for the marker went wrong
when that output held the marker of a later cell. Options considered:
replacing the markers with random tags of the same length before rendering
(works, but the rendered source then differs from the document, which errors
had to undo, and short markers leave little room for randomness).outputSpans still handles one, for pages that pass their own
cells: the text goes to the last cell whose marker is outside a tag, and the
swallowed cells show no output.markdown output is first turned into HTML with marked.markdown and table cells (2026-11-07): LaTeX between
$...$ in the text, or $$...$$ on lines of their own, typeset with
KaTeX (HTML output, web/src/editor/math.js). They are read after Texl
has rendered, so a tag inside one shows its value:
$\sigma = <% M / W %>$. In the UI they are “equations”: “formula” means a
<% %> tag. Choices:
$
has no white space after it, the closing one none before it and no
digit after it; \$ is a plain dollar. An equation has no blank line.| inside an equation still ends the table cell; write
\vert.stilo render and imports see the LaTeX as text: the file format does
not change.doc.data,
the names at the end of the document, not the names visible to each cell.
Options: the names of doc.data filtered by the cell where they are first
bound; a separate context render of the cells above the edited one (no
imports there); a Texl API for the names at each tag.[lib](lib.texl)) resolve from the folder of
the document showing them, because the app’s page address is the document’s
public address. Text from an imported document is part of the document
showing it, so its relative links resolve from there too. The uri that
texl.import returns lets an author build the right address.<texl-editor> at an address other than its
url gets links resolved against the page. The fix, when an embedder needs
it, is to resolve them against url in sanitizeOutput.Plain JavaScript (ES modules, JSDoc types) and Lit web components. The architecture page describes the modules in detail; this section keeps the outline.
<texl-editor> the app: document, navigation, rendering
├─ <texl-cell-text> one element per cell, by type
├─ <texl-cell-markdown>
└─ <texl-cell-…> custom cells from third parties
all extend TexlCell base: modes, layout, commit protocol
TexlCell (web/src/editor/texl-cell.js): base class. Switches between edit and
render mode, provides the common layout, and reports a committed edit with
a cell-change event carrying the new Texl source. Subclasses implement
fromTexl(), toTexl() and renderEditor() (the base only shows a
“no editor” notice). renderView() rarely needs overriding: the base
renders output as HTML, sanitised with DOMPurify.TextCell provides the text editor, a CodeMirror 6 view that exists only
in edit mode and keeps input up to date (without the line break that
ends the cell body, which belongs to the file format and is added back).
Its languageExtensions() give the editor its language: Swan
highlighting inside <% %> tags, Mod+E to insert a tag and
Shift+F2 to insert a comment (web/src/editor/swan.js). MarkdownCell extends it with Markdown highlighting
(tags stay Swan, Markdown does not look inside them) and renders its
output as Markdown.web/src/editor/registry.js): registerCell(CellClass) maps the type in the
marker to a custom element (texl-cell-<type>). This is the extension
point for developers’ own cells.<texl-editor> (web/src/editor/texl-editor.js): parses the file into cells
(web/src/editor/document.js), renders the document and splits the
rendering into cell outputs, handles navigation and
edit mode, and serialises the cells back. It is a web component itself, so
it can be embedded in other apps and later in the OnLabs platform.= (formula), t (text),
m (Markdown), T (table) and d (data table, 2026-11-09) change the selected line to that type and
edit it, as = starts a formula in Excel. On a line of that type
already, the key edits it, as Enter does; if the type does not accept
the line’s source, nothing changes and the line shows the reason the
type menu shows (“Needs a table”). The key itself is not typed into the
cell. With several lines selected, it acts on the active line alone.
A cell class sets its key (key, not inherited); the type menu shows
it next to each type.text cell. Paste replaces the
selected cells, as in Excel, and selects the pasted ones. The editor
handles the browser’s clipboard events rather than the keys, so the old
Ctrl+Insert, Shift+Insert and Shift+Delete copy, paste and cut too, and
text selected with the mouse is copied as usual.value clears the history. While editing,
these keys undo inside the cell.markdown or text cells at the end of
the document are dropped, as they look like the empty lines below it.markdown or text lines. Cell
classes give the menu their label and icon.formula cell (one tag, edited without the delimiters) is a
first version, started with = (see the type keys above); still open:
Mathcad-style display (“M = 56.25”), units.
Any of these must keep the formula a plain tag in the source.table cell stores a
Markdown pipe table and edits it as a grid of plain fields, one per
table cell, each showing that cell’s Texl source (Tab, Shift+Tab, ↑/↓;
Tab in the last field adds a row; buttons insert and delete rows and
columns). Outside edit mode it shows the rendered table. Three buttons,
as in Word, align the column of the current field left, centred or
right (:--, :-:, --: in the delimiter row); the pressed one shows
the column’s alignment, and a column without alignment (---) counts as
left and keeps its delimiter when set to left. A source that is not a
table is edited as Markdown text, and an unchanged table keeps its
source as written. Decided 2026-10-31 (O5): the table stays a Markdown
pipe table, and each table cell is ordinary Texl template, with
expressions between <% %> (no =); there are no references to table
cells (no column formulas, no A1 references): a value needed elsewhere
is labelled in its expression. So no renderer helper functions are
needed. Syntax highlighting in table cells is a nice to have, after the
MVP.data cell
stores one formula, <% loads: stilo.dataframe {columns: [...], rows:
[[...], ...]} %>, written one row per line, and shows the Markdown
table that the Stilo library’s stilo.dataframe renders through its
__text__ hook. In edit mode: an optional name (a Swan name; without it
the cell writes no label, shows the table, and cannot be referred to),
and a grid (shared with table: GridCell) whose header row holds the
column names as plain text and whose other fields each hold one value
as a Swan expression: 120, "ULS-1", 1.35 * Fx_k. An empty field is
"". No =: every field is an expression, so text needs its quotes.
Rows and columns can be inserted and deleted anywhere: the values do
not refer to each other (no A1 references), which is what made the
spreadsheet idea messy. Why row by row: Swan enumerates namespace
members sorted (column order would be lost), lists drop () (an empty
value would shift the values after it), and headers must be free text.
Checking values: a syntax error inside a Swan list makes the whole
expression undefined (Texl 0.10; before, it dropped the item silently),
so the table would vanish: each value is checked as
it is typed: by its text (no %>, no comma outside brackets: write a
tuple as (a, b)) and by the browser’s Texl engine, in an empty
context, as the member of a throwaway namespace beside another member
(nspace.size {x__: (value), y__: 1} must be 2). A wrong field is
outlined, with the reason as its tooltip, and the cell refuses to commit
until it is corrected (a commit waits for checks still running). A value
that is merely undefined, such as 1 + "a", passes and shows as
[[Undefined]] in its table cell; such values are not listed in the
errors pane (S7: they are not returned by the tag). A column name
cannot contain " or %> (Swan texts have no escapes); nor can a text
value. A source of another shape (edited by hand: comments inside the
tag, other members) is edited as text. The import: when a data
table is first written with content and no cell mentions
~/references/stilo.texlz/index.texl, the editor adds a hidden formula cell with the
import at the top (S12, S13).<texl-form> (texl-form.js), so every such
cell looks and works the same: one line per field, a fixed description
on the left, an input on the right. The lines are fixed (no lines the
user adds, no editable descriptions: the planned definitions cell, which
needed them, was dropped on 2026-11-10). Field types: text (free text,
saved as a Swan text "...", so no " or %>), choice (a drop-down,
saved as a text), number, and expression (Swan source, checked as it
is typed like the values of a data table: expression.js). A form cell
(FormCell, cells/form-cell.js, not a type itself) stores one tag
applying a function to the namespace, <% stilo.charts.line {x: ..., y:
...} %>, written one member per line in the order of the fields; an
empty field writes no member, a required one refuses the commit. A
drop-down on the first line chooses the kind (the function); changing it
keeps the fields the kinds share. Tab and ↑/↓ move between fields;
Mod+Enter and Escape commit and discard, as everywhere. A source edited
by hand into another shape (unknown members, a text field holding a
formula, comments inside the tag) is edited as text.chart cell is a form cell
whose kinds are the functions of stilo.charts (only line for now),
each returning an SVG image (texl-lib/charts.texl), so a chart renders
without the editor (stilo render, other Texl hosts). The image has a
fixed 16:9 viewBox and spans the cell’s width: its text scales with it
(Swan cannot know the width; accepted 2026-11-10). Axes and text use
currentColor, the line --texl-accent, so both themes work. X and Y
are formulas that give lists, typically columns of a data table; the
labels and title are plain text (not formulas: familiar, and enough).
The chart has no name: it is an end product. Like the data table, it
requires the Stilo library. Later: more series, other chart types
(each a kind of the drop-down and a function of stilo.charts).table a
Markdown pipe table, formula one tag; text and markdown accept any
source. Each type has accepts(source); white space and HTML comments
(cell comments among them) around the content never make it refuse a
source, and an empty source (only those) is accepted by every type, so a
new or empty cell can take any type. The menu offers a type only if it
accepts every selected cell; the others are greyed out with the reason.
So a type change never converts content (D11 stands on that point).
A structured cell refuses to commit a changed source that fails the
round-trip check (e.g. %> in a formula, also inside a string): it
stays in edit mode with a message, as Excel does; Escape discards. A
cell whose source lacks its type’s shape (edited by hand) is edited as
text, and commits only unchanged or once it has the shape.
Options considered (2026-10-30): O1 no type change, or only on empty
cells; O2 change to text or Markdown always allowed; O3 change allowed
only if the target type can parse the source (chosen, with O2 as its
case for types that accept everything); O4 no formula type, a cell that
is one tag shown as = expr (not chosen: a formula type under O3
instead); O5 tables as Markdown pipe tables (the current prototype,
decided with the table storage); O6 explicit “Convert to…” commands that
transform the source (e.g. a list into a table), undoable but not
lossless: later, per type, when a real case asks for it.
A cell cannot keep a stray marker line outside a tag: the commit splits it
(see File format).<% %>
tag, E for expression. It replaces Ctrl+Space, which switches the input
source on macOS and is the usual autocompletion key, kept free for that.
Mod+E is two keys on every keyboard layout; while editing a cell it
overrides the browser’s search shortcut.[[Undefined]], and the right margin counts them per line. A
click opens it in an Errors pane: description, source line, causes and where
it shows, as “Cell 3, line 12”: in this pane a row is a cell, and a line is a
line of text within it (left out when the cell has only one). A double click still edits. What counts as an error: S7 in
DECISIONS.md. Underlining the failing position in the source while editing
is still to do: formula and table cells need their positions mapped, and
pos is a single point.