question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] How to add "Ordered/Unordered List" option in rte/custom block

See original GitHub issue

Hi

I’m trying to create an ordered list with grapesjs. I tried adding the following to the rte:

editor.RichTextEditor.add('orderedList',
{
  icon: '1.',
  attributes: {title: 'Ordered List'},
  result: rte => rte.exec('insertOrderedList')
});

And this works if my page is pre-filled with html when the editor is initialized, like below:

Prefilled Editor: 1

Create Ordered List: 2

If, however, I drop a new block into the canvas, and then press the ordered list button, I get a NS_ERROR_ILLEGAL_VALUE message, like below:

Create new Paragraph Block: 3

Create Ordered List: 4

How can I fix this so that:

  1. we can insert lists in newly created blocks? (Side Note: My example shows me doing this through the rte toolbar, but I am open to making lists into a new block type, if that helps and someone can tell me how to make them work.)
  2. we can indent lists to create multilevel bullets (currently the indent command via the rte also does not work on new blocks, possibly for the same reasons above)
  3. (Optionally) we can use the tab key to indent the lists?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
thomas1204commented, Oct 31, 2019

From the above comments, I can now add ordered and unordered list. Is there any way to update existing ordered and unordered List ?

@artf @rahuloftheramaneffect

0reactions
josfh2005commented, Mar 1, 2021

Oh! Sorry. Here’s the online version: https://jsfiddle.net/qnj1mhkt/

This seems to be a problem with de P tag. With the default text inside the div, works fine in firefox.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add an alpha ordered list option in Redactor?
I am able to add custom formatting (with formattingAdd ) to create <ol class="my-class"></ol> , but I haven't found a way to allow...
Read more >
HTML Bullet Points – How to Create an Unordered List with ...
You create an unordered list using the ul tag. Then, you use the li tag to list each and every one of the...
Read more >
jquery - How to add a list item to an existing unordered list
This would do it: $("#header ul").append('<li><a href="/user/messages"><span class="tab">Message Center</span></a></li>');. Two things:.
Read more >
Styling lists - Learn web development | MDN
Throughout this article, we'll look at unordered, ordered, and description lists — all have styling features that are similar, as well as ...
Read more >
HTML Unordered Lists - W3Schools
Chapter Summary · Use the HTML <ul> element to define an unordered list · Use the CSS list-style-type property to define the list...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found