Upgrade to CodeMirror 6, add SQL autocomplete (#1893)

* Upgrade to CodeMirror 6
* Update contributing docs
* Change how resizing works
* Define a custom SQLite autocomplete dialect
* Add meta-enter to submit
* Add fixture schema for testing
This commit is contained in:
Brian Grinstead 2022-11-16 15:49:06 -08:00 committed by GitHub
commit ae11fa5887
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 1017 additions and 76 deletions

View file

@ -322,20 +322,10 @@ Upgrading CodeMirror
Datasette bundles `CodeMirror <https://codemirror.net/>`__ for the SQL editing interface, e.g. on `this page <https://latest.datasette.io/fixtures>`__. Here are the steps for upgrading to a new version of CodeMirror:
* Download and extract latest CodeMirror zip file from https://codemirror.net/codemirror.zip
* Rename ``lib/codemirror.js`` to ``codemirror-5.57.0.js`` (using latest version number)
* Rename ``lib/codemirror.css`` to ``codemirror-5.57.0.css``
* Rename ``mode/sql/sql.js`` to ``codemirror-5.57.0-sql.js``
* Edit both JavaScript files to make the top license comment a ``/* */`` block instead of multiple ``//`` lines
* Minify the JavaScript files like this::
npx uglify-js codemirror-5.57.0.js -o codemirror-5.57.0.min.js --comments '/LICENSE/'
npx uglify-js codemirror-5.57.0-sql.js -o codemirror-5.57.0-sql.min.js --comments '/LICENSE/'
* Install the packages with `npm i codemirror @codemirror/lang-sql`
* Build the bundle using the version number from package.json with:
* Check that the LICENSE comment did indeed survive minification
* Minify the CSS file like this::
node_modules/.bin/rollup datasette/static/cm-editor-6.0.1.js -f iife -n cm -o datasette/static/cm-editor-6.0.1.bundle.js -p @rollup/plugin-node-resolve -p @rollup/plugin-terser
npx clean-css-cli codemirror-5.57.0.css -o codemirror-5.57.0.min.css
* Edit the ``_codemirror.html`` template to reference the new files
* ``git rm`` the old files, ``git add`` the new files
* Update version reference in the `codemirror.html` template