-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16007 from ckeditor/ck/11210
Fix (paste-from-office): Paste from Office should not break the list on the following blocks in the same list item or deduce a start attribute for a split list. Closes #11210. Closes #15964.
- Loading branch information
Showing
113 changed files
with
4,361 additions
and
707 deletions.
There are no files selected for viewing
360 changes: 208 additions & 152 deletions
360
packages/ckeditor5-paste-from-office/src/filters/list.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/** | ||
* @module paste-from-office/filters/utils | ||
*/ | ||
|
||
/** | ||
* Normalizes CSS length value to 'px'. | ||
* | ||
* @internal | ||
*/ | ||
export function convertCssLengthToPx( value: string ): string { | ||
const numericValue = parseFloat( value ); | ||
|
||
if ( value.endsWith( 'pt' ) ) { | ||
// 1pt = 1in / 72 | ||
return toPx( numericValue * 96 / 72 ); | ||
} | ||
else if ( value.endsWith( 'pc' ) ) { | ||
// 1pc = 12pt = 1in / 6. | ||
return toPx( numericValue * 12 * 96 / 72 ); | ||
} | ||
else if ( value.endsWith( 'in' ) ) { | ||
// 1in = 2.54cm = 96px | ||
return toPx( numericValue * 96 ); | ||
} | ||
else if ( value.endsWith( 'cm' ) ) { | ||
// 1cm = 96px / 2.54 | ||
return toPx( numericValue * 96 / 2.54 ); | ||
} | ||
else if ( value.endsWith( 'mm' ) ) { | ||
// 1mm = 1cm / 10 | ||
return toPx( numericValue / 10 * 96 / 2.54 ); | ||
} | ||
|
||
return value; | ||
} | ||
|
||
/** | ||
* Returns true for value with 'px' unit. | ||
* | ||
* @internal | ||
*/ | ||
export function isPx( value?: string ): value is string { | ||
return value !== undefined && value.endsWith( 'px' ); | ||
} | ||
|
||
/** | ||
* Returns a rounded 'px' value. | ||
* | ||
* @internal | ||
*/ | ||
export function toPx( value: number ): string { | ||
return value.toFixed( 2 ).replace( /\.?0+$/, '' ) + 'px'; | ||
} |
2 changes: 1 addition & 1 deletion
2
...ste-from-office/tests/_data/basic-styles/bold-within-text/normalized.safari.word2016.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><span>Some text <b>with bold</b>.<o:p></o:p></span></p> | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><span>Some text <b>with bold</b>.</span></p> |
2 changes: 1 addition & 1 deletion
2
...tor5-paste-from-office/tests/_data/basic-styles/bold-within-text/normalized.word2016.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<p> | ||
<span lang=PL>Some text <b>with bold</b>.<o:p></o:p></span> | ||
<span lang=PL>Some text <b>with bold</b>.</span> | ||
</p> |
2 changes: 1 addition & 1 deletion
2
...from-office/tests/_data/basic-styles/italic-starting-text/normalized.safari.word2016.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><i><span>Italic</span></i><span>text.<o:p></o:p></span></p> | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><i><span>Italic</span></i><span>text.</span></p> |
2 changes: 1 addition & 1 deletion
2
...-paste-from-office/tests/_data/basic-styles/italic-starting-text/normalized.word2016.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<p> | ||
<i><span lang=PL>Italic</span></i> | ||
<span lang=PL> text.<o:p></o:p></span> | ||
<span lang=PL> text.</span> | ||
</p> |
6 changes: 3 additions & 3 deletions
6
...office/tests/_data/basic-styles/multiple-styles-multiline/normalized.safari.word2016.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><span>Line <b>bold</b>and <i>italics</i><o:p></o:p></span></p> | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><span>Line <b><u>foo</u></b><u>bar</u><o:p></o:p></span></p> | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><s><span lang="EN-US">Third</span></s><span lang="EN-US">line <b>styling, <i>space on e</i>nd </b><o:p></o:p></span></p> | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><span>Line <b>bold</b>and <i>italics</i></span></p> | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><span>Line <b><u>foo</u></b><u>bar</u></span></p> | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><s><span lang="EN-US">Third</span></s><span lang="EN-US">line <b>styling, <i>space on e</i>nd </b></span></p> |
6 changes: 3 additions & 3 deletions
6
...e-from-office/tests/_data/basic-styles/multiple-styles-multiline/normalized.word2016.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<p> | ||
<span lang=PL>Line <b>bold</b> and <i>italics</i><o:p></o:p></span> | ||
<span lang=PL>Line <b>bold</b> and <i>italics</i></span> | ||
</p> | ||
|
||
<p> | ||
<span lang=PL>Line <b><u>foo</u></b><u> bar</u><o:p></o:p></span> | ||
<span lang=PL>Line <b><u>foo</u></b><u> bar</u></span> | ||
</p> | ||
|
||
<p><s>Third</s> line <b>styling, <i>space on e</i>nd </b><o:p></o:p></p> | ||
<p><s>Third</s> line <b>styling, <i>space on e</i>nd </b></p> |
2 changes: 1 addition & 1 deletion
2
...fice/tests/_data/basic-styles/multiple-styles-single-line/normalized.safari.word2016.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><span>Text <b><u>containi<s>ng</s></u></b><s><u>multi</u>ple </s><i>styling</i>.<o:p></o:p></span></p> | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><span>Text <b><u>containi<s>ng</s></u></b><s><u>multi</u>ple </s><i>styling</i>.</span></p> |
2 changes: 1 addition & 1 deletion
2
...from-office/tests/_data/basic-styles/multiple-styles-single-line/normalized.word2016.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<p> | ||
<span lang=PL>Text <b><u>containi<s>ng</s></u></b><s><u> multi</u>ple </s><i>styling</i>.<o:p></o:p></span> | ||
<span lang=PL>Text <b><u>containi<s>ng</s></u></b><s><u> multi</u>ple </s><i>styling</i>.</span> | ||
</p> |
2 changes: 1 addition & 1 deletion
2
...office/tests/_data/basic-styles/strikethrough-ending-text/normalized.safari.word2016.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><span>Text <s>incorrect</s><o:p></o:p></span></p> | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><span>Text <s>incorrect</s></span></p> |
2 changes: 1 addition & 1 deletion
2
...e-from-office/tests/_data/basic-styles/strikethrough-ending-text/normalized.word2016.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<p><span lang=PL>Text <s>incorrect</s><o:p></o:p></span></p> | ||
<p><span lang=PL>Text <s>incorrect</s></span></p> |
2 changes: 1 addition & 1 deletion
2
...aste-from-office/tests/_data/basic-styles/underlined-text/normalized.safari.word2016.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><u><span>Whole text underlined<o:p></o:p></span></u></p> | ||
<p style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><u><span>Whole text underlined</span></u></p> |
2 changes: 1 addition & 1 deletion
2
...itor5-paste-from-office/tests/_data/basic-styles/underlined-text/normalized.word2016.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<p> | ||
<u><span lang=PL>Whole text underlined<o:p></o:p></span></u> | ||
<u><span lang=PL>Whole text underlined</span></u> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.