@storystick/react 0.0.0-stage → 0.2.0-rc.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/LICENSE +112 -0
- package/NOTICE +17 -0
- package/PUBLIC-API.md +36 -0
- package/README.md +226 -2
- package/dist/.source-hash +1 -0
- package/dist/file.d.ts +18 -0
- package/dist/file.js +44 -0
- package/dist/hydrate-slice.d.ts +3 -0
- package/dist/hydrate-slice.js +1 -0
- package/dist/image-component.d.ts +26 -0
- package/dist/image-component.js +79 -0
- package/dist/image-element.d.ts +6 -0
- package/dist/image-element.js +68 -0
- package/dist/image.d.ts +3 -0
- package/dist/image.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/link-adapter.d.ts +2 -0
- package/dist/link-adapter.js +2 -0
- package/dist/link-component.d.ts +53 -0
- package/dist/link-component.js +97 -0
- package/dist/link.d.ts +3 -0
- package/dist/link.js +3 -0
- package/dist/preview-generation.d.ts +21 -0
- package/dist/preview-generation.js +134 -0
- package/dist/preview-host/preview-assistant-continuation.d.ts +9 -0
- package/dist/preview-host/preview-assistant-continuation.js +39 -0
- package/dist/preview-host/preview-authoring-client.d.ts +12 -0
- package/dist/preview-host/preview-authoring-client.js +100 -0
- package/dist/preview-host/preview-editor-continuation.d.ts +13 -0
- package/dist/preview-host/preview-editor-continuation.js +68 -0
- package/dist/preview-host/preview-standalone-controls.d.ts +18 -0
- package/dist/preview-host/preview-standalone-controls.js +518 -0
- package/dist/preview-host/preview-studio-destination.d.ts +20 -0
- package/dist/preview-host/preview-studio-destination.js +55 -0
- package/dist/preview-host/use-standalone-presentation.d.ts +15 -0
- package/dist/preview-host/use-standalone-presentation.js +223 -0
- package/dist/preview-icons.d.ts +10 -0
- package/dist/preview-icons.js +8 -0
- package/dist/preview-interaction-control.d.ts +6 -0
- package/dist/preview-interaction-control.js +39 -0
- package/dist/preview-panel-state.d.ts +15 -0
- package/dist/preview-panel-state.js +28 -0
- package/dist/preview-provenance-publisher-model.d.ts +5 -0
- package/dist/preview-provenance-publisher-model.js +9 -0
- package/dist/preview-provenance-publisher.d.ts +15 -0
- package/dist/preview-provenance-publisher.js +68 -0
- package/dist/preview-provenance.d.ts +6 -0
- package/dist/preview-provenance.js +4 -0
- package/dist/preview-scope.d.ts +128 -0
- package/dist/preview-scope.js +161 -0
- package/dist/preview-slice-scope.d.ts +32 -0
- package/dist/preview-slice-scope.js +33 -0
- package/dist/preview-text-props.d.ts +18 -0
- package/dist/preview-text-props.js +13 -0
- package/dist/preview-toolbar-layout.d.ts +42 -0
- package/dist/preview-toolbar-layout.js +139 -0
- package/dist/preview-toolbar-panel.d.ts +13 -0
- package/dist/preview-toolbar-panel.js +6 -0
- package/dist/preview-toolbar-resize-handles.d.ts +9 -0
- package/dist/preview-toolbar-resize-handles.js +14 -0
- package/dist/preview-toolbar-shell.d.ts +18 -0
- package/dist/preview-toolbar-shell.js +138 -0
- package/dist/public-rich-text.d.ts +15 -0
- package/dist/public-rich-text.js +11 -0
- package/dist/public-slice-zone.d.ts +7 -0
- package/dist/public-slice-zone.js +6 -0
- package/dist/query-cache.d.ts +14 -0
- package/dist/query-cache.js +289 -0
- package/dist/query-preview-loader.d.ts +9 -0
- package/dist/query-preview-loader.js +28 -0
- package/dist/query-preview-runtime.d.ts +3 -0
- package/dist/query-preview-runtime.js +3 -0
- package/dist/rendering.d.ts +29 -0
- package/dist/rendering.js +17 -0
- package/dist/resize-edge.d.ts +8 -0
- package/dist/resize-edge.js +33 -0
- package/dist/rich-text.d.ts +150 -0
- package/dist/rich-text.js +618 -0
- package/dist/slice-render-failure.d.ts +8 -0
- package/dist/slice-render-failure.js +46 -0
- package/dist/slice-zone.d.ts +82 -0
- package/dist/slice-zone.js +273 -0
- package/dist/slice.d.ts +16 -0
- package/dist/slice.js +46 -0
- package/dist/storystick-mark.d.ts +3 -0
- package/dist/storystick-mark.js +5 -0
- package/dist/use-generated-query.d.ts +37 -0
- package/dist/use-generated-query.js +308 -0
- package/dist/use-momentary-preview-navigate-mode.d.ts +11 -0
- package/dist/use-momentary-preview-navigate-mode.js +158 -0
- package/dist/use-preview-perspective-intent.d.ts +53 -0
- package/dist/use-preview-perspective-intent.js +227 -0
- package/dist/use-preview-pointer-drag.d.ts +16 -0
- package/dist/use-preview-pointer-drag.js +98 -0
- package/dist/use-preview-toolbar-layout.d.ts +36 -0
- package/dist/use-preview-toolbar-layout.js +141 -0
- package/dist/use-render-mode-debounce.d.ts +31 -0
- package/dist/use-render-mode-debounce.js +143 -0
- package/dist/video.d.ts +21 -0
- package/dist/video.js +63 -0
- package/package.json +146 -3
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { type ContentSource } from '@storystick/client/internal';
|
|
2
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
3
|
+
import { type RichTextComponentTypes, type RichTextRenderContext, type RichTextRenderDiagnostic, type RichTextValue, type ResolvedLink } from '@storystick/types';
|
|
4
|
+
import type { SliceComponentRegistry } from './slice-zone.js';
|
|
5
|
+
import { type SliceContractRegistry, type SliceFallback, type SliceRenderFailureHandler } from './slice-render-failure.js';
|
|
6
|
+
import { type SliceAnchor } from '@storystick/preview/provenance/slice-model';
|
|
7
|
+
import { type PreviewProvenancePath, type PreviewProvenancePathCarrier } from './preview-provenance.js';
|
|
8
|
+
/** A node in the ProseMirror JSON document tree. */
|
|
9
|
+
export interface RichTextNode {
|
|
10
|
+
type: string;
|
|
11
|
+
attrs?: Record<string, unknown>;
|
|
12
|
+
content?: RichTextNode[];
|
|
13
|
+
text?: string;
|
|
14
|
+
marks?: RichTextMark[];
|
|
15
|
+
}
|
|
16
|
+
/** An inline mark on a text node. */
|
|
17
|
+
export interface RichTextMark {
|
|
18
|
+
type: string;
|
|
19
|
+
attrs?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export interface RichTextBlockComponentProps {
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
text?: string;
|
|
24
|
+
/** Canonical section id authored on this heading, when present. */
|
|
25
|
+
id?: string;
|
|
26
|
+
context: RichTextRenderContext;
|
|
27
|
+
}
|
|
28
|
+
export interface RichTextCodeComponentProps extends RichTextBlockComponentProps {
|
|
29
|
+
language?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface RichTextOrderedListComponentProps {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
start?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface RichTextListComponentProps {
|
|
36
|
+
children: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
export interface RichTextMarkComponentProps {
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
context: RichTextRenderContext;
|
|
41
|
+
}
|
|
42
|
+
export interface RichTextLinkMarkComponentProps extends RichTextMarkComponentProps {
|
|
43
|
+
link: ResolvedLink;
|
|
44
|
+
title?: string;
|
|
45
|
+
}
|
|
46
|
+
export type RichTextCustomMarkComponentProps<TValue = undefined> = RichTextMarkComponentProps & (TValue extends undefined ? Record<never, never> : {
|
|
47
|
+
value: TValue;
|
|
48
|
+
});
|
|
49
|
+
type RichTextDefinitionOf<T> = NonNullable<T> extends RichTextValue<string, boolean, infer TComponents> ? TComponents : NonNullable<T> extends RichTextComponentTypes ? NonNullable<T> : RichTextComponentTypes;
|
|
50
|
+
type RichTextCustomMarksOf<T> = RichTextDefinitionOf<NonNullable<T>>['marks'];
|
|
51
|
+
type RichTextEmbedsOf<T> = RichTextDefinitionOf<NonNullable<T>>['embeds'];
|
|
52
|
+
type RichTextCustomMarkRegistry<T> = {
|
|
53
|
+
readonly [TType in keyof RichTextCustomMarksOf<T>]: ComponentType<RichTextCustomMarkComponentProps<RichTextCustomMarksOf<T>[TType]>>;
|
|
54
|
+
};
|
|
55
|
+
type RichTextEmbedRegistry<T, TContext> = SliceComponentRegistry<RichTextEmbedsOf<T>, TContext>;
|
|
56
|
+
type RegistrySection<TName extends 'marks' | 'embeds', TRegistry, TMode extends RichTextRenderMode> = TMode extends 'strict' ? {
|
|
57
|
+
readonly [TKey in TName]: TRegistry;
|
|
58
|
+
} : {
|
|
59
|
+
readonly [TKey in TName]?: Partial<TRegistry>;
|
|
60
|
+
};
|
|
61
|
+
export type RichTextRenderMode = 'permissive' | 'strict';
|
|
62
|
+
type BuiltinMarkRegistry = Partial<{
|
|
63
|
+
bold: ComponentType<RichTextMarkComponentProps>;
|
|
64
|
+
italic: ComponentType<RichTextMarkComponentProps>;
|
|
65
|
+
underline: ComponentType<RichTextMarkComponentProps>;
|
|
66
|
+
strike: ComponentType<RichTextMarkComponentProps>;
|
|
67
|
+
code: ComponentType<RichTextMarkComponentProps>;
|
|
68
|
+
link: ComponentType<RichTextLinkMarkComponentProps>;
|
|
69
|
+
}>;
|
|
70
|
+
export type RichTextComponents<T = RichTextComponentTypes, TMode extends RichTextRenderMode = 'permissive', TContext = unknown> = {
|
|
71
|
+
block?: Partial<{
|
|
72
|
+
paragraph: ComponentType<RichTextBlockComponentProps>;
|
|
73
|
+
h1: ComponentType<RichTextBlockComponentProps>;
|
|
74
|
+
h2: ComponentType<RichTextBlockComponentProps>;
|
|
75
|
+
h3: ComponentType<RichTextBlockComponentProps>;
|
|
76
|
+
h4: ComponentType<RichTextBlockComponentProps>;
|
|
77
|
+
h5: ComponentType<RichTextBlockComponentProps>;
|
|
78
|
+
h6: ComponentType<RichTextBlockComponentProps>;
|
|
79
|
+
blockquote: ComponentType<RichTextBlockComponentProps>;
|
|
80
|
+
code: ComponentType<RichTextCodeComponentProps>;
|
|
81
|
+
divider: ComponentType<Record<never, never>>;
|
|
82
|
+
}>;
|
|
83
|
+
list?: Partial<{
|
|
84
|
+
bullet: ComponentType<RichTextListComponentProps>;
|
|
85
|
+
ordered: ComponentType<RichTextOrderedListComponentProps>;
|
|
86
|
+
}>;
|
|
87
|
+
listItem?: Partial<{
|
|
88
|
+
bullet: ComponentType<RichTextListComponentProps>;
|
|
89
|
+
ordered: ComponentType<RichTextListComponentProps>;
|
|
90
|
+
}>;
|
|
91
|
+
hardBreak?: ComponentType<Record<never, never>>;
|
|
92
|
+
} & RegistrySection<'marks', RichTextCustomMarkRegistry<T> & BuiltinMarkRegistry, TMode> & RegistrySection<'embeds', RichTextEmbedRegistry<T, TContext>, TMode>;
|
|
93
|
+
interface RichTextBaseProps<TContent, TMode extends RichTextRenderMode, TContext> {
|
|
94
|
+
/** Richtext content — JSON string or parsed ProseMirror document. */
|
|
95
|
+
content: TContent;
|
|
96
|
+
/** Advanced owner for raw richtext; SDK values already carry their source. */
|
|
97
|
+
source?: ContentSource;
|
|
98
|
+
/** One semantic registry for blocks, lists, marks and embeds. */
|
|
99
|
+
components?: RichTextComponents<TContent, TMode, TContext>;
|
|
100
|
+
/** Strict requires complete custom mark/embed registries at compile time. */
|
|
101
|
+
mode?: TMode;
|
|
102
|
+
/** Framework-neutral diagnostics for malformed or unknown renderer input. */
|
|
103
|
+
onDiagnostic?: (diagnostic: RichTextRenderDiagnostic) => void;
|
|
104
|
+
/** Context passed to every embed component (same as SliceZone). */
|
|
105
|
+
context?: TContext;
|
|
106
|
+
/** Customer-owned fallback for malformed or non-renderable slice embeds. */
|
|
107
|
+
sliceFallback?: SliceFallback;
|
|
108
|
+
/** Runtime variation IDs generated from the resolved Story schema. */
|
|
109
|
+
contracts?: SliceContractRegistry;
|
|
110
|
+
/** Local observability hook shared with SliceZone. */
|
|
111
|
+
onRenderFailure?: SliceRenderFailureHandler;
|
|
112
|
+
/**
|
|
113
|
+
* Preview-only edit-binding attrs keyed by rich-text text-node path. When
|
|
114
|
+
* present, RichText wraps matching text nodes in DOM spans carrying data-ss-p.
|
|
115
|
+
* Same object the SliceZone hands each slice as `bindings`.
|
|
116
|
+
*/
|
|
117
|
+
bindings?: PreviewProvenancePathCarrier;
|
|
118
|
+
/** Path to this richtext field inside the owning provenance carrier. */
|
|
119
|
+
provenancePath?: PreviewProvenancePath;
|
|
120
|
+
/** Preview-only owning rich-text field for sliceEmbed anchoring. */
|
|
121
|
+
sliceField?: string;
|
|
122
|
+
/** Preview-only ancestry when this rich text is rendered inside a slice zone. */
|
|
123
|
+
parentAnchors?: ReadonlyArray<SliceAnchor>;
|
|
124
|
+
/** Preview-only numeric visual path of the parent slice. */
|
|
125
|
+
parentPath?: string;
|
|
126
|
+
/** CSS class for wrapper div — if omitted, renders a React fragment. */
|
|
127
|
+
className?: string;
|
|
128
|
+
/** Fallback content when richtext is empty or null. */
|
|
129
|
+
fallback?: ReactNode;
|
|
130
|
+
}
|
|
131
|
+
export type RichTextProps<TContent = unknown, TMode extends RichTextRenderMode = 'permissive', TContext = unknown> = RichTextBaseProps<TContent, TMode, TContext> & (TMode extends 'strict' ? {
|
|
132
|
+
mode: 'strict';
|
|
133
|
+
components: RichTextComponents<TContent, 'strict', TContext>;
|
|
134
|
+
} : {
|
|
135
|
+
mode?: 'permissive';
|
|
136
|
+
});
|
|
137
|
+
export type RichTextInlineProps<TContent extends RichTextValue<string, true, RichTextComponentTypes>, TMode extends RichTextRenderMode = 'permissive', TContext = unknown> = Omit<RichTextProps<TContent | null | undefined, TMode, TContext>, 'className' | 'content'> & {
|
|
138
|
+
content: TContent | null | undefined;
|
|
139
|
+
};
|
|
140
|
+
declare function RichTextRoot<TContent = unknown, TMode extends RichTextRenderMode = 'permissive', TContext = unknown>(props: RichTextProps<TContent, TMode, TContext>): ReactNode;
|
|
141
|
+
declare function RichTextInline<TContent extends RichTextValue<string, true, RichTextComponentTypes>, TMode extends RichTextRenderMode = 'permissive', TContext = unknown>(props: RichTextInlineProps<TContent, TMode, TContext>): ReactNode;
|
|
142
|
+
export declare const RichText: typeof RichTextRoot & {
|
|
143
|
+
Inline: typeof RichTextInline;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Extract plain text from richtext content.
|
|
147
|
+
* Handles both JSON string and parsed ProseMirror document.
|
|
148
|
+
*/
|
|
149
|
+
export declare function toText(content: unknown, separator?: string): string;
|
|
150
|
+
export {};
|