@vishu1301/script-writing 1.1.4 → 1.1.5

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
@@ -43,11 +43,11 @@ declare function useScreenplayEditor(options?: UseScreenplayEditorOptions): {
43
43
  handleBlockTypeChange: (newType: BlockType) => void;
44
44
  handleSelectCharacterExtension: (extension: string) => void;
45
45
  handleKeyDown: (e: KeyboardEvent<HTMLDivElement>, id: string, text: string) => void;
46
- handleScriptImport: (title: string, content: string, preParsedBlocks?: Partial<Block>[]) => void;
46
+ handleScriptImport: (title: string, content: string, preParsedBlocks?: Partial<Block>[], isInitialLoad?: boolean) => void;
47
47
  handleSceneNumberChange: (id: string, newNumber: string) => void;
48
48
  handleFocus: (id: string) => void;
49
49
  handleBlur: (id: string) => void;
50
- loadFromUrl: (url: string, fetchOptions?: RequestInit) => Promise<void>;
50
+ loadFromUrl: (url: string, fetchOptions?: RequestInit, isInitialLoad?: boolean) => Promise<void>;
51
51
  };
52
52
 
53
53
  type ScreenplayEditorViewProps = ReturnType<typeof useScreenplayEditor> & {
package/dist/index.d.ts CHANGED
@@ -43,11 +43,11 @@ declare function useScreenplayEditor(options?: UseScreenplayEditorOptions): {
43
43
  handleBlockTypeChange: (newType: BlockType) => void;
44
44
  handleSelectCharacterExtension: (extension: string) => void;
45
45
  handleKeyDown: (e: KeyboardEvent<HTMLDivElement>, id: string, text: string) => void;
46
- handleScriptImport: (title: string, content: string, preParsedBlocks?: Partial<Block>[]) => void;
46
+ handleScriptImport: (title: string, content: string, preParsedBlocks?: Partial<Block>[], isInitialLoad?: boolean) => void;
47
47
  handleSceneNumberChange: (id: string, newNumber: string) => void;
48
48
  handleFocus: (id: string) => void;
49
49
  handleBlur: (id: string) => void;
50
- loadFromUrl: (url: string, fetchOptions?: RequestInit) => Promise<void>;
50
+ loadFromUrl: (url: string, fetchOptions?: RequestInit, isInitialLoad?: boolean) => Promise<void>;
51
51
  };
52
52
 
53
53
  type ScreenplayEditorViewProps = ReturnType<typeof useScreenplayEditor> & {
package/dist/index.js CHANGED
@@ -1365,7 +1365,7 @@ function useScreenplayEditor(options) {
1365
1365
  [blocks, handleBlockTextChange]
1366
1366
  );
1367
1367
  const handleScriptImport = useCallback(
1368
- (title, content, preParsedBlocks) => {
1368
+ (title, content, preParsedBlocks, isInitialLoad) => {
1369
1369
  let parsedBlocks = [];
1370
1370
  if (preParsedBlocks && preParsedBlocks.length > 0) {
1371
1371
  parsedBlocks = preParsedBlocks.map((b) => ({
@@ -1421,8 +1421,10 @@ function useScreenplayEditor(options) {
1421
1421
  }).join("");
1422
1422
  if (sbxData !== lastSavedContent.current) {
1423
1423
  lastSavedContent.current = sbxData;
1424
- const blob = new Blob([sbxData], { type: "text/plain" });
1425
- onSaveRef.current(blob);
1424
+ if (!isInitialLoad) {
1425
+ const blob = new Blob([sbxData], { type: "text/plain" });
1426
+ onSaveRef.current(blob);
1427
+ }
1426
1428
  }
1427
1429
  }
1428
1430
  setTimeout(() => {
@@ -1470,7 +1472,7 @@ function useScreenplayEditor(options) {
1470
1472
  }, 200);
1471
1473
  }, []);
1472
1474
  const loadFromUrl = useCallback(
1473
- async (url, fetchOptions = {}) => {
1475
+ async (url, fetchOptions = {}, isInitialLoad) => {
1474
1476
  var _a;
1475
1477
  try {
1476
1478
  const response = await fetch(url, fetchOptions);
@@ -1542,7 +1544,7 @@ function useScreenplayEditor(options) {
1542
1544
  }
1543
1545
  }
1544
1546
  const filename = ((_a = url.split("/").pop()) == null ? void 0 : _a.replace(/\.sbx$/i, "")) || "Imported from URL";
1545
- handleScriptImport(filename, scriptContent, preParsedBlocks);
1547
+ handleScriptImport(filename, scriptContent, preParsedBlocks, isInitialLoad);
1546
1548
  } catch (error) {
1547
1549
  console.error(
1548
1550
  "[useScreenplayEditor] Error loading script from URL:",
@@ -1556,7 +1558,7 @@ function useScreenplayEditor(options) {
1556
1558
  useEffect(() => {
1557
1559
  if ((options == null ? void 0 : options.initialUrl) && options.initialUrl !== loadedUrlRef.current) {
1558
1560
  loadedUrlRef.current = options.initialUrl;
1559
- loadFromUrl(options.initialUrl, options.fetchOptions);
1561
+ loadFromUrl(options.initialUrl, options.fetchOptions, true);
1560
1562
  }
1561
1563
  }, [options == null ? void 0 : options.initialUrl, options == null ? void 0 : options.fetchOptions, loadFromUrl]);
1562
1564
  return {