@vishu1301/script-writing 1.1.0 → 1.1.1
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 +18 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -970,6 +970,11 @@ function useScreenplayEditor(options) {
|
|
|
970
970
|
const [showExtensionSuggestions, setShowExtensionSuggestions] = useState(false);
|
|
971
971
|
const blurTimeout = useRef(null);
|
|
972
972
|
const loadedUrlRef = useRef(null);
|
|
973
|
+
const lastSavedContent = useRef(null);
|
|
974
|
+
const onSaveRef = useRef(options == null ? void 0 : options.onSave);
|
|
975
|
+
useEffect(() => {
|
|
976
|
+
onSaveRef.current = options == null ? void 0 : options.onSave;
|
|
977
|
+
}, [options == null ? void 0 : options.onSave]);
|
|
973
978
|
const characterExtensions = useMemo(
|
|
974
979
|
() => ["(V.O.)", "(O.S.)", "(O.C.)", "(SUBTITLE)", "(CONT'D)"],
|
|
975
980
|
[]
|
|
@@ -1326,11 +1331,10 @@ function useScreenplayEditor(options) {
|
|
|
1326
1331
|
);
|
|
1327
1332
|
const handleScriptImport = useCallback(
|
|
1328
1333
|
(title, content, preParsedBlocks) => {
|
|
1329
|
-
var _a;
|
|
1330
1334
|
let parsedBlocks = [];
|
|
1331
1335
|
if (preParsedBlocks && preParsedBlocks.length > 0) {
|
|
1332
1336
|
parsedBlocks = preParsedBlocks.map((b) => ({
|
|
1333
|
-
id: uuid(),
|
|
1337
|
+
id: b.id || uuid(),
|
|
1334
1338
|
type: b.type || "ACTION",
|
|
1335
1339
|
text: b.text || "",
|
|
1336
1340
|
sceneNumber: b.sceneNumber,
|
|
@@ -1356,7 +1360,7 @@ function useScreenplayEditor(options) {
|
|
|
1356
1360
|
return block;
|
|
1357
1361
|
});
|
|
1358
1362
|
setBlocks(finalizedBlocks);
|
|
1359
|
-
if (
|
|
1363
|
+
if (onSaveRef.current) {
|
|
1360
1364
|
const typeToDivClass = {
|
|
1361
1365
|
SCENE_HEADING: "divtype0",
|
|
1362
1366
|
ACTION: "divtype2",
|
|
@@ -1380,15 +1384,18 @@ function useScreenplayEditor(options) {
|
|
|
1380
1384
|
}
|
|
1381
1385
|
return `<div class="${divClass}" id="par${block.id}"${extraAttributes}>${text}</div>`;
|
|
1382
1386
|
}).join("");
|
|
1383
|
-
|
|
1384
|
-
|
|
1387
|
+
if (sbxData !== lastSavedContent.current) {
|
|
1388
|
+
lastSavedContent.current = sbxData;
|
|
1389
|
+
const blob = new Blob([sbxData], { type: "text/plain" });
|
|
1390
|
+
onSaveRef.current(blob);
|
|
1391
|
+
}
|
|
1385
1392
|
}
|
|
1386
1393
|
setTimeout(() => {
|
|
1387
|
-
var
|
|
1394
|
+
var _a;
|
|
1388
1395
|
const firstId = parsedBlocks[0].id;
|
|
1389
1396
|
if (firstId && refs.current[firstId]) {
|
|
1390
1397
|
setFocusedBlockId(firstId);
|
|
1391
|
-
(
|
|
1398
|
+
(_a = refs.current[firstId]) == null ? void 0 : _a.focus();
|
|
1392
1399
|
}
|
|
1393
1400
|
}, 100);
|
|
1394
1401
|
}
|
|
@@ -1470,6 +1477,10 @@ function useScreenplayEditor(options) {
|
|
|
1470
1477
|
}
|
|
1471
1478
|
}
|
|
1472
1479
|
const block = { type, text: divText };
|
|
1480
|
+
const idAttr = div.getAttribute("id");
|
|
1481
|
+
if (idAttr && idAttr.startsWith("par")) {
|
|
1482
|
+
block.id = idAttr.substring(3);
|
|
1483
|
+
}
|
|
1473
1484
|
if (type === "SCENE_HEADING") {
|
|
1474
1485
|
const sceneNum = div.getAttribute("data-scene");
|
|
1475
1486
|
if (sceneNum) block.sceneNumber = sceneNum;
|