diff --git a/src/trumbowyg.js b/src/trumbowyg.js
index 5464a3c73..4af5a351c 100644
--- a/src/trumbowyg.js
+++ b/src/trumbowyg.js
@@ -77,7 +77,14 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
imageWidthModalEdit: false,
prefix: 'trumbowyg-',
-
+// classes for inputs
+ tagClasses:{
+ 'h1': null,
+ 'h2': null,
+ 'h3': null,
+ 'h4': null,
+ 'p': null,
+ },
semantic: true,
semanticKeepAttributes: false,
resetCss: false,
@@ -496,7 +503,7 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
return;
}
- if (typeof(protocol) !== 'string') {
+ if (typeof (protocol) !== 'string') {
return 'https://';
}
return protocol.replace('://', '') + '://';
@@ -591,7 +598,8 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
try {
t.execCmd(key.fn, key.param);
return false;
- } catch (c) {}
+ } catch (c) {
+ }
} else {
if (t.o.tabToIndent && e.key === 'Tab') {
try {
@@ -601,7 +609,8 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
t.execCmd('indent', true, null);
}
return false;
- } catch (c) {}
+ } catch (c) {
+ }
}
}
})
@@ -659,8 +668,7 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
if (e.type === 'focus') {
t.autogrowOnEnterWasFocused = true;
t.autogrowEditorOnEnter();
- }
- else if (!t.o.autogrow) {
+ } else if (!t.o.autogrow) {
t.$ed.css({height: t.$ed.css('min-height')});
t.$c.trigger('tbwresize');
}
@@ -872,8 +880,8 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
type: 'button',
class: prefix + btnName + '-dropdown-button ' + (btn.class || '') + (btn.ico ? ' ' + prefix + btn.ico + '-button' : ''),
html: t.hasSvg && hasIcon ?
- '' + (btn.text || btn.title || t.lang[btnName] || btnName) :
- (btn.text || btn.title || t.lang[btnName] || btnName),
+ '' + (btn.text || btn.title || t.lang[btnName] || btnName) :
+ (btn.text || btn.title || t.lang[btnName] || btnName),
title: (btn.key ? '(' + (t.isMac ? 'Cmd' : 'Ctrl') + ' + ' + btn.key + ')' : null),
style: btn.style || null,
mousedown: function () {
@@ -1207,7 +1215,7 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
$(oldTag, this.$ed).each(function () {
var $oldTag = $(this);
- if($oldTag.contents().length === 0) {
+ if ($oldTag.contents().length === 0) {
return false;
}
@@ -1433,6 +1441,21 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
t.syncCode();
t.semanticCode(false, true);
+ try {
+ var listId = window.getSelection().focusNode;
+ if(!$(window.getSelection().focusNode.parentNode).hasClass('trumbowyg-editor')){
+ listId = window.getSelection().focusNode.parentNode;
+ }
+ var arr = t.o.tagClasses[param];
+ if (arr) {
+ for (var i = 0; i < arr.length; i++) {
+ $(listId).addClass(arr[i]);
+ }
+ }
+ } catch (e) {
+
+ }
+
}
if (cmd !== 'dropdown') {
@@ -1485,19 +1508,19 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
action: '',
html: content
})
- .on('submit', function () {
- $modal.trigger(CONFIRM_EVENT);
- return false;
- })
- .on('reset', function () {
- $modal.trigger(CANCEL_EVENT);
- return false;
- })
- .on('submit reset', function () {
- if (t.o.autogrowOnEnter) {
- t.autogrowOnEnterDontClose = false;
- }
- });
+ .on('submit', function () {
+ $modal.trigger(CONFIRM_EVENT);
+ return false;
+ })
+ .on('reset', function () {
+ $modal.trigger(CANCEL_EVENT);
+ return false;
+ })
+ .on('submit reset', function () {
+ if (t.o.autogrowOnEnter) {
+ t.autogrowOnEnterDontClose = false;
+ }
+ });
} else {
formOrContent = content;
}
@@ -1809,9 +1832,9 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
clearButtonPaneStatus: function () {
var t = this,
- prefix = t.o.prefix,
- activeClasses = prefix + 'active-button ' + prefix + 'active',
- originalIconClass = prefix + 'original-icon';
+ prefix = t.o.prefix,
+ activeClasses = prefix + 'active-button ' + prefix + 'active',
+ originalIconClass = prefix + 'original-icon';
// Reset all buttons and dropdown state
$('.' + prefix + 'active-button', t.$btnPane).removeClass(activeClasses);
@@ -1849,12 +1872,12 @@ Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', {
if (t.o.changeActiveDropdownIcon && $btnSvgUse.length > 0) {
// Save original icon
$dropdownBtn
- .addClass(originalIconClass)
- .data(originalIconClass, $dropdownBtnSvgUse.attr('xlink:href'));
+ .addClass(originalIconClass)
+ .data(originalIconClass, $dropdownBtnSvgUse.attr('xlink:href'));
// Put the active sub-button's icon
$dropdownBtnSvgUse
- .attr('xlink:href', $btnSvgUse.attr('xlink:href'));
+ .attr('xlink:href', $btnSvgUse.attr('xlink:href'));
}
} catch (e) {
}