mobiledoc-kit icon indicating copy to clipboard operation
mobiledoc-kit copied to clipboard

Can't detect ul and ol active sections

Open ef4 opened this issue 9 years ago • 1 comments

When editing inside a ul or ol block, editor.activeSections only returns the current li, and not its parent list element. This prevents a toolbar implementation from properly showing active buttons for these list elements.

ef4 avatar Jan 24 '16 22:01 ef4

A workaround is to detect when the activeSection isNested, and map its parent.tagName, e.g.:

let sections = editor.activeSections;
let tagNames = sections.map(section => {
  return section.isNested ? section.parent.tagName : section.tagName;
});

{{ember-mobiledoc-editor}} does this as well (see https://github.com/bustlelabs/ember-mobiledoc-editor/pull/74)

Related: #359 fixed a bug in the inputModeDidChange hook to ensure that it fires when changing from one type of list section to another.

bantic avatar Apr 14 '16 16:04 bantic