homegrade_theme_production/resources/js/editor.js

27 lines
1.0 KiB
JavaScript

export default function editorInit() {
const tablesCells = document.querySelectorAll('.wp-block-table td');
function filterCells(element, stringToParse) {
return element.textContent.trim() === stringToParse;
}
const checkedCells = Array.from(tablesCells).filter((element) => filterCells(element, '((v))'));
const crossedCells = Array.from(tablesCells).filter((element) => filterCells(element, '((x))'));
checkedCells.forEach((cell) => {
console.log(textTranslationsMainAppJS);
cell.innerHTML = `<span class="table-cell-icon table-cell-icon--checked" aria-label="${textTranslationsMainAppJS.yes}"></span>`;
});
crossedCells.forEach((cell) => {
cell.innerHTML = `<span class="table-cell-icon table-cell-icon--crossed " aria-label="${textTranslationsMainAppJS.no}"></span>`;
});
// tables.forEach((table) => {
// const tableCells = contains('td', '((v))');
// console.log(tableRows);
// tableRows.forEach((row) => {
// console.log(row);
// });
// });
}