You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow the third argument to editor.registerCommand() to take an object that includes the priority as well as the update options. registerCommand() could then be called as follows:
This would let us manage the command with more finesse, in situations where we need to use these options to narrow the scope of the command's changes.
For my current use case, I have an update listener that submits user input to the server. I also have a command that updates the editor with data from the server. While the command is operating, I don't want the listener to be active, or else it creates a feedback loop.
Currently I'm setting a flag in the command, and the update listener knows not to send to the server while that flag is set. I want to be able to unset the flag in an onUpdate callback function, but can't do so directly in the command. Right now I queue a microtask to do so, but that seems "unLexical."
The text was updated successfully, but these errors were encountered:
I think the biggest issue here is that you can register multiple listeners for the same command and it doesn't always make sense to combine these sorts of options (skipTransforms and discrete aren't very composable, if any update has them then its effect happens for all updates in that batch).
Having it be possible to add an onUpdate from within an update makes sense, I think a better solution for that would be to have a dollar function to do that. The implementation would be basically function $addOnUpdate(fn) { $getEditor()._deferred.push(fn); }
I don't think a new issue needs to be created, if you wanted to create a PR for it with a test then it would probably happen quickly. I didn't think too much about the name, maybe $onUpdate or $afterUpdate would be more clear.
Description
Allow the third argument to
editor.registerCommand()
to take an object that includes the priority as well as theupdate
options.registerCommand()
could then be called as follows:or
This would let us manage the command with more finesse, in situations where we need to use these options to narrow the scope of the command's changes.
For my current use case, I have an update listener that submits user input to the server. I also have a command that updates the editor with data from the server. While the command is operating, I don't want the listener to be active, or else it creates a feedback loop.
Currently I'm setting a flag in the command, and the update listener knows not to send to the server while that flag is set. I want to be able to unset the flag in an
onUpdate
callback function, but can't do so directly in the command. Right now I queue a microtask to do so, but that seems "unLexical."The text was updated successfully, but these errors were encountered: