@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 CHANGED
@@ -2425,7 +2425,7 @@ function createRangeFromGlobalOffset(element, startOffset, endOffset) {
2425
2425
  function useScreenplayEditor(options) {
2426
2426
  var _a;
2427
2427
  const [blocks, setBlocks] = React4.useState(
2428
- (options == null ? void 0 : options.blocks) || initialBlocks || []
2428
+ (options == null ? void 0 : options.blocks) || initialBlocks
2429
2429
  );
2430
2430
  const hasInitializedRef = React4.useRef(
2431
2431
  !!((options == null ? void 0 : options.blocks) && options.blocks.length > 0)
@@ -2549,13 +2549,17 @@ function useScreenplayEditor(options) {
2549
2549
  window.removeEventListener("beforeunload", handleBeforeUnload);
2550
2550
  };
2551
2551
  }, [autosaveStatus]);
2552
+ const autosaveStatusRef = React4.useRef(autosaveStatus);
2553
+ React4.useEffect(() => {
2554
+ autosaveStatusRef.current = autosaveStatus;
2555
+ }, [autosaveStatus]);
2552
2556
  React4.useEffect(() => {
2553
2557
  return () => {
2554
- if (autosaveStatus === "typing" && onSaveRef.current) {
2558
+ if (autosaveStatusRef.current === "typing" && onSaveRef.current) {
2555
2559
  onSaveRef.current(latestBlocksRef.current);
2556
2560
  }
2557
2561
  };
2558
- }, [autosaveStatus]);
2562
+ }, []);
2559
2563
  const characterExtensions = React4.useMemo(
2560
2564
  () => ["(V.O.)", "(O.S.)", "(O.C.)", "(SUBTITLE)", "(CONT'D)"],
2561
2565
  []
@@ -3110,6 +3114,9 @@ function useScreenplayEditor(options) {
3110
3114
  }
3111
3115
  }
3112
3116
  }
3117
+ if (onSaveRef.current && !isInitialLoad) {
3118
+ onSaveRef.current(finalizedBlocks);
3119
+ }
3113
3120
  setTimeout(() => {
3114
3121
  var _a2;
3115
3122
  const firstId = parsedBlocks[0].id;