@kedataindo/docflow-core 0.0.69 → 0.0.71
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/ai/index.d.cts +1 -1
- package/dist/ai/index.d.ts +1 -1
- package/dist/{index-CDULnDYX.d.cts → index-BTF6gajh.d.cts} +2 -0
- package/dist/{index-CDULnDYX.d.ts → index-BTF6gajh.d.ts} +2 -0
- package/dist/index.cjs +475 -524
- package/dist/index.d.cts +65 -5
- package/dist/index.d.ts +65 -5
- package/dist/index.js +475 -524
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -402,13 +402,13 @@ function replaceAll(editor, replacement) {
|
|
|
402
402
|
return s.matches.length;
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
-
//
|
|
405
|
+
// src/pagination/PaginationPlus.ts
|
|
406
406
|
import { Extension as Extension4 } from "@tiptap/core";
|
|
407
407
|
import { Plugin as Plugin3, PluginKey as PluginKey3 } from "@tiptap/pm/state";
|
|
408
408
|
import { ReplaceStep, ReplaceAroundStep, AddMarkStep, RemoveMarkStep, RemoveNodeMarkStep, AttrStep } from "@tiptap/pm/transform";
|
|
409
409
|
import { Decoration as Decoration3, DecorationSet as DecorationSet3 } from "@tiptap/pm/view";
|
|
410
410
|
|
|
411
|
-
//
|
|
411
|
+
// src/pagination/utils.ts
|
|
412
412
|
var updateCssVariables = (targetNode, config) => {
|
|
413
413
|
const cssVariables = {
|
|
414
414
|
"rm-page-height": `${config.pageHeight}px`,
|
|
@@ -435,75 +435,32 @@ var getPageSize = (height, width, marginTop, marginBottom, marginLeft, marginRig
|
|
|
435
435
|
marginRight
|
|
436
436
|
};
|
|
437
437
|
};
|
|
438
|
+
var getHeaderHeightSelector = (pageNumber, type) => {
|
|
439
|
+
return type === "actual" ? `.rm-page-header-${pageNumber}` : `.rm-page-header-${pageNumber} .rm-page-header-content`;
|
|
440
|
+
};
|
|
438
441
|
var getHeaderHeight = (targetNode, pageNumbers, type) => {
|
|
439
442
|
const headerHeightMap = /* @__PURE__ */ new Map();
|
|
440
443
|
const clientHeader = targetNode.querySelector(getHeaderHeightSelector(0, type));
|
|
441
444
|
headerHeightMap.set(0, clientHeader ? clientHeader.clientHeight : 0);
|
|
442
445
|
pageNumbers.forEach((pageNumber) => {
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
headerHeightMap.set(pageNumber, headerHeight);
|
|
446
|
+
const ch = targetNode.querySelector(getHeaderHeightSelector(pageNumber, type));
|
|
447
|
+
headerHeightMap.set(pageNumber, ch ? ch.clientHeight : 0);
|
|
446
448
|
});
|
|
447
449
|
return headerHeightMap;
|
|
448
450
|
};
|
|
449
|
-
var
|
|
450
|
-
return type === "actual" ? `.rm-page-
|
|
451
|
+
var getFooterHeightSelector = (pageNumber, type) => {
|
|
452
|
+
return type === "actual" ? `.rm-page-footer-${pageNumber}` : `.rm-page-footer-${pageNumber} .rm-page-footer-content`;
|
|
451
453
|
};
|
|
452
454
|
var getFooterHeight = (targetNode, pageNumbers, type) => {
|
|
453
455
|
const footerHeightMap = /* @__PURE__ */ new Map();
|
|
454
456
|
const clientFooter = targetNode.querySelector(getFooterHeightSelector(0, type));
|
|
455
457
|
footerHeightMap.set(0, clientFooter ? clientFooter.clientHeight : 0);
|
|
456
458
|
pageNumbers.forEach((pageNumber) => {
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
footerHeightMap.set(pageNumber, footerHeight);
|
|
459
|
+
const cf = targetNode.querySelector(getFooterHeightSelector(pageNumber, type));
|
|
460
|
+
footerHeightMap.set(pageNumber, cf ? cf.clientHeight : 0);
|
|
460
461
|
});
|
|
461
462
|
return footerHeightMap;
|
|
462
463
|
};
|
|
463
|
-
var getFooterHeightSelector = (pageNumber, type) => {
|
|
464
|
-
return type === "actual" ? `.rm-page-footer-${pageNumber}` : `.rm-page-footer-${pageNumber} .rm-page-footer-content`;
|
|
465
|
-
};
|
|
466
|
-
function deepEqualIterative(a, b) {
|
|
467
|
-
if (a === b)
|
|
468
|
-
return true;
|
|
469
|
-
if (typeof a !== "object" || typeof b !== "object" || a == null || b == null) {
|
|
470
|
-
return false;
|
|
471
|
-
}
|
|
472
|
-
const stack = [{ x: a, y: b }];
|
|
473
|
-
while (stack.length) {
|
|
474
|
-
const _stackItem = stack.pop();
|
|
475
|
-
if (!_stackItem)
|
|
476
|
-
continue;
|
|
477
|
-
const { x, y } = _stackItem;
|
|
478
|
-
if (x === y)
|
|
479
|
-
continue;
|
|
480
|
-
if (typeof x !== typeof y)
|
|
481
|
-
return false;
|
|
482
|
-
if (typeof x !== "object")
|
|
483
|
-
return false;
|
|
484
|
-
if (x == null || y == null)
|
|
485
|
-
return false;
|
|
486
|
-
const xKeys = Object.keys(x);
|
|
487
|
-
const yKeys = Object.keys(y);
|
|
488
|
-
if (xKeys.length !== yKeys.length)
|
|
489
|
-
return false;
|
|
490
|
-
for (const key2 of xKeys) {
|
|
491
|
-
if (!(key2 in y))
|
|
492
|
-
return false;
|
|
493
|
-
const xVal = x[key2];
|
|
494
|
-
const yVal = y[key2];
|
|
495
|
-
if (xVal === yVal)
|
|
496
|
-
continue;
|
|
497
|
-
if (typeof xVal === "object" && typeof yVal === "object") {
|
|
498
|
-
stack.push({ x: xVal, y: yVal });
|
|
499
|
-
} else {
|
|
500
|
-
if (xVal !== yVal)
|
|
501
|
-
return false;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
return true;
|
|
506
|
-
}
|
|
507
464
|
function getCustomPages(customHeader, customFooter) {
|
|
508
465
|
return [...Object.keys(customHeader), ...Object.keys(customFooter)].map(Number);
|
|
509
466
|
}
|
|
@@ -518,8 +475,8 @@ function getFooter(footerRightContent, footerLeftContent, onFooterClick, pageNum
|
|
|
518
475
|
pageFooterContent.classList.add("rm-page-footer-content");
|
|
519
476
|
pageFooterContent.style.width = "100%";
|
|
520
477
|
pageFooterContent.style.overflow = "hidden";
|
|
521
|
-
const footerRight = footerRightContent.replace("{page}", `<span class="rm-page-number"></span>`);
|
|
522
|
-
const footerLeft = footerLeftContent.replace("{page}", `<span class="rm-page-number"></span>`);
|
|
478
|
+
const footerRight = (footerRightContent || "").replace("{page}", `<span class="rm-page-number"></span>`);
|
|
479
|
+
const footerLeft = (footerLeftContent || "").replace("{page}", `<span class="rm-page-number"></span>`);
|
|
523
480
|
const pageFooterLeft = document.createElement("div");
|
|
524
481
|
pageFooterLeft.classList.add("rm-page-footer-left");
|
|
525
482
|
pageFooterLeft.innerHTML = footerLeft;
|
|
@@ -542,8 +499,8 @@ function getHeader(headerRightContent, headerLeftContent, onHeaderClick, pageNum
|
|
|
542
499
|
pageHeaderContent.classList.add("rm-page-header-content");
|
|
543
500
|
pageHeaderContent.style.width = "100%";
|
|
544
501
|
pageHeaderContent.style.overflow = "hidden";
|
|
545
|
-
const headerLeft = headerLeftContent.replace("{page}", `<span class="rm-page-number-plus"></span>`);
|
|
546
|
-
const headerRight = headerRightContent.replace("{page}", `<span class="rm-page-number-plus"></span>`);
|
|
502
|
+
const headerLeft = (headerLeftContent || "").replace("{page}", `<span class="rm-page-number-plus"></span>`);
|
|
503
|
+
const headerRight = (headerRightContent || "").replace("{page}", `<span class="rm-page-number-plus"></span>`);
|
|
547
504
|
const pageHeaderLeft = document.createElement("div");
|
|
548
505
|
pageHeaderLeft.classList.add("rm-page-header-left");
|
|
549
506
|
pageHeaderLeft.innerHTML = headerLeft;
|
|
@@ -567,22 +524,16 @@ var getHeight = (pageOptions, _headerHeight, _footerHeight) => {
|
|
|
567
524
|
};
|
|
568
525
|
var headerClickEvent = (pageNumber, onHeaderClick) => {
|
|
569
526
|
return (event) => {
|
|
570
|
-
onHeaderClick
|
|
571
|
-
event,
|
|
572
|
-
pageNumber
|
|
573
|
-
});
|
|
527
|
+
onHeaderClick?.({ event, pageNumber });
|
|
574
528
|
};
|
|
575
529
|
};
|
|
576
530
|
var footerClickEvent = (pageNumber, onFooterClick) => {
|
|
577
531
|
return (event) => {
|
|
578
|
-
onFooterClick
|
|
579
|
-
event,
|
|
580
|
-
pageNumber
|
|
581
|
-
});
|
|
532
|
+
onFooterClick?.({ event, pageNumber });
|
|
582
533
|
};
|
|
583
534
|
};
|
|
584
535
|
|
|
585
|
-
//
|
|
536
|
+
// src/pagination/PaginationPlus.ts
|
|
586
537
|
var page_count_meta_key = "PAGE_COUNT_META_KEY";
|
|
587
538
|
var key = new PluginKey3("brDecoration");
|
|
588
539
|
function buildDecorations(doc) {
|
|
@@ -602,7 +553,7 @@ function buildDecorations(doc) {
|
|
|
602
553
|
}
|
|
603
554
|
var defaultPageConfig = {
|
|
604
555
|
enabled: true,
|
|
605
|
-
pageBreakBackground: "#
|
|
556
|
+
pageBreakBackground: "#f1f5f9",
|
|
606
557
|
pageHeight: 800,
|
|
607
558
|
pageWidth: 789,
|
|
608
559
|
marginTop: 20,
|
|
@@ -619,14 +570,17 @@ var defaultPageConfig = {
|
|
|
619
570
|
customHeader: {},
|
|
620
571
|
customFooter: {}
|
|
621
572
|
};
|
|
622
|
-
var defaultOptions =
|
|
573
|
+
var defaultOptions = {
|
|
574
|
+
pageGapBorderSize: 1,
|
|
575
|
+
pageGapBorderColor: "#e5e5e5",
|
|
576
|
+
...defaultPageConfig
|
|
577
|
+
};
|
|
623
578
|
var refreshPage = (targetNode, paginationEnabled = true) => {
|
|
624
|
-
var _a;
|
|
625
579
|
const paginationElement = targetNode.querySelector("[data-rm-pagination]");
|
|
626
580
|
if (paginationEnabled) {
|
|
627
581
|
targetNode.removeAttribute("rm-pagination-disabled");
|
|
628
582
|
if (paginationElement) {
|
|
629
|
-
const lastPageBreak =
|
|
583
|
+
const lastPageBreak = paginationElement.lastElementChild?.querySelector(".breaker");
|
|
630
584
|
if (lastPageBreak) {
|
|
631
585
|
const minHeight = lastPageBreak.offsetTop + lastPageBreak.offsetHeight;
|
|
632
586
|
targetNode.style.minHeight = `calc(${minHeight}px + 2px)`;
|
|
@@ -634,65 +588,304 @@ var refreshPage = (targetNode, paginationEnabled = true) => {
|
|
|
634
588
|
}
|
|
635
589
|
} else {
|
|
636
590
|
targetNode.setAttribute("rm-pagination-disabled", "");
|
|
637
|
-
targetNode.style.minHeight =
|
|
591
|
+
targetNode.style.minHeight = "auto";
|
|
638
592
|
}
|
|
639
593
|
};
|
|
640
594
|
var getPageConfig = (_storage, _currentOptions) => {
|
|
641
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
642
595
|
const pageConfig = {
|
|
643
|
-
enabled:
|
|
644
|
-
pageBreakBackground:
|
|
645
|
-
pageHeight:
|
|
646
|
-
pageWidth:
|
|
647
|
-
marginTop:
|
|
648
|
-
marginBottom:
|
|
649
|
-
marginLeft:
|
|
650
|
-
marginRight:
|
|
651
|
-
pageGap:
|
|
652
|
-
contentMarginTop:
|
|
653
|
-
contentMarginBottom:
|
|
654
|
-
footerRight:
|
|
655
|
-
footerLeft:
|
|
656
|
-
headerRight:
|
|
657
|
-
headerLeft:
|
|
658
|
-
customHeader:
|
|
659
|
-
customFooter:
|
|
596
|
+
enabled: _storage.enabled ?? defaultOptions.enabled,
|
|
597
|
+
pageBreakBackground: _storage.pageBreakBackground ?? defaultOptions.pageBreakBackground,
|
|
598
|
+
pageHeight: _storage.pageHeight ?? defaultOptions.pageHeight,
|
|
599
|
+
pageWidth: _storage.pageWidth ?? defaultPageConfig.pageWidth,
|
|
600
|
+
marginTop: _storage.marginTop ?? defaultPageConfig.marginTop,
|
|
601
|
+
marginBottom: _storage.marginBottom ?? defaultPageConfig.marginBottom,
|
|
602
|
+
marginLeft: _storage.marginLeft ?? defaultPageConfig.marginLeft,
|
|
603
|
+
marginRight: _storage.marginRight ?? defaultPageConfig.marginRight,
|
|
604
|
+
pageGap: _storage.pageGap ?? defaultPageConfig.pageGap,
|
|
605
|
+
contentMarginTop: _storage.contentMarginTop ?? defaultPageConfig.contentMarginTop,
|
|
606
|
+
contentMarginBottom: _storage.contentMarginBottom ?? defaultPageConfig.contentMarginBottom,
|
|
607
|
+
footerRight: _storage.footerRight ?? defaultPageConfig.footerRight,
|
|
608
|
+
footerLeft: _storage.footerLeft ?? defaultPageConfig.footerLeft,
|
|
609
|
+
headerRight: _storage.headerRight ?? defaultPageConfig.headerRight,
|
|
610
|
+
headerLeft: _storage.headerLeft ?? defaultPageConfig.headerLeft,
|
|
611
|
+
customHeader: _storage.customHeader ?? defaultPageConfig.customHeader,
|
|
612
|
+
customFooter: _storage.customFooter ?? defaultPageConfig.customFooter
|
|
660
613
|
};
|
|
661
614
|
return {
|
|
662
615
|
config: pageConfig,
|
|
663
|
-
options:
|
|
616
|
+
options: { ..._currentOptions, ...pageConfig }
|
|
664
617
|
};
|
|
665
618
|
};
|
|
666
619
|
var getPageConfigFromOptions = (_currentOptions) => {
|
|
667
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
668
620
|
return {
|
|
669
|
-
enabled:
|
|
670
|
-
pageBreakBackground:
|
|
671
|
-
pageHeight:
|
|
672
|
-
pageWidth:
|
|
673
|
-
marginTop:
|
|
674
|
-
marginBottom:
|
|
675
|
-
marginLeft:
|
|
676
|
-
marginRight:
|
|
677
|
-
pageGap:
|
|
678
|
-
contentMarginTop:
|
|
679
|
-
contentMarginBottom:
|
|
680
|
-
footerRight:
|
|
681
|
-
footerLeft:
|
|
682
|
-
headerRight:
|
|
683
|
-
headerLeft:
|
|
684
|
-
customHeader:
|
|
685
|
-
customFooter:
|
|
621
|
+
enabled: _currentOptions.enabled ?? defaultOptions.enabled,
|
|
622
|
+
pageBreakBackground: _currentOptions.pageBreakBackground ?? defaultOptions.pageBreakBackground,
|
|
623
|
+
pageHeight: _currentOptions.pageHeight ?? defaultOptions.pageHeight,
|
|
624
|
+
pageWidth: _currentOptions.pageWidth ?? defaultPageConfig.pageWidth,
|
|
625
|
+
marginTop: _currentOptions.marginTop ?? defaultPageConfig.marginTop,
|
|
626
|
+
marginBottom: _currentOptions.marginBottom ?? defaultPageConfig.marginBottom,
|
|
627
|
+
marginLeft: _currentOptions.marginLeft ?? defaultPageConfig.marginLeft,
|
|
628
|
+
marginRight: _currentOptions.marginRight ?? defaultPageConfig.marginRight,
|
|
629
|
+
pageGap: _currentOptions.pageGap ?? defaultPageConfig.pageGap,
|
|
630
|
+
contentMarginTop: _currentOptions.contentMarginTop ?? defaultPageConfig.contentMarginTop,
|
|
631
|
+
contentMarginBottom: _currentOptions.contentMarginBottom ?? defaultPageConfig.contentMarginBottom,
|
|
632
|
+
footerRight: _currentOptions.footerRight ?? defaultPageConfig.footerRight,
|
|
633
|
+
footerLeft: _currentOptions.footerLeft ?? defaultPageConfig.footerLeft,
|
|
634
|
+
headerRight: _currentOptions.headerRight ?? defaultPageConfig.headerRight,
|
|
635
|
+
headerLeft: _currentOptions.headerLeft ?? defaultPageConfig.headerLeft,
|
|
636
|
+
customHeader: _currentOptions.customHeader ?? defaultPageConfig.customHeader,
|
|
637
|
+
customFooter: _currentOptions.customFooter ?? defaultPageConfig.customFooter
|
|
686
638
|
};
|
|
687
639
|
};
|
|
688
640
|
var paginationKey = new PluginKey3("pagination");
|
|
641
|
+
var getExistingPageCount = (view) => {
|
|
642
|
+
const editorDom = view.dom;
|
|
643
|
+
const paginationElement = editorDom.querySelector("[data-rm-pagination]");
|
|
644
|
+
if (paginationElement) {
|
|
645
|
+
return paginationElement.children.length;
|
|
646
|
+
}
|
|
647
|
+
return 0;
|
|
648
|
+
};
|
|
649
|
+
var pageGapTracker = /* @__PURE__ */ new WeakMap();
|
|
650
|
+
var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0) => {
|
|
651
|
+
const editorDom = view.dom;
|
|
652
|
+
const _pageHeaderHeight = pageOptions.contentMarginTop + pageOptions.marginTop + headerHeight;
|
|
653
|
+
const _pageFooterHeight = pageOptions.contentMarginBottom + pageOptions.marginBottom + footerHeight;
|
|
654
|
+
const pageContentAreaHeight = pageOptions.pageHeight - _pageHeaderHeight - _pageFooterHeight;
|
|
655
|
+
const paginationElement = editorDom.querySelector("[data-rm-pagination]");
|
|
656
|
+
const currentPageCount = getExistingPageCount(view);
|
|
657
|
+
if (paginationElement) {
|
|
658
|
+
const lastElementOfEditor = editorDom.lastElementChild;
|
|
659
|
+
const lastPageBreak = paginationElement.lastElementChild?.querySelector(".breaker");
|
|
660
|
+
if (lastElementOfEditor && lastPageBreak) {
|
|
661
|
+
const lastElementRect = lastElementOfEditor.getBoundingClientRect();
|
|
662
|
+
const lastPageBreakRect = lastPageBreak.getBoundingClientRect();
|
|
663
|
+
const lastPageGap = lastElementRect.bottom - lastPageBreakRect.bottom;
|
|
664
|
+
if (lastPageGap > 0) {
|
|
665
|
+
const addPage = Math.ceil(lastPageGap / pageContentAreaHeight);
|
|
666
|
+
if (lastElementRect.height > pageContentAreaHeight) {
|
|
667
|
+
const isSplittableTable = lastElementOfEditor.tagName === "TABLE" && lastElementOfEditor.hasAttribute("data-tps-splittable");
|
|
668
|
+
if (!isSplittableTable) {
|
|
669
|
+
return currentPageCount;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
let totalEditorContentHeight = 0;
|
|
673
|
+
for (const child of Array.from(editorDom.children)) {
|
|
674
|
+
if (!(child instanceof HTMLElement)) continue;
|
|
675
|
+
if (child.hasAttribute("data-rm-pagination")) continue;
|
|
676
|
+
if (child.classList.contains("rm-page-break")) continue;
|
|
677
|
+
totalEditorContentHeight += child.getBoundingClientRect().height;
|
|
678
|
+
}
|
|
679
|
+
const maxPagesByContent = Math.ceil(totalEditorContentHeight / pageContentAreaHeight);
|
|
680
|
+
const contentCap = Math.max(currentPageCount, maxPagesByContent + 1);
|
|
681
|
+
const prev = pageGapTracker.get(editorDom);
|
|
682
|
+
if (prev && prev.pages < currentPageCount && lastPageGap > prev.gap - 2 && currentPageCount >= maxPagesByContent) {
|
|
683
|
+
return currentPageCount;
|
|
684
|
+
}
|
|
685
|
+
const recent = prev?.recent ?? [];
|
|
686
|
+
let flapping = prev?.flapping ?? [];
|
|
687
|
+
if (recent.length >= 4 && recent.filter((p) => p === currentPageCount + addPage).length >= 2 && currentPageCount >= maxPagesByContent) {
|
|
688
|
+
flapping = [.../* @__PURE__ */ new Set([...flapping, currentPageCount + addPage, currentPageCount])];
|
|
689
|
+
pageGapTracker.set(editorDom, { gap: lastPageGap, pages: currentPageCount, recent, flapping });
|
|
690
|
+
return currentPageCount;
|
|
691
|
+
}
|
|
692
|
+
pageGapTracker.set(editorDom, { gap: lastPageGap, pages: currentPageCount, recent, flapping });
|
|
693
|
+
if (currentPageCount + addPage > contentCap) {
|
|
694
|
+
return contentCap;
|
|
695
|
+
}
|
|
696
|
+
const MAX_PAGES = 1e3;
|
|
697
|
+
if (currentPageCount + addPage > MAX_PAGES) {
|
|
698
|
+
return currentPageCount;
|
|
699
|
+
}
|
|
700
|
+
return currentPageCount + addPage;
|
|
701
|
+
} else {
|
|
702
|
+
const allBreaksAfterLastElement = Array.from(paginationElement.querySelectorAll(".breaker"));
|
|
703
|
+
const allBreaksAfterLastElementRect = allBreaksAfterLastElement.filter(
|
|
704
|
+
(element) => element.getBoundingClientRect().top > lastElementRect.bottom
|
|
705
|
+
);
|
|
706
|
+
const removePage = allBreaksAfterLastElementRect.length;
|
|
707
|
+
if (removePage > 1) {
|
|
708
|
+
return currentPageCount - (removePage - 1);
|
|
709
|
+
} else {
|
|
710
|
+
return currentPageCount;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
return 1;
|
|
715
|
+
} else {
|
|
716
|
+
const editorHeight = editorDom.scrollHeight;
|
|
717
|
+
let pageCount = Math.ceil(editorHeight / pageContentAreaHeight);
|
|
718
|
+
pageCount = pageCount <= 0 ? 1 : pageCount;
|
|
719
|
+
return pageCount;
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
var getNewPageCount = (view, pageOptions) => {
|
|
723
|
+
if (pageOptions.enabled) {
|
|
724
|
+
const pageCount = calculatePageCount(view, pageOptions);
|
|
725
|
+
return pageCount <= 1 ? 1 : pageCount;
|
|
726
|
+
} else return 0;
|
|
727
|
+
};
|
|
728
|
+
function createDecoration(pageOptions, headerHeightMap, footerHeightMap) {
|
|
729
|
+
if (!pageOptions.enabled) return [];
|
|
730
|
+
const commonHeaderOptions = {
|
|
731
|
+
headerLeft: pageOptions.headerLeft,
|
|
732
|
+
headerRight: pageOptions.headerRight
|
|
733
|
+
};
|
|
734
|
+
const commonFooterOptions = {
|
|
735
|
+
footerLeft: pageOptions.footerLeft,
|
|
736
|
+
footerRight: pageOptions.footerRight
|
|
737
|
+
};
|
|
738
|
+
return [
|
|
739
|
+
Decoration3.widget(
|
|
740
|
+
0,
|
|
741
|
+
(view) => {
|
|
742
|
+
const _pageGap = pageOptions.pageGap;
|
|
743
|
+
const _pageBreakBackground = pageOptions.pageBreakBackground;
|
|
744
|
+
const el = document.createElement("div");
|
|
745
|
+
el.dataset.rmPagination = "true";
|
|
746
|
+
const pageBreakDefinition = (firstPage, pageHeader, pageFooter, headerHeight, footerHeight, pageNumber) => {
|
|
747
|
+
const { _pageHeaderHeight, _pageHeight } = getHeight(pageOptions, headerHeight, footerHeight);
|
|
748
|
+
const pageContainer = document.createElement("div");
|
|
749
|
+
pageContainer.classList.add("rm-page-break");
|
|
750
|
+
const page = document.createElement("div");
|
|
751
|
+
page.classList.add("page");
|
|
752
|
+
page.style.position = "relative";
|
|
753
|
+
page.style.float = "left";
|
|
754
|
+
page.style.clear = "both";
|
|
755
|
+
const marginTop = firstPage ? `calc(${_pageHeaderHeight}px + ${_pageHeight}px)` : _pageHeight + "px";
|
|
756
|
+
if (pageNumber) {
|
|
757
|
+
page.style.marginTop = `var(--rm-page-content-${pageNumber}, ${marginTop})`;
|
|
758
|
+
} else {
|
|
759
|
+
page.style.marginTop = firstPage ? `var(--rm-page-content-first, ${marginTop})` : `var(--rm-page-content-general, ${marginTop})`;
|
|
760
|
+
}
|
|
761
|
+
const pageBreak = document.createElement("div");
|
|
762
|
+
pageBreak.classList.add("breaker");
|
|
763
|
+
pageBreak.style.width = `calc(100% + var(--rm-margin-left) + var(--rm-margin-right))`;
|
|
764
|
+
pageBreak.style.marginLeft = `calc(-1 * var(--rm-margin-left))`;
|
|
765
|
+
pageBreak.style.marginRight = `calc(-1 * var(--rm-margin-right))`;
|
|
766
|
+
pageBreak.style.position = "relative";
|
|
767
|
+
pageBreak.style.float = "left";
|
|
768
|
+
pageBreak.style.clear = "both";
|
|
769
|
+
pageBreak.style.left = "0px";
|
|
770
|
+
pageBreak.style.right = "0px";
|
|
771
|
+
pageBreak.style.zIndex = "2";
|
|
772
|
+
const pageSpace = document.createElement("div");
|
|
773
|
+
pageSpace.classList.add("rm-pagination-gap");
|
|
774
|
+
pageSpace.style.height = _pageGap + "px";
|
|
775
|
+
pageSpace.style.borderLeft = "1px solid";
|
|
776
|
+
pageSpace.style.borderRight = "1px solid";
|
|
777
|
+
pageSpace.style.position = "relative";
|
|
778
|
+
pageSpace.style.setProperty("width", "calc(100% + 2px)", "important");
|
|
779
|
+
pageSpace.style.left = "-1px";
|
|
780
|
+
pageSpace.style.backgroundColor = _pageBreakBackground;
|
|
781
|
+
pageSpace.style.borderLeftColor = _pageBreakBackground;
|
|
782
|
+
pageSpace.style.borderRightColor = _pageBreakBackground;
|
|
783
|
+
pageBreak.append(pageFooter, pageSpace, pageHeader);
|
|
784
|
+
pageContainer.append(page, pageBreak);
|
|
785
|
+
return pageContainer;
|
|
786
|
+
};
|
|
787
|
+
const _headerHeight = headerHeightMap.get(0) || 0;
|
|
788
|
+
const _footerHeight = footerHeightMap.get(0) || 0;
|
|
789
|
+
const fragment = document.createDocumentFragment();
|
|
790
|
+
const pageCount = getNewPageCount(view, pageOptions);
|
|
791
|
+
for (let i = 0; i < pageCount; i++) {
|
|
792
|
+
const pageNumber = i + 1;
|
|
793
|
+
const headerPageNumber = i + 2;
|
|
794
|
+
if (headerPageNumber in pageOptions.customHeader || pageNumber in pageOptions.customFooter || pageNumber in pageOptions.customHeader) {
|
|
795
|
+
let _headerOptions = commonHeaderOptions;
|
|
796
|
+
let _footerOptions = commonFooterOptions;
|
|
797
|
+
let _pageHeaderHeight = _headerHeight;
|
|
798
|
+
let _pageFooterHeight = _footerHeight;
|
|
799
|
+
if (headerPageNumber in pageOptions.customHeader) {
|
|
800
|
+
_headerOptions = pageOptions.customHeader[headerPageNumber] || commonHeaderOptions;
|
|
801
|
+
_pageHeaderHeight = headerHeightMap.get(headerPageNumber) || 0;
|
|
802
|
+
}
|
|
803
|
+
if (pageNumber in pageOptions.customFooter) {
|
|
804
|
+
_footerOptions = pageOptions.customFooter[pageNumber] || commonFooterOptions;
|
|
805
|
+
_pageFooterHeight = footerHeightMap.get(pageNumber) || 0;
|
|
806
|
+
}
|
|
807
|
+
const _pageHeader = getHeader(
|
|
808
|
+
_headerOptions.headerRight,
|
|
809
|
+
_headerOptions.headerLeft,
|
|
810
|
+
headerClickEvent(headerPageNumber, pageOptions.onHeaderClick),
|
|
811
|
+
headerPageNumber
|
|
812
|
+
);
|
|
813
|
+
const _pageFooter = getFooter(
|
|
814
|
+
_footerOptions.footerRight,
|
|
815
|
+
_footerOptions.footerLeft,
|
|
816
|
+
footerClickEvent(pageNumber, pageOptions.onFooterClick),
|
|
817
|
+
pageNumber
|
|
818
|
+
);
|
|
819
|
+
const pageBreak = pageBreakDefinition(
|
|
820
|
+
i === 0,
|
|
821
|
+
_pageHeader,
|
|
822
|
+
_pageFooter,
|
|
823
|
+
_pageHeaderHeight,
|
|
824
|
+
_pageFooterHeight,
|
|
825
|
+
pageNumber
|
|
826
|
+
);
|
|
827
|
+
fragment.appendChild(pageBreak);
|
|
828
|
+
} else {
|
|
829
|
+
const __pageHeader = getHeader(
|
|
830
|
+
commonHeaderOptions.headerRight,
|
|
831
|
+
commonHeaderOptions.headerLeft,
|
|
832
|
+
headerClickEvent(headerPageNumber, pageOptions.onHeaderClick)
|
|
833
|
+
);
|
|
834
|
+
const __pageFooter = getFooter(
|
|
835
|
+
commonFooterOptions.footerRight,
|
|
836
|
+
commonFooterOptions.footerLeft,
|
|
837
|
+
footerClickEvent(pageNumber, pageOptions.onFooterClick)
|
|
838
|
+
);
|
|
839
|
+
fragment.appendChild(pageBreakDefinition(i === 0, __pageHeader, __pageFooter, _headerHeight, _footerHeight));
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
el.append(fragment);
|
|
843
|
+
el.id = "pages";
|
|
844
|
+
el.classList.add("rm-pages-wrapper");
|
|
845
|
+
return el;
|
|
846
|
+
},
|
|
847
|
+
{ side: -1 }
|
|
848
|
+
),
|
|
849
|
+
Decoration3.widget(
|
|
850
|
+
0,
|
|
851
|
+
() => {
|
|
852
|
+
const pageNumber = 1;
|
|
853
|
+
let _headerOptions = commonHeaderOptions;
|
|
854
|
+
if (pageNumber in pageOptions.customHeader) {
|
|
855
|
+
_headerOptions = pageOptions.customHeader[pageNumber];
|
|
856
|
+
}
|
|
857
|
+
const el = getHeader(
|
|
858
|
+
_headerOptions.headerRight,
|
|
859
|
+
_headerOptions.headerLeft,
|
|
860
|
+
headerClickEvent(pageNumber, pageOptions.onHeaderClick)
|
|
861
|
+
);
|
|
862
|
+
el.classList.add("rm-first-page-header");
|
|
863
|
+
return el;
|
|
864
|
+
},
|
|
865
|
+
{ side: -1 }
|
|
866
|
+
)
|
|
867
|
+
];
|
|
868
|
+
}
|
|
869
|
+
var PAGE_SIZES = {
|
|
870
|
+
A4: getPageSize(1123, 794, 95, 95, 76, 76),
|
|
871
|
+
A3: getPageSize(1591, 1123, 95, 95, 76, 76),
|
|
872
|
+
A5: getPageSize(794, 419, 76, 76, 57, 57),
|
|
873
|
+
LETTER: getPageSize(1060, 818, 96, 96, 96, 96),
|
|
874
|
+
LEGAL: getPageSize(1404, 818, 96, 96, 96, 96),
|
|
875
|
+
TABLOID: getPageSize(1635, 1060, 96, 96, 96, 96)
|
|
876
|
+
};
|
|
689
877
|
var PaginationPlus = Extension4.create({
|
|
690
878
|
name: "PaginationPlus",
|
|
691
879
|
addOptions() {
|
|
692
880
|
return defaultOptions;
|
|
693
881
|
},
|
|
694
882
|
addStorage() {
|
|
695
|
-
return
|
|
883
|
+
return {
|
|
884
|
+
...defaultOptions,
|
|
885
|
+
headerHeight: /* @__PURE__ */ new Map(),
|
|
886
|
+
footerHeight: /* @__PURE__ */ new Map(),
|
|
887
|
+
appliedConfig: defaultPageConfig
|
|
888
|
+
};
|
|
696
889
|
},
|
|
697
890
|
onCreate() {
|
|
698
891
|
const { options: _currentOptions } = getPageConfig(this.storage, this.options);
|
|
@@ -700,210 +893,180 @@ var PaginationPlus = Extension4.create({
|
|
|
700
893
|
const targetNode = this.editor.view.dom;
|
|
701
894
|
targetNode.classList.add("rm-with-pagination");
|
|
702
895
|
targetNode.style.border = `1px solid var(--rm-page-gap-border-color)`;
|
|
703
|
-
targetNode.style.paddingLeft =
|
|
704
|
-
targetNode.style.paddingRight =
|
|
705
|
-
targetNode.style.width =
|
|
706
|
-
updateCssVariables(targetNode,
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
.
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
document.head.appendChild(style);
|
|
896
|
+
targetNode.style.paddingLeft = "var(--rm-margin-left)";
|
|
897
|
+
targetNode.style.paddingRight = "var(--rm-margin-right)";
|
|
898
|
+
targetNode.style.width = "var(--rm-page-width)";
|
|
899
|
+
updateCssVariables(targetNode, { ..._currentOptions, ...pageConfig });
|
|
900
|
+
if (!document.querySelector("style[data-rm-pagination-style]")) {
|
|
901
|
+
const style = document.createElement("style");
|
|
902
|
+
style.dataset.rmPaginationStyle = "";
|
|
903
|
+
style.textContent = `
|
|
904
|
+
.rm-pagination-gap{
|
|
905
|
+
border-top: 1px solid;
|
|
906
|
+
border-bottom: 1px solid;
|
|
907
|
+
border-color: var(--rm-page-gap-border-color);
|
|
908
|
+
}
|
|
909
|
+
.rm-with-pagination,
|
|
910
|
+
.rm-with-pagination .rm-first-page-header {
|
|
911
|
+
counter-reset: page-number page-number-plus 1;
|
|
912
|
+
}
|
|
913
|
+
.rm-with-pagination .image-plus-wrapper,
|
|
914
|
+
.rm-with-pagination .table-plus td,
|
|
915
|
+
.rm-with-pagination .table-plus th {
|
|
916
|
+
max-height: var(--rm-max-content-child-height);
|
|
917
|
+
overflow-y: auto;
|
|
918
|
+
}
|
|
919
|
+
.rm-with-pagination .image-plus-wrapper {
|
|
920
|
+
overflow-y: visible;
|
|
921
|
+
}
|
|
922
|
+
.rm-with-pagination .rm-page-break {
|
|
923
|
+
counter-increment: page-number page-number-plus;
|
|
924
|
+
}
|
|
925
|
+
.rm-with-pagination .rm-page-break:last-child .rm-pagination-gap {
|
|
926
|
+
display: none;
|
|
927
|
+
}
|
|
928
|
+
.rm-with-pagination .rm-page-break:last-child .rm-page-header {
|
|
929
|
+
display: none;
|
|
930
|
+
}
|
|
931
|
+
.rm-with-pagination table tr td,
|
|
932
|
+
.rm-with-pagination table tr th {
|
|
933
|
+
word-break: break-all;
|
|
934
|
+
}
|
|
935
|
+
.rm-with-pagination table > tr {
|
|
936
|
+
display: grid;
|
|
937
|
+
min-width: 100%;
|
|
938
|
+
}
|
|
939
|
+
.rm-with-pagination table {
|
|
940
|
+
border-collapse: collapse;
|
|
941
|
+
width: 100%;
|
|
942
|
+
display: contents;
|
|
943
|
+
}
|
|
944
|
+
.rm-with-pagination table tbody > tr{
|
|
945
|
+
display: table-row !important;
|
|
946
|
+
}
|
|
947
|
+
.rm-with-pagination *:has(>br.ProseMirror-trailingBreak:only-child) {
|
|
948
|
+
display: table;
|
|
949
|
+
width: 100%;
|
|
950
|
+
}
|
|
951
|
+
.rm-with-pagination .rm-br-decoration {
|
|
952
|
+
display: table;
|
|
953
|
+
width: 100%;
|
|
954
|
+
}
|
|
955
|
+
.rm-with-pagination .table-row-group {
|
|
956
|
+
max-height: var(--rm-max-content-child-height);
|
|
957
|
+
overflow-y: auto;
|
|
958
|
+
width: 100%;
|
|
959
|
+
}
|
|
960
|
+
.rm-with-pagination .rm-page-footer-left,
|
|
961
|
+
.rm-with-pagination .rm-page-footer-right,
|
|
962
|
+
.rm-with-pagination .rm-page-header-left,
|
|
963
|
+
.rm-with-pagination .rm-page-header-right {
|
|
964
|
+
display: inline-block;
|
|
965
|
+
}
|
|
966
|
+
.rm-with-pagination .rm-page-header-left,
|
|
967
|
+
.rm-with-pagination .rm-page-footer-left{
|
|
968
|
+
float: left;
|
|
969
|
+
margin-left: var(--rm-margin-left);
|
|
970
|
+
}
|
|
971
|
+
.rm-with-pagination .rm-page-header-right,
|
|
972
|
+
.rm-with-pagination .rm-page-footer-right{
|
|
973
|
+
float: right;
|
|
974
|
+
margin-right: var(--rm-margin-right);
|
|
975
|
+
}
|
|
976
|
+
.rm-with-pagination .rm-first-page-header .rm-page-header-right{
|
|
977
|
+
margin-right: 0px !important;
|
|
978
|
+
}
|
|
979
|
+
.rm-with-pagination .rm-first-page-header .rm-page-header-left{
|
|
980
|
+
margin-left: 0px !important;
|
|
981
|
+
}
|
|
982
|
+
.rm-with-pagination .rm-page-number::before {
|
|
983
|
+
content: counter(page-number);
|
|
984
|
+
}
|
|
985
|
+
.rm-with-pagination .rm-page-number-plus::before {
|
|
986
|
+
content: counter(page-number-plus);
|
|
987
|
+
}
|
|
988
|
+
.rm-with-pagination .rm-page-header,
|
|
989
|
+
.rm-with-pagination .rm-page-footer{
|
|
990
|
+
width: 100%;
|
|
991
|
+
}
|
|
992
|
+
.rm-with-pagination .rm-page-header{
|
|
993
|
+
padding-bottom: var(--rm-content-margin-top) !important;
|
|
994
|
+
padding-top: var(--rm-margin-top) !important;
|
|
995
|
+
display: inline-flex;
|
|
996
|
+
justify-content: space-between;
|
|
997
|
+
max-height: calc(calc(var(--rm-page-height) * 0.45) - var(--rm-margin-top) - var(--rm-content-margin-top));
|
|
998
|
+
overflow-y: hidden;
|
|
999
|
+
}
|
|
1000
|
+
.rm-with-pagination .rm-page-footer{
|
|
1001
|
+
padding-top: var(--rm-content-margin-bottom) !important;
|
|
1002
|
+
padding-bottom: var(--rm-margin-bottom) !important;
|
|
1003
|
+
display: inline-flex;
|
|
1004
|
+
justify-content: space-between;
|
|
1005
|
+
max-height: calc(calc(var(--rm-page-height) * 0.45) - var(--rm-content-margin-bottom) - var(--rm-margin-bottom));
|
|
1006
|
+
overflow-y: hidden;
|
|
1007
|
+
}
|
|
1008
|
+
.rm-with-pagination[rm-pagination-disabled] {
|
|
1009
|
+
padding-top: var(--rm-margin-top) !important;
|
|
1010
|
+
padding-bottom: var(--rm-margin-bottom) !important;
|
|
1011
|
+
}
|
|
1012
|
+
`;
|
|
1013
|
+
document.head.appendChild(style);
|
|
1014
|
+
}
|
|
823
1015
|
refreshPage(targetNode, _currentOptions.enabled);
|
|
824
1016
|
},
|
|
825
1017
|
addProseMirrorPlugins() {
|
|
826
|
-
const editor = this.editor;
|
|
827
1018
|
const storage = this.storage;
|
|
1019
|
+
const options = this.options;
|
|
828
1020
|
return [
|
|
829
1021
|
new Plugin3({
|
|
830
1022
|
key: paginationKey,
|
|
831
1023
|
state: {
|
|
832
|
-
init: (
|
|
833
|
-
|
|
834
|
-
const pageConfig =
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
storage.pageHeight = _currentOptions.pageHeight;
|
|
838
|
-
storage.pageWidth = _currentOptions.pageWidth;
|
|
839
|
-
storage.marginTop = _currentOptions.marginTop;
|
|
840
|
-
storage.marginBottom = _currentOptions.marginBottom;
|
|
841
|
-
storage.marginLeft = _currentOptions.marginLeft;
|
|
842
|
-
storage.marginRight = _currentOptions.marginRight;
|
|
843
|
-
storage.pageGap = _currentOptions.pageGap;
|
|
844
|
-
storage.contentMarginTop = _currentOptions.contentMarginTop;
|
|
845
|
-
storage.contentMarginBottom = _currentOptions.contentMarginBottom;
|
|
846
|
-
storage.footerRight = _currentOptions.footerRight;
|
|
847
|
-
storage.footerLeft = _currentOptions.footerLeft;
|
|
848
|
-
storage.headerRight = _currentOptions.headerRight;
|
|
849
|
-
storage.headerLeft = _currentOptions.headerLeft;
|
|
850
|
-
storage.customHeader = _currentOptions.customHeader;
|
|
851
|
-
storage.customFooter = _currentOptions.customFooter;
|
|
852
|
-
storage.headerHeight = /* @__PURE__ */ new Map();
|
|
853
|
-
storage.footerHeight = /* @__PURE__ */ new Map();
|
|
854
|
-
storage.appliedConfig = pageConfig;
|
|
855
|
-
return {
|
|
856
|
-
decorations: DecorationSet3.create(state.doc, widgetList)
|
|
857
|
-
};
|
|
858
|
-
},
|
|
859
|
-
apply: (tr, oldDeco, oldState, newState) => {
|
|
860
|
-
const { options: _currentOptions, config: pageConfig } = getPageConfig(storage, this.options);
|
|
861
|
-
if (storage.enabled === storage.appliedConfig.enabled && storage.enabled === false && storage.appliedConfig.enabled === false) {
|
|
862
|
-
return oldDeco;
|
|
1024
|
+
init: () => DecorationSet3.empty,
|
|
1025
|
+
apply: (tr, old) => {
|
|
1026
|
+
const { options: _currentOptions, config: pageConfig } = getPageConfig(storage, options);
|
|
1027
|
+
if (!pageConfig.enabled) {
|
|
1028
|
+
return DecorationSet3.empty;
|
|
863
1029
|
}
|
|
864
|
-
const
|
|
865
|
-
const
|
|
866
|
-
const
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
decorations: DecorationSet3.create(newState.doc, [...widgetList]),
|
|
877
|
-
footerHeight
|
|
878
|
-
};
|
|
879
|
-
};
|
|
880
|
-
if (
|
|
881
|
-
// If pagination is enabled only then check for other changes
|
|
882
|
-
(pageCount > 1 ? pageCount : 1) !== currentPageCount || storage.enabled !== storage.appliedConfig.enabled || storage.pageBreakBackground !== storage.appliedConfig.pageBreakBackground || storage.pageHeight !== storage.appliedConfig.pageHeight || storage.pageWidth !== storage.appliedConfig.pageWidth || storage.marginTop !== storage.appliedConfig.marginTop || storage.marginBottom !== storage.appliedConfig.marginBottom || storage.marginLeft !== storage.appliedConfig.marginLeft || storage.marginRight !== storage.appliedConfig.marginRight || storage.pageGap !== storage.appliedConfig.pageGap || storage.contentMarginTop !== storage.appliedConfig.contentMarginTop || storage.contentMarginBottom !== storage.appliedConfig.contentMarginBottom || storage.headerLeft !== storage.appliedConfig.headerLeft || storage.headerRight !== storage.appliedConfig.headerRight || storage.footerLeft !== storage.appliedConfig.footerLeft || storage.footerRight !== storage.appliedConfig.footerRight || !deepEqualIterative(storage.appliedConfig.customHeader, storage.customHeader) || !deepEqualIterative(storage.appliedConfig.customFooter, storage.customFooter)
|
|
883
|
-
) {
|
|
884
|
-
return getNewDecoration();
|
|
1030
|
+
const footerHeight = storage.footerHeight;
|
|
1031
|
+
const headerHeight = storage.headerHeight;
|
|
1032
|
+
const isPageCountChanged = tr.getMeta(page_count_meta_key);
|
|
1033
|
+
if (isPageCountChanged || tr.docChanged) {
|
|
1034
|
+
return DecorationSet3.create(
|
|
1035
|
+
tr.doc,
|
|
1036
|
+
createDecoration(
|
|
1037
|
+
{ ..._currentOptions, ...pageConfig },
|
|
1038
|
+
headerHeight ?? /* @__PURE__ */ new Map(),
|
|
1039
|
+
footerHeight ?? /* @__PURE__ */ new Map()
|
|
1040
|
+
)
|
|
1041
|
+
);
|
|
885
1042
|
}
|
|
886
|
-
return
|
|
1043
|
+
return old;
|
|
887
1044
|
}
|
|
888
1045
|
},
|
|
889
1046
|
props: {
|
|
890
1047
|
decorations(state) {
|
|
891
|
-
|
|
892
|
-
return (_a = this.getState(state)) === null || _a === void 0 ? void 0 : _a.decorations;
|
|
1048
|
+
return paginationKey.getState(state) ?? DecorationSet3.empty;
|
|
893
1049
|
}
|
|
894
1050
|
},
|
|
895
|
-
view: (
|
|
1051
|
+
view: () => {
|
|
896
1052
|
return {
|
|
897
1053
|
update: (view) => {
|
|
898
|
-
const { options: _currentOptions, config: pageConfig } = getPageConfig(storage,
|
|
1054
|
+
const { options: _currentOptions, config: pageConfig } = getPageConfig(storage, options);
|
|
899
1055
|
if (!pageConfig.enabled && !view.dom.hasAttribute("rm-pagination-disabled")) {
|
|
900
1056
|
refreshPage(view.dom, false);
|
|
901
1057
|
return;
|
|
902
1058
|
}
|
|
903
|
-
const pageCount = getNewPageCount(view,
|
|
1059
|
+
const pageCount = getNewPageCount(view, { ..._currentOptions, ...pageConfig });
|
|
904
1060
|
const currentPageCount = getExistingPageCount(view);
|
|
905
1061
|
const triggerUpdate = (_footerHeight) => {
|
|
906
1062
|
requestAnimationFrame(() => {
|
|
1063
|
+
const history = pageGapTracker.get(view.dom);
|
|
1064
|
+
if (history && history.flapping && history.flapping.includes(pageCount)) {
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
if (history && history.recent) {
|
|
1068
|
+
history.recent.push(pageCount);
|
|
1069
|
+
}
|
|
907
1070
|
const tr = view.state.tr.setMeta(page_count_meta_key, { footerHeight: _footerHeight });
|
|
908
1071
|
view.dispatch(tr);
|
|
909
1072
|
});
|
|
@@ -927,7 +1090,7 @@ var PaginationPlus = Extension4.create({
|
|
|
927
1090
|
}
|
|
928
1091
|
}
|
|
929
1092
|
const pagesSetToCheck = /* @__PURE__ */ new Set([1, ...footerHeightForCurrentPages.keys(), ...headerHeightForCurrentPages.keys()]);
|
|
930
|
-
let missingPageNumber
|
|
1093
|
+
let missingPageNumber;
|
|
931
1094
|
for (let i = 1; i <= pageCount; i++) {
|
|
932
1095
|
if (!pagesSetToCheck.has(i)) {
|
|
933
1096
|
missingPageNumber = i;
|
|
@@ -938,18 +1101,18 @@ var PaginationPlus = Extension4.create({
|
|
|
938
1101
|
pagesSetToCheck.add(missingPageNumber);
|
|
939
1102
|
}
|
|
940
1103
|
pagesSetToCheck.delete(0);
|
|
941
|
-
|
|
942
|
-
let maxContentHeight
|
|
1104
|
+
const pageContentHeightVariable = {};
|
|
1105
|
+
let maxContentHeight;
|
|
943
1106
|
for (const page of pagesSetToCheck) {
|
|
944
|
-
const
|
|
945
|
-
const
|
|
946
|
-
const { _pageHeaderHeight, _pageHeight } = getHeight(_currentOptions,
|
|
1107
|
+
const hHeight = headerHeightForCurrentPages.has(page) ? headerHeightForCurrentPages.get(page) || 0 : headerHeightForCurrentPages.get(0) || 0;
|
|
1108
|
+
const fHeight = footerHeightForCurrentPages.has(page) ? footerHeightForCurrentPages.get(page) || 0 : footerHeightForCurrentPages.get(0) || 0;
|
|
1109
|
+
const { _pageHeaderHeight, _pageHeight } = getHeight(_currentOptions, hHeight, fHeight);
|
|
947
1110
|
const contentHeight = page === 1 ? _pageHeight + _pageHeaderHeight : _pageHeight;
|
|
948
1111
|
if (page === 1) {
|
|
949
|
-
pageContentHeightVariable[
|
|
1112
|
+
pageContentHeightVariable["rm-page-content-first"] = `${contentHeight}px`;
|
|
950
1113
|
}
|
|
951
1114
|
if (page === missingPageNumber) {
|
|
952
|
-
pageContentHeightVariable[
|
|
1115
|
+
pageContentHeightVariable["rm-page-content-general"] = `${contentHeight}px`;
|
|
953
1116
|
} else {
|
|
954
1117
|
pageContentHeightVariable[`rm-page-content-${page}`] = `${contentHeight}px`;
|
|
955
1118
|
}
|
|
@@ -958,13 +1121,14 @@ var PaginationPlus = Extension4.create({
|
|
|
958
1121
|
}
|
|
959
1122
|
}
|
|
960
1123
|
if (maxContentHeight) {
|
|
961
|
-
|
|
1124
|
+
;
|
|
1125
|
+
view.dom.style.setProperty("--rm-max-content-child-height", `${maxContentHeight - 10}px`);
|
|
962
1126
|
}
|
|
963
|
-
Object.entries(pageContentHeightVariable).forEach(([
|
|
964
|
-
|
|
1127
|
+
Object.entries(pageContentHeightVariable).forEach(([k, value]) => {
|
|
1128
|
+
;
|
|
1129
|
+
view.dom.style.setProperty(`--${k}`, value);
|
|
965
1130
|
});
|
|
966
1131
|
refreshPage(view.dom, _currentOptions.enabled);
|
|
967
|
-
return;
|
|
968
1132
|
}
|
|
969
1133
|
};
|
|
970
1134
|
}
|
|
@@ -976,7 +1140,9 @@ var PaginationPlus = Extension4.create({
|
|
|
976
1140
|
return buildDecorations(state.doc);
|
|
977
1141
|
},
|
|
978
1142
|
apply(tr, old) {
|
|
979
|
-
if (tr.docChanged || tr.steps.some(
|
|
1143
|
+
if (tr.docChanged || tr.steps.some(
|
|
1144
|
+
(step) => step instanceof ReplaceStep || step instanceof ReplaceAroundStep || step instanceof AddMarkStep || step instanceof RemoveMarkStep || step instanceof RemoveNodeMarkStep || step instanceof AttrStep
|
|
1145
|
+
)) {
|
|
980
1146
|
return buildDecorations(tr.doc);
|
|
981
1147
|
}
|
|
982
1148
|
return old;
|
|
@@ -984,8 +1150,7 @@ var PaginationPlus = Extension4.create({
|
|
|
984
1150
|
},
|
|
985
1151
|
props: {
|
|
986
1152
|
decorations(state) {
|
|
987
|
-
|
|
988
|
-
return (_a = key.getState(state)) !== null && _a !== void 0 ? _a : DecorationSet3.empty;
|
|
1153
|
+
return key.getState(state) ?? DecorationSet3.empty;
|
|
989
1154
|
}
|
|
990
1155
|
}
|
|
991
1156
|
})
|
|
@@ -1025,31 +1190,14 @@ var PaginationPlus = Extension4.create({
|
|
|
1025
1190
|
this.storage.marginRight = margins.right;
|
|
1026
1191
|
return true;
|
|
1027
1192
|
},
|
|
1028
|
-
|
|
1029
|
-
this.storage.
|
|
1030
|
-
this.storage.
|
|
1193
|
+
updateHeaderContent: (left, right) => () => {
|
|
1194
|
+
if (left !== void 0) this.storage.headerLeft = left;
|
|
1195
|
+
if (right !== void 0) this.storage.headerRight = right;
|
|
1031
1196
|
return true;
|
|
1032
1197
|
},
|
|
1033
|
-
|
|
1034
|
-
if (
|
|
1035
|
-
|
|
1036
|
-
} else {
|
|
1037
|
-
this.storage.headerLeft = left;
|
|
1038
|
-
this.storage.headerRight = right;
|
|
1039
|
-
}
|
|
1040
|
-
return true;
|
|
1041
|
-
},
|
|
1042
|
-
updateFooterContent: (left, right, pageNumber) => () => {
|
|
1043
|
-
if (pageNumber) {
|
|
1044
|
-
this.storage.customFooter = Object.assign(Object.assign({}, this.storage.customFooter), { [pageNumber]: { footerLeft: left, footerRight: right } });
|
|
1045
|
-
} else {
|
|
1046
|
-
this.storage.footerLeft = left;
|
|
1047
|
-
this.storage.footerRight = right;
|
|
1048
|
-
}
|
|
1049
|
-
return true;
|
|
1050
|
-
},
|
|
1051
|
-
togglePagination: () => () => {
|
|
1052
|
-
this.storage.enabled = !this.storage.enabled;
|
|
1198
|
+
updateFooterContent: (left, right) => () => {
|
|
1199
|
+
if (left !== void 0) this.storage.footerLeft = left;
|
|
1200
|
+
if (right !== void 0) this.storage.footerRight = right;
|
|
1053
1201
|
return true;
|
|
1054
1202
|
},
|
|
1055
1203
|
enablePagination: () => () => {
|
|
@@ -1063,203 +1211,6 @@ var PaginationPlus = Extension4.create({
|
|
|
1063
1211
|
};
|
|
1064
1212
|
}
|
|
1065
1213
|
});
|
|
1066
|
-
var getExistingPageCount = (view) => {
|
|
1067
|
-
const editorDom = view.dom;
|
|
1068
|
-
const paginationElement = editorDom.querySelector("[data-rm-pagination]");
|
|
1069
|
-
if (paginationElement) {
|
|
1070
|
-
return paginationElement.children.length;
|
|
1071
|
-
}
|
|
1072
|
-
return 0;
|
|
1073
|
-
};
|
|
1074
|
-
var pageGapTracker = /* @__PURE__ */ new WeakMap();
|
|
1075
|
-
var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0) => {
|
|
1076
|
-
var _a;
|
|
1077
|
-
const editorDom = view.dom;
|
|
1078
|
-
const _pageHeaderHeight = pageOptions.contentMarginTop + pageOptions.marginTop + headerHeight;
|
|
1079
|
-
const _pageFooterHeight = pageOptions.contentMarginBottom + pageOptions.marginBottom + footerHeight;
|
|
1080
|
-
const pageContentAreaHeight = pageOptions.pageHeight - _pageHeaderHeight - _pageFooterHeight;
|
|
1081
|
-
const paginationElement = editorDom.querySelector("[data-rm-pagination]");
|
|
1082
|
-
const currentPageCount = getExistingPageCount(view);
|
|
1083
|
-
if (paginationElement) {
|
|
1084
|
-
const lastElementOfEditor = editorDom.lastElementChild;
|
|
1085
|
-
const lastPageBreak = (_a = paginationElement.lastElementChild) === null || _a === void 0 ? void 0 : _a.querySelector(".breaker");
|
|
1086
|
-
if (lastElementOfEditor && lastPageBreak) {
|
|
1087
|
-
const lastElementRect = lastElementOfEditor.getBoundingClientRect();
|
|
1088
|
-
const lastPageBreakRect = lastPageBreak.getBoundingClientRect();
|
|
1089
|
-
const lastPageGap = lastElementRect.bottom - lastPageBreakRect.bottom;
|
|
1090
|
-
if (lastPageGap > 0) {
|
|
1091
|
-
const addPage = Math.ceil(lastPageGap / pageContentAreaHeight);
|
|
1092
|
-
if (lastElementRect.height > pageContentAreaHeight) {
|
|
1093
|
-
const isSplittableTable = (lastElementOfEditor === null || lastElementOfEditor === void 0 ? void 0 : lastElementOfEditor.tagName) === "TABLE" && lastElementOfEditor.hasAttribute("data-tps-splittable");
|
|
1094
|
-
if (!isSplittableTable) {
|
|
1095
|
-
return currentPageCount;
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
const prev = pageGapTracker.get(editorDom);
|
|
1099
|
-
if (prev && prev.pages < currentPageCount && lastPageGap > prev.gap - 2) {
|
|
1100
|
-
return currentPageCount;
|
|
1101
|
-
}
|
|
1102
|
-
pageGapTracker.set(editorDom, { gap: lastPageGap, pages: currentPageCount });
|
|
1103
|
-
let totalEditorContentHeight = 0;
|
|
1104
|
-
for (const child of editorDom.children) {
|
|
1105
|
-
if (!(child instanceof HTMLElement)) continue;
|
|
1106
|
-
if (child.hasAttribute("data-rm-pagination")) continue;
|
|
1107
|
-
if (child.classList.contains("rm-page-break")) continue;
|
|
1108
|
-
totalEditorContentHeight += child.getBoundingClientRect().height;
|
|
1109
|
-
}
|
|
1110
|
-
const maxPagesByContent = Math.ceil(totalEditorContentHeight / pageContentAreaHeight);
|
|
1111
|
-
const contentCap = Math.max(currentPageCount, maxPagesByContent + 1);
|
|
1112
|
-
if (currentPageCount + addPage > contentCap) {
|
|
1113
|
-
return contentCap;
|
|
1114
|
-
}
|
|
1115
|
-
const MAX_PAGES = 1e3;
|
|
1116
|
-
if (currentPageCount + addPage > MAX_PAGES) {
|
|
1117
|
-
return currentPageCount;
|
|
1118
|
-
}
|
|
1119
|
-
return currentPageCount + addPage;
|
|
1120
|
-
} else {
|
|
1121
|
-
pageGapTracker.delete(editorDom);
|
|
1122
|
-
const allBreaksAfterLastElement = Array.from(paginationElement.querySelectorAll(".breaker"));
|
|
1123
|
-
const allBreaksAfterLastElementRect = allBreaksAfterLastElement.filter((element) => element.getBoundingClientRect().top > lastElementRect.bottom);
|
|
1124
|
-
const removePage = allBreaksAfterLastElementRect.length;
|
|
1125
|
-
if (removePage > 1) {
|
|
1126
|
-
return currentPageCount - removePage;
|
|
1127
|
-
} else {
|
|
1128
|
-
return currentPageCount;
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
return 1;
|
|
1133
|
-
} else {
|
|
1134
|
-
const editorHeight = editorDom.scrollHeight;
|
|
1135
|
-
let pageCount = Math.ceil(editorHeight / pageContentAreaHeight);
|
|
1136
|
-
pageCount = pageCount <= 0 ? 1 : pageCount;
|
|
1137
|
-
return pageCount;
|
|
1138
|
-
}
|
|
1139
|
-
};
|
|
1140
|
-
var getNewPageCount = (view, pageOptions) => {
|
|
1141
|
-
if (pageOptions.enabled) {
|
|
1142
|
-
const pageCount = calculatePageCount(view, pageOptions);
|
|
1143
|
-
return pageCount <= 1 ? 1 : pageCount;
|
|
1144
|
-
} else {
|
|
1145
|
-
return 0;
|
|
1146
|
-
}
|
|
1147
|
-
};
|
|
1148
|
-
function createDecoration(pageOptions, headerHeightMap, footerHeightMap) {
|
|
1149
|
-
if (!pageOptions.enabled) {
|
|
1150
|
-
return [];
|
|
1151
|
-
}
|
|
1152
|
-
const commonHeaderOptions = { headerLeft: pageOptions.headerLeft, headerRight: pageOptions.headerRight };
|
|
1153
|
-
const commonFooterOptions = { footerLeft: pageOptions.footerLeft, footerRight: pageOptions.footerRight };
|
|
1154
|
-
const pageWidget = Decoration3.widget(0, (view) => {
|
|
1155
|
-
const _pageGap = pageOptions.pageGap;
|
|
1156
|
-
const _pageBreakBackground = pageOptions.pageBreakBackground;
|
|
1157
|
-
const el = document.createElement("div");
|
|
1158
|
-
el.dataset.rmPagination = "true";
|
|
1159
|
-
const pageBreakDefinition = (firstPage, pageHeader, pageFooter, headerHeight, footerHeight, pageNumber) => {
|
|
1160
|
-
const { _pageHeaderHeight, _pageHeight } = getHeight(pageOptions, headerHeight, footerHeight);
|
|
1161
|
-
const pageContainer = document.createElement("div");
|
|
1162
|
-
pageContainer.classList.add("rm-page-break");
|
|
1163
|
-
const page = document.createElement("div");
|
|
1164
|
-
page.classList.add("page");
|
|
1165
|
-
page.style.position = "relative";
|
|
1166
|
-
page.style.float = "left";
|
|
1167
|
-
page.style.clear = "both";
|
|
1168
|
-
const marginTop = firstPage ? `calc(${_pageHeaderHeight}px + ${_pageHeight}px)` : _pageHeight + "px";
|
|
1169
|
-
if (pageNumber) {
|
|
1170
|
-
page.style.marginTop = `var(--rm-page-content-${pageNumber}, ${marginTop})`;
|
|
1171
|
-
} else {
|
|
1172
|
-
page.style.marginTop = firstPage ? `var(--rm-page-content-first, ${marginTop})` : `var(--rm-page-content-general, ${marginTop})`;
|
|
1173
|
-
}
|
|
1174
|
-
const pageBreak = document.createElement("div");
|
|
1175
|
-
pageBreak.classList.add("breaker");
|
|
1176
|
-
pageBreak.style.width = `calc(100% + var(--rm-margin-left) + var(--rm-margin-right))`;
|
|
1177
|
-
pageBreak.style.marginLeft = `calc(-1 * var(--rm-margin-left))`;
|
|
1178
|
-
pageBreak.style.marginRight = `calc(-1 * var(--rm-margin-right))`;
|
|
1179
|
-
pageBreak.style.position = "relative";
|
|
1180
|
-
pageBreak.style.float = "left";
|
|
1181
|
-
pageBreak.style.clear = "both";
|
|
1182
|
-
pageBreak.style.left = `0px`;
|
|
1183
|
-
pageBreak.style.right = `0px`;
|
|
1184
|
-
pageBreak.style.zIndex = "2";
|
|
1185
|
-
const pageSpace = document.createElement("div");
|
|
1186
|
-
pageSpace.classList.add("rm-pagination-gap");
|
|
1187
|
-
pageSpace.style.height = _pageGap + "px";
|
|
1188
|
-
pageSpace.style.borderLeft = "1px solid";
|
|
1189
|
-
pageSpace.style.borderRight = "1px solid";
|
|
1190
|
-
pageSpace.style.position = "relative";
|
|
1191
|
-
pageSpace.style.setProperty("width", "calc(100% + 2px)", "important");
|
|
1192
|
-
pageSpace.style.left = "-1px";
|
|
1193
|
-
pageSpace.style.backgroundColor = _pageBreakBackground;
|
|
1194
|
-
pageSpace.style.borderLeftColor = _pageBreakBackground;
|
|
1195
|
-
pageSpace.style.borderRightColor = _pageBreakBackground;
|
|
1196
|
-
pageBreak.append(pageFooter, pageSpace, pageHeader);
|
|
1197
|
-
pageContainer.append(page, pageBreak);
|
|
1198
|
-
return pageContainer;
|
|
1199
|
-
};
|
|
1200
|
-
const _headerHeight = headerHeightMap.get(0) || 0;
|
|
1201
|
-
const _footerHeight = footerHeightMap.get(0) || 0;
|
|
1202
|
-
const fragment = document.createDocumentFragment();
|
|
1203
|
-
const pageCount = getNewPageCount(view, pageOptions);
|
|
1204
|
-
for (let i = 0; i < pageCount; i++) {
|
|
1205
|
-
const pageNumber = i + 1;
|
|
1206
|
-
const headerPageNumber = i + 2;
|
|
1207
|
-
if (headerPageNumber in pageOptions.customHeader || pageNumber in pageOptions.customFooter || pageNumber in pageOptions.customHeader) {
|
|
1208
|
-
let _headerOptions = commonHeaderOptions;
|
|
1209
|
-
let _footerOptions = commonFooterOptions;
|
|
1210
|
-
let _pageHeaderHeight = _headerHeight;
|
|
1211
|
-
let _pageFooterHeight = _footerHeight;
|
|
1212
|
-
if (headerPageNumber in pageOptions.customHeader) {
|
|
1213
|
-
_headerOptions = pageOptions.customHeader[headerPageNumber] || commonHeaderOptions;
|
|
1214
|
-
_pageHeaderHeight = headerHeightMap.get(headerPageNumber) || 0;
|
|
1215
|
-
}
|
|
1216
|
-
if (pageNumber in pageOptions.customFooter) {
|
|
1217
|
-
_footerOptions = pageOptions.customFooter[pageNumber] || commonFooterOptions;
|
|
1218
|
-
_pageFooterHeight = footerHeightMap.get(pageNumber) || 0;
|
|
1219
|
-
}
|
|
1220
|
-
let _pageHeader = getHeader(_headerOptions.headerRight, _headerOptions.headerLeft, headerClickEvent(headerPageNumber, pageOptions.onHeaderClick), headerPageNumber);
|
|
1221
|
-
let _pageFooter = getFooter(_footerOptions.footerRight, _footerOptions.footerLeft, footerClickEvent(pageNumber, pageOptions.onFooterClick), pageNumber);
|
|
1222
|
-
let pageBreak = pageBreakDefinition(i === 0, _pageHeader, _pageFooter, _pageHeaderHeight, _pageFooterHeight, pageNumber);
|
|
1223
|
-
fragment.appendChild(pageBreak);
|
|
1224
|
-
} else {
|
|
1225
|
-
const __pageHeader = getHeader(commonHeaderOptions.headerRight, commonHeaderOptions.headerLeft, headerClickEvent(headerPageNumber, pageOptions.onHeaderClick));
|
|
1226
|
-
const __pageFooter = getFooter(commonFooterOptions.footerRight, commonFooterOptions.footerLeft, footerClickEvent(pageNumber, pageOptions.onFooterClick));
|
|
1227
|
-
fragment.appendChild(pageBreakDefinition(i === 0, __pageHeader, __pageFooter, _headerHeight, _footerHeight));
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
el.append(fragment);
|
|
1231
|
-
el.id = "pages";
|
|
1232
|
-
el.classList.add("rm-pages-wrapper");
|
|
1233
|
-
return el;
|
|
1234
|
-
}, { side: -1 });
|
|
1235
|
-
const firstHeaderWidget = Decoration3.widget(0, () => {
|
|
1236
|
-
const pageNumber = 1;
|
|
1237
|
-
let _headerOptions = commonHeaderOptions;
|
|
1238
|
-
if (pageNumber in pageOptions.customHeader) {
|
|
1239
|
-
_headerOptions = pageOptions.customHeader[pageNumber];
|
|
1240
|
-
}
|
|
1241
|
-
const el = getHeader(_headerOptions.headerRight, _headerOptions.headerLeft, headerClickEvent(pageNumber, pageOptions.onHeaderClick));
|
|
1242
|
-
el.classList.add("rm-first-page-header");
|
|
1243
|
-
return el;
|
|
1244
|
-
}, { side: -1 });
|
|
1245
|
-
return [pageWidget, firstHeaderWidget];
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
// ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=4857789ba5672a185fb96bdd854e03e0c6ec8ed26abfeea_16730b2b361cd3f71113c52459ed62fd/node_modules/tiptap-pagination-plus/dist/constants.js
|
|
1249
|
-
var A4_PAGE_SIZE = getPageSize(1123, 794, 95, 95, 76, 76);
|
|
1250
|
-
var A3_PAGE_SIZE = getPageSize(1591, 1123, 95, 95, 76, 76);
|
|
1251
|
-
var A5_PAGE_SIZE = getPageSize(794, 419, 76, 76, 57, 57);
|
|
1252
|
-
var LETTER_PAGE_SIZE = getPageSize(1060, 818, 96, 96, 96, 96);
|
|
1253
|
-
var LEGAL_PAGE_SIZE = getPageSize(1404, 818, 96, 96, 96, 96);
|
|
1254
|
-
var TABLOID_PAGE_SIZE = getPageSize(1635, 1060, 96, 96, 96, 96);
|
|
1255
|
-
var PAGE_SIZES = {
|
|
1256
|
-
A4: A4_PAGE_SIZE,
|
|
1257
|
-
A3: A3_PAGE_SIZE,
|
|
1258
|
-
A5: A5_PAGE_SIZE,
|
|
1259
|
-
LETTER: LETTER_PAGE_SIZE,
|
|
1260
|
-
LEGAL: LEGAL_PAGE_SIZE,
|
|
1261
|
-
TABLOID: TABLOID_PAGE_SIZE
|
|
1262
|
-
};
|
|
1263
1214
|
|
|
1264
1215
|
// src/PerformanceMonitor.ts
|
|
1265
1216
|
var TARGET_FRAME_MS = 1e3 / 60;
|