@tecof/theme-editor 0.0.26 → 0.0.27

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
@@ -1,7 +1,7 @@
1
1
  import * as React__default from 'react';
2
2
  import React__default__default, { createContext, memo, forwardRef, createElement, useRef, useCallback, useContext, useState, useEffect, useMemo, Component, useLayoutEffect } from 'react';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
- import { fieldsPlugin, Puck, Render, FieldLabel } from '@puckeditor/core';
4
+ import { blocksPlugin, outlinePlugin, fieldsPlugin, Puck, Render, FieldLabel } from '@puckeditor/core';
5
5
  import { useEditor, EditorContent } from '@tiptap/react';
6
6
  import Document from '@tiptap/extension-document';
7
7
  import Paragraph from '@tiptap/extension-paragraph';
@@ -431,7 +431,9 @@ var TecofEditor = ({
431
431
  ] }) });
432
432
  }
433
433
  const plugins = [
434
- ...fieldsPlugin ? [fieldsPlugin({ desktopSideBar: "left" })] : [],
434
+ { ...blocksPlugin(), label: "Bloklar" },
435
+ { ...outlinePlugin(), label: "Anahat" },
436
+ { ...fieldsPlugin({ desktopSideBar: "right" }), label: "Alanlar" },
435
437
  ...extraPlugins || []
436
438
  ];
437
439
  const mergedOverrides = {
@@ -450,7 +452,8 @@ var TecofEditor = ({
450
452
  data: initialData,
451
453
  onPublish: handlePuckPublish,
452
454
  onChange: handleChange,
453
- overrides: mergedOverrides
455
+ overrides: mergedOverrides,
456
+ metadata: { editMode: true }
454
457
  }
455
458
  ),
456
459
  saving && /* @__PURE__ */ jsx("div", { className: "tecof-editor-save-indicator", children: saveStatus === "error" ? "Save failed" : "Saving..." })
@@ -23982,6 +23985,25 @@ var normalizeHex = (hex) => {
23982
23985
  }
23983
23986
  return v2;
23984
23987
  };
23988
+ var toHex = (val) => {
23989
+ if (!val) return "";
23990
+ const trimmed = val.trim();
23991
+ if (trimmed.startsWith("#")) return trimmed;
23992
+ const rgbaMatch = trimmed.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)$/i);
23993
+ if (rgbaMatch) {
23994
+ const r2 = parseInt(rgbaMatch[1], 10);
23995
+ const g = parseInt(rgbaMatch[2], 10);
23996
+ const b = parseInt(rgbaMatch[3], 10);
23997
+ const a2 = rgbaMatch[4] !== void 0 ? parseFloat(rgbaMatch[4]) : 1;
23998
+ const hex = `#${[r2, g, b].map((c2) => c2.toString(16).padStart(2, "0")).join("")}`;
23999
+ if (a2 < 1) {
24000
+ const alphaHex = Math.round(a2 * 255).toString(16).padStart(2, "0");
24001
+ return hex + alphaHex;
24002
+ }
24003
+ return hex;
24004
+ }
24005
+ return trimmed;
24006
+ };
23985
24007
  var ColorField = ({
23986
24008
  value,
23987
24009
  onChange,
@@ -23991,14 +24013,15 @@ var ColorField = ({
23991
24013
  placeholder = "#000000",
23992
24014
  showReset = true
23993
24015
  }) => {
23994
- const [hexInput, setHexInput] = useState(value || "");
24016
+ const [hexInput, setHexInput] = useState(() => toHex(value || ""));
23995
24017
  const [opacity, setOpacity2] = useState(100);
23996
24018
  const [focused, setFocused] = useState(false);
23997
24019
  const inputRef = useRef(null);
23998
24020
  useEffect(() => {
23999
- setHexInput(value || "");
24000
- if (value && value.length === 9) {
24001
- const alphaHex = value.slice(7, 9);
24021
+ const hex = toHex(value || "");
24022
+ setHexInput(hex);
24023
+ if (hex && hex.length === 9) {
24024
+ const alphaHex = hex.slice(7, 9);
24002
24025
  const alphaPercent = Math.round(parseInt(alphaHex, 16) / 255 * 100);
24003
24026
  setOpacity2(alphaPercent);
24004
24027
  } else {