@ckeditor/ckeditor5-html-support 36.0.1 → 37.0.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.
Files changed (46) hide show
  1. package/build/html-support.js +1 -1
  2. package/package.json +42 -36
  3. package/src/conversionutils.d.ts +42 -0
  4. package/src/conversionutils.js +57 -77
  5. package/src/converters.d.ts +56 -0
  6. package/src/converters.js +104 -156
  7. package/src/datafilter.d.ts +255 -0
  8. package/src/datafilter.js +566 -782
  9. package/src/dataschema.d.ts +174 -0
  10. package/src/dataschema.js +143 -229
  11. package/src/fullpage.d.ts +26 -0
  12. package/src/fullpage.js +65 -86
  13. package/src/generalhtmlsupport.d.ts +93 -0
  14. package/src/generalhtmlsupport.js +244 -327
  15. package/src/generalhtmlsupportconfig.d.ts +76 -0
  16. package/src/generalhtmlsupportconfig.js +5 -0
  17. package/src/htmlcomment.d.ts +77 -0
  18. package/src/htmlcomment.js +175 -239
  19. package/src/htmlpagedataprocessor.d.ts +22 -0
  20. package/src/htmlpagedataprocessor.js +53 -76
  21. package/src/index.d.ts +13 -0
  22. package/src/index.js +0 -2
  23. package/src/integrations/codeblock.d.ts +27 -0
  24. package/src/integrations/codeblock.js +87 -115
  25. package/src/integrations/customelement.d.ts +30 -0
  26. package/src/integrations/customelement.js +127 -160
  27. package/src/integrations/documentlist.d.ts +31 -0
  28. package/src/integrations/documentlist.js +154 -191
  29. package/src/integrations/dualcontent.d.ts +49 -0
  30. package/src/integrations/dualcontent.js +92 -128
  31. package/src/integrations/heading.d.ts +30 -0
  32. package/src/integrations/heading.js +41 -54
  33. package/src/integrations/image.d.ts +30 -0
  34. package/src/integrations/image.js +154 -212
  35. package/src/integrations/integrationutils.d.ts +15 -0
  36. package/src/integrations/integrationutils.js +21 -0
  37. package/src/integrations/mediaembed.d.ts +30 -0
  38. package/src/integrations/mediaembed.js +101 -147
  39. package/src/integrations/script.d.ts +30 -0
  40. package/src/integrations/script.js +45 -67
  41. package/src/integrations/style.d.ts +30 -0
  42. package/src/integrations/style.js +45 -67
  43. package/src/integrations/table.d.ts +27 -0
  44. package/src/integrations/table.js +113 -160
  45. package/src/schemadefinitions.d.ts +13 -0
  46. package/src/schemadefinitions.js +846 -835
package/src/fullpage.js CHANGED
@@ -2,100 +2,79 @@
2
2
  * @license Copyright (c) 2003-2023, 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
-
6
5
  /**
7
6
  * @module html-support/fullpage
8
7
  */
9
-
10
8
  import { Plugin } from 'ckeditor5/src/core';
11
9
  import { UpcastWriter } from 'ckeditor5/src/engine';
12
10
  import HtmlPageDataProcessor from './htmlpagedataprocessor';
13
-
14
11
  /**
15
12
  * The full page editing feature. It preserves the whole HTML page in the editor data.
16
- *
17
- * @extends module:core/plugin~Plugin
18
13
  */
