1 | /**
|
2 | * @license Copyright (c) 2003-2022, 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 | /**
|
7 | * @module paste-from-office/filters/removeboldwrapper
|
8 | */
|
9 |
|
10 | /**
|
11 | * Removes `<b>` tag wrapper added by Google Docs to a copied content.
|
12 | *
|
13 | * @param {module:engine/view/documentfragment~DocumentFragment} documentFragment element `data.content` obtained from clipboard
|
14 | * @param {module:engine/view/upcastwriter~UpcastWriter} writer
|
15 | */
|
16 | export default function removeBoldWrapper( documentFragment, writer ) {
|
17 | for ( const child of documentFragment.getChildren() ) {
|
18 | if ( child.is( 'element', 'b' ) && child.getStyle( 'font-weight' ) === 'normal' ) {
|
19 | const childIndex = documentFragment.getChildIndex( child );
|
20 |
|
21 | writer.remove( child );
|
22 | writer.insertChild( childIndex, child.getChildren(), documentFragment );
|
23 | }
|
24 | }
|
25 | }
|