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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<!DOCTYPE html>
<html lang="en">
<head>
<title>Converse</title>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Converse: An XMPP chat client which can be integrated into any website" />
<meta name="keywords" content="xmpp chat webchat converse.js Converse" />
<link type="text/css" rel="stylesheet" media="screen" href="https://assets.immae.eu/converse/{{converseVersion}}/dist/converse.min.css" />
<style type="text/css">
#conversejs div.chat-msg__text pre {
background-color: #eee;
padding: 10px;
}
</style>
<script src="https://assets.immae.eu/converse/{{converseVersion}}/3rdparty/libsignal-protocol.min.js"></script>
<script src="https://assets.immae.eu/converse/{{converseVersion}}/dist/converse.min.js"></script>
<script src="https://assets.immae.eu/marked/1.2.6/marked.min.js"></script>
<script src="https://assets.immae.eu/markdown-it/10.0.0/markdown-it.min.js"></script>
</head>
<body>
<script>
var md = window.markdownit({
html: true,
});
converse.plugins.add('markdown', {
//initialize () {
// const { _converse } = this;
// _converse.api.listen.on('afterMessageBodyTransformed', (view, text) => {
// let newtext = text.replace(/<br\/>/g, '\n').replace(/```/g, "\n```\n");
// newtext = md.render(newtext).replace(/^<p>/, "").replace(/<\/p>\s*$/, "");
// view.model.save({'message': newtext}, {'silent': true });
// });
//}
overrides: {
MessageView: {
transformBodyText: async function(text) {
let newtext = await this.__super__.transformBodyText.apply(this, arguments);
newtext = newtext.replace(/<br\/>/g, '\n').replace(/```/g, "\n```\n");
return md.render(newtext).replace(/^<p>/, "").replace(/<\/p>\s*$/, "");
}
}
}
});
converse.initialize({
//bosh_service_url: 'https://im.immae.fr/bosh',
websocket_url: 'wss://im.immae.fr/ws',
view_mode: 'fullscreen',
show_controlbox_by_default: true,
whitelisted_plugins: ['markdown'],
});
</script>
</body>
</html>
|