@firecms/core 3.5.1 → 3.5.2-canary.16bf7bb

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.
Files changed (34) hide show
  1. package/dist/components/HomePage/HomePageDnD.d.ts +4 -2
  2. package/dist/{de-CBOjCvsy.js → de-CUF9f7S-.js} +2 -1
  3. package/dist/{de-CBOjCvsy.js.map → de-CUF9f7S-.js.map} +1 -1
  4. package/dist/{editor-BSo_aS1I.js → editor-WZytSO_1.js} +172 -137
  5. package/dist/editor-WZytSO_1.js.map +1 -0
  6. package/dist/{fr-DRfttcG0.js → fr-DmkMX6hp.js} +2 -1
  7. package/dist/{fr-DRfttcG0.js.map → fr-DmkMX6hp.js.map} +1 -1
  8. package/dist/{hi-DwieOZNf.js → hi-BKuaMr7w.js} +2 -1
  9. package/dist/{hi-DwieOZNf.js.map → hi-BKuaMr7w.js.map} +1 -1
  10. package/dist/index.es.js +70 -62
  11. package/dist/index.es.js.map +1 -1
  12. package/dist/index.umd.js +238 -189
  13. package/dist/index.umd.js.map +1 -1
  14. package/dist/{it-l2KXtx9n.js → it-BwQflFGz.js} +2 -1
  15. package/dist/{it-l2KXtx9n.js.map → it-BwQflFGz.js.map} +1 -1
  16. package/dist/{pl-DPZrdKhi.js → pl-BPsAvZvc.js} +2 -1
  17. package/dist/{pl-DPZrdKhi.js.map → pl-BPsAvZvc.js.map} +1 -1
  18. package/dist/{pt-BoHpabw1.js → pt-D5q7OQp1.js} +2 -1
  19. package/dist/{pt-BoHpabw1.js.map → pt-D5q7OQp1.js.map} +1 -1
  20. package/dist/types/translations.d.ts +1 -0
  21. package/package.json +3 -3
  22. package/src/components/HomePage/DefaultHomePage.tsx +2 -0
  23. package/src/components/HomePage/HomePageDnD.tsx +12 -4
  24. package/src/editor/selectors/link-selector.tsx +37 -12
  25. package/src/locales/de.ts +1 -0
  26. package/src/locales/en.ts +1 -0
  27. package/src/locales/es.ts +1 -0
  28. package/src/locales/fr.ts +1 -0
  29. package/src/locales/hi.ts +1 -0
  30. package/src/locales/it.ts +1 -0
  31. package/src/locales/pl.ts +1 -0
  32. package/src/locales/pt.ts +1 -0
  33. package/src/types/translations.ts +1 -0
  34. package/dist/editor-BSo_aS1I.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import React__default, { createContext, useContext, forwardRef, useRef, useState, useEffect, useLayoutEffect } from "react";
4
- import { defaultBorderMixin, cls, TextFieldsIcon, CheckBoxIcon, LooksOneIcon, LooksTwoIcon, Looks3Icon, FormatListBulletedIcon, FormatListNumberedIcon, FormatQuoteIcon, CodeIcon, ImageIcon, TableChartIcon, AutoFixHighIcon, TextField, Tooltip, IconButton, CheckIcon, Popover, Button, KeyboardArrowDownIcon, focusedDisabled, DeleteIcon, FormatBoldIcon, FormatItalicIcon, FormatUnderlinedIcon, FormatStrikethroughIcon, useInjectStyles, Separator, TextareaAutosize } from "@firecms/ui";
4
+ import { defaultBorderMixin, cls, TextFieldsIcon, CheckBoxIcon, LooksOneIcon, LooksTwoIcon, Looks3Icon, FormatListBulletedIcon, FormatListNumberedIcon, FormatQuoteIcon, CodeIcon, ImageIcon, TableChartIcon, AutoFixHighIcon, TextField, Tooltip, IconButton, CheckIcon, Popover, Button, KeyboardArrowDownIcon, focusedDisabled, DeleteIcon, Typography, FormatBoldIcon, FormatItalicIcon, FormatUnderlinedIcon, FormatStrikethroughIcon, useInjectStyles, Separator, TextareaAutosize } from "@firecms/ui";
5
5
  import { useTranslation } from "./index.es.js";
