Read-Only Ranges
Lock specific line ranges while keeping the rest of the document fully editable. Useful for boilerplate headers, licence blocks, generated output sections, or tutorial scaffolding where users should only fill in defined areas.
Basic Usage
Pass a readOnlyRanges array to createEditor(). Indices are 0-based and inclusive on both ends:
ReadOnlyRange Type
Visual Treatment
| Element | Appearance |
|---|---|
Background | Subtle amber tint (ThemeTokens.roBg) on every locked row. |
Left stripe | 3 px orange edge indicator on each locked row (ThemeTokens.orange). |
Cursor | not-allowed cursor when hovering over locked content. |
Insert indicators | Orange divider line + circular + badge at the top and bottom of the block when hovered. |
Insert-Line Affordance
When you hover inside a locked block, two insert controls appear — one at the top edge and one at the bottom edge of the block. Each is a full-width orange divider line with a circular + badge on the right. Click either to insert a new blank, editable line immediately above or below the block. The cursor is automatically placed on the new line.
What Is Blocked
· All edits — typing, paste, delete, backspace, indent, dedent, comment-toggle
· Autocomplete popup and trigger
· Emmet and snippet expansion
· Cursor placement by direct click into the range
· Arrow navigation into the block (Up/Down skip over locked rows)
· Gutter click-to-select on locked lines
What Still Works
· Hover documentation card
· Selection via Shift+Click and keyboard selection shortcuts
· Copy (Ctrl/Cmd+C)
· Find (Ctrl/Cmd+F) and Go-to-line (Ctrl/Cmd+G)
Partial-Selection Delete
When a selection spans both protected and writable rows (e.g. after Ctrl+A then Delete), only the writable portions are deleted — the locked rows survive exactly in place, and the RO range positions are preserved correctly in the undo/redo stack.
Range Shifting
Structural edits (typing, Enter, backspace, Alt+Up/Down) that insert or remove lines inside a writable area automatically shift all downstream protected ranges to keep them anchored to the correct content. The ranges remain accurate through unlimited undo/redo operations and across complex multi-line deletions.
Updating Ranges at Runtime
Theme Tokens
Two theme tokens control the visual appearance of locked ranges:
| Token | CSS variable | Controls |
|---|---|---|
roBg | --ro-bg | Background tint of locked rows and insert-button hover highlight. |
orange | --orange | Left-edge stripe colour and insert indicator / badge colour. |
© 2026 Syncline Editor. All rights reserved.