Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ep_font_size

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ep_font_size - npm Package Compare versions

Comparing version 0.0.6 to 0.1.0

locales/fr.json

15

ep.json

@@ -7,6 +7,9 @@ {

"postAceInit": "ep_font_size/static/js/index",
"aceInitialized": "ep_font_size/static/js/index",
"aceCreateDomLine": "ep_font_size/static/js/index",
"aceRegisterBlockElements": "ep_font_size/static/js/index",
"aceAttribsToClasses": "ep_font_size/static/js/index",
"collectContentPre": "ep_font_size/static/js/shared"
"aceAttribClasses":"ep_font_size/static/js/index",
"collectContentPre": "ep_font_size/static/js/shared",
"collectContentPost": "ep_font_size/static/js/shared",
"aceEditEvent": "ep_font_size/static/js/index",
"aceEditorCSS": "ep_font_size/static/js/index"
},

@@ -17,4 +20,6 @@ "hooks": {

"collectContentPost": "ep_font_size/static/js/shared",
"getLineHTMLForExport": "ep_font_size/index",
"eejsBlock_dd_format":"ep_font_size/index"
"eejsBlock_dd_format":"ep_font_size/index",
"aceAttribClasses":"ep_font_size/index",
"stylesForExport" : "ep_font_size/index",
"exportHtmlAdditionalTags" : "ep_font_size/index"
}

@@ -21,0 +26,0 @@ }

