Skip to content

Commit

Permalink
Do not show embed intent when editing is disabled
Browse files Browse the repository at this point in the history
fixes #129
  • Loading branch information
bantic committed Sep 16, 2015
1 parent 7600a1f commit 0f18698
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/js/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ class Editor {
* programmatic API is still permitted.
*
* @method disableEditing
* @return undefined
* @public
*/
disableEditing() {
Expand Down
1 change: 1 addition & 0 deletions src/js/views/embed-intent.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class EmbedIntent extends View {
const embedIntentHandler = () => {
const { editor } = this;
if (this._isDestroyed || editor._isDestroyed) { return; }
if (!editor.isEditable) { return; }

let showElement;

Expand Down
19 changes: 19 additions & 0 deletions tests/acceptance/embed-intent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,22 @@ test('clicking in empty mobiledoc shows embed intent', (assert) => {
});
});
});

test('when editing is disabled, embedIntent does not show', (assert) => {
const done = assert.async();
const mobiledoc = Helpers.mobiledoc.build(({post}) => post());
editor = new Editor({mobiledoc});
editor.disableEditing();
editor.render(editorElement);

assert.hasElement('#editor', 'precond - editor');
assert.hasNoElement('#editor p', 'precond - editor has no p');

Helpers.dom.moveCursorTo($('#editor')[0]);
Helpers.dom.triggerEvent(document, 'click');

setTimeout(() => {
assertHasNoEmbedIntent(assert, 'embed intent not shown');
done();
});
});

0 comments on commit 0f18698

Please sign in to comment.