Prism_1 = tslib_1.__importDefault(Prism_1);
PrismHelper = tslib_1.__importStar(PrismHelper);
prism_meta_1 = tslib_1.__importDefault(prism_meta_1);
- const CHUNK_SIZE = 50;
async function waitForIdle() {
return new Promise((resolve, _reject) => {
if (window.requestIdleCallback) {
await waitForIdle();
const originalLines = this.codeContainer.querySelectorAll(".codeBoxLine > span");
const highlightedLines = PrismHelper.splitIntoLines(container);
- for (let chunkStart = 0, max = originalLines.length; chunkStart < max; chunkStart += CHUNK_SIZE) {
+ for (let chunkStart = 0, max = originalLines.length; chunkStart < max; chunkStart += Code.chunkSize) {
await waitForIdle();
- const chunkEnd = Math.min(chunkStart + CHUNK_SIZE, max);
+ const chunkEnd = Math.min(chunkStart + Code.chunkSize, max);
for (let offset = chunkStart; offset < chunkEnd; offset++) {
const toReplace = originalLines[offset];
const replacement = highlightedLines.next().value;
this.container.classList.add("highlighted");
}
}
+ Code.chunkSize = 50;
return Code;
});
import * as PrismHelper from "../Prism/Helper";
import PrismMeta from "../prism-meta";
-const CHUNK_SIZE = 50;
-
async function waitForIdle(): Promise<void> {
return new Promise((resolve, _reject) => {
if ((window as any).requestIdleCallback) {
}
class Code {
+ private static readonly chunkSize = 50;
+
private readonly container: HTMLElement;
private codeContainer: HTMLElement;
private language: string | undefined;
const originalLines = this.codeContainer.querySelectorAll(".codeBoxLine > span");
const highlightedLines = PrismHelper.splitIntoLines(container);
- for (let chunkStart = 0, max = originalLines.length; chunkStart < max; chunkStart += CHUNK_SIZE) {
+ for (let chunkStart = 0, max = originalLines.length; chunkStart < max; chunkStart += Code.chunkSize) {
await waitForIdle();
- const chunkEnd = Math.min(chunkStart + CHUNK_SIZE, max);
+ const chunkEnd = Math.min(chunkStart + Code.chunkSize, max);
for (let offset = chunkStart; offset < chunkEnd; offset++) {
const toReplace = originalLines[offset]!;