@xh/hoist 69.0.0-SNAPSHOT.1727288627891 → 69.0.0-SNAPSHOT.1727461290353

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/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## 69.0.0-SNAPSHOT - unreleased
4
4
 
5
+ ### 🎁 New Features
6
+
7
+ * `Markdown` now supports a `reactMarkdownOptions` prop to allow passing React Markdown
8
+ props to the underlying `reactMarkdown` instance.
9
+
5
10
  ### ⚙️ Technical
6
11
  * Misc. Improvements to Cluster Tab in Admin Panel.
7
12
 
@@ -1,17 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import { HoistProps } from '@xh/hoist/core';
3
- import { Components } from 'react-markdown';
3
+ import { Options } from 'react-markdown';
4
4
  interface MarkdownProps extends HoistProps {
5
5
  /** Markdown formatted string to render. */
6
6
  content: string;
7
- /**
8
- * Map of html tag to tag or functional component to control rendering of standard html
9
- * elements. See https://www.npmjs.com/package/react-markdown/v/8.0.6#appendix-b-components
10
- * for details.
11
- */
12
- components?: Components;
13
7
  /** True (default) to render new lines with <br/> tags. */
14
8
  lineBreaks?: boolean;
9
+ /** Escape hatch to provide additional options to the React Markdown implementation */
10
+ reactMarkdownOptions?: Partial<Options>;
15
11
  }
16
12
  /**
17
13
  * Render Markdown formatted strings as HTML (e.g. **foo** becomes <strong>foo</strong>).
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import {hoistCmp, HoistProps} from '@xh/hoist/core';
8
8
  import {reactMarkdown} from '@xh/hoist/kit/react-markdown';
9
- import {Components} from 'react-markdown';
9
+ import {Options} from 'react-markdown';
10
10
  import remarkBreaks from 'remark-breaks';
11
11
  import remarkGfm from 'remark-gfm';
12
12
  import {PluggableList} from 'unified/lib';
@@ -15,15 +15,11 @@ interface MarkdownProps extends HoistProps {
15
15
  /** Markdown formatted string to render. */
16
16
  content: string;
17
17
 
18
- /**
19
- * Map of html tag to tag or functional component to control rendering of standard html
20
- * elements. See https://www.npmjs.com/package/react-markdown/v/8.0.6#appendix-b-components
21
- * for details.
22
- */
23
- components?: Components;
24
-
25
18
  /** True (default) to render new lines with <br/> tags. */
26
19
  lineBreaks?: boolean;
20
+
21
+ /** Escape hatch to provide additional options to the React Markdown implementation */
22
+ reactMarkdownOptions?: Partial<Options>;
27
23
  }
28
24
 
29
25
  /**
@@ -34,13 +30,18 @@ interface MarkdownProps extends HoistProps {
34
30
  */
35
31
  export const [Markdown, markdown] = hoistCmp.withFactory<MarkdownProps>({
36
32
  displayName: 'Markdown',
37
- render({content, lineBreaks = true, components = {}}) {
38
- const remarkPlugins: PluggableList = [remarkGfm];
33
+ render({content, lineBreaks = true, reactMarkdownOptions = {}}) {
34
+ // add default remark plugins, ensure app provided takes precedence
35
+ const remarkPlugins: PluggableList = [],
36
+ appRemarkPlugins = reactMarkdownOptions.remarkPlugins;
37
+ if (appRemarkPlugins) remarkPlugins.push(...appRemarkPlugins);
39
38
  if (lineBreaks) remarkPlugins.push(remarkBreaks);
39
+ remarkPlugins.push(remarkGfm);
40
+
40
41
  return reactMarkdown({
41
42
  item: content,
42
- remarkPlugins,
43
- components
43
+ ...reactMarkdownOptions,
44
+ remarkPlugins
44
45
  });
45
46
  }
46
47
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "69.0.0-SNAPSHOT.1727288627891",
3
+ "version": "69.0.0-SNAPSHOT.1727461290353",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",