Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paste from word now respect enter_br mode #826

Merged
merged 10 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions plugins/pastefromword/filter/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@
style[ 'mso-list' ].match( /level/ ) ) {
container.attributes[ 'cke-list-level' ] = style[ 'mso-list' ].match( /level(\d+)/ )[1];
}

// Adapt paragraph formatting to editor's convention according to enter-mode (#423).
if ( editor.config.enterMode == CKEDITOR.ENTER_BR ) {
// We suffer from attribute/style lost in this situation.
delete element.name;
element.add( new CKEDITOR.htmlParser.element( 'br' ) );
}

}

Style.createStyleStack( element, filter, editor );
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<strong><em>Paste from Word<br />Next</em></strong><br />
<strong><em>Totally new</em></strong>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><i style='mso-bidi-font-style:normal'>Paste from word<br>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's correct fixture for Firefox. It should like like the one from Chrome, containing all HTML as Firefox also supports fetching HTML from native dataTransfer.

Next<o:p></o:p></i></b></p>

<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><i style='mso-bidi-font-style:normal'>Totally new<o:p></o:p></i></b></p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<font color="#000000" face="Times New Roman" size="3">

</font><p style="margin: 0in 0in 8pt;"><b style="mso-bidi-font-weight: normal;"><i style="mso-bidi-font-style: normal;"><font face="Calibri"><font color="#000000" size="3">Paste from word<br></font><font color="#000000" size="3">
Next</font></font></i></b></p><font color="#000000" face="Times New Roman" size="3">

</font><p style="margin: 0in 0in 8pt;"><b style="mso-bidi-font-weight: normal;"><i style="mso-bidi-font-style: normal;"><font color="#000000" face="Calibri" size="3">Totally new</font></i></b></p><font color="#000000" face="Times New Roman" size="3">

</font>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<P style="MARGIN: 0in 0in 8pt" class=MsoNormal><B style="mso-bidi-font-weight: normal"><I style="mso-bidi-font-style: normal"><FONT size=3><FONT color=#000000>Paste from word<BR>Next<o:p></o:p></FONT></FONT></I></B></P>
<P style="MARGIN: 0in 0in 8pt" class=MsoNormal><B style="mso-bidi-font-weight: normal"><I style="mso-bidi-font-style: normal"><FONT size=3><FONT color=#000000>Totally new<o:p></o:p></FONT></FONT></I></B></P>
39 changes: 39 additions & 0 deletions tests/plugins/pastefromword/generated/enter_br.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* bender-tags: clipboard,pastefromword */
/* jshint ignore:start */
/* bender-ckeditor-plugins: pastefromword,ajax,basicstyles,toolbar */
/* jshint ignore:end */
/* bender-include: _lib/q.js,_helpers/promisePasteEvent.js,_helpers/assertWordFilter.js,_helpers/createTestCase.js */
/* bender-include: _helpers/createTestSuite.js */
/* global createTestSuite */

( function() {
'use strict';

var config = {
language: 'en',
colorButton_normalizeBackground: false,
allowedContent: 'p strong em',
enterMode: CKEDITOR.ENTER_BR
};

bender.editor = {
config: config
};

bender.test( createTestSuite( {
browsers: [
'chrome',
'firefox',
'ie11',
'ie8'
],
wordVersions: [
'word2016'
],
tests: {
'Enter_BR': true
},

compareRawData: false
} ) );
} )();
8 changes: 8 additions & 0 deletions tests/plugins/pastefromword/manual/enterbr.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<textarea cols="80" id="editor1" name="editor1" rows="10">
Hello World
</textarea>
<script>
var editor = CKEDITOR.replace( 'editor1', {
enterMode: CKEDITOR.ENTER_BR
} );
</script>
14 changes: 14 additions & 0 deletions tests/plugins/pastefromword/manual/enterbr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@bender-tags: bug, 4.7.3, word
@bender-ui: collapsed
@bender-ckeditor-plugins: pastefromword,toolbar,basicstyles,wysiwygarea,sourcearea

----
1. Open [docx file](https://github.com/ckeditor/ckeditor-dev/blob/master/tests/plugins/pastefromword/generated/_fixtures/Enter_BR/Enter_BR.docx) in Microsft Word.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use relative path as this one is not working currently.

1. Copy text from file and paste it to editor.
1. Check Source in editor.

**Expected:** There is no `<p>` tags in source. Every pparagraph is replaced wit `<br />`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, fix typos.


**Unexpected:** There are `<p>` tag after paste.