mirror of
https://github.com/humhub/humhub.git
synced 2025-01-29 12:28:06 +01:00
Removed redundant markdown addition.
This commit is contained in:
parent
dd7545f19d
commit
7556625914
@ -9,7 +9,6 @@ humhub.module('ui.additions', function (module, require, $) {
|
|||||||
|
|
||||||
var event = require('event');
|
var event = require('event');
|
||||||
var object = require('util.object');
|
var object = require('util.object');
|
||||||
|
|
||||||
var richtext = require('ui.richtext', true);
|
var richtext = require('ui.richtext', true);
|
||||||
|
|
||||||
var _additions = {};
|
var _additions = {};
|
||||||
@ -124,49 +123,7 @@ humhub.module('ui.additions', function (module, require, $) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
module.register('markdown', '[data-ui-markdown]', function ($match) {
|
|
||||||
var converter = new Markdown.getSanitizingConverter();
|
|
||||||
Markdown.Extra.init(converter);
|
|
||||||
$match.each(function () {
|
|
||||||
var $this = $(this);
|
|
||||||
|
|
||||||
if ($this.data('markdownProcessed')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Export all richtext features
|
|
||||||
var features = {};
|
|
||||||
$this.find('[data-richtext-feature], .oembed_snippet').each(function () {
|
|
||||||
var $this = $(this);
|
|
||||||
|
|
||||||
var featureKey = $this.data('guid') || '@-'+$this.attr('id');
|
|
||||||
|
|
||||||
// old oembeds
|
|
||||||
if($this.is('.oembed_snippted') && !$this.data('guid')) {
|
|
||||||
featureKey = '@-oembed-'+$this.data('url');
|
|
||||||
}
|
|
||||||
|
|
||||||
features[featureKey] = $this.clone();
|
|
||||||
// We add a space to make sure our placeholder is not appended to any link or something.
|
|
||||||
$this.replaceWith(' '+featureKey);
|
|
||||||
});
|
|
||||||
|
|
||||||
var text = richtext.Richtext.plainText($this.clone());
|
|
||||||
var result = converter.makeHtml(text);
|
|
||||||
|
|
||||||
// Rewrite richtext feature
|
|
||||||
$.each(features, function (featureKey, $element) {
|
|
||||||
result = result.replace(new RegExp('( )?'+featureKey.trim(), 'g'), $('<div></div>').html($element).html());
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$this.html(result).data('markdownProcessed', true);
|
|
||||||
|
|
||||||
// Make sure to add noopener to all links
|
|
||||||
$this.find('a').attr('rel', 'noopener noreferrer');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on('click.humhub-ui-additions', function () {
|
$(document).on('click.humhub-ui-additions', function () {
|
||||||
$('.tooltip').remove();
|
$('.tooltip').remove();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user