-
-
Save JonCatmull/9ef6187b4162444b3e58fdcba90b3372 to your computer and use it in GitHub Desktop.
Froala Editor line-height plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* Froala Line Height plugin | |
* froala_editor v2.7.1 (https://www.froala.com/wysiwyg-editor) | |
*/ | |
!function (a) { | |
"function" == typeof define && define.amd ? define(["jquery"], a) : "object" == typeof module && module.exports ? module.exports = function (b, c) { | |
return void 0 === c && (c = "undefined" != typeof window ? require("jquery") : require("jquery")(b)), a(c), c | |
} : a(jQuery) | |
}(function (a) { | |
a.extend(a.FE.DEFAULTS, { | |
lineHeight: ["inherit", "1", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "2", "2.25", "2.5", "2.75", "3"], | |
lineHeightSelection: !1, | |
lineHeightDefaultSelection: "1.4" | |
}), a.FE.PLUGINS.lineHeight = function (b) { | |
function c(c) { | |
b.selection.save(), b.html.wrap(!0, !0, !0, !0), b.selection.restore(); | |
for (var d = b.selection.blocks(), e = 0; e < d.length; e++) { | |
a(d[e]).css("line-height", c).removeClass("fr-temp-div"); | |
} | |
b.selection.save(), b.html.unwrap(), b.selection.restore() | |
} | |
function d(c, d) { | |
var e = a(b.selection.element()).css("line-height"); | |
d.find(".fr-command.fr-active").removeClass("fr-active").attr("aria-selected", !1), d.find('.fr-command[data-param1="' + e + '"]').addClass("fr-active").attr("aria-selected", !0); | |
var f = d.find(".fr-dropdown-list"), g = d.find(".fr-active").parent(); | |
g.length ? f.parent().scrollTop(g.offset().top - f.offset().top - (f.parent().outerHeight() / 2 - g.outerHeight() / 2)) : f.parent().scrollTop(0) | |
} | |
function e(c) { | |
if (b.opts.lineHeightSelection) { | |
var d = a(b.selection.element()).css("line-height"); | |
c.find("> span").text(d) | |
} | |
} | |
return {apply: c, refreshOnShow: d, refresh: e} | |
}, a.FE.RegisterCommand("lineHeight", { | |
type: "dropdown", title: "Line Height", displaySelection: function (a) { | |
return a.opts.lineHeightSelection | |
}, displaySelectionWidth: 30, defaultSelection: function (a) { | |
return a.opts.lineHeightDefaultSelection | |
}, html: function () { | |
for (var a = '<ul class="fr-dropdown-list" role="presentation">', b = this.opts.lineHeight, c = 0; c < b.length; c++) { | |
var d = b[c]; | |
a += '<li role="presentation"><a class="fr-command" tabIndex="-1" role="option" data-cmd="lineHeight" data-param1="' + d + '" title="' + d + '">' + d + "</a></li>" | |
} | |
return a += "</ul>" | |
}, callback: function (a, b) { | |
this.lineHeight.apply(b) | |
}, refresh: function (a) { | |
this.lineHeight.refresh(a) | |
}, refreshOnShow: function (a, b) { | |
this.lineHeight.refreshOnShow(a, b) | |
}, plugin: "lineHeight" | |
}), a.FE.DefineIcon("lineHeight", {NAME: "arrows-v"}) | |
}); |
Apologies I didn't see a notification of your comments. Yes it should work, what version of Froala are you using?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yea this throws an error for me too.
Uncaught TypeError: Cannot read property 'DEFAULTS' of undefined
Any example how to get it working?