You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-02 22:49:09 +02:00
Desktop: WYSIWYG: Preserve HTML code in Markdown when editing from wysiwyg editor
This commit is contained in:
@@ -70,7 +70,13 @@ class HtmlUtils {
|
||||
return selfClosingElements.includes(tagName.toLowerCase());
|
||||
}
|
||||
|
||||
sanitizeHtml(html) {
|
||||
sanitizeHtml(html, options = null) {
|
||||
options = Object.assign({}, {
|
||||
// If true, adds a "jop-noMdConv" class to all the tags.
|
||||
// It can be used afterwards to restore HTML tags in Markdown.
|
||||
addNoMdConvClass: false,
|
||||
}, options);
|
||||
|
||||
const htmlparser2 = require('htmlparser2');
|
||||
|
||||
const output = [];
|
||||
@@ -95,6 +101,15 @@ class HtmlUtils {
|
||||
for (const eventName of JS_EVENT_NAMES) {
|
||||
delete attrs[eventName];
|
||||
}
|
||||
|
||||
if (options.addNoMdConvClass) {
|
||||
let classAttr = attrs['class'] || '';
|
||||
if (!classAttr.includes('jop-noMdConv')) {
|
||||
classAttr += ' jop-noMdConv';
|
||||
attrs['class'] = classAttr.trim();
|
||||
}
|
||||
}
|
||||
|
||||
let attrHtml = this.attributesHtml(attrs);
|
||||
if (attrHtml) attrHtml = ` ${attrHtml}`;
|
||||
const closingSign = this.isSelfClosingTag(name) ? '/>' : '>';
|
||||
|
||||
Reference in New Issue
Block a user