From d07c54918d0eefce3da8aff2b53bc69c8c1c3429 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Wed, 16 May 2018 21:37:48 +0200 Subject: [PATCH] Indent, outdent fixes --- .../client/components/rte/lib/dom.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/talk-plugin-rich-text/client/components/rte/lib/dom.js b/plugins/talk-plugin-rich-text/client/components/rte/lib/dom.js index a5fbec19e..c82b13d59 100644 --- a/plugins/talk-plugin-rich-text/client/components/rte/lib/dom.js +++ b/plugins/talk-plugin-rich-text/client/components/rte/lib/dom.js @@ -381,9 +381,13 @@ export function isBogusBR(node) { } /** - * Returns an array of all nodes after `node`. + * Returns an array of all nodes after `node` in a _line_. */ export function getRightOfNode(node) { + if (node.tagName === 'BR') { + return []; + } + let result = []; let cur = node; while ( @@ -515,10 +519,10 @@ export function outdentBlock(node, changeSelection) { // A new lines to substitute the missing block element. const needLineAfter = - node.nextSibling && - !isBlockElement(node.nextSibling) && - node.lastChild && - !isBlockElement(node.lastChild); + !node.lastChild || + (node.nextSibling && + !isBlockElement(node.nextSibling) && + !isBlockElement(node.lastChild)); const needLineBefore = node.previousSibling && !isBlockElement(node.previousSibling) &&