@thanh01.pmt/presentation-kit 0.2.8 → 0.2.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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkVLAPHJOC_cjs = require('../chunk-VLAPHJOC.cjs');
4
- var chunkIGCFC6GI_cjs = require('../chunk-IGCFC6GI.cjs');
3
+ var chunkTGI6YSZP_cjs = require('../chunk-TGI6YSZP.cjs');
4
+ var chunkTV6NFIIV_cjs = require('../chunk-TV6NFIIV.cjs');
5
5
  var react = require('react');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
 
@@ -21,7 +21,7 @@ function useSlideState(options) {
21
21
  const result = react.useMemo(() => {
22
22
  if (!markdown || !markdown.trim()) return null;
23
23
  renderCountRef.current++;
24
- return chunkVLAPHJOC_cjs.renderSlide(markdown, {
24
+ return chunkTGI6YSZP_cjs.renderSlide(markdown, {
25
25
  theme,
26
26
  enableMermaid: true,
27
27
  enableClicks,
@@ -585,15 +585,28 @@ function SlideDesignOverlay({
585
585
  layout,
586
586
  onLayoutChange,
587
587
  onSave,
588
+ onDeleteBox,
589
+ onAddBox,
588
590
  onClose,
589
591
  isActive,
590
- theme = "dark"
592
+ theme = "dark",
593
+ selectedBoxId,
594
+ onSelectBoxId
591
595
  }) {
592
596
  if (!isActive) return null;
593
597
  const [boxes, setBoxes] = react.useState(layout?.boxes ?? []);
594
- const [selectedId, setSelectedId] = react.useState(null);
598
+ const [selectedId, setSelectedIdState] = react.useState(selectedBoxId ?? null);
595
599
  const [editingId, setEditingId] = react.useState(null);
596
600
  const containerRef = react.useRef(null);
601
+ const setSelectedId = react.useCallback((id) => {
602
+ setSelectedIdState(id);
603
+ if (onSelectBoxId) onSelectBoxId(id);
604
+ }, [onSelectBoxId]);
605
+ react.useEffect(() => {
606
+ if (selectedBoxId !== void 0) {
607
+ setSelectedIdState(selectedBoxId);
608
+ }
609
+ }, [selectedBoxId]);
597
610
  react.useEffect(() => {
598
611
  setBoxes(layout?.boxes ?? []);
599
612
  }, [layout, slideIndex]);
@@ -629,30 +642,38 @@ function SlideDesignOverlay({
629
642
  newY = Math.round(Math.max(0, Math.min(720 - origH, origY + dy)));
630
643
  break;
631
644
  case "se":
632
- newW = Math.round(Math.max(100, Math.min(1280 - origX, origW + dx)));
633
- newH = Math.round(Math.max(40, Math.min(720 - origY, origH + dy)));
645
+ newW = Math.round(Math.max(60, Math.min(1280 - origX, origW + dx)));
646
+ newH = Math.round(Math.max(30, Math.min(720 - origY, origH + dy)));
634
647
  break;
635
648
  case "e":
636
- newW = Math.round(Math.max(100, Math.min(1280 - origX, origW + dx)));
649
+ newW = Math.round(Math.max(60, Math.min(1280 - origX, origW + dx)));
637
650
  break;
638
651
  case "s":
639
- newH = Math.round(Math.max(40, Math.min(720 - origY, origH + dy)));
652
+ newH = Math.round(Math.max(30, Math.min(720 - origY, origH + dy)));
640
653
  break;
641
654
  case "sw":
642
- newW = Math.round(Math.max(100, origW - dx));
643
- newX = Math.round(Math.min(origX + origW - 100, origX + dx));
644
- newH = Math.round(Math.max(40, origH + dy));
655
+ newW = Math.round(Math.max(60, origW - dx));
656
+ newX = Math.round(Math.min(origX + origW - 60, origX + dx));
657
+ newH = Math.round(Math.max(30, origH + dy));
645
658
  break;
646
659
  case "ne":
647
- newW = Math.round(Math.max(100, origW + dx));
648
- newH = Math.round(Math.max(40, origH - dy));
649
- newY = Math.round(Math.min(origY + origH - 40, origY + dy));
660
+ newW = Math.round(Math.max(60, origW + dx));
661
+ newH = Math.round(Math.max(30, origH - dy));
662
+ newY = Math.round(Math.min(origY + origH - 30, origY + dy));
650
663
  break;
651
664
  case "nw":
652
- newW = Math.round(Math.max(100, origW - dx));
653
- newX = Math.round(Math.min(origX + origW - 100, origX + dx));
654
- newH = Math.round(Math.max(40, origH - dy));
655
- newY = Math.round(Math.min(origY + origH - 40, origY + dy));
665
+ newW = Math.round(Math.max(60, origW - dx));
666
+ newX = Math.round(Math.min(origX + origW - 60, origX + dx));
667
+ newH = Math.round(Math.max(30, origH - dy));
668
+ newY = Math.round(Math.min(origY + origH - 30, origY + dy));
669
+ break;
670
+ case "n":
671
+ newH = Math.round(Math.max(30, origH - dy));
672
+ newY = Math.round(Math.min(origY + origH - 30, origY + dy));
673
+ break;
674
+ case "w":
675
+ newW = Math.round(Math.max(60, origW - dx));
676
+ newX = Math.round(Math.min(origX + origW - 60, origX + dx));
656
677
  break;
657
678
  }
658
679
  return { ...b, pos: [newX, newY, newW, newH] };
@@ -662,8 +683,11 @@ function SlideDesignOverlay({
662
683
  });
663
684
  }, [dragging, onLayoutChange]);
664
685
  const handleMouseUp = react.useCallback(() => {
686
+ if (dragging && onSave) {
687
+ onSave({ boxes });
688
+ }
665
689
  setDragging(null);
666
- }, []);
690
+ }, [dragging, boxes, onSave]);
667
691
  react.useEffect(() => {
668
692
  if (dragging) {
669
693
  window.addEventListener("mousemove", handleMouseMove);
@@ -674,6 +698,33 @@ function SlideDesignOverlay({
674
698
  };
675
699
  }
676
700
  }, [dragging, handleMouseMove, handleMouseUp]);
701
+ const removeSelectedBox = react.useCallback(() => {
702
+ if (!selectedId) return;
703
+ const boxToRemove = boxes.find((b) => b.id === selectedId);
704
+ setBoxes((prev) => {
705
+ const updated = prev.filter((b) => b.id !== selectedId);
706
+ onLayoutChange({ boxes: updated });
707
+ if (onSave) onSave({ boxes: updated });
708
+ return updated;
709
+ });
710
+ setSelectedId(null);
711
+ if (boxToRemove && onDeleteBox) {
712
+ onDeleteBox(boxToRemove);
713
+ }
714
+ }, [selectedId, boxes, onLayoutChange, onSave, onDeleteBox, setSelectedId]);
715
+ react.useEffect(() => {
716
+ const handleKeyDown = (e) => {
717
+ if (editingId) return;
718
+ if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) return;
719
+ if ((e.key === "Delete" || e.key === "Backspace") && selectedId) {
720
+ e.preventDefault();
721
+ e.stopPropagation();
722
+ removeSelectedBox();
723
+ }
724
+ };
725
+ window.addEventListener("keydown", handleKeyDown);
726
+ return () => window.removeEventListener("keydown", handleKeyDown);
727
+ }, [selectedId, editingId, removeSelectedBox]);
677
728
  const addNewBox = (targetTag) => {
678
729
  const isH1 = targetTag === "h1";
679
730
  const newId = `box-${Date.now().toString(36)}`;
@@ -691,6 +742,9 @@ function SlideDesignOverlay({
691
742
  setSelectedId(newId);
692
743
  setEditingId(newId);
693
744
  onLayoutChange({ boxes: updated });
745
+ if (onAddBox) {
746
+ onAddBox(newBox);
747
+ }
694
748
  };
695
749
  const updateSelectedBox = (partial) => {
696
750
  if (!selectedId) return;
@@ -700,15 +754,6 @@ function SlideDesignOverlay({
700
754
  return updated;
701
755
  });
702
756
  };
703
- const removeSelectedBox = () => {
704
- if (!selectedId) return;
705
- setBoxes((prev) => {
706
- const updated = prev.filter((b) => b.id !== selectedId);
707
- onLayoutChange({ boxes: updated });
708
- return updated;
709
- });
710
- setSelectedId(null);
711
- };
712
757
  const isLight = theme === "light";
713
758
  const isNavy = theme === "navy";
714
759
  const toolbarBg = isLight ? "rgba(255, 255, 255, 0.96)" : isNavy ? "rgba(11, 19, 43, 0.95)" : "rgba(24, 25, 32, 0.95)";
@@ -778,7 +823,7 @@ function SlideDesignOverlay({
778
823
  "select",
779
824
  {
780
825
  onChange: (e) => {
781
- const preset = chunkIGCFC6GI_cjs.SLIDE_LAYOUT_PRESETS.find((p) => p.id === e.target.value);
826
+ const preset = chunkTV6NFIIV_cjs.SLIDE_LAYOUT_PRESETS.find((p) => p.id === e.target.value);
782
827
  if (preset) {
783
828
  const clonedBoxes = JSON.parse(JSON.stringify(preset.layout.boxes));
784
829
  setBoxes(clonedBoxes);
@@ -798,7 +843,7 @@ function SlideDesignOverlay({
798
843
  title: "\xC1p d\u1EE5ng m\u1EABu b\u1ED1 c\u1EE5c c\xF3 s\u1EB5n",
799
844
  children: [
800
845
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, style: { backgroundColor: isLight ? "#ffffff" : "#1e1f29", color: subtextColor }, children: "M\u1EABu b\u1ED1 c\u1EE5c (Presets)..." }),
801
- chunkIGCFC6GI_cjs.SLIDE_LAYOUT_PRESETS.map((p) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: p.id, style: { backgroundColor: isLight ? "#ffffff" : "#1e1f29", color: isLight ? "#0f172a" : "#f8fafc" }, children: p.name }, p.id))
846
+ chunkTV6NFIIV_cjs.SLIDE_LAYOUT_PRESETS.map((p) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: p.id, style: { backgroundColor: isLight ? "#ffffff" : "#1e1f29", color: isLight ? "#0f172a" : "#f8fafc" }, children: p.name }, p.id))
802
847
  ]
803
848
  }
804
849
  ),
@@ -940,12 +985,14 @@ function SlideDesignOverlay({
940
985
  }
941
986
  ),
942
987
  isSelected && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
943
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("se", isLight), onMouseDown: (e) => handleMouseDown(e, box, "se") }),
944
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("e", isLight), onMouseDown: (e) => handleMouseDown(e, box, "e") }),
945
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("s", isLight), onMouseDown: (e) => handleMouseDown(e, box, "s") }),
946
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("sw", isLight), onMouseDown: (e) => handleMouseDown(e, box, "sw") }),
947
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("ne", isLight), onMouseDown: (e) => handleMouseDown(e, box, "ne") }),
948
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("nw", isLight), onMouseDown: (e) => handleMouseDown(e, box, "nw") })
988
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("nw", isLight), onMouseDown: (e) => handleMouseDown(e, box, "nw"), title: "K\xE9o g\xF3c tr\xEAn-tr\xE1i" }),
989
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("n", isLight), onMouseDown: (e) => handleMouseDown(e, box, "n"), title: "K\xE9o c\u1EA1nh tr\xEAn" }),
990
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("ne", isLight), onMouseDown: (e) => handleMouseDown(e, box, "ne"), title: "K\xE9o g\xF3c tr\xEAn-ph\u1EA3i" }),
991
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("e", isLight), onMouseDown: (e) => handleMouseDown(e, box, "e"), title: "K\xE9o c\u1EA1nh ph\u1EA3i (Ch\u1EC9nh \u0111\u1ED9 r\u1ED9ng / wrap text)" }),
992
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("se", isLight), onMouseDown: (e) => handleMouseDown(e, box, "se"), title: "K\xE9o g\xF3c d\u01B0\u1EDBi-ph\u1EA3i (Ch\u1EC9nh k\xEDch th\u01B0\u1EDBc / wrap text)" }),
993
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("s", isLight), onMouseDown: (e) => handleMouseDown(e, box, "s"), title: "K\xE9o c\u1EA1nh d\u01B0\u1EDBi" }),
994
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("sw", isLight), onMouseDown: (e) => handleMouseDown(e, box, "sw"), title: "K\xE9o g\xF3c d\u01B0\u1EDBi-tr\xE1i" }),
995
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: handleStyle("w", isLight), onMouseDown: (e) => handleMouseDown(e, box, "w"), title: "K\xE9o c\u1EA1nh tr\xE1i (Ch\u1EC9nh \u0111\u1ED9 r\u1ED9ng / wrap text)" })
949
996
  ] })
