From 7303a98d6b4828a4eaa599de65a566513943c685 Mon Sep 17 00:00:00 2001 From: Maksim Novikov Date: Sun, 17 Apr 2022 14:50:22 +0200 Subject: [PATCH] Add create issue button to playground --- docs/index.html | 8 +++++++- docs/playground.js | 22 +++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/docs/index.html b/docs/index.html index 95fd83ded2..b55bff5c9a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -12,6 +12,11 @@ #playground-container .CodeMirror { border: 1px solid; } + #create-issue-btn { + padding: 0.2em; + float: right; + font-size: 1.5em; + } #checkboxes { padding-bottom: 1em; } @@ -67,12 +72,13 @@

Tree


       
+ - + diff --git a/docs/playground.js b/docs/playground.js index be5668aae0..7da55f5c90 100644 --- a/docs/playground.js +++ b/docs/playground.js @@ -31,6 +31,7 @@ let tree; ); const playgroundContainer = document.getElementById("playground-container"); const queryCheckbox = document.getElementById("query-checkbox"); + const createIssueBtn = document.getElementById("create-issue-btn"); const queryContainer = document.getElementById("query-container"); const queryInput = document.getElementById("query-input"); const updateTimeSpan = document.getElementById("update-time"); @@ -75,7 +76,7 @@ let tree; loggingCheckbox.addEventListener("change", handleLoggingChange); queryCheckbox.addEventListener("change", handleQueryEnableChange); outputContainer.addEventListener("click", handleTreeClick); - + createIssueBtn.addEventListener("click", handleCreateIssue); handleQueryEnableChange(); await loadLanguage(); @@ -348,6 +349,25 @@ let tree; } } + function handleCreateIssue() { + const queryText = codeEditor.getValue(); + const outputText = outputContainer.innerText; + const title = `Error parsing SQL`; + const body = `Error when parsing the following SQL: +\`\`\` +${queryText} +\`\`\` +Error: +\`\`\` +${outputText} +\`\`\``; + const queryParams = `title=${encodeURIComponent( + title, + )}&body=${encodeURIComponent(body)}`; + const url = `https://github.com/m-novikov/tree-sitter-sql/issues/new?${queryParams}`; + window.open(url); + } + function handleTreeClick(event) { if (event.target.tagName === "A") { event.preventDefault();