@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.cjs +8 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1390,7 +1390,7 @@ function useScreenplayEditor(options) {
|
|
|
1390
1390
|
[blocks, handleBlockTextChange]
|
|
1391
1391
|
);
|
|
1392
1392
|
const handleScriptImport = react.useCallback(
|
|
1393
|
-
(title, content, preParsedBlocks) => {
|
|
1393
|
+
(title, content, preParsedBlocks, isInitialLoad) => {
|
|
1394
1394
|
let parsedBlocks = [];
|
|
1395
1395
|
if (preParsedBlocks && preParsedBlocks.length > 0) {
|
|
1396
1396
|
parsedBlocks = preParsedBlocks.map((b) => ({
|
|
@@ -1446,8 +1446,10 @@ function useScreenplayEditor(options) {
|
|
|
1446
1446
|
}).join("");
|
|
1447
1447
|
if (sbxData !== lastSavedContent.current) {
|
|
1448
1448
|
lastSavedContent.current = sbxData;
|
|
1449
|
-
|
|
1450
|
-
|
|
1449
|
+
if (!isInitialLoad) {
|
|
1450
|
+
const blob = new Blob([sbxData], { type: "text/plain" });
|
|
1451
|
+
onSaveRef.current(blob);
|
|
1452
|
+
}
|
|
1451
1453
|
}
|
|
1452
1454
|
}
|
|
1453
1455
|
setTimeout(() => {
|
|
@@ -1495,7 +1497,7 @@ function useScreenplayEditor(options) {
|
|
|
1495
1497
|
}, 200);
|
|
1496
1498
|
}, []);
|
|
1497
1499
|
const loadFromUrl = react.useCallback(
|
|
1498
|
-
async (url, fetchOptions = {}) => {
|
|
1500
|
+
async (url, fetchOptions = {}, isInitialLoad) => {
|
|
1499
1501
|
var _a;
|
|
1500
1502
|
try {
|
|
1501
1503
|
const response = await fetch(url, fetchOptions);
|
|
@@ -1567,7 +1569,7 @@ function useScreenplayEditor(options) {
|
|
|
1567
1569
|
}
|
|
1568
1570
|
}
|
|
1569
1571
|
const filename = ((_a = url.split("/").pop()) == null ? void 0 : _a.replace(/\.sbx$/i, "")) || "Imported from URL";
|
|
1570
|
-
handleScriptImport(filename, scriptContent, preParsedBlocks);
|
|
1572
|
+
handleScriptImport(filename, scriptContent, preParsedBlocks, isInitialLoad);
|
|
1571
1573
|
} catch (error) {
|
|
1572
1574
|
console.error(
|
|
1573
1575
|
"[useScreenplayEditor] Error loading script from URL:",
|
|
@@ -1581,7 +1583,7 @@ function useScreenplayEditor(options) {
|
|
|
1581
1583
|
react.useEffect(() => {
|
|
1582
1584
|
if ((options == null ? void 0 : options.initialUrl) && options.initialUrl !== loadedUrlRef.current) {
|
|
1583
1585
|
loadedUrlRef.current = options.initialUrl;
|
|
1584
|
-
loadFromUrl(options.initialUrl, options.fetchOptions);
|
|
1586
|
+
loadFromUrl(options.initialUrl, options.fetchOptions, true);
|
|
1585
1587
|
}
|
|
1586
1588
|
}, [options == null ? void 0 : options.initialUrl, options == null ? void 0 : options.fetchOptions, loadFromUrl]);
|
|
1587
1589
|
return {
|