@ckeditor/ckeditor5-paste-from-office 40.0.0 → 40.2.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +12 -12
  2. package/LICENSE.md +2 -2
  3. package/build/paste-from-office.js +1 -1
  4. package/package.json +2 -2
  5. package/src/augmentation.d.ts +10 -10
  6. package/src/augmentation.js +5 -5
  7. package/src/filters/br.d.ts +14 -14
  8. package/src/filters/br.js +65 -65
  9. package/src/filters/image.d.ts +24 -24
  10. package/src/filters/image.js +241 -241
  11. package/src/filters/list.d.ts +26 -26
  12. package/src/filters/list.js +395 -395
  13. package/src/filters/parse.d.ts +35 -35
  14. package/src/filters/parse.js +96 -93
  15. package/src/filters/removeboldwrapper.d.ts +14 -14
  16. package/src/filters/removeboldwrapper.js +18 -18
  17. package/src/filters/removegooglesheetstag.d.ts +14 -14
  18. package/src/filters/removegooglesheetstag.js +18 -18
  19. package/src/filters/removeinvalidtablewidth.d.ts +14 -14
  20. package/src/filters/removeinvalidtablewidth.js +16 -16
  21. package/src/filters/removemsattributes.d.ts +14 -0
  22. package/src/filters/removemsattributes.js +41 -0
  23. package/src/filters/removestyleblock.d.ts +14 -14
  24. package/src/filters/removestyleblock.js +16 -16
  25. package/src/filters/removexmlns.d.ts +14 -14
  26. package/src/filters/removexmlns.js +16 -16
  27. package/src/filters/space.d.ts +25 -25
  28. package/src/filters/space.js +60 -60
  29. package/src/index.d.ts +12 -12
  30. package/src/index.js +11 -11
  31. package/src/normalizer.d.ts +30 -30
  32. package/src/normalizer.js +5 -5
  33. package/src/normalizers/googledocsnormalizer.d.ts +29 -29
  34. package/src/normalizers/googledocsnormalizer.js +42 -42
  35. package/src/normalizers/googlesheetsnormalizer.d.ts +29 -29
  36. package/src/normalizers/googlesheetsnormalizer.js +44 -44
  37. package/src/normalizers/mswordnormalizer.d.ts +26 -26
  38. package/src/normalizers/mswordnormalizer.js +41 -39
  39. package/src/pastefromoffice.d.ts +36 -36
  40. package/src/pastefromoffice.js +70 -70
  41. package/build/paste-from-office.js.map +0 -1
