react-intlayer 7.6.0-canary.0 → 8.0.0-canary.2
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/assets/markdown/_fixture.md +896 -0
- package/dist/cjs/client/IntlayerProvider.cjs +30 -3
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/format/index.cjs +2 -0
- package/dist/cjs/client/format/useIntl.cjs +45 -0
- package/dist/cjs/client/format/useIntl.cjs.map +1 -0
- package/dist/cjs/client/t.cjs +21 -2
- package/dist/cjs/client/t.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +16 -3
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +27 -7
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +2 -0
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +2 -0
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/html/HTMLProvider.cjs +18 -0
- package/dist/cjs/html/HTMLProvider.cjs.map +1 -0
- package/dist/cjs/html/HTMLRenderer.cjs +59 -0
- package/dist/cjs/html/HTMLRenderer.cjs.map +1 -0
- package/dist/cjs/html/HTMLRendererPlugin.cjs +36 -0
- package/dist/cjs/html/HTMLRendererPlugin.cjs.map +1 -0
- package/dist/cjs/html/index.cjs +11 -0
- package/dist/cjs/html/types.cjs +0 -0
- package/dist/cjs/index.cjs +13 -1
- package/dist/cjs/markdown/MarkdownProvider.cjs +76 -5
- package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +192 -32
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRendererPlugin.cjs +33 -0
- package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -0
- package/dist/cjs/markdown/index.cjs +19 -2
- package/dist/cjs/markdown/processor.cjs +61 -0
- package/dist/cjs/markdown/processor.cjs.map +1 -0
- package/dist/cjs/markdown/runtime.cjs +45 -0
- package/dist/cjs/markdown/runtime.cjs.map +1 -0
- package/dist/cjs/plugins.cjs +83 -7
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/reactElement/renderReactElement.cjs +8 -8
- package/dist/cjs/reactElement/renderReactElement.cjs.map +1 -1
- package/dist/cjs/server/IntlayerServerProvider.cjs +2 -2
- package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
- package/dist/cjs/server/format/useIntl.cjs +44 -0
- package/dist/cjs/server/format/useIntl.cjs.map +1 -0
- package/dist/cjs/server/index.cjs +2 -0
- package/dist/esm/IntlayerNode.mjs +2 -2
- package/dist/esm/IntlayerNode.mjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs +30 -3
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/format/index.mjs +2 -1
- package/dist/esm/client/format/useIntl.mjs +44 -0
- package/dist/esm/client/format/useIntl.mjs.map +1 -0
- package/dist/esm/client/t.mjs +21 -2
- package/dist/esm/client/t.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +16 -3
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +27 -7
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/editor/IntlayerEditorProvider.mjs +3 -3
- package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +3 -1
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +3 -1
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/html/HTMLProvider.mjs +16 -0
- package/dist/esm/html/HTMLProvider.mjs.map +1 -0
- package/dist/esm/html/HTMLRenderer.mjs +55 -0
- package/dist/esm/html/HTMLRenderer.mjs.map +1 -0
- package/dist/esm/html/HTMLRendererPlugin.mjs +35 -0
- package/dist/esm/html/HTMLRendererPlugin.mjs.map +1 -0
- package/dist/esm/html/index.mjs +5 -0
- package/dist/esm/html/types.mjs +0 -0
- package/dist/esm/index.mjs +5 -1
- package/dist/esm/markdown/MarkdownProvider.mjs +76 -5
- package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs +191 -32
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRendererPlugin.mjs +31 -0
- package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -0
- package/dist/esm/markdown/index.mjs +5 -2
- package/dist/esm/markdown/processor.mjs +54 -0
- package/dist/esm/markdown/processor.mjs.map +1 -0
- package/dist/esm/markdown/runtime.mjs +41 -0
- package/dist/esm/markdown/runtime.mjs.map +1 -0
- package/dist/esm/plugins.mjs +82 -8
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/reactElement/renderReactElement.mjs +8 -8
- package/dist/esm/reactElement/renderReactElement.mjs.map +1 -1
- package/dist/esm/server/IntlayerServerProvider.mjs +2 -2
- package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
- package/dist/esm/server/format/useIntl.mjs +42 -0
- package/dist/esm/server/format/useIntl.mjs.map +1 -0
- package/dist/esm/server/index.mjs +2 -1
- package/dist/types/IntlayerNode.d.ts.map +1 -1
- package/dist/types/UI/ContentSelector.d.ts.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts +50 -5
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/format/index.d.ts +2 -1
- package/dist/types/client/format/useCompact.d.ts +2 -3
- package/dist/types/client/format/useCompact.d.ts.map +1 -1
- package/dist/types/client/format/useCurrency.d.ts +2 -3
- package/dist/types/client/format/useCurrency.d.ts.map +1 -1
- package/dist/types/client/format/useDate.d.ts +0 -1
- package/dist/types/client/format/useDate.d.ts.map +1 -1
- package/dist/types/client/format/useIntl.d.ts +92 -0
- package/dist/types/client/format/useIntl.d.ts.map +1 -0
- package/dist/types/client/format/useList.d.ts +2 -3
- package/dist/types/client/format/useList.d.ts.map +1 -1
- package/dist/types/client/format/useNumber.d.ts +2 -3
- package/dist/types/client/format/useNumber.d.ts.map +1 -1
- package/dist/types/client/format/usePercentage.d.ts +2 -3
- package/dist/types/client/format/usePercentage.d.ts.map +1 -1
- package/dist/types/client/format/useRelativeTime.d.ts +2 -3
- package/dist/types/client/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/client/format/useUnit.d.ts +2 -3
- package/dist/types/client/format/useUnit.d.ts.map +1 -1
- package/dist/types/client/t.d.ts +21 -3
- package/dist/types/client/t.d.ts.map +1 -1
- package/dist/types/client/useDictionary.d.ts +2 -3
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryAsync.d.ts +0 -1
- package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +0 -1
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useI18n.d.ts +0 -1
- package/dist/types/client/useI18n.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +18 -6
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +21 -1
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useLocaleBase.d.ts +5 -5
- package/dist/types/client/useLocaleBase.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +5 -6
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/client/useTraduction.d.ts +0 -1
- package/dist/types/client/useTraduction.d.ts.map +1 -1
- package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
- package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
- package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/html/HTMLProvider.d.ts +17 -0
- package/dist/types/html/HTMLProvider.d.ts.map +1 -0
- package/dist/types/html/HTMLRenderer.d.ts +46 -0
- package/dist/types/html/HTMLRenderer.d.ts.map +1 -0
- package/dist/types/html/HTMLRendererPlugin.d.ts +15 -0
- package/dist/types/html/HTMLRendererPlugin.d.ts.map +1 -0
- package/dist/types/html/index.d.ts +5 -0
- package/dist/types/html/types.d.ts +26 -0
- package/dist/types/html/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownProvider.d.ts +42 -3
- package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts +251 -11
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts +19 -0
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -0
- package/dist/types/markdown/index.d.ts +6 -3
- package/dist/types/markdown/processor.d.ts +92 -0
- package/dist/types/markdown/processor.d.ts.map +1 -0
- package/dist/types/markdown/runtime.d.ts +19 -0
- package/dist/types/markdown/runtime.d.ts.map +1 -0
- package/dist/types/plugins.d.ts +35 -13
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/reactElement/renderReactElement.d.ts +2 -2
- package/dist/types/reactElement/renderReactElement.d.ts.map +1 -1
- package/dist/types/server/IntlayerServerProvider.d.ts +2 -2
- package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -1
- package/dist/types/server/format/useCompact.d.ts +0 -1
- package/dist/types/server/format/useCompact.d.ts.map +1 -1
- package/dist/types/server/format/useCurrency.d.ts +0 -1
- package/dist/types/server/format/useCurrency.d.ts.map +1 -1
- package/dist/types/server/format/useDate.d.ts +0 -1
- package/dist/types/server/format/useDate.d.ts.map +1 -1
- package/dist/types/server/format/useIntl.d.ts +92 -0
- package/dist/types/server/format/useIntl.d.ts.map +1 -0
- package/dist/types/server/format/useList.d.ts +0 -1
- package/dist/types/server/format/useList.d.ts.map +1 -1
- package/dist/types/server/format/useNumber.d.ts +0 -1
- package/dist/types/server/format/useNumber.d.ts.map +1 -1
- package/dist/types/server/format/usePercentage.d.ts +0 -1
- package/dist/types/server/format/usePercentage.d.ts.map +1 -1
- package/dist/types/server/format/useRelativeTime.d.ts +0 -1
- package/dist/types/server/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/server/format/useUnit.d.ts +0 -1
- package/dist/types/server/format/useUnit.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +2 -1
- package/dist/types/server/serverContext.d.ts +0 -1
- package/dist/types/server/serverContext.d.ts.map +1 -1
- package/dist/types/server/t.d.ts +0 -1
- package/dist/types/server/t.d.ts.map +1 -1
- package/dist/types/server/useDictionary.d.ts +2 -3
- package/dist/types/server/useDictionary.d.ts.map +1 -1
- package/dist/types/server/useDictionaryAsync.d.ts +2 -3
- package/dist/types/server/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/server/useDictionaryDynamic.d.ts +0 -1
- package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/server/useI18n.d.ts +0 -1
- package/dist/types/server/useI18n.d.ts.map +1 -1
- package/dist/types/server/useIntlayer.d.ts +3 -3
- package/dist/types/server/useIntlayer.d.ts.map +1 -1
- package/dist/types/server/useLoadDynamic.d.ts.map +1 -1
- package/dist/types/server/useLocale.d.ts.map +1 -1
- package/package.json +22 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HTMLRendererPlugin.d.ts","names":[],"sources":["../../../src/html/HTMLRendererPlugin.tsx"],"mappings":";;;;KAWK,uBAAA;EACH,aAAA;EACA,OAAA,EAAS,OAAA;EACT,IAAA;EACA,MAAA,GAAS,MAAA;EACT,cAAA,GAAiB,MAAA;AAAA;AAAA,cAGN,kBAAA,EAAoB,EAAA,CAAG,uBAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { HTMLProvider, useHTMLContext } from "./HTMLProvider.js";
|
|
2
|
+
import { ExtractTags, ReactComponentProps, ReactHTMLComponent, ReactHTMLComponentMap } from "./types.js";
|
|
3
|
+
import { HTMLRenderer, HTMLRendererProps, RenderHTMLProps, defaultHTMLComponents, renderHTML, useHTMLRenderer } from "./HTMLRenderer.js";
|
|
4
|
+
import { HTMLRendererPlugin } from "./HTMLRendererPlugin.js";
|
|
5
|
+
export { ExtractTags, HTMLProvider, HTMLRenderer, HTMLRendererPlugin, HTMLRendererProps, ReactComponentProps, ReactHTMLComponent, ReactHTMLComponentMap, RenderHTMLProps, defaultHTMLComponents, renderHTML, useHTMLContext, useHTMLRenderer };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BaseHTMLProps, ExtractTags } from "@intlayer/core";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/html/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Props for React HTML components
|
|
7
|
+
* Extends base HTML props with ReactNode children
|
|
8
|
+
*/
|
|
9
|
+
interface ReactComponentProps extends BaseHTMLProps {
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* React HTML component function type
|
|
14
|
+
*/
|
|
15
|
+
type ReactHTMLComponent = (props: ReactComponentProps) => ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Component map type for React
|
|
18
|
+
* - Standard HTML tags are optional (Partial)
|
|
19
|
+
* - Custom components are required
|
|
20
|
+
*/
|
|
21
|
+
type ReactHTMLComponentMap<T = never> = (T extends Record<string, any> ? { [K in keyof T]: (props: T[K] & {
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
}) => ReactNode } : T extends string ? { [K in T]: ReactHTMLComponent } : {}) & Partial<Record<string, ReactHTMLComponent>>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { type ExtractTags, ReactComponentProps, ReactHTMLComponent, ReactHTMLComponentMap };
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/html/types.ts"],"mappings":";;;;;;AAOA;;UAAiB,mBAAA,SAA4B,aAAA;EAC3C,QAAA,GAAW,SAAA;AAAA;;;;KAMD,kBAAA,IAAsB,KAAA,EAAO,mBAAA,KAAwB,SAAA;AAAjE;;;;;AAAA,KAOY,qBAAA,eAAoC,CAAA,SAAU,MAAA,8BACxC,CAAA,IAAK,KAAA,EAAO,CAAA,CAAE,CAAA;EAAO,QAAA,GAAW,SAAA;AAAA,MAAgB,SAAA,KAC9D,CAAA,0BACU,CAAA,GAAI,kBAAA,WAEhB,OAAA,CAAQ,MAAA,SAAe,kBAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IntlayerNode } from "./IntlayerNode.js";
|
|
2
2
|
import { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, IntlayerProviderProps, useIntlayerContext } from "./client/IntlayerProvider.js";
|
|
3
|
+
import { useIntl } from "./client/format/useIntl.js";
|
|
3
4
|
import { t } from "./client/t.js";
|
|
4
5
|
import { IInterpreterPluginReact } from "./plugins.js";
|
|
5
6
|
import { useDictionary } from "./client/useDictionary.js";
|
|
@@ -13,13 +14,18 @@ import { useLocaleBase } from "./client/useLocaleBase.js";
|
|
|
13
14
|
import { localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage } from "./client/useLocaleStorage.js";
|
|
14
15
|
import { getDictionary } from "./getDictionary.js";
|
|
15
16
|
import { getIntlayer } from "./getIntlayer.js";
|
|
17
|
+
import { HTMLProvider } from "./html/HTMLProvider.js";
|
|
18
|
+
import { HTMLRenderer, HTMLRendererProps, RenderHTMLProps, renderHTML, useHTMLRenderer } from "./html/HTMLRenderer.js";
|
|
19
|
+
import "./html/index.js";
|
|
16
20
|
import { MarkdownProvider } from "./markdown/MarkdownProvider.js";
|
|
21
|
+
import { MarkdownRenderer, MarkdownRendererProps, RenderMarkdownProps, renderMarkdown, useMarkdownRenderer } from "./markdown/MarkdownRenderer.js";
|
|
17
22
|
import "./markdown/index.js";
|
|
23
|
+
import { LocalesValues } from "@intlayer/types";
|
|
18
24
|
|
|
19
25
|
//#region src/index.d.ts
|
|
20
26
|
declare module '@intlayer/core' {
|
|
21
|
-
interface IInterpreterPlugin<T, S, L> extends IInterpreterPluginReact<T> {}
|
|
27
|
+
interface IInterpreterPlugin<T, S, L extends LocalesValues> extends IInterpreterPluginReact<T, S, L> {}
|
|
22
28
|
}
|
|
23
29
|
//#endregion
|
|
24
|
-
export { IntlayerClientContext, type IntlayerNode, IntlayerProvider, IntlayerProviderContent, type IntlayerProviderProps, MarkdownProvider, getDictionary, getIntlayer, localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useI18n, useIntlayer, useIntlayerContext, useLoadDynamic, useLocale, useLocaleBase, useLocaleCookie, useLocaleStorage };
|
|
30
|
+
export { HTMLProvider, HTMLRenderer, type HTMLRendererProps, IntlayerClientContext, type IntlayerNode, IntlayerProvider, IntlayerProviderContent, type IntlayerProviderProps, MarkdownProvider, MarkdownRenderer, type MarkdownRendererProps, type RenderHTMLProps, type RenderMarkdownProps, getDictionary, getIntlayer, localeCookie, localeInStorage, renderHTML, renderMarkdown, setLocaleCookie, setLocaleInStorage, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useHTMLRenderer, useI18n, useIntl, useIntlayer, useIntlayerContext, useLoadDynamic, useLocale, useLocaleBase, useLocaleCookie, useLocaleStorage, useMarkdownRenderer };
|
|
25
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAIY,kBAAA,iBAAmC,aAAA,UACnC,uBAAA,CAAwB,CAAA,EAAG,CAAA,EAAG,CAAA;AAAA"}
|
|
@@ -1,12 +1,51 @@
|
|
|
1
|
+
import { Overrides } from "@intlayer/core";
|
|
1
2
|
import { FC, PropsWithChildren, ReactNode } from "react";
|
|
2
3
|
|
|
3
4
|
//#region src/markdown/MarkdownProvider.d.ts
|
|
5
|
+
type MarkdownProviderOptions = {
|
|
6
|
+
/** Forces the compiler to always output content with a block-level wrapper. */forceBlock?: boolean; /** Forces the compiler to always output content with an inline wrapper. */
|
|
7
|
+
forceInline?: boolean; /** Whether to preserve frontmatter in the markdown content. */
|
|
8
|
+
preserveFrontmatter?: boolean; /** Whether to use the GitHub Tag Filter for security. */
|
|
9
|
+
tagfilter?: boolean;
|
|
10
|
+
};
|
|
11
|
+
type RenderMarkdownOptions = MarkdownProviderOptions & {
|
|
12
|
+
components?: Overrides;
|
|
13
|
+
wrapper?: FC<any>;
|
|
14
|
+
};
|
|
4
15
|
type MarkdownContextValue = {
|
|
5
|
-
renderMarkdown: (markdown: string) => ReactNode;
|
|
16
|
+
renderMarkdown: (markdown: string, components?: Overrides | RenderMarkdownOptions) => ReactNode;
|
|
6
17
|
};
|
|
7
|
-
type MarkdownProviderProps = PropsWithChildren<
|
|
18
|
+
type MarkdownProviderProps = PropsWithChildren<MarkdownProviderOptions & {
|
|
19
|
+
components?: Overrides;
|
|
20
|
+
wrapper?: any;
|
|
21
|
+
renderMarkdown?: (markdown: string, overrides?: Overrides | RenderMarkdownOptions) => ReactNode;
|
|
22
|
+
}>;
|
|
8
23
|
declare const useMarkdownContext: () => MarkdownContextValue;
|
|
24
|
+
/**
|
|
25
|
+
* Provider for the MarkdownRenderer component.
|
|
26
|
+
*
|
|
27
|
+
* It will provide the `renderMarkdown` function to the context, which can be used to render markdown.
|
|
28
|
+
*
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const content = useIntlayer('app');
|
|
31
|
+
*
|
|
32
|
+
* return (
|
|
33
|
+
* <div>
|
|
34
|
+
* {content.markdown} // Will be rendered with the components and options provided to the MarkdownProvider
|
|
35
|
+
* </div>
|
|
36
|
+
* );
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <MarkdownProvider components={{ h1: CustomHeading }}>
|
|
42
|
+
* <MarkdownRenderer>
|
|
43
|
+
* {markdownContent}
|
|
44
|
+
* </MarkdownRenderer>
|
|
45
|
+
* </MarkdownProvider>
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
9
48
|
declare const MarkdownProvider: FC<MarkdownProviderProps>;
|
|
10
49
|
//#endregion
|
|
11
|
-
export { MarkdownProvider, useMarkdownContext };
|
|
50
|
+
export { MarkdownProvider, MarkdownProviderOptions, useMarkdownContext };
|
|
12
51
|
//# sourceMappingURL=MarkdownProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownProvider.d.ts","names":[],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"
|
|
1
|
+
{"version":3,"file":"MarkdownProvider.d.ts","names":[],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"mappings":";;;;KAYY,uBAAA;iFAEV,UAAA,YAFiC;EAIjC,WAAA,YAJiC;EAMjC,mBAAA,YAFA;EAIA,SAAA;AAAA;AAAA,KAGG,qBAAA,GAAwB,uBAAA;EAC3B,UAAA,GAAa,SAAA;EACb,OAAA,GAAU,EAAA;AAAA;AAAA,KAGP,oBAAA;EACH,cAAA,GACE,QAAA,UACA,UAAA,GAAa,SAAA,GAAY,qBAAA,KACtB,SAAA;AAAA;AAAA,KAGF,qBAAA,GAAwB,iBAAA,CAC3B,uBAAA;EACE,UAAA,GAAa,SAAA;EACb,OAAA;EACA,cAAA,IACE,QAAA,UACA,SAAA,GAAY,SAAA,GAAY,qBAAA,KACrB,SAAA;AAAA;AAAA,cAQI,kBAAA,QAAkB,oBAAA;;;;;AAzBjB;;;;;;;;;;;;;;;;AAOE;;;;cAsGH,gBAAA,EAAkB,EAAA,CAAG,qBAAA"}
|
|
@@ -1,18 +1,258 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { MarkdownProviderOptions } from "./MarkdownProvider.js";
|
|
2
|
+
import { Overrides } from "@intlayer/core";
|
|
3
|
+
import * as react0 from "react";
|
|
4
|
+
import { FC, JSX, ReactNode } from "react";
|
|
3
5
|
|
|
4
6
|
//#region src/markdown/MarkdownRenderer.d.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Props for rendering markdown content.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const props: RenderMarkdownProps = {
|
|
13
|
+
* components: {
|
|
14
|
+
* h1: ({ children }) => <h1 className="text-3xl">{children}</h1>,
|
|
15
|
+
* p: ({ children }) => <p className="text-gray-700">{children}</p>,
|
|
16
|
+
* },
|
|
17
|
+
* wrapper: ({ children }) => <article>{children}</article>,
|
|
18
|
+
* options: {
|
|
19
|
+
* forceBlock: true,
|
|
20
|
+
* preserveFrontmatter: false,
|
|
21
|
+
* tagfilter: true,
|
|
22
|
+
* },
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
type RenderMarkdownProps = MarkdownProviderOptions & {
|
|
27
|
+
/**
|
|
28
|
+
* Component overrides for HTML tags.
|
|
29
|
+
* Allows you to customize how specific HTML elements are rendered.
|
|
30
|
+
* Only used if not wrapped in a MarkdownProvider.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* components={{
|
|
35
|
+
* h1: ({ children }) => <h1 className="title">{children}</h1>,
|
|
36
|
+
* a: ({ href, children }) => <Link to={href}>{children}</Link>,
|
|
37
|
+
* }}
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
components?: Overrides;
|
|
41
|
+
/**
|
|
42
|
+
* Wrapper element or component to be used when there are multiple children.
|
|
43
|
+
* Only used if not wrapped in a MarkdownProvider.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* wrapper={({ children }) => <div className="markdown-content">{children}</div>}
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
wrapper?: FC;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Renders markdown content to JSX with the provided components and options.
|
|
54
|
+
*
|
|
55
|
+
* This function does not use context from MarkdownProvider. Use `useMarkdownRenderer`
|
|
56
|
+
* hook if you want to leverage provider context.
|
|
57
|
+
*
|
|
58
|
+
* @param content - The markdown string to render
|
|
59
|
+
* @param props - Configuration options for rendering
|
|
60
|
+
* @param props.components - Component overrides for HTML tags
|
|
61
|
+
* @param props.wrapper - Wrapper component for multiple children
|
|
62
|
+
* @returns JSX element representing the rendered markdown
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* import { renderMarkdown } from '@intlayer/react-intlayer/markdown';
|
|
67
|
+
*
|
|
68
|
+
* const markdown = '# Hello World\n\nThis is **bold** text.';
|
|
69
|
+
* const jsx = renderMarkdown(markdown, {
|
|
70
|
+
* components: {
|
|
71
|
+
* h1: ({ children }) => <h1 className="title">{children}</h1>,
|
|
72
|
+
* },
|
|
73
|
+
* forceBlock: true,
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
declare const renderMarkdown: (content: string, {
|
|
78
|
+
components,
|
|
79
|
+
wrapper,
|
|
80
|
+
forceBlock,
|
|
81
|
+
forceInline,
|
|
82
|
+
preserveFrontmatter,
|
|
83
|
+
tagfilter
|
|
84
|
+
}?: RenderMarkdownProps) => JSX.Element;
|
|
85
|
+
/**
|
|
86
|
+
* Hook that returns a function to render markdown content.
|
|
87
|
+
*
|
|
88
|
+
* This hook considers the configuration from the `MarkdownProvider` context if available,
|
|
89
|
+
* falling back to the provided props or default behavior.
|
|
90
|
+
*
|
|
91
|
+
* @param props - Optional configuration that will override context values
|
|
92
|
+
* @param props.components - Component overrides for HTML tags (overrides context)
|
|
93
|
+
* @param props.wrapper - Wrapper component (overrides context)
|
|
94
|
+
* @returns A function that takes markdown content and returns JSX
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```tsx
|
|
98
|
+
* import { useMarkdownRenderer } from '@intlayer/react-intlayer/markdown';
|
|
99
|
+
*
|
|
100
|
+
* function MyComponent() {
|
|
101
|
+
* const renderMarkdown = useMarkdownRenderer({
|
|
102
|
+
* components: {
|
|
103
|
+
* h1: ({ children }) => <h1 className="custom">{children}</h1>,
|
|
104
|
+
* },
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* return (
|
|
108
|
+
* <div>
|
|
109
|
+
* {renderMarkdown('# Hello\n\nThis is **markdown**')}
|
|
110
|
+
* </div>
|
|
111
|
+
* );
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```tsx
|
|
117
|
+
* // With MarkdownProvider context
|
|
118
|
+
* function App() {
|
|
119
|
+
* return (
|
|
120
|
+
* <MarkdownProvider
|
|
121
|
+
* components={{ h1: CustomHeading }}
|
|
122
|
+
* forceBlock={true}
|
|
123
|
+
* >
|
|
124
|
+
* <MyComponent />
|
|
125
|
+
* </MarkdownProvider>
|
|
126
|
+
* );
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
declare const useMarkdownRenderer: ({
|
|
131
|
+
components,
|
|
132
|
+
wrapper,
|
|
133
|
+
forceBlock,
|
|
134
|
+
forceInline,
|
|
135
|
+
preserveFrontmatter,
|
|
136
|
+
tagfilter
|
|
137
|
+
}?: RenderMarkdownProps) => (content: string) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react0.ReactPortal | react0.ReactElement<unknown, string | react0.JSXElementConstructor<any>> | Iterable<ReactNode>> | JSX.Element;
|
|
138
|
+
/**
|
|
139
|
+
* Props for the MarkdownRenderer component.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```tsx
|
|
143
|
+
* const props: MarkdownRendererProps = {
|
|
144
|
+
* children: '# Hello World\n\nThis is **bold** text.',
|
|
145
|
+
* components: {
|
|
146
|
+
* h1: ({ children }) => <h1 className="title">{children}</h1>,
|
|
147
|
+
* },
|
|
148
|
+
* wrapper: ({ children }) => <article>{children}</article>,
|
|
149
|
+
* forceBlock: true,
|
|
150
|
+
* };
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
type MarkdownRendererProps = RenderMarkdownProps & {
|
|
154
|
+
/**
|
|
155
|
+
* The markdown content to render as a string.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```tsx
|
|
159
|
+
* <MarkdownRenderer>
|
|
160
|
+
* {`# Title\n\nParagraph with **bold** text.`}
|
|
161
|
+
* </MarkdownRenderer>
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
9
164
|
children: string;
|
|
165
|
+
/**
|
|
166
|
+
* Custom render function for markdown.
|
|
167
|
+
* If provided, it will overwrite context and default rendering.
|
|
168
|
+
*
|
|
169
|
+
* @param markdown - The markdown string to render
|
|
170
|
+
* @param options - Optional rendering options
|
|
171
|
+
* @returns React node representing the rendered markdown
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```tsx
|
|
175
|
+
* <MarkdownRenderer
|
|
176
|
+
* renderMarkdown={(md, opts) => {
|
|
177
|
+
* // Custom rendering logic
|
|
178
|
+
* return <div dangerouslySetInnerHTML={{ __html: customParser(md) }} />;
|
|
179
|
+
* }}
|
|
180
|
+
* >
|
|
181
|
+
* {markdownContent}
|
|
182
|
+
* </MarkdownRenderer>
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
renderMarkdown?: (markdown: string, options?: {
|
|
186
|
+
components?: Overrides;
|
|
187
|
+
wrapper?: FC;
|
|
188
|
+
forceBlock?: boolean;
|
|
189
|
+
forceInline?: boolean;
|
|
190
|
+
preserveFrontmatter?: boolean;
|
|
191
|
+
tagfilter?: boolean;
|
|
192
|
+
}) => ReactNode;
|
|
10
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* React component that renders markdown content to JSX.
|
|
196
|
+
*
|
|
197
|
+
* This component uses the `renderMarkdown` function from the `MarkdownProvider` context
|
|
198
|
+
* if available. Otherwise, it falls back to the default compiler with provided components
|
|
199
|
+
* and options. You can also provide a custom `renderMarkdown` function prop to override
|
|
200
|
+
* all rendering behavior.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```tsx
|
|
204
|
+
* import { MarkdownRenderer } from '@intlayer/react-intlayer/markdown';
|
|
205
|
+
*
|
|
206
|
+
* function MyComponent() {
|
|
207
|
+
* return (
|
|
208
|
+
* <MarkdownRenderer>
|
|
209
|
+
* {`# Hello World
|
|
210
|
+
*
|
|
211
|
+
* This is a paragraph with **bold** and *italic* text.
|
|
212
|
+
*
|
|
213
|
+
* - List item 1
|
|
214
|
+
* - List item 2`}
|
|
215
|
+
* </MarkdownRenderer>
|
|
216
|
+
* );
|
|
217
|
+
* }
|
|
218
|
+
* ```
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```tsx
|
|
222
|
+
* // With custom components
|
|
223
|
+
* <MarkdownRenderer
|
|
224
|
+
* components={{
|
|
225
|
+
* h1: ({ children }) => <h1 className="text-4xl font-bold">{children}</h1>,
|
|
226
|
+
* a: ({ href, children }) => (
|
|
227
|
+
* <a href={href} className="text-blue-500 hover:underline">
|
|
228
|
+
* {children}
|
|
229
|
+
* </a>
|
|
230
|
+
* ),
|
|
231
|
+
* }}
|
|
232
|
+
* forceBlock={true}
|
|
233
|
+
* >
|
|
234
|
+
* {markdownContent}
|
|
235
|
+
* </MarkdownRenderer>
|
|
236
|
+
* ```
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```tsx
|
|
240
|
+
* // With MarkdownProvider context
|
|
241
|
+
* function App() {
|
|
242
|
+
* return (
|
|
243
|
+
* <MarkdownProvider
|
|
244
|
+
* components={{ h1: CustomHeading }}
|
|
245
|
+
* forceBlock={true}
|
|
246
|
+
* >
|
|
247
|
+
* <MarkdownRenderer>
|
|
248
|
+
* {markdownContent}
|
|
249
|
+
* </MarkdownRenderer>
|
|
250
|
+
* </MarkdownProvider>
|
|
251
|
+
* );
|
|
252
|
+
* }
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
11
255
|
declare const MarkdownRenderer: FC<MarkdownRendererProps>;
|
|
12
|
-
type MarkdownMetadataRendererProps = MarkdownRendererProps & {
|
|
13
|
-
metadataKeyPath: KeyPath[];
|
|
14
|
-
};
|
|
15
|
-
declare const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps>;
|
|
16
256
|
//#endregion
|
|
17
|
-
export {
|
|
257
|
+
export { MarkdownRenderer, MarkdownRendererProps, RenderMarkdownProps, renderMarkdown, useMarkdownRenderer };
|
|
18
258
|
//# sourceMappingURL=MarkdownRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRenderer.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"
|
|
1
|
+
{"version":3,"file":"MarkdownRenderer.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"mappings":";;;;;;;;;AA2BA;;;;;;;;;;;;;;;AAoDA;KApDY,mBAAA,GAAsB,uBAAA;;;;;;;;;;;;;;EAchC,UAAA,GAAa,SAAA;EAwCb;;;;;;;;;EA9BA,OAAA,GAAU,EAAA;AAAA;;;;;AAkGZ;;;;;;;;;;;;;;;;;;;;;cAtEa,cAAA,GACX,OAAA;EACA,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAOG,mBAAA,KACF,GAAA,CAAI,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GP;;;;;;;;;;;;;;;;;;;;cAhDa,mBAAA;EAAuB,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAOjC,mBAAA,MAGO,OAAA,kDAAe,QAAA,CAAA,SAAA,IAAA,OAAA,sCAAA,MAAA,CAAA,WAAA,GAAA,MAAA,CAAA,YAAA,mBAAA,MAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,SAAA,KAAA,GAAA,CAAA,OAAA;;;;;AAgJzB;;;;;;;;;;;KA1GY,qBAAA,GAAwB,mBAAA;;;;;;;;;;;EAWlC,QAAA;;;;;;;;;;;;;;;;;;;;;EAqBA,cAAA,IACE,QAAA,UACA,OAAA;IACE,UAAA,GAAa,SAAA;IACb,OAAA,GAAU,EAAA;IACV,UAAA;IACA,WAAA;IACA,mBAAA;IACA,SAAA;EAAA,MAEC,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgEM,gBAAA,EAAkB,EAAA,CAAG,qBAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { KeyPath, LocalesValues } from "@intlayer/types";
|
|
3
|
+
|
|
4
|
+
//#region src/markdown/MarkdownRendererPlugin.d.ts
|
|
5
|
+
type MarkdownRendererPluginProps = {
|
|
6
|
+
dictionaryKey: string;
|
|
7
|
+
keyPath: KeyPath[];
|
|
8
|
+
locale?: LocalesValues;
|
|
9
|
+
children: string;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
declare const MarkdownRendererPlugin: FC<MarkdownRendererPluginProps>;
|
|
13
|
+
type MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {
|
|
14
|
+
metadataKeyPath: KeyPath[];
|
|
15
|
+
};
|
|
16
|
+
declare const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { MarkdownMetadataRenderer, MarkdownRendererPlugin };
|
|
19
|
+
//# sourceMappingURL=MarkdownRendererPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkdownRendererPlugin.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"mappings":";;;;KASK,2BAAA;EACH,aAAA;EACA,OAAA,EAAS,OAAA;EACT,MAAA,GAAS,aAAA;EACT,QAAA;EAAA,CACC,GAAA;AAAA;AAAA,cAGU,sBAAA,EAAwB,EAAA,CAAG,2BAAA;AAAA,KAkBnC,6BAAA,GAAgC,2BAAA;EACnC,eAAA,EAAiB,OAAA;AAAA;AAAA,cAGN,wBAAA,EAA0B,EAAA,CAAG,6BAAA"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import { MarkdownProvider, useMarkdownContext } from "./MarkdownProvider.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { MarkdownProvider, MarkdownProviderOptions, useMarkdownContext } from "./MarkdownProvider.js";
|
|
2
|
+
import { MarkdownRenderer, MarkdownRendererProps, RenderMarkdownProps, renderMarkdown, useMarkdownRenderer } from "./MarkdownRenderer.js";
|
|
3
|
+
import { MarkdownMetadataRenderer, MarkdownRendererPlugin } from "./MarkdownRendererPlugin.js";
|
|
4
|
+
import { LegacyMarkdownRenderer, MarkdownRendererOptions, Overrides as CoreOverrides, ParseState, ParserResult, RuleOutput, RuleType, State, compile, compileMarkdown, compiler, sanitizer as defaultSanitizer, slugify as defaultSlugify } from "./processor.js";
|
|
5
|
+
import reactRuntime, { createReactRuntime } from "./runtime.js";
|
|
6
|
+
export { LegacyMarkdownRenderer, MarkdownMetadataRenderer, MarkdownProvider, MarkdownProviderOptions, MarkdownRenderer, MarkdownRendererOptions, MarkdownRendererPlugin, MarkdownRendererProps, CoreOverrides as Overrides, ParseState, ParserResult, RenderMarkdownProps, RuleOutput, RuleType, State, compile, compileMarkdown, compiler, createReactRuntime, reactRuntime, renderMarkdown, defaultSanitizer as sanitizer, defaultSlugify as slugify, useMarkdownContext, useMarkdownRenderer };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Overrides as CoreOverrides, ParseState, ParserResult, RenderRuleHook, RuleOutput, RuleType, sanitizer as defaultSanitizer, slugify as defaultSlugify } from "@intlayer/core";
|
|
2
|
+
import { FC, HTMLAttributes, JSX, ReactNode, createElement } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/markdown/processor.d.ts
|
|
5
|
+
type HTMLTags = keyof JSX.IntrinsicElements;
|
|
6
|
+
type State = ParseState;
|
|
7
|
+
/**
|
|
8
|
+
* Refined MarkdownRendererOptions type.
|
|
9
|
+
*/
|
|
10
|
+
type MarkdownRendererOptions = Partial<{
|
|
11
|
+
/**
|
|
12
|
+
* Ultimate control over the output of all rendered JSX.
|
|
13
|
+
*/
|
|
14
|
+
createElement: (tag: Parameters<typeof createElement>[0], props: JSX.IntrinsicAttributes, ...children: ReactNode[]) => ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* The library automatically generates an anchor tag for bare URLs included in the markdown
|
|
17
|
+
* document, but this behavior can be disabled if desired.
|
|
18
|
+
*/
|
|
19
|
+
disableAutoLink: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Disable the compiler's best-effort transcription of provided raw HTML
|
|
22
|
+
* into JSX-equivalent.
|
|
23
|
+
*/
|
|
24
|
+
disableParsingRawHTML: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Forces the compiler to have space between hash sign and the header text.
|
|
27
|
+
*/
|
|
28
|
+
enforceAtxHeadings: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Forces the compiler to always output content with a block-level wrapper.
|
|
31
|
+
*/
|
|
32
|
+
forceBlock: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Forces the compiler to always output content with an inline wrapper.
|
|
35
|
+
*/
|
|
36
|
+
forceInline: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Forces the compiler to wrap results, even if there is only a single child.
|
|
39
|
+
*/
|
|
40
|
+
forceWrapper: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Supply additional HTML entity: unicode replacement mappings.
|
|
43
|
+
*/
|
|
44
|
+
namedCodesToUnicode: {
|
|
45
|
+
[key: string]: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Selectively control the output of particular HTML tags.
|
|
49
|
+
*/
|
|
50
|
+
components: CoreOverrides;
|
|
51
|
+
/**
|
|
52
|
+
* Allows for full control over rendering of particular rules.
|
|
53
|
+
*/
|
|
54
|
+
renderRule: RenderRuleHook;
|
|
55
|
+
/**
|
|
56
|
+
* Override the built-in sanitizer function for URLs.
|
|
57
|
+
*/
|
|
58
|
+
sanitizer: (value: string, tag: HTMLTags, attribute: string) => string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Override normalization of non-URI-safe characters for anchor linking.
|
|
61
|
+
*/
|
|
62
|
+
slugify: (input: string) => string;
|
|
63
|
+
/**
|
|
64
|
+
* Declare the type of the wrapper to be used when there are multiple children.
|
|
65
|
+
*/
|
|
66
|
+
wrapper: any | null;
|
|
67
|
+
/**
|
|
68
|
+
* Whether to preserve frontmatter in the markdown content.
|
|
69
|
+
*/
|
|
70
|
+
preserveFrontmatter: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Whether to use the GitHub Tag Filter.
|
|
73
|
+
*/
|
|
74
|
+
tagfilter: boolean;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Compile markdown to React elements.
|
|
78
|
+
* This is the primary export - use this for new code.
|
|
79
|
+
*/
|
|
80
|
+
declare const compileMarkdown: (markdown?: string, options?: MarkdownRendererOptions) => JSX.Element;
|
|
81
|
+
declare const compiler: (markdown?: string, options?: MarkdownRendererOptions) => JSX.Element;
|
|
82
|
+
declare const compile: (markdown?: string, options?: MarkdownRendererOptions) => JSX.Element;
|
|
83
|
+
/**
|
|
84
|
+
* React component that renders markdown to JSX (legacy).
|
|
85
|
+
*/
|
|
86
|
+
declare const LegacyMarkdownRenderer: FC<Omit<HTMLAttributes<Element>, 'children'> & {
|
|
87
|
+
children: string;
|
|
88
|
+
options?: MarkdownRendererOptions;
|
|
89
|
+
}>;
|
|
90
|
+
//#endregion
|
|
91
|
+
export { LegacyMarkdownRenderer, MarkdownRendererOptions, type CoreOverrides as Overrides, type ParseState, type ParserResult, type RuleOutput, RuleType, type State, compile, compileMarkdown, compiler, defaultSanitizer as sanitizer, defaultSlugify as slugify };
|
|
92
|
+
//# sourceMappingURL=processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor.d.ts","names":[],"sources":["../../../src/markdown/processor.tsx"],"mappings":";;;;KA8BK,QAAA,SAAiB,GAAA,CAAI,iBAAA;AAAA,KAErB,KAAA,GAAQ,UAAA;;;;KAKD,uBAAA,GAA0B,OAAA;EAL5B;;;EASR,aAAA,GACE,GAAA,EAAK,UAAA,QAAkB,aAAA,MACvB,KAAA,EAAO,GAAA,CAAI,mBAAA,KACR,QAAA,EAAU,SAAA,OACV,SAAA;EARK;;;;EAcV,eAAA;EARS;;;;EAcT,qBAAA;EA0CgC;;;EArChC,kBAAA;EAzBoC;;;EA8BpC,UAAA;EAzBE;;;EA8BF,WAAA;EA5BK;;;EAiCL,YAAA;EApBA;;;EAyBA,mBAAA;IAAA,CACG,GAAA;EAAA;EAAA;;;EAMH,UAAA,EAAY,aAAA;EAKA;;;EAAZ,UAAA,EAAY,cAAA;EAKe;;;EAA3B,SAAA,GAAY,KAAA,UAAe,GAAA,EAAK,QAAA,EAAU,SAAA;EAU1C;;;EALA,OAAA,GAAU,KAAA;EAeD;AAiBX;;EA3BE,OAAA;EA2ED;;;EAtEC,mBAAA;EAyBC;;;EApBD,SAAA;AAAA;;;;;cAiBW,eAAA,GACX,QAAA,WACA,OAAA,GAAS,uBAAA,KACR,GAAA,CAAI,OAAA;AAAA,cAgDM,QAAA,GAAQ,QAAA,WAlDH,OAAA,GACP,uBAAA,KACR,GAAA,CAAI,OAAA;AAAA,cAiDM,OAAA,GAAO,QAAA,WAnDF,OAAA,GACP,uBAAA,KACR,GAAA,CAAI,OAAA;;;;cAsDM,sBAAA,EAAwB,EAAA,CACnC,IAAA,CAAK,cAAA,CAAe,OAAA;EAClB,QAAA;EACA,OAAA,GAAU,uBAAA;AAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MarkdownRuntime } from "@intlayer/core";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/markdown/runtime.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* React-specific runtime for the markdown processor.
|
|
7
|
+
* Implements the MarkdownRuntime interface using React's primitives.
|
|
8
|
+
*/
|
|
9
|
+
declare const reactRuntime: MarkdownRuntime;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a React runtime with custom createElement for advanced use cases.
|
|
12
|
+
* Useful for wrapping elements or adding middleware.
|
|
13
|
+
*/
|
|
14
|
+
declare const createReactRuntime: (options?: {
|
|
15
|
+
onCreateElement?: (type: string | any, props: Record<string, any> | null, children: any[]) => ReactNode;
|
|
16
|
+
}) => MarkdownRuntime;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { createReactRuntime, reactRuntime as default, reactRuntime };
|
|
19
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","names":[],"sources":["../../../src/markdown/runtime.ts"],"mappings":";;;;;;;;cAuBa,YAAA,EAAc,eAAA;;;;;cA6Dd,kBAAA,GACX,OAAA;EACE,eAAA,IACE,IAAA,gBACA,KAAA,EAAO,MAAA,sBACP,QAAA,YACG,SAAA;AAAA,MAEN,eAAA"}
|
package/dist/types/plugins.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { IntlayerNode } from "./IntlayerNode.js";
|
|
2
|
-
import { DeepTransformContent as DeepTransformContent$1, IInterpreterPluginState as IInterpreterPluginState$1, Plugins } from "@intlayer/core";
|
|
3
|
-
import { ReactNode } from "react";
|
|
2
|
+
import { DeepTransformContent as DeepTransformContent$1, HTMLCond, IInterpreterPluginState as IInterpreterPluginState$1, Plugins } from "@intlayer/core";
|
|
3
|
+
import { ComponentType, ElementType, ReactNode } from "react";
|
|
4
4
|
import { DeclaredLocales, LocalesValues, NodeType } from "@intlayer/types";
|
|
5
5
|
|
|
6
6
|
//#region src/plugins.d.ts
|
|
7
|
-
|
|
8
7
|
/** ---------------------------------------------
|
|
9
8
|
* INTLAYER NODE PLUGIN
|
|
10
9
|
* --------------------------------------------- */
|
|
@@ -20,29 +19,50 @@ type ReactNodeCond<T> = T extends {
|
|
|
20
19
|
} ? ReactNode : never;
|
|
21
20
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
22
21
|
declare const reactNodePlugins: Plugins;
|
|
22
|
+
/** ---------------------------------------------
|
|
23
|
+
* INSERTION PLUGIN
|
|
24
|
+
* --------------------------------------------- */
|
|
25
|
+
type InsertionCond<T, S, L> = T extends {
|
|
26
|
+
nodeType: NodeType | string;
|
|
27
|
+
[NodeType.Insertion]: string;
|
|
28
|
+
fields: readonly string[];
|
|
29
|
+
} ? (values: { [K in T['fields'][number]]: ReactNode }) => ReactNode : never;
|
|
30
|
+
/** Insertion plugin for React. Handles component/node insertion. */
|
|
31
|
+
declare const insertionPlugin: Plugins;
|
|
23
32
|
/**
|
|
24
33
|
* MARKDOWN PLUGIN
|
|
25
34
|
*/
|
|
26
35
|
type MarkdownStringCond<T> = T extends string ? IntlayerNode<string, {
|
|
27
36
|
metadata: DeepTransformContent<string>;
|
|
37
|
+
use: (components: any) => any;
|
|
28
38
|
}> : never;
|
|
29
39
|
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
30
40
|
declare const markdownStringPlugin: Plugins;
|
|
31
|
-
type
|
|
41
|
+
type MarkdownComponentMap = Record<string, ComponentType<any> | ElementType>;
|
|
42
|
+
type MarkdownCond<T, S, L extends LocalesValues> = T extends {
|
|
32
43
|
nodeType: NodeType | string;
|
|
33
44
|
[NodeType.Markdown]: infer M;
|
|
34
45
|
metadata?: infer U;
|
|
35
|
-
} ?
|
|
36
|
-
|
|
37
|
-
|
|
46
|
+
} ? {
|
|
47
|
+
use: (components?: MarkdownComponentMap) => ReactNode;
|
|
48
|
+
metadata: DeepTransformContent<U, L>;
|
|
49
|
+
} & any : never;
|
|
38
50
|
declare const markdownPlugin: Plugins;
|
|
51
|
+
/** ---------------------------------------------
|
|
52
|
+
* HTML PLUGIN
|
|
53
|
+
* --------------------------------------------- */
|
|
54
|
+
type HTMLPluginCond<T, S, L> = HTMLCond<T, S, L>;
|
|
55
|
+
/** HTML plugin. Replaces node with a function that takes components => ReactNode. */
|
|
56
|
+
declare const htmlPlugin: Plugins;
|
|
39
57
|
/** ---------------------------------------------
|
|
40
58
|
* PLUGINS RESULT
|
|
41
59
|
* --------------------------------------------- */
|
|
42
|
-
interface IInterpreterPluginReact<T> {
|
|
60
|
+
interface IInterpreterPluginReact<T, S, L extends LocalesValues> {
|
|
43
61
|
reactNode: ReactNodeCond<T>;
|
|
44
|
-
|
|
45
|
-
|
|
62
|
+
reactIntlayerNode: IntlayerNodeCond<T>;
|
|
63
|
+
reactInsertion: InsertionCond<T, S, L>;
|
|
64
|
+
reactMarkdown: MarkdownCond<T, S, L>;
|
|
65
|
+
reactHtml: HTMLPluginCond<T, S, L>;
|
|
46
66
|
}
|
|
47
67
|
/**
|
|
48
68
|
* Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.
|
|
@@ -51,10 +71,12 @@ interface IInterpreterPluginReact<T> {
|
|
|
51
71
|
*/
|
|
52
72
|
type IInterpreterPluginState = IInterpreterPluginState$1 & {
|
|
53
73
|
reactNode: true;
|
|
54
|
-
|
|
55
|
-
|
|
74
|
+
reactIntlayerNode: true;
|
|
75
|
+
reactInsertion: true;
|
|
76
|
+
reactMarkdown: true;
|
|
77
|
+
reactHtml: true;
|
|
56
78
|
};
|
|
57
79
|
type DeepTransformContent<T, L extends LocalesValues = DeclaredLocales> = DeepTransformContent$1<T, IInterpreterPluginState, L>;
|
|
58
80
|
//#endregion
|
|
59
|
-
export { DeepTransformContent, IInterpreterPluginReact, IInterpreterPluginState, IntlayerNodeCond, MarkdownCond, MarkdownStringCond, ReactNodeCond, intlayerNodePlugins, markdownPlugin, markdownStringPlugin, reactNodePlugins };
|
|
81
|
+
export { DeepTransformContent, HTMLPluginCond, IInterpreterPluginReact, IInterpreterPluginState, InsertionCond, IntlayerNodeCond, MarkdownCond, MarkdownStringCond, ReactNodeCond, htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, markdownStringPlugin, reactNodePlugins };
|
|
60
82
|
//# sourceMappingURL=plugins.d.ts.map
|