1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import { UpcastWriter } 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 |
|
16 |
|
17 | export default class GoogleSheetsNormalizer {
|
18 | |
19 |
|
20 |
|
21 |
|
22 |
|
23 | constructor(document) {
|
24 | this.document = document;
|
25 | }
|
26 | |
27 |
|
28 |
|
29 | isActive(htmlString) {
|
30 | return googleSheetsMatch.test(htmlString);
|
31 | }
|
32 | |
33 |
|
34 |
|
35 | execute(data) {
|
36 | const writer = new UpcastWriter(this.document);
|
37 | const { body: documentFragment } = data._parsedData;
|
38 | removeGoogleSheetsTag(documentFragment, writer);
|
39 | removeXmlns(documentFragment, writer);
|
40 | removeInvalidTableWidth(documentFragment, writer);
|
41 | removeStyleBlock(documentFragment, writer);
|
42 | data.content = documentFragment;
|
43 | }
|
44 | }
|