Merge remote-tracking branch 'origin/staging' into staging

This commit is contained in:
David Benque 2022-10-17 14:26:58 +02:00
commit 87e46dd4ae
5 changed files with 1517 additions and 4 deletions

View File

@ -68,6 +68,7 @@ define([
'markdown',
'gfm',
'html',
'asciidoc',
'htmlembedded',
'htmlmixed',
'index.html',
@ -143,6 +144,31 @@ define([
previews['htmlmixed'] = function (val, $div, common) {
DiffMd.apply(val, $div, common);
};
previews['asciidoc'] = function (val, $div, common) {
require([
'asciidoctor',
'/lib/highlight/highlight.pack.js',
'css!/lib/highlight/styles/' + (window.CryptPad_theme === 'dark' ? 'dark.css' : 'github.css')
], function (asciidoctor) {
var reg = asciidoctor.Extensions.create();
var Highlight = window.hljs;
reg.inlineMacro('media-tag', function () {
var t = this;
t.process(function (parent, target) {
var d = target.split('|');
return t.createInline(parent, 'quoted', `<media-tag src="${d[0]}" data-crypto-key="${d[1]}"></media-tag>`).convert();
});
});
var html = asciidoctor.convert(val, { attributes: 'showtitle', extension_registry: reg });
DiffMd.apply(html, $div, common);
$div.find('pre code').each(function (i, el) {
Highlight.highlightBlock(el);
});
});
};
var mkPreviewPane = function (editor, CodeMirror, framework, isPresentMode) {
var $previewContainer = $('#cp-app-code-preview');
@ -370,9 +396,17 @@ define([
evModeChange.reg(function (mode) {
if (MEDIA_TAG_MODES.indexOf(mode) !== -1) {
// Embedding is enabled
framework.setMediaTagEmbedder(function (mt) {
framework.setMediaTagEmbedder(function (mt, d) {
editor.focus();
editor.replaceSelection($(mt)[0].outerHTML);
var txt = $(mt)[0].outerHTML;
if (editor.getMode().name === "asciidoc") {
if (d.static) {
txt = d.href + `[${d.name}]`;
} else {
txt = `media-tag:${d.src}|${d.key}[]`;
}
}
editor.replaceSelection(txt);
});
} else {
// Embedding is disabled

View File

@ -3023,7 +3023,7 @@ define([
}
return options;
}
};
var createNewButton = function (isInRoot, $container) {
if (!APP.editable) { return; }
if (!APP.loggedIn) { return; } // Anonymous users can use the + menu in the toolbar

View File

@ -20,7 +20,9 @@ define([
'netflux-client': '/bower_components/netflux-websocket/netflux-client',
'chainpad-netflux': '/bower_components/chainpad-netflux/chainpad-netflux',
'chainpad-listmap': '/bower_components/chainpad-listmap/chainpad-listmap',
'cm-extra': '/lib/codemirror-extra-modes'
'cm-extra': '/lib/codemirror-extra-modes',
// asciidoctor same
'asciidoctor': '/lib/asciidoctor/asciidoctor.min'
},
map: {
'*': {

1476
www/lib/asciidoctor/asciidoctor.min.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -12,4 +12,5 @@ This file is intended to be used as a log of what third-party source we have ven
* [Fabricjs 4.6.0](https://github.com/fabricjs/fabric.js) and [Fabric-history](https://github.com/lyzerk/fabric-history) for the whiteboard app
* [Requirejs optional module plugin](https://stackoverflow.com/a/27422370)
* [asciidoc.js 2.0.0](https://github.com/asciidoctor/codemirror-asciidoc/releases/tag/2.0.0) with slight changes to match the format of other codemirror modes
* [Asciidoctor.js 2.2.6](https://github.com/asciidoctor/asciidoctor.js/releases/tag/v2.2.6) for AsciiDoc rendering