Skip to content

Commit

Permalink
Ensure paragraph is selected for firefox. Also ensure that we select the
Browse files Browse the repository at this point in the history
parent if ever a br tag is the selected element when typing. #1455
  • Loading branch information
Pete Chappell committed Mar 7, 2019
1 parent 9156a11 commit f89381c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@
this.options.ownerDocument.execCommand('formatBlock', false, 'p');
}

// https://github.com/yabwe/medium-editor/issues/1455
// if somehow we have the BR as the selected element, typing does nothing, so move the cursor
if (node.nodeName === 'BR') {
MediumEditor.selection.moveCursor(this.options.ownerDocument, node.parentElement);
}

// https://github.com/yabwe/medium-editor/issues/834
// https://github.com/yabwe/medium-editor/pull/382
// Don't call format block if this is a block element (ie h1, figCaption, etc.)
Expand All @@ -193,6 +199,14 @@
this.options.ownerDocument.execCommand('unlink', false, null);
} else if (!event.shiftKey && !event.ctrlKey) {
this.options.ownerDocument.execCommand('formatBlock', false, 'p');
// https://github.com/yabwe/medium-editor/issues/1455
// firefox puts the focus on the br - so we need to move the cursor to the newly created p
if (MediumEditor.util.isFF) {
var newParagraph = node.querySelector('p');
if (newParagraph) {
MediumEditor.selection.moveCursor(this.options.ownerDocument, newParagraph);
}
}
}
}
}
Expand Down

0 comments on commit f89381c

Please sign in to comment.