@ckeditor/ckeditor5-engine 36.0.1 → 37.0.0-alpha.1

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.
Files changed (203) hide show
  1. package/README.md +1 -1
  2. package/package.json +25 -24
  3. package/src/controller/datacontroller.d.ts +331 -0
  4. package/src/controller/datacontroller.js +72 -116
  5. package/src/controller/editingcontroller.d.ts +98 -0
  6. package/src/controller/editingcontroller.js +22 -46
  7. package/src/conversion/conversion.d.ts +476 -0
  8. package/src/conversion/conversion.js +328 -347
  9. package/src/conversion/conversionhelpers.d.ts +26 -0
  10. package/src/conversion/conversionhelpers.js +1 -5
  11. package/src/conversion/downcastdispatcher.d.ts +547 -0
  12. package/src/conversion/downcastdispatcher.js +74 -152
  13. package/src/conversion/downcasthelpers.d.ts +1226 -0
  14. package/src/conversion/downcasthelpers.js +843 -762
  15. package/src/conversion/mapper.d.ts +503 -0
  16. package/src/conversion/mapper.js +84 -99
  17. package/src/conversion/modelconsumable.d.ts +201 -0
  18. package/src/conversion/modelconsumable.js +96 -99
  19. package/src/conversion/upcastdispatcher.d.ts +492 -0
  20. package/src/conversion/upcastdispatcher.js +73 -100
  21. package/src/conversion/upcasthelpers.d.ts +499 -0
  22. package/src/conversion/upcasthelpers.js +406 -373
  23. package/src/conversion/viewconsumable.d.ts +369 -0
  24. package/src/conversion/viewconsumable.js +139 -173
  25. package/src/dataprocessor/basichtmlwriter.d.ts +18 -0
  26. package/src/dataprocessor/basichtmlwriter.js +0 -9
  27. package/src/dataprocessor/dataprocessor.d.ts +61 -0
  28. package/src/dataprocessor/htmldataprocessor.d.ts +76 -0
  29. package/src/dataprocessor/htmldataprocessor.js +6 -28
  30. package/src/dataprocessor/htmlwriter.d.ts +16 -0
  31. package/src/dataprocessor/xmldataprocessor.d.ts +90 -0
  32. package/src/dataprocessor/xmldataprocessor.js +8 -40
  33. package/src/dev-utils/model.d.ts +124 -0
  34. package/src/dev-utils/model.js +41 -38
  35. package/src/dev-utils/operationreplayer.d.ts +51 -0
  36. package/src/dev-utils/operationreplayer.js +6 -14
  37. package/src/dev-utils/utils.d.ts +37 -0
  38. package/src/dev-utils/utils.js +5 -18
  39. package/src/dev-utils/view.d.ts +319 -0
  40. package/src/dev-utils/view.js +205 -226
  41. package/src/index.d.ts +108 -0
  42. package/src/index.js +4 -0
  43. package/src/model/batch.d.ts +106 -0
  44. package/src/model/differ.d.ts +329 -0
  45. package/src/model/document.d.ts +246 -0
  46. package/src/model/document.js +1 -1
  47. package/src/model/documentfragment.d.ts +196 -0
  48. package/src/model/documentfragment.js +2 -2
  49. package/src/model/documentselection.d.ts +420 -0
  50. package/src/model/element.d.ts +165 -0
  51. package/src/model/history.d.ts +114 -0
  52. package/src/model/item.d.ts +14 -0
  53. package/src/model/liveposition.d.ts +77 -0
  54. package/src/model/liverange.d.ts +102 -0
  55. package/src/model/markercollection.d.ts +335 -0
  56. package/src/model/model.d.ts +885 -0
  57. package/src/model/model.js +59 -81
  58. package/src/model/node.d.ts +256 -0
  59. package/src/model/nodelist.d.ts +91 -0
  60. package/src/model/operation/attributeoperation.d.ts +98 -0
  61. package/src/model/operation/detachoperation.d.ts +55 -0
  62. package/src/model/operation/insertoperation.d.ts +85 -0
  63. package/src/model/operation/markeroperation.d.ts +86 -0
  64. package/src/model/operation/mergeoperation.d.ts +95 -0
  65. package/src/model/operation/mergeoperation.js +1 -1
  66. package/src/model/operation/moveoperation.d.ts +91 -0
  67. package/src/model/operation/nooperation.d.ts +33 -0
  68. package/src/model/operation/operation.d.ts +89 -0
  69. package/src/model/operation/operationfactory.d.ts +18 -0
  70. package/src/model/operation/renameoperation.d.ts +78 -0
  71. package/src/model/operation/rootattributeoperation.d.ts +97 -0
  72. package/src/model/operation/rootattributeoperation.js +1 -1
  73. package/src/model/operation/splitoperation.d.ts +104 -0
  74. package/src/model/operation/splitoperation.js +1 -1
  75. package/src/model/operation/transform.d.ts +100 -0
  76. package/src/model/operation/utils.d.ts +71 -0
  77. package/src/model/operation/utils.js +1 -1
  78. package/src/model/position.d.ts +539 -0
  79. package/src/model/position.js +1 -1
  80. package/src/model/range.d.ts +458 -0
  81. package/src/model/range.js +1 -1
  82. package/src/model/rootelement.d.ts +40 -0
  83. package/src/model/schema.d.ts +1176 -0
  84. package/src/model/schema.js +19 -19
  85. package/src/model/selection.d.ts +472 -0
  86. package/src/model/text.d.ts +66 -0
  87. package/src/model/text.js +0 -2
  88. package/src/model/textproxy.d.ts +144 -0
  89. package/src/model/treewalker.d.ts +186 -0
  90. package/src/model/treewalker.js +19 -10
  91. package/src/model/typecheckable.d.ts +285 -0
  92. package/src/model/utils/autoparagraphing.d.ts +37 -0
  93. package/src/model/utils/deletecontent.d.ts +58 -0
  94. package/src/model/utils/findoptimalinsertionrange.d.ts +32 -0
  95. package/src/model/utils/getselectedcontent.d.ts +30 -0
  96. package/src/model/utils/insertcontent.d.ts +46 -0
  97. package/src/model/utils/insertcontent.js +2 -12
  98. package/src/model/utils/insertobject.d.ts +44 -0
  99. package/src/model/utils/insertobject.js +3 -14
  100. package/src/model/utils/modifyselection.d.ts +48 -0
  101. package/src/model/utils/selection-post-fixer.d.ts +65 -0
  102. package/src/model/writer.d.ts +823 -0
  103. package/src/model/writer.js +6 -61
  104. package/src/view/attributeelement.d.ts +108 -0
  105. package/src/view/attributeelement.js +25 -69
  106. package/src/view/containerelement.d.ts +49 -0
  107. package/src/view/containerelement.js +10 -43
  108. package/src/view/datatransfer.d.ts +75 -0
  109. package/src/view/document.d.ts +184 -0
  110. package/src/view/document.js +15 -84
  111. package/src/view/documentfragment.d.ts +149 -0
  112. package/src/view/documentfragment.js +39 -81
  113. package/src/view/documentselection.d.ts +306 -0
  114. package/src/view/documentselection.js +42 -143
  115. package/src/view/domconverter.d.ts +650 -0
  116. package/src/view/domconverter.js +157 -283
  117. package/src/view/downcastwriter.d.ts +996 -0
  118. package/src/view/downcastwriter.js +259 -426
  119. package/src/view/editableelement.d.ts +52 -0
  120. package/src/view/editableelement.js +9 -49
  121. package/src/view/element.d.ts +468 -0
  122. package/src/view/element.js +150 -222
  123. package/src/view/elementdefinition.d.ts +87 -0
  124. package/src/view/emptyelement.d.ts +41 -0
  125. package/src/view/emptyelement.js +11 -44
  126. package/src/view/filler.d.ts +111 -0
  127. package/src/view/filler.js +24 -21
  128. package/src/view/item.d.ts +14 -0
  129. package/src/view/matcher.d.ts +486 -0
  130. package/src/view/matcher.js +247 -218
  131. package/src/view/node.d.ts +163 -0
  132. package/src/view/node.js +26 -100
  133. package/src/view/observer/arrowkeysobserver.d.ts +41 -0
  134. package/src/view/observer/arrowkeysobserver.js +0 -13
  135. package/src/view/observer/bubblingemittermixin.d.ts +166 -0
  136. package/src/view/observer/bubblingemittermixin.js +36 -25
  137. package/src/view/observer/bubblingeventinfo.d.ts +47 -0
  138. package/src/view/observer/bubblingeventinfo.js +3 -29
  139. package/src/view/observer/clickobserver.d.ts +43 -0
  140. package/src/view/observer/clickobserver.js +9 -19
  141. package/src/view/observer/compositionobserver.d.ts +82 -0
  142. package/src/view/observer/compositionobserver.js +13 -42
  143. package/src/view/observer/domeventdata.d.ts +50 -0
  144. package/src/view/observer/domeventdata.js +5 -30
  145. package/src/view/observer/domeventobserver.d.ts +69 -0
  146. package/src/view/observer/domeventobserver.js +19 -21
  147. package/src/view/observer/fakeselectionobserver.d.ts +43 -0
  148. package/src/view/observer/fakeselectionobserver.js +0 -16
  149. package/src/view/observer/focusobserver.d.ts +82 -0
  150. package/src/view/observer/focusobserver.js +14 -40
  151. package/src/view/observer/inputobserver.d.ts +86 -0
  152. package/src/view/observer/inputobserver.js +18 -64
  153. package/src/view/observer/keyobserver.d.ts +66 -0
  154. package/src/view/observer/keyobserver.js +8 -42
  155. package/src/view/observer/mouseobserver.d.ts +89 -0
  156. package/src/view/observer/mouseobserver.js +8 -28
  157. package/src/view/observer/mutationobserver.d.ts +82 -0
  158. package/src/view/observer/mutationobserver.js +7 -37
  159. package/src/view/observer/observer.d.ts +84 -0
  160. package/src/view/observer/observer.js +12 -25
  161. package/src/view/observer/selectionobserver.d.ts +144 -0
  162. package/src/view/observer/selectionobserver.js +17 -107
  163. package/src/view/observer/tabobserver.d.ts +42 -0
  164. package/src/view/observer/tabobserver.js +0 -14
  165. package/src/view/placeholder.d.ts +85 -0
  166. package/src/view/placeholder.js +26 -43
  167. package/src/view/position.d.ts +189 -0
  168. package/src/view/position.js +36 -83
  169. package/src/view/range.d.ts +279 -0
  170. package/src/view/range.js +79 -122
  171. package/src/view/rawelement.d.ts +73 -0
  172. package/src/view/rawelement.js +34 -48
  173. package/src/view/renderer.d.ts +265 -0
  174. package/src/view/renderer.js +105 -193
  175. package/src/view/rooteditableelement.d.ts +41 -0
  176. package/src/view/rooteditableelement.js +12 -40
  177. package/src/view/selection.d.ts +375 -0
  178. package/src/view/selection.js +79 -153
  179. package/src/view/styles/background.d.ts +33 -0
  180. package/src/view/styles/background.js +14 -12
  181. package/src/view/styles/border.d.ts +43 -0
  182. package/src/view/styles/border.js +58 -48
  183. package/src/view/styles/margin.d.ts +29 -0
  184. package/src/view/styles/margin.js +13 -11
  185. package/src/view/styles/padding.d.ts +29 -0
  186. package/src/view/styles/padding.js +13 -11
  187. package/src/view/styles/utils.d.ts +93 -0
  188. package/src/view/styles/utils.js +22 -48
  189. package/src/view/stylesmap.d.ts +675 -0
  190. package/src/view/stylesmap.js +249 -244
  191. package/src/view/text.d.ts +74 -0
  192. package/src/view/text.js +16 -46
  193. package/src/view/textproxy.d.ts +97 -0
  194. package/src/view/textproxy.js +10 -59
  195. package/src/view/treewalker.d.ts +195 -0
  196. package/src/view/treewalker.js +43 -106
  197. package/src/view/typecheckable.d.ts +448 -0
  198. package/src/view/uielement.d.ts +96 -0
  199. package/src/view/uielement.js +29 -63
  200. package/src/view/upcastwriter.d.ts +417 -0
  201. package/src/view/upcastwriter.js +86 -157
  202. package/src/view/view.d.ts +417 -0
  203. package/src/view/view.js +47 -175
