-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Enable "tab" key #1197
Comments
Could you write more? What would you like that Tab key do? The tab is already supported in some of editor's features. |
i mean when we are in paragraph text then on tab can we add "\t" to paragraph (or something like indent feature so that we can move text line to right by "\t" or no. of spaces ). |
It could have some configuration on what should happen. |
yes @dkrahn and that's my current/urgent (since i already chose ckeditor5 for our website and i can not leave it in between) requirement to have it in editor. with some try/trick and logic somehow i able to enable it by both way ( one is with toolbar button like indent and another one with tab key event listener ) and it working fine for me now. but still i don't know the correct way to do it since their are many listeners working at the same time which operate conditionally on prev, current/next states. for now this trick works but i'll wait for complete tab support in next official release. |
Isn't it a problem that the I'll add that in CKE4 Tab by default inserts a configurable number of spaces. Would that be reasonable for you? Or would it be better if Tab set the |
There's also text-indent property: https://www.w3schools.com/cssref/pr_text_text-indent.asp |
@Reinmar @scofalik no. of spaces option
or as @scofalik say
either we can use for paragraph, but for code-blocks we need to enable \t. ( actually i am using pre code-block to enable longer code/program writing feature for editor and its my company requirement for editor to have \t on tab key while writing program/code. so it is just like if ckeditor5 enable \t by default then it will remove my overhead tricks to enable it ) . its just my suggestion. |
That should be handled by your plugin, then. The editor would need to guess whether you're in a preformatted text or in a normal paragraph. That semantics is not available in the model and might need to be obtained from the view, but I'd like if we avoided that cause it may not be reliable. Plus, we'd never know whether one wants to insert tabs or spaces and how many. So, if you're implementing a code block feature, you should handle the Tab key in it. The editor may by default only handle Tab as in a normal text. And it's still an open topic what should that do. |
sure, it was just suggestion. currently to fulfill office requirement i managed \t with below things. const editor = this.editor;
const view = editor.editing.view;
const viewDocument = view.document;
viewDocument.on( 'keydown', ( evt, data ) => {
if( (data.keyCode == keyCodes.tab) && viewDocument.isFocused ){
// with white space setting to pre
editor.execute( 'input', { text: "\t" } );
// editor.execute( 'input', { text: " " } );
evt.stop(); // Prevent executing the default handler.
data.preventDefault();
view.scrollToTheSelection();
}
} ); we can replace \t by no. of spaces too but when user press back then its notable difference that he/she needs to press no. of times back button to delete one tab spaces. |
Another TC: #6724 (pasting text with |
@Reinmar can we able to create a soft tab model element which will act as fixed character \t text node in view and vice versa ? But till now whatever ckeditor5 team had done is great...! Thanks to all of you |
For our use case, adding spaces works for code-blocks since the font-style is mono-spaced. For editing regular content and attempting to align it, we can't ensure that 4 spaces on one line will give the same exact width as 4 spaces on another. |
when ckeditor5 will release their official tab key feature ?
The text was updated successfully, but these errors were encountered: