SCEditor
SCEditor copied to clipboard
Feature Request: enterMode option
@samclarke If you could put it in priority. Many in Mybb are complaining about this differentiated behavior that has in SCEditor using Chrome. http://community.mybb.com/thread-159045.html
Something this that has in CKEditor : http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-enterMode
To avoid something this: https://github.com/samclarke/SCEditor/issues/181#issuecomment-57037618
Only SCEditor result in something above using Chrome... makes no sense, just SCEditor act differently. I tried Redactor, CKEditor, WysiBB etc... and not result in something above.
@samclarke plz check this. To avoid create same tag when press enter. https://github.com/samclarke/SCEditor/issues/181#issuecomment-57037618
Personally, as it works now, it seems both are correct ways of expressing the content. Is that wrong? Did I understand wrong what you are trying to show?
@brunoais what logic to put same tag in all line? make sense?
https://github.com/samclarke/SCEditor/issues/181#issuecomment-57106654
Yes.
<i>
is inline Element.
Enter
is to make a new block element (no matter what the browser actually places)
Inline elements must not span through multiple block elements.
Changing that is not viable at all :S.
Use ctrl+Enter
to make a new line.
What can be made, however, is to internally remap Enter
to ctrl+Enter
. Do you want that?
@brunoais you tried other editor? for me not made any sense. Only polute message. And it is not easy to convince all users to press ctrl + enter. This is inconvenience.
you tried other editor?
CKE? Yeah. It is very memory heavy, a bit too slow, at times with loads of code bloat. It is also a huge pain that all buttons are disabled when in source code mode.
Also, you didn't answer my question.
@brunoais my request of this ticket is "Feature Request: enterMode option" but remap Enter to ctrl+enter is ok for me...
@brunoais i'm too i hate cke... but mybb team want change to CKE in mybb 2.0 http://community.mybb.com/thread-168414.html for me is very bad idea... but i can't made anything.
There, I placed there a good question for them to think on. AFAIK, there's no better alternative to SCE. It has its own issues, yes, but that doesn't mean it is not the best one for this purpose.
How do I remap Enter to Ctrl+Enter?
There's currently no such thing... Probably making a shortcut using addShortcut() may work.
@brunoais Nice suggestion! I tried it. It kinda works, but I have a problem.
I use:
this.wysiwygEditorInsertHtml('<br>');
to insert newlines. But somehow when you are typing som text and press enter, nothing happens. You need to use "enter" twice for newline.
But, if there is no text it works as expected. Only need one "enter". Any idea why?
Not really, no. Try checking how the HTML changes as you type. That may help.
I tried it in Firefox and IE11 now. No problem at all. It looks like it is something related to Chrome/Webkit.
Where can I find the code for "shift+enter"?
After some digging I found #248 Somehow I need to reuse some of this logic but do not know how... Any can help?
If the <br>
is the last child of a block and the previous sibling is inline, then the <br>
will be collapsed in all browsers except from IE < 11. In order for the new line to show there needs to be two <br>
elements.
The code to do this is already in the editor so adding an option to enable it for all blocks shouldn't be too difficult.
This is the code that's currently used in the editor to do it is this:
instance.addShortcut('enter', function () {
var currentNode = this.currentBlockNode();
var rangeHelper = this.getRangeHelper();
// Browsers have special handling for list items so exclude them
if ($(currentNode).is('li') || $(currentNode.parent).is('li')) {
return;
}
var br = this.getBody()[0].ownerDocument.createElement('br');
rangeHelper.insertNode(br);
// The last <br> of a block will be collapsed if the previous sibling
// is inline (except in IE < 11) so need to make sure the <br> that
// was inserted isn't the last child of a block.
if (!$.sceditor.ie || $.sceditor.ie > 10) {
var parent = br.parentNode;
var lastChild = parent.lastChild;
// Sometimes an empty next node is created after the <br>
if (lastChild && lastChild.nodeType === 3 && lastChild.nodeValue === '') {
parent.removeChild(lastChild);
lastChild = parent.lastChild;
}
if (lastChild === br && !$.sceditor.dom.isInline(parent, true) &&
$.sceditor.dom.isInline(br.previousSibling)) {
rangeHelper.insertHTML('<br>');
}
}
return false;
});
problem that in chrome when press enter key create another 'div' blocks. In FF is correct, use same 'div' block.
so ie is not consistent.
sceditor in FF using something like: CKEDITOR.ENTER_BR (2) – lines are broken with 'br' elements;
but in chrome (webkit) using something like: CKEDITOR.ENTER_DIV (3) – new 'div' blocks are created.
What i want, i want that set CKEDITOR.ENTER_BR (2) to all brownser.
http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-enterMode
You're right, it should really have consistent behaviour. I'm just not sure which, if any, should be the default.
Maybe the best solution is to have an option like CKEditor so you can choose between the default browser behaviour, newlines or blocks. It shouldn't be too difficult implement or increase the code size as the code to do it's already there.
@samclarke thanks! Options is better...
+1