Đi tới nội dung tài liệu
Underverse UI Logo
ComponentForm Input

UEditor

Đã cập nhật

UEditor 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ợ.

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ínhMô tảKiểuMặc định
getPortalContainerReturns the per-editor container used by menus and other portalled overlays.() => HTMLElement | null—
contentInitial or controlled HTML content for the editor.string""
onChangeCalled with the current HTML after editor updates. Kept for backward compatibility with `onHtmlChange`.(content: string) => void—
onHtmlChangeCalled with the current HTML after editor updates. Prefer this when the consumer stores HTML.(html: string) => void—
onJsonChangeCalled with the current TipTap JSON document after editor updates.(json: object) => void—
outputDebounceMsDebounces 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.number0
uploadImageUploads images immediately when they are inserted in `imageInsertMode="upload"`.(file: File) => Promise<string> | string—
uploadImageForSaveUploads embedded/base64 images during `prepareContentForSave`; use this for save-time normalization.UEditorUploadImageForSave—
uploadImageConcurrencyMaximum number of concurrent save-time image/file uploads.number3
imageInsertModeWhether inserted images are kept as base64 in editor state or uploaded immediately."base64" | "upload""base64"
maxImageFileSizeMã nguồn chưa cung cấp mô tả bổ sung.number—
allowedImageMimeTypesMã nguồn chưa cung cấp mô tả bổ sung.string[]—
fallbackToDataUrlMã nguồn chưa cung cấp mô tả bổ sung.boolean—
onImageUploadErrorReports rejected files and immediate image upload/read failures.(error: Error, file: File) => void—
placeholderMã nguồn chưa cung cấp mô tả bổ sung.string—
ariaLabelAccessible name for the editable surface.string—
ariaLabelledByID of an external element that labels the editable surface.string—
ariaDescribedByID of an external element that describes the editable surface.string—
classNameMã nguồn chưa cung cấp mô tả bổ sung.string—
editableMã nguồn chưa cung cấp mô tả bổ sung.booleantrue
autofocusMã nguồn chưa cung cấp mô tả bổ sung.booleanfalse
showToolbarMã nguồn chưa cung cấp mô tả bổ sung.booleantrue
showBubbleMenuMã nguồn chưa cung cấp mô tả bổ sung.booleantrue
bubbleMenuPlacementPreferred side for the selection bubble menu. Defaults to `"auto"`.UEditorBubbleMenuPlacement"auto"
showFloatingMenuMã nguồn chưa cung cấp mô tả bổ sung.booleanfalse
enableAutocompleteEnables typed Markdown-style autocomplete such as headings, lists, quotes, dividers, and to-do lists. Defaults to `true`.booleantrue
showCharacterCountMã nguồn chưa cung cấp mô tả bổ sung.booleantrue
showFooterWhether to show the editor footer. Defaults to `true`.booleantrue
maxCharactersMã nguồn chưa cung cấp mô tả bổ sung.number—
minHeightMã nguồn chưa cung cấp mô tả bổ sung.number | string"200px"
maxHeightMã nguồn chưa cung cấp mô tả bổ sung.number | string"auto"
tableCellHorizontalPaddingHorizontal padding for table cells in pixels. Defaults to `8`.number8
expandWideTablesLet wide tables overflow through the editor content scrollbar rather than a scrollbar inside each table. Defaults to `true`.booleantrue
tableDateFormatSeparatorDate delimiter used for table cell date formatting. Defaults to `"/"`."/" | "-""/"
tableDateFormatDate 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"—
tableCurrencySymbolCurrency symbol used for table cell currency formatting. Defaults to `"$"` or locale currency.string—
variantMã nguồn chưa cung cấp mô tả bổ sung."default" | "minimal" | "medium" | "medium-full" | "full" | "notion""default"
roundedWhether the editor has rounded corners. Defaults to `true`.booleantrue
fontFamiliesMã nguồn chưa cung cấp mô tả bổ sung.UEditorFontFamilyOption[]—
showFontFamilyControlShow the font selector even when the resolved catalog has one font.booleanfalse
disableFontFamilyControlShow the font selector as read-only; users cannot open or change it.booleanfalse
allowedFontFamilyIdsRestricts 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"
disallowedFontFamilyBehaviorHow disallowed pasted font families are handled. Defaults to `preserve`.UEditorDisallowedFontFamilyBehavior"preserve"
onDisallowedFontFamilyMã nguồn chưa cung cấp mô tả bổ sung.(event: UEditorDisallowedFontFamilyEvent) => void—
defaultFontFamilyDefault font family for the editor. Defaults to `"Inter"`.UEditorBuiltinFontFamily"Inter"
fontSizesMã nguồn chưa cung cấp mô tả bổ sung.UEditorFontSizeOption[]—
defaultFontSizeDefault font size for the editor. Defaults to `"13"` ("13px").string | number"13"
lineHeightsMã nguồn chưa cung cấp mô tả bổ sung.UEditorLineHeightOption[]—
letterSpacingsMã nguồn chưa cung cấp mô tả bổ sung.UEditorLetterSpacingOption[]—
fetchMetadataMã nguồn chưa cung cấp mô tả bổ sung.(url: string) => Promise<{ title?: string; description?: string; image?: string; publisher?: string }>—
uploadFileUploads file cards immediately after insertion when available.(file: File) => Promise<string> | string—
uploadFileForSaveUploads embedded/base64 file cards during `prepareContentForSave`; falls back to `uploadImageForSave` if omitted.(file: File) => Promise<string | ({ url: string } & Record<string, unknown>)>—
extraExtensionsAdditional TipTap extensions appended after the built-in UEditor extensions.Extension[]—
showMenuBarMã nguồn chưa cung cấp mô tả bổ sung.booleanfalse
showPreviewButtonWhether to show the preview button at the end of the menu bar. Defaults to `true`.booleantrue
onSaveMã nguồn chưa cung cấp mô tả bổ sung.() => void—
onExportMã nguồn chưa cung cấp mô tả bổ sung.() => void—
onSourceCodeMã nguồn chưa cung cấp mô tả bổ sung.() => void—
onPreviewFires 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ế.