@lingjingai/script-editor 0.1.20 → 0.1.21

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createContext, memo, useState, useMemo, useCallback, Fragment, useRef, useContext, useEffect, useLayoutEffect, useDeferredValue } from 'react';
2
- import { Plus, Trash2, X, Check, Eraser, ArrowUp, ArrowDown, GripVertical, MessageCircle, Film, Brain, BookOpen, Scissors, ArrowUpToLine, BookText, ChevronRight, FileText, Users, MapPin, Package, Undo2, Redo2, MessageSquareQuote, ArrowLeft, ChevronLeft, Search, Loader2, AlertCircle } from 'lucide-react';
2
+ import { Plus, Trash2, X, Check, ArrowUp, ArrowDown, GripVertical, MessageCircle, Film, Brain, BookOpen, Eraser, Scissors, ArrowUpToLine, BookText, ChevronRight, FileText, Users, MapPin, Package, Undo2, Redo2, MessageSquareQuote, ArrowLeft, ChevronLeft, Search, Loader2, AlertCircle } from 'lucide-react';
3
3
  import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
4
4
  import { Virtuoso } from 'react-virtuoso';
5
5
  import { createPortal } from 'react-dom';
@@ -2782,56 +2782,6 @@ function removeEntityState(data, kind, id, stateId) {
2782
2782
  states: (e.states ?? []).filter((s) => (s.state_id ?? "").trim() !== stateId)
2783
2783
  }));
2784
2784
  }
2785
- var CONFIRM_TTL_MS = 2500;
2786
- function DeleteConfirmButton({
2787
- onConfirm,
2788
- disabled,
2789
- targetScope,
2790
- title = "\u5220\u9664\uFF1F"
2791
- }) {
2792
- const [confirming, setConfirming] = useState(false);
2793
- const timerRef = useRef(null);
2794
- useEffect(
2795
- () => () => {
2796
- if (timerRef.current) clearTimeout(timerRef.current);
2797
- },
2798
- []
2799
- );
2800
- const cancel = () => {
2801
- if (timerRef.current) {
2802
- clearTimeout(timerRef.current);
2803
- timerRef.current = null;
2804
- }
2805
- setConfirming(false);
2806
- };
2807
- const handleClick = () => {
2808
- if (confirming) {
2809
- cancel();
2810
- void onConfirm();
2811
- return;
2812
- }
2813
- setConfirming(true);
2814
- if (timerRef.current) clearTimeout(timerRef.current);
2815
- timerRef.current = setTimeout(() => {
2816
- setConfirming(false);
2817
- timerRef.current = null;
2818
- }, CONFIRM_TTL_MS);
2819
- };
2820
- return /* @__PURE__ */ jsx(
2821
- "button",
2822
- {
2823
- type: "button",
2824
- disabled,
2825
- "data-delete-target": targetScope,
2826
- "data-confirming": confirming || void 0,
2827
- onClick: handleClick,
2828
- "aria-label": confirming ? `\u518D\u70B9\u4E00\u6B21\u786E\u8BA4\uFF1A${title}` : title,
2829
- title: confirming ? "\u518D\u70B9\u4E00\u6B21\u786E\u8BA4\uFF082.5 \u79D2\u540E\u81EA\u52A8\u53D6\u6D88\uFF09" : title,
2830
- className: cn("lj-se-del", confirming && "is-confirming"),
2831
- children: confirming ? /* @__PURE__ */ jsx(Check, { className: "lj-se-icon", strokeWidth: 2.2 }) : /* @__PURE__ */ jsx(Eraser, { className: "lj-se-icon", strokeWidth: 1.5 })
2832
- }
2833
- );
2834
- }
2835
2785
  var SPACE_ZH = { interior: "\u5185", exterior: "\u5916" };
2836
2786
  var TIME_ZH = { day: "\u65E5", night: "\u591C", dawn: "\u6668", dusk: "\u66AE" };
