From ae3867793820a6a078a8a5688e7ebc1e3b792017 Mon Sep 17 00:00:00 2001 From: x-Wawa <66263633+x-Wawa@users.noreply.github.com> Date: Thu, 28 Jul 2022 23:57:14 +0200 Subject: [PATCH] add a copy button to copy expression --- dev/lib/codemirror.js | 13 +++++++++++++ index.html | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/dev/lib/codemirror.js b/dev/lib/codemirror.js index aba145d8..f80ffa0e 100644 --- a/dev/lib/codemirror.js +++ b/dev/lib/codemirror.js @@ -80,8 +80,21 @@ function elt(tag, content, className, style) { function eltP(tag, content, className, style) { var e = elt(tag, content, className, style) e.setAttribute("role", "presentation") + e.setAttribute("id", "presentation") return e } +function copyExpression() { + var expressionText = "" + document.getElementById("presentation").childNodes.forEach((child) => { + expressionText += child.innerText + }) + navigator.clipboard.writeText(expressionText) + + document.getElementById("copyExpressionButton").innerText= "Copied !" + setTimeout(() => { + document.getElementById("copyExpressionButton").innerText= "Copy Expression" + }, 800); +} var range if (document.createRange) { range = function(node, start, end, endNode) { diff --git a/index.html b/index.html index acde6aa0..bbf2e8b9 100644 --- a/index.html +++ b/index.html @@ -157,6 +157,20 @@