6
6
  import { autoUpdate, computePosition, offset, flip, shift } from "@floating-ui/dom";
7
7
  import { NodeSelection, Plugin, PluginKey, TextSelection, EditorState } from "prosemirror-state";
@@ -2668,7 +2668,7 @@ function getUrlFromString(str) {
2668
2668
  }
2669
2669
  }
2670
2670
  const LinkSelector = (t0) => {
2671
- const $ = c(58);
2671
+ const $ = c(66);
2672
2672
  const {
2673
2673
  open,
2674
2674
  onOpenChange
@@ -2681,20 +2681,23 @@ const LinkSelector = (t0) => {
2681
2681
  const {
2682
2682
  t
2683
2683
  } = useTranslation();
2684
+ const [error, setError] = useState(null);
2685
+ const isInputInvalid = !!error;
2684
2686
  let t1;
2685
- let t2;
2686
- if ($[0] !== open) {
2687
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2687
2688
  t1 = () => {
2688
- if (open && inputRef.current) {
2689
- inputRef.current.focus();
2690
- }
2689
+ setError(null);
2691
2690
  };
2691
+ $[0] = t1;
2692
+ } else {
2693
+ t1 = $[0];
2694
+ }
2695
+ let t2;
2696
+ if ($[1] !== open) {
2692
2697
  t2 = [open];
2693
- $[0] = open;
2694
- $[1] = t1;
2698
+ $[1] = open;
2695
2699
  $[2] = t2;
2696
2700
  } else {
2697
- t1 = $[1];
2698
2701
  t2 = $[2];
2699
2702
  }
2700
2703
  useEffect(t1, t2);
@@ -2702,195 +2705,227 @@ const LinkSelector = (t0) => {
2702
2705
  return null;
2703
2706
  }
2704
2707
  let t3;
2705
- if ($[3] !== onOpenChange || $[4] !== view) {
2708
+ if ($[3] !== isInputInvalid) {
2706
2709
  t3 = (e) => {
2707
- e.preventDefault();
2710
+ if (isInputInvalid) {
2711
+ setError(null);
2712
+ }
2713
+ };
2714
+ $[3] = isInputInvalid;
2715
+ $[4] = t3;
2716
+ } else {
2717
+ t3 = $[4];
2718
+ }
2719
+ const handleChange = t3;
2720
+ let t4;
2721
+ if ($[5] !== onOpenChange || $[6] !== t || $[7] !== view) {
2722
+ t4 = (e_0) => {
2723
+ e_0.preventDefault();
2724
+ e_0.stopPropagation();
2725
+ setError(null);
2708
2726
  const value = inputRef.current?.value;
2709
2727
  if (!value) {
2710
2728
  return;
2711
2729
  }
2712
2730
  const url = getUrlFromString(value);
2713
- if (url) {
2714
- setMark(schema.marks.link, {
2715
- href: url
2716
- })(view.state, view.dispatch);
2717
- view.focus();
2718
- onOpenChange(false);
2731
+ if (!url) {
2732
+ setError(t("editor_invalid_url"));
2733
+ return;
2719
2734
  }
2735
+ setMark(schema.marks.link, {
2736
+ href: url
2737
+ })(view.state, view.dispatch);
2738
+ view.focus();
2739
+ onOpenChange(false);
2720
2740
  };
2721
- $[3] = onOpenChange;
2722
- $[4] = view;
2723
- $[5] = t3;
2741
+ $[5] = onOpenChange;
2742
+ $[6] = t;
2743
+ $[7] = view;
2744
+ $[8] = t4;
2724
2745
  } else {
2725
- t3 = $[5];
2746
+ t4 = $[8];
2726
2747
  }
2727
- const handleSubmit = t3;
2728
- let t4;
2729
- if ($[6] !== onOpenChange || $[7] !== view) {
2730
- t4 = () => {
2748
+ const handleSubmit = t4;
2749
+ let t5;
2750
+ if ($[9] !== onOpenChange || $[10] !== view) {
2751
+ t5 = () => {
2731
2752
  unsetMark(schema.marks.link)(view.state, view.dispatch);
2732
2753
  view.focus();
2733
2754
  onOpenChange(false);
2734
2755
  };
2735
- $[6] = onOpenChange;
2736
- $[7] = view;
2737
- $[8] = t4;
2756
+ $[9] = onOpenChange;
2757
+ $[10] = view;
2758
+ $[11] = t5;
2738
2759
  } else {
2739
- t4 = $[8];
2760
+ t5 = $[11];
2740
2761
  }
2741
- const handleRemoveLink = t4;
2762
+ const handleRemoveLink = t5;
2742
2763
  let T0;
2743
2764
  let T1;
2744
2765
  let href;
2745
2766
  let t10;
2746
2767
  let t11;
2747
2768
  let t12;
2748
- let t5;
2769
+ let t13;
2749
2770
  let t6;
2750
2771
  let t7;
2751
2772
  let t8;
2752
2773
  let t9;
2753
- if ($[9] !== onOpenChange || $[10] !== open || $[11] !== state) {
2774
+ if ($[12] !== onOpenChange || $[13] !== open || $[14] !== state) {
2754
2775
  const isActive = isMarkActive(state, schema.marks.link);
2755
- let t132;
2756
- if ($[23] !== state) {
2757
- t132 = getMarkAttributes(state, schema.marks.link).href || "";
2758
- $[23] = state;
2759
- $[24] = t132;
2776
+ let t142;
2777
+ if ($[26] !== state) {
2778
+ t142 = getMarkAttributes(state, schema.marks.link).href || "";
2779
+ $[26] = state;
2780
+ $[27] = t142;
2760
2781
  } else {
2761
- t132 = $[24];
2782
+ t142 = $[27];
2762
2783
  }
2763
- href = t132;
2784
+ href = t142;
2764
2785
  T1 = Popover;
2765
- t10 = true;
2766
- t11 = open;
2767
- t12 = onOpenChange;
2786
+ t11 = true;
2787
+ t12 = open;
2788
+ t13 = onOpenChange;
2768
2789
  T0 = Button;
2769
- t6 = "text";
2770
- t7 = "button";
2771
- t8 = "gap-2 rounded-none";
2772
- t9 = "text";
2773
- t5 = cls("underline decoration-stone-400 underline-offset-4", {
2790
+ t7 = "text";
2791
+ t8 = "button";
2792
+ t9 = "gap-2 rounded-none";
2793
+ t10 = "text";
2794
+ t6 = cls("underline decoration-stone-400 underline-offset-4", {
2774
2795
  "text-blue-500": isActive
2775
2796
  });
2776
- $[9] = onOpenChange;
2777
- $[10] = open;
2778
- $[11] = state;
2779
- $[12] = T0;
2780
- $[13] = T1;
2781
- $[14] = href;
2782
- $[15] = t10;
2783
- $[16] = t11;
2784
- $[17] = t12;
2785
- $[18] = t5;
2786
- $[19] = t6;
2787
- $[20] = t7;
2788
- $[21] = t8;
2789
- $[22] = t9;
2790
- } else {
2791
- T0 = $[12];
2792
- T1 = $[13];
2793
- href = $[14];
2794
- t10 = $[15];
2795
- t11 = $[16];
2796
- t12 = $[17];
2797
- t5 = $[18];
2798
- t6 = $[19];
2799
- t7 = $[20];
2800
- t8 = $[21];
2801
- t9 = $[22];
2802
- }
2803
- let t13;
2804
- if ($[25] !== t) {
2805
- t13 = t("editor_link");
2806
- $[25] = t;
2807
- $[26] = t13;
2797
+ $[12] = onOpenChange;
2798
+ $[13] = open;
2799
+ $[14] = state;
2800
+ $[15] = T0;
2801
+ $[16] = T1;
2802
+ $[17] = href;
2803
+ $[18] = t10;
2804
+ $[19] = t11;
2805
+ $[20] = t12;
2806
+ $[21] = t13;
2807
+ $[22] = t6;
2808
+ $[23] = t7;
2809
+ $[24] = t8;
2810
+ $[25] = t9;
2808
2811
  } else {
2809
- t13 = $[26];
2812
+ T0 = $[15];
2813
+ T1 = $[16];
2814
+ href = $[17];
2815
+ t10 = $[18];
2816
+ t11 = $[19];
2817
+ t12 = $[20];
2818
+ t13 = $[21];
2819
+ t6 = $[22];
2820
+ t7 = $[23];
2821
+ t8 = $[24];
2822
+ t9 = $[25];
2810
2823
  }
2811
2824
  let t14;
2812
- if ($[27] !== t13 || $[28] !== t5) {
2813
- t14 = /* @__PURE__ */ jsx("p", { className: t5, children: t13 });
2814
- $[27] = t13;
2815
- $[28] = t5;
2825
+ if ($[28] !== t) {
2826
+ t14 = t("editor_link");
2827
+ $[28] = t;
2816
2828
  $[29] = t14;
2817
2829
  } else {
2818
2830
  t14 = $[29];
2819
2831
  }
2820
2832
  let t15;
2821
- if ($[30] !== T0 || $[31] !== t14 || $[32] !== t6 || $[33] !== t7 || $[34] !== t8 || $[35] !== t9) {
2822
- t15 = /* @__PURE__ */ jsx(T0, { variant: t6, type: t7, className: t8, color: t9, children: t14 });
2823
- $[30] = T0;
2824
- $[31] = t14;
2825
- $[32] = t6;
2826
- $[33] = t7;
2827
- $[34] = t8;
2828
- $[35] = t9;
2829
- $[36] = t15;
2833
+ if ($[30] !== t14 || $[31] !== t6) {
2834
+ t15 = /* @__PURE__ */ jsx("p", { className: t6, children: t14 });
2835
+ $[30] = t14;
2836
+ $[31] = t6;
2837
+ $[32] = t15;
2830
2838
  } else {
2831
- t15 = $[36];
2839
+ t15 = $[32];
2832
2840
  }
2833
2841
  let t16;
2834
- if ($[37] !== t) {
2835
- t16 = t("editor_paste_or_type_link");
2836
- $[37] = t;
2837
- $[38] = t16;
2842
+ if ($[33] !== T0 || $[34] !== t10 || $[35] !== t15 || $[36] !== t7 || $[37] !== t8 || $[38] !== t9) {
2843
+ t16 = /* @__PURE__ */ jsx(T0, { variant: t7, type: t8, className: t9, color: t10, children: t15 });
2844
+ $[33] = T0;
2845
+ $[34] = t10;
2846
+ $[35] = t15;
2847
+ $[36] = t7;
2848
+ $[37] = t8;
2849
+ $[38] = t9;
2850
+ $[39] = t16;
2838
2851
  } else {
2839
- t16 = $[38];
2852
+ t16 = $[39];
2840
2853
  }
2841
2854
  let t17;
2842
- if ($[39] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2843
- t17 = cls("text-surface-900 dark:text-white flex-grow bg-transparent p-1 text-sm outline-none", focusedDisabled);
2844
- $[39] = t17;
2855
+ if ($[40] !== t) {
2856
+ t17 = t("editor_paste_or_type_link");
2857
+ $[40] = t;
2858
+ $[41] = t17;
2845
2859
  } else {
2846
- t17 = $[39];
2860
+ t17 = $[41];
2847
2861
  }
2848
2862
  let t18;
2849
- if ($[40] !== href || $[41] !== open || $[42] !== t16) {
2850
- t18 = /* @__PURE__ */ jsx("input", { ref: inputRef, autoFocus: open, placeholder: t16, defaultValue: href, className: t17 });
2851
- $[40] = href;
2852
- $[41] = open;
2853
- $[42] = t16;
2854
- $[43] = t18;
2863
+ if ($[42] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2864
+ t18 = cls("text-surface-900 dark:text-white flex-grow bg-transparent p-1 text-sm outline-none", focusedDisabled);
2865
+ $[42] = t18;
2855
2866
  } else {
2856
- t18 = $[43];
2867
+ t18 = $[42];
2857
2868
  }
2858
2869
  let t19;
2859
- if ($[44] !== handleRemoveLink || $[45] !== href) {
2860
- t19 = href ? /* @__PURE__ */ jsx(Button, { size: "small", variant: "text", type: "button", color: "text", className: "flex items-center", onClick: handleRemoveLink, children: /* @__PURE__ */ jsx(DeleteIcon, { size: "small" }) }) : /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", variant: "text", children: /* @__PURE__ */ jsx(CheckIcon, { size: "small" }) });
2861
- $[44] = handleRemoveLink;
2862
- $[45] = href;
2863
- $[46] = t19;
2870
+ if ($[43] !== href || $[44] !== isInputInvalid || $[45] !== open || $[46] !== t17) {
2871
+ t19 = /* @__PURE__ */ jsx("input", { ref: inputRef, autoFocus: open, placeholder: t17, defaultValue: href, className: t18, "aria-invalid": isInputInvalid });
2872
+ $[43] = href;
2873
+ $[44] = isInputInvalid;
2874
+ $[45] = open;
2875
+ $[46] = t17;
2876
+ $[47] = t19;
2864
2877
  } else {
2865
- t19 = $[46];
2878
+ t19 = $[47];
2866
2879
  }
2867
2880
  let t20;
2868
- if ($[47] !== handleSubmit || $[48] !== t18 || $[49] !== t19) {
2869
- t20 = /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "flex p-1 gap-1", children: [
2870
- t18,
2871
- t19
2872
- ] });
2873
- $[47] = handleSubmit;
2874
- $[48] = t18;
2875
- $[49] = t19;
2881
+ if ($[48] !== handleRemoveLink || $[49] !== href) {
2882
+ t20 = href ? /* @__PURE__ */ jsx(Button, { size: "small", variant: "text", type: "button", color: "text", className: "flex items-center", onClick: handleRemoveLink, children: /* @__PURE__ */ jsx(DeleteIcon, { size: "small" }) }) : /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", variant: "text", children: /* @__PURE__ */ jsx(CheckIcon, { size: "small" }) });
2883
+ $[48] = handleRemoveLink;
2884
+ $[49] = href;
2876
2885
  $[50] = t20;
2877
2886
  } else {
2878
2887
  t20 = $[50];
2879
2888
  }
2880
2889
  let t21;
2881
- if ($[51] !== T1 || $[52] !== t10 || $[53] !== t11 || $[54] !== t12 || $[55] !== t15 || $[56] !== t20) {
2882
- t21 = /* @__PURE__ */ jsx(T1, { modal: t10, open: t11, onOpenChange: t12, trigger: t15, children: t20 });
2883
- $[51] = T1;
2884
- $[52] = t10;
2885
- $[53] = t11;
2886
- $[54] = t12;
2887
- $[55] = t15;
2888
- $[56] = t20;
2889
- $[57] = t21;
2890
+ if ($[51] !== handleChange || $[52] !== handleSubmit || $[53] !== t19 || $[54] !== t20) {
2891
+ t21 = /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "flex p-1 gap-1", onChange: handleChange, children: [
2892
+ t19,
2893
+ t20
2894
+ ] });
2895
+ $[51] = handleChange;
2896
+ $[52] = handleSubmit;
2897
+ $[53] = t19;
2898
+ $[54] = t20;
2899
+ $[55] = t21;
2900
+ } else {
2901
+ t21 = $[55];
2902
+ }
2903
+ let t22;
2904
+ if ($[56] !== error) {
2905
+ t22 = error && /* @__PURE__ */ jsx("div", { className: "p-2", children: /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "error", role: "alert", "aria-live": "polite", children: error }) });
2906
+ $[56] = error;
2907
+ $[57] = t22;
2908
+ } else {
2909
+ t22 = $[57];
2910
+ }
2911
+ let t23;
2912
+ if ($[58] !== T1 || $[59] !== t11 || $[60] !== t12 || $[61] !== t13 || $[62] !== t16 || $[63] !== t21 || $[64] !== t22) {
2913
+ t23 = /* @__PURE__ */ jsxs(T1, { modal: t11, open: t12, onOpenChange: t13, trigger: t16, children: [
2914
+ t21,
2915
+ t22
2916
+ ] });
2917
+ $[58] = T1;
2918
+ $[59] = t11;
2919
+ $[60] = t12;
2920
+ $[61] = t13;
2921
+ $[62] = t16;
2922
+ $[63] = t21;
2923
+ $[64] = t22;
2924
+ $[65] = t23;
2890
2925
  } else {
2891
- t21 = $[57];
2926
+ t23 = $[65];
2892
2927
  }
2893
- return t21;
2928
+ return t23;
2894
2929
  };
2895
2930
  const TextButtons = () => {
2896
2931
  const $ = c(3);
@@ -4560,4 +4595,4 @@ ul[data-type="taskList"] li[data-checked="true"] > div > p {
4560
4595
  export {
4561
4596
  FireCMSEditor
4562
4597
  };
4563
- //# sourceMappingURL=editor-BSo_aS1I.js.map
4598
+ //# sourceMappingURL=editor-WZytSO_1.js.map