From a63ddb646cdc0f3e923c7daca5664c971d5612fb Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 5 Nov 2020 14:46:46 +0530 Subject: [PATCH 1/2] include anchors in rich text table of contents --- www/pad/inner.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/www/pad/inner.js b/www/pad/inner.js index eeabbb337..235b4fafa 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -650,9 +650,25 @@ define([ }, 500); // 500ms to make sure it is sent after chainpad sync }; + var isAnchor = function (el) { return el.nodeName === 'A'; }; + var getAnchorName = function (el) { + return el.getAttribute('id') || + el.getAttribute('data-cke-saved-name') || + el.getAttribute('name') || + Util.stripTags($(el).text()); + }; + var updateTOC = Util.throttle(function () { var toc = []; - $inner.find('h1, h2, h3').each(function (i, el) { + $inner.find('h1, h2, h3, a[id][data-cke-saved-name]').each(function (i, el) { + if (isAnchor(el)) { + return void toc.push({ + level: 2, + el: el, + title: getAnchorName(el), + }); + } + toc.push({ level: Number(el.tagName.slice(1)), el: el, @@ -661,6 +677,8 @@ define([ }); var content = [h('h2', Messages.markdown_toc)]; toc.forEach(function (obj) { + var title = (obj.title || "").trim(); + if (!title) { return; } // Only include level 2 headings var level = obj.level; var a = h('a.cp-pad-toc-link', { @@ -672,7 +690,7 @@ define([ if (!obj.el || UIElements.isVisible(obj.el, $inner)) { return; } obj.el.scrollIntoView(); }); - a.innerHTML = obj.title; + a.innerHTML = title; content.push(h('p.cp-pad-toc-'+level, a)); }); $toc.html('').append(content); @@ -1098,7 +1116,7 @@ define([ */ Ckeditor.dom.element.prototype.setHtml = function(a){ if (/callFunction/.test(a)) { - a = a.replace(/on(mousedown|blur|keydown|focus|click|dragstart)/g, function (value) { + a = a.replace(/on(mousedown|blur|keydown|focus|click|dragstart|mouseover|mouseout)/g, function (value) { return 'o' + value; }); } From d5b348a366f97b1f5d521c2aa30a183dbb556a1a Mon Sep 17 00:00:00 2001 From: Weblate Date: Wed, 4 Nov 2020 15:25:59 +0100 Subject: [PATCH 2/2] Translated using Weblate (German) Currently translated at 100.0% (1372 of 1372 strings) Translation: CryptPad/App Translate-URL: http://weblate.cryptpad.fr/projects/cryptpad/app/de/ --- www/common/translations/messages.de.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/common/translations/messages.de.json b/www/common/translations/messages.de.json index 6b5046aa0..b8aa108ed 100644 --- a/www/common/translations/messages.de.json +++ b/www/common/translations/messages.de.json @@ -1467,5 +1467,6 @@ "loading_state_2": "Inhalte aktualisieren", "loading_state_1": "Drive laden", "loading_state_0": "Oberfläche vorbereiten", - "loading_state_5": "Dokument rekonstruieren" + "loading_state_5": "Dokument rekonstruieren", + "error_unhelpfulScriptError": "Skriptfehler: Siehe Konsole im Browser für Details" }