950
997
  ]
951
998
  },
@@ -1029,7 +1076,7 @@ function SlideDesignOverlay({
1029
1076
  /* @__PURE__ */ jsxRuntime.jsx("input", { type: "color", value: selectedBox.color ?? (isLight ? "#0f172a" : "#38bdf8"), onChange: (e) => updateSelectedBox({ color: e.target.value }), style: { width: "22px", height: "22px", padding: "0", border: "none", borderRadius: "4px", cursor: "pointer", backgroundColor: "transparent" } })
1030
1077
  ] }),
1031
1078
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", alignItems: "center", gap: "2px", whiteSpace: "nowrap" }, children: ["left", "center", "right"].map((align) => /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => updateSelectedBox({ textAlign: align }), style: { ...btnStyle, backgroundColor: selectedBox.textAlign === align ? "#0284c7" : isLight ? "rgba(0,0,0,0.05)" : "rgba(255,255,255,0.05)", color: selectedBox.textAlign === align ? "#ffffff" : isLight ? "#0f172a" : "#e2e8f0", textTransform: "capitalize", fontSize: "11px", padding: "2px 6px", height: "22px" }, children: align }, align)) }),
1032
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: removeSelectedBox, style: { ...btnStyle, backgroundColor: isLight ? "rgba(239, 68, 68, 0.1)" : "rgba(239, 68, 68, 0.2)", color: isLight ? "#dc2626" : "#f87171", border: isLight ? "1px solid rgba(239, 68, 68, 0.3)" : "1px solid rgba(239, 68, 68, 0.4)", fontWeight: 500, height: "22px", padding: "0 8px" }, title: "X\xF3a \u0111\u1ECBnh v\u1ECB t\u1EF1 do c\u1EE7a khung n\xE0y", children: "X\xF3a v\u1ECB tr\xED" })
1079
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: removeSelectedBox, style: { ...btnStyle, backgroundColor: isLight ? "rgba(239, 68, 68, 0.1)" : "rgba(239, 68, 68, 0.2)", color: isLight ? "#dc2626" : "#f87171", border: isLight ? "1px solid rgba(239, 68, 68, 0.3)" : "1px solid rgba(239, 68, 68, 0.4)", fontWeight: 500, height: "22px", padding: "0 8px" }, title: "X\xF3a ph\u1EA7n t\u1EED (ho\u1EB7c nh\u1EA5n Delete tr\xEAn b\xE0n ph\xEDm)", children: "X\xF3a ph\u1EA7n t\u1EED (Del)" })
1033
1080
  ]
