react-intlayer 5.2.9 → 5.3.0
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/cjs/IntlayerNode.cjs +8 -4
- package/dist/cjs/IntlayerNode.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelectorWrapper.cjs +7 -22
- package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
- package/dist/cjs/editor/index.cjs +1 -3
- package/dist/cjs/editor/index.cjs.map +1 -1
- package/dist/cjs/editor/useEditedContentRenderer.cjs +52 -0
- package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -0
- package/dist/cjs/markdown/MarkdownRenderer.cjs +30 -5
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
- package/dist/cjs/markdown/index.cjs +1 -3
- package/dist/cjs/markdown/index.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +56 -15
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/esm/IntlayerNode.mjs +7 -3
- package/dist/esm/IntlayerNode.mjs.map +1 -1
- package/dist/esm/editor/ContentSelectorWrapper.mjs +9 -33
- package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
- package/dist/esm/editor/index.mjs +0 -1
- package/dist/esm/editor/index.mjs.map +1 -1
- package/dist/esm/editor/useEditedContentRenderer.mjs +27 -0
- package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -0
- package/dist/esm/markdown/MarkdownRenderer.mjs +32 -5
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
- package/dist/esm/markdown/index.mjs +0 -1
- package/dist/esm/markdown/index.mjs.map +1 -1
- package/dist/esm/plugins.mjs +60 -17
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/types/IntlayerNode.d.ts +10 -4
- package/dist/types/IntlayerNode.d.ts.map +1 -1
- package/dist/types/editor/ContentSelectorWrapper.d.ts +2 -2
- package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
- package/dist/types/editor/index.d.ts +0 -1
- package/dist/types/editor/index.d.ts.map +1 -1
- package/dist/types/editor/useEditedContentRenderer.d.ts +12 -0
- package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -0
- package/dist/types/markdown/MarkdownRenderer.d.ts +12 -3
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/dist/types/markdown/index.d.ts +0 -1
- package/dist/types/markdown/index.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +5 -2
- package/dist/types/plugins.d.ts.map +1 -1
- package/package.json +15 -14
- package/dist/cjs/editor/renderContentEditor.cjs +0 -35
- package/dist/cjs/editor/renderContentEditor.cjs.map +0 -1
- package/dist/cjs/markdown/renderMarkdown.cjs +0 -31
- package/dist/cjs/markdown/renderMarkdown.cjs.map +0 -1
- package/dist/esm/editor/renderContentEditor.mjs +0 -13
- package/dist/esm/editor/renderContentEditor.mjs.map +0 -1
- package/dist/esm/markdown/renderMarkdown.mjs +0 -7
- package/dist/esm/markdown/renderMarkdown.mjs.map +0 -1
- package/dist/types/editor/renderContentEditor.d.ts +0 -8
- package/dist/types/editor/renderContentEditor.d.ts.map +0 -1
- package/dist/types/markdown/renderMarkdown.d.ts +0 -3
- package/dist/types/markdown/renderMarkdown.d.ts.map +0 -1
|
@@ -18,14 +18,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var IntlayerNode_exports = {};
|
|
20
20
|
__export(IntlayerNode_exports, {
|
|
21
|
-
|
|
21
|
+
renderIntlayerNode: () => renderIntlayerNode
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(IntlayerNode_exports);
|
|
24
24
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
25
|
var import_react = require("react");
|
|
26
|
-
const
|
|
26
|
+
const renderIntlayerNode = ({
|
|
27
|
+
children,
|
|
27
28
|
value,
|
|
28
|
-
|
|
29
|
+
additionalProps
|
|
29
30
|
}) => {
|
|
30
31
|
const element = (0, import_react.isValidElement)(children) ? children : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
31
32
|
return new Proxy(element, {
|
|
@@ -33,12 +34,15 @@ const rendererIntlayerNode = ({
|
|
|
33
34
|
if (prop === "value") {
|
|
34
35
|
return value;
|
|
35
36
|
}
|
|
37
|
+
if (additionalProps && Object.keys(additionalProps).includes(prop)) {
|
|
38
|
+
return additionalProps[prop];
|
|
39
|
+
}
|
|
36
40
|
return Reflect.get(target, prop, receiver);
|
|
37
41
|
}
|
|
38
42
|
});
|
|
39
43
|
};
|
|
40
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
45
|
0 && (module.exports = {
|
|
42
|
-
|
|
46
|
+
renderIntlayerNode
|
|
43
47
|
});
|
|
44
48
|
//# sourceMappingURL=IntlayerNode.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core';\nimport {\n type PropsWithChildren,\n type ReactNode,\n type ReactElement,\n isValidElement,\n} from 'react';\n\nexport type IntlayerNode
|
|
1
|
+
{"version":3,"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core';\nimport {\n type PropsWithChildren,\n type ReactNode,\n type ReactElement,\n isValidElement,\n} from 'react';\n\nexport type IntlayerNode<\n T = NodeProps['children'],\n AdditionalProps = {},\n> = ReactNode & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = PropsWithChildren<{\n value: T;\n children: ReactNode;\n additionalProps?: { [key: string]: any };\n}>;\n\nexport const renderIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n children,\n value,\n additionalProps,\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is not a valid ReactElement, wrap it in a fragment\n const element: ReactElement<any> = isValidElement(children) ? (\n children\n ) : (\n <>{children}</>\n );\n\n // Return a Proxy that pretends to be the original element\n // but also has a .value getter.\n return new Proxy(element as ReactElement, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCI;AA/BJ,mBAKO;AAeA,MAAM,qBAAqB,CAEhC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAmD;AAEjD,QAAM,cAA6B,6BAAe,QAAQ,IACxD,WAEA,2EAAG,UAAS;AAKd,SAAO,IAAI,MAAM,SAAyB;AAAA,IACxC,IAAI,QAAQ,MAAM,UAAU;AAC1B,UAAI,SAAS,SAAS;AACpB,eAAO;AAAA,MACT;AAEA,UACE,mBACA,OAAO,KAAK,eAAe,EAAE,SAAS,IAAc,GACpD;AACA,eAAO,gBAAgB,IAAoC;AAAA,MAC7D;AAEA,aAAO,QAAQ,IAAI,QAAQ,MAAM,QAAQ;AAAA,IAC3C;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var ContentSelectorWrapper_exports = {};
|
|
21
21
|
__export(ContentSelectorWrapper_exports, {
|
|
22
|
-
|
|
22
|
+
ContentSelectorRenderer: () => ContentSelectorRenderer
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(ContentSelectorWrapper_exports);
|
|
25
25
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -31,38 +31,23 @@ var import_ContentSelector = require('../UI/ContentSelector.cjs');
|
|
|
31
31
|
const ContentSelectorWrapperContent = ({
|
|
32
32
|
children,
|
|
33
33
|
dictionaryKey,
|
|
34
|
-
keyPath
|
|
35
|
-
dictionaryPath,
|
|
36
|
-
...props
|
|
34
|
+
keyPath
|
|
37
35
|
}) => {
|
|
38
36
|
const { focusedContent, setFocusedContent } = (0, import_editor_react.useFocusDictionary)();
|
|
39
|
-
const { getEditedContentValue } = (0, import_editor_react.useEditedContentActions)();
|
|
40
|
-
const editedValue = (0, import_react.useMemo)(
|
|
41
|
-
() => getEditedContentValue(dictionaryKey, keyPath),
|
|
42
|
-
[dictionaryKey, keyPath, getEditedContentValue]
|
|
43
|
-
);
|
|
44
|
-
const [displayedChildren, setDisplayedChildren] = (0, import_react.useState)(children);
|
|
45
37
|
const handleSelect = (0, import_react.useCallback)(
|
|
46
38
|
() => setFocusedContent({
|
|
47
39
|
dictionaryKey,
|
|
48
40
|
keyPath
|
|
49
41
|
}),
|
|
50
|
-
[dictionaryKey, keyPath
|
|
42
|
+
[dictionaryKey, keyPath]
|
|
51
43
|
);
|
|
52
44
|
const isSelected = (0, import_react.useMemo)(
|
|
53
45
|
() => (focusedContent?.dictionaryKey === dictionaryKey && (focusedContent?.keyPath?.length ?? 0) > 0 && (0, import_core.isSameKeyPath)(focusedContent?.keyPath ?? [], keyPath)) ?? false,
|
|
54
46
|
[focusedContent, keyPath, dictionaryKey]
|
|
55
47
|
);
|
|
56
|
-
(0,
|
|
57
|
-
if (editedValue && typeof editedValue === "string") {
|
|
58
|
-
setDisplayedChildren(editedValue);
|
|
59
|
-
} else {
|
|
60
|
-
setDisplayedChildren(children);
|
|
61
|
-
}
|
|
62
|
-
}, [editedValue, focusedContent, children]);
|
|
63
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentSelector.ContentSelector, { onPress: handleSelect, isSelecting: isSelected, ...props, children: displayedChildren });
|
|
48
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentSelector.ContentSelector, { onPress: handleSelect, isSelecting: isSelected, children });
|
|
64
49
|
};
|
|
65
|
-
const
|
|
50
|
+
const ContentSelectorRenderer = ({
|
|
66
51
|
children,
|
|
67
52
|
...props
|
|
68
53
|
}) => {
|
|
@@ -71,10 +56,10 @@ const ContentSelectorWrapper = ({
|
|
|
71
56
|
if (enabled && !disableEditor) {
|
|
72
57
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContentSelectorWrapperContent, { ...props, children });
|
|
73
58
|
}
|
|
74
|
-
return
|
|
59
|
+
return children;
|
|
75
60
|
};
|
|
76
61
|
// Annotate the CommonJS export names for ESM import in node:
|
|
77
62
|
0 && (module.exports = {
|
|
78
|
-
|
|
63
|
+
ContentSelectorRenderer
|
|
79
64
|
});
|
|
80
65
|
//# sourceMappingURL=ContentSelectorWrapper.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type NodeProps, isSameKeyPath } from '@intlayer/core';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type NodeProps, isSameKeyPath } from '@intlayer/core';\nimport { useFocusDictionary, useEditorEnabled } from '@intlayer/editor-react';\nimport { type HTMLAttributes, useCallback, useMemo, type FC } from 'react';\nimport { useIntlayerContext } from '../client';\nimport { ContentSelector } from '../UI/ContentSelector';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n keyPath,\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath,\n }),\n [dictionaryKey, keyPath]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false,\n [focusedContent, keyPath, dictionaryKey]\n );\n\n return (\n <ContentSelector onPress={handleSelect} isSelecting={isSelected}>\n {children}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorRenderer: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n const { disableEditor } = useIntlayerContext();\n\n if (enabled && !disableEditor) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return children;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqCI;AAnCJ,kBAA8C;AAC9C,0BAAqD;AACrD,mBAAmE;AACnE,oBAAmC;AACnC,6BAAgC;AAKhC,MAAM,gCAAiE,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,gBAAgB,kBAAkB,QAAI,wCAAmB;AAEjE,QAAM,mBAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,OAAO;AAAA,EACzB;AAEA,QAAM,iBAAa;AAAA,IACjB,OACG,gBAAgB,kBAAkB,kBAChC,gBAAgB,SAAS,UAAU,KAAK,SACzC,2BAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAAA,IACF,CAAC,gBAAgB,SAAS,aAAa;AAAA,EACzC;AAEA,SACE,4CAAC,0CAAgB,SAAS,cAAc,aAAa,YAClD,UACH;AAEJ;AAEO,MAAM,0BAA2D,CAAC;AAAA,EACvE;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,QAAI,sCAAiB;AACrC,QAAM,EAAE,cAAc,QAAI,kCAAmB;AAE7C,MAAI,WAAW,CAAC,eAAe;AAC7B,WACE,4CAAC,iCAA+B,GAAG,OAChC,UACH;AAAA,EAEJ;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -16,10 +16,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
var editor_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(editor_exports);
|
|
18
18
|
__reExport(editor_exports, require('./ContentSelectorWrapper.cjs'), module.exports);
|
|
19
|
-
__reExport(editor_exports, require('./renderContentEditor.cjs'), module.exports);
|
|
20
19
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21
20
|
0 && (module.exports = {
|
|
22
|
-
...require('./ContentSelectorWrapper.cjs')
|
|
23
|
-
...require('./renderContentEditor.cjs')
|
|
21
|
+
...require('./ContentSelectorWrapper.cjs')
|
|
24
22
|
});
|
|
25
23
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/index.ts"],"sourcesContent":["export * from './ContentSelectorWrapper';\
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/index.ts"],"sourcesContent":["export * from './ContentSelectorWrapper';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,2BAAc,qCAAd;","names":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var useEditedContentRenderer_exports = {};
|
|
21
|
+
__export(useEditedContentRenderer_exports, {
|
|
22
|
+
EditedContentRenderer: () => EditedContentRenderer,
|
|
23
|
+
useEditedContentRenderer: () => useEditedContentRenderer
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useEditedContentRenderer_exports);
|
|
26
|
+
var import_editor_react = require("@intlayer/editor-react");
|
|
27
|
+
const useEditedContentRenderer = ({
|
|
28
|
+
dictionaryKey,
|
|
29
|
+
keyPath,
|
|
30
|
+
children
|
|
31
|
+
}) => {
|
|
32
|
+
const editedContentContext = (0, import_editor_react.useEditedContentActions)();
|
|
33
|
+
if (editedContentContext) {
|
|
34
|
+
const editedValue = editedContentContext.getEditedContentValue(
|
|
35
|
+
dictionaryKey,
|
|
36
|
+
keyPath
|
|
37
|
+
);
|
|
38
|
+
const value = editedValue ?? children;
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
return children;
|
|
42
|
+
};
|
|
43
|
+
const EditedContentRenderer = (props) => {
|
|
44
|
+
const content = useEditedContentRenderer(props);
|
|
45
|
+
return content;
|
|
46
|
+
};
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
EditedContentRenderer,
|
|
50
|
+
useEditedContentRenderer
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=useEditedContentRenderer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/useEditedContentRenderer.tsx"],"sourcesContent":["'use client';\n\nimport type { FC } from 'react';\nimport { useEditedContentActions } from '@intlayer/editor-react';\nimport type { KeyPath } from '@intlayer/core';\n\ntype EditedContentRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n children: string;\n renderChildren?: (children: any) => any;\n};\n\nexport const useEditedContentRenderer = ({\n dictionaryKey,\n keyPath,\n children,\n}: EditedContentRendererProps) => {\n const editedContentContext = useEditedContentActions();\n\n if (editedContentContext) {\n const editedValue = editedContentContext.getEditedContentValue(\n dictionaryKey,\n keyPath\n ) as string;\n\n const value = editedValue ?? children;\n\n return value;\n }\n\n return children;\n};\n\nexport const EditedContentRenderer: FC<EditedContentRendererProps> = (\n props\n) => {\n const content = useEditedContentRenderer(props);\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAwC;AAUjC,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AACF,MAAkC;AAChC,QAAM,2BAAuB,6CAAwB;AAErD,MAAI,sBAAsB;AACxB,UAAM,cAAc,qBAAqB;AAAA,MACvC;AAAA,MACA;AAAA,IACF;AAEA,UAAM,QAAQ,eAAe;AAE7B,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,MAAM,wBAAwD,CACnE,UACG;AACH,QAAM,UAAU,yBAAyB,KAAK;AAE9C,SAAO;AACT;","names":[]}
|
|
@@ -19,22 +19,47 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var MarkdownRenderer_exports = {};
|
|
21
21
|
__export(MarkdownRenderer_exports, {
|
|
22
|
+
MarkdownMetadataRenderer: () => MarkdownMetadataRenderer,
|
|
22
23
|
MarkdownRenderer: () => MarkdownRenderer
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(MarkdownRenderer_exports);
|
|
25
|
-
var import_IntlayerNode = require('../IntlayerNode.cjs');
|
|
26
26
|
var import_MarkdownProvider = require('./MarkdownProvider.cjs');
|
|
27
|
+
var import_useEditedContentRenderer = require('../editor/useEditedContentRenderer.cjs');
|
|
28
|
+
var import_core = require("@intlayer/core");
|
|
27
29
|
const MarkdownRenderer = ({
|
|
28
|
-
|
|
30
|
+
dictionaryKey,
|
|
31
|
+
keyPath,
|
|
32
|
+
children
|
|
29
33
|
}) => {
|
|
30
34
|
const { renderMarkdown } = (0, import_MarkdownProvider.useMarkdownContext)();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
const editedContentContext = (0, import_useEditedContentRenderer.useEditedContentRenderer)({
|
|
36
|
+
dictionaryKey,
|
|
37
|
+
keyPath,
|
|
38
|
+
children
|
|
34
39
|
});
|
|
40
|
+
return renderMarkdown(editedContentContext);
|
|
41
|
+
};
|
|
42
|
+
const MarkdownMetadataRenderer = ({
|
|
43
|
+
dictionaryKey,
|
|
44
|
+
keyPath,
|
|
45
|
+
children,
|
|
46
|
+
metadataKeyPath
|
|
47
|
+
}) => {
|
|
48
|
+
const editedContentContext = (0, import_useEditedContentRenderer.useEditedContentRenderer)({
|
|
49
|
+
dictionaryKey,
|
|
50
|
+
keyPath,
|
|
51
|
+
children
|
|
52
|
+
});
|
|
53
|
+
const metadata = (0, import_core.getMarkdownMetadata)(editedContentContext);
|
|
54
|
+
const metadataEl = (0, import_core.getContentNodeByKeyPath)(
|
|
55
|
+
metadata,
|
|
56
|
+
metadataKeyPath
|
|
57
|
+
);
|
|
58
|
+
return metadataEl;
|
|
35
59
|
};
|
|
36
60
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
61
|
0 && (module.exports = {
|
|
62
|
+
MarkdownMetadataRenderer,
|
|
38
63
|
MarkdownRenderer
|
|
39
64
|
});
|
|
40
65
|
//# sourceMappingURL=MarkdownRenderer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport type { FC } from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport type { FC, ReactNode } from 'react';\nimport { useMarkdownContext } from './MarkdownProvider';\nimport { useEditedContentRenderer } from '../editor/useEditedContentRenderer';\nimport {\n ContentNode,\n getContentNodeByKeyPath,\n getMarkdownMetadata,\n KeyPath,\n} from '@intlayer/core';\n\ntype MarkdownRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n children: string;\n};\n\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n}): ReactNode => {\n const { renderMarkdown } = useMarkdownContext();\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n\n return renderMarkdown(editedContentContext);\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n metadataKeyPath,\n}): ReactNode => {\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n const metadata = getMarkdownMetadata(editedContentContext);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath\n );\n\n return metadataEl as ReactNode;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,8BAAmC;AACnC,sCAAyC;AACzC,kBAKO;AAQA,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AACF,MAAiB;AACf,QAAM,EAAE,eAAe,QAAI,4CAAmB;AAC9C,QAAM,2BAAuB,0DAAyB;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO,eAAe,oBAAoB;AAC5C;AAMO,MAAM,2BAA8D,CAAC;AAAA,EAC1E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAiB;AACf,QAAM,2BAAuB,0DAAyB;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,eAAW,iCAAoB,oBAAoB;AAEzD,QAAM,iBAAa;AAAA,IACjB;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -17,11 +17,9 @@ var markdown_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(markdown_exports);
|
|
18
18
|
__reExport(markdown_exports, require('./MarkdownProvider.cjs'), module.exports);
|
|
19
19
|
__reExport(markdown_exports, require('./MarkdownRenderer.cjs'), module.exports);
|
|
20
|
-
__reExport(markdown_exports, require('./renderMarkdown.cjs'), module.exports);
|
|
21
20
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
21
|
0 && (module.exports = {
|
|
23
22
|
...require('./MarkdownProvider.cjs'),
|
|
24
|
-
...require('./MarkdownRenderer.cjs')
|
|
25
|
-
...require('./renderMarkdown.cjs')
|
|
23
|
+
...require('./MarkdownRenderer.cjs')
|
|
26
24
|
});
|
|
27
25
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/markdown/index.ts"],"sourcesContent":["export * from './MarkdownProvider';\nexport * from './MarkdownRenderer';\
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/index.ts"],"sourcesContent":["export * from './MarkdownProvider';\nexport * from './MarkdownRenderer';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,+BAAd;AACA,6BAAc,+BADd;","names":[]}
|
package/dist/cjs/plugins.cjs
CHANGED
|
@@ -23,17 +23,23 @@ __export(plugins_exports, {
|
|
|
23
23
|
reactNodePlugins: () => reactNodePlugins
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(plugins_exports);
|
|
26
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
27
|
var import_core = require("@intlayer/core");
|
|
28
|
+
var import_IntlayerNode = require('./IntlayerNode.cjs');
|
|
29
|
+
var import_useEditedContentRenderer = require('./editor/useEditedContentRenderer.cjs');
|
|
27
30
|
var import_editor = require('./editor/index.cjs');
|
|
28
|
-
var
|
|
29
|
-
var import_renderReactElement = require('./reactElement/renderReactElement.cjs');
|
|
31
|
+
var import_markdown = require('./markdown/index.cjs');
|
|
30
32
|
const intlayerNodePlugins = {
|
|
31
33
|
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
32
34
|
transform: (_node, {
|
|
33
35
|
plugins,
|
|
34
36
|
// Removed to avoid next error - Functions cannot be passed directly to Client Components
|
|
35
37
|
...rest
|
|
36
|
-
}) => (0,
|
|
38
|
+
}) => (0, import_IntlayerNode.renderIntlayerNode)({
|
|
39
|
+
...rest,
|
|
40
|
+
value: rest.children,
|
|
41
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor.ContentSelectorRenderer, { ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_useEditedContentRenderer.EditedContentRenderer, { ...rest, children: rest.children }) })
|
|
42
|
+
})
|
|
37
43
|
};
|
|
38
44
|
const reactNodePlugins = {
|
|
39
45
|
canHandle: (node) => typeof node === "object" && typeof node.props !== "undefined" && typeof node.key !== "undefined",
|
|
@@ -41,23 +47,58 @@ const reactNodePlugins = {
|
|
|
41
47
|
plugins,
|
|
42
48
|
// Removed to avoid next error - Functions cannot be passed directly to Client Components
|
|
43
49
|
...rest
|
|
44
|
-
}) => (0,
|
|
50
|
+
}) => (0, import_IntlayerNode.renderIntlayerNode)({
|
|
45
51
|
...rest,
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
value: "[[react-element]]",
|
|
53
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor.ContentSelectorRenderer, { ...rest, children: "renderReactElement(node)" })
|
|
48
54
|
})
|
|
49
55
|
};
|
|
50
56
|
const markdownPlugin = {
|
|
51
57
|
canHandle: (node) => typeof node === "object" && node?.nodeType === import_core.NodeType.Markdown,
|
|
52
|
-
transform: (node, {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
transform: (node, props) => {
|
|
59
|
+
const {
|
|
60
|
+
plugins,
|
|
61
|
+
// Removed to avoid next error - Functions cannot be passed directly to Client Components
|
|
62
|
+
...rest
|
|
63
|
+
} = 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);
|
|
72
|
+
const metadataPlugins = {
|
|
73
|
+
canHandle: (node2) => typeof node2 === "string" || typeof node2 === "number" || typeof node2 === "boolean" || !node2,
|
|
74
|
+
transform: (node2, props2) => (0, import_IntlayerNode.renderIntlayerNode)({
|
|
75
|
+
...props2,
|
|
76
|
+
value: node2,
|
|
77
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor.ContentSelectorRenderer, { ...rest, keyPath: newKeyPath, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
78
|
+
import_markdown.MarkdownMetadataRenderer,
|
|
79
|
+
{
|
|
80
|
+
...rest,
|
|
81
|
+
keyPath: newKeyPath,
|
|
82
|
+
metadataKeyPath: props2.keyPath,
|
|
83
|
+
children: content
|
|
84
|
+
}
|
|
85
|
+
) })
|
|
86
|
+
})
|
|
87
|
+
};
|
|
88
|
+
const metadataNodes = (0, import_core.deepTransformNode)(metadata, {
|
|
89
|
+
plugins: [metadataPlugins],
|
|
90
|
+
dictionaryKey: rest.dictionaryKey,
|
|
91
|
+
keyPath: []
|
|
92
|
+
});
|
|
93
|
+
return (0, import_IntlayerNode.renderIntlayerNode)({
|
|
94
|
+
...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 }) }),
|
|
97
|
+
additionalProps: {
|
|
98
|
+
metadata: metadataNodes
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
61
102
|
};
|
|
62
103
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
104
|
0 && (module.exports = {
|
package/dist/cjs/plugins.cjs.map
CHANGED
|
@@ -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} from '@intlayer/core';\nimport type { ReactNode } from 'react';\nimport {
|
|
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,IACjB,GAAG;AAAA,IACH,OAAO,KAAK;AAAA,IACZ,UACE,4CAAC,yCAAyB,GAAG,MAC3B,sDAAC,yDAAuB,GAAG,MACxB,eAAK,UACR,GACF;AAAA,EAEJ,CAAC;AACL;AAcO,MAAM,mBAA4B;AAAA,EACvC,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;AAAA,EAEtB,WAAW,CACT,MACA;AAAA,IACE;AAAA;AAAA,IACA,GAAG;AAAA,EACL,UAEA,wCAAmB;AAAA,IACjB,GAAG;AAAA,IACH,OAAO;AAAA,IACP,UACE,4CAAC,yCAAyB,GAAG,MAAM,sCAEnC;AAAA,EAEJ,CAAC;AACL;AAeO,MAAM,iBAA0B;AAAA,EACrC,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,qBAAS;AAAA,EAC1D,WAAW,CAAC,MAAuB,UAAU;AAC3C,UAAM;AAAA,MACJ;AAAA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AAEJ,UAAM,aAAwB;AAAA,MAC5B,GAAG,MAAM;AAAA,MACT;AAAA,QACE,MAAM,qBAAS;AAAA,MACjB;AAAA,IACF;AAEA,UAAM,UAAU,KAAK,qBAAS,QAAQ;AACtC,UAAM,eAAW,iCAAoB,OAAO;AAE5C,UAAM,kBAA2B;AAAA,MAC/B,WAAW,CAACA,UACV,OAAOA,UAAS,YAChB,OAAOA,UAAS,YAChB,OAAOA,UAAS,aAChB,CAACA;AAAA,MACH,WAAW,CAACA,OAAMC,eAChB,wCAAmB;AAAA,QACjB,GAAGA;AAAA,QACH,OAAOD;AAAA,QACP,UACE,4CAAC,yCAAyB,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,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"]}
|
|
@@ -2,9 +2,10 @@ import { Fragment, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import {
|
|
3
3
|
isValidElement
|
|
4
4
|
} from "react";
|
|
5
|
-
const
|
|
5
|
+
const renderIntlayerNode = ({
|
|
6
|
+
children,
|
|
6
7
|
value,
|
|
7
|
-
|
|
8
|
+
additionalProps
|
|
8
9
|
}) => {
|
|
9
10
|
const element = isValidElement(children) ? children : /* @__PURE__ */ jsx(Fragment, { children });
|
|
10
11
|
return new Proxy(element, {
|
|
@@ -12,11 +13,14 @@ const rendererIntlayerNode = ({
|
|
|
12
13
|
if (prop === "value") {
|
|
13
14
|
return value;
|
|
14
15
|
}
|
|
16
|
+
if (additionalProps && Object.keys(additionalProps).includes(prop)) {
|
|
17
|
+
return additionalProps[prop];
|
|
18
|
+
}
|
|
15
19
|
return Reflect.get(target, prop, receiver);
|
|
16
20
|
}
|
|
17
21
|
});
|
|
18
22
|
};
|
|
19
23
|
export {
|
|
20
|
-
|
|
24
|
+
renderIntlayerNode
|
|
21
25
|
};
|
|
22
26
|
//# sourceMappingURL=IntlayerNode.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core';\nimport {\n type PropsWithChildren,\n type ReactNode,\n type ReactElement,\n isValidElement,\n} from 'react';\n\nexport type IntlayerNode
|
|
1
|
+
{"version":3,"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core';\nimport {\n type PropsWithChildren,\n type ReactNode,\n type ReactElement,\n isValidElement,\n} from 'react';\n\nexport type IntlayerNode<\n T = NodeProps['children'],\n AdditionalProps = {},\n> = ReactNode & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = PropsWithChildren<{\n value: T;\n children: ReactNode;\n additionalProps?: { [key: string]: any };\n}>;\n\nexport const renderIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n children,\n value,\n additionalProps,\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is not a valid ReactElement, wrap it in a fragment\n const element: ReactElement<any> = isValidElement(children) ? (\n children\n ) : (\n <>{children}</>\n );\n\n // Return a Proxy that pretends to be the original element\n // but also has a .value getter.\n return new Proxy(element as ReactElement, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":"AAgCI;AA/BJ;AAAA,EAIE;AAAA,OACK;AAeA,MAAM,qBAAqB,CAEhC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAmD;AAEjD,QAAM,UAA6B,eAAe,QAAQ,IACxD,WAEA,gCAAG,UAAS;AAKd,SAAO,IAAI,MAAM,SAAyB;AAAA,IACxC,IAAI,QAAQ,MAAM,UAAU;AAC1B,UAAI,SAAS,SAAS;AACpB,eAAO;AAAA,MACT;AAEA,UACE,mBACA,OAAO,KAAK,eAAe,EAAE,SAAS,IAAc,GACpD;AACA,eAAO,gBAAgB,IAAoC;AAAA,MAC7D;AAEA,aAAO,QAAQ,IAAI,QAAQ,MAAM,QAAQ;AAAA,IAC3C;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,54 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { isSameKeyPath } from "@intlayer/core";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
useEditedContentActions,
|
|
7
|
-
useEditorEnabled
|
|
8
|
-
} from "@intlayer/editor-react";
|
|
9
|
-
import {
|
|
10
|
-
useCallback,
|
|
11
|
-
useEffect,
|
|
12
|
-
useState,
|
|
13
|
-
useMemo
|
|
14
|
-
} from "react";
|
|
4
|
+
import { useFocusDictionary, useEditorEnabled } from "@intlayer/editor-react";
|
|
5
|
+
import { useCallback, useMemo } from "react";
|
|
15
6
|
import { useIntlayerContext } from "../client/index.mjs";
|
|
16
7
|
import { ContentSelector } from "../UI/ContentSelector.mjs";
|
|
17
8
|
const ContentSelectorWrapperContent = ({
|
|
18
9
|
children,
|
|
19
10
|
dictionaryKey,
|
|
20
|
-
keyPath
|
|
21
|
-
dictionaryPath,
|
|
22
|
-
...props
|
|
11
|
+
keyPath
|
|
23
12
|
}) => {
|
|
24
13
|
const { focusedContent, setFocusedContent } = useFocusDictionary();
|
|
25
|
-
const { getEditedContentValue } = useEditedContentActions();
|
|
26
|
-
const editedValue = useMemo(
|
|
27
|
-
() => getEditedContentValue(dictionaryKey, keyPath),
|
|
28
|
-
[dictionaryKey, keyPath, getEditedContentValue]
|
|
29
|
-
);
|
|
30
|
-
const [displayedChildren, setDisplayedChildren] = useState(children);
|
|
31
14
|
const handleSelect = useCallback(
|
|
32
15
|
() => setFocusedContent({
|
|
33
16
|
dictionaryKey,
|
|
34
17
|
keyPath
|
|
35
18
|
}),
|
|
36
|
-
[dictionaryKey, keyPath
|
|
19
|
+
[dictionaryKey, keyPath]
|
|
37
20
|
);
|
|
38
21
|
const isSelected = useMemo(
|
|
39
22
|
() => (focusedContent?.dictionaryKey === dictionaryKey && (focusedContent?.keyPath?.length ?? 0) > 0 && isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ?? false,
|
|
40
23
|
[focusedContent, keyPath, dictionaryKey]
|
|
41
24
|
);
|
|
42
|
-
|
|
43
|
-
if (editedValue && typeof editedValue === "string") {
|
|
44
|
-
setDisplayedChildren(editedValue);
|
|
45
|
-
} else {
|
|
46
|
-
setDisplayedChildren(children);
|
|
47
|
-
}
|
|
48
|
-
}, [editedValue, focusedContent, children]);
|
|
49
|
-
return /* @__PURE__ */ jsx(ContentSelector, { onPress: handleSelect, isSelecting: isSelected, ...props, children: displayedChildren });
|
|
25
|
+
return /* @__PURE__ */ jsx(ContentSelector, { onPress: handleSelect, isSelecting: isSelected, children });
|
|
50
26
|
};
|
|
51
|
-
const
|
|
27
|
+
const ContentSelectorRenderer = ({
|
|
52
28
|
children,
|
|
53
29
|
...props
|
|
54
30
|
}) => {
|
|
@@ -57,9 +33,9 @@ const ContentSelectorWrapper = ({
|
|
|
57
33
|
if (enabled && !disableEditor) {
|
|
58
34
|
return /* @__PURE__ */ jsx(ContentSelectorWrapperContent, { ...props, children });
|
|
59
35
|
}
|
|
60
|
-
return
|
|
36
|
+
return children;
|
|
61
37
|
};
|
|
62
38
|
export {
|
|
63
|
-
|
|
39
|
+
ContentSelectorRenderer
|
|
64
40
|
};
|
|
65
41
|
//# sourceMappingURL=ContentSelectorWrapper.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type NodeProps, isSameKeyPath } from '@intlayer/core';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type NodeProps, isSameKeyPath } from '@intlayer/core';\nimport { useFocusDictionary, useEditorEnabled } from '@intlayer/editor-react';\nimport { type HTMLAttributes, useCallback, useMemo, type FC } from 'react';\nimport { useIntlayerContext } from '../client';\nimport { ContentSelector } from '../UI/ContentSelector';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n keyPath,\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath,\n }),\n [dictionaryKey, keyPath]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false,\n [focusedContent, keyPath, dictionaryKey]\n );\n\n return (\n <ContentSelector onPress={handleSelect} isSelecting={isSelected}>\n {children}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorRenderer: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n const { disableEditor } = useIntlayerContext();\n\n if (enabled && !disableEditor) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return children;\n};\n"],"mappings":";AAqCI;AAnCJ,SAAyB,qBAAqB;AAC9C,SAAS,oBAAoB,wBAAwB;AACrD,SAA8B,aAAa,eAAwB;AACnE,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAKhC,MAAM,gCAAiE,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,gBAAgB,kBAAkB,IAAI,mBAAmB;AAEjE,QAAM,eAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,OAAO;AAAA,EACzB;AAEA,QAAM,aAAa;AAAA,IACjB,OACG,gBAAgB,kBAAkB,kBAChC,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAAA,IACF,CAAC,gBAAgB,SAAS,aAAa;AAAA,EACzC;AAEA,SACE,oBAAC,mBAAgB,SAAS,cAAc,aAAa,YAClD,UACH;AAEJ;AAEO,MAAM,0BAA2D,CAAC;AAAA,EACvE;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AACrC,QAAM,EAAE,cAAc,IAAI,mBAAmB;AAE7C,MAAI,WAAW,CAAC,eAAe;AAC7B,WACE,oBAAC,iCAA+B,GAAG,OAChC,UACH;AAAA,EAEJ;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/index.ts"],"sourcesContent":["export * from './ContentSelectorWrapper';\
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/index.ts"],"sourcesContent":["export * from './ContentSelectorWrapper';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEditedContentActions } from "@intlayer/editor-react";
|
|
3
|
+
const useEditedContentRenderer = ({
|
|
4
|
+
dictionaryKey,
|
|
5
|
+
keyPath,
|
|
6
|
+
children
|
|
7
|
+
}) => {
|
|
8
|
+
const editedContentContext = useEditedContentActions();
|
|
9
|
+
if (editedContentContext) {
|
|
10
|
+
const editedValue = editedContentContext.getEditedContentValue(
|
|
11
|
+
dictionaryKey,
|
|
12
|
+
keyPath
|
|
13
|
+
);
|
|
14
|
+
const value = editedValue ?? children;
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
return children;
|
|
18
|
+
};
|
|
19
|
+
const EditedContentRenderer = (props) => {
|
|
20
|
+
const content = useEditedContentRenderer(props);
|
|
21
|
+
return content;
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
EditedContentRenderer,
|
|
25
|
+
useEditedContentRenderer
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=useEditedContentRenderer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/useEditedContentRenderer.tsx"],"sourcesContent":["'use client';\n\nimport type { FC } from 'react';\nimport { useEditedContentActions } from '@intlayer/editor-react';\nimport type { KeyPath } from '@intlayer/core';\n\ntype EditedContentRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n children: string;\n renderChildren?: (children: any) => any;\n};\n\nexport const useEditedContentRenderer = ({\n dictionaryKey,\n keyPath,\n children,\n}: EditedContentRendererProps) => {\n const editedContentContext = useEditedContentActions();\n\n if (editedContentContext) {\n const editedValue = editedContentContext.getEditedContentValue(\n dictionaryKey,\n keyPath\n ) as string;\n\n const value = editedValue ?? children;\n\n return value;\n }\n\n return children;\n};\n\nexport const EditedContentRenderer: FC<EditedContentRendererProps> = (\n props\n) => {\n const content = useEditedContentRenderer(props);\n\n return content;\n};\n"],"mappings":";AAGA,SAAS,+BAA+B;AAUjC,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AACF,MAAkC;AAChC,QAAM,uBAAuB,wBAAwB;AAErD,MAAI,sBAAsB;AACxB,UAAM,cAAc,qBAAqB;AAAA,MACvC;AAAA,MACA;AAAA,IACF;AAEA,UAAM,QAAQ,eAAe;AAE7B,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,MAAM,wBAAwD,CACnE,UACG;AACH,QAAM,UAAU,yBAAyB,KAAK;AAE9C,SAAO;AACT;","names":[]}
|
|
@@ -1,16 +1,43 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { rendererIntlayerNode } from "../IntlayerNode.mjs";
|
|
3
2
|
import { useMarkdownContext } from "./MarkdownProvider.mjs";
|
|
3
|
+
import { useEditedContentRenderer } from "../editor/useEditedContentRenderer.mjs";
|
|
4
|
+
import {
|
|
5
|
+
getContentNodeByKeyPath,
|
|
6
|
+
getMarkdownMetadata
|
|
7
|
+
} from "@intlayer/core";
|
|
4
8
|
const MarkdownRenderer = ({
|
|
5
|
-
|
|
9
|
+
dictionaryKey,
|
|
10
|
+
keyPath,
|
|
11
|
+
children
|
|
6
12
|
}) => {
|
|
7
13
|
const { renderMarkdown } = useMarkdownContext();
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
const editedContentContext = useEditedContentRenderer({
|
|
15
|
+
dictionaryKey,
|
|
16
|
+
keyPath,
|
|
17
|
+
children
|
|
11
18
|
});
|
|
19
|
+
return renderMarkdown(editedContentContext);
|
|
20
|
+
};
|
|
21
|
+
const MarkdownMetadataRenderer = ({
|
|
22
|
+
dictionaryKey,
|
|
23
|
+
keyPath,
|
|
24
|
+
children,
|
|
25
|
+
metadataKeyPath
|
|
26
|
+
}) => {
|
|
27
|
+
const editedContentContext = useEditedContentRenderer({
|
|
28
|
+
dictionaryKey,
|
|
29
|
+
keyPath,
|
|
30
|
+
children
|
|
31
|
+
});
|
|
32
|
+
const metadata = getMarkdownMetadata(editedContentContext);
|
|
33
|
+
const metadataEl = getContentNodeByKeyPath(
|
|
34
|
+
metadata,
|
|
35
|
+
metadataKeyPath
|
|
36
|
+
);
|
|
37
|
+
return metadataEl;
|
|
12
38
|
};
|
|
13
39
|
export {
|
|
40
|
+
MarkdownMetadataRenderer,
|
|
14
41
|
MarkdownRenderer
|
|
15
42
|
};
|
|
16
43
|
//# sourceMappingURL=MarkdownRenderer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport type { FC } from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport type { FC, ReactNode } from 'react';\nimport { useMarkdownContext } from './MarkdownProvider';\nimport { useEditedContentRenderer } from '../editor/useEditedContentRenderer';\nimport {\n ContentNode,\n getContentNodeByKeyPath,\n getMarkdownMetadata,\n KeyPath,\n} from '@intlayer/core';\n\ntype MarkdownRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n children: string;\n};\n\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n}): ReactNode => {\n const { renderMarkdown } = useMarkdownContext();\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n\n return renderMarkdown(editedContentContext);\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n metadataKeyPath,\n}): ReactNode => {\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n const metadata = getMarkdownMetadata(editedContentContext);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath\n );\n\n return metadataEl as ReactNode;\n};\n"],"mappings":";AAGA,SAAS,0BAA0B;AACnC,SAAS,gCAAgC;AACzC;AAAA,EAEE;AAAA,EACA;AAAA,OAEK;AAQA,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AACF,MAAiB;AACf,QAAM,EAAE,eAAe,IAAI,mBAAmB;AAC9C,QAAM,uBAAuB,yBAAyB;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO,eAAe,oBAAoB;AAC5C;AAMO,MAAM,2BAA8D,CAAC;AAAA,EAC1E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAiB;AACf,QAAM,uBAAuB,yBAAyB;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,WAAW,oBAAoB,oBAAoB;AAEzD,QAAM,aAAa;AAAA,IACjB;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/markdown/index.ts"],"sourcesContent":["export * from './MarkdownProvider';\nexport * from './MarkdownRenderer';\
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/index.ts"],"sourcesContent":["export * from './MarkdownProvider';\nexport * from './MarkdownRenderer';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
1
2
|
import {
|
|
2
|
-
NodeType
|
|
3
|
+
NodeType,
|
|
4
|
+
getMarkdownMetadata,
|
|
5
|
+
deepTransformNode
|
|
3
6
|
} from "@intlayer/core";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
+
import { renderIntlayerNode } from "./IntlayerNode.mjs";
|
|
8
|
+
import { EditedContentRenderer } from "./editor/useEditedContentRenderer.mjs";
|
|
9
|
+
import { ContentSelectorRenderer } from "./editor/index.mjs";
|
|
10
|
+
import { MarkdownMetadataRenderer, MarkdownRenderer } from "./markdown/index.mjs";
|
|
7
11
|
const intlayerNodePlugins = {
|
|
8
12
|
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
9
13
|
transform: (_node, {
|
|
10
14
|
plugins,
|
|
11
15
|
// Removed to avoid next error - Functions cannot be passed directly to Client Components
|
|
12
16
|
...rest
|
|
13
|
-
}) =>
|
|
17
|
+
}) => renderIntlayerNode({
|
|
18
|
+
...rest,
|
|
19
|
+
value: rest.children,
|
|
20
|
+
children: /* @__PURE__ */ jsx(ContentSelectorRenderer, { ...rest, children: /* @__PURE__ */ jsx(EditedContentRenderer, { ...rest, children: rest.children }) })
|
|
21
|
+
})
|
|
14
22
|
};
|
|
15
23
|
const reactNodePlugins = {
|
|
16
24
|
canHandle: (node) => typeof node === "object" && typeof node.props !== "undefined" && typeof node.key !== "undefined",
|
|
@@ -18,23 +26,58 @@ const reactNodePlugins = {
|
|
|
18
26
|
plugins,
|
|
19
27
|
// Removed to avoid next error - Functions cannot be passed directly to Client Components
|
|
20
28
|
...rest
|
|
21
|
-
}) =>
|
|
29
|
+
}) => renderIntlayerNode({
|
|
22
30
|
...rest,
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
value: "[[react-element]]",
|
|
32
|
+
children: /* @__PURE__ */ jsx(ContentSelectorRenderer, { ...rest, children: "renderReactElement(node)" })
|
|
25
33
|
})
|
|
26
34
|
};
|
|
27
35
|
const markdownPlugin = {
|
|
28
36
|
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Markdown,
|
|
29
|
-
transform: (node, {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
transform: (node, props) => {
|
|
38
|
+
const {
|
|
39
|
+
plugins,
|
|
40
|
+
// Removed to avoid next error - Functions cannot be passed directly to Client Components
|
|
41
|
+
...rest
|
|
42
|
+
} = 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);
|
|
51
|
+
const metadataPlugins = {
|
|
52
|
+
canHandle: (node2) => typeof node2 === "string" || typeof node2 === "number" || typeof node2 === "boolean" || !node2,
|
|
53
|
+
transform: (node2, props2) => renderIntlayerNode({
|
|
54
|
+
...props2,
|
|
55
|
+
value: node2,
|
|
56
|
+
children: /* @__PURE__ */ jsx(ContentSelectorRenderer, { ...rest, keyPath: newKeyPath, children: /* @__PURE__ */ jsx(
|
|
57
|
+
MarkdownMetadataRenderer,
|
|
58
|
+
{
|
|
59
|
+
...rest,
|
|
60
|
+
keyPath: newKeyPath,
|
|
61
|
+
metadataKeyPath: props2.keyPath,
|
|
62
|
+
children: content
|
|
63
|
+
}
|
|
64
|
+
) })
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
const metadataNodes = deepTransformNode(metadata, {
|
|
68
|
+
plugins: [metadataPlugins],
|
|
69
|
+
dictionaryKey: rest.dictionaryKey,
|
|
70
|
+
keyPath: []
|
|
71
|
+
});
|
|
72
|
+
return renderIntlayerNode({
|
|
73
|
+
...props,
|
|
74
|
+
value: content,
|
|
75
|
+
children: /* @__PURE__ */ jsx(ContentSelectorRenderer, { ...rest, keyPath: newKeyPath, children: /* @__PURE__ */ jsx(MarkdownRenderer, { ...rest, keyPath: newKeyPath, children: content }) }),
|
|
76
|
+
additionalProps: {
|
|
77
|
+
metadata: metadataNodes
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
38
81
|
};
|
|
39
82
|
export {
|
|
40
83
|
intlayerNodePlugins,
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -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} from '@intlayer/core';\nimport type { ReactNode } from 'react';\nimport {
|
|
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;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,MAEA,mBAAmB;AAAA,IACjB,GAAG;AAAA,IACH,OAAO,KAAK;AAAA,IACZ,UACE,oBAAC,2BAAyB,GAAG,MAC3B,8BAAC,yBAAuB,GAAG,MACxB,eAAK,UACR,GACF;AAAA,EAEJ,CAAC;AACL;AAcO,MAAM,mBAA4B;AAAA,EACvC,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;AAAA,EAEtB,WAAW,CACT,MACA;AAAA,IACE;AAAA;AAAA,IACA,GAAG;AAAA,EACL,MAEA,mBAAmB;AAAA,IACjB,GAAG;AAAA,IACH,OAAO;AAAA,IACP,UACE,oBAAC,2BAAyB,GAAG,MAAM,sCAEnC;AAAA,EAEJ,CAAC;AACL;AAeO,MAAM,iBAA0B;AAAA,EACrC,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAAuB,UAAU;AAC3C,UAAM;AAAA,MACJ;AAAA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AAEJ,UAAM,aAAwB;AAAA,MAC5B,GAAG,MAAM;AAAA,MACT;AAAA,QACE,MAAM,SAAS;AAAA,MACjB;AAAA,IACF;AAEA,UAAM,UAAU,KAAK,SAAS,QAAQ;AACtC,UAAM,WAAW,oBAAoB,OAAO;AAE5C,UAAM,kBAA2B;AAAA,MAC/B,WAAW,CAACA,UACV,OAAOA,UAAS,YAChB,OAAOA,UAAS,YAChB,OAAOA,UAAS,aAChB,CAACA;AAAA,MACH,WAAW,CAACA,OAAMC,WAChB,mBAAmB;AAAA,QACjB,GAAGA;AAAA,QACH,OAAOD;AAAA,QACP,UACE,oBAAC,2BAAyB,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,9 +1,15 @@
|
|
|
1
1
|
import type { NodeProps } from '@intlayer/core';
|
|
2
2
|
import { type PropsWithChildren, type ReactNode } from 'react';
|
|
3
|
-
export type IntlayerNode<T = NodeProps['
|
|
3
|
+
export type IntlayerNode<T = NodeProps['children'], AdditionalProps = {}> = ReactNode & {
|
|
4
4
|
value: T;
|
|
5
|
-
};
|
|
6
|
-
|
|
5
|
+
} & AdditionalProps;
|
|
6
|
+
type RenderIntlayerNodeProps<T> = PropsWithChildren<{
|
|
7
7
|
value: T;
|
|
8
|
-
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
additionalProps?: {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
export declare const renderIntlayerNode: <T extends number | string | boolean | undefined | null>({ children, value, additionalProps, }: RenderIntlayerNodeProps<T>) => IntlayerNode<T>;
|
|
14
|
+
export {};
|
|
9
15
|
//# sourceMappingURL=IntlayerNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerNode.d.ts","sourceRoot":"","sources":["../../src/IntlayerNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAEf,MAAM,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"IntlayerNode.d.ts","sourceRoot":"","sources":["../../src/IntlayerNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAEf,MAAM,MAAM,YAAY,CACtB,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,EACzB,eAAe,GAAG,EAAE,IAClB,SAAS,GAAG;IACd,KAAK,EAAE,CAAC,CAAC;CACV,GAAG,eAAe,CAAC;AAEpB,KAAK,uBAAuB,CAAC,CAAC,IAAI,iBAAiB,CAAC;IAClD,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CAC1C,CAAC,CAAC;AAEH,eAAO,MAAM,kBAAkB,GAC7B,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,EACtD,uCAIC,uBAAuB,CAAC,CAAC,CAAC,KAAG,YAAY,CAAC,CAAC,CA0B7C,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type NodeProps } from '@intlayer/core';
|
|
2
2
|
import { type HTMLAttributes, type FC } from 'react';
|
|
3
|
-
export type ContentSelectorWrapperProps = NodeProps & Omit<HTMLAttributes<HTMLDivElement>, '
|
|
4
|
-
export declare const
|
|
3
|
+
export type ContentSelectorWrapperProps = NodeProps & Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
4
|
+
export declare const ContentSelectorRenderer: FC<ContentSelectorWrapperProps>;
|
|
5
5
|
//# sourceMappingURL=ContentSelectorWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,KAAK,cAAc,EAAwB,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3E,MAAM,MAAM,2BAA2B,GAAG,SAAS,GACjD,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,CAAC;AAkCnD,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,2BAA2B,CAgBnE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/editor/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/editor/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { KeyPath } from '@intlayer/core';
|
|
3
|
+
type EditedContentRendererProps = {
|
|
4
|
+
dictionaryKey: string;
|
|
5
|
+
keyPath: KeyPath[];
|
|
6
|
+
children: string;
|
|
7
|
+
renderChildren?: (children: any) => any;
|
|
8
|
+
};
|
|
9
|
+
export declare const useEditedContentRenderer: ({ dictionaryKey, keyPath, children, }: EditedContentRendererProps) => string;
|
|
10
|
+
export declare const EditedContentRenderer: FC<EditedContentRendererProps>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=useEditedContentRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEditedContentRenderer.d.ts","sourceRoot":"","sources":["../../../src/editor/useEditedContentRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,KAAK,0BAA0B,GAAG;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,GAAG,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,uCAItC,0BAA0B,WAe5B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,0BAA0B,CAMhE,CAAC"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { FC } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { KeyPath } from '@intlayer/core';
|
|
3
|
+
type MarkdownRendererProps = {
|
|
4
|
+
dictionaryKey: string;
|
|
5
|
+
keyPath: KeyPath[];
|
|
6
|
+
children: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const MarkdownRenderer: FC<MarkdownRendererProps>;
|
|
9
|
+
type MarkdownMetadataRendererProps = MarkdownRendererProps & {
|
|
10
|
+
metadataKeyPath: KeyPath[];
|
|
11
|
+
};
|
|
12
|
+
export declare const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps>;
|
|
13
|
+
export {};
|
|
5
14
|
//# sourceMappingURL=MarkdownRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRenderer.d.ts","sourceRoot":"","sources":["../../../src/markdown/MarkdownRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"MarkdownRenderer.d.ts","sourceRoot":"","sources":["../../../src/markdown/MarkdownRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAa,MAAM,OAAO,CAAC;AAG3C,OAAO,EAIL,OAAO,EACR,MAAM,gBAAgB,CAAC;AAExB,KAAK,qBAAqB,GAAG;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAatD,CAAC;AAEF,KAAK,6BAA6B,GAAG,qBAAqB,GAAG;IAC3D,eAAe,EAAE,OAAO,EAAE,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,EAAE,CAAC,6BAA6B,CAmBtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/markdown/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/markdown/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
package/dist/types/plugins.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Plugins, type IInterpreterPluginState as IInterpreterPluginStateCore, type DeepTransformContent as DeepTransformContentCore, NodeType } from '@intlayer/core';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
|
-
import type
|
|
3
|
+
import { type IntlayerNode } from './IntlayerNode';
|
|
4
4
|
/** ---------------------------------------------
|
|
5
5
|
* INTLAYER NODE PLUGIN
|
|
6
6
|
* --------------------------------------------- */
|
|
@@ -22,7 +22,10 @@ export declare const reactNodePlugins: Plugins;
|
|
|
22
22
|
export type MarkdownCond<T> = T extends {
|
|
23
23
|
nodeType: NodeType | string;
|
|
24
24
|
[NodeType.Markdown]: string;
|
|
25
|
-
|
|
25
|
+
metadata?: infer U;
|
|
26
|
+
} ? IntlayerNode<string, {
|
|
27
|
+
metadata: DeepTransformContent<U>;
|
|
28
|
+
}> : never;
|
|
26
29
|
/** Markdown plugin. Replaces node with a function that takes quantity => string. */
|
|
27
30
|
export declare const markdownPlugin: Plugins;
|
|
28
31
|
/** ---------------------------------------------
|
|
@@ -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,
|
|
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,YAAY,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC,GAC3D,KAAK,CAAC;AAEV,oFAAoF;AACpF,eAAO,MAAM,cAAc,EAAE,OAiE5B,CAAC;AAEF;;oDAEoD;AAEpD,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAC5B,YAAY,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAClC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,2BAA2B,GAAG;IAClE,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,EAAE,IAAI,CAAC;IACnB,QAAQ,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,wBAAwB,CAC5D,CAAC,EACD,uBAAuB,CACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intlayer",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"url": "https://github.com/aymericzip"
|
|
35
35
|
}
|
|
36
36
|
],
|
|
37
|
+
"sideEffects": false,
|
|
37
38
|
"exports": {
|
|
38
39
|
".": {
|
|
39
40
|
"types": "./dist/types/index.d.ts",
|
|
@@ -68,11 +69,11 @@
|
|
|
68
69
|
],
|
|
69
70
|
"dependencies": {
|
|
70
71
|
"js-cookie": "^3.0.5",
|
|
71
|
-
"@intlayer/api": "5.
|
|
72
|
-
"@intlayer/config": "5.
|
|
73
|
-
"@intlayer/core": "5.
|
|
74
|
-
"@intlayer/
|
|
75
|
-
"@intlayer/
|
|
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"
|
|
76
77
|
},
|
|
77
78
|
"devDependencies": {
|
|
78
79
|
"@craco/types": "^7.1.0",
|
|
@@ -89,20 +90,20 @@
|
|
|
89
90
|
"tsup": "^8.3.5",
|
|
90
91
|
"typescript": "^5.7.3",
|
|
91
92
|
"@utils/eslint-config": "1.0.4",
|
|
92
|
-
"@utils/ts-config-types": "1.0.4",
|
|
93
93
|
"@utils/ts-config": "1.0.4",
|
|
94
|
+
"@utils/ts-config-types": "1.0.4",
|
|
94
95
|
"@utils/tsup-config": "1.0.4",
|
|
95
|
-
"@intlayer/backend": "5.
|
|
96
|
+
"@intlayer/backend": "5.3.0"
|
|
96
97
|
},
|
|
97
98
|
"peerDependencies": {
|
|
98
99
|
"react": ">=16.0.0",
|
|
99
100
|
"react-dom": ">=16.0.0",
|
|
100
|
-
"@intlayer/
|
|
101
|
-
"@intlayer/
|
|
102
|
-
"@intlayer/
|
|
103
|
-
"@intlayer/
|
|
104
|
-
"intlayer": "5.
|
|
105
|
-
"@intlayer/
|
|
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"
|
|
106
107
|
},
|
|
107
108
|
"engines": {
|
|
108
109
|
"node": ">=14.18"
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var renderContentEditor_exports = {};
|
|
20
|
-
__export(renderContentEditor_exports, {
|
|
21
|
-
renderIntlayerEditor: () => renderIntlayerEditor
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(renderContentEditor_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
-
var import_IntlayerNode = require('../IntlayerNode.cjs');
|
|
26
|
-
var import_ContentSelectorWrapper = require('./ContentSelectorWrapper.cjs');
|
|
27
|
-
const renderIntlayerEditor = (props) => (0, import_IntlayerNode.rendererIntlayerNode)({
|
|
28
|
-
value: props.value ?? props.content,
|
|
29
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentSelectorWrapper.ContentSelectorWrapper, { ...props, children: props.content })
|
|
30
|
-
});
|
|
31
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
-
0 && (module.exports = {
|
|
33
|
-
renderIntlayerEditor
|
|
34
|
-
});
|
|
35
|
-
//# sourceMappingURL=renderContentEditor.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/renderContentEditor.tsx"],"sourcesContent":["import { type NodeProps } from '@intlayer/core';\nimport { type IntlayerNode, rendererIntlayerNode } from '../IntlayerNode';\nimport {\n ContentSelectorWrapper,\n type ContentSelectorWrapperProps,\n} from './ContentSelectorWrapper';\n\nexport type RenderIntlayerEditorProps = Omit<\n ContentSelectorWrapperProps,\n 'children' | 'content'\n> &\n NodeProps & {\n value?: string;\n };\n\nexport const renderIntlayerEditor = (\n props: RenderIntlayerEditorProps\n): IntlayerNode =>\n rendererIntlayerNode({\n value: props.value ?? props.content,\n children: (\n <ContentSelectorWrapper {...props}>\n {props.content}\n </ContentSelectorWrapper>\n ),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBM;AApBN,0BAAwD;AACxD,oCAGO;AAUA,MAAM,uBAAuB,CAClC,cAEA,0CAAqB;AAAA,EACnB,OAAO,MAAM,SAAS,MAAM;AAAA,EAC5B,UACE,4CAAC,wDAAwB,GAAG,OACzB,gBAAM,SACT;AAEJ,CAAC;","names":[]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var renderMarkdown_exports = {};
|
|
20
|
-
__export(renderMarkdown_exports, {
|
|
21
|
-
renderMarkdown: () => renderMarkdown
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(renderMarkdown_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
-
var import_MarkdownRenderer = require('./MarkdownRenderer.cjs');
|
|
26
|
-
const renderMarkdown = (markdown) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MarkdownRenderer.MarkdownRenderer, { markdown });
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
renderMarkdown
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=renderMarkdown.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/markdown/renderMarkdown.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { MarkdownRenderer } from './MarkdownRenderer';\n\nexport const renderMarkdown = (markdown: string): ReactNode => (\n <MarkdownRenderer markdown={markdown} />\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIE;AAHF,8BAAiC;AAE1B,MAAM,iBAAiB,CAAC,aAC7B,4CAAC,4CAAiB,UAAoB;","names":[]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { rendererIntlayerNode } from "../IntlayerNode.mjs";
|
|
3
|
-
import {
|
|
4
|
-
ContentSelectorWrapper
|
|
5
|
-
} from "./ContentSelectorWrapper.mjs";
|
|
6
|
-
const renderIntlayerEditor = (props) => rendererIntlayerNode({
|
|
7
|
-
value: props.value ?? props.content,
|
|
8
|
-
children: /* @__PURE__ */ jsx(ContentSelectorWrapper, { ...props, children: props.content })
|
|
9
|
-
});
|
|
10
|
-
export {
|
|
11
|
-
renderIntlayerEditor
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=renderContentEditor.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/renderContentEditor.tsx"],"sourcesContent":["import { type NodeProps } from '@intlayer/core';\nimport { type IntlayerNode, rendererIntlayerNode } from '../IntlayerNode';\nimport {\n ContentSelectorWrapper,\n type ContentSelectorWrapperProps,\n} from './ContentSelectorWrapper';\n\nexport type RenderIntlayerEditorProps = Omit<\n ContentSelectorWrapperProps,\n 'children' | 'content'\n> &\n NodeProps & {\n value?: string;\n };\n\nexport const renderIntlayerEditor = (\n props: RenderIntlayerEditorProps\n): IntlayerNode =>\n rendererIntlayerNode({\n value: props.value ?? props.content,\n children: (\n <ContentSelectorWrapper {...props}>\n {props.content}\n </ContentSelectorWrapper>\n ),\n });\n"],"mappings":"AAqBM;AApBN,SAA4B,4BAA4B;AACxD;AAAA,EACE;AAAA,OAEK;AAUA,MAAM,uBAAuB,CAClC,UAEA,qBAAqB;AAAA,EACnB,OAAO,MAAM,SAAS,MAAM;AAAA,EAC5B,UACE,oBAAC,0BAAwB,GAAG,OACzB,gBAAM,SACT;AAEJ,CAAC;","names":[]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { MarkdownRenderer } from "./MarkdownRenderer.mjs";
|
|
3
|
-
const renderMarkdown = (markdown) => /* @__PURE__ */ jsx(MarkdownRenderer, { markdown });
|
|
4
|
-
export {
|
|
5
|
-
renderMarkdown
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=renderMarkdown.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/markdown/renderMarkdown.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { MarkdownRenderer } from './MarkdownRenderer';\n\nexport const renderMarkdown = (markdown: string): ReactNode => (\n <MarkdownRenderer markdown={markdown} />\n);\n"],"mappings":"AAIE;AAHF,SAAS,wBAAwB;AAE1B,MAAM,iBAAiB,CAAC,aAC7B,oBAAC,oBAAiB,UAAoB;","names":[]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type NodeProps } from '@intlayer/core';
|
|
2
|
-
import { type IntlayerNode } from '../IntlayerNode';
|
|
3
|
-
import { type ContentSelectorWrapperProps } from './ContentSelectorWrapper';
|
|
4
|
-
export type RenderIntlayerEditorProps = Omit<ContentSelectorWrapperProps, 'children' | 'content'> & NodeProps & {
|
|
5
|
-
value?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const renderIntlayerEditor: (props: RenderIntlayerEditorProps) => IntlayerNode;
|
|
8
|
-
//# sourceMappingURL=renderContentEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderContentEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/renderContentEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,2BAA2B,EAC3B,UAAU,GAAG,SAAS,CACvB,GACC,SAAS,GAAG;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEJ,eAAO,MAAM,oBAAoB,GAC/B,OAAO,yBAAyB,KAC/B,YAQC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderMarkdown.d.ts","sourceRoot":"","sources":["../../../src/markdown/renderMarkdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,KAAG,SAEjD,CAAC"}
|