Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
initMedium() {
// initialising editor. see http://jakiestfu.github.io/Medium.js/docs/
this.medium = new Medium({
element: this.mediumMount(),
modifier: "auto",
placeholder:
"What? - Short title shown in lists <br> Longer description. You can use #tags",
autoHR: false, //if true, inserts <hr> after two empty lines
mode: Medium.partialMode, // allows newlines, no styling
attributes: {
//remove: ['style', 'class'] //TODO does this remove the ng-class?
remove: ["style"], //TODO does this remove the ng-class?
},
beforeInsertHtml: function() {
//this = Medium.Html (!)
// Replace `<br>`s with the `<p>`s we use for line-breaking, to allow
// multi-line pasting. This assumes that pasting happens inside
// a `</p><p>` element and will horribly fail otherwise.
// The trimming happens, as leading whitespaces are removed in other
// lines as well during pasting.
const originalHtml = this.html;
const sanitizedHtml = originalHtml.trim().replace(/<br>/g, "</p><p>");
this.html = sanitizedHtml;
</p>