@ckeditor/ckeditor5-html-support 31.1.0 → 34.0.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.
Files changed (49) hide show
  1. package/LICENSE.md +2 -2
  2. package/README.md +2 -1
  3. package/build/html-support.js +3 -3
  4. package/build/html-support.js.map +1 -0
  5. package/build/translations/cs.js +1 -0
  6. package/build/translations/el.js +1 -0
  7. package/build/translations/en-au.js +1 -0
  8. package/build/translations/hr.js +1 -0
  9. package/build/translations/jv.js +1 -0
  10. package/build/translations/sk.js +1 -0
  11. package/lang/translations/cs.po +21 -0
  12. package/lang/translations/de.po +1 -1
  13. package/lang/translations/el.po +21 -0
  14. package/lang/translations/en-au.po +21 -0
  15. package/lang/translations/en.po +1 -1
  16. package/lang/translations/es.po +1 -1
  17. package/lang/translations/gl.po +1 -1
  18. package/lang/translations/hr.po +21 -0
  19. package/lang/translations/hu.po +1 -1
  20. package/lang/translations/id.po +1 -1
  21. package/lang/translations/it.po +1 -1
  22. package/lang/translations/jv.po +21 -0
  23. package/lang/translations/nl.po +1 -1
  24. package/lang/translations/pl.po +1 -1
  25. package/lang/translations/pt-br.po +1 -1
  26. package/lang/translations/ru.po +1 -1
  27. package/lang/translations/sk.po +21 -0
  28. package/lang/translations/sr-latn.po +1 -1
  29. package/lang/translations/sr.po +1 -1
  30. package/lang/translations/zh.po +1 -1
  31. package/package.json +34 -34
  32. package/src/conversionutils.js +49 -6
  33. package/src/converters.js +27 -19
  34. package/src/datafilter.js +17 -7
  35. package/src/dataschema.js +1 -1
  36. package/src/generalhtmlsupport.js +234 -2
  37. package/src/htmlcomment.js +1 -1
  38. package/src/index.js +1 -1
  39. package/src/integrations/codeblock.js +6 -4
  40. package/src/integrations/documentlist.js +200 -0
  41. package/src/integrations/dualcontent.js +1 -1
  42. package/src/integrations/heading.js +1 -1
  43. package/src/integrations/image.js +29 -18
  44. package/src/integrations/mediaembed.js +4 -3
  45. package/src/integrations/script.js +74 -0
  46. package/src/integrations/style.js +74 -0
  47. package/src/integrations/table.js +1 -1
  48. package/src/schemadefinitions.js +65 -69
  49. package/theme/datafilter.css +5 -0
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2022, 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
+ /**
7
+ * @module html-support/integrations/script
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import {
12
+ createObjectView,
13
+ modelToViewBlockAttributeConverter,
14
+ viewToModelBlockAttributeConverter,
15
+ viewToModelObjectConverter
16
+ } from '../converters.js';
17
+
18
+ import DataFilter from '../datafilter';
19
+
20
+ /**
21
+ * Provides the General HTML Support for `script` elements.
22
+ *
23
+ * @extends module:core/plugin~Plugin
24
+ */
25
+ export default class ScriptElementSupport extends Plugin {
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get requires() {
30
+ return [ DataFilter ];
31
+ }
32
+
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ init() {
37
+ const dataFilter = this.editor.plugins.get( DataFilter );
38
+
39
+ dataFilter.on( 'register:script', ( evt, definition ) => {
40
+ const editor = this.editor;
41
+ const schema = editor.model.schema;
42
+ const conversion = editor.conversion;
43
+
44
+ schema.register( 'htmlScript', definition.modelSchema );
45
+
46
+ schema.extend( 'htmlScript', {
47
+ allowAttributes: [ 'htmlAttributes', 'htmlContent' ],
48
+ isContent: true
49
+ } );
50
+
51
+ editor.data.registerRawContentMatcher( {
52
+ name: 'script'
53
+ } );
54
+
55
+ conversion.for( 'upcast' ).elementToElement( {
56
+ view: 'script',
57
+ model: viewToModelObjectConverter( definition )
58
+ } );
59
+
60
+ conversion.for( 'upcast' ).add( viewToModelBlockAttributeConverter( definition, dataFilter ) );
61
+
62
+ conversion.for( 'downcast' ).elementToElement( {
63
+ model: 'htmlScript',
64
+ view: ( modelElement, { writer } ) => {
65
+ return createObjectView( 'script', modelElement, writer );
66
+ }
67
+ } );
68
+
69
+ conversion.for( 'downcast' ).add( modelToViewBlockAttributeConverter( definition ) );
70
+
71
+ evt.stop();
72
+ } );
73
+ }
74
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2022, 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
+ /**
7
+ * @module html-support/integrations/style
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import {
12
+ createObjectView,
13
+ modelToViewBlockAttributeConverter,
14
+ viewToModelBlockAttributeConverter,
15
+ viewToModelObjectConverter
16
+ } from '../converters.js';
17
+
18
+ import DataFilter from '../datafilter';
19
+
20
+ /**
21
+ * Provides the General HTML Support for `style` elements.
22
+ *
23
+ * @extends module:core/plugin~Plugin
24
+ */
25
+ export default class StyleElementSupport extends Plugin {
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get requires() {
30
+ return [ DataFilter ];
31
+ }
32
+
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ init() {
37
+ const dataFilter = this.editor.plugins.get( DataFilter );
38
+
39
+ dataFilter.on( 'register:style', ( evt, definition ) => {
40
+ const editor = this.editor;
41
+ const schema = editor.model.schema;
42
+ const conversion = editor.conversion;
43
+
44
+ schema.register( 'htmlStyle', definition.modelSchema );
45
+
46
+ schema.extend( 'htmlStyle', {
47
+ allowAttributes: [ 'htmlAttributes', 'htmlContent' ],
48
+ isContent: true
49
+ } );
50
+
51
+ editor.data.registerRawContentMatcher( {
52
+ name: 'style'
53
+ } );
54
+
55
+ conversion.for( 'upcast' ).elementToElement( {
56
+ view: 'style',
57
+ model: viewToModelObjectConverter( definition )
58
+ } );
59
+
60
+ conversion.for( 'upcast' ).add( viewToModelBlockAttributeConverter( definition, dataFilter ) );
61
+
62
+ conversion.for( 'downcast' ).elementToElement( {
63
+ model: 'htmlStyle',
64
+ view: ( modelElement, { writer } ) => {
65
+ return createObjectView( 'style', modelElement, writer );
66
+ }
67
+ } );
68
+
69
+ conversion.for( 'downcast' ).add( modelToViewBlockAttributeConverter( definition ) );
70
+
71
+ evt.stop();
72
+ } );
73
+ }
74
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
@@ -46,7 +46,6 @@
46
46
  //
47
47
  // Skipped hidden elements:
48
48
  // noscript
49
- // script
50
49
 
51
50
  export default {
52
51
  block: [
@@ -109,14 +108,6 @@ export default {
109
108
  },
110
109
 
111
110
  // Compatibility features
112
- {
113
- model: '$htmlSection',
114
- modelSchema: {
115
- allowChildren: '$block',
116
- allowIn: [ '$root', '$htmlSection' ],
117
- isBlock: true
118
- }
119
- },
120
111
  {
121
112
  model: 'htmlP',
122
113
  view: 'p',
@@ -128,14 +119,14 @@ export default {
128
119
  model: 'htmlBlockquote',
129
120
  view: 'blockquote',
130
121
  modelSchema: {
131
- inheritAllFrom: '$htmlSection'
122
+ inheritAllFrom: '$container'
132
123
  }
133
124
  },
134
125
  {
135
126
  model: 'htmlTable',
136
127
  view: 'table',
137
128
  modelSchema: {
138
- allowIn: [ '$htmlSection', '$root' ],
129
+ allowWhere: '$block',
139
130
  isBlock: true
140
131
  }
141
132
  },
@@ -176,8 +167,7 @@ export default {
176
167
  model: 'htmlTr',
177
168
  view: 'tr',
178
169
  modelSchema: {
179
- allowIn: [ 'htmlTable', 'htmlThead', 'htmlTbody' ],
180
- isBlock: true
170
+ allowIn: [ 'htmlTable', 'htmlThead', 'htmlTbody' ]
181
171
  }
182
172
  },
183
173
  // TODO can also include text.
@@ -186,8 +176,7 @@ export default {
186
176
  view: 'td',
187
177
  modelSchema: {
188
178
  allowIn: 'htmlTr',
189
- allowChildren: [ '$block', '$htmlSection' ],
190
- isBlock: true
179
+ allowContentOf: '$container'
191
180
  }
192
181
  },
193
182
  // TODO can also include text.
@@ -196,8 +185,7 @@ export default {
196
185
  view: 'th',
197
186
  modelSchema: {
198
187
  allowIn: 'htmlTr',
199
- allowChildren: [ '$block', '$htmlSection' ],
200
- isBlock: true
188
+ allowContentOf: '$container'
201
189
  }
202
190
  },
203
191
  // TODO can also include text.
@@ -205,7 +193,7 @@ export default {
205
193
  model: 'htmlFigure',
206
194
  view: 'figure',
207
195
  modelSchema: {
208
- inheritAllFrom: '$htmlSection',
196
+ inheritAllFrom: '$container',
209
197
  isBlock: true
210
198
  }
211
199
  },
@@ -224,7 +212,8 @@ export default {
224
212
  model: 'htmlAddress',
225
213
  view: 'address',
226
214
  modelSchema: {
227
- inheritAllFrom: '$htmlSection'
215
+ inheritAllFrom: '$container',
216
+ isBlock: true
228
217
  }
229
218
  },
230
219
  // TODO can also include text.
@@ -232,7 +221,8 @@ export default {
232
221
  model: 'htmlAside',
233
222
  view: 'aside',
234
223
  modelSchema: {
235
- inheritAllFrom: '$htmlSection'
224
+ inheritAllFrom: '$container',
225
+ isBlock: true
236
226
  }
237
227
  },
238
228
  // TODO can also include text.
@@ -240,7 +230,8 @@ export default {
240
230
  model: 'htmlMain',
241
231
  view: 'main',
242
232
  modelSchema: {
243
- inheritAllFrom: '$htmlSection'
233
+ inheritAllFrom: '$container',
234
+ isBlock: true
244
235
  }
245
236
  },
246
237
  // TODO can also include text.
@@ -248,7 +239,8 @@ export default {
248
239
  model: 'htmlDetails',
249
240
  view: 'details',
250
241
  modelSchema: {
251
- inheritAllFrom: '$htmlSection'
242
+ inheritAllFrom: '$container',
243
+ isBlock: true
252
244
  }
253
245
  },
254
246
  {
@@ -265,7 +257,7 @@ export default {
265
257
  view: 'div',
266
258
  paragraphLikeModel: 'htmlDivParagraph',
267
259
  modelSchema: {
268
- inheritAllFrom: '$htmlSection'
260
+ inheritAllFrom: '$container'
269
261
  }
270
262
  },
271
263
  // TODO can also include text.
@@ -273,7 +265,8 @@ export default {
273
265
  model: 'htmlFieldset',
274
266
  view: 'fieldset',
275
267
  modelSchema: {
276
- inheritAllFrom: '$htmlSection'
268
+ inheritAllFrom: '$container',
269
+ isBlock: true
277
270
  }
278
271
  },
279
272
  // TODO can also include h1-h6.
@@ -290,7 +283,8 @@ export default {
290
283
  model: 'htmlHeader',
291
284
  view: 'header',
292
285
  modelSchema: {
293
- inheritAllFrom: '$htmlSection'
286
+ inheritAllFrom: '$container',
287
+ isBlock: true
294
288
  }
295
289
  },
296
290
  // TODO can also include text.
@@ -298,7 +292,8 @@ export default {
298
292
  model: 'htmlFooter',
299
293
  view: 'footer',
300
294
  modelSchema: {
301
- inheritAllFrom: '$htmlSection'
295
+ inheritAllFrom: '$container',
296
+ isBlock: true
302
297
  }
303
298
  },
304
299
  // TODO can also include text.
@@ -306,7 +301,8 @@ export default {
306
301
  model: 'htmlForm',
307
302
  view: 'form',
308
303
  modelSchema: {
309
- inheritAllFrom: '$htmlSection'
304
+ inheritAllFrom: '$container',
305
+ isBlock: true
310
306
  }
311
307
  },
312
308
  {
@@ -369,7 +365,7 @@ export default {
369
365
  {
370
366
  model: '$htmlList',
371
367
  modelSchema: {
372
- allowWhere: '$htmlSection',
368
+ allowWhere: '$container',
373
369
  allowChildren: [ '$htmlList', 'htmlLi' ],
374
370
  isBlock: true
375
371
  }
@@ -423,14 +419,16 @@ export default {
423
419
  model: 'htmlArticle',
424
420
  view: 'article',
425
421
  modelSchema: {
426
- inheritAllFrom: '$htmlSection'
422
+ inheritAllFrom: '$container',
423
+ isBlock: true
427
424
  }
428
425
  },
429
426
  {
430
427
  model: 'htmlSection',
431
428
  view: 'section',
432
429
  modelSchema: {
433
- inheritAllFrom: '$htmlSection'
430
+ inheritAllFrom: '$container',
431
+ isBlock: true
434
432
  }
435
433
  },
436
434
  // TODO can also include text.
@@ -438,14 +436,15 @@ export default {
438
436
  model: 'htmlNav',
439
437
  view: 'nav',
440
438
  modelSchema: {
441
- inheritAllFrom: '$htmlSection'
439
+ inheritAllFrom: '$container',
440
+ isBlock: true
442
441
  }
443
442
  },
444
443
  {
445
444
  model: 'htmlDl',
446
445
  view: 'dl',
447
446
  modelSchema: {
448
- allowIn: [ '$htmlSection', '$root' ],
447
+ allowWhere: '$container',
449
448
  allowChildren: [ 'htmlDt', 'htmlDd' ],
450
449
  isBlock: true
451
450
  }
@@ -470,17 +469,8 @@ export default {
470
469
  model: 'htmlCenter',
471
470
  view: 'center',
472
471
  modelSchema: {
473
- inheritAllFrom: '$htmlSection'
474
- }
475
- },
476
- // Objects
477
- {
478
- model: '$htmlObjectBlock',
479
- isObject: true,
480
- modelSchema: {
481
- isObject: true,
482
- isBlock: true,
483
- allowWhere: '$block'
472
+ inheritAllFrom: '$container',
473
+ isBlock: true
484
474
  }
485
475
  }
486
476
  ],
@@ -707,22 +697,12 @@ export default {
707
697
  },
708
698
 
709
699
  // Objects
710
- {
711
- model: '$htmlObjectInline',
712
- isObject: true,
713
- modelSchema: {
714
- isObject: true,
715
- isInline: true,
716
- allowWhere: '$text',
717
- allowAttributesOf: '$text'
718
- }
719
- },
720
700
  {
721
701
  model: 'htmlObject',
722
702
  view: 'object',
723
703
  isObject: true,
724
704
  modelSchema: {
725
- inheritAllFrom: '$htmlObjectInline'
705
+ inheritAllFrom: '$inlineObject'
726
706
  }
727
707
  },
728
708
  {
@@ -730,7 +710,7 @@ export default {
730
710
  view: 'iframe',
731
711
  isObject: true,
732
712
  modelSchema: {
733
- inheritAllFrom: '$htmlObjectInline'
713
+ inheritAllFrom: '$inlineObject'
734
714
  }
735
715
  },
736
716
  {
@@ -738,7 +718,7 @@ export default {
738
718
  view: 'input',
739
719
  isObject: true,
740
720
  modelSchema: {
741
- inheritAllFrom: '$htmlObjectInline'
721
+ inheritAllFrom: '$inlineObject'
742
722
  }
743
723
  },
744
724
  {
@@ -746,7 +726,7 @@ export default {
746
726
  view: 'button',
747
727
  isObject: true,
748
728
  modelSchema: {
749
- inheritAllFrom: '$htmlObjectInline'
729
+ inheritAllFrom: '$inlineObject'
750
730
  }
751
731
  },
752
732
  {
@@ -754,7 +734,7 @@ export default {
754
734
  view: 'textarea',
755
735
  isObject: true,
756
736
  modelSchema: {
757
- inheritAllFrom: '$htmlObjectInline'
737
+ inheritAllFrom: '$inlineObject'
758
738
  }
759
739
  },
760
740
  {
@@ -762,7 +742,7 @@ export default {
762
742
  view: 'select',
763
743
  isObject: true,
764
744
  modelSchema: {
765
- inheritAllFrom: '$htmlObjectInline'
745
+ inheritAllFrom: '$inlineObject'
766
746
  }
767
747
  },
768
748
  {
@@ -770,7 +750,7 @@ export default {
770
750
  view: 'video',
771
751
  isObject: true,
772
752
  modelSchema: {
773
- inheritAllFrom: '$htmlObjectInline'
753
+ inheritAllFrom: '$inlineObject'
774
754
  }
775
755
  },
776
756
  {
@@ -778,7 +758,7 @@ export default {
778
758
  view: 'embed',
779
759
  isObject: true,
780
760
  modelSchema: {
781
- inheritAllFrom: '$htmlObjectInline'
761
+ inheritAllFrom: '$inlineObject'
782
762
  }
783
763
  },
784
764
  {
@@ -786,7 +766,7 @@ export default {
786
766
  view: 'oembed',
787
767
  isObject: true,
788
768
  modelSchema: {
789
- inheritAllFrom: '$htmlObjectInline'
769
+ inheritAllFrom: '$inlineObject'
790
770
  }
791
771
  },
792
772
  {
@@ -794,7 +774,7 @@ export default {
794
774
  view: 'audio',
795
775
  isObject: true,
796
776
  modelSchema: {
797
- inheritAllFrom: '$htmlObjectInline'
777
+ inheritAllFrom: '$inlineObject'
798
778
  }
799
779
  },
800
780
  {
@@ -802,7 +782,7 @@ export default {
802
782
  view: 'img',
803
783
  isObject: true,
804
784
  modelSchema: {
805
- inheritAllFrom: '$htmlObjectInline'
785
+ inheritAllFrom: '$inlineObject'
806
786
  }
807
787
  },
808
788
  {
@@ -810,7 +790,7 @@ export default {
810
790
  view: 'canvas',
811
791
  isObject: true,
812
792
  modelSchema: {
813
- inheritAllFrom: '$htmlObjectInline'
793
+ inheritAllFrom: '$inlineObject'
814
794
  }
815
795
  },
816
796
  // TODO it could be probably represented as non-object element, although it has graphical representation,
@@ -820,17 +800,33 @@ export default {
820
800
  view: 'meter',
821
801
  isObject: true,
822
802
  modelSchema: {
823
- inheritAllFrom: '$htmlObjectInline'
803
+ inheritAllFrom: '$inlineObject'
824
804
  }
825
805
  },
826
- // TODO it could be probably represented as non-object element, although it has grafical representation,
806
+ // TODO it could be probably represented as non-object element, although it has graphical representation,
827
807
  // so probably makes more sense to keep it as an object.
828
808
  {
829
809
  model: 'htmlProgress',
830
810
  view: 'progress',
831
811
  isObject: true,
832
812
  modelSchema: {
833
- inheritAllFrom: '$htmlObjectInline'
813
+ inheritAllFrom: '$inlineObject'
814
+ }
815
+ },
816
+ {
817
+ model: 'htmlScript',
818
+ view: 'script',
819
+ modelSchema: {
820
+ allowWhere: [ '$text', '$block' ],
821
+ isInline: true
822
+ }
823
+ },
824
+ {
825
+ model: 'htmlStyle',
826
+ view: 'style',
827
+ modelSchema: {
828
+ allowWhere: [ '$text', '$block' ],
829
+ isInline: true
834
830
  }
835
831
  }
836
832
  ]
@@ -1,3 +1,8 @@
1
+ /*
2
+ * Copyright (c) 2003-2022, 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
+
1
6
  :root {
2
7
  --ck-html-object-embed-unfocused-outline-width: 1px;
3
8
  }