mirror of
https://github.com/simonw/datasette.git
synced 2026-07-16 20:44:35 +02:00
Single source of truth for the CodeMirror setup: SQLiteDialect, createSqlEditor() (delegable history with host undo/redo forwarding, hostChange annotation for echo suppression, submit/escape callbacks, fixed-tooltip mode, per-editor Compartment updateSchema), and datasetteSchema() which fetches /-/editor-schema.json and maps it to a lang-sql SQLNamespace identical to the server-inlined shape. cm-editor.js is now a thin consumer; rollup emits both the IIFE and an importable ESM bundle. Submit key is Mod-Enter (Cmd on mac as before, now also Ctrl elsewhere) plus Shift-Enter. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
30 lines
925 B
JavaScript
30 lines
925 B
JavaScript
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
import terser from "@rollup/plugin-terser";
|
|
|
|
const plugins = [nodeResolve(), terser()];
|
|
|
|
export default [
|
|
// IIFE bundle for Datasette's own pages (global name `cm`, included by
|
|
// _codemirror.html). The shared datasette-sql-editor.js module is inlined.
|
|
{
|
|
input: "datasette/static/cm-editor.js",
|
|
output: {
|
|
file: "datasette/static/cm-editor.bundle.js",
|
|
format: "iife",
|
|
name: "cm",
|
|
},
|
|
plugins,
|
|
},
|
|
// Self-contained ESM bundle for plugin authors to import directly, e.g.
|
|
// import {createSqlEditor, datasetteSchema} from
|
|
// "/-/static/datasette-sql-editor.bundle.js"
|
|
// No bare specifiers remain; all @codemirror/* deps are inlined.
|
|
{
|
|
input: "datasette/static/datasette-sql-editor.js",
|
|
output: {
|
|
file: "datasette/static/datasette-sql-editor.bundle.js",
|
|
format: "es",
|
|
},
|
|
plugins,
|
|
},
|
|
];
|