@promptbook/components 0.112.0-100 → 0.112.0-102
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/esm/index.es.js +39 -4
- package/esm/index.es.js.map +1 -1
- package/esm/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +1 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +39 -4
- package/umd/index.umd.js.map +1 -1
- package/umd/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +1 -0
- package/umd/src/version.d.ts +1 -1
package/esm/src/version.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.112.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.112.0-101`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* @generated
|
|
32
32
|
* @see https://github.com/webgptorg/promptbook
|
|
33
33
|
*/
|
|
34
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
34
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-102';
|
|
35
35
|
/**
|
|
36
36
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
37
37
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -22176,6 +22176,23 @@
|
|
|
22176
22176
|
* @private utility of `MarkdownContent` component
|
|
22177
22177
|
*/
|
|
22178
22178
|
const DETAILS_SUMMARY_SELECTOR = 'summary';
|
|
22179
|
+
/**
|
|
22180
|
+
* Resolves the active document theme when a host application does not pass an explicit theme.
|
|
22181
|
+
*
|
|
22182
|
+
* @private utility of `MarkdownContent` component
|
|
22183
|
+
*/
|
|
22184
|
+
function resolveMarkdownContentTheme(explicitTheme) {
|
|
22185
|
+
if (explicitTheme) {
|
|
22186
|
+
return explicitTheme;
|
|
22187
|
+
}
|
|
22188
|
+
if (typeof document !== 'undefined') {
|
|
22189
|
+
const resolvedTheme = document.documentElement.dataset.themeResolved;
|
|
22190
|
+
if (resolvedTheme === 'dark' || document.documentElement.classList.contains('dark')) {
|
|
22191
|
+
return 'DARK';
|
|
22192
|
+
}
|
|
22193
|
+
}
|
|
22194
|
+
return 'LIGHT';
|
|
22195
|
+
}
|
|
22179
22196
|
/**
|
|
22180
22197
|
* Returns a stable key for a `<details>` element based on its `<summary>` text.
|
|
22181
22198
|
* Used to identify and restore open state across re-renders.
|
|
@@ -22231,16 +22248,34 @@
|
|
|
22231
22248
|
* @public exported from `@promptbook/components`
|
|
22232
22249
|
*/
|
|
22233
22250
|
const MarkdownContent = react.memo(function MarkdownContent(props) {
|
|
22234
|
-
const { content, className, onCreateAgent } = props;
|
|
22251
|
+
const { content, className, onCreateAgent, theme } = props;
|
|
22235
22252
|
const htmlContent = react.useMemo(() => renderMarkdown(content, {
|
|
22236
22253
|
citationReferenceClassName: styles$b.citationRef,
|
|
22237
22254
|
}), [content]);
|
|
22255
|
+
const [resolvedTheme, setResolvedTheme] = react.useState(() => resolveMarkdownContentTheme(theme));
|
|
22238
22256
|
const containerRef = react.useRef(null);
|
|
22239
22257
|
const rootsRef = react.useRef([]);
|
|
22240
22258
|
/** Tracks which `<details>` elements (by summary key) are currently open */
|
|
22241
22259
|
const openDetailsKeysRef = react.useRef(new Set());
|
|
22242
22260
|
const onCreateAgentRef = react.useRef(onCreateAgent);
|
|
22243
22261
|
onCreateAgentRef.current = onCreateAgent;
|
|
22262
|
+
react.useEffect(() => {
|
|
22263
|
+
if (theme) {
|
|
22264
|
+
setResolvedTheme(theme);
|
|
22265
|
+
return;
|
|
22266
|
+
}
|
|
22267
|
+
const updateTheme = () => setResolvedTheme(resolveMarkdownContentTheme());
|
|
22268
|
+
updateTheme();
|
|
22269
|
+
if (typeof document === 'undefined' || typeof MutationObserver === 'undefined') {
|
|
22270
|
+
return;
|
|
22271
|
+
}
|
|
22272
|
+
const observer = new MutationObserver(updateTheme);
|
|
22273
|
+
observer.observe(document.documentElement, {
|
|
22274
|
+
attributes: true,
|
|
22275
|
+
attributeFilter: ['class', 'data-theme-resolved'],
|
|
22276
|
+
});
|
|
22277
|
+
return () => observer.disconnect();
|
|
22278
|
+
}, [theme]);
|
|
22244
22279
|
react.useEffect(() => {
|
|
22245
22280
|
// Cleanup previous roots
|
|
22246
22281
|
rootsRef.current.forEach((root) => root.unmount());
|
|
@@ -22313,7 +22348,7 @@
|
|
|
22313
22348
|
pre.appendChild(mountPoint);
|
|
22314
22349
|
// Render CodeBlock
|
|
22315
22350
|
const root = client.createRoot(mountPoint);
|
|
22316
|
-
root.render(jsxRuntime.jsx(CodeBlock, { code: code, language: language, onCreateAgent: onCreateAgentRef.current }));
|
|
22351
|
+
root.render(jsxRuntime.jsx(CodeBlock, { code: code, language: language, onCreateAgent: onCreateAgentRef.current, theme: resolvedTheme }));
|
|
22317
22352
|
rootsRef.current.push(root);
|
|
22318
22353
|
});
|
|
22319
22354
|
return () => {
|
|
@@ -22324,7 +22359,7 @@
|
|
|
22324
22359
|
rootsRef.current.forEach((root) => root.unmount());
|
|
22325
22360
|
rootsRef.current = [];
|
|
22326
22361
|
};
|
|
22327
|
-
}, [htmlContent]);
|
|
22362
|
+
}, [htmlContent, resolvedTheme]);
|
|
22328
22363
|
return (jsxRuntime.jsx("div", { ref: containerRef, className: classNames(styles$b.MarkdownContent, className), dangerouslySetInnerHTML: {
|
|
22329
22364
|
__html: htmlContent,
|
|
22330
22365
|
} }));
|