mirror of
https://github.com/flarum/core.git
synced 2025-08-06 16:36:47 +02:00
Keep images and links when quoting (#25)
* Keep images and links when quoting * Fix bower dependencies
This commit is contained in:
committed by
Toby Zerner
parent
2bbf4a2b4b
commit
86496f3e06
19
extensions/mentions/js/forum/dist/extension.js
vendored
19
extensions/mentions/js/forum/dist/extension.js
vendored
@@ -1218,9 +1218,9 @@ System.register('flarum/mentions/utils/reply', ['flarum/utils/DiscussionControls
|
|||||||
execute: function () {}
|
execute: function () {}
|
||||||
};
|
};
|
||||||
});;
|
});;
|
||||||
"use strict";
|
'use strict';
|
||||||
|
|
||||||
System.register("flarum/mentions/utils/selectedText", [], function (_export, _context) {
|
System.register('flarum/mentions/utils/selectedText', [], function (_export, _context) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function selectedText(body) {
|
function selectedText(body) {
|
||||||
@@ -1230,16 +1230,29 @@ System.register("flarum/mentions/utils/selectedText", [], function (_export, _co
|
|||||||
var parent = range.commonAncestorContainer;
|
var parent = range.commonAncestorContainer;
|
||||||
if (body[0] === parent || $.contains(body[0], parent)) {
|
if (body[0] === parent || $.contains(body[0], parent)) {
|
||||||
var clone = $("<div>").append(range.cloneContents());
|
var clone = $("<div>").append(range.cloneContents());
|
||||||
|
|
||||||
|
// Replace emoji images with their shortcode (found in alt attribute)
|
||||||
clone.find('img.emoji').replaceWith(function () {
|
clone.find('img.emoji').replaceWith(function () {
|
||||||
return this.alt;
|
return this.alt;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Replace all other images with a Markdown image
|
||||||
|
clone.find('img').replaceWith(function () {
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
|
||||||
|
// Replace all links with a Markdown link
|
||||||
|
clone.find('a').replaceWith(function () {
|
||||||
|
return '[' + this.innerText + '](' + this.href + ')';
|
||||||
|
});
|
||||||
|
|
||||||
return clone.text();
|
return clone.text();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
_export("default", selectedText);
|
_export('default', selectedText);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setters: [],
|
setters: [],
|
||||||
|
@@ -5,9 +5,22 @@ export default function selectedText(body) {
|
|||||||
const parent = range.commonAncestorContainer;
|
const parent = range.commonAncestorContainer;
|
||||||
if (body[0] === parent || $.contains(body[0], parent)) {
|
if (body[0] === parent || $.contains(body[0], parent)) {
|
||||||
const clone = $("<div>").append(range.cloneContents());
|
const clone = $("<div>").append(range.cloneContents());
|
||||||
|
|
||||||
|
// Replace emoji images with their shortcode (found in alt attribute)
|
||||||
clone.find('img.emoji').replaceWith(function() {
|
clone.find('img.emoji').replaceWith(function() {
|
||||||
return this.alt;
|
return this.alt;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Replace all other images with a Markdown image
|
||||||
|
clone.find('img').replaceWith(function() {
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
|
||||||
|
// Replace all links with a Markdown link
|
||||||
|
clone.find('a').replaceWith(function() {
|
||||||
|
return '[' + this.innerText + '](' + this.href + ')';
|
||||||
|
});
|
||||||
|
|
||||||
return clone.text();
|
return clone.text();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user