diff --git a/packages/editor/core/src/lib/utils.ts b/packages/editor/core/src/lib/utils.ts index 64b5a3db7..82618a4c6 100644 --- a/packages/editor/core/src/lib/utils.ts +++ b/packages/editor/core/src/lib/utils.ts @@ -1,5 +1,17 @@ import { clsx, type ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; +interface EditorClassNames { + noBorder?: boolean; + borderOnFocus?: boolean; + customClassName?: string; +} + +export const getEditorClassNames = ({ noBorder, borderOnFocus, customClassName }: EditorClassNames) => cn( + 'relative w-full max-w-full sm:rounded-lg mt-2 p-3 relative focus:outline-none rounded-md', + noBorder ? '' : 'border border-custom-border-200', + borderOnFocus ? 'focus:border border-custom-border-300' : 'focus:border-0', + customClassName +); export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); @@ -14,16 +26,8 @@ export const findTableAncestor = ( return node as HTMLTableElement; }; -interface EditorClassNames { - noBorder?: boolean; - borderOnFocus?: boolean; - customClassName?: string; -} - -export const getEditorClassNames = ({ noBorder, borderOnFocus, customClassName }: EditorClassNames) => cn( - 'relative w-full max-w-full sm:rounded-lg mt-2 p-3 relative focus:outline-none rounded-md', - noBorder ? '' : 'border border-custom-border-200', - borderOnFocus ? 'focus:border border-custom-border-300' : 'focus:border-0', - customClassName -); - +export const getTrimmedHTML = (html: string) => { + html = html.replace(/^(

<\/p>)+/, ''); + html = html.replace(/(

<\/p>)+$/, ''); + return html; +} \ No newline at end of file diff --git a/packages/editor/core/src/ui/hooks/useEditor.tsx b/packages/editor/core/src/ui/hooks/useEditor.tsx index 7f7629119..43d7799ee 100644 --- a/packages/editor/core/src/ui/hooks/useEditor.tsx +++ b/packages/editor/core/src/ui/hooks/useEditor.tsx @@ -6,6 +6,7 @@ import { DeleteImage } from '@/types/delete-image'; import { CoreEditorProps } from "../props"; import { CoreEditorExtensions } from "../extensions"; import { EditorProps } from '@tiptap/pm/view'; +import { getTrimmedHTML } from "@/lib/utils"; const DEBOUNCE_DELAY = 1500; @@ -24,6 +25,7 @@ interface CustomEditorProps { } export const useEditor = ({ uploadFile, editable, deleteFile, editorProps = {}, value, extensions = [], onChange, setIsSubmitting, debouncedUpdatesEnabled, forwardedRef, setShouldShowAlert, }: CustomEditorProps) => { + console.log("content aaya", value) const editor = useCustomEditor({ editable: editable ?? true, editorProps: { @@ -39,7 +41,7 @@ export const useEditor = ({ uploadFile, editable, deleteFile, editorProps = {}, if (debouncedUpdatesEnabled) { debouncedUpdates({ onChange: onChange, editor }); } else { - onChange?.(editor.getJSON(), editor.getHTML()); + onChange?.(editor.getJSON(), getTrimmedHTML(editor.getHTML())); } }, }); @@ -58,7 +60,7 @@ export const useEditor = ({ uploadFile, editable, deleteFile, editorProps = {}, const debouncedUpdates = useDebouncedCallback(async ({ onChange, editor }) => { if (onChange) { - onChange(editor.getJSON(), editor.getHTML()); + onChange(editor.getJSON(), getTrimmedHTML(editor.getHTML())); } }, DEBOUNCE_DELAY); diff --git a/web/pages/[workspaceSlug]/me/profile/activity.tsx b/web/pages/[workspaceSlug]/me/profile/activity.tsx index a50fdde01..9305577cf 100644 --- a/web/pages/[workspaceSlug]/me/profile/activity.tsx +++ b/web/pages/[workspaceSlug]/me/profile/activity.tsx @@ -20,8 +20,6 @@ import { USER_ACTIVITY } from "constants/fetch-keys"; // helper import { timeAgo } from "helpers/date-time.helper"; import { SettingsSidebar } from "components/project"; -// services -import fileService from "@/services/file.service"; const ProfileActivity = () => { const router = useRouter();