diff --git a/lib/csp.js b/lib/csp.js
index 94e78d02..701e6eb7 100644
--- a/lib/csp.js
+++ b/lib/csp.js
@@ -17,8 +17,8 @@ var defaultDirectives = {
}
var cdnDirectives = {
- scriptSrc: ['https://cdnjs.cloudflare.com', 'https://cdn.mathjax.org'],
- styleSrc: ['https://cdnjs.cloudflare.com', 'https://fonts.googleapis.com'],
+ scriptSrc: ['https://cdnjs.cloudflare.com', 'https://cdn.jsdelivr.net', 'https://cdn.mathjax.org'],
+ styleSrc: ['https://cdnjs.cloudflare.com', 'https://cdn.jsdelivr.net', 'https://fonts.googleapis.com'],
fontSrc: ['https://cdnjs.cloudflare.com', 'https://fonts.gstatic.com']
}
diff --git a/public/js/extra.js b/public/js/extra.js
index 356e8a49..adbfdecc 100644
--- a/public/js/extra.js
+++ b/public/js/extra.js
@@ -12,6 +12,7 @@ import unescapeHTML from 'lodash/unescape'
import { stripTags } from '../../utils/string'
import getUIElements from './lib/editor/ui-elements'
+import { emojifyImageDir } from './lib/editor/constants'
import markdownit from 'markdown-it'
import markdownitContainer from 'markdown-it-container'
@@ -647,7 +648,7 @@ function generateCleanHTML (view) {
let name = $(value).attr('alt')
name = name.substr(1)
name = name.slice(0, name.length - 1)
- $(value).attr('src', `https://cdnjs.cloudflare.com/ajax/libs/emojify.js/1.1.0/images/basic/${name}.png`)
+ $(value).attr('src', `https://cdn.jsdelivr.net/npm/@hackmd/emojify.js@2.1.0/dist/images/basic/${name}.png`)
})
// replace video to iframe
src.find('div[data-videoid]').each((key, value) => {
@@ -1065,7 +1066,7 @@ window.emojify.setConfig({
elements: ['script', 'textarea', 'a', 'pre', 'code', 'svg'],
classes: ['no-emojify']
},
- img_dir: `${serverurl}/build/emojify.js/dist/images/basic`,
+ img_dir: emojifyImageDir,
ignore_emoticons: true
})
@@ -1271,7 +1272,7 @@ const emojijsPlugin = new Plugin(
(match, utils) => {
const emoji = match[1].toLowerCase()
- const div = $(``)
+ const div = $(``)
return div[0].outerHTML
}
)
diff --git a/public/js/index.js b/public/js/index.js
index 67c1525d..1002f707 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -76,6 +76,7 @@ import { preventXSS } from './render'
import Editor from './lib/editor'
import getUIElements from './lib/editor/ui-elements'
+import { emojifyImageDir } from './lib/editor/constants'
import modeType from './lib/modeType'
import appState from './lib/appState'
@@ -3158,7 +3159,7 @@ $(editor.getInputField())
callback(list)
},
template: function (value) {
- return ' ' + value
+ return ` ${value}`
},
replace: function (value) {
return '$1:' + value + ': '
diff --git a/public/js/lib/editor/constants.js b/public/js/lib/editor/constants.js
index 022d433d..697f4514 100644
--- a/public/js/lib/editor/constants.js
+++ b/public/js/lib/editor/constants.js
@@ -1,3 +1,5 @@
+import { serverurl } from '../config'
+
export const availableThemes = [
{ name: 'Light', value: 'default' },
{ name: 'One Dark (Default)', value: 'one-dark' },
@@ -13,3 +15,5 @@ export const availableThemes = [
{ name: 'Tomorror Night Bright', value: 'tomorrow-night-bright' },
{ name: 'Tomorror Night Eighties', value: 'tomorrow-night-eighties' }
]
+
+export const emojifyImageDir = window.USE_CDN ? `https://cdn.jsdelivr.net/npm/@hackmd/emojify.js@2.1.0/dist/images/basic` : `${serverurl}/build/emojify.js/dist/images/basic`
diff --git a/public/views/codimd/foot.ejs b/public/views/codimd/foot.ejs
index 5dbaa2cb..b86a62c6 100644
--- a/public/views/codimd/foot.ejs
+++ b/public/views/codimd/foot.ejs
@@ -11,7 +11,7 @@
-
+
diff --git a/public/views/codimd/head.ejs b/public/views/codimd/head.ejs
index e3edde66..d1ffd463 100644
--- a/public/views/codimd/head.ejs
+++ b/public/views/codimd/head.ejs
@@ -12,7 +12,7 @@
-
+
<%- include ../build/index-header %>
<%- include ../shared/polyfill %>
<% } else { %>
diff --git a/public/views/html.hbs b/public/views/html.hbs
index 8e91b7b2..f0069094 100644
--- a/public/views/html.hbs
+++ b/public/views/html.hbs
@@ -20,7 +20,7 @@
-
+
diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs
index 2c0ccffb..74531b18 100644
--- a/public/views/pretty.ejs
+++ b/public/views/pretty.ejs
@@ -21,7 +21,7 @@
-
+
<%- include build/pretty-header %>
<%- include shared/polyfill %>
<% } else { %>
@@ -83,7 +83,7 @@
-
+
diff --git a/public/views/slide.ejs b/public/views/slide.ejs
index d50e3cda..d4c090ed 100644
--- a/public/views/slide.ejs
+++ b/public/views/slide.ejs
@@ -19,7 +19,7 @@
-
+
<%- include build/slide-header %>
<%- include shared/polyfill %>
<% } else { %>
@@ -99,7 +99,7 @@
-
+