@ckeditor/ckeditor5-import-word
Version:
Import from Word feature for CKEditor 5.
100 lines (99 loc) • 3.28 kB
TypeScript
/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/
/**
* @module import-word/importwordcommand
* @publicApi
*/
import { Command, type Editor } from '@ckeditor/ckeditor5-core';
import { type Batch } from '@ckeditor/ckeditor5-engine';
/**
* The import from Word command.
*
* It sends the Word file to the converter endpoint and inserts its content into the editor.
*/
export declare class ImportWordCommand extends Command {
/**
* A command state that indicates if the command is currently executing.
*
* @observable
*/
isBusy: boolean;
/**
* @inheritDoc
*/
constructor(editor: Editor);
/**
* @inheritDoc
*/
refresh(): void;
/**
* Executes the command. Sends the provided file instance to the converter service endpoint and inserts the result into the model.
*
* @fires execute
* @param file The Word file instance to be uploaded for conversion.
* @param [serviceConfig] Additional options to pass to the converter service.
*/
execute(file: File, serviceConfig?: Record<string, unknown>): Promise<unknown>;
}
/**
* Fired when the converter service returned the HTML content that will be inserted into the editor.
*
* @eventName ~ImportWordCommand#dataInsert
*/
export type ImportWordDataInsertEvent = {
name: 'dataInsert';
args: [data: ImportWordDataInsertEventData];
};
export interface ImportWordDataInsertEventData {
/**
* The batch used to undo all changes made by the command. Each time the command is executed, a new batch is created.
* Use it when some additional changes should be added to the document as part of the same undo step.
*/
readonly undoStepBatch: Batch;
/**
* The HTML content to insertion.
*/
html: string;
/**
* The headers definitions extracted from the Word document.
* Contains HTML content for different types of headers (default, first page, odd/even pages).
*/
headers?: ImportWordDataHeaderFooterDefinitions;
/**
* The footers definitions extracted from the Word document.
* Contains HTML content for different types of footers (default, first page, odd/even pages).
*/
footers?: ImportWordDataHeaderFooterDefinitions;
}
/**
* Represents a collection of header or footer definitions corresponding to different page types.
*/
export interface ImportWordDataHeaderFooterDefinitions {
/**
* Content for the default header/footer. Used for all pages unless specific overrides (first/odd/even) apply.
*/
default?: ImportWordDataHeaderFooterContent;
/**
* Content for the first page header/footer.
*/
first?: ImportWordDataHeaderFooterContent;
/**
* Content for the odd pages header/footer.
*/
odd?: ImportWordDataHeaderFooterContent;
/**
* Content for the even pages header/footer.
*/
even?: ImportWordDataHeaderFooterContent;
}
/**
* Represents the content of a single header or footer variant.
*/
export interface ImportWordDataHeaderFooterContent {
/**
* The HTML content of the header or footer.
*/
html: string;
}