From b2701caba7e54ca4c40554b897e090acdb31b371 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Fri, 4 Oct 2019 22:23:51 +0800 Subject: [PATCH 1/4] Fix viz.js@2 api changes Signed-off-by: Yukai Huang --- public/js/extra.js | 18 ++++++++++-------- public/views/codimd/foot.ejs | 3 ++- public/views/pretty.ejs | 3 ++- public/views/slide.ejs | 3 ++- webpack.common.js | 13 +++++++++---- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/public/js/extra.js b/public/js/extra.js index b62f0e6f..977e6bc7 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -1,5 +1,5 @@ /* eslint-env browser, jquery */ -/* global moment, serverurl, plantumlServer */ +/* global moment, serverurl, plantumlServer, Viz */ import Prism from 'prismjs' import hljs from 'highlight.js' @@ -30,7 +30,7 @@ require('prismjs/components/prism-gherkin') require('./lib/common/login') require('../vendor/md-toc') -var Viz = require('viz.js') +const viz = new window.Viz() const plantumlEncoder = require('plantuml-encoder') const ui = getUIElements() @@ -369,13 +369,15 @@ export function finishView (view) { try { var $value = $(value) var $ele = $(value).parent().parent() + $value.unwrap() + viz.renderString($value.text()) + .then(graphviz => { + if (!graphviz) throw Error('viz.js output empty graph') + $value.html(graphviz) - var graphviz = Viz($value.text()) - if (!graphviz) throw Error('viz.js output empty graph') - $value.html(graphviz) - - $ele.addClass('graphviz') - $value.children().unwrap().unwrap() + $ele.addClass('graphviz') + $value.children().unwrap() + }) } catch (err) { $value.unwrap() $value.parent().append(`
${escapeHTML(err)}
`) diff --git a/public/views/codimd/foot.ejs b/public/views/codimd/foot.ejs index babddf76..3456fd05 100644 --- a/public/views/codimd/foot.ejs +++ b/public/views/codimd/foot.ejs @@ -17,7 +17,8 @@ - + + diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs index 28c67213..9a71bb4a 100644 --- a/public/views/pretty.ejs +++ b/public/views/pretty.ejs @@ -87,7 +87,8 @@ - + + diff --git a/public/views/slide.ejs b/public/views/slide.ejs index 4644406f..e4374ab9 100644 --- a/public/views/slide.ejs +++ b/public/views/slide.ejs @@ -103,7 +103,8 @@ - + + diff --git a/webpack.common.js b/webpack.common.js index 2fe57720..fce94b35 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -259,7 +259,8 @@ module.exports = { 'script-loader!ot', 'flowchart.js', 'imports-loader?Raphael=raphael!js-sequence-diagrams', - 'expose-loader?Viz!viz.js', + 'script-loader!viz.js', + 'script-loader!viz.render.js', 'script-loader!abcjs', 'script-loader!vega', 'script-loader!vega-lite', @@ -297,7 +298,8 @@ module.exports = { 'script-loader!gist-embed', 'flowchart.js', 'imports-loader?Raphael=raphael!js-sequence-diagrams', - 'expose-loader?Viz!viz.js', + 'script-loader!viz.js', + 'script-loader!viz.render.js', 'script-loader!abcjs', 'script-loader!vega', 'script-loader!vega-lite', @@ -338,7 +340,8 @@ module.exports = { 'script-loader!gist-embed', 'flowchart.js', 'imports-loader?Raphael=raphael!js-sequence-diagrams', - 'expose-loader?Viz!viz.js', + 'script-loader!viz.js', + 'script-loader!viz.render.js', 'script-loader!abcjs', 'script-loader!vega', 'script-loader!vega-lite', @@ -380,7 +383,9 @@ module.exports = { 'vega-lite': path.join(__dirname, 'node_modules/vega-lite/build/vega-lite.min.js'), 'vega-embed': path.join(__dirname, 'node_modules/vega-embed/build/vega-embed.min.js'), 'emojify.js': path.join(__dirname, 'node_modules/@hackmd/emojify.js/dist/js/emojify-browser.min.js'), - 'markdown-it': path.join(__dirname, 'node_modules/markdown-it/dist/markdown-it.js') + 'markdown-it': path.join(__dirname, 'node_modules/markdown-it/dist/markdown-it.js'), + 'viz.js': path.join(__dirname, 'node_modules/viz.js/viz.js'), + 'viz.render.js': path.join(__dirname, 'node_modules/viz.js/full.render.js') } }, From be900d8db6c2d309baeafab51a3df74cf0aa7149 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Fri, 4 Oct 2019 22:59:09 +0800 Subject: [PATCH 2/4] Fix cdn integrity (#1284) Signed-off-by: Yukai Huang --- public/views/codimd/foot.ejs | 10 +++++----- public/views/index/foot.ejs | 6 +++--- public/views/index/head.ejs | 6 +++--- public/views/pretty.ejs | 10 +++++----- public/views/slide.ejs | 16 ++++++++-------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/public/views/codimd/foot.ejs b/public/views/codimd/foot.ejs index 3456fd05..5dbaa2cb 100644 --- a/public/views/codimd/foot.ejs +++ b/public/views/codimd/foot.ejs @@ -1,7 +1,7 @@ <% if(useCDN) { %> - + @@ -9,17 +9,17 @@ - + - - + + - + diff --git a/public/views/index/foot.ejs b/public/views/index/foot.ejs index 78bbc867..e9af48e5 100644 --- a/public/views/index/foot.ejs +++ b/public/views/index/foot.ejs @@ -1,10 +1,10 @@ <% if(useCDN) { %> - - + + - + <%- include ../build/cover-scripts %> diff --git a/public/views/index/head.ejs b/public/views/index/head.ejs index 0a6ac3f0..6fc56fc8 100644 --- a/public/views/index/head.ejs +++ b/public/views/index/head.ejs @@ -11,10 +11,10 @@ <% if(useCDN) { %> - + - - + + <%- include ../build/cover-header %> <%- include ../shared/polyfill %> <% } else { %> diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs index 9a71bb4a..2c0ccffb 100644 --- a/public/views/pretty.ejs +++ b/public/views/pretty.ejs @@ -73,19 +73,19 @@ <% if(useCDN) { %> - - + + - + - - + + diff --git a/public/views/slide.ejs b/public/views/slide.ejs index e4374ab9..d50e3cda 100644 --- a/public/views/slide.ejs +++ b/public/views/slide.ejs @@ -16,7 +16,7 @@ <% if(useCDN) { %> - + @@ -90,18 +90,18 @@ <% if(useCDN) { %> - - + + - - + + - + - - + + From 8d978cd2d022a83afb6dc56bb55758bc99f3adda Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Fri, 4 Oct 2019 23:03:45 +0800 Subject: [PATCH 3/4] Fix linting error Signed-off-by: Yukai Huang --- public/js/extra.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/extra.js b/public/js/extra.js index 977e6bc7..03f04664 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -1,5 +1,5 @@ /* eslint-env browser, jquery */ -/* global moment, serverurl, plantumlServer, Viz */ +/* global moment, serverurl, plantumlServer */ import Prism from 'prismjs' import hljs from 'highlight.js' From 5495880bf52ac3e8cff9a7ae8c1b9c062fafaf25 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Sat, 5 Oct 2019 16:16:43 +0800 Subject: [PATCH 4/4] Update yarn.lock Signed-off-by: Yukai Huang --- yarn.lock | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7a708b09..cb7b2c23 100644 --- a/yarn.lock +++ b/yarn.lock @@ -905,6 +905,13 @@ resolved "https://registry.yarnpkg.com/@babel/preset-stage-0/-/preset-stage-0-7.0.0.tgz#999aaec79ee8f0a763042c68c06539c97c6e0646" integrity sha512-FBMd0IiARPtH5aaOFUVki6evHiJQiY0pFy7fizyRF7dtwc+el3nwpzvhb9qBNzceG1OIJModG1xpE0DDFjPXwA== +"@babel/runtime@^7.5.5": + version "7.6.2" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.6.2.tgz#c3d6e41b304ef10dcf13777a33e7694ec4a9a6dd" + integrity sha512-EXxN64agfUqqIGeEjI5dL5z0Sw0ZwWo1mLTi4mQowCZ42O59b7DRpZAnTC6OqdF28wMBMFKNb/4uFGrVaigSpg== + dependencies: + regenerator-runtime "^0.13.2" + "@babel/template@^7.1.0", "@babel/template@^7.4.0", "@babel/template@^7.4.4": version "7.4.4" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.4.4.tgz#f4b88d1225689a08f5bc3a17483545be9e4ed237" @@ -953,6 +960,14 @@ resolved "https://registry.yarnpkg.com/@hackmd/diff-match-patch/-/diff-match-patch-1.1.3.tgz#c9b06119934bb638e49df5a82bab5ce03b07104d" integrity sha512-n6drMSGRHzK33vc8qNhJmMwLYOrtWKugkJAFTETHEKew+E3KwEKhaR0TTHl1sgm5gujvdPPQRXAHC5EI81tMFA== +"@hackmd/emojify.js@^2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@hackmd/emojify.js/-/emojify.js-2.1.0.tgz#4555a7004679f75aa91ccec65eba3b3b8646b1ea" + integrity sha512-RmQXPGD/uGaa0w2qoc+y6ur+TpQhAr2aBOm2QDLBDMzOdhkdmh9MyadM2rtLGz6U3ZilPjkQYzs+gHm1BhwvtA== + dependencies: + "@babel/runtime" "^7.5.5" + core-js "^3.2.1" + "@hackmd/idle-js@~1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@hackmd/idle-js/-/idle-js-1.0.1.tgz#89079a76d9c7bda87029660a708e72fbb2be3605" @@ -3425,6 +3440,11 @@ core-js@^2.0.0, core-js@^2.4.0, core-js@^2.5.0: resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.9.tgz#6b4b214620c834152e179323727fc19741b084f2" integrity sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A== +core-js@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.2.1.tgz#cd41f38534da6cc59f7db050fe67307de9868b09" + integrity sha512-Qa5XSVefSVPRxy2XfUC13WbvqkxhkwB3ve+pgCQveNgYzbM/UxZeu1dcOX/xr4UmfUd+muuvsaxilQzCyUurMw== + core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -4649,11 +4669,6 @@ emoji-regex@~6.1.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-6.1.3.tgz#ec79a3969b02d2ecf2b72254279bf99bc7a83932" integrity sha1-7HmjlpsC0uzytyJUJ5v5m8eoOTI= -emojify.js@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/emojify.js/-/emojify.js-1.1.0.tgz#079fff223307c9007f570785e8e4935d5c398beb" - integrity sha1-B5//IjMHyQB/VweF6OSTXVw5i+s= - emojis-list@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" @@ -7880,6 +7895,11 @@ markdown-it-regexp@~0.4.0: resolved "https://registry.yarnpkg.com/markdown-it-regexp/-/markdown-it-regexp-0.4.0.tgz#d64d713eecec55ce4cfdeb321750ecc099e2c2dc" integrity sha1-1k1xPuzsVc5M/esyF1DswJniwtw= +markdown-it-ruby@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/markdown-it-ruby/-/markdown-it-ruby-0.1.1.tgz#6e2050a9b2c3275afc2844920d53cdffbbe12f78" + integrity sha1-biBQqbLDJ1r8KESSDVPN/7vhL3g= + markdown-it-sub@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/markdown-it-sub/-/markdown-it-sub-1.0.0.tgz#375fd6026eae7ddcb012497f6411195ea1e3afe8" @@ -10513,6 +10533,11 @@ regenerator-runtime@^0.11.0: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== +regenerator-runtime@^0.13.2: + version "0.13.3" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz#7cf6a77d8f5c6f60eb73c5fc1955b2ceb01e6bf5" + integrity sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw== + regenerator-transform@^0.10.0: version "0.10.1" resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.10.1.tgz#1e4996837231da8b7f3cf4114d71b5691a0680dd"