diff --git a/spec_integration/contenteditable-integration-spec.es6 b/spec_integration/contenteditable-integration-spec.es6 index 2641b4815..733a7845f 100644 --- a/spec_integration/contenteditable-integration-spec.es6 +++ b/spec_integration/contenteditable-integration-spec.es6 @@ -81,6 +81,19 @@ describe('Contenteditable Integration Spec', function() { }).then(done).catch(done.fail); }); + it("Doesn't create unordered lists with dash when it's not at the start of the composer", (done) => { + this.ce.test({ + keys: ['asdf', 'Space', 'Back space', '-', 'Space'], + expectedHTML: `asdf- `, + expectedSelectionResolver: (dom) => { + return { + node: dom.childNodes[1], + offset: 2, + }; + }, + }).then(done).catch(done.fail); + }); + it('Undoes unordered list creation with backspace', (done) => { this.ce.test({ keys: ['-', 'Space', 'Back space'], @@ -192,6 +205,7 @@ describe('Contenteditable Integration Spec', function() { expectedSelectionResolver: (dom) => { return { node: dom.querySelectorAll('li')[0].childNodes[0], + offset: 1 }; }, }).then(done).catch(done.fail); @@ -204,6 +218,7 @@ describe('Contenteditable Integration Spec', function() { expectedSelectionResolver: (dom) => { return { node: dom.querySelectorAll('li')[0].childNodes[0], + offset: 1 }; }, }).then(done).catch(done.fail); diff --git a/src/components/contenteditable/list-manager.coffee b/src/components/contenteditable/list-manager.coffee index 0cdd78b41..c04992bc6 100644 --- a/src/components/contenteditable/list-manager.coffee +++ b/src/components/contenteditable/list-manager.coffee @@ -40,8 +40,11 @@ class ListManager extends ContenteditableExtension return false unless selection?.anchorNode return false if not selection.isCollapsed - text = selection.anchorNode.textContent - return @numberRegex().test(text) or @bulletRegex().test(text) + sibling = selection.anchorNode.previousElementSibling + if not sibling or DOMUtils.looksLikeBlockElement(sibling) + text = selection.anchorNode.textContent + return @numberRegex().test(text) or @bulletRegex().test(text) + else return false @createList: (editor) -> text = editor.currentSelection().anchorNode?.textContent