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

Fix broken paste of plain text in firefox #3525

Merged
merged 5 commits into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Fixed Issues:

* [#3415](https://github.com/ckeditor/ckeditor4/issues/3415): [Firefox] Fixed: Pasting individual list elements fails. Thanks to [Jack Wickham](https://github.com/jackwickham)!
* [#3413](https://github.com/ckeditor/ckeditor4/issues/3413): Fixed: Menu items with labels containing double quotes are rendered incorrectly.
* [#3475](https://github.com/ckeditor/ckeditor4/issues/3475): [Firefox] Fixed: Pasting plain text over existing content fails and throws an error.

## CKEditor 4.13

Expand Down
2 changes: 1 addition & 1 deletion core/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@
// On Webkit&Gecko (#1113) we use focusout which is fired more often than blur. I.e. it will also be
// fired when nested editable is blurred.
editable.attachListener( editable, CKEDITOR.env.webkit || CKEDITOR.env.gecko ? 'focusout' : 'blur', function() {
var isFakeOrSingleSelection = lastSel && ( lastSel.isFake || lastSel.getRanges() < 2 );
var isFakeOrSingleSelection = lastSel && ( lastSel.isFake || lastSel.getRanges().length < 2 );

// Ignore cases that doesn't produce issue in Firefox (#3136).
if ( CKEDITOR.env.gecko && !isInline && isFakeOrSingleSelection ) {
Expand Down
23 changes: 23 additions & 0 deletions tests/core/selection/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,29 @@ bender.test( {
editor.editable().findOne( '#nested' ).focus();

assert.areEqual( 'em', editor.elementPath().blockLimit.getName() );
},

// (#3475)
'test selection with one range should not be locked': function() {
if ( !CKEDITOR.env.gecko ) {
assert.ignore();
}

bender.editorBot.create( {
name: 'plain-text',
config: {
plugins: 'wysiwygarea,clipboard,toolbar'
}
}, function( bot ) {
var editor = bot.editor,
editable = editor.editable();

bot.setHtmlWithSelection( '<p>foo [bar] baz</p>' );

editable.fire( 'focusout' );

assert.areEqual( 0, editor.getSelection().isLocked, 'Simple selection should not be locked' );
} );
}
} );

Expand Down
12 changes: 12 additions & 0 deletions tests/core/selection/manual/plaintextpasteinfirefox.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<input type="text" value="test" readonly>
<div id="editor1">
<p>Foo Bar Baz</p>
</div>

<script>
if ( !CKEDITOR.env.gecko ) {
bender.ignore();
}

CKEDITOR.replace( 'editor1' );
</script>
14 changes: 14 additions & 0 deletions tests/core/selection/manual/plaintextpasteinfirefox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@bender-tags: selection, 4.13.1, bug, 3475
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, undo, clipboard

1. Open browser's dev console.
1. Select text in the input above the editor and copy it with <kbd>CTRL</kbd>/<kbd>CMD</kbd>+<kbd>C</kbd>.
1. Make **non-collapsed** selection in the editor, for example over a `Bar` word.
1. Paste previously copied text.

### Expected:
Text is correctly pasted into editor.

### Unexpected
The error is thrown in the console.
2 changes: 1 addition & 1 deletion tests/core/selection/manual/tableselection.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@bender-tags: selection, 4.13.0, bug, 3136
@bender-tags: selection, 4.13.0, 4.13.1, bug, 3136, 3475
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, table, tabletools, toolbar

Expand Down