Skip to content

Commit

Permalink
Merge pull request #1543 from gamebeaker/move-TableToDiv-from-WebToEp…
Browse files Browse the repository at this point in the history
…ub-to-EpubEditor

Revert "Create convertTableToDiv to fix royalroad tables on tolino"
  • Loading branch information
dteviot authored Oct 9, 2024
2 parents 0d1321a + 59b6bac commit f8567ed
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 36 deletions.
7 changes: 0 additions & 7 deletions plugin/js/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class Parser {
util.decodeCloudflareProtectedEmails(content);
this.removeNextAndPreviousChapterHyperlinks(webPage, content);
this.removeUnwantedElementsFromContentElement(content);
this.convertTabletoDiv(content);
this.addTitleToContent(webPage, content);
util.fixBlockTagsNestedInInlineTags(content);
this.imageCollector.replaceImageTags(content);
Expand Down Expand Up @@ -151,12 +150,6 @@ class Parser {
util.removeLeadingWhiteSpace(element);
};

convertTabletoDiv(element) {
if (this.userPreferences.styleSheet.value.includes(".WebToEpub-table")) {
util.convertTableToDiv(element);
}
};

customRawDomToContentStep(chapter, content) { // eslint-disable-line no-unused-vars
// override for any custom processing
}
Expand Down
30 changes: 1 addition & 29 deletions plugin/js/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,33 +234,6 @@ var util = (function () {
node.remove();
}

var convertTableToDiv = function(element) {
for(let table of [...element.querySelectorAll("table")]) {
replaceTableToDivHelper(table, "td", "WebToEpub-cell");
replaceTableToDivHelper(table, "tr", "WebToEpub-row");
replaceTableToDivHelper(table, "tbody", "");
replaceTableToDivHelper(table.parentNode, "table", "WebToEpub-table");
}
}

var replaceTableToDivHelper = function(element, elementtoreplace, divclass) {
if (element == null || element == undefined) {
return;
}
for(let node of [...element.querySelectorAll(elementtoreplace)]) {
let elementchildren = [...node.childNodes];
let div = document.createElement("div");
div.append(...elementchildren);
if (elementtoreplace == "table") {
node.parentNode.style.overflow = "visible";
}
if (divclass != "") {
div.classList.add(divclass);
}
node.replaceWith(div);
}
}

/**
* @todo expand to remove ALL event handlers
*/
Expand Down Expand Up @@ -1062,8 +1035,7 @@ var util = (function () {
createChapterTab: createChapterTab,
syncLoadSampleDoc : syncLoadSampleDoc,
xmlToString: xmlToString,
zeroPad: zeroPad,
convertTableToDiv: convertTableToDiv
zeroPad: zeroPad
};
})();

Expand Down

0 comments on commit f8567ed

Please sign in to comment.