var eejs = require('ep_etherpad-lite/node/eejs/');
var Changeset = require("ep_etherpad-lite/static/js/Changeset");
/********************
* UI
*/
exports.eejsBlock_editbarMenuLeft = function (hook_name, args, cb) {

@@ -8,3 +11,3 @@ args.content = args.content + eejs.require("ep_font_size/templates/editbarButtons.ejs");

exports.eejsBlock_dd_format = function(hook_name, args, cb){
exports.eejsBlock_dd_format = function (hook_name, args, cb) {
args.content = args.content + eejs.require("ep_font_size/templates/fileMenu.ejs");

@@ -14,25 +17,49 @@ return cb();

function getInlineStyle(size) {
return "font_size: "+size+"px;";
}
// line, apool,attribLine,text
exports.getLineHTMLForExport = function (hook, context) {
var header = _analyzeLine(context.attribLine, context.apool);
if (header) {
var inlineStyle = getInlineStyle(header);
return "<span style=\"" + inlineStyle + "\">" + context.text.substring(1) + "</span>";
}
/********************
* Editor
*/
// Allow <whatever> to be an attribute
exports.aceAttribClasses = function(hook_name, attr, cb){
attr.fs8 = 'tag:fs8';
attr.fs9 = 'tag:fs9';
attr.fs10 = 'tag:fs10';
attr.fs11 = 'tag:fs11';
attr.fs12 = 'tag:fs12';
attr.fs13 = 'tag:fs13';
attr.fs14 = 'tag:fs14';
attr.fs15 = 'tag:fs15';
attr.fs16 = 'tag:fs16';
attr.fs17 = 'tag:fs17';
attr.fs18 = 'tag:fs18';
attr.fs19 = 'tag:fs19';
attr.fs20 = 'tag:fs20';
cb(attr);
}
function _analyzeLine(alineAttrs, apool) {
var header = null;
if (alineAttrs) {
var opIter = Changeset.opIterator(alineAttrs);
if (opIter.hasNext()) {
var op = opIter.next();
header = Changeset.opAttributeValue(op, 'font_size', apool);
}
}
return header;
}
/********************
* Export
*/
// Include CSS for HTML export
exports.stylesForExport = function(hook, padId, cb){
var css = "fs8{font-size:8px};"+
"fs9{font-size:9px};"+
"fs10{font-size:10px;}"+
"fs11{font-size:11px;}"+
"fs12{font-size:12px;}"+
"fs13{font-size:13px;}"+
"fs14{font-size:14px;}"+
"fs15{font-size:15px;}"+
"fs16{font-size:16px;}"+
"fs17{font-size:17px;}"+
"fs18{font-size:18px;}"+
"fs19{font-size:19px;}"+
"fs20{font-size:20px;}"
cb(css);
};
// Add the props to be supported in export
exports.exportHtmlAdditionalTags = function(hook, pad, cb){
cb(["fs8", "fs9", "fs10", "fs11", "fs12", "fs13", "fs14", "fs15", "fs16", "fs17", "fs18", "fs19", "fs20"]);
};
{
"description": "Change the font size",
"description": "Add support for Font Sizes",
"name": "ep_font_size",
"version": "0.0.6",
"version": "0.1.0",
"author": {

@@ -6,0 +6,0 @@ "name": "John McLear",

@@ -1,24 +0,20 @@

var _, $, jQuery;
var $, jQuery;
var $ = require('ep_etherpad-lite/static/js/rjquery').$;
var _ = require('ep_etherpad-lite/static/js/underscore');
var sizesClass = 'sizes';
var cssFiles = ['ep_sizes/static/css/editor.css'];
var sizes = ['8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'];
/*****
* Basic setup
******/
// Bind the event handler to the toolbar buttons
var postAceInit = function(hook, context){
var hs = $('.size-selection');
hs.on('change', function(){
exports.postAceInit = function(hook, context){
var fontSize = $('.size-selection');
fontSize.on('change', function(){
var value = $(this).val();
var intValue = parseInt(value,10);
if(!_.isNaN(intValue)){
applyFontSize(context, intValue);
hs.val("dummy");
}
var intValue = parseInt(value,10) + 8;
context.ace.callWithAce(function(ace){
ace.ace_setAttributeOnSelection("fs"+intValue, true);
},'insertfontsize' , true);
})
$('.ep_font_size').click(function(){
var size = $(this).data("size");
console.log(size);
applyFontSize(context, size);
});

@@ -31,86 +27,51 @@ $('.font_size').hover(function(){

});
};
function applyFontSize(context, size){
context.ace.callWithAce(function(ace){
ace.ace_doInsertSizes(size);
},'font_size' , true);
// To do show what font size is active on current selection
exports.aceEditEvent = function(hook, call, cb){
// TODO
}
/*****
* Editor setup
******/
// Our sizes attribute will result in a heaading:h1... :h6 class
function aceAttribsToClasses(hook, context){
if(context.key.indexOf("sizes:") !== -1){
var size = /(?:^| )sizes:([A-Za-z0-9]*)/.exec(context.key);
return ['sizes:' + size[1] ];
// Our fontsize attribute will result in a class
// I'm not sure if this is actually required..
exports.aceAttribsToClasses = function(hook, context){
var fs = (["fs8", "fs9", "fs10", "fs11", "fs12", "fs13", "fs14", "fs15", "fs16", "fs17", "fs18", "fs19", "fs20"]);
if(fs.indexOf(context.key) !== -1){
return [context.key];
}
if(context.key == 'sizes'){
return ['sizes:' + context.value ];
}
}
// Block elements
// I'm not sure if this is actually required..
exports.aceRegisterBlockElements = function(){
var fs = (["fs8", "fs9", "fs10", "fs11", "fs12", "fs13", "fs14", "fs15", "fs16", "fs17", "fs18", "fs19", "fs20"]);
return fs;
}
// Here we convert the class sizes:h1 into a tag
exports.aceCreateDomLine = function(name, context){
var cls = context.cls;
var domline = context.domline;
var sizesType = /(?:^| )sizes:([A-Za-z0-9]*)/.exec(cls);
var tagIndex;
if (sizesType) tagIndex = _.indexOf(sizes, sizesType[1]);
if (tagIndex !== undefined && tagIndex >= 0){
// var tag = sizes[tagIndex];
var lineHeight = tag*1.25;
var tag = sizes[tagIndex];
var modifier = {
extraOpenTags: '<span style="font-size: ' + tag + 'px;line-height:'+lineHeight+'px;">',
extraCloseTags: '</span>',
cls: cls
};
return [modifier];
}
return [];
};
// Find out which lines are selected and assign them the sizes attribute.
// Passing a level >= 0 will set a sizes on the selected lines, level < 0
// will remove it
function doInsertSizes(level){
var rep = this.rep,
documentAttributeManager = this.documentAttributeManager;
if (!(rep.selStart && rep.selEnd) || (level >= 0 && sizes[level] === undefined))
{
return;
}
if(level >= 0){
documentAttributeManager.setAttributesOnRange(rep.selStart, rep.selEnd, [
['sizes', sizes[level]]
]);
}else{
documentAttributeManager.setAttributesOnRange(rep.selStart, rep.selEnd, [
['sizes', '']
]);
}
// Register attributes that are html markup / blocks not just classes
// This should make export export properly IE <sub>helllo</sub>world
// will be the output and not <span class=sub>helllo</span>
exports.aceAttribClasses = function(hook, attr){
attr.fs8 = 'tag:fs8';
attr.fs9 = 'tag:fs9';
attr.fs10 = 'tag:fs10';
attr.fs11 = 'tag:fs11';
attr.fs12 = 'tag:fs12';
attr.fs13 = 'tag:fs13';
attr.fs14 = 'tag:fs14';
attr.fs15 = 'tag:fs15';
attr.fs16 = 'tag:fs16';
attr.fs17 = 'tag:fs17';
attr.fs18 = 'tag:fs18';
attr.fs19 = 'tag:fs19';
attr.fs20 = 'tag:fs20';
return attr;
}
// Once ace is initialized, we set ace_doInsertSizes and bind it to the context
function aceInitialized(hook, context){
var editorInfo = context.editorInfo;
editorInfo.ace_doInsertSizes = _(doInsertSizes).bind(context);
exports.aceEditorCSS = function(hook_name, cb){
return ["/ep_font_size/static/css/iframe.css"];
}
// Export all hooks
//exports.aceRegisterBlockElements = aceRegisterBlockElements;
exports.aceInitialized = aceInitialized;
exports.postAceInit = postAceInit;
//exports.aceDomLineProcessLineAttributes = aceDomLineProcessLineAttributes;
exports.aceAttribsToClasses = aceAttribsToClasses;
//exports.aceEditorCSS = aceEditorCSS;

@@ -1,24 +0,21 @@

var _ = require('ep_etherpad-lite/static/js/underscore');
var sizes = ['black', 'red', 'green', 'blue', 'yellow', 'orange'];
var collectContentPre = function(hook, context){
var sizes = /(?:^| )sizes:([A-Za-z0-9]*)/.exec(context.cls);
if(sizes && sizes[1]){
context.cc.doAttrib(context.state, sizes[0]);
exports.collectContentPre = function(hook, context){
var tname = context.tname;
var state = context.state;
var lineAttributes = state.lineAttributes
var tagIndex = tname;
var fs = (["fs8", "fs9", "fs10", "fs11", "fs12", "fs13", "fs14", "fs15", "fs16", "fs17", "fs18", "fs19", "fs20"]);
if(fs.indexOf(tname) !== -1){
context.cc.doAttrib(state, tname);
}
};
var collectContentPost = function(hook, context){
exports.collectContentPost = function(hook, context){
var tname = context.tname;
var state = context.state;
var lineAttributes = state.lineAttributes
var tagIndex = _.indexOf(sizes, tname);
var tagIndex = tname;
if(tagIndex >= 0){
delete lineAttributes['size'];
delete lineAttributes['sub'];
}
};
exports.collectContentPre = collectContentPre;
exports.collectContentPost = collectContentPost;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc