Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semanticblocks #33

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
styles = JSON.parse(styles);
var items = [];
var icon, span, spanpreview, inlinehint;
var blocklevel = ['block', 'h3', 'h4', 'h5', 'blockquote'];
Y.Array.each(styles, function(style) {
icon = '<i></i>';
span = '<span>';
Expand All @@ -52,9 +53,9 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
if (style.type === 'nostyle') {
icon = '<i class="fa fa-fw fa-times"></i>';
span = '<span class="nostyle">';
} else if (style.type === 'block') {
} else if (blocklevel.indexOf(style.type) != -1) {
icon = '<i class="fa fa-fw fa-tint"></i>';
span = '<span class="blockstyle">';
span = '<span class="blockstyle ' + style.type + '">';
} else if (style.type == 'inline') {
icon = '<i class="fa fa-fw fa-i-cursor"></i>';
span = '<span class="inlinestyle">';
Expand Down Expand Up @@ -110,6 +111,7 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
*/
_changeStyle: function(e, style) {
var eID, element, p, pstyle, styles, host, i;
var semanticblocks = ['<block>', '<h3>', '<h4>', '<h5>', '<blockquote>'];
if (style[0] === '<nostyle>') {
element = window.getSelection().focusNode;
if (!this.editor.contains(element)) {
Expand All @@ -126,8 +128,9 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
}
}
return;
} else if (style[0] === '<block>') {
document.execCommand('formatBlock', false, '<div>');
} else if (semanticblocks.indexOf(style[0]) != -1) {
var formatblock = (style[0] == '<block>') ? '<div>' : style[0];
document.execCommand('formatBlock', false, formatblock);
element = window.getSelection().focusNode;
if (!this.editor.contains(element)) {
return;
Expand Down

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

11 changes: 7 additions & 4 deletions yui/build/moodle-atto_styles-button/moodle-atto_styles-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
styles = JSON.parse(styles);
var items = [];
var icon, span, spanpreview, inlinehint;
var blocklevel = ['block', 'h3', 'h4', 'h5', 'blockquote'];
Y.Array.each(styles, function(style) {
icon = '<i></i>';
span = '<span>';
Expand All @@ -52,9 +53,9 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
if (style.type === 'nostyle') {
icon = '<i class="fa fa-fw fa-times"></i>';
span = '<span class="nostyle">';
} else if (style.type === 'block') {
} else if (blocklevel.indexOf(style.type) != -1) {
icon = '<i class="fa fa-fw fa-tint"></i>';
span = '<span class="blockstyle">';
span = '<span class="blockstyle ' + style.type + '">';
} else if (style.type == 'inline') {
icon = '<i class="fa fa-fw fa-i-cursor"></i>';
span = '<span class="inlinestyle">';
Expand Down Expand Up @@ -110,6 +111,7 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
*/
_changeStyle: function(e, style) {
var eID, element, p, pstyle, styles, host, i;
var semanticblocks = ['<block>', '<h3>', '<h4>', '<h5>', '<blockquote>'];
if (style[0] === '<nostyle>') {
element = window.getSelection().focusNode;
if (!this.editor.contains(element)) {
Expand All @@ -126,8 +128,9 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
}
}
return;
} else if (style[0] === '<block>') {
document.execCommand('formatBlock', false, '<div>');
} else if (semanticblocks.indexOf(style[0]) != -1) {
var formatblock = (style[0] == '<block>') ? '<div>' : style[0];
document.execCommand('formatBlock', false, formatblock);
element = window.getSelection().focusNode;
if (!this.editor.contains(element)) {
return;
Expand Down
11 changes: 7 additions & 4 deletions yui/src/button/js/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
styles = JSON.parse(styles);
var items = [];
var icon, span, spanpreview, inlinehint;
var blocklevel = ['block', 'h3', 'h4', 'h5', 'blockquote'];
Y.Array.each(styles, function(style) {
icon = '<i></i>';
span = '<span>';
Expand All @@ -50,9 +51,9 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
if (style.type === 'nostyle') {
icon = '<i class="fa fa-fw fa-times"></i>';
span = '<span class="nostyle">';
} else if (style.type === 'block') {
} else if (blocklevel.indexOf(style.type) != -1) {
icon = '<i class="fa fa-fw fa-tint"></i>';
span = '<span class="blockstyle">';
span = '<span class="blockstyle ' + style.type + '">';
} else if (style.type == 'inline') {
icon = '<i class="fa fa-fw fa-i-cursor"></i>';
span = '<span class="inlinestyle">';
Expand Down Expand Up @@ -108,6 +109,7 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
*/
_changeStyle: function(e, style) {
var eID, element, p, pstyle, styles, host, i;
var semanticblocks = ['<block>', '<h3>', '<h4>', '<h5>', '<blockquote>'];
if (style[0] === '<nostyle>') {
element = window.getSelection().focusNode;
if (!this.editor.contains(element)) {
Expand All @@ -124,8 +126,9 @@ Y.namespace('M.atto_styles').Button = Y.Base.create('button', Y.M.editor_atto.Ed
}
}
return;
} else if (style[0] === '<block>') {
document.execCommand('formatBlock', false, '<div>');
} else if (semanticblocks.indexOf(style[0]) != -1) {
var formatblock = (style[0] == '<block>') ? '<div>' : style[0];
document.execCommand('formatBlock', false, formatblock);
element = window.getSelection().focusNode;
if (!this.editor.contains(element)) {
return;
Expand Down