New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ep_font_color

Package Overview
Dependencies
Maintainers
5
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ep_font_color - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

.ep_initialized

62

exportHTML.js

@@ -1,12 +0,9 @@

var eejs = require('ep_etherpad-lite/node/eejs/');
var _ = require('ep_etherpad-lite/static/js/underscore');
const _ = require('ep_etherpad-lite/static/js/underscore');
const eejs = require('ep_etherpad-lite/node/eejs/');
var colors = ['black', 'red', 'green', 'blue', 'yellow', 'orange'];
const colors = ['black', 'red', 'green', 'blue', 'yellow', 'orange'];
// Add the props to be supported in export
exports.exportHtmlAdditionalTagsWithData = function(hook, pad, cb){
var colors_used = findAllColorUsedOn(pad);
var tags = transformColorsIntoTags(colors_used);
cb(tags);
exports.exportHtmlAdditionalTagsWithData = async (hookName, pad) => {
return findAllColorUsedOn(pad).map((name) => ['color', name]);
};

@@ -16,45 +13,16 @@

function findAllColorUsedOn(pad) {
var colors_used = [];
pad.pool.eachAttrib(function(key, value){
if (key === "color") {
colors_used.push(value);
}
});
return colors_used;
const colorsUsed = [];
pad.pool.eachAttrib((key, value) => { if (key === 'color') colorsUsed.push(value); });
return colorsUsed;
}
// Transforms an array of color names into color tags like ["color", "red"]
function transformColorsIntoTags(color_names) {
return _.map(color_names, function(color_name) {
return ["color", color_name];
});
}
// Include CSS for HTML export
exports.stylesForExport = function(hook, padId, cb){
var style = eejs.require("ep_font_color/static/css/color.css");
cb(style);
exports.stylesForExport = async (hookName, padId) => {
return eejs.require('ep_font_color/static/css/color.css');
};
// TODO: when "asyncLineHTMLForExport" hook is available on Etherpad, use it instead of "getLineHTMLForExport"
// exports.asyncLineHTMLForExport = function (hook, context, cb) {
// cb(rewriteLine);
// }
exports.getLineHTMLForExport = function (hook, context) {
rewriteLine(context);
}
function rewriteLine(context){
var lineContent = context.lineContent;
lineContent = replaceDataByClass(lineContent);
// TODO: when "asyncLineHTMLForExport" hook is available on Etherpad, return "lineContent" instead of re-setting it
context.lineContent = lineContent;
}
// Change from <span data-color:x to <span class:color:x
function replaceDataByClass(text) {
return text.replace(/data-color=["|']([0-9a-zA-Z]+)["|']/gi, "class='color:$1'");
}
exports.getLineHTMLForExport = async (hookName, context) => {
// Replace data-color="foo" with class="color:x".
context.lineContent =
context.lineContent.replace(/data-color=["|']([0-9a-zA-Z]+)["|']/gi, 'class="color:$1"');
};
{
"description": "Apply colors to fonts",
"name": "ep_font_color",
"version": "0.0.15",
"version": "0.0.16",
"license": "Apache-2.0",

@@ -6,0 +6,0 @@ "author": {

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