-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
💡Indent inline text on tab key pressed #1163
Comments
Hi, this might be a solution for your problem: turn off the editor tab eventYou may need to modify the original editor.js code library.
public get INTERNAL_SETTINGS(): {[name: string]: string} {
return {
IS_ENABLED_LINE_BREAKS: 'enableLineBreaks',
IS_DISABLED_DEFAULT_TAB_EVENT: 'disableDefaultTabEvent', // the new config
IS_INLINE: 'isInline',
TITLE: 'title',
SHORTCUT: 'shortcut',
TOOLBOX: 'toolbox',
SANITIZE_CONFIG: 'sanitize',
CONVERSION_CONFIG: 'conversionConfig',
};
}
if (tool && tool[Tools.INTERNAL_SETTINGS.IS_DISABLED_DEFAULT_TAB_EVENT]) {
event.preventDefault();
return;
}
editing in your own project
static get disableDefaultTabEvent() {
return true;
}
if (e.code === 'Tab') {
this.yourIndentInsertFunction()
} |
Thanks for your suggestion! I'm wondering is this possible to make it as a feature to eliminate my need to permanently maintaining my own fork. |
Tab indent might be a bit troublesome in a contentEditable div. I tried my own indentInsertFunction. It works well in Chrome but failed in Safari. After inserting indents, the caret is automatically jumping to the end of the block. I did not figure out why this happened. Hope someone could make Tab indent as a feature as well. |
Actually the same problem present when you try to tab a textarea. I've added a custom code block plugin to my application and found it impossible to use tab in it – the keypresses are just hijacked by the editor.js engine. |
I've found this issue #927 which seems to relevant to this issue as well. There is a small code-snippet where I have deactivated the editor.js TAB functionality and use it only while a toolbox is open. Maybe this can help to catch the tab-event in your custom module. Code reference is here: christoph-kluge@405cd85) |
Thank you @christoph-kluge, I have seen this ticket. However, this workaround assumes that I maintain my own copy/fork of editor.js just to apply this patch. I'm afraid this is far from a scalable solution because at least it would be my responsibilty to keep my copy/fork up to date. It would be much better if the option provided by the library itself. |
@tommiv I see. Just wanted to give you an heads up how to achieve it. In my case I do only update the library every now and then when there is something relevant for me in a new release. In this case my personal effort is fine and I'm trying to add support for my own relevant features. |
solution above works but backspacing is problematic - the block prior just disappears |
Describe a problem.
When I press the tab key in a new line, it shows a toolbar but I'd like the text to indent as a nested block.
Describe the solution you'd like. Mockups are welcome.
It's handy to make the inline text to indent after the tab key is pressed - this behavior can be seen in both Notion and Roam Research. Maybe make key shortcuts configurable to render customized actions?
Are there any alternatives?
Or make it as an Inline Tool? But as a markdown user I'd prefer to have quick typing without too many keystrokes for styling.
The text was updated successfully, but these errors were encountered: