-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
dataprocessor.ts
69 lines (61 loc) · 3 KB
/
dataprocessor.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/**
* @module engine/dataprocessor/dataprocessor
*/
import type ViewDocumentFragment from '../view/documentfragment.js';
import type { MatcherPattern } from '../view/matcher.js';
/**
* The data processor interface. It should be implemented by actual data processors.
*
* Each data processor implements a certain format of the data. For example, {@glink features/markdown Markdown data processor}
* will convert the data (a Markdown string) to a {@link module:engine/view/documentfragment~DocumentFragment document fragment} and back.
*
* **Note:** While the CKEditor 5 architecture supports changing the data format, in most scenarios we do recommend sticking to
* the default format which is HTML (supported by the {@link module:engine/dataprocessor/htmldataprocessor~HtmlDataProcessor}).
* HTML remains [the best standard for rich-text data](https://medium.com/content-uneditable/a-standard-for-rich-text-data-4b3a507af552).
*
* And please do remember – using Markdown [does not automatically make your
* application/website secure](https://github.com/ckeditor/ckeditor5-markdown-gfm/issues/16#issuecomment-375752994).
*/
export default interface DataProcessor {
/**
* Converts a {@link module:engine/view/documentfragment~DocumentFragment document fragment} to data.
*
* @param viewFragment The document fragment to be processed.
*/
toData( viewFragment: ViewDocumentFragment ): string;
/**
* Converts the data to a {@link module:engine/view/documentfragment~DocumentFragment document fragment}.
*
* @param data The data to be processed.
*/
toView( data: string ): ViewDocumentFragment;
/**
* Registers a {@link module:engine/view/matcher~MatcherPattern} for view elements whose content should be treated as raw data
* and its content should be converted to a
* {@link module:engine/view/element~Element#getCustomProperty custom property of a view element} called `"$rawContent"` while
* converting {@link #toView to view}.
*
* @param pattern Pattern matching all view elements whose content should be treated as plain text.
*/
registerRawContentMatcher( pattern: MatcherPattern ): void;
/**
* If the processor is set to use marked fillers, it will insert ` ` fillers wrapped in `<span>` elements
* (`<span data-cke-filler="true"> </span>`) instead of regular ` ` characters.
*
* This mode allows for more precise handling of block fillers (so they do not leak into the editor content) but bloats the
* editor data with additional markup.
*
* This mode may be required by some features and will be turned on by them automatically.
*
* @param type Whether to use the default or marked ` ` block fillers.
*/
useFillerType( type: 'default' | 'marked' ): void;
/**
* If `false`, comment nodes will be converted to `$comment`. Otherwise comment nodes are ignored.
*/
skipComments?: boolean;
}