import * as i0 from '@angular/core'; import { OnInit, OnDestroy } from '@angular/core'; import { ModelRange, EditorConfig, ModelDocumentSelection, EventInfo, ViewDataTransfer, ClassicEditor, Plugin, Widget, ContextualBalloon } from 'ckeditor5'; import { I18nParams } from '@sdcorejs/angular/i18n'; /** * Comment status based on text changes */ type CkCommentStatus = 'normal' | 'modified' | 'broken'; /** * Color configuration for comment markers */ interface CkCommentColors { marker?: string; markerSelected?: string; markerPending?: string; markerModified?: string; markerBroken?: string; } /** * Comment data structure for CkCommentPlugin */ interface CkComment { id: string | number; startPath: number[]; endPath: number[]; originalText: string; currentText: string; status: CkCommentStatus; data?: T; } /** * Config for CkCommentPlugin */ interface CkCommentConfig { onPendingComment?: (comment: CkComment) => void; onAddComment?: (comment: CkComment) => void; onSelectComment?: (id: string | number) => void; onRemoveComment?: (id: string | number) => void; onChange?: (comments: CkComment[]) => void; onCancelPending?: () => void; onError?: (error: { code: string; message: string; data?: any; }) => void; searchRange?: number; debug?: boolean; colors?: CkCommentColors; maxTextLength?: number; allowCreating?: boolean; } /** * Data returned when user selects text for comment */ interface CkCommentSelection { range: ModelRange; startPath: number[]; endPath: number[]; text: string; } /** Plain translator cho CKEditor plugin — tránh truyền thẳng I18nService (private fields mất `this` qua config). */ interface DocumentBuilderI18n { t(key: string, params?: I18nParams): string; } type DocumentBuilderOption = EditorConfig & { getOption?: () => SdDocumentBuilderOption; _i18n?: DocumentBuilderI18n; }; interface SdDocumentBuilderOption { onDropVariable?: (variable: SdDocumentBuilderVariable) => boolean | Promise; onAfterDropVariable?: (variable: SdDocumentBuilderVariable) => void; onPasteVariable?: (display: string) => SdDocumentBuilderVariable | null | Promise; comment?: CkCommentConfig; onSelection?: (selection: ModelDocumentSelection, $event: EventInfo) => void; onOrientation?: (orientation: 'PORTRAIT' | 'LANDSCAPE') => void; onPaste?: (data: SdPasteEventData) => void | Promise; orientation?: 'PORTRAIT' | 'LANDSCAPE'; } interface SdDocumentBuilderVariable { id: string; uuid?: string; value: string; display: string; bindingValue?: string; data?: T; } interface SdDocumentBuilderHeading { id: string; text: string; level: number; type: string; } interface SdPasteEventData { html?: string; text: string; source: 'word' | 'excel' | 'google-docs' | 'web' | 'unknown'; dataTransfer: ViewDataTransfer; } declare class SdHeaderFooterBuilder { #private; Editor: typeof ClassicEditor; set model(value: string | undefined | null); readonly modelChange: i0.OutputEmitterRef; config: EditorConfig & { _i18n?: DocumentBuilderI18n; }; onReady(editor: ClassicEditor): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class VariablePlugin extends Plugin { #private; static get pluginName(): "VariablePlugin"; static get requires(): (typeof Widget)[]; init(): void; /** * Lấy tất cả variables trong document. * @returns Danh sách tất cả variables (bao gồm bindingValue nếu đã binding) */ all(): SdDocumentBuilderVariable[]; /** * Scroll tới vị trí của variable theo uuid. * @param uuid - uuid của variable (FE tự sinh sau mỗi lần drop) */ scroll(uuid: string): void; /** * Gán giá trị cho TẤT CẢ variable có cùng id trong document. * Nếu value rỗng → tự động gọi clearValue(id). * @param id - id của variable definition * @param value - giá trị binding cần hiển thị * @returns số instance đã được cập nhật */ bindValue(id: string, value: string): number; /** * Xóa binding value của TẤT CẢ variable có cùng id. * @param id - id của variable definition * @returns số instance đã được cập nhật */ clearValue(id: string): number; /** * Batch bind nhiều variables theo map { id → value }. * Toàn bộ thực hiện trong 1 model.change() → 1 undo step duy nhất. * @param map - { [id]: boundValue } */ bindValues(map: Record): void; /** * Batch clear binding của nhiều variables. * @param ids - danh sách id cần clear; nếu không truyền/rỗng → clear TẤT CẢ */ clearValues(ids?: string[]): void; /** Xóa toàn bộ binding values trong document. Shorthand của clearValues(). */ clearAllValues(): void; } declare class CkCommentPlugin extends Plugin { #private; static get pluginName(): string; static get requires(): (typeof ContextualBalloon)[]; static readonly PENDING_MARKER_ID = "__pending_comment__"; static readonly DEFAULT_SEARCH_RANGE = 5; static readonly DEFAULT_MAX_TEXT_LENGTH = 1000; static readonly DEFAULT_COLORS: CkCommentColors; init(): void; /** * Thiết lập config với callbacks */ setConfig(config: CkCommentConfig): void; /** * Thêm comment và tạo marker */ addComment(comment: CkComment): boolean; /** * Xóa comment theo id */ removeComment(id: string | number): boolean; /** * Chọn comment theo id - chỉ thêm class highlight, không bôi đen text */ selectComment(id: string | number, scrollIntoView?: boolean): void; /** * Thiết lập tất cả comments (khôi phục từ dữ liệu) */ setComments(comments: CkComment[]): void; /** * Lấy tất cả comments */ get comments(): CkComment[]; /** * Thiết lập pending highlight cho selection (khi user đang nhập nội dung comment) */ setPendingSelection(startPath: number[], endPath: number[]): boolean; /** * Xóa pending highlight và fire onCancelPending callback */ clearPendingSelection(): void; } declare class SdDocumentBuilder implements OnInit, OnDestroy { #private; readonly option: i0.InputSignal; disabled: boolean; set _disabled(val: boolean | '' | undefined | null); readonly contentChange: i0.OutputEmitterRef; Editor: typeof ClassicEditor; config: DocumentBuilderOption; ngOnInit(): void; ngOnDestroy(): void; onReady(editor: ClassicEditor): void; setContent: (html: string) => void; getContent: () => string; setOrientation: (orientation: "PORTRAIT" | "LANDSCAPE") => void; getOrientation: () => "PORTRAIT" | "LANDSCAPE"; scrollToTop(): void; heading: { /** * Lấy tất cả headings trong document * @returns Danh sách tất cả headings */ all: () => SdDocumentBuilderHeading[]; /** * Scroll tới vị trí của heading * @param id - ID của heading cần scroll tới */ scroll: (id: string) => void; }; getCommentPluginAPI(): CkCommentPlugin | null; getVariablePluginAPI(): VariablePlugin | null; /** * Xuất file Word có Header/Footer * @param fileName Tên file * @param headerText Nội dung Header (hoặc HTML) * '

CÔNG TY CỔ PHẦN CÔNG NGHỆ ABC

' * @param footerText Nội dung Footer (hoặc HTML) * '

Trang /

' */ exportDocx(args: { fileName?: string; header?: string; footer?: string; }): void; hightSelectRange: (range: ModelRange) => void; removeHighlightSeclectRange: () => void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } export { SdDocumentBuilder, SdHeaderFooterBuilder }; export type { CkComment, CkCommentColors, CkCommentConfig, CkCommentSelection, CkCommentStatus, DocumentBuilderI18n, DocumentBuilderOption, SdDocumentBuilderHeading, SdDocumentBuilderOption, SdDocumentBuilderVariable, SdPasteEventData };