Problem
There's no way to change the alignment of a block. All content renders left-aligned. Users should be able to set blocks to left, center, or right alignment.
Context
The block model (internal/block/block.go) currently has three fields: Type, Content, and Checked. Rendering in internal/editor/render.go always left-aligns text within the available width. The command palette (internal/editor/palette.go) handles block type changes but has no concept of block properties beyond type.
Key files:
internal/block/block.go — Block struct, BlockType enum
internal/block/parse.go — Markdown → Blocks parsing
internal/block/serialize.go — Blocks → Markdown serialization
internal/editor/editor.go — Keyboard handling, block operations
internal/editor/render.go — Active/inactive/view rendering
internal/editor/palette.go — Command palette
internal/editor/undo.go — State snapshots (includes block data)
Approach
Data model: Add an Align field to Block (enum: Left, Center, Right, default Left).
Markdown persistence: Serialize as an HTML comment above the block — <!-- align:center -->. This is invisible to other markdown renderers and won't corrupt content. On parse, detect and strip the comment, setting the block's alignment.
Rendering: Pad lines with leading spaces to shift content center or right within the available width. Applies to both active block, inactive block, and view mode rendering paths in render.go.
UX:
- Add
/left, /center, /right entries to the command palette
- Consider a keyboard shortcut (single key that cycles, or direct shortcuts — avoid Ctrl+E/Ctrl+A per macOS terminal conflicts)
- Show alignment in the gutter or as a subtle indicator
Tasks
Acceptance criteria
Problem
There's no way to change the alignment of a block. All content renders left-aligned. Users should be able to set blocks to left, center, or right alignment.
Context
The block model (
internal/block/block.go) currently has three fields:Type,Content, andChecked. Rendering ininternal/editor/render.goalways left-aligns text within the available width. The command palette (internal/editor/palette.go) handles block type changes but has no concept of block properties beyond type.Key files:
internal/block/block.go— Block struct, BlockType enuminternal/block/parse.go— Markdown → Blocks parsinginternal/block/serialize.go— Blocks → Markdown serializationinternal/editor/editor.go— Keyboard handling, block operationsinternal/editor/render.go— Active/inactive/view renderinginternal/editor/palette.go— Command paletteinternal/editor/undo.go— State snapshots (includes block data)Approach
Data model: Add an
Alignfield toBlock(enum:Left,Center,Right, defaultLeft).Markdown persistence: Serialize as an HTML comment above the block —
<!-- align:center -->. This is invisible to other markdown renderers and won't corrupt content. On parse, detect and strip the comment, setting the block's alignment.Rendering: Pad lines with leading spaces to shift content center or right within the available width. Applies to both active block, inactive block, and view mode rendering paths in
render.go.UX:
/left,/center,/rightentries to the command paletteTasks
Alignfield andAlignmentenum tointernal/block/block.gointernal/block/parse.goto detect<!-- align:X -->comments and set alignmentinternal/block/serialize.goto emit alignment comments for non-left blocksinternal/editor/render.go— pad lines for center/right in all three render pathsinternal/editor/palette.gointernal/editor/editor.goeditorStateininternal/editor/undo.goif needed (alignment is stored on blocks, so it should already be captured)Acceptance criteria
<!-- align:left -->comment emitted for default