@ckeditor/ckeditor5-paste-from-office 46.0.1-alpha.1 → 46.0.1-alpha.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-paste-from-office",
3
- "version": "46.0.1-alpha.1",
3
+ "version": "46.0.1-alpha.2",
4
4
  "description": "Paste from Office feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,10 +13,10 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-clipboard": "46.0.1-alpha.1",
17
- "@ckeditor/ckeditor5-core": "46.0.1-alpha.1",
18
- "@ckeditor/ckeditor5-engine": "46.0.1-alpha.1",
19
- "ckeditor5": "46.0.1-alpha.1"
16
+ "@ckeditor/ckeditor5-clipboard": "46.0.1-alpha.2",
17
+ "@ckeditor/ckeditor5-core": "46.0.1-alpha.2",
18
+ "@ckeditor/ckeditor5-engine": "46.0.1-alpha.2",
19
+ "ckeditor5": "46.0.1-alpha.2"
20
20
  },
21
21
  "author": "CKSource (http://cksource.com/)",
22
22
  "license": "SEE LICENSE IN LICENSE.md",
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import type { ViewUpcastWriter, ViewDocumentFragment } from 'ckeditor5/src/engine.js';
9
9
  /**
10
- * Removes the `width:0px` style from table pasted from Google Sheets.
10
+ * Removes the `width:0px` style from table pasted from Google Sheets and `width="0"` attribute from Word tables.
11
11
  *
12
12
  * @param documentFragment element `data.content` obtained from clipboard
13
13
  * @internal
@@ -3,15 +3,22 @@
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
6
- * Removes the `width:0px` style from table pasted from Google Sheets.
6
+ * Removes the `width:0px` style from table pasted from Google Sheets and `width="0"` attribute from Word tables.
7
7
  *
8
8
  * @param documentFragment element `data.content` obtained from clipboard
9
9
  * @internal
10
10
  */
11
11
  export function removeInvalidTableWidth(documentFragment, writer) {
12
- for (const child of documentFragment.getChildren()) {
13
- if (child.is('element', 'table') && child.getStyle('width') === '0px') {
14
- writer.removeStyle('width', child);
12
+ for (const child of writer.createRangeIn(documentFragment).getItems()) {
13
+ if (child.is('element', 'table')) {
14
+ // Remove invalid width style (Google Sheets: width:0px).
15
+ if (child.getStyle('width') === '0px') {
16
+ writer.removeStyle('width', child);
17
+ }
18
+ // Remove invalid width attribute (Word: width="0").
19
+ if (child.getAttribute('width') === '0') {
20
+ writer.removeAttribute('width', child);
21
+ }
15
22
  }
16
23
  }
17
24
  }
@@ -10,6 +10,7 @@ import { transformListItemLikeElementsIntoLists } from '../filters/list.js';
10
10
  import { replaceImagesSourceWithBase64 } from '../filters/image.js';
11
11
  import { removeMSAttributes } from '../filters/removemsattributes.js';
12
12
  import { transformTables } from '../filters/table.js';
13
+ import { removeInvalidTableWidth } from '../filters/removeinvalidtablewidth.js';
13
14
  import { ViewUpcastWriter } from 'ckeditor5/src/engine.js';
14
15
  const msWordMatch1 = /<meta\s*name="?generator"?\s*content="?microsoft\s*word\s*\d+"?\/?>/i;
15
16
  const msWordMatch2 = /xmlns:o="urn:schemas-microsoft-com/i;
@@ -44,6 +45,7 @@ export class PasteFromOfficeMSWordNormalizer {
44
45
  transformListItemLikeElementsIntoLists(documentFragment, stylesString, this.hasMultiLevelListPlugin);
45
46
  replaceImagesSourceWithBase64(documentFragment, data.dataTransfer.getData('text/rtf'));
46
47
  transformTables(documentFragment, writer);
48
+ removeInvalidTableWidth(documentFragment, writer);
47
49
  removeMSAttributes(documentFragment);
48
50
  data.content = documentFragment;
49
51
  }