@@ -14,32 +14,13 @@ import { get, isObject, merge, set, unset } from 'lodash-es';
14
14
  export default class StylesMap {
15
15
  /**
16
16
  * Creates Styles instance.
17
- *
18
- * @param {module:engine/view/stylesmap~StylesProcessor} styleProcessor
19
17
  */
20
18
  constructor(styleProcessor) {
21
- /**
22
- * Keeps an internal representation of styles map. Normalized styles are kept as object tree to allow unified modification and
23
- * value access model using lodash's get, set, unset, etc methods.
24
- *
25
- * When no style processor rules are defined it acts as simple key-value storage.
26
- *
27
- * @private
28
- * @type {Object}
29
- */
30
19
  this._styles = {};
31
- /**
32
- * An instance of the {@link module:engine/view/stylesmap~StylesProcessor}.
33
- *
34
- * @private
35
- * @member {module:engine/view/stylesmap~StylesProcessor}
36
- */
37
20
  this._styleProcessor = styleProcessor;
38
21
  }
39
22
  /**
40
23
  * Returns true if style map has no styles set.
41
- *
42
- * @type {Boolean}
43
24
  */
44
25
  get isEmpty() {
45
26
  const entries = Object.entries(this._styles);
@@ -48,8 +29,6 @@ export default class StylesMap {
48
29
  }
49
30
  /**
50
31
  * Number of styles defined.
51
- *
52
- * @type {Number}
53
32
  */
54
33
  get size() {
55
34
  if (this.isEmpty) {
@@ -60,9 +39,9 @@ export default class StylesMap {
60
39
  /**
61
40
  * Set styles map to a new value.
62
41
  *
63
- * styles.setTo( 'border:1px solid blue;margin-top:1px;' );
64
- *
65
- * @param {String} inlineStyle
42
+ * ```ts
43
+ * styles.setTo( 'border:1px solid blue;margin-top:1px;' );
44
+ * ```
66
45
  */
67
46
  setTo(inlineStyle) {
68
47
  this.clear();
@@ -74,30 +53,33 @@ export default class StylesMap {
74
53
  /**
75
54
  * Checks if a given style is set.
76
55
  *
77
- * styles.setTo( 'margin-left:1px;' );
56
+ * ```ts
57
+ * styles.setTo( 'margin-left:1px;' );
78
58
  *
79
- * styles.has( 'margin-left' ); // -> true
80
- * styles.has( 'padding' ); // -> false
59
+ * styles.has( 'margin-left' ); // -> true
60
+ * styles.has( 'padding' ); // -> false
61
+ * ```
81
62
  *
82
63
  * **Note**: This check supports normalized style names.
83
64
  *
84
- * // Enable 'margin' shorthand processing:
85
- * editor.data.addStyleProcessorRules( addMarginRules );
65
+ * ```ts
66
+ * // Enable 'margin' shorthand processing:
67
+ * editor.data.addStyleProcessorRules( addMarginRules );
86
68
  *
87
- * styles.setTo( 'margin:2px;' );
69
+ * styles.setTo( 'margin:2px;' );
88
70
  *
89
- * styles.has( 'margin' ); // -> true
90
- * styles.has( 'margin-top' ); // -> true
91
- * styles.has( 'margin-left' ); // -> true
71
+ * styles.has( 'margin' ); // -> true
72
+ * styles.has( 'margin-top' ); // -> true
73
+ * styles.has( 'margin-left' ); // -> true
92
74
  *
93
- * styles.remove( 'margin-top' );
75
+ * styles.remove( 'margin-top' );
94
76
  *
95
- * styles.has( 'margin' ); // -> false
96
- * styles.has( 'margin-top' ); // -> false
97
- * styles.has( 'margin-left' ); // -> true
77
+ * styles.has( 'margin' ); // -> false
78
+ * styles.has( 'margin-top' ); // -> false
79
+ * styles.has( 'margin-left' ); // -> true
80
+ * ```
98
81
  *
99
- * @param {String} name Style name.
100
- * @returns {Boolean}
82
+ * @param name Style name.
101
83
  */
102
84
  has(name) {
103
85
  if (this.isEmpty) {
@@ -121,26 +103,30 @@ export default class StylesMap {
121
103
  /**
122
104
  * Removes given style.
123
105
  *
124
- * styles.setTo( 'background:#f00;margin-right:2px;' );
106
+ * ```ts
107
+ * styles.setTo( 'background:#f00;margin-right:2px;' );
125
108
  *
126
- * styles.remove( 'background' );
109
+ * styles.remove( 'background' );
127
110
  *
128
- * styles.toString(); // -> 'margin-right:2px;'
111
+ * styles.toString(); // -> 'margin-right:2px;'
112
+ * ```
129
113
  *
130
114
  * ***Note**:* This method uses {@link module:engine/controller/datacontroller~DataController#addStyleProcessorRules
131
115
  * enabled style processor rules} to normalize passed values.
132
116
  *
133
- * // Enable 'margin' shorthand processing:
134
- * editor.data.addStyleProcessorRules( addMarginRules );
117
+ * ```ts
118
+ * // Enable 'margin' shorthand processing:
119
+ * editor.data.addStyleProcessorRules( addMarginRules );
135
120
  *
136
- * styles.setTo( 'margin:1px' );
121
+ * styles.setTo( 'margin:1px' );
137
122
  *
138
- * styles.remove( 'margin-top' );
139
- * styles.remove( 'margin-right' );
123
+ * styles.remove( 'margin-top' );
124
+ * styles.remove( 'margin-right' );
140
125
  *
141
- * styles.toString(); // -> 'margin-bottom:1px;margin-left:1px;'
126
+ * styles.toString(); // -> 'margin-bottom:1px;margin-left:1px;'
127
+ * ```
142
128
  *
143
- * @param {String} name Style name.
129
+ * @param name Style name.
144
130
  */
145
131
  remove(name) {
146
132
  const path = toPath(name);
@@ -151,27 +137,28 @@ export default class StylesMap {
151
137
  /**
152
138
  * Returns a normalized style object or a single value.
153
139
  *
154
- * // Enable 'margin' shorthand processing:
155
- * editor.data.addStyleProcessorRules( addMarginRules );
140
+ * ```ts
141
+ * // Enable 'margin' shorthand processing:
142
+ * editor.data.addStyleProcessorRules( addMarginRules );
156
143
  *
157
- * const styles = new Styles();
158
- * styles.setTo( 'margin:1px 2px 3em;' );
144
+ * const styles = new Styles();
145
+ * styles.setTo( 'margin:1px 2px 3em;' );
159
146
  *
160
- * styles.getNormalized( 'margin' );
161
- * // will log:
162
- * // {
163
- * // top: '1px',
164
- * // right: '2px',
165
- * // bottom: '3em',
166
- * // left: '2px' // normalized value from margin shorthand
167
- * // }
147
+ * styles.getNormalized( 'margin' );
148
+ * // will log:
149
+ * // {
150
+ * // top: '1px',
151
+ * // right: '2px',
152
+ * // bottom: '3em',
153
+ * // left: '2px' // normalized value from margin shorthand
154
+ * // }
168
155
  *
169
- * styles.getNormalized( 'margin-left' ); // -> '2px'
156
+ * styles.getNormalized( 'margin-left' ); // -> '2px'
157
+ * ```
170
158
  *
171
159
  * **Note**: This method will only return normalized styles if a style processor was defined.
172
160
  *
173
- * @param {String} name Style name.
174
- * @returns {Object|String|undefined}
161
+ * @param name Style name.
175
162
  */
176
163
  getNormalized(name) {
177
164
  return this._styleProcessor.getNormalized(name, this._styles);
@@ -179,24 +166,26 @@ export default class StylesMap {
179
166
  /**
180
167
  * Returns a normalized style string. Styles are sorted by name.
181
168
  *
182
- * styles.set( 'margin' , '1px' );
183
- * styles.set( 'background', '#f00' );
169
+ * ```ts
170
+ * styles.set( 'margin' , '1px' );
171
+ * styles.set( 'background', '#f00' );
184
172
  *
185
- * styles.toString(); // -> 'background:#f00;margin:1px;'
173
+ * styles.toString(); // -> 'background:#f00;margin:1px;'
174
+ * ```
186
175
  *
187
176
  * **Note**: This method supports normalized styles if defined.
188
177
  *
189
- * // Enable 'margin' shorthand processing:
190
- * editor.data.addStyleProcessorRules( addMarginRules );
191
- *
192
- * styles.set( 'margin' , '1px' );
193
- * styles.set( 'background', '#f00' );
194
- * styles.remove( 'margin-top' );
195
- * styles.remove( 'margin-right' );
178
+ * ```ts
179
+ * // Enable 'margin' shorthand processing:
180
+ * editor.data.addStyleProcessorRules( addMarginRules );
196
181
  *
197
- * styles.toString(); // -> 'background:#f00;margin-bottom:1px;margin-left:1px;'
182
+ * styles.set( 'margin' , '1px' );
183
+ * styles.set( 'background', '#f00' );
184
+ * styles.remove( 'margin-top' );
185
+ * styles.remove( 'margin-right' );
198
186
  *
199
- * @returns {String}
187
+ * styles.toString(); // -> 'background:#f00;margin-bottom:1px;margin-left:1px;'
188
+ * ```
200
189
  */
201
190
  toString() {
202
191
  if (this.isEmpty) {
@@ -210,53 +199,58 @@ export default class StylesMap {
210
199
  /**
211
200
  * Returns property as a value string or undefined if property is not set.
212
201
  *
213
- * // Enable 'margin' shorthand processing:
214
- * editor.data.addStyleProcessorRules( addMarginRules );
202
+ * ```ts
203
+ * // Enable 'margin' shorthand processing:
204
+ * editor.data.addStyleProcessorRules( addMarginRules );
215
205
  *
216
- * const styles = new Styles();
217
- * styles.setTo( 'margin:1px;' );
218
- * styles.set( 'margin-bottom', '3em' );
206
+ * const styles = new Styles();
207
+ * styles.setTo( 'margin:1px;' );
208
+ * styles.set( 'margin-bottom', '3em' );
219
209
  *
220
- * styles.getAsString( 'margin' ); // -> 'margin: 1px 1px 3em;'
210
+ * styles.getAsString( 'margin' ); // -> 'margin: 1px 1px 3em;'
211
+ * ```
221
212
  *
222
213
  * Note, however, that all sub-values must be set for the longhand property name to return a value:
223
214
  *
224
- * const styles = new Styles();
225
- * styles.setTo( 'margin:1px;' );
226
- * styles.remove( 'margin-bottom' );
215
+ * ```ts
216
+ * const styles = new Styles();
217
+ * styles.setTo( 'margin:1px;' );
218
+ * styles.remove( 'margin-bottom' );
227
219
  *
228
- * styles.getAsString( 'margin' ); // -> undefined
220
+ * styles.getAsString( 'margin' ); // -> undefined
221
+ * ```
229
222
  *
230
223
  * In the above scenario, it is not possible to return a `margin` value, so `undefined` is returned.
231
224
  * Instead, you should use:
232
225
  *
233
- * const styles = new Styles();
234
- * styles.setTo( 'margin:1px;' );
235
- * styles.remove( 'margin-bottom' );
226
+ * ```ts
227
+ * const styles = new Styles();
228
+ * styles.setTo( 'margin:1px;' );
229
+ * styles.remove( 'margin-bottom' );
236
230
  *
237
- * for ( const styleName of styles.getStyleNames() ) {
238
- * console.log( styleName, styles.getAsString( styleName ) );
239
- * }
240
- * // 'margin-top', '1px'
241
- * // 'margin-right', '1px'
242
- * // 'margin-left', '1px'
231
+ * for ( const styleName of styles.getStyleNames() ) {
232
+ * console.log( styleName, styles.getAsString( styleName ) );
233
+ * }
234
+ * // 'margin-top', '1px'
235
+ * // 'margin-right', '1px'
236
+ * // 'margin-left', '1px'
237
+ * ```
243
238
  *
244
239
  * In general, it is recommend to iterate over style names like in the example above. This way, you will always get all
245
240
  * the currently set style values. So, if all the 4 margin values would be set
246
241
  * the for-of loop above would yield only `'margin'`, `'1px'`:
247
242
  *
248
- * const styles = new Styles();
249
- * styles.setTo( 'margin:1px;' );
243
+ * ```ts
244
+ * const styles = new Styles();
245
+ * styles.setTo( 'margin:1px;' );
250
246
  *
251
- * for ( const styleName of styles.getStyleNames() ) {
252
- * console.log( styleName, styles.getAsString( styleName ) );
253
- * }
254
- * // 'margin', '1px'
247
+ * for ( const styleName of styles.getStyleNames() ) {
248
+ * console.log( styleName, styles.getAsString( styleName ) );
249
+ * }
250
+ * // 'margin', '1px'
251
+ * ```
255
252
  *
256
253
  * **Note**: To get a normalized version of a longhand property use the {@link #getNormalized `#getNormalized()`} method.
257
- *
258
- * @param {String} propertyName
259
- * @returns {String|undefined}
260
254
  */
261
255
  getAsString(propertyName) {
262
256
  if (this.isEmpty) {
@@ -278,14 +272,17 @@ export default class StylesMap {
278
272
  *
279
273
  * When `expand` is set to true and there's a shorthand style property set, it will also return all equivalent styles:
280
274
  *
281
- * stylesMap.setTo( 'margin: 1em' )
275
+ * ```ts
276
+ * stylesMap.setTo( 'margin: 1em' )
277
+ * ```
282
278
  *
283
279
  * will be expanded to:
284
280
  *
285
- * [ 'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left' ]
281
+ * ```ts
282
+ * [ 'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left' ]
283
+ * ```
286
284
  *
287
- * @param {Boolean} [expand=false] Expand shorthand style properties and all return equivalent style representations.
288
- * @returns {Array.<String>}
285
+ * @param expand Expand shorthand style properties and all return equivalent style representations.
289
286
  */
290
287
  getStyleNames(expand = false) {
291
288
  if (this.isEmpty) {
@@ -305,9 +302,6 @@ export default class StylesMap {
305
302
  }
306
303
  /**
307
304
  * Returns normalized styles entries for further processing.
308
- *
309
- * @private
310
- * @returns {Array.<module:engine/view/stylesmap~PropertyDescriptor>}
311
305
  */
312
306
  _getStylesEntries() {
313
307
  const parsed = [];
@@ -319,9 +313,6 @@ export default class StylesMap {
319
313
  }
320
314
  /**
321
315
  * Removes empty objects upon removing an entry from internal object.
322
- *
323
- * @param {String} path
324
- * @private
325
316
  */
326
317
  _cleanEmptyObjectsOnPath(path) {
327
318
  const pathParts = path.split('.');
@@ -347,7 +338,7 @@ export class StylesProcessor {
347
338
  /**
348
339
  * Creates StylesProcessor instance.
349
340
  *
350
- * @private
341
+ * @internal
351
342
  */
352
343
  constructor() {
353
344
  this._normalizers = new Map();
@@ -358,17 +349,19 @@ export class StylesProcessor {
358
349
  /**
359
350
  * Parse style string value to a normalized object and appends it to styles object.
360
351
  *
361
- * const styles = {};
352
+ * ```ts
353
+ * const styles = {};
362
354
  *
363
- * stylesProcessor.toNormalizedForm( 'margin', '1px', styles );
355
+ * stylesProcessor.toNormalizedForm( 'margin', '1px', styles );
364
356
  *
365
- * // styles will consist: { margin: { top: '1px', right: '1px', bottom: '1px', left: '1px; } }
357
+ * // styles will consist: { margin: { top: '1px', right: '1px', bottom: '1px', left: '1px; } }
358
+ * ```
366
359
  *
367
360
  * **Note**: To define normalizer callbacks use {@link #setNormalizer}.
368
361
  *
369
- * @param {String} name Name of style property.
370
- * @param {String} propertyValue Value of style property.
371
- * @param {Object} styles Object holding normalized styles.
362
+ * @param name Name of style property.
363
+ * @param propertyValue Value of style property.
364
+ * @param styles Object holding normalized styles.
372
365
  */
373
366
  toNormalizedForm(name, propertyValue, styles) {
374
367
  if (isObject(propertyValue)) {
@@ -386,22 +379,24 @@ export class StylesProcessor {
386
379
  }
387
380
  /**
388
381
  * Returns a normalized version of a style property.
389
- * const styles = {
390
- * margin: { top: '1px', right: '1px', bottom: '1px', left: '1px; },
391
- * background: { color: '#f00' }
392
- * };
393
382
  *
394
- * stylesProcessor.getNormalized( 'background' );
395
- * // will return: { color: '#f00' }
383
+ * ```ts
384
+ * const styles = {
385
+ * margin: { top: '1px', right: '1px', bottom: '1px', left: '1px; },
386
+ * background: { color: '#f00' }
387
+ * };
388
+ *
389
+ * stylesProcessor.getNormalized( 'background' );
390
+ * // will return: { color: '#f00' }
396
391
  *
397
- * stylesProcessor.getNormalized( 'margin-top' );
398
- * // will return: '1px'
392
+ * stylesProcessor.getNormalized( 'margin-top' );
393
+ * // will return: '1px'
394
+ * ```
399
395
  *
400
396
  * **Note**: In some cases extracting single value requires defining an extractor callback {@link #setExtractor}.
401
397
  *
402
- * @param {String} name Name of style property.
403
- * @param {Object} styles Object holding normalized styles.
404
- * @returns {*}
398
+ * @param name Name of style property.
399
+ * @param styles Object holding normalized styles.
405
400
  */
406
401
  getNormalized(name, styles) {
407
402
  if (!name) {
@@ -428,30 +423,34 @@ export class StylesProcessor {
428
423
  *
429
424
  * For default margin reducer, the below code:
430
425
  *
431
- * stylesProcessor.getReducedForm( 'margin', {
432
- * margin: { top: '1px', right: '1px', bottom: '2px', left: '1px; }
433
- * } );
426
+ * ```ts
427
+ * stylesProcessor.getReducedForm( 'margin', {
428
+ * margin: { top: '1px', right: '1px', bottom: '2px', left: '1px; }
429
+ * } );
430
+ * ```
434
431
  *
435
432
  * will return:
436
433
  *
437
- * [
438
- * [ 'margin', '1px 1px 2px' ]
439
- * ]
434
+ * ```ts
435
+ * [
436
+ * [ 'margin', '1px 1px 2px' ]
437
+ * ]
438
+ * ```
440
439
  *
441
440
  * because it might be represented as a shorthand 'margin' value. However if one of margin long hand values is missing it should return:
442
441
  *
443
- * [
444
- * [ 'margin-top', '1px' ],
445
- * [ 'margin-right', '1px' ],
446
- * [ 'margin-bottom', '2px' ]
447
- * // the 'left' value is missing - cannot use 'margin' shorthand.
448
- * ]
442
+ * ```ts
443
+ * [
444
+ * [ 'margin-top', '1px' ],
445
+ * [ 'margin-right', '1px' ],
446
+ * [ 'margin-bottom', '2px' ]
447
+ * // the 'left' value is missing - cannot use 'margin' shorthand.
448
+ * ]
449
+ * ```
449
450
  *
450
451
  * **Note**: To define reducer callbacks use {@link #setReducer}.
451
452
  *
452
- * @param {String} name Name of style property.
453
- * @param {Object} styles Object holding normalized styles.
454
- * @returns {Array.<module:engine/view/stylesmap~PropertyDescriptor>}
453
+ * @param name Name of style property.
455
454
  */
456
455
  getReducedForm(name, styles) {
457
456
  const normalizedValue = this.getNormalized(name, styles);
@@ -468,8 +467,7 @@ export class StylesProcessor {
468
467
  /**
469
468
  * Return all style properties. Also expand shorthand properties (e.g. `margin`, `background`) if respective extractor is available.
470
469
  *
471
- * @param {Object} styles Object holding normalized styles.
472
- * @returns {Array.<String>}
470
+ * @param styles Object holding normalized styles.
473
471
  */
474
472
  getStyleNames(styles) {
475
473
  // Find all extractable styles that have a value.
@@ -491,17 +489,16 @@ export class StylesProcessor {
491
489
  /**
492
490
  * Returns related style names.
493
491
  *
494
- * stylesProcessor.getRelatedStyles( 'margin' );
495
- * // will return: [ 'margin-top', 'margin-right', 'margin-bottom', 'margin-left' ];
492
+ * ```ts
493
+ * stylesProcessor.getRelatedStyles( 'margin' );
494
+ * // will return: [ 'margin-top', 'margin-right', 'margin-bottom', 'margin-left' ];
496
495
  *
497
- * stylesProcessor.getRelatedStyles( 'margin-top' );
498
- * // will return: [ 'margin' ];
496
+ * stylesProcessor.getRelatedStyles( 'margin-top' );
497
+ * // will return: [ 'margin' ];
498
+ * ```
499
499
  *
500
500
  * **Note**: To define new style relations load an existing style processor or use
501
501
  * {@link module:engine/view/stylesmap~StylesProcessor#setStyleRelation `StylesProcessor.setStyleRelation()`}.
502
- *
503
- * @param {String} name
504
- * @returns {Array.<String>}
505
502
  */
506
503
  getRelatedStyles(name) {
507
504
  return this._consumables.get(name) || [];
@@ -523,39 +520,42 @@ export class StylesProcessor {
523
520
  *
524
521
  * A normalizer should parse various margin notations as a single object:
525
522
  *
526
- * const styles = {
527
- * margin: {
528
- * top: '1px',
529
- * right: '2em',
530
- * bottom: '1px',
531
- * left: '2em'
532
- * }
533
- * };
523
+ * ```ts
524
+ * const styles = {
525
+ * margin: {
526
+ * top: '1px',
527
+ * right: '2em',
528
+ * bottom: '1px',
529
+ * left: '2em'
530
+ * }
531
+ * };
532
+ * ```
534
533
  *
535
534
  * Thus a normalizer for 'margin' style should return an object defining style path and value to store:
536
535
  *
537
- * const returnValue = {
538
- * path: 'margin',
539
- * value: {
540
- * top: '1px',
541
- * right: '2em',
542
- * bottom: '1px',
543
- * left: '2em'
544
- * }
545
- * };
536
+ * ```ts
537
+ * const returnValue = {
538
+ * path: 'margin',
539
+ * value: {
540
+ * top: '1px',
541
+ * right: '2em',
542
+ * bottom: '1px',
543
+ * left: '2em'
544
+ * }
545
+ * };
546
+ * ```
546
547
  *
547
548
  * Additionally to fully support all margin notations there should be also defined 4 normalizers for longhand margin notations. Below
548
549
  * is an example for 'margin-top' style property normalizer:
549
550
  *
550
- * stylesProcessor.setNormalizer( 'margin-top', valueString => {
551
- * return {
552
- * path: 'margin.top',
553
- * value: valueString
554
- * }
555
- * } );
556
- *
557
- * @param {String} name
558
- * @param {Function} callback
551
+ * ```ts
552
+ * stylesProcessor.setNormalizer( 'margin-top', valueString => {
553
+ * return {
554
+ * path: 'margin.top',
555
+ * value: valueString
556
+ * }
557
+ * } );
558
+ * ```
559
559
  */
560
560
  setNormalizer(name, callback) {
561
561
  this._normalizers.set(name, callback);
@@ -565,39 +565,44 @@ export class StylesProcessor {
565
565
  *
566
566
  * Most normalized style values are stored as one level objects. It is assumed that `'margin-top'` style will be stored as:
567
567
  *
568
- * const styles = {
569
- * margin: {
570
- * top: 'value'
571
- * }
572
- * }
568
+ * ```ts
569
+ * const styles = {
570
+ * margin: {
571
+ * top: 'value'
572
+ * }
573
+ * }
574
+ * ```
573
575
  *
574
576
  * However, some styles can have conflicting notations and thus it might be harder to extract a style value from shorthand. For instance
575
577
  * the 'border-top-style' can be defined using `'border-top:solid'`, `'border-style:solid none none none'` or by `'border:solid'`
576
578
  * shorthands. The default border styles processors stores styles as:
577
579
  *
578
- * const styles = {
579
- * border: {
580
- * style: {
581
- * top: 'solid'
582
- * }
583
- * }
584
- * }
580
+ * ```ts
581
+ * const styles = {
582
+ * border: {
583
+ * style: {
584
+ * top: 'solid'
585
+ * }
586
+ * }
587
+ * }
588
+ * ```
585
589
  *
586
590
  * as it is better to modify border style independently from other values. On the other part the output of the border might be
587
591
  * desired as `border-top`, `border-left`, etc notation.
588
592
  *
589
- * In the above example a reducer should return a side border value that combines style, color and width:
593
+ * In the above example an extractor should return a side border value that combines style, color and width:
590
594
  *
591
- * styleProcessor.setExtractor( 'border-top', styles => {
592
- * return {
593
- * color: styles.border.color.top,
594
- * style: styles.border.style.top,
595
- * width: styles.border.width.top
596
- * }
597
- * } );
595
+ * ```ts
596
+ * styleProcessor.setExtractor( 'border-top', styles => {
597
+ * return {
598
+ * color: styles.border.color.top,
599
+ * style: styles.border.style.top,
600
+ * width: styles.border.width.top
601
+ * }
602
+ * } );
603
+ * ```
598
604
  *
599
- * @param {String} name
600
- * @param {Function|String} callbackOrPath Callback that return a requested value or path string for single values.
605
+ * @param callbackOrPath Callback that return a requested value or path string for single values.
601
606
  */
602
607
  setExtractor(name, callbackOrPath) {
603
608
  this._extractors.set(name, callbackOrPath);
@@ -611,29 +616,32 @@ export class StylesProcessor {
611
616
  * For shorthand styles a reducer should return minimal style notation either by returning single name-value tuple or multiple tuples
612
617
  * if a shorthand cannot be used. For instance for a margin shorthand a reducer might return:
613
618
  *
614
- * const marginShortHandTuple = [
615
- * [ 'margin', '1px 1px 2px' ]
616
- * ];
619
+ * ```ts
620
+ * const marginShortHandTuple = [
621
+ * [ 'margin', '1px 1px 2px' ]
622
+ * ];
623
+ * ```
617
624
  *
618
625
  * or a longhand tuples for defined values:
619
626
  *
620
- * // Considering margin.bottom and margin.left are undefined.
621
- * const marginLonghandsTuples = [
622
- * [ 'margin-top', '1px' ],
623
- * [ 'margin-right', '1px' ]
624
- * ];
627
+ * ```ts
628
+ * // Considering margin.bottom and margin.left are undefined.
629
+ * const marginLonghandsTuples = [
630
+ * [ 'margin-top', '1px' ],
631
+ * [ 'margin-right', '1px' ]
632
+ * ];
633
+ * ```
625
634
  *
626
635
  * A reducer obtains a normalized style value:
627
636
  *
628
- * // Simplified reducer that always outputs 4 values which are always present:
629
- * stylesProcessor.setReducer( 'margin', margin => {
630
- * return [
631
- * [ 'margin', `${ margin.top } ${ margin.right } ${ margin.bottom } ${ margin.left }` ]
632
- * ]
633
- * } );
634
- *
635
- * @param {String} name
636
- * @param {Function} callback
637
+ * ```ts
638
+ * // Simplified reducer that always outputs 4 values which are always present:
639
+ * stylesProcessor.setReducer( 'margin', margin => {
640
+ * return [
641
+ * [ 'margin', `${ margin.top } ${ margin.right } ${ margin.bottom } ${ margin.left }` ]
642
+ * ]
643
+ * } );
644
+ * ```
637
645
  */
638
646
  setReducer(name, callback) {
639
647
  this._reducers.set(name, callback);
@@ -641,12 +649,14 @@ export class StylesProcessor {
641
649
  /**
642
650
  * Defines a style shorthand relation to other style notations.
643
651
  *
644
- * stylesProcessor.setStyleRelation( 'margin', [
645
- * 'margin-top',
646
- * 'margin-right',
647
- * 'margin-bottom',
648
- * 'margin-left'
649
- * ] );
652
+ * ```ts
653
+ * stylesProcessor.setStyleRelation( 'margin', [
654
+ * 'margin-top',
655
+ * 'margin-right',
656
+ * 'margin-bottom',
657
+ * 'margin-left'
658
+ * ] );
659
+ * ```
650
660
  *
651
661
  * This enables expanding of style names for shorthands. For instance, if defined,
652
662
  * {@link module:engine/conversion/viewconsumable~ViewConsumable view consumable} items are automatically created
@@ -656,9 +666,6 @@ export class StylesProcessor {
656
666
  * fine since the view consumable will contain a consumable `margin-left` item (thanks to the relation) and
657
667
  * `element.getStyle( 'margin-left' )` will work as well assuming that the style processor was correctly configured.
658
668
  * However, once `margin-left` is consumed, `margin` will not be consumable anymore.
659
- *
660
- * @param {String} shorthandName
661
- * @param {Array.<String>} styleNames
662
669
  */
663
670
  setStyleRelation(shorthandName, styleNames) {
664
671
  this._mapStyleNames(shorthandName, styleNames);
@@ -668,10 +675,6 @@ export class StylesProcessor {
668
675
  }
669
676
  /**
670
677
  * Set two-way binding of style names.
671
- *
672
- * @param {String} name
673
- * @param {Array.<String>} styleNames
674
- * @private
675
678
  */
676
679
  _mapStyleNames(name, styleNames) {
677
680
  if (!this._consumables.has(name)) {
@@ -680,10 +683,12 @@ export class StylesProcessor {
680
683
  this._consumables.get(name).push(...styleNames);
681
684
  }
682
685
  }
683
- // Parses inline styles and puts property - value pairs into styles map.
684
- //
685
- // @param {String} stylesString Styles to parse.
686
- // @returns {Map.<String, String>} stylesMap Map of parsed properties and values.
686
+ /**
687
+ * Parses inline styles and puts property - value pairs into styles map.
688
+ *
689
+ * @param stylesString Styles to parse.
690
+ * @returns Map of parsed properties and values.
691
+ */
687
692
  function parseInlineStyles(stylesString) {
688
693
  // `null` if no quote was found in input string or last found quote was a closing quote. See below.
689
694
  let quoteType = null;
@@ -743,15 +748,15 @@ function parseInlineStyles(stylesString) {
743
748
  }
744
749
  return stylesMap;
745
750
  }
746
- // Return lodash compatible path from style name.
751
+ /**
752
+ * Return lodash compatible path from style name.
753
+ */
747
754
  function toPath(name) {
748
755
  return name.replace('-', '.');
749
756
  }
750
- // Appends style definition to the styles object.
751
- //
752
- // @param {String} nameOrPath
753
- // @param {String|Object} valueOrObject
754
- // @private
757
+ /**
758
+ * Appends style definition to the styles object.
759
+ */
755
760
  function appendStyleValue(stylesObject, nameOrPath, valueOrObject) {
756
761
  let valueToSet = valueOrObject;
757
762
  if (isObject(valueOrObject)) {