Open yurenchen000 opened 2 years ago
didn't create docker image, just copy files to instance:
https://github.com/yurenchen000/hedgedoc/commits/1.9_add_viewjs
copy them
public/viewjs/
├── viewer.css
├── viewer.js
└── viewer.png
diff for 1.9.2
diff --git a/lib/csp.js b/lib/csp.js
index 82573bea..46e35b8d 100644
--- a/lib/csp.js
+++ b/lib/csp.js
@@ -27,6 +27,11 @@ const defaultDirectives = {
mediaSrc: ['*']
}
+const viewjsDirectives = {
+ scriptSrc: [config.serverURL + '/viewjs/'],
+ styleSrc: [config.serverURL + '/viewjs/']
+}
+
const disqusDirectives = {
scriptSrc: ['https://disqus.com', 'https://*.disqus.com', 'https://*.disquscdn.com'],
styleSrc: ['https://*.disquscdn.com'],
@@ -53,6 +58,7 @@ const allowPDFEmbedDirectives = {
CspStrategy.computeDirectives = function () {
const directives = {}
mergeDirectives(directives, config.csp.directives)
+ mergeDirectives(directives, viewjsDirectives)
mergeDirectivesIf(config.csp.addDefaults, directives, defaultDirectives)
mergeDirectivesIf(config.csp.addDisqus, directives, disqusDirectives)
mergeDirectivesIf(config.csp.addGoogleAnalytics, directives, googleAnalyticsDirectives)
diff --git a/public/views/hedgedoc.ejs b/public/views/hedgedoc.ejs
index 725e11c8..33c66280 100644
--- a/public/views/hedgedoc.ejs
+++ b/public/views/hedgedoc.ejs
@@ -11,4 +11,10 @@
<%- include('hedgedoc/footer') %>
</body>
+<!------------- codimd.ejs ----->
+
+<!--- chen added for viewerjs // edit page --->
+<script src="/viewjs/viewer.js"></script>
+<link href="/viewjs/viewer.css" rel="stylesheet">
+
</html>
diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs
index 97274ba1..47f56933 100644
--- a/public/views/pretty.ejs
+++ b/public/views/pretty.ejs
@@ -76,3 +76,10 @@
<script src="<%- serverURL %>/build/MathJax/config/Safe.js" defer></script>
<%- include('build/pretty-pack-scripts') %>
<%- include('shared/ga') %>
+
+
+<!------- pretty.ejs ------->
+
+<!--- chen added for viewerjs // view page --->
+<script src="/viewjs/viewer.js"></script>
+<link href="/viewjs/viewer.css" rel="stylesheet">
add an image viewer component from https://fengyuanchen.github.io/viewerjs
link: https://github.com/hedgedoc/hedgedoc/issues/2230
TODO:
gallery.update()
in F12 manually.