Jul 24 - Update Rich-text editor to enhance table editor 6

This commit is contained in:
2026-07-24 15:35:12 -04:00
parent 22754f6ae8
commit a321a881d8
5 changed files with 33 additions and 19 deletions
+6 -8
View File
@@ -149,11 +149,6 @@
var toolbarEl = document.getElementById('editor-toolbar');
var editorEl = document.getElementById('editor');
// Persist alignment as inline `text-align` (style) rather than a Quill CSS
// class, so cell alignment survives the HTML sanitizer and renders on the
// public page with no extra CSS. Must run before the editor is created.
Quill.register(Quill.import('attributors/style/align'), true);
// quill-table-better: resizable columns/rows + a cell menu for alignment,
// borders and background. Registered only if the vendor script loaded.
var hasTables = typeof QuillTableBetter !== 'undefined';
@@ -226,12 +221,15 @@
var hasText = quill.getText().trim().length > 0;
var hasEmbed = quill.root.querySelector('img, table');
if (!hasText && !hasEmbed) { ta.value = ''; return; }
// Drop quill-table-better's transient selection nodes, then serialize
// clean semantic HTML (not raw innerHTML, which can leak UI markup).
// Drop quill-table-better's transient selection nodes, then save the raw
// editor HTML. We deliberately avoid getSemanticHTML() here: it rewrites
// Quill's `ql-align-*` class as an inline text-align style, which breaks
// quill-table-better's cell-alignment readback (its getAlign() only reads
// the class). innerHTML keeps the class so alignment round-trips.
if (hasTables) {
try { quill.getModule('table-better').deleteTableTemporary(); } catch (e) {}
}
ta.value = quill.getSemanticHTML();
ta.value = quill.root.innerHTML;
});
})();
</script>