import * as _angular_core from '@angular/core'; import { InjectionToken } from '@angular/core'; import { EditorConfig, ClassicEditor } from 'ckeditor5'; import { I18nService } from '@sdcorejs/angular/i18n'; import { FormGroup } from '@angular/forms'; import { SdCustomValidator, SdFormControl } from '@sdcorejs/angular/forms/models'; interface SdEditorUploadFileDetail { idOrKey: string; cdn: string; name?: string; } type SdEditorUploadFileFuncUpload = (files: File[]) => Promise; interface ISdEditorConfiguration { key?: string; upload: SdEditorUploadFileFuncUpload; } declare const SD_EDITOR_CONFIGURATION: InjectionToken; interface SdEditorImageUploadValidation { minWidth?: number; minHeight?: number; maxWidth?: number; maxHeight?: number; maxSizeMB?: number; allowedFormats?: string[]; } interface SdEditorImageConfig { /** * Chế độ tải lên hình ảnh. * 'immediate': Upload ngay khi chọn ảnh. * 'deferred': Lưu tạm ảnh blob, khi submit thì viewChild component sd-editor rồi gọi upload() để tự động map lại src lấy từ uploadFn, * @default 'deferred' */ uploadMode?: 'deferred' | 'immediate'; /** * Hàm xử lý tải lên file * Nếu thuộc tính này được khai báo, tính năng tải lên hình ảnh trong editor sẽ tự động được kích hoạt. * @param files Danh sách các tệp (File) cần tải lên. * @returns Promise chứa mảng thông tin chi tiết của các tệp sau khi tải lên thành công. */ uploadFn?: (files: File[]) => Promise; /** * Validation hình ảnh trước khi tiến hành tải lên. */ validation?: SdEditorImageUploadValidation; /** * Số lượng luồng tải lên (API calls) tối đa được thực thi đồng thời. * Ví dụ: Nếu có 10 API cần tải lên, hệ thống sẽ đưa vào hàng đợi và xử lý song song dựa trên giới hạn này để tránh nghẽn mạng và rateLimit phía BE. * @default 2 */ maxConcurrentUploads?: number; /** * Số lượng file được gom nhóm (batch) trong mỗi lần gọi hàm `uploadFn`. * Nếu Backend hỗ trợ multi-file, có thể thiết lập số này lớn hơn để gửi nhiều file trong cùng một payload. * Ví dụ: Nếu chọn 10 file và `batchSize = 5`, hệ thống sẽ chỉ gọi 2 API, mỗi lần gửi 5 file. * * @default 2 */ batchSize?: number; /** * Số lượng hình ảnh tối đa người dùng được phép chọn trong một lần thao tác. */ maxImagesPerSelection?: number; /** * Kích hoạt chế độ tải chậm (lazy load) cho hình ảnh để tối ưu hóa hiệu suất * @default true */ lazyLoad?: boolean; } interface SdEditorOption { imageConfig?: SdEditorImageConfig; _i18n?: I18nService; } type EditorOption = EditorConfig & { getOption?: () => SdEditorOption; }; declare class SdEditor { #private; readonly option: _angular_core.InputSignal; readonly height: _angular_core.InputSignal; readonly maxHeight: _angular_core.InputSignal; readonly maxlength: _angular_core.InputSignal; readonly label: _angular_core.InputSignal; readonly helperText: _angular_core.InputSignal; readonly required: _angular_core.InputSignalWithTransform; readonly disabled: _angular_core.InputSignalWithTransform; readonly readonly: _angular_core.InputSignalWithTransform; readonly hideInlineError: _angular_core.InputSignalWithTransform; readonly inlineError: _angular_core.InputSignal; readonly placeholder: _angular_core.InputSignal; readonly validator: _angular_core.InputSignal; readonly form: _angular_core.InputSignalWithTransform | undefined, any>; readonly key: _angular_core.InputSignal; readonly autoIdInput: _angular_core.InputSignal; readonly autoId: _angular_core.Signal; readonly dataDisabled: _angular_core.Signal<"true" | "false">; readonly dataEmpty: _angular_core.Signal<"true" | "false">; readonly name: _angular_core.InputSignal; readonly valueModel: _angular_core.ModelSignal; readonly sdChange: _angular_core.OutputEmitterRef; readonly sdBlur: _angular_core.OutputEmitterRef; readonly sdFocus: _angular_core.OutputEmitterRef; readonly _textLength: _angular_core.WritableSignal; readonly formControl: SdFormControl; readonly isOverLimit: _angular_core.Signal; get errorMessage(): string | undefined; readonly Editor: typeof ClassicEditor; readonly editorConfig: _angular_core.Signal; constructor(); onReady: (editor: ClassicEditor) => void; focusEditor: () => void | undefined; /** * Xử lý tải lên các file và trả về nội dung dữ liệu cuối cùng. * * @description * - Đối với các file upload chế độ 'deferred' (chỉ xử lý khi submit), cần @ViewChild component và gọi hàm upload() này. * - Hỗ trợ two-way binding. * - Hàm hỗ trợ trả ra data cuối cùng. * * @returns {Promise} Nội dung cuối cùng được trích xuất từ sd-editor. */ upload: () => Promise; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } export { SD_EDITOR_CONFIGURATION, SdEditor }; export type { EditorOption, ISdEditorConfiguration, SdEditorImageConfig, SdEditorImageUploadValidation, SdEditorOption, SdEditorUploadFileDetail, SdEditorUploadFileFuncUpload };