Skip to content

Commit 4d7cdfe

Browse files
committed
wip
1 parent cf2af62 commit 4d7cdfe

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

patches/tiptap-pagination-plus+3.0.5.patch

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/node_modules/tiptap-pagination-plus/dist/PaginationPlus.js b/node_modules/tiptap-pagination-plus/dist/PaginationPlus.js
2-
index 52bd368..60f19f5 100644
2+
index 52bd368..0b4d0d7 100644
33
--- a/node_modules/tiptap-pagination-plus/dist/PaginationPlus.js
44
+++ b/node_modules/tiptap-pagination-plus/dist/PaginationPlus.js
55
@@ -59,7 +59,11 @@ export const PaginationPlus = Extension.create({
@@ -26,7 +26,7 @@ index 52bd368..60f19f5 100644
2626
.rm-with-pagination .rm-br-decoration {
2727
display: table;
2828
width: 100%;
29-
@@ -202,36 +202,28 @@ export const PaginationPlus = Extension.create({
29+
@@ -202,36 +202,35 @@ export const PaginationPlus = Extension.create({
3030
};
3131
},
3232
apply: (tr, oldDeco, oldState, newState) => {
@@ -37,7 +37,14 @@ index 52bd368..60f19f5 100644
3737
+ return oldDeco;
3838
+ }
3939
+
40-
+ const opts = editor.storage.PaginationPlus
40+
+ const opts = editor.storage.PaginationPlus;
41+
+ const forceUpdate = tr.getMeta('pageFormatUpdate') || tr.getMeta('forcePaginationUpdate');
42+
+ const isInitialized = oldDeco && oldDeco.decorations && typeof oldDeco.decorations.find === 'function' && oldDeco.decorations.find().length > 0;
43+
+
44+
+ if (!tr.docChanged && !forceUpdate && isInitialized) {
45+
+ return oldDeco;
46+
+ }
47+
+
4148
+ const pageCount = calculatePageCount(currentView, opts);
4249
+ const currentPageCount = getExistingPageCount(currentView);
4350
+
@@ -77,7 +84,7 @@ index 52bd368..60f19f5 100644
7784
return getNewDecoration();
7885
}
7986
return oldDeco;
80-
@@ -246,7 +238,8 @@ export const PaginationPlus = Extension.create({
87+
@@ -246,7 +245,8 @@ export const PaginationPlus = Extension.create({
8188
view: (editorView) => {
8289
return {
8390
update: (view) => {
@@ -87,7 +94,7 @@ index 52bd368..60f19f5 100644
8794
const currentPageCount = getExistingPageCount(view);
8895
const triggerUpdate = (_footerHeight) => {
8996
requestAnimationFrame(() => {
90-
@@ -258,8 +251,8 @@ export const PaginationPlus = Extension.create({
97+
@@ -258,8 +258,8 @@ export const PaginationPlus = Extension.create({
9198
triggerUpdate();
9299
return;
93100
}
@@ -98,16 +105,34 @@ index 52bd368..60f19f5 100644
98105
const footerHeightForCurrentPages = new Map();
99106
for (let i = 0; i <= pageCount; i++) {
100107
if (footerHeight.has(i)) {
101-
@@ -289,7 +282,7 @@ export const PaginationPlus = Extension.create({
108+
@@ -289,8 +289,24 @@ export const PaginationPlus = Extension.create({
102109
for (const page of pagesSetToCheck) {
103110
const headerHeight = headerHeightForCurrentPages.has(page) ? headerHeightForCurrentPages.get(page) || 0 : headerHeightForCurrentPages.get(0) || 0;
104111
const footerHeight = footerHeightForCurrentPages.has(page) ? footerHeightForCurrentPages.get(page) || 0 : footerHeightForCurrentPages.get(0) || 0;
105112
- const { _pageHeaderHeight, _pageHeight } = getHeight(this.options, headerHeight, footerHeight);
113+
- const contentHeight = page === 1 ? _pageHeight + _pageHeaderHeight : _pageHeight;
106114
+ const { _pageHeaderHeight, _pageHeight } = getHeight(opts, headerHeight, footerHeight);
107-
const contentHeight = page === 1 ? _pageHeight + _pageHeaderHeight : _pageHeight;
115+
+ let contentHeight = page === 1 ? _pageHeight + _pageHeaderHeight : _pageHeight;
116+
+
117+
+ // --- ORPHAN PREVENTION OVERRIDE ---
118+
+ // Find any text node below this page that forces a break
119+
+ // To know which forced break belongs to this page, we look at the DOM
120+
+ // The paragraphs are visually ordered.
121+
+ // It's easiest to let the orphan-prevention-extension assign a specific data attribute for the page.
122+
+ // If the node has data-forced-page="1", we use its value.
123+
+ const domForcedNode = view.dom.querySelector(`[data-forced-page="${page}"]`);
124+
+ if (domForcedNode) {
125+
+ const forceOffset = parseFloat(domForcedNode.getAttribute('data-force-page-break-offset'));
126+
+ if (!isNaN(forceOffset) && forceOffset > 0) {
127+
+ contentHeight = forceOffset;
128+
+ }
129+
+ }
130+
+ // --- END ORPHAN PREVENTION OVERRIDE ---
131+
+
108132
if (page === 1) {
109133
pageContentHeightVariable[`rm-page-content-first`] = `${contentHeight}px`;
110-
@@ -347,65 +340,74 @@ export const PaginationPlus = Extension.create({
134+
}
135+
@@ -347,65 +363,74 @@ export const PaginationPlus = Extension.create({
111136
addCommands() {
112137
return {
113138
updatePageBreakBackground: (color) => () => {

src/lib/screenplay/editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ export const useScriptioEditor = (
500500
sceneBookmarkExtension,
501501
sceneNumberRightExtension,
502502
sceneIdDedupExtension,
503-
commentMarkExtension,
503+
/*commentMarkExtension,*/
504504
],
505505

506506
onSelectionUpdate({ editor, transaction }) {

0 commit comments

Comments
 (0)