1(function (document) { 2 "use strict"; 3 4 function wrapExistingTables(root) { 5 const scope = root || document; 6 const tables = scope.querySelectorAll(".RichText table"); 7 tables.forEach(function (table) { 8 // Skip if already inside a .Table wrapper 9 if (table.closest(".RichText--table")) return; 10 11 // Create wrapper and insert around the table 12 const wrapper = document.createElement("div"); 13 wrapper.className = "RichText--table"; 14 15 // Insert wrapper before the table, then move the table inside 16 table.parentNode.insertBefore(wrapper, table); 17 wrapper.appendChild(table); 18 }); 19 } 20 21 // Run when AEM injects/initializes content in authoring 22 document.addEventListener("foundation-contentloaded", function (e) { 23 // Slight delay to allow any async rendering to complete (mirrors your setTimeout 100) 24 setTimeout(function () { 25 wrapExistingTables(e.target || document); 26 }, 100); 27 }); 28 29 // Also run once on initial page load (author/publish) 30 document.addEventListener("DOMContentLoaded", function () { 31 setTimeout(function () { 32 wrapExistingTables(document); 33 }, 100); 34 }); 35 36})(document);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.