diff --git a/config/current.ver b/config/current.ver index 2b5429a..b5db1a7 100644 --- a/config/current.ver +++ b/config/current.ver @@ -1 +1 @@ -1.1.74 \ No newline at end of file +1.1.75 \ 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 e71b2e1..f26ce3e 100644 --- a/public/assets/js/bridge/rte-editor.js +++ b/public/assets/js/bridge/rte-editor.js @@ -181,10 +181,9 @@ const isText = (component.is && component.is('text')) || (component.get && component.get('type') === 'text'); try { - if (isText && component.components) { - try { - component.components(content); - } catch {} + const hasInlineStyle = /style\s*=\s*["'][^"']*["']/.test(content) || / { + applyComponentStyle({ textAlign: 'left' }); + }); + addButton(icon('M5 7h14v2H5zM4 11h16v2H4zM5 15h14v2H5z'), 'Zentriert', null, null, () => { + applyComponentStyle({ textAlign: 'center' }); + }); + addButton(icon('M10 7h10v2H10zM4 11h16v2H4zM8 15h12v2H8z'), 'Rechtsbuendig', null, null, () => { + applyComponentStyle({ textAlign: 'right' }); + }); + addButton(icon('M4 7h16v2H4zM4 11h16v2H4zM4 15h16v2H4z'), 'Blocksatz', null, null, () => { + applyComponentStyle({ textAlign: 'justify' }); + }); const linkModal = doc.createElement('div'); linkModal.style.display = 'none'; linkModal.style.position = 'absolute'; diff --git a/public/editor/bridge-core.js b/public/editor/bridge-core.js index d06b21c..f82c6bf 100644 --- a/public/editor/bridge-core.js +++ b/public/editor/bridge-core.js @@ -450,6 +450,9 @@ } catch {} } catch {} }; + const hasInlineStyle = (html) => { + return / { const target = resolveTextModel(model); if (!isTextLike(target)) return; @@ -462,7 +465,7 @@ if (viewHtml) return; try { syncing.add(target); - if (target.components) { + if (target.components && !hasInlineStyle(modelHtml)) { try { target.components(modelHtml); } catch {} } if (target.set) target.set('content', modelHtml); @@ -501,7 +504,7 @@ if (viewHtml === modelHtml) return; try { syncing.add(target); - if (target.components) { + if (target.components && !hasInlineStyle(viewHtml)) { try { target.components(viewHtml); } catch {} } if (target.set) target.set('content', viewHtml); @@ -536,7 +539,7 @@ if (viewHtml === modelHtml && hasComps) return; try { syncing.add(target); - if (target.components) { + if (target.components && !hasInlineStyle(viewHtml)) { try { target.components(viewHtml); } catch {} } if (target.set) target.set('content', viewHtml); @@ -575,6 +578,9 @@ const DEBUG_UI_SUMMARY = B && typeof B.DEBUG_UI_SUMMARY !== 'undefined' ? !!B.DEBUG_UI_SUMMARY : true; + const hasInlineStyle = (html) => { + return / { if (!model) return ''; let html = ''; @@ -722,7 +728,7 @@ if (viewHtml === modelHtml) return; try { syncing.add(component); - if (component.components) { + if (component.components && !hasInlineStyle(viewHtml)) { try { component.components(viewHtml); } catch {} } if (component.set) component.set('content', viewHtml); @@ -790,7 +796,7 @@ const viewHtml = normalizeViewHtml(selectedEl.innerHTML || ''); if (!viewHtml) return; syncing.add(selected); - if (selected.components) { + if (selected.components && !hasInlineStyle(viewHtml)) { try { selected.components(viewHtml); } catch {} } if (selected.set) selected.set('content', viewHtml);