19
14
  export default class FullPage extends Plugin {
20
- /**
21
- * @inheritDoc
22
- */
23
- static get pluginName() {
24
- return 'FullPage';
25
- }
26
-
27
- /**
28
- * @inheritDoc
29
- */
30
- init() {
31
- const editor = this.editor;
32
- const properties = [ '$fullPageDocument', '$fullPageDocType', '$fullPageXmlDeclaration' ];
33
-
34
- editor.data.processor = new HtmlPageDataProcessor( editor.data.viewDocument );
35
-
36
- editor.model.schema.extend( '$root', {
37
- allowAttributes: properties
38
- } );
39
-
40
- // Apply custom properties from view document fragment to the model root attributes.
41
- editor.data.on( 'toModel', ( evt, [ viewElementOrFragment ] ) => {
42
- const root = editor.model.document.getRoot();
43
-
44
- editor.model.change( writer => {
45
- for ( const name of properties ) {
46
- const value = viewElementOrFragment.getCustomProperty( name );
47
-
48
- if ( value ) {
49
- writer.setAttribute( name, value, root );
50
- }
51
- }
52
- } );
53
- }, { priority: 'low' } );
54
-
55
- // Apply root attributes to the view document fragment.
56
- editor.data.on( 'toView', ( evt, [ modelElementOrFragment ] ) => {
57
- if ( !modelElementOrFragment.is( 'rootElement' ) ) {
58
- return;
59
- }
60
-
61
- const root = modelElementOrFragment;
62
- const viewFragment = evt.return;
63
-
64
- if ( !root.hasAttribute( '$fullPageDocument' ) ) {
65
- return;
66
- }
67
-
68
- const writer = new UpcastWriter( viewFragment.document );
69
-
70
- for ( const name of properties ) {
71
- const value = root.getAttribute( name );
72
-
73
- if ( value ) {
74
- writer.setCustomProperty( name, value, viewFragment );
75
- }
76
- }
77
- }, { priority: 'low' } );
78
-
79
- // Clear root attributes related to full page editing on editor content reset.
80
- editor.data.on( 'set', () => {
81
- const root = editor.model.document.getRoot();
82
-
83
- editor.model.change( writer => {
84
- for ( const name of properties ) {
85
- if ( root.hasAttribute( name ) ) {
86
- writer.removeAttribute( name, root );
87
- }
88
- }
89
- } );
90
- }, { priority: 'high' } );
91
-
92
- // Make sure that document is returned even if there is no content in the page body.
93
- editor.data.on( 'get', ( evt, args ) => {
94
- if ( !args[ 0 ] ) {
95
- args[ 0 ] = {};
96
- }
97
-
98
- args[ 0 ].trim = false;
99
- }, { priority: 'high' } );
100
- }
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ static get pluginName() {
19
+ return 'FullPage';
20
+ }
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ init() {
25
+ const editor = this.editor;
26
+ const properties = ['$fullPageDocument', '$fullPageDocType', '$fullPageXmlDeclaration'];
27
+ editor.data.processor = new HtmlPageDataProcessor(editor.data.viewDocument);
28
+ editor.model.schema.extend('$root', {
29
+ allowAttributes: properties
30
+ });
31
+ // Apply custom properties from view document fragment to the model root attributes.
32
+ editor.data.on('toModel', (evt, [viewElementOrFragment]) => {
33
+ const root = editor.model.document.getRoot();
34
+ editor.model.change(writer => {
35
+ for (const name of properties) {
36
+ const value = viewElementOrFragment.getCustomProperty(name);
37
+ if (value) {
38
+ writer.setAttribute(name, value, root);
39
+ }
40
+ }
41
+ });
42
+ }, { priority: 'low' });
43
+ // Apply root attributes to the view document fragment.
44
+ editor.data.on('toView', (evt, [modelElementOrFragment]) => {
45
+ if (!modelElementOrFragment.is('rootElement')) {
46
+ return;
47
+ }
48
+ const root = modelElementOrFragment;
49
+ const viewFragment = evt.return;
50
+ if (!root.hasAttribute('$fullPageDocument')) {
51
+ return;
52
+ }
53
+ const writer = new UpcastWriter(viewFragment.document);
54
+ for (const name of properties) {
55
+ const value = root.getAttribute(name);
56
+ if (value) {
57
+ writer.setCustomProperty(name, value, viewFragment);
58
+ }
59
+ }
60
+ }, { priority: 'low' });
61
+ // Clear root attributes related to full page editing on editor content reset.
62
+ editor.data.on('set', () => {
63
+ const root = editor.model.document.getRoot();
64
+ editor.model.change(writer => {
65
+ for (const name of properties) {
66
+ if (root.hasAttribute(name)) {
67
+ writer.removeAttribute(name, root);
68
+ }
69
+ }
70
+ });
71
+ }, { priority: 'high' });
72
+ // Make sure that document is returned even if there is no content in the page body.
73
+ editor.data.on('get', (evt, args) => {
74
+ if (!args[0]) {
75
+ args[0] = {};
76
+ }
77
+ args[0].trim = false;
78
+ }, { priority: 'high' });
79
+ }
101
80
  }
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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 html-support/generalhtmlsupport
7
+ */
8
+ import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
9
+ import { type ArrayOrItem } from 'ckeditor5/src/utils';
10
+ import type { Range, Selectable } from 'ckeditor5/src/engine';
11
+ type LimitedSelectable = Exclude<Selectable, Iterable<Range> | null>;
12
+ /**
13
+ * The General HTML Support feature.
14
+ *
15
+ * This is a "glue" plugin which initializes the {@link module:html-support/datafilter~DataFilter data filter} configuration
16
+ * and features integration with the General HTML Support.
17
+ */
18
+ export default class GeneralHtmlSupport extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName(): 'GeneralHtmlSupport';
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get requires(): PluginDependencies;
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ init(): void;
31
+ /**
32
+ * Returns a GHS model attribute name related to a given view element name.
33
+ *
34
+ * @param viewElementName A view element name.
35
+ */
36
+ private getGhsAttributeNameForElement;
37
+ /**
38
+ * Updates GHS model attribute for a specified view element name, so it includes the given class name.
39
+ *
40
+ * @internal
41
+ * @param viewElementName A view element name.
42
+ * @param className The css class to add.
43
+ * @param selectable The selection or element to update.
44
+ */
45
+ addModelHtmlClass(viewElementName: string, className: ArrayOrItem<string>, selectable: LimitedSelectable): void;
46
+ /**
47
+ * Updates GHS model attribute for a specified view element name, so it does not include the given class name.
48
+ *
49
+ * @internal
50
+ * @param viewElementName A view element name.
51
+ * @param className The css class to remove.
52
+ * @param selectable The selection or element to update.
53
+ */
54
+ removeModelHtmlClass(viewElementName: string, className: ArrayOrItem<string>, selectable: LimitedSelectable): void;
55
+ /**
56
+ * Updates GHS model attribute for a specified view element name, so it includes the given attribute.
57
+ *
58
+ * @param viewElementName A view element name.
59
+ * @param attributes The object with attributes to set.
60
+ * @param selectable The selection or element to update.
61
+ */
62
+ private setModelHtmlAttributes;
63
+ /**
64
+ * Updates GHS model attribute for a specified view element name, so it does not include the given attribute.
65
+ *
66
+ * @param viewElementName A view element name.
67
+ * @param attributeName The attribute name (or names) to remove.
68
+ * @param selectable The selection or element to update.
69
+ */
70
+ private removeModelHtmlAttributes;
71
+ /**
72
+ * Updates GHS model attribute for a specified view element name, so it includes a given style.
73
+ *
74
+ * @param viewElementName A view element name.
75
+ * @param styles The object with styles to set.
76
+ * @param selectable The selection or element to update.
77
+ */
78
+ private setModelHtmlStyles;
79
+ /**
80
+ * Updates GHS model attribute for a specified view element name, so it does not include a given style.
81
+ *
82
+ * @param viewElementName A view element name.
83
+ * @param properties The style (or styles list) to remove.
84
+ * @param selectable The selection or element to update.
85
+ */
86
+ private removeModelHtmlStyles;
87
+ }
88
+ declare module '@ckeditor/ckeditor5-core' {
89
+ interface PluginsMap {
90
+ [GeneralHtmlSupport.pluginName]: GeneralHtmlSupport;
91
+ }
92
+ }
93
+ export {};