UNPKG

ep_align

Version:

Etherpad plugin to set left, center, right, or full justification for a paragraph

30 lines (26 loc) 768 B
'use strict'; const tags = ['left', 'center', 'justify', 'right']; exports.collectContentPre = (hookName, context, cb) => { const tname = context.tname; const state = context.state; const lineAttributes = state.lineAttributes; const tagIndex = tags.indexOf(tname); if (tname === 'div' || tname === 'p') { delete lineAttributes.align; } if (tagIndex >= 0) { lineAttributes.align = tags[tagIndex]; } return cb(); }; // I don't even know when this is run.. exports.collectContentPost = (hookName, context, cb) => { const tname = context.tname; const state = context.state; const lineAttributes = state.lineAttributes; const tagIndex = tags.indexOf(tname); if (tagIndex >= 0) { delete lineAttributes.align; } return cb(); };