@barocss/office-slide 0.0.0-stage → 0.1.1
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/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +28 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +785 -0
- package/dist/index.js.map +7 -0
- package/dist/model.d.ts +169 -0
- package/dist/pptx.d.ts +5 -0
- package/package.json +43 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @barocss/office-slide
|
|
2
|
+
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Prepare the first CI release with npm Trusted Publishing and provenance. Update package documentation to reflect the published npm packages.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @barocss/office-core@0.1.1
|
|
10
|
+
|
|
11
|
+
## 0.1.0
|
|
12
|
+
|
|
13
|
+
- Initial public release.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 jinho park(cyberuls@gmail.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @barocss/office-slide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Slide document model, templates, alignment, and PPTX export.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
Use Node.js 22.18 or later. This package uses ES modules.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @barocss/office-slide
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This package and its dependencies are available on npm.
|
|
16
|
+
|
|
17
|
+
## Use
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import {createSlideNode} from "@barocss/office-slide";
|
|
21
|
+
const slide = createSlideNode({title: "Plan"});
|
|
22
|
+
console.log(slide.type); // slide
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
See the [Office repository](https://github.com/barocss/office) for examples and development instructions.
|
|
26
|
+
|
|
27
|
+
## License
|
|
28
|
+
|
|
29
|
+
MIT.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { SLIDE_LAYOUT_TEMPLATES, addImage, addShape, addTextBox, alignObjects, appendSlide, appendSlideFromTemplate, bringToFront, cloneSlideObjectNodes, createImageNode, createShapeNode, createSlideNode, createTextBoxNode, deleteSlide, deleteSlideObject, deleteSlideObjects, duplicateSlide, duplicateSlideObjects, extractSlideDeck, groupSlideObjects, pasteSlideObjectNodes, reorderSlide, sendToBack, snapFrameToGuides, ungroupSlideObjects, updateObjectFrame, updateObjectMeta, updateShapeStyle, updateSlideBackground, updateSlideNotes, updateSlideTransition, updateTextBoxContent, updateTextBoxStyle, } from "./model.js";
|
|
2
|
+
export type { SlideAlignMode, SlideFrame, SlideObjectView, SlideShapeKind, SlideTemplateId, SlideTransitionKind, SlideView, SnapResult, } from "./model.js";
|
|
3
|
+
export { slidesToPptxBytes } from "./pptx.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,785 @@
|
|
|
1
|
+
// src/model.ts
|
|
2
|
+
function readNodeText(node) {
|
|
3
|
+
if (!node) return "";
|
|
4
|
+
const parts = [];
|
|
5
|
+
if (node.runs) {
|
|
6
|
+
for (const r of node.runs) {
|
|
7
|
+
if ("text" in r) parts.push(r.text);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
if (node.children) {
|
|
11
|
+
for (const c of node.children) {
|
|
12
|
+
const t = readNodeText(c);
|
|
13
|
+
if (t) parts.push(t);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return parts.join("\n");
|
|
17
|
+
}
|
|
18
|
+
function readFrame(attrs) {
|
|
19
|
+
const raw = attrs?.frame ?? {};
|
|
20
|
+
return {
|
|
21
|
+
x: typeof raw.x === "number" ? raw.x : 80,
|
|
22
|
+
y: typeof raw.y === "number" ? raw.y : 80,
|
|
23
|
+
width: typeof raw.width === "number" ? raw.width : 320,
|
|
24
|
+
height: typeof raw.height === "number" ? raw.height : 120,
|
|
25
|
+
rotation: typeof raw.rotation === "number" ? raw.rotation : 0,
|
|
26
|
+
z: typeof raw.z === "number" ? raw.z : 0
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function extractSlideDeck(unit) {
|
|
30
|
+
const root = unit.readModel();
|
|
31
|
+
const children = root.children ?? [];
|
|
32
|
+
const slides = [];
|
|
33
|
+
for (let rootIdx = 0; rootIdx < children.length; rootIdx++) {
|
|
34
|
+
const node = children[rootIdx];
|
|
35
|
+
if (node.type !== "slide") continue;
|
|
36
|
+
const canvasRaw = node.attrs?.canvas ?? {};
|
|
37
|
+
const canvas = {
|
|
38
|
+
width: typeof canvasRaw.width === "number" ? canvasRaw.width : 1280,
|
|
39
|
+
height: typeof canvasRaw.height === "number" ? canvasRaw.height : 720,
|
|
40
|
+
background: typeof canvasRaw.background === "string" ? canvasRaw.background : "#ffffff"
|
|
41
|
+
};
|
|
42
|
+
let title = "";
|
|
43
|
+
let notes = "";
|
|
44
|
+
const objects = [];
|
|
45
|
+
const slideChildren = node.children ?? [];
|
|
46
|
+
for (let objIdx = 0; objIdx < slideChildren.length; objIdx++) {
|
|
47
|
+
const child = slideChildren[objIdx];
|
|
48
|
+
if (child.type === "slide-title") {
|
|
49
|
+
title = readNodeText(child);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (child.type === "speaker-notes") {
|
|
53
|
+
notes = readNodeText(child);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (child.type === "text-box" || child.type === "shape" || child.type === "image" || child.type === "chart") {
|
|
57
|
+
const path = [rootIdx, objIdx];
|
|
58
|
+
objects.push({
|
|
59
|
+
path,
|
|
60
|
+
id: path.join("."),
|
|
61
|
+
type: child.type,
|
|
62
|
+
frame: readFrame(child.attrs),
|
|
63
|
+
text: child.type === "text-box" ? readNodeText(child) : void 0,
|
|
64
|
+
label: typeof child.attrs?.label === "string" ? child.attrs.label : "",
|
|
65
|
+
fontSize: typeof child.attrs?.fontSize === "number" ? child.attrs.fontSize : void 0,
|
|
66
|
+
textAlign: child.attrs?.textAlign === "center" || child.attrs?.textAlign === "right" ? child.attrs.textAlign : "left",
|
|
67
|
+
textColor: typeof child.attrs?.textColor === "string" ? child.attrs.textColor : void 0,
|
|
68
|
+
shapeKind: child.type === "shape" ? child.attrs?.kind ?? "rectangle" : void 0,
|
|
69
|
+
fill: typeof child.attrs?.fill === "string" ? child.attrs.fill : void 0,
|
|
70
|
+
stroke: typeof child.attrs?.stroke === "string" ? child.attrs.stroke : void 0,
|
|
71
|
+
strokeWidth: typeof child.attrs?.strokeWidth === "number" ? child.attrs.strokeWidth : 2,
|
|
72
|
+
dashed: child.attrs?.dashed === true,
|
|
73
|
+
shadow: child.attrs?.shadow === true,
|
|
74
|
+
opacity: typeof child.attrs?.opacity === "number" ? child.attrs.opacity : 100,
|
|
75
|
+
radius: typeof child.attrs?.radius === "number" ? child.attrs.radius : 12,
|
|
76
|
+
groupId: typeof child.attrs?.groupId === "string" ? child.attrs.groupId : "",
|
|
77
|
+
locked: child.attrs?.locked === true,
|
|
78
|
+
hidden: child.attrs?.hidden === true,
|
|
79
|
+
src: typeof child.attrs?.src === "string" ? child.attrs.src : void 0,
|
|
80
|
+
alt: typeof child.attrs?.alt === "string" ? child.attrs.alt : void 0
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
objects.sort((a, b) => a.frame.z - b.frame.z || a.path[1] - b.path[1]);
|
|
85
|
+
const tr = node.attrs?.transition;
|
|
86
|
+
const transition = tr === "fade" || tr === "slide" || tr === "zoom" ? tr : "none";
|
|
87
|
+
slides.push({
|
|
88
|
+
rootIndex: rootIdx,
|
|
89
|
+
slideNumber: slides.length + 1,
|
|
90
|
+
title,
|
|
91
|
+
notes,
|
|
92
|
+
layout: typeof node.attrs?.layout === "string" ? node.attrs.layout : "blank",
|
|
93
|
+
transition,
|
|
94
|
+
canvas,
|
|
95
|
+
objects
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return slides;
|
|
99
|
+
}
|
|
100
|
+
function createSlideNode(options = {}) {
|
|
101
|
+
return {
|
|
102
|
+
type: "slide",
|
|
103
|
+
attrs: {
|
|
104
|
+
layout: "blank",
|
|
105
|
+
canvas: {
|
|
106
|
+
width: 1280,
|
|
107
|
+
height: 720,
|
|
108
|
+
background: options.background ?? "#ffffff"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
children: [
|
|
112
|
+
{
|
|
113
|
+
type: "slide-title",
|
|
114
|
+
runs: options.title ? [{ text: options.title, marks: {} }] : []
|
|
115
|
+
},
|
|
116
|
+
...options.objects ?? [],
|
|
117
|
+
{
|
|
118
|
+
type: "speaker-notes",
|
|
119
|
+
children: [
|
|
120
|
+
{
|
|
121
|
+
type: "paragraph",
|
|
122
|
+
runs: options.notes ? [{ text: options.notes, marks: {} }] : []
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function createTextBoxNode(options) {
|
|
130
|
+
const frame = {
|
|
131
|
+
x: options.frame.x ?? 120,
|
|
132
|
+
y: options.frame.y ?? 120,
|
|
133
|
+
width: options.frame.width ?? 480,
|
|
134
|
+
height: options.frame.height ?? 110,
|
|
135
|
+
rotation: options.frame.rotation ?? 0,
|
|
136
|
+
z: options.frame.z ?? 10
|
|
137
|
+
};
|
|
138
|
+
const lines = options.text.split("\n");
|
|
139
|
+
return {
|
|
140
|
+
type: "text-box",
|
|
141
|
+
attrs: { frame },
|
|
142
|
+
children: lines.map((line) => ({
|
|
143
|
+
type: "paragraph",
|
|
144
|
+
runs: line ? [{ text: line, marks: options.bold ? { bold: true } : {} }] : []
|
|
145
|
+
}))
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function createShapeNode(options) {
|
|
149
|
+
const frame = {
|
|
150
|
+
x: options.frame.x ?? 160,
|
|
151
|
+
y: options.frame.y ?? 160,
|
|
152
|
+
width: options.frame.width ?? 240,
|
|
153
|
+
height: options.frame.height ?? 140,
|
|
154
|
+
rotation: options.frame.rotation ?? 0,
|
|
155
|
+
z: options.frame.z ?? 1
|
|
156
|
+
};
|
|
157
|
+
return {
|
|
158
|
+
type: "shape",
|
|
159
|
+
attrs: {
|
|
160
|
+
kind: options.kind,
|
|
161
|
+
frame,
|
|
162
|
+
fill: options.fill ?? "#eff6ff",
|
|
163
|
+
stroke: options.stroke ?? "#2563eb",
|
|
164
|
+
opacity: options.opacity ?? 100,
|
|
165
|
+
radius: options.radius ?? 12
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function createImageNode(options) {
|
|
170
|
+
const frame = {
|
|
171
|
+
x: options.frame.x ?? 180,
|
|
172
|
+
y: options.frame.y ?? 140,
|
|
173
|
+
width: options.frame.width ?? 480,
|
|
174
|
+
height: options.frame.height ?? 280,
|
|
175
|
+
rotation: options.frame.rotation ?? 0,
|
|
176
|
+
z: options.frame.z ?? 8
|
|
177
|
+
};
|
|
178
|
+
return {
|
|
179
|
+
type: "image",
|
|
180
|
+
attrs: {
|
|
181
|
+
src: options.src,
|
|
182
|
+
alt: options.alt ?? "Slide Image",
|
|
183
|
+
frame
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function appendSlide(unit, options = {}) {
|
|
188
|
+
const rootChildren = unit.readModel().children ?? [];
|
|
189
|
+
const insertAt = rootChildren.length;
|
|
190
|
+
const node = createSlideNode(options);
|
|
191
|
+
unit.edit([{ op: "insert", at: [insertAt], content: [node] }]);
|
|
192
|
+
return insertAt;
|
|
193
|
+
}
|
|
194
|
+
function deleteSlide(unit, rootIndex) {
|
|
195
|
+
unit.edit([{ op: "delete", at: [rootIndex], count: 1 }]);
|
|
196
|
+
}
|
|
197
|
+
function slideInsertIndex(unit, slideRootIndex) {
|
|
198
|
+
const slide = unit.readModel().children?.[slideRootIndex];
|
|
199
|
+
const children = slide?.children ?? [];
|
|
200
|
+
const notesIdx = children.findIndex((c) => c.type === "speaker-notes");
|
|
201
|
+
return notesIdx >= 0 ? notesIdx : children.length;
|
|
202
|
+
}
|
|
203
|
+
function addTextBox(unit, slideRootIndex, options) {
|
|
204
|
+
const idx = slideInsertIndex(unit, slideRootIndex);
|
|
205
|
+
unit.edit([{ op: "insert", at: [slideRootIndex, idx], content: [createTextBoxNode(options)] }]);
|
|
206
|
+
return [slideRootIndex, idx];
|
|
207
|
+
}
|
|
208
|
+
function addShape(unit, slideRootIndex, options) {
|
|
209
|
+
const idx = slideInsertIndex(unit, slideRootIndex);
|
|
210
|
+
unit.edit([{ op: "insert", at: [slideRootIndex, idx], content: [createShapeNode(options)] }]);
|
|
211
|
+
return [slideRootIndex, idx];
|
|
212
|
+
}
|
|
213
|
+
function addImage(unit, slideRootIndex, options) {
|
|
214
|
+
const idx = slideInsertIndex(unit, slideRootIndex);
|
|
215
|
+
unit.edit([{ op: "insert", at: [slideRootIndex, idx], content: [createImageNode(options)] }]);
|
|
216
|
+
return [slideRootIndex, idx];
|
|
217
|
+
}
|
|
218
|
+
function duplicateSlide(unit, slideRootIndex) {
|
|
219
|
+
const source = unit.readModel().children?.[slideRootIndex];
|
|
220
|
+
if (!source || source.type !== "slide") return slideRootIndex;
|
|
221
|
+
const cloned = structuredClone(source);
|
|
222
|
+
const insertAt = slideRootIndex + 1;
|
|
223
|
+
unit.edit([{ op: "insert", at: [insertAt], content: [cloned] }]);
|
|
224
|
+
return insertAt;
|
|
225
|
+
}
|
|
226
|
+
function cloneSlideObjectNodes(unit, objectPaths, offsetPx = 28) {
|
|
227
|
+
const model = unit.readModel();
|
|
228
|
+
const clones = [];
|
|
229
|
+
for (const p of objectPaths) {
|
|
230
|
+
const node = model.children?.[p[0]]?.children?.[p[1]];
|
|
231
|
+
if (!node) continue;
|
|
232
|
+
const copy = structuredClone(node);
|
|
233
|
+
const f = readFrame(copy.attrs);
|
|
234
|
+
copy.attrs = {
|
|
235
|
+
...copy.attrs ?? {},
|
|
236
|
+
frame: { ...f, x: f.x + offsetPx, y: f.y + offsetPx, z: f.z + 1 }
|
|
237
|
+
};
|
|
238
|
+
clones.push(copy);
|
|
239
|
+
}
|
|
240
|
+
return clones;
|
|
241
|
+
}
|
|
242
|
+
function pasteSlideObjectNodes(unit, slideRootIndex, nodes) {
|
|
243
|
+
if (nodes.length === 0) return [];
|
|
244
|
+
const idx = slideInsertIndex(unit, slideRootIndex);
|
|
245
|
+
const cloned = nodes.map((n) => structuredClone(n));
|
|
246
|
+
unit.edit([{ op: "insert", at: [slideRootIndex, idx], content: cloned }]);
|
|
247
|
+
return cloned.map((_, i) => [slideRootIndex, idx + i]);
|
|
248
|
+
}
|
|
249
|
+
function duplicateSlideObjects(unit, slideRootIndex, objectPaths) {
|
|
250
|
+
const clones = cloneSlideObjectNodes(unit, objectPaths, 28);
|
|
251
|
+
return pasteSlideObjectNodes(unit, slideRootIndex, clones);
|
|
252
|
+
}
|
|
253
|
+
function deleteSlideObjects(unit, objectPaths) {
|
|
254
|
+
if (objectPaths.length === 0) return;
|
|
255
|
+
const sorted = [...objectPaths].sort((a, b) => (b[1] ?? 0) - (a[1] ?? 0));
|
|
256
|
+
unit.edit(sorted.map((at) => ({ op: "delete", at, count: 1 })));
|
|
257
|
+
}
|
|
258
|
+
function updateTextBoxStyle(unit, objectPath, style) {
|
|
259
|
+
const attrs = {};
|
|
260
|
+
if (style.fontSize !== void 0) attrs.fontSize = Math.max(10, Math.min(140, Math.round(style.fontSize)));
|
|
261
|
+
if (style.textAlign !== void 0) attrs.textAlign = style.textAlign;
|
|
262
|
+
if (style.textColor !== void 0) attrs.textColor = style.textColor;
|
|
263
|
+
if (Object.keys(attrs).length > 0) {
|
|
264
|
+
unit.edit([{ op: "update", at: objectPath, attrs }]);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function alignObjects(unit, objects, mode, canvasWidth = 1280, canvasHeight = 720) {
|
|
268
|
+
if (objects.length === 0) return;
|
|
269
|
+
const edits = [];
|
|
270
|
+
const multi = objects.length > 1;
|
|
271
|
+
const minX = multi ? Math.min(...objects.map((o) => o.frame.x)) : 0;
|
|
272
|
+
const maxX = multi ? Math.max(...objects.map((o) => o.frame.x + o.frame.width)) : canvasWidth;
|
|
273
|
+
const minY = multi ? Math.min(...objects.map((o) => o.frame.y)) : 0;
|
|
274
|
+
const maxY = multi ? Math.max(...objects.map((o) => o.frame.y + o.frame.height)) : canvasHeight;
|
|
275
|
+
const midX = (minX + maxX) / 2;
|
|
276
|
+
const midY = (minY + maxY) / 2;
|
|
277
|
+
if (mode === "distribute-h" && objects.length >= 3) {
|
|
278
|
+
const sorted = [...objects].sort((a, b) => a.frame.x - b.frame.x);
|
|
279
|
+
const totalObjW = sorted.reduce((acc, o) => acc + o.frame.width, 0);
|
|
280
|
+
const span = sorted[sorted.length - 1].frame.x + sorted[sorted.length - 1].frame.width - sorted[0].frame.x;
|
|
281
|
+
const gap = (span - totalObjW) / (sorted.length - 1);
|
|
282
|
+
let curX = sorted[0].frame.x;
|
|
283
|
+
for (const obj of sorted) {
|
|
284
|
+
edits.push({ op: "update", at: obj.path, attrs: { frame: { x: Math.round(curX) } } });
|
|
285
|
+
curX += obj.frame.width + gap;
|
|
286
|
+
}
|
|
287
|
+
} else if (mode === "distribute-v" && objects.length >= 3) {
|
|
288
|
+
const sorted = [...objects].sort((a, b) => a.frame.y - b.frame.y);
|
|
289
|
+
const totalObjH = sorted.reduce((acc, o) => acc + o.frame.height, 0);
|
|
290
|
+
const span = sorted[sorted.length - 1].frame.y + sorted[sorted.length - 1].frame.height - sorted[0].frame.y;
|
|
291
|
+
const gap = (span - totalObjH) / (sorted.length - 1);
|
|
292
|
+
let curY = sorted[0].frame.y;
|
|
293
|
+
for (const obj of sorted) {
|
|
294
|
+
edits.push({ op: "update", at: obj.path, attrs: { frame: { y: Math.round(curY) } } });
|
|
295
|
+
curY += obj.frame.height + gap;
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
for (const obj of objects) {
|
|
299
|
+
if (mode === "left") edits.push({ op: "update", at: obj.path, attrs: { frame: { x: Math.round(minX) } } });
|
|
300
|
+
if (mode === "center") edits.push({ op: "update", at: obj.path, attrs: { frame: { x: Math.round(midX - obj.frame.width / 2) } } });
|
|
301
|
+
if (mode === "right") edits.push({ op: "update", at: obj.path, attrs: { frame: { x: Math.round(maxX - obj.frame.width) } } });
|
|
302
|
+
if (mode === "top") edits.push({ op: "update", at: obj.path, attrs: { frame: { y: Math.round(minY) } } });
|
|
303
|
+
if (mode === "middle") edits.push({ op: "update", at: obj.path, attrs: { frame: { y: Math.round(midY - obj.frame.height / 2) } } });
|
|
304
|
+
if (mode === "bottom") edits.push({ op: "update", at: obj.path, attrs: { frame: { y: Math.round(maxY - obj.frame.height) } } });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (edits.length > 0) unit.edit(edits);
|
|
308
|
+
}
|
|
309
|
+
function bringToFront(unit, target, allObjects) {
|
|
310
|
+
const maxZ = Math.max(0, ...allObjects.map((o) => o.frame.z));
|
|
311
|
+
updateObjectFrame(unit, target.path, { z: maxZ + 1 });
|
|
312
|
+
}
|
|
313
|
+
function sendToBack(unit, target, allObjects) {
|
|
314
|
+
const minZ = Math.min(0, ...allObjects.map((o) => o.frame.z));
|
|
315
|
+
updateObjectFrame(unit, target.path, { z: minZ - 1 });
|
|
316
|
+
}
|
|
317
|
+
function updateObjectFrame(unit, objectPath, patch) {
|
|
318
|
+
const rounded = {};
|
|
319
|
+
if (patch.x !== void 0) rounded.x = Math.round(patch.x);
|
|
320
|
+
if (patch.y !== void 0) rounded.y = Math.round(patch.y);
|
|
321
|
+
if (patch.width !== void 0) rounded.width = Math.max(24, Math.round(patch.width));
|
|
322
|
+
if (patch.height !== void 0) rounded.height = Math.max(24, Math.round(patch.height));
|
|
323
|
+
if (patch.rotation !== void 0) rounded.rotation = Math.max(-360, Math.min(360, Math.round(patch.rotation)));
|
|
324
|
+
if (patch.z !== void 0) rounded.z = Math.round(patch.z);
|
|
325
|
+
unit.edit([{ op: "update", at: objectPath, attrs: { frame: rounded } }]);
|
|
326
|
+
}
|
|
327
|
+
function updateShapeStyle(unit, objectPath, style) {
|
|
328
|
+
const attrs = {};
|
|
329
|
+
if (style.label !== void 0) attrs.label = style.label;
|
|
330
|
+
if (style.fill !== void 0) attrs.fill = style.fill;
|
|
331
|
+
if (style.stroke !== void 0) attrs.stroke = style.stroke;
|
|
332
|
+
if (style.strokeWidth !== void 0) attrs.strokeWidth = Math.max(0, Math.min(16, Math.round(style.strokeWidth)));
|
|
333
|
+
if (style.dashed !== void 0) attrs.dashed = style.dashed;
|
|
334
|
+
if (style.shadow !== void 0) attrs.shadow = style.shadow;
|
|
335
|
+
if (style.opacity !== void 0) attrs.opacity = Math.max(10, Math.min(100, Math.round(style.opacity)));
|
|
336
|
+
if (style.radius !== void 0) attrs.radius = Math.max(0, Math.min(120, Math.round(style.radius)));
|
|
337
|
+
if (Object.keys(attrs).length > 0) {
|
|
338
|
+
unit.edit([{ op: "update", at: objectPath, attrs }]);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function updateObjectMeta(unit, objectPath, meta) {
|
|
342
|
+
const attrs = {};
|
|
343
|
+
if (meta.locked !== void 0) attrs.locked = meta.locked;
|
|
344
|
+
if (meta.hidden !== void 0) attrs.hidden = meta.hidden;
|
|
345
|
+
if (meta.groupId !== void 0) attrs.groupId = meta.groupId;
|
|
346
|
+
if (meta.shadow !== void 0) attrs.shadow = meta.shadow;
|
|
347
|
+
if (Object.keys(attrs).length > 0) {
|
|
348
|
+
unit.edit([{ op: "update", at: objectPath, attrs }]);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function groupSlideObjects(unit, objects) {
|
|
352
|
+
if (objects.length < 2) return "";
|
|
353
|
+
const groupId = `grp-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
|
|
354
|
+
unit.edit(objects.map((o) => ({ op: "update", at: o.path, attrs: { groupId } })));
|
|
355
|
+
return groupId;
|
|
356
|
+
}
|
|
357
|
+
function ungroupSlideObjects(unit, objects) {
|
|
358
|
+
if (objects.length === 0) return;
|
|
359
|
+
unit.edit(objects.map((o) => ({ op: "update", at: o.path, attrs: { groupId: "" } })));
|
|
360
|
+
}
|
|
361
|
+
function reorderSlide(unit, fromRootIndex, toRootIndex) {
|
|
362
|
+
if (fromRootIndex === toRootIndex) return;
|
|
363
|
+
const children = unit.readModel().children ?? [];
|
|
364
|
+
const target = children[fromRootIndex];
|
|
365
|
+
if (!target || target.type !== "slide") return;
|
|
366
|
+
const cloned = structuredClone(target);
|
|
367
|
+
const adjustedDest = toRootIndex > fromRootIndex ? toRootIndex : toRootIndex;
|
|
368
|
+
unit.edit([
|
|
369
|
+
{ op: "delete", at: [fromRootIndex], count: 1 },
|
|
370
|
+
{ op: "insert", at: [adjustedDest], content: [cloned] }
|
|
371
|
+
]);
|
|
372
|
+
}
|
|
373
|
+
function updateSlideTransition(unit, slideRootIndex, transition) {
|
|
374
|
+
unit.edit([{ op: "update", at: [slideRootIndex], attrs: { transition } }]);
|
|
375
|
+
}
|
|
376
|
+
var SLIDE_LAYOUT_TEMPLATES = [
|
|
377
|
+
{ id: "blank", label: "\uBE48 \uC2AC\uB77C\uC774\uB4DC", desc: "\uC790\uC720 \uBC30\uCE58 \uCE94\uBC84\uC2A4" },
|
|
378
|
+
{ id: "title", label: "\uD45C\uC9C0 \uD0C0\uC774\uD2C0", desc: "\uC911\uC559 \uB300\uC81C\uBAA9 + \uBD80\uC81C\uBAA9" },
|
|
379
|
+
{ id: "two-column", label: "2\uB2E8 \uBCF8\uBB38", desc: "\uC81C\uBAA9 + \uC88C\uC6B0 2\uCEEC\uB7FC \uCE74\uB4DC" },
|
|
380
|
+
{ id: "comparison", label: "\uBE44\uAD50 \uB808\uC774\uC544\uC6C3", desc: "Before / After \uB300\uBE44" },
|
|
381
|
+
{ id: "kpi", label: "KPI \uB300\uC2DC\uBCF4\uB4DC", desc: "\uD575\uC2EC \uC9C0\uD45C 3\uCE74\uB4DC" }
|
|
382
|
+
];
|
|
383
|
+
function appendSlideFromTemplate(unit, template, slideNumber = 1) {
|
|
384
|
+
if (template === "title") {
|
|
385
|
+
return appendSlide(unit, {
|
|
386
|
+
title: `\uD45C\uC9C0 ${slideNumber}`,
|
|
387
|
+
background: "#1e293b",
|
|
388
|
+
objects: [
|
|
389
|
+
createShapeNode({ kind: "rectangle", frame: { x: 84, y: 210, width: 120, height: 10, z: 2 }, fill: "#3b82f6", stroke: "#3b82f6" }),
|
|
390
|
+
createTextBoxNode({ text: "\uD504\uB808\uC820\uD14C\uC774\uC158 \uB300\uC81C\uBAA9", frame: { x: 84, y: 246, width: 1080, height: 110, z: 10 }, bold: true }),
|
|
391
|
+
createTextBoxNode({ text: "\uBD80\uC81C\uBAA9 \uB610\uB294 \uBC1C\uD45C\uC790 \xB7 \uB0A0\uC9DC\uB97C \uC785\uB825\uD558\uC138\uC694", frame: { x: 84, y: 374, width: 880, height: 72, z: 11 } })
|
|
392
|
+
]
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
if (template === "two-column") {
|
|
396
|
+
return appendSlide(unit, {
|
|
397
|
+
title: `2\uB2E8 \uC2AC\uB77C\uC774\uB4DC ${slideNumber}`,
|
|
398
|
+
background: "#ffffff",
|
|
399
|
+
objects: [
|
|
400
|
+
createTextBoxNode({ text: "\uD575\uC2EC \uC544\uC820\uB2E4 \uC694\uC57D", frame: { x: 80, y: 64, width: 1120, height: 80, z: 10 }, bold: true }),
|
|
401
|
+
{
|
|
402
|
+
type: "shape",
|
|
403
|
+
attrs: { kind: "rectangle", frame: { x: 80, y: 176, width: 540, height: 460, rotation: 0, z: 2 }, fill: "#f8fafc", stroke: "#cbd5e1", label: "\uC88C\uCE21 \uC139\uC158 \uB0B4\uC6A9\uC744 \uC785\uB825\uD558\uC138\uC694", shadow: true }
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
type: "shape",
|
|
407
|
+
attrs: { kind: "rectangle", frame: { x: 660, y: 176, width: 540, height: 460, rotation: 0, z: 3 }, fill: "#eff6ff", stroke: "#93c5fd", label: "\uC6B0\uCE21 \uC139\uC158 \uB0B4\uC6A9\uC744 \uC785\uB825\uD558\uC138\uC694", shadow: true }
|
|
408
|
+
}
|
|
409
|
+
]
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
if (template === "comparison") {
|
|
413
|
+
return appendSlide(unit, {
|
|
414
|
+
title: `\uBE44\uAD50 ${slideNumber}`,
|
|
415
|
+
background: "#f8fafc",
|
|
416
|
+
objects: [
|
|
417
|
+
createTextBoxNode({ text: "As-Is vs To-Be \uBE44\uAD50", frame: { x: 80, y: 58, width: 1120, height: 76, z: 10 }, bold: true }),
|
|
418
|
+
{
|
|
419
|
+
type: "shape",
|
|
420
|
+
attrs: { kind: "rectangle", frame: { x: 80, y: 170, width: 490, height: 450, rotation: 0, z: 2 }, fill: "#fef2f2", stroke: "#f87171", label: "\uAE30\uC874 \uBC29\uC2DD (As-Is)\n\u2022 \uC774\uC911 \uC2A4\uD1A0\uC5B4 \uB3D9\uAE30\uD654 \uC9C0\uC5F0\n\u2022 \uC218\uB3D9 \uC11C\uC2DD \uC791\uC5C5", shadow: true }
|
|
421
|
+
},
|
|
422
|
+
createShapeNode({ kind: "arrow", frame: { x: 590, y: 375, width: 100, height: 44, z: 6 }, fill: "#2563eb", stroke: "#2563eb" }),
|
|
423
|
+
{
|
|
424
|
+
type: "shape",
|
|
425
|
+
attrs: { kind: "rectangle", frame: { x: 710, y: 170, width: 490, height: 450, rotation: 0, z: 3 }, fill: "#ecfdf5", stroke: "#10b981", label: "DocOffice \uBC29\uC2DD (To-Be)\n\u2022 \uB2E8\uC77C doc-sync CRDT\n\u2022 \uC2E4\uC2DC\uAC04 MCP AI \uD611\uC5C5", shadow: true }
|
|
426
|
+
}
|
|
427
|
+
]
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
if (template === "kpi") {
|
|
431
|
+
return appendSlide(unit, {
|
|
432
|
+
title: `KPI ${slideNumber}`,
|
|
433
|
+
background: "#ffffff",
|
|
434
|
+
objects: [
|
|
435
|
+
createTextBoxNode({ text: "\uBD84\uAE30 \uD575\uC2EC KPI \uD558\uC774\uB77C\uC774\uD2B8", frame: { x: 80, y: 64, width: 1120, height: 80, z: 10 }, bold: true }),
|
|
436
|
+
{
|
|
437
|
+
type: "shape",
|
|
438
|
+
attrs: { kind: "rectangle", frame: { x: 80, y: 200, width: 344, height: 340, rotation: 0, z: 2 }, fill: "#eff6ff", stroke: "#2563eb", label: "\u20A91.45\uC5B5\nQ4 \uCD1D \uB9E4\uCD9C (+28%)", shadow: true }
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
type: "shape",
|
|
442
|
+
attrs: { kind: "rectangle", frame: { x: 468, y: 200, width: 344, height: 340, rotation: 0, z: 3 }, fill: "#ecfdf5", stroke: "#059669", label: "99.98%\n\uC2E4\uC2DC\uAC04 CRDT \uB3D9\uAE30\uD654\uC728", shadow: true }
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
type: "shape",
|
|
446
|
+
attrs: { kind: "rectangle", frame: { x: 856, y: 200, width: 344, height: 340, rotation: 0, z: 4 }, fill: "#ede9fe", stroke: "#7c3aed", label: "3.4x\nAI \uACF5\uB3D9 \uC800\uC791 \uC0DD\uC0B0\uC131", shadow: true }
|
|
447
|
+
}
|
|
448
|
+
]
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
return appendSlide(unit, {
|
|
452
|
+
title: `\uC2AC\uB77C\uC774\uB4DC ${slideNumber}`,
|
|
453
|
+
background: "#ffffff",
|
|
454
|
+
objects: [createTextBoxNode({ text: `\uC2AC\uB77C\uC774\uB4DC ${slideNumber} \uC81C\uBAA9`, frame: { x: 96, y: 80, width: 1088, height: 84, z: 10 }, bold: true })]
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
function updateSlideBackground(unit, slideRootIndex, background) {
|
|
458
|
+
unit.edit([{ op: "update", at: [slideRootIndex], attrs: { canvas: { background } } }]);
|
|
459
|
+
}
|
|
460
|
+
function updateTextBoxContent(unit, objectPath, nextText) {
|
|
461
|
+
const model = unit.readModel();
|
|
462
|
+
const slide = model.children?.[objectPath[0]];
|
|
463
|
+
const box = slide?.children?.[objectPath[1]];
|
|
464
|
+
if (!box || box.type !== "text-box") return;
|
|
465
|
+
const existingLines = box.children ?? [];
|
|
466
|
+
const edits = [];
|
|
467
|
+
for (let i = existingLines.length - 1; i >= 1; i--) {
|
|
468
|
+
edits.push({ op: "delete", at: [...objectPath, i], count: 1 });
|
|
469
|
+
}
|
|
470
|
+
const firstLen = readNodeText(existingLines[0]).length;
|
|
471
|
+
if (firstLen > 0) {
|
|
472
|
+
edits.push({ op: "delete", at: [...objectPath, 0, 0], count: firstLen });
|
|
473
|
+
}
|
|
474
|
+
const lines = nextText.replace(/\r\n/g, "\n").split("\n");
|
|
475
|
+
for (let i = 0; i < lines.length; i++) {
|
|
476
|
+
if (i > 0) edits.push({ op: "split", at: [...objectPath, i - 1, lines[i - 1].length] });
|
|
477
|
+
if (lines[i].length > 0) {
|
|
478
|
+
edits.push({ op: "insert", at: [...objectPath, i, 0], content: lines[i] });
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (edits.length > 0) unit.edit(edits);
|
|
482
|
+
}
|
|
483
|
+
function updateSlideNotes(unit, slideRootIndex, notes) {
|
|
484
|
+
const slide = unit.readModel().children?.[slideRootIndex];
|
|
485
|
+
const children = slide?.children ?? [];
|
|
486
|
+
const notesIdx = children.findIndex((c) => c.type === "speaker-notes");
|
|
487
|
+
if (notesIdx < 0) return;
|
|
488
|
+
const notesNode = children[notesIdx];
|
|
489
|
+
const firstPara = notesNode.children?.[0];
|
|
490
|
+
const currentLen = readNodeText(firstPara).length;
|
|
491
|
+
const edits = [];
|
|
492
|
+
if (currentLen > 0) edits.push({ op: "delete", at: [slideRootIndex, notesIdx, 0, 0], count: currentLen });
|
|
493
|
+
if (notes.length > 0) edits.push({ op: "insert", at: [slideRootIndex, notesIdx, 0, 0], content: notes });
|
|
494
|
+
if (edits.length > 0) unit.edit(edits);
|
|
495
|
+
}
|
|
496
|
+
function deleteSlideObject(unit, objectPath) {
|
|
497
|
+
unit.edit([{ op: "delete", at: objectPath, count: 1 }]);
|
|
498
|
+
}
|
|
499
|
+
function snapFrameToGuides(moving, siblings, canvasWidth, canvasHeight, threshold = 8) {
|
|
500
|
+
const targetsX = [0, canvasWidth / 2, canvasWidth];
|
|
501
|
+
const targetsY = [0, canvasHeight / 2, canvasHeight];
|
|
502
|
+
for (const s of siblings) {
|
|
503
|
+
targetsX.push(s.frame.x, s.frame.x + s.frame.width / 2, s.frame.x + s.frame.width);
|
|
504
|
+
targetsY.push(s.frame.y, s.frame.y + s.frame.height / 2, s.frame.y + s.frame.height);
|
|
505
|
+
}
|
|
506
|
+
let snappedX = moving.x;
|
|
507
|
+
let bestDx = threshold + 1;
|
|
508
|
+
const guidesX = [];
|
|
509
|
+
const anchorsX = [
|
|
510
|
+
{ offset: 0, pos: moving.x },
|
|
511
|
+
{ offset: moving.width / 2, pos: moving.x + moving.width / 2 },
|
|
512
|
+
{ offset: moving.width, pos: moving.x + moving.width }
|
|
513
|
+
];
|
|
514
|
+
for (const t of targetsX) {
|
|
515
|
+
for (const a of anchorsX) {
|
|
516
|
+
const dist = Math.abs(a.pos - t);
|
|
517
|
+
if (dist < bestDx) {
|
|
518
|
+
bestDx = dist;
|
|
519
|
+
snappedX = t - a.offset;
|
|
520
|
+
guidesX.length = 0;
|
|
521
|
+
guidesX.push(t);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
let snappedY = moving.y;
|
|
526
|
+
let bestDy = threshold + 1;
|
|
527
|
+
const guidesY = [];
|
|
528
|
+
const anchorsY = [
|
|
529
|
+
{ offset: 0, pos: moving.y },
|
|
530
|
+
{ offset: moving.height / 2, pos: moving.y + moving.height / 2 },
|
|
531
|
+
{ offset: moving.height, pos: moving.y + moving.height }
|
|
532
|
+
];
|
|
533
|
+
for (const t of targetsY) {
|
|
534
|
+
for (const a of anchorsY) {
|
|
535
|
+
const dist = Math.abs(a.pos - t);
|
|
536
|
+
if (dist < bestDy) {
|
|
537
|
+
bestDy = dist;
|
|
538
|
+
snappedY = t - a.offset;
|
|
539
|
+
guidesY.length = 0;
|
|
540
|
+
guidesY.push(t);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return {
|
|
545
|
+
x: Math.round(snappedX),
|
|
546
|
+
y: Math.round(snappedY),
|
|
547
|
+
guidesX: bestDx <= threshold ? guidesX : [],
|
|
548
|
+
guidesY: bestDy <= threshold ? guidesY : []
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// src/pptx.ts
|
|
553
|
+
var CRC32_TABLE = (() => {
|
|
554
|
+
const table = new Uint32Array(256);
|
|
555
|
+
for (let i = 0; i < 256; i++) {
|
|
556
|
+
let c = i;
|
|
557
|
+
for (let k = 0; k < 8; k++) c = (c & 1) !== 0 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
558
|
+
table[i] = c >>> 0;
|
|
559
|
+
}
|
|
560
|
+
return table;
|
|
561
|
+
})();
|
|
562
|
+
function crc32(bytes) {
|
|
563
|
+
let crc = 4294967295;
|
|
564
|
+
for (let i = 0; i < bytes.length; i++) crc = CRC32_TABLE[(crc ^ bytes[i]) & 255] ^ crc >>> 8;
|
|
565
|
+
return (crc ^ 4294967295) >>> 0;
|
|
566
|
+
}
|
|
567
|
+
function encodeUtf8(text) {
|
|
568
|
+
return new TextEncoder().encode(text);
|
|
569
|
+
}
|
|
570
|
+
function createZipStore(entries) {
|
|
571
|
+
const localParts = [];
|
|
572
|
+
const centralParts = [];
|
|
573
|
+
let offset = 0;
|
|
574
|
+
for (const entry of entries) {
|
|
575
|
+
const nameBytes = encodeUtf8(entry.name);
|
|
576
|
+
const data = entry.data;
|
|
577
|
+
const crc = crc32(data);
|
|
578
|
+
const local = new Uint8Array(30 + nameBytes.length + data.length);
|
|
579
|
+
const lv = new DataView(local.buffer);
|
|
580
|
+
lv.setUint32(0, 67324752, true);
|
|
581
|
+
lv.setUint16(4, 20, true);
|
|
582
|
+
lv.setUint16(6, 2048, true);
|
|
583
|
+
lv.setUint32(14, crc, true);
|
|
584
|
+
lv.setUint32(18, data.length, true);
|
|
585
|
+
lv.setUint32(22, data.length, true);
|
|
586
|
+
lv.setUint16(26, nameBytes.length, true);
|
|
587
|
+
local.set(nameBytes, 30);
|
|
588
|
+
local.set(data, 30 + nameBytes.length);
|
|
589
|
+
localParts.push(local);
|
|
590
|
+
const central = new Uint8Array(46 + nameBytes.length);
|
|
591
|
+
const cv = new DataView(central.buffer);
|
|
592
|
+
cv.setUint32(0, 33639248, true);
|
|
593
|
+
cv.setUint16(4, 20, true);
|
|
594
|
+
cv.setUint16(6, 20, true);
|
|
595
|
+
cv.setUint16(8, 2048, true);
|
|
596
|
+
cv.setUint32(16, crc, true);
|
|
597
|
+
cv.setUint32(20, data.length, true);
|
|
598
|
+
cv.setUint32(24, data.length, true);
|
|
599
|
+
cv.setUint16(28, nameBytes.length, true);
|
|
600
|
+
cv.setUint32(42, offset, true);
|
|
601
|
+
central.set(nameBytes, 46);
|
|
602
|
+
centralParts.push(central);
|
|
603
|
+
offset += local.length;
|
|
604
|
+
}
|
|
605
|
+
const centralSize = centralParts.reduce((acc, p) => acc + p.length, 0);
|
|
606
|
+
const eocd = new Uint8Array(22);
|
|
607
|
+
const ev = new DataView(eocd.buffer);
|
|
608
|
+
ev.setUint32(0, 101010256, true);
|
|
609
|
+
ev.setUint16(8, entries.length, true);
|
|
610
|
+
ev.setUint16(10, entries.length, true);
|
|
611
|
+
ev.setUint32(12, centralSize, true);
|
|
612
|
+
ev.setUint32(16, offset, true);
|
|
613
|
+
const out = new Uint8Array(offset + centralSize + eocd.length);
|
|
614
|
+
let pos = 0;
|
|
615
|
+
for (const part of localParts) {
|
|
616
|
+
out.set(part, pos);
|
|
617
|
+
pos += part.length;
|
|
618
|
+
}
|
|
619
|
+
for (const part of centralParts) {
|
|
620
|
+
out.set(part, pos);
|
|
621
|
+
pos += part.length;
|
|
622
|
+
}
|
|
623
|
+
out.set(eocd, pos);
|
|
624
|
+
return out;
|
|
625
|
+
}
|
|
626
|
+
function escapeXml(text) {
|
|
627
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
628
|
+
}
|
|
629
|
+
var PX_TO_EMU = 9525;
|
|
630
|
+
function hexClean(color, fallback) {
|
|
631
|
+
if (color && /^#[0-9a-fA-F]{6}$/.test(color)) return color.slice(1).toUpperCase();
|
|
632
|
+
return fallback;
|
|
633
|
+
}
|
|
634
|
+
function shapePresetGeom(kind) {
|
|
635
|
+
if (kind === "ellipse") return "ellipse";
|
|
636
|
+
if (kind === "diamond") return "diamond";
|
|
637
|
+
if (kind === "triangle") return "triangle";
|
|
638
|
+
if (kind === "arrow") return "rightArrow";
|
|
639
|
+
if (kind === "line") return "line";
|
|
640
|
+
return "roundRect";
|
|
641
|
+
}
|
|
642
|
+
function serializeSlideObjectXml(obj, shapeId) {
|
|
643
|
+
if (obj.hidden) return "";
|
|
644
|
+
const x = Math.round(obj.frame.x * PX_TO_EMU);
|
|
645
|
+
const y = Math.round(obj.frame.y * PX_TO_EMU);
|
|
646
|
+
const cx = Math.max(9525, Math.round(obj.frame.width * PX_TO_EMU));
|
|
647
|
+
const cy = Math.max(9525, Math.round(obj.frame.height * PX_TO_EMU));
|
|
648
|
+
const rot = Math.round((obj.frame.rotation ?? 0) * 6e4);
|
|
649
|
+
const xfrm = `<a:xfrm${rot ? ` rot="${rot}"` : ""}><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm>`;
|
|
650
|
+
if (obj.type === "shape") {
|
|
651
|
+
const fill = hexClean(obj.fill, "EFF6FF");
|
|
652
|
+
const stroke = hexClean(obj.stroke, "2563EB");
|
|
653
|
+
const strokeW = Math.round((obj.strokeWidth ?? 2) * 12700);
|
|
654
|
+
const lines = (obj.label ?? "").split("\n").filter(Boolean);
|
|
655
|
+
const paras2 = lines.length > 0 ? lines.map((l) => `<a:p><a:pPr algn="ctr"/><a:r><a:rPr lang="ko-KR" sz="1800" b="1"/><a:t>${escapeXml(l)}</a:t></a:r></a:p>`).join("") : "<a:p/>";
|
|
656
|
+
return `<p:sp>
|
|
657
|
+
<p:nvSpPr><p:cNvPr id="${shapeId}" name="Shape ${shapeId}"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr>
|
|
658
|
+
<p:spPr>${xfrm}<a:prstGeom prst="${shapePresetGeom(obj.shapeKind)}"><a:avLst/></a:prstGeom><a:solidFill><a:srgbClr val="${fill}"/></a:solidFill><a:ln w="${strokeW}"><a:solidFill><a:srgbClr val="${stroke}"/></a:solidFill></a:ln></p:spPr>
|
|
659
|
+
<p:txBody><a:bodyPr anchor="ctr"/><a:lstStyle/>${paras2}</p:txBody>
|
|
660
|
+
</p:sp>`;
|
|
661
|
+
}
|
|
662
|
+
const rawText = obj.type === "image" ? `[Image: ${obj.alt || "Image"}]` : obj.text ?? "";
|
|
663
|
+
const fontSizePt = Math.round((obj.fontSize ?? (obj.frame.y < 180 && obj.frame.width > 500 ? 32 : 18)) * 100);
|
|
664
|
+
const algn = obj.textAlign === "center" ? "ctr" : obj.textAlign === "right" ? "r" : "l";
|
|
665
|
+
const textColor = hexClean(obj.textColor, "0F172A");
|
|
666
|
+
const paras = rawText.split("\n").map((line) => `<a:p><a:pPr algn="${algn}"/><a:r><a:rPr lang="ko-KR" sz="${fontSizePt}"><a:solidFill><a:srgbClr val="${textColor}"/></a:solidFill></a:rPr><a:t>${escapeXml(line)}</a:t></a:r></a:p>`).join("");
|
|
667
|
+
return `<p:sp>
|
|
668
|
+
<p:nvSpPr><p:cNvPr id="${shapeId}" name="TextBox ${shapeId}"/><p:cNvSpPr txBox="1"/><p:nvPr/></p:nvSpPr>
|
|
669
|
+
<p:spPr>${xfrm}<a:prstGeom prst="rect"><a:avLst/></a:prstGeom><a:noFill/></p:spPr>
|
|
670
|
+
<p:txBody><a:bodyPr wrap="square"/><a:lstStyle/>${paras || "<a:p/>"}</p:txBody>
|
|
671
|
+
</p:sp>`;
|
|
672
|
+
}
|
|
673
|
+
function slidesToPptxBytes(deck) {
|
|
674
|
+
const slides = deck.length > 0 ? deck : [];
|
|
675
|
+
const slideOverrides = slides.map((_, i) => ` <Override PartName="/ppt/slides/slide${i + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/>`).join("\n");
|
|
676
|
+
const contentTypes = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
677
|
+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
|
678
|
+
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
|
679
|
+
<Default Extension="xml" ContentType="application/xml"/>
|
|
680
|
+
<Override PartName="/ppt/presentation.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"/>
|
|
681
|
+
<Override PartName="/ppt/slideLayouts/slideLayout1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>
|
|
682
|
+
<Override PartName="/ppt/slideMasters/slideMaster1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"/>
|
|
683
|
+
${slideOverrides}
|
|
684
|
+
</Types>`;
|
|
685
|
+
const rootRels = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
686
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
687
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="ppt/presentation.xml"/>
|
|
688
|
+
</Relationships>`;
|
|
689
|
+
const presRels = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
690
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
691
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" Target="slideMasters/slideMaster1.xml"/>
|
|
692
|
+
${slides.map((_, i) => ` <Relationship Id="rId${i + 2}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide${i + 1}.xml"/>`).join("\n")}
|
|
693
|
+
</Relationships>`;
|
|
694
|
+
const sldIdLst = slides.map((_, i) => ` <p:sldId id="${256 + i}" r:id="rId${i + 2}"/>`).join("\n");
|
|
695
|
+
const presentationXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
696
|
+
<p:presentation xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
|
|
697
|
+
<p:sldMasterIdLst><p:sldMasterId id="2147483648" r:id="rId1"/></p:sldMasterIdLst>
|
|
698
|
+
<p:sldIdLst>
|
|
699
|
+
${sldIdLst}
|
|
700
|
+
</p:sldIdLst>
|
|
701
|
+
<p:sldSz cx="12192000" cy="6858000"/>
|
|
702
|
+
<p:notesSz cx="6858000" cy="9144000"/>
|
|
703
|
+
</p:presentation>`;
|
|
704
|
+
const slideMasterXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
705
|
+
<p:sldMaster xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
|
|
706
|
+
<p:cSld><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr/></p:spTree></p:cSld>
|
|
707
|
+
<p:sldLayoutIdLst><p:sldLayoutId id="2147483649" r:id="rId1"/></p:sldLayoutIdLst>
|
|
708
|
+
</p:sldMaster>`;
|
|
709
|
+
const slideMasterRels = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
710
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
711
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>
|
|
712
|
+
</Relationships>`;
|
|
713
|
+
const slideLayoutXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
714
|
+
<p:sldLayout xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" type="blank">
|
|
715
|
+
<p:cSld><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr/></p:spTree></p:cSld>
|
|
716
|
+
</p:sldLayout>`;
|
|
717
|
+
const slideRelsXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
718
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
719
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>
|
|
720
|
+
</Relationships>`;
|
|
721
|
+
const entries = [
|
|
722
|
+
{ name: "[Content_Types].xml", data: encodeUtf8(contentTypes) },
|
|
723
|
+
{ name: "_rels/.rels", data: encodeUtf8(rootRels) },
|
|
724
|
+
{ name: "ppt/presentation.xml", data: encodeUtf8(presentationXml) },
|
|
725
|
+
{ name: "ppt/_rels/presentation.xml.rels", data: encodeUtf8(presRels) },
|
|
726
|
+
{ name: "ppt/slideMasters/slideMaster1.xml", data: encodeUtf8(slideMasterXml) },
|
|
727
|
+
{ name: "ppt/slideMasters/_rels/slideMaster1.xml.rels", data: encodeUtf8(slideMasterRels) },
|
|
728
|
+
{ name: "ppt/slideLayouts/slideLayout1.xml", data: encodeUtf8(slideLayoutXml) }
|
|
729
|
+
];
|
|
730
|
+
slides.forEach((slide, idx) => {
|
|
731
|
+
const bgHex = hexClean(slide.canvas.background, "FFFFFF");
|
|
732
|
+
const shapesXml = slide.objects.map((o, j) => serializeSlideObjectXml(o, j + 2)).join("\n");
|
|
733
|
+
const slideXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
734
|
+
<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
|
|
735
|
+
<p:cSld>
|
|
736
|
+
<p:bg><p:bgPr><a:solidFill><a:srgbClr val="${bgHex}"/></a:solidFill></p:bgPr></p:bg>
|
|
737
|
+
<p:spTree>
|
|
738
|
+
<p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>
|
|
739
|
+
<p:grpSpPr/>
|
|
740
|
+
${shapesXml}
|
|
741
|
+
</p:spTree>
|
|
742
|
+
</p:cSld>
|
|
743
|
+
</p:sld>`;
|
|
744
|
+
entries.push({ name: `ppt/slides/slide${idx + 1}.xml`, data: encodeUtf8(slideXml) });
|
|
745
|
+
entries.push({ name: `ppt/slides/_rels/slide${idx + 1}.xml.rels`, data: encodeUtf8(slideRelsXml) });
|
|
746
|
+
});
|
|
747
|
+
return createZipStore(entries);
|
|
748
|
+
}
|
|
749
|
+
export {
|
|
750
|
+
SLIDE_LAYOUT_TEMPLATES,
|
|
751
|
+
addImage,
|
|
752
|
+
addShape,
|
|
753
|
+
addTextBox,
|
|
754
|
+
alignObjects,
|
|
755
|
+
appendSlide,
|
|
756
|
+
appendSlideFromTemplate,
|
|
757
|
+
bringToFront,
|
|
758
|
+
cloneSlideObjectNodes,
|
|
759
|
+
createImageNode,
|
|
760
|
+
createShapeNode,
|
|
761
|
+
createSlideNode,
|
|
762
|
+
createTextBoxNode,
|
|
763
|
+
deleteSlide,
|
|
764
|
+
deleteSlideObject,
|
|
765
|
+
deleteSlideObjects,
|
|
766
|
+
duplicateSlide,
|
|
767
|
+
duplicateSlideObjects,
|
|
768
|
+
extractSlideDeck,
|
|
769
|
+
groupSlideObjects,
|
|
770
|
+
pasteSlideObjectNodes,
|
|
771
|
+
reorderSlide,
|
|
772
|
+
sendToBack,
|
|
773
|
+
slidesToPptxBytes,
|
|
774
|
+
snapFrameToGuides,
|
|
775
|
+
ungroupSlideObjects,
|
|
776
|
+
updateObjectFrame,
|
|
777
|
+
updateObjectMeta,
|
|
778
|
+
updateShapeStyle,
|
|
779
|
+
updateSlideBackground,
|
|
780
|
+
updateSlideNotes,
|
|
781
|
+
updateSlideTransition,
|
|
782
|
+
updateTextBoxContent,
|
|
783
|
+
updateTextBoxStyle
|
|
784
|
+
};
|
|
785
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/model.ts", "../src/pptx.ts"],
|
|
4
|
+
"sourcesContent": ["import type {EditOp, NodeJSON} from \"@barocss/doc-sync\";\nimport type {DocUnit} from \"@barocss/office-core\";\n\nexport interface SlideFrame {\n x: number;\n y: number;\n width: number;\n height: number;\n rotation: number;\n z: number;\n}\n\nexport type SlideShapeKind = \"rectangle\" | \"ellipse\" | \"diamond\" | \"triangle\" | \"line\" | \"arrow\";\nexport type SlideAlignMode = \"left\" | \"center\" | \"right\" | \"top\" | \"middle\" | \"bottom\" | \"distribute-h\" | \"distribute-v\";\nexport type SlideTransitionKind = \"none\" | \"fade\" | \"slide\" | \"zoom\";\nexport type SlideTemplateId = \"blank\" | \"title\" | \"two-column\" | \"comparison\" | \"kpi\";\n\nexport interface SlideObjectView {\n /** Stable model path inside the DocUnit root (e.g. [slideChildIdx, objChildIdx]). */\n path: number[];\n id: string;\n type: \"text-box\" | \"shape\" | \"image\" | \"chart\";\n frame: SlideFrame;\n text?: string;\n label?: string;\n fontSize?: number;\n textAlign?: \"left\" | \"center\" | \"right\";\n textColor?: string;\n shapeKind?: SlideShapeKind;\n fill?: string;\n stroke?: string;\n strokeWidth?: number;\n dashed?: boolean;\n shadow?: boolean;\n opacity?: number;\n radius?: number;\n groupId?: string;\n locked?: boolean;\n hidden?: boolean;\n src?: string;\n alt?: string;\n}\n\nexport interface SlideView {\n /** Child index inside office-deck root */\n rootIndex: number;\n slideNumber: number;\n title: string;\n notes: string;\n layout: string;\n transition: SlideTransitionKind;\n canvas: {\n width: number;\n height: number;\n background: string;\n };\n objects: SlideObjectView[];\n}\n\nexport interface SnapResult {\n x: number;\n y: number;\n guidesX: number[];\n guidesY: number[];\n}\n\nfunction readNodeText(node: NodeJSON | undefined): string {\n if (!node) return \"\";\n const parts: string[] = [];\n if (node.runs) {\n for (const r of node.runs) {\n if (\"text\" in r) parts.push(r.text);\n }\n }\n if (node.children) {\n for (const c of node.children) {\n const t = readNodeText(c);\n if (t) parts.push(t);\n }\n }\n return parts.join(\"\\n\");\n}\n\nfunction readFrame(attrs: Record<string, unknown> | undefined): SlideFrame {\n const raw = (attrs?.frame ?? {}) as Partial<SlideFrame>;\n return {\n x: typeof raw.x === \"number\" ? raw.x : 80,\n y: typeof raw.y === \"number\" ? raw.y : 80,\n width: typeof raw.width === \"number\" ? raw.width : 320,\n height: typeof raw.height === \"number\" ? raw.height : 120,\n rotation: typeof raw.rotation === \"number\" ? raw.rotation : 0,\n z: typeof raw.z === \"number\" ? raw.z : 0,\n };\n}\n\n/**\n * Extracts all structured slides and their absolute-positioned objects from a DocUnit(\"slide\").\n */\nexport function extractSlideDeck(unit: DocUnit): SlideView[] {\n const root = unit.readModel();\n const children = root.children ?? [];\n const slides: SlideView[] = [];\n\n for (let rootIdx = 0; rootIdx < children.length; rootIdx++) {\n const node = children[rootIdx];\n if (node.type !== \"slide\") continue;\n\n const canvasRaw = (node.attrs?.canvas ?? {}) as {width?: number; height?: number; background?: string};\n const canvas = {\n width: typeof canvasRaw.width === \"number\" ? canvasRaw.width : 1280,\n height: typeof canvasRaw.height === \"number\" ? canvasRaw.height : 720,\n background: typeof canvasRaw.background === \"string\" ? canvasRaw.background : \"#ffffff\",\n };\n\n let title = \"\";\n let notes = \"\";\n const objects: SlideObjectView[] = [];\n const slideChildren = node.children ?? [];\n\n for (let objIdx = 0; objIdx < slideChildren.length; objIdx++) {\n const child = slideChildren[objIdx];\n if (child.type === \"slide-title\") {\n title = readNodeText(child);\n continue;\n }\n if (child.type === \"speaker-notes\") {\n notes = readNodeText(child);\n continue;\n }\n if (\n child.type === \"text-box\" ||\n child.type === \"shape\" ||\n child.type === \"image\" ||\n child.type === \"chart\"\n ) {\n const path = [rootIdx, objIdx];\n objects.push({\n path,\n id: path.join(\".\"),\n type: child.type,\n frame: readFrame(child.attrs),\n text: child.type === \"text-box\" ? readNodeText(child) : undefined,\n label: typeof child.attrs?.label === \"string\" ? child.attrs.label : \"\",\n fontSize: typeof child.attrs?.fontSize === \"number\" ? child.attrs.fontSize : undefined,\n textAlign:\n child.attrs?.textAlign === \"center\" || child.attrs?.textAlign === \"right\"\n ? child.attrs.textAlign\n : \"left\",\n textColor: typeof child.attrs?.textColor === \"string\" ? child.attrs.textColor : undefined,\n shapeKind: child.type === \"shape\" ? ((child.attrs?.kind as SlideShapeKind) ?? \"rectangle\") : undefined,\n fill: typeof child.attrs?.fill === \"string\" ? child.attrs.fill : undefined,\n stroke: typeof child.attrs?.stroke === \"string\" ? child.attrs.stroke : undefined,\n strokeWidth: typeof child.attrs?.strokeWidth === \"number\" ? child.attrs.strokeWidth : 2,\n dashed: child.attrs?.dashed === true,\n shadow: child.attrs?.shadow === true,\n opacity: typeof child.attrs?.opacity === \"number\" ? child.attrs.opacity : 100,\n radius: typeof child.attrs?.radius === \"number\" ? child.attrs.radius : 12,\n groupId: typeof child.attrs?.groupId === \"string\" ? child.attrs.groupId : \"\",\n locked: child.attrs?.locked === true,\n hidden: child.attrs?.hidden === true,\n src: typeof child.attrs?.src === \"string\" ? child.attrs.src : undefined,\n alt: typeof child.attrs?.alt === \"string\" ? child.attrs.alt : undefined,\n });\n }\n }\n\n objects.sort((a, b) => a.frame.z - b.frame.z || a.path[1] - b.path[1]);\n const tr = node.attrs?.transition;\n const transition: SlideTransitionKind =\n tr === \"fade\" || tr === \"slide\" || tr === \"zoom\" ? tr : \"none\";\n slides.push({\n rootIndex: rootIdx,\n slideNumber: slides.length + 1,\n title,\n notes,\n layout: typeof node.attrs?.layout === \"string\" ? node.attrs.layout : \"blank\",\n transition,\n canvas,\n objects,\n });\n }\n\n return slides;\n}\n\nexport function createSlideNode(options: {\n title?: string;\n background?: string;\n notes?: string;\n objects?: NodeJSON[];\n} = {}): NodeJSON {\n return {\n type: \"slide\",\n attrs: {\n layout: \"blank\",\n canvas: {\n width: 1280,\n height: 720,\n background: options.background ?? \"#ffffff\",\n },\n },\n children: [\n {\n type: \"slide-title\",\n runs: options.title ? [{text: options.title, marks: {}}] : [],\n },\n ...(options.objects ?? []),\n {\n type: \"speaker-notes\",\n children: [\n {\n type: \"paragraph\",\n runs: options.notes ? [{text: options.notes, marks: {}}] : [],\n },\n ],\n },\n ],\n };\n}\n\nexport function createTextBoxNode(options: {\n text: string;\n frame: Partial<SlideFrame>;\n bold?: boolean;\n}): NodeJSON {\n const frame: SlideFrame = {\n x: options.frame.x ?? 120,\n y: options.frame.y ?? 120,\n width: options.frame.width ?? 480,\n height: options.frame.height ?? 110,\n rotation: options.frame.rotation ?? 0,\n z: options.frame.z ?? 10,\n };\n const lines = options.text.split(\"\\n\");\n return {\n type: \"text-box\",\n attrs: {frame},\n children: lines.map(line => ({\n type: \"paragraph\",\n runs: line ? [{text: line, marks: options.bold ? {bold: true} : {}}] : [],\n })),\n };\n}\n\nexport function createShapeNode(options: {\n kind: SlideShapeKind;\n frame: Partial<SlideFrame>;\n fill?: string;\n stroke?: string;\n opacity?: number;\n radius?: number;\n}): NodeJSON {\n const frame: SlideFrame = {\n x: options.frame.x ?? 160,\n y: options.frame.y ?? 160,\n width: options.frame.width ?? 240,\n height: options.frame.height ?? 140,\n rotation: options.frame.rotation ?? 0,\n z: options.frame.z ?? 1,\n };\n return {\n type: \"shape\",\n attrs: {\n kind: options.kind,\n frame,\n fill: options.fill ?? \"#eff6ff\",\n stroke: options.stroke ?? \"#2563eb\",\n opacity: options.opacity ?? 100,\n radius: options.radius ?? 12,\n },\n };\n}\n\nexport function createImageNode(options: {\n src: string;\n alt?: string;\n frame: Partial<SlideFrame>;\n}): NodeJSON {\n const frame: SlideFrame = {\n x: options.frame.x ?? 180,\n y: options.frame.y ?? 140,\n width: options.frame.width ?? 480,\n height: options.frame.height ?? 280,\n rotation: options.frame.rotation ?? 0,\n z: options.frame.z ?? 8,\n };\n return {\n type: \"image\",\n attrs: {\n src: options.src,\n alt: options.alt ?? \"Slide Image\",\n frame,\n },\n };\n}\n\n/**\n * Appends a new blank (or starter) slide into the DocUnit deck.\n */\nexport function appendSlide(\n unit: DocUnit,\n options: {title?: string; background?: string; notes?: string; objects?: NodeJSON[]} = {},\n): number {\n const rootChildren = unit.readModel().children ?? [];\n const insertAt = rootChildren.length;\n const node = createSlideNode(options);\n unit.edit([{op: \"insert\", at: [insertAt], content: [node]}]);\n return insertAt;\n}\n\nexport function deleteSlide(unit: DocUnit, rootIndex: number): void {\n unit.edit([{op: \"delete\", at: [rootIndex], count: 1}]);\n}\n\nfunction slideInsertIndex(unit: DocUnit, slideRootIndex: number): number {\n const slide = unit.readModel().children?.[slideRootIndex];\n const children = slide?.children ?? [];\n // Insert right before speaker-notes (the required last child)\n const notesIdx = children.findIndex(c => c.type === \"speaker-notes\");\n return notesIdx >= 0 ? notesIdx : children.length;\n}\n\nexport function addTextBox(\n unit: DocUnit,\n slideRootIndex: number,\n options: {text: string; frame: Partial<SlideFrame>; bold?: boolean},\n): number[] {\n const idx = slideInsertIndex(unit, slideRootIndex);\n unit.edit([{op: \"insert\", at: [slideRootIndex, idx], content: [createTextBoxNode(options)]}]);\n return [slideRootIndex, idx];\n}\n\nexport function addShape(\n unit: DocUnit,\n slideRootIndex: number,\n options: {kind: SlideShapeKind; frame: Partial<SlideFrame>; fill?: string; stroke?: string; opacity?: number; radius?: number},\n): number[] {\n const idx = slideInsertIndex(unit, slideRootIndex);\n unit.edit([{op: \"insert\", at: [slideRootIndex, idx], content: [createShapeNode(options)]}]);\n return [slideRootIndex, idx];\n}\n\nexport function addImage(\n unit: DocUnit,\n slideRootIndex: number,\n options: {src: string; alt?: string; frame: Partial<SlideFrame>},\n): number[] {\n const idx = slideInsertIndex(unit, slideRootIndex);\n unit.edit([{op: \"insert\", at: [slideRootIndex, idx], content: [createImageNode(options)]}]);\n return [slideRootIndex, idx];\n}\n\nexport function duplicateSlide(unit: DocUnit, slideRootIndex: number): number {\n const source = unit.readModel().children?.[slideRootIndex];\n if (!source || source.type !== \"slide\") return slideRootIndex;\n const cloned = structuredClone(source);\n const insertAt = slideRootIndex + 1;\n unit.edit([{op: \"insert\", at: [insertAt], content: [cloned]}]);\n return insertAt;\n}\n\nexport function cloneSlideObjectNodes(\n unit: DocUnit,\n objectPaths: readonly number[][],\n offsetPx = 28,\n): NodeJSON[] {\n const model = unit.readModel();\n const clones: NodeJSON[] = [];\n for (const p of objectPaths) {\n const node = model.children?.[p[0]]?.children?.[p[1]];\n if (!node) continue;\n const copy = structuredClone(node);\n const f = readFrame(copy.attrs);\n copy.attrs = {\n ...(copy.attrs ?? {}),\n frame: {...f, x: f.x + offsetPx, y: f.y + offsetPx, z: f.z + 1},\n };\n clones.push(copy);\n }\n return clones;\n}\n\nexport function pasteSlideObjectNodes(\n unit: DocUnit,\n slideRootIndex: number,\n nodes: readonly NodeJSON[],\n): number[][] {\n if (nodes.length === 0) return [];\n const idx = slideInsertIndex(unit, slideRootIndex);\n const cloned = nodes.map(n => structuredClone(n));\n unit.edit([{op: \"insert\", at: [slideRootIndex, idx], content: cloned}]);\n return cloned.map((_, i) => [slideRootIndex, idx + i]);\n}\n\nexport function duplicateSlideObjects(\n unit: DocUnit,\n slideRootIndex: number,\n objectPaths: readonly number[][],\n): number[][] {\n const clones = cloneSlideObjectNodes(unit, objectPaths, 28);\n return pasteSlideObjectNodes(unit, slideRootIndex, clones);\n}\n\nexport function deleteSlideObjects(unit: DocUnit, objectPaths: readonly number[][]): void {\n if (objectPaths.length === 0) return;\n // Delete in descending child index order so earlier paths never shift\n const sorted = [...objectPaths].sort((a, b) => (b[1] ?? 0) - (a[1] ?? 0));\n unit.edit(sorted.map(at => ({op: \"delete\", at, count: 1})));\n}\n\nexport function updateTextBoxStyle(\n unit: DocUnit,\n objectPath: number[],\n style: {fontSize?: number; textAlign?: \"left\" | \"center\" | \"right\"; textColor?: string},\n): void {\n const attrs: Record<string, unknown> = {};\n if (style.fontSize !== undefined) attrs.fontSize = Math.max(10, Math.min(140, Math.round(style.fontSize)));\n if (style.textAlign !== undefined) attrs.textAlign = style.textAlign;\n if (style.textColor !== undefined) attrs.textColor = style.textColor;\n if (Object.keys(attrs).length > 0) {\n unit.edit([{op: \"update\", at: objectPath, attrs}]);\n }\n}\n\nexport function alignObjects(\n unit: DocUnit,\n objects: readonly SlideObjectView[],\n mode: SlideAlignMode,\n canvasWidth = 1280,\n canvasHeight = 720,\n): void {\n if (objects.length === 0) return;\n const edits: EditOp[] = [];\n const multi = objects.length > 1;\n\n const minX = multi ? Math.min(...objects.map(o => o.frame.x)) : 0;\n const maxX = multi ? Math.max(...objects.map(o => o.frame.x + o.frame.width)) : canvasWidth;\n const minY = multi ? Math.min(...objects.map(o => o.frame.y)) : 0;\n const maxY = multi ? Math.max(...objects.map(o => o.frame.y + o.frame.height)) : canvasHeight;\n const midX = (minX + maxX) / 2;\n const midY = (minY + maxY) / 2;\n\n if (mode === \"distribute-h\" && objects.length >= 3) {\n const sorted = [...objects].sort((a, b) => a.frame.x - b.frame.x);\n const totalObjW = sorted.reduce((acc, o) => acc + o.frame.width, 0);\n const span = sorted[sorted.length - 1].frame.x + sorted[sorted.length - 1].frame.width - sorted[0].frame.x;\n const gap = (span - totalObjW) / (sorted.length - 1);\n let curX = sorted[0].frame.x;\n for (const obj of sorted) {\n edits.push({op: \"update\", at: obj.path, attrs: {frame: {x: Math.round(curX)}}});\n curX += obj.frame.width + gap;\n }\n } else if (mode === \"distribute-v\" && objects.length >= 3) {\n const sorted = [...objects].sort((a, b) => a.frame.y - b.frame.y);\n const totalObjH = sorted.reduce((acc, o) => acc + o.frame.height, 0);\n const span = sorted[sorted.length - 1].frame.y + sorted[sorted.length - 1].frame.height - sorted[0].frame.y;\n const gap = (span - totalObjH) / (sorted.length - 1);\n let curY = sorted[0].frame.y;\n for (const obj of sorted) {\n edits.push({op: \"update\", at: obj.path, attrs: {frame: {y: Math.round(curY)}}});\n curY += obj.frame.height + gap;\n }\n } else {\n for (const obj of objects) {\n if (mode === \"left\") edits.push({op: \"update\", at: obj.path, attrs: {frame: {x: Math.round(minX)}}});\n if (mode === \"center\") edits.push({op: \"update\", at: obj.path, attrs: {frame: {x: Math.round(midX - obj.frame.width / 2)}}});\n if (mode === \"right\") edits.push({op: \"update\", at: obj.path, attrs: {frame: {x: Math.round(maxX - obj.frame.width)}}});\n if (mode === \"top\") edits.push({op: \"update\", at: obj.path, attrs: {frame: {y: Math.round(minY)}}});\n if (mode === \"middle\") edits.push({op: \"update\", at: obj.path, attrs: {frame: {y: Math.round(midY - obj.frame.height / 2)}}});\n if (mode === \"bottom\") edits.push({op: \"update\", at: obj.path, attrs: {frame: {y: Math.round(maxY - obj.frame.height)}}});\n }\n }\n\n if (edits.length > 0) unit.edit(edits);\n}\n\nexport function bringToFront(unit: DocUnit, target: SlideObjectView, allObjects: readonly SlideObjectView[]): void {\n const maxZ = Math.max(0, ...allObjects.map(o => o.frame.z));\n updateObjectFrame(unit, target.path, {z: maxZ + 1});\n}\n\nexport function sendToBack(unit: DocUnit, target: SlideObjectView, allObjects: readonly SlideObjectView[]): void {\n const minZ = Math.min(0, ...allObjects.map(o => o.frame.z));\n updateObjectFrame(unit, target.path, {z: minZ - 1});\n}\n\nexport function updateObjectFrame(\n unit: DocUnit,\n objectPath: number[],\n patch: Partial<SlideFrame>,\n): void {\n const rounded: Partial<SlideFrame> = {};\n if (patch.x !== undefined) rounded.x = Math.round(patch.x);\n if (patch.y !== undefined) rounded.y = Math.round(patch.y);\n if (patch.width !== undefined) rounded.width = Math.max(24, Math.round(patch.width));\n if (patch.height !== undefined) rounded.height = Math.max(24, Math.round(patch.height));\n if (patch.rotation !== undefined) rounded.rotation = Math.max(-360, Math.min(360, Math.round(patch.rotation)));\n if (patch.z !== undefined) rounded.z = Math.round(patch.z);\n unit.edit([{op: \"update\", at: objectPath, attrs: {frame: rounded}}]);\n}\n\nexport function updateShapeStyle(\n unit: DocUnit,\n objectPath: number[],\n style: {\n label?: string;\n fill?: string;\n stroke?: string;\n strokeWidth?: number;\n dashed?: boolean;\n shadow?: boolean;\n opacity?: number;\n radius?: number;\n },\n): void {\n const attrs: Record<string, unknown> = {};\n if (style.label !== undefined) attrs.label = style.label;\n if (style.fill !== undefined) attrs.fill = style.fill;\n if (style.stroke !== undefined) attrs.stroke = style.stroke;\n if (style.strokeWidth !== undefined) attrs.strokeWidth = Math.max(0, Math.min(16, Math.round(style.strokeWidth)));\n if (style.dashed !== undefined) attrs.dashed = style.dashed;\n if (style.shadow !== undefined) attrs.shadow = style.shadow;\n if (style.opacity !== undefined) attrs.opacity = Math.max(10, Math.min(100, Math.round(style.opacity)));\n if (style.radius !== undefined) attrs.radius = Math.max(0, Math.min(120, Math.round(style.radius)));\n if (Object.keys(attrs).length > 0) {\n unit.edit([{op: \"update\", at: objectPath, attrs}]);\n }\n}\n\nexport function updateObjectMeta(\n unit: DocUnit,\n objectPath: number[],\n meta: {locked?: boolean; hidden?: boolean; groupId?: string; shadow?: boolean},\n): void {\n const attrs: Record<string, unknown> = {};\n if (meta.locked !== undefined) attrs.locked = meta.locked;\n if (meta.hidden !== undefined) attrs.hidden = meta.hidden;\n if (meta.groupId !== undefined) attrs.groupId = meta.groupId;\n if (meta.shadow !== undefined) attrs.shadow = meta.shadow;\n if (Object.keys(attrs).length > 0) {\n unit.edit([{op: \"update\", at: objectPath, attrs}]);\n }\n}\n\nexport function groupSlideObjects(unit: DocUnit, objects: readonly SlideObjectView[]): string {\n if (objects.length < 2) return \"\";\n const groupId = `grp-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;\n unit.edit(objects.map(o => ({op: \"update\", at: o.path, attrs: {groupId}})));\n return groupId;\n}\n\nexport function ungroupSlideObjects(unit: DocUnit, objects: readonly SlideObjectView[]): void {\n if (objects.length === 0) return;\n unit.edit(objects.map(o => ({op: \"update\", at: o.path, attrs: {groupId: \"\"}})));\n}\n\nexport function reorderSlide(unit: DocUnit, fromRootIndex: number, toRootIndex: number): void {\n if (fromRootIndex === toRootIndex) return;\n const children = unit.readModel().children ?? [];\n const target = children[fromRootIndex];\n if (!target || target.type !== \"slide\") return;\n const cloned = structuredClone(target);\n const adjustedDest = toRootIndex > fromRootIndex ? toRootIndex : toRootIndex;\n unit.edit([\n {op: \"delete\", at: [fromRootIndex], count: 1},\n {op: \"insert\", at: [adjustedDest], content: [cloned]},\n ]);\n}\n\nexport function updateSlideTransition(\n unit: DocUnit,\n slideRootIndex: number,\n transition: SlideTransitionKind,\n): void {\n unit.edit([{op: \"update\", at: [slideRootIndex], attrs: {transition}}]);\n}\n\nexport const SLIDE_LAYOUT_TEMPLATES: ReadonlyArray<{id: SlideTemplateId; label: string; desc: string}> = [\n {id: \"blank\", label: \"\uBE48 \uC2AC\uB77C\uC774\uB4DC\", desc: \"\uC790\uC720 \uBC30\uCE58 \uCE94\uBC84\uC2A4\"},\n {id: \"title\", label: \"\uD45C\uC9C0 \uD0C0\uC774\uD2C0\", desc: \"\uC911\uC559 \uB300\uC81C\uBAA9 + \uBD80\uC81C\uBAA9\"},\n {id: \"two-column\", label: \"2\uB2E8 \uBCF8\uBB38\", desc: \"\uC81C\uBAA9 + \uC88C\uC6B0 2\uCEEC\uB7FC \uCE74\uB4DC\"},\n {id: \"comparison\", label: \"\uBE44\uAD50 \uB808\uC774\uC544\uC6C3\", desc: \"Before / After \uB300\uBE44\"},\n {id: \"kpi\", label: \"KPI \uB300\uC2DC\uBCF4\uB4DC\", desc: \"\uD575\uC2EC \uC9C0\uD45C 3\uCE74\uB4DC\"},\n];\n\nexport function appendSlideFromTemplate(unit: DocUnit, template: SlideTemplateId, slideNumber = 1): number {\n if (template === \"title\") {\n return appendSlide(unit, {\n title: `\uD45C\uC9C0 ${slideNumber}`,\n background: \"#1e293b\",\n objects: [\n createShapeNode({kind: \"rectangle\", frame: {x: 84, y: 210, width: 120, height: 10, z: 2}, fill: \"#3b82f6\", stroke: \"#3b82f6\"}),\n createTextBoxNode({text: \"\uD504\uB808\uC820\uD14C\uC774\uC158 \uB300\uC81C\uBAA9\", frame: {x: 84, y: 246, width: 1080, height: 110, z: 10}, bold: true}),\n createTextBoxNode({text: \"\uBD80\uC81C\uBAA9 \uB610\uB294 \uBC1C\uD45C\uC790 \u00B7 \uB0A0\uC9DC\uB97C \uC785\uB825\uD558\uC138\uC694\", frame: {x: 84, y: 374, width: 880, height: 72, z: 11}}),\n ],\n });\n }\n if (template === \"two-column\") {\n return appendSlide(unit, {\n title: `2\uB2E8 \uC2AC\uB77C\uC774\uB4DC ${slideNumber}`,\n background: \"#ffffff\",\n objects: [\n createTextBoxNode({text: \"\uD575\uC2EC \uC544\uC820\uB2E4 \uC694\uC57D\", frame: {x: 80, y: 64, width: 1120, height: 80, z: 10}, bold: true}),\n {\n type: \"shape\",\n attrs: {kind: \"rectangle\", frame: {x: 80, y: 176, width: 540, height: 460, rotation: 0, z: 2}, fill: \"#f8fafc\", stroke: \"#cbd5e1\", label: \"\uC88C\uCE21 \uC139\uC158 \uB0B4\uC6A9\uC744 \uC785\uB825\uD558\uC138\uC694\", shadow: true},\n },\n {\n type: \"shape\",\n attrs: {kind: \"rectangle\", frame: {x: 660, y: 176, width: 540, height: 460, rotation: 0, z: 3}, fill: \"#eff6ff\", stroke: \"#93c5fd\", label: \"\uC6B0\uCE21 \uC139\uC158 \uB0B4\uC6A9\uC744 \uC785\uB825\uD558\uC138\uC694\", shadow: true},\n },\n ],\n });\n }\n if (template === \"comparison\") {\n return appendSlide(unit, {\n title: `\uBE44\uAD50 ${slideNumber}`,\n background: \"#f8fafc\",\n objects: [\n createTextBoxNode({text: \"As-Is vs To-Be \uBE44\uAD50\", frame: {x: 80, y: 58, width: 1120, height: 76, z: 10}, bold: true}),\n {\n type: \"shape\",\n attrs: {kind: \"rectangle\", frame: {x: 80, y: 170, width: 490, height: 450, rotation: 0, z: 2}, fill: \"#fef2f2\", stroke: \"#f87171\", label: \"\uAE30\uC874 \uBC29\uC2DD (As-Is)\\n\u2022 \uC774\uC911 \uC2A4\uD1A0\uC5B4 \uB3D9\uAE30\uD654 \uC9C0\uC5F0\\n\u2022 \uC218\uB3D9 \uC11C\uC2DD \uC791\uC5C5\", shadow: true},\n },\n createShapeNode({kind: \"arrow\", frame: {x: 590, y: 375, width: 100, height: 44, z: 6}, fill: \"#2563eb\", stroke: \"#2563eb\"}),\n {\n type: \"shape\",\n attrs: {kind: \"rectangle\", frame: {x: 710, y: 170, width: 490, height: 450, rotation: 0, z: 3}, fill: \"#ecfdf5\", stroke: \"#10b981\", label: \"DocOffice \uBC29\uC2DD (To-Be)\\n\u2022 \uB2E8\uC77C doc-sync CRDT\\n\u2022 \uC2E4\uC2DC\uAC04 MCP AI \uD611\uC5C5\", shadow: true},\n },\n ],\n });\n }\n if (template === \"kpi\") {\n return appendSlide(unit, {\n title: `KPI ${slideNumber}`,\n background: \"#ffffff\",\n objects: [\n createTextBoxNode({text: \"\uBD84\uAE30 \uD575\uC2EC KPI \uD558\uC774\uB77C\uC774\uD2B8\", frame: {x: 80, y: 64, width: 1120, height: 80, z: 10}, bold: true}),\n {\n type: \"shape\",\n attrs: {kind: \"rectangle\", frame: {x: 80, y: 200, width: 344, height: 340, rotation: 0, z: 2}, fill: \"#eff6ff\", stroke: \"#2563eb\", label: \"\u20A91.45\uC5B5\\nQ4 \uCD1D \uB9E4\uCD9C (+28%)\", shadow: true},\n },\n {\n type: \"shape\",\n attrs: {kind: \"rectangle\", frame: {x: 468, y: 200, width: 344, height: 340, rotation: 0, z: 3}, fill: \"#ecfdf5\", stroke: \"#059669\", label: \"99.98%\\n\uC2E4\uC2DC\uAC04 CRDT \uB3D9\uAE30\uD654\uC728\", shadow: true},\n },\n {\n type: \"shape\",\n attrs: {kind: \"rectangle\", frame: {x: 856, y: 200, width: 344, height: 340, rotation: 0, z: 4}, fill: \"#ede9fe\", stroke: \"#7c3aed\", label: \"3.4x\\nAI \uACF5\uB3D9 \uC800\uC791 \uC0DD\uC0B0\uC131\", shadow: true},\n },\n ],\n });\n }\n return appendSlide(unit, {\n title: `\uC2AC\uB77C\uC774\uB4DC ${slideNumber}`,\n background: \"#ffffff\",\n objects: [createTextBoxNode({text: `\uC2AC\uB77C\uC774\uB4DC ${slideNumber} \uC81C\uBAA9`, frame: {x: 96, y: 80, width: 1088, height: 84, z: 10}, bold: true})],\n });\n}\n\nexport function updateSlideBackground(unit: DocUnit, slideRootIndex: number, background: string): void {\n unit.edit([{op: \"update\", at: [slideRootIndex], attrs: {canvas: {background}}}]);\n}\n\nexport function updateTextBoxContent(unit: DocUnit, objectPath: number[], nextText: string): void {\n const model = unit.readModel();\n const slide = model.children?.[objectPath[0]];\n const box = slide?.children?.[objectPath[1]];\n if (!box || box.type !== \"text-box\") return;\n\n const existingLines = box.children ?? [];\n const edits: EditOp[] = [];\n\n // Remove extra trailing paragraphs beyond the first\n for (let i = existingLines.length - 1; i >= 1; i--) {\n edits.push({op: \"delete\", at: [...objectPath, i], count: 1});\n }\n const firstLen = readNodeText(existingLines[0]).length;\n if (firstLen > 0) {\n edits.push({op: \"delete\", at: [...objectPath, 0, 0], count: firstLen});\n }\n\n const lines = nextText.replace(/\\r\\n/g, \"\\n\").split(\"\\n\");\n for (let i = 0; i < lines.length; i++) {\n if (i > 0) edits.push({op: \"split\", at: [...objectPath, i - 1, lines[i - 1].length]});\n if (lines[i].length > 0) {\n edits.push({op: \"insert\", at: [...objectPath, i, 0], content: lines[i]});\n }\n }\n\n if (edits.length > 0) unit.edit(edits);\n}\n\nexport function updateSlideNotes(unit: DocUnit, slideRootIndex: number, notes: string): void {\n const slide = unit.readModel().children?.[slideRootIndex];\n const children = slide?.children ?? [];\n const notesIdx = children.findIndex(c => c.type === \"speaker-notes\");\n if (notesIdx < 0) return;\n\n const notesNode = children[notesIdx];\n const firstPara = notesNode.children?.[0];\n const currentLen = readNodeText(firstPara).length;\n const edits: EditOp[] = [];\n if (currentLen > 0) edits.push({op: \"delete\", at: [slideRootIndex, notesIdx, 0, 0], count: currentLen});\n if (notes.length > 0) edits.push({op: \"insert\", at: [slideRootIndex, notesIdx, 0, 0], content: notes});\n if (edits.length > 0) unit.edit(edits);\n}\n\nexport function deleteSlideObject(unit: DocUnit, objectPath: number[]): void {\n unit.edit([{op: \"delete\", at: objectPath, count: 1}]);\n}\n\n/**\n * Figma/Keynote-style smart alignment snapping against slide center and sibling object edges.\n */\nexport function snapFrameToGuides(\n moving: {x: number; y: number; width: number; height: number},\n siblings: readonly SlideObjectView[],\n canvasWidth: number,\n canvasHeight: number,\n threshold = 8,\n): SnapResult {\n const targetsX: number[] = [0, canvasWidth / 2, canvasWidth];\n const targetsY: number[] = [0, canvasHeight / 2, canvasHeight];\n\n for (const s of siblings) {\n targetsX.push(s.frame.x, s.frame.x + s.frame.width / 2, s.frame.x + s.frame.width);\n targetsY.push(s.frame.y, s.frame.y + s.frame.height / 2, s.frame.y + s.frame.height);\n }\n\n let snappedX = moving.x;\n let bestDx = threshold + 1;\n const guidesX: number[] = [];\n\n const anchorsX = [\n {offset: 0, pos: moving.x},\n {offset: moving.width / 2, pos: moving.x + moving.width / 2},\n {offset: moving.width, pos: moving.x + moving.width},\n ];\n for (const t of targetsX) {\n for (const a of anchorsX) {\n const dist = Math.abs(a.pos - t);\n if (dist < bestDx) {\n bestDx = dist;\n snappedX = t - a.offset;\n guidesX.length = 0;\n guidesX.push(t);\n }\n }\n }\n\n let snappedY = moving.y;\n let bestDy = threshold + 1;\n const guidesY: number[] = [];\n\n const anchorsY = [\n {offset: 0, pos: moving.y},\n {offset: moving.height / 2, pos: moving.y + moving.height / 2},\n {offset: moving.height, pos: moving.y + moving.height},\n ];\n for (const t of targetsY) {\n for (const a of anchorsY) {\n const dist = Math.abs(a.pos - t);\n if (dist < bestDy) {\n bestDy = dist;\n snappedY = t - a.offset;\n guidesY.length = 0;\n guidesY.push(t);\n }\n }\n }\n\n return {\n x: Math.round(snappedX),\n y: Math.round(snappedY),\n guidesX: bestDx <= threshold ? guidesX : [],\n guidesY: bestDy <= threshold ? guidesY : [],\n };\n}\n", "import type {SlideObjectView, SlideView} from \"./model.js\";\n\nconst CRC32_TABLE = (() => {\n const table = new Uint32Array(256);\n for (let i = 0; i < 256; i++) {\n let c = i;\n for (let k = 0; k < 8; k++) c = (c & 1) !== 0 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n table[i] = c >>> 0;\n }\n return table;\n})();\n\nfunction crc32(bytes: Uint8Array): number {\n let crc = 0xffffffff;\n for (let i = 0; i < bytes.length; i++) crc = CRC32_TABLE[(crc ^ bytes[i]) & 0xff] ^ (crc >>> 8);\n return (crc ^ 0xffffffff) >>> 0;\n}\n\nfunction encodeUtf8(text: string): Uint8Array {\n return new TextEncoder().encode(text);\n}\n\nfunction createZipStore(entries: Array<{name: string; data: Uint8Array}>): Uint8Array {\n const localParts: Uint8Array[] = [];\n const centralParts: Uint8Array[] = [];\n let offset = 0;\n for (const entry of entries) {\n const nameBytes = encodeUtf8(entry.name);\n const data = entry.data;\n const crc = crc32(data);\n const local = new Uint8Array(30 + nameBytes.length + data.length);\n const lv = new DataView(local.buffer);\n lv.setUint32(0, 0x04034b50, true);\n lv.setUint16(4, 20, true);\n lv.setUint16(6, 0x0800, true);\n lv.setUint32(14, crc, true);\n lv.setUint32(18, data.length, true);\n lv.setUint32(22, data.length, true);\n lv.setUint16(26, nameBytes.length, true);\n local.set(nameBytes, 30);\n local.set(data, 30 + nameBytes.length);\n localParts.push(local);\n\n const central = new Uint8Array(46 + nameBytes.length);\n const cv = new DataView(central.buffer);\n cv.setUint32(0, 0x02014b50, true);\n cv.setUint16(4, 20, true);\n cv.setUint16(6, 20, true);\n cv.setUint16(8, 0x0800, true);\n cv.setUint32(16, crc, true);\n cv.setUint32(20, data.length, true);\n cv.setUint32(24, data.length, true);\n cv.setUint16(28, nameBytes.length, true);\n cv.setUint32(42, offset, true);\n central.set(nameBytes, 46);\n centralParts.push(central);\n offset += local.length;\n }\n const centralSize = centralParts.reduce((acc, p) => acc + p.length, 0);\n const eocd = new Uint8Array(22);\n const ev = new DataView(eocd.buffer);\n ev.setUint32(0, 0x06054b50, true);\n ev.setUint16(8, entries.length, true);\n ev.setUint16(10, entries.length, true);\n ev.setUint32(12, centralSize, true);\n ev.setUint32(16, offset, true);\n\n const out = new Uint8Array(offset + centralSize + eocd.length);\n let pos = 0;\n for (const part of localParts) { out.set(part, pos); pos += part.length; }\n for (const part of centralParts) { out.set(part, pos); pos += part.length; }\n out.set(eocd, pos);\n return out;\n}\n\nfunction escapeXml(text: string): string {\n return text.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\").replace(/\"/g, \""\");\n}\n\n// 1280\u00D7720px -> 12192000\u00D76858000 EMU (standard 16:9 PowerPoint widescreen)\nconst PX_TO_EMU = 9525;\n\nfunction hexClean(color: string | undefined, fallback: string): string {\n if (color && /^#[0-9a-fA-F]{6}$/.test(color)) return color.slice(1).toUpperCase();\n return fallback;\n}\n\nfunction shapePresetGeom(kind: SlideObjectView[\"shapeKind\"]): string {\n if (kind === \"ellipse\") return \"ellipse\";\n if (kind === \"diamond\") return \"diamond\";\n if (kind === \"triangle\") return \"triangle\";\n if (kind === \"arrow\") return \"rightArrow\";\n if (kind === \"line\") return \"line\";\n return \"roundRect\";\n}\n\nfunction serializeSlideObjectXml(obj: SlideObjectView, shapeId: number): string {\n if (obj.hidden) return \"\";\n const x = Math.round(obj.frame.x * PX_TO_EMU);\n const y = Math.round(obj.frame.y * PX_TO_EMU);\n const cx = Math.max(9525, Math.round(obj.frame.width * PX_TO_EMU));\n const cy = Math.max(9525, Math.round(obj.frame.height * PX_TO_EMU));\n const rot = Math.round((obj.frame.rotation ?? 0) * 60000);\n const xfrm = `<a:xfrm${rot ? ` rot=\"${rot}\"` : \"\"}><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm>`;\n\n if (obj.type === \"shape\") {\n const fill = hexClean(obj.fill, \"EFF6FF\");\n const stroke = hexClean(obj.stroke, \"2563EB\");\n const strokeW = Math.round((obj.strokeWidth ?? 2) * 12700);\n const lines = (obj.label ?? \"\").split(\"\\n\").filter(Boolean);\n const paras = lines.length > 0\n ? lines.map(l => `<a:p><a:pPr algn=\"ctr\"/><a:r><a:rPr lang=\"ko-KR\" sz=\"1800\" b=\"1\"/><a:t>${escapeXml(l)}</a:t></a:r></a:p>`).join(\"\")\n : \"<a:p/>\";\n return `<p:sp>\n <p:nvSpPr><p:cNvPr id=\"${shapeId}\" name=\"Shape ${shapeId}\"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr>\n <p:spPr>${xfrm}<a:prstGeom prst=\"${shapePresetGeom(obj.shapeKind)}\"><a:avLst/></a:prstGeom><a:solidFill><a:srgbClr val=\"${fill}\"/></a:solidFill><a:ln w=\"${strokeW}\"><a:solidFill><a:srgbClr val=\"${stroke}\"/></a:solidFill></a:ln></p:spPr>\n <p:txBody><a:bodyPr anchor=\"ctr\"/><a:lstStyle/>${paras}</p:txBody>\n</p:sp>`;\n }\n\n const rawText = obj.type === \"image\" ? `[Image: ${obj.alt || \"Image\"}]` : (obj.text ?? \"\");\n const fontSizePt = Math.round((obj.fontSize ?? (obj.frame.y < 180 && obj.frame.width > 500 ? 32 : 18)) * 100);\n const algn = obj.textAlign === \"center\" ? \"ctr\" : obj.textAlign === \"right\" ? \"r\" : \"l\";\n const textColor = hexClean(obj.textColor, \"0F172A\");\n const paras = rawText\n .split(\"\\n\")\n .map(line => `<a:p><a:pPr algn=\"${algn}\"/><a:r><a:rPr lang=\"ko-KR\" sz=\"${fontSizePt}\"><a:solidFill><a:srgbClr val=\"${textColor}\"/></a:solidFill></a:rPr><a:t>${escapeXml(line)}</a:t></a:r></a:p>`)\n .join(\"\");\n return `<p:sp>\n <p:nvSpPr><p:cNvPr id=\"${shapeId}\" name=\"TextBox ${shapeId}\"/><p:cNvSpPr txBox=\"1\"/><p:nvPr/></p:nvSpPr>\n <p:spPr>${xfrm}<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom><a:noFill/></p:spPr>\n <p:txBody><a:bodyPr wrap=\"square\"/><a:lstStyle/>${paras || \"<a:p/>\"}</p:txBody>\n</p:sp>`;\n}\n\n/**\n * Serializes a DocOffice Slide Deck into a valid 16:9 OpenXML `.pptx` PowerPoint archive (Uint8Array).\n */\nexport function slidesToPptxBytes(deck: readonly SlideView[]): Uint8Array {\n const slides = deck.length > 0 ? deck : [];\n const slideOverrides = slides\n .map((_, i) => ` <Override PartName=\"/ppt/slides/slide${i + 1}.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.slide+xml\"/>`)\n .join(\"\\n\");\n\n const contentTypes = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\n <Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>\n <Default Extension=\"xml\" ContentType=\"application/xml\"/>\n <Override PartName=\"/ppt/presentation.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml\"/>\n <Override PartName=\"/ppt/slideLayouts/slideLayout1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml\"/>\n <Override PartName=\"/ppt/slideMasters/slideMaster1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml\"/>\n${slideOverrides}\n</Types>`;\n\n const rootRels = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n <Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\" Target=\"ppt/presentation.xml\"/>\n</Relationships>`;\n\n const presRels = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n <Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster\" Target=\"slideMasters/slideMaster1.xml\"/>\n${slides.map((_, i) => ` <Relationship Id=\"rId${i + 2}\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide\" Target=\"slides/slide${i + 1}.xml\"/>`).join(\"\\n\")}\n</Relationships>`;\n\n const sldIdLst = slides\n .map((_, i) => ` <p:sldId id=\"${256 + i}\" r:id=\"rId${i + 2}\"/>`)\n .join(\"\\n\");\n\n const presentationXml = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<p:presentation xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\">\n <p:sldMasterIdLst><p:sldMasterId id=\"2147483648\" r:id=\"rId1\"/></p:sldMasterIdLst>\n <p:sldIdLst>\n${sldIdLst}\n </p:sldIdLst>\n <p:sldSz cx=\"12192000\" cy=\"6858000\"/>\n <p:notesSz cx=\"6858000\" cy=\"9144000\"/>\n</p:presentation>`;\n\n const slideMasterXml = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<p:sldMaster xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\">\n <p:cSld><p:spTree><p:nvGrpSpPr><p:cNvPr id=\"1\" name=\"\"/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr/></p:spTree></p:cSld>\n <p:sldLayoutIdLst><p:sldLayoutId id=\"2147483649\" r:id=\"rId1\"/></p:sldLayoutIdLst>\n</p:sldMaster>`;\n\n const slideMasterRels = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n <Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout\" Target=\"../slideLayouts/slideLayout1.xml\"/>\n</Relationships>`;\n\n const slideLayoutXml = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<p:sldLayout xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\" type=\"blank\">\n <p:cSld><p:spTree><p:nvGrpSpPr><p:cNvPr id=\"1\" name=\"\"/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr/></p:spTree></p:cSld>\n</p:sldLayout>`;\n\n const slideRelsXml = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n <Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout\" Target=\"../slideLayouts/slideLayout1.xml\"/>\n</Relationships>`;\n\n const entries: Array<{name: string; data: Uint8Array}> = [\n {name: \"[Content_Types].xml\", data: encodeUtf8(contentTypes)},\n {name: \"_rels/.rels\", data: encodeUtf8(rootRels)},\n {name: \"ppt/presentation.xml\", data: encodeUtf8(presentationXml)},\n {name: \"ppt/_rels/presentation.xml.rels\", data: encodeUtf8(presRels)},\n {name: \"ppt/slideMasters/slideMaster1.xml\", data: encodeUtf8(slideMasterXml)},\n {name: \"ppt/slideMasters/_rels/slideMaster1.xml.rels\", data: encodeUtf8(slideMasterRels)},\n {name: \"ppt/slideLayouts/slideLayout1.xml\", data: encodeUtf8(slideLayoutXml)},\n ];\n\n slides.forEach((slide, idx) => {\n const bgHex = hexClean(slide.canvas.background, \"FFFFFF\");\n const shapesXml = slide.objects.map((o, j) => serializeSlideObjectXml(o, j + 2)).join(\"\\n\");\n const slideXml = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<p:sld xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\">\n <p:cSld>\n <p:bg><p:bgPr><a:solidFill><a:srgbClr val=\"${bgHex}\"/></a:solidFill></p:bgPr></p:bg>\n <p:spTree>\n <p:nvGrpSpPr><p:cNvPr id=\"1\" name=\"\"/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>\n <p:grpSpPr/>\n ${shapesXml}\n </p:spTree>\n </p:cSld>\n</p:sld>`;\n entries.push({name: `ppt/slides/slide${idx + 1}.xml`, data: encodeUtf8(slideXml)});\n entries.push({name: `ppt/slides/_rels/slide${idx + 1}.xml.rels`, data: encodeUtf8(slideRelsXml)});\n });\n\n return createZipStore(entries);\n}\n"],
|
|
5
|
+
"mappings": ";AAkEA,SAAS,aAAa,MAAoC;AACtD,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,QAAkB,CAAC;AACzB,MAAI,KAAK,MAAM;AACX,eAAW,KAAK,KAAK,MAAM;AACvB,UAAI,UAAU,EAAG,OAAM,KAAK,EAAE,IAAI;AAAA,IACtC;AAAA,EACJ;AACA,MAAI,KAAK,UAAU;AACf,eAAW,KAAK,KAAK,UAAU;AAC3B,YAAM,IAAI,aAAa,CAAC;AACxB,UAAI,EAAG,OAAM,KAAK,CAAC;AAAA,IACvB;AAAA,EACJ;AACA,SAAO,MAAM,KAAK,IAAI;AAC1B;AAEA,SAAS,UAAU,OAAwD;AACvE,QAAM,MAAO,OAAO,SAAS,CAAC;AAC9B,SAAO;AAAA,IACH,GAAG,OAAO,IAAI,MAAM,WAAW,IAAI,IAAI;AAAA,IACvC,GAAG,OAAO,IAAI,MAAM,WAAW,IAAI,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Y,EAAC,CAAC;AAAA,EACpG,CAAC;AAED,SAAO,eAAe,OAAO;AACjC;",
|
|
6
|
+
"names": ["paras"]
|
|
7
|
+
}
|
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { NodeJSON } from "@barocss/doc-sync";
|
|
2
|
+
import type { DocUnit } from "@barocss/office-core";
|
|
3
|
+
export interface SlideFrame {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
rotation: number;
|
|
9
|
+
z: number;
|
|
10
|
+
}
|
|
11
|
+
export type SlideShapeKind = "rectangle" | "ellipse" | "diamond" | "triangle" | "line" | "arrow";
|
|
12
|
+
export type SlideAlignMode = "left" | "center" | "right" | "top" | "middle" | "bottom" | "distribute-h" | "distribute-v";
|
|
13
|
+
export type SlideTransitionKind = "none" | "fade" | "slide" | "zoom";
|
|
14
|
+
export type SlideTemplateId = "blank" | "title" | "two-column" | "comparison" | "kpi";
|
|
15
|
+
export interface SlideObjectView {
|
|
16
|
+
/** Stable model path inside the DocUnit root (e.g. [slideChildIdx, objChildIdx]). */
|
|
17
|
+
path: number[];
|
|
18
|
+
id: string;
|
|
19
|
+
type: "text-box" | "shape" | "image" | "chart";
|
|
20
|
+
frame: SlideFrame;
|
|
21
|
+
text?: string;
|
|
22
|
+
label?: string;
|
|
23
|
+
fontSize?: number;
|
|
24
|
+
textAlign?: "left" | "center" | "right";
|
|
25
|
+
textColor?: string;
|
|
26
|
+
shapeKind?: SlideShapeKind;
|
|
27
|
+
fill?: string;
|
|
28
|
+
stroke?: string;
|
|
29
|
+
strokeWidth?: number;
|
|
30
|
+
dashed?: boolean;
|
|
31
|
+
shadow?: boolean;
|
|
32
|
+
opacity?: number;
|
|
33
|
+
radius?: number;
|
|
34
|
+
groupId?: string;
|
|
35
|
+
locked?: boolean;
|
|
36
|
+
hidden?: boolean;
|
|
37
|
+
src?: string;
|
|
38
|
+
alt?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface SlideView {
|
|
41
|
+
/** Child index inside office-deck root */
|
|
42
|
+
rootIndex: number;
|
|
43
|
+
slideNumber: number;
|
|
44
|
+
title: string;
|
|
45
|
+
notes: string;
|
|
46
|
+
layout: string;
|
|
47
|
+
transition: SlideTransitionKind;
|
|
48
|
+
canvas: {
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
background: string;
|
|
52
|
+
};
|
|
53
|
+
objects: SlideObjectView[];
|
|
54
|
+
}
|
|
55
|
+
export interface SnapResult {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
guidesX: number[];
|
|
59
|
+
guidesY: number[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Extracts all structured slides and their absolute-positioned objects from a DocUnit("slide").
|
|
63
|
+
*/
|
|
64
|
+
export declare function extractSlideDeck(unit: DocUnit): SlideView[];
|
|
65
|
+
export declare function createSlideNode(options?: {
|
|
66
|
+
title?: string;
|
|
67
|
+
background?: string;
|
|
68
|
+
notes?: string;
|
|
69
|
+
objects?: NodeJSON[];
|
|
70
|
+
}): NodeJSON;
|
|
71
|
+
export declare function createTextBoxNode(options: {
|
|
72
|
+
text: string;
|
|
73
|
+
frame: Partial<SlideFrame>;
|
|
74
|
+
bold?: boolean;
|
|
75
|
+
}): NodeJSON;
|
|
76
|
+
export declare function createShapeNode(options: {
|
|
77
|
+
kind: SlideShapeKind;
|
|
78
|
+
frame: Partial<SlideFrame>;
|
|
79
|
+
fill?: string;
|
|
80
|
+
stroke?: string;
|
|
81
|
+
opacity?: number;
|
|
82
|
+
radius?: number;
|
|
83
|
+
}): NodeJSON;
|
|
84
|
+
export declare function createImageNode(options: {
|
|
85
|
+
src: string;
|
|
86
|
+
alt?: string;
|
|
87
|
+
frame: Partial<SlideFrame>;
|
|
88
|
+
}): NodeJSON;
|
|
89
|
+
/**
|
|
90
|
+
* Appends a new blank (or starter) slide into the DocUnit deck.
|
|
91
|
+
*/
|
|
92
|
+
export declare function appendSlide(unit: DocUnit, options?: {
|
|
93
|
+
title?: string;
|
|
94
|
+
background?: string;
|
|
95
|
+
notes?: string;
|
|
96
|
+
objects?: NodeJSON[];
|
|
97
|
+
}): number;
|
|
98
|
+
export declare function deleteSlide(unit: DocUnit, rootIndex: number): void;
|
|
99
|
+
export declare function addTextBox(unit: DocUnit, slideRootIndex: number, options: {
|
|
100
|
+
text: string;
|
|
101
|
+
frame: Partial<SlideFrame>;
|
|
102
|
+
bold?: boolean;
|
|
103
|
+
}): number[];
|
|
104
|
+
export declare function addShape(unit: DocUnit, slideRootIndex: number, options: {
|
|
105
|
+
kind: SlideShapeKind;
|
|
106
|
+
frame: Partial<SlideFrame>;
|
|
107
|
+
fill?: string;
|
|
108
|
+
stroke?: string;
|
|
109
|
+
opacity?: number;
|
|
110
|
+
radius?: number;
|
|
111
|
+
}): number[];
|
|
112
|
+
export declare function addImage(unit: DocUnit, slideRootIndex: number, options: {
|
|
113
|
+
src: string;
|
|
114
|
+
alt?: string;
|
|
115
|
+
frame: Partial<SlideFrame>;
|
|
116
|
+
}): number[];
|
|
117
|
+
export declare function duplicateSlide(unit: DocUnit, slideRootIndex: number): number;
|
|
118
|
+
export declare function cloneSlideObjectNodes(unit: DocUnit, objectPaths: readonly number[][], offsetPx?: number): NodeJSON[];
|
|
119
|
+
export declare function pasteSlideObjectNodes(unit: DocUnit, slideRootIndex: number, nodes: readonly NodeJSON[]): number[][];
|
|
120
|
+
export declare function duplicateSlideObjects(unit: DocUnit, slideRootIndex: number, objectPaths: readonly number[][]): number[][];
|
|
121
|
+
export declare function deleteSlideObjects(unit: DocUnit, objectPaths: readonly number[][]): void;
|
|
122
|
+
export declare function updateTextBoxStyle(unit: DocUnit, objectPath: number[], style: {
|
|
123
|
+
fontSize?: number;
|
|
124
|
+
textAlign?: "left" | "center" | "right";
|
|
125
|
+
textColor?: string;
|
|
126
|
+
}): void;
|
|
127
|
+
export declare function alignObjects(unit: DocUnit, objects: readonly SlideObjectView[], mode: SlideAlignMode, canvasWidth?: number, canvasHeight?: number): void;
|
|
128
|
+
export declare function bringToFront(unit: DocUnit, target: SlideObjectView, allObjects: readonly SlideObjectView[]): void;
|
|
129
|
+
export declare function sendToBack(unit: DocUnit, target: SlideObjectView, allObjects: readonly SlideObjectView[]): void;
|
|
130
|
+
export declare function updateObjectFrame(unit: DocUnit, objectPath: number[], patch: Partial<SlideFrame>): void;
|
|
131
|
+
export declare function updateShapeStyle(unit: DocUnit, objectPath: number[], style: {
|
|
132
|
+
label?: string;
|
|
133
|
+
fill?: string;
|
|
134
|
+
stroke?: string;
|
|
135
|
+
strokeWidth?: number;
|
|
136
|
+
dashed?: boolean;
|
|
137
|
+
shadow?: boolean;
|
|
138
|
+
opacity?: number;
|
|
139
|
+
radius?: number;
|
|
140
|
+
}): void;
|
|
141
|
+
export declare function updateObjectMeta(unit: DocUnit, objectPath: number[], meta: {
|
|
142
|
+
locked?: boolean;
|
|
143
|
+
hidden?: boolean;
|
|
144
|
+
groupId?: string;
|
|
145
|
+
shadow?: boolean;
|
|
146
|
+
}): void;
|
|
147
|
+
export declare function groupSlideObjects(unit: DocUnit, objects: readonly SlideObjectView[]): string;
|
|
148
|
+
export declare function ungroupSlideObjects(unit: DocUnit, objects: readonly SlideObjectView[]): void;
|
|
149
|
+
export declare function reorderSlide(unit: DocUnit, fromRootIndex: number, toRootIndex: number): void;
|
|
150
|
+
export declare function updateSlideTransition(unit: DocUnit, slideRootIndex: number, transition: SlideTransitionKind): void;
|
|
151
|
+
export declare const SLIDE_LAYOUT_TEMPLATES: ReadonlyArray<{
|
|
152
|
+
id: SlideTemplateId;
|
|
153
|
+
label: string;
|
|
154
|
+
desc: string;
|
|
155
|
+
}>;
|
|
156
|
+
export declare function appendSlideFromTemplate(unit: DocUnit, template: SlideTemplateId, slideNumber?: number): number;
|
|
157
|
+
export declare function updateSlideBackground(unit: DocUnit, slideRootIndex: number, background: string): void;
|
|
158
|
+
export declare function updateTextBoxContent(unit: DocUnit, objectPath: number[], nextText: string): void;
|
|
159
|
+
export declare function updateSlideNotes(unit: DocUnit, slideRootIndex: number, notes: string): void;
|
|
160
|
+
export declare function deleteSlideObject(unit: DocUnit, objectPath: number[]): void;
|
|
161
|
+
/**
|
|
162
|
+
* Figma/Keynote-style smart alignment snapping against slide center and sibling object edges.
|
|
163
|
+
*/
|
|
164
|
+
export declare function snapFrameToGuides(moving: {
|
|
165
|
+
x: number;
|
|
166
|
+
y: number;
|
|
167
|
+
width: number;
|
|
168
|
+
height: number;
|
|
169
|
+
}, siblings: readonly SlideObjectView[], canvasWidth: number, canvasHeight: number, threshold?: number): SnapResult;
|
package/dist/pptx.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barocss/office-slide",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "node --test test/*.test.ts",
|
|
14
|
+
"prepack": "node ../../scripts/build-packages.mjs view-slide"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@barocss/doc-sync": "^0.1.0",
|
|
18
|
+
"@barocss/office-core": "^0.1.1"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"description": "Slide document model, templates, alignment, and PPTX export.",
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22.18"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md",
|
|
30
|
+
"CHANGELOG.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/barocss/office.git",
|
|
39
|
+
"directory": "packages/view-slide"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/barocss/office#readme",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/barocss/office/issues"
|
|
44
|
+
}
|
|
45
|
+
}
|