"use client"; import { Skeleton } from "@suphark/ui/components/ui/skeleton"; import { useMounted } from "@suphark/ui/hooks/use-mounted"; import { cn } from "@suphark/ui/lib/utils"; import { lazy, Suspense } from "react"; import type { RichTextEditorProps, RichTextEditorRef } from "./editor"; export type { RichTextEditorProps, RichTextEditorRef }; /** โครงหน้าตาเดียวกับ editor จริง เพื่อไม่ให้ layout ขยับตอนโหลดเสร็จ */ function RichTextEditorSkeleton({ className }: { className?: string }) { return (
{Array.from({ length: 8 }, (_, i) => ( // biome-ignore lint/suspicious/noArrayIndexKey: skeleton ที่ตำแหน่งคงที่ ไม่มีการเรียงใหม่ ))}
); } // Lexical + ปลั๊กอิน + ทูลบาร์ใหญ่ — โหลดเมื่อหน้าที่ใช้ render เท่านั้น (ไม่ติด initial bundle) const LazyRichTextEditor = lazy(() => import("./editor").then((m) => ({ default: m.RichTextEditor })), ); /** * ช่องพิมพ์ข้อความจัดรูปแบบ (HTML) บน Lexical: ตัวหนา/เอียง/ขีดเส้นใต้, ขนาดตัวอักษร, จัดแนว, รายการ, * ลิงก์, ตาราง (รวม/แยกช่อง สีพื้น ความสูงแถว ปรับความกว้างคอลัมน์), เส้นคั่น, ตัวแปร `{{…}}` * * render ฝั่ง client เท่านั้น (Lexical ต้องใช้ DOM ตอนเริ่ม) — ก่อน mount/ระหว่างโหลดแสดงโครงเปล่า * ref ของ editor ส่งผ่าน `editorRef` (API เดิมของ supplychain) */ export function RichTextEditor(props: RichTextEditorProps) { const mounted = useMounted(); const skeleton = ; if (!mounted) return skeleton; return ( ); }