@ckeditor/ckeditor5-paste-from-office 47.6.1 → 48.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.
- 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
package/ckeditor5-metadata.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"className": "PasteFromOffice",
|
|
6
6
|
"description": "Handles the content pasted from Microsoft Office or Google Docs and transforms it (if necessary) to a valid structure which can then be understood by the editor features.",
|
|
7
7
|
"docs": "features/pasting/paste-from-office.html",
|
|
8
|
-
"path": "src/pastefromoffice.
|
|
8
|
+
"path": "src/pastefromoffice.ts"
|
|
9
9
|
}
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/bookmark
|
|
7
7
|
*/
|
|
8
|
-
import { type ViewUpcastWriter, type ViewDocumentFragment } from 'ckeditor5
|
|
8
|
+
import { type ViewUpcastWriter, type ViewDocumentFragment } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Transforms `<a>` elements which are bookmarks by moving their children after the element.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/br
|
|
7
7
|
*/
|
|
8
|
-
import { type ViewUpcastWriter, type ViewDocumentFragment } from 'ckeditor5
|
|
8
|
+
import { type ViewUpcastWriter, type ViewDocumentFragment } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Transforms `<br>` elements that are siblings to some block element into a paragraphs.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/image
|
|
7
7
|
*/
|
|
8
|
-
import { type ViewDocumentFragment } from 'ckeditor5
|
|
8
|
+
import { type ViewDocumentFragment } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Replaces source attribute of all `<img>` elements representing regular
|
|
11
11
|
* images (not the Word shapes) with inlined base64 image representation extracted from RTF or Blob data.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/list
|
|
7
7
|
*/
|
|
8
|
-
import { ViewUpcastWriter, type ViewDocumentFragment } from 'ckeditor5
|
|
8
|
+
import { ViewUpcastWriter, type ViewDocumentFragment } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Transforms Word specific list-like elements to the semantic HTML lists.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/parse
|
|
7
7
|
*/
|
|
8
|
-
import { type StylesProcessor, type ViewDocumentFragment } from 'ckeditor5
|
|
8
|
+
import { type StylesProcessor, type ViewDocumentFragment } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Parses the provided HTML extracting contents of `<body>` and `<style>` tags.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/removeboldwrapper
|
|
7
7
|
*/
|
|
8
|
-
import type { ViewUpcastWriter, ViewDocumentFragment } from 'ckeditor5
|
|
8
|
+
import type { ViewUpcastWriter, ViewDocumentFragment } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Removes the `<b>` tag wrapper added by Google Docs to a copied content.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/removegooglesheetstag
|
|
7
7
|
*/
|
|
8
|
-
import type { ViewUpcastWriter, ViewDocumentFragment } from 'ckeditor5
|
|
8
|
+
import type { ViewUpcastWriter, ViewDocumentFragment } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Removes the `<google-sheets-html-origin>` tag wrapper added by Google Sheets to a copied content.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/removeinvalidtablewidth
|
|
7
7
|
*/
|
|
8
|
-
import type { ViewUpcastWriter, ViewDocumentFragment } from 'ckeditor5
|
|
8
|
+
import type { ViewUpcastWriter, ViewDocumentFragment } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Removes the `width:0px` style from table pasted from Google Sheets and `width="0"` attribute from Word tables.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/removemsattributes
|
|
7
7
|
*/
|
|
8
|
-
import { type ViewDocumentFragment } from 'ckeditor5
|
|
8
|
+
import { type ViewDocumentFragment } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Cleanup MS attributes like styles, attributes and elements.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/removestyleblock
|
|
7
7
|
*/
|
|
8
|
-
import type { ViewUpcastWriter, ViewDocumentFragment } from 'ckeditor5
|
|
8
|
+
import type { ViewUpcastWriter, ViewDocumentFragment } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Removes `<style>` block added by Google Sheets to a copied content.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/removexmlns
|
|
7
7
|
*/
|
|
8
|
-
import type { ViewUpcastWriter, ViewDocumentFragment } from 'ckeditor5
|
|
8
|
+
import type { ViewUpcastWriter, ViewDocumentFragment } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Removes the `xmlns` attribute from table pasted from Google Sheets.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/replacemsfootnotes
|
|
7
7
|
*/
|
|
8
|
-
import type { ViewDocumentFragment, ViewUpcastWriter } from 'ckeditor5
|
|
8
|
+
import type { ViewDocumentFragment, ViewUpcastWriter } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Replaces MS Word specific footnotes references and definitions with proper elements.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/replacetabswithinprewithspaces
|
|
7
7
|
*/
|
|
8
|
-
import type { ViewDocumentFragment, ViewUpcastWriter } from 'ckeditor5
|
|
8
|
+
import type { ViewDocumentFragment, ViewUpcastWriter } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Replaces tab characters with spaces in text nodes that are inside elements styled with `white-space: pre-wrap`.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module paste-from-office/filters/table
|
|
7
7
|
*/
|
|
8
|
-
import { type ViewUpcastWriter, type ViewDocumentFragment } from 'ckeditor5
|
|
8
|
+
import { type ViewUpcastWriter, type ViewDocumentFragment } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
10
|
* Applies border none for table and cells without a border specified.
|
|
11
11
|
* Normalizes style length units to px.
|
|
@@ -13,4 +13,4 @@ import { type ViewUpcastWriter, type ViewDocumentFragment } from 'ckeditor5/src/
|
|
|
13
13
|
*
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
|
-
export declare function transformTables(documentFragment: ViewDocumentFragment, writer: ViewUpcastWriter, hasTablePropertiesPlugin?: boolean
|
|
16
|
+
export declare function transformTables(documentFragment: ViewDocumentFragment, writer: ViewUpcastWriter, hasTablePropertiesPlugin?: boolean): void;
|
package/dist/index.css
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.css"],"names":[],"mappings":";;;;;;AAEA,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC","file":"index.css.map","sourcesContent":["\n\n/*# sourceMappingURL=index.css.map */"]}
|
package/dist/index.js
CHANGED
|
@@ -819,7 +819,7 @@ function isList(element) {
|
|
|
819
819
|
* Handles left block table alignment.
|
|
820
820
|
*
|
|
821
821
|
* @internal
|
|
822
|
-
*/ function transformTables(documentFragment, writer, hasTablePropertiesPlugin = false
|
|
822
|
+
*/ function transformTables(documentFragment, writer, hasTablePropertiesPlugin = false) {
|
|
823
823
|
for (const item of writer.createRangeIn(documentFragment).getItems()){
|
|
824
824
|
if (!item.is('element', 'table') && !item.is('element', 'td') && !item.is('element', 'th')) {
|
|
825
825
|
continue;
|
|
@@ -834,7 +834,7 @@ function isList(element) {
|
|
|
834
834
|
// Additionally, the structure may change when pasting content from MS Word.
|
|
835
835
|
// Some browsers (e.g., Safari) may insert extra elements around the table (e.g., a <span>),
|
|
836
836
|
// so the surrounding `<div>` with the `align` attribute may end up being the table's grandparent.
|
|
837
|
-
if (hasTablePropertiesPlugin &&
|
|
837
|
+
if (hasTablePropertiesPlugin && item.is('element', 'table')) {
|
|
838
838
|
const directParent = item.parent?.is('element', 'div') ? item.parent : null;
|
|
839
839
|
const grandParent = item.parent?.parent?.is('element', 'div') ? item.parent.parent : null;
|
|
840
840
|
const divParent = directParent ?? grandParent;
|
|
@@ -1124,16 +1124,14 @@ const msWordMatch2 = /xmlns:o="urn:schemas-microsoft-com/i;
|
|
|
1124
1124
|
document;
|
|
1125
1125
|
hasMultiLevelListPlugin;
|
|
1126
1126
|
hasTablePropertiesPlugin;
|
|
1127
|
-
hasExtendedTableBlockAlignment;
|
|
1128
1127
|
/**
|
|
1129
1128
|
* Creates a new `PasteFromOfficeMSWordNormalizer` instance.
|
|
1130
1129
|
*
|
|
1131
1130
|
* @param document View document.
|
|
1132
|
-
*/ constructor(document, hasMultiLevelListPlugin = false, hasTablePropertiesPlugin = false
|
|
1131
|
+
*/ constructor(document, hasMultiLevelListPlugin = false, hasTablePropertiesPlugin = false){
|
|
1133
1132
|
this.document = document;
|
|
1134
1133
|
this.hasMultiLevelListPlugin = hasMultiLevelListPlugin;
|
|
1135
1134
|
this.hasTablePropertiesPlugin = hasTablePropertiesPlugin;
|
|
1136
|
-
this.hasExtendedTableBlockAlignment = hasExtendedTableBlockAlignment;
|
|
1137
1135
|
}
|
|
1138
1136
|
/**
|
|
1139
1137
|
* @inheritDoc
|
|
@@ -1148,7 +1146,7 @@ const msWordMatch2 = /xmlns:o="urn:schemas-microsoft-com/i;
|
|
|
1148
1146
|
transformBookmarks(documentFragment, writer);
|
|
1149
1147
|
transformListItemLikeElementsIntoLists(documentFragment, stylesString, this.hasMultiLevelListPlugin);
|
|
1150
1148
|
replaceImagesSourceWithBase64(documentFragment, data.dataTransfer.getData('text/rtf'));
|
|
1151
|
-
transformTables(documentFragment, writer, this.hasTablePropertiesPlugin
|
|
1149
|
+
transformTables(documentFragment, writer, this.hasTablePropertiesPlugin);
|
|
1152
1150
|
removeInvalidTableWidth(documentFragment, writer);
|
|
1153
1151
|
replaceMSFootnotes(documentFragment, writer);
|
|
1154
1152
|
removeMSAttributes(documentFragment);
|
|
@@ -1609,8 +1607,7 @@ const googleSheetsMatch = /<google-sheets-html-origin/i;
|
|
|
1609
1607
|
const normalizers = [];
|
|
1610
1608
|
const hasMultiLevelListPlugin = this.editor.plugins.has('MultiLevelListEditing');
|
|
1611
1609
|
const hasTablePropertiesPlugin = this.editor.plugins.has('TablePropertiesEditing');
|
|
1612
|
-
|
|
1613
|
-
normalizers.push(new PasteFromOfficeMSWordNormalizer(viewDocument, hasMultiLevelListPlugin, hasTablePropertiesPlugin, hasExtendedTableBlockAlignment));
|
|
1610
|
+
normalizers.push(new PasteFromOfficeMSWordNormalizer(viewDocument, hasMultiLevelListPlugin, hasTablePropertiesPlugin));
|
|
1614
1611
|
normalizers.push(new GoogleDocsNormalizer(viewDocument));
|
|
1615
1612
|
normalizers.push(new GoogleSheetsNormalizer(viewDocument));
|
|
1616
1613
|
clipboardPipeline.on('inputTransformation', (evt, data)=>{
|