@dxos/react-ui-markdown 0.8.4-main.abd8ff62ef → 0.8.4-main.bc2380dfbc

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-markdown",
3
- "version": "0.8.4-main.abd8ff62ef",
3
+ "version": "0.8.4-main.bc2380dfbc",
4
4
  "description": "Markdown components.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -8,7 +8,7 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/dxos/dxos"
10
10
  },
11
- "license": "MIT",
11
+ "license": "FSL-1.1-Apache-2.0",
12
12
  "author": "DXOS.org",
13
13
  "type": "module",
14
14
  "exports": {
@@ -27,7 +27,7 @@
27
27
  "@codemirror/autocomplete": "^6.19.0",
28
28
  "@codemirror/language": "^6.11.3",
29
29
  "@codemirror/state": "^6.5.2",
30
- "@codemirror/view": "^6.38.4",
30
+ "@codemirror/view": "^6.38.5",
31
31
  "@lezer/common": "^1.2.2",
32
32
  "@lezer/highlight": "^1.2.1",
33
33
  "@lezer/markdown": "^1.3.1",
@@ -39,18 +39,18 @@
39
39
  "react-markdown": "^10.1.0",
40
40
  "react-resize-detector": "^11.0.1",
41
41
  "remark-gfm": "^4.0.1",
42
- "@dxos/async": "0.8.4-main.abd8ff62ef",
43
- "@dxos/echo": "0.8.4-main.abd8ff62ef",
44
- "@dxos/effect": "0.8.4-main.abd8ff62ef",
45
- "@dxos/invariant": "0.8.4-main.abd8ff62ef",
46
- "@dxos/react-ui": "0.8.4-main.abd8ff62ef",
47
- "@dxos/react-ui-editor": "0.8.4-main.abd8ff62ef",
48
- "@dxos/log": "0.8.4-main.abd8ff62ef",
49
- "@dxos/react-ui-syntax-highlighter": "0.8.4-main.abd8ff62ef",
50
- "@dxos/ui": "0.8.4-main.abd8ff62ef",
51
- "@dxos/ui-editor": "0.8.4-main.abd8ff62ef",
52
- "@dxos/ui-theme": "0.8.4-main.abd8ff62ef",
53
- "@dxos/util": "0.8.4-main.abd8ff62ef"
42
+ "@dxos/echo": "0.8.4-main.bc2380dfbc",
43
+ "@dxos/effect": "0.8.4-main.bc2380dfbc",
44
+ "@dxos/async": "0.8.4-main.bc2380dfbc",
45
+ "@dxos/invariant": "0.8.4-main.bc2380dfbc",
46
+ "@dxos/react-ui": "0.8.4-main.bc2380dfbc",
47
+ "@dxos/react-ui-editor": "0.8.4-main.bc2380dfbc",
48
+ "@dxos/log": "0.8.4-main.bc2380dfbc",
49
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.bc2380dfbc",
50
+ "@dxos/ui-editor": "0.8.4-main.bc2380dfbc",
51
+ "@dxos/ui": "0.8.4-main.bc2380dfbc",
52
+ "@dxos/util": "0.8.4-main.bc2380dfbc",
53
+ "@dxos/ui-theme": "0.8.4-main.bc2380dfbc"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@effect/vitest": "0.29.0",
@@ -58,23 +58,23 @@
58
58
  "@types/react-dom": "~19.2.3",
59
59
  "react": "~19.2.3",
60
60
  "react-dom": "~19.2.3",
61
- "vite": "^8.0.10",
62
- "@dxos/echo": "0.8.4-main.abd8ff62ef",
63
- "@dxos/keys": "0.8.4-main.abd8ff62ef",
64
- "@dxos/random": "0.8.4-main.abd8ff62ef",
65
- "@dxos/react-client": "0.8.4-main.abd8ff62ef",
66
- "@dxos/lit-ui": "0.8.4-main.abd8ff62ef",
67
- "@dxos/schema": "0.8.4-main.abd8ff62ef",
68
- "@dxos/react-ui": "0.8.4-main.abd8ff62ef",
69
- "@dxos/storybook-utils": "0.8.4-main.abd8ff62ef",
70
- "@dxos/ui-theme": "0.8.4-main.abd8ff62ef"
61
+ "vite": "^8.0.13",
62
+ "@dxos/keys": "0.8.4-main.bc2380dfbc",
63
+ "@dxos/echo": "0.8.4-main.bc2380dfbc",
64
+ "@dxos/lit-ui": "0.8.4-main.bc2380dfbc",
65
+ "@dxos/random": "0.8.4-main.bc2380dfbc",
66
+ "@dxos/react-client": "0.8.4-main.bc2380dfbc",
67
+ "@dxos/react-ui": "0.8.4-main.bc2380dfbc",
68
+ "@dxos/schema": "0.8.4-main.bc2380dfbc",
69
+ "@dxos/storybook-utils": "0.8.4-main.bc2380dfbc",
70
+ "@dxos/ui-theme": "0.8.4-main.bc2380dfbc"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "effect": "3.20.0",
74
74
  "react": "~19.2.3",
75
75
  "react-dom": "~19.2.3",
76
- "@dxos/ui-theme": "0.8.4-main.abd8ff62ef",
77
- "@dxos/react-ui": "0.8.4-main.abd8ff62ef"
76
+ "@dxos/react-ui": "0.8.4-main.bc2380dfbc",
77
+ "@dxos/ui-theme": "0.8.4-main.bc2380dfbc"
78
78
  },
