UNPKG

1.27 kBTypeScriptView Raw
1/**
2 * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4 */
5/**
6 * @module paste-from-office/normalizer
7 */
8import type { ClipboardInputTransformationData } from 'ckeditor5/src/clipboard.js';
9import type { ParseHtmlResult } from './filters/parse.js';
10/**
11 * Interface defining a content transformation pasted from an external editor.
12 *
13 * Normalizers are registered by the {@link module:paste-from-office/pastefromoffice~PasteFromOffice} plugin and run on
14 * {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation inputTransformation event}.
15 * They detect environment-specific quirks and transform it into a form compatible with other CKEditor features.
16 */
17export interface Normalizer {
18 /**
19 * Must return `true` if the `htmlString` contains content which this normalizer can transform.
20 */
21 isActive(htmlString: string): boolean;
22 /**
23 * Executes the normalization of a given data.
24 */
25 execute(data: NormalizerData): void;
26}
27export interface NormalizerData extends ClipboardInputTransformationData {
28 _isTransformedWithPasteFromOffice?: boolean;
29 _parsedData: ParseHtmlResult;
30}