Skip to content

Commit

Permalink
fix(paste): Fix bug #498: Pasting into an empty Mobiledoc via the bro…
Browse files Browse the repository at this point in the history
…wser File menu does not work (#499)

* Fix typo in documentation about Grammarly.

* Fix bug #498

* Retry build.
  • Loading branch information
YoranBrondsema authored and bantic committed Oct 11, 2016
1 parent 8a3633e commit c75711c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ parsed by the next plugin or the default parser.
## Caveats

### Mobiledoc-kit and the Grammarly extension
`mobiledoc-kit` and the [Grammarly extension](https://www.grammarly.com/) do not play well together (see [issue 422](https://github.com/bustlelabs/mobiledoc-kit/issues/422)). Until this is resolved, you can avoid any such problems by disabling Grammarly for the `mobiledoc-kit` instances on your page. To do this, add the `data-gram="false"` attribute to the `mobiledoc-kit` main DOM element.
`mobiledoc-kit` and the [Grammarly extension](https://www.grammarly.com/) do not play well together (see [issue 422](https://github.com/bustlelabs/mobiledoc-kit/issues/422)). Until this is resolved, you can avoid any such problems by disabling Grammarly for the `mobiledoc-kit` instances on your page. To do this, add the `data-gramm="false"` attribute to the `mobiledoc-kit` main DOM element.

## Contributing

Expand Down
5 changes: 5 additions & 0 deletions src/js/editor/event-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ export default class EventManager {
if (!range.isCollapsed) {
editor.performDelete();
}

if (editor.post.isBlank) {
editor._insertEmptyMarkupSectionAtCursor();
}

let position = editor.range.head;
let targetFormat = this.modifierKeys.shift ? 'text' : 'html';
let pastedPost = parsePostFromPaste(event, editor, {targetFormat});
Expand Down
14 changes: 14 additions & 0 deletions tests/acceptance/editor-copy-paste-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ test('paste plain text with list items', (assert) => {
assert.hasElement('#editor ul li:contains(def)', 'list item is pasted');
});

test('paste plain text into an empty Mobiledoc', (assert) => {
const mobiledoc = Helpers.mobiledoc.build(
({post}) => {
return post();
});
editor = new Editor({mobiledoc});
editor.render(editorElement);

Helpers.dom.setCopyData(MIME_TEXT_PLAIN, 'abc');
Helpers.dom.triggerPasteEvent(editor);

assert.hasElement('#editor p:contains(abc)', 'pastes the text');
});

test('can cut and then paste content', (assert) => {
const mobiledoc = Helpers.mobiledoc.build(
({post, markupSection, marker}) => {
Expand Down

0 comments on commit c75711c

Please sign in to comment.