@vishu1301/script-writing 1.4.7 → 1.4.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.cjs CHANGED
@@ -843,7 +843,7 @@ function ScreenplayEditorView({
843
843
  /* @__PURE__ */ jsxRuntime.jsx(
844
844
  "div",
845
845
  {
846
- className: `fixed bottom-10 left-[60%] -translate-x-1/2 z-[100] w-full max-w-[95%] sm:max-w-2xl transition-all duration-500 ease-in-out ${showUnsavedPopover ? "translate-y-0 opacity-100 scale-100" : "translate-y-12 opacity-0 scale-95 pointer-events-none"}`,
846
+ className: `fixed bottom-10 left-[53%] -translate-x-1/2 z-[100] w-full max-w-[95%] sm:max-w-2xl transition-all duration-500 ease-in-out ${showUnsavedPopover ? "translate-y-0 opacity-100 scale-100" : "translate-y-12 opacity-0 scale-95 pointer-events-none"}`,
847
847
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-auto rounded-[2.5rem] bg-white/95 border border-white/60 shadow-[0_20px_50px_rgba(16,37,54,0.12),0_4px_12px_rgba(16,37,54,0.05)] backdrop-blur-2xl flex items-center justify-between px-2 py-1.5 sm:px-4 sm:py-2.5 select-none transition-all hover:shadow-[0_25px_60px_rgba(16,37,54,0.18)]", children: [
848
848
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
849
849
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-10 h-10 flex items-center justify-center rounded-[2.5rem] bg-blumine-50 text-blumine-500 border border-blumine-100 shadow-inner", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "w-5 h-5" }) }),
@@ -975,6 +975,8 @@ function changeBlockType(blocks, id, newType) {
975
975
  if (newType === "PARENTHETICAL") {
976
976
  const cleanText = currentBlock.text.replace(/[()]/g, "");
977
977
  newBlock.text = `(${cleanText})`;
978
+ } else if (currentBlock.type === "PARENTHETICAL") {
979
+ newBlock.text = currentBlock.text.replace(/[()]/g, "");
978
980
  } else {
979
981
  newBlock.text = currentBlock.text;
980
982
  }
@@ -1352,12 +1354,18 @@ function useScreenplayEditor(options) {
1352
1354
  setTimeout(() => {
1353
1355
  const el = refs.current[focusedBlockId];
1354
1356
  if (el) {
1355
- el.focus();
1356
- const currentBlock = blocks.find((b) => b.id === focusedBlockId);
1357
- if (currentBlock) {
1357
+ setBlocks((currentBlocks) => {
1358
+ const currentBlock = currentBlocks.find(
1359
+ (b) => b.id === focusedBlockId
1360
+ );
1361
+ if (currentBlock && el.innerText !== currentBlock.text) {
1362
+ el.innerText = currentBlock.text;
1363
+ }
1364
+ el.focus();
1358
1365
  const pos = newType === "PARENTHETICAL" ? el.innerText.length - 1 : el.innerText.length;
1359
1366
  setCaretPosition(el, Math.max(0, pos));
1360
- }
1367
+ return currentBlocks;
1368
+ });
1361
1369
  }
1362
1370
  }, 10);
1363
1371
  },
@@ -1416,12 +1424,19 @@ function useScreenplayEditor(options) {
1416
1424
  setTimeout(() => {
1417
1425
  const el = refs.current[id];
1418
1426
  if (el) {
1419
- el.focus();
1420
- if (newType === "PARENTHETICAL") {
1421
- setCaretPosition(el, 1);
1422
- } else {
1423
- setCaretPosition(el, el.innerText.length);
1424
- }
1427
+ setBlocks((currentBlocks) => {
1428
+ const currentBlock = currentBlocks.find((b) => b.id === id);
1429
+ if (currentBlock && el.innerText !== currentBlock.text) {
1430
+ el.innerText = currentBlock.text;
1431
+ }
1432
+ el.focus();
1433
+ if (newType === "PARENTHETICAL") {
1434
+ setCaretPosition(el, 1);
1435
+ } else {
1436
+ setCaretPosition(el, el.innerText.length);
1437
+ }
1438
+ return currentBlocks;
1439
+ });
1425
1440
  }
1426
1441
  }, 10);
1427
1442
  };