feat: trigger inputrule on enter for code block#1940
feat: trigger inputrule on enter for code block#1940nanokind wants to merge 1 commit intoueberdosis:mainfrom
Conversation
| export default function (options: any = {}) { | ||
| const rules: InputRule[] = options.rules || [] | ||
| const plugin: Plugin = new ProseMirrorPlugin({ | ||
| props: { |
There was a problem hiding this comment.
This is missing the compositionend event in the original inputrule, and well as the isInputRules field which allows undoInputRule to work; as well as the original plugin state. Why not just copy the original plugin and add the handleKeyDown field?
There was a problem hiding this comment.
ProseMirror/prosemirror-inputrules#6
Because marijnh said {enter} is not a kind of inputrule, so I made a standalone plugin
There was a problem hiding this comment.
The origin inputrule plugin is not removed, IMO there is no necessary to add compositionend here maybe.
I'm not familiar with ProseMirror, I'm not sure whether the origin plugin state is needed here 😥
There was a problem hiding this comment.
I'm not sure whether
the origin plugin stateis needed here
The plugin state is kept there so that the undoInputRule function (which is binded to backspace) can work using the setMeta and getMeta fields.
https://prosemirror.net/docs/ref/#state.Transaction.setMeta
https://prosemirror.net/docs/ref/#state.Transaction.getMeta
Because marijnh said {enter} is not a kind of inputrule, so I made a standalone plugin
I think you could argue enter is a type of inputrule, but where the trigger isn't an explicit key being entered, but an implicit key being pressed; plus, you're still using the InputRule abstraction, just handling / running it differently.
|
I currently working on a re-write of Inputrules and Pasterules. I’ve already implemented this feature in that branch based on this solution (thanks @BrianHung 😀). So I don’t want to merge this. Thank you anyway! |
Support using {space} or {enter} to trigger inputrule
related issue: #1107