2024-09-18 09:44:51 +08:00
|
|
|
|
import type { Block, Inline, Theme } from '@/types'
|
2020-02-15 21:44:42 +08:00
|
|
|
|
|
2024-09-18 09:44:51 +08:00
|
|
|
|
import type { PropertiesHyphen } from 'csstype'
|
|
|
|
|
import { prefix } from '@/config'
|
|
|
|
|
import juice from 'juice'
|
2024-08-31 11:27:26 +08:00
|
|
|
|
import * as prettierPluginBabel from 'prettier/plugins/babel'
|
|
|
|
|
import * as prettierPluginEstree from 'prettier/plugins/estree'
|
2024-09-18 09:44:51 +08:00
|
|
|
|
import * as prettierPluginMarkdown from 'prettier/plugins/markdown'
|
2024-08-30 15:17:45 +08:00
|
|
|
|
import * as prettierPluginCss from 'prettier/plugins/postcss'
|
2024-09-18 09:44:51 +08:00
|
|
|
|
import { format } from 'prettier/standalone'
|
2024-08-18 19:49:16 +08:00
|
|
|
|
|
2024-09-16 17:07:47 +08:00
|
|
|
|
export function addPrefix(str: string) {
|
2024-08-18 19:49:16 +08:00
|
|
|
|
return `${prefix}__${str}`
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-16 17:07:47 +08:00
|
|
|
|
export function customizeTheme(theme: Theme, options: {
|
|
|
|
|
fontSize?: string
|
|
|
|
|
color?: string
|
|
|
|
|
}) {
|
2024-08-29 19:43:06 +08:00
|
|
|
|
const newTheme = JSON.parse(JSON.stringify(theme))
|
|
|
|
|
const { fontSize, color } = options
|
|
|
|
|
if (fontSize) {
|
2024-08-29 18:36:59 +08:00
|
|
|
|
for (let i = 1; i <= 4; i++) {
|
2024-08-29 19:43:06 +08:00
|
|
|
|
const v = newTheme.block[`h${i}`][`font-size`]
|
2024-09-16 17:07:47 +08:00
|
|
|
|
newTheme.block[`h${i}`][`font-size`] = `${Number(fontSize) * Number.parseFloat(v)}px`
|
2024-08-19 11:09:09 +08:00
|
|
|
|
}
|
2022-02-28 19:09:39 +08:00
|
|
|
|
}
|
2024-08-29 19:43:06 +08:00
|
|
|
|
if (color) {
|
|
|
|
|
newTheme.base[`--md-primary-color`] = color
|
|
|
|
|
}
|
2024-09-16 17:07:47 +08:00
|
|
|
|
return newTheme as Theme
|
2024-08-19 11:09:09 +08:00
|
|
|
|
}
|
2020-01-13 22:16:04 +08:00
|
|
|
|
|
2024-09-16 17:07:47 +08:00
|
|
|
|
export function customCssWithTemplate(jsonString: Partial<Record<Block | Inline, PropertiesHyphen>>, color: string, theme: Theme) {
|
2024-08-30 15:17:45 +08:00
|
|
|
|
const newTheme = customizeTheme(theme, { color })
|
2022-02-28 19:09:39 +08:00
|
|
|
|
|
2024-09-16 17:07:47 +08:00
|
|
|
|
const mergeProperties = <T extends Block | Inline = Block>(target: Record<T, PropertiesHyphen>, source: Partial<Record<Block | Inline, PropertiesHyphen>>, keys: T[]) => {
|
2024-08-30 15:17:45 +08:00
|
|
|
|
keys.forEach((key) => {
|
2024-08-29 19:43:06 +08:00
|
|
|
|
if (source[key]) {
|
2024-08-30 15:17:45 +08:00
|
|
|
|
target[key] = Object.assign(target[key] || {}, source[key])
|
2024-08-29 19:43:06 +08:00
|
|
|
|
}
|
2024-08-30 15:17:45 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
2021-02-28 14:50:52 +08:00
|
|
|
|
|
2024-09-16 17:07:47 +08:00
|
|
|
|
const blockKeys: Block[] = [
|
2024-08-30 15:17:45 +08:00
|
|
|
|
`h1`,
|
|
|
|
|
`h2`,
|
|
|
|
|
`h3`,
|
|
|
|
|
`h4`,
|
|
|
|
|
`code`,
|
2024-09-14 09:11:52 +08:00
|
|
|
|
`code_pre`,
|
2024-08-30 15:17:45 +08:00
|
|
|
|
`p`,
|
|
|
|
|
`hr`,
|
|
|
|
|
`blockquote`,
|
|
|
|
|
`blockquote_p`,
|
|
|
|
|
`image`,
|
|
|
|
|
`ul`,
|
|
|
|
|
`ol`,
|
|
|
|
|
]
|
2024-09-16 17:07:47 +08:00
|
|
|
|
const inlineKeys: Inline[] = [`strong`, `codespan`, `link`, `wx_link`, `listitem`]
|
2024-08-30 15:17:45 +08:00
|
|
|
|
|
|
|
|
|
mergeProperties(newTheme.block, jsonString, blockKeys)
|
|
|
|
|
mergeProperties(newTheme.inline, jsonString, inlineKeys)
|
|
|
|
|
return newTheme
|
2020-01-13 22:16:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-08-20 19:01:44 +08:00
|
|
|
|
* 将 CSS 字符串转换为 JSON 对象
|
2020-01-13 22:16:04 +08:00
|
|
|
|
*
|
2024-08-20 19:01:44 +08:00
|
|
|
|
* @param {string} css - CSS 字符串
|
|
|
|
|
* @returns {object} - JSON 格式的 CSS
|
2020-01-13 22:16:04 +08:00
|
|
|
|
*/
|
2024-09-16 17:07:47 +08:00
|
|
|
|
export function css2json(css: string): Partial<Record<Block | Inline, PropertiesHyphen>> {
|
2024-08-20 19:01:44 +08:00
|
|
|
|
// 去除所有 CSS 注释
|
|
|
|
|
css = css.replace(/\/\*[\s\S]*?\*\//g, ``)
|
2021-02-28 14:50:52 +08:00
|
|
|
|
|
2024-09-16 17:07:47 +08:00
|
|
|
|
const json: Partial<Record<Block | Inline, PropertiesHyphen>> = {}
|
2021-02-28 14:50:52 +08:00
|
|
|
|
|
2024-08-20 19:01:44 +08:00
|
|
|
|
// 辅助函数:将声明数组转换为对象
|
2024-09-16 17:07:47 +08:00
|
|
|
|
const toObject = (array: any[]) =>
|
|
|
|
|
array.reduce<{ [k: string]: string }>((obj, item) => {
|
|
|
|
|
const [property, value] = item.split(`:`).map((part: string) => part.trim())
|
2024-08-20 19:01:44 +08:00
|
|
|
|
if (property)
|
|
|
|
|
obj[property] = value
|
|
|
|
|
return obj
|
|
|
|
|
}, {})
|
|
|
|
|
|
|
|
|
|
while (css.includes(`{`) && css.includes(`}`)) {
|
2022-02-28 19:09:39 +08:00
|
|
|
|
const lbracket = css.indexOf(`{`)
|
|
|
|
|
const rbracket = css.indexOf(`}`)
|
2021-02-28 14:50:52 +08:00
|
|
|
|
|
2024-08-20 19:01:44 +08:00
|
|
|
|
// 获取声明块并转换为对象
|
|
|
|
|
const declarations = css.substring(lbracket + 1, rbracket)
|
2022-02-28 19:09:39 +08:00
|
|
|
|
.split(`;`)
|
2024-08-18 19:49:16 +08:00
|
|
|
|
.map(e => e.trim())
|
2024-08-20 19:01:44 +08:00
|
|
|
|
.filter(Boolean)
|
2021-02-28 14:50:52 +08:00
|
|
|
|
|
2024-08-20 19:01:44 +08:00
|
|
|
|
// 获取选择器并去除空格
|
|
|
|
|
const selectors = css.substring(0, lbracket)
|
2022-02-28 19:09:39 +08:00
|
|
|
|
.split(`,`)
|
2024-09-16 17:07:47 +08:00
|
|
|
|
.map(selector => selector.trim()) as (Block | Inline)[]
|
2021-02-28 14:50:52 +08:00
|
|
|
|
|
2024-08-20 19:01:44 +08:00
|
|
|
|
const declarationObj = toObject(declarations)
|
|
|
|
|
|
|
|
|
|
// 将声明对象关联到相应的选择器
|
2021-02-28 14:50:52 +08:00
|
|
|
|
selectors.forEach((selector) => {
|
2024-08-20 19:01:44 +08:00
|
|
|
|
json[selector] = { ...(json[selector] || {}), ...declarationObj }
|
2022-02-28 19:09:39 +08:00
|
|
|
|
})
|
2020-01-13 22:16:04 +08:00
|
|
|
|
|
2024-08-20 19:01:44 +08:00
|
|
|
|
// 处理下一个声明块
|
2022-02-28 19:09:39 +08:00
|
|
|
|
css = css.slice(rbracket + 1).trim()
|
2021-02-28 14:50:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-28 19:09:39 +08:00
|
|
|
|
return json
|
2020-01-13 22:16:04 +08:00
|
|
|
|
}
|
2020-05-01 21:30:25 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2024-08-30 15:17:45 +08:00
|
|
|
|
* 格式化内容
|
|
|
|
|
* @param {string} content - 要格式化的内容
|
|
|
|
|
* @param {'markdown' | 'css'} [type] - 内容类型,决定使用的解析器,默认为'markdown'
|
|
|
|
|
* @returns {Promise<string>} - 格式化后的内容
|
2020-05-01 21:30:25 +08:00
|
|
|
|
*/
|
2024-09-16 17:07:47 +08:00
|
|
|
|
export async function formatDoc(content: string, type: `markdown` | `css` = `markdown`) {
|
2024-08-30 15:17:45 +08:00
|
|
|
|
const plugins = {
|
|
|
|
|
markdown: [prettierPluginMarkdown, prettierPluginBabel, prettierPluginEstree],
|
|
|
|
|
css: [prettierPluginCss],
|
2024-08-18 19:49:16 +08:00
|
|
|
|
}
|
2020-05-01 21:30:25 +08:00
|
|
|
|
|
2024-08-30 15:17:45 +08:00
|
|
|
|
const parser = type in plugins ? type : `markdown`
|
|
|
|
|
return await format(content, {
|
|
|
|
|
parser,
|
|
|
|
|
plugins: plugins[parser],
|
2022-02-28 19:09:39 +08:00
|
|
|
|
})
|
2020-12-03 00:51:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 09:33:45 +08:00
|
|
|
|
/**
|
2021-11-23 21:45:53 +08:00
|
|
|
|
* 导出原始 Markdown 文档
|
2022-08-01 21:19:00 +08:00
|
|
|
|
* @param {string} doc - 文档内容
|
2020-11-21 09:33:45 +08:00
|
|
|
|
*/
|
2024-09-16 17:07:47 +08:00
|
|
|
|
export function downloadMD(doc: string) {
|
2022-08-01 21:19:00 +08:00
|
|
|
|
const downLink = document.createElement(`a`)
|
2020-07-13 00:26:29 +08:00
|
|
|
|
|
2022-02-28 19:09:39 +08:00
|
|
|
|
downLink.download = `content.md`
|
|
|
|
|
downLink.style.display = `none`
|
2022-08-01 21:19:00 +08:00
|
|
|
|
const blob = new Blob([doc])
|
2020-07-13 00:26:29 +08:00
|
|
|
|
|
2022-02-28 19:09:39 +08:00
|
|
|
|
downLink.href = URL.createObjectURL(blob)
|
|
|
|
|
document.body.appendChild(downLink)
|
|
|
|
|
downLink.click()
|
|
|
|
|
document.body.removeChild(downLink)
|
2020-08-31 20:48:22 +08:00
|
|
|
|
}
|
2020-10-13 00:07:14 +08:00
|
|
|
|
|
2021-10-14 20:12:19 +08:00
|
|
|
|
/**
|
|
|
|
|
* 导出 HTML 生成内容
|
|
|
|
|
*/
|
2021-10-30 22:54:41 +08:00
|
|
|
|
export function exportHTML() {
|
2024-09-16 17:07:47 +08:00
|
|
|
|
const element = document.querySelector(`#output`)!
|
2022-02-28 19:09:39 +08:00
|
|
|
|
setStyles(element)
|
|
|
|
|
const htmlStr = element.innerHTML
|
2021-10-30 22:54:41 +08:00
|
|
|
|
|
2022-02-28 19:09:39 +08:00
|
|
|
|
const downLink = document.createElement(`a`)
|
2021-10-14 20:12:19 +08:00
|
|
|
|
|
2022-02-28 19:09:39 +08:00
|
|
|
|
downLink.download = `content.html`
|
|
|
|
|
downLink.style.display = `none`
|
2024-08-18 19:49:16 +08:00
|
|
|
|
const blob = new Blob([
|
2021-10-16 09:54:45 +08:00
|
|
|
|
`<html><head><meta charset="utf-8" /></head><body><div style="width: 750px; margin: auto;">${htmlStr}</div></body></html>`,
|
2022-02-28 19:09:39 +08:00
|
|
|
|
])
|
2021-10-14 20:12:19 +08:00
|
|
|
|
|
2022-02-28 19:09:39 +08:00
|
|
|
|
downLink.href = URL.createObjectURL(blob)
|
|
|
|
|
document.body.appendChild(downLink)
|
|
|
|
|
downLink.click()
|
|
|
|
|
document.body.removeChild(downLink)
|
2021-10-30 22:54:41 +08:00
|
|
|
|
|
2024-09-16 17:07:47 +08:00
|
|
|
|
function setStyles(element: Element) {
|
2022-08-01 21:19:00 +08:00
|
|
|
|
/**
|
|
|
|
|
* 获取一个 DOM 元素的所有样式,
|
|
|
|
|
* @param {DOM 元素} element DOM 元素
|
|
|
|
|
* @param {排除的属性} excludes 如果某些属性对结果有不良影响,可以使用这个参数来排除
|
|
|
|
|
* @returns 行内样式拼接结果
|
|
|
|
|
*/
|
2024-09-16 17:07:47 +08:00
|
|
|
|
function getElementStyles(element: Element, excludes = [`width`, `height`]) {
|
2022-08-01 21:19:00 +08:00
|
|
|
|
const styles = getComputedStyle(element, null)
|
|
|
|
|
return Object.entries(styles)
|
|
|
|
|
.filter(
|
2024-08-18 19:49:16 +08:00
|
|
|
|
([key]) => styles.getPropertyValue(key) && !excludes.includes(key),
|
2022-08-01 21:19:00 +08:00
|
|
|
|
)
|
|
|
|
|
.map(([key, value]) => `${key}:${value};`)
|
|
|
|
|
.join(``)
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-30 22:54:41 +08:00
|
|
|
|
switch (true) {
|
|
|
|
|
case isPre(element):
|
|
|
|
|
case isCode(element):
|
|
|
|
|
case isSpan(element):
|
2022-02-28 19:09:39 +08:00
|
|
|
|
element.setAttribute(`style`, getElementStyles(element))
|
2021-10-30 22:54:41 +08:00
|
|
|
|
}
|
|
|
|
|
if (element.children.length) {
|
2024-08-18 19:49:16 +08:00
|
|
|
|
Array.from(element.children).forEach(child => setStyles(child))
|
2021-10-30 22:54:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 判断是否是包裹代码块的 pre 元素
|
2024-09-16 17:07:47 +08:00
|
|
|
|
function isPre(element: Element) {
|
2021-10-30 22:54:41 +08:00
|
|
|
|
return (
|
2024-08-18 19:49:16 +08:00
|
|
|
|
element.tagName === `PRE`
|
|
|
|
|
&& Array.from(element.classList).includes(`code__pre`)
|
2022-02-28 19:09:39 +08:00
|
|
|
|
)
|
2021-10-30 22:54:41 +08:00
|
|
|
|
}
|
2022-08-01 21:19:00 +08:00
|
|
|
|
|
2021-10-30 22:54:41 +08:00
|
|
|
|
// 判断是否是包裹代码块的 code 元素
|
2024-09-16 17:07:47 +08:00
|
|
|
|
function isCode(element: Element | null) {
|
|
|
|
|
if (element == null) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2024-07-23 22:41:02 +08:00
|
|
|
|
return element.tagName === `CODE`
|
2021-10-30 22:54:41 +08:00
|
|
|
|
}
|
2022-08-01 21:19:00 +08:00
|
|
|
|
|
2021-10-30 22:54:41 +08:00
|
|
|
|
// 判断是否是包裹代码字符的 span 元素
|
2024-09-16 17:07:47 +08:00
|
|
|
|
function isSpan(element: Element) {
|
2021-10-30 22:54:41 +08:00
|
|
|
|
return (
|
2024-08-18 19:49:16 +08:00
|
|
|
|
element.tagName === `SPAN`
|
|
|
|
|
&& (isCode(element.parentElement)
|
2024-09-17 16:13:24 +08:00
|
|
|
|
|| isCode((element.parentElement!).parentElement))
|
2022-02-28 19:09:39 +08:00
|
|
|
|
)
|
2021-10-30 22:54:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-14 20:12:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-13 00:07:14 +08:00
|
|
|
|
/**
|
2024-08-20 12:39:32 +08:00
|
|
|
|
* 根据数据生成 Markdown 表格
|
|
|
|
|
*
|
|
|
|
|
* @param {object} options - 选项
|
|
|
|
|
* @param {object} options.data - 表格数据
|
|
|
|
|
* @param {number} options.rows - 行数
|
|
|
|
|
* @param {number} options.cols - 列数
|
|
|
|
|
* @returns {string} 生成的 Markdown 表格
|
2020-10-13 00:07:14 +08:00
|
|
|
|
*/
|
2024-09-16 17:07:47 +08:00
|
|
|
|
export function createTable({ data, rows, cols }: { data: { [k: string]: string }, rows: number, cols: number }) {
|
2022-02-28 19:09:39 +08:00
|
|
|
|
let table = ``
|
2021-02-28 14:50:52 +08:00
|
|
|
|
for (let i = 0; i < rows + 2; ++i) {
|
2022-07-27 14:09:06 +08:00
|
|
|
|
table += `| `
|
|
|
|
|
const currRow = []
|
2021-02-28 14:50:52 +08:00
|
|
|
|
for (let j = 0; j < cols; ++j) {
|
2022-02-28 19:09:39 +08:00
|
|
|
|
const rowIdx = i > 1 ? i - 1 : i
|
2022-07-27 14:09:06 +08:00
|
|
|
|
currRow.push(i === 1 ? `---` : data[`k_${rowIdx}_${j}`] || ` `)
|
2020-10-13 00:07:14 +08:00
|
|
|
|
}
|
2022-07-27 14:09:06 +08:00
|
|
|
|
table += currRow.join(` | `)
|
|
|
|
|
table += ` |\n`
|
2021-02-28 14:50:52 +08:00
|
|
|
|
}
|
2020-10-13 00:07:14 +08:00
|
|
|
|
|
2022-02-28 19:09:39 +08:00
|
|
|
|
return table
|
2020-10-20 11:43:11 +00:00
|
|
|
|
}
|
2020-12-04 00:57:46 +08:00
|
|
|
|
|
2024-09-16 17:07:47 +08:00
|
|
|
|
export function toBase64(file: Blob) {
|
2024-09-17 08:26:52 +08:00
|
|
|
|
return new Promise<string>((resolve, reject) => {
|
2022-02-28 19:09:39 +08:00
|
|
|
|
const reader = new FileReader()
|
|
|
|
|
reader.readAsDataURL(file)
|
2024-09-17 08:26:52 +08:00
|
|
|
|
reader.onload = () => resolve((reader.result as string).split(`,`).pop()!)
|
2024-08-18 19:49:16 +08:00
|
|
|
|
reader.onerror = error => reject(error)
|
2022-02-28 19:09:39 +08:00
|
|
|
|
})
|
2022-08-01 21:19:00 +08:00
|
|
|
|
}
|
2020-12-05 21:16:09 +08:00
|
|
|
|
|
2024-09-16 17:07:47 +08:00
|
|
|
|
export function checkImage(file: File) {
|
2024-08-20 12:39:32 +08:00
|
|
|
|
// 检查文件名后缀
|
2024-08-20 19:01:44 +08:00
|
|
|
|
const isValidSuffix = /\.(?:gif|jpe?g|png)$/i.test(file.name)
|
2021-02-28 14:50:52 +08:00
|
|
|
|
if (!isValidSuffix) {
|
|
|
|
|
return {
|
|
|
|
|
ok: false,
|
2022-02-28 19:09:39 +08:00
|
|
|
|
msg: `请上传 JPG/PNG/GIF 格式的图片`,
|
|
|
|
|
}
|
2021-02-28 14:50:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-20 12:39:32 +08:00
|
|
|
|
// 检查文件大小
|
|
|
|
|
const maxSizeMB = 10
|
|
|
|
|
if (file.size > maxSizeMB * 1024 * 1024) {
|
2021-02-28 14:50:52 +08:00
|
|
|
|
return {
|
|
|
|
|
ok: false,
|
2024-08-20 12:39:32 +08:00
|
|
|
|
msg: `由于公众号限制,图片大小不能超过 ${maxSizeMB}M`,
|
2022-02-28 19:09:39 +08:00
|
|
|
|
}
|
2021-02-28 14:50:52 +08:00
|
|
|
|
}
|
2024-08-20 12:39:32 +08:00
|
|
|
|
|
2022-02-28 19:09:39 +08:00
|
|
|
|
return { ok: true }
|
2020-12-05 21:16:09 +08:00
|
|
|
|
}
|
2021-10-30 22:54:41 +08:00
|
|
|
|
|
2021-11-24 14:31:19 +08:00
|
|
|
|
/**
|
|
|
|
|
* 移除左边多余空格
|
2024-09-16 17:07:47 +08:00
|
|
|
|
* @param {string} str
|
2024-08-18 19:49:16 +08:00
|
|
|
|
* @returns string
|
2021-11-24 14:31:19 +08:00
|
|
|
|
*/
|
2024-09-16 17:07:47 +08:00
|
|
|
|
export function removeLeft(str: string) {
|
2022-02-28 19:09:39 +08:00
|
|
|
|
const lines = str.split(`\n`)
|
2021-11-24 14:31:19 +08:00
|
|
|
|
// 获取应该删除的空白符数量
|
2022-02-28 19:09:39 +08:00
|
|
|
|
const minSpaceNum = lines
|
2024-08-18 19:49:16 +08:00
|
|
|
|
.filter(item => item.trim())
|
2024-09-16 17:07:47 +08:00
|
|
|
|
.map(item => (item.match(/(^\s+)?/)!)[0].length)
|
2021-11-24 14:31:19 +08:00
|
|
|
|
.sort((a, b) => a - b)[0]
|
|
|
|
|
// 删除空白符
|
2024-08-18 19:49:16 +08:00
|
|
|
|
return lines.map(item => item.slice(minSpaceNum)).join(`\n`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function solveWeChatImage() {
|
2024-09-16 17:07:47 +08:00
|
|
|
|
const clipboardDiv = document.getElementById(`output`)!
|
2024-08-18 19:49:16 +08:00
|
|
|
|
const images = clipboardDiv.getElementsByTagName(`img`)
|
|
|
|
|
for (let i = 0; i < images.length; i++) {
|
|
|
|
|
const image = images[i]
|
2024-09-16 17:07:47 +08:00
|
|
|
|
const width = image.getAttribute(`width`)!
|
|
|
|
|
const height = image.getAttribute(`height`)!
|
2024-08-18 19:49:16 +08:00
|
|
|
|
image.removeAttribute(`width`)
|
|
|
|
|
image.removeAttribute(`height`)
|
|
|
|
|
image.style.width = width
|
|
|
|
|
image.style.height = height
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-16 17:07:47 +08:00
|
|
|
|
export function mergeCss(html: string) {
|
2024-08-18 19:49:16 +08:00
|
|
|
|
return juice(html, {
|
|
|
|
|
inlinePseudoElements: true,
|
|
|
|
|
preserveImportant: true,
|
|
|
|
|
})
|
2021-11-26 23:42:56 +08:00
|
|
|
|
}
|