@glyphjs/runtime 0.2.0 → 0.3.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.d.cts CHANGED
@@ -278,6 +278,21 @@ interface InlineRendererProps {
278
278
  */
279
279
  declare function InlineRenderer({ nodes }: InlineRendererProps): ReactNode;
280
280
 
281
+ interface RichTextProps {
282
+ content: string | InlineNode[];
283
+ style?: React.CSSProperties;
284
+ className?: string;
285
+ }
286
+ /**
287
+ * Renders text that may be plain string or formatted InlineNode[].
288
+ * Type guard checks if content is array, then uses InlineRenderer.
289
+ *
290
+ * This component enables component text fields to support both:
291
+ * - Plain strings (backward compatibility)
292
+ * - Markdown-parsed InlineNode arrays (when markdown: true)
293
+ */
294
+ declare function RichText({ content, style, className }: RichTextProps): ReactNode;
295
+
281
296
  /**
282
297
  * Renders a heading block (`<h1>` through `<h6>`) based on `data.depth`.
283
298
  * Generates an `id` attribute from the heading text for anchor links.
@@ -584,4 +599,4 @@ declare function SSRPlaceholder({ width, height, className, children, }: SSRPlac
584
599
  */
585
600
  declare function debounceInteractions(callback: (event: InteractionEvent) => void, delay?: number): (event: InteractionEvent) => void;
586
601
 
587
- export { AnimationContext, AnimationProvider, type AnimationState, type BlockAnimationResult, BlockDiagnosticIndicator, BlockRenderer, PluginRegistry as ComponentRegistry, ContainerMeasure, DashboardLayout, DiagnosticsOverlay, DocumentLayout, ErrorBoundary, FallbackRenderer, GlyphBlockquote, GlyphCodeBlock, GlyphDocument, GlyphHeading, GlyphImage, GlyphList, GlyphParagraph, GlyphRawHtml, GlyphThematicBreak, InlineRenderer, LayoutProvider, type NavigationResult, PluginRegistry, PresentationLayout, ReferenceIndicator, type RegistryChangeListener, type RuntimeContextValue, RuntimeProvider, type RuntimeProviderProps, SSRPlaceholder, type SSRPlaceholderProps, ThemeProvider, type ThemeProviderProps, type ValidationResult, builtInRenderers, createGlyphRuntime, createResolveVar, darkTheme, debounceInteractions, isDarkTheme, lightTheme, mergeThemeDefaults, resolveComponentProps, resolveTheme, resolveTier, useAnimation, useBlockAnimation, useGlyphTheme, useIsClient, useLayout, useNavigation, useReferences, useRuntime, validateComponentDefinition };
602
+ export { AnimationContext, AnimationProvider, type AnimationState, type BlockAnimationResult, BlockDiagnosticIndicator, BlockRenderer, PluginRegistry as ComponentRegistry, ContainerMeasure, DashboardLayout, DiagnosticsOverlay, DocumentLayout, ErrorBoundary, FallbackRenderer, GlyphBlockquote, GlyphCodeBlock, GlyphDocument, GlyphHeading, GlyphImage, GlyphList, GlyphParagraph, GlyphRawHtml, GlyphThematicBreak, InlineRenderer, LayoutProvider, type NavigationResult, PluginRegistry, PresentationLayout, ReferenceIndicator, type RegistryChangeListener, RichText, type RichTextProps, type RuntimeContextValue, RuntimeProvider, type RuntimeProviderProps, SSRPlaceholder, type SSRPlaceholderProps, ThemeProvider, type ThemeProviderProps, type ValidationResult, builtInRenderers, createGlyphRuntime, createResolveVar, darkTheme, debounceInteractions, isDarkTheme, lightTheme, mergeThemeDefaults, resolveComponentProps, resolveTheme, resolveTier, useAnimation, useBlockAnimation, useGlyphTheme, useIsClient, useLayout, useNavigation, useReferences, useRuntime, validateComponentDefinition };
package/dist/index.d.ts CHANGED
@@ -278,6 +278,21 @@ interface InlineRendererProps {
278
278
  */
279
279
  declare function InlineRenderer({ nodes }: InlineRendererProps): ReactNode;
280
280
 
281
+ interface RichTextProps {
282
+ content: string | InlineNode[];
283
+ style?: React.CSSProperties;
284
+ className?: string;
285
+ }
286
+ /**
287
+ * Renders text that may be plain string or formatted InlineNode[].
288
+ * Type guard checks if content is array, then uses InlineRenderer.
289
+ *
290
+ * This component enables component text fields to support both:
291
+ * - Plain strings (backward compatibility)
292
+ * - Markdown-parsed InlineNode arrays (when markdown: true)
293
+ */
294
+ declare function RichText({ content, style, className }: RichTextProps): ReactNode;
295
+
281
296
  /**
282
297
  * Renders a heading block (`<h1>` through `<h6>`) based on `data.depth`.
283
298
  * Generates an `id` attribute from the heading text for anchor links.
@@ -584,4 +599,4 @@ declare function SSRPlaceholder({ width, height, className, children, }: SSRPlac
584
599
  */
585
600
  declare function debounceInteractions(callback: (event: InteractionEvent) => void, delay?: number): (event: InteractionEvent) => void;
586
601
 
587
- export { AnimationContext, AnimationProvider, type AnimationState, type BlockAnimationResult, BlockDiagnosticIndicator, BlockRenderer, PluginRegistry as ComponentRegistry, ContainerMeasure, DashboardLayout, DiagnosticsOverlay, DocumentLayout, ErrorBoundary, FallbackRenderer, GlyphBlockquote, GlyphCodeBlock, GlyphDocument, GlyphHeading, GlyphImage, GlyphList, GlyphParagraph, GlyphRawHtml, GlyphThematicBreak, InlineRenderer, LayoutProvider, type NavigationResult, PluginRegistry, PresentationLayout, ReferenceIndicator, type RegistryChangeListener, type RuntimeContextValue, RuntimeProvider, type RuntimeProviderProps, SSRPlaceholder, type SSRPlaceholderProps, ThemeProvider, type ThemeProviderProps, type ValidationResult, builtInRenderers, createGlyphRuntime, createResolveVar, darkTheme, debounceInteractions, isDarkTheme, lightTheme, mergeThemeDefaults, resolveComponentProps, resolveTheme, resolveTier, useAnimation, useBlockAnimation, useGlyphTheme, useIsClient, useLayout, useNavigation, useReferences, useRuntime, validateComponentDefinition };
602
+ export { AnimationContext, AnimationProvider, type AnimationState, type BlockAnimationResult, BlockDiagnosticIndicator, BlockRenderer, PluginRegistry as ComponentRegistry, ContainerMeasure, DashboardLayout, DiagnosticsOverlay, DocumentLayout, ErrorBoundary, FallbackRenderer, GlyphBlockquote, GlyphCodeBlock, GlyphDocument, GlyphHeading, GlyphImage, GlyphList, GlyphParagraph, GlyphRawHtml, GlyphThematicBreak, InlineRenderer, LayoutProvider, type NavigationResult, PluginRegistry, PresentationLayout, ReferenceIndicator, type RegistryChangeListener, RichText, type RichTextProps, type RuntimeContextValue, RuntimeProvider, type RuntimeProviderProps, SSRPlaceholder, type SSRPlaceholderProps, ThemeProvider, type ThemeProviderProps, type ValidationResult, builtInRenderers, createGlyphRuntime, createResolveVar, darkTheme, debounceInteractions, isDarkTheme, lightTheme, mergeThemeDefaults, resolveComponentProps, resolveTheme, resolveTier, useAnimation, useBlockAnimation, useGlyphTheme, useIsClient, useLayout, useNavigation, useReferences, useRuntime, validateComponentDefinition };
package/dist/index.js CHANGED
@@ -779,6 +779,12 @@ function GlyphRawHtml({ block }) {
779
779
  const clean = DOMPurify.sanitize(data.value);
780
780
  return /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: clean } });
