@yoamigo.com/core 0.3.16 → 0.4.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.
|
@@ -154,4 +154,4 @@ interface MarkdownTextProps {
|
|
|
154
154
|
*/
|
|
155
155
|
declare function MarkdownText({ content, className }: MarkdownTextProps): react_jsx_runtime.JSX.Element;
|
|
156
156
|
|
|
157
|
-
export { ContentStoreProvider as C, type EditMode as E, MpText as M, type PageInfo as P, type StaticTextProps as S, YaEmbed as Y, type ContentStore as a, MpImage as b, type StaticImageProps as c, MarkdownText as d, type MarkdownTextProps as e, type
|
|
157
|
+
export { ContentStoreProvider as C, type EditMode as E, MpText as M, type PageInfo as P, type StaticTextProps as S, YaEmbed as Y, type ContentStore as a, MpImage as b, type StaticImageProps as c, MarkdownText as d, type MarkdownTextProps as e, type EmbedFieldValue as f, type YaEmbedProps as g, type EmbedType as h, YaLink as i, type YaLinkProps as j, parseEmbedUrl as p, serializeEmbedValue as s, useContentStore as u };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1, { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
|
|
3
|
+
import { f as EmbedFieldValue } from './MarkdownText-_ykp-njt.js';
|
|
4
|
+
export { C as ContentStoreProviderProd, h as EmbedType, d as MarkdownText, e as MarkdownTextProps, P as PageInfo, b as StaticImage, c as StaticImageProps, M as StaticText, S as StaticTextProps, Y as YaEmbed, g as YaEmbedProps, i as YaLink, j as YaLinkProps, p as parseEmbedUrl, s as serializeEmbedValue, u as useContentStoreProd } from './MarkdownText-_ykp-njt.js';
|
|
4
5
|
export { Link, LinkProps, NavigateFunction, Router, RouterProps, ScrollRestoration, useNavigate } from './router.js';
|
|
5
6
|
export { Route, Switch, useParams } from 'wouter';
|
|
6
7
|
export { A as AssetResolverFn, C as ContentRegistry, c as contentRegistry, a as getAllContent, g as getContent, h as hasContent, r as registerContent, b as resolveAssetUrl, s as setAssetResolver } from './asset-resolver-BnIvDkVv.js';
|
|
@@ -229,6 +230,109 @@ interface SafeTriangleBelowProps {
|
|
|
229
230
|
*/
|
|
230
231
|
declare function SafeTriangleBelow({ triggerRef, popoverRef, isVisible, onLeave, onStayInside, }: SafeTriangleBelowProps): null;
|
|
231
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Content Helpers for content.ts
|
|
235
|
+
*
|
|
236
|
+
* Type-safe helper functions for creating content values.
|
|
237
|
+
* These eliminate the need for manual JSON.stringify() and escaping.
|
|
238
|
+
*
|
|
239
|
+
* Usage:
|
|
240
|
+
* ```ts
|
|
241
|
+
* import { text, image, background, video, embed } from '@yoamigo.com/core'
|
|
242
|
+
*
|
|
243
|
+
* export default {
|
|
244
|
+
* "hero.title": text("Welcome to Our Site"),
|
|
245
|
+
* "profile.image": image({ src: "/photo.jpg", alt: "Headshot" }),
|
|
246
|
+
* "hero.background": background({ type: "color", backgroundColor: "#000" }),
|
|
247
|
+
* } as const satisfies Record<string, string>
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Text content for YaText fields.
|
|
253
|
+
*
|
|
254
|
+
* Supports HTML formatting:
|
|
255
|
+
* - `<strong>`, `<b>` for bold
|
|
256
|
+
* - `<em>`, `<i>` for italic
|
|
257
|
+
* - `<a href="...">` for links
|
|
258
|
+
* - `<span style="...">` for inline styles
|
|
259
|
+
* - `<br>` for line breaks
|
|
260
|
+
*
|
|
261
|
+
* Allowed inline styles: font-size, font-weight
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* text("Hello World")
|
|
265
|
+
* text("Welcome to <strong>YoAmigo</strong>")
|
|
266
|
+
* text('<span style="font-size: 20px">Large text</span>')
|
|
267
|
+
*/
|
|
268
|
+
declare function text(content: string): string;
|
|
269
|
+
/**
|
|
270
|
+
* Image field value for YaImage components.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* image({ src: "/photo.jpg", alt: "Description" })
|
|
274
|
+
* image({ src: "/hero.jpg", objectFit: "cover", objectPosition: "center top" })
|
|
275
|
+
* image({ src: "/profile.jpg", focalPoint: { x: 50, y: 30 } })
|
|
276
|
+
*/
|
|
277
|
+
declare function image(config: ImageFieldValue): string;
|
|
278
|
+
/**
|
|
279
|
+
* Background config for YaContainer components.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* // Solid color
|
|
283
|
+
* background({ type: "color", backgroundColor: "#000" })
|
|
284
|
+
*
|
|
285
|
+
* // Image background
|
|
286
|
+
* background({
|
|
287
|
+
* type: "image",
|
|
288
|
+
* backgroundImage: { src: "/bg.jpg", objectFit: "cover" }
|
|
289
|
+
* })
|
|
290
|
+
*
|
|
291
|
+
* // Image with overlay
|
|
292
|
+
* background({
|
|
293
|
+
* type: "image",
|
|
294
|
+
* backgroundImage: { src: "/bg.jpg" },
|
|
295
|
+
* overlay: { color: "#000", opacity: 0.5 }
|
|
296
|
+
* })
|
|
297
|
+
*
|
|
298
|
+
* // No background (transparent)
|
|
299
|
+
* background({ type: "none" })
|
|
300
|
+
*/
|
|
301
|
+
declare function background(config: BackgroundConfig): string;
|
|
302
|
+
/**
|
|
303
|
+
* Video field value for YaVideo components.
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* // YouTube video
|
|
307
|
+
* video({ type: "youtube", src: "dQw4w9WgXcQ" })
|
|
308
|
+
*
|
|
309
|
+
* // Vimeo video
|
|
310
|
+
* video({ type: "vimeo", src: "123456789" })
|
|
311
|
+
*
|
|
312
|
+
* // Uploaded video
|
|
313
|
+
* video({ type: "upload", src: "/videos/intro.mp4" })
|
|
314
|
+
*
|
|
315
|
+
* // With options
|
|
316
|
+
* video({ type: "youtube", src: "dQw4w9WgXcQ", autoplay: true, muted: true, loop: true })
|
|
317
|
+
*/
|
|
318
|
+
declare function video(config: VideoFieldValue): string;
|
|
319
|
+
/**
|
|
320
|
+
* Embed field value for YaEmbed components.
|
|
321
|
+
*
|
|
322
|
+
* Supports: Spotify, SoundCloud, Twitter/X, Instagram
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* // Spotify track
|
|
326
|
+
* embed({ type: "spotify", src: "track/4PTG3Z6", spotifyType: "track" })
|
|
327
|
+
*
|
|
328
|
+
* // Spotify playlist
|
|
329
|
+
* embed({ type: "spotify", src: "playlist/37i9dQZF1DXcBWIGoYBM5M", spotifyType: "playlist" })
|
|
330
|
+
*
|
|
331
|
+
* // SoundCloud
|
|
332
|
+
* embed({ type: "soundcloud", src: "user/track" })
|
|
333
|
+
*/
|
|
334
|
+
declare function embed(config: EmbedFieldValue): string;
|
|
335
|
+
|
|
232
336
|
/**
|
|
233
337
|
* Animation state for a single field
|
|
234
338
|
*/
|
|
@@ -675,4 +779,4 @@ interface UseSafeTriangleReturn<T extends HTMLElement, U extends HTMLElement> {
|
|
|
675
779
|
*/
|
|
676
780
|
declare function useSafeTriangle<T extends HTMLElement = HTMLElement, U extends HTMLElement = HTMLDivElement>(options?: UseSafeTriangleOptions): UseSafeTriangleReturn<T, U>;
|
|
677
781
|
|
|
678
|
-
export { type AIEditContextValue, AIEditProvider, type AnimatedTextOptions, type AnimatedTextResult, type AnimationConfig, type AnimationMetadata, type AnimationOptions, type AnimationPhase, type AnimationResult, type AnimationState, type AnimationStrategy, type BackgroundConfig, type BackgroundImageConfig, type ContentStoreContextType, type ContentStoreMode, ContentStoreProvider, type ImageFieldValue, type ImageValue, type LinkValue, type OverlayConfig, SafeHtml, type SafeHtmlProps, SafeTriangleBelow, type TextAnimationMetadata, type TextDiff, type VideoFieldValue, YaContainer, type YaContainerProps, YaImage, type YaImageProps, YaText, type YaTextProps, YaVideo, type YaVideoProps, buildIntermediateText, calculateAnimationTiming, computeTextDiff, containsHtml, getTextCursorPosition, imageCrossfadeStrategy, linkTransitionStrategy, parseBackgroundConfig, serializeBackgroundConfig, serializeImageValue, serializeVideoValue, stripHtml, textTypingStrategy, useAIEditAnimation, useAIEditContext, useAIEditContextOptional, useAnimatedText, useContentStore, useSafeTriangle };
|
|
782
|
+
export { type AIEditContextValue, AIEditProvider, type AnimatedTextOptions, type AnimatedTextResult, type AnimationConfig, type AnimationMetadata, type AnimationOptions, type AnimationPhase, type AnimationResult, type AnimationState, type AnimationStrategy, type BackgroundConfig, type BackgroundImageConfig, type ContentStoreContextType, type ContentStoreMode, ContentStoreProvider, EmbedFieldValue, type ImageFieldValue, type ImageValue, type LinkValue, type OverlayConfig, SafeHtml, type SafeHtmlProps, SafeTriangleBelow, type TextAnimationMetadata, type TextDiff, type VideoFieldValue, YaContainer, type YaContainerProps, YaImage, type YaImageProps, YaText, type YaTextProps, YaVideo, type YaVideoProps, background, buildIntermediateText, calculateAnimationTiming, computeTextDiff, containsHtml, embed, getTextCursorPosition, image, imageCrossfadeStrategy, linkTransitionStrategy, parseBackgroundConfig, serializeBackgroundConfig, serializeImageValue, serializeVideoValue, stripHtml, text, textTypingStrategy, useAIEditAnimation, useAIEditContext, useAIEditContextOptional, useAnimatedText, useContentStore, useSafeTriangle, video };
|
package/dist/index.js
CHANGED
|
@@ -395,12 +395,12 @@ var BuilderSelectionManager = class {
|
|
|
395
395
|
return this.toTitleCase(el.dataset.mpSelectable);
|
|
396
396
|
}
|
|
397
397
|
const tag = el.tagName.toLowerCase();
|
|
398
|
-
const
|
|
398
|
+
const text2 = el.textContent?.trim().slice(0, 30) || "";
|
|
399
399
|
if (tag === "button" || el.getAttribute("role") === "button") {
|
|
400
|
-
return
|
|
400
|
+
return text2 ? `"${text2}" Button` : "Button";
|
|
401
401
|
}
|
|
402
402
|
if (tag === "a") {
|
|
403
|
-
return
|
|
403
|
+
return text2 ? `"${text2}" Link` : "Link";
|
|
404
404
|
}
|
|
405
405
|
if (tag === "img") {
|
|
406
406
|
return el.alt || "Image";
|
|
@@ -422,7 +422,7 @@ var BuilderSelectionManager = class {
|
|
|
422
422
|
return caption ? `Figure: ${caption.slice(0, 20)}` : "Figure";
|
|
423
423
|
}
|
|
424
424
|
if (tag === "figcaption") {
|
|
425
|
-
return
|
|
425
|
+
return text2 ? `Caption: ${text2.slice(0, 20)}` : "Caption";
|
|
426
426
|
}
|
|
427
427
|
if (tag === "input") {
|
|
428
428
|
const type = el.type || "text";
|
|
@@ -440,19 +440,19 @@ var BuilderSelectionManager = class {
|
|
|
440
440
|
return "Dropdown";
|
|
441
441
|
}
|
|
442
442
|
if (tag === "label") {
|
|
443
|
-
return
|
|
443
|
+
return text2 ? `Label: ${text2.slice(0, 20)}` : "Label";
|
|
444
444
|
}
|
|
445
445
|
if (tag === "form") {
|
|
446
446
|
return "Form";
|
|
447
447
|
}
|
|
448
448
|
if (["h1", "h2", "h3", "h4", "h5", "h6"].includes(tag)) {
|
|
449
|
-
return
|
|
449
|
+
return text2 ? `Heading: ${text2.slice(0, 25)}` : `${tag.toUpperCase()} Heading`;
|
|
450
450
|
}
|
|
451
451
|
if (tag === "p") {
|
|
452
|
-
return
|
|
452
|
+
return text2 ? `Paragraph: ${text2.slice(0, 20)}...` : "Paragraph";
|
|
453
453
|
}
|
|
454
454
|
if (tag === "blockquote") {
|
|
455
|
-
return
|
|
455
|
+
return text2 ? `Quote: ${text2.slice(0, 20)}...` : "Block Quote";
|
|
456
456
|
}
|
|
457
457
|
if (tag === "table") {
|
|
458
458
|
return "Table";
|
|
@@ -461,7 +461,7 @@ var BuilderSelectionManager = class {
|
|
|
461
461
|
return "Table Row";
|
|
462
462
|
}
|
|
463
463
|
if (tag === "td" || tag === "th") {
|
|
464
|
-
return
|
|
464
|
+
return text2 ? `Cell: ${text2.slice(0, 15)}` : "Table Cell";
|
|
465
465
|
}
|
|
466
466
|
if (tag === "ol") {
|
|
467
467
|
return "Ordered List";
|
|
@@ -470,7 +470,7 @@ var BuilderSelectionManager = class {
|
|
|
470
470
|
return "Unordered List";
|
|
471
471
|
}
|
|
472
472
|
if (tag === "li") {
|
|
473
|
-
const preview =
|
|
473
|
+
const preview = text2.length > 20 ? text2.slice(0, 20) + "..." : text2;
|
|
474
474
|
return preview ? `List Item: ${preview}` : "List Item";
|
|
475
475
|
}
|
|
476
476
|
if (tag === "section") {
|
|
@@ -490,7 +490,7 @@ var BuilderSelectionManager = class {
|
|
|
490
490
|
if (tag === "footer") {
|
|
491
491
|
return "Footer";
|
|
492
492
|
}
|
|
493
|
-
return
|
|
493
|
+
return text2 || this.toTitleCase(tag);
|
|
494
494
|
}
|
|
495
495
|
/**
|
|
496
496
|
* Convert kebab-case or tag names to Title Case
|
|
@@ -1409,8 +1409,8 @@ function extractLinkDisplayText(href) {
|
|
|
1409
1409
|
if (href.startsWith("/")) {
|
|
1410
1410
|
const segments = href.split("/").filter(Boolean);
|
|
1411
1411
|
const lastSegment = segments[segments.length - 1] || "home";
|
|
1412
|
-
const
|
|
1413
|
-
return { text, isExternal: false };
|
|
1412
|
+
const text2 = lastSegment.replace(/-/g, " ").replace(/^\w/, (c) => c.toUpperCase());
|
|
1413
|
+
return { text: text2, isExternal: false };
|
|
1414
1414
|
}
|
|
1415
1415
|
if (href.startsWith("mailto:")) {
|
|
1416
1416
|
return { text: "email", isExternal: true };
|
|
@@ -1532,14 +1532,14 @@ function SafeHtml({ content, className, mode = "read-only" }) {
|
|
|
1532
1532
|
clearTimeout(hideTimerRef.current);
|
|
1533
1533
|
showTimerRef.current = window.setTimeout(() => {
|
|
1534
1534
|
const href = link.getAttribute("href") || "";
|
|
1535
|
-
const { text, isExternal } = extractLinkDisplayText(href);
|
|
1535
|
+
const { text: text2, isExternal } = extractLinkDisplayText(href);
|
|
1536
1536
|
const rect = link.getBoundingClientRect();
|
|
1537
1537
|
const top = rect.bottom + window.scrollY + 8;
|
|
1538
1538
|
const left = rect.left + rect.width / 2 + window.scrollX;
|
|
1539
1539
|
setPopoverState({
|
|
1540
1540
|
isVisible: true,
|
|
1541
1541
|
href,
|
|
1542
|
-
displayText:
|
|
1542
|
+
displayText: text2,
|
|
1543
1543
|
isExternal,
|
|
1544
1544
|
position: { top, left }
|
|
1545
1545
|
});
|
|
@@ -1859,8 +1859,8 @@ function useAIEditAnimation(fieldId, value, options) {
|
|
|
1859
1859
|
}
|
|
1860
1860
|
|
|
1861
1861
|
// src/lib/text-diff.ts
|
|
1862
|
-
function containsHtml(
|
|
1863
|
-
return /<[^>]+>/.test(
|
|
1862
|
+
function containsHtml(text2) {
|
|
1863
|
+
return /<[^>]+>/.test(text2);
|
|
1864
1864
|
}
|
|
1865
1865
|
function stripHtml(html) {
|
|
1866
1866
|
const withNewlines = html.replace(/<br\s*\/?>/gi, "\n");
|
|
@@ -3552,7 +3552,7 @@ function YaImage({
|
|
|
3552
3552
|
fallbackSrc,
|
|
3553
3553
|
fallbackAlt
|
|
3554
3554
|
}) {
|
|
3555
|
-
const { getValue, mode } = useContentStore();
|
|
3555
|
+
const { getValue, setValue, mode } = useContentStore();
|
|
3556
3556
|
const containerRef = useRef8(null);
|
|
3557
3557
|
const imgRef = useRef8(null);
|
|
3558
3558
|
const [isSelected, setIsSelected] = useState7(false);
|
|
@@ -3560,12 +3560,14 @@ function YaImage({
|
|
|
3560
3560
|
const [isSmallImage, setIsSmallImage] = useState7(false);
|
|
3561
3561
|
const [isDropMode, setIsDropMode] = useState7(false);
|
|
3562
3562
|
const [isDropHover, setIsDropHover] = useState7(false);
|
|
3563
|
+
const [previewOverride, setPreviewOverride] = useState7(null);
|
|
3563
3564
|
const rawValue = getValue(fieldId);
|
|
3564
3565
|
const imageData = parseImageValue(rawValue);
|
|
3565
|
-
const
|
|
3566
|
-
const
|
|
3567
|
-
const
|
|
3568
|
-
const
|
|
3566
|
+
const displayData = previewOverride || imageData;
|
|
3567
|
+
const src = displayData.src || fallbackSrc || PLACEHOLDER_SVG;
|
|
3568
|
+
const altText = displayData.alt || alt || fallbackAlt || "";
|
|
3569
|
+
const objectFit = displayData.objectFit || propObjectFit || "cover";
|
|
3570
|
+
const objectPosition = getObjectPosition(displayData) || propObjectPosition || "50% 50%";
|
|
3569
3571
|
const handleClick = useCallback9(() => {
|
|
3570
3572
|
if (mode !== "inline-edit") return;
|
|
3571
3573
|
if (document.body.classList.contains("builder-selector-active")) return;
|
|
@@ -3598,17 +3600,23 @@ function YaImage({
|
|
|
3598
3600
|
if (mode !== "inline-edit") return;
|
|
3599
3601
|
const handleMessage2 = (event) => {
|
|
3600
3602
|
if (event.data?.type === "YA_IMAGE_EDIT_COMPLETE" && event.data.fieldId === fieldId) {
|
|
3603
|
+
const value = event.data.value;
|
|
3604
|
+
setValue(fieldId, serializeImageValue(value), "user");
|
|
3605
|
+
setPreviewOverride(null);
|
|
3601
3606
|
setIsSelected(false);
|
|
3602
3607
|
}
|
|
3603
3608
|
if (event.data?.type === "YA_IMAGE_EDIT_CANCEL" && event.data.fieldId === fieldId) {
|
|
3609
|
+
setPreviewOverride(null);
|
|
3604
3610
|
setIsSelected(false);
|
|
3605
3611
|
}
|
|
3606
3612
|
if (event.data?.type === "YA_IMAGE_UPDATE_PREVIEW" && event.data.fieldId === fieldId) {
|
|
3613
|
+
const value = event.data.value;
|
|
3614
|
+
setPreviewOverride(value);
|
|
3607
3615
|
}
|
|
3608
3616
|
};
|
|
3609
3617
|
window.addEventListener("message", handleMessage2);
|
|
3610
3618
|
return () => window.removeEventListener("message", handleMessage2);
|
|
3611
|
-
}, [mode, fieldId]);
|
|
3619
|
+
}, [mode, fieldId, setValue]);
|
|
3612
3620
|
useEffect8(() => {
|
|
3613
3621
|
if (mode !== "inline-edit") return;
|
|
3614
3622
|
const handleDropModeMessage = (event) => {
|
|
@@ -3970,12 +3978,12 @@ function YaVideo({
|
|
|
3970
3978
|
(e) => {
|
|
3971
3979
|
if ((e.key === " " || e.key === "Enter") && videoData.type === "upload" && controls) {
|
|
3972
3980
|
e.preventDefault();
|
|
3973
|
-
const
|
|
3974
|
-
if (
|
|
3975
|
-
if (
|
|
3976
|
-
|
|
3981
|
+
const video2 = videoRef.current;
|
|
3982
|
+
if (video2) {
|
|
3983
|
+
if (video2.paused) {
|
|
3984
|
+
video2.play();
|
|
3977
3985
|
} else {
|
|
3978
|
-
|
|
3986
|
+
video2.pause();
|
|
3979
3987
|
}
|
|
3980
3988
|
}
|
|
3981
3989
|
}
|
|
@@ -4902,13 +4910,13 @@ function YaLink({ fieldId, href: defaultHref = "#", className, style, as: Compon
|
|
|
4902
4910
|
const storeText = getValue(textFieldId);
|
|
4903
4911
|
const storeHref = getValue(hrefFieldId);
|
|
4904
4912
|
const isIconMode = children != null && typeof children !== "string";
|
|
4905
|
-
const
|
|
4913
|
+
const text2 = storeText || (typeof children === "string" ? children : "");
|
|
4906
4914
|
const href = storeHref || defaultHref;
|
|
4907
4915
|
const isExternal = isExternalHref(href);
|
|
4908
4916
|
const effectiveTarget = target ?? (isExternal ? "_blank" : void 0);
|
|
4909
4917
|
const effectiveRel = rel ?? (isExternal ? "noopener noreferrer" : void 0);
|
|
4910
4918
|
const [editingMode, setEditingMode] = useState12(null);
|
|
4911
|
-
const [originalText, setOriginalText] = useState12(
|
|
4919
|
+
const [originalText, setOriginalText] = useState12(text2);
|
|
4912
4920
|
const [originalHref, setOriginalHref] = useState12(href);
|
|
4913
4921
|
const [currentHref, setCurrentHref] = useState12(href);
|
|
4914
4922
|
const [isExternalUrl, setIsExternalUrl] = useState12(false);
|
|
@@ -4962,7 +4970,7 @@ function YaLink({ fieldId, href: defaultHref = "#", className, style, as: Compon
|
|
|
4962
4970
|
FontSize2,
|
|
4963
4971
|
FontWeight2
|
|
4964
4972
|
],
|
|
4965
|
-
content:
|
|
4973
|
+
content: text2,
|
|
4966
4974
|
editable: true,
|
|
4967
4975
|
editorProps: {
|
|
4968
4976
|
attributes: {
|
|
@@ -4991,11 +4999,11 @@ function YaLink({ fieldId, href: defaultHref = "#", className, style, as: Compon
|
|
|
4991
4999
|
});
|
|
4992
5000
|
useEffect13(() => {
|
|
4993
5001
|
if (editor && editingMode !== "text") {
|
|
4994
|
-
if (editor.getHTML() !==
|
|
4995
|
-
editor.commands.setContent(
|
|
5002
|
+
if (editor.getHTML() !== text2) {
|
|
5003
|
+
editor.commands.setContent(text2);
|
|
4996
5004
|
}
|
|
4997
5005
|
}
|
|
4998
|
-
}, [
|
|
5006
|
+
}, [text2, editor, editingMode]);
|
|
4999
5007
|
useEffect13(() => {
|
|
5000
5008
|
if (editingMode !== "link") {
|
|
5001
5009
|
setCurrentHref(href);
|
|
@@ -5120,12 +5128,12 @@ function YaLink({ fieldId, href: defaultHref = "#", className, style, as: Compon
|
|
|
5120
5128
|
}));
|
|
5121
5129
|
} else {
|
|
5122
5130
|
setEditingMode("text");
|
|
5123
|
-
setOriginalText(
|
|
5131
|
+
setOriginalText(text2);
|
|
5124
5132
|
setTimeout(() => {
|
|
5125
5133
|
editor?.chain().focus().selectAll().run();
|
|
5126
5134
|
}, 20);
|
|
5127
5135
|
}
|
|
5128
|
-
}, [
|
|
5136
|
+
}, [text2, editor, hideEditPopover, isIconMode, fieldId]);
|
|
5129
5137
|
const startEditLink = useCallback14(() => {
|
|
5130
5138
|
hideEditPopover();
|
|
5131
5139
|
setEditingMode("link");
|
|
@@ -5205,7 +5213,7 @@ function YaLink({ fieldId, href: defaultHref = "#", className, style, as: Compon
|
|
|
5205
5213
|
return attrs.fontWeight || "";
|
|
5206
5214
|
};
|
|
5207
5215
|
if (mode === "read-only") {
|
|
5208
|
-
const content = isIconMode ? children : /* @__PURE__ */ jsx15(SafeHtml, { content:
|
|
5216
|
+
const content = isIconMode ? children : /* @__PURE__ */ jsx15(SafeHtml, { content: text2, mode });
|
|
5209
5217
|
if (isInternalPath(href)) {
|
|
5210
5218
|
return /* @__PURE__ */ jsx15(
|
|
5211
5219
|
WouterLink,
|
|
@@ -5336,8 +5344,8 @@ function YaLink({ fieldId, href: defaultHref = "#", className, style, as: Compon
|
|
|
5336
5344
|
),
|
|
5337
5345
|
document.body
|
|
5338
5346
|
)
|
|
5339
|
-
] }) : /* @__PURE__ */ jsx15(SafeHtml, { content:
|
|
5340
|
-
] }) : /* @__PURE__ */ jsx15(SafeHtml, { content:
|
|
5347
|
+
] }) : /* @__PURE__ */ jsx15(SafeHtml, { content: text2, mode })
|
|
5348
|
+
] }) : /* @__PURE__ */ jsx15(SafeHtml, { content: text2, mode })
|
|
5341
5349
|
}
|
|
5342
5350
|
),
|
|
5343
5351
|
showEditPopover && !editingMode && mode === "inline-edit" && /* @__PURE__ */ jsxs9(
|
|
@@ -6053,9 +6061,9 @@ function MpImage({
|
|
|
6053
6061
|
// src/components/MarkdownText.tsx
|
|
6054
6062
|
import { Fragment as Fragment6 } from "react";
|
|
6055
6063
|
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
6056
|
-
function tokenize(
|
|
6064
|
+
function tokenize(text2) {
|
|
6057
6065
|
const tokens = [];
|
|
6058
|
-
let remaining =
|
|
6066
|
+
let remaining = text2;
|
|
6059
6067
|
const patterns = [
|
|
6060
6068
|
// Bold: **text**
|
|
6061
6069
|
{ regex: /^\*\*(.+?)\*\*/, type: "bold" },
|
|
@@ -6287,6 +6295,23 @@ function ScrollRestoration() {
|
|
|
6287
6295
|
|
|
6288
6296
|
// src/router/index.ts
|
|
6289
6297
|
import { Route, Switch, useParams } from "wouter";
|
|
6298
|
+
|
|
6299
|
+
// src/lib/content-helpers.ts
|
|
6300
|
+
function text(content) {
|
|
6301
|
+
return content;
|
|
6302
|
+
}
|
|
6303
|
+
function image(config) {
|
|
6304
|
+
return JSON.stringify(config);
|
|
6305
|
+
}
|
|
6306
|
+
function background(config) {
|
|
6307
|
+
return JSON.stringify(config);
|
|
6308
|
+
}
|
|
6309
|
+
function video(config) {
|
|
6310
|
+
return JSON.stringify(config);
|
|
6311
|
+
}
|
|
6312
|
+
function embed(config) {
|
|
6313
|
+
return JSON.stringify(config);
|
|
6314
|
+
}
|
|
6290
6315
|
export {
|
|
6291
6316
|
AIEditProvider,
|
|
6292
6317
|
ContentStoreProvider,
|
|
@@ -6307,15 +6332,18 @@ export {
|
|
|
6307
6332
|
YaLink,
|
|
6308
6333
|
YaText,
|
|
6309
6334
|
YaVideo,
|
|
6335
|
+
background,
|
|
6310
6336
|
buildIntermediateText,
|
|
6311
6337
|
calculateAnimationTiming,
|
|
6312
6338
|
computeTextDiff,
|
|
6313
6339
|
containsHtml,
|
|
6314
6340
|
contentRegistry,
|
|
6341
|
+
embed,
|
|
6315
6342
|
getAllContent,
|
|
6316
6343
|
getContent,
|
|
6317
6344
|
getTextCursorPosition,
|
|
6318
6345
|
hasContent,
|
|
6346
|
+
image,
|
|
6319
6347
|
imageCrossfadeStrategy,
|
|
6320
6348
|
initBuilderSelection,
|
|
6321
6349
|
linkTransitionStrategy,
|
|
@@ -6329,6 +6357,7 @@ export {
|
|
|
6329
6357
|
serializeVideoValue,
|
|
6330
6358
|
setAssetResolver,
|
|
6331
6359
|
stripHtml,
|
|
6360
|
+
text,
|
|
6332
6361
|
textTypingStrategy,
|
|
6333
6362
|
useAIEditAnimation,
|
|
6334
6363
|
useAIEditContext,
|
|
@@ -6338,5 +6367,6 @@ export {
|
|
|
6338
6367
|
useContentStore2 as useContentStoreProd,
|
|
6339
6368
|
useNavigate,
|
|
6340
6369
|
useParams,
|
|
6341
|
-
useSafeTriangle
|
|
6370
|
+
useSafeTriangle,
|
|
6371
|
+
video
|
|
6342
6372
|
};
|
package/dist/prod.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as ContentStore, E as ContentStoreMode, C as ContentStoreProvider, d as MarkdownText, e as MarkdownTextProps, P as PageInfo, b as StaticImage, c as StaticImageProps, M as StaticText, S as StaticTextProps, b as YaImage, c as YaImageProps, M as YaText, S as YaTextProps, p as parseEmbedUrl, u as useContentStore } from './MarkdownText-
|
|
1
|
+
export { a as ContentStore, E as ContentStoreMode, C as ContentStoreProvider, d as MarkdownText, e as MarkdownTextProps, P as PageInfo, b as StaticImage, c as StaticImageProps, M as StaticText, S as StaticTextProps, b as YaImage, c as YaImageProps, M as YaText, S as YaTextProps, p as parseEmbedUrl, u as useContentStore } from './MarkdownText-_ykp-njt.js';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import React, { CSSProperties, ReactNode } from 'react';
|
|
4
4
|
export { Link, LinkProps, NavigateFunction, Router, RouterProps, ScrollRestoration, useNavigate } from './router.js';
|