docs: 添加注释

This commit is contained in:
pipipi-pikachu 2021-08-21 15:25:02 +08:00
parent f2f5ea67f1
commit c1e56746f9
6 changed files with 21 additions and 4 deletions

View File

@ -16,11 +16,13 @@ export default () => {
const exporting = ref(false)
// 导出JSON文件
const exportJSON = () => {
const blob = new Blob([JSON.stringify(slides.value)], { type: '' })
saveAs(blob, 'pptist_slides.json')
}
// 格式化颜色值为 透明度 + HexString供pptxgenjs使用
const formatColor = (_color: string) => {
const c = tinycolor(_color)
const alpha = c.getAlpha()
@ -33,6 +35,8 @@ export default () => {
type FormatColor = ReturnType<typeof formatColor>
// 将HTML字符串格式化为pptxgenjs所需的格式
// 核心思路将HTML字符串按样式分片平铺每个片段需要继承祖先元素的样式信息遇到块级元素需要换行
const formatHTML = (html: string) => {
const ast = toAST(html)
@ -134,6 +138,8 @@ export default () => {
| { x: number; y: number; curve: { type: 'cubic'; x1: number; y1: number; x2: number; y2: number } }
| { close: true }
>
// 将SVG路径信息格式化为pptxgenjs所需要的格式
const formatPoints = (points: SvgPoints, scale = { x: 1, y: 1 }): Points => {
return points.map(point => {
if (point.close !== undefined) {
@ -179,6 +185,7 @@ export default () => {
})
}
// 导出PPTX文件
const exportPPTX = () => {
exporting.value = true
const pptx = new pptxgen()

View File

@ -157,7 +157,6 @@ export const uniqAlignLines = (lines: AlignLine[]) => {
* ID原有的关系
* groupIdgroupId
* @param elements
* @returns
*/
export const createElementIdMap = (elements: PPTElement[]) => {
const groupIdMap = {}
@ -178,7 +177,6 @@ export const createElementIdMap = (elements: PPTElement[]) => {
/**
*
* @param themeColor
* @returns
*/
export const getTableSubThemeColor = (themeColor: string) => {
const rgba = tinycolor(themeColor).toRgb()
@ -193,7 +191,6 @@ export const getTableSubThemeColor = (themeColor: string) => {
/**
* 线
* @param element 线
* @returns
*/
export const getLineElementPath = (element: PPTLineElement) => {
const start = element.start.join(',')

View File

@ -1,4 +1,4 @@
// https://github.com/scriptex/svg64
// svg转base64图片参考https://github.com/scriptex/svg64
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
const PREFIX = 'data:image/svg+xml;base64,'

View File

@ -14,6 +14,10 @@ const typeMap = {
512: 'A',
}
/**
* SVG路径
* @param d SVG path d属性
*/
export const parseSvgPath = (d: string) => {
const pathData = new SVGPathData(d)
@ -25,6 +29,10 @@ export const parseSvgPath = (d: string) => {
export type SvgPath = ReturnType<typeof parseSvgPath>
/**
* SVG路径AC
* @param d SVG path d属性
*/
export const toPoints = (d: string) => {
const pathData = new SVGPathData(d)

View File

@ -1,3 +1,7 @@
/**
* HTML字符串
* @param text
*/
export const parseText2Paragraphs = (text: string) => {
const htmlText = text.replace(/[\n\r]+/g, '<br>')
const paragraphs = htmlText.split('<br>')

View File

@ -72,6 +72,7 @@ export default defineComponent({
return false
})
//
const openLink = () => {
if (props.elementInfo.link) window.open(props.elementInfo.link)
}