From c08bd25577939bf463c2acf48b4d0a858aa0c4ff Mon Sep 17 00:00:00 2001 From: Nokome Bentley Date: Fri, 9 Sep 2022 18:42:51 +1200 Subject: [PATCH] feat(Editor): Register SQL and PrQL as editor languages --- packages/components/package-lock.json | 71 +++++++------------ packages/components/package.json | 1 + .../src/components/editor/editor.tsx | 4 ++ .../src/components/editor/languageUtils.ts | 10 +++ 4 files changed, 41 insertions(+), 45 deletions(-) diff --git a/packages/components/package-lock.json b/packages/components/package-lock.json index 52da351a4..0c22e09b5 100644 --- a/packages/components/package-lock.json +++ b/packages/components/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@stencila/components", - "version": "0.54.2", + "version": "0.54.3", "license": "Apache-2.0", "dependencies": { "@codemirror/autocomplete": "^0.19.15", @@ -21,6 +21,7 @@ "@codemirror/lang-json": "^0.19.2", "@codemirror/lang-markdown": "^0.19.6", "@codemirror/lang-python": "^0.19.5", + "@codemirror/lang-sql": "^0.19.4", "@codemirror/lang-xml": "^0.19.2", "@codemirror/legacy-modes": "^0.19.1", "@codemirror/matchbrackets": "^0.19.4", @@ -31,8 +32,6 @@ "@codemirror/view": "^0.19.48", "@nll/datum": "^3.5.0", "@popperjs/core": "^2.11.0", - "@stencila/style-material": "0.16.13", - "@stencila/style-stencila": "0.29.9", "animate-presence": "^0.2.1", "d3": "^7.0.1", "d3-drag": "^3.0.0", @@ -902,6 +901,18 @@ "@lezer/python": "^0.15.0" } }, + "node_modules/@codemirror/lang-sql": { + "version": "0.19.4", + "resolved": "https://registry.npmjs.org/@codemirror/lang-sql/-/lang-sql-0.19.4.tgz", + "integrity": "sha512-4FqLC8aNe1iCDyAWbJmSqa8K7rgz2xTwW36V35z4oiyLoyOLsCayKIwoQqp5DNIq2ckGCsyzotgxXKpgtg/pgg==", + "dependencies": { + "@codemirror/autocomplete": "^0.19.0", + "@codemirror/highlight": "^0.19.0", + "@codemirror/language": "^0.19.0", + "@codemirror/state": "^0.19.0", + "@lezer/lr": "^0.15.0" + } + }, "node_modules/@codemirror/lang-xml": { "version": "0.19.2", "resolved": "https://registry.npmjs.org/@codemirror/lang-xml/-/lang-xml-0.19.2.tgz", @@ -1717,11 +1728,6 @@ "node": ">=0.10.0" } }, - "node_modules/@stencila/brand": { - "version": "0.7.30", - "resolved": "https://registry.npmjs.org/@stencila/brand/-/brand-0.7.30.tgz", - "integrity": "sha512-NCprpL7AbYH97uKlarqXzNBkwhk2SB1fmRiG5L55HFyNvuehJ09WSd9KvkkQJCXFsGu2nK43VoftePzeETjyfg==" - }, "node_modules/@stencila/eslint-config-stencil": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@stencila/eslint-config-stencil/-/eslint-config-stencil-2.0.5.tgz", @@ -1750,22 +1756,6 @@ "integrity": "sha512-mWvEi6Y+8hQRqlRfJHUPQ/GZUN+rfY7kB7JSx1Cts64PsF+odgJ2AFu+fltnK94jRB8Ohk0B4SPJLnuGLeZGBg==", "dev": true }, - "node_modules/@stencila/style-material": { - "version": "0.16.13", - "resolved": "https://registry.npmjs.org/@stencila/style-material/-/style-material-0.16.13.tgz", - "integrity": "sha512-6X6LbG0MY12hxQ/7NE8GgiCZNsKyyG5yrtlvKiw7F7cJr6CvaApK9Y5K9HVouxV+Qw7FINpr5gO71FOLBsQ3Ag==", - "dependencies": { - "@stencila/brand": "0.7.30" - } - }, - "node_modules/@stencila/style-stencila": { - "version": "0.29.9", - "resolved": "https://registry.npmjs.org/@stencila/style-stencila/-/style-stencila-0.29.9.tgz", - "integrity": "sha512-Cbz7YQoPvPtcJ1rnb4Zyv3AcI/E+mUmFZ+cH5UwJ7yKbRqj8HHPobkGCj6rJTgTq4odXt8UhhUeGgVm1ioDBiA==", - "dependencies": { - "@stencila/brand": "0.7.30" - } - }, "node_modules/@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -10629,6 +10619,18 @@ "@lezer/python": "^0.15.0" } }, + "@codemirror/lang-sql": { + "version": "0.19.4", + "resolved": "https://registry.npmjs.org/@codemirror/lang-sql/-/lang-sql-0.19.4.tgz", + "integrity": "sha512-4FqLC8aNe1iCDyAWbJmSqa8K7rgz2xTwW36V35z4oiyLoyOLsCayKIwoQqp5DNIq2ckGCsyzotgxXKpgtg/pgg==", + "requires": { + "@codemirror/autocomplete": "^0.19.0", + "@codemirror/highlight": "^0.19.0", + "@codemirror/language": "^0.19.0", + "@codemirror/state": "^0.19.0", + "@lezer/lr": "^0.15.0" + } + }, "@codemirror/lang-xml": { "version": "0.19.2", "resolved": "https://registry.npmjs.org/@codemirror/lang-xml/-/lang-xml-0.19.2.tgz", @@ -11304,11 +11306,6 @@ } } }, - "@stencila/brand": { - "version": "0.7.30", - "resolved": "https://registry.npmjs.org/@stencila/brand/-/brand-0.7.30.tgz", - "integrity": "sha512-NCprpL7AbYH97uKlarqXzNBkwhk2SB1fmRiG5L55HFyNvuehJ09WSd9KvkkQJCXFsGu2nK43VoftePzeETjyfg==" - }, "@stencila/eslint-config-stencil": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@stencila/eslint-config-stencil/-/eslint-config-stencil-2.0.5.tgz", @@ -11322,22 +11319,6 @@ "integrity": "sha512-mWvEi6Y+8hQRqlRfJHUPQ/GZUN+rfY7kB7JSx1Cts64PsF+odgJ2AFu+fltnK94jRB8Ohk0B4SPJLnuGLeZGBg==", "dev": true }, - "@stencila/style-material": { - "version": "0.16.13", - "resolved": "https://registry.npmjs.org/@stencila/style-material/-/style-material-0.16.13.tgz", - "integrity": "sha512-6X6LbG0MY12hxQ/7NE8GgiCZNsKyyG5yrtlvKiw7F7cJr6CvaApK9Y5K9HVouxV+Qw7FINpr5gO71FOLBsQ3Ag==", - "requires": { - "@stencila/brand": "0.7.30" - } - }, - "@stencila/style-stencila": { - "version": "0.29.9", - "resolved": "https://registry.npmjs.org/@stencila/style-stencila/-/style-stencila-0.29.9.tgz", - "integrity": "sha512-Cbz7YQoPvPtcJ1rnb4Zyv3AcI/E+mUmFZ+cH5UwJ7yKbRqj8HHPobkGCj6rJTgTq4odXt8UhhUeGgVm1ioDBiA==", - "requires": { - "@stencila/brand": "0.7.30" - } - }, "@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", diff --git a/packages/components/package.json b/packages/components/package.json index f3a2485b4..adcd8f0cd 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -75,6 +75,7 @@ "@codemirror/lang-markdown": "^0.19.6", "@codemirror/lang-python": "^0.19.5", "@codemirror/lang-xml": "^0.19.2", + "@codemirror/lang-sql": "^0.19.4", "@codemirror/legacy-modes": "^0.19.1", "@codemirror/matchbrackets": "^0.19.4", "@codemirror/panel": "^0.19.0", diff --git a/packages/components/src/components/editor/editor.tsx b/packages/components/src/components/editor/editor.tsx index 9f75498c9..937d3782d 100644 --- a/packages/components/src/components/editor/editor.tsx +++ b/packages/components/src/components/editor/editor.tsx @@ -265,6 +265,10 @@ export class Editor { const { markdown } = await import('@codemirror/lang-markdown') return markdown() } + case 'sql': { + const { sql } = await import('@codemirror/lang-sql') + return sql() + } } } diff --git a/packages/components/src/components/editor/languageUtils.ts b/packages/components/src/components/editor/languageUtils.ts index 2c816c8ba..968042718 100644 --- a/packages/components/src/components/editor/languageUtils.ts +++ b/packages/components/src/components/editor/languageUtils.ts @@ -52,6 +52,11 @@ export const fileFormatMap: FileFormatMap = { ext: 'txt', aliases: ['txt'], }, + PrQL: { + name: 'PrQL', + ext: 'prql', + aliases: ['prql'], + }, Python: { name: 'Python', ext: 'py', @@ -67,6 +72,11 @@ export const fileFormatMap: FileFormatMap = { ext: 'rmd', aliases: ['rmd', 'r markdown', 'rmarkdown'], }, + SQL: { + name: 'SQL', + ext: 'sql', + aliases: ['sql'], + }, TOML: { name: 'TOML', ext: 'toml',