-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathexportHTML.js
More file actions
31 lines (26 loc) · 815 Bytes
/
exportHTML.js
File metadata and controls
31 lines (26 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
const Changeset = require('ep_etherpad-lite/static/js/Changeset');
const _analyzeLine = (alineAttrs, apool) => {
let image = null;
if (alineAttrs) {
const opIter = Changeset.opIterator(alineAttrs);
if (opIter.hasNext()) {
const op = opIter.next();
image = Changeset.opAttributeValue(op, 'img', apool);
if (image.indexOf('<img') === 0) {
const urlMatch = (/src\s*=\s*"([^\s]+\/\/[^/]+.\/[^\s]+\.\w*)/gi).exec(image);
image = urlMatch[1];
}
}
}
return image;
};
exports.getLineHTMLForExport = async (hook, context) => {
const image = _analyzeLine(context.attribLine, context.apool);
if (image) {
context.lineContent = `<img src="${image}">`;
}
};
exports.stylesForExport = (hook, padId, cb) => {
cb('img{max-width:100%}');
};