Fix HTML rendering for service descriptions, allow zero price for services, improve image_url handling
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import { useEditor, EditorContent } from "@tiptap/react";
|
||||
import StarterKit from "@tiptap/starter-kit";
|
||||
import Placeholder from "@tiptap/extension-placeholder";
|
||||
@@ -95,10 +95,14 @@ const MenuBar = ({ editor }) => {
|
||||
};
|
||||
|
||||
const RichTextEditor = ({
|
||||
value,
|
||||
content,
|
||||
onChange,
|
||||
placeholder = "Enter description...",
|
||||
}) => {
|
||||
// Support both 'value' and 'content' props for flexibility
|
||||
const initialContent = value || content || "";
|
||||
|
||||
const editor = useEditor({
|
||||
extensions: [
|
||||
StarterKit,
|
||||
@@ -106,12 +110,23 @@ const RichTextEditor = ({
|
||||
placeholder,
|
||||
}),
|
||||
],
|
||||
content,
|
||||
content: initialContent,
|
||||
onUpdate: ({ editor }) => {
|
||||
onChange(editor.getHTML());
|
||||
},
|
||||
});
|
||||
|
||||
// Update editor content when value/content prop changes externally
|
||||
useEffect(() => {
|
||||
if (editor && initialContent !== undefined) {
|
||||
const currentContent = editor.getHTML();
|
||||
// Only update if the content is actually different (prevents cursor jump)
|
||||
if (currentContent !== initialContent && initialContent !== "<p></p>") {
|
||||
editor.commands.setContent(initialContent);
|
||||
}
|
||||
}
|
||||
}, [editor, initialContent]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="border border-border rounded-md overflow-hidden resize-y min-h-[240px] max-h-[600px]"
|
||||
|
||||
Reference in New Issue
Block a user