@ckeditor/ckeditor5-paste-from-office 47.6.1 → 48.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.
- package/ckeditor5-metadata.json +1 -1
- package/{src → dist}/filters/bookmark.d.ts +1 -1
- package/{src → dist}/filters/br.d.ts +1 -1
- package/{src → dist}/filters/image.d.ts +1 -1
- package/{src → dist}/filters/list.d.ts +1 -1
- package/{src → dist}/filters/parse.d.ts +1 -1
- package/{src → dist}/filters/removeboldwrapper.d.ts +1 -1
- package/{src → dist}/filters/removegooglesheetstag.d.ts +1 -1
- package/{src → dist}/filters/removeinvalidtablewidth.d.ts +1 -1
- package/{src → dist}/filters/removemsattributes.d.ts +1 -1
- package/{src → dist}/filters/removestyleblock.d.ts +1 -1
- package/{src → dist}/filters/removexmlns.d.ts +1 -1
- package/{src → dist}/filters/replacemsfootnotes.d.ts +1 -1
- package/{src → dist}/filters/replacetabswithinprewithspaces.d.ts +1 -1
- package/{src → dist}/filters/table.d.ts +2 -2
- package/dist/index.css +3 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +5 -8
- package/dist/index.js.map +1 -1
- package/{src → dist}/normalizer.d.ts +1 -1
- package/{src → dist}/normalizers/googledocsnormalizer.d.ts +1 -1
- package/{src → dist}/normalizers/googlesheetsnormalizer.d.ts +1 -1
- package/{src → dist}/normalizers/mswordnormalizer.d.ts +2 -3
- package/{src → dist}/pastefromoffice.d.ts +2 -2
- package/package.json +21 -43
- package/build/paste-from-office.js +0 -4
- package/src/augmentation.js +0 -5
- package/src/filters/bookmark.js +0 -25
- package/src/filters/br.js +0 -66
- package/src/filters/image.js +0 -263
- package/src/filters/list.js +0 -504
- package/src/filters/parse.js +0 -95
- package/src/filters/removeboldwrapper.js +0 -19
- package/src/filters/removegooglesheetstag.js +0 -19
- package/src/filters/removeinvalidtablewidth.js +0 -24
- package/src/filters/removemsattributes.js +0 -44
- package/src/filters/removestyleblock.js +0 -17
- package/src/filters/removexmlns.js +0 -17
- package/src/filters/replacemsfootnotes.js +0 -209
- package/src/filters/replacetabswithinprewithspaces.js +0 -63
- package/src/filters/space.js +0 -63
- package/src/filters/table.js +0 -77
- package/src/filters/utils.js +0 -52
- package/src/index.js +0 -26
- package/src/normalizer.js +0 -5
- package/src/normalizers/googledocsnormalizer.js +0 -47
- package/src/normalizers/googlesheetsnormalizer.js +0 -47
- package/src/normalizers/mswordnormalizer.js +0 -58
- package/src/pastefromoffice.js +0 -92
- /package/{src → dist}/augmentation.d.ts +0 -0
- /package/{src → dist}/filters/space.d.ts +0 -0
- /package/{src → dist}/filters/utils.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
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
|
-
/**
|
|
6
|
-
* @module paste-from-office/normalizers/googlesheetsnormalizer
|
|
7
|
-
*/
|
|
8
|
-
import { ViewUpcastWriter } from 'ckeditor5/src/engine.js';
|
|
9
|
-
import { removeXmlns } from '../filters/removexmlns.js';
|
|
10
|
-
import { removeGoogleSheetsTag } from '../filters/removegooglesheetstag.js';
|
|
11
|
-
import { removeInvalidTableWidth } from '../filters/removeinvalidtablewidth.js';
|
|
12
|
-
import { removeStyleBlock } from '../filters/removestyleblock.js';
|
|
13
|
-
const googleSheetsMatch = /<google-sheets-html-origin/i;
|
|
14
|
-
/**
|
|
15
|
-
* Normalizer for the content pasted from Google Sheets.
|
|
16
|
-
*
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
export class GoogleSheetsNormalizer {
|
|
20
|
-
document;
|
|
21
|
-
/**
|
|
22
|
-
* Creates a new `GoogleSheetsNormalizer` instance.
|
|
23
|
-
*
|
|
24
|
-
* @param document View document.
|
|
25
|
-
*/
|
|
26
|
-
constructor(document) {
|
|
27
|
-
this.document = document;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @inheritDoc
|
|
31
|
-
*/
|
|
32
|
-
isActive(htmlString) {
|
|
33
|
-
return googleSheetsMatch.test(htmlString);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @inheritDoc
|
|
37
|
-
*/
|
|
38
|
-
execute(data) {
|
|
39
|
-
const writer = new ViewUpcastWriter(this.document);
|
|
40
|
-
const { body: documentFragment } = data._parsedData;
|
|
41
|
-
removeGoogleSheetsTag(documentFragment, writer);
|
|
42
|
-
removeXmlns(documentFragment, writer);
|
|
43
|
-
removeInvalidTableWidth(documentFragment, writer);
|
|
44
|
-
removeStyleBlock(documentFragment, writer);
|
|
45
|
-
data.content = documentFragment;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
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
|
-
/**
|
|
6
|
-
* @module paste-from-office/normalizers/mswordnormalizer
|
|
7
|
-
*/
|
|
8
|
-
import { transformBookmarks } from '../filters/bookmark.js';
|
|
9
|
-
import { transformListItemLikeElementsIntoLists } from '../filters/list.js';
|
|
10
|
-
import { replaceImagesSourceWithBase64 } from '../filters/image.js';
|
|
11
|
-
import { removeMSAttributes } from '../filters/removemsattributes.js';
|
|
12
|
-
import { transformTables } from '../filters/table.js';
|
|
13
|
-
import { removeInvalidTableWidth } from '../filters/removeinvalidtablewidth.js';
|
|
14
|
-
import { replaceMSFootnotes } from '../filters/replacemsfootnotes.js';
|
|
15
|
-
import { ViewUpcastWriter } from 'ckeditor5/src/engine.js';
|
|
16
|
-
const msWordMatch1 = /<meta\s*name="?generator"?\s*content="?microsoft\s*word\s*\d+"?\/?>/i;
|
|
17
|
-
const msWordMatch2 = /xmlns:o="urn:schemas-microsoft-com/i;
|
|
18
|
-
/**
|
|
19
|
-
* Normalizer for the content pasted from Microsoft Word.
|
|
20
|
-
*/
|
|
21
|
-
export class PasteFromOfficeMSWordNormalizer {
|
|
22
|
-
document;
|
|
23
|
-
hasMultiLevelListPlugin;
|
|
24
|
-
hasTablePropertiesPlugin;
|
|
25
|
-
hasExtendedTableBlockAlignment;
|
|
26
|
-
/**
|
|
27
|
-
* Creates a new `PasteFromOfficeMSWordNormalizer` instance.
|
|
28
|
-
*
|
|
29
|
-
* @param document View document.
|
|
30
|
-
*/
|
|
31
|
-
constructor(document, hasMultiLevelListPlugin = false, hasTablePropertiesPlugin = false, hasExtendedTableBlockAlignment = false) {
|
|
32
|
-
this.document = document;
|
|
33
|
-
this.hasMultiLevelListPlugin = hasMultiLevelListPlugin;
|
|
34
|
-
this.hasTablePropertiesPlugin = hasTablePropertiesPlugin;
|
|
35
|
-
this.hasExtendedTableBlockAlignment = hasExtendedTableBlockAlignment;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* @inheritDoc
|
|
39
|
-
*/
|
|
40
|
-
isActive(htmlString) {
|
|
41
|
-
return msWordMatch1.test(htmlString) || msWordMatch2.test(htmlString);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* @inheritDoc
|
|
45
|
-
*/
|
|
46
|
-
execute(data) {
|
|
47
|
-
const writer = new ViewUpcastWriter(this.document);
|
|
48
|
-
const { body: documentFragment, stylesString } = data._parsedData;
|
|
49
|
-
transformBookmarks(documentFragment, writer);
|
|
50
|
-
transformListItemLikeElementsIntoLists(documentFragment, stylesString, this.hasMultiLevelListPlugin);
|
|
51
|
-
replaceImagesSourceWithBase64(documentFragment, data.dataTransfer.getData('text/rtf'));
|
|
52
|
-
transformTables(documentFragment, writer, this.hasTablePropertiesPlugin, this.hasExtendedTableBlockAlignment);
|
|
53
|
-
removeInvalidTableWidth(documentFragment, writer);
|
|
54
|
-
replaceMSFootnotes(documentFragment, writer);
|
|
55
|
-
removeMSAttributes(documentFragment);
|
|
56
|
-
data.content = documentFragment;
|
|
57
|
-
}
|
|
58
|
-
}
|
package/src/pastefromoffice.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
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
|
-
/**
|
|
6
|
-
* @module paste-from-office/pastefromoffice
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
|
|
10
|
-
import { PasteFromOfficeMSWordNormalizer } from './normalizers/mswordnormalizer.js';
|
|
11
|
-
import { GoogleDocsNormalizer } from './normalizers/googledocsnormalizer.js';
|
|
12
|
-
import { GoogleSheetsNormalizer } from './normalizers/googlesheetsnormalizer.js';
|
|
13
|
-
import { parsePasteOfficeHtml } from './filters/parse.js';
|
|
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~PasteFromOfficeNormalizer normalizers}.
|
|
21
|
-
* This plugin includes following normalizers:
|
|
22
|
-
* * {@link module:paste-from-office/normalizers/mswordnormalizer~PasteFromOfficeMSWordNormalizer 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 class PasteFromOffice extends Plugin {
|
|
28
|
-
/**
|
|
29
|
-
* @inheritDoc
|
|
30
|
-
*/
|
|
31
|
-
static get pluginName() {
|
|
32
|
-
return 'PasteFromOffice';
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* @inheritDoc
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
static get licenseFeatureCode() {
|
|
39
|
-
return 'PFO';
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* @inheritDoc
|
|
43
|
-
*/
|
|
44
|
-
static get isOfficialPlugin() {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @inheritDoc
|
|
49
|
-
*/
|
|
50
|
-
static get isPremiumPlugin() {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @inheritDoc
|
|
55
|
-
*/
|
|
56
|
-
static get requires() {
|
|
57
|
-
return [ClipboardPipeline];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* @inheritDoc
|
|
61
|
-
*/
|
|
62
|
-
init() {
|
|
63
|
-
const editor = this.editor;
|
|
64
|
-
const clipboardPipeline = editor.plugins.get('ClipboardPipeline');
|
|
65
|
-
const viewDocument = editor.editing.view.document;
|
|
66
|
-
const normalizers = [];
|
|
67
|
-
const hasMultiLevelListPlugin = this.editor.plugins.has('MultiLevelListEditing');
|
|
68
|
-
const hasTablePropertiesPlugin = this.editor.plugins.has('TablePropertiesEditing');
|
|
69
|
-
const hasExtendedTableBlockAlignment = !!this.editor.config.get('experimentalFlags.useExtendedTableBlockAlignment');
|
|
70
|
-
normalizers.push(new PasteFromOfficeMSWordNormalizer(viewDocument, hasMultiLevelListPlugin, hasTablePropertiesPlugin, hasExtendedTableBlockAlignment));
|
|
71
|
-
normalizers.push(new GoogleDocsNormalizer(viewDocument));
|
|
72
|
-
normalizers.push(new GoogleSheetsNormalizer(viewDocument));
|
|
73
|
-
clipboardPipeline.on('inputTransformation', (evt, data) => {
|
|
74
|
-
if (data._isTransformedWithPasteFromOffice) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const codeBlock = editor.model.document.selection.getFirstPosition().parent;
|
|
78
|
-
if (codeBlock.is('element', 'codeBlock')) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const htmlString = data.dataTransfer.getData('text/html');
|
|
82
|
-
const activeNormalizer = normalizers.find(normalizer => normalizer.isActive(htmlString));
|
|
83
|
-
if (activeNormalizer) {
|
|
84
|
-
if (!data._parsedData) {
|
|
85
|
-
data._parsedData = parsePasteOfficeHtml(htmlString, viewDocument.stylesProcessor);
|
|
86
|
-
}
|
|
87
|
-
activeNormalizer.execute(data);
|
|
88
|
-
data._isTransformedWithPasteFromOffice = true;
|
|
89
|
-
}
|
|
90
|
-
}, { priority: 'high' });
|
|
91
|
-
}
|
|
92
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{src → dist}/index.d.ts
RENAMED
|
File without changes
|