diff options
Diffstat (limited to 'public/js')
-rw-r--r-- | public/js/extra.js | 35 | ||||
-rw-r--r-- | public/js/index.js | 14 | ||||
-rw-r--r-- | public/js/render.js | 2 |
3 files changed, 17 insertions, 34 deletions
diff --git a/public/js/extra.js b/public/js/extra.js index 76e95635..f8e0eb22 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -459,34 +459,13 @@ export function finishView (view) { // speakerdeck view.find('div.speakerdeck.raw').removeClass('raw') .each((key, value) => { - const url = `https://speakerdeck.com/oembed.json?url=https%3A%2F%2Fspeakerdeck.com%2F${encodeURIComponent($(value).attr('data-speakerdeckid'))}` - // use yql because speakerdeck not support jsonp - $.ajax({ - url: 'https://query.yahooapis.com/v1/public/yql', - data: { - q: `select * from json where url ='${url}'`, - format: 'json' - }, - dataType: 'jsonp', - success (data) { - if (!data.query || !data.query.results) return - const json = data.query.results.json - const html = json.html - var ratio = json.height / json.width - $(value).html(html) - const iframe = $(value).children('iframe') - const src = iframe.attr('src') - if (src.indexOf('//') === 0) { iframe.attr('src', `https:${src}`) } - const inner = $('<div class="inner"></div>').append(iframe) - const height = iframe.attr('height') - const width = iframe.attr('width') - ratio = (height / width) * 100 - inner.css('padding-bottom', `${ratio}%`) - $(value).html(inner) - if (window.viewAjaxCallback) window.viewAjaxCallback() - } - }) - }) + const url = `https://speakerdeck.com/${$(value).attr('data-speakerdeckid')}` + const inner = $('<a>Speakerdeck</a>') + inner.attr('href', url) + inner.attr('rel', 'noopener noreferrer') + inner.attr('target', '_blank') + $(value).append(inner) + }) // pdf view.find('div.pdf.raw').removeClass('raw') .each(function (key, value) { diff --git a/public/js/index.js b/public/js/index.js index c2969e92..76f952c1 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1,7 +1,6 @@ /* eslint-env browser, jquery */ -/* global CodeMirror, Cookies, moment, editor, ui, Spinner, - modeType, Idle, serverurl, key, gapi, Dropbox, FilePicker - ot, MediaUploader, hex2rgb, num_loaded, Visibility */ +/* global CodeMirror, Cookies, moment, Spinner, Idle, serverurl, + key, Dropbox, ot, hex2rgb, Visibility */ require('../vendor/showup/showup') @@ -12,7 +11,7 @@ require('../css/site.css') require('highlight.js/styles/github-gist.css') -import toMarkdown from 'to-markdown' +import TurndownService from 'turndown' import { saveAs } from 'file-saver' import randomColor from 'randomcolor' @@ -1498,7 +1497,12 @@ $('#snippetExportModalConfirm').click(function () { }) function parseToEditor (data) { - var parsed = toMarkdown(data) + var turndownService = new TurndownService({ + defaultReplacement: function (innerHTML, node) { + return node.isBlock ? '\n\n' + node.outerHTML + '\n\n' : node.outerHTML + } + }) + var parsed = turndownService.turndown(data) if (parsed) { replaceAll(parsed) } } diff --git a/public/js/render.js b/public/js/render.js index ff5e2bf2..87e5cfdf 100644 --- a/public/js/render.js +++ b/public/js/render.js @@ -45,7 +45,7 @@ var filterXSSOptions = { // allow comment tag if (tag === '!--') { // do not filter its attributes - return html + return html.replace(/<(?!!--)/g, '<').replace(/-->/g, '__HTML_COMMENT_END__').replace(/>/g, '>').replace(/__HTML_COMMENT_END__/g, '-->') } }, onTagAttr: function (tag, name, value, isWhiteAttr) { |