@thangph2146/nextjs-editor 1.0.4 → 1.0.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.js CHANGED
@@ -2113,12 +2113,17 @@ function ContentEditable({
2113
2113
  placeholder: placeholder2,
2114
2114
  className,
2115
2115
  placeholderClassName,
2116
- placeholderDefaults = true
2116
+ placeholderDefaults = true,
2117
+ readOnly = false
2117
2118
  }) {
2118
2119
  return /* @__PURE__ */ jsx17(
2119
2120
  LexicalContentEditable,
2120
2121
  {
2121
- className: cn("ContentEditable__root relative block min-h-72 px-8 py-4 focus:outline-none", className),
2122
+ className: cn(
2123
+ "ContentEditable__root relative block px-8 py-4 focus:outline-none",
2124
+ readOnly ? "min-h-0" : "min-h-72",
2125
+ className
2126
+ ),
2122
2127
  "aria-placeholder": placeholder2,
2123
2128
  "aria-label": placeholder2 || "Editor n\u1ED9i dung",
2124
2129
  placeholder: /* @__PURE__ */ jsx17(
@@ -2628,20 +2633,39 @@ function ImageComponent({
2628
2633
  e.stopPropagation();
2629
2634
  setIsViewOriginalOpen(true);
2630
2635
  }, [isEditable]);
2631
- const imageWrapper = /* @__PURE__ */ jsx19("div", { draggable, children: isLoadError ? /* @__PURE__ */ jsx19(BrokenImage, {}) : /* @__PURE__ */ jsx19(
2632
- LazyImage,
2636
+ const imageWrapper = /* @__PURE__ */ jsx19(
2637
+ "div",
2633
2638
  {
2634
- className: imageClassName,
2635
- src,
2636
- altText,
2637
- imageRef,
2638
- width: responsiveDimensions.width,
2639
- height: responsiveDimensions.height,
2640
- maxWidth,
2641
- onError: () => setIsLoadError(true),
2642
- fetchPriority: isPriority ? "high" : "auto"
2639
+ draggable,
2640
+ ...!isEditable && {
2641
+ role: "button",
2642
+ tabIndex: 0,
2643
+ onClick: handleViewOriginal,
2644
+ onKeyDown: (e) => {
2645
+ if (e.key === "Enter" || e.key === " ") {
2646
+ e.preventDefault();
2647
+ handleViewOriginal(e);
2648
+ }
2649
+ },
2650
+ style: { cursor: "pointer", pointerEvents: "auto" },
2651
+ className: "block w-full"
2652
+ },
2653
+ children: isLoadError ? /* @__PURE__ */ jsx19(BrokenImage, {}) : /* @__PURE__ */ jsx19(
2654
+ LazyImage,
2655
+ {
2656
+ className: imageClassName,
2657
+ src,
2658
+ altText,
2659
+ imageRef,
2660
+ width: responsiveDimensions.width,
2661
+ height: responsiveDimensions.height,
2662
+ maxWidth,
2663
+ onError: () => setIsLoadError(true),
2664
+ fetchPriority: isPriority ? "high" : "auto"
2665
+ }
2666
+ )
2643
2667
  }
2644
- ) });
2668
+ );
2645
2669
  return /* @__PURE__ */ jsx19(
2646
2670
  Suspense,
2647
2671
  {
@@ -2658,7 +2682,8 @@ function ImageComponent({
2658
2682
  {
2659
2683
  type: "button",
2660
2684
  onClick: handleViewOriginal,
2661
- className: "cursor-pointer border-0 bg-transparent p-0 text-left outline-none [&>div]:outline-none",
2685
+ className: "block w-full cursor-pointer border-0 bg-transparent p-0 text-left outline-none [&>div]:outline-none",
2686
+ style: { pointerEvents: "auto" },
2662
2687
  "aria-label": "Xem h\xECnh g\u1ED1c",
2663
2688
  children: imageWrapper
2664
2689
  }
@@ -2709,29 +2734,29 @@ function ImageComponent({
2709
2734
  className: "max-w-[96vw] max-h-[96vh] w-[96vw] h-[96vh] overflow-hidden flex flex-col p-0 gap-0 rounded-xl border shadow-2xl",
2710
2735
  "aria-describedby": "view-original-image-desc",
2711
2736
  children: [
2712
- /* @__PURE__ */ jsx19(DialogHeader, { className: "shrink-0 px-6 pt-5 pb-2 border-b bg-muted/30", children: /* @__PURE__ */ jsx19(DialogTitle, { className: "text-base font-semibold", children: "Xem h\xECnh g\u1ED1c" }) }),
2737
+ /* @__PURE__ */ jsx19(DialogHeader, { className: "shrink-0 px-4 pt-3 pb-3 pr-12 border-b border-border/50 bg-muted/20 rounded-t-xl text-center sm:text-center", children: /* @__PURE__ */ jsx19(DialogTitle, { className: "text-sm font-semibold", children: "Xem h\xECnh g\u1ED1c" }) }),
2713
2738
  /* @__PURE__ */ jsx19(
2714
2739
  "div",
2715
2740
  {
2716
2741
  id: "view-original-image-desc",
2717
- className: "flex-1 min-h-[70vh] overflow-auto flex items-center justify-center p-4 bg-black/20",
2718
- children: /* @__PURE__ */ jsx19(
2742
+ className: "flex-1 min-h-0 w-full max-w-full overflow-x-hidden overflow-y-auto flex items-center justify-center p-4 bg-black/10",
2743
+ children: /* @__PURE__ */ jsx19("div", { className: "max-w-full max-h-full min-w-0 min-h-0 flex items-center justify-center", children: /* @__PURE__ */ jsx19(
2719
2744
  "img",
2720
2745
  {
2721
2746
  src,
2722
2747
  alt: altText || "H\xECnh g\u1ED1c",
2723
- className: "flex-1 min-w-0 min-h-0 w-full h-full max-w-full max-h-full object-contain rounded-lg"
2748
+ className: "min-w-0 min-h-0 max-w-full max-h-full w-auto h-auto object-contain rounded-lg select-none"
2724
2749
  }
2725
- )
2750
+ ) })
2726
2751
  }
2727
2752
  ),
2728
- /* @__PURE__ */ jsx19(DialogFooter, { className: "shrink-0 flex-row justify-center gap-2 px-6 py-4 border-t bg-muted/20 rounded-b-xl", children: /* @__PURE__ */ jsx19(
2753
+ /* @__PURE__ */ jsx19(DialogFooter, { className: "shrink-0 flex-row justify-center gap-2 px-4 py-3 border-t border-border/50 bg-muted/20 rounded-b-xl", children: /* @__PURE__ */ jsx19(
2729
2754
  Button,
2730
2755
  {
2731
2756
  variant: "outline",
2732
- size: "default",
2757
+ size: "sm",
2733
2758
  asChild: true,
2734
- className: "gap-2 text-base",
2759
+ className: "gap-2",
2735
2760
  children: /* @__PURE__ */ jsxs9(
2736
2761
  "a",
2737
2762
  {
@@ -33515,7 +33540,8 @@ function Plugins({
33515
33540
  ContentEditable,
33516
33541
  {
33517
33542
  placeholder: readOnly ? "" : placeholder,
33518
- className: `ContentEditable__root relative block min-h-72 px-8 py-4 focus:outline-none ${readOnly ? "cursor-default select-text border border-border rounded-md" : ""}`
33543
+ readOnly,
33544
+ className: readOnly ? "cursor-default select-text border-0 bg-transparent shadow-none" : ""
33519
33545
  }
33520
33546
  ) }) }),
33521
33547
  ErrorBoundary: LexicalErrorBoundary2,
@@ -33691,9 +33717,11 @@ function Editor({
33691
33717
  {
33692
33718
  ref: editorRef,
33693
33719
  className: cn(
33694
- "bg-background rounded-lg shadow w-full"
33720
+ "bg-background rounded-lg w-full",
33721
+ readOnly ? "shadow-none" : "shadow"
33695
33722
  ),
33696
33723
  id: "editor-x",
33724
+ "data-readonly": readOnly ? "true" : void 0,
33697
33725
  children: /* @__PURE__ */ jsx96(EditorContainerProvider, { value: { maxWidth: editorMaxWidth }, children: /* @__PURE__ */ jsx96(
33698
33726
  LexicalComposer,
33699
33727
  {