781
781
  }
782
+ function RichText({ content, style, className }) {
783
+ if (Array.isArray(content)) {
784
+ return /* @__PURE__ */ jsx("span", { style, className, children: /* @__PURE__ */ jsx(InlineRenderer, { nodes: content }) });
785
+ }
786
+ return /* @__PURE__ */ jsx("span", { style, className, children: content });
787
+ }
782
788
 
783
789
  // src/renderers/index.ts
784
790
  var builtInRenderers = {
@@ -1742,6 +1748,6 @@ function debounceInteractions(callback, delay = 300) {
1742
1748
  };
1743
1749
  }
1744
1750
 
1745
- export { AnimationContext, AnimationProvider, BlockDiagnosticIndicator, BlockRenderer, PluginRegistry as ComponentRegistry, ContainerMeasure, DashboardLayout, DiagnosticsOverlay, DocumentLayout, ErrorBoundary, FallbackRenderer, GlyphBlockquote, GlyphCodeBlock, GlyphDocument, GlyphHeading, GlyphImage, GlyphList, GlyphParagraph, GlyphRawHtml, GlyphThematicBreak, InlineRenderer, LayoutProvider, PluginRegistry, PresentationLayout, ReferenceIndicator, RuntimeProvider, SSRPlaceholder, ThemeProvider, builtInRenderers, createGlyphRuntime, createResolveVar, darkTheme, debounceInteractions, isDarkTheme, lightTheme, mergeThemeDefaults, resolveComponentProps, resolveTheme, resolveTier, useAnimation, useBlockAnimation, useGlyphTheme, useIsClient, useLayout, useNavigation, useReferences, useRuntime, validateComponentDefinition };
1751
+ export { AnimationContext, AnimationProvider, BlockDiagnosticIndicator, BlockRenderer, PluginRegistry as ComponentRegistry, ContainerMeasure, DashboardLayout, DiagnosticsOverlay, DocumentLayout, ErrorBoundary, FallbackRenderer, GlyphBlockquote, GlyphCodeBlock, GlyphDocument, GlyphHeading, GlyphImage, GlyphList, GlyphParagraph, GlyphRawHtml, GlyphThematicBreak, InlineRenderer, LayoutProvider, PluginRegistry, PresentationLayout, ReferenceIndicator, RichText, RuntimeProvider, SSRPlaceholder, ThemeProvider, builtInRenderers, createGlyphRuntime, createResolveVar, darkTheme, debounceInteractions, isDarkTheme, lightTheme, mergeThemeDefaults, resolveComponentProps, resolveTheme, resolveTier, useAnimation, useBlockAnimation, useGlyphTheme, useIsClient, useLayout, useNavigation, useReferences, useRuntime, validateComponentDefinition };
1746
1752
  //# sourceMappingURL=index.js.map
1747
1753
  //# sourceMappingURL=index.js.map