-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Expose the input
command
#3058
Comments
I think it is cool to have a "fake typing" command, so |
Yep, that's the idea. We badly need it for testing purposes and it can be useful also in other situations. |
Private class |
Nope, input command should not fire anything on view. Input command should be the handler of "text input" behaviour, and there can be multiple user actions which should result in text input. Mutations are just one of those ways. For instance, if we'll want to handle input using the |
I don't want to let For now |
Right now in current, early version of |
Please see the ticket description ;)
The command should only work with a text. All the rest (translation from a mutation to a params which the command accepts should be done inside the input feature. |
Yep, I read it, but couple of things were unclear to me and I had conflicting conclusions. Thanks for confirmation :) (e.g. |
Current, rough version kind of passes the tests, but still needs cleanup and check for CC level. |
It seems, that current refactor broke manual tests. Especially the Undo feature seems to revert just one character per one undo step. This might be connected to moving variable for counting inserted characters, The |
Also, inserting text in the current form, not only expects the range and the text, but also amount of characters to insert/delete (https://github.com/ckeditor/ckeditor5-typing/blob/t/48/src/inputcommand.js#L39). It is also used to decide if we want to remove or insert text. This is extremely ugly, but for now I can't see any better way to do this. When I fix manual tests, I'll focus on fixing this. Any suggestions are welcome. |
Quick, temporary fix confirms my assumption - when I reset |
OK... but without the code your comment makes no sense. You mention |
Here you can find my second approach to the Input refactoring: ckeditor/ckeditor5-typing@712e859?diff=unified. Please look at the part: ckeditor/ckeditor5-typing@712e859?diff=unified#diff-8052e4286a369903aa5d7f6c2d8b7190R154. |
This issue is blocked by https://github.com/ckeditor/ckeditor5-typing/issues/51#issuecomment-252164451. It turned out that we need to change the behaviour of typing quite significantly anyway. |
After looking a little bit into 1. 2.
does it mean the array of ranges should be passed so the command will handle multiple ranges properly? 3. |
That's a very good question. I actually introduces such an observer when I was working on a PoC of the typing feature based on the native |
Yes. The native However, it will be a bit unclear which range should be actually modified by the command, because it's not yet testable in which cases the So, if we're not using multiple ranges now (I think we don't) we can accept one and implement a support for an array of ranges later on. Supporting one range will even be useful, because most of the time you want to modify just one, so there's no need to pass an array. |
The input feature works like this (or at least I think so), currently:
So, the entire 2nd step must be replaced by the command (that's why we're passing range(s) to it, not a position). |
Just one clarificiation – don't confuse that with the "hello wurd" Then the input feature must handle replacing "ur" letters with "orl". So that happens based on mutations. The input command should be executed with range covering the "ur" letters and insert "orl" letters. |
Ok, so no I will stick with single range and we may extend it in the future. I was thinking about support for single range but passing it as an array (so it will be compatible with future changes), however I think it might be a little misleading (what is the point of passing an array if only first element is processed) so I think There is one thing which slightly confuses me in case of integrating |
Handling the keydown event is a job for the plugin itself, not the command. It's a hack which has nothing to do with the input itself if we were using the Please read https://lists.w3.org/Archives/Public/public-editing-tf/2017Feb/0029.html – I described there how this feature works currently. It may shed some light on this for you. |
I pushed a proposal of However, there are still two things I would like to discuss: 1.
Both results are different than in previous implementation. 2. |
First of all, I'd notice that if we have two separate mutations, then it's not currently a problem that the input command will be called twice for them. Such mutations should never occur – they mean that some big part of content changed and I'd doubt that this is a result of typing. For example, as you noticed correctly, the pasting and dnd operations will be handled by separate features (pasting is, in fact, so you can add the clipboard feature to the sample). Regarding the expected buffer change... I'd say that it's most reasonable to count only the positive values. So if you type a text and "a" is replaced by "à" (composition), it's still +1. But really, it's of a low importance – for the buffer size mostly the typed text count. Spell checking and other types of changes are irrelevant as they happen rather infrequently (except autosuggestions on mobiles) and, in fact, they should be counted as separate undo steps AFAIK. |
Yes, definitely. The resulting selection should always be at the end of the inserted text and it's input's commands duty to set it. Hence, it's the input feature's role to pass such data to the command to place the selection correctly. |
Pushed changes based on @Reinmar comments to t/48 branch. Now the buffer size considers only added/typed text. Also the selection setting was moved to
|
Feature: Introduced `InputCommand` which can be used to simulate typing. Closes #48.
Currently, the input feature simply listens on the view events and transforms them into changes on the model. However, this is a pretty complex logic and it's hard to reproduce those behaviours in tests.
The idea is to expose the
input
command, just likedelete
command is exposed by the delete feature.Naming
I've been also considering
insertText
command, however, I see it a bit differently – likeinsertHtml
. Both are used in CKE4 for pasting purposes, so e.g. they create separate undo steps and may process the content in some way.Therefore, for now, let's call the command like we called the feature, so
input
. If we'll see a chance to somehow squash the two things together, then we may do this in the future.The interface
From the command's perspective alone, it should simply accept a:
(Note: Target range concept comes from the native
beforeinput
event: https://github.com/ckeditor/ckeditor5-typing/issues/46)So what the command will do is:
However, I've got some doubts whether it will be possible to extract such command from the current input feature. I hope it will...
The text was updated successfully, but these errors were encountered: