Skip to content

Commit

Permalink
Fix bug #395
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoran Brondsema committed May 11, 2016
1 parent a6f3944 commit 7b0b97d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
18 changes: 10 additions & 8 deletions src/js/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const CALLBACK_QUEUES = {
};

/**
* The Editor is a core component of mobiledoc-kit. After instantiating
* The Editor is a core component of mobiledoc-kit. After instantiating
* an editor, use {@link Editor#render} to display the editor on the web page.
*
* An editor uses a {@link Post} internally to represent the displayed document.
Expand Down Expand Up @@ -409,14 +409,16 @@ class Editor {
* @private
*/
_notifyRangeChange() {
this._resetRange();
this._editState.reset();
if (this.isEditable) {
this._resetRange();
this._editState.reset();

if (this._editState.rangeDidChange()) {
this._rangeDidChange();
}
if (this._editState.inputModeDidChange()) {
this._inputModeDidChange();
if (this._editState.rangeDidChange()) {
this._rangeDidChange();
}
if (this._editState.inputModeDidChange()) {
this._inputModeDidChange();
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions tests/acceptance/editor-selections-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test('selecting across sections is possible', (assert) => {
assert.equal(editor.activeSections.length, 2, 'selects 2 sections');
});

test('selecting outside of the editor is possible when editing is disabled', (assert) => {
test('when editing is disabled, the selection detection code is disabled', (assert) => {
$('#qunit-fixture').append('<p>outside section</p>');

editor = new Editor({mobiledoc: mobileDocWithSection});
Expand All @@ -67,11 +67,12 @@ test('selecting outside of the editor is possible when editing is disabled', (as
let firstSection = $('p:contains(one trick pony)')[0];
let outsideSection = $('p:contains(outside section)')[0];

Helpers.dom.selectText(editor ,'one', firstSection,
Helpers.dom.selectText(editor ,'trick', firstSection,
'outside', outsideSection);

Helpers.dom.triggerEvent(document, 'mouseup');
assert.equal(editor.activeSections.length, 1, 'selects 1 section');
assert.equal(editor.activeSections.length, 0, 'no selection inside the editor');
assert.equal(Helpers.dom.getSelectedText(), "trick pony\n\noutside");
});

test('selecting an entire section and deleting removes it', (assert) => {
Expand Down

0 comments on commit 7b0b97d

Please sign in to comment.