I noticed that the autolist button enters additional lines for list items when enter is keyed at the end of a line. this behavior is not reproduced when the button is copied to BBCode. What's up with that & how can I enable it for the same behavior in BBCOde editor?

Thanks

Comments

ufku’s picture

Auto list is implemented in %BUEDITOR/library/bue.li.js. It works for only html lists.
For bbcode a similar implementation could be:

BUE.preprocess.bbcodeAutoList = function(E, $) {
  $(E.textArea).bind('keyup.bue', function(e) {
    if (!e.ctrlKey && !e.shiftKey && !e.originalEvent.altKey && e.keyCode == 13) {
      var prefix = E.getContent().substr(0, E.posSelection().start);
      /\[\*\][^\n\r]*[\n\r][ \t]*$/.test(prefix) && E.tagSelection('[*]', '');
    }
  });
};

You can put this code in a js file and include the path in Editor paths.

Alternatively, you can create a template button to include the javascript code in the page.
Add a button with title tpl:BBcode Auto List, and content:

js:
BUE.preprocess.bbcodeAutoList = function(E, $) {
  $(E.textArea).bind('keyup.bue', function(e) {
    if (!e.ctrlKey && !e.shiftKey && !e.originalEvent.altKey && e.keyCode == 13) {
      var prefix = E.getContent().substr(0, E.posSelection().start);
      /\[\*\][^\n\r]*[\n\r][ \t]*$/.test(prefix) && E.tagSelection('[*]', '');
    }
  });
};
Ashlar’s picture

Thanks. The js was in the library. I did not realize that it was necessary to provide paths for each editor definition separately. Adding the path fixed the problem.

ufku’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.