From fb0a216eb99e011c7e71dad244bb2ca8b064f964 Mon Sep 17 00:00:00 2001 From: SliOrtega295 Date: Fri, 6 Mar 2026 00:06:34 +0800 Subject: [PATCH] Fix #2216: Table of contents not clickable in read-only mode Problem: - In read-only mode, clicking on table of contents links does nothing - The anchor links use CKEditor's restoreRealElement which may not work in read-only mode Solution: - Add fallback to find anchor by ID directly - Use foundAnchor flag to stop searching after first match This matches the implementation in links.js which already has this fallback. --- www/pad/inner.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/www/pad/inner.js b/www/pad/inner.js index 04d81d5d4..159923d54 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -728,13 +728,21 @@ define([ var href = el.getAttribute('href'); if (/^#/.test(href)) { try { + var foundAnchor = false; $inner.find('.cke_anchor[data-cke-realelement]').each(function (j, el) { + if (foundAnchor) { return; } var i = editor.restoreRealElement($(el)); var node = i.$; if (node.id === href.slice(1)) { el.scrollIntoView(); + foundAnchor = true; } }); + // Fallback: try to find anchor by ID directly + if (!foundAnchor) { + var anchorsById = $inner.find('#' + href.slice(1)); + if (anchorsById.length) { anchorsById[0].scrollIntoView(); } + } } catch (err) {} return; }