ComponentForm Input
Bắt đầu nhanh
Import UEditor từ entry công khai. Các ví dụ bên dưới thể hiện những kiểu tương tác và cấu hình được hỗ trợ.
component.tsxtsx
import { UEditor } from '@underverse-ui/underverse';Ví dụ tương tác
Dùng thử UEditor thật, xem mã ví dụ và tra cứu các prop đã được mô tả.
Đang tải ví dụ tương tác…
Tham chiếu
Tham chiếu API
Tra cứu các thuộc tính, kiểu dữ liệu được chấp nhận, giá trị mặc định và lưu ý về hành vi.
Dữ liệu được sinh từ API TypeScript công khai của thư viện. Kiểu dữ liệu, thuộc tính bắt buộc và giá trị mặc định luôn đồng bộ với mã nguồn.
UEditor
Component| Thuộc tính | Mô tả | Kiểu | Mặc định |
|---|---|---|---|
getPortalContainer | Returns the per-editor container used by menus and other portalled overlays. | () => HTMLElement | null | — |
content | Initial or controlled HTML content for the editor. | string | "" |
onChange | Called with the current HTML after editor updates. Kept for backward compatibility with `onHtmlChange`. | (content: string) => void | — |
onHtmlChange | Called with the current HTML after editor updates. Prefer this when the consumer stores HTML. | (html: string) => void | — |
onJsonChange | Called with the current TipTap JSON document after editor updates. | (json: object) => void | — |
outputDebounceMs | Debounces HTML/JSON output callbacks by the given number of milliseconds. Defaults to `0` for backward-compatible immediate updates. Values around `100-200` are recommended for large controlled documents. | number | 0 |
uploadImage | Uploads images immediately when they are inserted in `imageInsertMode="upload"`. | (file: File) => Promise<string> | string | — |
uploadImageForSave | Uploads embedded/base64 images during `prepareContentForSave`; use this for save-time normalization. | UEditorUploadImageForSave | — |
uploadImageConcurrency | Maximum number of concurrent save-time image/file uploads. | number | 3 |
imageInsertMode | Whether inserted images are kept as base64 in editor state or uploaded immediately. | "base64" | "upload" | "base64" |
maxImageFileSize | Mã nguồn chưa cung cấp mô tả bổ sung. | number | — |
allowedImageMimeTypes | Mã nguồn chưa cung cấp mô tả bổ sung. | string[] | — |
fallbackToDataUrl | Mã nguồn chưa cung cấp mô tả bổ sung. | boolean | — |
placeholder | Mã nguồn chưa cung cấp mô tả bổ sung. | string | — |
className | Mã nguồn chưa cung cấp mô tả bổ sung. | string | — |
editable | Mã nguồn chưa cung cấp mô tả bổ sung. | boolean | true |
autofocus | Mã nguồn chưa cung cấp mô tả bổ sung. | boolean | false |
showToolbar | Mã nguồn chưa cung cấp mô tả bổ sung. | boolean | true |
showBubbleMenu | Mã nguồn chưa cung cấp mô tả bổ sung. | boolean | true |
showFloatingMenu | Mã nguồn chưa cung cấp mô tả bổ sung. | boolean | false |
showCharacterCount | Mã nguồn chưa cung cấp mô tả bổ sung. | boolean | true |
showFooter | Whether to show the editor footer. Defaults to `true`. | boolean | true |
maxCharacters | Mã nguồn chưa cung cấp mô tả bổ sung. | number | — |
minHeight | Mã nguồn chưa cung cấp mô tả bổ sung. | number | string | "200px" |
maxHeight | Mã nguồn chưa cung cấp mô tả bổ sung. | number | string | "auto" |
variant | Mã nguồn chưa cung cấp mô tả bổ sung. | "default" | "minimal" | "medium" | "medium-full" | "full" | "notion" | "default" |
rounded | Whether the editor has rounded corners. Defaults to `true`. | boolean | true |
fontFamilies | Mã nguồn chưa cung cấp mô tả bổ sung. | UEditorFontFamilyOption[] | — |
defaultFontFamily | Default font family for the editor. Defaults to `"Inter"`. | UEditorBuiltinFontFamily | "Inter" |
fontSizes | Mã nguồn chưa cung cấp mô tả bổ sung. | UEditorFontSizeOption[] | — |
lineHeights | Mã nguồn chưa cung cấp mô tả bổ sung. | UEditorLineHeightOption[] | — |
letterSpacings | Mã nguồn chưa cung cấp mô tả bổ sung. | UEditorLetterSpacingOption[] | — |
fetchMetadata | Mã nguồn chưa cung cấp mô tả bổ sung. | (url: string) => Promise<{ title?: string; description?: string; image?: string; publisher?: string }> | — |
uploadFile | Uploads file cards immediately after insertion when available. | (file: File) => Promise<string> | string | — |
uploadFileForSave | Uploads embedded/base64 file cards during `prepareContentForSave`; falls back to `uploadImageForSave` if omitted. | (file: File) => Promise<string | ({ url: string } & Record<string, unknown>)> | — |
extraExtensions | Additional TipTap extensions appended after the built-in UEditor extensions. | Extension[] | — |
showMenuBar | Mã nguồn chưa cung cấp mô tả bổ sung. | boolean | false |
showPreviewButton | Whether to show the preview button at the end of the menu bar. Defaults to `true`. | boolean | true |
onSave | Mã nguồn chưa cung cấp mô tả bổ sung. | () => void | — |
onExport | Mã nguồn chưa cung cấp mô tả bổ sung. | () => void | — |
onSourceCode | Mã nguồn chưa cung cấp mô tả bổ sung. | () => void | — |
onPreview | Fires when View > Preview or the eye button is clicked. Return false to prevent the built-in preview dialog. | (html: string) => void | false | — |
Hướng dẫn sử dụng
Kết nối UEditor với nhãn hiển thị, thông báo xác thực và trạng thái form rõ ràng. Không dùng placeholder làm nhãn duy nhất.
Trợ năng
Khi dùng UEditor, hãy giữ trạng thái focus dễ nhận biết, cung cấp tên truy cập khi cần và kiểm tra bàn phím cùng trình đọc màn hình trong ngữ cảnh thực tế.
