refactor code + propre

This commit is contained in:
Valentin
2024-02-06 17:28:48 +01:00
parent 903c9a993e
commit abc1b70eb5
42 changed files with 1752 additions and 1338 deletions
@@ -1,5 +1,5 @@
/**
* @license Paged.js v0.4.2 | MIT | https://gitlab.coko.foundation/pagedjs/pagedjs
* @license Paged.js v0.4.3 | MIT | https://gitlab.coko.foundation/pagedjs/pagedjs
*/
(function (global, factory) {
@@ -1418,6 +1418,7 @@
this.hooks = hooks;
} else {
this.hooks = {};
this.hooks.onPageLayout = new Hook();
this.hooks.layout = new Hook();
this.hooks.renderNode = new Hook();
this.hooks.layoutNode = new Hook();
@@ -1425,6 +1426,7 @@
this.hooks.onOverflow = new Hook();
this.hooks.afterOverflowRemoved = new Hook();
this.hooks.onBreakToken = new Hook();
this.hooks.beforeRenderResult = new Hook();
}
this.settings = options || {};
@@ -1449,6 +1451,8 @@
let prevBreakToken = breakToken || new BreakToken(start);
this.hooks && this.hooks.onPageLayout.trigger(wrapper, prevBreakToken, this);
while (!done && !newBreakToken) {
next = walker.next();
prevNode = node;
@@ -1467,11 +1471,13 @@
if (newBreakToken && newBreakToken.equals(prevBreakToken)) {
console.warn("Unable to layout item: ", prevNode);
this.hooks && this.hooks.beforeRenderResult.trigger(undefined, wrapper, this);
return new RenderResult(undefined, new OverflowContentError("Unable to layout item", [prevNode]));
}
this.rebuildTableFromBreakToken(newBreakToken, wrapper);
this.hooks && this.hooks.beforeRenderResult.trigger(newBreakToken, wrapper, this);
return new RenderResult(newBreakToken);
}
@@ -1577,6 +1583,7 @@
if (after) {
newBreakToken = new BreakToken(after);
} else {
this.hooks && this.hooks.beforeRenderResult.trigger(undefined, wrapper, this);
return new RenderResult(undefined, new OverflowContentError("Unable to layout item", [node]));
}
}
@@ -1584,6 +1591,7 @@
}
this.hooks && this.hooks.beforeRenderResult.trigger(newBreakToken, wrapper, this);
return new RenderResult(newBreakToken);
}
@@ -2840,12 +2848,14 @@
this.hooks.filter = new Hook(this);
this.hooks.afterParsed = new Hook(this);
this.hooks.beforePageLayout = new Hook(this);
this.hooks.onPageLayout = new Hook(this);
this.hooks.layout = new Hook(this);
this.hooks.renderNode = new Hook(this);
this.hooks.layoutNode = new Hook(this);
this.hooks.onOverflow = new Hook(this);
this.hooks.afterOverflowRemoved = new Hook(this);
this.hooks.onBreakToken = new Hook();
this.hooks.beforeRenderResult = new Hook(this);
this.hooks.afterPageLayout = new Hook(this);
this.hooks.finalizePage = new Hook(this);
this.hooks.afterRendered = new Hook(this);