import { bytesToSize } from 'educoder'; export function isImageExtension(fileName) { return fileName ? !!(fileName.match(/.(jpg|jpeg|png|gif)$/i)) : false } export function markdownToHTML(oldContent, selector) { window.$('#md_div').html('') // markdown to html var markdwonParser = window.editormd.markdownToHTML("md_div", { markdown: oldContent, emoji: true, htmlDecode: "style,script,iframe", // you can filter tags decode taskList: true, tex: true, // 默认不解析 flowChart: true, // 默认不解析 sequenceDiagram: true // 默认不解析 }); const content = window.$('#md_div').html() if (selector) { window.$(selector).html(content) } return content } export function appendFileSizeToUploadFile(item) { return `${item.title}${uploadNameSizeSeperator}${item.filesize}` } export function appendFileSizeToUploadFileAll(fileList) { return fileList.map(item => { if (item.name.indexOf(uploadNameSizeSeperator) == -1) { return Object.assign({}, item, {name: `${item.name}${uploadNameSizeSeperator}${bytesToSize(item.size)}`}) } return item }) } export const uploadNameSizeSeperator = '  '