@ckeditor/ckeditor5-paste-from-office 39.0.2 → 40.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 (36) hide show
  1. package/build/paste-from-office.js.map +1 -0
  2. package/package.json +2 -2
  3. package/src/augmentation.d.ts +10 -10
  4. package/src/augmentation.js +5 -5
  5. package/src/filters/br.d.ts +14 -14
  6. package/src/filters/br.js +65 -65
  7. package/src/filters/image.d.ts +24 -24
  8. package/src/filters/image.js +241 -241
  9. package/src/filters/list.d.ts +26 -26
  10. package/src/filters/list.js +395 -395
  11. package/src/filters/parse.d.ts +35 -35
  12. package/src/filters/parse.js +93 -93
  13. package/src/filters/removeboldwrapper.d.ts +14 -14
  14. package/src/filters/removeboldwrapper.js +18 -18
  15. package/src/filters/removegooglesheetstag.d.ts +14 -14
  16. package/src/filters/removegooglesheetstag.js +18 -18
  17. package/src/filters/removeinvalidtablewidth.d.ts +14 -14
  18. package/src/filters/removeinvalidtablewidth.js +16 -16
  19. package/src/filters/removestyleblock.d.ts +14 -14
  20. package/src/filters/removestyleblock.js +16 -16
  21. package/src/filters/removexmlns.d.ts +14 -14
  22. package/src/filters/removexmlns.js +16 -16
  23. package/src/filters/space.d.ts +25 -25
  24. package/src/filters/space.js +60 -60
  25. package/src/index.d.ts +12 -12
  26. package/src/index.js +11 -11
  27. package/src/normalizer.d.ts +30 -30
  28. package/src/normalizer.js +5 -5
  29. package/src/normalizers/googledocsnormalizer.d.ts +29 -29
  30. package/src/normalizers/googledocsnormalizer.js +42 -42
  31. package/src/normalizers/googlesheetsnormalizer.d.ts +29 -29
  32. package/src/normalizers/googlesheetsnormalizer.js +44 -44
  33. package/src/normalizers/mswordnormalizer.d.ts +26 -26
  34. package/src/normalizers/mswordnormalizer.js +39 -39
  35. package/src/pastefromoffice.d.ts +36 -36
  36. package/src/pastefromoffice.js +70 -70
