@vishu1301/script-writing 1.6.0 → 1.6.2
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 +10 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2397,7 +2397,7 @@ function createRangeFromGlobalOffset(element, startOffset, endOffset) {
|
|
|
2397
2397
|
function useScreenplayEditor(options) {
|
|
2398
2398
|
var _a;
|
|
2399
2399
|
const [blocks, setBlocks] = useState(
|
|
2400
|
-
(options == null ? void 0 : options.blocks) || initialBlocks
|
|
2400
|
+
(options == null ? void 0 : options.blocks) || initialBlocks
|
|
2401
2401
|
);
|
|
2402
2402
|
const hasInitializedRef = useRef(
|
|
2403
2403
|
!!((options == null ? void 0 : options.blocks) && options.blocks.length > 0)
|
|
@@ -2521,13 +2521,17 @@ function useScreenplayEditor(options) {
|
|
|
2521
2521
|
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
2522
2522
|
};
|
|
2523
2523
|
}, [autosaveStatus]);
|
|
2524
|
+
const autosaveStatusRef = useRef(autosaveStatus);
|
|
2525
|
+
useEffect(() => {
|
|
2526
|
+
autosaveStatusRef.current = autosaveStatus;
|
|
2527
|
+
}, [autosaveStatus]);
|
|
2524
2528
|
useEffect(() => {
|
|
2525
2529
|
return () => {
|
|
2526
|
-
if (
|
|
2530
|
+
if (autosaveStatusRef.current === "typing" && onSaveRef.current) {
|
|
2527
2531
|
onSaveRef.current(latestBlocksRef.current);
|
|
2528
2532
|
}
|
|
2529
2533
|
};
|
|
2530
|
-
}, [
|
|
2534
|
+
}, []);
|
|
2531
2535
|
const characterExtensions = useMemo(
|
|
2532
2536
|
() => ["(V.O.)", "(O.S.)", "(O.C.)", "(SUBTITLE)", "(CONT'D)"],
|
|
2533
2537
|
[]
|
|
@@ -3082,6 +3086,9 @@ function useScreenplayEditor(options) {
|
|
|
3082
3086
|
}
|
|
3083
3087
|
}
|
|
3084
3088
|
}
|
|
3089
|
+
if (onSaveRef.current && !isInitialLoad) {
|
|
3090
|
+
onSaveRef.current(finalizedBlocks);
|
|
3091
|
+
}
|
|
3085
3092
|
setTimeout(() => {
|
|
3086
3093
|
var _a2;
|
|
3087
3094
|
const firstId = parsedBlocks[0].id;
|