@intlayer/editor-react 8.3.3 → 8.4.0-canary.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/CommunicatorContext.cjs +1 -1
- package/dist/cjs/CommunicatorContext.cjs.map +1 -1
- package/dist/cjs/ConfigurationContext.cjs +1 -1
- package/dist/cjs/ConfigurationContext.cjs.map +1 -1
- package/dist/cjs/DictionariesRecordContext.cjs +1 -1
- package/dist/cjs/DictionariesRecordContext.cjs.map +1 -1
- package/dist/cjs/EditedContentContext.cjs +1 -1
- package/dist/cjs/EditedContentContext.cjs.map +1 -1
- package/dist/cjs/EditorEnabledContext.cjs +1 -1
- package/dist/cjs/EditorEnabledContext.cjs.map +1 -1
- package/dist/cjs/EditorProvider.cjs +1 -1
- package/dist/cjs/EditorProvider.cjs.map +1 -1
- package/dist/cjs/EditorStateContext.cjs +2 -0
- package/dist/cjs/EditorStateContext.cjs.map +1 -0
- package/dist/cjs/FocusDictionaryContext.cjs +1 -1
- package/dist/cjs/FocusDictionaryContext.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/useCrossFrameMessageListener.cjs +1 -1
- package/dist/cjs/useCrossFrameMessageListener.cjs.map +1 -1
- package/dist/cjs/useCrossFrameState.cjs +1 -1
- package/dist/cjs/useCrossFrameState.cjs.map +1 -1
- package/dist/cjs/useCrossURLPathState.cjs +1 -1
- package/dist/cjs/useCrossURLPathState.cjs.map +1 -1
- package/dist/cjs/useEditorLocale.cjs +1 -1
- package/dist/cjs/useEditorLocale.cjs.map +1 -1
- package/dist/cjs/useFocusUnmergedDictionary.cjs +1 -1
- package/dist/cjs/useFocusUnmergedDictionary.cjs.map +1 -1
- package/dist/cjs/useIframeClickInterceptor.cjs +1 -1
- package/dist/cjs/useIframeClickInterceptor.cjs.map +1 -1
- package/dist/esm/CommunicatorContext.mjs +1 -1
- package/dist/esm/CommunicatorContext.mjs.map +1 -1
- package/dist/esm/ConfigurationContext.mjs +1 -1
- package/dist/esm/ConfigurationContext.mjs.map +1 -1
- package/dist/esm/DictionariesRecordContext.mjs +1 -1
- package/dist/esm/DictionariesRecordContext.mjs.map +1 -1
- package/dist/esm/EditedContentContext.mjs +1 -1
- package/dist/esm/EditedContentContext.mjs.map +1 -1
- package/dist/esm/EditorEnabledContext.mjs +1 -1
- package/dist/esm/EditorEnabledContext.mjs.map +1 -1
- package/dist/esm/EditorProvider.mjs +1 -1
- package/dist/esm/EditorProvider.mjs.map +1 -1
- package/dist/esm/EditorStateContext.mjs +2 -0
- package/dist/esm/EditorStateContext.mjs.map +1 -0
- package/dist/esm/FocusDictionaryContext.mjs +1 -1
- package/dist/esm/FocusDictionaryContext.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/useCrossFrameMessageListener.mjs +1 -1
- package/dist/esm/useCrossFrameMessageListener.mjs.map +1 -1
- package/dist/esm/useCrossFrameState.mjs +1 -1
- package/dist/esm/useCrossFrameState.mjs.map +1 -1
- package/dist/esm/useCrossURLPathState.mjs +1 -1
- package/dist/esm/useCrossURLPathState.mjs.map +1 -1
- package/dist/esm/useEditorLocale.mjs +1 -1
- package/dist/esm/useEditorLocale.mjs.map +1 -1
- package/dist/esm/useFocusUnmergedDictionary.mjs.map +1 -1
- package/dist/esm/useIframeClickInterceptor.mjs +1 -1
- package/dist/esm/useIframeClickInterceptor.mjs.map +1 -1
- package/dist/types/CommunicatorContext.d.ts +6 -5
- package/dist/types/CommunicatorContext.d.ts.map +1 -1
- package/dist/types/ConfigurationContext.d.ts +5 -5
- package/dist/types/ConfigurationContext.d.ts.map +1 -1
- package/dist/types/DictionariesRecordContext.d.ts +8 -11
- package/dist/types/DictionariesRecordContext.d.ts.map +1 -1
- package/dist/types/EditedContentContext.d.ts +9 -11
- package/dist/types/EditedContentContext.d.ts.map +1 -1
- package/dist/types/EditorEnabledContext.d.ts +21 -9
- package/dist/types/EditorEnabledContext.d.ts.map +1 -1
- package/dist/types/EditorProvider.d.ts +9 -4
- package/dist/types/EditorProvider.d.ts.map +1 -1
- package/dist/types/EditorStateContext.d.ts +11 -0
- package/dist/types/EditorStateContext.d.ts.map +1 -0
- package/dist/types/FocusDictionaryContext.d.ts +8 -16
- package/dist/types/FocusDictionaryContext.d.ts.map +1 -1
- package/dist/types/index.d.ts +9 -8
- package/dist/types/useCrossFrameMessageListener.d.ts +3 -13
- package/dist/types/useCrossFrameMessageListener.d.ts.map +1 -1
- package/dist/types/useCrossFrameState.d.ts +2 -20
- package/dist/types/useCrossFrameState.d.ts.map +1 -1
- package/dist/types/useCrossURLPathState.d.ts.map +1 -1
- package/dist/types/useEditorLocale.d.ts +2 -3
- package/dist/types/useEditorLocale.d.ts.map +1 -1
- package/dist/types/useFocusUnmergedDictionary.d.ts +1 -2
- package/dist/types/useFocusUnmergedDictionary.d.ts.map +1 -1
- package/dist/types/useIframeClickInterceptor.d.ts +11 -1
- package/dist/types/useIframeClickInterceptor.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{useEffect as t,useState as n}from"react";const r=()=>{let t=e();return{setEditedContentState:e=>t?.editedContent.set(e),setEditedDictionary:e=>t?.setEditedDictionary(e),setEditedContent:(e,n)=>t?.setEditedContent(e,n),addEditedContent:(e,n,r,i)=>t?.addContent(e,n,r,i),renameEditedContent:(e,n,r)=>t?.renameContent(e,n,r),removeEditedContent:(e,n)=>t?.removeContent(e,n),restoreEditedContent:e=>t?.restoreContent(e),clearEditedDictionaryContent:e=>t?.clearContent(e),clearEditedContent:()=>t?.clearAllContent(),getEditedContentValue:(e,n)=>t?.getContentValue(e,n)}},i=()=>{let i=e(),[a,o]=n(i?.editedContent.value);return t(()=>{if(!i)return;let e=e=>o(e.detail);return i.editedContent.addEventListener(`change`,e),()=>i.editedContent.removeEventListener(`change`,e)},[i]),{editedContent:a,...r()}},a=n=>{let r=e();t(()=>{if(!(!n||!r))return r.messenger.subscribe(`INTLAYER_EDITED_CONTENT_CHANGED/post`,n)},[r,n])},o=()=>{let t=e();return()=>{t?.messenger.send(`INTLAYER_EDITED_CONTENT_CHANGED/get`)}};export{i as useEditedContent,r as useEditedContentActions,o as useGetEditedContentState,a as usePostEditedContentState};
|
|
2
2
|
//# sourceMappingURL=EditedContentContext.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditedContentContext.mjs","names":[],"sources":["../../src/EditedContentContext.tsx"],"sourcesContent":["'use client';\n\nimport {\n editDictionaryByKeyPath,\n getContentNodeByKeyPath,\n renameContentNodeByKeyPath,\n} from '@intlayer/core/dictionaryManipulator';\nimport { MessageKey } from '@intlayer/editor';\nimport type { ContentNode, Dictionary, LocalDictionaryId } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';;\nimport { NodeType } from '@intlayer/types/nodeType';\nimport {\n createContext,\n type Dispatch,\n type FC,\n type PropsWithChildren,\n type SetStateAction,\n useContext,\n} from 'react';\nimport {\n type DictionaryContent,\n useDictionariesRecord,\n} from './DictionariesRecordContext';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\nimport { useCrossFrameState } from './useCrossFrameState';\nimport { useEditorLocale } from './useEditorLocale';\n\ntype EditedContentStateContextType = {\n editedContent: Record<LocalDictionaryId, Dictionary> | undefined;\n};\n\nconst EditedContentStateContext = createContext<\n EditedContentStateContextType | undefined\n>(undefined);\n\nexport const usePostEditedContentState = <S,>(\n onEventTriggered?: (data: S) => void\n) =>\n useCrossFrameMessageListener(\n `${MessageKey.INTLAYER_EDITED_CONTENT_CHANGED}/post`,\n onEventTriggered\n );\n\nexport const useGetEditedContentState = <S,>(\n onEventTriggered?: (data: S) => void\n) =>\n useCrossFrameMessageListener(\n `${MessageKey.INTLAYER_EDITED_CONTENT_CHANGED}/get`,\n onEventTriggered\n );\n\ntype EditedContentActionsContextType = {\n setEditedContentState: (editedContent: DictionaryContent) => void;\n setEditedDictionary: Dispatch<SetStateAction<Dictionary>>;\n setEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newValue: Dictionary['content']\n ) => void;\n addEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newValue: ContentNode<any>,\n keyPath?: KeyPath[],\n overwrite?: boolean\n ) => void;\n renameEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newKey: KeyPath['key'],\n keyPath?: KeyPath[]\n ) => void;\n removeEditedContent: (\n localDictionaryId: LocalDictionaryId,\n keyPath: KeyPath[]\n ) => void;\n restoreEditedContent: (localDictionaryId: LocalDictionaryId) => void;\n clearEditedDictionaryContent: (localDictionaryId: LocalDictionaryId) => void;\n clearEditedContent: () => void;\n getEditedContentValue: (\n localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\n keyPath: KeyPath[]\n ) => ContentNode | undefined;\n};\n\nconst EditedContentActionsContext = createContext<\n EditedContentActionsContextType | undefined\n>(undefined);\n\nconst resolveState = <S,>(state?: SetStateAction<S>, prevState?: S): S =>\n typeof state === 'function'\n ? (state as (prevState?: S) => S)(prevState)\n : (state as S);\n\nexport const EditedContentProvider: FC<PropsWithChildren> = ({ children }) => {\n const { localeDictionaries } = useDictionariesRecord();\n const currentLocale = useEditorLocale();\n\n const [editedContent, setEditedContentState] =\n useCrossFrameState<DictionaryContent>(\n MessageKey.INTLAYER_EDITED_CONTENT_CHANGED\n );\n\n const setEditedDictionary: Dispatch<SetStateAction<Dictionary>> = (\n newValue\n ) => {\n let updatedDictionaries: Dictionary = resolveState(newValue);\n\n setEditedContentState((prev) => {\n if (!updatedDictionaries.localId) {\n console.error('no localId', updatedDictionaries);\n\n return prev;\n }\n\n updatedDictionaries = resolveState(\n newValue,\n prev?.[updatedDictionaries.localId]\n );\n\n return {\n ...prev,\n [updatedDictionaries.localId as LocalDictionaryId]: updatedDictionaries,\n };\n });\n\n return updatedDictionaries;\n };\n\n const setEditedContent = (\n localDictionaryId: LocalDictionaryId,\n newValue: Dictionary['content']\n ) => {\n setEditedContentState((prev) => ({\n ...prev,\n [localDictionaryId]: {\n ...prev?.[localDictionaryId],\n content: newValue,\n },\n }));\n };\n\n const addEditedContent = (\n localDictionaryId: LocalDictionaryId,\n newValue: ContentNode,\n keyPath: KeyPath[] = [],\n overwrite: boolean = true\n ) => {\n setEditedContentState((prev) => {\n // Get the starting content: edited version if available, otherwise a deep copy of the original\n const originalContent = localeDictionaries[localDictionaryId]?.content;\n const currentContent = structuredClone(\n prev?.[localDictionaryId]?.content ?? originalContent\n );\n\n let newKeyPath = keyPath;\n if (!overwrite) {\n // Find a unique key based on the keyPath provided\n let index = 0;\n\n const otherKeyPath = keyPath.slice(0, -1);\n const lastKeyPath: KeyPath = keyPath[keyPath.length - 1];\n\n let finalKey = lastKeyPath.key;\n\n // Loop until we find a key that does not exist\n while (\n typeof getContentNodeByKeyPath(currentContent, newKeyPath) !==\n 'undefined'\n ) {\n index++;\n finalKey =\n index === 0 ? lastKeyPath.key : `${lastKeyPath.key} (${index})`;\n newKeyPath = [\n ...otherKeyPath,\n { ...lastKeyPath, key: finalKey } as KeyPath,\n ];\n }\n }\n\n const updatedContent = editDictionaryByKeyPath(\n currentContent,\n newKeyPath,\n newValue\n );\n\n return {\n ...prev,\n [localDictionaryId]: {\n ...prev?.[localDictionaryId],\n content: updatedContent as Dictionary['content'],\n },\n };\n });\n };\n\n const renameEditedContent = (\n localDictionaryId: LocalDictionaryId,\n newKey: KeyPath['key'],\n keyPath: KeyPath[] = []\n ) => {\n setEditedContentState((prev) => {\n // Retrieve the base content: use edited version if available, otherwise deep copy of original\n const originalContent = localeDictionaries[localDictionaryId]?.content;\n const currentContent = structuredClone(\n prev?.[localDictionaryId]?.content ?? originalContent\n );\n\n const contentWithNewField = renameContentNodeByKeyPath(\n currentContent,\n newKey,\n keyPath\n );\n\n return {\n ...prev,\n [localDictionaryId]: {\n ...prev?.[localDictionaryId],\n content: contentWithNewField as Dictionary['content'],\n },\n };\n });\n };\n\n const removeEditedContent = (\n localDictionaryId: LocalDictionaryId,\n keyPath: KeyPath[]\n ) => {\n setEditedContentState((prev) => {\n // Retrieve the original content as reference\n const originalContent = localeDictionaries[localDictionaryId]?.content;\n const currentContent = structuredClone(\n prev?.[localDictionaryId]?.content ?? originalContent\n );\n\n // Get the initial value from the original dictionary content\n const initialContent = getContentNodeByKeyPath(originalContent, keyPath);\n\n // Restore the value at the given keyPath\n const restoredContent = editDictionaryByKeyPath(\n currentContent,\n keyPath,\n initialContent\n );\n\n return {\n ...prev,\n [localDictionaryId]: {\n ...prev?.[localDictionaryId],\n content: restoredContent as Dictionary['content'],\n },\n };\n });\n };\n\n const restoreEditedContent = (localDictionaryId: LocalDictionaryId) => {\n setEditedContentState((prev) => {\n const updated = { ...prev };\n delete updated[localDictionaryId];\n return updated;\n });\n };\n\n const clearEditedDictionaryContent = (\n localDictionaryId: LocalDictionaryId\n ) => {\n setEditedContentState((prev) => {\n const filtered = { ...prev };\n delete filtered[localDictionaryId];\n return filtered;\n });\n };\n\n const clearEditedContent = () => {\n setEditedContentState({});\n };\n\n const getEditedContentValue = (\n localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\n keyPath: KeyPath[]\n ): ContentNode | undefined => {\n if (!editedContent) return undefined;\n\n const filteredKeyPath = keyPath.filter(\n (key) => key.type !== NodeType.Translation\n );\n\n const isDictionaryId =\n localDictionaryIdOrKey.includes(':local:') ||\n localDictionaryIdOrKey.includes(':remote:');\n\n if (isDictionaryId) {\n const currentContent =\n editedContent?.[localDictionaryIdOrKey as LocalDictionaryId]?.content ??\n {};\n\n const contentNode = getContentNodeByKeyPath(\n currentContent,\n filteredKeyPath,\n currentLocale\n );\n\n return contentNode;\n }\n\n const filteredDictionariesLocalId = Object.keys(editedContent).filter(\n (key) => key.startsWith(`${localDictionaryIdOrKey}:`)\n );\n\n for (const localDictionaryId of filteredDictionariesLocalId) {\n const currentContent =\n editedContent?.[localDictionaryId as LocalDictionaryId]?.content ?? {};\n const contentNode = getContentNodeByKeyPath(\n currentContent,\n filteredKeyPath,\n currentLocale\n );\n\n if (contentNode) return contentNode;\n }\n\n return undefined;\n };\n\n return (\n <EditedContentStateContext.Provider\n value={{\n editedContent,\n }}\n >\n <EditedContentActionsContext.Provider\n value={{\n setEditedContentState,\n setEditedDictionary,\n setEditedContent,\n addEditedContent,\n renameEditedContent,\n removeEditedContent,\n restoreEditedContent,\n clearEditedDictionaryContent,\n clearEditedContent,\n getEditedContentValue,\n }}\n >\n {children}\n </EditedContentActionsContext.Provider>\n </EditedContentStateContext.Provider>\n );\n};\n\nexport const useEditedContentActions = () =>\n useContext(EditedContentActionsContext);\n\nexport const useEditedContent = () => {\n const stateContext = useContext(EditedContentStateContext);\n const actionContext = useEditedContentActions();\n\n return { ...stateContext, ...actionContext };\n};\n"],"mappings":"ymBA+BA,MAAM,EAA4B,EAEhC,IAAA,GAAU,CAEC,EACX,GAEA,EACE,GAAG,EAAW,gCAAgC,OAC9C,EACD,CAEU,EACX,GAEA,EACE,GAAG,EAAW,gCAAgC,MAC9C,EACD,CAiCG,EAA8B,EAElC,IAAA,GAAU,CAEN,GAAoB,EAA2B,IACnD,OAAO,GAAU,WACZ,EAA+B,EAAU,CACzC,EAEM,GAAgD,CAAE,cAAe,CAC5E,GAAM,CAAE,sBAAuB,GAAuB,CAChD,EAAgB,GAAiB,CAEjC,CAAC,EAAe,GACpB,EACE,EAAW,gCACZ,CA+NH,OACE,EAAC,EAA0B,SAA3B,CACE,MAAO,CACL,gBACD,UAED,EAAC,EAA4B,SAA7B,CACE,MAAO,CACL,wBACA,oBArON,GACG,CACH,IAAI,EAAkC,EAAa,EAAS,CAoB5D,OAlBA,EAAuB,GAChB,EAAoB,SAMzB,EAAsB,EACpB,EACA,IAAO,EAAoB,SAC5B,CAEM,CACL,GAAG,GACF,EAAoB,SAA+B,EACrD,GAbC,QAAQ,MAAM,aAAc,EAAoB,CAEzC,GAYT,CAEK,GAgND,kBA5MN,EACA,IACG,CACH,EAAuB,IAAU,CAC/B,GAAG,GACF,GAAoB,CACnB,GAAG,IAAO,GACV,QAAS,EACV,CACF,EAAE,EAoMG,kBAhMN,EACA,EACA,EAAqB,EAAE,CACvB,EAAqB,KAClB,CACH,EAAuB,GAAS,CAE9B,IAAM,EAAkB,EAAmB,IAAoB,QACzD,EAAiB,gBACrB,IAAO,IAAoB,SAAW,EACvC,CAEG,EAAa,EACjB,GAAI,CAAC,EAAW,CAEd,IAAI,EAAQ,EAEN,EAAe,EAAQ,MAAM,EAAG,GAAG,CACnC,EAAuB,EAAQ,EAAQ,OAAS,GAElD,EAAW,EAAY,IAG3B,KACS,EAAwB,EAAgB,EAAW,GAC1D,QAEA,IACA,EACE,IAAU,EAAI,EAAY,IAAM,GAAG,EAAY,IAAI,IAAI,EAAM,GAC/D,EAAa,CACX,GAAG,EACH,CAAE,GAAG,EAAa,IAAK,EAAU,CAClC,CAIL,IAAM,EAAiB,EACrB,EACA,EACA,EACD,CAED,MAAO,CACL,GAAG,GACF,GAAoB,CACnB,GAAG,IAAO,GACV,QAAS,EACV,CACF,EACD,EA+II,qBA3IN,EACA,EACA,EAAqB,EAAE,GACpB,CACH,EAAuB,GAAS,CAE9B,IAAM,EAAkB,EAAmB,IAAoB,QAKzD,EAAsB,EAJL,gBACrB,IAAO,IAAoB,SAAW,EACvC,CAIC,EACA,EACD,CAED,MAAO,CACL,GAAG,GACF,GAAoB,CACnB,GAAG,IAAO,GACV,QAAS,EACV,CACF,EACD,EAoHI,qBAhHN,EACA,IACG,CACH,EAAuB,GAAS,CAE9B,IAAM,EAAkB,EAAmB,IAAoB,QASzD,EAAkB,EARD,gBACrB,IAAO,IAAoB,SAAW,EACvC,CAQC,EALqB,EAAwB,EAAiB,EAAQ,CAOvE,CAED,MAAO,CACL,GAAG,GACF,GAAoB,CACnB,GAAG,IAAO,GACV,QAAS,EACV,CACF,EACD,EAsFI,qBAnFsB,GAAyC,CACrE,EAAuB,GAAS,CAC9B,IAAM,EAAU,CAAE,GAAG,EAAM,CAE3B,OADA,OAAO,EAAQ,GACR,GACP,EA+EI,6BA3EN,GACG,CACH,EAAuB,GAAS,CAC9B,IAAM,EAAW,CAAE,GAAG,EAAM,CAE5B,OADA,OAAO,EAAS,GACT,GACP,EAsEI,uBAnEyB,CAC/B,EAAsB,EAAE,CAAC,EAmEnB,uBA/DN,EACA,IAC4B,CAC5B,GAAI,CAAC,EAAe,OAEpB,IAAM,EAAkB,EAAQ,OAC7B,GAAQ,EAAI,OAAS,EAAS,YAChC,CAMD,GAHE,EAAuB,SAAS,UAAU,EAC1C,EAAuB,SAAS,WAAW,CAa3C,OANoB,EAHlB,IAAgB,IAA8C,SAC9D,EAAE,CAIF,EACA,EACD,CAKH,IAAM,EAA8B,OAAO,KAAK,EAAc,CAAC,OAC5D,GAAQ,EAAI,WAAW,GAAG,EAAuB,GAAG,CACtD,CAED,IAAK,IAAM,KAAqB,EAA6B,CAG3D,IAAM,EAAc,EADlB,IAAgB,IAAyC,SAAW,EAAE,CAGtE,EACA,EACD,CAED,GAAI,EAAa,OAAO,IAwBrB,CAEA,WACoC,CAAA,CACJ,CAAA,EAI5B,MACX,EAAW,EAA4B,CAE5B,MAAyB,CACpC,IAAM,EAAe,EAAW,EAA0B,CACpD,EAAgB,GAAyB,CAE/C,MAAO,CAAE,GAAG,EAAc,GAAG,EAAe"}
|
|
1
|
+
{"version":3,"file":"EditedContentContext.mjs","names":[],"sources":["../../src/EditedContentContext.tsx"],"sourcesContent":["'use client';\n\nimport type { DictionaryContent } from '@intlayer/editor';\nimport type {\n ContentNode,\n Dictionary,\n LocalDictionaryId,\n} from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { DictionaryContent } from '@intlayer/editor';\n\ntype EditedContentActionsContextType = {\n setEditedContentState: (editedContent: DictionaryContent) => void;\n setEditedDictionary: (dict: Dictionary) => void;\n setEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newValue: Dictionary['content']\n ) => void;\n addEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newValue: ContentNode<any>,\n keyPath?: KeyPath[],\n overwrite?: boolean\n ) => void;\n renameEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newKey: KeyPath['key'],\n keyPath?: KeyPath[]\n ) => void;\n removeEditedContent: (\n localDictionaryId: LocalDictionaryId,\n keyPath: KeyPath[]\n ) => void;\n restoreEditedContent: (localDictionaryId: LocalDictionaryId) => void;\n clearEditedDictionaryContent: (localDictionaryId: LocalDictionaryId) => void;\n clearEditedContent: () => void;\n getEditedContentValue: (\n localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\n keyPath: KeyPath[]\n ) => ContentNode | undefined;\n};\n\nexport const useEditedContentActions = (): EditedContentActionsContextType => {\n const manager = useEditorStateManager();\n\n return {\n setEditedContentState: (value: DictionaryContent) =>\n manager?.editedContent.set(value),\n setEditedDictionary: (dict: Dictionary) =>\n manager?.setEditedDictionary(dict),\n setEditedContent: (\n localId: LocalDictionaryId,\n value: Dictionary['content']\n ) => manager?.setEditedContent(localId, value),\n addEditedContent: (localId, value, keyPath, overwrite) =>\n manager?.addContent(localId, value, keyPath, overwrite),\n renameEditedContent: (localId, newKey, keyPath) =>\n manager?.renameContent(localId, newKey, keyPath),\n removeEditedContent: (localId, keyPath) =>\n manager?.removeContent(localId, keyPath),\n restoreEditedContent: (localId) => manager?.restoreContent(localId),\n clearEditedDictionaryContent: (localId) => manager?.clearContent(localId),\n clearEditedContent: () => manager?.clearAllContent(),\n getEditedContentValue: (localIdOrKey, keyPath) =>\n manager?.getContentValue(localIdOrKey, keyPath),\n };\n};\n\nexport const useEditedContent = () => {\n const manager = useEditorStateManager();\n const [editedContent, setEditedContentState] = useState<\n DictionaryContent | undefined\n >(manager?.editedContent.value);\n\n useEffect(() => {\n if (!manager) return;\n const handler = (e: Event) =>\n setEditedContentState((e as CustomEvent<DictionaryContent>).detail);\n manager.editedContent.addEventListener('change', handler);\n return () => manager.editedContent.removeEventListener('change', handler);\n }, [manager]);\n\n const actions = useEditedContentActions();\n return { editedContent, ...actions };\n};\n\nexport const usePostEditedContentState = <S,>(\n onEventTriggered?: (data: S) => void\n) => {\n const manager = useEditorStateManager();\n useEffect(() => {\n if (!onEventTriggered || !manager) return;\n return manager.messenger.subscribe(\n `INTLAYER_EDITED_CONTENT_CHANGED/post`,\n onEventTriggered as (data: unknown) => void\n );\n }, [manager, onEventTriggered]);\n};\n\nexport const useGetEditedContentState = () => {\n const manager = useEditorStateManager();\n return () => {\n manager?.messenger.send('INTLAYER_EDITED_CONTENT_CHANGED/get');\n };\n};\n"],"mappings":"8HA6CA,MAAa,MAAiE,CAC5E,IAAM,EAAU,GAAuB,CAEvC,MAAO,CACL,sBAAwB,GACtB,GAAS,cAAc,IAAI,EAAM,CACnC,oBAAsB,GACpB,GAAS,oBAAoB,EAAK,CACpC,kBACE,EACA,IACG,GAAS,iBAAiB,EAAS,EAAM,CAC9C,kBAAmB,EAAS,EAAO,EAAS,IAC1C,GAAS,WAAW,EAAS,EAAO,EAAS,EAAU,CACzD,qBAAsB,EAAS,EAAQ,IACrC,GAAS,cAAc,EAAS,EAAQ,EAAQ,CAClD,qBAAsB,EAAS,IAC7B,GAAS,cAAc,EAAS,EAAQ,CAC1C,qBAAuB,GAAY,GAAS,eAAe,EAAQ,CACnE,6BAA+B,GAAY,GAAS,aAAa,EAAQ,CACzE,uBAA0B,GAAS,iBAAiB,CACpD,uBAAwB,EAAc,IACpC,GAAS,gBAAgB,EAAc,EAAQ,CAClD,EAGU,MAAyB,CACpC,IAAM,EAAU,GAAuB,CACjC,CAAC,EAAe,GAAyB,EAE7C,GAAS,cAAc,MAAM,CAW/B,OATA,MAAgB,CACd,GAAI,CAAC,EAAS,OACd,IAAM,EAAW,GACf,EAAuB,EAAqC,OAAO,CAErE,OADA,EAAQ,cAAc,iBAAiB,SAAU,EAAQ,KAC5C,EAAQ,cAAc,oBAAoB,SAAU,EAAQ,EACxE,CAAC,EAAQ,CAAC,CAGN,CAAE,gBAAe,GADR,GAAyB,CACL,EAGzB,EACX,GACG,CACH,IAAM,EAAU,GAAuB,CACvC,MAAgB,CACV,MAAC,GAAoB,CAAC,GAC1B,OAAO,EAAQ,UAAU,UACvB,uCACA,EACD,EACA,CAAC,EAAS,EAAiB,CAAC,EAGpB,MAAiC,CAC5C,IAAM,EAAU,GAAuB,CACvC,UAAa,CACX,GAAS,UAAU,KAAK,sCAAsC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{useEffect as t,useState as n}from"react";import{MessageKey as r}from"@intlayer/editor";const i=()=>{let r=e(),[i,a]=n(r?.editorEnabled.value??!1);return t(()=>{if(!r)return;let e=e=>a(e.detail);return r.editorEnabled.addEventListener(`change`,e),()=>r.editorEnabled.removeEventListener(`change`,e)},[r]),{enabled:i}},a=n=>{let i=e();t(()=>{if(n)return i?.messenger.subscribe(`${r.INTLAYER_EDITOR_ENABLED}/get`,n)},[i,n])},o=()=>{let t=e();return e=>{t?.editorEnabled.set(e),t?.editorEnabled.postCurrentValue()}},s=()=>{let{enabled:t}=i(),n=e();return[t,e=>n?.editorEnabled.set(e)]},c=()=>{let t=e();return()=>t?.pingClient()};export{i as useEditorEnabled,s as useEditorEnabledState,c as useEditorPingClient,a as useGetEditorEnabledState,o as usePostEditorEnabledState};
|
|
2
2
|
//# sourceMappingURL=EditorEnabledContext.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorEnabledContext.mjs","names":[],"sources":["../../src/EditorEnabledContext.tsx"],"sourcesContent":["'use client';\n\nimport { MessageKey } from '@intlayer/editor';\nimport {
|
|
1
|
+
{"version":3,"file":"EditorEnabledContext.mjs","names":[],"sources":["../../src/EditorEnabledContext.tsx"],"sourcesContent":["'use client';\n\nimport { MessageKey } from '@intlayer/editor';\nimport { useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type EditorEnabledStateProps = {\n enabled: boolean;\n};\n\n/**\n * Returns the current editor-enabled state, kept in sync with the shared\n * EditorStateManager. Replaces the old EditorEnabledContext + EditorEnabledProvider.\n */\nexport const useEditorEnabled = (): EditorEnabledStateProps => {\n const manager = useEditorStateManager();\n const [enabled, setEnabled] = useState<boolean>(\n manager?.editorEnabled.value ?? false\n );\n\n useEffect(() => {\n if (!manager) return;\n\n const handler = (e: Event) =>\n setEnabled((e as CustomEvent<boolean>).detail);\n manager.editorEnabled.addEventListener('change', handler);\n return () => manager.editorEnabled.removeEventListener('change', handler);\n }, [manager]);\n\n return { enabled };\n};\n\n/**\n * Subscribes to incoming \"get\" requests for editor-enabled state and calls\n * the provided callback so the caller can respond.\n * Used by the editor side to respond when the client asks for the current state.\n */\nexport const useGetEditorEnabledState = (onRequest?: () => void) => {\n const manager = useEditorStateManager();\n\n useEffect(() => {\n if (!onRequest) return;\n\n return manager?.messenger.subscribe(\n `${MessageKey.INTLAYER_EDITOR_ENABLED}/get`,\n onRequest\n );\n }, [manager, onRequest]);\n};\n\n/**\n * Returns a function that sets the editor-enabled state and broadcasts it.\n */\nexport const usePostEditorEnabledState = () => {\n const manager = useEditorStateManager();\n\n return (value: boolean) => {\n manager?.editorEnabled.set(value);\n manager?.editorEnabled.postCurrentValue();\n };\n};\n\nexport const useEditorEnabledState = () => {\n const { enabled } = useEditorEnabled();\n const manager = useEditorStateManager();\n const setter = (value: boolean) => manager?.editorEnabled.set(value);\n\n return [enabled, setter] as const;\n};\n\n/**\n * Returns a function that re-pings the client via ARE_YOU_THERE.\n * Use this as the onClick for an \"Enable Editor\" / reconnect button.\n */\nexport const useEditorPingClient = (): (() => void) => {\n const manager = useEditorStateManager();\n\n return () => manager?.pingClient();\n};\n"],"mappings":"4KAcA,MAAa,MAAkD,CAC7D,IAAM,EAAU,GAAuB,CACjC,CAAC,EAAS,GAAc,EAC5B,GAAS,cAAc,OAAS,GACjC,CAWD,OATA,MAAgB,CACd,GAAI,CAAC,EAAS,OAEd,IAAM,EAAW,GACf,EAAY,EAA2B,OAAO,CAEhD,OADA,EAAQ,cAAc,iBAAiB,SAAU,EAAQ,KAC5C,EAAQ,cAAc,oBAAoB,SAAU,EAAQ,EACxE,CAAC,EAAQ,CAAC,CAEN,CAAE,UAAS,EAQP,EAA4B,GAA2B,CAClE,IAAM,EAAU,GAAuB,CAEvC,MAAgB,CACT,KAEL,OAAO,GAAS,UAAU,UACxB,GAAG,EAAW,wBAAwB,MACtC,EACD,EACA,CAAC,EAAS,EAAU,CAAC,EAMb,MAAkC,CAC7C,IAAM,EAAU,GAAuB,CAEvC,MAAQ,IAAmB,CACzB,GAAS,cAAc,IAAI,EAAM,CACjC,GAAS,cAAc,kBAAkB,GAIhC,MAA8B,CACzC,GAAM,CAAE,WAAY,GAAkB,CAChC,EAAU,GAAuB,CAGvC,MAAO,CAAC,EAFQ,GAAmB,GAAS,cAAc,IAAI,EAAM,CAE5C,EAOb,MAA0C,CACrD,IAAM,EAAU,GAAuB,CAEvC,UAAa,GAAS,YAAY"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{EditorStateProvider as e}from"./EditorStateContext.mjs";import{useEffect as t,useRef as n}from"react";import{jsx as r}from"react/jsx-runtime";import{EditorStateManager as i,defineIntlayerElements as a,setGlobalEditorManager as o}from"@intlayer/editor";const s=({children:s,configuration:c,postMessage:l,allowedOrigins:u})=>{let d=n(null);d.current||=new i({mode:`editor`,messenger:{allowedOrigins:u,postMessageFn:l},configuration:c});let f=d.current;return t(()=>(a(),o(f),f.start(),()=>{f.stop(),o(null)}),[f]),r(e,{manager:f,children:s})};export{s as EditorProvider};
|
|
2
2
|
//# sourceMappingURL=EditorProvider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorProvider.mjs","names":[],"sources":["../../src/EditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n
|
|
1
|
+
{"version":3,"file":"EditorProvider.mjs","names":[],"sources":["../../src/EditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n defineIntlayerElements,\n EditorStateManager,\n type MessengerConfig,\n setGlobalEditorManager,\n} from '@intlayer/editor';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FC, type PropsWithChildren, useEffect, useRef } from 'react';\nimport { EditorStateProvider } from './EditorStateContext';\n\nexport type EditorProviderProps = {\n configuration: IntlayerConfig;\n postMessage: (data: any) => void;\n allowedOrigins: string[];\n};\n\n/**\n * EditorProvider creates and manages the lifecycle of an EditorStateManager,\n * provides it to all descendants, and registers the Lit web components.\n */\nexport const EditorProvider: FC<PropsWithChildren<EditorProviderProps>> = ({\n children,\n configuration,\n postMessage,\n allowedOrigins,\n}) => {\n const managerRef = useRef<EditorStateManager | null>(null);\n\n if (!managerRef.current) {\n const messengerConfig: MessengerConfig = {\n allowedOrigins,\n postMessageFn: postMessage,\n };\n\n managerRef.current = new EditorStateManager({\n mode: 'editor',\n messenger: messengerConfig,\n configuration,\n });\n }\n const manager = managerRef.current;\n\n useEffect(() => {\n defineIntlayerElements();\n setGlobalEditorManager(manager);\n\n manager.start();\n return () => {\n manager.stop();\n setGlobalEditorManager(null);\n };\n }, [manager]);\n\n return (\n <EditorStateProvider manager={manager}>{children}</EditorStateProvider>\n );\n};\n"],"mappings":"gRAsBA,MAAa,GAA8D,CACzE,WACA,gBACA,cACA,oBACI,CACJ,IAAM,EAAa,EAAkC,KAAK,CAE1D,AAME,EAAW,UAAU,IAAI,EAAmB,CAC1C,KAAM,SACN,UAPuC,CACvC,iBACA,cAAe,EAChB,CAKC,gBACD,CAAC,CAEJ,IAAM,EAAU,EAAW,QAa3B,OAXA,OACE,GAAwB,CACxB,EAAuB,EAAQ,CAE/B,EAAQ,OAAO,KACF,CACX,EAAQ,MAAM,CACd,EAAuB,KAAK,GAE7B,CAAC,EAAQ,CAAC,CAGX,EAAC,EAAD,CAA8B,UAAU,WAA+B,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";import{createContext as e,useContext as t}from"react";import{jsx as n}from"react/jsx-runtime";const r=e(null),i=({children:e,manager:t})=>n(r.Provider,{value:t,children:e}),a=()=>t(r);export{i as EditorStateProvider,a as useEditorStateManager};
|
|
2
|
+
//# sourceMappingURL=EditorStateContext.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorStateContext.mjs","names":[],"sources":["../../src/EditorStateContext.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorStateManager } from '@intlayer/editor';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n} from 'react';\n\nconst EditorStateContext = createContext<EditorStateManager | null>(null);\n\nexport const EditorStateProvider: FC<\n PropsWithChildren<{ manager: EditorStateManager }>\n> = ({ children, manager }) => (\n <EditorStateContext.Provider value={manager}>\n {children}\n </EditorStateContext.Provider>\n);\n\nexport const useEditorStateManager = (): EditorStateManager | null =>\n useContext(EditorStateContext);\n"],"mappings":"2GAUA,MAAM,EAAqB,EAAyC,KAAK,CAE5D,GAER,CAAE,WAAU,aACf,EAAC,EAAmB,SAApB,CAA6B,MAAO,EACjC,WAC2B,CAAA,CAGnB,MACX,EAAW,EAAmB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{useEffect as t,useState as n}from"react";const r=()=>{let r=e(),[i,a]=n(r?.focusedContent.value??null);return t(()=>{if(!r)return;let e=e=>a(e.detail);return r.focusedContent.addEventListener(`change`,e),()=>r.focusedContent.removeEventListener(`change`,e)},[r]),{focusedContent:i,setFocusedContent:e=>r?.focusedContent.set(e),setFocusedContentKeyPath:e=>r?.setFocusedContentKeyPath(e)}},i=()=>{let{setFocusedContent:e,setFocusedContentKeyPath:t}=r();return{setFocusedContent:e,setFocusedContentKeyPath:t}};export{r as useFocusDictionary,i as useFocusDictionaryActions};
|
|
2
2
|
//# sourceMappingURL=FocusDictionaryContext.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FocusDictionaryContext.mjs","names":[],"sources":["../../src/FocusDictionaryContext.tsx"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"file":"FocusDictionaryContext.mjs","names":[],"sources":["../../src/FocusDictionaryContext.tsx"],"sourcesContent":["'use client';\n\nimport type { FileContent } from '@intlayer/editor';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { FileContent } from '@intlayer/editor';\n\nexport type FocusDictionaryState = {\n focusedContent: FileContent | null;\n};\n\nexport type FocusDictionaryActions = {\n setFocusedContent: (value: FileContent | null) => void;\n setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;\n};\n\n/**\n * Returns the focused-content state and setters, backed by EditorStateManager.\n */\nexport const useFocusDictionary = (): FocusDictionaryState &\n FocusDictionaryActions => {\n const manager = useEditorStateManager();\n const [focusedContent, setFocusedContentState] = useState<FileContent | null>(\n manager?.focusedContent.value ?? null\n );\n\n useEffect(() => {\n if (!manager) return;\n const handler = (e: Event) =>\n setFocusedContentState((e as CustomEvent<FileContent | null>).detail);\n manager.focusedContent.addEventListener('change', handler);\n return () => manager.focusedContent.removeEventListener('change', handler);\n }, [manager]);\n\n return {\n focusedContent,\n setFocusedContent: (value: FileContent | null) =>\n manager?.focusedContent.set(value),\n setFocusedContentKeyPath: (keyPath: KeyPath[]) =>\n manager?.setFocusedContentKeyPath(keyPath),\n };\n};\n\nexport const useFocusDictionaryActions = (): FocusDictionaryActions => {\n const { setFocusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n return { setFocusedContent, setFocusedContentKeyPath };\n};\n"],"mappings":"8HAqBA,MAAa,MACe,CAC1B,IAAM,EAAU,GAAuB,CACjC,CAAC,EAAgB,GAA0B,EAC/C,GAAS,eAAe,OAAS,KAClC,CAUD,OARA,MAAgB,CACd,GAAI,CAAC,EAAS,OACd,IAAM,EAAW,GACf,EAAwB,EAAsC,OAAO,CAEvE,OADA,EAAQ,eAAe,iBAAiB,SAAU,EAAQ,KAC7C,EAAQ,eAAe,oBAAoB,SAAU,EAAQ,EACzE,CAAC,EAAQ,CAAC,CAEN,CACL,iBACA,kBAAoB,GAClB,GAAS,eAAe,IAAI,EAAM,CACpC,yBAA2B,GACzB,GAAS,yBAAyB,EAAQ,CAC7C,EAGU,MAA0D,CACrE,GAAM,CAAE,oBAAmB,4BAA6B,GAAoB,CAC5E,MAAO,CAAE,oBAAmB,2BAA0B"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{EditorStateProvider as e,useEditorStateManager as t}from"./EditorStateContext.mjs";import{useFocusDictionary as n,useFocusDictionaryActions as r}from"./FocusDictionaryContext.mjs";import{useCrossFrameState as i}from"./useCrossFrameState.mjs";import{useCrossURLPathSetter as a,useCrossURLPathState as o}from"./useCrossURLPathState.mjs";import{useDictionariesRecord as s,useDictionariesRecordActions as c}from"./DictionariesRecordContext.mjs";import{useEditorLocale as l,useSetEditorLocale as u}from"./useEditorLocale.mjs";import{useFocusUnmergedDictionary as d}from"./useFocusUnmergedDictionary.mjs";import{EditorProvider as f}from"./EditorProvider.mjs";import{useCommunicator as p}from"./CommunicatorContext.mjs";import{ConfigurationProvider as m,useConfiguration as h,useConfigurationState as g}from"./ConfigurationContext.mjs";import{useEditedContent as _,useEditedContentActions as v,useGetEditedContentState as y,usePostEditedContentState as b}from"./EditedContentContext.mjs";import{useEditorEnabled as x,useEditorEnabledState as S,useEditorPingClient as C,useGetEditorEnabledState as w,usePostEditorEnabledState as T}from"./EditorEnabledContext.mjs";import{useCrossFrameMessageListener as E}from"./useCrossFrameMessageListener.mjs";import{useIframeClickInterceptor as D,useIframeClickMerger as O}from"./useIframeClickInterceptor.mjs";import{MessageKey as k}from"@intlayer/editor";export{m as ConfigurationProvider,f as EditorProvider,e as EditorStateProvider,k as MessageKey,p as useCommunicator,h as useConfiguration,g as useConfigurationState,E as useCrossFrameMessageListener,i as useCrossFrameState,a as useCrossURLPathSetter,o as useCrossURLPathState,s as useDictionariesRecord,c as useDictionariesRecordActions,_ as useEditedContent,v as useEditedContentActions,x as useEditorEnabled,S as useEditorEnabledState,l as useEditorLocale,C as useEditorPingClient,t as useEditorStateManager,n as useFocusDictionary,r as useFocusDictionaryActions,d as useFocusUnmergedDictionary,y as useGetEditedContentState,w as useGetEditorEnabledState,D as useIframeClickInterceptor,O as useIframeClickMerger,b as usePostEditedContentState,T as usePostEditorEnabledState,u as useSetEditorLocale};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{useEffect as t}from"react";const n=(n,r,i)=>{let a=e();return t(()=>{if(r)return a?.messenger.subscribe(n,r)},[a,n,i]),e=>{a?.messenger.send(n,e)}};export{n as useCrossFrameMessageListener};
|
|
2
2
|
//# sourceMappingURL=useCrossFrameMessageListener.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossFrameMessageListener.mjs","names":[],"sources":["../../src/useCrossFrameMessageListener.tsx"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"file":"useCrossFrameMessageListener.mjs","names":[],"sources":["../../src/useCrossFrameMessageListener.tsx"],"sourcesContent":["'use client';\n\nimport type { MessageKey } from '@intlayer/editor';\nimport { useEffect } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\n/**\n * Listens for cross-frame messages of the specified type and calls the callback.\n * Returns a function to manually send a message of the same type.\n *\n * Backed by CrossFrameMessenger from EditorStateManager.\n */\nexport const useCrossFrameMessageListener = <S,>(\n key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`,\n onEventTriggered?: (data: S) => void,\n revalidator?: any\n) => {\n const manager = useEditorStateManager();\n\n useEffect(() => {\n if (!onEventTriggered) return;\n return manager?.messenger.subscribe<S>(key, onEventTriggered);\n }, [manager, key, revalidator]);\n\n return (data?: S) => {\n manager?.messenger.send(key, data);\n };\n};\n"],"mappings":"gHAYA,MAAa,GACX,EACA,EACA,IACG,CACH,IAAM,EAAU,GAAuB,CAOvC,OALA,MAAgB,CACT,KACL,OAAO,GAAS,UAAU,UAAa,EAAK,EAAiB,EAC5D,CAAC,EAAS,EAAK,EAAY,CAAC,CAEvB,GAAa,CACnB,GAAS,UAAU,KAAK,EAAK,EAAK"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{useEffect as t,useRef as n,useState as r}from"react";import{CrossFrameStateManager as i}from"@intlayer/editor";const a=(a,o,s)=>{let c=e(),l=typeof o==`function`?o():o,[u,d]=r(l),f=n(l),p=n(null);return t(()=>{let{emit:e=!0,receive:t=!0}=s??{},n=new i(a,c?.messenger,{emit:e,receive:t,initialValue:l});p.current=n;let r=e=>{let t=e.detail;f.current=t,d(t)};return n.addEventListener(`change`,r),n.start(),()=>{n.removeEventListener(`change`,r),n.stop(),p.current=null}},[a,c?.messenger,s?.emit,s?.receive]),[u,e=>{d(t=>{let n=typeof e==`function`?e(t):e;return f.current=n,p.current?.set(n),n})},()=>{p.current?.postCurrentValue()}]};export{a as useCrossFrameState};
|
|
2
2
|
//# sourceMappingURL=useCrossFrameState.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossFrameState.mjs","names":[],"sources":["../../src/useCrossFrameState.tsx"],"sourcesContent":["'use client';\n\nimport type { MessageKey } from '@intlayer/editor';\nimport {
|
|
1
|
+
{"version":3,"file":"useCrossFrameState.mjs","names":[],"sources":["../../src/useCrossFrameState.tsx"],"sourcesContent":["'use client';\n\nimport type { MessageKey } from '@intlayer/editor';\nimport { CrossFrameStateManager } from '@intlayer/editor';\nimport {\n type Dispatch,\n type SetStateAction,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type CrossFrameStateOptions = {\n emit?: boolean;\n receive?: boolean;\n};\n\n/**\n * Synchronizes a React state value across frames using CrossFrameStateManager.\n */\nexport const useCrossFrameState = <S,>(\n key: `${MessageKey}`,\n initialState?: S | (() => S),\n options?: CrossFrameStateOptions\n): [S, Dispatch<SetStateAction<S>>, () => void] => {\n const manager = useEditorStateManager();\n\n const resolvedInitial =\n typeof initialState === 'function'\n ? (initialState as () => S)()\n : initialState;\n\n const [value, setValueState] = useState<S>(resolvedInitial as S);\n const valueRef = useRef<S>(resolvedInitial as S);\n\n const stateManagerRef = useRef<CrossFrameStateManager<S> | null>(null);\n\n useEffect(() => {\n const { emit = true, receive = true } = options ?? {};\n const stateManager = new CrossFrameStateManager<S>(\n key,\n manager?.messenger,\n {\n emit,\n receive,\n initialValue: resolvedInitial,\n }\n );\n stateManagerRef.current = stateManager;\n\n const handler = (e: Event) => {\n const newValue = (e as CustomEvent<S>).detail;\n valueRef.current = newValue;\n setValueState(newValue);\n };\n stateManager.addEventListener('change', handler);\n stateManager.start();\n\n return () => {\n stateManager.removeEventListener('change', handler);\n stateManager.stop();\n stateManagerRef.current = null;\n };\n }, [key, manager?.messenger, options?.emit, options?.receive]);\n\n const setValue: Dispatch<SetStateAction<S>> = (valueOrUpdater) => {\n setValueState((prev) => {\n const newValue =\n typeof valueOrUpdater === 'function'\n ? (valueOrUpdater as (prev: S) => S)(prev)\n : valueOrUpdater;\n valueRef.current = newValue;\n stateManagerRef.current?.set(newValue);\n return newValue;\n });\n };\n\n const postState = () => {\n stateManagerRef.current?.postCurrentValue();\n };\n\n return [value, setValue, postState];\n};\n"],"mappings":"oMAqBA,MAAa,GACX,EACA,EACA,IACiD,CACjD,IAAM,EAAU,GAAuB,CAEjC,EACJ,OAAO,GAAiB,WACnB,GAA0B,CAC3B,EAEA,CAAC,EAAO,GAAiB,EAAY,EAAqB,CAC1D,EAAW,EAAU,EAAqB,CAE1C,EAAkB,EAAyC,KAAK,CA8CtE,OA5CA,MAAgB,CACd,GAAM,CAAE,OAAO,GAAM,UAAU,IAAS,GAAW,EAAE,CAC/C,EAAe,IAAI,EACvB,EACA,GAAS,UACT,CACE,OACA,UACA,aAAc,EACf,CACF,CACD,EAAgB,QAAU,EAE1B,IAAM,EAAW,GAAa,CAC5B,IAAM,EAAY,EAAqB,OACvC,EAAS,QAAU,EACnB,EAAc,EAAS,EAKzB,OAHA,EAAa,iBAAiB,SAAU,EAAQ,CAChD,EAAa,OAAO,KAEP,CACX,EAAa,oBAAoB,SAAU,EAAQ,CACnD,EAAa,MAAM,CACnB,EAAgB,QAAU,OAE3B,CAAC,EAAK,GAAS,UAAW,GAAS,KAAM,GAAS,QAAQ,CAAC,CAkBvD,CAAC,EAhBuC,GAAmB,CAChE,EAAe,GAAS,CACtB,IAAM,EACJ,OAAO,GAAmB,WACrB,EAAkC,EAAK,CACxC,EAGN,MAFA,GAAS,QAAU,EACnB,EAAgB,SAAS,IAAI,EAAS,CAC/B,GACP,MAGoB,CACtB,EAAgB,SAAS,kBAAkB,EAGV"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{useCrossFrameState as e}from"./useCrossFrameState.mjs";import{MessageKey as t}from"@intlayer/editor";
|
|
1
|
+
"use client";import{useCrossFrameState as e}from"./useCrossFrameState.mjs";import{MessageKey as t}from"@intlayer/editor";const n=(n,r)=>e(t.INTLAYER_URL_CHANGE,n,r),r=e=>n(e,{emit:!0,receive:!1});export{r as useCrossURLPathSetter,n as useCrossURLPathState};
|
|
2
2
|
//# sourceMappingURL=useCrossURLPathState.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossURLPathState.mjs","names":[],"sources":["../../src/useCrossURLPathState.tsx"],"sourcesContent":["'use client';\n\nimport { MessageKey } from '@intlayer/editor';\nimport {
|
|
1
|
+
{"version":3,"file":"useCrossURLPathState.mjs","names":[],"sources":["../../src/useCrossURLPathState.tsx"],"sourcesContent":["'use client';\n\nimport { MessageKey } from '@intlayer/editor';\nimport {\n type CrossFrameStateOptions,\n useCrossFrameState,\n} from './useCrossFrameState';\n\nexport const useCrossURLPathState = (\n initialState?: string,\n options?: CrossFrameStateOptions\n) => useCrossFrameState(MessageKey.INTLAYER_URL_CHANGE, initialState, options);\n\nexport const useCrossURLPathSetter = (initialState?: string) => {\n // The EditorStateManager already handles URL tracking in client mode via\n // UrlStateManager.start(). This hook remains for explicit use cases.\n return useCrossURLPathState(initialState, { emit: true, receive: false });\n};\n"],"mappings":"yHAQA,MAAa,GACX,EACA,IACG,EAAmB,EAAW,oBAAqB,EAAc,EAAQ,CAEjE,EAAyB,GAG7B,EAAqB,EAAc,CAAE,KAAM,GAAM,QAAS,GAAO,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
"use client";import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{useEffect as t,useState as n}from"react";const r=()=>{let r=e(),[i,a]=n(r?.currentLocale.value);return t(()=>{if(!r)return;let e=e=>a(e.detail);return r.currentLocale.addEventListener(`change`,e),()=>r.currentLocale.removeEventListener(`change`,e)},[r]),i},i=()=>{let t=e();return e=>t?.currentLocale.set(e)};export{r as useEditorLocale,i as useSetEditorLocale};
|
|
2
2
|
//# sourceMappingURL=useEditorLocale.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditorLocale.mjs","names":[],"sources":["../../src/useEditorLocale.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"useEditorLocale.mjs","names":[],"sources":["../../src/useEditorLocale.tsx"],"sourcesContent":["'use client';\n\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport const useEditorLocale = (): Locale | undefined => {\n const manager = useEditorStateManager();\n const [locale, setLocale] = useState<Locale | undefined>(\n manager?.currentLocale.value\n );\n\n useEffect(() => {\n if (!manager) return;\n\n const handler = (e: Event) => setLocale((e as CustomEvent<Locale>).detail);\n manager.currentLocale.addEventListener('change', handler);\n\n return () => manager.currentLocale.removeEventListener('change', handler);\n }, [manager]);\n\n return locale;\n};\n\nexport const useSetEditorLocale = () => {\n const manager = useEditorStateManager();\n return (locale: Locale) => manager?.currentLocale.set(locale);\n};\n"],"mappings":"8HAMA,MAAa,MAA4C,CACvD,IAAM,EAAU,GAAuB,CACjC,CAAC,EAAQ,GAAa,EAC1B,GAAS,cAAc,MACxB,CAWD,OATA,MAAgB,CACd,GAAI,CAAC,EAAS,OAEd,IAAM,EAAW,GAAa,EAAW,EAA0B,OAAO,CAG1E,OAFA,EAAQ,cAAc,iBAAiB,SAAU,EAAQ,KAE5C,EAAQ,cAAc,oBAAoB,SAAU,EAAQ,EACxE,CAAC,EAAQ,CAAC,CAEN,GAGI,MAA2B,CACtC,IAAM,EAAU,GAAuB,CACvC,MAAQ,IAAmB,GAAS,cAAc,IAAI,EAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusUnmergedDictionary.mjs","names":[],"sources":["../../src/useFocusUnmergedDictionary.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport type {
|
|
1
|
+
{"version":3,"file":"useFocusUnmergedDictionary.mjs","names":[],"sources":["../../src/useFocusUnmergedDictionary.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { useMemo } from 'react';\nimport { useDictionariesRecord } from './DictionariesRecordContext';\nimport { type FileContent, useFocusDictionary } from './FocusDictionaryContext';\nimport { useEditorLocale } from './useEditorLocale';\n\ntype UnmergedKeyPath = {\n keyPath: KeyPath[];\n dictionaryLocalId?: LocalDictionaryId;\n};\n\n/**\n * Converts merged keypath format to unmerged format.\n * Merged: [{type: \"translation\", key: \"fr\"}, {type: \"object\", key: \"title\"}]\n * Unmerged: [{type: \"object\", key: \"title\"}, {type: \"translation\", key: \"fr\"}]\n */\nconst mergedKeyPathToUnmergedKeyPath = (\n keyPath: KeyPath[],\n dictionaries: Dictionary[],\n locale?: Locale\n): UnmergedKeyPath | undefined => {\n // If we have a dictionary, verify the path exists\n // Try to find the correct position for the translation key\n // by checking which path actually exists in the dictionary\n for (const dictionary of dictionaries) {\n try {\n const result = getContentNodeByKeyPath(\n dictionary.content,\n keyPath ?? [],\n locale\n );\n\n if (result) {\n return { keyPath, dictionaryLocalId: dictionary.localId };\n }\n } catch {\n // Continue to next candidate\n }\n }\n};\n\nexport const useFocusUnmergedDictionary = () => {\n const { localeDictionaries } = useDictionariesRecord();\n const currentLocale = useEditorLocale();\n const {\n setFocusedContent,\n setFocusedContentKeyPath,\n focusedContent: mergedFocusedContent,\n } = useFocusDictionary();\n\n const focusedContent = useMemo<FileContent | null>(() => {\n if (!mergedFocusedContent) return mergedFocusedContent;\n if (!localeDictionaries) return mergedFocusedContent;\n if (mergedFocusedContent.dictionaryLocalId) return mergedFocusedContent;\n\n const dictionaries = Object.values(localeDictionaries).filter(\n (dictionary) => dictionary.key === mergedFocusedContent.dictionaryKey\n );\n\n const unmergedKeyPath = mergedKeyPathToUnmergedKeyPath(\n mergedFocusedContent.keyPath ?? [],\n dictionaries,\n currentLocale\n );\n\n return {\n ...mergedFocusedContent,\n ...unmergedKeyPath,\n };\n }, [mergedFocusedContent, localeDictionaries, currentLocale]);\n\n return {\n focusedContent,\n setFocusedContent,\n setFocusedContentKeyPath,\n };\n};\n"],"mappings":"8TAqBA,MAAM,GACJ,EACA,EACA,IACgC,CAIhC,IAAK,IAAM,KAAc,EACvB,GAAI,CAOF,GANe,EACb,EAAW,QACX,GAAW,EAAE,CACb,EACD,CAGC,MAAO,CAAE,UAAS,kBAAmB,EAAW,QAAS,MAErD,IAMC,MAAmC,CAC9C,GAAM,CAAE,sBAAuB,GAAuB,CAChD,EAAgB,GAAiB,CACjC,CACJ,oBACA,2BACA,eAAgB,GACd,GAAoB,CAuBxB,MAAO,CACL,eAtBqB,MAAkC,CAGvD,GAFI,CAAC,GACD,CAAC,GACD,EAAqB,kBAAmB,OAAO,EAEnD,IAAM,EAAe,OAAO,OAAO,EAAmB,CAAC,OACpD,GAAe,EAAW,MAAQ,EAAqB,cACzD,CAEK,EAAkB,EACtB,EAAqB,SAAW,EAAE,CAClC,EACA,EACD,CAED,MAAO,CACL,GAAG,EACH,GAAG,EACJ,EACA,CAAC,EAAsB,EAAoB,EAAc,CAAC,CAI3D,oBACA,2BACD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{useCrossFrameMessageListener as e}from"./useCrossFrameMessageListener.mjs";import{MessageKey as t,mergeIframeClick as n}from"@intlayer/editor";
|
|
1
|
+
"use client";import{useCrossFrameMessageListener as e}from"./useCrossFrameMessageListener.mjs";import{MessageKey as t,mergeIframeClick as n}from"@intlayer/editor";const r=()=>{e(t.INTLAYER_IFRAME_CLICKED)},i=()=>{e(t.INTLAYER_IFRAME_CLICKED,n)};export{r as useIframeClickInterceptor,i as useIframeClickMerger};
|
|
2
2
|
//# sourceMappingURL=useIframeClickInterceptor.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIframeClickInterceptor.mjs","names":[],"sources":["../../src/useIframeClickInterceptor.tsx"],"sourcesContent":["'use client';\n\nimport { MessageKey, mergeIframeClick } from '@intlayer/editor';\nimport {
|
|
1
|
+
{"version":3,"file":"useIframeClickInterceptor.mjs","names":[],"sources":["../../src/useIframeClickInterceptor.tsx"],"sourcesContent":["'use client';\n\nimport { MessageKey, mergeIframeClick } from '@intlayer/editor';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\n/**\n * Broadcasts mousedown events from within an iframe to the parent frame.\n * Called in the client application (inside the iframe).\n * Note: EditorStateManager.start() already sets this up in client mode.\n * This hook exists for explicit / standalone use cases.\n */\nexport const useIframeClickInterceptor = () => {\n useCrossFrameMessageListener<undefined>(MessageKey.INTLAYER_IFRAME_CLICKED);\n};\n\n/**\n * Merges received iframe click events into the parent's DOM event stream.\n * Called in the editor (parent frame).\n */\nexport const useIframeClickMerger = () => {\n useCrossFrameMessageListener<MessageEvent>(\n MessageKey.INTLAYER_IFRAME_CLICKED,\n mergeIframeClick\n );\n};\n"],"mappings":"mKAWA,MAAa,MAAkC,CAC7C,EAAwC,EAAW,wBAAwB,EAOhE,MAA6B,CACxC,EACE,EAAW,wBACX,EACD"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MessagePayload, MessengerConfig } from "@intlayer/editor";
|
|
2
2
|
|
|
3
3
|
//#region src/CommunicatorContext.d.ts
|
|
4
4
|
type UseCrossPlatformStateProps = {
|
|
5
|
-
postMessage:
|
|
5
|
+
postMessage: (payload: MessagePayload) => void;
|
|
6
6
|
allowedOrigins?: string[];
|
|
7
7
|
senderId: string;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Returns the communicator API backed by the shared EditorStateManager messenger.
|
|
11
|
+
*/
|
|
11
12
|
declare const useCommunicator: () => UseCrossPlatformStateProps;
|
|
12
13
|
//#endregion
|
|
13
|
-
export {
|
|
14
|
+
export { type MessengerConfig, UseCrossPlatformStateProps, useCommunicator };
|
|
14
15
|
//# sourceMappingURL=CommunicatorContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommunicatorContext.d.ts","names":[],"sources":["../../src/CommunicatorContext.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"CommunicatorContext.d.ts","names":[],"sources":["../../src/CommunicatorContext.tsx"],"mappings":";;;KAKY,0BAAA;EACV,WAAA,GAAc,OAAA,EAAS,cAAA;EACvB,cAAA;EACA,QAAA;AAAA;;;;cAMW,eAAA,QAAsB,0BAAA"}
|
|
@@ -3,12 +3,12 @@ import { FC, PropsWithChildren } from "react";
|
|
|
3
3
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
4
4
|
|
|
5
5
|
//#region src/ConfigurationContext.d.ts
|
|
6
|
-
|
|
7
|
-
type ConfigurationProviderProps = {
|
|
6
|
+
type ConfigurationProviderProps = PropsWithChildren<{
|
|
8
7
|
configuration?: IntlayerConfig;
|
|
9
|
-
}
|
|
10
|
-
declare const ConfigurationProvider: FC<
|
|
11
|
-
declare const useConfiguration: () => IntlayerConfig;
|
|
8
|
+
}>;
|
|
9
|
+
declare const ConfigurationProvider: FC<ConfigurationProviderProps>;
|
|
10
|
+
declare const useConfiguration: () => IntlayerConfig | undefined;
|
|
11
|
+
declare const useConfigurationState: () => readonly [IntlayerConfig, react.Dispatch<react.SetStateAction<IntlayerConfig>>, () => void];
|
|
12
12
|
//#endregion
|
|
13
13
|
export { ConfigurationProvider, ConfigurationProviderProps, useConfiguration, useConfigurationState };
|
|
14
14
|
//# sourceMappingURL=ConfigurationContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurationContext.d.ts","names":[],"sources":["../../src/ConfigurationContext.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"ConfigurationContext.d.ts","names":[],"sources":["../../src/ConfigurationContext.tsx"],"mappings":";;;;;KAMY,0BAAA,GAA6B,iBAAA;EACvC,aAAA,GAAgB,cAAA;AAAA;AAAA,cAGL,qBAAA,EAAuB,EAAA,CAAG,0BAAA;AAAA,cAe1B,gBAAA,QAAuB,cAAA;AAAA,cAkBvB,qBAAA,kBAAqB,cAAA,EAAA,KAAA,CAAA,QAAA,CAAA,KAAA,CAAA,cAAA,CAAA,cAAA"}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Dictionary
|
|
1
|
+
import { DictionaryContent, DictionaryContent as DictionaryContent$1 } from "@intlayer/editor";
|
|
2
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
3
|
|
|
4
4
|
//#region src/DictionariesRecordContext.d.ts
|
|
5
|
-
type
|
|
5
|
+
type DictionariesRecordStatesContextType = {
|
|
6
|
+
localeDictionaries: DictionaryContent$1;
|
|
7
|
+
};
|
|
6
8
|
type DictionariesRecordActionsContextType = {
|
|
7
|
-
setLocaleDictionaries:
|
|
9
|
+
setLocaleDictionaries: (value: DictionaryContent$1) => void;
|
|
8
10
|
setLocaleDictionary: (dictionary: Dictionary) => void;
|
|
9
11
|
};
|
|
10
|
-
declare const
|
|
12
|
+
declare const useDictionariesRecord: () => DictionariesRecordStatesContextType & DictionariesRecordActionsContextType;
|
|
11
13
|
declare const useDictionariesRecordActions: () => DictionariesRecordActionsContextType;
|
|
12
|
-
declare const useDictionariesRecord: () => {
|
|
13
|
-
setLocaleDictionaries: Dispatch<SetStateAction<DictionaryContent>>;
|
|
14
|
-
setLocaleDictionary: (dictionary: Dictionary) => void;
|
|
15
|
-
localeDictionaries: DictionaryContent;
|
|
16
|
-
};
|
|
17
14
|
//#endregion
|
|
18
|
-
export {
|
|
15
|
+
export { type DictionaryContent, useDictionariesRecord, useDictionariesRecordActions };
|
|
19
16
|
//# sourceMappingURL=DictionariesRecordContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionariesRecordContext.d.ts","names":[],"sources":["../../src/DictionariesRecordContext.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"DictionariesRecordContext.d.ts","names":[],"sources":["../../src/DictionariesRecordContext.tsx"],"mappings":";;;;KASK,mCAAA;EACH,kBAAA,EAAoB,mBAAA;AAAA;AAAA,KAEjB,oCAAA;EACH,qBAAA,GAAwB,KAAA,EAAO,mBAAA;EAC/B,mBAAA,GAAsB,UAAA,EAAY,UAAA;AAAA;AAAA,cAGvB,qBAAA,QAA4B,mCAAA,GACvC,oCAAA;AAAA,cAgCW,4BAAA,QACP,oCAAA"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { DictionaryContent } from "
|
|
2
|
-
import { Dispatch, FC, PropsWithChildren, SetStateAction } from "react";
|
|
1
|
+
import { DictionaryContent, DictionaryContent as DictionaryContent$1 } from "@intlayer/editor";
|
|
3
2
|
import { ContentNode, Dictionary, LocalDictionaryId } from "@intlayer/types/dictionary";
|
|
4
3
|
import { KeyPath } from "@intlayer/types/keyPath";
|
|
5
4
|
|
|
6
5
|
//#region src/EditedContentContext.d.ts
|
|
7
|
-
declare const usePostEditedContentState: <S>(onEventTriggered?: (data: S) => void) => (data?: S) => void;
|
|
8
|
-
declare const useGetEditedContentState: <S>(onEventTriggered?: (data: S) => void) => (data?: S) => void;
|
|
9
6
|
type EditedContentActionsContextType = {
|
|
10
|
-
setEditedContentState: (editedContent: DictionaryContent) => void;
|
|
11
|
-
setEditedDictionary:
|
|
7
|
+
setEditedContentState: (editedContent: DictionaryContent$1) => void;
|
|
8
|
+
setEditedDictionary: (dict: Dictionary) => void;
|
|
12
9
|
setEditedContent: (localDictionaryId: LocalDictionaryId, newValue: Dictionary['content']) => void;
|
|
13
10
|
addEditedContent: (localDictionaryId: LocalDictionaryId, newValue: ContentNode<any>, keyPath?: KeyPath[], overwrite?: boolean) => void;
|
|
14
11
|
renameEditedContent: (localDictionaryId: LocalDictionaryId, newKey: KeyPath['key'], keyPath?: KeyPath[]) => void;
|
|
@@ -18,11 +15,10 @@ type EditedContentActionsContextType = {
|
|
|
18
15
|
clearEditedContent: () => void;
|
|
19
16
|
getEditedContentValue: (localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string, keyPath: KeyPath[]) => ContentNode | undefined;
|
|
20
17
|
};
|
|
21
|
-
declare const EditedContentProvider: FC<PropsWithChildren>;
|
|
22
18
|
declare const useEditedContentActions: () => EditedContentActionsContextType;
|
|
23
19
|
declare const useEditedContent: () => {
|
|
24
|
-
setEditedContentState: (editedContent: DictionaryContent) => void;
|
|
25
|
-
setEditedDictionary:
|
|
20
|
+
setEditedContentState: (editedContent: DictionaryContent$1) => void;
|
|
21
|
+
setEditedDictionary: (dict: Dictionary) => void;
|
|
26
22
|
setEditedContent: (localDictionaryId: LocalDictionaryId, newValue: Dictionary["content"]) => void;
|
|
27
23
|
addEditedContent: (localDictionaryId: LocalDictionaryId, newValue: ContentNode<any>, keyPath?: KeyPath[], overwrite?: boolean) => void;
|
|
28
24
|
renameEditedContent: (localDictionaryId: LocalDictionaryId, newKey: KeyPath["key"], keyPath?: KeyPath[]) => void;
|
|
@@ -31,8 +27,10 @@ declare const useEditedContent: () => {
|
|
|
31
27
|
clearEditedDictionaryContent: (localDictionaryId: LocalDictionaryId) => void;
|
|
32
28
|
clearEditedContent: () => void;
|
|
33
29
|
getEditedContentValue: (localDictionaryIdOrKey: LocalDictionaryId | Dictionary["key"] | string, keyPath: KeyPath[]) => ContentNode | undefined;
|
|
34
|
-
editedContent:
|
|
30
|
+
editedContent: DictionaryContent$1;
|
|
35
31
|
};
|
|
32
|
+
declare const usePostEditedContentState: <S>(onEventTriggered?: (data: S) => void) => void;
|
|
33
|
+
declare const useGetEditedContentState: () => () => void;
|
|
36
34
|
//#endregion
|
|
37
|
-
export {
|
|
35
|
+
export { type DictionaryContent, useEditedContent, useEditedContentActions, useGetEditedContentState, usePostEditedContentState };
|
|
38
36
|
//# sourceMappingURL=EditedContentContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditedContentContext.d.ts","names":[],"sources":["../../src/EditedContentContext.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditedContentContext.d.ts","names":[],"sources":["../../src/EditedContentContext.tsx"],"mappings":";;;;;KAcK,+BAAA;EACH,qBAAA,GAAwB,aAAA,EAAe,mBAAA;EACvC,mBAAA,GAAsB,IAAA,EAAM,UAAA;EAC5B,gBAAA,GACE,iBAAA,EAAmB,iBAAA,EACnB,QAAA,EAAU,UAAA;EAEZ,gBAAA,GACE,iBAAA,EAAmB,iBAAA,EACnB,QAAA,EAAU,WAAA,OACV,OAAA,GAAU,OAAA,IACV,SAAA;EAEF,mBAAA,GACE,iBAAA,EAAmB,iBAAA,EACnB,MAAA,EAAQ,OAAA,SACR,OAAA,GAAU,OAAA;EAEZ,mBAAA,GACE,iBAAA,EAAmB,iBAAA,EACnB,OAAA,EAAS,OAAA;EAEX,oBAAA,GAAuB,iBAAA,EAAmB,iBAAA;EAC1C,4BAAA,GAA+B,iBAAA,EAAmB,iBAAA;EAClD,kBAAA;EACA,qBAAA,GACE,sBAAA,EAAwB,iBAAA,GAAoB,UAAA,kBAC5C,OAAA,EAAS,OAAA,OACN,WAAA;AAAA;AAAA,cAGM,uBAAA,QAA8B,+BAAA;AAAA,cA0B9B,gBAAA;0BAxDa,aAAA,EAAe,mBAAA;wBACjB,IAAA,EAAM,UAAA;qBAE1B,iBAAA,EAAmB,iBAAA,EACnB,QAAA,EAAU,UAAA;qBAGV,iBAAA,EAAmB,iBAAA,EACnB,QAAA,EAAU,WAAA,OACV,OAAA,GAAU,OAAA,IACV,SAAA;wBAGA,iBAAA,EAAmB,iBAAA,EACnB,MAAA,EAAQ,OAAA,SACR,OAAA,GAAU,OAAA;wBAGV,iBAAA,EAAmB,iBAAA,EACnB,OAAA,EAAS,OAAA;yBAEY,iBAAA,EAAmB,iBAAA;iCACX,iBAAA,EAAmB,iBAAA;;0BAGhD,sBAAA,EAAwB,iBAAA,GAAoB,UAAA,kBAC5C,OAAA,EAAS,OAAA,OACN,WAAA;;;cA+CM,yBAAA,MACX,gBAAA,IAAoB,IAAA,EAAM,CAAA;AAAA,cAYf,wBAAA"}
|
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import { CrossFrameStateOptions } from "./useCrossFrameState.js";
|
|
2
|
-
import * as react from "react";
|
|
3
|
-
import { FC, PropsWithChildren } from "react";
|
|
4
|
-
|
|
5
1
|
//#region src/EditorEnabledContext.d.ts
|
|
6
2
|
type EditorEnabledStateProps = {
|
|
7
3
|
enabled: boolean;
|
|
8
4
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Returns the current editor-enabled state, kept in sync with the shared
|
|
7
|
+
* EditorStateManager. Replaces the old EditorEnabledContext + EditorEnabledProvider.
|
|
8
|
+
*/
|
|
13
9
|
declare const useEditorEnabled: () => EditorEnabledStateProps;
|
|
10
|
+
/**
|
|
11
|
+
* Subscribes to incoming "get" requests for editor-enabled state and calls
|
|
12
|
+
* the provided callback so the caller can respond.
|
|
13
|
+
* Used by the editor side to respond when the client asks for the current state.
|
|
14
|
+
*/
|
|
15
|
+
declare const useGetEditorEnabledState: (onRequest?: () => void) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Returns a function that sets the editor-enabled state and broadcasts it.
|
|
18
|
+
*/
|
|
19
|
+
declare const usePostEditorEnabledState: () => (value: boolean) => void;
|
|
20
|
+
declare const useEditorEnabledState: () => readonly [boolean, (value: boolean) => void];
|
|
21
|
+
/**
|
|
22
|
+
* Returns a function that re-pings the client via ARE_YOU_THERE.
|
|
23
|
+
* Use this as the onClick for an "Enable Editor" / reconnect button.
|
|
24
|
+
*/
|
|
25
|
+
declare const useEditorPingClient: () => (() => void);
|
|
14
26
|
//#endregion
|
|
15
|
-
export {
|
|
27
|
+
export { EditorEnabledStateProps, useEditorEnabled, useEditorEnabledState, useEditorPingClient, useGetEditorEnabledState, usePostEditorEnabledState };
|
|
16
28
|
//# sourceMappingURL=EditorEnabledContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorEnabledContext.d.ts","names":[],"sources":["../../src/EditorEnabledContext.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditorEnabledContext.d.ts","names":[],"sources":["../../src/EditorEnabledContext.tsx"],"mappings":";KAMY,uBAAA;EACV,OAAA;AAAA;;;;AAOF;cAAa,gBAAA,QAAuB,uBAAA;;;;AAuBpC;;cAAa,wBAAA,GAA4B,SAAA;;;AAgBzC;cAAa,yBAAA,SAGH,KAAA;AAAA,cAMG,qBAAA,4BAAqB,KAAA;;;AAAlC;;cAYa,mBAAA"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { CommunicatorProviderProps } from "./CommunicatorContext.js";
|
|
2
|
-
import { ConfigurationProviderProps } from "./ConfigurationContext.js";
|
|
3
1
|
import { FC, PropsWithChildren } from "react";
|
|
2
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
4
3
|
|
|
5
4
|
//#region src/EditorProvider.d.ts
|
|
6
|
-
type EditorProviderProps =
|
|
7
|
-
|
|
5
|
+
type EditorProviderProps = {
|
|
6
|
+
configuration: IntlayerConfig;
|
|
7
|
+
postMessage: (data: any) => void;
|
|
8
|
+
allowedOrigins: string[];
|
|
8
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* EditorProvider creates and manages the lifecycle of an EditorStateManager,
|
|
12
|
+
* provides it to all descendants, and registers the Lit web components.
|
|
13
|
+
*/
|
|
9
14
|
declare const EditorProvider: FC<PropsWithChildren<EditorProviderProps>>;
|
|
10
15
|
//#endregion
|
|
11
16
|
export { EditorProvider, EditorProviderProps };
|