From 98de2b089973c4a01bd0f02745a4be02ad51642e Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 2 Nov 2020 15:46:37 -0500 Subject: [PATCH] Use `contentEditable` for all browsers This makes it possible to disable `contentEditable` for certain elements in some circumstances (e.g., on links so that users can click on them normally). --- src/static/js/ace2_inner.js | 48 ++----------------------------------- 1 file changed, 2 insertions(+), 46 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 789f7395b..07b09d37e 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -605,19 +605,9 @@ function Ace2Inner(){ recolorLinesInRange(0, rep.alltext.length); } - function setEditable(newVal) - { + function setEditable(newVal) { isEditable = newVal; - - // the following may fail, e.g. if iframe is hidden - if (!isEditable) - { - setDesignMode(false); - } - else - { - setDesignMode(true); - } + root.contentEditable = isEditable ? 'true' : 'false'; root.classList.toggle('static', !isEditable); } @@ -4674,40 +4664,6 @@ function Ace2Inner(){ }); } - function setDesignMode(newVal) - { - try - { - function setIfNecessary(target, prop, val) - { - if (String(target[prop]).toLowerCase() != val) - { - target[prop] = val; - return true; - } - return false; - } - if (browser.msie || browser.safari) - { - setIfNecessary(root, 'contentEditable', (newVal ? 'true' : 'false')); - } - else - { - var wasSet = setIfNecessary(doc, 'designMode', (newVal ? 'on' : 'off')); - if (wasSet && newVal && browser.opera) - { - // turning on designMode clears event handlers - bindTheEventHandlers(); - } - } - return true; - } - catch (e) - { - return false; - } - } - var iePastedLines = null; function handleIEPaste(evt)