diff --git a/plugins/talk-plugin-rich-text/client/components/rte/features/Bold.js b/plugins/talk-plugin-rich-text/client/components/rte/features/Bold.js index 8f5b55de5..fe072e2b1 100644 --- a/plugins/talk-plugin-rich-text/client/components/rte/features/Bold.js +++ b/plugins/talk-plugin-rich-text/client/components/rte/features/Bold.js @@ -1,5 +1,5 @@ import createToggle from '../factories/createToggle'; -import { findIntersecting } from '../lib/dom'; +import { findIntersecting, findAncestor } from '../lib/dom'; const boldTags = ['B', 'STRONG']; @@ -21,7 +21,8 @@ function isDisabled() { n => n.nodeName !== '#text' && window.getComputedStyle(n).getPropertyValue('font-weight') === 'bold' && - !boldTags.includes(n.tagName), + !boldTags.includes(n.tagName) && + !findAncestor(n, n => boldTags.includes(n.tagName), this.container), this.container ); } diff --git a/plugins/talk-plugin-rich-text/client/components/rte/features/Italic.js b/plugins/talk-plugin-rich-text/client/components/rte/features/Italic.js index d35f08da0..80703f47c 100644 --- a/plugins/talk-plugin-rich-text/client/components/rte/features/Italic.js +++ b/plugins/talk-plugin-rich-text/client/components/rte/features/Italic.js @@ -1,5 +1,5 @@ import createToggle from '../factories/createToggle'; -import { findIntersecting } from '../lib/dom'; +import { findIntersecting, findAncestor } from '../lib/dom'; const italicTags = ['I', 'EM']; @@ -19,7 +19,8 @@ function isDisabled() { n => n.nodeName !== '#text' && window.getComputedStyle(n).getPropertyValue('font-style') === 'italic' && - !italicTags.includes(n.tagName), + !italicTags.includes(n.tagName) && + !findAncestor(n, n => italicTags.includes(n.tagName), this.container), this.container ); }