sketchmark 0.2.0 → 0.2.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/dist/animation/index.d.ts +2 -1
- package/dist/animation/index.d.ts.map +1 -1
- package/dist/index.cjs +102 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +102 -26
- package/dist/index.js.map +1 -1
- package/dist/sketchmark.iife.js +102 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6397,6 +6397,7 @@ const getEdgeEl = (svg, f, t) => getEl(svg, `edge-${f}-${t}`);
|
|
|
6397
6397
|
const getTableEl = (svg, id) => getEl(svg, `table-${id}`);
|
|
6398
6398
|
const getNoteEl = (svg, id) => getEl(svg, `note-${id}`);
|
|
6399
6399
|
const getChartEl = (svg, id) => getEl(svg, `chart-${id}`);
|
|
6400
|
+
const getMarkdownEl = (svg, id) => getEl(svg, `markdown-${id}`);
|
|
6400
6401
|
function resolveEl(svg, target) {
|
|
6401
6402
|
// check edge first — target contains connector like "a-->b"
|
|
6402
6403
|
const edge = parseEdgeTarget(target);
|
|
@@ -6408,6 +6409,7 @@ function resolveEl(svg, target) {
|
|
|
6408
6409
|
getTableEl(svg, target) ??
|
|
6409
6410
|
getNoteEl(svg, target) ??
|
|
6410
6411
|
getChartEl(svg, target) ??
|
|
6412
|
+
getMarkdownEl(svg, target) ??
|
|
6411
6413
|
null);
|
|
6412
6414
|
}
|
|
6413
6415
|
function pathLength(p) {
|
|
@@ -6418,6 +6420,15 @@ function pathLength(p) {
|
|
|
6418
6420
|
return 200;
|
|
6419
6421
|
}
|
|
6420
6422
|
}
|
|
6423
|
+
function clearDashOverridesAfter(el, delayMs) {
|
|
6424
|
+
setTimeout(() => {
|
|
6425
|
+
el.querySelectorAll('path').forEach(p => {
|
|
6426
|
+
p.style.strokeDasharray = '';
|
|
6427
|
+
p.style.strokeDashoffset = '';
|
|
6428
|
+
p.style.transition = '';
|
|
6429
|
+
});
|
|
6430
|
+
}, delayMs);
|
|
6431
|
+
}
|
|
6421
6432
|
// ── Arrow connector parser ────────────────────────────────
|
|
6422
6433
|
const ARROW_CONNECTORS = ["<-->", "<->", "-->", "<--", "->", "<-", "---", "--"];
|
|
6423
6434
|
function parseEdgeTarget(target) {
|
|
@@ -6525,32 +6536,39 @@ function clearEdgeDrawStyles(el) {
|
|
|
6525
6536
|
});
|
|
6526
6537
|
}
|
|
6527
6538
|
function animateEdgeDraw(el, conn) {
|
|
6528
|
-
const paths = Array.from(el.querySelectorAll(
|
|
6539
|
+
const paths = Array.from(el.querySelectorAll('path'));
|
|
6529
6540
|
if (!paths.length)
|
|
6530
6541
|
return;
|
|
6531
6542
|
const linePath = paths[0];
|
|
6532
6543
|
const headPaths = paths.slice(1);
|
|
6533
6544
|
const STROKE_DUR = 360;
|
|
6534
6545
|
const len = pathLength(linePath);
|
|
6535
|
-
const reversed = conn.startsWith(
|
|
6546
|
+
const reversed = conn.startsWith('<') && !conn.includes('>');
|
|
6536
6547
|
linePath.style.strokeDasharray = `${len}`;
|
|
6537
6548
|
linePath.style.strokeDashoffset = reversed ? `${-len}` : `${len}`;
|
|
6538
|
-
linePath.style.transition =
|
|
6539
|
-
headPaths.forEach(
|
|
6540
|
-
p.style.opacity =
|
|
6541
|
-
p.style.transition =
|
|
6549
|
+
linePath.style.transition = 'none';
|
|
6550
|
+
headPaths.forEach(p => {
|
|
6551
|
+
p.style.opacity = '0';
|
|
6552
|
+
p.style.transition = 'none';
|
|
6542
6553
|
});
|
|
6543
|
-
el.classList.remove(
|
|
6544
|
-
el.classList.add(
|
|
6545
|
-
el.style.opacity =
|
|
6554
|
+
el.classList.remove('draw-hidden');
|
|
6555
|
+
el.classList.add('draw-reveal');
|
|
6556
|
+
el.style.opacity = '1';
|
|
6546
6557
|
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
6547
6558
|
linePath.style.transition = `stroke-dashoffset ${STROKE_DUR}ms cubic-bezier(.4,0,.2,1)`;
|
|
6548
|
-
linePath.style.strokeDashoffset =
|
|
6559
|
+
linePath.style.strokeDashoffset = '0';
|
|
6549
6560
|
setTimeout(() => {
|
|
6550
|
-
headPaths.forEach(
|
|
6551
|
-
p.style.transition =
|
|
6552
|
-
p.style.opacity =
|
|
6561
|
+
headPaths.forEach(p => {
|
|
6562
|
+
p.style.transition = 'opacity 120ms ease';
|
|
6563
|
+
p.style.opacity = '1';
|
|
6553
6564
|
});
|
|
6565
|
+
// ── ADD: clear inline dash overrides so SVG attribute
|
|
6566
|
+
// (stroke-dasharray="6,5" for dashed arrows) takes over again
|
|
6567
|
+
setTimeout(() => {
|
|
6568
|
+
linePath.style.strokeDasharray = '';
|
|
6569
|
+
linePath.style.strokeDashoffset = '';
|
|
6570
|
+
linePath.style.transition = '';
|
|
6571
|
+
}, 160);
|
|
6554
6572
|
}, STROKE_DUR - 40);
|
|
6555
6573
|
}));
|
|
6556
6574
|
}
|
|
@@ -6574,6 +6592,7 @@ class AnimationController {
|
|
|
6574
6592
|
this.drawTargetTables = new Set();
|
|
6575
6593
|
this.drawTargetNotes = new Set();
|
|
6576
6594
|
this.drawTargetCharts = new Set();
|
|
6595
|
+
this.drawTargetMarkdowns = new Set();
|
|
6577
6596
|
for (const s of steps) {
|
|
6578
6597
|
if (s.action !== "draw" || parseEdgeTarget(s.target))
|
|
6579
6598
|
continue;
|
|
@@ -6594,6 +6613,10 @@ class AnimationController {
|
|
|
6594
6613
|
this.drawTargetCharts.add(`chart-${s.target}`);
|
|
6595
6614
|
this.drawTargetNodes.delete(`node-${s.target}`);
|
|
6596
6615
|
}
|
|
6616
|
+
if (svg.querySelector(`#markdown-${s.target}`)) {
|
|
6617
|
+
this.drawTargetMarkdowns.add(`markdown-${s.target}`);
|
|
6618
|
+
this.drawTargetNodes.delete(`node-${s.target}`);
|
|
6619
|
+
}
|
|
6597
6620
|
}
|
|
6598
6621
|
this._clearAll();
|
|
6599
6622
|
}
|
|
@@ -6765,7 +6788,24 @@ class AnimationController {
|
|
|
6765
6788
|
});
|
|
6766
6789
|
}
|
|
6767
6790
|
});
|
|
6768
|
-
|
|
6791
|
+
// Markdown
|
|
6792
|
+
this.svg.querySelectorAll(".mdg").forEach((el) => {
|
|
6793
|
+
clearDrawStyles(el);
|
|
6794
|
+
el.style.transition = "none";
|
|
6795
|
+
el.style.opacity = "";
|
|
6796
|
+
if (this.drawTargetMarkdowns.has(el.id)) {
|
|
6797
|
+
el.classList.add("gg-hidden");
|
|
6798
|
+
}
|
|
6799
|
+
else {
|
|
6800
|
+
el.classList.remove("gg-hidden");
|
|
6801
|
+
requestAnimationFrame(() => {
|
|
6802
|
+
el.style.transition = "";
|
|
6803
|
+
});
|
|
6804
|
+
}
|
|
6805
|
+
});
|
|
6806
|
+
this.svg
|
|
6807
|
+
.querySelectorAll(".tg, .ntg, .cg, .mdg")
|
|
6808
|
+
.forEach((el) => {
|
|
6769
6809
|
el.style.transform = "";
|
|
6770
6810
|
el.style.transition = "";
|
|
6771
6811
|
el.style.opacity = "";
|
|
@@ -6943,6 +6983,9 @@ class AnimationController {
|
|
|
6943
6983
|
if (!firstPath?.style.strokeDasharray)
|
|
6944
6984
|
prepareForDraw(groupEl);
|
|
6945
6985
|
animateShapeDraw(groupEl, 550, 40);
|
|
6986
|
+
const pathCount = groupEl.querySelectorAll('path').length;
|
|
6987
|
+
const totalMs = pathCount * 40 + 550 + 120; // stagger + duration + buffer
|
|
6988
|
+
clearDashOverridesAfter(groupEl, totalMs);
|
|
6946
6989
|
}
|
|
6947
6990
|
return;
|
|
6948
6991
|
}
|
|
@@ -6963,6 +7006,8 @@ class AnimationController {
|
|
|
6963
7006
|
tableEl.classList.remove("gg-hidden");
|
|
6964
7007
|
prepareForDraw(tableEl);
|
|
6965
7008
|
animateShapeDraw(tableEl, 500, 40);
|
|
7009
|
+
const tablePathCount = tableEl.querySelectorAll('path').length;
|
|
7010
|
+
clearDashOverridesAfter(tableEl, tablePathCount * 40 + 500 + 120);
|
|
6966
7011
|
}
|
|
6967
7012
|
return;
|
|
6968
7013
|
}
|
|
@@ -6983,6 +7028,8 @@ class AnimationController {
|
|
|
6983
7028
|
noteEl.classList.remove("gg-hidden");
|
|
6984
7029
|
prepareForDraw(noteEl);
|
|
6985
7030
|
animateShapeDraw(noteEl, 420, 55);
|
|
7031
|
+
const notePathCount = noteEl.querySelectorAll('path').length;
|
|
7032
|
+
clearDashOverridesAfter(noteEl, notePathCount * 55 + 420 + 120);
|
|
6986
7033
|
}
|
|
6987
7034
|
return;
|
|
6988
7035
|
}
|
|
@@ -7010,6 +7057,28 @@ class AnimationController {
|
|
|
7010
7057
|
}
|
|
7011
7058
|
return;
|
|
7012
7059
|
}
|
|
7060
|
+
// ── Markdown ──────────────────────────────────────────
|
|
7061
|
+
const markdownEl = getMarkdownEl(this.svg, target);
|
|
7062
|
+
if (markdownEl) {
|
|
7063
|
+
if (silent) {
|
|
7064
|
+
markdownEl.style.transition = "none";
|
|
7065
|
+
markdownEl.style.opacity = "";
|
|
7066
|
+
markdownEl.classList.remove("gg-hidden");
|
|
7067
|
+
markdownEl.style.opacity = "1";
|
|
7068
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
7069
|
+
markdownEl.style.transition = "";
|
|
7070
|
+
}));
|
|
7071
|
+
}
|
|
7072
|
+
else {
|
|
7073
|
+
markdownEl.style.opacity = "0";
|
|
7074
|
+
markdownEl.classList.remove("gg-hidden");
|
|
7075
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
7076
|
+
markdownEl.style.transition = "opacity 500ms ease";
|
|
7077
|
+
markdownEl.style.opacity = "1";
|
|
7078
|
+
}));
|
|
7079
|
+
}
|
|
7080
|
+
return;
|
|
7081
|
+
}
|
|
7013
7082
|
// ── Node draw ──────────────────────────────────────
|
|
7014
7083
|
const nodeEl = getNodeEl(this.svg, target);
|
|
7015
7084
|
if (!nodeEl)
|
|
@@ -7023,14 +7092,16 @@ class AnimationController {
|
|
|
7023
7092
|
if (!firstPath?.style.strokeDasharray)
|
|
7024
7093
|
prepareForDraw(nodeEl);
|
|
7025
7094
|
animateShapeDraw(nodeEl, 420, 55);
|
|
7095
|
+
const nodePathCount = nodeEl.querySelectorAll('path').length;
|
|
7096
|
+
clearDashOverridesAfter(nodeEl, nodePathCount * 55 + 420 + 120);
|
|
7026
7097
|
}
|
|
7027
7098
|
}
|
|
7028
7099
|
// ── erase ─────────────────────────────────────────────────
|
|
7029
7100
|
_doErase(target) {
|
|
7030
7101
|
const el = resolveEl(this.svg, target); // handles edges too now
|
|
7031
7102
|
if (el) {
|
|
7032
|
-
el.style.transition =
|
|
7033
|
-
el.style.opacity =
|
|
7103
|
+
el.style.transition = "opacity 0.4s";
|
|
7104
|
+
el.style.opacity = "0";
|
|
7034
7105
|
}
|
|
7035
7106
|
}
|
|
7036
7107
|
// ── show / hide ───────────────────────────────────────────
|
|
@@ -7058,10 +7129,10 @@ class AnimationController {
|
|
|
7058
7129
|
return;
|
|
7059
7130
|
// edge — color stroke
|
|
7060
7131
|
if (parseEdgeTarget(target)) {
|
|
7061
|
-
el.querySelectorAll(
|
|
7132
|
+
el.querySelectorAll("path, line, polyline").forEach((p) => {
|
|
7062
7133
|
p.style.stroke = color;
|
|
7063
7134
|
});
|
|
7064
|
-
el.querySelectorAll(
|
|
7135
|
+
el.querySelectorAll("polygon").forEach((p) => {
|
|
7065
7136
|
p.style.fill = color;
|
|
7066
7137
|
p.style.stroke = color;
|
|
7067
7138
|
});
|
|
@@ -7069,22 +7140,24 @@ class AnimationController {
|
|
|
7069
7140
|
}
|
|
7070
7141
|
// everything else — color fill
|
|
7071
7142
|
let hit = false;
|
|
7072
|
-
el.querySelectorAll(
|
|
7073
|
-
const attrFill = c.getAttribute(
|
|
7074
|
-
if (attrFill ===
|
|
7143
|
+
el.querySelectorAll("path, rect, ellipse, polygon").forEach((c) => {
|
|
7144
|
+
const attrFill = c.getAttribute("fill");
|
|
7145
|
+
if (attrFill === "none")
|
|
7075
7146
|
return;
|
|
7076
|
-
if (attrFill === null && c.tagName ===
|
|
7147
|
+
if (attrFill === null && c.tagName === "path")
|
|
7077
7148
|
return;
|
|
7078
7149
|
c.style.fill = color;
|
|
7079
7150
|
hit = true;
|
|
7080
7151
|
});
|
|
7081
7152
|
if (!hit) {
|
|
7082
|
-
el.querySelectorAll(
|
|
7153
|
+
el.querySelectorAll("text").forEach((t) => {
|
|
7154
|
+
t.style.fill = color;
|
|
7155
|
+
});
|
|
7083
7156
|
}
|
|
7084
7157
|
}
|
|
7085
7158
|
}
|
|
7086
7159
|
const ANIMATION_CSS = `
|
|
7087
|
-
.ng, .gg, .tg, .ntg, .cg, .eg {
|
|
7160
|
+
.ng, .gg, .tg, .ntg, .cg, .eg, .mdg {
|
|
7088
7161
|
transform-box: fill-box;
|
|
7089
7162
|
transform-origin: center;
|
|
7090
7163
|
transition: filter 0.3s, opacity 0.35s;
|
|
@@ -7095,9 +7168,10 @@ const ANIMATION_CSS = `
|
|
|
7095
7168
|
.tg.hl path, .tg.hl rect,
|
|
7096
7169
|
.ntg.hl path, .ntg.hl polygon,
|
|
7097
7170
|
.cg.hl path, .cg.hl rect,
|
|
7171
|
+
.mdg.hl text,
|
|
7098
7172
|
.eg.hl path, .eg.hl line, .eg.hl polygon { stroke-width: 2.8 !important; }
|
|
7099
7173
|
|
|
7100
|
-
.ng.hl, .tg.hl, .ntg.hl, .cg.hl, .eg.hl {
|
|
7174
|
+
.ng.hl, .tg.hl, .ntg.hl, .cg.hl, .mdg.hl, .eg.hl {
|
|
7101
7175
|
animation: ng-pulse 1.4s ease-in-out infinite;
|
|
7102
7176
|
}
|
|
7103
7177
|
@keyframes ng-pulse {
|
|
@@ -7106,7 +7180,8 @@ const ANIMATION_CSS = `
|
|
|
7106
7180
|
}
|
|
7107
7181
|
|
|
7108
7182
|
/* fade */
|
|
7109
|
-
.ng.faded, .gg.faded, .tg.faded, .ntg.faded,
|
|
7183
|
+
.ng.faded, .gg.faded, .tg.faded, .ntg.faded,
|
|
7184
|
+
.cg.faded, .eg.faded, .mdg.faded { opacity: 0.22; }
|
|
7110
7185
|
|
|
7111
7186
|
.ng.hidden { opacity: 0; pointer-events: none; }
|
|
7112
7187
|
.eg.draw-hidden { opacity: 0; }
|
|
@@ -7115,6 +7190,7 @@ const ANIMATION_CSS = `
|
|
|
7115
7190
|
.tg.gg-hidden { opacity: 0; }
|
|
7116
7191
|
.ntg.gg-hidden { opacity: 0; }
|
|
7117
7192
|
.cg.gg-hidden { opacity: 0; }
|
|
7193
|
+
.mdg.gg-hidden { opacity: 0; }
|
|
7118
7194
|
`;
|
|
7119
7195
|
|
|
7120
7196
|
// ============================================================
|