@particle-academy/fancy-slides 0.6.0 → 0.7.0
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/index.cjs +85 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +86 -15
- package/dist/index.js.map +1 -1
- package/package.json +28 -7
package/dist/index.cjs
CHANGED
|
@@ -477,6 +477,18 @@ var BUILD_KEYFRAMES = `
|
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
`;
|
|
480
|
+
|
|
481
|
+
// src/components/elements/TextElement/editor-preset.ts
|
|
482
|
+
var PRESENTATION_EDITOR_ACTIONS = [
|
|
483
|
+
{ icon: "B", label: "Bold", command: "bold" },
|
|
484
|
+
{ icon: "I", label: "Italic", command: "italic" },
|
|
485
|
+
{ icon: "H", label: "Heading", command: "formatBlock", commandArg: "<h2>" },
|
|
486
|
+
{ icon: "P", label: "Paragraph", command: "formatBlock", commandArg: "<p>" },
|
|
487
|
+
{ icon: "\u2022", label: "Bullet list", command: "insertUnorderedList" }
|
|
488
|
+
];
|
|
489
|
+
function normalizeSlideMarkdown(md) {
|
|
490
|
+
return md.replace(/\r\n/g, "\n").replace(/\n{2,}/g, "\n").replace(/[ \t]+$/gm, "").trim();
|
|
491
|
+
}
|
|
480
492
|
function TextElementRenderer({
|
|
481
493
|
element,
|
|
482
494
|
theme,
|
|
@@ -515,19 +527,58 @@ function TextElementRenderer({
|
|
|
515
527
|
overflow: "hidden"
|
|
516
528
|
};
|
|
517
529
|
if (editing && selected) {
|
|
518
|
-
|
|
519
|
-
|
|
530
|
+
const fontPx = Math.round((style.fontSize ?? 28) * scale);
|
|
531
|
+
const lh = style.lineHeight ?? 1.4;
|
|
532
|
+
const editScope = scopeId;
|
|
533
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
534
|
+
"div",
|
|
520
535
|
{
|
|
521
|
-
|
|
522
|
-
onChange: (e) => onContentChange?.(e.target.value),
|
|
536
|
+
"data-fs-edit-scope": editScope,
|
|
523
537
|
style: {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
resize: "none",
|
|
527
|
-
border: "none",
|
|
538
|
+
width: "100%",
|
|
539
|
+
height: "100%",
|
|
528
540
|
pointerEvents: "auto",
|
|
529
|
-
cursor: "text"
|
|
530
|
-
|
|
541
|
+
cursor: "text",
|
|
542
|
+
textAlign: style.align ?? "left",
|
|
543
|
+
color: style.color ?? t.colors?.text,
|
|
544
|
+
fontFamily: style.fontFamily ?? t.fonts?.body
|
|
545
|
+
},
|
|
546
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
547
|
+
children: [
|
|
548
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
549
|
+
[data-fs-edit-scope="${editScope}"] [data-react-fancy-editor] {
|
|
550
|
+
border: none; background: transparent; border-radius: 0;
|
|
551
|
+
height: 100%; display: flex; flex-direction: column; overflow: hidden;
|
|
552
|
+
}
|
|
553
|
+
[data-fs-edit-scope="${editScope}"] [data-react-fancy-editor-toolbar] {
|
|
554
|
+
background: rgba(244,244,245,0.85); border-radius: 6px 6px 0 0;
|
|
555
|
+
padding: 2px 4px;
|
|
556
|
+
}
|
|
557
|
+
[data-fs-edit-scope="${editScope}"] [data-react-fancy-editor-content] {
|
|
558
|
+
flex: 1; min-height: 0; padding: 4px 2px; overflow: auto;
|
|
559
|
+
font-size: ${fontPx}px; line-height: ${lh};
|
|
560
|
+
}
|
|
561
|
+
[data-fs-edit-scope="${editScope}"] [data-react-fancy-editor-content] :is(p, ul, ol, li) { font-size: inherit; margin: 0; }
|
|
562
|
+
[data-fs-edit-scope="${editScope}"] [data-react-fancy-editor-content] :where(p, li) + :where(p, li, ul, ol) { margin-top: 0.4em; }
|
|
563
|
+
[data-fs-edit-scope="${editScope}"] [data-react-fancy-editor-content] h1 { font-size: 1.6em; font-weight: 700; margin: 0; }
|
|
564
|
+
[data-fs-edit-scope="${editScope}"] [data-react-fancy-editor-content] h2 { font-size: 1.35em; font-weight: 700; margin: 0; }
|
|
565
|
+
[data-fs-edit-scope="${editScope}"] [data-react-fancy-editor-content] h3 { font-size: 1.15em; font-weight: 600; margin: 0; }
|
|
566
|
+
` }),
|
|
567
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
568
|
+
reactFancy.Editor,
|
|
569
|
+
{
|
|
570
|
+
value: element.content,
|
|
571
|
+
onChange: (md) => onContentChange?.(normalizeSlideMarkdown(md)),
|
|
572
|
+
outputFormat: "markdown",
|
|
573
|
+
lineSpacing: lh,
|
|
574
|
+
children: [
|
|
575
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactFancy.Editor.Toolbar, { actions: PRESENTATION_EDITOR_ACTIONS }),
|
|
576
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactFancy.Editor.Content, {})
|
|
577
|
+
]
|
|
578
|
+
},
|
|
579
|
+
element.id
|
|
580
|
+
)
|
|
581
|
+
]
|
|
531
582
|
}
|
|
532
583
|
);
|
|
533
584
|
}
|
|
@@ -1658,6 +1709,11 @@ function SlideThumbnail({
|
|
|
1658
1709
|
className,
|
|
1659
1710
|
style
|
|
1660
1711
|
}) {
|
|
1712
|
+
const resolved = resolveTheme(theme);
|
|
1713
|
+
const ratio = resolved.aspectRatio ?? 16 / 9;
|
|
1714
|
+
const designWidth = resolved.slideWidth ?? 1280;
|
|
1715
|
+
const scale = width / designWidth;
|
|
1716
|
+
const height = width / ratio;
|
|
1661
1717
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1662
1718
|
"div",
|
|
1663
1719
|
{
|
|
@@ -1670,12 +1726,27 @@ function SlideThumbnail({
|
|
|
1670
1726
|
boxShadow: active ? "0 0 0 3px rgba(139, 92, 246, 0.2)" : "0 1px 2px rgba(0,0,0,0.05)",
|
|
1671
1727
|
background: "#ffffff",
|
|
1672
1728
|
width,
|
|
1729
|
+
height,
|
|
1673
1730
|
...style
|
|
1674
1731
|
},
|
|
1675
1732
|
onClick,
|
|
1676
1733
|
onContextMenu,
|
|
1677
1734
|
"data-fancy-slides-thumbnail": slide.id,
|
|
1678
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1735
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1736
|
+
"div",
|
|
1737
|
+
{
|
|
1738
|
+
style: {
|
|
1739
|
+
width: designWidth,
|
|
1740
|
+
height: designWidth / ratio,
|
|
1741
|
+
transform: `scale(${scale})`,
|
|
1742
|
+
transformOrigin: "top left",
|
|
1743
|
+
// The thumb owns interaction — charts/code/iframes inside the
|
|
1744
|
+
// scaled slide shouldn't capture clicks.
|
|
1745
|
+
pointerEvents: "none"
|
|
1746
|
+
},
|
|
1747
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Slide, { slide, theme, width: designWidth, renderElement })
|
|
1748
|
+
}
|
|
1749
|
+
)
|
|
1679
1750
|
}
|
|
1680
1751
|
);
|
|
1681
1752
|
}
|
|
@@ -3112,7 +3183,7 @@ function DeckEditor({
|
|
|
3112
3183
|
slide,
|
|
3113
3184
|
theme: deck.theme,
|
|
3114
3185
|
editing: true,
|
|
3115
|
-
onElementContentChange: (eid, content) => ops.updateElement(slide.id, eid, { content }),
|
|
3186
|
+
onElementContentChange: (eid, content) => ops.updateElement(slide.id, eid, { content, format: "markdown" }),
|
|
3116
3187
|
onElementSelect: setElementIdSelected,
|
|
3117
3188
|
selectedElementId: elementIdSelected,
|
|
3118
3189
|
onElementMove: (eid, x, y) => ops.moveElement(slide.id, eid, x, y),
|
|
@@ -3153,6 +3224,7 @@ exports.DeckEditor = DeckEditor;
|
|
|
3153
3224
|
exports.EditorToolbar = EditorToolbar;
|
|
3154
3225
|
exports.ElementInspector = ElementInspector;
|
|
3155
3226
|
exports.ImageElementRenderer = ImageElementRenderer;
|
|
3227
|
+
exports.PRESENTATION_EDITOR_ACTIONS = PRESENTATION_EDITOR_ACTIONS;
|
|
3156
3228
|
exports.PresenterView = PresenterView;
|
|
3157
3229
|
exports.ShapeElementRenderer = ShapeElementRenderer;
|
|
3158
3230
|
exports.Slide = Slide;
|
|
@@ -3173,6 +3245,7 @@ exports.defineTheme = defineTheme;
|
|
|
3173
3245
|
exports.elementId = elementId;
|
|
3174
3246
|
exports.isByParagraph = isByParagraph;
|
|
3175
3247
|
exports.nextId = nextId;
|
|
3248
|
+
exports.normalizeSlideMarkdown = normalizeSlideMarkdown;
|
|
3176
3249
|
exports.paragraphReveals = paragraphReveals;
|
|
3177
3250
|
exports.reduceDeck = reduce;
|
|
3178
3251
|
exports.resolveTheme = resolveTheme;
|