export const EPUB_HTML_TAGS = new Set(
"a,abbr,address,area,article,aside,audio,b,base,bdi,bdo,blockquote,body,br,button,canvas,caption,cite,code,col,colgroup,data,datalist,dd,del,details,dfn,dialog,div,dl,dt,em,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,img,input,ins,kbd,label,legend,li,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,optgroup,option,output,p,picture,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,search,section,select,slot,small,source,span,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,u,ul,var,video,wbr".split(
","
)
);
export const EPUB_HTML_VOID_TAGS = new Set(
"area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr".split(",")
);
export const HTML_FRAME_STYLE =
'';
// The isolated document follows the Reader (not the OS) and keeps width
// constraints inside the frame. Spreadsheets use their own two-axis viewport.
export const HTML_PROSE_STYLE = ``;
// Layout for sanitized content separated from its archived website shell.
export const CLEAN_WEB_HTML_STYLE = ``;
// The recognized article's fixed-width archive shell is not a data table.
export const LEGACY_ARTICLE_HTML_STYLE = ``;
// Reflow only the validated post shells; authored tables inside posts stay tables.
export const PHPWIND_HTML_STYLE = ``;
export const DISCOURSE_POST_SELECTOR = ".topic-post .cooked";
export const DISCOURSE_TITLE_SELECTOR = "#topic-title .fancy-title, .topic-link, title";
// Constrain content to the reading column, even in a wide viewport.
export const EBOOK_LAYOUT_STYLE = `
.reader-ebook-table-scroll { display: block; }
.epub-frame > .reader-epub-chapter {
min-inline-size: 0;
overflow-x: auto;
}
.epub-frame > .reader-epub-chapter
:is(article, aside, blockquote, dd, div, dl, dt, figure, figcaption, footer, header,
h1, h2, h3, h4, h5, h6, li, main, ol, p, section, ul):not(pre *, svg *, math *) {
box-sizing: border-box !important;
min-inline-size: 0 !important;
max-inline-size: 100% !important;
}
.epub-frame > .reader-epub-chapter
:where(:not(pre, pre *, svg, svg *, math, math *)) {
/* Change the wrap mode without collapsing authored spaces or newlines. */
text-wrap-mode: wrap !important;
overflow-wrap: anywhere !important;
}
@supports not (text-wrap-mode: wrap) {
.epub-frame > .reader-epub-chapter
:where(:not(pre, pre *, svg, svg *, math, math *)) { white-space: normal !important; }
}
.epub-frame > .reader-epub-chapter :is(img, svg, video, canvas):not(svg *, math *) {
min-inline-size: 0 !important;
max-inline-size: 100% !important;
block-size: auto !important;
}
.epub-frame > .reader-epub-chapter :is(pre, .reader-ebook-table-scroll) {
box-sizing: border-box !important;
min-inline-size: 0 !important;
max-inline-size: 100% !important;
overflow-x: auto !important;
}`;
/** @param {HTMLElement} body */
export function wrapEbookTables(body) {
for (const table of body.querySelectorAll("table")) {
if (table.matches("[data-reader-legacy-article]") ||
table.parentElement?.closest("table:not([data-reader-legacy-article])")) continue;
const region = body.ownerDocument.createElement("div");
region.className = "reader-ebook-table-scroll";
region.tabIndex = 0;
region.setAttribute("role", "region");
region.setAttribute("aria-label", table.caption?.textContent?.trim() || "书内表格");
table.before(region);
region.appendChild(table);
}
}
export const DISCOURSE_HTML_STYLE = ``;
export const SPREADSHEET_HTML_STYLE = ``;