mobiledoc-kit
mobiledoc-kit copied to clipboard
Can't detect ul and ol active sections
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.
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.