@kedataindo/docflow-core 0.0.77 → 0.0.79
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/index.cjs +39 -16
- package/dist/index.js +39 -16
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -627,6 +627,28 @@ var footerClickEvent = (pageNumber, onFooterClick) => {
|
|
|
627
627
|
};
|
|
628
628
|
};
|
|
629
629
|
|
|
630
|
+
// src/pagination/pageCount.ts
|
|
631
|
+
var MAX_PAGES = 1e3;
|
|
632
|
+
function grownPageCount(input) {
|
|
633
|
+
const { currentPageCount, lastPageGap, pageContentAreaHeight, maxPagesByContent } = input;
|
|
634
|
+
if (!(lastPageGap > 0) || !(pageContentAreaHeight > 0)) {
|
|
635
|
+
return currentPageCount;
|
|
636
|
+
}
|
|
637
|
+
const addPage = Math.ceil(lastPageGap / pageContentAreaHeight);
|
|
638
|
+
if (!Number.isFinite(addPage) || addPage <= 0) {
|
|
639
|
+
return currentPageCount;
|
|
640
|
+
}
|
|
641
|
+
const contentCap = Math.max(currentPageCount, maxPagesByContent + 1);
|
|
642
|
+
const desired = currentPageCount + addPage;
|
|
643
|
+
if (desired > contentCap) {
|
|
644
|
+
return contentCap;
|
|
645
|
+
}
|
|
646
|
+
if (desired > MAX_PAGES) {
|
|
647
|
+
return currentPageCount;
|
|
648
|
+
}
|
|
649
|
+
return desired;
|
|
650
|
+
}
|
|
651
|
+
|
|
630
652
|
// src/pagination/PaginationPlus.ts
|
|
631
653
|
var page_count_meta_key = "PAGE_COUNT_META_KEY";
|
|
632
654
|
var key = new import_state3.PluginKey("brDecoration");
|
|
@@ -740,6 +762,16 @@ var getExistingPageCount = (view) => {
|
|
|
740
762
|
}
|
|
741
763
|
return 0;
|
|
742
764
|
};
|
|
765
|
+
var lastContentChild = (editorDom) => {
|
|
766
|
+
for (let i = editorDom.children.length - 1; i >= 0; i--) {
|
|
767
|
+
const child = editorDom.children[i];
|
|
768
|
+
if (!(child instanceof HTMLElement)) continue;
|
|
769
|
+
if (child.hasAttribute("data-rm-pagination")) continue;
|
|
770
|
+
if (child.classList.contains("rm-page-break")) continue;
|
|
771
|
+
return child;
|
|
772
|
+
}
|
|
773
|
+
return null;
|
|
774
|
+
};
|
|
743
775
|
var pageGapTracker = /* @__PURE__ */ new WeakMap();
|
|
744
776
|
var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0) => {
|
|
745
777
|
const editorDom = view.dom;
|
|
@@ -749,7 +781,7 @@ var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0)
|
|
|
749
781
|
const paginationElement = editorDom.querySelector("[data-rm-pagination]");
|
|
750
782
|
const currentPageCount = getExistingPageCount(view);
|
|
751
783
|
if (paginationElement) {
|
|
752
|
-
const lastElementOfEditor = editorDom
|
|
784
|
+
const lastElementOfEditor = lastContentChild(editorDom);
|
|
753
785
|
const lastPageBreak = paginationElement.lastElementChild?.querySelector(".breaker");
|
|
754
786
|
if (lastElementOfEditor && lastPageBreak) {
|
|
755
787
|
const lastElementRect = lastElementOfEditor.getBoundingClientRect();
|
|
@@ -757,12 +789,6 @@ var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0)
|
|
|
757
789
|
const lastPageGap = lastElementRect.bottom - lastPageBreakRect.bottom;
|
|
758
790
|
if (lastPageGap > 0) {
|
|
759
791
|
const addPage = Math.ceil(lastPageGap / pageContentAreaHeight);
|
|
760
|
-
if (lastElementRect.height > pageContentAreaHeight) {
|
|
761
|
-
const isSplittableTable = lastElementOfEditor.tagName === "TABLE" && lastElementOfEditor.hasAttribute("data-tps-splittable");
|
|
762
|
-
if (!isSplittableTable) {
|
|
763
|
-
return currentPageCount;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
792
|
let totalEditorContentHeight = 0;
|
|
767
793
|
for (const child of Array.from(editorDom.children)) {
|
|
768
794
|
if (!(child instanceof HTMLElement)) continue;
|
|
@@ -771,7 +797,6 @@ var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0)
|
|
|
771
797
|
totalEditorContentHeight += child.getBoundingClientRect().height;
|
|
772
798
|
}
|
|
773
799
|
const maxPagesByContent = Math.ceil(totalEditorContentHeight / pageContentAreaHeight);
|
|
774
|
-
const contentCap = Math.max(currentPageCount, maxPagesByContent + 1);
|
|
775
800
|
const prev = pageGapTracker.get(editorDom);
|
|
776
801
|
if (prev && prev.pages < currentPageCount && lastPageGap > prev.gap - 2 && currentPageCount >= maxPagesByContent) {
|
|
777
802
|
return currentPageCount;
|
|
@@ -784,14 +809,12 @@ var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0)
|
|
|
784
809
|
return currentPageCount;
|
|
785
810
|
}
|
|
786
811
|
pageGapTracker.set(editorDom, { gap: lastPageGap, pages: currentPageCount, recent, flapping });
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
}
|
|
794
|
-
return currentPageCount + addPage;
|
|
812
|
+
return grownPageCount({
|
|
813
|
+
currentPageCount,
|
|
814
|
+
lastPageGap,
|
|
815
|
+
pageContentAreaHeight,
|
|
816
|
+
maxPagesByContent
|
|
817
|
+
});
|
|
795
818
|
} else {
|
|
796
819
|
const allBreaksAfterLastElement = Array.from(paginationElement.querySelectorAll(".breaker"));
|
|
797
820
|
const allBreaksAfterLastElementRect = allBreaksAfterLastElement.filter(
|
package/dist/index.js
CHANGED
|
@@ -436,6 +436,28 @@ var footerClickEvent = (pageNumber, onFooterClick) => {
|
|
|
436
436
|
};
|
|
437
437
|
};
|
|
438
438
|
|
|
439
|
+
// src/pagination/pageCount.ts
|
|
440
|
+
var MAX_PAGES = 1e3;
|
|
441
|
+
function grownPageCount(input) {
|
|
442
|
+
const { currentPageCount, lastPageGap, pageContentAreaHeight, maxPagesByContent } = input;
|
|
443
|
+
if (!(lastPageGap > 0) || !(pageContentAreaHeight > 0)) {
|
|
444
|
+
return currentPageCount;
|
|
445
|
+
}
|
|
446
|
+
const addPage = Math.ceil(lastPageGap / pageContentAreaHeight);
|
|
447
|
+
if (!Number.isFinite(addPage) || addPage <= 0) {
|
|
448
|
+
return currentPageCount;
|
|
449
|
+
}
|
|
450
|
+
const contentCap = Math.max(currentPageCount, maxPagesByContent + 1);
|
|
451
|
+
const desired = currentPageCount + addPage;
|
|
452
|
+
if (desired > contentCap) {
|
|
453
|
+
return contentCap;
|
|
454
|
+
}
|
|
455
|
+
if (desired > MAX_PAGES) {
|
|
456
|
+
return currentPageCount;
|
|
457
|
+
}
|
|
458
|
+
return desired;
|
|
459
|
+
}
|
|
460
|
+
|
|
439
461
|
// src/pagination/PaginationPlus.ts
|
|
440
462
|
var page_count_meta_key = "PAGE_COUNT_META_KEY";
|
|
441
463
|
var key = new PluginKey3("brDecoration");
|
|
@@ -549,6 +571,16 @@ var getExistingPageCount = (view) => {
|
|
|
549
571
|
}
|
|
550
572
|
return 0;
|
|
551
573
|
};
|
|
574
|
+
var lastContentChild = (editorDom) => {
|
|
575
|
+
for (let i = editorDom.children.length - 1; i >= 0; i--) {
|
|
576
|
+
const child = editorDom.children[i];
|
|
577
|
+
if (!(child instanceof HTMLElement)) continue;
|
|
578
|
+
if (child.hasAttribute("data-rm-pagination")) continue;
|
|
579
|
+
if (child.classList.contains("rm-page-break")) continue;
|
|
580
|
+
return child;
|
|
581
|
+
}
|
|
582
|
+
return null;
|
|
583
|
+
};
|
|
552
584
|
var pageGapTracker = /* @__PURE__ */ new WeakMap();
|
|
553
585
|
var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0) => {
|
|
554
586
|
const editorDom = view.dom;
|
|
@@ -558,7 +590,7 @@ var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0)
|
|
|
558
590
|
const paginationElement = editorDom.querySelector("[data-rm-pagination]");
|
|
559
591
|
const currentPageCount = getExistingPageCount(view);
|
|
560
592
|
if (paginationElement) {
|
|
561
|
-
const lastElementOfEditor = editorDom
|
|
593
|
+
const lastElementOfEditor = lastContentChild(editorDom);
|
|
562
594
|
const lastPageBreak = paginationElement.lastElementChild?.querySelector(".breaker");
|
|
563
595
|
if (lastElementOfEditor && lastPageBreak) {
|
|
564
596
|
const lastElementRect = lastElementOfEditor.getBoundingClientRect();
|
|
@@ -566,12 +598,6 @@ var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0)
|
|
|
566
598
|
const lastPageGap = lastElementRect.bottom - lastPageBreakRect.bottom;
|
|
567
599
|
if (lastPageGap > 0) {
|
|
568
600
|
const addPage = Math.ceil(lastPageGap / pageContentAreaHeight);
|
|
569
|
-
if (lastElementRect.height > pageContentAreaHeight) {
|
|
570
|
-
const isSplittableTable = lastElementOfEditor.tagName === "TABLE" && lastElementOfEditor.hasAttribute("data-tps-splittable");
|
|
571
|
-
if (!isSplittableTable) {
|
|
572
|
-
return currentPageCount;
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
601
|
let totalEditorContentHeight = 0;
|
|
576
602
|
for (const child of Array.from(editorDom.children)) {
|
|
577
603
|
if (!(child instanceof HTMLElement)) continue;
|
|
@@ -580,7 +606,6 @@ var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0)
|
|
|
580
606
|
totalEditorContentHeight += child.getBoundingClientRect().height;
|
|
581
607
|
}
|
|
582
608
|
const maxPagesByContent = Math.ceil(totalEditorContentHeight / pageContentAreaHeight);
|
|
583
|
-
const contentCap = Math.max(currentPageCount, maxPagesByContent + 1);
|
|
584
609
|
const prev = pageGapTracker.get(editorDom);
|
|
585
610
|
if (prev && prev.pages < currentPageCount && lastPageGap > prev.gap - 2 && currentPageCount >= maxPagesByContent) {
|
|
586
611
|
return currentPageCount;
|
|
@@ -593,14 +618,12 @@ var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0)
|
|
|
593
618
|
return currentPageCount;
|
|
594
619
|
}
|
|
595
620
|
pageGapTracker.set(editorDom, { gap: lastPageGap, pages: currentPageCount, recent, flapping });
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
}
|
|
603
|
-
return currentPageCount + addPage;
|
|
621
|
+
return grownPageCount({
|
|
622
|
+
currentPageCount,
|
|
623
|
+
lastPageGap,
|
|
624
|
+
pageContentAreaHeight,
|
|
625
|
+
maxPagesByContent
|
|
626
|
+
});
|
|
604
627
|
} else {
|
|
605
628
|
const allBreaksAfterLastElement = Array.from(paginationElement.querySelectorAll(".breaker"));
|
|
606
629
|
const allBreaksAfterLastElementRect = allBreaksAfterLastElement.filter(
|