ep_author_neat2
Advanced tools
Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "ep_author_neat2", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Etherpad plugin that uses colored underlines instead of colored backgrounds to indicate authorship.", | ||
@@ -21,4 +21,29 @@ "repository": { | ||
"type": "individual", | ||
"url": "http://etherpad.org/" | ||
"url": "https://etherpad.org/" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^7.28.0", | ||
"eslint-config-etherpad": "^2.0.0", | ||
"eslint-plugin-cypress": "^2.11.3", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-mocha": "^9.0.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prefer-arrow": "^1.2.3", | ||
"eslint-plugin-promise": "^5.1.0", | ||
"eslint-plugin-you-dont-need-lodash-underscore": "^6.12.0" | ||
}, | ||
"peerDependencies": { | ||
"ep_etherpad-lite": ">=1.8.6" | ||
}, | ||
"engines": { | ||
"node": ">=12.13.0" | ||
}, | ||
"eslintConfig": { | ||
"root": true, | ||
"extends": "etherpad/plugin" | ||
}, | ||
"scripts": { | ||
"lint": "eslint .", | ||
"lint:fix": "eslint --fix ." | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
![Publish Status](https://github.com/ether/ep_author_neat2/workflows/Node.js%20Package/badge.svg) ![Backend Tests Status](https://github.com/ether/ep_author_neat2/workflows/Backend%20tests/badge.svg) | ||
# ep_author_neat2 | ||
@@ -2,0 +4,0 @@ |
@@ -1,58 +0,49 @@ | ||
var $sidedivinner, getAuthorClassName, init, authorNameAndColorFromAuthorId, out$ = typeof exports != 'undefined' && exports || this; | ||
function allClasses($node){ | ||
var ref$; | ||
return ((ref$ = $node.attr('class')) != null ? ref$ : '').split(' '); | ||
} | ||
out$.postAceInit = postAceInit; | ||
function postAceInit(hook_name, arg$){ | ||
var ace; | ||
ace = arg$.ace; | ||
'use strict'; | ||
let $sidedivinner; | ||
let init; | ||
exports.postAceInit = (hookName, context) => { | ||
$sidedivinner = $('iframe[name="ace_outer"]').contents().find('#sidedivinner'); | ||
if (!$('#editorcontainerbox').hasClass('flex-layout')) { | ||
return $.gritter.add({ | ||
title: "Error", | ||
title: 'Error', | ||
text: 'ep_author_neat2: Please upgrade to Etherpad 1.8.4 for this plugin to work correctly', | ||
sticky: true, | ||
class_name: "error" | ||
class_name: 'error', | ||
}); | ||
} | ||
} | ||
function derivePrimaryAuthor($node){ | ||
var byAuthor, mPA, authorClass, author, value; | ||
byAuthor = {}; | ||
$node.find('span').each(function(){ | ||
var $this, i$, ref$, len$, spanclass, results$ = []; | ||
$this = $(this); | ||
for (i$ = 0, len$ = (ref$ = allClasses($this)).length; i$ < len$; ++i$) { | ||
spanclass = ref$[i$]; | ||
if (/^author/.exec(spanclass)) { | ||
byAuthor[spanclass] == null && (byAuthor[spanclass] = 0); | ||
results$.push(byAuthor[spanclass] += $this.text().length); | ||
}; | ||
const derivePrimaryAuthor = ($node) => { | ||
let mPA, authorClass; | ||
const byAuthor = new Map(); | ||
$node.find('span').each(function () { | ||
const $this = $(this); | ||
for (const spanclass of this.classList) { | ||
if (spanclass.startsWith('author')) { | ||
byAuthor.set(spanclass, (byAuthor.get(spanclass) || 0) + $this.text().length); | ||
} | ||
} | ||
return results$; | ||
}); | ||
mPA = 0; | ||
authorClass = null; | ||
for (author in byAuthor) { | ||
value = byAuthor[author]; | ||
if (value > mPA) { | ||
mPA = value; | ||
authorClass = author; | ||
} | ||
for (const [author, value] of byAuthor) { | ||
if (value <= mPA) continue; | ||
mPA = value; | ||
authorClass = author; | ||
} | ||
return authorClass; | ||
} | ||
function toggleAuthor($node, prefix, authorClass){ | ||
var hasClass, myClass, i$, ref$, len$, c; | ||
hasClass = false; | ||
myClass = prefix + "-" + authorClass; | ||
for (i$ = 0, len$ = (ref$ = allClasses($node)).length; i$ < len$; ++i$) { | ||
c = ref$[i$]; | ||
if (c.indexOf(prefix) === 0) { | ||
if (c === myClass) { | ||
hasClass = true; | ||
} else { | ||
$node.removeClass(c); | ||
} | ||
}; | ||
const toggleAuthor = ($node, prefix, authorClass) => { | ||
if ($node.length === 0) return true; | ||
let hasClass = false; | ||
const myClass = `${prefix}-${authorClass}`; | ||
for (const c of $node[0].classList) { | ||
if (c.indexOf(prefix) !== 0) continue; | ||
if (c === myClass) { | ||
hasClass = true; | ||
} else { | ||
$node.removeClass(c); | ||
} | ||
@@ -65,33 +56,32 @@ } | ||
return true; | ||
} | ||
function updateDomline($node){ | ||
var lineNumber, authorClass; | ||
lineNumber = $node.index() + 1; | ||
}; | ||
const updateDomline = ($node) => { | ||
const lineNumber = $node.index() + 1; | ||
if (!lineNumber) { | ||
return false; | ||
} | ||
authorClass = $node.text().length > 0 ? derivePrimaryAuthor($node) : "none"; | ||
toggleAuthor($node, "primary", authorClass); | ||
const authorClass = $node.text().length > 0 ? derivePrimaryAuthor($node) : 'none'; | ||
toggleAuthor($node, 'primary', authorClass); | ||
return authorViewUpdate($node, lineNumber, null, authorClass); | ||
} | ||
function extractAuthor($node){ | ||
var ref$, a, ref1$; | ||
return (ref$ = (function(){ | ||
var i$, ref$, len$, results$ = []; | ||
for (i$ = 0, len$ = (ref$ = allClasses($node)).length; i$ < len$; ++i$) { | ||
a = ref$[i$]; | ||
if (/^primary-/.exec(a)) { | ||
results$.push(a); | ||
} | ||
}; | ||
const extractAuthor = ($node) => { | ||
let ref$, ref1$; | ||
return (ref$ = (() => { | ||
const results$ = []; | ||
for (const a of $node[0].classList) { | ||
if (a.startsWith('primary-')) results$.push(a); | ||
} | ||
return results$; | ||
}())) != null ? (ref1$ = ref$[0]) != null ? ref1$.replace(/^primary-/, '') : void 8 : void 8; | ||
} | ||
function authorViewUpdate($node, lineNumber, prevAuthor, authorClass){ | ||
var $authorContainer, prev, prevId, ref$, authorChanged, next, logicalPrevAuthor; | ||
})()) != null ? (ref1$ = ref$[0]) != null ? ref1$.replace(/^primary-/, '') : void 8 : void 8; | ||
}; | ||
const authorViewUpdate = ($node, lineNumber, prevAuthor, authorClass) => { | ||
let prev, ref$, authorChanged, logicalPrevAuthor; | ||
if (!$sidedivinner) { | ||
$sidedivinner = $('iframe[name="ace_outer"]').contents().find('#sidedivinner'); | ||
} | ||
$authorContainer = $sidedivinner.find("div:nth-child(" + lineNumber + ")"); | ||
authorClass == null && (authorClass = extractAuthor($node)); | ||
const $authorContainer = $sidedivinner.find(`div:nth-child(${lineNumber})`); | ||
if (authorClass == null) authorClass = extractAuthor($node); | ||
if (!prevAuthor) { | ||
@@ -106,10 +96,6 @@ prev = $authorContainer; | ||
} | ||
if (prevAuthor === authorClass) { | ||
$authorContainer.addClass('concise'); | ||
} else { | ||
$authorContainer.removeClass('concise'); | ||
} | ||
prevId = (ref$ = $authorContainer.attr('id')) != null ? ref$.replace(/^ref-/, '') : void 8; | ||
$authorContainer.toggleClass('concise', prevAuthor === authorClass); | ||
const prevId = (ref$ = $authorContainer.attr('id')) != null ? ref$.replace(/^ref-/, '') : void 8; | ||
if (prevId === $node.attr('id')) { | ||
authorChanged = toggleAuthor($authorContainer, "primary", authorClass); | ||
authorChanged = toggleAuthor($authorContainer, 'primary', authorClass); | ||
if (!authorChanged) { | ||
@@ -119,6 +105,6 @@ return; | ||
} else { | ||
$authorContainer.attr('id', 'ref-' + $node.attr('id')); | ||
toggleAuthor($authorContainer, "primary", authorClass); | ||
$authorContainer.attr('id', `ref-${$node.attr('id')}`); | ||
toggleAuthor($authorContainer, 'primary', authorClass); | ||
} | ||
next = $node.next(); | ||
const next = $node.next(); | ||
if (next.length) { | ||
@@ -128,19 +114,18 @@ logicalPrevAuthor = authorClass === 'none' ? prevAuthor : authorClass; | ||
} | ||
} | ||
getAuthorClassName = function(author){ | ||
return 'author-' + author.replace(/[^a-y0-9]/g, function(c){ | ||
if (c === '.') { | ||
return '-'; | ||
} else { | ||
return 'z' + c.charCodeAt(0) + 'z'; | ||
} | ||
}); | ||
}; | ||
function outerInit(outerDynamicCSS){ | ||
var x$, y$, z$; | ||
x$ = outerDynamicCSS.selectorStyle('#sidedivinner.authorColors > div'); | ||
const getAuthorClassName = (author) => `author-${author.replace(/[^a-y0-9]/g, (c) => { | ||
if (c === '.') { | ||
return '-'; | ||
} else { | ||
return `z${c.charCodeAt(0)}z`; | ||
} | ||
})}`; | ||
const outerInit = (outerDynamicCSS) => { | ||
const x$ = outerDynamicCSS.selectorStyle('#sidedivinner.authorColors > div'); | ||
x$.borderRight = 'solid 5px transparent'; | ||
y$ = outerDynamicCSS.selectorStyle('#sidedivinner.authorColors > div.concise::before'); | ||
const y$ = outerDynamicCSS.selectorStyle('#sidedivinner.authorColors > div.concise::before'); | ||
y$.content = "' '"; | ||
z$ = outerDynamicCSS.selectorStyle('#sidedivinner.authorColors > div::before'); | ||
const z$ = outerDynamicCSS.selectorStyle('#sidedivinner.authorColors > div::before'); | ||
z$.fontSize = '11px'; | ||
@@ -151,57 +136,62 @@ z$.textTransform = 'capitalize'; | ||
return init = true; | ||
} | ||
out$.aceSetAuthorStyle = aceSetAuthorStyle; | ||
function aceSetAuthorStyle(name, context){ | ||
var dynamicCSS, outerDynamicCSS, parentDynamicCSS, info, author, authorSelector, color, authorClass, authorName, x$, y$, z$, z1$, z2$, z3$; | ||
dynamicCSS = context.dynamicCSS, outerDynamicCSS = context.outerDynamicCSS, parentDynamicCSS = context.parentDynamicCSS, info = context.info, author = context.author; | ||
}; | ||
exports.aceSetAuthorStyle = (hookName, context) => { | ||
const {author, dynamicCSS, info, outerDynamicCSS, parentDynamicCSS} = context; | ||
if (!init) { | ||
outerInit(outerDynamicCSS); | ||
} | ||
authorClass = getAuthorClassName(author); | ||
authorSelector = ".authorColors span." + authorClass; | ||
const authorClass = getAuthorClassName(author); | ||
const authorSelector = `.authorColors span.${authorClass}`; | ||
if (info) { | ||
if (!(color = info.bgcolor)) { | ||
const color = info.bgcolor; | ||
if (!color) { | ||
return 1; | ||
} | ||
authorName = authorNameAndColorFromAuthorId(author).name; | ||
x$ = dynamicCSS.selectorStyle("#innerdocbody.authorColors span." + authorClass); | ||
x$.borderBottom = "2px solid " + color; | ||
x$.paddingBottom = "1px"; | ||
y$ = parentDynamicCSS.selectorStyle(authorSelector); | ||
y$.borderBottom = "2px solid " + color; | ||
y$.paddingBottom = "1px"; | ||
z$ = dynamicCSS.selectorStyle("#innerdocbody.authorColors .primary-" + authorClass + " span." + authorClass); | ||
const authorName = authorNameAndColorFromAuthorId(author).name; | ||
const x$ = dynamicCSS.selectorStyle(`#innerdocbody.authorColors span.${authorClass}`); | ||
x$.borderBottom = `2px solid ${color}`; | ||
x$.paddingBottom = '1px'; | ||
const y$ = parentDynamicCSS.selectorStyle(authorSelector); | ||
y$.borderBottom = `2px solid ${color}`; | ||
y$.paddingBottom = '1px'; | ||
const z$ = dynamicCSS.selectorStyle( | ||
`#innerdocbody.authorColors .primary-${authorClass} span.${authorClass}`); | ||
z$.borderBottom = '0px'; | ||
z1$ = outerDynamicCSS.selectorStyle("#sidedivinner.authorColors > div.primary-" + authorClass); | ||
z1$.borderRight = "solid 5px " + color; | ||
z2$ = outerDynamicCSS.selectorStyle("#sidedivinner.authorColors > div.primary-" + authorClass + "::before"); | ||
z2$.content = "'" + authorName + "'"; | ||
z2$.paddingLeft = "5px"; | ||
z2$.whiteSpace = "nowrap"; | ||
z3$ = outerDynamicCSS.selectorStyle(".line-numbers-hidden #sidedivinner.authorColors > div.primary-" + authorClass + "::before"); | ||
z3$.paddingRight = "12px"; | ||
const z1$ = outerDynamicCSS.selectorStyle( | ||
`#sidedivinner.authorColors > div.primary-${authorClass}`); | ||
z1$.borderRight = `solid 5px ${color}`; | ||
const z2$ = outerDynamicCSS.selectorStyle( | ||
`#sidedivinner.authorColors > div.primary-${authorClass}::before`); | ||
z2$.content = `'${authorName}'`; | ||
z2$.paddingLeft = '5px'; | ||
z2$.whiteSpace = 'nowrap'; | ||
const z3$ = outerDynamicCSS.selectorStyle( | ||
`.line-numbers-hidden #sidedivinner.authorColors > div.primary-${authorClass}::before`); | ||
z3$.paddingRight = '12px'; | ||
} else { | ||
dynamicCSS.removeSelectorStyle("#innerdocbody.authorColors span." + authorClass); | ||
dynamicCSS.removeSelectorStyle(`#innerdocbody.authorColors span.${authorClass}`); | ||
parentDynamicCSS.removeSelectorStyle(authorSelector); | ||
} | ||
return 1; | ||
} | ||
authorNameAndColorFromAuthorId = function(authorId){ | ||
var myAuthorId, authorObj; | ||
myAuthorId = pad.myUserInfo.userId; | ||
}; | ||
const authorNameAndColorFromAuthorId = (authorId) => { | ||
let authorObj; | ||
const myAuthorId = pad.myUserInfo.userId; | ||
if (myAuthorId === authorId) { | ||
return { | ||
name: 'Me', | ||
color: pad.myUserInfo.colorId | ||
color: pad.myUserInfo.colorId, | ||
}; | ||
} | ||
authorObj = {}; | ||
$('#otheruserstable > tbody > tr').each(function(){ | ||
var x$; | ||
$('#otheruserstable > tbody > tr').each(function () { | ||
let x$; | ||
if (authorId === $(this).data('authorid')) { | ||
x$ = $(this); | ||
x$.find('.usertdname').each(function(){ | ||
x$.find('.usertdname').each(function () { | ||
return authorObj.name = $(this).text() || 'Unknown Author'; | ||
}); | ||
x$.find('.usertdswatch > div').each(function(){ | ||
x$.find('.usertdswatch > div').each(function () { | ||
return authorObj.color = $(this).css('background-color'); | ||
@@ -217,27 +207,22 @@ }); | ||
name: 'Unknown Author', | ||
color: '#fff' | ||
color: '#fff', | ||
}; | ||
}; | ||
out$.acePostWriteDomLineHTML = acePostWriteDomLineHTML; | ||
function acePostWriteDomLineHTML(hook_name, args) { | ||
return setTimeout(function(){ | ||
return updateDomline($(args.node)); | ||
}, 200); | ||
} | ||
out$.aceEditEvent = aceEditEvent; | ||
function aceEditEvent(hook_name, context) { | ||
var callstack, x$; | ||
callstack = context.callstack; | ||
exports.acePostWriteDomLineHTML = | ||
(hookName, {node}) => setTimeout(() => updateDomline($(node)), 200); | ||
exports.aceEditEvent = (hookName, {callstack}) => { | ||
if (callstack.type !== 'setWraps') { | ||
return; | ||
} | ||
x$ = $('iframe[name="ace_outer"]').contents(); | ||
const x$ = $('iframe[name="ace_outer"]').contents(); | ||
x$.find('#sidediv').css({ | ||
'padding-right': '0px' | ||
'padding-right': '0px', | ||
}); | ||
x$.find('#sidedivinner').css({ | ||
'max-width': '180px', | ||
overflow: 'hidden' | ||
'overflow': 'hidden', | ||
}); | ||
return x$; | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
190816
10
25
1
9
222
1