@tarviks/lexical-rich-editor 1.0.7 → 1.0.8

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.mjs CHANGED
@@ -5032,10 +5032,16 @@ var PRESET = [
5032
5032
  ];
5033
5033
  var clamp3 = (v, min, max) => Math.min(max, Math.max(min, v));
5034
5034
  var normalizeHex = (v) => {
5035
- let s = (v ?? "").trim();
5035
+ const s = (v ?? "").trim();
5036
5036
  if (!s) return "#000000";
5037
- if (!s.startsWith("#")) s = `#${s}`;
5038
- if (s.length === 4 || s.length === 7) return s;
5037
+ const rgbMatch = s.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)$/i);
5038
+ if (rgbMatch) {
5039
+ const [, r, g, b] = rgbMatch;
5040
+ return rgbToHex(clamp3(+r, 0, 255), clamp3(+g, 0, 255), clamp3(+b, 0, 255));
5041
+ }
5042
+ let hex = s.startsWith("#") ? s : `#${s}`;
5043
+ if (hex.length === 9) hex = hex.slice(0, 7);
5044
+ if (hex.length === 4 || hex.length === 7) return hex.toLowerCase();
5039
5045
  return "#000000";
5040
5046
  };
5041
5047
  var hexToRgb = (hex) => {
@@ -5217,6 +5223,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
5217
5223
  /* @__PURE__ */ jsx(
5218
5224
  Button,
5219
5225
  {
5226
+ type: "button",
5220
5227
  size: "small",
5221
5228
  icon,
5222
5229
  value: title,
@@ -5316,13 +5323,14 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
5316
5323
  /* @__PURE__ */ jsx(
5317
5324
  DefaultButton,
5318
5325
  {
5326
+ type: "button",
5319
5327
  text: "Apply",
5320
5328
  onClick: () => {
5321
5329
  commitHsv(h, s, v, true);
5322
5330
  }
5323
5331
  }
5324
5332
  ),
5325
- /* @__PURE__ */ jsx(DefaultButton, { text: "Close", onClick: () => setOpen(false) })
5333
+ /* @__PURE__ */ jsx(DefaultButton, { type: "button", text: "Close", onClick: () => setOpen(false) })
5326
5334
  ] })
5327
5335
  ] })
5328
5336
  }