@vanduo-oss/vd3-cbun 1.3.0 → 1.3.2
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 +27 -0
- package/README.md +5 -4
- package/dist/draw/core.d.ts +3 -0
- package/dist/draw/index.cjs +44 -5
- package/dist/draw/index.cjs.map +3 -3
- package/dist/draw/index.js +44 -5
- package/dist/draw/index.js.map +3 -3
- package/dist/draw/vue.d.ts +12 -0
- package/dist/flowchart/index.cjs +103 -68
- package/dist/flowchart/index.cjs.map +2 -2
- package/dist/flowchart/index.js +103 -68
- package/dist/flowchart/index.js.map +2 -2
- package/dist/flowchart/vd3-flowchart.css +176 -47
- package/dist/meta.json +20 -20
- package/package.json +1 -1
package/dist/draw/index.js
CHANGED
|
@@ -216,8 +216,31 @@ function resizeHandlePositions(bounds) {
|
|
|
216
216
|
{ key: "w", x, y: my }
|
|
217
217
|
];
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function pointsToCatmullRomPath(points) {
|
|
220
|
+
const pts = points.map((p) => [Number(p[0]), Number(p[1])]);
|
|
221
|
+
if (pts.length < 3) {
|
|
222
|
+
const [first, ...rest] = pts;
|
|
223
|
+
let d2 = `M ${round(first[0])} ${round(first[1])}`;
|
|
224
|
+
for (const [px, py] of rest) d2 += ` L ${round(px)} ${round(py)}`;
|
|
225
|
+
return d2;
|
|
226
|
+
}
|
|
227
|
+
let d = `M ${round(pts[0][0])} ${round(pts[0][1])}`;
|
|
228
|
+
for (let i = 0; i < pts.length - 1; i += 1) {
|
|
229
|
+
const p0 = pts[i === 0 ? i : i - 1];
|
|
230
|
+
const p1 = pts[i];
|
|
231
|
+
const p2 = pts[i + 1];
|
|
232
|
+
const p3 = pts[i + 2 < pts.length ? i + 2 : i + 1];
|
|
233
|
+
const c1x = p1[0] + (p2[0] - p0[0]) / 6;
|
|
234
|
+
const c1y = p1[1] + (p2[1] - p0[1]) / 6;
|
|
235
|
+
const c2x = p2[0] - (p3[0] - p1[0]) / 6;
|
|
236
|
+
const c2y = p2[1] - (p3[1] - p1[1]) / 6;
|
|
237
|
+
d += ` C ${round(c1x)} ${round(c1y)} ${round(c2x)} ${round(c2y)} ${round(p2[0])} ${round(p2[1])}`;
|
|
238
|
+
}
|
|
239
|
+
return d;
|
|
240
|
+
}
|
|
241
|
+
function pointsToPath(points, options = {}) {
|
|
220
242
|
if (!points || !points.length) return "";
|
|
243
|
+
if (options.smooth && points.length >= 3) return pointsToCatmullRomPath(points);
|
|
221
244
|
const [first, ...rest] = points;
|
|
222
245
|
let d = `M ${round(first[0])} ${round(first[1])}`;
|
|
223
246
|
for (const [px, py] of rest) d += ` L ${round(px)} ${round(py)}`;
|
|
@@ -396,7 +419,8 @@ function normalizeShape(raw, usedIds) {
|
|
|
396
419
|
...base,
|
|
397
420
|
points,
|
|
398
421
|
arrowStart: Boolean(raw.arrowStart),
|
|
399
|
-
arrowEnd: raw.arrowEnd == null ? true : Boolean(raw.arrowEnd)
|
|
422
|
+
arrowEnd: raw.arrowEnd == null ? true : Boolean(raw.arrowEnd),
|
|
423
|
+
smooth: Boolean(raw.smooth)
|
|
400
424
|
};
|
|
401
425
|
}
|
|
402
426
|
const shape = {
|
|
@@ -1021,6 +1045,9 @@ var VdDraw = class {
|
|
|
1021
1045
|
getShape(id) {
|
|
1022
1046
|
return this.documentData.shapes.find((s) => s.id === id) || null;
|
|
1023
1047
|
}
|
|
1048
|
+
getShapes() {
|
|
1049
|
+
return this.documentData.shapes.map((s) => deepClone(s));
|
|
1050
|
+
}
|
|
1024
1051
|
addShape(partial = {}) {
|
|
1025
1052
|
const type = DRAW_SHAPE_TYPES.includes(partial.type) ? partial.type : "rectangle";
|
|
1026
1053
|
const s = this.style;
|
|
@@ -1046,7 +1073,9 @@ var VdDraw = class {
|
|
|
1046
1073
|
strokeWidth: partial.strokeWidth == null ? this._shapeStrokeWidth() : partial.strokeWidth,
|
|
1047
1074
|
opacity: partial.opacity == null ? s.opacity : partial.opacity,
|
|
1048
1075
|
arrowStart: Boolean(partial.arrowStart),
|
|
1049
|
-
arrowEnd: partial.arrowEnd == null ? true : Boolean(partial.arrowEnd)
|
|
1076
|
+
arrowEnd: partial.arrowEnd == null ? true : Boolean(partial.arrowEnd),
|
|
1077
|
+
// AI-authored multi-point curves set smooth:true; interactive 2-pt lines stay sharp.
|
|
1078
|
+
smooth: partial.smooth == null ? false : Boolean(partial.smooth)
|
|
1050
1079
|
};
|
|
1051
1080
|
} else {
|
|
1052
1081
|
shape = {
|
|
@@ -1999,7 +2028,9 @@ var VdDraw = class {
|
|
|
1999
2028
|
this._applyShapeStroke(el, shape, standalone, colors);
|
|
2000
2029
|
setOpacity(el);
|
|
2001
2030
|
} else if (shape.type === "line") {
|
|
2002
|
-
el = createSvgEl("path", {
|
|
2031
|
+
el = createSvgEl("path", {
|
|
2032
|
+
d: pointsToPath(shape.points, { smooth: Boolean(shape.smooth) })
|
|
2033
|
+
});
|
|
2003
2034
|
el.classList.add("vd-draw-shape");
|
|
2004
2035
|
this._applyShapeStroke(el, shape, standalone, colors);
|
|
2005
2036
|
setOpacity(el);
|
|
@@ -2209,7 +2240,15 @@ var VdDraw2 = defineComponent({
|
|
|
2209
2240
|
canUndo: () => Boolean(instance?.canUndo()),
|
|
2210
2241
|
canRedo: () => Boolean(instance?.canRedo()),
|
|
2211
2242
|
toSVG: () => instance?.toSVG(),
|
|
2212
|
-
toPNG: (options) => instance?.toPNG(options)
|
|
2243
|
+
toPNG: (options) => instance?.toPNG(options),
|
|
2244
|
+
addShape: (partial) => instance?.addShape(partial),
|
|
2245
|
+
updateShape: (id, patch, options) => instance?.updateShape(id, patch, options),
|
|
2246
|
+
removeShape: (id) => instance?.removeShape(id),
|
|
2247
|
+
getShape: (id) => instance?.getShape(id),
|
|
2248
|
+
getShapes: () => instance?.getShapes(),
|
|
2249
|
+
clear: () => instance?.clear(),
|
|
2250
|
+
load: (data) => instance?.load(data),
|
|
2251
|
+
toJSON: () => instance?.toJSON()
|
|
2213
2252
|
});
|
|
2214
2253
|
return () => h("div", { ref: el, class: "vd-draw" });
|
|
2215
2254
|
}
|