@@ -1,16 +1,16 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- * Removes the `xmlns` attribute from table pasted from Google Sheets.
7
- *
8
- * @param documentFragment element `data.content` obtained from clipboard
9
- */
10
- export default function removeXmlns(documentFragment, writer) {
11
- for (const child of documentFragment.getChildren()) {
12
- if (child.is('element', 'table') && child.hasAttribute('xmlns')) {
13
- writer.removeAttribute('xmlns', child);
14
- }
15
- }
16
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ * Removes the `xmlns` attribute from table pasted from Google Sheets.
7
+ *
8
+ * @param documentFragment element `data.content` obtained from clipboard
9
+ */
10
+ export default function removeXmlns(documentFragment, writer) {
11
+ for (const child of documentFragment.getChildren()) {
12
+ if (child.is('element', 'table') && child.hasAttribute('xmlns')) {
13
+ writer.removeAttribute('xmlns', child);
14
+ }
15
+ }
16
+ }
@@ -1,25 +1,25 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- * @module paste-from-office/filters/space
7
- */
8
- /**
9
- * Replaces last space preceding elements closing tag with ` `. Such operation prevents spaces from being removed
10
- * during further DOM/View processing (see especially {@link module:engine/view/domconverter~DomConverter#_processDomInlineNodes}).
11
- * This method also takes into account Word specific `<o:p></o:p>` empty tags.
12
- * Additionally multiline sequences of spaces and new lines between tags are removed (see #39 and #40).
13
- *
14
- * @param htmlString HTML string in which spacing should be normalized.
15
- * @returns Input HTML with spaces normalized.
16
- */
17
- export declare function normalizeSpacing(htmlString: string): string;
18
- /**
19
- * Normalizes spacing in special Word `spacerun spans` (`<span style='mso-spacerun:yes'>\s+</span>`) by replacing
20
- * all spaces with `&nbsp; ` pairs. This prevents spaces from being removed during further DOM/View processing
21
- * (see especially {@link module:engine/view/domconverter~DomConverter#_processDomInlineNodes}).
22
- *
23
- * @param htmlDocument Native `Document` object in which spacing should be normalized.
24
- */
25
- export declare function normalizeSpacerunSpans(htmlDocument: Document): void;
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ * @module paste-from-office/filters/space
7
+ */
8
+ /**
9
+ * Replaces last space preceding elements closing tag with `&nbsp;`. Such operation prevents spaces from being removed
10
+ * during further DOM/View processing (see especially {@link module:engine/view/domconverter~DomConverter#_processDomInlineNodes}).
11
+ * This method also takes into account Word specific `<o:p></o:p>` empty tags.
12
+ * Additionally multiline sequences of spaces and new lines between tags are removed (see #39 and #40).
13
+ *
14
+ * @param htmlString HTML string in which spacing should be normalized.
15
+ * @returns Input HTML with spaces normalized.
16
+ */
17
+ export declare function normalizeSpacing(htmlString: string): string;
18
+ /**
19
+ * Normalizes spacing in special Word `spacerun spans` (`<span style='mso-spacerun:yes'>\s+</span>`) by replacing
20
+ * all spaces with `&nbsp; ` pairs. This prevents spaces from being removed during further DOM/View processing
21
+ * (see especially {@link module:engine/view/domconverter~DomConverter#_processDomInlineNodes}).
22
+ *
23
+ * @param htmlDocument Native `Document` object in which spacing should be normalized.
24
+ */
25
+ export declare function normalizeSpacerunSpans(htmlDocument: Document): void;
@@ -1,60 +1,60 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- * @module paste-from-office/filters/space
7
- */
8
- /**
9
- * Replaces last space preceding elements closing tag with `&nbsp;`. Such operation prevents spaces from being removed
10
- * during further DOM/View processing (see especially {@link module:engine/view/domconverter~DomConverter#_processDomInlineNodes}).
11
- * This method also takes into account Word specific `<o:p></o:p>` empty tags.
12
- * Additionally multiline sequences of spaces and new lines between tags are removed (see #39 and #40).
13
- *
14
- * @param htmlString HTML string in which spacing should be normalized.
15
- * @returns Input HTML with spaces normalized.
16
- */
17
- export function normalizeSpacing(htmlString) {
18
- // Run normalizeSafariSpaceSpans() two times to cover nested spans.
19
- return normalizeSafariSpaceSpans(normalizeSafariSpaceSpans(htmlString))
20
- // Remove all \r\n from "spacerun spans" so the last replace line doesn't strip all whitespaces.
21
- .replace(/(<span\s+style=['"]mso-spacerun:yes['"]>[^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g, '$1$2')
22
- .replace(/<span\s+style=['"]mso-spacerun:yes['"]><\/span>/g, '')
23
- .replace(/(<span\s+style=['"]letter-spacing:[^'"]+?['"]>)[\r\n]+(<\/span>)/g, '$1 $2')
24
- .replace(/ <\//g, '\u00A0</')
25
- .replace(/ <o:p><\/o:p>/g, '\u00A0<o:p></o:p>')
26
- // Remove <o:p> block filler from empty paragraph. Safari uses \u00A0 instead of &nbsp;.
27
- .replace(/<o:p>(&nbsp;|\u00A0)<\/o:p>/g, '')
28
- // Remove all whitespaces when they contain any \r or \n.
29
- .replace(/>([^\S\r\n]*[\r\n]\s*)</g, '><');
30
- }
31
- /**
32
- * Normalizes spacing in special Word `spacerun spans` (`<span style='mso-spacerun:yes'>\s+</span>`) by replacing
33
- * all spaces with `&nbsp; ` pairs. This prevents spaces from being removed during further DOM/View processing
34
- * (see especially {@link module:engine/view/domconverter~DomConverter#_processDomInlineNodes}).
35
- *
36
- * @param htmlDocument Native `Document` object in which spacing should be normalized.
37
- */
38
- export function normalizeSpacerunSpans(htmlDocument) {
39
- htmlDocument.querySelectorAll('span[style*=spacerun]').forEach(el => {
40
- const htmlElement = el;
41
- const innerTextLength = htmlElement.innerText.length || 0;
42
- htmlElement.innerText = Array(innerTextLength + 1).join('\u00A0 ').substr(0, innerTextLength);
43
- });
44
- }
45
- /**
46
- * Normalizes specific spacing generated by Safari when content pasted from Word (`<span class="Apple-converted-space"> </span>`)
47
- * by replacing all spaces sequences longer than 1 space with `&nbsp; ` pairs. This prevents spaces from being removed during
48
- * further DOM/View processing (see especially {@link module:engine/view/domconverter~DomConverter#_processDataFromDomText}).
49
- *
50
- * This function is similar to {@link module:clipboard/utils/normalizeclipboarddata normalizeClipboardData util} but uses
51
- * regular spaces / &nbsp; sequence for replacement.
52
- *
53
- * @param htmlString HTML string in which spacing should be normalized
54
- * @returns Input HTML with spaces normalized.
55
- */
56
- function normalizeSafariSpaceSpans(htmlString) {
57
- return htmlString.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g, (fullMatch, spaces) => {
58
- return spaces.length === 1 ? ' ' : Array(spaces.length + 1).join('\u00A0 ').substr(0, spaces.length);
59
- });
60
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ * @module paste-from-office/filters/space
7
+ */
8
+ /**
9
+ * Replaces last space preceding elements closing tag with `&nbsp;`. Such operation prevents spaces from being removed
10
+ * during further DOM/View processing (see especially {@link module:engine/view/domconverter~DomConverter#_processDomInlineNodes}).
11
+ * This method also takes into account Word specific `<o:p></o:p>` empty tags.
12
+ * Additionally multiline sequences of spaces and new lines between tags are removed (see #39 and #40).
13
+ *
14
+ * @param htmlString HTML string in which spacing should be normalized.
15
+ * @returns Input HTML with spaces normalized.
16
+ */
17
+ export function normalizeSpacing(htmlString) {
18
+ // Run normalizeSafariSpaceSpans() two times to cover nested spans.
19
+ return normalizeSafariSpaceSpans(normalizeSafariSpaceSpans(htmlString))
20
+ // Remove all \r\n from "spacerun spans" so the last replace line doesn't strip all whitespaces.
21
+ .replace(/(<span\s+style=['"]mso-spacerun:yes['"]>[^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g, '$1$2')
22
+ .replace(/<span\s+style=['"]mso-spacerun:yes['"]><\/span>/g, '')
23
+ .replace(/(<span\s+style=['"]letter-spacing:[^'"]+?['"]>)[\r\n]+(<\/span>)/g, '$1 $2')
24
+ .replace(/ <\//g, '\u00A0</')
25
+ .replace(/ <o:p><\/o:p>/g, '\u00A0<o:p></o:p>')
26
+ // Remove <o:p> block filler from empty paragraph. Safari uses \u00A0 instead of &nbsp;.
27
+ .replace(/<o:p>(&nbsp;|\u00A0)<\/o:p>/g, '')
28
+ // Remove all whitespaces when they contain any \r or \n.
29
+ .replace(/>([^\S\r\n]*[\r\n]\s*)</g, '><');
30
+ }
31
+ /**
32
+ * Normalizes spacing in special Word `spacerun spans` (`<span style='mso-spacerun:yes'>\s+</span>`) by replacing
33
+ * all spaces with `&nbsp; ` pairs. This prevents spaces from being removed during further DOM/View processing
34
+ * (see especially {@link module:engine/view/domconverter~DomConverter#_processDomInlineNodes}).
35
+ *
36
+ * @param htmlDocument Native `Document` object in which spacing should be normalized.
37
+ */
38
+ export function normalizeSpacerunSpans(htmlDocument) {
39
+ htmlDocument.querySelectorAll('span[style*=spacerun]').forEach(el => {
40
+ const htmlElement = el;
41
+ const innerTextLength = htmlElement.innerText.length || 0;
42
+ htmlElement.innerText = Array(innerTextLength + 1).join('\u00A0 ').substr(0, innerTextLength);
43
+ });
44
+ }
45
+ /**
46
+ * Normalizes specific spacing generated by Safari when content pasted from Word (`<span class="Apple-converted-space"> </span>`)
47
+ * by replacing all spaces sequences longer than 1 space with `&nbsp; ` pairs. This prevents spaces from being removed during
48
+ * further DOM/View processing (see especially {@link module:engine/view/domconverter~DomConverter#_processDataFromDomText}).
49
+ *
50
+ * This function is similar to {@link module:clipboard/utils/normalizeclipboarddata normalizeClipboardData util} but uses
51
+ * regular spaces / &nbsp; sequence for replacement.
52
+ *
53
+ * @param htmlString HTML string in which spacing should be normalized
54
+ * @returns Input HTML with spaces normalized.
55
+ */
56
+ function normalizeSafariSpaceSpans(htmlString) {
57
+ return htmlString.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g, (fullMatch, spaces) => {
58
+ return spaces.length === 1 ? ' ' : Array(spaces.length + 1).join('\u00A0 ').substr(0, spaces.length);
59
+ });
60
+ }
package/src/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- * @module paste-from-office
7
- */
8
- export { default as PasteFromOffice } from './pastefromoffice';
9
- export { Normalizer, type NormalizerData } from './normalizer';
10
- export { default as MSWordNormalizer } from './normalizers/mswordnormalizer';
11
- export { parseHtml } from './filters/parse';
12
- import './augmentation';
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ * @module paste-from-office
7
+ */
8
+ export { default as PasteFromOffice } from './pastefromoffice';
9
+ export { Normalizer, type NormalizerData } from './normalizer';
10
+ export { default as MSWordNormalizer } from './normalizers/mswordnormalizer';
11
+ export { parseHtml } from './filters/parse';
12
+ import './augmentation';
package/src/index.js CHANGED
@@ -1,11 +1,11 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- * @module paste-from-office
7
- */
8
- export { default as PasteFromOffice } from './pastefromoffice';
9
- export { default as MSWordNormalizer } from './normalizers/mswordnormalizer';
10
- export { parseHtml } from './filters/parse';
11
- import './augmentation';
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ * @module paste-from-office
7
+ */
8
+ export { default as PasteFromOffice } from './pastefromoffice';
9
+ export { default as MSWordNormalizer } from './normalizers/mswordnormalizer';
10
+ export { parseHtml } from './filters/parse';
11
+ import './augmentation';
@@ -1,30 +1,30 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- * @module paste-from-office/normalizer
7
- */
8
- import type { ClipboardInputTransformationData } from 'ckeditor5/src/clipboard';
9
- import type { ParseHtmlResult } from './filters/parse';
10
- /**
11
- * Interface defining a content transformation pasted from an external editor.
12
- *
13
- * Normalizers are registered by the {@link module:paste-from-office/pastefromoffice~PasteFromOffice} plugin and run on
14
- * {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation inputTransformation event}.
15
- * They detect environment-specific quirks and transform it into a form compatible with other CKEditor features.
16
- */
17
- export interface Normalizer {
18
- /**
19
- * Must return `true` if the `htmlString` contains content which this normalizer can transform.
20
- */
21
- isActive(htmlString: string): boolean;
22
- /**
23
- * Executes the normalization of a given data.
24
- */
25
- execute(data: NormalizerData): void;
26
- }
27
- export interface NormalizerData extends ClipboardInputTransformationData {
28
- _isTransformedWithPasteFromOffice?: boolean;
29
- _parsedData: ParseHtmlResult;
30
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ * @module paste-from-office/normalizer
7
+ */
8
+ import type { ClipboardInputTransformationData } from 'ckeditor5/src/clipboard';
9
+ import type { ParseHtmlResult } from './filters/parse';
10
+ /**
11
+ * Interface defining a content transformation pasted from an external editor.
12
+ *
13
+ * Normalizers are registered by the {@link module:paste-from-office/pastefromoffice~PasteFromOffice} plugin and run on
14
+ * {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation inputTransformation event}.
15
+ * They detect environment-specific quirks and transform it into a form compatible with other CKEditor features.
16
+ */
17
+ export interface Normalizer {
18
+ /**
19
+ * Must return `true` if the `htmlString` contains content which this normalizer can transform.
20
+ */
21
+ isActive(htmlString: string): boolean;
22
+ /**
23
+ * Executes the normalization of a given data.
24
+ */
25
+ execute(data: NormalizerData): void;
26
+ }
27
+ export interface NormalizerData extends ClipboardInputTransformationData {
28
+ _isTransformedWithPasteFromOffice?: boolean;
29
+ _parsedData: ParseHtmlResult;
30
+ }
package/src/normalizer.js CHANGED
@@ -1,5 +1,5 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- export {};
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ export {};
@@ -1,29 +1,29 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- * @module paste-from-office/normalizers/googledocsnormalizer
7
- */
8
- import { type ViewDocument } from 'ckeditor5/src/engine';
9
- import type { Normalizer, NormalizerData } from '../normalizer';
10
- /**
11
- * Normalizer for the content pasted from Google Docs.
12
- */
13
- export default class GoogleDocsNormalizer implements Normalizer {
14
- readonly document: ViewDocument;
15
- /**
16
- * Creates a new `GoogleDocsNormalizer` instance.
17
- *
18
- * @param document View document.
19
- */
20
- constructor(document: ViewDocument);
21
- /**
22
- * @inheritDoc
23
- */
24
- isActive(htmlString: string): boolean;
25
- /**
26
- * @inheritDoc
27
- */
28
- execute(data: NormalizerData): void;
29
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ * @module paste-from-office/normalizers/googledocsnormalizer
7
+ */
8
+ import { type ViewDocument } from 'ckeditor5/src/engine';
9
+ import type { Normalizer, NormalizerData } from '../normalizer';
10
+ /**
11
+ * Normalizer for the content pasted from Google Docs.
12
+ */
13
+ export default class GoogleDocsNormalizer implements Normalizer {
14
+ readonly document: ViewDocument;
15
+ /**
16
+ * Creates a new `GoogleDocsNormalizer` instance.
17
+ *
18
+ * @param document View document.
19
+ */
20
+ constructor(document: ViewDocument);
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ isActive(htmlString: string): boolean;
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ execute(data: NormalizerData): void;
29
+ }
@@ -1,42 +1,42 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- * @module paste-from-office/normalizers/googledocsnormalizer
7
- */
8
- import { UpcastWriter } from 'ckeditor5/src/engine';
9
- import removeBoldWrapper from '../filters/removeboldwrapper';
10
- import transformBlockBrsToParagraphs from '../filters/br';
11
- import { unwrapParagraphInListItem } from '../filters/list';
12
- const googleDocsMatch = /id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;
13
- /**
14
- * Normalizer for the content pasted from Google Docs.
15
- */
16
- export default class GoogleDocsNormalizer {
17
- /**
18
- * Creates a new `GoogleDocsNormalizer` instance.
19
- *
20
- * @param document View document.
21
- */
22
- constructor(document) {
23
- this.document = document;
24
- }
25
- /**
26
- * @inheritDoc
27
- */
28
- isActive(htmlString) {
29
- return googleDocsMatch.test(htmlString);
30
- }
31
- /**
32
- * @inheritDoc
33
- */
34
- execute(data) {
35
- const writer = new UpcastWriter(this.document);
36
- const { body: documentFragment } = data._parsedData;
37
- removeBoldWrapper(documentFragment, writer);
38
- unwrapParagraphInListItem(documentFragment, writer);
39
- transformBlockBrsToParagraphs(documentFragment, writer);
40
- data.content = documentFragment;
41
- }
42
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ * @module paste-from-office/normalizers/googledocsnormalizer
7
+ */
8
+ import { UpcastWriter } from 'ckeditor5/src/engine';
9
+ import removeBoldWrapper from '../filters/removeboldwrapper';
10
+ import transformBlockBrsToParagraphs from '../filters/br';
11
+ import { unwrapParagraphInListItem } from '../filters/list';
12
+ const googleDocsMatch = /id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;
13
+ /**
14
+ * Normalizer for the content pasted from Google Docs.
15
+ */
16
+ export default class GoogleDocsNormalizer {
17
+ /**
18
+ * Creates a new `GoogleDocsNormalizer` instance.
19
+ *
20
+ * @param document View document.
21
+ */
22
+ constructor(document) {
23
+ this.document = document;
24
+ }
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ isActive(htmlString) {
29
+ return googleDocsMatch.test(htmlString);
30
+ }
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ execute(data) {
35
+ const writer = new UpcastWriter(this.document);
36
+ const { body: documentFragment } = data._parsedData;
37
+ removeBoldWrapper(documentFragment, writer);
38
+ unwrapParagraphInListItem(documentFragment, writer);
39
+ transformBlockBrsToParagraphs(documentFragment, writer);
40
+ data.content = documentFragment;
41
+ }
42
+ }
@@ -1,29 +1,29 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- * @module paste-from-office/normalizers/googlesheetsnormalizer
7
- */
8
- import { type ViewDocument } from 'ckeditor5/src/engine';
9
- import type { Normalizer, NormalizerData } from '../normalizer';
10
- /**
11
- * Normalizer for the content pasted from Google Sheets.
12
- */
13
- export default class GoogleSheetsNormalizer implements Normalizer {
14
- readonly document: ViewDocument;
15
- /**
16
- * Creates a new `GoogleSheetsNormalizer` instance.
17
- *
18
- * @param document View document.
19
- */
20
- constructor(document: ViewDocument);
21
- /**
22
- * @inheritDoc
23
- */
24
- isActive(htmlString: string): boolean;
25
- /**
26
- * @inheritDoc
27
- */
28
- execute(data: NormalizerData): void;
29
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ * @module paste-from-office/normalizers/googlesheetsnormalizer
7
+ */
8
+ import { type ViewDocument } from 'ckeditor5/src/engine';
9
+ import type { Normalizer, NormalizerData } from '../normalizer';
10
+ /**
11
+ * Normalizer for the content pasted from Google Sheets.
12
+ */
13
+ export default class GoogleSheetsNormalizer implements Normalizer {
14
+ readonly document: ViewDocument;
15
+ /**
16
+ * Creates a new `GoogleSheetsNormalizer` instance.
17
+ *
18
+ * @param document View document.
19
+ */
20
+ constructor(document: ViewDocument);
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ isActive(htmlString: string): boolean;
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ execute(data: NormalizerData): void;
29
+ }
@@ -1,44 +1,44 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, 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
- * @module paste-from-office/normalizers/googlesheetsnormalizer
7
- */
8
- import { UpcastWriter } from 'ckeditor5/src/engine';
9
- import removeXmlns from '../filters/removexmlns';
10
- import removeGoogleSheetsTag from '../filters/removegooglesheetstag';
11
- import removeInvalidTableWidth from '../filters/removeinvalidtablewidth';
12
- import removeStyleBlock from '../filters/removestyleblock';
13
- const googleSheetsMatch = /<google-sheets-html-origin/i;
14
- /**
15
- * Normalizer for the content pasted from Google Sheets.
16
- */
17
- export default class GoogleSheetsNormalizer {
18
- /**
19
- * Creates a new `GoogleSheetsNormalizer` instance.
20
- *
21
- * @param document View document.
22
- */
23
- constructor(document) {
24
- this.document = document;
25
- }
26
- /**
27
- * @inheritDoc
28
- */
29
- isActive(htmlString) {
30
- return googleSheetsMatch.test(htmlString);
31
- }
32
- /**
33
- * @inheritDoc
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
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ * @module paste-from-office/normalizers/googlesheetsnormalizer
7
+ */
8
+ import { UpcastWriter } from 'ckeditor5/src/engine';
9
+ import removeXmlns from '../filters/removexmlns';
10
+ import removeGoogleSheetsTag from '../filters/removegooglesheetstag';
11
+ import removeInvalidTableWidth from '../filters/removeinvalidtablewidth';
12
+ import removeStyleBlock from '../filters/removestyleblock';
13
+ const googleSheetsMatch = /<google-sheets-html-origin/i;
14
+ /**
15
+ * Normalizer for the content pasted from Google Sheets.
16
+ */
17
+ export default class GoogleSheetsNormalizer {
18
+ /**
19
+ * Creates a new `GoogleSheetsNormalizer` instance.
20
+ *
21
+ * @param document View document.
22
+ */
23
+ constructor(document) {
24
+ this.document = document;
25
+ }
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ isActive(htmlString) {
30
+ return googleSheetsMatch.test(htmlString);
31
+ }
32
+ /**
33
+ * @inheritDoc
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
+ }