You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
All: Extract note renderer to separate package (WIP) (#2206)
* Started updating to use external renderer package * Added way to build renderer assets * Done mobile compatilibty * Upgrade joplin-renderer * Added joplin-renderer package
This commit is contained in:
@ -1,17 +1,36 @@
|
||||
const markdownUtils = require('lib/markdownUtils');
|
||||
const htmlUtils = require('lib/htmlUtils');
|
||||
const Note = require('lib/models/Note');
|
||||
const Setting = require('lib/models/Setting');
|
||||
const Resource = require('lib/models/Resource');
|
||||
const { MarkupToHtml } = require('joplin-renderer');
|
||||
|
||||
class MarkupLanguageUtils {
|
||||
lib_(language) {
|
||||
if (language === Note.MARKUP_LANGUAGE_HTML) return htmlUtils;
|
||||
if (language === Note.MARKUP_LANGUAGE_MARKDOWN) return markdownUtils;
|
||||
if (language === MarkupToHtml.MARKUP_LANGUAGE_HTML) return htmlUtils;
|
||||
if (language === MarkupToHtml.MARKUP_LANGUAGE_MARKDOWN) return markdownUtils;
|
||||
throw new Error(`Unsupported markup language: ${language}`);
|
||||
}
|
||||
|
||||
extractImageUrls(language, text) {
|
||||
return this.lib_(language).extractImageUrls(text);
|
||||
}
|
||||
|
||||
// Create a new MarkupToHtml instance while injecting options specific to Joplin
|
||||
// desktop and mobile applications.
|
||||
newMarkupToHtml(options = null) {
|
||||
const subValues = Setting.subValues('markdown.plugin', Setting.toPlainObject());
|
||||
const pluginOptions = {};
|
||||
for (const n in subValues) {
|
||||
pluginOptions[n] = { enabled: subValues[n] };
|
||||
}
|
||||
|
||||
options = Object.assign({
|
||||
ResourceModel: Resource,
|
||||
pluginOptions: pluginOptions,
|
||||
}, options);
|
||||
|
||||
return new MarkupToHtml(options);
|
||||
}
|
||||
}
|
||||
|
||||
const markupLanguageUtils = new MarkupLanguageUtils();
|
||||
|
Reference in New Issue
Block a user