@@ -1,39 +1,39 @@
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 paste-from-office/normalizers/mswordnormalizer
7
- */
8
- import { transformListItemLikeElementsIntoLists } from '../filters/list';
9
- import { replaceImagesSourceWithBase64 } from '../filters/image';
10
- const msWordMatch1 = /<meta\s*name="?generator"?\s*content="?microsoft\s*word\s*\d+"?\/?>/i;
11
- const msWordMatch2 = /xmlns:o="urn:schemas-microsoft-com/i;
12
- /**
13
- * Normalizer for the content pasted from Microsoft Word.
14
- */
15
- export default class MSWordNormalizer {
16
- /**
17
- * Creates a new `MSWordNormalizer` instance.
18
- *
19
- * @param document View document.
20
- */
21
- constructor(document) {
22
- this.document = document;
23
- }
24
- /**
25
- * @inheritDoc
26
- */
27
- isActive(htmlString) {
28
- return msWordMatch1.test(htmlString) || msWordMatch2.test(htmlString);
29
- }
30
- /**
31
- * @inheritDoc
32
- */
33
- execute(data) {
34
- const { body: documentFragment, stylesString } = data._parsedData;
35
- transformListItemLikeElementsIntoLists(documentFragment, stylesString);
36
- replaceImagesSourceWithBase64(documentFragment, data.dataTransfer.getData('text/rtf'));
37
- data.content = documentFragment;
38
- }
39
- }
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 paste-from-office/normalizers/mswordnormalizer
7
+ */
8
+ import { transformListItemLikeElementsIntoLists } from '../filters/list';
9
+ import { replaceImagesSourceWithBase64 } from '../filters/image';
10
+ const msWordMatch1 = /<meta\s*name="?generator"?\s*content="?microsoft\s*word\s*\d+"?\/?>/i;
11
+ const msWordMatch2 = /xmlns:o="urn:schemas-microsoft-com/i;
12
+ /**
13
+ * Normalizer for the content pasted from Microsoft Word.
14
+ */
15
+ export default class MSWordNormalizer {
16
+ /**
17
+ * Creates a new `MSWordNormalizer` instance.
18
+ *
19
+ * @param document View document.
20
+ */
21
+ constructor(document) {
22
+ this.document = document;
23
+ }
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ isActive(htmlString) {
28
+ return msWordMatch1.test(htmlString) || msWordMatch2.test(htmlString);
29
+ }
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ execute(data) {
34
+ const { body: documentFragment, stylesString } = data._parsedData;
35
+ transformListItemLikeElementsIntoLists(documentFragment, stylesString);
36
+ replaceImagesSourceWithBase64(documentFragment, data.dataTransfer.getData('text/rtf'));
37
+ data.content = documentFragment;
38
+ }
39
+ }
@@ -1,36 +1,36 @@
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 paste-from-office/pastefromoffice
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import { ClipboardPipeline } from 'ckeditor5/src/clipboard';
10
- /**
11
- * The Paste from Office plugin.
12
- *
13
- * This plugin handles content pasted from Office apps and transforms it (if necessary)
14
- * to a valid structure which can then be understood by the editor features.
15
- *
16
- * Transformation is made by a set of predefined {@link module:paste-from-office/normalizer~Normalizer normalizers}.
17
- * This plugin includes following normalizers:
18
- * * {@link module:paste-from-office/normalizers/mswordnormalizer~MSWordNormalizer Microsoft Word normalizer}
19
- * * {@link module:paste-from-office/normalizers/googledocsnormalizer~GoogleDocsNormalizer Google Docs normalizer}
20
- *
21
- * For more information about this feature check the {@glink api/paste-from-office package page}.
22
- */
23
- export default class PasteFromOffice extends Plugin {
24
- /**
25
- * @inheritDoc
26
- */
27
- static get pluginName(): "PasteFromOffice";
28
- /**
29
- * @inheritDoc
30
- */
31
- static get requires(): readonly [typeof ClipboardPipeline];
32
- /**
33
- * @inheritDoc
34
- */
35
- init(): void;
36
- }
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 paste-from-office/pastefromoffice
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import { ClipboardPipeline } from 'ckeditor5/src/clipboard';
10
+ /**
11
+ * The Paste from Office plugin.
12
+ *
13
+ * This plugin handles content pasted from Office apps and transforms it (if necessary)
14
+ * to a valid structure which can then be understood by the editor features.
15
+ *
16
+ * Transformation is made by a set of predefined {@link module:paste-from-office/normalizer~Normalizer normalizers}.
17
+ * This plugin includes following normalizers:
18
+ * * {@link module:paste-from-office/normalizers/mswordnormalizer~MSWordNormalizer Microsoft Word normalizer}
19
+ * * {@link module:paste-from-office/normalizers/googledocsnormalizer~GoogleDocsNormalizer Google Docs normalizer}
20
+ *
21
+ * For more information about this feature check the {@glink api/paste-from-office package page}.
22
+ */
23
+ export default class PasteFromOffice extends Plugin {
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ static get pluginName(): "PasteFromOffice";
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ static get requires(): readonly [typeof ClipboardPipeline];
32
+ /**
33
+ * @inheritDoc
34
+ */
35
+ init(): void;
36
+ }
@@ -1,70 +1,70 @@
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 paste-from-office/pastefromoffice
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import { ClipboardPipeline } from 'ckeditor5/src/clipboard';
10
- import MSWordNormalizer from './normalizers/mswordnormalizer';
11
- import GoogleDocsNormalizer from './normalizers/googledocsnormalizer';
12
- import GoogleSheetsNormalizer from './normalizers/googlesheetsnormalizer';
13
- import { parseHtml } from './filters/parse';
14
- /**
15
- * The Paste from Office plugin.
16
- *
17
- * This plugin handles content pasted from Office apps and transforms it (if necessary)
18
- * to a valid structure which can then be understood by the editor features.
19
- *
20
- * Transformation is made by a set of predefined {@link module:paste-from-office/normalizer~Normalizer normalizers}.
21
- * This plugin includes following normalizers:
22
- * * {@link module:paste-from-office/normalizers/mswordnormalizer~MSWordNormalizer Microsoft Word normalizer}
23
- * * {@link module:paste-from-office/normalizers/googledocsnormalizer~GoogleDocsNormalizer Google Docs normalizer}
24
- *
25
- * For more information about this feature check the {@glink api/paste-from-office package page}.
26
- */
27
- export default class PasteFromOffice extends Plugin {
28
- /**
29
- * @inheritDoc
30
- */
31
- static get pluginName() {
32
- return 'PasteFromOffice';
33
- }
34
- /**
35
- * @inheritDoc
36
- */
37
- static get requires() {
38
- return [ClipboardPipeline];
39
- }
40
- /**
41
- * @inheritDoc
42
- */
43
- init() {
44
- const editor = this.editor;
45
- const clipboardPipeline = editor.plugins.get('ClipboardPipeline');
46
- const viewDocument = editor.editing.view.document;
47
- const normalizers = [];
48
- normalizers.push(new MSWordNormalizer(viewDocument));
49
- normalizers.push(new GoogleDocsNormalizer(viewDocument));
50
- normalizers.push(new GoogleSheetsNormalizer(viewDocument));
51
- clipboardPipeline.on('inputTransformation', (evt, data) => {
52
- if (data._isTransformedWithPasteFromOffice) {
53
- return;
54
- }
55
- const codeBlock = editor.model.document.selection.getFirstPosition().parent;
56
- if (codeBlock.is('element', 'codeBlock')) {
57
- return;
58
- }
59
- const htmlString = data.dataTransfer.getData('text/html');
60
- const activeNormalizer = normalizers.find(normalizer => normalizer.isActive(htmlString));
61
- if (activeNormalizer) {
62
- if (!data._parsedData) {
63
- data._parsedData = parseHtml(htmlString, viewDocument.stylesProcessor);
64
- }
65
- activeNormalizer.execute(data);
66
- data._isTransformedWithPasteFromOffice = true;
67
- }
68
- }, { priority: 'high' });
69
- }
70
- }
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 paste-from-office/pastefromoffice
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import { ClipboardPipeline } from 'ckeditor5/src/clipboard';
10
+ import MSWordNormalizer from './normalizers/mswordnormalizer';
11
+ import GoogleDocsNormalizer from './normalizers/googledocsnormalizer';
12
+ import GoogleSheetsNormalizer from './normalizers/googlesheetsnormalizer';
13
+ import { parseHtml } from './filters/parse';
14
+ /**
15
+ * The Paste from Office plugin.
16
+ *
17
+ * This plugin handles content pasted from Office apps and transforms it (if necessary)
18
+ * to a valid structure which can then be understood by the editor features.
19
+ *
20
+ * Transformation is made by a set of predefined {@link module:paste-from-office/normalizer~Normalizer normalizers}.
21
+ * This plugin includes following normalizers:
22
+ * * {@link module:paste-from-office/normalizers/mswordnormalizer~MSWordNormalizer Microsoft Word normalizer}
23
+ * * {@link module:paste-from-office/normalizers/googledocsnormalizer~GoogleDocsNormalizer Google Docs normalizer}
24
+ *
25
+ * For more information about this feature check the {@glink api/paste-from-office package page}.
26
+ */
27
+ export default class PasteFromOffice extends Plugin {
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ static get pluginName() {
32
+ return 'PasteFromOffice';
33
+ }
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ static get requires() {
38
+ return [ClipboardPipeline];
39
+ }
40
+ /**
41
+ * @inheritDoc
42
+ */
43
+ init() {
44
+ const editor = this.editor;
45
+ const clipboardPipeline = editor.plugins.get('ClipboardPipeline');
46
+ const viewDocument = editor.editing.view.document;
47
+ const normalizers = [];
48
+ normalizers.push(new MSWordNormalizer(viewDocument));
49
+ normalizers.push(new GoogleDocsNormalizer(viewDocument));
50
+ normalizers.push(new GoogleSheetsNormalizer(viewDocument));
51
+ clipboardPipeline.on('inputTransformation', (evt, data) => {
52
+ if (data._isTransformedWithPasteFromOffice) {
53
+ return;
54
+ }
55
+ const codeBlock = editor.model.document.selection.getFirstPosition().parent;
56
+ if (codeBlock.is('element', 'codeBlock')) {
57
+ return;
58
+ }
59
+ const htmlString = data.dataTransfer.getData('text/html');
60
+ const activeNormalizer = normalizers.find(normalizer => normalizer.isActive(htmlString));
61
+ if (activeNormalizer) {
62
+ if (!data._parsedData) {
63
+ data._parsedData = parseHtml(htmlString, viewDocument.stylesProcessor);
64
+ }
65
+ activeNormalizer.execute(data);
66
+ data._isTransformedWithPasteFromOffice = true;
67
+ }
68
+ }, { priority: 'high' });
69
+ }
70
+ }