Open raulmabe-labhouse opened 1 year ago
@raulmabe-labhouse can you look at the current state of Super Editor on GitHub and let me know if you're able to accomplish these goals? We've introduced an edit pipeline, which has requests, commands, and reactions. You still don't have direct access to the IME behaviors, but I think you might have enough access to accomplish the goals you listed in this ticket.
You are right, with the current edit pipeline our features can be accomplished through some custom commands and reactions.
However, we still have to adapt our code to undo some default logic from Super Editor (i.e. pressing enter
on a paragraph node) because this default logic sits at the start of the pipeline and developers can not opt out for this logic.
I guess that my main pro with my approach with EditRules
is that they sit before this default logic, allowing us (developers) to opt out for this default logic Super Editor has.
Can you please provide two code examples: First, the current workaround that you have to do with Super Editor that you'd prefer not to do. Second, a hypothetical example demonstrating your ideal setup?
Sounds good, I will as soon as I have some spare time 👍🏼
Description of the feature
For our company it would be necessary that SuperEditor allows us to customise the experience of the editor.
For example, if the user presses
enter
(on its software OR hardware keyboard) after a header, the editor will add aListItemNode
afterwards automatically.Another example would be to split a
TaskNode
when the user pressesenter
while the selection is inside aTaskNode
. As far as I know this is only available throughkeyboardActions
right now, which are only valid for Hardware Keyboards.Proposed solution
For this purpose Flutter Quill uses "rules". These rules are executed as a chain of responsibility and each one of these rules have access to the delta text.
Once #870 is merged, I propose to add a new concept called
EditorRule
, which would look like this:Then, the
DocumentEditor
would accept these rules through its constructor, and delegate the execution of these rules to aSoftwareKeyboardHandler
or aHardwareKeyboardHandler
.In my case I just added these two lines
on the
applyDeltas
method:Usage
Now we are able to add the
SplitTaskRequest
whenever we detect the user has pressedenter
while the selection is in aTaskNode
:Opinions