Skip to content

Commit b3d66a3

Browse files
committed
bump to staging
1 parent 4d7cdfe commit b3d66a3

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

src/lib/screenplay/editor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,10 @@ export const useScriptioEditor = (
481481
footerRight: "",
482482
...SCREENPLAY_FORMATS[pageSize],
483483
}),
484-
/*OrphanPreventionExtension.configure({
484+
OrphanPreventionExtension.configure({
485485
getContdLabel: () => contdLabelRef.current,
486-
getMoreLabel: () => moreLabelRef.current
487-
}),*/
486+
getMoreLabel: () => moreLabelRef.current,
487+
}),
488488
KeybindsExtension.configure({
489489
userKeybinds: userKeybinds || {},
490490
onAction: (id, editorInstance) => {
@@ -500,7 +500,7 @@ export const useScriptioEditor = (
500500
sceneBookmarkExtension,
501501
sceneNumberRightExtension,
502502
sceneIdDedupExtension,
503-
/*commentMarkExtension,*/
503+
commentMarkExtension,
504504
],
505505

506506
onSelectionUpdate({ editor, transaction }) {

src/lib/screenplay/extensions/orphan-prevention-extension.ts

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ export interface OrphanPreventionExtensionOptions {
3434
getMoreLabel: () => string;
3535
}
3636

37-
async function computeAndDispatch(view: EditorView, isCancelled: () => boolean, options: OrphanPreventionOptions): Promise<void> {
37+
async function computeAndDispatch(
38+
view: EditorView,
39+
isCancelled: () => boolean,
40+
options: OrphanPreventionOptions,
41+
): Promise<void> {
3842
const editorDom = view.dom as HTMLElement;
3943
const editorTop = editorDom.getBoundingClientRect().top;
4044

@@ -69,31 +73,31 @@ async function computeAndDispatch(view: EditorView, isCancelled: () => boolean,
6973
lastNodeHeight = pRect.height;
7074
} else break;
7175
}
72-
76+
7377
if (lastNode) {
7478
// Red: node that straddles the page break (debug reference).
7579
try {
7680
const pos = view.posAtDOM(lastNode, 0);
7781
const resolved = view.state.doc.resolve(pos);
7882
const start = resolved.before(resolved.depth);
79-
80-
const isStraddling = (lastNodeTop + lastNodeHeight) > (breakerTop + 6);
81-
83+
84+
const isStraddling = lastNodeTop + lastNodeHeight > breakerTop + 6;
85+
8286
// Clear labels for this specific gap synchronously to avoid flashing across yields
83-
gapEl.querySelectorAll(".injected-dialogue-label").forEach(el => el.remove());
84-
87+
gapEl.querySelectorAll(".injected-dialogue-label").forEach((el) => el.remove());
88+
8589
// Debug visually: Highlight the strictly identified `lastNode` right before the page gap.
8690
decorations.push(
8791
Decoration.node(start, start + resolved.parent.nodeSize, {
88-
style: "background-color: rgba(255, 0, 0, 0.2) !important; outline: 2px solid red;",
89-
class: "orphan-debug-last-node"
90-
})
92+
/*style: "background-color: rgba(255, 0, 0, 0.2) !important; outline: 2px solid red;",*/
93+
class: "orphan-debug-last-node",
94+
}),
9195
);
9296

9397
// If it's dialogue straddling a page break (actually physically crossing the breaker gap)
9498
if (isStraddling && lastNode.classList.contains("dialogue")) {
9599
const computedStyle = window.getComputedStyle(lastNode);
96-
100+
97101
const moreElem = document.createElement("div");
98102
moreElem.className = "injected-dialogue-label";
99103
moreElem.innerText = options.getMoreLabel();
@@ -104,7 +108,7 @@ async function computeAndDispatch(view: EditorView, isCancelled: () => boolean,
104108
moreElem.style.textAlign = "center";
105109
moreElem.style.pointerEvents = "none";
106110
moreElem.style.zIndex = "10";
107-
111+
108112
moreElem.style.fontFamily = computedStyle.fontFamily;
109113
moreElem.style.fontSize = computedStyle.fontSize;
110114
moreElem.style.color = computedStyle.color;
@@ -121,7 +125,9 @@ async function computeAndDispatch(view: EditorView, isCancelled: () => boolean,
121125

122126
const contElem = document.createElement("div");
123127
contElem.className = "injected-dialogue-label";
124-
contElem.innerText = characterName ? `${characterName} ${options.getContdLabel()}` : options.getContdLabel();
128+
contElem.innerText = characterName
129+
? `${characterName} ${options.getContdLabel()}`
130+
: options.getContdLabel();
125131
contElem.style.position = "absolute";
126132
contElem.style.bottom = "0px";
127133
contElem.style.left = "0px";
@@ -130,12 +136,12 @@ async function computeAndDispatch(view: EditorView, isCancelled: () => boolean,
130136
contElem.style.pointerEvents = "none";
131137
contElem.style.zIndex = "10";
132138
contElem.style.textTransform = "uppercase";
133-
139+
134140
contElem.style.fontFamily = computedStyle.fontFamily;
135141
contElem.style.fontSize = computedStyle.fontSize;
136142
contElem.style.lineHeight = computedStyle.lineHeight;
137143
contElem.style.color = computedStyle.color;
138-
144+
139145
gapEl.appendChild(moreElem);
140146
gapEl.appendChild(contElem);
141147
} else if (isStraddling) {
@@ -160,7 +166,7 @@ async function computeAndDispatch(view: EditorView, isCancelled: () => boolean,
160166

161167
export const OrphanPreventionExtension = Extension.create<OrphanPreventionExtensionOptions>({
162168
name: "orphanPrevention",
163-
169+
164170
addOptions() {
165171
return {
166172
getContdLabel: () => "(CONT'D)",
@@ -191,16 +197,16 @@ export const OrphanPreventionExtension = Extension.create<OrphanPreventionExtens
191197
apply(tr, old, _, newState) {
192198
const meta = tr.getMeta(pluginKey);
193199
if (meta instanceof DecorationSet) return { decos: meta, version: old.version };
194-
200+
195201
let nextDecos = old.decos;
196202
if (tr.docChanged) {
197203
nextDecos = old.decos.map(tr.mapping, newState.doc);
198204
}
199-
205+
200206
if (meta === "force-update" || tr.docChanged) {
201207
return { decos: nextDecos, version: old.version + 1 };
202208
}
203-
209+
204210
return old;
205211
},
206212
},
@@ -243,7 +249,9 @@ export const OrphanPreventionExtension = Extension.create<OrphanPreventionExtens
243249
const currPluginState = pluginKey.getState(view.state);
244250
if (
245251
view.state.doc !== prev.doc ||
246-
(prevPluginState && currPluginState && prevPluginState.version !== currPluginState.version)
252+
(prevPluginState &&
253+
currPluginState &&
254+
prevPluginState.version !== currPluginState.version)
247255
) {
248256
schedule();
249257
}

0 commit comments

Comments
 (0)