UEditor
Đã cập nhậtUEditor thuộc nhóm Form Input. Xem demo trực tiếp, cách tích hợp và các lưu ý triển khai.
Bắt đầu nhanh
Import UEditor từ entry của gói Free. 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ợ.
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ả.
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 | — |
onImageUploadError | Reports rejected files and immediate image upload/read failures. | (error: Error, file: File) => void | — |
placeholder | Mã nguồn chưa cung cấp mô tả bổ sung. | string | — |
ariaLabel | Accessible name for the editable surface. | string | — |
ariaLabelledBy | ID of an external element that labels the editable surface. | string | — |
ariaDescribedBy | ID of an external element that describes the editable surface. | 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 |
bubbleMenuPlacement | Preferred side for the selection bubble menu. Defaults to `"auto"`. | UEditorBubbleMenuPlacement | "auto" |
showFloatingMenu | Mã nguồn chưa cung cấp mô tả bổ sung. | boolean | false |
enableAutocomplete | Enables typed Markdown-style autocomplete such as headings, lists, quotes, dividers, and to-do lists. Defaults to `true`. | boolean | true |
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" |
tableCellHorizontalPadding | Horizontal padding for table cells in pixels. Defaults to `8`. | number | 8 |
expandWideTables | Let wide tables overflow through the editor content scrollbar rather than a scrollbar inside each table. Defaults to `true`. | boolean | true |
tableDateFormatSeparator | Date delimiter used for table cell date formatting. Defaults to `"/"`. | "/" | "-" | "/" |
tableDateFormat | Date format pattern for table cell date formatting. Supported: `"DD/MM/YYYY"`, `"DD-MM-YYYY"`, `"YYYY-MM-DD"`. | "YYYY/MM/DD" | "YYYY-MM-DD" | "DD/MM/YYYY" | "DD-MM-YYYY" | — |
tableCurrencySymbol | Currency symbol used for table cell currency formatting. Defaults to `"$"` or locale currency. | string | — |
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[] | — |
showFontFamilyControl | Show the font selector even when the resolved catalog has one font. | boolean | false |
disableFontFamilyControl | Show the font selector as read-only; users cannot open or change it. | boolean | false |
allowedFontFamilyIds | Restricts the supplied catalog by stable IDs (after `fontFamilies` is resolved). | string[] | — |
fontFamilyPolicy | `toolbar-only` preserves all imported markup; `sanitize-paste` filters pasted HTML only. | UEditorFontFamilyPolicy | "toolbar-only" |
disallowedFontFamilyBehavior | How disallowed pasted font families are handled. Defaults to `preserve`. | UEditorDisallowedFontFamilyBehavior | "preserve" |
onDisallowedFontFamily | Mã nguồn chưa cung cấp mô tả bổ sung. | (event: UEditorDisallowedFontFamilyEvent) => void | — |
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[] | — |
defaultFontSize | Default font size for the editor. Defaults to `"13"` ("13px"). | string | number | "13" |
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ế.
