瀏覽代碼

fix: clear prettyprinted class when re-rendering as plaintext/markdown

prettyPrint() adds the 'prettyprinted' marker class to signal it has
processed the element. When the viewer is re-used (e.g. clone flow or
same-page re-render) and the format changes away from syntaxhighlighting,
parsePaste() was removing 'prettyprint' (the styling class) but not
'prettyprinted' (the processed marker), leaving isPrettyPrinted()
returning true stale. This also caused the PasteViewer fast-check test
to fail across iterations when syntaxhighlighting ran before plaintext.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
rugk 1 月之前
父節點
當前提交
eb58717657
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      js/privatebin.js

+ 1 - 1
js/privatebin.js

@@ -2651,7 +2651,7 @@ window.PrivateBin = (function () {
                     Helper.urls2links(prettyPrintEl, format !== 'syntaxhighlighting');
                     prettyPrintEl.style.whiteSpace = 'pre-wrap';
                     prettyPrintEl.style.wordBreak = 'normal';
-                    prettyPrintEl.classList.remove('prettyprint');
+                    prettyPrintEl.classList.remove('prettyprint', 'prettyprinted');
                 }
             }
         }