2837
2787
  function resolveCueId(item, actorMap, speakerMap) {
@@ -3073,6 +3023,38 @@ var META = {
3073
3023
  function newStateId(id) {
3074
3024
  return `st_${id}_${Date.now().toString(36)}`;
3075
3025
  }
3026
+ function StateDeleteButton({ stateName, onConfirm }) {
3027
+ const [open, setOpen] = useState(false);
3028
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3029
+ /* @__PURE__ */ jsx("button", { type: "button", className: "lj-se-assetcard-state-del", title: "\u5220\u9664\u8BE5\u72B6\u6001", "aria-label": "\u5220\u9664\u8BE5\u72B6\u6001", onClick: () => setOpen(true), children: /* @__PURE__ */ jsx(X, { className: "lj-se-ic-3", strokeWidth: 1.8 }) }),
3030
+ open ? /* @__PURE__ */ jsx("div", { className: "lj-se-modal-backdrop", role: "presentation", onMouseDown: () => setOpen(false), children: /* @__PURE__ */ jsxs("div", { className: "lj-se-modal", role: "dialog", "aria-modal": "true", "aria-labelledby": "lj-se-delete-state-title", onMouseDown: (e) => e.stopPropagation(), children: [
3031
+ /* @__PURE__ */ jsxs("div", { className: "lj-se-modal-head", children: [
3032
+ /* @__PURE__ */ jsx("h2", { id: "lj-se-delete-state-title", className: "lj-se-modal-title", children: "\u5220\u9664\u72B6\u6001" }),
3033
+ /* @__PURE__ */ jsx("button", { type: "button", className: "lj-se-modal-x", "aria-label": "\u5173\u95ED", onClick: () => setOpen(false), children: /* @__PURE__ */ jsx(X, { className: "lj-se-ic-3", strokeWidth: 1.8 }) })
3034
+ ] }),
3035
+ /* @__PURE__ */ jsxs("p", { className: "lj-se-modal-body", children: [
3036
+ "\u786E\u8BA4\u5220\u9664\u300C",
3037
+ stateName || "\u672A\u547D\u540D\u72B6\u6001",
3038
+ "\u300D\uFF1F"
3039
+ ] }),
3040
+ /* @__PURE__ */ jsxs("div", { className: "lj-se-modal-actions", children: [
3041
+ /* @__PURE__ */ jsx("button", { type: "button", className: "lj-se-modal-btn", onClick: () => setOpen(false), children: "\u53D6\u6D88" }),
3042
+ /* @__PURE__ */ jsx(
3043
+ "button",
3044
+ {
3045
+ type: "button",
3046
+ className: "lj-se-modal-btn lj-se-modal-btn-danger",
3047
+ onClick: () => {
3048
+ setOpen(false);
3049
+ onConfirm();
3050
+ },
3051
+ children: "\u5220\u9664"
3052
+ }
3053
+ )
3054
+ ] })
3055
+ ] }) }) : null
3056
+ ] });
3057
+ }
3076
3058
  function AssetCardImpl({
3077
3059
  data,
3078
3060
  group,
@@ -3179,7 +3161,13 @@ function AssetCardImpl({
3179
3161
  onSave: (v) => onEdit((p) => updateEntityStateField(p, kind, assetId, sid, "state_name", v))
3180
3162
  }
3181
3163
  ),
3182
- !disabled && (state.state_id ?? "").trim() ? /* @__PURE__ */ jsx(DeleteConfirmButton, { targetScope: "row", title: "\u5220\u9664\u8BE5\u72B6\u6001\uFF1F", onConfirm: () => onEdit((p) => removeEntityState(p, kind, assetId, sid)) }) : null
3164
+ !disabled && (state.state_id ?? "").trim() ? /* @__PURE__ */ jsx(
3165
+ StateDeleteButton,
3166
+ {
3167
+ stateName: state.state_name ?? state.name ?? "",
3168
+ onConfirm: () => onEdit((p) => removeEntityState(p, kind, assetId, sid))
3169
+ }
3170
+ ) : null
3183
3171
  ] }),
3184
3172
  /* @__PURE__ */ jsx(
3185
3173
  EditableText,
@@ -4542,6 +4530,56 @@ __export(mutations_exports, {
4542
4530
  updateSceneLocationState: () => updateSceneLocationState,
4543
4531
  updateScenePropState: () => updateScenePropState
4544
4532
  });
4533
+ var CONFIRM_TTL_MS = 2500;
4534
+ function DeleteConfirmButton({
4535
+ onConfirm,
4536
+ disabled,
4537
+ targetScope,
4538
+ title = "\u5220\u9664\uFF1F"
4539
+ }) {
4540
+ const [confirming, setConfirming] = useState(false);
4541
+ const timerRef = useRef(null);
4542
+ useEffect(
4543
+ () => () => {
4544
+ if (timerRef.current) clearTimeout(timerRef.current);
4545
+ },
4546
+ []
4547
+ );
4548
+ const cancel = () => {
4549
+ if (timerRef.current) {
4550
+ clearTimeout(timerRef.current);
4551
+ timerRef.current = null;
4552
+ }
4553
+ setConfirming(false);
4554
+ };
4555
+ const handleClick = () => {
4556
+ if (confirming) {
4557
+ cancel();
4558
+ void onConfirm();
4559
+ return;
4560
+ }
4561
+ setConfirming(true);
4562
+ if (timerRef.current) clearTimeout(timerRef.current);
4563
+ timerRef.current = setTimeout(() => {
4564
+ setConfirming(false);
4565
+ timerRef.current = null;
4566
+ }, CONFIRM_TTL_MS);
4567
+ };
4568
+ return /* @__PURE__ */ jsx(
4569
+ "button",
4570
+ {
4571
+ type: "button",
4572
+ disabled,
4573
+ "data-delete-target": targetScope,
4574
+ "data-confirming": confirming || void 0,
4575
+ onClick: handleClick,
4576
+ "aria-label": confirming ? `\u518D\u70B9\u4E00\u6B21\u786E\u8BA4\uFF1A${title}` : title,
4577
+ title: confirming ? "\u518D\u70B9\u4E00\u6B21\u786E\u8BA4\uFF082.5 \u79D2\u540E\u81EA\u52A8\u53D6\u6D88\uFF09" : title,
4578
+ className: cn("lj-se-del", confirming && "is-confirming"),
4579
+ children: confirming ? /* @__PURE__ */ jsx(Check, { className: "lj-se-icon", strokeWidth: 2.2 }) : /* @__PURE__ */ jsx(Eraser, { className: "lj-se-icon", strokeWidth: 1.5 })
4580
+ }
4581
+ );
4582
+ }
4545
4583
 
4546
4584
  export { DeleteConfirmButton, EMPTY_SELECTION, EditableText, Popover, ScriptContentType, ScriptEditor, SelectField, acceptActionIntoBaseline, acceptSceneIntoBaseline, applyActionAccept, applyActionReject, buildActionDiff, buildDiffFromBaseline, buildScriptNav, buildSelectionFrom, changeSetToDiffScenes, computeChangeSet, computeSceneActionDiff, findBaselineScene, fromToSelection, getActorCueVar, getActorMap, getEpisodeTitle, getLocationMap, getPropMap, getSceneContext, getSelectionEpisodeIdx, getSpeakerMap, isClipSelected, isEpisodeOpen, isSameSelectionTarget, isSceneSelected, mutations_exports as mutations, rejectActionToBaseline, rejectSceneToBaseline, sceneChangeKey, selectionFromScriptReference, selectionTargetKey, withOrigin };
4547
4585
  //# sourceMappingURL=index.js.map