Medium.js icon indicating copy to clipboard operation
Medium.js copied to clipboard

How to use <li>

Open andraaspar opened this issue 10 years ago • 3 comments

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?

andraaspar avatar Jan 06 '15 16:01 andraaspar

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
  1. 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
      1. .

    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

robertleeplummerjr avatar Jan 06 '15 20:01 robertleeplummerjr

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?

andraaspar avatar Jan 07 '15 11:01 andraaspar

Also having this issue.

benplum avatar Jan 20 '15 20:01 benplum