-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 mobile paste #1229
Fix mobile paste #1229
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just minor comments, as I had a quick look.
That was a really quick turnaround, nice!
We're missing integration with context menu options.
plugins/clipboard/plugin.js
Outdated
} | ||
|
||
CKEDITOR.tools.array.forEach( editor._.pasteButtons, function( name ) { | ||
var pasteButton = editor.ui.get( name ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function might return undefined
, for instance you could have clipboard plugin, but no "Paste" (or related) button in the toolbar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In such case editor._.pasteButtons
should be empty or undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check /tests/plugins/clipboard/manual/missingbutton manual test in t/595-nobutton branch.
I extracted context menu integration to #1347. |
Before merging/closing this ticket #1347 should be covered and merged here. |
Rebased onto latest 4.9.0 branch. Changed the base of this PR accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated tags in tests, API docs etc. Generally good job, it works reliably.
The good
- I see that at the same time you took the chance to remove old Opera-related timeouts. Good idea, any
setTimeout
removed is a win for us, and reduced complexity. 👍
Missed things
- Change paste dialog message, it says about keyboard. Well it should either about the touch, or just about the native ways to do that.
Notices/discussion
- Talking about cleanup, this
evt.cancel()
call doesn't have much sense as the only place firing thepasteDialogCommit
event is paste dialog and it doesn't care whether event was canceled or not. WDYT? - Doesn't work on Edge/IE11 but it's fine as we do not officially support them. So that's not an issue.
plugins/clipboard/dialogs/paste.js
Outdated
this.customTitle = null; | ||
|
||
// Reset commited indicator. | ||
this._.commited = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commited
-> committed
The fix has to be applied across entire PR.
@@ -427,12 +440,19 @@ | |||
* an upcoming major release. | |||
*/ | |||
editor.getClipboardData = function( callbackOrOptions, callback ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function signature once again changed, now we're using options once again…
That's a messy situation and we should adjust the API docs correctly. I mean that the options argument is again supported, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just dropped handling of options as it was used only to set custom title of paste dialog, which wasn't even working.
if ( pasteButton ) { | ||
var buttonElement = CKEDITOR.document.getById( pasteButton._.id ); | ||
|
||
buttonElement.on( 'touchend', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about optimizing this listener, and putting it once on the entire toolbar and just then check what button was pressed. However after playing a bit with it I start to think that it's too much of effort for the benefit. So I guess it's fine the way it is.
plugins/clipboard/plugin.js
Outdated
} | ||
} ); | ||
|
||
delete editor._.pasteButtons; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not remove this member from the editor, so it could be reused by other plugins if needed this workarounds for mobile.
plugins/clipboard/plugin.js
Outdated
* Internal event to open the Paste dialog window. | ||
* | ||
* @private | ||
* @event pasteDialog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should note that pasteDialog
event was not available in 4.7.0 - 4.8.0 versions.
* @param {String} name Name of the button. | ||
* @param {Object} definition Definition of the button. | ||
*/ | ||
addPasteButton: function( editor, name, definition ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addPasteButton
should return created CKEDITOR.ui.button
instance, so that we could use it for instance with Balloon Toolbar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to the super convoluted way of accessing button instance from our UI, we decided to not introduce this change. Info gathered from editor._.pasteButtons
should be enough to create buttons for Balloon Toolbar.
It was a part of whole dialog logic from the beginning and revert of dialog deletion brought it back. Honestly I also don't see much sense in it, but I was just afraid to touch it 😄 However it seems that removing it does not change anything. |
Actually I located the issue: without this |
I've added unit test for |
Thanks for the research. I have rebased onto latest major. There was an issue that on IE unit tests would trigger a security dialog (request for allowing the paste). I have stubbed the I'll wait with a final R+ for #1347. |
Paste dialog context menu integration for mobile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Unfortunately, this will reintroduce all the clipboard plugin that we wanted to remove in 4.7.0 - but we can't break pasting on mobiles.
What is the purpose of this pull request?
Bug fix
Does your PR contain necessary tests?
All patches which change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.
This PR contains
What changes did you make?
I've added back our beloved paste dialog. It's shown only if user touches the button (via recognising
touchend
event).There are missing language files entries that should be added before merging. For now only
en
locale is covered.Closes #595.