@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.cjs
CHANGED
|
@@ -995,6 +995,11 @@ function useScreenplayEditor(options) {
|
|
|
995
995
|
const [showExtensionSuggestions, setShowExtensionSuggestions] = react.useState(false);
|
|
996
996
|
const blurTimeout = react.useRef(null);
|
|
997
997
|
const loadedUrlRef = react.useRef(null);
|
|
998
|
+
const lastSavedContent = react.useRef(null);
|
|
999
|
+
const onSaveRef = react.useRef(options == null ? void 0 : options.onSave);
|
|
1000
|
+
react.useEffect(() => {
|
|
1001
|
+
onSaveRef.current = options == null ? void 0 : options.onSave;
|
|
1002
|
+
}, [options == null ? void 0 : options.onSave]);
|
|
998
1003
|
const characterExtensions = react.useMemo(
|
|
999
1004
|
() => ["(V.O.)", "(O.S.)", "(O.C.)", "(SUBTITLE)", "(CONT'D)"],
|
|
1000
1005
|
[]
|
|
@@ -1351,11 +1356,10 @@ function useScreenplayEditor(options) {
|
|
|
1351
1356
|
);
|
|
1352
1357
|
const handleScriptImport = react.useCallback(
|
|
1353
1358
|
(title, content, preParsedBlocks) => {
|
|
1354
|
-
var _a;
|
|
1355
1359
|
let parsedBlocks = [];
|
|
1356
1360
|
if (preParsedBlocks && preParsedBlocks.length > 0) {
|
|
1357
1361
|
parsedBlocks = preParsedBlocks.map((b) => ({
|
|
1358
|
-
id: uuid(),
|
|
1362
|
+
id: b.id || uuid(),
|
|
1359
1363
|
type: b.type || "ACTION",
|
|
1360
1364
|
text: b.text || "",
|
|
1361
1365
|
sceneNumber: b.sceneNumber,
|
|
@@ -1381,7 +1385,7 @@ function useScreenplayEditor(options) {
|
|
|
1381
1385
|
return block;
|
|
1382
1386
|
});
|
|
1383
1387
|
setBlocks(finalizedBlocks);
|
|
1384
|
-
if (
|
|
1388
|
+
if (onSaveRef.current) {
|
|
1385
1389
|
const typeToDivClass = {
|
|
1386
1390
|
SCENE_HEADING: "divtype0",
|
|
1387
1391
|
ACTION: "divtype2",
|
|
@@ -1405,15 +1409,18 @@ function useScreenplayEditor(options) {
|
|
|
1405
1409
|
}
|
|
1406
1410
|
return `<div class="${divClass}" id="par${block.id}"${extraAttributes}>${text}</div>`;
|
|
1407
1411
|
}).join("");
|
|
1408
|
-
|
|
1409
|
-
|
|
1412
|
+
if (sbxData !== lastSavedContent.current) {
|
|
1413
|
+
lastSavedContent.current = sbxData;
|
|
1414
|
+
const blob = new Blob([sbxData], { type: "text/plain" });
|
|
1415
|
+
onSaveRef.current(blob);
|
|
1416
|
+
}
|
|
1410
1417
|
}
|
|
1411
1418
|
setTimeout(() => {
|
|
1412
|
-
var
|
|
1419
|
+
var _a;
|
|
1413
1420
|
const firstId = parsedBlocks[0].id;
|
|
1414
1421
|
if (firstId && refs.current[firstId]) {
|
|
1415
1422
|
setFocusedBlockId(firstId);
|
|
1416
|
-
(
|
|
1423
|
+
(_a = refs.current[firstId]) == null ? void 0 : _a.focus();
|
|
1417
1424
|
}
|
|
1418
1425
|
}, 100);
|
|
1419
1426
|
}
|
|
@@ -1495,6 +1502,10 @@ function useScreenplayEditor(options) {
|
|
|
1495
1502
|
}
|
|
1496
1503
|
}
|
|
1497
1504
|
const block = { type, text: divText };
|
|
1505
|
+
const idAttr = div.getAttribute("id");
|
|
1506
|
+
if (idAttr && idAttr.startsWith("par")) {
|
|
1507
|
+
block.id = idAttr.substring(3);
|
|
1508
|
+
}
|
|
1498
1509
|
if (type === "SCENE_HEADING") {
|
|
1499
1510
|
const sceneNum = div.getAttribute("data-scene");
|
|
1500
1511
|
if (sceneNum) block.sceneNumber = sceneNum;
|