jvs-ppt-ui 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -2
- package/dist/lib/jvs-ppt-ui.es.js +22404 -21454
- package/dist/lib/jvs-ppt-ui.umd.js +102 -101
- package/dist/lib/style.css +1 -1
- package/package.json +1 -1
- package/src/App.vue +53 -53
- package/src/components/AIPptDialog.vue +2 -0
- package/src/components/CanvasArea.vue +164 -72
- package/src/components/Header.vue +374 -144
- package/src/components/PptEditor.vue +33 -15
- package/src/components/PresentationMode.vue +24 -4
- package/src/components/SidebarRight.vue +8 -1
- package/src/components/SvgChart.vue +5 -2
- package/src/components/TemplateGallery.vue +1321 -866
- package/src/components/Toolbar.vue +244 -22
- package/src/components/canvas/CanvasTransformHandles.vue +5 -1
- package/src/components/canvas/elements/CanvasShapeElement.vue +98 -19
- package/src/components/canvas/elements/CanvasTextElement.vue +39 -9
- package/src/components/canvas/textSelectionOverlay.ts +305 -0
- package/src/composables/canvas/useCanvasAlignment.ts +286 -238
- package/src/composables/canvas/useCanvasContextMenu.ts +53 -22
- package/src/composables/canvas/useCanvasFormatting.ts +35 -12
- package/src/composables/canvas/useCanvasTable.ts +52 -24
- package/src/composables/canvas/useCanvasText.ts +12 -0
- package/src/composables/canvas/useCanvasTransform.ts +15 -2
- package/src/composables/sidebar/useSidebarElementTransform.ts +5 -5
- package/src/composables/sidebar/useSidebarShapeFormat.ts +2 -2
- package/src/composables/useSlides.ts +495 -132
- package/src/style.css +88 -0
- package/src/types/index.ts +8 -0
- package/src/utils/line.ts +274 -312
- package/src/utils/pptxShapes.ts +1 -1
- package/src/utils/pptxShapesLazy.ts +39 -0
- package/src/utils/svgPathParser.ts +12 -1
package/src/utils/pptxShapes.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { shallowRef } from 'vue'
|
|
2
|
+
import type { ShapeListItem, ShapePathFormula } from './pptxShapes'
|
|
3
|
+
|
|
4
|
+
type PptxShapesModule = typeof import('./pptxShapes')
|
|
5
|
+
|
|
6
|
+
// 98KB 形状公式/预设表从启动 chunk 拆出:本模块求值时即后台加载(不阻塞首屏),
|
|
7
|
+
// 表就绪后写入 shallowRef,依赖它的 computed(如形状调整点 keypoints)会自动重算。
|
|
8
|
+
export const pptxShapeFormulas = shallowRef<Record<string, ShapePathFormula> | null>(null)
|
|
9
|
+
export const pptxShapeList = shallowRef<ShapeListItem[] | null>(null)
|
|
10
|
+
|
|
11
|
+
const EMPTY_FORMULAS: Record<string, ShapePathFormula> = {}
|
|
12
|
+
const EMPTY_LIST: ShapeListItem[] = []
|
|
13
|
+
|
|
14
|
+
/** 同步读取形状公式表;未就绪时返回空表(调用点均有 if (formulaObj) 守卫,安全降级) */
|
|
15
|
+
export function shapeFormulas(): Record<string, ShapePathFormula> {
|
|
16
|
+
return pptxShapeFormulas.value ?? EMPTY_FORMULAS
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** 同步读取形状预设列表;未就绪时返回空数组 */
|
|
20
|
+
export function shapeList(): ShapeListItem[] {
|
|
21
|
+
return pptxShapeList.value ?? EMPTY_LIST
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let loadPromise: Promise<PptxShapesModule> | null = null
|
|
25
|
+
|
|
26
|
+
/** 确保形状表已加载;文件导入/DSL 编译等异步解析路径在调用解析器前 await 一次 */
|
|
27
|
+
export function ensurePptxShapes(): Promise<PptxShapesModule> {
|
|
28
|
+
if (!loadPromise) {
|
|
29
|
+
loadPromise = import('./pptxShapes').then(mod => {
|
|
30
|
+
pptxShapeFormulas.value = mod.SHAPE_PATH_FORMULAS
|
|
31
|
+
pptxShapeList.value = mod.SHAPE_LIST
|
|
32
|
+
return mod
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
return loadPromise
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 启动即后台预载:与首屏渲染并行,用户首次交互(插形状/拖调整点/导文件)前早已就绪
|
|
39
|
+
ensurePptxShapes()
|
|
@@ -71,6 +71,13 @@ export const getSvgPathRange = (path: string) => {
|
|
|
71
71
|
for (const item of pathData.commands) {
|
|
72
72
|
if ('x' in item) xList.push(item.x)
|
|
73
73
|
if ('y' in item) yList.push(item.y)
|
|
74
|
+
// 贝塞尔控制点也纳入边界:曲线的实际极值可能只出现在控制点上
|
|
75
|
+
// (端点算出的范围会偏小,导致 viewBox 被错误收窄、形状被拉伸),
|
|
76
|
+
// 与 normalizeSvgPath 的边界口径保持一致。
|
|
77
|
+
if ('x1' in item) xList.push(item.x1)
|
|
78
|
+
if ('y1' in item) yList.push(item.y1)
|
|
79
|
+
if ('x2' in item) xList.push(item.x2)
|
|
80
|
+
if ('y2' in item) yList.push(item.y2)
|
|
74
81
|
}
|
|
75
82
|
return {
|
|
76
83
|
minX: Math.min(...xList),
|
|
@@ -102,9 +109,13 @@ export const normalizeSvgPath = (path: string) => {
|
|
|
102
109
|
|
|
103
110
|
const xList: number[] = []
|
|
104
111
|
const yList: number[] = []
|
|
105
|
-
for (const item of pathData.commands) {
|
|
112
|
+
for (const item of pathData.commands as any[]) {
|
|
106
113
|
if ('x' in item) xList.push(item.x)
|
|
107
114
|
if ('y' in item) yList.push(item.y)
|
|
115
|
+
if ('x1' in item) xList.push(item.x1)
|
|
116
|
+
if ('y1' in item) yList.push(item.y1)
|
|
117
|
+
if ('x2' in item) xList.push(item.x2)
|
|
118
|
+
if ('y2' in item) yList.push(item.y2)
|
|
108
119
|
}
|
|
109
120
|
|
|
110
121
|
if (xList.length === 0 || yList.length === 0) {
|