79
79
  "publishConfig": {
80
80
  "access": "public"
@@ -37,7 +37,7 @@ import {
37
37
  navigatePreviousEffect,
38
38
  preview,
39
39
  scroller,
40
- scrollerLineEffect,
40
+ crawlerLineEffect,
41
41
  fader,
42
42
  typewriter,
43
43
  typewriterBypass,
@@ -45,7 +45,6 @@ import {
45
45
  xmlTagResetEffect,
46
46
  xmlTagUpdateEffect,
47
47
  xmlTags,
48
- autoScroll,
49
48
  documentSlots,
50
49
  xmlFormatting,
51
50
  xmlBlockDecoration,
@@ -213,14 +212,12 @@ export const MarkdownStream = forwardRef<MarkdownStreamController | null, Markdo
213
212
  return (
214
213
  <>
215
214
  {/* Markdown editor. */}
216
- <div role='none' className={mx('dx-container', classNames)} ref={parentRef} />
215
+ <div className={mx('dx-container', classNames)} ref={parentRef} />
217
216
 
218
217
  {/* React widgets are rendered in portals outside of the editor. */}
219
218
  <ErrorBoundary name='markdown-stream'>
220
219
  {widgets.map(({ Component, root, id, props }) => (
221
- <div key={id} role='none'>
222
- {createPortal(<Component view={view} {...props} />, root)}
223
- </div>
220
+ <div key={id}>{createPortal(<Component view={view} {...props} />, root)}</div>
224
221
  ))}
225
222
  {footerRoot && footerVisible && createPortal(footer, footerRoot)}
226
223
  </ErrorBoundary>
@@ -289,8 +286,7 @@ const useMarkdownStreamTextEditor = (
289
286
  hideTags: true,
290
287
  }),
291
288
  xmlTags({ registry, setWidgets, bookmarks: ['prompt'] }),
292
- scroller({ overScroll: 80 }),
293
- options?.autoScroll && autoScroll(),
289
+ scroller({ overScroll: 80, autoScroll: options?.autoScroll }),
294
290
  options?.typewriter &&
295
291
  typewriter({
296
292
  cursor: options?.cursor,
@@ -392,7 +388,7 @@ const createMarkdownStreamController = ({
392
388
  /** Scroll to bottom. */
393
389
  scrollToBottom: (behavior?: ScrollBehavior) => {
394
390
  viewRef.current?.dispatch({
395
- effects: scrollerLineEffect.of({ line: -1, behavior }),
391
+ effects: crawlerLineEffect.of({ line: -1, behavior }),
396
392
  });
397
393
  },
398
394
 
@@ -8,24 +8,24 @@ import { random } from '@dxos/random';
8
8
  import { withLayout, withTheme } from '@dxos/react-ui/testing';
9
9
  import { trim } from '@dxos/util';
10
10
 
11
- import { MarkdownBlock } from './MarkdownBlock';
11
+ import { MarkdownView } from './MarkdownView';
12
12
 
13
13
  random.seed(0);
14
14
 
15
15
  const meta = {
16
- title: 'ui/react-ui-markdown/MarkdownBlock',
17
- component: MarkdownBlock,
16
+ title: 'ui/react-ui-markdown/MarkdownView',
17
+ component: MarkdownView,
18
18
  decorators: [withTheme(), withLayout({ layout: 'column' })],
19
- } satisfies Meta<typeof MarkdownBlock>;
19
+ } satisfies Meta<typeof MarkdownView>;
20
20
 
21
21
  export default meta;
22
22
 
23
- type Story = StoryObj<typeof MarkdownBlock>;
23
+ type Story = StoryObj<typeof MarkdownView>;
24
24
 
25
25
  const content = trim`
26
26
  # Hello World!
27
27
 
28
- > An example of the MarkdownBlock component.
28
+ > An example of the MarkdownView component.
29
29
 
30
30
  ${random.lorem.paragraphs(1)}
31
31
 
@@ -6,11 +6,11 @@ import React, { type PropsWithChildren } from 'react';
6
6
  import ReactMarkdown, { type Options as ReactMarkdownOptions } from 'react-markdown';
7
7
  import remarkGfm from 'remark-gfm';
8
8
 
9
- import { type ThemedClassName } from '@dxos/react-ui';
9
+ import { MediaPlayer, type ThemedClassName } from '@dxos/react-ui';
10
10
  import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
11
11
  import { mx } from '@dxos/ui-theme';
12
12
 
13
- export type MarkdownBlockProps = ThemedClassName<
13
+ export type MarkdownViewProps = ThemedClassName<
14
14
  PropsWithChildren<{
15
15
  content?: string;
16
16
  components?: ReactMarkdownOptions['components'];
@@ -23,7 +23,7 @@ export type MarkdownBlockProps = ThemedClassName<
23
23
  * markdown -> remark -> [mdast -> remark plugins] -> [hast -> rehype plugins] -> components -> react elements.
24
24
  * Consider using @dxos/react-ui-editor.
25
25
  */
26
- export const MarkdownBlock = ({ classNames, children, components, content = '' }: MarkdownBlockProps) => {
26
+ export const MarkdownView = ({ classNames, children, components, content = '' }: MarkdownViewProps) => {
27
27
  return (
28
28
  <div className={mx(classNames)}>
29
29
  <ReactMarkdown remarkPlugins={[remarkGfm]} skipHtml components={{ ...defaultComponents, ...components }}>
@@ -44,6 +44,9 @@ const defaultComponents: ReactMarkdownOptions['components'] = {
44
44
  h3: ({ children }) => {
45
45
  return <h3 className='pt-1 pb-1 text-accent-text text-base'>{children}</h3>;
46
46
  },
47
+ h4: ({ children }) => {
48
+ return <h4 className='pt-1 pb-1 uppercase text-base'>{children}</h4>;
49
+ },
47
50
  blockquote: ({ children, ...props }) => (
48
51
  <blockquote className='my-2 py-2 ps-4 border-l-4 border-accent-text text-accent-text' {...props}>
49
52
  {children}
@@ -63,6 +66,19 @@ const defaultComponents: ReactMarkdownOptions['components'] = {
63
66
  {children}
64
67
  </a>
65
68
  ),
69
+ // Hide broken images: many markdown sources reference remote URLs that
70
+ // 404 or are blocked. Drop the element on load failure rather than
71
+ // leaving the browser's broken-image placeholder.
72
+ //
73
+ // Media URLs (mp4/mp3/etc. or legacy `iframe`-style embeds) are swapped to a
74
+ // native `<video>` / `<audio>` element by {@link MediaPlayer} so playable
75
+ // media in the source document renders inline.
76
+ img: ({ src, alt }) => {
77
+ if (!src) {
78
+ return null;
79
+ }
80
+ return <MediaPlayer src={src} alt={alt} mediaClassNames='aspect-video w-full' imgClassNames='w-full' />;
81
+ },
66
82
  ol: ({ children, ...props }) => (
67
83
  <ol className='pt-1 pb-1 ps-6 leading-tight list-decimal' {...props}>
68
84
  {children}
@@ -2,4 +2,4 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './MarkdownBlock';
5
+ export * from './MarkdownView';
package/src/index.ts CHANGED
@@ -2,5 +2,5 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './MarkdownBlock';
5
+ export * from './MarkdownView';
6
6
  export * from './MarkdownStream';
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownBlock.d.ts","sourceRoot":"","sources":["../../../../src/MarkdownBlock/MarkdownBlock.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACtD,OAAsB,EAAE,KAAK,OAAO,IAAI,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGrF,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAC9C,iBAAiB,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAC;CACjD,CAAC,CACH,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,kDAAwD,kBAAkB,sBASnG,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownBlock.stories.d.ts","sourceRoot":"","sources":["../../../../src/MarkdownBlock/MarkdownBlock.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAMjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD,QAAA,MAAM,IAAI;;;;CAI4B,CAAC;eAExB,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,aAAa,CAAC,CAAC;AA+C5C,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './MarkdownBlock';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/MarkdownBlock/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC"}