react-intlayer 5.3.0 → 5.3.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.
@@ -20,6 +20,7 @@ var plugins_exports = {};
20
20
  __export(plugins_exports, {
21
21
  intlayerNodePlugins: () => intlayerNodePlugins,
22
22
  markdownPlugin: () => markdownPlugin,
23
+ markdownStringPlugin: () => markdownStringPlugin,
23
24
  reactNodePlugins: () => reactNodePlugins
24
25
  });
25
26
  module.exports = __toCommonJS(plugins_exports);
@@ -30,6 +31,7 @@ var import_useEditedContentRenderer = require('./editor/useEditedContentRenderer
30
31
  var import_editor = require('./editor/index.cjs');
31
32
  var import_markdown = require('./markdown/index.cjs');
32
33
  const intlayerNodePlugins = {
34
+ id: "intlayer-node-plugin",
33
35
  canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
34
36
  transform: (_node, {
35
37
  plugins,
@@ -42,8 +44,9 @@ const intlayerNodePlugins = {
42
44
  })
43
45
  };
44
46
  const reactNodePlugins = {
47
+ id: "react-node-plugin",
45
48
  canHandle: (node) => typeof node === "object" && typeof node.props !== "undefined" && typeof node.key !== "undefined",
46
- transform: (node, {
49
+ transform: (_node, {
47
50
  plugins,
48
51
  // Removed to avoid next error - Functions cannot be passed directly to Client Components
49
52
  ...rest
@@ -53,57 +56,71 @@ const reactNodePlugins = {
53
56
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor.ContentSelectorRenderer, { ...rest, children: "renderReactElement(node)" })
54
57
  })
55
58
  };
56
- const markdownPlugin = {
57
- canHandle: (node) => typeof node === "object" && node?.nodeType === import_core.NodeType.Markdown,
58
- transform: (node, props) => {
59
+ const markdownStringPlugin = {
60
+ id: "markdown-string-plugin",
61
+ canHandle: (node) => typeof node === "string",
62
+ transform: (node, props, deepTransformNode) => {
59
63
  const {
60
64
  plugins,
61
65
  // Removed to avoid next error - Functions cannot be passed directly to Client Components
62
66
  ...rest
63
67
  } = props;
64
- const newKeyPath = [
65
- ...props.keyPath,
66
- {
67
- type: import_core.NodeType.Markdown
68
- }
69
- ];
70
- const content = node[import_core.NodeType.Markdown];
71
- const metadata = (0, import_core.getMarkdownMetadata)(content);
68
+ const metadata = (0, import_core.getMarkdownMetadata)(node);
72
69
  const metadataPlugins = {
70
+ id: "markdown-metadata-plugin",
73
71
  canHandle: (node2) => typeof node2 === "string" || typeof node2 === "number" || typeof node2 === "boolean" || !node2,
74
72
  transform: (node2, props2) => (0, import_IntlayerNode.renderIntlayerNode)({
75
73
  ...props2,
76
74
  value: node2,
77
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor.ContentSelectorRenderer, { ...rest, keyPath: newKeyPath, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
75
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor.ContentSelectorRenderer, { ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
78
76
  import_markdown.MarkdownMetadataRenderer,
79
77
  {
80
78
  ...rest,
81
- keyPath: newKeyPath,
82
79
  metadataKeyPath: props2.keyPath,
83
- children: content
80
+ children: node2
84
81
  }
85
82
  ) })
86
83
  })
87
84
  };
88
- const metadataNodes = (0, import_core.deepTransformNode)(metadata, {
85
+ const metadataNodes = deepTransformNode(metadata, {
89
86
  plugins: [metadataPlugins],
90
87
  dictionaryKey: rest.dictionaryKey,
91
88
  keyPath: []
92
89
  });
93
90
  return (0, import_IntlayerNode.renderIntlayerNode)({
94
91
  ...props,
95
- value: content,
96
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor.ContentSelectorRenderer, { ...rest, keyPath: newKeyPath, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_markdown.MarkdownRenderer, { ...rest, keyPath: newKeyPath, children: content }) }),
92
+ value: node,
93
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor.ContentSelectorRenderer, { ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_markdown.MarkdownRenderer, { ...rest, children: node }) }),
97
94
  additionalProps: {
98
95
  metadata: metadataNodes
99
96
  }
100
97
  });
101
98
  }
102
99
  };
100
+ const markdownPlugin = {
101
+ id: "markdown-plugin",
102
+ canHandle: (node) => typeof node === "object" && node?.nodeType === import_core.NodeType.Markdown,
103
+ transform: (node, props, deepTransformNode) => {
104
+ const newKeyPath = [
105
+ ...props.keyPath,
106
+ {
107
+ type: import_core.NodeType.Markdown
108
+ }
109
+ ];
110
+ const children = node[import_core.NodeType.Markdown];
111
+ return deepTransformNode(children, {
112
+ ...props,
113
+ children,
114
+ keyPath: newKeyPath,
115
+ plugins: [markdownStringPlugin, ...props.plugins ?? []]
116
+ });
117
+ }
118
+ };
103
119
  // Annotate the CommonJS export names for ESM import in node:
104
120
  0 && (module.exports = {
105
121
  intlayerNodePlugins,
106
122
  markdownPlugin,
123
+ markdownStringPlugin,
107
124
  reactNodePlugins
108
125
  });
109
126
  //# sourceMappingURL=plugins.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["import {\n type Plugins,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type DeepTransformContent as DeepTransformContentCore,\n type MarkdownContent,\n NodeType,\n KeyPath,\n getMarkdownMetadata,\n deepTransformNode,\n} from '@intlayer/core';\nimport type { ReactNode } from 'react';\nimport { renderIntlayerNode, type IntlayerNode } from './IntlayerNode';\nimport { EditedContentRenderer } from './editor/useEditedContentRenderer';\nimport { ContentSelectorRenderer } from './editor';\nimport { MarkdownMetadataRenderer, MarkdownRenderer } from './markdown';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: (\n <ContentSelectorRenderer {...rest}>\n <EditedContentRenderer {...rest}>\n {rest.children}\n </EditedContentRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: (\n <ContentSelectorRenderer {...rest}>\n renderReactElement(node)\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: string;\n metadata?: infer U;\n}\n ? IntlayerNode<string, { metadata: DeepTransformContent<U> }>\n : never;\n\n/** Markdown plugin. Replaces node with a function that takes quantity => string. */\nexport const markdownPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const content = node[NodeType.Markdown];\n const metadata = getMarkdownMetadata(content);\n\n const metadataPlugins: Plugins = {\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean' ||\n !node,\n transform: (node, props) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest} keyPath={newKeyPath}>\n <MarkdownMetadataRenderer\n {...rest}\n keyPath={newKeyPath}\n metadataKeyPath={props.keyPath}\n >\n {content}\n </MarkdownMetadataRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n return renderIntlayerNode({\n ...props,\n value: content,\n children: (\n <ContentSelectorRenderer {...rest} keyPath={newKeyPath}>\n <MarkdownRenderer {...rest} keyPath={newKeyPath}>\n {content}\n </MarkdownRenderer>\n </ContentSelectorRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginReact<T> {\n reactNode: ReactNodeCond<T>;\n intlayerNode: IntlayerNodeCond<T>;\n markdown: MarkdownCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n reactNode: true;\n intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CU;AA1CV,kBASO;AAEP,0BAAsD;AACtD,sCAAsC;AACtC,oBAAwC;AACxC,sBAA2D;AAWpD,MAAM,sBAA+B;AAAA,EAC1C,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CACT,OACA;AAAA,IACE;AAAA;AAAA,IACA,GAAG;AAAA,EACL,UAEA,wCAAmB;AAAA,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oBAAgB,+BAAkB,UAAU;AAAA,MAChD,SAAS,CAAC,eAAe;AAAA,MACzB,eAAe,KAAK;AAAA,MACpB,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,eAAO,wCAAmB;AAAA,MACxB,GAAG;AAAA,MACH,OAAO;AAAA,MACP,UACE,4CAAC,yCAAyB,GAAG,MAAM,SAAS,YAC1C,sDAAC,oCAAkB,GAAG,MAAM,SAAS,YAClC,mBACH,GACF;AAAA,MAEF,iBAAiB;AAAA,QACf,UAAU;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":["node","props"]}
1
+ {"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["import {\n type Plugins,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type DeepTransformContent as DeepTransformContentCore,\n type MarkdownContent,\n NodeType,\n KeyPath,\n getMarkdownMetadata,\n} from '@intlayer/core';\nimport type { ReactNode } from 'react';\nimport { renderIntlayerNode, type IntlayerNode } from './IntlayerNode';\nimport { EditedContentRenderer } from './editor/useEditedContentRenderer';\nimport { ContentSelectorRenderer } from './editor';\nimport { MarkdownMetadataRenderer, MarkdownRenderer } from './markdown';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: (\n <ContentSelectorRenderer {...rest}>\n <EditedContentRenderer {...rest}>\n {rest.children}\n </EditedContentRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: (\n <ContentSelectorRenderer {...rest}>\n renderReactElement(node)\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean' ||\n !node,\n transform: (node, props) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n return renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownRenderer {...rest}>{node}</MarkdownRenderer>\n </ContentSelectorRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n metadata?: infer U;\n}\n ? IntlayerNode<DeepTransformContent<M>, { metadata: DeepTransformContent<U> }>\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginReact<T> {\n reactNode: ReactNodeCond<T>;\n intlayerNode: IntlayerNodeCond<T>;\n markdown: MarkdownCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n reactNode: true;\n intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CU;AA1CV,kBAQO;AAEP,0BAAsD;AACtD,sCAAsC;AACtC,oBAAwC;AACxC,sBAA2D;AAWpD,MAAM,sBAA+B;AAAA,EAC1C,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CACT,OACA;AAAA,I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e,KAAK;AAAA,MACpB,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,eAAO,wCAAmB;AAAA,MACxB,GAAG;AAAA,MACH,OAAO;AAAA,MACP,UACE,4CAAC,yCAAyB,GAAG,MAC3B,sDAAC,oCAAkB,GAAG,MAAO,gBAAK,GACpC;AAAA,MAEF,iBAAiB;AAAA,QACf,UAAU;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAUO,MAAM,iBAA0B;AAAA,EACrC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,qBAAS;AAAA,EAC1D,WAAW,CAAC,MAAuB,OAAO,sBAAsB;AAC9D,UAAM,aAAwB;AAAA,MAC5B,GAAG,MAAM;AAAA,MACT;AAAA,QACE,MAAM,qBAAS;AAAA,MACjB;AAAA,IACF;AAEA,UAAM,WAAW,KAAK,qBAAS,QAAQ;AAEvC,WAAO,kBAAkB,UAAU;AAAA,MACjC,GAAG;AAAA,MACH;AAAA,MACA,SAAS;AAAA,MACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,CAAC,CAAE;AAAA,IAC1D,CAAC;AAAA,EACH;AACF;","names":["node","props"]}
@@ -1,14 +1,14 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import {
3
3
  NodeType,
4
- getMarkdownMetadata,
5
- deepTransformNode
4
+ getMarkdownMetadata
6
5
  } from "@intlayer/core";
7
6
  import { renderIntlayerNode } from "./IntlayerNode.mjs";
8
7
  import { EditedContentRenderer } from "./editor/useEditedContentRenderer.mjs";
9
8
  import { ContentSelectorRenderer } from "./editor/index.mjs";
10
9
  import { MarkdownMetadataRenderer, MarkdownRenderer } from "./markdown/index.mjs";
11
10
  const intlayerNodePlugins = {
11
+ id: "intlayer-node-plugin",
12
12
  canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
13
13
  transform: (_node, {
14
14
  plugins,
@@ -21,8 +21,9 @@ const intlayerNodePlugins = {
21
21
  })
22
22
  };
23
23
  const reactNodePlugins = {
24
+ id: "react-node-plugin",
24
25
  canHandle: (node) => typeof node === "object" && typeof node.props !== "undefined" && typeof node.key !== "undefined",
25
- transform: (node, {
26
+ transform: (_node, {
26
27
  plugins,
27
28
  // Removed to avoid next error - Functions cannot be passed directly to Client Components
28
29
  ...rest
@@ -32,34 +33,28 @@ const reactNodePlugins = {
32
33
  children: /* @__PURE__ */ jsx(ContentSelectorRenderer, { ...rest, children: "renderReactElement(node)" })
33
34
  })
34
35
  };
35
- const markdownPlugin = {
36
- canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Markdown,
37
- transform: (node, props) => {
36
+ const markdownStringPlugin = {
37
+ id: "markdown-string-plugin",
38
+ canHandle: (node) => typeof node === "string",
39
+ transform: (node, props, deepTransformNode) => {
38
40
  const {
39
41
  plugins,
40
42
  // Removed to avoid next error - Functions cannot be passed directly to Client Components
41
43
  ...rest
42
44
  } = props;
43
- const newKeyPath = [
44
- ...props.keyPath,
45
- {
46
- type: NodeType.Markdown
47
- }
48
- ];
49
- const content = node[NodeType.Markdown];
50
- const metadata = getMarkdownMetadata(content);
45
+ const metadata = getMarkdownMetadata(node);
51
46
  const metadataPlugins = {
47
+ id: "markdown-metadata-plugin",
52
48
  canHandle: (node2) => typeof node2 === "string" || typeof node2 === "number" || typeof node2 === "boolean" || !node2,
53
49
  transform: (node2, props2) => renderIntlayerNode({
54
50
  ...props2,
55
51
  value: node2,
56
- children: /* @__PURE__ */ jsx(ContentSelectorRenderer, { ...rest, keyPath: newKeyPath, children: /* @__PURE__ */ jsx(
52
+ children: /* @__PURE__ */ jsx(ContentSelectorRenderer, { ...rest, children: /* @__PURE__ */ jsx(
57
53
  MarkdownMetadataRenderer,
58
54
  {
59
55
  ...rest,
60
- keyPath: newKeyPath,
61
56
  metadataKeyPath: props2.keyPath,
62
- children: content
57
+ children: node2
63
58
  }
64
59
  ) })
65
60
  })
@@ -71,17 +66,37 @@ const markdownPlugin = {
71
66
  });
72
67
  return renderIntlayerNode({
73
68
  ...props,
74
- value: content,
75
- children: /* @__PURE__ */ jsx(ContentSelectorRenderer, { ...rest, keyPath: newKeyPath, children: /* @__PURE__ */ jsx(MarkdownRenderer, { ...rest, keyPath: newKeyPath, children: content }) }),
69
+ value: node,
70
+ children: /* @__PURE__ */ jsx(ContentSelectorRenderer, { ...rest, children: /* @__PURE__ */ jsx(MarkdownRenderer, { ...rest, children: node }) }),
76
71
  additionalProps: {
77
72
  metadata: metadataNodes
78
73
  }
79
74
  });
80
75
  }
81
76
  };
77
+ const markdownPlugin = {
78
+ id: "markdown-plugin",
79
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Markdown,
80
+ transform: (node, props, deepTransformNode) => {
81
+ const newKeyPath = [
82
+ ...props.keyPath,
83
+ {
84
+ type: NodeType.Markdown
85
+ }
86
+ ];
87
+ const children = node[NodeType.Markdown];
88
+ return deepTransformNode(children, {
89
+ ...props,
90
+ children,
91
+ keyPath: newKeyPath,
92
+ plugins: [markdownStringPlugin, ...props.plugins ?? []]
93
+ });
94
+ }
95
+ };
82
96
  export {
83
97
  intlayerNodePlugins,
84
98
  markdownPlugin,
99
+ markdownStringPlugin,
85
100
  reactNodePlugins
86
101
  };
87
102
  //# sourceMappingURL=plugins.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["import {\n type Plugins,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type DeepTransformContent as DeepTransformContentCore,\n type MarkdownContent,\n NodeType,\n KeyPath,\n getMarkdownMetadata,\n deepTransformNode,\n} from '@intlayer/core';\nimport type { ReactNode } from 'react';\nimport { renderIntlayerNode, type IntlayerNode } from './IntlayerNode';\nimport { EditedContentRenderer } from './editor/useEditedContentRenderer';\nimport { ContentSelectorRenderer } from './editor';\nimport { MarkdownMetadataRenderer, MarkdownRenderer } from './markdown';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: (\n <ContentSelectorRenderer {...rest}>\n <EditedContentRenderer {...rest}>\n {rest.children}\n </EditedContentRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: (\n <ContentSelectorRenderer {...rest}>\n renderReactElement(node)\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: string;\n metadata?: infer U;\n}\n ? IntlayerNode<string, { metadata: DeepTransformContent<U> }>\n : never;\n\n/** Markdown plugin. Replaces node with a function that takes quantity => string. */\nexport const markdownPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const content = node[NodeType.Markdown];\n const metadata = getMarkdownMetadata(content);\n\n const metadataPlugins: Plugins = {\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean' ||\n !node,\n transform: (node, props) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest} keyPath={newKeyPath}>\n <MarkdownMetadataRenderer\n {...rest}\n keyPath={newKeyPath}\n metadataKeyPath={props.keyPath}\n >\n {content}\n </MarkdownMetadataRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n return renderIntlayerNode({\n ...props,\n value: content,\n children: (\n <ContentSelectorRenderer {...rest} keyPath={newKeyPath}>\n <MarkdownRenderer {...rest} keyPath={newKeyPath}>\n {content}\n </MarkdownRenderer>\n </ContentSelectorRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginReact<T> {\n reactNode: ReactNodeCond<T>;\n intlayerNode: IntlayerNodeCond<T>;\n markdown: MarkdownCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n reactNode: true;\n intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":"AA0CU;AA1CV;AAAA,EAKE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,0BAA6C;AACtD,SAAS,6BAA6B;AACtC,SAAS,+BAA+B;AACxC,SAAS,0BAA0B,wBAAwB;A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AAyB,GAAG,MAAM,SAAS,YAC1C;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACJ,SAAS;AAAA,YACT,iBAAiBC,OAAM;AAAA,YAEtB;AAAA;AAAA,QACH,GACF;AAAA,MAEJ,CAAC;AAAA,IACL;AAGA,UAAM,gBAAgB,kBAAkB,UAAU;AAAA,MAChD,SAAS,CAAC,eAAe;AAAA,MACzB,eAAe,KAAK;AAAA,MACpB,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,WAAO,mBAAmB;AAAA,MACxB,GAAG;AAAA,MACH,OAAO;AAAA,MACP,UACE,oBAAC,2BAAyB,GAAG,MAAM,SAAS,YAC1C,8BAAC,oBAAkB,GAAG,MAAM,SAAS,YAClC,mBACH,GACF;AAAA,MAEF,iBAAiB;AAAA,QACf,UAAU;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":["node","props"]}
1
+ {"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["import {\n type Plugins,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type DeepTransformContent as DeepTransformContentCore,\n type MarkdownContent,\n NodeType,\n KeyPath,\n getMarkdownMetadata,\n} from '@intlayer/core';\nimport type { ReactNode } from 'react';\nimport { renderIntlayerNode, type IntlayerNode } from './IntlayerNode';\nimport { EditedContentRenderer } from './editor/useEditedContentRenderer';\nimport { ContentSelectorRenderer } from './editor';\nimport { MarkdownMetadataRenderer, MarkdownRenderer } from './markdown';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: (\n <ContentSelectorRenderer {...rest}>\n <EditedContentRenderer {...rest}>\n {rest.children}\n </EditedContentRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: (\n <ContentSelectorRenderer {...rest}>\n renderReactElement(node)\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean' ||\n !node,\n transform: (node, props) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n return renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownRenderer {...rest}>{node}</MarkdownRenderer>\n </ContentSelectorRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n metadata?: infer U;\n}\n ? IntlayerNode<DeepTransformContent<M>, { metadata: DeepTransformContent<U> }>\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginReact<T> {\n reactNode: ReactNodeCond<T>;\n intlayerNode: IntlayerNodeCond<T>;\n markdown: MarkdownCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n reactNode: true;\n intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":"AA0CU;AA1CV;AAAA,EAKE;AAAA,EAEA;AAAA,OACK;AAEP,SAAS,0BAA6C;AACtD,SAAS,6BAA6B;AACtC,SAAS,+BAA+B;AAC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AAA,YACJ,iBAAiBC,OAAM;AAAA,YAEtB,UAAAD;AAAA;AAAA,QACH,GACF;AAAA,MAEJ,CAAC;AAAA,IACL;AAGA,UAAM,gBAAgB,kBAAkB,UAAU;AAAA,MAChD,SAAS,CAAC,eAAe;AAAA,MACzB,eAAe,KAAK;AAAA,MACpB,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,WAAO,mBAAmB;AAAA,MACxB,GAAG;AAAA,MACH,OAAO;AAAA,MACP,UACE,oBAAC,2BAAyB,GAAG,MAC3B,8BAAC,oBAAkB,GAAG,MAAO,gBAAK,GACpC;AAAA,MAEF,iBAAiB;AAAA,QACf,UAAU;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAUO,MAAM,iBAA0B;AAAA,EACrC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAAuB,OAAO,sBAAsB;AAC9D,UAAM,aAAwB;AAAA,MAC5B,GAAG,MAAM;AAAA,MACT;AAAA,QACE,MAAM,SAAS;AAAA,MACjB;AAAA,IACF;AAEA,UAAM,WAAW,KAAK,SAAS,QAAQ;AAEvC,WAAO,kBAAkB,UAAU;AAAA,MACjC,GAAG;AAAA,MACH;AAAA,MACA,SAAS;AAAA,MACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,CAAC,CAAE;AAAA,IAC1D,CAAC;AAAA,EACH;AACF;","names":["node","props"]}
@@ -19,14 +19,18 @@ export declare const reactNodePlugins: Plugins;
19
19
  /**
20
20
  * MARKDOWN PLUGIN
21
21
  */
22
+ export type MarkdownStringCond<T> = T extends string ? IntlayerNode<string, {
23
+ metadata: DeepTransformContent<string>;
24
+ }> : never;
25
+ /** Markdown string plugin. Replaces string node with a component that render the markdown. */
26
+ export declare const markdownStringPlugin: Plugins;
22
27
  export type MarkdownCond<T> = T extends {
23
28
  nodeType: NodeType | string;
24
- [NodeType.Markdown]: string;
29
+ [NodeType.Markdown]: infer M;
25
30
  metadata?: infer U;
26
- } ? IntlayerNode<string, {
31
+ } ? IntlayerNode<DeepTransformContent<M>, {
27
32
  metadata: DeepTransformContent<U>;
28
33
  }> : never;
29
- /** Markdown plugin. Replaces node with a function that takes quantity => string. */
30
34
  export declare const markdownPlugin: Plugins;
31
35
  /** ---------------------------------------------
32
36
  * PLUGINS RESULT
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/plugins.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,uBAAuB,IAAI,2BAA2B,EAC3D,KAAK,oBAAoB,IAAI,wBAAwB,EAErD,QAAQ,EAIT,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAKvE;;oDAEoD;AAEpD,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,MAAM,GACvD,YAAY,CAAC,CAAC,CAAC,GACf,KAAK,CAAC;AAEV,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,EAAE,OAuBjC,CAAC;AAEF;;oDAEoD;AAEpD,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS;IACvC,KAAK,EAAE,GAAG,CAAC;IACX,GAAG,EAAE,GAAG,CAAC;CACV,GACG,SAAS,GACT,KAAK,CAAC;AAEV,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,EAAE,OAsB9B,CAAC;AAEF;;GAEG;AAEH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS;IACtC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC5B,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;CACpB,GACG,Y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ACD,uBAAuB,CACxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "5.3.0",
3
+ "version": "5.3.2",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -69,11 +69,11 @@
69
69
  ],
70
70
  "dependencies": {
71
71
  "js-cookie": "^3.0.5",
72
- "@intlayer/api": "5.3.0",
73
- "@intlayer/config": "5.3.0",
74
- "@intlayer/core": "5.3.0",
75
- "@intlayer/editor-react": "5.3.0",
76
- "@intlayer/dictionaries-entry": "5.3.0"
72
+ "@intlayer/api": "5.3.2",
73
+ "@intlayer/core": "5.3.2",
74
+ "@intlayer/config": "5.3.2",
75
+ "@intlayer/dictionaries-entry": "5.3.2",
76
+ "@intlayer/editor-react": "5.3.2"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@craco/types": "^7.1.0",
@@ -90,20 +90,20 @@
90
90
  "tsup": "^8.3.5",
91
91
  "typescript": "^5.7.3",
92
92
  "@utils/eslint-config": "1.0.4",
93
+ "@intlayer/backend": "5.3.2",
93
94
  "@utils/ts-config": "1.0.4",
94
95
  "@utils/ts-config-types": "1.0.4",
95
- "@utils/tsup-config": "1.0.4",
96
- "@intlayer/backend": "5.3.0"
96
+ "@utils/tsup-config": "1.0.4"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "react": ">=16.0.0",
100
100
  "react-dom": ">=16.0.0",
101
- "@intlayer/api": "5.3.0",
102
- "@intlayer/config": "5.3.0",
103
- "@intlayer/core": "5.3.0",
104
- "@intlayer/editor-react": "5.3.0",
105
- "intlayer": "5.3.0",
106
- "@intlayer/dictionaries-entry": "5.3.0"
101
+ "@intlayer/api": "5.3.2",
102
+ "@intlayer/config": "5.3.2",
103
+ "@intlayer/core": "5.3.2",
104
+ "@intlayer/dictionaries-entry": "5.3.2",
105
+ "@intlayer/editor-react": "5.3.2",
106
+ "intlayer": "5.3.2"
107
107
  },
108
108
  "engines": {
109
109
  "node": ">=14.18"