How to use <li>
I've been attempting to create a toolbar button for Medium.js that would wrap the selected paragraphs into an <ol> and <li>s. I was using invokeElement().
I have had various difficulties. Like:
- In Chrome, I would get separate lists, each wrapped in a
<p>. Ideally, I wanted<p>s to be replaced with<li>s in an<ol>. - IE11 sometimes does not create
<ol>or<li>.
So I'd like to ask, is there an official way of doing this?
Interesting read: http://stackoverflow.com/questions/5681481/should-ol-ul-be-inside-p-or-outside Wouldn't the best option be to put them beside each other? Or to toggle them from one type (p) to the other (ol/ul)?
On Tue, Jan 6, 2015 at 11:49 AM, andraaspar [email protected] wrote:
I've been attempting to create a toolbar button for Medium.js that would wrap the selected paragraphs into an
and
- s. I was using invokeElement().
I have had various difficulties. Like:
- In Chrome, I would get separate lists, each wrapped in a
. Ideally, I wanted
s to be replaced with
- s in an
.
- IE11 sometimes does not create
or
- .
So I'd like to ask, is there an official way of doing this?
— Reply to this email directly or view it on GitHub https://github.com/jakiestfu/Medium.js/issues/127.
Robert Plummer
I think this will be easier to discuss over a fiddle.
This is as far as I got with my implementation. As you can see, it makes heavy use of jQuery. It almost works in Chrome and Firefox, but fails in IE11.
Bugs:
- Incorrect markup is produced when invoking
editor.invokeElement('ol').invokeElement('li');. The result is<p><ol><li>× 2, whereas the expected result would be<ol><li><li>. This is worked around using jQuery. <b>tags, and their contents are removed.- IE11 does not do anything beyond selecting the two paragraphs. Interestingly, double clicking the button does seem to trigger the conversion – but not the conversion back.
What would be the right way to do this?
Also having this issue.