react-intlayer 8.3.3 → 8.3.4

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.
@@ -1,2 +1,2 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../client/IntlayerProvider.cjs`),t=require(`../UI/ContentSelector.cjs`);let n=require(`@intlayer/types/nodeType`),r=require(`react`),i=require(`@intlayer/core/utils`),a=require(`@intlayer/editor-react`),o=require(`react/jsx-runtime`);const s=({children:e,dictionaryKey:s,keyPath:c})=>{let{focusedContent:l,setFocusedContent:u}=(0,a.useFocusDictionary)(),{postMessage:d,senderId:f}=(0,a.useCommunicator)(),p=(0,r.useMemo)(()=>c.filter(e=>e.type!==n.NodeType.Translation),[c]);return(0,o.jsx)(t.ContentSelector,{onPress:(0,r.useCallback)(()=>u({dictionaryKey:s,keyPath:p}),[s,p]),onHover:(0,r.useCallback)(()=>d({type:`${a.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,data:{dictionaryKey:s,keyPath:p},senderId:f}),[s,p]),onUnhover:(0,r.useCallback)(()=>d({type:`${a.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,data:null,senderId:f}),[f]),isSelecting:(0,r.useMemo)(()=>(l?.dictionaryKey===s&&(l?.keyPath?.length??0)>0&&(0,i.isSameKeyPath)(l?.keyPath??[],p))??!1,[l,p,s]),children:e})},c=({children:t,...n})=>{let{enabled:r}=(0,a.useEditorEnabled)(),{disableEditor:i}=e.useIntlayerContext();return r&&!i?(0,o.jsx)(s,{...n,children:t}):t};exports.ContentSelectorRenderer=c;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../client/IntlayerProvider.cjs`);let t=require(`@intlayer/types/nodeType`),n=require(`react`),r=require(`@intlayer/core/utils`),i=require(`@intlayer/editor`),a=require(`@intlayer/editor-react`),o=require(`react/jsx-runtime`);const s=({children:e,dictionaryKey:s,keyPath:c})=>{let{focusedContent:l,setFocusedContent:u}=(0,a.useFocusDictionary)(),{postMessage:d,senderId:f}=(0,a.useCommunicator)(),p=(0,n.useRef)(null),m=c.filter(e=>e.type!==t.NodeType.Translation),h=(l?.dictionaryKey===s&&(l?.keyPath?.length??0)>0&&(0,r.isSameKeyPath)(l?.keyPath??[],m))??!1;return(0,n.useEffect)(()=>{let e=p.current;if(!e)return;let t=()=>{u({dictionaryKey:s,keyPath:m})},n=()=>{d({type:`${i.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,data:{dictionaryKey:s,keyPath:m},senderId:f})},r=()=>{d({type:`${i.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,data:null,senderId:f})};return e.addEventListener(`intlayer:press`,t),e.addEventListener(`intlayer:hover`,n),e.addEventListener(`intlayer:unhover`,r),()=>{e.removeEventListener(`intlayer:press`,t),e.removeEventListener(`intlayer:hover`,n),e.removeEventListener(`intlayer:unhover`,r)}}),(0,o.jsx)(`intlayer-content-selector`,{ref:p,"is-selecting":h||void 0,children:e})},c=({children:t,...n})=>{let{enabled:r}=(0,a.useEditorEnabled)(),{disableEditor:i}=e.useIntlayerContext();return r&&!i?(0,o.jsx)(s,{...n,children:t}):t};exports.ContentSelectorRenderer=c;
2
2
  //# sourceMappingURL=ContentSelectorWrapper.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelectorWrapper.cjs","names":["NodeType","ContentSelector","MessageKey","useIntlayerContext"],"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport type { NodeProps } from '@intlayer/core/interpreter';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport {\n MessageKey,\n useCommunicator,\n useEditorEnabled,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { type FC, type HTMLAttributes, useCallback, useMemo } 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 const { postMessage, senderId } = useCommunicator();\n\n // Filter out translation nodes for more flexibility with the editor that can have different format\n const filteredKeyPath = useMemo(\n () => keyPath.filter((key) => key.type !== NodeType.Translation),\n [keyPath]\n );\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath: filteredKeyPath,\n }),\n [dictionaryKey, filteredKeyPath]\n );\n\n const handleHover = useCallback(\n () =>\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: {\n dictionaryKey,\n keyPath: filteredKeyPath,\n },\n senderId,\n }),\n [dictionaryKey, filteredKeyPath]\n );\n\n const handleUnhover = useCallback(\n () =>\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: null,\n senderId,\n }),\n [senderId]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], filteredKeyPath)) ??\n false,\n [focusedContent, filteredKeyPath, dictionaryKey]\n );\n\n return (\n <ContentSelector\n onPress={handleSelect}\n onHover={handleHover}\n onUnhover={handleUnhover}\n isSelecting={isSelected}\n >\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":"wXAkBA,MAAM,GAAkE,CACtE,WACA,gBACA,aACI,CACJ,GAAM,CAAE,iBAAgB,sBAAA,EAAA,EAAA,qBAA0C,CAC5D,CAAE,cAAa,aAAA,EAAA,EAAA,kBAA8B,CAG7C,GAAA,EAAA,EAAA,aACE,EAAQ,OAAQ,GAAQ,EAAI,OAASA,EAAAA,SAAS,YAAY,CAChE,CAAC,EAAQ,CACV,CA2CD,OACE,EAAA,EAAA,KAACC,EAAAA,gBAAD,CACE,SAAA,EAAA,EAAA,iBAzCA,EAAkB,CAChB,gBACA,QAAS,EACV,CAAC,CACJ,CAAC,EAAe,EAAgB,CACjC,CAqCG,SAAA,EAAA,EAAA,iBAjCA,EAAY,CACV,KAAM,GAAGC,EAAAA,WAAW,iCAAiC,OACrD,KAAM,CACJ,gBACA,QAAS,EACV,CACD,WACD,CAAC,CACJ,CAAC,EAAe,EAAgB,CACjC,CAyBG,WAAA,EAAA,EAAA,iBArBA,EAAY,CACV,KAAM,GAAGA,EAAAA,WAAW,iCAAiC,OACrD,KAAM,KACN,WACD,CAAC,CACJ,CAAC,EAAS,CACX,CAgBG,aAAA,EAAA,EAAA,cAZC,GAAgB,gBAAkB,IAChC,GAAgB,SAAS,QAAU,GAAK,IAAA,EAAA,EAAA,eAC3B,GAAgB,SAAW,EAAE,CAAE,EAAgB,GAC/D,GACF,CAAC,EAAgB,EAAiB,EAAc,CACjD,CASI,WACe,CAAA,EAIT,GAA4D,CACvE,WACA,GAAG,KACC,CACJ,GAAM,CAAE,YAAA,EAAA,EAAA,mBAA8B,CAChC,CAAE,iBAAkBC,EAAAA,oBAAoB,CAU9C,OARI,GAAW,CAAC,GAEZ,EAAA,EAAA,KAAC,EAAD,CAA+B,GAAI,EAChC,WAC6B,CAAA,CAI7B"}
1
+ {"version":3,"file":"ContentSelectorWrapper.cjs","names":["NodeType","MessageKey","useIntlayerContext"],"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport type { NodeProps } from '@intlayer/core/interpreter';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport { MessageKey } from '@intlayer/editor';\nimport {\n useCommunicator,\n useEditorEnabled,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { type FC, type HTMLAttributes, useEffect, useRef } from 'react';\nimport { useIntlayerContext } from '../client';\n\n// JSX declaration for the Lit web component\ndeclare global {\n namespace JSX {\n interface IntrinsicElements {\n 'intlayer-content-selector': React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement> & {\n 'is-selecting'?: boolean;\n 'press-duration'?: number;\n },\n HTMLElement\n >;\n }\n }\n}\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 const { postMessage, senderId } = useCommunicator();\n const ref = useRef<HTMLElement>(null);\n\n const filteredKeyPath = keyPath.filter(\n (key) => key.type !== NodeType.Translation\n );\n\n const isSelected =\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], filteredKeyPath)) ??\n false;\n\n // React 18: web component custom events are not forwarded via JSX — use addEventListener\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n\n const handlePress = () => {\n setFocusedContent({ dictionaryKey, keyPath: filteredKeyPath });\n };\n\n const handleHover = () => {\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: { dictionaryKey, keyPath: filteredKeyPath },\n senderId,\n });\n };\n\n const handleUnhover = () => {\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: null,\n senderId,\n });\n };\n\n el.addEventListener('intlayer:press', handlePress);\n el.addEventListener('intlayer:hover', handleHover);\n el.addEventListener('intlayer:unhover', handleUnhover);\n return () => {\n el.removeEventListener('intlayer:press', handlePress);\n el.removeEventListener('intlayer:hover', handleHover);\n el.removeEventListener('intlayer:unhover', handleUnhover);\n };\n });\n\n return (\n // @ts-ignore — ref typing for custom elements\n <intlayer-content-selector ref={ref} is-selecting={isSelected || undefined}>\n {children}\n </intlayer-content-selector>\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":"+WAgCA,MAAM,GAAkE,CACtE,WACA,gBACA,aACI,CACJ,GAAM,CAAE,iBAAgB,sBAAA,EAAA,EAAA,qBAA0C,CAC5D,CAAE,cAAa,aAAA,EAAA,EAAA,kBAA8B,CAC7C,GAAA,EAAA,EAAA,QAA0B,KAAK,CAE/B,EAAkB,EAAQ,OAC7B,GAAQ,EAAI,OAASA,EAAAA,SAAS,YAChC,CAEK,GACH,GAAgB,gBAAkB,IAChC,GAAgB,SAAS,QAAU,GAAK,IAAA,EAAA,EAAA,eAC3B,GAAgB,SAAW,EAAE,CAAE,EAAgB,GAC/D,GAqCF,OAlCA,EAAA,EAAA,eAAgB,CACd,IAAM,EAAK,EAAI,QACf,GAAI,CAAC,EAAI,OAET,IAAM,MAAoB,CACxB,EAAkB,CAAE,gBAAe,QAAS,EAAiB,CAAC,EAG1D,MAAoB,CACxB,EAAY,CACV,KAAM,GAAGC,EAAAA,WAAW,iCAAiC,OACrD,KAAM,CAAE,gBAAe,QAAS,EAAiB,CACjD,WACD,CAAC,EAGE,MAAsB,CAC1B,EAAY,CACV,KAAM,GAAGA,EAAAA,WAAW,iCAAiC,OACrD,KAAM,KACN,WACD,CAAC,EAMJ,OAHA,EAAG,iBAAiB,iBAAkB,EAAY,CAClD,EAAG,iBAAiB,iBAAkB,EAAY,CAClD,EAAG,iBAAiB,mBAAoB,EAAc,KACzC,CACX,EAAG,oBAAoB,iBAAkB,EAAY,CACrD,EAAG,oBAAoB,iBAAkB,EAAY,CACrD,EAAG,oBAAoB,mBAAoB,EAAc,GAE3D,EAIA,EAAA,EAAA,KAAC,4BAAD,CAAgC,MAAK,eAAc,GAAc,IAAA,GAC9D,WACyB,CAAA,EAInB,GAA4D,CACvE,WACA,GAAG,KACC,CACJ,GAAM,CAAE,YAAA,EAAA,EAAA,mBAA8B,CAChC,CAAE,iBAAkBC,EAAAA,oBAAoB,CAU9C,OARI,GAAW,CAAC,GAEZ,EAAA,EAAA,KAAC,EAAD,CAA+B,GAAI,EAChC,WAC6B,CAAA,CAI7B"}
@@ -1,2 +1,2 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`@intlayer/config/built`);t=e.__toESM(t);let n=require(`react`),r=require(`@intlayer/editor-react`),i=require(`react/jsx-runtime`);const a=()=>{(0,r.useCrossURLPathSetter)(),(0,r.useIframeClickInterceptor)();let{setLocaleDictionaries:e}=(0,r.useDictionariesRecordActions)();return(0,n.useEffect)(()=>{import(`@intlayer/unmerged-dictionaries-entry`).then(t=>{let n=t.getUnmergedDictionaries(),r=Object.fromEntries(Object.values(n).flat().map(e=>[e.localId,e]));e?.(r)})},[]),(0,i.jsx)(i.Fragment,{})},{editor:o}=t.default??{},s=()=>{let{enabled:e}=(0,r.useEditorEnabled)();return e?(0,i.jsx)(a,{}):(0,i.jsx)(i.Fragment,{})},c=({children:e})=>(0,i.jsxs)(r.EditorProvider,{postMessage:e=>{typeof window>`u`||o&&window.self!==window.top&&(o.applicationURL.length>0&&window?.postMessage(e,o.applicationURL),o.editorURL.length>0&&window.parent?.postMessage(e,o.editorURL),o.cmsURL.length>0&&window.parent?.postMessage(e,o.cmsURL))},allowedOrigins:[o?.editorURL,o?.cmsURL,o?.applicationURL].filter(Boolean),mode:`client`,configuration:t.default,children:[(0,i.jsx)(s,{}),e]});exports.IntlayerEditorProvider=c;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/editor-react`),t=require(`react/jsx-runtime`);const n=({children:n})=>(0,t.jsx)(e.EditorProvider,{mode:`client`,children:n});exports.IntlayerEditorProvider=n;
2
2
  //# sourceMappingURL=IntlayerEditorProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerEditorProvider.cjs","names":["configuration","EditorProvider"],"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport {\n EditorProvider,\n useCrossURLPathSetter,\n useDictionariesRecordActions,\n useEditorEnabled,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport type { FC, PropsWithChildren } from 'react';\nimport { useEffect } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathSetter();\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n /**\n * Sent local dictionaries to editor\n */\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n useEffect(() => {\n // Load dictionaries dynamically to do not impact the bundle, and send them to the editor\n import('@intlayer/unmerged-dictionaries-entry').then((mod) => {\n const unmergedDictionaries = mod.getUnmergedDictionaries();\n const dictionariesList = Object.fromEntries(\n Object.values(unmergedDictionaries)\n .flat()\n .map((dictionary) => [dictionary.localId, dictionary])\n );\n\n setLocaleDictionaries?.(dictionariesList);\n });\n }, []);\n\n return <></>;\n};\n\nconst { editor } = configuration ?? {};\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n if (!editor) return;\n\n const isInIframe = window.self !== window.top;\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\n window?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current application URL to synchronize the locales states.\n editor.applicationURL\n );\n }\n\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={\n [editor?.editorURL, editor?.cmsURL, editor?.applicationURL].filter(\n Boolean\n ) as string[]\n }\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":"sRAaA,MAAM,MAAuC,EAI3C,EAAA,EAAA,wBAAuB,EAKvB,EAAA,EAAA,4BAA2B,CAK3B,GAAM,CAAE,0BAAA,EAAA,EAAA,+BAAwD,CAehE,OAdA,EAAA,EAAA,eAAgB,CAEd,OAAO,yCAAyC,KAAM,GAAQ,CAC5D,IAAM,EAAuB,EAAI,yBAAyB,CACpD,EAAmB,OAAO,YAC9B,OAAO,OAAO,EAAqB,CAChC,MAAM,CACN,IAAK,GAAe,CAAC,EAAW,QAAS,EAAW,CAAC,CACzD,CAED,IAAwB,EAAiB,EACzC,EACD,EAAE,CAAC,EAEC,EAAA,EAAA,KAAA,EAAA,SAAA,EAAK,CAAA,EAGR,CAAE,UAAWA,EAAAA,SAAiB,EAAE,CAEhC,MAA+B,CACnC,GAAM,CAAE,YAAA,EAAA,EAAA,mBAA8B,CAEtC,OAAO,GAAU,EAAA,EAAA,KAAC,EAAD,EAA8B,CAAA,EAAG,EAAA,EAAA,KAAA,EAAA,SAAA,EAAK,CAAA,EAG5C,GAAiD,CAAE,eAE5D,EAAA,EAAA,MAACC,EAAAA,eAAD,CACE,YAAc,GAAc,CACtB,OAAO,OAAW,KACjB,GAEc,OAAO,OAAS,OAAO,MAGtC,EAAO,eAAe,OAAS,GACjC,QAAQ,YACN,EAGA,EAAO,eACR,CAGC,EAAO,UAAU,OAAS,GAC5B,OAAO,QAAQ,YACb,EAGA,EAAO,UACR,CAGC,EAAO,OAAO,OAAS,GACzB,OAAO,QAAQ,YACb,EAGA,EAAO,OACR,GAGL,eACE,CAAC,GAAQ,UAAW,GAAQ,OAAQ,GAAQ,eAAe,CAAC,OAC1D,QACD,CAEH,KAAK,SACL,cAAeD,EAAAA,iBAzCjB,EA2CE,EAAA,EAAA,KAAC,EAAD,EAAsB,CAAA,CACrB,EACc"}
1
+ {"version":3,"file":"IntlayerEditorProvider.cjs","names":["EditorProvider"],"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { EditorProvider } from '@intlayer/editor-react';\nimport type { FC, PropsWithChildren } from 'react';\n\n/**\n * Wraps the application with the Intlayer editor provider in client mode.\n * All configuration (URLs, origins) is read from @intlayer/config/built.\n */\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => (\n <EditorProvider mode=\"client\">{children}</EditorProvider>\n);\n"],"mappings":"oMASA,MAAa,GAAiD,CAAE,eAC9D,EAAA,EAAA,KAACA,EAAAA,eAAD,CAAgB,KAAK,SAAU,WAA0B,CAAA"}
@@ -1,2 +1,2 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./ContentSelectorWrapper.cjs`);let t=require(`@intlayer/core/interpreter`),n=require(`react`),r=require(`@intlayer/editor-react`);const i=({dictionaryKey:e,keyPath:t,children:n})=>{let i=(0,r.useEditedContentActions)();return i?i.getEditedContentValue(e,t)??n:n},a=r=>{let a=i(r);if(typeof a==`object`){let i=(0,t.getContent)(a,r,r.locale);return typeof i==`string`?(0,n.createElement)(e.ContentSelectorRenderer,{...r,key:r.children},i):(console.error(`Incorrect edited content format. Content type: ${typeof i}. Expected string. Value ${JSON.stringify(i)}`),(0,n.createElement)(e.ContentSelectorRenderer,{...r,key:r.children},r.children))}return(0,n.createElement)(e.ContentSelectorRenderer,{...r,key:r.children},a)};exports.EditedContentRenderer=a,exports.useEditedContentRenderer=i;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./ContentSelectorWrapper.cjs`);let t=require(`@intlayer/core/interpreter`),n=require(`react`),r=require(`@intlayer/editor-react`);const i=({dictionaryKey:e,keyPath:t,children:n})=>{let i=(0,r.useEditedContentActions)();return i?i.getEditedContentValue(e,t)??n:n},a=r=>{let a=i(r);if(typeof a==`object`){let i=(0,t.getContent)(a,{...r,locale:r.locale},(0,t.getBasePlugins)(r.locale));return typeof i==`string`?(0,n.createElement)(e.ContentSelectorRenderer,{...r,key:r.children},i):(console.error(`Incorrect edited content format. Content type: ${typeof i}. Expected string. Value ${JSON.stringify(i)}`),(0,n.createElement)(e.ContentSelectorRenderer,{...r,key:r.children},r.children))}return(0,n.createElement)(e.ContentSelectorRenderer,{...r,key:r.children},a)};exports.EditedContentRenderer=a,exports.useEditedContentRenderer=i;
2
2
  //# sourceMappingURL=useEditedContentRenderer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useEditedContentRenderer.cjs","names":["ContentSelectorRenderer"],"sources":["../../../src/editor/useEditedContentRenderer.tsx"],"sourcesContent":["'use client';\n\nimport { getContent } from '@intlayer/core/interpreter';\nimport { useEditedContentActions } from '@intlayer/editor-react';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { FC } from 'react';\nimport { ContentSelectorRenderer } from './ContentSelectorWrapper';\n\ntype EditedContentRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n children: string;\n locale?: Locale;\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 if (typeof content === 'object') {\n const transformedEditedContent = getContent(content, props, props.locale);\n\n if (typeof transformedEditedContent !== 'string') {\n console.error(\n `Incorrect edited content format. Content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`\n );\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {props.children}\n </ContentSelectorRenderer>\n );\n }\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {transformedEditedContent}\n </ContentSelectorRenderer>\n );\n }\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {content}\n </ContentSelectorRenderer>\n );\n};\n"],"mappings":"gRAgBA,MAAa,GAA4B,CACvC,gBACA,UACA,cACgC,CAChC,IAAM,GAAA,EAAA,EAAA,0BAAgD,CAatD,OAXI,EACkB,EAAqB,sBACvC,EACA,EACD,EAE4B,EAKxB,GAGI,EACX,GACG,CACH,IAAM,EAAU,EAAyB,EAAM,CAE/C,GAAI,OAAO,GAAY,SAAU,CAC/B,IAAM,GAAA,EAAA,EAAA,YAAsC,EAAS,EAAO,EAAM,OAAO,CAczE,OAZI,OAAO,GAA6B,UAatC,EAAA,EAAA,eAACA,EAAAA,wBAAD,CAAyB,GAAI,EAAO,IAAK,EAAM,SAErB,CADvB,EACuB,EAd1B,QAAQ,MACN,kDAAkD,OAAO,EAAyB,2BAA2B,KAAK,UAAU,EAAyB,GACtJ,EAGC,EAAA,EAAA,eAACA,EAAAA,wBAAD,CAAyB,GAAI,EAAO,IAAK,EAAM,SAErB,CADvB,EAAM,SACiB,EAWhC,OACE,EAAA,EAAA,eAACA,EAAAA,wBAAD,CAAyB,GAAI,EAAO,IAAK,EAAM,SAErB,CADvB,EACuB"}
1
+ {"version":3,"file":"useEditedContentRenderer.cjs","names":["ContentSelectorRenderer"],"sources":["../../../src/editor/useEditedContentRenderer.tsx"],"sourcesContent":["'use client';\n\nimport { getBasePlugins, getContent } from '@intlayer/core/interpreter';\nimport { useEditedContentActions } from '@intlayer/editor-react';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { FC } from 'react';\nimport { ContentSelectorRenderer } from './ContentSelectorWrapper';\n\ntype EditedContentRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n children: string;\n locale?: Locale;\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 if (typeof content === 'object') {\n const transformedEditedContent = getContent(\n content,\n { ...props, locale: props.locale },\n getBasePlugins(props.locale)\n );\n\n if (typeof transformedEditedContent !== 'string') {\n console.error(\n `Incorrect edited content format. Content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`\n );\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {props.children}\n </ContentSelectorRenderer>\n );\n }\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {transformedEditedContent}\n </ContentSelectorRenderer>\n );\n }\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {content}\n </ContentSelectorRenderer>\n );\n};\n"],"mappings":"gRAgBA,MAAa,GAA4B,CACvC,gBACA,UACA,cACgC,CAChC,IAAM,GAAA,EAAA,EAAA,0BAAgD,CAatD,OAXI,EACkB,EAAqB,sBACvC,EACA,EACD,EAE4B,EAKxB,GAGI,EACX,GACG,CACH,IAAM,EAAU,EAAyB,EAAM,CAE/C,GAAI,OAAO,GAAY,SAAU,CAC/B,IAAM,GAAA,EAAA,EAAA,YACJ,EACA,CAAE,GAAG,EAAO,OAAQ,EAAM,OAAQ,EAAA,EAAA,EAAA,gBACnB,EAAM,OAAO,CAC7B,CAcD,OAZI,OAAO,GAA6B,UAatC,EAAA,EAAA,eAACA,EAAAA,wBAAD,CAAyB,GAAI,EAAO,IAAK,EAAM,SAErB,CADvB,EACuB,EAd1B,QAAQ,MACN,kDAAkD,OAAO,EAAyB,2BAA2B,KAAK,UAAU,EAAyB,GACtJ,EAGC,EAAA,EAAA,eAACA,EAAAA,wBAAD,CAAyB,GAAI,EAAO,IAAK,EAAM,SAErB,CADvB,EAAM,SACiB,EAWhC,OACE,EAAA,EAAA,eAACA,EAAAA,wBAAD,CAAyB,GAAI,EAAO,IAAK,EAAM,SAErB,CADvB,EACuB"}
@@ -1,2 +1,2 @@
1
- "use client";import{useIntlayerContext as e}from"../client/IntlayerProvider.mjs";import{ContentSelector as t}from"../UI/ContentSelector.mjs";import{NodeType as n}from"@intlayer/types/nodeType";import{useCallback as r,useMemo as i}from"react";import{isSameKeyPath as a}from"@intlayer/core/utils";import{MessageKey as o,useCommunicator as s,useEditorEnabled as c,useFocusDictionary as l}from"@intlayer/editor-react";import{jsx as u}from"react/jsx-runtime";const d=({children:e,dictionaryKey:c,keyPath:d})=>{let{focusedContent:f,setFocusedContent:p}=l(),{postMessage:m,senderId:h}=s(),g=i(()=>d.filter(e=>e.type!==n.Translation),[d]);return u(t,{onPress:r(()=>p({dictionaryKey:c,keyPath:g}),[c,g]),onHover:r(()=>m({type:`${o.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,data:{dictionaryKey:c,keyPath:g},senderId:h}),[c,g]),onUnhover:r(()=>m({type:`${o.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,data:null,senderId:h}),[h]),isSelecting:i(()=>(f?.dictionaryKey===c&&(f?.keyPath?.length??0)>0&&a(f?.keyPath??[],g))??!1,[f,g,c]),children:e})},f=({children:t,...n})=>{let{enabled:r}=c(),{disableEditor:i}=e();return r&&!i?u(d,{...n,children:t}):t};export{f as ContentSelectorRenderer};
1
+ "use client";import{useIntlayerContext as e}from"../client/IntlayerProvider.mjs";import{NodeType as t}from"@intlayer/types/nodeType";import{useEffect as n,useRef as r}from"react";import{isSameKeyPath as i}from"@intlayer/core/utils";import{MessageKey as a}from"@intlayer/editor";import{useCommunicator as o,useEditorEnabled as s,useFocusDictionary as c}from"@intlayer/editor-react";import{jsx as l}from"react/jsx-runtime";const u=({children:e,dictionaryKey:s,keyPath:u})=>{let{focusedContent:d,setFocusedContent:f}=c(),{postMessage:p,senderId:m}=o(),h=r(null),g=u.filter(e=>e.type!==t.Translation),_=(d?.dictionaryKey===s&&(d?.keyPath?.length??0)>0&&i(d?.keyPath??[],g))??!1;return n(()=>{let e=h.current;if(!e)return;let t=()=>{f({dictionaryKey:s,keyPath:g})},n=()=>{p({type:`${a.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,data:{dictionaryKey:s,keyPath:g},senderId:m})},r=()=>{p({type:`${a.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,data:null,senderId:m})};return e.addEventListener(`intlayer:press`,t),e.addEventListener(`intlayer:hover`,n),e.addEventListener(`intlayer:unhover`,r),()=>{e.removeEventListener(`intlayer:press`,t),e.removeEventListener(`intlayer:hover`,n),e.removeEventListener(`intlayer:unhover`,r)}}),l(`intlayer-content-selector`,{ref:h,"is-selecting":_||void 0,children:e})},d=({children:t,...n})=>{let{enabled:r}=s(),{disableEditor:i}=e();return r&&!i?l(u,{...n,children:t}):t};export{d as ContentSelectorRenderer};
2
2
  //# sourceMappingURL=ContentSelectorWrapper.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelectorWrapper.mjs","names":[],"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport type { NodeProps } from '@intlayer/core/interpreter';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport {\n MessageKey,\n useCommunicator,\n useEditorEnabled,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { type FC, type HTMLAttributes, useCallback, useMemo } 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 const { postMessage, senderId } = useCommunicator();\n\n // Filter out translation nodes for more flexibility with the editor that can have different format\n const filteredKeyPath = useMemo(\n () => keyPath.filter((key) => key.type !== NodeType.Translation),\n [keyPath]\n );\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath: filteredKeyPath,\n }),\n [dictionaryKey, filteredKeyPath]\n );\n\n const handleHover = useCallback(\n () =>\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: {\n dictionaryKey,\n keyPath: filteredKeyPath,\n },\n senderId,\n }),\n [dictionaryKey, filteredKeyPath]\n );\n\n const handleUnhover = useCallback(\n () =>\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: null,\n senderId,\n }),\n [senderId]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], filteredKeyPath)) ??\n false,\n [focusedContent, filteredKeyPath, dictionaryKey]\n );\n\n return (\n <ContentSelector\n onPress={handleSelect}\n onHover={handleHover}\n onUnhover={handleUnhover}\n isSelecting={isSelected}\n >\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":"scAkBA,MAAM,GAAkE,CACtE,WACA,gBACA,aACI,CACJ,GAAM,CAAE,iBAAgB,qBAAsB,GAAoB,CAC5D,CAAE,cAAa,YAAa,GAAiB,CAG7C,EAAkB,MAChB,EAAQ,OAAQ,GAAQ,EAAI,OAAS,EAAS,YAAY,CAChE,CAAC,EAAQ,CACV,CA2CD,OACE,EAAC,EAAD,CACE,QA3CiB,MAEjB,EAAkB,CAChB,gBACA,QAAS,EACV,CAAC,CACJ,CAAC,EAAe,EAAgB,CACjC,CAqCG,QAnCgB,MAEhB,EAAY,CACV,KAAM,GAAG,EAAW,iCAAiC,OACrD,KAAM,CACJ,gBACA,QAAS,EACV,CACD,WACD,CAAC,CACJ,CAAC,EAAe,EAAgB,CACjC,CAyBG,UAvBkB,MAElB,EAAY,CACV,KAAM,GAAG,EAAW,iCAAiC,OACrD,KAAM,KACN,WACD,CAAC,CACJ,CAAC,EAAS,CACX,CAgBG,YAde,OAEd,GAAgB,gBAAkB,IAChC,GAAgB,SAAS,QAAU,GAAK,GACzC,EAAc,GAAgB,SAAW,EAAE,CAAE,EAAgB,GAC/D,GACF,CAAC,EAAgB,EAAiB,EAAc,CACjD,CASI,WACe,CAAA,EAIT,GAA4D,CACvE,WACA,GAAG,KACC,CACJ,GAAM,CAAE,WAAY,GAAkB,CAChC,CAAE,iBAAkB,GAAoB,CAU9C,OARI,GAAW,CAAC,EAEZ,EAAC,EAAD,CAA+B,GAAI,EAChC,WAC6B,CAAA,CAI7B"}
1
+ {"version":3,"file":"ContentSelectorWrapper.mjs","names":[],"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport type { NodeProps } from '@intlayer/core/interpreter';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport { MessageKey } from '@intlayer/editor';\nimport {\n useCommunicator,\n useEditorEnabled,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { type FC, type HTMLAttributes, useEffect, useRef } from 'react';\nimport { useIntlayerContext } from '../client';\n\n// JSX declaration for the Lit web component\ndeclare global {\n namespace JSX {\n interface IntrinsicElements {\n 'intlayer-content-selector': React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement> & {\n 'is-selecting'?: boolean;\n 'press-duration'?: number;\n },\n HTMLElement\n >;\n }\n }\n}\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 const { postMessage, senderId } = useCommunicator();\n const ref = useRef<HTMLElement>(null);\n\n const filteredKeyPath = keyPath.filter(\n (key) => key.type !== NodeType.Translation\n );\n\n const isSelected =\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], filteredKeyPath)) ??\n false;\n\n // React 18: web component custom events are not forwarded via JSX — use addEventListener\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n\n const handlePress = () => {\n setFocusedContent({ dictionaryKey, keyPath: filteredKeyPath });\n };\n\n const handleHover = () => {\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: { dictionaryKey, keyPath: filteredKeyPath },\n senderId,\n });\n };\n\n const handleUnhover = () => {\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: null,\n senderId,\n });\n };\n\n el.addEventListener('intlayer:press', handlePress);\n el.addEventListener('intlayer:hover', handleHover);\n el.addEventListener('intlayer:unhover', handleUnhover);\n return () => {\n el.removeEventListener('intlayer:press', handlePress);\n el.removeEventListener('intlayer:hover', handleHover);\n el.removeEventListener('intlayer:unhover', handleUnhover);\n };\n });\n\n return (\n // @ts-ignore — ref typing for custom elements\n <intlayer-content-selector ref={ref} is-selecting={isSelected || undefined}>\n {children}\n </intlayer-content-selector>\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":"qaAgCA,MAAM,GAAkE,CACtE,WACA,gBACA,aACI,CACJ,GAAM,CAAE,iBAAgB,qBAAsB,GAAoB,CAC5D,CAAE,cAAa,YAAa,GAAiB,CAC7C,EAAM,EAAoB,KAAK,CAE/B,EAAkB,EAAQ,OAC7B,GAAQ,EAAI,OAAS,EAAS,YAChC,CAEK,GACH,GAAgB,gBAAkB,IAChC,GAAgB,SAAS,QAAU,GAAK,GACzC,EAAc,GAAgB,SAAW,EAAE,CAAE,EAAgB,GAC/D,GAqCF,OAlCA,MAAgB,CACd,IAAM,EAAK,EAAI,QACf,GAAI,CAAC,EAAI,OAET,IAAM,MAAoB,CACxB,EAAkB,CAAE,gBAAe,QAAS,EAAiB,CAAC,EAG1D,MAAoB,CACxB,EAAY,CACV,KAAM,GAAG,EAAW,iCAAiC,OACrD,KAAM,CAAE,gBAAe,QAAS,EAAiB,CACjD,WACD,CAAC,EAGE,MAAsB,CAC1B,EAAY,CACV,KAAM,GAAG,EAAW,iCAAiC,OACrD,KAAM,KACN,WACD,CAAC,EAMJ,OAHA,EAAG,iBAAiB,iBAAkB,EAAY,CAClD,EAAG,iBAAiB,iBAAkB,EAAY,CAClD,EAAG,iBAAiB,mBAAoB,EAAc,KACzC,CACX,EAAG,oBAAoB,iBAAkB,EAAY,CACrD,EAAG,oBAAoB,iBAAkB,EAAY,CACrD,EAAG,oBAAoB,mBAAoB,EAAc,GAE3D,CAIA,EAAC,4BAAD,CAAgC,MAAK,eAAc,GAAc,IAAA,GAC9D,WACyB,CAAA,EAInB,GAA4D,CACvE,WACA,GAAG,KACC,CACJ,GAAM,CAAE,WAAY,GAAkB,CAChC,CAAE,iBAAkB,GAAoB,CAU9C,OARI,GAAW,CAAC,EAEZ,EAAC,EAAD,CAA+B,GAAI,EAChC,WAC6B,CAAA,CAI7B"}
@@ -1,2 +1,2 @@
1
- "use client";import e from"@intlayer/config/built";import{useEffect as t}from"react";import{EditorProvider as n,useCrossURLPathSetter as r,useDictionariesRecordActions as i,useEditorEnabled as a,useIframeClickInterceptor as o}from"@intlayer/editor-react";import{Fragment as s,jsx as c,jsxs as l}from"react/jsx-runtime";const u=()=>{r(),o();let{setLocaleDictionaries:e}=i();return t(()=>{import(`@intlayer/unmerged-dictionaries-entry`).then(t=>{let n=t.getUnmergedDictionaries(),r=Object.fromEntries(Object.values(n).flat().map(e=>[e.localId,e]));e?.(r)})},[]),c(s,{})},{editor:d}=e??{},f=()=>{let{enabled:e}=a();return c(e?u:s,{})},p=({children:t})=>l(n,{postMessage:e=>{typeof window>`u`||d&&window.self!==window.top&&(d.applicationURL.length>0&&window?.postMessage(e,d.applicationURL),d.editorURL.length>0&&window.parent?.postMessage(e,d.editorURL),d.cmsURL.length>0&&window.parent?.postMessage(e,d.cmsURL))},allowedOrigins:[d?.editorURL,d?.cmsURL,d?.applicationURL].filter(Boolean),mode:`client`,configuration:e,children:[c(f,{}),t]});export{p as IntlayerEditorProvider};
1
+ "use client";import{EditorProvider as e}from"@intlayer/editor-react";import{jsx as t}from"react/jsx-runtime";const n=({children:n})=>t(e,{mode:`client`,children:n});export{n as IntlayerEditorProvider};
2
2
  //# sourceMappingURL=IntlayerEditorProvider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerEditorProvider.mjs","names":[],"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport {\n EditorProvider,\n useCrossURLPathSetter,\n useDictionariesRecordActions,\n useEditorEnabled,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport type { FC, PropsWithChildren } from 'react';\nimport { useEffect } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathSetter();\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n /**\n * Sent local dictionaries to editor\n */\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n useEffect(() => {\n // Load dictionaries dynamically to do not impact the bundle, and send them to the editor\n import('@intlayer/unmerged-dictionaries-entry').then((mod) => {\n const unmergedDictionaries = mod.getUnmergedDictionaries();\n const dictionariesList = Object.fromEntries(\n Object.values(unmergedDictionaries)\n .flat()\n .map((dictionary) => [dictionary.localId, dictionary])\n );\n\n setLocaleDictionaries?.(dictionariesList);\n });\n }, []);\n\n return <></>;\n};\n\nconst { editor } = configuration ?? {};\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n if (!editor) return;\n\n const isInIframe = window.self !== window.top;\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\n window?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current application URL to synchronize the locales states.\n editor.applicationURL\n );\n }\n\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={\n [editor?.editorURL, editor?.cmsURL, editor?.applicationURL].filter(\n Boolean\n ) as string[]\n }\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":"+TAaA,MAAM,MAAuC,CAI3C,GAAuB,CAKvB,GAA2B,CAK3B,GAAM,CAAE,yBAA0B,GAA8B,CAehE,OAdA,MAAgB,CAEd,OAAO,yCAAyC,KAAM,GAAQ,CAC5D,IAAM,EAAuB,EAAI,yBAAyB,CACpD,EAAmB,OAAO,YAC9B,OAAO,OAAO,EAAqB,CAChC,MAAM,CACN,IAAK,GAAe,CAAC,EAAW,QAAS,EAAW,CAAC,CACzD,CAED,IAAwB,EAAiB,EACzC,EACD,EAAE,CAAC,CAEC,EAAA,EAAA,EAAK,CAAA,EAGR,CAAE,UAAW,GAAiB,EAAE,CAEhC,MAA+B,CACnC,GAAM,CAAE,WAAY,GAAkB,CAEtC,OAAiB,EAAV,EAAW,EAAgC,EAAjC,EAA8B,CAAQ,EAG5C,GAAiD,CAAE,cAE5D,EAAC,EAAD,CACE,YAAc,GAAc,CACtB,OAAO,OAAW,KACjB,GAEc,OAAO,OAAS,OAAO,MAGtC,EAAO,eAAe,OAAS,GACjC,QAAQ,YACN,EAGA,EAAO,eACR,CAGC,EAAO,UAAU,OAAS,GAC5B,OAAO,QAAQ,YACb,EAGA,EAAO,UACR,CAGC,EAAO,OAAO,OAAS,GACzB,OAAO,QAAQ,YACb,EAGA,EAAO,OACR,GAGL,eACE,CAAC,GAAQ,UAAW,GAAQ,OAAQ,GAAQ,eAAe,CAAC,OAC1D,QACD,CAEH,KAAK,SACU,yBAzCjB,CA2CE,EAAC,EAAD,EAAsB,CAAA,CACrB,EACc"}
1
+ {"version":3,"file":"IntlayerEditorProvider.mjs","names":[],"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { EditorProvider } from '@intlayer/editor-react';\nimport type { FC, PropsWithChildren } from 'react';\n\n/**\n * Wraps the application with the Intlayer editor provider in client mode.\n * All configuration (URLs, origins) is read from @intlayer/config/built.\n */\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => (\n <EditorProvider mode=\"client\">{children}</EditorProvider>\n);\n"],"mappings":"6GASA,MAAa,GAAiD,CAAE,cAC9D,EAAC,EAAD,CAAgB,KAAK,SAAU,WAA0B,CAAA"}
@@ -1,2 +1,2 @@
1
- "use client";import{ContentSelectorRenderer as e}from"./ContentSelectorWrapper.mjs";import{getContent as t}from"@intlayer/core/interpreter";import{createElement as n}from"react";import{useEditedContentActions as r}from"@intlayer/editor-react";const i=({dictionaryKey:e,keyPath:t,children:n})=>{let i=r();return i?i.getEditedContentValue(e,t)??n:n},a=r=>{let a=i(r);if(typeof a==`object`){let i=t(a,r,r.locale);return typeof i==`string`?n(e,{...r,key:r.children},i):(console.error(`Incorrect edited content format. Content type: ${typeof i}. Expected string. Value ${JSON.stringify(i)}`),n(e,{...r,key:r.children},r.children))}return n(e,{...r,key:r.children},a)};export{a as EditedContentRenderer,i as useEditedContentRenderer};
1
+ "use client";import{ContentSelectorRenderer as e}from"./ContentSelectorWrapper.mjs";import{getBasePlugins as t,getContent as n}from"@intlayer/core/interpreter";import{createElement as r}from"react";import{useEditedContentActions as i}from"@intlayer/editor-react";const a=({dictionaryKey:e,keyPath:t,children:n})=>{let r=i();return r?r.getEditedContentValue(e,t)??n:n},o=i=>{let o=a(i);if(typeof o==`object`){let a=n(o,{...i,locale:i.locale},t(i.locale));return typeof a==`string`?r(e,{...i,key:i.children},a):(console.error(`Incorrect edited content format. Content type: ${typeof a}. Expected string. Value ${JSON.stringify(a)}`),r(e,{...i,key:i.children},i.children))}return r(e,{...i,key:i.children},o)};export{o as EditedContentRenderer,a as useEditedContentRenderer};
2
2
  //# sourceMappingURL=useEditedContentRenderer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useEditedContentRenderer.mjs","names":[],"sources":["../../../src/editor/useEditedContentRenderer.tsx"],"sourcesContent":["'use client';\n\nimport { getContent } from '@intlayer/core/interpreter';\nimport { useEditedContentActions } from '@intlayer/editor-react';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { FC } from 'react';\nimport { ContentSelectorRenderer } from './ContentSelectorWrapper';\n\ntype EditedContentRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n children: string;\n locale?: Locale;\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 if (typeof content === 'object') {\n const transformedEditedContent = getContent(content, props, props.locale);\n\n if (typeof transformedEditedContent !== 'string') {\n console.error(\n `Incorrect edited content format. Content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`\n );\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {props.children}\n </ContentSelectorRenderer>\n );\n }\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {transformedEditedContent}\n </ContentSelectorRenderer>\n );\n }\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {content}\n </ContentSelectorRenderer>\n );\n};\n"],"mappings":"mPAgBA,MAAa,GAA4B,CACvC,gBACA,UACA,cACgC,CAChC,IAAM,EAAuB,GAAyB,CAatD,OAXI,EACkB,EAAqB,sBACvC,EACA,EACD,EAE4B,EAKxB,GAGI,EACX,GACG,CACH,IAAM,EAAU,EAAyB,EAAM,CAE/C,GAAI,OAAO,GAAY,SAAU,CAC/B,IAAM,EAA2B,EAAW,EAAS,EAAO,EAAM,OAAO,CAczE,OAZI,OAAO,GAA6B,SAatC,EAAC,EAAD,CAAyB,GAAI,EAAO,IAAK,EAAM,SAErB,CADvB,EACuB,EAd1B,QAAQ,MACN,kDAAkD,OAAO,EAAyB,2BAA2B,KAAK,UAAU,EAAyB,GACtJ,CAGC,EAAC,EAAD,CAAyB,GAAI,EAAO,IAAK,EAAM,SAErB,CADvB,EAAM,SACiB,EAWhC,OACE,EAAC,EAAD,CAAyB,GAAI,EAAO,IAAK,EAAM,SAErB,CADvB,EACuB"}
1
+ {"version":3,"file":"useEditedContentRenderer.mjs","names":[],"sources":["../../../src/editor/useEditedContentRenderer.tsx"],"sourcesContent":["'use client';\n\nimport { getBasePlugins, getContent } from '@intlayer/core/interpreter';\nimport { useEditedContentActions } from '@intlayer/editor-react';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { FC } from 'react';\nimport { ContentSelectorRenderer } from './ContentSelectorWrapper';\n\ntype EditedContentRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n children: string;\n locale?: Locale;\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 if (typeof content === 'object') {\n const transformedEditedContent = getContent(\n content,\n { ...props, locale: props.locale },\n getBasePlugins(props.locale)\n );\n\n if (typeof transformedEditedContent !== 'string') {\n console.error(\n `Incorrect edited content format. Content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`\n );\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {props.children}\n </ContentSelectorRenderer>\n );\n }\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {transformedEditedContent}\n </ContentSelectorRenderer>\n );\n }\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {content}\n </ContentSelectorRenderer>\n );\n};\n"],"mappings":"uQAgBA,MAAa,GAA4B,CACvC,gBACA,UACA,cACgC,CAChC,IAAM,EAAuB,GAAyB,CAatD,OAXI,EACkB,EAAqB,sBACvC,EACA,EACD,EAE4B,EAKxB,GAGI,EACX,GACG,CACH,IAAM,EAAU,EAAyB,EAAM,CAE/C,GAAI,OAAO,GAAY,SAAU,CAC/B,IAAM,EAA2B,EAC/B,EACA,CAAE,GAAG,EAAO,OAAQ,EAAM,OAAQ,CAClC,EAAe,EAAM,OAAO,CAC7B,CAcD,OAZI,OAAO,GAA6B,SAatC,EAAC,EAAD,CAAyB,GAAI,EAAO,IAAK,EAAM,SAErB,CADvB,EACuB,EAd1B,QAAQ,MACN,kDAAkD,OAAO,EAAyB,2BAA2B,KAAK,UAAU,EAAyB,GACtJ,CAGC,EAAC,EAAD,CAAyB,GAAI,EAAO,IAAK,EAAM,SAErB,CADvB,EAAM,SACiB,EAWhC,OACE,EAAC,EAAD,CAAyB,GAAI,EAAO,IAAK,EAAM,SAErB,CADvB,EACuB"}
@@ -2,6 +2,16 @@ import { NodeProps } from "@intlayer/core/interpreter";
2
2
  import { FC, HTMLAttributes } from "react";
3
3
 
4
4
  //#region src/editor/ContentSelectorWrapper.d.ts
5
+ declare global {
6
+ namespace JSX {
7
+ interface IntrinsicElements {
8
+ 'intlayer-content-selector': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
9
+ 'is-selecting'?: boolean;
10
+ 'press-duration'?: number;
11
+ }, HTMLElement>;
12
+ }
13
+ }
14
+ }
5
15
  type ContentSelectorWrapperProps = NodeProps & Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
6
16
  declare const ContentSelectorRenderer: FC<ContentSelectorWrapperProps>;
7
17
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelectorWrapper.d.ts","names":[],"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"mappings":";;;;KAeY,2BAAA,GAA8B,SAAA,GACxC,IAAA,CAAK,cAAA,CAAe,cAAA;AAAA,cAqET,uBAAA,EAAyB,EAAA,CAAG,2BAAA"}
1
+ {"version":3,"file":"ContentSelectorWrapper.d.ts","names":[],"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"mappings":";;;;QAeQ,MAAA;EAAA,UACI,GAAA;IAAA,UACE,iBAAA;MACR,2BAAA,EAA6B,KAAA,CAAM,iBAAA,CACjC,KAAA,CAAM,cAAA,CAAe,WAAA;QACnB,cAAA;QACA,gBAAA;MAAA,GAEF,WAAA;IAAA;EAAA;AAAA;AAAA,KAMI,2BAAA,GAA8B,SAAA,GACxC,IAAA,CAAK,cAAA,CAAe,cAAA;AAAA,cAgET,uBAAA,EAAyB,EAAA,CAAG,2BAAA"}
@@ -1,6 +1,10 @@
1
1
  import { FC, PropsWithChildren } from "react";
2
2
 
3
3
  //#region src/editor/IntlayerEditorProvider.d.ts
4
+ /**
5
+ * Wraps the application with the Intlayer editor provider in client mode.
6
+ * All configuration (URLs, origins) is read from @intlayer/config/built.
7
+ */
4
8
  declare const IntlayerEditorProvider: FC<PropsWithChildren>;
5
9
  //#endregion
6
10
  export { IntlayerEditorProvider };
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerEditorProvider.d.ts","names":[],"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"mappings":";;;cAqDa,sBAAA,EAAwB,EAAA,CAAG,iBAAA"}
1
+ {"version":3,"file":"IntlayerEditorProvider.d.ts","names":[],"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"mappings":";;;;;AASA;;cAAa,sBAAA,EAAwB,EAAA,CAAG,iBAAA"}
@@ -1,6 +1,6 @@
1
1
  import { FC } from "react";
2
- import { KeyPath } from "@intlayer/types/keyPath";
3
2
  import { Locale } from "@intlayer/types/allLocales";
3
+ import { KeyPath } from "@intlayer/types/keyPath";
4
4
 
5
5
  //#region src/editor/useEditedContentRenderer.d.ts
6
6
  type EditedContentRendererProps = {
@@ -1,6 +1,6 @@
1
1
  import { FC } from "react";
2
- import { KeyPath } from "@intlayer/types/keyPath";
3
2
  import { Locale } from "@intlayer/types/allLocales";
3
+ import { KeyPath } from "@intlayer/types/keyPath";
4
4
 
5
5
  //#region src/html/HTMLRendererPlugin.d.ts
6
6
  type HTMLRendererPluginProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "8.3.3",
3
+ "version": "8.3.4",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -115,14 +115,14 @@
115
115
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
116
116
  },
117
117
  "dependencies": {
118
- "@intlayer/api": "8.3.3",
119
- "@intlayer/config": "8.3.3",
120
- "@intlayer/core": "8.3.3",
121
- "@intlayer/dictionaries-entry": "8.3.3",
122
- "@intlayer/editor-react": "8.3.3",
123
- "@intlayer/types": "8.3.3",
124
- "@intlayer/unmerged-dictionaries-entry": "8.3.3",
125
- "intlayer": "8.3.3"
118
+ "@intlayer/api": "8.3.4",
119
+ "@intlayer/config": "8.3.4",
120
+ "@intlayer/core": "8.3.4",
121
+ "@intlayer/dictionaries-entry": "8.3.4",
122
+ "@intlayer/editor": "8.3.4",
123
+ "@intlayer/editor-react": "8.3.4",
124
+ "@intlayer/types": "8.3.4",
125
+ "intlayer": "8.3.4"
126
126
  },
127
127
  "devDependencies": {
128
128
  "@craco/types": "7.1.0",
@@ -134,7 +134,7 @@
134
134
  "@utils/ts-config-types": "1.0.4",
135
135
  "@utils/tsdown-config": "1.0.4",
136
136
  "rimraf": "6.1.3",
137
- "tsdown": "0.21.2",
137
+ "tsdown": "0.21.4",
138
138
  "typescript": "5.9.3",
139
139
  "vite-tsconfig-paths": "6.1.1",
140
140
  "vitest": "4.1.0"