@tecof/theme-editor 0.0.25 → 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..." })
@@ -507,8 +510,9 @@ var TecofPicture = memo(({
507
510
  const { apiClient } = useTecof();
508
511
  const cdnUrl = apiClient.cdnUrl;
509
512
  if (!data3) return null;
513
+ const buildPath = (fileName) => data3?.folder && data3.folder !== "/" ? `${data3.folder.replace(/^\//, "")}/${fileName}` : fileName;
510
514
  const isExternal = data3?.type === "external" || data3?.provider === "external";
511
- const fileURL = isExternal ? data3?.url || "" : `${cdnUrl}/${data3?.name}`;
515
+ const fileURL = isExternal ? data3?.url || "" : `${cdnUrl}/${buildPath(data3?.name)}`;
512
516
  const isImageType2 = isExternal ? true : isImage(data3?.type);
513
517
  const isVideoType = isExternal ? false : isVideo(data3?.type);
514
518
  if (!fileURL) return null;
@@ -23981,6 +23985,25 @@ var normalizeHex = (hex) => {
23981
23985
  }
23982
23986
  return v2;
23983
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
+ };
23984
24007
  var ColorField = ({
23985
24008
  value,
23986
24009
  onChange,
@@ -23990,14 +24013,15 @@ var ColorField = ({
23990
24013
  placeholder = "#000000",
23991
24014
  showReset = true
23992
24015
  }) => {
23993
- const [hexInput, setHexInput] = useState(value || "");
24016
+ const [hexInput, setHexInput] = useState(() => toHex(value || ""));
23994
24017
  const [opacity, setOpacity2] = useState(100);
23995
24018
  const [focused, setFocused] = useState(false);
23996
24019
  const inputRef = useRef(null);
23997
24020
  useEffect(() => {
23998
- setHexInput(value || "");
23999
- if (value && value.length === 9) {
24000
- 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);
24001
24025
  const alphaPercent = Math.round(parseInt(alphaHex, 16) / 255 * 100);
24002
24026
  setOpacity2(alphaPercent);
24003
24027
  } else {