@vishu1301/script-writing 1.0.7 → 1.0.9

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.d.cts CHANGED
@@ -25,7 +25,7 @@ declare const blockStyles: Record<BlockType, {
25
25
  interface UseScreenplayEditorOptions {
26
26
  initialUrl?: string;
27
27
  fetchOptions?: RequestInit;
28
- onSave?: (content?: string) => void;
28
+ onSave?: (content?: Blob) => void;
29
29
  }
30
30
  declare function useScreenplayEditor(options?: UseScreenplayEditorOptions): {
31
31
  blocks: Block[];
package/dist/index.d.ts CHANGED
@@ -25,7 +25,7 @@ declare const blockStyles: Record<BlockType, {
25
25
  interface UseScreenplayEditorOptions {
26
26
  initialUrl?: string;
27
27
  fetchOptions?: RequestInit;
28
- onSave?: (content?: string) => void;
28
+ onSave?: (content?: Blob) => void;
29
29
  }
30
30
  declare function useScreenplayEditor(options?: UseScreenplayEditorOptions): {
31
31
  blocks: Block[];
package/dist/index.js CHANGED
@@ -970,6 +970,10 @@ function useScreenplayEditor(options) {
970
970
  const [showExtensionSuggestions, setShowExtensionSuggestions] = useState(false);
971
971
  const blurTimeout = useRef(null);
972
972
  const loadedUrlRef = useRef(null);
973
+ const onSaveRef = useRef(options == null ? void 0 : options.onSave);
974
+ useEffect(() => {
975
+ onSaveRef.current = options == null ? void 0 : options.onSave;
976
+ }, [options == null ? void 0 : options.onSave]);
973
977
  const characterExtensions = useMemo(
974
978
  () => ["(V.O.)", "(O.S.)", "(O.C.)", "(SUBTITLE)", "(CONT'D)"],
975
979
  []
@@ -1355,8 +1359,7 @@ function useScreenplayEditor(options) {
1355
1359
  return block;
1356
1360
  });
1357
1361
  setBlocks(finalizedBlocks);
1358
- if (options == null ? void 0 : options.onSave) {
1359
- options.onSave(content);
1362
+ if (onSaveRef.current) {
1360
1363
  const typeToDivClass = {
1361
1364
  SCENE_HEADING: "divtype0",
1362
1365
  ACTION: "divtype2",
@@ -1380,7 +1383,8 @@ function useScreenplayEditor(options) {
1380
1383
  }
1381
1384
  return `<div class="${divClass}" id="par${block.id}"${extraAttributes}>${text}</div>`;
1382
1385
  }).join("");
1383
- options.onSave(sbxData);
1386
+ const blob = new Blob([sbxData], { type: "text/plain" });
1387
+ onSaveRef.current(blob);
1384
1388
  }
1385
1389
  setTimeout(() => {
1386
1390
  var _a;
@@ -1392,7 +1396,7 @@ function useScreenplayEditor(options) {
1392
1396
  }, 100);
1393
1397
  }
1394
1398
  },
1395
- [refs, options == null ? void 0 : options.onSave]
1399
+ [refs]
1396
1400
  );
1397
1401
  const handleFocus = useCallback(
1398
1402
  (id) => {