Reputation: 3198
How can I convert an existing paragraph or text element to list item? where the cursor is placed.
if (cursor) {
var someElement = cursor.getElement();
//someElement is a paragraph or text element
}
Upvotes: 0
Views: 642
Reputation: 1280
Basically you have to build a newList item out of the text, and then swap them. Should look roughly like this:
var location = body.getChildIndex(yourParagraph);
var pText = yourParagraph.getText();
var lItem = body.appendListItem();
lItem.setText(pText);
body.insertListItem(location, lItem);
You might have to fiddle with this a little. But this is the general idea you are looking for, I think.
Upvotes: 1