1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Revert "Revert "Update website""

This reverts commit 49b56e84a7.
This commit is contained in:
Laurent Cozic
2019-02-27 23:38:50 +00:00
parent 49b56e84a7
commit 770a435029
17 changed files with 499 additions and 42 deletions

View File

@@ -19,6 +19,7 @@ class MdToHtml {
this.cachedContent_ = null;
this.cachedContentKey_ = null;
this.extraCssBlocks_ = [];
this.lastExecutedPlugins_ = [];
// Must include last "/"
this.resourceBaseUrl_ = ('resourceBaseUrl' in options) ? options.resourceBaseUrl : null;
@@ -248,6 +249,10 @@ class MdToHtml {
if (isCodeBlock) rendererPlugin = this.rendererPlugin_(codeBlockLanguage);
if (rendererPlugin && this.lastExecutedPlugins_.indexOf(codeBlockLanguage) < 0) {
this.lastExecutedPlugins_.push(codeBlockLanguage);
}
if (isInlineCode) {
openTag = null;
} else if (tag && (t.type.indexOf('html_inline') >= 0 || t.type.indexOf('html_block') >= 0)) {
@@ -408,6 +413,8 @@ class MdToHtml {
const cacheKey = this.makeContentKey(this.loadedResources_, body, style, options);
if (this.cachedContentKey_ === cacheKey) return this.cachedContent_;
this.lastExecutedPlugins_ = [];
const md = new MarkdownIt({
breaks: true,
linkify: true,
@@ -742,6 +749,17 @@ class MdToHtml {
return body;
}
injectedJavaScript() {
const output = [];
for (let i = 0; i < this.lastExecutedPlugins_.length; i++) {
const name = this.lastExecutedPlugins_[i];
const plugin = this.rendererPlugin_(name);
if (!plugin.injectedJavaScript) continue;
output.push(plugin.injectedJavaScript());
}
return output.join('\n');
}
handleCheckboxClick(msg, noteBody) {
msg = msg.split(':');
let index = Number(msg[msg.length - 1]);

View File

@@ -1,5 +1,6 @@
const { shim } = require('lib/shim');
const mermaid = require('mermaid');
const injectedJs = require('lib/rnInjectedJs/mermaid');
class MdToHtml_Mermaid {
@@ -16,6 +17,10 @@ class MdToHtml_Mermaid {
return '';
}
injectedJavaScript() {
return injectedJs + '\n' + 'mermaid.init();';
}
async loadAssets() {}
}

View File

@@ -96,6 +96,8 @@ class NoteBodyViewer extends Component {
let html = this.mdToHtml_.render(note ? note.body : '', this.props.webViewStyle, mdOptions);
const injectedJs = this.mdToHtml_.injectedJavaScript();
html = `
<!DOCTYPE html>
<html>
@@ -146,6 +148,7 @@ class NoteBodyViewer extends Component {
scalesPageToFit={Platform.OS !== 'ios'}
style={webViewStyle}
source={source}
injectedJavaScript={injectedJs}
originWhitelist={['file://*', './*', 'http://*', 'https://*']}
mixedContentMode="always"
allowFileAccess={true}

File diff suppressed because one or more lines are too long

View File

@@ -14,7 +14,7 @@
// require("ReactFeatureFlags").warnAboutDeprecatedLifecycles = false;
// console.disableYellowBox = true
console.disableYellowBox = true
const { AppRegistry } = require('react-native');
const { Root } = require('./root.js');

File diff suppressed because one or more lines are too long

View File

@@ -20,7 +20,6 @@
"markdown-it": "^8.4.0",
"markdown-it-katex": "^2.0.3",
"md5": "^2.2.1",
"mermaid": "^8.0.0",
"moment": "^2.18.1",
"prop-types": "^15.6.0",
"punycode": "^2.1.1",

View File

@@ -0,0 +1,5 @@
<?php
$content = file_get_contents('../ElectronClient/app/node_modules/mermaid/dist/mermaid.min.js');
file_put_contents('mermaid.json', json_encode($content));