@lark-apaas/coding-registry-buildless 0.1.25-alpha.20260922061823 → 0.1.25
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/components/design-canvas.jsx +8 -47
- package/package.json +1 -1
- package/scripts/deck-stage.js +93 -2
- package/scripts/design-canvas.js +3 -105
|
@@ -96,17 +96,6 @@ function dcFitTransformToBounds(bounds, vp, minScale, maxScale) {
|
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
function dcPresentationSectionAtViewport(vp) {
|
|
100
|
-
if (!vp) return null;
|
|
101
|
-
const top = vp.getBoundingClientRect().top;
|
|
102
|
-
let current = null, distance = Infinity;
|
|
103
|
-
vp.querySelectorAll('[data-dc-section]').forEach((el) => {
|
|
104
|
-
const delta = Math.abs(el.getBoundingClientRect().top - top);
|
|
105
|
-
if (delta < distance) { current = el.dataset.dcSection || null; distance = delta; }
|
|
106
|
-
});
|
|
107
|
-
return current;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
99
|
// ── Mirror sync singleton ──────────────────────────────────────────────────
|
|
111
100
|
// Shared by every buildless script on the page (first one to load defines
|
|
112
101
|
// it). Inlined per script rather than shipped as its own registry file:
|
|
@@ -527,22 +516,15 @@ function DesignCanvas({ children, minScale, maxScale, style }) {
|
|
|
527
516
|
};
|
|
528
517
|
});
|
|
529
518
|
|
|
530
|
-
const [presentationMode, setPresentationMode] = React.useState(false);
|
|
531
|
-
const [presentationSectionId, setPresentationSectionId] = React.useState(null);
|
|
532
|
-
|
|
533
519
|
const api = React.useMemo(() => ({
|
|
534
520
|
state,
|
|
535
|
-
presentationMode,
|
|
536
|
-
setPresentationMode,
|
|
537
|
-
presentationSectionId,
|
|
538
|
-
setPresentationSectionId,
|
|
539
521
|
section: (id) => state.sections[id] || {},
|
|
540
522
|
patchSection: (id, p) => setState((s) => ({
|
|
541
523
|
...s,
|
|
542
524
|
sections: { ...s.sections, [id]: { ...s.sections[id], ...(typeof p === 'function' ? p(s.sections[id] || {}) : p) } },
|
|
543
525
|
})),
|
|
544
526
|
setFocus: (slotId) => setState((s) => ({ ...s, focus: slotId })),
|
|
545
|
-
}), [state
|
|
527
|
+
}), [state]);
|
|
546
528
|
|
|
547
529
|
// Esc exits focus; any outside pointerdown commits an in-progress rename.
|
|
548
530
|
React.useEffect(() => {
|
|
@@ -568,12 +550,6 @@ function DesignCanvas({ children, minScale, maxScale, style }) {
|
|
|
568
550
|
return (
|
|
569
551
|
<DCCtx.Provider value={api}>
|
|
570
552
|
<DCViewport minScale={minScale} maxScale={maxScale} style={style}>{ready && worldChildren}</DCViewport>
|
|
571
|
-
{presentationMode && sectionMeta[presentationSectionId || sectionOrder[0]] && (
|
|
572
|
-
<div data-dc-presentation-title style={{ position: 'fixed', top: 16, left: 20, zIndex: 60, pointerEvents: 'none', fontFamily: DC.font }}>
|
|
573
|
-
<div style={{ fontSize: 16, fontWeight: 600, color: DC.title }}>{sectionMeta[presentationSectionId || sectionOrder[0]].title}</div>
|
|
574
|
-
{sectionMeta[presentationSectionId || sectionOrder[0]].subtitle && <div style={{ marginTop: 2, fontSize: 12, color: DC.subtitle }}>{sectionMeta[presentationSectionId || sectionOrder[0]].subtitle}</div>}
|
|
575
|
-
</div>
|
|
576
|
-
)}
|
|
577
553
|
{ready && overlayChildren}
|
|
578
554
|
{state.focus && registry[state.focus] && (
|
|
579
555
|
<DCFocusOverlay entry={registry[state.focus]} sectionMeta={sectionMeta} sectionOrder={sectionOrder} />
|
|
@@ -684,8 +660,6 @@ function DCZoomControl({ scalePct, minScale, maxScale, onZoomTo }) {
|
|
|
684
660
|
// keeps pans at 60fps on dense canvases.
|
|
685
661
|
// ─────────────────────────────────────────────────────────────
|
|
686
662
|
function DCViewport({ children, minScale = 0.1, maxScale = 8, style = {} }) {
|
|
687
|
-
const ctx = React.useContext(DCCtx);
|
|
688
|
-
const { presentationMode, setPresentationMode, setPresentationSectionId } = ctx;
|
|
689
663
|
const vpRef = React.useRef(null);
|
|
690
664
|
const worldRef = React.useRef(null);
|
|
691
665
|
// Pre-fit fallback scale. A fresh canvas is reframed by the first-visit fit
|
|
@@ -771,21 +745,13 @@ function DCViewport({ children, minScale = 0.1, maxScale = 8, style = {} }) {
|
|
|
771
745
|
mirrorEmitT.current = 0;
|
|
772
746
|
const bounds = dcBoundsFromTransform(tf.current, vpRef.current);
|
|
773
747
|
if (!bounds) return;
|
|
774
|
-
const sectionId = presentationMode ? dcPresentationSectionAtViewport(vpRef.current) : null;
|
|
775
|
-
if (sectionId) setPresentationSectionId((current) => current === sectionId ? current : sectionId);
|
|
776
748
|
window.__miaodaMirror.emit(
|
|
777
|
-
{ type: 'miaoda:canvas:viewport-changed', v: 2, bounds,
|
|
749
|
+
{ type: 'miaoda:canvas:viewport-changed', v: 2, bounds, x: tf.current.x, y: tf.current.y, scale: tf.current.scale },
|
|
778
750
|
{ key: 'canvas:viewport', throttle: 60 },
|
|
779
751
|
);
|
|
780
752
|
}, 120);
|
|
781
753
|
}
|
|
782
|
-
}, [tfKey
|
|
783
|
-
|
|
784
|
-
React.useLayoutEffect(() => {
|
|
785
|
-
if (!presentationMode) return;
|
|
786
|
-
const sectionId = dcPresentationSectionAtViewport(vpRef.current);
|
|
787
|
-
if (sectionId) setPresentationSectionId((current) => current === sectionId ? current : sectionId);
|
|
788
|
-
}, [presentationMode, setPresentationSectionId]);
|
|
754
|
+
}, [tfKey]);
|
|
789
755
|
|
|
790
756
|
// Whether the mount-time restore found a saved viewport — when it did, the
|
|
791
757
|
// first-visit fit below is skipped so revisits keep the user's own view.
|
|
@@ -1142,9 +1108,6 @@ function DCViewport({ children, minScale = 0.1, maxScale = 8, style = {} }) {
|
|
|
1142
1108
|
applyingRemoteView.current = viewIsRemote.current;
|
|
1143
1109
|
apply();
|
|
1144
1110
|
applyingRemoteView.current = false;
|
|
1145
|
-
} else if (d && d.type === 'miaoda:canvas:presentation-mode') {
|
|
1146
|
-
setPresentationMode(!!d.enabled);
|
|
1147
|
-
if (!d.enabled) setPresentationSectionId(null);
|
|
1148
1111
|
}
|
|
1149
1112
|
};
|
|
1150
1113
|
window.addEventListener('message', onHostMsg);
|
|
@@ -1179,7 +1142,6 @@ function DCViewport({ children, minScale = 0.1, maxScale = 8, style = {} }) {
|
|
|
1179
1142
|
// viewport as soon as content mounts.
|
|
1180
1143
|
didFit.current = true;
|
|
1181
1144
|
if (m.v === 2) {
|
|
1182
|
-
if (m.sectionId) setPresentationSectionId(m.sectionId);
|
|
1183
1145
|
return applyRemoteBounds(m.bounds) ? { type: 'applied' } : { type: 'ignored', reason: 'bad bounds snapshot' };
|
|
1184
1146
|
}
|
|
1185
1147
|
if (![m.x, m.y, m.scale].every(Number.isFinite)) return { type: 'ignored', reason: 'bad snapshot' };
|
|
@@ -1237,13 +1199,12 @@ function DCViewport({ children, minScale = 0.1, maxScale = 8, style = {} }) {
|
|
|
1237
1199
|
vp.removeEventListener('pointercancel', pu);
|
|
1238
1200
|
if (mobRaf) cancelAnimationFrame(mobRaf);
|
|
1239
1201
|
};
|
|
1240
|
-
}, [apply, minScale, maxScale
|
|
1202
|
+
}, [apply, minScale, maxScale]);
|
|
1241
1203
|
|
|
1242
1204
|
return (
|
|
1243
1205
|
<div
|
|
1244
1206
|
ref={vpRef}
|
|
1245
|
-
className={
|
|
1246
|
-
data-dc-presentation-mode={presentationMode ? '' : undefined}
|
|
1207
|
+
className={dcIsMobile ? 'design-canvas dc-mobile' : 'design-canvas'}
|
|
1247
1208
|
style={{
|
|
1248
1209
|
height: '100vh', width: '100vw',
|
|
1249
1210
|
background: DC.bg,
|
|
@@ -1315,8 +1276,8 @@ function DCSection({ id, title, subtitle, children, gap = 48 }) {
|
|
|
1315
1276
|
// the title sits tight against its own row at every zoom.
|
|
1316
1277
|
return (
|
|
1317
1278
|
<div data-dc-section={sid}
|
|
1318
|
-
style={{ marginBottom:
|
|
1319
|
-
|
|
1279
|
+
style={{ marginBottom: 'calc(80px * var(--dc-inv-zoom, 1))', position: 'relative' }}>
|
|
1280
|
+
<div style={{ padding: '0 60px' }}>
|
|
1320
1281
|
<div className="dc-sectionhead" style={{ paddingBottom: 'calc(36px * var(--dc-inv-zoom, 1))' }}>
|
|
1321
1282
|
<DCEditable tag="div" value={sec.title ?? title}
|
|
1322
1283
|
onChange={(v) => ctx && sid && ctx.patchSection(sid, { title: v })}
|
|
@@ -1328,7 +1289,7 @@ function DCSection({ id, title, subtitle, children, gap = 48 }) {
|
|
|
1328
1289
|
}} />
|
|
1329
1290
|
{subtitle && <div style={{ fontSize: 'calc(14px * var(--dc-inv-zoom, 1))', color: DC.subtitle, lineHeight: 'calc(22px * var(--dc-inv-zoom, 1))' }}>{subtitle}</div>}
|
|
1330
1291
|
</div>
|
|
1331
|
-
</div>
|
|
1292
|
+
</div>
|
|
1332
1293
|
<div style={{ display: 'flex', gap, padding: '0 60px', alignItems: 'flex-start', width: 'max-content' }}>
|
|
1333
1294
|
{order.map((k) => (
|
|
1334
1295
|
<DCArtboardFrame key={k} sectionId={sid} artboard={byId[k]} order={order}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/coding-registry-buildless",
|
|
3
|
-
"version": "0.1.25
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"description": "Miaoda registry (buildless runtime) — shadcn-style copy-in SDKs (globals + CDN-pinned, browser Babel) for buildless static HTML stacks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
package/scripts/deck-stage.js
CHANGED
|
@@ -14,6 +14,12 @@
|
|
|
14
14
|
* On touch devices, tapping the left/right half of the stage goes
|
|
15
15
|
* prev/next (not in mobile browse mode — see (g)) — taps on links,
|
|
16
16
|
* buttons and other interactive slide content are left alone.
|
|
17
|
+
* In mobile presenting mode a swipe pages too, in all four directions:
|
|
18
|
+
* swipe left or up for the NEXT slide, right or down for the previous
|
|
19
|
+
* one — the deck moves with the finger, so the gesture is the mirror of
|
|
20
|
+
* the tap zones (tap left = previous), exactly as in Keynote/PPT.
|
|
21
|
+
* Swipes that start on interactive or scrollable slide content are left
|
|
22
|
+
* alone, and browse mode has no swipe — there it is the list's scroll.
|
|
17
23
|
* (c) press R to reset to slide 0.
|
|
18
24
|
* (d) auto-scaling — inner canvas is a fixed design size (default 1920×1080)
|
|
19
25
|
* scaled with `transform: scale()` to fit the viewport, letterboxed.
|
|
@@ -65,7 +71,7 @@
|
|
|
65
71
|
* e.detail.total // total slide count
|
|
66
72
|
* e.detail.slide // the new active slide element
|
|
67
73
|
* e.detail.previousSlide // the prior slide element, or null on init
|
|
68
|
-
* e.detail.reason // 'init' | 'keyboard' | 'click' | 'tap' | 'api'
|
|
74
|
+
* e.detail.reason // 'init' | 'keyboard' | 'click' | 'tap' | 'swipe' | 'api'
|
|
69
75
|
* });
|
|
70
76
|
*
|
|
71
77
|
* Persistence: none at the deck level. The host app keeps the current slide
|
|
@@ -211,6 +217,24 @@
|
|
|
211
217
|
const NARROW_MQ = matchMedia('(max-width: 640px)');
|
|
212
218
|
// Slide-authored controls that should keep a tap instead of it navigating.
|
|
213
219
|
const INTERACTIVE_SEL = 'a[href], button, input, select, textarea, summary, label, video[controls], audio[controls], [role="button"], [onclick], [tabindex]:not([tabindex^="-"]), [contenteditable]:not([contenteditable="false" i])';
|
|
220
|
+
// Swipe paging thresholds. The travel floor is what separates a swipe from a
|
|
221
|
+
// sloppy tap; the axis ratio makes a diagonal drag do nothing rather than
|
|
222
|
+
// have the deck guess which way the user meant.
|
|
223
|
+
const SWIPE_MIN_PX = 40;
|
|
224
|
+
const SWIPE_AXIS_RATIO = 1.5;
|
|
225
|
+
// A slide-authored scroller owns any gesture that starts inside it — same
|
|
226
|
+
// yield-to-the-slide rule as INTERACTIVE_SEL, one step further out. Slide
|
|
227
|
+
// sections themselves are overflow:hidden, so this only ever matches
|
|
228
|
+
// something the author deliberately made scrollable.
|
|
229
|
+
const isScrollable = (el) => {
|
|
230
|
+
if (!el || el.nodeType !== 1) return false;
|
|
231
|
+
const cs = getComputedStyle(el);
|
|
232
|
+
const scrolls = (v) => v === 'auto' || v === 'scroll';
|
|
233
|
+
return (
|
|
234
|
+
(scrolls(cs.overflowY) && el.scrollHeight > el.clientHeight) ||
|
|
235
|
+
(scrolls(cs.overflowX) && el.scrollWidth > el.clientWidth)
|
|
236
|
+
);
|
|
237
|
+
};
|
|
214
238
|
|
|
215
239
|
/* Custom element families whose thumbnail clones keep their tag instead of
|
|
216
240
|
* being neutered (see _materialize).
|
|
@@ -869,6 +893,8 @@
|
|
|
869
893
|
this._onResize = this._onResize.bind(this);
|
|
870
894
|
this._onSlotChange = this._onSlotChange.bind(this);
|
|
871
895
|
this._onTap = this._onTap.bind(this);
|
|
896
|
+
this._onTouchStart = this._onTouchStart.bind(this);
|
|
897
|
+
this._onTouchEnd = this._onTouchEnd.bind(this);
|
|
872
898
|
this._onMessage = this._onMessage.bind(this);
|
|
873
899
|
this._onHashChange = this._onHashChange.bind(this);
|
|
874
900
|
// Capture-phase close so a click anywhere dismisses the menu, but
|
|
@@ -937,6 +963,10 @@
|
|
|
937
963
|
window.addEventListener('hashchange', this._onHashChange);
|
|
938
964
|
window.addEventListener('click', this._onDocClick, true);
|
|
939
965
|
this.addEventListener('click', this._onTap);
|
|
966
|
+
// touchend stays non-passive: preventDefault there is what stops the
|
|
967
|
+
// trailing compatibility click from paging a second time.
|
|
968
|
+
this.addEventListener('touchstart', this._onTouchStart, { passive: true });
|
|
969
|
+
this.addEventListener('touchend', this._onTouchEnd, { passive: false });
|
|
940
970
|
// Print lays every slide out as its own page, so [data-deck-active]-
|
|
941
971
|
// gated entrance styles need the attribute on every slide (not just
|
|
942
972
|
// the current one) or their content prints at the hidden base style.
|
|
@@ -1369,6 +1399,8 @@
|
|
|
1369
1399
|
if (this._freezeStyle) { this._freezeStyle.remove(); this._freezeStyle = null; }
|
|
1370
1400
|
if (this._dragGhost) { this._dragGhost.remove(); this._dragGhost = null; }
|
|
1371
1401
|
this.removeEventListener('click', this._onTap);
|
|
1402
|
+
this.removeEventListener('touchstart', this._onTouchStart);
|
|
1403
|
+
this.removeEventListener('touchend', this._onTouchEnd);
|
|
1372
1404
|
if (this._liveTimer) clearTimeout(this._liveTimer);
|
|
1373
1405
|
if (this._authorCssTimer) clearTimeout(this._authorCssTimer);
|
|
1374
1406
|
if (this._railAnimTimer) clearTimeout(this._railAnimTimer);
|
|
@@ -1897,7 +1929,7 @@
|
|
|
1897
1929
|
total: this._slides.length,
|
|
1898
1930
|
slide: this._slides[curr] || null,
|
|
1899
1931
|
previousSlide: prev >= 0 ? (this._slides[prev] || null) : null,
|
|
1900
|
-
reason: reason, // 'init' | 'keyboard' | 'click' | 'tap' | 'api'
|
|
1932
|
+
reason: reason, // 'init' | 'keyboard' | 'click' | 'tap' | 'swipe' | 'api'
|
|
1901
1933
|
};
|
|
1902
1934
|
this.dispatchEvent(new CustomEvent('slidechange', {
|
|
1903
1935
|
detail,
|
|
@@ -2241,6 +2273,9 @@
|
|
|
2241
2273
|
}
|
|
2242
2274
|
|
|
2243
2275
|
_onTap(e) {
|
|
2276
|
+
// A swipe already paged; the click the browser synthesises after it must
|
|
2277
|
+
// not page again. Set in _onTouchEnd, cleared on the next touchstart.
|
|
2278
|
+
if (this._swipeNav) return;
|
|
2244
2279
|
// Touch-only for normal browse/edit — on desktop there, keyboard + the
|
|
2245
2280
|
// overlay toolbar cover nav. But in presenting mode the overlay is hidden
|
|
2246
2281
|
// and click-to-advance is the expected gesture (Keynote/PPT), so allow it
|
|
@@ -2293,6 +2328,62 @@
|
|
|
2293
2328
|
return x < 1 / 3 ? 'prev' : x > 2 / 3 ? 'next' : 'menu';
|
|
2294
2329
|
}
|
|
2295
2330
|
|
|
2331
|
+
// Swipe paging, mobile presenting only. The deck travels with the finger:
|
|
2332
|
+
// dragging left/up pulls the next slide in, right/down the previous one.
|
|
2333
|
+
// That is deliberately the mirror of the tap zones (tap left = previous,
|
|
2334
|
+
// a positional target rather than a drag) — the same pair every deck app
|
|
2335
|
+
// ships, so neither half should be "fixed" to match the other.
|
|
2336
|
+
// Browse mode is excluded on purpose — there the vertical gesture is the
|
|
2337
|
+
// card list's own scroll, and a horizontal one has no counterpart.
|
|
2338
|
+
_onTouchStart(e) {
|
|
2339
|
+
// Cleared at the start of every touch rather than after the suppressed
|
|
2340
|
+
// click: a WebView that swallows that click outright would otherwise
|
|
2341
|
+
// leave the flag set and eat the next genuine tap. Resetting here is
|
|
2342
|
+
// also what makes a second finger (pinch) abandon the gesture.
|
|
2343
|
+
this._swipeNav = false;
|
|
2344
|
+
this._swipeFrom = null;
|
|
2345
|
+
if (e.touches.length !== 1) return;
|
|
2346
|
+
if (!this.hasAttribute('data-mobile-present')) return;
|
|
2347
|
+
const path = e.composedPath();
|
|
2348
|
+
if (!this._stage || !path.includes(this._stage)) return;
|
|
2349
|
+
for (const n of path) {
|
|
2350
|
+
if (n === this._stage) break;
|
|
2351
|
+
if (n.matches && n.matches(INTERACTIVE_SEL)) return;
|
|
2352
|
+
if (isScrollable(n)) return;
|
|
2353
|
+
}
|
|
2354
|
+
const t = e.touches[0];
|
|
2355
|
+
this._swipeFrom = { x: t.clientX, y: t.clientY };
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
_onTouchEnd(e) {
|
|
2359
|
+
const from = this._swipeFrom;
|
|
2360
|
+
this._swipeFrom = null;
|
|
2361
|
+
// Another finger still down: this is the tail of a multi-touch gesture,
|
|
2362
|
+
// not a swipe that ended.
|
|
2363
|
+
if (!from || e.touches.length) return;
|
|
2364
|
+
const t = e.changedTouches && e.changedTouches[0];
|
|
2365
|
+
if (!t) return;
|
|
2366
|
+
const dx = t.clientX - from.x;
|
|
2367
|
+
const dy = t.clientY - from.y;
|
|
2368
|
+
// Rotated stage = the visual axes come off the viewport swapped. Reached
|
|
2369
|
+
// through the same predicate as the tap zones, and derived the same way:
|
|
2370
|
+
// _mobPresentZone reads visual x off viewport y, which fixes visual y as
|
|
2371
|
+
// the negated viewport x.
|
|
2372
|
+
const rotated = this._presentRotated();
|
|
2373
|
+
const vx = rotated ? dy : dx;
|
|
2374
|
+
const vy = rotated ? -dx : dy;
|
|
2375
|
+
const major = Math.abs(vx) >= Math.abs(vy) ? vx : vy;
|
|
2376
|
+
const minor = Math.abs(vx) >= Math.abs(vy) ? vy : vx;
|
|
2377
|
+
if (Math.abs(major) < SWIPE_MIN_PX) return;
|
|
2378
|
+
if (Math.abs(major) < Math.abs(minor) * SWIPE_AXIS_RATIO) return;
|
|
2379
|
+
this._swipeNav = true;
|
|
2380
|
+
e.preventDefault();
|
|
2381
|
+
this._advance(major < 0 ? 1 : -1, 'swipe');
|
|
2382
|
+
// Parity with tap: a gesture while the control layer is up restarts its
|
|
2383
|
+
// auto-hide instead of letting it disappear mid-navigation.
|
|
2384
|
+
if (this.hasAttribute('data-mob-ui')) this._toggleMobUi(true);
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2296
2387
|
_toggleMobUi(force) {
|
|
2297
2388
|
const wasOpen = this.hasAttribute('data-mob-ui');
|
|
2298
2389
|
const on = force != null ? !!force : !wasOpen;
|
package/scripts/design-canvas.js
CHANGED
|
@@ -630,23 +630,9 @@
|
|
|
630
630
|
this.style.marginBottom = 'calc(80px * var(--dc-inv-zoom, 1))';
|
|
631
631
|
this._render();
|
|
632
632
|
}
|
|
633
|
-
/**
|
|
634
|
-
* Presentation mode keeps section headings outside the transformed world.
|
|
635
|
-
* The remaining section/card layout is then purely world-space, which is the
|
|
636
|
-
* coordinate model mirrored by the v2 bounds snapshot.
|
|
637
|
-
*/
|
|
638
|
-
setPresentationMode(active) {
|
|
639
|
-
this._presentationMode = !!active;
|
|
640
|
-
this.style.marginBottom = active ? '80px' : 'calc(80px * var(--dc-inv-zoom, 1))';
|
|
641
|
-
// Rebuild instead of merely hiding the existing heading: in a shadow tree
|
|
642
|
-
// hidden descendants can still participate in measurement in some engines.
|
|
643
|
-
// Omitting it makes the presentation world genuinely title-free.
|
|
644
|
-
this._render();
|
|
645
|
-
}
|
|
646
633
|
/** Pushed down by <design-canvas>: renamed title, order, deleted artboards. */
|
|
647
634
|
applyState(meta) {
|
|
648
635
|
this._order = meta.slotIds;
|
|
649
|
-
this._stateTitle = meta.title;
|
|
650
636
|
const t = this.shadowRoot?.querySelector('.dc-sectionhead .dc-editable');
|
|
651
637
|
if (t && meta.title != null && t.textContent !== meta.title) t.textContent = meta.title;
|
|
652
638
|
const boards = [...this.querySelectorAll(':scope > dc-artboard')];
|
|
@@ -702,14 +688,11 @@
|
|
|
702
688
|
.dc-sectionhead{padding-bottom:calc(36px * var(--dc-inv-zoom,1))}
|
|
703
689
|
</style>
|
|
704
690
|
<div part="frame">
|
|
705
|
-
|
|
706
|
-
this._presentationMode
|
|
707
|
-
? ''
|
|
708
|
-
: `<div class="dc-sectionhead-wrap" style="padding:0 60px">
|
|
691
|
+
<div style="padding:0 60px">
|
|
709
692
|
<div class="dc-sectionhead" part="sectionhead">
|
|
710
693
|
${editable(
|
|
711
694
|
'',
|
|
712
|
-
this.
|
|
695
|
+
this.attr('title', ''),
|
|
713
696
|
`font-size:calc(20px * var(--dc-inv-zoom,1));font-weight:600;color:${DC.title};` +
|
|
714
697
|
'letter-spacing:calc(-0.4px * var(--dc-inv-zoom,1));margin-bottom:calc(2px * var(--dc-inv-zoom,1));' +
|
|
715
698
|
'display:inline-block;line-height:calc(28px * var(--dc-inv-zoom,1))',
|
|
@@ -720,8 +703,7 @@
|
|
|
720
703
|
: ''
|
|
721
704
|
}
|
|
722
705
|
</div>
|
|
723
|
-
</div
|
|
724
|
-
}
|
|
706
|
+
</div>
|
|
725
707
|
<div style="display:flex;gap:${px(gap)};padding:0 60px;align-items:flex-start;width:max-content">
|
|
726
708
|
<slot></slot>
|
|
727
709
|
</div>
|
|
@@ -1245,9 +1227,6 @@
|
|
|
1245
1227
|
this._applyingRemoteView = false;
|
|
1246
1228
|
this._viewIsRemote = false;
|
|
1247
1229
|
this._remoteBounds = null;
|
|
1248
|
-
this._presentationMode = false;
|
|
1249
|
-
this._presentationSectionId = null;
|
|
1250
|
-
this._presentationTitle = null;
|
|
1251
1230
|
this._mirrorSeeded = false;
|
|
1252
1231
|
this._mirrorEmitT = 0;
|
|
1253
1232
|
this._mirrorOffs = [];
|
|
@@ -1392,7 +1371,6 @@
|
|
|
1392
1371
|
// presenter's viewport.
|
|
1393
1372
|
this._didFit = true;
|
|
1394
1373
|
if (m.v === 2) {
|
|
1395
|
-
if (m.sectionId) this._syncPresentationTitle(m.sectionId);
|
|
1396
1374
|
return this._applyRemoteBounds(m.bounds)
|
|
1397
1375
|
? { type: 'applied' }
|
|
1398
1376
|
: { type: 'ignored', reason: 'bad bounds snapshot' };
|
|
@@ -1428,8 +1406,6 @@
|
|
|
1428
1406
|
window.removeEventListener('pagehide', this._flushView);
|
|
1429
1407
|
window.removeEventListener('resize', this._onViewportResize);
|
|
1430
1408
|
this._flushView?.();
|
|
1431
|
-
this._presentationTitle?.remove();
|
|
1432
|
-
this._presentationTitle = null;
|
|
1433
1409
|
this.overlay.close();
|
|
1434
1410
|
for (const off of this._offs || []) off();
|
|
1435
1411
|
this._offs = [];
|
|
@@ -1472,77 +1448,6 @@
|
|
|
1472
1448
|
if (!dcIsMobile) this._renderZoom();
|
|
1473
1449
|
}
|
|
1474
1450
|
|
|
1475
|
-
_setPresentationMode(active) {
|
|
1476
|
-
this._presentationMode = !!active;
|
|
1477
|
-
this.vp?.classList.toggle('dc-presentation-mode', this._presentationMode);
|
|
1478
|
-
this.vp?.toggleAttribute('data-dc-presentation-mode', this._presentationMode);
|
|
1479
|
-
for (const sec of this.querySelectorAll(':scope > dc-section'))
|
|
1480
|
-
sec.setPresentationMode?.(this._presentationMode);
|
|
1481
|
-
if (!this._presentationMode) {
|
|
1482
|
-
this._presentationSectionId = null;
|
|
1483
|
-
this._presentationTitle?.remove();
|
|
1484
|
-
this._presentationTitle = null;
|
|
1485
|
-
this.apply();
|
|
1486
|
-
return;
|
|
1487
|
-
}
|
|
1488
|
-
this._syncPresentationTitle();
|
|
1489
|
-
// The world layout just changed (counter-scaled headings moved to fixed
|
|
1490
|
-
// chrome). Re-run the normal transform pipeline so an already-presenting
|
|
1491
|
-
// peer receives the presentation-layout bounds on the next snapshot.
|
|
1492
|
-
this.apply();
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
_presentationSectionAtViewport() {
|
|
1496
|
-
if (!this.vp) return null;
|
|
1497
|
-
const top = this.vp.getBoundingClientRect().top;
|
|
1498
|
-
let current = null;
|
|
1499
|
-
let distance = Infinity;
|
|
1500
|
-
for (const sec of this.querySelectorAll(':scope > dc-section')) {
|
|
1501
|
-
const delta = Math.abs(sec.getBoundingClientRect().top - top);
|
|
1502
|
-
if (delta < distance) {
|
|
1503
|
-
current = sec.sectionId;
|
|
1504
|
-
distance = delta;
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
return current;
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
_syncPresentationTitle(sectionId = this._presentationSectionAtViewport()) {
|
|
1511
|
-
if (!this._presentationMode) return;
|
|
1512
|
-
const sid = sectionId || this.sectionOrder[0];
|
|
1513
|
-
const meta = sid && this.sectionMeta[sid];
|
|
1514
|
-
if (!meta) return;
|
|
1515
|
-
this._presentationSectionId = sid;
|
|
1516
|
-
if (!this._presentationTitle) {
|
|
1517
|
-
const title = document.createElement('div');
|
|
1518
|
-
title.setAttribute('data-dc-presentation-title', '');
|
|
1519
|
-
Object.assign(title.style, {
|
|
1520
|
-
position: 'fixed',
|
|
1521
|
-
top: '16px',
|
|
1522
|
-
left: '20px',
|
|
1523
|
-
zIndex: '60',
|
|
1524
|
-
pointerEvents: 'none',
|
|
1525
|
-
fontFamily: DC.font,
|
|
1526
|
-
});
|
|
1527
|
-
this.shadowRoot.appendChild(title);
|
|
1528
|
-
this._presentationTitle = title;
|
|
1529
|
-
}
|
|
1530
|
-
this._presentationTitle.textContent = '';
|
|
1531
|
-
const main = document.createElement('div');
|
|
1532
|
-
main.textContent = meta.title || '';
|
|
1533
|
-
Object.assign(main.style, { fontSize: '16px', fontWeight: '600', color: DC.title });
|
|
1534
|
-
this._presentationTitle.appendChild(main);
|
|
1535
|
-
const subtitle = [...this.querySelectorAll(':scope > dc-section')]
|
|
1536
|
-
.find((sec) => sec.sectionId === sid)
|
|
1537
|
-
?.getAttribute('subtitle');
|
|
1538
|
-
if (subtitle) {
|
|
1539
|
-
const sub = document.createElement('div');
|
|
1540
|
-
sub.textContent = subtitle;
|
|
1541
|
-
Object.assign(sub.style, { marginTop: '2px', fontSize: '12px', color: DC.subtitle });
|
|
1542
|
-
this._presentationTitle.appendChild(sub);
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
1451
|
// ── Zoom control (bottom right) ─────────────────────────
|
|
1547
1452
|
_renderZoom() {
|
|
1548
1453
|
const wrap = document.createElement('div');
|
|
@@ -1722,14 +1627,11 @@
|
|
|
1722
1627
|
this._mirrorEmitT = 0;
|
|
1723
1628
|
const bounds = this._boundsFromTransform();
|
|
1724
1629
|
if (!bounds) return;
|
|
1725
|
-
const sectionId = this._presentationMode ? this._presentationSectionAtViewport() : null;
|
|
1726
|
-
if (sectionId) this._syncPresentationTitle(sectionId);
|
|
1727
1630
|
window.__miaodaMirror.emit(
|
|
1728
1631
|
{
|
|
1729
1632
|
type: 'miaoda:canvas:viewport-changed',
|
|
1730
1633
|
v: 2,
|
|
1731
1634
|
bounds,
|
|
1732
|
-
sectionId,
|
|
1733
1635
|
x: this.tf.x,
|
|
1734
1636
|
y: this.tf.y,
|
|
1735
1637
|
scale: this.tf.scale,
|
|
@@ -2140,8 +2042,6 @@
|
|
|
2140
2042
|
} catch {}
|
|
2141
2043
|
this._lastPostedScale = undefined;
|
|
2142
2044
|
this.apply();
|
|
2143
|
-
} else if (d && d.type === 'miaoda:canvas:presentation-mode') {
|
|
2144
|
-
this._setPresentationMode(!!d.enabled);
|
|
2145
2045
|
}
|
|
2146
2046
|
};
|
|
2147
2047
|
window.addEventListener('message', this._onHostMsg);
|
|
@@ -2318,7 +2218,6 @@
|
|
|
2318
2218
|
};
|
|
2319
2219
|
this.sectionMeta[sid] = meta;
|
|
2320
2220
|
sec.applyState(meta);
|
|
2321
|
-
sec.setPresentationMode?.(this._presentationMode);
|
|
2322
2221
|
}
|
|
2323
2222
|
// If the focused artboard is gone (deleted, or content regenerated), leave focus.
|
|
2324
2223
|
// This is a LOCAL correction, not a user action, so it must not broadcast: in a
|
|
@@ -2337,7 +2236,6 @@
|
|
|
2337
2236
|
// useLayoutEffect. Deferring to rAF is one tick late and flashes an unfitted
|
|
2338
2237
|
// first frame.
|
|
2339
2238
|
this.fitToContent();
|
|
2340
|
-
this._syncPresentationTitle();
|
|
2341
2239
|
}
|
|
2342
2240
|
}
|
|
2343
2241
|
|