From 4f0e9bb9bb5d56ecf5d18d8a9b2917bcd0438527 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Tue, 26 Mar 2024 16:36:05 -0400 Subject: [PATCH] Scaffold: Enable syntax highlighting/formatting in Test Input --- chrome/content/scaffold/scaffold.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/chrome/content/scaffold/scaffold.js b/chrome/content/scaffold/scaffold.js index df8c74372f..b1df123669 100644 --- a/chrome/content/scaffold/scaffold.js +++ b/chrome/content/scaffold/scaffold.js @@ -700,6 +700,22 @@ var Scaffold = new function () { // Then go to line 1 _editors.code.setPosition({ lineNumber: 1, column: 1 }); + // Set Test Input editor language based on translator metadata + let language = 'plaintext'; + if (translator.translatorType & Zotero.Translator.TRANSLATOR_TYPES.import) { + if (translator.target.includes('json')) { + language = 'json'; + } + else if (translator.target.includes('xml')) { + language = 'xml'; + } + } + else if (translator.translatorType & Zotero.Translator.TRANSLATOR_TYPES.search) { + language = 'json'; + } + _editors.importGlobal.editor.setModelLanguage(_editors.import.getModel(), language); + _editors.import.setPosition({ lineNumber: 1, column: 1 }); + // Reset configOptions and displayOptions before loading document.getElementById('textbox-configOptions').value = ''; document.getElementById('textbox-displayOptions').value = '';