Documentation
¶
Overview ¶
Package editor is the in-TUI ADF-native rich-text editor. The internal buffer is the typed adf.Document, not a Markdown string. Markdown-style key shortcuts mutate the document in place — there is no convert-on-submit step.
Opaque blocks (unknown ADF nodes preserved on parse) are treated as protected: they render but cannot be edited or deleted.
Index ¶
- type Editor
- func (e *Editor) ApplyMarkToCurrentParagraphRange(start, end int, markType string) bool
- func (e *Editor) CurrentParagraphLen() int
- func (e *Editor) DeleteCurrentBlock() bool
- func (e *Editor) DeleteLastRune() bool
- func (e *Editor) Document() adf.Document
- func (e *Editor) HandleShortcut(token string)
- func (e *Editor) InsertText(s string)
- func (e *Editor) IsAtOpaqueBlock() bool
- func (e *Editor) MoveTo(p Position)
- func (e *Editor) SelectAll()
- type Options
- type Position
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Editor ¶
type Editor struct {
// contains filtered or unexported fields
}
Editor is the public ADF editor model. The Bubble Tea model wraps it.
func (*Editor) ApplyMarkToCurrentParagraphRange ¶
ApplyMarkToCurrentParagraphRange applies markType to the rune range [start, end) of the current paragraph's flat text content. Existing marks on adjacent runs are preserved — text nodes are split at the range boundaries so the affected run carries exactly the new mark (in addition to whatever marks it already had) and nothing else changes.
Returns false when the caret is not on a text-bearing block, or when [start, end) is empty / out of bounds. Idempotent on a range already carrying the same mark.
Used by the TUI's Markdown-style shortcut layer to apply strong/em/code/strike marks to a precise span without rebuilding the document and losing earlier marks.
func (*Editor) CurrentParagraphLen ¶
CurrentParagraphLen returns the rune length of all text in the current paragraph — used by the form to map between visible buffer length and editor offsets when applying range marks.
func (*Editor) DeleteCurrentBlock ¶
DeleteCurrentBlock removes the caret's block, EXCEPT when it is an opaque (protected) block. Returns true if anything was deleted.
func (*Editor) DeleteLastRune ¶
DeleteLastRune removes the trailing rune from the current paragraph without disturbing marks on the remaining text. If the trailing run becomes empty, the empty text node is removed. Returns false when the paragraph is already empty.
Used by the TUI form's keystroke mirror so backspace doesn't have to rebuild the editor (which would destroy mark history).
func (*Editor) HandleShortcut ¶
HandleShortcut applies a Markdown-style shortcut to the editor state. The supported shortcuts are the documented Markdown shortcuts plus the few inline marks the tests exercise; the full MVP set lives behind individual helper methods invoked from the Bubble Tea key handler.
func (*Editor) InsertText ¶
InsertText appends text to the current block. If the current block is not a text-bearing paragraph/heading, a new paragraph is appended.
func (*Editor) IsAtOpaqueBlock ¶
IsAtOpaqueBlock reports whether the caret currently sits on a block the editor cannot edit (an unknown ADF node preserved by Parse).