jack 4 일 전
부모
커밋
d8f4eaae69
2개의 변경된 파일7개의 추가작업 그리고 5개의 파일을 삭제
  1. 6 4
      src/hooks/useImport.ts
  2. 1 1
      src/views/components/element/ShapeElement/index.vue

+ 6 - 4
src/hooks/useImport.ts

@@ -47,9 +47,9 @@ const getStyle = (htmlString: string) => {
   // 2. 解析 HTML 字符串为文档对象
   const doc = parser.parseFromString(htmlString, 'text/html')
   // 3. 获取 p 元素
-  const p = doc.querySelector('p')
-  // 4. 读取 style 属性(内联样式字符串)
-  const styleAttr = p?.getAttribute('allstyle')
+  const firstElem = doc.querySelector('p, ul, ol, table');
+  // 读取该元素的 allstyle 属性
+  const styleAttr = firstElem?.getAttribute('allstyle');
   console.log(styleAttr) // 输出完整的 style 字符串
   return styleAttr || ''
 
@@ -1963,7 +1963,7 @@ export default () => {
                   gradient,
                   pattern,
                   fixedRatio: false,
-                  rotate: el.rotate,
+                  rotate: 0,
                   pathBBox: el.pathBBox,
                   outline: {
                     color: el.borderColor,
@@ -1994,6 +1994,7 @@ export default () => {
                   const { maxX, maxY } = getSvgPathRange(el.path)
                   element.path = el.path
                   element.viewBox = poriginWidth ? [maxX, maxY] : [originWidth, originHeight]
+                  /*
                   if (shape.pathFormula) {
                     element.pathFormula = shape.pathFormula
                     element.viewBox = [el.width, el.height]
@@ -2007,6 +2008,7 @@ export default () => {
                       element.path = pathFormula.formula(el.width, el.height)
                     }
                   }
+                  */
                 }
                 else if (el.path && el.path.indexOf('NaN') === -1) {
                   const { maxX, maxY } = getSvgPathRange(el.path)

+ 1 - 1
src/views/components/element/ShapeElement/index.vue

@@ -21,7 +21,7 @@
         :style="{
           opacity: elementInfo.opacity,
           filter: shadowStyle ? `drop-shadow(${shadowStyle})` : '',
-          transform: flipStyle,
+          //transform: flipStyle,
           color: text.defaultColor,
           fontFamily: text.defaultFontName,
         }"