UNPKG

ep_headings2

Version:

Adds heading support to Etherpad Lite. Includes improved suppot for export, i18n etc.

30 lines (26 loc) 768 B
'use strict'; const tags = ['h1', 'h2', 'h3', 'h4', 'code']; 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.heading; } if (tagIndex >= 0) { lineAttributes.heading = 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.heading; } return cb(); };