1034
1081
  }
1035
1082
  )
@@ -1062,6 +1109,10 @@ function handleStyle(pos, isLight = false) {
1062
1109
  return { ...base, right: `-${size / 2}px`, top: `-${size / 2}px`, cursor: "ne-resize" };
1063
1110
  case "nw":
1064
1111
  return { ...base, left: `-${size / 2}px`, top: `-${size / 2}px`, cursor: "nw-resize" };
1112
+ case "n":
1113
+ return { ...base, top: `-${size / 2}px`, left: `calc(50% - ${size / 2}px)`, cursor: "n-resize" };
1114
+ case "w":
1115
+ return { ...base, left: `-${size / 2}px`, top: `calc(50% - ${size / 2}px)`, cursor: "w-resize" };
1065
1116
  }
1066
1117
  }
1067
1118
  var DEFAULT_THEME_OPTIONS = [
@@ -1197,7 +1248,7 @@ function SlideViewer({
1197
1248
  containers.forEach((container) => {
1198
1249
  if (container instanceof HTMLElement) {
1199
1250
  const themeName2 = typeof theme === "string" ? theme : "dark";
1200
- chunkVLAPHJOC_cjs.renderMermaidDiagrams(container, themeName2).catch(() => {
1251
+ chunkTGI6YSZP_cjs.renderMermaidDiagrams(container, themeName2).catch(() => {
1201
1252
  });
1202
1253
  }
1203
1254
  });
@@ -1414,7 +1465,7 @@ function SlideViewer({
1414
1465
  onSave: (layout) => {
1415
1466
  setLiveLayout(layout);
1416
1467
  if (onSaveMarkdown) {
1417
- const updated = chunkIGCFC6GI_cjs.updateSlideLayoutInMarkdown(markdown, currentIndex, layout);
1468
+ const updated = chunkTV6NFIIV_cjs.updateSlideLayoutInMarkdown(markdown, currentIndex, layout);
1418
1469
  onSaveMarkdown(updated);
1419
1470
  }
1420
1471
  },
@@ -1450,35 +1501,35 @@ function SlideViewer({
1450
1501
 
1451
1502
  Object.defineProperty(exports, "defineTheme", {
1452
1503
  enumerable: true,
1453
- get: function () { return chunkVLAPHJOC_cjs.defineTheme; }
1504
+ get: function () { return chunkTGI6YSZP_cjs.defineTheme; }
1454
1505
  });
1455
1506
  Object.defineProperty(exports, "extractMaxClicks", {
1456
1507
  enumerable: true,
1457
- get: function () { return chunkVLAPHJOC_cjs.extractMaxClicks; }
1508
+ get: function () { return chunkTGI6YSZP_cjs.extractMaxClicks; }
1458
1509
  });
1459
1510
  Object.defineProperty(exports, "generateClickCss", {
1460
1511
  enumerable: true,
1461
- get: function () { return chunkVLAPHJOC_cjs.generateClickCss; }
1512
+ get: function () { return chunkTGI6YSZP_cjs.generateClickCss; }
1462
1513
  });
1463
1514
  Object.defineProperty(exports, "postprocessClicks", {
1464
1515
  enumerable: true,
1465
- get: function () { return chunkVLAPHJOC_cjs.postprocessClicks; }
1516
+ get: function () { return chunkTGI6YSZP_cjs.postprocessClicks; }
1466
1517
  });
1467
1518
  Object.defineProperty(exports, "preprocessClicks", {
1468
1519
  enumerable: true,
1469
- get: function () { return chunkVLAPHJOC_cjs.preprocessClicks; }
1520
+ get: function () { return chunkTGI6YSZP_cjs.preprocessClicks; }
1470
1521
  });
1471
1522
  Object.defineProperty(exports, "renderSlide", {
1472
1523
  enumerable: true,
1473
- get: function () { return chunkVLAPHJOC_cjs.renderSlide; }
1524
+ get: function () { return chunkTGI6YSZP_cjs.renderSlide; }
1474
1525
  });
1475
1526
  Object.defineProperty(exports, "renderSlideAsync", {
1476
1527
  enumerable: true,
1477
- get: function () { return chunkVLAPHJOC_cjs.renderSlideAsync; }
1528
+ get: function () { return chunkTGI6YSZP_cjs.renderSlideAsync; }
1478
1529
  });
1479
1530
  Object.defineProperty(exports, "resolveTheme", {
1480
1531
  enumerable: true,
1481
- get: function () { return chunkVLAPHJOC_cjs.resolveTheme; }
1532
+ get: function () { return chunkTGI6YSZP_cjs.resolveTheme; }
1482
1533
  });
1483
1534
  exports.DeckView = DeckView;
1484
1535
  exports.NavigationBar = NavigationBar;