Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CSV Plugin (@lapis-notes/csv)

Source: packages/plugins/plugin-csv/src/

Package: @lapis-notes/csv. Manifest id: csv.

The CSV package owns bundled CSV and TSV editing with rainbow source highlighting and an editable table preview.

Registration

  • View type: csv
  • Core-plugin activation through the workspace shell
  • File associations: .csv, .tsv
  • Language-service provider: csv-lint (in-plugin, diagnostics for csv and tsv)

Current Functionality

  • Ships the first-party plugin package and manifest for bundled CSV support.
  • Registers a dedicated file-backed CSV leaf instead of falling back to a generic text editor.
  • Opens .csv and .tsv files in a dual-mode view: table preview (default) and rainbow-highlighted source.
  • Uses a vendored Lezer grammar adapted from codemirror-lang-csv for rainbow column highlighting in source mode.
  • Parses and serializes CSV text through Papa Parse with a mutable CsvGrid model for table preview edits.
  • Syncs preview and source through the shared text Editor instance attached to the leaf.
  • Renders the table preview with @lapis-notes/ui/table, sticky headers, optional 1-based # row numbers, rainbow column tinting in preview, border-positioned row/column grips (column grip on the header top border), rectangle multi-cell selection, @dnd-kit/svelte row/column drag reorder with a custom DragOverlay preview of the full row or column, a 5px pointer-move activation threshold on grips so click-to-select stays distinct from drag-to-reorder, accent drop indicators, and in-table source fading while dragging, context menus for clear/delete cells plus row/column actions, editable headers with automatic header-row promotion, column move menu actions, and markdown-inspired --interactive-accent selection chrome. Header column menus are absolutely positioned so selection borders align with body cells. Row drag uses a single draggable on the first body cell grip with row droppables on every body cell. Playwright coverage in packages/workspace/e2e/csv-editor.spec.ts includes grip click selection, column grip drag reorder, multi-cell drag-select, row reorder via the context-menu Move row down action, and computed-style checks that selected cells render the accent fill (--table-selection) and border (--interactive-accent) overlay.
  • Wires preview-mode undo/redo (Mod+Z, Mod+Shift+Z, Mod+Y) through a view scope while deferring to native input undo during active cell edits.
  • Marks preview serialization edits as CodeMirror user events so shared editor history groups sensibly.
  • Skips CodeMirror lint diagnostics in table preview mode; CSVLint runs only in source mode to avoid redundant parse work during table edits.
  • Registers an in-plugin CSVLint-inspired language-service provider (csv/field-count, csv/quote-consistency, csv/parse-error) with line-bounded diagnostic ranges and a document-size guard; surfaced in source mode through shared lint gutter/inline UI.
  • Shows Papa Parse errors in the table preview banner without re-parsing on programmatic editor sync echoes.
  • Persists plugin settings (header row, delimiter override, row numbers) through bundled plugin data.
  • Emits dist/app.css for workspace loading and dist/styles.css for standalone/plugin-local CSS consumption.
  • Namespaces plugin-owned chrome under csv-... selectors and maps colors through --csv-... theme variables.

E2E Vault Fixtures

Tracked under e2e-vault/plugin-csv/:

  • CSV Feature Tour.md — manual verification guide
  • assets/valid-basic.csv — table preview baseline
  • assets/valid-quoted-multiline.csv — quoted commas and multiline cells
  • assets/valid-sample.tsv — tab-delimited sample
  • assets/lint-ragged-columns.csv — ragged row lint fixture
  • assets/lint-quote-mismatch.csv — broken quoting lint fixture

Package Boundary

The plugin owns CSV-specific file views, parsing, table preview UI, CSV lint registration, and CodeMirror language support. Generic file-view lifecycle, plugin activation, shared lint UI, and vault I/O remain in @lapis-notes/api and the workspace shell.