I'm trying to make a button for the <li></li> tag using the following:

js: E.wrapLines('\n', '  <li>', '</li>', '\n');

The only problem is, after using the provided ul or ol buttons, using this button inserts the new line and list item in the middle of the existing li. Is there any way to specify to go to the end of line before doing the '\n' (ie '\eol')? I spend some time researching and playing around with this in js, but couldn't get anything to work.

Comments

ufku’s picture

You can get & set cursor position n BUEditor.
For example,

js:
// get cursor position
var pos = E.posSelection();
// Check the right hand side for the closing tag
if (E.getContent().substr(pos.end, 5) == '</li>') {
  // Move cursor to the right by the length of the tag.
  E.makeSelection(pos.end + 5);
}
// Now we can add a new line and the li tag
E.tagSelection('\n  <li>', '</li>');

You may want to use library/bue.li.js if you want to add list items using enter key.

WorldFallz’s picture

Status: Active » Fixed

nice-- i'm more and more impressed by the power and flexibility of this module every time I configure it-- really nice job.

And thanks for the quick response!

Status: Fixed » Closed (fixed)

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