From 3cc563ec599ae3d7e8109471aa8f788c43d2f3c5 Mon Sep 17 00:00:00 2001 From: Max Wu Date: Thu, 27 Feb 2020 17:35:17 +0800 Subject: [PATCH] feat: define vega code block using json overlay mode in editor to get vega-lite syntax highlighting work Signed-off-by: Max Wu --- public/js/lib/editor/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public/js/lib/editor/index.js b/public/js/lib/editor/index.js index 5daca68d..4bead7ef 100644 --- a/public/js/lib/editor/index.js +++ b/public/js/lib/editor/index.js @@ -131,6 +131,17 @@ export default class Editor { } this.eventListeners = {} this.config = config + + // define modes from mode mime + let ignoreOverlay = { + token: function (stream, state) { + stream.next() + return null + } + } + CodeMirror.defineMode('vega', function (config, modeConfig) { + return CodeMirror.overlayMode(CodeMirror.getMode(config, 'application/ld+json'), ignoreOverlay) + }) } on (event, cb) {