Browse Source

fix: 修复ppt主题颜色识别问题

李志伟 3 tuần trước cách đây
mục cha
commit
4bf7aa8ec7

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 836 - 234
pnpm-lock.yaml


+ 5 - 7
src/utils/pptxToJson/align.js

@@ -1,6 +1,6 @@
 import { getTextByPathList } from './utils'
 
-export function getHorizontalAlign(node, pNode, type, warpObj) {
+export function getHorizontalAlign (node, pNode, type, warpObj) {
   let algn = getTextByPathList(node, ['a:pPr', 'attrs', 'algn'])
   if (!algn) algn = getTextByPathList(pNode, ['a:pPr', 'attrs', 'algn'])
 
@@ -18,11 +18,9 @@ export function getHorizontalAlign(node, pNode, type, warpObj) {
       if (!algn && type === 'subTitle') {
         algn = getTextByPathList(warpObj, ['slideMasterTextStyles', 'p:bodyStyle', lvlStr, 'attrs', 'algn'])
       }
-    } 
-    else if (type === 'body') {
+    } else if (type === 'body') {
       algn = getTextByPathList(warpObj, ['slideMasterTextStyles', 'p:bodyStyle', 'a:lvl1pPr', 'attrs', 'algn'])
-    } 
-    else {
+    } else {
       algn = getTextByPathList(warpObj, ['slideMasterTables', 'typeTable', type, 'p:txBody', 'a:lstStyle', 'a:lvl1pPr', 'attrs', 'algn'])
     }
   }
@@ -52,7 +50,7 @@ export function getHorizontalAlign(node, pNode, type, warpObj) {
   return align
 }
 
-export function getVerticalAlign(node, slideLayoutSpNode, slideMasterSpNode) {
+export function getVerticalAlign (node, slideLayoutSpNode, slideMasterSpNode) {
   let anchor = getTextByPathList(node, ['p:txBody', 'a:bodyPr', 'attrs', 'anchor'])
   if (!anchor) {
     anchor = getTextByPathList(slideLayoutSpNode, ['p:txBody', 'a:bodyPr', 'attrs', 'anchor'])
@@ -62,4 +60,4 @@ export function getVerticalAlign(node, slideLayoutSpNode, slideMasterSpNode) {
     }
   }
   return (anchor === 'ctr') ? 'mid' : ((anchor === 'b') ? 'down' : 'up')
-}
+}

+ 4 - 4
src/utils/pptxToJson/border.js

@@ -2,7 +2,7 @@ import tinycolor from 'tinycolor2'
 import { getSchemeColorFromTheme } from './schemeColor'
 import { getTextByPathList } from './utils'
 
-export function getBorder(node, elType, warpObj) {
+export function getBorder (node, elType, warpObj) {
   let lineNode = getTextByPathList(node, ['p:spPr', 'a:ln'])
   if (!lineNode) {
     const lnRefNode = getTextByPathList(node, ['p:style', 'a:lnRef'])
@@ -39,7 +39,7 @@ export function getBorder(node, elType, warpObj) {
 
       if (shade) {
         shade = parseInt(shade) / 100000
-        
+
         const color = tinycolor('#' + borderColor).toHsl()
         borderColor = tinycolor({ h: color.h, s: color.s, l: color.l * shade, a: color.a }).toHex()
       }
@@ -100,6 +100,6 @@ export function getBorder(node, elType, warpObj) {
     borderColor,
     borderWidth,
     borderType,
-    strokeDasharray,
+    strokeDasharray
   }
-}
+}

+ 24 - 27
src/utils/pptxToJson/chart.js

@@ -1,7 +1,7 @@
 import { eachElement, getTextByPathList } from './utils'
 import { applyTint } from './color'
 
-function extractChartColors(serNode, warpObj) {
+function extractChartColors (serNode, warpObj) {
   if (serNode.constructor !== Array) serNode = [serNode]
   const schemeClrs = []
   for (const node of serNode) {
@@ -16,8 +16,7 @@ function extractChartColors(serNode, warpObj) {
       if (clr && !isNaN(tint)) {
         clr = applyTint(clr, tint)
       }
-    }
-    else clr = getTextByPathList(node, ['c:spPr', 'a:solidFill', 'a:srgbClr', 'attrs', 'val'])
+    } else clr = getTextByPathList(node, ['c:spPr', 'a:solidFill', 'a:srgbClr', 'attrs', 'val'])
 
     if (clr) clr = '#' + clr
     schemeClrs.push(clr)
@@ -25,7 +24,7 @@ function extractChartColors(serNode, warpObj) {
   return schemeClrs
 }
 
-function extractChartData(serNode) {
+function extractChartData (serNode) {
   const dataMat = []
   if (!serNode) return dataMat
 
@@ -42,8 +41,7 @@ function extractChartData(serNode) {
       return ''
     })
     dataMat.push(dataRow)
-  } 
-  else {
+  } else {
     eachElement(serNode, (innerNode, index) => {
       const dataRow = []
       const colName = getTextByPathList(innerNode, ['c:tx', 'c:strRef', 'c:strCache', 'c:pt', 'c:v']) || index
@@ -54,8 +52,7 @@ function extractChartData(serNode) {
           rowNames[innerNode['attrs']['idx']] = innerNode['c:v']
           return ''
         })
-      } 
-      else if (getTextByPathList(innerNode, ['c:cat', 'c:numRef', 'c:numCache', 'c:pt'])) {
+      } else if (getTextByPathList(innerNode, ['c:cat', 'c:numRef', 'c:numCache', 'c:pt'])) {
         eachElement(innerNode['c:cat']['c:numRef']['c:numCache']['c:pt'], innerNode => {
           rowNames[innerNode['attrs']['idx']] = innerNode['c:v']
           return ''
@@ -66,7 +63,7 @@ function extractChartData(serNode) {
         eachElement(innerNode['c:val']['c:numRef']['c:numCache']['c:pt'], innerNode => {
           dataRow.push({
             x: innerNode['attrs']['idx'],
-            y: parseFloat(innerNode['c:v']),
+            y: parseFloat(innerNode['c:v'])
           })
           return ''
         })
@@ -75,7 +72,7 @@ function extractChartData(serNode) {
       dataMat.push({
         key: colName,
         values: dataRow,
-        xlabels: rowNames,
+        xlabels: rowNames
       })
       return ''
     })
@@ -84,7 +81,7 @@ function extractChartData(serNode) {
   return dataMat
 }
 
-export function getChartInfo(plotArea, warpObj) {
+export function getChartInfo (plotArea, warpObj) {
   let chart = null
   for (const key in plotArea) {
     switch (key) {
@@ -94,7 +91,7 @@ export function getChartInfo(plotArea, warpObj) {
           data: extractChartData(plotArea[key]['c:ser']),
           colors: extractChartColors(plotArea[key]['c:ser'], warpObj),
           grouping: getTextByPathList(plotArea[key], ['c:grouping', 'attrs', 'val']),
-          marker: plotArea[key]['c:marker'] ? true : false,
+          marker: !!plotArea[key]['c:marker']
         }
         break
       case 'c:line3DChart':
@@ -102,7 +99,7 @@ export function getChartInfo(plotArea, warpObj) {
           type: 'line3DChart',
           data: extractChartData(plotArea[key]['c:ser']),
           colors: extractChartColors(plotArea[key]['c:ser'], warpObj),
-          grouping: getTextByPathList(plotArea[key], ['c:grouping', 'attrs', 'val']),
+          grouping: getTextByPathList(plotArea[key], ['c:grouping', 'attrs', 'val'])
         }
         break
       case 'c:barChart':
@@ -111,7 +108,7 @@ export function getChartInfo(plotArea, warpObj) {
           data: extractChartData(plotArea[key]['c:ser']),
           colors: extractChartColors(plotArea[key]['c:ser'], warpObj),
           grouping: getTextByPathList(plotArea[key], ['c:grouping', 'attrs', 'val']),
-          barDir: getTextByPathList(plotArea[key], ['c:barDir', 'attrs', 'val']),
+          barDir: getTextByPathList(plotArea[key], ['c:barDir', 'attrs', 'val'])
         }
         break
       case 'c:bar3DChart':
@@ -120,21 +117,21 @@ export function getChartInfo(plotArea, warpObj) {
           data: extractChartData(plotArea[key]['c:ser']),
           colors: extractChartColors(plotArea[key]['c:ser'], warpObj),
           grouping: getTextByPathList(plotArea[key], ['c:grouping', 'attrs', 'val']),
-          barDir: getTextByPathList(plotArea[key], ['c:barDir', 'attrs', 'val']),
+          barDir: getTextByPathList(plotArea[key], ['c:barDir', 'attrs', 'val'])
         }
         break
       case 'c:pieChart':
         chart = {
           type: 'pieChart',
           data: extractChartData(plotArea[key]['c:ser']),
-          colors: extractChartColors(plotArea[key]['c:ser']['c:dPt'], warpObj),
+          colors: extractChartColors(plotArea[key]['c:ser']['c:dPt'], warpObj)
         }
         break
       case 'c:pie3DChart':
         chart = {
           type: 'pie3DChart',
           data: extractChartData(plotArea[key]['c:ser']),
-          colors: extractChartColors(plotArea[key]['c:ser']['c:dPt'], warpObj),
+          colors: extractChartColors(plotArea[key]['c:ser']['c:dPt'], warpObj)
         }
         break
       case 'c:doughnutChart':
@@ -142,7 +139,7 @@ export function getChartInfo(plotArea, warpObj) {
           type: 'doughnutChart',
           data: extractChartData(plotArea[key]['c:ser']),
           colors: extractChartColors(plotArea[key]['c:ser']['c:dPt'], warpObj),
-          holeSize: getTextByPathList(plotArea[key], ['c:holeSize', 'attrs', 'val']),
+          holeSize: getTextByPathList(plotArea[key], ['c:holeSize', 'attrs', 'val'])
         }
         break
       case 'c:areaChart':
@@ -150,7 +147,7 @@ export function getChartInfo(plotArea, warpObj) {
           type: 'areaChart',
           data: extractChartData(plotArea[key]['c:ser']),
           colors: extractChartColors(plotArea[key]['c:ser'], warpObj),
-          grouping: getTextByPathList(plotArea[key], ['c:grouping', 'attrs', 'val']),
+          grouping: getTextByPathList(plotArea[key], ['c:grouping', 'attrs', 'val'])
         }
         break
       case 'c:area3DChart':
@@ -158,7 +155,7 @@ export function getChartInfo(plotArea, warpObj) {
           type: 'area3DChart',
           data: extractChartData(plotArea[key]['c:ser']),
           colors: extractChartColors(plotArea[key]['c:ser'], warpObj),
-          grouping: getTextByPathList(plotArea[key], ['c:grouping', 'attrs', 'val']),
+          grouping: getTextByPathList(plotArea[key], ['c:grouping', 'attrs', 'val'])
         }
         break
       case 'c:scatterChart':
@@ -166,14 +163,14 @@ export function getChartInfo(plotArea, warpObj) {
           type: 'scatterChart',
           data: extractChartData(plotArea[key]['c:ser']),
           colors: extractChartColors(plotArea[key]['c:ser'], warpObj),
-          style: getTextByPathList(plotArea[key], ['c:scatterStyle', 'attrs', 'val']),
+          style: getTextByPathList(plotArea[key], ['c:scatterStyle', 'attrs', 'val'])
         }
         break
       case 'c:bubbleChart':
         chart = {
           type: 'bubbleChart',
           data: extractChartData(plotArea[key]['c:ser']),
-          colors: extractChartColors(plotArea[key]['c:ser'], warpObj),
+          colors: extractChartColors(plotArea[key]['c:ser'], warpObj)
         }
         break
       case 'c:radarChart':
@@ -181,28 +178,28 @@ export function getChartInfo(plotArea, warpObj) {
           type: 'radarChart',
           data: extractChartData(plotArea[key]['c:ser']),
           colors: extractChartColors(plotArea[key]['c:ser'], warpObj),
-          style: getTextByPathList(plotArea[key], ['c:radarStyle', 'attrs', 'val']),
+          style: getTextByPathList(plotArea[key], ['c:radarStyle', 'attrs', 'val'])
         }
         break
       case 'c:surfaceChart':
         chart = {
           type: 'surfaceChart',
           data: extractChartData(plotArea[key]['c:ser']),
-          colors: extractChartColors(plotArea[key]['c:ser'], warpObj),
+          colors: extractChartColors(plotArea[key]['c:ser'], warpObj)
         }
         break
       case 'c:surface3DChart':
         chart = {
           type: 'surface3DChart',
           data: extractChartData(plotArea[key]['c:ser']),
-          colors: extractChartColors(plotArea[key]['c:ser'], warpObj),
+          colors: extractChartColors(plotArea[key]['c:ser'], warpObj)
         }
         break
       case 'c:stockChart':
         chart = {
           type: 'stockChart',
           data: extractChartData(plotArea[key]['c:ser']),
-          colors: [],
+          colors: []
         }
         break
       default:
@@ -210,4 +207,4 @@ export function getChartInfo(plotArea, warpObj) {
   }
 
   return chart
-}
+}

+ 13 - 14
src/utils/pptxToJson/color.js

@@ -1,6 +1,6 @@
 import tinycolor from 'tinycolor2'
 
-export function hueToRgb(t1, t2, hue) {
+export function hueToRgb (t1, t2, hue) {
   if (hue < 0) hue += 6
   if (hue >= 6) hue -= 6
   if (hue < 1) return (t2 - t1) * hue + t1
@@ -9,13 +9,12 @@ export function hueToRgb(t1, t2, hue) {
   return t1
 }
 
-export function hslToRgb(hue, sat, light) {
+export function hslToRgb (hue, sat, light) {
   let t2
   hue = hue / 60
   if (light <= 0.5) {
     t2 = light * (sat + 1)
-  } 
-  else {
+  } else {
     t2 = light + sat - (light * sat)
   }
   const t1 = light * 2 - t2
@@ -25,7 +24,7 @@ export function hslToRgb(hue, sat, light) {
   return { r, g, b }
 }
 
-export function applyShade(rgbStr, shadeValue, isAlpha) {
+export function applyShade (rgbStr, shadeValue, isAlpha) {
   const color = tinycolor(rgbStr).toHsl()
   if (shadeValue >= 1) shadeValue = 1
   const cacl_l = Math.min(color.l * shadeValue, 1)
@@ -42,11 +41,11 @@ export function applyShade(rgbStr, shadeValue, isAlpha) {
     h: color.h,
     s: color.s,
     l: cacl_l,
-    a: color.a,
+    a: color.a
   }).toHex()
 }
 
-export function applyTint(rgbStr, tintValue, isAlpha) {
+export function applyTint (rgbStr, tintValue, isAlpha) {
   const color = tinycolor(rgbStr).toHsl()
   if (tintValue >= 1) tintValue = 1
   const cacl_l = color.l * tintValue + (1 - tintValue)
@@ -67,7 +66,7 @@ export function applyTint(rgbStr, tintValue, isAlpha) {
   }).toHex()
 }
 
-export function applyLumOff(rgbStr, offset, isAlpha) {
+export function applyLumOff (rgbStr, offset, isAlpha) {
   const color = tinycolor(rgbStr).toHsl()
   const lum = offset + color.l
   if (lum >= 1) {
@@ -79,7 +78,7 @@ export function applyLumOff(rgbStr, offset, isAlpha) {
         a: color.a
       }).toHex8()
     }
-      
+
     return tinycolor({
       h: color.h,
       s: color.s,
@@ -104,7 +103,7 @@ export function applyLumOff(rgbStr, offset, isAlpha) {
   }).toHex()
 }
 
-export function applyLumMod(rgbStr, multiplier, isAlpha) {
+export function applyLumMod (rgbStr, multiplier, isAlpha) {
   const color = tinycolor(rgbStr).toHsl()
   let cacl_l = color.l * multiplier
   if (cacl_l >= 1) cacl_l = 1
@@ -125,7 +124,7 @@ export function applyLumMod(rgbStr, multiplier, isAlpha) {
   }).toHex()
 }
 
-export function applyHueMod(rgbStr, multiplier, isAlpha) {
+export function applyHueMod (rgbStr, multiplier, isAlpha) {
   const color = tinycolor(rgbStr).toHsl()
   let cacl_h = color.h * multiplier
   if (cacl_h >= 360) cacl_h = cacl_h - 360
@@ -146,7 +145,7 @@ export function applyHueMod(rgbStr, multiplier, isAlpha) {
   }).toHex()
 }
 
-export function applySatMod(rgbStr, multiplier, isAlpha) {
+export function applySatMod (rgbStr, multiplier, isAlpha) {
   const color = tinycolor(rgbStr).toHsl()
   let cacl_s = color.s * multiplier
   if (cacl_s >= 1) cacl_s = 1
@@ -167,11 +166,11 @@ export function applySatMod(rgbStr, multiplier, isAlpha) {
   }).toHex()
 }
 
-export function getColorName2Hex(name) {
+export function getColorName2Hex (name) {
   let hex
   const colorName = ['white', 'AliceBlue', 'AntiqueWhite', 'Aqua', 'Aquamarine', 'Azure', 'Beige', 'Bisque', 'black', 'BlanchedAlmond', 'Blue', 'BlueViolet', 'Brown', 'BurlyWood', 'CadetBlue', 'Chartreuse', 'Chocolate', 'Coral', 'CornflowerBlue', 'Cornsilk', 'Crimson', 'Cyan', 'DarkBlue', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkGrey', 'DarkGreen', 'DarkKhaki', 'DarkMagenta', 'DarkOliveGreen', 'DarkOrange', 'DarkOrchid', 'DarkRed', 'DarkSalmon', 'DarkSeaGreen', 'DarkSlateBlue', 'DarkSlateGray', 'DarkSlateGrey', 'DarkTurquoise', 'DarkViolet', 'DeepPink', 'DeepSkyBlue', 'DimGray', 'DimGrey', 'DodgerBlue', 'FireBrick', 'FloralWhite', 'ForestGreen', 'Fuchsia', 'Gainsboro', 'GhostWhite', 'Gold', 'GoldenRod', 'Gray', 'Grey', 'Green', 'GreenYellow', 'HoneyDew', 'HotPink', 'IndianRed', 'Indigo', 'Ivory', 'Khaki', 'Lavender', 'LavenderBlush', 'LawnGreen', 'LemonChiffon', 'LightBlue', 'LightCoral', 'LightCyan', 'LightGoldenRodYellow', 'LightGray', 'LightGrey', 'LightGreen', 'LightPink', 'LightSalmon', 'LightSeaGreen', 'LightSkyBlue', 'LightSlateGray', 'LightSlateGrey', 'LightSteelBlue', 'LightYellow', 'Lime', 'LimeGreen', 'Linen', 'Magenta', 'Maroon', 'MediumAquaMarine', 'MediumBlue', 'MediumOrchid', 'MediumPurple', 'MediumSeaGreen', 'MediumSlateBlue', 'MediumSpringGreen', 'MediumTurquoise', 'MediumVioletRed', 'MidnightBlue', 'MintCream', 'MistyRose', 'Moccasin', 'NavajoWhite', 'Navy', 'OldLace', 'Olive', 'OliveDrab', 'Orange', 'OrangeRed', 'Orchid', 'PaleGoldenRod', 'PaleGreen', 'PaleTurquoise', 'PaleVioletRed', 'PapayaWhip', 'PeachPuff', 'Peru', 'Pink', 'Plum', 'PowderBlue', 'Purple', 'RebeccaPurple', 'Red', 'RosyBrown', 'RoyalBlue', 'SaddleBrown', 'Salmon', 'SandyBrown', 'SeaGreen', 'SeaShell', 'Sienna', 'Silver', 'SkyBlue', 'SlateBlue', 'SlateGray', 'SlateGrey', 'Snow', 'SpringGreen', 'SteelBlue', 'Tan', 'Teal', 'Thistle', 'Tomato', 'Turquoise', 'Violet', 'Wheat', 'White', 'WhiteSmoke', 'Yellow', 'YellowGreen']
   const colorHex = ['ffffff', 'f0f8ff', 'faebd7', '00ffff', '7fffd4', 'f0ffff', 'f5f5dc', 'ffe4c4', '000000', 'ffebcd', '0000ff', '8a2be2', 'a52a2a', 'deb887', '5f9ea0', '7fff00', 'd2691e', 'ff7f50', '6495ed', 'fff8dc', 'dc143c', '00ffff', '00008b', '008b8b', 'b8860b', 'a9a9a9', 'a9a9a9', '006400', 'bdb76b', '8b008b', '556b2f', 'ff8c00', '9932cc', '8b0000', 'e9967a', '8fbc8f', '483d8b', '2f4f4f', '2f4f4f', '00ced1', '9400d3', 'ff1493', '00bfff', '696969', '696969', '1e90ff', 'b22222', 'fffaf0', '228b22', 'ff00ff', 'dcdcdc', 'f8f8ff', 'ffd700', 'daa520', '808080', '808080', '008000', 'adff2f', 'f0fff0', 'ff69b4', 'cd5c5c', '4b0082', 'fffff0', 'f0e68c', 'e6e6fa', 'fff0f5', '7cfc00', 'fffacd', 'add8e6', 'f08080', 'e0ffff', 'fafad2', 'd3d3d3', 'd3d3d3', '90ee90', 'ffb6c1', 'ffa07a', '20b2aa', '87cefa', '778899', '778899', 'b0c4de', 'ffffe0', '00ff00', '32cd32', 'faf0e6', 'ff00ff', '800000', '66cdaa', '0000cd', 'ba55d3', '9370db', '3cb371', '7b68ee', '00fa9a', '48d1cc', 'c71585', '191970', 'f5fffa', 'ffe4e1', 'ffe4b5', 'ffdead', '000080', 'fdf5e6', '808000', '6b8e23', 'ffa500', 'ff4500', 'da70d6', 'eee8aa', '98fb98', 'afeeee', 'db7093', 'ffefd5', 'ffdab9', 'cd853f', 'ffc0cb', 'dda0dd', 'b0e0e6', '800080', '663399', 'ff0000', 'bc8f8f', '4169e1', '8b4513', 'fa8072', 'f4a460', '2e8b57', 'fff5ee', 'a0522d', 'c0c0c0', '87ceeb', '6a5acd', '708090', '708090', 'fffafa', '00ff7f', '4682b4', 'd2b48c', '008080', 'd8bfd8', 'ff6347', '40e0d0', 'ee82ee', 'f5deb3', 'ffffff', 'f5f5f5', 'ffff00', '9acd32']
   const findIndx = colorName.indexOf(name)
   if (findIndx !== -1) hex = colorHex[findIndx]
   return hex
-}
+}

+ 1 - 1
src/utils/pptxToJson/constants.js

@@ -1,3 +1,3 @@
 export const RATIO_Inches_EMUs = 914400 // 1英寸 = 914400EMUs
 export const RATIO_Inches_Points = 72 // 1英寸 = 72pt
-export const RATIO_EMUs_Points = RATIO_Inches_Points / RATIO_Inches_EMUs // 1EMUs = (72 / 914400)pt
+export const RATIO_EMUs_Points = RATIO_Inches_Points / RATIO_Inches_EMUs // 1EMUs = (72 / 914400)pt

+ 66 - 105
src/utils/pptxToJson/fill.js

@@ -8,7 +8,7 @@ import {
   applyHueMod,
   applySatMod,
   hslToRgb,
-  getColorName2Hex,
+  getColorName2Hex
 } from './color'
 
 import {
@@ -17,10 +17,10 @@ import {
   angleToDegrees,
   escapeHtml,
   getMimeType,
-  toHex,
+  toHex
 } from './utils'
 
-export function getFillType(node) {
+export function getFillType (node) {
   let fillType = ''
   if (node['a:noFill']) fillType = 'NO_FILL'
   if (node['a:solidFill']) fillType = 'SOLID_FILL'
@@ -32,23 +32,19 @@ export function getFillType(node) {
   return fillType
 }
 
-export async function getPicFill(type, node, warpObj) {
+export async function getPicFill (type, node, warpObj) {
   let img
   const rId = node['a:blip']['attrs']['r:embed']
   let imgPath
   if (type === 'slideBg' || type === 'slide') {
     imgPath = getTextByPathList(warpObj, ['slideResObj', rId, 'target'])
-  }
-  else if (type === 'slideLayoutBg') {
+  } else if (type === 'slideLayoutBg') {
     imgPath = getTextByPathList(warpObj, ['layoutResObj', rId, 'target'])
-  }
-  else if (type === 'slideMasterBg') {
+  } else if (type === 'slideMasterBg') {
     imgPath = getTextByPathList(warpObj, ['masterResObj', rId, 'target'])
-  }
-  else if (type === 'themeBg') {
+  } else if (type === 'themeBg') {
     imgPath = getTextByPathList(warpObj, ['themeResObj', rId, 'target'])
-  }
-  else if (type === 'diagramBg') {
+  } else if (type === 'diagramBg') {
     imgPath = getTextByPathList(warpObj, ['diagramResObj', rId, 'target'])
   }
   if (!imgPath) return imgPath
@@ -71,7 +67,7 @@ export async function getPicFill(type, node, warpObj) {
   return img
 }
 
-export function getPicFillOpacity(node) {
+export function getPicFillOpacity (node) {
   const aBlipNode = node['a:blip']
 
   const aphaModFixNode = getTextByPathList(aBlipNode, ['a:alphaModFix', 'attrs'])
@@ -83,7 +79,7 @@ export function getPicFillOpacity(node) {
   return opacity
 }
 
-export async function getBgPicFill(bgPr, sorce, warpObj) {
+export async function getBgPicFill (bgPr, sorce, warpObj) {
   const picBase64 = await getPicFill(sorce, bgPr['a:blipFill'], warpObj)
   const aBlipNode = bgPr['a:blipFill']['a:blip']
 
@@ -95,20 +91,20 @@ export async function getBgPicFill(bgPr, sorce, warpObj) {
 
   return {
     picBase64,
-    opacity,
+    opacity
   }
 }
 
-export function getGradientFill(node, warpObj) {
+export function getGradientFill (node, warpObj) {
   const gsLst = node['a:gsLst']['a:gs']
   const colors = []
   for (let i = 0; i < gsLst.length; i++) {
     const lo_color = getSolidFill(gsLst[i], undefined, undefined, warpObj)
     const pos = getTextByPathList(gsLst[i], ['attrs', 'pos'])
-    
+
     colors[i] = {
       pos: pos ? (pos / 1000 + '%') : '',
-      color: lo_color,
+      color: lo_color
     }
   }
   const lin = node['a:lin']
@@ -117,28 +113,28 @@ export function getGradientFill(node, warpObj) {
   if (lin) rot = angleToDegrees(lin['attrs']['ang'])
   else {
     const path = node['a:path']
-    if (path && path['attrs'] && path['attrs']['path']) pathType = path['attrs']['path'] 
+    if (path && path['attrs'] && path['attrs']['path']) pathType = path['attrs']['path']
   }
   return {
     rot,
     path: pathType,
-    colors: colors.sort((a, b) => parseInt(a.pos) - parseInt(b.pos)),
+    colors: colors.sort((a, b) => parseInt(a.pos) - parseInt(b.pos))
   }
 }
 
-export function getBgGradientFill(bgPr, phClr, slideMasterContent, warpObj) {
+export function getBgGradientFill (bgPr, phClr, slideMasterContent, warpObj) {
   if (bgPr) {
     const grdFill = bgPr['a:gradFill']
     const gsLst = grdFill['a:gsLst']['a:gs']
     const colors = []
-    
+
     for (let i = 0; i < gsLst.length; i++) {
       const lo_color = getSolidFill(gsLst[i], slideMasterContent['p:sldMaster']['p:clrMap']['attrs'], phClr, warpObj)
       const pos = getTextByPathList(gsLst[i], ['attrs', 'pos'])
 
       colors[i] = {
         pos: pos ? (pos / 1000 + '%') : '',
-        color: lo_color,
+        color: lo_color
       }
     }
     const lin = grdFill['a:lin']
@@ -147,25 +143,24 @@ export function getBgGradientFill(bgPr, phClr, slideMasterContent, warpObj) {
     if (lin) rot = angleToDegrees(lin['attrs']['ang']) + 0
     else {
       const path = grdFill['a:path']
-      if (path && path['attrs'] && path['attrs']['path']) pathType = path['attrs']['path'] 
+      if (path && path['attrs'] && path['attrs']['path']) pathType = path['attrs']['path']
     }
     return {
       rot,
       path: pathType,
-      colors: colors.sort((a, b) => parseInt(a.pos) - parseInt(b.pos)),
+      colors: colors.sort((a, b) => parseInt(a.pos) - parseInt(b.pos))
     }
-  }
-  else if (phClr) {
+  } else if (phClr) {
     return phClr.indexOf('#') === -1 ? `#${phClr}` : phClr
   }
   return null
 }
 
-export async function getSlideBackgroundFill(warpObj) {
+export async function getSlideBackgroundFill (warpObj) {
   const slideContent = warpObj['slideContent']
   const slideLayoutContent = warpObj['slideLayoutContent']
   const slideMasterContent = warpObj['slideMasterContent']
-  
+
   let bgPr = getTextByPathList(slideContent, ['p:sld', 'p:cSld', 'p:bg', 'p:bgPr'])
   let bgRef = getTextByPathList(slideContent, ['p:sld', 'p:cSld', 'p:bg', 'p:bgRef'])
 
@@ -187,23 +182,19 @@ export async function getSlideBackgroundFill(warpObj) {
       }
       const sldBgClr = getSolidFill(sldFill, clrMapOvr, undefined, warpObj)
       background = sldBgClr
-    }
-    else if (bgFillTyp === 'GRADIENT_FILL') {
+    } else if (bgFillTyp === 'GRADIENT_FILL') {
       const gradientFill = getBgGradientFill(bgPr, undefined, slideMasterContent, warpObj)
       if (typeof gradientFill === 'string') {
         background = gradientFill
-      }
-      else if (gradientFill) {
+      } else if (gradientFill) {
         background = gradientFill
         backgroundType = 'gradient'
       }
-    }
-    else if (bgFillTyp === 'PIC_FILL') {
+    } else if (bgFillTyp === 'PIC_FILL') {
       background = await getBgPicFill(bgPr, 'slideBg', warpObj)
       backgroundType = 'image'
     }
-  }
-  else if (bgRef) {
+  } else if (bgRef) {
     let clrMapOvr
     const sldClrMapOvr = getTextByPathList(slideContent, ['p:sld', 'p:clrMapOvr', 'a:overrideClrMapping', 'attrs'])
     if (sldClrMapOvr) clrMapOvr = sldClrMapOvr
@@ -234,8 +225,7 @@ export async function getSlideBackgroundFill(warpObj) {
               }
               sortblAry.push(obj)
             }
-          } 
-          else {
+          } else {
             const obj = {}
             obj[key] = bgFillLstTyp
             if (bgFillLstTyp['attrs']) {
@@ -256,20 +246,17 @@ export async function getSlideBackgroundFill(warpObj) {
         const sldFill = bgFillLstIdx['a:solidFill']
         const sldBgClr = getSolidFill(sldFill, clrMapOvr, undefined, warpObj)
         background = sldBgClr
-      } 
-      else if (bgFillTyp === 'GRADIENT_FILL') {
+      } else if (bgFillTyp === 'GRADIENT_FILL') {
         const gradientFill = getBgGradientFill(bgFillLstIdx, phClr, slideMasterContent, warpObj)
         if (typeof gradientFill === 'string') {
           background = gradientFill
-        }
-        else if (gradientFill) {
+        } else if (gradientFill) {
           background = gradientFill
           backgroundType = 'gradient'
         }
       }
     }
-  }
-  else {
+  } else {
     bgPr = getTextByPathList(slideLayoutContent, ['p:sldLayout', 'p:cSld', 'p:bg', 'p:bgPr'])
     bgRef = getTextByPathList(slideLayoutContent, ['p:sldLayout', 'p:cSld', 'p:bg', 'p:bgRef'])
 
@@ -284,26 +271,22 @@ export async function getSlideBackgroundFill(warpObj) {
         const sldFill = bgPr['a:solidFill']
         const sldBgClr = getSolidFill(sldFill, clrMapOvr, undefined, warpObj)
         background = sldBgClr
-      }
-      else if (bgFillTyp === 'GRADIENT_FILL') {
+      } else if (bgFillTyp === 'GRADIENT_FILL') {
         const gradientFill = getBgGradientFill(bgPr, undefined, slideMasterContent, warpObj)
         if (typeof gradientFill === 'string') {
           background = gradientFill
-        }
-        else if (gradientFill) {
+        } else if (gradientFill) {
           background = gradientFill
           backgroundType = 'gradient'
         }
-      }
-      else if (bgFillTyp === 'PIC_FILL') {
+      } else if (bgFillTyp === 'PIC_FILL') {
         background = await getBgPicFill(bgPr, 'slideLayoutBg', warpObj)
         backgroundType = 'image'
       }
-    }
-    else if (bgRef) {
+    } else if (bgRef) {
       const phClr = getSolidFill(bgRef, clrMapOvr, undefined, warpObj)
       const idx = Number(bgRef['attrs']['idx'])
-  
+
       if (idx > 1000) {
         const trueIdx = idx - 1000
         const bgFillLst = warpObj['themeContent']['a:theme']['a:themeElements']['a:fmtScheme']['a:bgFillStyleLst']
@@ -323,8 +306,7 @@ export async function getSlideBackgroundFill(warpObj) {
                 }
                 sortblAry.push(obj)
               }
-            } 
-            else {
+            } else {
               const obj = {}
               obj[key] = bgFillLstTyp
               if (bgFillLstTyp['attrs']) {
@@ -345,24 +327,20 @@ export async function getSlideBackgroundFill(warpObj) {
           const sldFill = bgFillLstIdx['a:solidFill']
           const sldBgClr = getSolidFill(sldFill, clrMapOvr, undefined, warpObj)
           background = sldBgClr
-        } 
-        else if (bgFillTyp === 'GRADIENT_FILL') {
+        } else if (bgFillTyp === 'GRADIENT_FILL') {
           const gradientFill = getBgGradientFill(bgFillLstIdx, phClr, slideMasterContent, warpObj)
           if (typeof gradientFill === 'string') {
             background = gradientFill
-          }
-          else if (gradientFill) {
+          } else if (gradientFill) {
             background = gradientFill
             backgroundType = 'gradient'
           }
-        }
-        else if (bgFillTyp === 'PIC_FILL') {
+        } else if (bgFillTyp === 'PIC_FILL') {
           background = await getBgPicFill(bgFillLstIdx, 'themeBg', warpObj)
           backgroundType = 'image'
         }
       }
-    }
-    else {
+    } else {
       bgPr = getTextByPathList(slideMasterContent, ['p:sldMaster', 'p:cSld', 'p:bg', 'p:bgPr'])
       bgRef = getTextByPathList(slideMasterContent, ['p:sldMaster', 'p:cSld', 'p:bg', 'p:bgRef'])
 
@@ -373,26 +351,22 @@ export async function getSlideBackgroundFill(warpObj) {
           const sldFill = bgPr['a:solidFill']
           const sldBgClr = getSolidFill(sldFill, clrMap, undefined, warpObj)
           background = sldBgClr
-        }
-        else if (bgFillTyp === 'GRADIENT_FILL') {
+        } else if (bgFillTyp === 'GRADIENT_FILL') {
           const gradientFill = getBgGradientFill(bgPr, undefined, slideMasterContent, warpObj)
           if (typeof gradientFill === 'string') {
             background = gradientFill
-          }
-          else if (gradientFill) {
+          } else if (gradientFill) {
             background = gradientFill
             backgroundType = 'gradient'
           }
-        }
-        else if (bgFillTyp === 'PIC_FILL') {
+        } else if (bgFillTyp === 'PIC_FILL') {
           background = await getBgPicFill(bgPr, 'slideMasterBg', warpObj)
           backgroundType = 'image'
         }
-      }
-      else if (bgRef) {
+      } else if (bgRef) {
         const phClr = getSolidFill(bgRef, clrMap, undefined, warpObj)
         const idx = Number(bgRef['attrs']['idx'])
-    
+
         if (idx > 1000) {
           const trueIdx = idx - 1000
           const bgFillLst = warpObj['themeContent']['a:theme']['a:themeElements']['a:fmtScheme']['a:bgFillStyleLst']
@@ -412,8 +386,7 @@ export async function getSlideBackgroundFill(warpObj) {
                   }
                   sortblAry.push(obj)
                 }
-              } 
-              else {
+              } else {
                 const obj = {}
                 obj[key] = bgFillLstTyp
                 if (bgFillLstTyp['attrs']) {
@@ -434,18 +407,15 @@ export async function getSlideBackgroundFill(warpObj) {
             const sldFill = bgFillLstIdx['a:solidFill']
             const sldBgClr = getSolidFill(sldFill, clrMapOvr, undefined, warpObj)
             background = sldBgClr
-          } 
-          else if (bgFillTyp === 'GRADIENT_FILL') {
+          } else if (bgFillTyp === 'GRADIENT_FILL') {
             const gradientFill = getBgGradientFill(bgFillLstIdx, phClr, slideMasterContent, warpObj)
             if (typeof gradientFill === 'string') {
               background = gradientFill
-            }
-            else if (gradientFill) {
+            } else if (gradientFill) {
               background = gradientFill
               backgroundType = 'gradient'
             }
-          }
-          else if (bgFillTyp === 'PIC_FILL') {
+          } else if (bgFillTyp === 'PIC_FILL') {
             background = await getBgPicFill(bgFillLstIdx, 'themeBg', warpObj)
             backgroundType = 'image'
           }
@@ -455,34 +425,31 @@ export async function getSlideBackgroundFill(warpObj) {
   }
   return {
     type: backgroundType,
-    value: background,
+    value: background
   }
 }
 
-export async function getShapeFill(node, pNode, isSvgMode, warpObj, source) {
+export async function getShapeFill (node, pNode, isSvgMode, warpObj, source) {
   const fillType = getFillType(getTextByPathList(node, ['p:spPr']))
   let type = 'color'
   let fillValue = ''
   if (fillType === 'NO_FILL') {
     return isSvgMode ? 'none' : ''
-  } 
-  else if (fillType === 'SOLID_FILL') {
+  } else if (fillType === 'SOLID_FILL') {
     const shpFill = node['p:spPr']['a:solidFill']
     fillValue = getSolidFill(shpFill, undefined, undefined, warpObj)
     type = 'color'
-  }
-  else if (fillType === 'GRADIENT_FILL') {
+  } else if (fillType === 'GRADIENT_FILL') {
     const shpFill = node['p:spPr']['a:gradFill']
     fillValue = getGradientFill(shpFill, warpObj)
     type = 'gradient'
-  }
-  else if (fillType === 'PIC_FILL') {
+  } else if (fillType === 'PIC_FILL') {
     const shpFill = node['p:spPr']['a:blipFill']
     const picBase64 = await getPicFill(source, shpFill, warpObj)
     const opacity = getPicFillOpacity(shpFill)
     fillValue = {
       picBase64,
-      opacity,
+      opacity
     }
     type = 'image'
   }
@@ -499,19 +466,18 @@ export async function getShapeFill(node, pNode, isSvgMode, warpObj, source) {
         const spShpNode = { 'p:spPr': grpShpFill }
         return getShapeFill(spShpNode, node, isSvgMode, warpObj, source)
       }
-    } 
-    else if (fillType === 'NO_FILL') {
+    } else if (fillType === 'NO_FILL') {
       return isSvgMode ? 'none' : ''
     }
   }
 
   return {
     type,
-    value: fillValue,
+    value: fillValue
   }
 }
 
-export function getSolidFill(solidFill, clrMap, phClr, warpObj) {
+export function getSolidFill (solidFill, clrMap, phClr, warpObj) {
   if (!solidFill) return ''
 
   let color = ''
@@ -520,26 +486,22 @@ export function getSolidFill(solidFill, clrMap, phClr, warpObj) {
   if (solidFill['a:srgbClr']) {
     clrNode = solidFill['a:srgbClr']
     color = getTextByPathList(clrNode, ['attrs', 'val'])
-  } 
-  else if (solidFill['a:schemeClr']) {
+  } else if (solidFill['a:schemeClr']) {
     clrNode = solidFill['a:schemeClr']
     const schemeClr = 'a:' + getTextByPathList(clrNode, ['attrs', 'val'])
     color = getSchemeColorFromTheme(schemeClr, warpObj, clrMap, phClr) || ''
-  }
-  else if (solidFill['a:scrgbClr']) {
+  } else if (solidFill['a:scrgbClr']) {
     clrNode = solidFill['a:scrgbClr']
     const defBultColorVals = clrNode['attrs']
     const red = (defBultColorVals['r'].indexOf('%') !== -1) ? defBultColorVals['r'].split('%').shift() : defBultColorVals['r']
     const green = (defBultColorVals['g'].indexOf('%') !== -1) ? defBultColorVals['g'].split('%').shift() : defBultColorVals['g']
     const blue = (defBultColorVals['b'].indexOf('%') !== -1) ? defBultColorVals['b'].split('%').shift() : defBultColorVals['b']
     color = toHex(255 * (Number(red) / 100)) + toHex(255 * (Number(green) / 100)) + toHex(255 * (Number(blue) / 100))
-  } 
-  else if (solidFill['a:prstClr']) {
+  } else if (solidFill['a:prstClr']) {
     clrNode = solidFill['a:prstClr']
     const prstClr = getTextByPathList(clrNode, ['attrs', 'val'])
     color = getColorName2Hex(prstClr)
-  } 
-  else if (solidFill['a:hslClr']) {
+  } else if (solidFill['a:hslClr']) {
     clrNode = solidFill['a:hslClr']
     const defBultColorVals = clrNode['attrs']
     const hue = Number(defBultColorVals['hue']) / 100000
@@ -547,8 +509,7 @@ export function getSolidFill(solidFill, clrMap, phClr, warpObj) {
     const lum = Number((defBultColorVals['lum'].indexOf('%') !== -1) ? defBultColorVals['lum'].split('%').shift() : defBultColorVals['lum']) / 100
     const hsl2rgb = hslToRgb(hue, sat, lum)
     color = toHex(hsl2rgb.r) + toHex(hsl2rgb.g) + toHex(hsl2rgb.b)
-  } 
-  else if (solidFill['a:sysClr']) {
+  } else if (solidFill['a:sysClr']) {
     clrNode = solidFill['a:sysClr']
     const sysClr = getTextByPathList(clrNode, ['attrs', 'lastClr'])
     if (sysClr) color = sysClr
@@ -591,4 +552,4 @@ export function getSolidFill(solidFill, clrMap, phClr, warpObj) {
   if (color && color.indexOf('#') === -1) color = '#' + color
 
   return color
-}
+}

+ 21 - 29
src/utils/pptxToJson/fontStyle.js

@@ -2,7 +2,7 @@ import { getTextByPathList } from './utils'
 import { getShadow } from './shadow'
 import { getFillType, getSolidFill } from './fill'
 
-export function getFontType(node, type, warpObj) {
+export function getFontType (node, type, warpObj) {
   let typeface = getTextByPathList(node, ['a:rPr', 'a:latin', 'attrs', 'typeface'])
 
   if (!typeface) {
@@ -10,11 +10,9 @@ export function getFontType(node, type, warpObj) {
 
     if (type === 'title' || type === 'subTitle' || type === 'ctrTitle') {
       typeface = getTextByPathList(fontSchemeNode, ['a:majorFont', 'a:latin', 'attrs', 'typeface'])
-    } 
-    else if (type === 'body') {
+    } else if (type === 'body') {
       typeface = getTextByPathList(fontSchemeNode, ['a:minorFont', 'a:latin', 'attrs', 'typeface'])
-    } 
-    else {
+    } else {
       typeface = getTextByPathList(fontSchemeNode, ['a:minorFont', 'a:latin', 'attrs', 'typeface'])
     }
   }
@@ -22,7 +20,7 @@ export function getFontType(node, type, warpObj) {
   return typeface || ''
 }
 
-export function getFontColor(node, pNode, lstStyle, pFontStyle, lvl, warpObj) {
+export function getFontColor (node, pNode, lstStyle, pFontStyle, lvl, warpObj) {
   const rPrNode = getTextByPathList(node, ['a:rPr'])
   let filTyp, color
   if (rPrNode) {
@@ -48,8 +46,7 @@ export function getFontColor(node, pNode, lstStyle, pFontStyle, lvl, warpObj) {
   return color || ''
 }
 
-export function getFontSize(node, slideLayoutSpNode, type, slideMasterTextStyles) {
-  
+export function getFontSize (node, slideLayoutSpNode, type, slideMasterTextStyles) {
   let fontSize
 
   // 检查列表样式中的字体大小
@@ -71,26 +68,24 @@ export function getFontSize(node, slideLayoutSpNode, type, slideMasterTextStyles
     const pPrNode = getTextByPathList(node, ['a:pPr'])
     if (pPrNode) {
       const lvl = parseInt(pPrNode.attrs?.lvl || '0')
-      
+
       // 检查布局中的字体大小设置
       const layoutSz = getTextByPathList(slideLayoutSpNode, ['p:txBody', 'a:lstStyle', `a:lvl${lvl + 1}pPr`, 'a:defRPr', 'attrs', 'sz'])
       if (layoutSz) {
         fontSize = parseInt(layoutSz) / 100
       }
-      
+
       // 如果没有找到布局大小,检查母版样式
       if ((!fontSize || isNaN(fontSize)) && slideMasterTextStyles) {
         let styleNode
         if (type === 'title' || type === 'ctrTitle') {
           styleNode = getTextByPathList(slideMasterTextStyles, ['p:titleStyle'])
-        }
-        else if (type === 'body') {
+        } else if (type === 'body') {
           styleNode = getTextByPathList(slideMasterTextStyles, ['p:bodyStyle'])
-        }
-        else if (type === 'subTitle') {
+        } else if (type === 'subTitle') {
           styleNode = getTextByPathList(slideMasterTextStyles, ['p:otherStyle'])
         }
-        
+
         if (styleNode) {
           const masterSz = getTextByPathList(styleNode, [`a:lvl${lvl + 1}pPr`, 'a:defRPr', 'attrs', 'sz'])
           if (masterSz) {
@@ -105,14 +100,11 @@ export function getFontSize(node, slideLayoutSpNode, type, slideMasterTextStyles
   if (!fontSize || isNaN(fontSize)) {
     if (type === 'title' || type === 'ctrTitle') {
       fontSize = 60 // 标题默认60磅
-    }
-    else if (type === 'subTitle') {
+    } else if (type === 'subTitle') {
       fontSize = 32 // 副标题默认32磅
-    }
-    else if (type === 'body') {
+    } else if (type === 'body') {
       fontSize = 18 // 正文默认18磅
-    }
-    else {
+    } else {
       fontSize = 18 // 其他默认18磅
     }
   }
@@ -120,34 +112,34 @@ export function getFontSize(node, slideLayoutSpNode, type, slideMasterTextStyles
   return fontSize + 'pt'
 }
 
-export function getFontBold(node) {
+export function getFontBold (node) {
   return getTextByPathList(node, ['a:rPr', 'attrs', 'b']) === '1' ? 'bold' : ''
 }
 
-export function getFontItalic(node) {
+export function getFontItalic (node) {
   return getTextByPathList(node, ['a:rPr', 'attrs', 'i']) === '1' ? 'italic' : ''
 }
 
-export function getFontDecoration(node) {
+export function getFontDecoration (node) {
   return getTextByPathList(node, ['a:rPr', 'attrs', 'u']) === 'sng' ? 'underline' : ''
 }
 
-export function getFontDecorationLine(node) {
+export function getFontDecorationLine (node) {
   return getTextByPathList(node, ['a:rPr', 'attrs', 'strike']) === 'sngStrike' ? 'line-through' : ''
 }
 
-export function getFontSpace(node) {
+export function getFontSpace (node) {
   const spc = getTextByPathList(node, ['a:rPr', 'attrs', 'spc'])
   return spc ? (parseInt(spc) / 100 + 'pt') : ''
 }
 
-export function getFontSubscript(node) {
+export function getFontSubscript (node) {
   const baseline = getTextByPathList(node, ['a:rPr', 'attrs', 'baseline'])
   if (!baseline) return ''
   return parseInt(baseline) > 0 ? 'super' : 'sub'
 }
 
-export function getFontShadow(node, warpObj) {
+export function getFontShadow (node, warpObj) {
   const txtShadow = getTextByPathList(node, ['a:rPr', 'a:effectLst', 'a:outerShdw'])
   if (txtShadow) {
     const shadow = getShadow(txtShadow, warpObj)
@@ -159,4 +151,4 @@ export function getFontShadow(node, warpObj) {
     }
   }
   return ''
-}
+}

+ 20 - 22
src/utils/pptxToJson/math.js

@@ -1,10 +1,10 @@
 import { getTextByPathList } from './utils'
 
-export function findOMath(obj) {
+export function findOMath (obj) {
   let results = []
   if (typeof obj !== 'object') return results
   if (obj['m:oMath']) results = results.concat(obj['m:oMath'])
-  
+
   Object.values(obj).forEach(value => {
     if (Array.isArray(value) || typeof value === 'object') {
       results = results.concat(findOMath(value))
@@ -13,46 +13,46 @@ export function findOMath(obj) {
   return results
 }
 
-export function parseFraction(fraction) {
+export function parseFraction (fraction) {
   const numerator = parseOMath(fraction['m:num'])
   const denominator = parseOMath(fraction['m:den'])
   return `\\frac{${numerator}}{${denominator}}`
 }
-export function parseSuperscript(superscript) {
+export function parseSuperscript (superscript) {
   const base = parseOMath(superscript['m:e'])
   const sup = parseOMath(superscript['m:sup'])
   return `${base}^{${sup}}`
 }
-export function parseSubscript(subscript) {
+export function parseSubscript (subscript) {
   const base = parseOMath(subscript['m:e'])
   const sub = parseOMath(subscript['m:sub'])
   return `${base}_{${sub}}`
 }
-export function parseRadical(radical) {
+export function parseRadical (radical) {
   const degree = parseOMath(radical['m:deg'])
   const expression = parseOMath(radical['m:e'])
   return degree ? `\\sqrt[${degree}]{${expression}}` : `\\sqrt{${expression}}`
 }
-export function parseMatrix(matrix) {
+export function parseMatrix (matrix) {
   const rows = matrix['m:mr']
   const matrixRows = rows.map((row) => {
     return row['m:e'].map((element) => parseOMath(element)).join(' & ')
   })
   return `\\begin{matrix} ${matrixRows.join(' \\\\ ')} \\end{matrix}`
 }
-export function parseNary(nary) {
+export function parseNary (nary) {
   const op = getTextByPathList(nary, ['m:naryPr', 'm:chr', 'attrs', 'm:val']) || '∫'
   const sub = parseOMath(nary['m:sub'])
   const sup = parseOMath(nary['m:sup'])
   const e = parseOMath(nary['m:e'])
   return `${op}_{${sub}}^{${sup}}{${e}}`
 }
-export function parseLimit(limit, type) {
+export function parseLimit (limit, type) {
   const base = parseOMath(limit['m:e'])
   const lim = parseOMath(limit['m:lim'])
   return type === 'low' ? `${base}_{${lim}}` : `${base}^{${lim}}`
 }
-export function parseDelimiter(delimiter) {
+export function parseDelimiter (delimiter) {
   let left = getTextByPathList(delimiter, ['m:dPr', 'm:begChr', 'attrs', 'm:val'])
   let right = getTextByPathList(delimiter, ['m:dPr', 'm:endChr', 'attrs', 'm:val'])
   if (!left && !right) {
@@ -66,26 +66,26 @@ export function parseDelimiter(delimiter) {
   const e = parseOMath(delimiter['m:e'])
   return `${left}${e}${right}`
 }
-export function parseFunction(func) {
+export function parseFunction (func) {
   const name = parseOMath(func['m:fName'])
   const arg = parseOMath(func['m:e'])
   return `\\${name}{${arg}}`
 }
-export function parseGroupChr(groupChr) {
+export function parseGroupChr (groupChr) {
   const chr = getTextByPathList(groupChr, ['m:groupChrPr', 'm:chr', 'attrs', 'm:val'])
   const e = parseOMath(groupChr['m:e'])
   return `${chr}${e}${chr}`
 }
-export function parseEqArr(eqArr) {
+export function parseEqArr (eqArr) {
   const equations = eqArr['m:e'].map((eq) => parseOMath(eq)).join(' \\\\ ')
   return `\\begin{cases} ${equations} \\end{cases}`
 }
-export function parseBar(bar) {
+export function parseBar (bar) {
   const e = parseOMath(bar['m:e'])
   const pos = getTextByPathList(bar, ['m:barPr', 'm:pos', 'attrs', 'm:val'])
   return pos === 'top' ? `\\overline{${e}}` : `\\underline{${e}}`
 }
-export function parseAccent(accent) {
+export function parseAccent (accent) {
   const chr = getTextByPathList(accent, ['m:accPr', 'm:chr', 'attrs', 'm:val']) || '^'
   const e = parseOMath(accent['m:e'])
   switch (chr) {
@@ -117,13 +117,12 @@ export function parseAccent(accent) {
       return `\\${chr}{${e}}`
   }
 }
-export function parseBox(box) {
+export function parseBox (box) {
   const e = parseOMath(box['m:e'])
   return `\\boxed{${e}}`
 }
 
-
-export function parseOMath(oMath) {
+export function parseOMath (oMath) {
   if (!oMath) return ''
 
   if (Array.isArray(oMath)) {
@@ -135,8 +134,7 @@ export function parseOMath(oMath) {
   for (const key of keys) {
     if (Array.isArray(oMath[key])) {
       oMathList.push(...oMath[key].map(item => ({ key, value: item })))
-    }
-    else oMathList.push({ key, value: oMath[key] })
+    } else oMathList.push({ key, value: oMath[key] })
   }
 
   oMathList.sort((a, b) => {
@@ -175,10 +173,10 @@ export function parseOMath(oMath) {
   }).join('')
 }
 
-export function latexFormart(latex) {
+export function latexFormart (latex) {
   return latex.replaceAll(/&lt;/g, '<')
     .replaceAll(/&gt;/g, '>')
     .replaceAll(/&amp;/g, '&')
     .replaceAll(/&apos;/g, "'")
     .replaceAll(/&quot;/g, '"')
-}
+}

+ 12 - 5
src/utils/pptxToJson/position.js

@@ -1,6 +1,13 @@
+/*
+ * @Author: LiZhiWei
+ * @Date: 2025-04-21 16:39:43
+ * @LastEditors: LiZhiWei
+ * @LastEditTime: 2025-04-21 16:41:33
+ * @Description:
+ */
 import { RATIO_EMUs_Points } from './constants'
 
-export function getPosition(slideSpNode, slideLayoutSpNode, slideMasterSpNode) {
+export function getPosition (slideSpNode, slideLayoutSpNode, slideMasterSpNode) {
   let off
 
   if (slideSpNode) off = slideSpNode['a:off']['attrs']
@@ -11,11 +18,11 @@ export function getPosition(slideSpNode, slideLayoutSpNode, slideMasterSpNode) {
 
   return {
     top: parseInt(off['y']) * RATIO_EMUs_Points,
-    left: parseInt(off['x']) * RATIO_EMUs_Points,
+    left: parseInt(off['x']) * RATIO_EMUs_Points
   }
 }
 
-export function getSize(slideSpNode, slideLayoutSpNode, slideMasterSpNode) {
+export function getSize (slideSpNode, slideLayoutSpNode, slideMasterSpNode) {
   let ext
 
   if (slideSpNode) ext = slideSpNode['a:ext']['attrs']
@@ -26,6 +33,6 @@ export function getSize(slideSpNode, slideLayoutSpNode, slideMasterSpNode) {
 
   return {
     width: parseInt(ext['cx']) * RATIO_EMUs_Points,
-    height: parseInt(ext['cy']) * RATIO_EMUs_Points,
+    height: parseInt(ext['cy']) * RATIO_EMUs_Points
   }
-}
+}

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 637 - 158
src/utils/pptxToJson/pptxtojson.js


+ 6 - 7
src/utils/pptxToJson/readXmlFile.js

@@ -2,14 +2,14 @@ import * as txml from 'txml/dist/txml.mjs'
 
 let cust_attr_order = 0
 
-export function simplifyLostLess(children, parentAttributes = {}) {
+export function simplifyLostLess (children, parentAttributes = {}) {
   const out = {}
   if (!children.length) return out
 
   if (children.length === 1 && typeof children[0] === 'string') {
     return Object.keys(parentAttributes).length ? {
       attrs: { order: cust_attr_order++, ...parentAttributes },
-      value: children[0],
+      value: children[0]
     } : children[0]
   }
   for (const child of children) {
@@ -19,7 +19,7 @@ export function simplifyLostLess(children, parentAttributes = {}) {
     if (!out[child.tagName]) out[child.tagName] = []
 
     const kids = simplifyLostLess(child.children || [], child.attributes)
-    
+
     if (typeof kids === 'object') {
       if (!kids.attrs) kids.attrs = { order: cust_attr_order++ }
       else kids.attrs.order = cust_attr_order++
@@ -36,12 +36,11 @@ export function simplifyLostLess(children, parentAttributes = {}) {
   return out
 }
 
-export async function readXmlFile(zip, filename) {
+export async function readXmlFile (zip, filename) {
   try {
     const data = await zip.file(filename).async('string')
     return simplifyLostLess(txml.parse(data))
-  }
-  catch {
+  } catch {
     return null
   }
-}
+}

+ 3 - 4
src/utils/pptxToJson/schemeColor.js

@@ -1,6 +1,6 @@
 import { getTextByPathList } from './utils'
 
-export function getSchemeColorFromTheme(schemeClr, warpObj, clrMap, phClr) {
+export function getSchemeColorFromTheme (schemeClr, warpObj, clrMap, phClr) {
   let color
   let slideLayoutClrOvride
   if (clrMap) slideLayoutClrOvride = clrMap
@@ -29,8 +29,7 @@ export function getSchemeColorFromTheme(schemeClr, warpObj, clrMap, phClr) {
         default:
           break
       }
-    }
-    else {
+    } else {
       switch (schemeClr) {
         case 'tx1':
           schemeClr = 'a:dk1'
@@ -53,4 +52,4 @@ export function getSchemeColorFromTheme(schemeClr, warpObj, clrMap, phClr) {
     if (!color && refNode) color = getTextByPathList(refNode, ['a:sysClr', 'attrs', 'lastClr'])
   }
   return color
-}
+}

+ 3 - 3
src/utils/pptxToJson/shadow.js

@@ -1,7 +1,7 @@
 import { getSolidFill } from './fill'
 import { RATIO_EMUs_Points } from './constants'
 
-export function getShadow(node, warpObj) {
+export function getShadow (node, warpObj) {
   const chdwClrNode = getSolidFill(node, undefined, undefined, warpObj)
   const outerShdwAttrs = node['attrs']
   const dir = outerShdwAttrs['dir'] ? (parseInt(outerShdwAttrs['dir']) / 60000) : 0
@@ -14,6 +14,6 @@ export function getShadow(node, warpObj) {
     h: hx,
     v: vx,
     blur: blurRad,
-    color: chdwClrNode,
+    color: chdwClrNode
   }
-}
+}

+ 14 - 19
src/utils/pptxToJson/shape.js

@@ -1,6 +1,6 @@
 import { getTextByPathList } from './utils'
 
-export function shapeArc(cX, cY, rX, rY, stAng, endAng, isClose) {
+export function shapeArc (cX, cY, rX, rY, stAng, endAng, isClose) {
   let dData
   let angle = stAng
   if (endAng >= stAng) {
@@ -14,8 +14,7 @@ export function shapeArc(cX, cY, rX, rY, stAng, endAng, isClose) {
       dData += ' L' + x + ' ' + y
       angle++
     }
-  } 
-  else {
+  } else {
     while (angle > endAng) {
       const radians = angle * (Math.PI / 180)
       const x = cX + Math.cos(radians) * rX
@@ -31,7 +30,7 @@ export function shapeArc(cX, cY, rX, rY, stAng, endAng, isClose) {
   return dData
 }
 
-export function getCustomShapePath(custShapType, w, h) {
+export function getCustomShapePath (custShapType, w, h) {
   const pathLstNode = getTextByPathList(custShapType, ['a:pathLst'])
   let pathNodes = getTextByPathList(pathLstNode, ['a:path'])
 
@@ -65,7 +64,7 @@ export function getCustomShapePath(custShapType, w, h) {
             type: 'movto',
             x: spX,
             y: spY,
-            order,
+            order
           })
         })
       }
@@ -83,7 +82,7 @@ export function getCustomShapePath(custShapType, w, h) {
               type: 'lnto',
               x: ptX,
               y: ptY,
-              order,
+              order
             })
           })
         }
@@ -103,7 +102,7 @@ export function getCustomShapePath(custShapType, w, h) {
         key.forEach(pt => {
           const pt_obj = {
             x: pt['attrs']['x'],
-            y: pt['attrs']['y'],
+            y: pt['attrs']['y']
           }
           pts_ary.push(pt_obj)
         })
@@ -111,7 +110,7 @@ export function getCustomShapePath(custShapType, w, h) {
         multiSapeAry.push({
           type: 'cubicBezTo',
           cubBzPt: pts_ary,
-          order,
+          order
         })
       })
     }
@@ -137,7 +136,7 @@ export function getCustomShapePath(custShapType, w, h) {
         swAng: swAng,
         shftX: shftX,
         shftY: shftY,
-        order,
+        order
       })
     }
     if (closeNode) {
@@ -145,7 +144,7 @@ export function getCustomShapePath(custShapType, w, h) {
       Object.keys(closeNode).forEach(() => {
         multiSapeAry.push({
           type: 'close',
-          order: Infinity,
+          order: Infinity
         })
       })
     }
@@ -158,13 +157,11 @@ export function getCustomShapePath(custShapType, w, h) {
         const spX = parseInt(multiSapeAry[k].x) * cX
         const spY = parseInt(multiSapeAry[k].y) * cY
         d += ' M' + spX + ',' + spY
-      } 
-      else if (multiSapeAry[k].type === 'lnto') {
+      } else if (multiSapeAry[k].type === 'lnto') {
         const Lx = parseInt(multiSapeAry[k].x) * cX
         const Ly = parseInt(multiSapeAry[k].y) * cY
         d += ' L' + Lx + ',' + Ly
-      } 
-      else if (multiSapeAry[k].type === 'cubicBezTo') {
+      } else if (multiSapeAry[k].type === 'cubicBezTo') {
         const Cx1 = parseInt(multiSapeAry[k].cubBzPt[0].x) * cX
         const Cy1 = parseInt(multiSapeAry[k].cubBzPt[0].y) * cY
         const Cx2 = parseInt(multiSapeAry[k].cubBzPt[1].x) * cX
@@ -172,19 +169,17 @@ export function getCustomShapePath(custShapType, w, h) {
         const Cx3 = parseInt(multiSapeAry[k].cubBzPt[2].x) * cX
         const Cy3 = parseInt(multiSapeAry[k].cubBzPt[2].y) * cY
         d += ' C' + Cx1 + ',' + Cy1 + ' ' + Cx2 + ',' + Cy2 + ' ' + Cx3 + ',' + Cy3
-      } 
-      else if (multiSapeAry[k].type === 'arcTo') {
+      } else if (multiSapeAry[k].type === 'arcTo') {
         const hR = parseInt(multiSapeAry[k].hR) * cX
         const wR = parseInt(multiSapeAry[k].wR) * cY
         const stAng = parseInt(multiSapeAry[k].stAng) / 60000
         const swAng = parseInt(multiSapeAry[k].swAng) / 60000
         const endAng = stAng + swAng
         d += shapeArc(wR, hR, wR, hR, stAng, endAng, false)
-      }
-      else if (multiSapeAry[k].type === 'close') d += 'z'
+      } else if (multiSapeAry[k].type === 'close') d += 'z'
       k++
     }
   }
 
   return d
-}
+}

+ 8 - 9
src/utils/pptxToJson/table.js

@@ -2,7 +2,7 @@ import { getShapeFill, getSolidFill } from './fill'
 import { getTextByPathList } from './utils'
 import { getBorder } from './border'
 
-export function getTableBorders(node, warpObj) {
+export function getTableBorders (node, warpObj) {
   const borders = {}
   if (node['a:bottom']) {
     const obj = {
@@ -43,7 +43,7 @@ export function getTableBorders(node, warpObj) {
   return borders
 }
 
-export async function getTableCellParams(tcNode, thisTblStyle, cellSource, warpObj) {
+export async function getTableCellParams (tcNode, thisTblStyle, cellSource, warpObj) {
   const rowSpan = getTextByPathList(tcNode, ['attrs', 'rowSpan'])
   const colSpan = getTextByPathList(tcNode, ['attrs', 'gridSpan'])
   const vMerge = getTextByPathList(tcNode, ['attrs', 'vMerge'])
@@ -58,7 +58,7 @@ export async function getTableCellParams(tcNode, thisTblStyle, cellSource, warpO
     const fill = await getShapeFill(cellObj, undefined, false, warpObj, 'slide')
 
     if (fill && fill.type === 'color' && fill.value) {
-      fillColor = fill.value 
+      fillColor = fill.value
     }
   }
   if (!fillColor) {
@@ -111,11 +111,11 @@ export async function getTableCellParams(tcNode, thisTblStyle, cellSource, warpO
     rowSpan: rowSpan ? +rowSpan : undefined,
     colSpan: colSpan ? +colSpan : undefined,
     vMerge: vMerge ? +vMerge : undefined,
-    hMerge: hMerge ? +hMerge : undefined,
+    hMerge: hMerge ? +hMerge : undefined
   }
 }
 
-export function getTableRowParams(trNodes, i, tblStylAttrObj, thisTblStyle, warpObj) {
+export function getTableRowParams (trNodes, i, tblStylAttrObj, thisTblStyle, warpObj) {
   let fillColor
   let fontColor
   let fontBold
@@ -145,8 +145,7 @@ export function getTableRowParams(trNodes, i, tblStylAttrObj, thisTblStyle, warp
       if (local_fontColor) fontColor = local_fontColor
       if (getTextByPathList(rowTxtStyl, ['attrs', 'b']) === 'on') fontBold = true
     }
-  }
-  else if (i > 0 && tblStylAttrObj['isBandRowAttr'] === 1 && thisTblStyle) {
+  } else if (i > 0 && tblStylAttrObj['isBandRowAttr'] === 1 && thisTblStyle) {
     fillColor = ''
     if ((i % 2) === 0 && thisTblStyle['a:band2H']) {
       const bgFillschemeClr = getTextByPathList(thisTblStyle, ['a:band2H', 'a:tcStyle', 'a:fill', 'a:solidFill'])
@@ -194,6 +193,6 @@ export function getTableRowParams(trNodes, i, tblStylAttrObj, thisTblStyle, warp
   return {
     fillColor,
     fontColor,
-    fontBold,
+    fontBold
   }
-}
+}

+ 21 - 33
src/utils/pptxToJson/text.js

@@ -11,17 +11,16 @@ import {
   getFontDecorationLine,
   getFontSpace,
   getFontSubscript,
-  getFontShadow,
+  getFontShadow
 } from './fontStyle'
 
-export function genTextBody(
+export function genTextBody (
   textBodyNode,
   spNode,
   slideLayoutSpNode,
   type,
   warpObj
 ) {
-
   if (!textBodyNode) return ''
 
   let text = ''
@@ -63,24 +62,23 @@ export function genTextBody(
       const [tagName, className] = listType.split(' ')
       const level = parseInt(pNode['a:pPr'].attrs?.lvl || '0') // 获取列表层级
       const indentSize = (level + 1) * 20 // 根据层级计算缩进大小
-      
+
       if (!isList) {
-        text += `<${tagName} style="list-style: none; padding-left: ${indentSize}px;" class="${className}">`
+        text += `<${tagName} style="list-style: none; " class="${className}">`
         isList = listType
         listCounters[className] = 0
-      }
-      else if (isList && isList !== listType) {
+      } else if (isList && isList !== listType) {
         text += `</${isList.split(' ')[0]}>`
-        text += `<${tagName} style="list-style: none; padding-left: ${indentSize}px;" class="${className}">`
+        text += `<${tagName} style="list-style: none; " class="${className}">`
         isList = listType
         listCounters[className] = 0
       }
 
       listCounters[className]++
       const currentNumber = listCounters[className]
-      
-      text += `<li style="text-align: ${align};">`
-      
+
+      text += `<li style="text-align: ${align}; padding-left: ${indentSize}px;">`
+
       if (className === 'custom-bullet') {
         const bulletChar = pNode['a:pPr']['a:buChar'].attrs?.char || '•'
         const symbolMap = {
@@ -90,14 +88,13 @@ export function genTextBody(
           'p': '□', // 空心方块
           'ü': '✔', // 对号
           'Ø': '➢', // 箭头
-          '': '•', // 默认圆点
+          '': '•' // 默认圆点
         }
         const displayChar = symbolMap[bulletChar] || bulletChar
         text += `<span style="display: inline-block; width: 20px; margin-left: -${indentSize}px;">${displayChar}</span>`
-      }
-      else {
+      } else {
         let displayNumber = ''
-        
+
         switch (className) {
           case 'circle-number':
             const circleNums = ['①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩']
@@ -123,11 +120,10 @@ export function genTextBody(
           default:
             displayNumber = `${currentNumber}.`
         }
-      
+
         text += `<span style="display: inline-block; margin-left: -${indentSize}px;">${displayNumber}</span>`
       }
-    }
-    else {
+    } else {
       if (isList) {
         text += `</${isList.split(' ')[0]}>`
         isList = ''
@@ -145,8 +141,7 @@ export function genTextBody(
         type,
         warpObj
       )
-    }
-    else {
+    } else {
       for (const rNodeItem of rNode) {
         text += genSpanElement(
           rNodeItem,
@@ -166,10 +161,10 @@ export function genTextBody(
   return text
 }
 
-export function getListType(node) {
+export function getListType (node) {
   const pPrNode = node['a:pPr']
   if (!pPrNode) return ''
-    
+
   if (pPrNode['a:buChar']) {
     return 'ul custom-bullet'
   }
@@ -196,10 +191,7 @@ export function getListType(node) {
   return ''
 }
 
-
-
-
-export function genSpanElement(
+export function genSpanElement (
   node,
   pNode,
   textBodyNode,
@@ -218,21 +210,17 @@ export function genSpanElement(
     if (lvlNode !== undefined) lvl = parseInt(lvlNode) + 1
   }
 
-
   let fontSize
   const directSize = getTextByPathList(node, ['a:rPr', 'attrs', 'sz'])
-  
+
   if (directSize) {
     // 如果节点本身有字体大小设置,直接使用
     fontSize = getFontSize(node, slideLayoutSpNode, type, slideMasterTextStyles)
-  }
-  else {
+  } else {
     // 如果节点没有字体大小设置,使用 textBodyNode
     fontSize = getFontSize(textBodyNode, slideLayoutSpNode, type, slideMasterTextStyles)
   }
 
-
-
   let text = node['a:t']
   if (typeof text !== 'string') text = getTextByPathList(node, ['a:fld', 'a:t'])
   if (typeof text !== 'string') text = '&nbsp;'
@@ -272,7 +260,7 @@ export function genSpanElement(
     'a:rPr',
     'a:hlinkClick',
     'attrs',
-    'r:id',
+    'r:id'
   ])
   if (linkID) {
     const linkURL = warpObj['slideResObj'][linkID]['target']

+ 15 - 17
src/utils/pptxToJson/utils.js

@@ -1,10 +1,10 @@
-export function base64ArrayBuffer(arrayBuffer) {
+export function base64ArrayBuffer (arrayBuffer) {
   const encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
   const bytes = new Uint8Array(arrayBuffer)
   const byteLength = bytes.byteLength
   const byteRemainder = byteLength % 3
   const mainLength = byteLength - byteRemainder
-  
+
   let base64 = ''
   let a, b, c, d
   let chunk
@@ -23,8 +23,7 @@ export function base64ArrayBuffer(arrayBuffer) {
     a = (chunk & 252) >> 2
     b = (chunk & 3) << 4
     base64 += encodings[a] + encodings[b] + '=='
-  } 
-  else if (byteRemainder === 2) {
+  } else if (byteRemainder === 2) {
     chunk = (bytes[mainLength] << 8) | bytes[mainLength + 1]
     a = (chunk & 64512) >> 10
     b = (chunk & 1008) >> 4
@@ -35,11 +34,11 @@ export function base64ArrayBuffer(arrayBuffer) {
   return base64
 }
 
-export function extractFileExtension(filename) {
+export function extractFileExtension (filename) {
   return filename.substr((~-filename.lastIndexOf('.') >>> 0) + 2)
 }
 
-export function eachElement(node, func) {
+export function eachElement (node, func) {
   if (!node) return node
 
   let result = ''
@@ -47,13 +46,12 @@ export function eachElement(node, func) {
     for (let i = 0; i < node.length; i++) {
       result += func(node[i], i)
     }
-  } 
-  else result += func(node, 0)
+  } else result += func(node, 0)
 
   return result
 }
 
-export function getTextByPathList(node, path) {
+export function getTextByPathList (node, path) {
   if (!node) return node
 
   for (const key of path) {
@@ -64,23 +62,23 @@ export function getTextByPathList(node, path) {
   return node
 }
 
-export function angleToDegrees(angle) {
+export function angleToDegrees (angle) {
   if (!angle) return 0
   return Math.round(angle / 60000)
 }
 
-export function escapeHtml(text) {
+export function escapeHtml (text) {
   const map = {
     '&': '&amp;',
     '<': '&lt;',
     '>': '&gt;',
     '"': '&quot;',
-    "'": '&#039;',
+    "'": '&#039;'
   }
   return text.replace(/[&<>"']/g, m => map[m])
 }
 
-export function getMimeType(imgFileExt) {
+export function getMimeType (imgFileExt) {
   let mimeType = ''
   switch (imgFileExt.toLowerCase()) {
     case 'jpg':
@@ -137,12 +135,12 @@ export function getMimeType(imgFileExt) {
   return mimeType
 }
 
-export function isVideoLink(vdoFile) {
+export function isVideoLink (vdoFile) {
   const urlRegex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
   return urlRegex.test(vdoFile)
 }
 
-export function toHex(n) {
+export function toHex (n) {
   let hex = n.toString(16)
   while (hex.length < 2) {
     hex = '0' + hex
@@ -150,11 +148,11 @@ export function toHex(n) {
   return hex
 }
 
-export function hasValidText(htmlString) {
+export function hasValidText (htmlString) {
   if (!DOMParser) return true
 
   const parser = new DOMParser()
   const doc = parser.parseFromString(htmlString, 'text/html')
   const text = doc.body.textContent || doc.body.innerText
   return text.trim() !== ''
-}
+}

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác