@ckeditor/ckeditor5-merge-fields 48.2.0-alpha.7 → 48.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/augmentation.d.ts +27 -27
- package/dist/index.d.ts +15 -15
- package/dist/index.js +1 -1
- package/dist/insertmergefieldblockcommand.d.ts +24 -24
- package/dist/insertmergefieldcommand.d.ts +27 -27
- package/dist/insertmergefieldimagecommand.d.ts +33 -33
- package/dist/mergefields.d.ts +31 -31
- package/dist/mergefieldsconfig.d.ts +243 -243
- package/dist/mergefieldsediting.d.ts +144 -144
- package/dist/mergefieldsui.d.ts +42 -42
- package/dist/previewmergefieldscommand.d.ts +39 -39
- package/dist/translations/af.js +1 -1
- package/dist/translations/af.umd.js +1 -1
- package/dist/translations/ar.js +1 -1
- package/dist/translations/ar.umd.js +1 -1
- package/dist/translations/ast.js +1 -1
- package/dist/translations/ast.umd.js +1 -1
- package/dist/translations/az.js +1 -1
- package/dist/translations/az.umd.js +1 -1
- package/dist/translations/be.js +1 -1
- package/dist/translations/be.umd.js +1 -1
- package/dist/translations/bg.js +1 -1
- package/dist/translations/bg.umd.js +1 -1
- package/dist/translations/bn.js +1 -1
- package/dist/translations/bn.umd.js +1 -1
- package/dist/translations/bs.js +1 -1
- package/dist/translations/bs.umd.js +1 -1
- package/dist/translations/ca.js +1 -1
- package/dist/translations/ca.umd.js +1 -1
- package/dist/translations/cs.js +1 -1
- package/dist/translations/cs.umd.js +1 -1
- package/dist/translations/da.js +1 -1
- package/dist/translations/da.umd.js +1 -1
- package/dist/translations/de-ch.js +1 -1
- package/dist/translations/de-ch.umd.js +1 -1
- package/dist/translations/de.js +1 -1
- package/dist/translations/de.umd.js +1 -1
- package/dist/translations/el.js +1 -1
- package/dist/translations/el.umd.js +1 -1
- package/dist/translations/en-au.js +1 -1
- package/dist/translations/en-au.umd.js +1 -1
- package/dist/translations/en-gb.js +1 -1
- package/dist/translations/en-gb.umd.js +1 -1
- package/dist/translations/en.js +1 -1
- package/dist/translations/en.umd.js +1 -1
- package/dist/translations/eo.js +1 -1
- package/dist/translations/eo.umd.js +1 -1
- package/dist/translations/es-co.js +1 -1
- package/dist/translations/es-co.umd.js +1 -1
- package/dist/translations/es.js +1 -1
- package/dist/translations/es.umd.js +1 -1
- package/dist/translations/et.js +1 -1
- package/dist/translations/et.umd.js +1 -1
- package/dist/translations/eu.js +1 -1
- package/dist/translations/eu.umd.js +1 -1
- package/dist/translations/fa.js +1 -1
- package/dist/translations/fa.umd.js +1 -1
- package/dist/translations/fi.js +1 -1
- package/dist/translations/fi.umd.js +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/fr.umd.js +1 -1
- package/dist/translations/gl.js +1 -1
- package/dist/translations/gl.umd.js +1 -1
- package/dist/translations/gu.js +1 -1
- package/dist/translations/gu.umd.js +1 -1
- package/dist/translations/he.js +1 -1
- package/dist/translations/he.umd.js +1 -1
- package/dist/translations/hi.js +1 -1
- package/dist/translations/hi.umd.js +1 -1
- package/dist/translations/hr.js +1 -1
- package/dist/translations/hr.umd.js +1 -1
- package/dist/translations/hu.js +1 -1
- package/dist/translations/hu.umd.js +1 -1
- package/dist/translations/hy.js +1 -1
- package/dist/translations/hy.umd.js +1 -1
- package/dist/translations/id.js +1 -1
- package/dist/translations/id.umd.js +1 -1
- package/dist/translations/it.js +1 -1
- package/dist/translations/it.umd.js +1 -1
- package/dist/translations/ja.js +1 -1
- package/dist/translations/ja.umd.js +1 -1
- package/dist/translations/jv.js +1 -1
- package/dist/translations/jv.umd.js +1 -1
- package/dist/translations/kk.js +1 -1
- package/dist/translations/kk.umd.js +1 -1
- package/dist/translations/km.js +1 -1
- package/dist/translations/km.umd.js +1 -1
- package/dist/translations/kn.js +1 -1
- package/dist/translations/kn.umd.js +1 -1
- package/dist/translations/ko.js +1 -1
- package/dist/translations/ko.umd.js +1 -1
- package/dist/translations/ku.js +1 -1
- package/dist/translations/ku.umd.js +1 -1
- package/dist/translations/lt.js +1 -1
- package/dist/translations/lt.umd.js +1 -1
- package/dist/translations/lv.js +1 -1
- package/dist/translations/lv.umd.js +1 -1
- package/dist/translations/ms.js +1 -1
- package/dist/translations/ms.umd.js +1 -1
- package/dist/translations/nb.js +1 -1
- package/dist/translations/nb.umd.js +1 -1
- package/dist/translations/ne.js +1 -1
- package/dist/translations/ne.umd.js +1 -1
- package/dist/translations/nl.js +1 -1
- package/dist/translations/nl.umd.js +1 -1
- package/dist/translations/no.js +1 -1
- package/dist/translations/no.umd.js +1 -1
- package/dist/translations/oc.js +1 -1
- package/dist/translations/oc.umd.js +1 -1
- package/dist/translations/pl.js +1 -1
- package/dist/translations/pl.umd.js +1 -1
- package/dist/translations/pt-br.js +1 -1
- package/dist/translations/pt-br.umd.js +1 -1
- package/dist/translations/pt.js +1 -1
- package/dist/translations/pt.umd.js +1 -1
- package/dist/translations/ro.js +1 -1
- package/dist/translations/ro.umd.js +1 -1
- package/dist/translations/ru.js +1 -1
- package/dist/translations/ru.umd.js +1 -1
- package/dist/translations/si.js +1 -1
- package/dist/translations/si.umd.js +1 -1
- package/dist/translations/sk.js +1 -1
- package/dist/translations/sk.umd.js +1 -1
- package/dist/translations/sl.js +1 -1
- package/dist/translations/sl.umd.js +1 -1
- package/dist/translations/sq.js +1 -1
- package/dist/translations/sq.umd.js +1 -1
- package/dist/translations/sr-latn.js +1 -1
- package/dist/translations/sr-latn.umd.js +1 -1
- package/dist/translations/sr.js +1 -1
- package/dist/translations/sr.umd.js +1 -1
- package/dist/translations/sv.js +1 -1
- package/dist/translations/sv.umd.js +1 -1
- package/dist/translations/th.js +1 -1
- package/dist/translations/th.umd.js +1 -1
- package/dist/translations/ti.js +1 -1
- package/dist/translations/ti.umd.js +1 -1
- package/dist/translations/tk.js +1 -1
- package/dist/translations/tk.umd.js +1 -1
- package/dist/translations/tr.js +1 -1
- package/dist/translations/tr.umd.js +1 -1
- package/dist/translations/tt.js +1 -1
- package/dist/translations/tt.umd.js +1 -1
- package/dist/translations/ug.js +1 -1
- package/dist/translations/ug.umd.js +1 -1
- package/dist/translations/uk.js +1 -1
- package/dist/translations/uk.umd.js +1 -1
- package/dist/translations/ur.js +1 -1
- package/dist/translations/ur.umd.js +1 -1
- package/dist/translations/uz.js +1 -1
- package/dist/translations/uz.umd.js +1 -1
- package/dist/translations/vi.js +1 -1
- package/dist/translations/vi.umd.js +1 -1
- package/dist/translations/zh-cn.js +1 -1
- package/dist/translations/zh-cn.umd.js +1 -1
- package/dist/translations/zh.js +1 -1
- package/dist/translations/zh.umd.js +1 -1
- package/dist/ui/mergefieldslistview.d.ts +17 -17
- package/dist/ui/mergefieldspanelview.d.ts +11 -11
- package/dist/utils/common-translations.d.ts +6 -6
- package/package.json +9 -9
|
@@ -1,259 +1,259 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import type { Editor } from
|
|
6
|
+
* @module merge-fields/mergefieldsconfig
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import type { Editor } from "@ckeditor/ckeditor5-core";
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
11
|
+
* The configuration of the merge fields feature.
|
|
12
|
+
*
|
|
13
|
+
* The properties defined in this config are set in the `config.mergeFields` namespace.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* ClassicEditor
|
|
17
|
+
* .create( {
|
|
18
|
+
* mergeFields: {
|
|
19
|
+
* // Merge fields configuration.
|
|
20
|
+
* }
|
|
21
|
+
* } )
|
|
22
|
+
* .then( ... )
|
|
23
|
+
* .catch( ... );
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
27
|
+
*/
|
|
28
28
|
export interface MergeFieldsConfig {
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
29
|
+
/**
|
|
30
|
+
* The definitions of the merge fields that can be used in the editor.
|
|
31
|
+
* It's allowed to define them in any combination of groups and individual merge fields.
|
|
32
|
+
* The order of the definitions is respected when displaying the merge fields in the UI dropdown
|
|
33
|
+
* except that merge fields that are not assigned to any group are displayed at the
|
|
34
|
+
* very bottom of the list.
|
|
35
|
+
*/
|
|
36
|
+
definitions?: Array<MergeFieldsGroupDefinition | MergeFieldDefinition>;
|
|
37
|
+
/**
|
|
38
|
+
* A prefix used to identify merge fields in the editor data.
|
|
39
|
+
*
|
|
40
|
+
* The list of allowed characters includes: ``'"`!#%:;=@{}~$()*+/?[\]^|``.
|
|
41
|
+
*
|
|
42
|
+
* @default '\{\{'
|
|
43
|
+
*/
|
|
44
|
+
prefix?: string;
|
|
45
|
+
/**
|
|
46
|
+
* A suffix used to identify merge fields in the editor data.
|
|
47
|
+
*
|
|
48
|
+
* The list of allowed characters includes: ``'"`!#%:;=@{}~$()*+/?[\]^|``.
|
|
49
|
+
*
|
|
50
|
+
* @default '\}\}'
|
|
51
|
+
*/
|
|
52
|
+
suffix?: string;
|
|
53
|
+
/**
|
|
54
|
+
* The data sets that can be displayed in place of the merge fields in the editor.
|
|
55
|
+
*
|
|
56
|
+
* @default []
|
|
57
|
+
*/
|
|
58
|
+
dataSets?: Array<MergeFieldsDataSetDefinition>;
|
|
59
|
+
/**
|
|
60
|
+
* Determines the available preview modes in the dropdown and menu bar. Possible values are:
|
|
61
|
+
*
|
|
62
|
+
* * `'$labels'` - adds the option to display the labels of the merge fields.
|
|
63
|
+
* * `'$defaultValues'` - adds the option to display the default values.
|
|
64
|
+
* * `'$dataSets'` - adds the options to display each of the configured data sets.
|
|
65
|
+
*
|
|
66
|
+
* At least one mode must be enabled. If more than one preview mode is configured,
|
|
67
|
+
* you can add `previewMergeFields` button to the toolbar to switch between them,
|
|
68
|
+
* and the menu bar button will be added automatically to the `View` category.
|
|
69
|
+
*
|
|
70
|
+
* @default [ '$labels', '$defaultValues', '$dataSets' ]
|
|
71
|
+
*/
|
|
72
|
+
previewModes?: Array<string>;
|
|
73
|
+
/**
|
|
74
|
+
* A name of the preview mode that should be active when the editor is initialized. Possible values are:
|
|
75
|
+
*
|
|
76
|
+
* * `'$labels'` - displays the labels of the merge fields,
|
|
77
|
+
* * `'$defaultValues'` - displays the default values,
|
|
78
|
+
* * one of the configured {@link module:merge-fields/mergefieldsconfig~MergeFieldsConfig#dataSets data sets} identifiers.
|
|
79
|
+
*
|
|
80
|
+
* If not set, it will default to the one of the {@link ~MergeFieldsConfig#previewModes available preview modes}, with the priority as
|
|
81
|
+
* in the list above.
|
|
82
|
+
*/
|
|
83
|
+
initialPreviewMode?: string;
|
|
84
|
+
/**
|
|
85
|
+
* A flag indicating whether the feature preview mode should interpret merge fields
|
|
86
|
+
* {@link ~MergeFieldsDataSetDefinition#values data set values} and {@link ~MergeFieldDefinition#defaultValue default values} as
|
|
87
|
+
* HTML strings and render them as HTML.
|
|
88
|
+
*
|
|
89
|
+
* When set to `true`, the merge field value will be interpreted and rendered as HTML. For example, `'<img src="image.jpg" />'` merge
|
|
90
|
+
* field value will be previewed as the image located at given `src`.
|
|
91
|
+
*
|
|
92
|
+
* When set to `false`, the merge field value will be interpreted as a regular text. For example, `'<img src="image.jpg" />'` will be
|
|
93
|
+
* displayed exactly as defined, meaning that text `<img src="image.jpg" />` will be displayed instead of an image.
|
|
94
|
+
*
|
|
95
|
+
* By default, it is set to `false`.
|
|
96
|
+
*
|
|
97
|
+
* Read more about the security of previewing merge fields HTML values in the
|
|
98
|
+
* {@glink features/merge-fields#using-html-tags-in-merge-fields-values Merge fields feature} documentation.
|
|
99
|
+
*
|
|
100
|
+
* @default false
|
|
101
|
+
*/
|
|
102
|
+
previewHtmlValues?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Callback used to sanitize the HTML used in merge fields values when they are previewed inside the editor.
|
|
105
|
+
*
|
|
106
|
+
* We strongly recommend overwriting the default function to avoid XSS vulnerabilities.
|
|
107
|
+
*
|
|
108
|
+
* Read more about the security aspect of this feature in {@glink features/merge-fields#using-html-tags-in-merge-fields-values Merge
|
|
109
|
+
* fields feature} documentation.
|
|
110
|
+
*
|
|
111
|
+
* The function receives the input HTML (as a string), and should return an object
|
|
112
|
+
* that matches the {@link module:merge-fields/mergefieldsconfig~MergeFieldsSanitizeOutput} interface.
|
|
113
|
+
*
|
|
114
|
+
* ```ts
|
|
115
|
+
* ClassicEditor
|
|
116
|
+
* .create( {
|
|
117
|
+
* mergeFields: {
|
|
118
|
+
* previewHtmlValues: true,
|
|
119
|
+
* sanitizeHtml( inputHtml ) {
|
|
120
|
+
* // Strip unsafe elements and attributes, e.g.:
|
|
121
|
+
* // the `<script>` elements and `on*` attributes.
|
|
122
|
+
* const outputHtml = sanitize( inputHtml );
|
|
123
|
+
*
|
|
124
|
+
* return {
|
|
125
|
+
* html: outputHtml,
|
|
126
|
+
* // true or false depending on whether the sanitizer stripped anything.
|
|
127
|
+
* hasChanged: ...
|
|
128
|
+
* };
|
|
129
|
+
* },
|
|
130
|
+
* }
|
|
131
|
+
* } )
|
|
132
|
+
* .then( ... )
|
|
133
|
+
* .catch( ... );
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* **Note:** The function is used only when the feature
|
|
137
|
+
* {@link module:merge-fields/mergefieldsconfig~MergeFieldsConfig#previewHtmlValues is configured to render previews}.
|
|
138
|
+
*/
|
|
139
|
+
sanitizeHtml?: (html: string) => MergeFieldsSanitizeOutput;
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
* An object returned by the {@link module:merge-fields/mergefieldsconfig~MergeFieldsConfig#sanitizeHtml} function.
|
|
143
|
+
*/
|
|
144
144
|
export interface MergeFieldsSanitizeOutput {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
145
|
+
/**
|
|
146
|
+
* An output (safe) HTML that will be inserted into the {@glink framework/architecture/editing-engine editing view}.
|
|
147
|
+
*/
|
|
148
|
+
html: string;
|
|
149
|
+
/**
|
|
150
|
+
* A flag that indicates whether the output HTML is different than the input value.
|
|
151
|
+
*/
|
|
152
|
+
hasChanged: boolean;
|
|
153
153
|
}
|
|
154
154
|
export type MergeFieldsGroupDefinition = {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
155
|
+
/**
|
|
156
|
+
* The unique identifier of the group.
|
|
157
|
+
*
|
|
158
|
+
* If {@link ~MergeFieldsGroupDefinition#groupLabel} is not specified, the ID will be used as a label in the UI.
|
|
159
|
+
*/
|
|
160
|
+
groupId: string;
|
|
161
|
+
/**
|
|
162
|
+
* The human-readable label of the group.
|
|
163
|
+
*
|
|
164
|
+
* It is displayed by the feature's UI.
|
|
165
|
+
*/
|
|
166
|
+
groupLabel?: string;
|
|
167
|
+
/**
|
|
168
|
+
* The array of merge fields definitions that belong to the group.
|
|
169
|
+
*/
|
|
170
|
+
definitions: Array<MergeFieldDefinition>;
|
|
171
171
|
};
|
|
172
172
|
/**
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
173
|
+
* The definition of a single merge field.
|
|
174
|
+
*
|
|
175
|
+
* Depending on the {@link ~MergeFieldDefinition#type type}, some of the properties may not be relevant:
|
|
176
|
+
*
|
|
177
|
+
* * For `text` merge fields, the `id`, `label`, and `defaultValue` properties are used.
|
|
178
|
+
* * For `block` merge fields, the `id`, `label`, `height`, and `defaultValue` properties are used.
|
|
179
|
+
* * For `image` merge fields, the `id`, `label`, `height`, `width`, and `defaultValue` properties are used.
|
|
180
|
+
*/
|
|
181
181
|
export interface MergeFieldDefinition {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
182
|
+
/**
|
|
183
|
+
* The unique identifier of the merge field.
|
|
184
|
+
*
|
|
185
|
+
* If {@link ~MergeFieldDefinition#label label} is not specified, the ID will be used as a label.
|
|
186
|
+
*
|
|
187
|
+
* The list of allowed characters includes: `a-z`, `A-Z`, `0-9`, `_`, `.`, and `-`.
|
|
188
|
+
*/
|
|
189
|
+
id: string;
|
|
190
|
+
/**
|
|
191
|
+
* The human-readable label of the merge field.
|
|
192
|
+
*
|
|
193
|
+
* It is displayed by the feature's UI and inside the editing area.
|
|
194
|
+
*/
|
|
195
|
+
label?: string;
|
|
196
|
+
/**
|
|
197
|
+
* The type of the merge field. It determines how the merge field is rendered in the editor editing area.
|
|
198
|
+
*
|
|
199
|
+
* Possible options are `text` (meaning the merge field will be inline), `block` and `image`.
|
|
200
|
+
*
|
|
201
|
+
* @default 'text'
|
|
202
|
+
*/
|
|
203
|
+
type?: MergeFieldType;
|
|
204
|
+
/**
|
|
205
|
+
* The height of the non-text merge field in pixels.
|
|
206
|
+
*
|
|
207
|
+
* It is used only for merge fields of type `block` and `image`. If unset, the default height for block is 120 pixels
|
|
208
|
+
* and for image - 400 pixels.
|
|
209
|
+
*
|
|
210
|
+
* @default 120 (for block)/ 400 (for image)
|
|
211
|
+
*/
|
|
212
|
+
height?: number;
|
|
213
|
+
/**
|
|
214
|
+
* The width of the image merge field in pixels.
|
|
215
|
+
*
|
|
216
|
+
* It is used only for merge fields of type `image`. If unset, the default width is 400 pixels.
|
|
217
|
+
*
|
|
218
|
+
* @default 400
|
|
219
|
+
*/
|
|
220
|
+
width?: number;
|
|
221
|
+
/**
|
|
222
|
+
* Default value of the merge field.
|
|
223
|
+
*
|
|
224
|
+
* It is used if a value for given merge field has not been provided in a data set and in the default values preview mode.
|
|
225
|
+
*/
|
|
226
|
+
defaultValue?: MergeFieldDataSetValue;
|
|
227
227
|
}
|
|
228
228
|
export type MergeFieldsDataSetDefinition = {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
229
|
+
/**
|
|
230
|
+
* A unique identifier of the data set. It cannot start with `$`, as it is reserved for internal use.
|
|
231
|
+
*/
|
|
232
|
+
id: string;
|
|
233
|
+
/**
|
|
234
|
+
* A human-readable label of the data set.
|
|
235
|
+
*/
|
|
236
|
+
label?: string;
|
|
237
|
+
/**
|
|
238
|
+
* The data to be displayed in the editor in place of merge fields when the data set is previewed.
|
|
239
|
+
*
|
|
240
|
+
* The keys of this object are merge field IDs, while values are the merge field values, which can be strings or functions.
|
|
241
|
+
* If the value is specified as a function, it should return a string. The function will be evaluated each time the data set values
|
|
242
|
+
* are retrieved.
|
|
243
|
+
*
|
|
244
|
+
* ```ts
|
|
245
|
+
* const mergeFieldsConfig = {
|
|
246
|
+
* dataSets: [
|
|
247
|
+
* id: 'customDataSet',
|
|
248
|
+
* values: {
|
|
249
|
+
* companyName: 'CKSource',
|
|
250
|
+
* productName: 'CKEditor 5'
|
|
251
|
+
* }
|
|
252
|
+
* ]
|
|
253
|
+
* };
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
values: Record<string, MergeFieldDataSetValue>;
|
|
257
257
|
};
|
|
258
258
|
export type MergeFieldDataSetValue = string | ((editor: Editor) => string);
|
|
259
|
-
export type MergeFieldType =
|
|
259
|
+
export type MergeFieldType = "text" | "block" | "image";
|