vobi_document 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/print.cjs +41 -6
- package/dist/print.cjs.map +1 -1
- package/dist/print.js +41 -6
- package/dist/print.js.map +1 -1
- package/package.json +1 -1
package/dist/print.cjs
CHANGED
|
@@ -156,6 +156,36 @@ var REPEAT_TABLE_HEADERS = `(function () {
|
|
|
156
156
|
return ancestors;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
function isIgnorable(node) {
|
|
160
|
+
return node.nodeType === 8 || (node.nodeType === 3 && !node.textContent.trim());
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function nextSignificantNode(node) {
|
|
164
|
+
var sibling = node.nextSibling;
|
|
165
|
+
while (sibling) {
|
|
166
|
+
if (!isIgnorable(sibling)) return sibling;
|
|
167
|
+
sibling = sibling.nextSibling;
|
|
168
|
+
}
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function nodeAfter(node, limiter) {
|
|
173
|
+
if (limiter && node === limiter) return null;
|
|
174
|
+
var significant = nextSignificantNode(node);
|
|
175
|
+
if (significant) return significant;
|
|
176
|
+
var current = node;
|
|
177
|
+
while ((current = current.parentNode)) {
|
|
178
|
+
if (limiter && current === limiter) return null;
|
|
179
|
+
significant = nextSignificantNode(current);
|
|
180
|
+
if (significant) return significant;
|
|
181
|
+
}
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function hasChildTag(el, tag) {
|
|
186
|
+
return Array.prototype.slice.call(el.children).some(function (child) { return child.tagName === tag; });
|
|
187
|
+
}
|
|
188
|
+
|
|
159
189
|
class RepeatingTableHeaders extends window.Paged.Handler {
|
|
160
190
|
constructor(chunker, polisher, caller) {
|
|
161
191
|
super(chunker, polisher, caller);
|
|
@@ -177,7 +207,8 @@ var REPEAT_TABLE_HEADERS = `(function () {
|
|
|
177
207
|
var thead = node.tagName === 'THEAD' ? node : findFirstAncestor(node, 'thead');
|
|
178
208
|
if (thead) {
|
|
179
209
|
var lastTheadNode = thead.hasChildNodes() ? thead.lastChild : thead;
|
|
180
|
-
|
|
210
|
+
var next = nodeAfter(lastTheadNode, chunker.source);
|
|
211
|
+
if (next) breakToken.node = next;
|
|
181
212
|
}
|
|
182
213
|
}
|
|
183
214
|
|
|
@@ -188,12 +219,16 @@ var REPEAT_TABLE_HEADERS = `(function () {
|
|
|
188
219
|
if (!renderedTable || renderedTable.getAttribute('data-repeated-headers')) return;
|
|
189
220
|
var sourceTable = self.chunker.source.querySelector("[data-ref='" + ref + "']");
|
|
190
221
|
if (!sourceTable) return;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
222
|
+
if (!hasChildTag(renderedTable, 'COLGROUP')) {
|
|
223
|
+
var firstChild = renderedTable.firstChild;
|
|
224
|
+
sourceTable.querySelectorAll('colgroup').forEach(function (colgroup) {
|
|
225
|
+
renderedTable.insertBefore(colgroup.cloneNode(true), firstChild);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
195
228
|
var thead = sourceTable.querySelector('thead');
|
|
196
|
-
if (thead
|
|
229
|
+
if (thead && !hasChildTag(renderedTable, 'THEAD')) {
|
|
230
|
+
renderedTable.insertBefore(thead.cloneNode(true), renderedTable.firstChild);
|
|
231
|
+
}
|
|
197
232
|
renderedTable.setAttribute('data-repeated-headers', 'true');
|
|
198
233
|
});
|
|
199
234
|
}
|