UNPKG

md-editor-v3

Version:

Markdown editor for vue3, developed in jsx and typescript, dark theme、beautify content by prettier、render articles directly、paste or clip the picture and upload it...

51 lines (50 loc) 1.56 kB
"use strict"; const config = require("./config.cjs"); const base642File = (base64, fileName = "image.png") => { const arr = base64.split(","); const regResult = arr[0].match(/:(.*?);/); if (regResult) { const mime = regResult[1]; const bstr = atob(arr[1]); let n = bstr.length; const u8arr = new Uint8Array(n); while (n--) { u8arr[n] = bstr.charCodeAt(n); } return new File([u8arr], fileName, { type: mime }); } return null; }; const generateCodeRowNumber = (code, source) => { if (!code) { return code; } const list = source.split("\n"); const rowNumberList = ['<span rn-wrapper aria-hidden="true">']; list.forEach(() => { rowNumberList.push("<span></span>"); }); rowNumberList.push("</span>"); return `<span class="${config.prefix}-code-block">${code}</span>${rowNumberList.join("")}`; }; const getRelativeTop = (element, container) => { if (!element || !container) { return 0; } const eleRect = element == null ? void 0 : element.getBoundingClientRect(); if (container === document.documentElement) { return eleRect.top - container.clientTop; } const conRect = container == null ? void 0 : container.getBoundingClientRect(); return eleRect.top - conRect.top; }; const getZIndexIncrement = /* @__PURE__ */ (() => { let startIndex = 0; return () => { return ++startIndex; }; })(); exports.base642File = base642File; exports.generateCodeRowNumber = generateCodeRowNumber; exports.getRelativeTop = getRelativeTop; exports.getZIndexIncrement = getZIndexIncrement;