Skip to content

Commit

Permalink
- Fixes Firefox bug where a selection outside the editor would be styled
Browse files Browse the repository at this point in the history
  • Loading branch information
danowar2k authored and abias committed Nov 26, 2022
1 parent 8d573d5 commit a7ed889
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
var eID, element, p, pstyle, styles, host, i;
if (style[0] === '<nostyle>') {
element = window.getSelection().focusNode;
if (!this.editor.contains(element)) {
return;
}
for (p = element; p; p = p.parentNode) {
if (p.nodeType !== 1) {
continue;
Expand All @@ -126,6 +129,9 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
} else if (style[0] === '<block>') {
document.execCommand('formatBlock', false, '<div>');
element = window.getSelection().focusNode;
if (!this.editor.contains(element)) {
return;
}
for (p = element; p; p = p.parentNode) {
if (p.nodeType !== 1) {
continue;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
var eID, element, p, pstyle, styles, host, i;
if (style[0] === '<nostyle>') {
element = window.getSelection().focusNode;
if (!this.editor.contains(element)) {
return;
}
for (p = element; p; p = p.parentNode) {
if (p.nodeType !== 1) {
continue;
Expand All @@ -126,6 +129,9 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
} else if (style[0] === '<block>') {
document.execCommand('formatBlock', false, '<div>');
element = window.getSelection().focusNode;
if (!this.editor.contains(element)) {
return;
}
for (p = element; p; p = p.parentNode) {
if (p.nodeType !== 1) {
continue;
Expand Down
6 changes: 6 additions & 0 deletions yui/src/button/js/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
var eID, element, p, pstyle, styles, host, i;
if (style[0] === '<nostyle>') {
element = window.getSelection().focusNode;
if (!this.editor.contains(element)) {
return;
}
for (p = element; p; p = p.parentNode) {
if (p.nodeType !== 1) {
continue;
Expand All @@ -124,6 +127,9 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
} else if (style[0] === '<block>') {
document.execCommand('formatBlock', false, '<div>');
element = window.getSelection().focusNode;
if (!this.editor.contains(element)) {
return;
}
for (p = element; p; p = p.parentNode) {
if (p.nodeType !== 1) {
continue;
Expand Down

0 comments on commit a7ed889

Please sign in to comment.