mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-09-01 11:21:31 +09:00
Replace Trix with Lexxy
This commit is contained in:
@@ -76,7 +76,20 @@ export default class MessageFormatter {
|
||||
}
|
||||
|
||||
#highlightCodeBlock(block) {
|
||||
if (this.#isPlainText(block)) window.hljs.highlightElement(block)
|
||||
this.#normalizeLineBreaks(block)
|
||||
if (!this.#isPlainText(block)) return
|
||||
|
||||
const language = block.dataset.language
|
||||
if (language && window.hljs.getLanguage(language)) {
|
||||
block.classList.add(`language-${language}`)
|
||||
}
|
||||
|
||||
window.hljs.highlightElement(block)
|
||||
}
|
||||
|
||||
// Lexxy breaks code block lines with <br>, Trix-era blocks used newlines
|
||||
#normalizeLineBreaks(block) {
|
||||
block.querySelectorAll("br").forEach(br => br.replaceWith("\n"))
|
||||
}
|
||||
|
||||
#isPlainText(element) {
|
||||
|
||||
Reference in New Issue
Block a user