From 94fde301bcac210666d20cc16144a4c526c564c7 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Sat, 31 Jan 2026 23:26:08 +0100 Subject: [PATCH] Font --- config/current.ver | 2 +- public/assets/js/bridge/rte-editor.js | 32 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/config/current.ver b/config/current.ver index b5db1a7..1c651ab 100644 --- a/config/current.ver +++ b/config/current.ver @@ -1 +1 @@ -1.1.75 \ No newline at end of file +1.1.76 \ No newline at end of file diff --git a/public/assets/js/bridge/rte-editor.js b/public/assets/js/bridge/rte-editor.js index f26ce3e..cf7f122 100644 --- a/public/assets/js/bridge/rte-editor.js +++ b/public/assets/js/bridge/rte-editor.js @@ -90,7 +90,7 @@ wrapper.querySelectorAll('script,style').forEach((node) => node.remove()); - const inlineTags = new Set(['A', 'B', 'STRONG', 'I', 'EM', 'U', 'S', 'BR', 'SUB', 'SUP', 'SPAN']); + const inlineTags = new Set(['A', 'B', 'STRONG', 'I', 'EM', 'U', 'S', 'BR', 'SUB', 'SUP', 'SPAN', 'FONT']); const blockTags = new Set([ 'DIV', 'P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'UL', 'OL', 'LI', 'TABLE', 'TBODY', 'THEAD', 'TFOOT', 'TR', 'TD', 'TH', @@ -116,6 +116,36 @@ const tag = el.tagName; const tagLower = tag.toLowerCase(); if (inlineTags.has(tag)) { + if (tagLower === 'font') { + const face = el.getAttribute('face'); + const size = el.getAttribute('size'); + const color = el.getAttribute('color'); + const styles = []; + if (face) styles.push(`font-family:${face}`); + if (color) styles.push(`color:${color}`); + if (size) { + const sizeMap = { + 1: '10px', + 2: '12px', + 3: '14px', + 4: '16px', + 5: '18px', + 6: '24px', + 7: '32px', + }; + const mapped = sizeMap[size] || sizeMap[parseInt(size, 10)] || null; + if (mapped) styles.push(`font-size:${mapped}`); + } + if (styles.length) { + const span = document.createElement('span'); + span.setAttribute('style', styles.join(';')); + while (el.firstChild) span.appendChild(el.firstChild); + el.replaceWith(span); + } else { + unwrap(el, false); + } + return; + } if (tagLower === 'a' && !el.getAttribute('href')) { unwrap(el, false); return;