Docs / Guides
Code studio
The Code studio builds websites inside an OpenFini document. It combines two ways of working on the same files:
- a code editor (HTML, CSS, JavaScript and TypeScript, JSON, YAML, TOML, Markdown, LaTeX, SVG, plain text) with an explorer, tabs, search, a command palette, Emmet and completions that know your project — the everyday workflow of a desktop code editor;
- a visual designer: a live canvas at real breakpoints, an element navigator, an element palette, and a style panel with classes, breakpoints and inheritance — the workflow of a visual site builder.
They are not two views of a model. The files are the only source of truth. Every visual action is turned into a minimal text edit of your HTML or CSS (so your formatting and comments survive), and every edit you type is reflected on the canvas immediately. Undo and redo are the editor's own history.
Open it with the Code button in the header, Alt+4, Studio ▸ Code Studio, or ?studio=code.
Getting started#
- New website (File ▸ New, choose Code): pick a template — Blank, Landing page, Portfolio, Blog, Documentation or Link in bio (responsive, accessible, no external requests), or a framework starter that runs without a build step: Tailwind CSS, Bootstrap, Alpine.js, htmx, Vue, Preact, React, Lit, web components, Three.js, a Markdown blog, a Markdown docs site and a PWA. See frameworks.md.
- Open a file or folder: Markdown, LaTeX, JSON, YAML and other text files open from File ▸ Open, drag and drop and Open Folder as a one-file project (Markdown and LaTeX get a live preview). See frameworks.md.
- Import: Import a folder… or Import files… on the start screen, or drag a folder onto the Explorer.
- The project is stored inside the
.ofinidocument (web/files/…) next to your design pages, so one file holds the artwork and the site. Autosave and Save cover both.
Workbench#
| Area | What it does |
|---|---|
| Activity bar (left) | Explorer · Add elements · Navigator · Search · Source Control · Assets · Libraries · Settings |
| Explorer | Create, rename (F2), move (drag), duplicate, delete, upload, download; drop files or folders from your computer; set the home page. Renaming or moving a file updates links to it in HTML and CSS. |
| Editor | One editor tab per file, each with its own undo history. Syntax highlighting, bracket matching, folding, multiple cursors, find and replace, completions (tags, attributes, CSS properties, your class names, var(--…), file paths), snippets, diagnostics. |
| Canvas | The live preview of the selected page in a sandboxed frame. Design mode selects and edits; live preview lets the page behave normally. |
| Navigator | The page's element tree. Click to select; drag rows to reorder or nest. |
| Add | Elements and ready-made sections (hero, feature grid, pricing, FAQ, …). Click to insert after the selection or drag onto the canvas. |
| Style panel (right dock) | Layout, spacing, size, position, typography, backgrounds, borders and effects of the selected element. |
| Settings panel (right dock) | Tag, id, classes, attributes (link targets, image sources, form fields …), text. |
| Console / Problems / Terminal (bottom) | console.log output and runtime errors of the page; HTML, CSS, JavaScript and JSON problems with click-to-jump; a terminal for the project folder (desktop app). |
Switch between Design, Split and Code with the buttons in the toolbar or Mod+Alt+1/2/3.
The visual designer#
- Select by clicking on the canvas or in the Navigator.
Alt+click selects the parent. Selecting an element on the canvas moves the caret to its tag in the code; moving the caret in the HTML selects the element. - Edit text by double-clicking text on the canvas (or
Enter).Esccancels. - Move by dragging an element on the canvas (a blue line shows where it will land) or in the Navigator.
- Insert from the Add pane. Sections bring their CSS with them — inserted once, even if you add the section twice.
- Copy / paste / duplicate / delete / wrap with the usual shortcuts or the right-click menu.
- Margin and padding guides are drawn around the selection (orange / green).
Classes and breakpoints#
The Style panel styles a class selector (like a class-based site builder): select an element, name a class
(or use the one it has) and every change writes declarations to that class's rule in your stylesheet. Elements
without a class get an automatic div-block-style class on their first edit; choose inline to write a style
attribute instead (desktop only).
Breakpoints use a desktop-first cascade:
| Breakpoint | Width | CSS written |
|---|---|---|
| Desktop 1920 / 1440 | 1920 / 1440 px | @media (min-width: …) |
| Desktop (base) | 1280 px | no media query |
| Tablet | 991 px | @media (max-width: 991px) |
| Mobile landscape | 767 px | @media (max-width: 767px) |
| Mobile portrait | 478 px | @media (max-width: 478px) |
Edits at a smaller breakpoint go into the matching @media block of the same rule (created if needed, in
cascade order). A blue dot marks a value set here, an orange dot a value inherited from a larger screen;
click the dot to reset it. Values you have not set show the computed default, dimmed.
Viewport, rulers and zoom#
The viewport bar above the canvas sets the size of the page in CSS pixels:
- Width / height fields: type a number (or
834px) and pressEnteror leave the field;↑/↓change it by 1,Shiftby 10 (100 to 4000 px). The lock keeps the aspect ratio, rotate swaps width and height, and fill height lets the frame use the available height again (the default). - Presets: Desktop 1440 / 1280 / 1024, Tablet 820 / 768 and Phone 390 / 375 / 360 / 320 (generic sizes, no product names). The star saves the current size under a name (Saved sizes, up to 12; stored in the project and as a default for new projects).
- Zoom: Fit, or 25 to 400 %. At 100 % the page is drawn on whole pixels.
- Width slider (280 to 2560 px): drag for quick responsive testing. It snaps to a breakpoint marker within 6 px unless you hold
Alt. - Drag handles on the right, bottom and corner edges of the frame resize it live with a size badge such as "834 × 612". They are
keyboard accessible too (focus a handle, arrow keys ±1,
Shift±10). While dragging, the zoom stays fixed. - Rulers show CSS pixels and adapt their ticks to the zoom. The triangles on the horizontal ruler mark widths where the layout
changes: the editor's breakpoints (blue) and the
min-width/max-widthconditions of every@mediarule in your CSS (amber); click one to jump to that width.
The size and breakpoint are remembered per project. The breakpoint of the style panel always follows the width, so styles you edit
at a custom width are written to the @media block of the matching breakpoint, exactly as before.
Measure tool#
Press M (or the ruler button in the toolbar, View ▸ Measure Tool, command code.measure) and hover over the canvas:
| Gesture | Result |
|---|---|
| Hover | Box model bands (margin orange, border yellow, padding green, content blue), tag and size, lines to the viewport edges |
Hold Alt | Distance to the pinned element, else the selected one, else the parent (red lines) |
| Click | Pins the element (click again to unpin) |
Shift+click | Pins and links to the previous pin with distance lines |
D | Shows the margin and padding values on the bands |
Ctrl+C | Copies the size, for example 320×48px (or click the readout in the viewport bar) |
Esc | Clears pins, then leaves the tool |
Units: px, mm, cm, in, pt, rem, em and % of the parent. Physical units follow the CSS definition (1 in = 96 px); change the ppi basis if you want a different density, or turn on Device pixels to count CSS px × device pixel ratio. While the tool is on, clicks do not select or edit. The overlay is drawn inside the preview, so it scales with the zoom.
How measurement works#
All numbers in the viewport bar, the rulers, the measure tool and the media-query logic are CSS pixels of the page inside the preview frame. By definition they agree:
- Viewport = the configured width × height of the frame (
window.innerWidth/innerHeightinside the page). - Layout width =
documentElement.clientWidth= what awidth: 100%element,%units and the measure tool use. It equals the viewport width as long as the page has no classic scrollbar. A classic scrollbar steals its own width from the layout (15 px on a desktop, a fractional amount such as 15.33 at a device pixel ratio of 1.5), which is why a 100 % wide box used to measure 375 px in a 390 px viewport. The preview therefore hides the root scrollbar by default (scrolling by wheel, touch or keys still works); the Show the page scrollbar button (commandcode.previewScrollbar) shows it again and the readout then says390 × 844 · layout 374.67 (scrollbar 15.33). - Media queries use the viewport width including the scrollbar (
100vw), exactly like a real browser, so breakpoints trigger at the configured width in both modes. - Zoom is a CSS
transform: scale()on the frame box. The page itself is laid out at the unscaled size andgetBoundingClientRectinside the frame is unaffected, so measurements never depend on the zoom; the host divides pointer coordinates by the scale. The device box is not rounded (it used to be), so the frame and its box cannot drift by a pixel. - Units: 1 in = 96 CSS px, 1 mm = 96/25.4 px, 1 pt = 96/72 px;
%is relative to the parent's border box (to the layout width for the root);rem/emuse the computed font sizes. Values are rounded only for display (px 1 decimal, mm 1, cm 2, in 3). Device pixels multiplies bydevicePixelRatioonly when switched on; browser zoom changes the ratio, never the CSS pixels. - Self-check: the bridge keeps two invisible fixed probes,
width: 100%andwidth: 100vw, and reportsinnerWidth,clientWidthand both probe widths (layoutMetrics). The status line next to the zoom showsPhone · 50% · 390 × 844 · layout 390; if the frame ever disagrees with the configured size (innerWidth ≠ width, 100vw ≠ innerWidth, or the 100 % probe ≠clientWidth) a warning sign is added and the tooltip names the failed check. The logic is pure (describeLayoutinengine/web/viewport.js, tests intests/web/viewport.test.js).
Preview and code stay in sync#
Settings ▸ Code studio ▸ Sync highlighting (command code.syncHighlight) controls all of this:
- Preview to code: selecting an element scrolls the editor to its start tag and keeps a subtle line highlight with an accent bar on those lines. Hovering an element in the preview lightly highlights its lines.
- Code to preview: the caret in the page's HTML selects the element in the preview; hovering a line of the page's HTML outlines
the element there. The caret inside a CSS rule outlines every element the rule matches (the selector is evaluated in the
frame with
querySelectorAll; states such as:hoverand pseudo-elements are ignored) and shows a badge "7 elements". - Breadcrumb bar above the editor:
html › body › section.hero › h1. Click selects the element and shows its code; hovering outlines it in the preview. Next to it, Rules lists the CSS rules whose last selector part matches the element's tag, id and classes (a static approximation without combinators or attributes; the preview does the exact match); each chip jumps to the rule.
Text selection in the preview#
Selecting text in the live preview, or while editing text inline (double-click in design mode), selects exactly that text
in the page's HTML in the editor (Split and Code views; in design mode a click selects elements, not text). A selection across
elements selects the source from the first to the last character, tags in between included. The mapping is precise: a character
reference such as & or é is one character on the page and its whole reference in the source, CRLF line endings and
the dropped first newline of <pre> are accounted for.
How: the bridge reports the anchor and focus of the selection as { id, index, offset, data } (the data-of id of the text's element,
the text node's index among that element's text nodes, the offset and the node's text) or { id, edge } for a position between
elements (bridge message textSel, debounced). engine/web/text-map.js aligns the DOM text with the source text of the matching
parsed text node (alignText) and returns the source range; the message is untrusted, so points are validated
(sanitizeTextPoint) and a text that does not match the source exactly (a script changed it, or the page changed meanwhile)
selects nothing. Tests: tests/web/text-map.test.js.
The other way round, selecting text in the page's HTML in the editor highlights exactly that text in the preview (Split and
Design views, with Sync highlighting on) and scrolls it into view when it is off screen. textPointsFor in text-map.js turns
the source range into the same { id, index, offset, data } points (decodeTextMap is the inverse of alignText: references,
CRLF and the <pre> newline), ends inside tags snap to the nearest text in the range and whitespace-only text at the ends is
skipped. The bridge (markText) finds the text nodes, checks their text, and paints the range with the CSS Custom Highlight
API; it never changes the page's own selection, so a selection made in the preview and shown in the editor is not sent back.
The highlight is only sent while the editor has the focus.
Live updates#
Typing in the code editor or editing in the visual designer never reloads the preview unless it must, so the page does not flicker or jump and keeps its scroll position, text selection, focus, form input and the state of its scripts:
| Edit | What the preview does |
|---|---|
| A linked stylesheet the page uses | Hot-swaps its <style> (no reload) |
The page's HTML: text, attributes, elements, inline <style>, <title> | Patches the changed element in place (no reload) |
A script, an inline event handler (onclick="…"), a <template>, the doctype, other files the page loads | Rebuilds the page, restoring scroll position and text selection before showing it |
| Another page, a caret move, a click, a selection | Nothing |
Typing is debounced (about 220 ms in the editor; edits from the visual designer go out at once). An edit made inline in the visual designer is written to the code and the preview is patched, but the text being edited is left alone, so the caret does not move.
How: planPagePatch(old, new) in engine/web/live-patch.js finds the changed source range (common prefix and suffix; an
insertion or deletion is slid to start at a tag), the deepest element that contains it in both versions (the root), and the
renumbering of the data-of ids (ids before the change stay, the ones inside are dropped, later ones move by the difference).
It verifies every other element (tag, position and, outside the root, parent) and asks for a reload when anything does not
match, when a <script>, <template>, <noscript> or inline event handler is touched, or when the doctype changes. The host rebuilds the
preview document as before, parses it with DOMParser (inert) and posts the root element as a plain JSON tree with the plan
(bridge patch, accepted only from the app window's origin, which the host passes in the preview config; the frame never parses
HTML from a message); the bridge rebuilds the tree detached with createElementNS, renumbers the live
ids and morphs the root to its new version with the self-contained morphKit: children are matched by data-of, the rest by
position and node name; text nodes, attributes and moved elements are updated in place; scripts are never re-created; nodes
the page's own scripts added (no data-of) and the inspector's overlay are kept. A frame that cannot apply a patch answers
ok: false and is rebuilt. For a rebuild, the new frame stays hidden until it reports restored (scroll position from the frame
on screen, bridge reportScroll, and the last text selection in live preview mode). Elements the page's scripts created inside
the edited element, and text the scripts changed there, are reset to the source. Tests: tests/web/live-patch.test.js (a small
fake DOM, including a fuzz test that every patched edit gives exactly the new document).
Editing assets in a design studio#
Right-click an image in Assets or the Explorer: Open in Pixel Studio (PNG, JPEG, WebP, ICO) or Open in Vector Studio (SVG)
opens it as its own document, linked to the project file (ui/code/asset-edit.js). File ▸ Save (Mod+S) in that document
writes the image back into the project in its own format at the document's page size; Save Back to Website and Return
(command code.assetSaveBack) also returns to the Code studio. The preview, the Assets pane and exports use the new file at once,
and the website document is marked as changed (save it as usual). Save As still writes an .ofini copy.
- Choosing the command again for a file that is already open switches to that document.
- SVG is rewritten by the SVG exporter: comments, scripts,
<style>rules and features the Vector studio does not model are not kept, and a<title>is added (the opening toast says so). JPEG is encoded again (lossy). - An ICO opens its largest image; saving back writes every standard size (16 to 256 px) up to the image size again
(
engine/export/ico.js), so sizes that were drawn by hand in the original file are replaced by scaled ones. - GIF, BMP and AVIF are not offered (the browser cannot write them back faithfully).
- The link is runtime state: it is not stored in documents. If the website document was closed, or the file was renamed or deleted meanwhile, nothing is written and a message says so.
Linked Proto designs#
A Proto design can be linked to this project (Proto Studio ▸ Code studio link). Then:
- the design writes a DTCG tokens file (default
tokens/tokens.json) andtokens.cssnext to it; edits you make to the tokens file update the design's variables about 0.3 s later, and the design's variable edits come back as one undo step of that file; - its linked layers are written as code between guarded markers (
/* @ofini-proto begin <layer> hash=… */…/* @ofini-proto end <layer> */,<!-- … -->in HTML). Everything outside the markers is yours and is never changed; edits inside a region are kept until the design changes the same region, which is then a conflict you resolve in Proto (keep, overwrite, or compare); - a Proto badge on the first line of every region names the layer (with edited when you changed its code); click it to
open the layer in Proto. Open in Proto (command palette) does the same from the caret or from the element selected in
the preview (generated HTML has
data-proto-idattributes); Sync with Linked Proto Designs syncs now; - the Explorer marks files written by the design: ● in sync, ✎ edited here, ! conflict, ⊘ markers removed.
Code: ui/code/proto-link.js; the sync engine is engine/proto/link.js and engine/proto/regions.js.
Terminal#
The Terminal tab of the bottom panel (Show Terminal, Mod+Alt+T) is a console for the project folder in the desktop app
(decision: ADR 0025; security: security.md):
- It works for projects opened from a folder with File ▸ Open Folder in this session; commands run in that folder. Otherwise the tab shows Open Folder…. The browser version explains that the desktop app is needed.
- One line = one program with arguments, no shell:
npm test,git status,npx eslint .. Quotes group arguments; pipes, redirects,&&, variables and wildcards are refused. Programs get no keyboard input (no prompts, REPLs or editors) and no TTY (color codes are removed). - The allow list, deny list and deny patterns, time limit and output cap of Settings ▸ Artificial intelligence ▸ Terminal apply (shells are never run). The assistant's on/off switch does not: you start every command yourself, and the assistant cannot use this console.
- Built in:
cd(relative,~, never outside the project folder),pwd,clear/cls(orCtrl+L),history,help.Up/Downrecall earlier lines (kept in memory only). Stop orCtrl+Cends the running program; one program runs at a time. - Programs see the files on disk, not unsaved edits of the project.
Code: ui/code/terminal.js (UI), ui/code/terminal-model.js (pure: line planning, history, escape removal; tests in
tests/ui/code-terminal.test.js), running through cmd_run / cmd_kill (src-tauri/src/cmd.rs).
Formatting#
Format Document (Shift+Alt+F, command code.format), Format Selection (code.formatSelection), Format on save and
Format pasted code use the built-in, dependency-free formatters in engine/web/format.js and engine/web/js-format.js. A formatter contributed by a VS Code
extension still takes precedence for whole documents.
| Language | What it does |
|---|---|
| HTML | Re-indents blocks, re-wraps inline text at the line width (a newline between inline items equals a space), wraps long start tags one attribute per line, keeps <pre>, <textarea>, <title>, comments, attribute values and the spacing between inline elements; script and style bodies are re-indented; optional end tags stay omitted |
| CSS | One declaration per line, normalized spacing and blank lines (formatCss); selector lists one per line or on one line, blank lines between rules on or off, hex colors kept, lower or upper case (never inside url() or custom properties) |
| JavaScript | Beautify (default, engine/web/js-format.js): a tokenizer that knows strings, template literals with nested ${}, comments, regex literals and numbers; the printer normalizes spacing, puts statements and blocks on their own lines, keeps short objects inline and breaks long ones one property per line, indents case bodies, keeps } else {, } catch and } while together. Re-indent only (and always for .ts, .tsx, .jsx): re-indents by bracket depth, trims trailing whitespace, collapses blank lines |
| JSON | Pretty print (invalid JSON, comments and trailing commas are reported, the file is left alone) |
| Markdown | Trailing whitespace, hard breaks kept, blank lines around headings, fenced code untouched |
The beautifier's safety rules: after printing, the output is tokenized again and must have exactly the same tokens (string quotes
may change only when the body has no quote or backslash), and every line break between two tokens in the source must still be there,
so automatic semicolon insertion, return and postfix ++ keep their meaning. It never joins lines and adds line breaks only after
;, {, , in broken objects and around }. If a check fails or the file cannot be tokenized (an unterminated string, <!-- in a
script, U+2028), the re-indentation is used instead. Tested in tests/web/js-format.test.js, including every module of the app's own
engine/web, ui/code and core folders (formatted safely and idempotently).
Formatting options (Edit ▸ Formatting Options…, command code.formatOptions, also in Settings ▸ Code studio): a preset and
per-language options with a live before/after sample, stored in the codeFormat preference as { preset, ...values }. Your own
values win over the preset; the preset wins over the editor settings (tab size, Indent with tabs, Formatter line width,
Attribute quotes). Choosing a preset clears your own values.
| Preset | Differs from Default |
|---|---|
| Default | 2 spaces, width 100, 1 blank line, attributes wrapped when too long, quotes and void tags kept |
| Prettier-like | width 80, double quotes in HTML and JavaScript, <br />, lower-case hex colors |
| Standard-like | single quotes in JavaScript, function name (), lower-case hex colors |
| Compact | width 140, no blank lines, attributes never wrapped, <head>/<body> not indented inside <html>, selector lists on one line, no blank lines between rules |
| Spacious | 4 spaces, 2 blank lines, attributes always one per line, braces on the next line (Allman) |
| Tab | Options |
|---|---|
| General | indentation (1 to 8), tabs, line width (40 to 240), blank lines to keep (0 to 3) |
| HTML | own indentation (0 = general), wrap attributes (when too long, always, never), empty elements (keep, <br>, <br />), attribute quotes, indent inside <html> |
| CSS | own indentation, one selector per line, blank line between rules, hex colors (keep, lower, upper) |
| JavaScript | own indentation, style (beautify, re-indent only), braces (same line, next line), string quotes (keep, double, single; a string containing a quote or backslash is never changed), space before function parentheses, short objects on one line |
| Minify | keep license comments (/*!, @license, @preserve), minify inline scripts in HTML |
Minify (code.minify Minify File, in place and undoable; code.minifyCopy Minify into a .min File, writes
name.min.ext next to the file): HTML (comments and insignificant whitespace as in the website export, inline styles, inline scripts),
CSS (minifyCss), JavaScript (minifyJs: comments and whitespace removed; a source line break stays a line break wherever both sides
could end and start a statement, so semicolon insertion cannot change the program; the result is checked token by token and an
unsafe script is left alone) and JSON. TypeScript and JSX are not minified; names are never shortened.
Guarantees, tested in tests/web/format.test.js: formatting is idempotent and does not change the rendered structure (tags,
attributes, collapsed text) of every starter template. Limit: CSS white-space: pre on an ordinary element is not known to the
formatter; the beautifier does not wrap long expressions or call arguments (only objects). The Vibe tool format_file runs the same
code with your options.
Syntax colors, suggestions and hover popovers#
Settings ▸ Code studio, loaded with the editor (ui/code/assist.js, ui/code/editor-settings.js, stylesheet styles/code-assist.css):
- Syntax color theme (also View ▸ Syntax Color Theme…, command
code.syntaxTheme): Follow the interface theme (default) or one of 17 editor themes (Dark Plus, Light Plus, Monokai, One Dark, Dracula, GitHub Dark and Light, Solarized Dark and Light, Nord, Night Owl, Gruvbox Dark, Tomorrow Night, Catppuccin Mocha, Quiet Light, High Contrast Dark and Light; original palettes inengine/web/syntax-themes.js). Every one of the 19 colors (background, text, line numbers, current line, selection, cursor and the token kinds) can be overridden on top of the theme. The theme sets--of-editor-*and--of-syn-*on the editor element only; the rest of the interface keeps its own theme. PreferencescodeSyntaxTheme,codeSyntaxCustom. - Suggestions: on or off (
codeSuggest; off also turns offCtrl+Space), while typing or only onCtrl+Space(codeSuggestOnType), delay (codeSuggestDelay, default 100 ms). Besides the language's own completions and Emmet: words of the file (codeSuggestWords, ranked last) and names from the project (codeSuggestProject): classes and ids of your pages in CSS selectors,querySelector(),closest(),matches(),getElementById()andclassList.*(), ids inhref="#…",forandaria-*references, and the hex colors your stylesheets already use (with a swatch). - Your snippets (
codeSnippets,engine/web/snippets.js): language (or every language), prefix, description and body in the CodeMirror snippet syntax (${1:name},${};Tabmoves between fields). At most 200, a body up to 4000 characters. - Color popover (
codeHoverColors): hovering a hex,rgb(),hsl()or (in CSS and style attributes) named color shows a swatch and a color picker with opacity; picking rewrites the value in its own notation (short hex stays short when possible, comma or space syntax is kept), Write as HEX / RGB / HSL converts it. Inline swatches (codeColorSwatches) sit in front of every color value; clicking one opens the picker. - Path popover (
codeHoverPaths): hovering a local path in a quoted string orurl()(src,href,import, …) previews the file (image with its size, or the first lines of text) with Open, or offers Create file when it does not exist.Ctrl+click(Cmd+click) on a path that exists opens it; elsewhere it still adds a cursor. External URLs,data:URIs, fragments and package names ("react") are ignored.
Pure parts are tested in tests/web/code-assist.test.js. Limits: color detection is per line (no colors across line breaks, lines
over 4000 characters get no swatches); lab(), lch(), oklch() and color() are not recognized.
Split layouts#
In Split view choose the arrangement with the four buttons in the toolbar, View ▸ Split Layout or the commands
code.layout.codeLeft, codeRight, codeTop and codeBottom: code left of the preview (default), code right, code above, or code
below. Automatic keeps code on the left and stacks it above the preview when the workbench is narrower than 760 px; an explicit choice
is never overridden. Drag the splitter to resize (the ratio is remembered separately for side-by-side and stacked layouts,
double-click resets to 50/50) or focus it and use the arrow keys (Shift for bigger steps; Home / End for the limits). Both panes
keep at least 240 px. The layout is stored in the project and as the default for new projects. A detached preview in its own window is
not offered yet.
Code editor shortcuts#
| Action | Shortcut |
|---|---|
| Command palette | Mod+Shift+P (or F1) |
| Quick open file | Mod+P (prefix > commands, # elements, : line) |
| Find / replace in file | Mod+F / Mod+H |
| Find in files | Mod+Shift+F |
| Go to line | Mod+G |
| Expand Emmet abbreviation | Tab (for example ul>li*3, .card>h3{Title}+p, m10-20, df) |
| Format document | Shift+Alt+F (CSS and JSON are rewritten, other languages re-indented) |
| Toggle comment | Mod+/ |
| Move / copy line | Alt+↑/↓ · Shift+Alt+↑/↓ |
| Add next occurrence | Mod+D |
| Toggle sidebar / bottom panel | Mod+B / Mod+J |
| Design / split / code view | Mod+Alt+1 / 2 / 3 |
| Design mode ↔ live preview | Mod+Alt+P |
| Measure tool on / off | M (focus in the canvas or workbench, not in a text field) |
| Viewport width / height field | Enter applies · ↑ ↓ ±1 · Shift+↑↓ ±10 |
| Resize handle / splitter | Arrow keys (Shift for bigger steps) |
| Split layout | View ▸ Split Layout (no default shortcut; assign one in the shortcut editor) |
| Word wrap | Alt+Z |
File types and syntax highlighting#
The Code studio opens, highlights and saves back far more than web files. One table, engine/web/code-langs.js, lists every
text and source-code type with its extensions, exact file names, MIME type, Explorer icon and highlighter; the open dispatch
(core/text-docs.js), save back to the original format (core/source-format.js), the File ▸ Open filters (core/io.js),
languageOf() / mimeOf() / isTextPath() (engine/web/paths.js) and the status bar all read it.
- Web: HTML, Vue, Svelte, Astro (HTML highlighting), CSS, Sass/SCSS, Less, Stylus, JavaScript, JSX, TypeScript, TSX,
CoffeeScript, JSON (also
.jsonc,.json5,.webmanifest), Markdown, XML (also.plist,.csproj,.xaml…), Pug, Jinja, Twig, Liquid, Handlebars. - Scripts and build files: shell (
.sh,.bash,.zsh,.bashrc…), PowerShell (.ps1,.psm1), Windows batch (.bat,.cmd), Makefile, Dockerfile (alsoDockerfile.dev,*.dockerfile), CMake, nginx. - Languages: Python, Ruby, PHP, Perl, Lua, R, Julia, Go, Rust, C, C++, Objective-C, C#, F#, Visual Basic, Java, Kotlin, Scala, Groovy (Gradle, Jenkinsfile), Dart, Swift, Haskell, Elm, Erlang / Elixir, Clojure, OCaml, Fortran, Pascal, Tcl, Verilog, VHDL, shaders (GLSL, HLSL, WGSL), Zig, SQL, GraphQL, Protocol Buffers.
- Configuration and data: YAML, TOML, INI /
.conf/.cfg/.properties,.env(also.env.local),.editorconfig,.gitattributes,.gitignoreand the other ignore files, CSV / TSV, logs (levels and timestamps colored), diffs and patches, plain text (README,LICENSE,.rst,.adoc, subtitles).
HTML, CSS, JavaScript, JSON, Markdown, XML, LaTeX, YAML, TOML and INI are highlighted by the main editor bundle. The other
languages use CodeMirror's legacy stream modes in a second bundle, vendor/codemirror-modes/modes.js (about 84 KiB gzip), that is
loaded the first time such a file is opened and then cached by the service worker; batch files, logs, ignore files and PHP have
small modes of their own in ui/code/languages.js. Offline before that first use, those files open as plain text. The language
names in the status bar come from the table.
Every listed file opened with File ▸ Open (or dropped, or handed over by the system) opens as a one-file project and File ▸ Save
writes it back byte for byte while unchanged, keeping the BOM and line endings (CRLF for .bat) once edited. Names without an
extension (Dockerfile, Makefile, .gitignore) keep their full name. CSV and TSV open as text here; right-click one in the
Explorer and choose Open in Spreadsheet to open a copy in the Office Spreadsheet app (in the Office studio, File ▸ Open opens
them as spreadsheets directly).
Embedding files#
Right-click a file in the Explorer while another file is open in the editor:
- Embed in current file inserts the reference that fits both file types at the caret: an image becomes
<img src alt>in HTML (also Vue, Svelte, PHP and template files),url("…")in CSS,in Markdown,\includegraphics{…}in LaTeX (also PDF and EPS figures) and animportin TypeScript and JSX (bundlers) ornew URL("…", import.meta.url).hrefin plain JavaScript modules. A stylesheet becomes<link rel="stylesheet">in HTML,@import url()in CSS andimport "./x.css"in scripts; a script becomes<script src>(type="module"for.mjsand TypeScript) or animportwith a./or../path (TypeScript drops the.tsextension); JSON becomesimport x from "./x.json" with { type: "json" }; a font becomes a@font-facerule in CSS and a preload<link>in HTML; a web manifest becomes<link rel="manifest">; pages and other files become links in HTML and Markdown,\input{}or\bibliography{}in LaTeX,import a.bfor Python modules, and the relative path everywhere else. Snippets that belong on their own line (<link>,<script>, imports,@font-face) are inserted on a new line with the indentation of the current one. - Inline as data URI inserts the same form with a
data:URI instead of the path, for files up to 64 KiB. - Copy relative path copies the path from the open file to the clicked one.
Drag and drop a file from the Explorer into the editor to embed it at the drop point; hold Alt (Option) while dropping to
inline a small file as a data URI. Each insertion is one undo step. Paths are percent-encoded where they are URLs (HTML, CSS,
Markdown) and attribute text is escaped. The logic is the pure engine/web/embed.js (tests in tests/web/embed.test.js); the
menu and drop handling are in ui/code/embed-ui.js.
Libraries, Markdown and LaTeX#
- Libraries (activity bar, Libraries… in the palette): add, update and remove CDN libraries and import-map entries,
search npm and cdnjs, and Download into project (
vendor/) so the exported site works offline. - Markdown and LaTeX files show a live document preview instead of the canvas, with a formatting toolbar above the editor, a heading outline in the Navigator, and export to an HTML page or print / PDF. The LaTeX preview is a subset converter, not a TeX engine; unsupported commands are marked.
- Completions for Tailwind and Bootstrap classes, Alpine and htmx attributes; Add-panel snippets for Bootstrap, Tailwind and htmx.
Preview and security#
The canvas is an <iframe sandbox="allow-scripts …"> without allow-same-origin. Your page's scripts run, but
they cannot read or change OpenFini, its storage or your documents. A small inspector script is injected as the
first script of the preview; it draws the selection and forwards clicks and keys with postMessage — it is never
part of an export.
- Local
<link>,<script>, images and fonts are resolved from the project; scripts are delivered asdata:URLs (the app's Content-Security-Policy forbids inline scripts, and the preview inherits it). ES modules that import other project files work; circular imports are reported. - Inline event handler attributes (
onclick="…") are converted to equivalent assignments in the preview. - Inline import maps are blocked by the desktop CSP, so the preview resolves bare module specifiers through the page's import map itself (see frameworks.md).
- The desktop app's CSP allows
https:images, fonts, stylesheets and embeds and scripts fromcdn.jsdelivr.net,cdnjs.cloudflare.comandunpkg.com.fetch/XMLHttpRequestto other servers are blocked in the desktop preview; the web version has no such restriction. Forms are not submitted in the preview.
Local folders and Open in Browser#
A folder opened with File ▸ Open Folder (desktop by path, web through the directory picker) stays linked to the disk for
the session (localSources in ui/open-folder.js, never saved in documents). ui/code/local-preview.js polls it
(desktop: the preview_dir_stamps command, web: the directory handle) and reloads changed files that have no unsaved
edits, so the preview updates live. Open Preview in Browser starts src-tauri/src/preview_server.rs on the desktop:
std-only HTTP on 127.0.0.1 (all interfaces only with Allow other devices in the network, confirmed each time), every URL
below a random token, Host header checked, ../backslash/drive/control-character paths refused, symbolic links that leave
the folder not followed, folder must be in the granted fs scope. Unsaved edits are pushed as an overlay; HTML gets a
live-reload script. Port and SPA fallback: Settings ▸ Code studio. The web build opens a sandboxed tab instead.
Pure helpers and tests: engine/web/local-serve.js, tests/web/local-serve.test.js. LaTeX: see latex.md.
Opening folders, archives and pages#
- A folder dropped anywhere (also on the Vector, Pixel or Layout canvas, which no longer tries to place it) opens with
openFolderEntries: a folder with HTML, Markdown or LaTeX becomes one Code studio project (one wrapping folder is the project root), design files open as documents. - A .zip (dropped, or File ▸ Open) is unpacked in memory and opens the same way (
ui/open-drop.js,engine/web/open-plan.js projectFromZip). Protection: entry names with.., a leading/, a drive letter, a backslash or a NUL are skipped (zip slip), as are names that only become safe after normalization; at most 5000 entries, 50 MB per entry and 200 MB in total (declared sizes are checked before inflating and actual sizes after); the archive itself may be 200 MB. macOS metadata (__MACOSX,._*,.DS_Store), dot files,.gitandnode_modulesare skipped. Problems are listed in a toast. - An HTML page with its files: when the dropped files include a page and files it loads (
<link rel=stylesheet|icon|manifest>,<script src>,<img src/srcset>, media, frames andurl()in styles; plain<a href>links do not count), a dialog offers Open together: one website project where every file is placed at the path the page uses (a droppedstyle.csslands atcss/style.csswhen the page links that). Referenced files that were not dropped are named in the dialog. Open separately opens each file as before. - A page dropped alone that loads local files offers Choose folder… (the folder picker, to open the whole site) or Open page only.
Limits: browsers do not give dropped files their folder path, so the app cannot find the other files of a page on its own.
Publishing#
Export ▸ Website (header button or File ▸ Export…):
- ZIP archive — upload to any static host.
- Single-file pages — CSS, JavaScript and images inlined into each HTML file.
- Folder — writes the site into a folder you choose (browsers with the File System Access API, desktop app).
Options: minify HTML and CSS, and generate sitemap.xml + robots.txt from a site address. The export contains
only your project files — no OpenFini code, no preview bridge. Warnings list broken links and missing files.
Design pages can become assets: Assets ▸ Add a design page as SVG or PNG exports a page of the same document into
assets/ — so artwork made in the Vector, Pixel or Layout studio can be used on the site.
Architecture in one paragraph#
app/src/engine/web/ is a pure engine (no DOM) with an offset-preserving HTML parser and CSS parser, source
edits as Change[], the style-panel schema, the preview and site builders, templates, the element catalog and Emmet
(see web-engine.md). app/src/core/web.js is the project model stored in the document.
app/src/ui/code/ holds the workbench: CodeMirror 6 (vendored, one EditorState per file), the preview pane and
its inspector bridge, the explorer, navigator, panels and palette. The module is loaded lazily the first time the
studio is opened, so it adds nothing to application start-up.
Architecture: viewport, measure and layout#
-
Pure logic (unit-tested,
tests/web/viewport.test.js,tests/web/measure.test.js):app/src/engine/web/viewport.js(presets, size parsing and clamping, breakpoint markers parsed from CSS, snapping, ruler ticks, layout resolution, split ratios and splitter keys) andapp/src/engine/web/measure.js(unit conversion, distance guides, box bands, strict validation of boxes received from the frame).measureKit()inmeasure.jsis self-contained:bridge.jsserializes it into the preview frame, so the overlay and the host compute identical numbers. -
Preview pane (
ui/code/preview.js): ownsvw/vh(CSS px;vhnull = fill), derivesbpfrom the width (breakpointForWidth), persistsweb.settings.viewport,zoom,rulers, and emitsviewport,breakpoint,measure. All size changes go throughsetSize/resizeTo(snapping and aspect lock) so the style panel, toolbar and rulers stay in sync. -
UI (
ui/code/viewport-ui.js): bar, rulers (canvas) and handles; styles inapp/styles/code.css. -
Bridge protocol (additive): host to frame
measure {on, unit, ppi, dprAware, details, accent}andmeasureBox {id, reqId}; frame to hostmeasureInfo,measureBox,measureExit,measureCopied,measureOpt. The frame is untrusted (the page's own scripts can post to the parent), so the host validates every box withsanitizeBoxand ignores anything malformed. -
Layout (
ui/code/workspace.js):data-layouton.of-splitwith CSS flex direction reversal; settingslayout,splitH,splitV; prefscodeLayout,codeMeasureUnit,codeMeasurePpi,codeMeasureDpr,codeViewportSizes. -
Commands and Vibe tools:
code.measure,code.rulers,code.viewportRotate,code.layout.*incommands/code.js;set_viewport,get_viewport,measure_element,set_code_layoutinvibe/tools/web-view.js. -
Preview probe (
ui/code/probe.js):probeKitis injected next to the bridge and answersprobemessages (query,state,act) for the Vibe toolspreview_query,preview_stateandpreview_interact;PreviewPane.probe()is the host side. The kit is self-contained ES5, never evaluates code, and its replies passsanitizeProbebefore use. -
Layout metrics and sync (additive bridge messages): host to frame
viewportOpts {scrollbar},metrics,matchSel {selector}; frame to hostlayoutMetrics,matchCount. Sync lives inui/code/sync.js(SyncController: line highlights as a CodeMirrorStateField, hover links, breadcrumb bar) on top of the pureengine/web/sync.js(crumbsOf,openTagLines,cssRuleAt,matchableSelector,rulesForElement; tests intests/web/sync.test.js). Formatters:engine/web/format.js; editor entry pointsCodeEditors#format,#formatSelection, format-on-paste ineditor.js. -
Live updates (bridge messages): host to frame
patch {seq, tree, root, keep, removed, added},restore {x, y, sel},reportScroll,markText {a, b, scroll}; frame to hostpatched {seq, ok},restored. Planning is pure (engine/web/live-patch.js:changedRange,planPagePatch, the serializedmorphKit);PreviewPane#flushdecides between hot CSS, patch and rebuild, andPreviewPane.statscounts patches and rebuilds. See Live updates.
How to extend: add a preset to DEVICE_PRESETS, a unit to UNITS and the kit's PER_INCH / DECIMALS, or a bridge message in
bridge.js plus a validated handler in preview.js.
Source Control and one-click publishing#
The Source Control pane (activity bar) gives the project real Git: commits, branches, merging, tags, history with a
graph, diffs, restore from any commit and Git status in the Explorer and the editor gutter. The history is stored
inside the .ofini document and can be exported as a ZIP with a real .git folder. GitHub sync works through its API;
other servers need a CORS proxy. The Publish button (and Export ▸ Publish) deploys to Netlify, Vercel, GitHub
Pages and WebDAV, or to FTP/SFTP/rsync/SMTP through a small local helper (npm run publish:helper), after pre-publish
checks and a confirmation. Details, storage format and honest limits: git-and-publishing.md.
Limitations#
See known-limits.md and the roadmap. In short: no CMS, symbols/components, interactions editor, multi-page shared layouts (partials) or real-time collaboration; no stash/rebase in Source Control; no language servers; the terminal is a console without a shell or TTY; the visual designer edits one page at a time.
Edit on GitHub → docs/code-studio.md