@intlayer/editor-react 8.9.2 → 8.9.3

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.
Files changed (30) hide show
  1. package/dist/cjs/CommunicatorContext.cjs.map +1 -1
  2. package/dist/cjs/ConfigurationContext.cjs.map +1 -1
  3. package/dist/cjs/DictionariesRecordContext.cjs.map +1 -1
  4. package/dist/cjs/EditedContentContext.cjs.map +1 -1
  5. package/dist/cjs/EditorEnabledContext.cjs.map +1 -1
  6. package/dist/cjs/EditorProvider.cjs.map +1 -1
  7. package/dist/cjs/FocusDictionaryContext.cjs +8 -2
  8. package/dist/cjs/FocusDictionaryContext.cjs.map +1 -1
  9. package/dist/cjs/useCrossFrameMessageListener.cjs.map +1 -1
  10. package/dist/cjs/useCrossFrameState.cjs.map +1 -1
  11. package/dist/cjs/useCrossURLPathState.cjs.map +1 -1
  12. package/dist/cjs/useEditorLocale.cjs.map +1 -1
  13. package/dist/cjs/useFocusUnmergedDictionary.cjs.map +1 -1
  14. package/dist/cjs/useIframeClickInterceptor.cjs.map +1 -1
  15. package/dist/esm/CommunicatorContext.mjs.map +1 -1
  16. package/dist/esm/ConfigurationContext.mjs.map +1 -1
  17. package/dist/esm/DictionariesRecordContext.mjs.map +1 -1
  18. package/dist/esm/EditedContentContext.mjs.map +1 -1
  19. package/dist/esm/EditorEnabledContext.mjs.map +1 -1
  20. package/dist/esm/EditorProvider.mjs.map +1 -1
  21. package/dist/esm/FocusDictionaryContext.mjs +8 -2
  22. package/dist/esm/FocusDictionaryContext.mjs.map +1 -1
  23. package/dist/esm/useCrossFrameMessageListener.mjs.map +1 -1
  24. package/dist/esm/useCrossFrameState.mjs.map +1 -1
  25. package/dist/esm/useCrossURLPathState.mjs.map +1 -1
  26. package/dist/esm/useEditorLocale.mjs.map +1 -1
  27. package/dist/esm/useFocusUnmergedDictionary.mjs.map +1 -1
  28. package/dist/esm/useIframeClickInterceptor.mjs.map +1 -1
  29. package/dist/types/FocusDictionaryContext.d.ts.map +1 -1
  30. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"CommunicatorContext.cjs","names":["useEditorStateManager"],"sources":["../../src/CommunicatorContext.tsx"],"sourcesContent":["'use client';\n\nimport type { MessagePayload } from '@intlayer/editor';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type UseCrossPlatformStateProps = {\n postMessage: (payload: MessagePayload) => void;\n allowedOrigins?: string[];\n senderId: string;\n};\n\n/**\n * Returns the communicator API backed by the shared EditorStateManager messenger.\n */\nexport const useCommunicator = (): UseCrossPlatformStateProps => {\n const manager = useEditorStateManager();\n\n return {\n postMessage: (payload: MessagePayload) =>\n manager?.messenger.send(payload.type, payload.data),\n senderId: manager?.messenger.senderId ?? '',\n };\n};\n\n// Re-export type for backward compatibility\nexport type { MessengerConfig } from '@intlayer/editor';\n"],"mappings":";;;;;;;;;AAcA,MAAa,wBAAoD;CAC/D,MAAM,UAAUA,kDAAuB;AAEvC,QAAO;EACL,cAAc,YACZ,SAAS,UAAU,KAAK,QAAQ,MAAM,QAAQ,KAAK;EACrD,UAAU,SAAS,UAAU,YAAY;EAC1C"}
1
+ {"version":3,"file":"CommunicatorContext.cjs","names":["useEditorStateManager"],"sources":["../../src/CommunicatorContext.tsx"],"sourcesContent":["'use client';\n\nimport type { MessagePayload } from '@intlayer/editor';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type UseCrossPlatformStateProps = {\n postMessage: (payload: MessagePayload) => void;\n allowedOrigins?: string[];\n senderId: string;\n};\n\n/**\n * Returns the communicator API backed by the shared EditorStateManager messenger.\n */\nexport const useCommunicator = (): UseCrossPlatformStateProps => {\n const manager = useEditorStateManager();\n\n return {\n postMessage: (payload: MessagePayload) =>\n manager?.messenger.send(payload.type, payload.data),\n senderId: manager?.messenger.senderId ?? '',\n };\n};\n\n// Re-export type for backward compatibility\nexport type { MessengerConfig } from '@intlayer/editor';\n"],"mappings":";;;;;;;;;AAcA,MAAa,wBAAoD;CAC/D,MAAM,UAAUA,kDAAuB;CAEvC,OAAO;EACL,cAAc,YACZ,SAAS,UAAU,KAAK,QAAQ,MAAM,QAAQ,KAAK;EACrD,UAAU,SAAS,UAAU,YAAY;EAC1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigurationContext.cjs","names":["useEditorStateManager"],"sources":["../../src/ConfigurationContext.tsx"],"sourcesContent":["'use client';\n\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\n// 1. Create a native React context\nconst ConfigurationReactContext = createContext<IntlayerConfig | undefined>(\n undefined\n);\n\nexport type ConfigurationProviderProps = PropsWithChildren<{\n configuration?: IntlayerConfig;\n}>;\n\nexport const ConfigurationProvider: FC<ConfigurationProviderProps> = ({\n configuration,\n children,\n}) => {\n const manager = useEditorStateManager();\n\n useEffect(() => {\n if (!manager || !configuration) return;\n\n manager.configuration.set(configuration);\n }, [manager, configuration]);\n\n // 2. Wrap children in the native provider\n return (\n <ConfigurationReactContext.Provider value={configuration}>\n {children}\n </ConfigurationReactContext.Provider>\n );\n};\n\nexport const useConfiguration = (): IntlayerConfig | undefined => {\n const manager = useEditorStateManager();\n const reactConfig = useContext(ConfigurationReactContext); // 3. Consume native context\n\n const [config, setConfig] = useState<IntlayerConfig | undefined>(\n manager?.configuration.value ?? reactConfig\n );\n\n useEffect(() => {\n if (!manager) {\n setConfig(reactConfig);\n return;\n }\n\n const handler = (e: Event) => {\n const detail = (e as CustomEvent<IntlayerConfig>).detail;\n setConfig(detail ?? reactConfig);\n };\n\n manager.configuration.addEventListener('change', handler);\n return () => manager.configuration.removeEventListener('change', handler);\n }, [manager, reactConfig]);\n\n // Prefer event-driven config, fallback to React context config\n return config ?? reactConfig;\n};\n\nexport const useConfigurationState = () => {\n const manager = useEditorStateManager();\n const reactConfig = useContext(ConfigurationReactContext);\n\n const [config, setConfig] = useState<IntlayerConfig | undefined>(\n manager?.configuration.value ?? reactConfig\n );\n\n return [\n config ?? reactConfig,\n setConfig,\n () => manager?.configuration.postCurrentValue(),\n ] as const;\n};\n"],"mappings":";;;;;;;;;AAcA,MAAM,qDACJ,OACD;AAMD,MAAa,yBAAyD,EACpE,eACA,eACI;CACJ,MAAM,UAAUA,kDAAuB;AAEvC,4BAAgB;AACd,MAAI,CAAC,WAAW,CAAC,cAAe;AAEhC,UAAQ,cAAc,IAAI,cAAc;IACvC,CAAC,SAAS,cAAc,CAAC;AAG5B,QACE,2CAAC,0BAA0B,UAA3B;EAAoC,OAAO;EACxC;EACkC;;AAIzC,MAAa,yBAAqD;CAChE,MAAM,UAAUA,kDAAuB;CACvC,MAAM,oCAAyB,0BAA0B;CAEzD,MAAM,CAAC,QAAQ,iCACb,SAAS,cAAc,SAAS,YACjC;AAED,4BAAgB;AACd,MAAI,CAAC,SAAS;AACZ,aAAU,YAAY;AACtB;;EAGF,MAAM,WAAW,MAAa;GAC5B,MAAM,SAAU,EAAkC;AAClD,aAAU,UAAU,YAAY;;AAGlC,UAAQ,cAAc,iBAAiB,UAAU,QAAQ;AACzD,eAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,SAAS,YAAY,CAAC;AAG1B,QAAO,UAAU;;AAGnB,MAAa,8BAA8B;CACzC,MAAM,UAAUA,kDAAuB;CACvC,MAAM,oCAAyB,0BAA0B;CAEzD,MAAM,CAAC,QAAQ,iCACb,SAAS,cAAc,SAAS,YACjC;AAED,QAAO;EACL,UAAU;EACV;QACM,SAAS,cAAc,kBAAkB;EAChD"}
1
+ {"version":3,"file":"ConfigurationContext.cjs","names":["useEditorStateManager"],"sources":["../../src/ConfigurationContext.tsx"],"sourcesContent":["'use client';\n\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\n// 1. Create a native React context\nconst ConfigurationReactContext = createContext<IntlayerConfig | undefined>(\n undefined\n);\n\nexport type ConfigurationProviderProps = PropsWithChildren<{\n configuration?: IntlayerConfig;\n}>;\n\nexport const ConfigurationProvider: FC<ConfigurationProviderProps> = ({\n configuration,\n children,\n}) => {\n const manager = useEditorStateManager();\n\n useEffect(() => {\n if (!manager || !configuration) return;\n\n manager.configuration.set(configuration);\n }, [manager, configuration]);\n\n // 2. Wrap children in the native provider\n return (\n <ConfigurationReactContext.Provider value={configuration}>\n {children}\n </ConfigurationReactContext.Provider>\n );\n};\n\nexport const useConfiguration = (): IntlayerConfig | undefined => {\n const manager = useEditorStateManager();\n const reactConfig = useContext(ConfigurationReactContext); // 3. Consume native context\n\n const [config, setConfig] = useState<IntlayerConfig | undefined>(\n manager?.configuration.value ?? reactConfig\n );\n\n useEffect(() => {\n if (!manager) {\n setConfig(reactConfig);\n return;\n }\n\n const handler = (e: Event) => {\n const detail = (e as CustomEvent<IntlayerConfig>).detail;\n setConfig(detail ?? reactConfig);\n };\n\n manager.configuration.addEventListener('change', handler);\n return () => manager.configuration.removeEventListener('change', handler);\n }, [manager, reactConfig]);\n\n // Prefer event-driven config, fallback to React context config\n return config ?? reactConfig;\n};\n\nexport const useConfigurationState = () => {\n const manager = useEditorStateManager();\n const reactConfig = useContext(ConfigurationReactContext);\n\n const [config, setConfig] = useState<IntlayerConfig | undefined>(\n manager?.configuration.value ?? reactConfig\n );\n\n return [\n config ?? reactConfig,\n setConfig,\n () => manager?.configuration.postCurrentValue(),\n ] as const;\n};\n"],"mappings":";;;;;;;;;AAcA,MAAM,qDACJ,OACD;AAMD,MAAa,yBAAyD,EACpE,eACA,eACI;CACJ,MAAM,UAAUA,kDAAuB;CAEvC,2BAAgB;EACd,IAAI,CAAC,WAAW,CAAC,eAAe;EAEhC,QAAQ,cAAc,IAAI,cAAc;IACvC,CAAC,SAAS,cAAc,CAAC;CAG5B,OACE,2CAAC,0BAA0B,UAA3B;EAAoC,OAAO;EACxC;EACkC;;AAIzC,MAAa,yBAAqD;CAChE,MAAM,UAAUA,kDAAuB;CACvC,MAAM,oCAAyB,0BAA0B;CAEzD,MAAM,CAAC,QAAQ,iCACb,SAAS,cAAc,SAAS,YACjC;CAED,2BAAgB;EACd,IAAI,CAAC,SAAS;GACZ,UAAU,YAAY;GACtB;;EAGF,MAAM,WAAW,MAAa;GAC5B,MAAM,SAAU,EAAkC;GAClD,UAAU,UAAU,YAAY;;EAGlC,QAAQ,cAAc,iBAAiB,UAAU,QAAQ;EACzD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,SAAS,YAAY,CAAC;CAG1B,OAAO,UAAU;;AAGnB,MAAa,8BAA8B;CACzC,MAAM,UAAUA,kDAAuB;CACvC,MAAM,oCAAyB,0BAA0B;CAEzD,MAAM,CAAC,QAAQ,iCACb,SAAS,cAAc,SAAS,YACjC;CAED,OAAO;EACL,UAAU;EACV;QACM,SAAS,cAAc,kBAAkB;EAChD"}
@@ -1 +1 @@
1
- {"version":3,"file":"DictionariesRecordContext.cjs","names":["useEditorStateManager"],"sources":["../../src/DictionariesRecordContext.tsx"],"sourcesContent":["'use client';\n\nimport type { DictionaryContent } from '@intlayer/editor';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { useCallback, useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { DictionaryContent } from '@intlayer/editor';\n\ntype DictionariesRecordStatesContextType = {\n localeDictionaries: DictionaryContent;\n};\ntype DictionariesRecordActionsContextType = {\n setLocaleDictionaries: (value: DictionaryContent) => void;\n setLocaleDictionary: (dictionary: Dictionary) => void;\n};\n\nexport const useDictionariesRecord = (): DictionariesRecordStatesContextType &\n DictionariesRecordActionsContextType => {\n const manager = useEditorStateManager();\n const [localeDictionaries, setLocaleDictionariesState] =\n useState<DictionaryContent>(manager?.localeDictionaries.value ?? {});\n\n useEffect(() => {\n if (!manager) return;\n\n const handler = (e: Event) =>\n setLocaleDictionariesState(\n (e as CustomEvent<DictionaryContent>).detail ?? {}\n );\n\n manager.localeDictionaries.addEventListener('change', handler);\n\n return () =>\n manager.localeDictionaries.removeEventListener('change', handler);\n }, [manager]);\n\n const setLocaleDictionaries = useCallback(\n (value: DictionaryContent) => manager?.localeDictionaries.set(value),\n [manager]\n );\n\n const setLocaleDictionary = useCallback(\n (dictionary: Dictionary) => manager?.setLocaleDictionary(dictionary),\n [manager]\n );\n\n return { localeDictionaries, setLocaleDictionaries, setLocaleDictionary };\n};\n\nexport const useDictionariesRecordActions =\n (): DictionariesRecordActionsContextType => {\n const { setLocaleDictionaries, setLocaleDictionary } =\n useDictionariesRecord();\n return { setLocaleDictionaries, setLocaleDictionary };\n };\n"],"mappings":";;;;;;;;AAiBA,MAAa,8BAC6B;CACxC,MAAM,UAAUA,kDAAuB;CACvC,MAAM,CAAC,oBAAoB,kDACG,SAAS,mBAAmB,SAAS,EAAE,CAAC;AAEtE,4BAAgB;AACd,MAAI,CAAC,QAAS;EAEd,MAAM,WAAW,MACf,2BACG,EAAqC,UAAU,EAAE,CACnD;AAEH,UAAQ,mBAAmB,iBAAiB,UAAU,QAAQ;AAE9D,eACE,QAAQ,mBAAmB,oBAAoB,UAAU,QAAQ;IAClE,CAAC,QAAQ,CAAC;AAYb,QAAO;EAAE;EAAoB,+CAT1B,UAA6B,SAAS,mBAAmB,IAAI,MAAM,EACpE,CAAC,QAAQ,CAQuC;EAAE,6CAJjD,eAA2B,SAAS,oBAAoB,WAAW,EACpE,CAAC,QAAQ,CAG4D;EAAE;;AAG3E,MAAa,qCACiC;CAC1C,MAAM,EAAE,uBAAuB,wBAC7B,uBAAuB;AACzB,QAAO;EAAE;EAAuB;EAAqB"}
1
+ {"version":3,"file":"DictionariesRecordContext.cjs","names":["useEditorStateManager"],"sources":["../../src/DictionariesRecordContext.tsx"],"sourcesContent":["'use client';\n\nimport type { DictionaryContent } from '@intlayer/editor';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { useCallback, useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { DictionaryContent } from '@intlayer/editor';\n\ntype DictionariesRecordStatesContextType = {\n localeDictionaries: DictionaryContent;\n};\ntype DictionariesRecordActionsContextType = {\n setLocaleDictionaries: (value: DictionaryContent) => void;\n setLocaleDictionary: (dictionary: Dictionary) => void;\n};\n\nexport const useDictionariesRecord = (): DictionariesRecordStatesContextType &\n DictionariesRecordActionsContextType => {\n const manager = useEditorStateManager();\n const [localeDictionaries, setLocaleDictionariesState] =\n useState<DictionaryContent>(manager?.localeDictionaries.value ?? {});\n\n useEffect(() => {\n if (!manager) return;\n\n const handler = (e: Event) =>\n setLocaleDictionariesState(\n (e as CustomEvent<DictionaryContent>).detail ?? {}\n );\n\n manager.localeDictionaries.addEventListener('change', handler);\n\n return () =>\n manager.localeDictionaries.removeEventListener('change', handler);\n }, [manager]);\n\n const setLocaleDictionaries = useCallback(\n (value: DictionaryContent) => manager?.localeDictionaries.set(value),\n [manager]\n );\n\n const setLocaleDictionary = useCallback(\n (dictionary: Dictionary) => manager?.setLocaleDictionary(dictionary),\n [manager]\n );\n\n return { localeDictionaries, setLocaleDictionaries, setLocaleDictionary };\n};\n\nexport const useDictionariesRecordActions =\n (): DictionariesRecordActionsContextType => {\n const { setLocaleDictionaries, setLocaleDictionary } =\n useDictionariesRecord();\n return { setLocaleDictionaries, setLocaleDictionary };\n };\n"],"mappings":";;;;;;;;AAiBA,MAAa,8BAC6B;CACxC,MAAM,UAAUA,kDAAuB;CACvC,MAAM,CAAC,oBAAoB,kDACG,SAAS,mBAAmB,SAAS,EAAE,CAAC;CAEtE,2BAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MACf,2BACG,EAAqC,UAAU,EAAE,CACnD;EAEH,QAAQ,mBAAmB,iBAAiB,UAAU,QAAQ;EAE9D,aACE,QAAQ,mBAAmB,oBAAoB,UAAU,QAAQ;IAClE,CAAC,QAAQ,CAAC;CAYb,OAAO;EAAE;EAAoB,+CAT1B,UAA6B,SAAS,mBAAmB,IAAI,MAAM,EACpE,CAAC,QAAQ,CAQuC;EAAE,6CAJjD,eAA2B,SAAS,oBAAoB,WAAW,EACpE,CAAC,QAAQ,CAG4D;EAAE;;AAG3E,MAAa,qCACiC;CAC1C,MAAM,EAAE,uBAAuB,wBAC7B,uBAAuB;CACzB,OAAO;EAAE;EAAuB;EAAqB"}
@@ -1 +1 @@
1
- {"version":3,"file":"EditedContentContext.cjs","names":["useEditorStateManager"],"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":";;;;;;;;AA6CA,MAAa,gCAAiE;CAC5E,MAAM,UAAUA,kDAAuB;AAEvC,QAAO;EACL,wBAAwB,UACtB,SAAS,cAAc,IAAI,MAAM;EACnC,sBAAsB,SACpB,SAAS,oBAAoB,KAAK;EACpC,mBACE,SACA,UACG,SAAS,iBAAiB,SAAS,MAAM;EAC9C,mBAAmB,SAAS,OAAO,SAAS,cAC1C,SAAS,WAAW,SAAS,OAAO,SAAS,UAAU;EACzD,sBAAsB,SAAS,QAAQ,YACrC,SAAS,cAAc,SAAS,QAAQ,QAAQ;EAClD,sBAAsB,SAAS,YAC7B,SAAS,cAAc,SAAS,QAAQ;EAC1C,uBAAuB,YAAY,SAAS,eAAe,QAAQ;EACnE,+BAA+B,YAAY,SAAS,aAAa,QAAQ;EACzE,0BAA0B,SAAS,iBAAiB;EACpD,wBAAwB,cAAc,YACpC,SAAS,gBAAgB,cAAc,QAAQ;EAClD;;AAGH,MAAa,yBAAyB;CACpC,MAAM,UAAUA,kDAAuB;CACvC,MAAM,CAAC,eAAe,6CAEpB,SAAS,cAAc,MAAM;AAE/B,4BAAgB;AACd,MAAI,CAAC,QAAS;EACd,MAAM,WAAW,MACf,sBAAuB,EAAqC,OAAO;AACrE,UAAQ,cAAc,iBAAiB,UAAU,QAAQ;AACzD,eAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,QAAQ,CAAC;AAGb,QAAO;EAAE;EAAe,GADR,yBACkB;EAAE;;AAGtC,MAAa,6BACX,qBACG;CACH,MAAM,UAAUA,kDAAuB;AACvC,4BAAgB;AACd,MAAI,CAAC,oBAAoB,CAAC,QAAS;AACnC,SAAO,QAAQ,UAAU,UACvB,wCACA,iBACD;IACA,CAAC,SAAS,iBAAiB,CAAC;;AAGjC,MAAa,iCAAiC;CAC5C,MAAM,UAAUA,kDAAuB;AACvC,cAAa;AACX,WAAS,UAAU,KAAK,sCAAsC"}
1
+ {"version":3,"file":"EditedContentContext.cjs","names":["useEditorStateManager"],"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":";;;;;;;;AA6CA,MAAa,gCAAiE;CAC5E,MAAM,UAAUA,kDAAuB;CAEvC,OAAO;EACL,wBAAwB,UACtB,SAAS,cAAc,IAAI,MAAM;EACnC,sBAAsB,SACpB,SAAS,oBAAoB,KAAK;EACpC,mBACE,SACA,UACG,SAAS,iBAAiB,SAAS,MAAM;EAC9C,mBAAmB,SAAS,OAAO,SAAS,cAC1C,SAAS,WAAW,SAAS,OAAO,SAAS,UAAU;EACzD,sBAAsB,SAAS,QAAQ,YACrC,SAAS,cAAc,SAAS,QAAQ,QAAQ;EAClD,sBAAsB,SAAS,YAC7B,SAAS,cAAc,SAAS,QAAQ;EAC1C,uBAAuB,YAAY,SAAS,eAAe,QAAQ;EACnE,+BAA+B,YAAY,SAAS,aAAa,QAAQ;EACzE,0BAA0B,SAAS,iBAAiB;EACpD,wBAAwB,cAAc,YACpC,SAAS,gBAAgB,cAAc,QAAQ;EAClD;;AAGH,MAAa,yBAAyB;CACpC,MAAM,UAAUA,kDAAuB;CACvC,MAAM,CAAC,eAAe,6CAEpB,SAAS,cAAc,MAAM;CAE/B,2BAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,WAAW,MACf,sBAAuB,EAAqC,OAAO;EACrE,QAAQ,cAAc,iBAAiB,UAAU,QAAQ;EACzD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,QAAQ,CAAC;CAGb,OAAO;EAAE;EAAe,GADR,yBACkB;EAAE;;AAGtC,MAAa,6BACX,qBACG;CACH,MAAM,UAAUA,kDAAuB;CACvC,2BAAgB;EACd,IAAI,CAAC,oBAAoB,CAAC,SAAS;EACnC,OAAO,QAAQ,UAAU,UACvB,wCACA,iBACD;IACA,CAAC,SAAS,iBAAiB,CAAC;;AAGjC,MAAa,iCAAiC;CAC5C,MAAM,UAAUA,kDAAuB;CACvC,aAAa;EACX,SAAS,UAAU,KAAK,sCAAsC"}
@@ -1 +1 @@
1
- {"version":3,"file":"EditorEnabledContext.cjs","names":["useEditorStateManager","MessageKey"],"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":";;;;;;;;;;;;;AAcA,MAAa,yBAAkD;CAC7D,MAAM,UAAUA,kDAAuB;CACvC,MAAM,CAAC,SAAS,kCACd,SAAS,cAAc,SAAS,MACjC;AAED,4BAAgB;AACd,MAAI,CAAC,QAAS;EAEd,MAAM,WAAW,MACf,WAAY,EAA2B,OAAO;AAChD,UAAQ,cAAc,iBAAiB,UAAU,QAAQ;AACzD,eAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,QAAQ,CAAC;AAEb,QAAO,EAAE,SAAS;;;;;;;AAQpB,MAAa,4BAA4B,cAA2B;CAClE,MAAM,UAAUA,kDAAuB;AAEvC,4BAAgB;AACd,MAAI,CAAC,UAAW;AAEhB,SAAO,SAAS,UAAU,UACxB,GAAGC,4BAAW,wBAAwB,OACtC,UACD;IACA,CAAC,SAAS,UAAU,CAAC;;;;;AAM1B,MAAa,kCAAkC;CAC7C,MAAM,UAAUD,kDAAuB;AAEvC,SAAQ,UAAmB;AACzB,WAAS,cAAc,IAAI,MAAM;AACjC,WAAS,cAAc,kBAAkB;;;AAI7C,MAAa,8BAA8B;CACzC,MAAM,EAAE,YAAY,kBAAkB;CACtC,MAAM,UAAUA,kDAAuB;CACvC,MAAM,UAAU,UAAmB,SAAS,cAAc,IAAI,MAAM;AAEpE,QAAO,CAAC,SAAS,OAAO;;;;;;AAO1B,MAAa,4BAA0C;CACrD,MAAM,UAAUA,kDAAuB;AAEvC,cAAa,SAAS,YAAY"}
1
+ {"version":3,"file":"EditorEnabledContext.cjs","names":["useEditorStateManager","MessageKey"],"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":";;;;;;;;;;;;;AAcA,MAAa,yBAAkD;CAC7D,MAAM,UAAUA,kDAAuB;CACvC,MAAM,CAAC,SAAS,kCACd,SAAS,cAAc,SAAS,MACjC;CAED,2BAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MACf,WAAY,EAA2B,OAAO;EAChD,QAAQ,cAAc,iBAAiB,UAAU,QAAQ;EACzD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,QAAQ,CAAC;CAEb,OAAO,EAAE,SAAS;;;;;;;AAQpB,MAAa,4BAA4B,cAA2B;CAClE,MAAM,UAAUA,kDAAuB;CAEvC,2BAAgB;EACd,IAAI,CAAC,WAAW;EAEhB,OAAO,SAAS,UAAU,UACxB,GAAGC,4BAAW,wBAAwB,OACtC,UACD;IACA,CAAC,SAAS,UAAU,CAAC;;;;;AAM1B,MAAa,kCAAkC;CAC7C,MAAM,UAAUD,kDAAuB;CAEvC,QAAQ,UAAmB;EACzB,SAAS,cAAc,IAAI,MAAM;EACjC,SAAS,cAAc,kBAAkB;;;AAI7C,MAAa,8BAA8B;CACzC,MAAM,EAAE,YAAY,kBAAkB;CACtC,MAAM,UAAUA,kDAAuB;CACvC,MAAM,UAAU,UAAmB,SAAS,cAAc,IAAI,MAAM;CAEpE,OAAO,CAAC,SAAS,OAAO;;;;;;AAO1B,MAAa,4BAA0C;CACrD,MAAM,UAAUA,kDAAuB;CAEvC,aAAa,SAAS,YAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"EditorProvider.cjs","names":["EditorStateManager","EditorStateProvider"],"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":";;;;;;;;;;;;;;AAsBA,MAAa,kBAA8D,EACzE,UACA,eACA,aACA,qBACI;CACJ,MAAM,+BAA+C,KAAK;AAE1D,KAAI,CAAC,WAAW,QAMd,YAAW,UAAU,IAAIA,oCAAmB;EAC1C,MAAM;EACN,WAAW;GANX;GACA,eAAe;GAKW;EAC1B;EACD,CAAC;CAEJ,MAAM,UAAU,WAAW;AAE3B,4BAAgB;AACd,gDAAwB;AACxB,+CAAuB,QAAQ;AAE/B,UAAQ,OAAO;AACf,eAAa;AACX,WAAQ,MAAM;AACd,gDAAuB,KAAK;;IAE7B,CAAC,QAAQ,CAAC;AAEb,QACE,2CAACC,gDAAD;EAA8B;EAAU;EAA+B"}
1
+ {"version":3,"file":"EditorProvider.cjs","names":["EditorStateManager","EditorStateProvider"],"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":";;;;;;;;;;;;;;AAsBA,MAAa,kBAA8D,EACzE,UACA,eACA,aACA,qBACI;CACJ,MAAM,+BAA+C,KAAK;CAE1D,IAAI,CAAC,WAAW,SAMd,WAAW,UAAU,IAAIA,oCAAmB;EAC1C,MAAM;EACN,WAAW;GANX;GACA,eAAe;GAKW;EAC1B;EACD,CAAC;CAEJ,MAAM,UAAU,WAAW;CAE3B,2BAAgB;EACd,8CAAwB;EACxB,6CAAuB,QAAQ;EAE/B,QAAQ,OAAO;EACf,aAAa;GACX,QAAQ,MAAM;GACd,6CAAuB,KAAK;;IAE7B,CAAC,QAAQ,CAAC;CAEb,OACE,2CAACC,gDAAD;EAA8B;EAAU;EAA+B"}
@@ -52,8 +52,14 @@ const useFocusDictionary = () => {
52
52
  }, [manager, reactContext?.focusedContent]);
53
53
  return {
54
54
  focusedContent,
55
- setFocusedContent: reactContext?.setFocusedContent ?? (() => {}),
56
- setFocusedContentKeyPath: reactContext?.setFocusedContentKeyPath ?? (() => {})
55
+ setFocusedContent: (0, react.useCallback)((value) => {
56
+ if (reactContext) reactContext.setFocusedContent(value);
57
+ else if (manager) manager.focusedContent.set(value);
58
+ }, [reactContext, manager]),
59
+ setFocusedContentKeyPath: (0, react.useCallback)((keyPath) => {
60
+ if (reactContext) reactContext.setFocusedContentKeyPath(keyPath);
61
+ else if (manager) manager.setFocusedContentKeyPath(keyPath);
62
+ }, [reactContext, manager])
57
63
  };
58
64
  };
59
65
  const useFocusDictionaryActions = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"FocusDictionaryContext.cjs","names":["useEditorStateManager","NodeTypes"],"sources":["../../src/FocusDictionaryContext.tsx"],"sourcesContent":["'use client';\n\nimport type { FileContent } from '@intlayer/editor';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useState,\n} 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\ntype FocusDictionaryContextType = FocusDictionaryState & FocusDictionaryActions;\n\n// Create native React context fallback\nconst FocusDictionaryReactContext = createContext<\n FocusDictionaryContextType | undefined\n>(undefined);\n\n// Create the Provider\nexport const FocusDictionaryProvider: FC<PropsWithChildren> = ({\n children,\n}) => {\n const manager = useEditorStateManager();\n const [fallbackContent, setFallbackContent] = useState<FileContent | null>(\n null\n );\n\n const setFocusedContent = useCallback(\n (value: FileContent | null) => {\n if (manager) {\n manager.focusedContent.set(value);\n } else {\n setFallbackContent(value);\n }\n },\n [manager]\n );\n\n const setFocusedContentKeyPath = useCallback(\n (keyPath: KeyPath[]) => {\n if (manager) {\n manager.setFocusedContentKeyPath(keyPath);\n } else {\n setFallbackContent((prev) => {\n if (!prev) return null;\n const filtered = keyPath.filter(\n (key) => key.type !== NodeTypes.TRANSLATION\n );\n return { ...prev, keyPath: filtered };\n });\n }\n },\n [manager]\n );\n\n return (\n <FocusDictionaryReactContext.Provider\n value={{\n focusedContent: manager?.focusedContent.value ?? fallbackContent,\n setFocusedContent,\n setFocusedContentKeyPath,\n }}\n >\n {children}\n </FocusDictionaryReactContext.Provider>\n );\n};\n\n// 3. Update the hook to consume the fallback context\nexport const useFocusDictionary = (): FocusDictionaryState &\n FocusDictionaryActions => {\n const manager = useEditorStateManager();\n const reactContext = useContext(FocusDictionaryReactContext);\n\n const [focusedContent, setFocusedContentState] = useState<FileContent | null>(\n manager?.focusedContent.value ?? reactContext?.focusedContent ?? null\n );\n\n useEffect(() => {\n if (!manager) {\n setFocusedContentState(reactContext?.focusedContent ?? null);\n return;\n }\n\n const handler = (e: Event) =>\n setFocusedContentState((e as CustomEvent<FileContent | null>).detail);\n manager.focusedContent.addEventListener('change', handler);\n\n return () => manager.focusedContent.removeEventListener('change', handler);\n }, [manager, reactContext?.focusedContent]);\n\n return {\n focusedContent,\n setFocusedContent: reactContext?.setFocusedContent ?? (() => {}),\n setFocusedContentKeyPath:\n reactContext?.setFocusedContentKeyPath ?? (() => {}),\n };\n};\n\nexport const useFocusDictionaryActions = (): FocusDictionaryActions => {\n const { setFocusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n return { setFocusedContent, setFocusedContentKeyPath };\n};\n"],"mappings":";;;;;;;;;;;AA8BA,MAAM,uDAEJ,OAAU;AAGZ,MAAa,2BAAkD,EAC7D,eACI;CACJ,MAAM,UAAUA,kDAAuB;CACvC,MAAM,CAAC,iBAAiB,0CACtB,KACD;CAED,MAAM,4CACH,UAA8B;AAC7B,MAAI,QACF,SAAQ,eAAe,IAAI,MAAM;MAEjC,oBAAmB,MAAM;IAG7B,CAAC,QAAQ,CACV;CAED,MAAM,mDACH,YAAuB;AACtB,MAAI,QACF,SAAQ,yBAAyB,QAAQ;MAEzC,qBAAoB,SAAS;AAC3B,OAAI,CAAC,KAAM,QAAO;GAClB,MAAM,WAAW,QAAQ,QACtB,QAAQ,IAAI,SAASC,yBAAU,YACjC;AACD,UAAO;IAAE,GAAG;IAAM,SAAS;IAAU;IACrC;IAGN,CAAC,QAAQ,CACV;AAED,QACE,2CAAC,4BAA4B,UAA7B;EACE,OAAO;GACL,gBAAgB,SAAS,eAAe,SAAS;GACjD;GACA;GACD;EAEA;EACoC;;AAK3C,MAAa,2BACe;CAC1B,MAAM,UAAUD,kDAAuB;CACvC,MAAM,qCAA0B,4BAA4B;CAE5D,MAAM,CAAC,gBAAgB,8CACrB,SAAS,eAAe,SAAS,cAAc,kBAAkB,KAClE;AAED,4BAAgB;AACd,MAAI,CAAC,SAAS;AACZ,0BAAuB,cAAc,kBAAkB,KAAK;AAC5D;;EAGF,MAAM,WAAW,MACf,uBAAwB,EAAsC,OAAO;AACvE,UAAQ,eAAe,iBAAiB,UAAU,QAAQ;AAE1D,eAAa,QAAQ,eAAe,oBAAoB,UAAU,QAAQ;IACzE,CAAC,SAAS,cAAc,eAAe,CAAC;AAE3C,QAAO;EACL;EACA,mBAAmB,cAAc,4BAA4B;EAC7D,0BACE,cAAc,mCAAmC;EACpD;;AAGH,MAAa,kCAA0D;CACrE,MAAM,EAAE,mBAAmB,6BAA6B,oBAAoB;AAC5E,QAAO;EAAE;EAAmB;EAA0B"}
1
+ {"version":3,"file":"FocusDictionaryContext.cjs","names":["useEditorStateManager","NodeTypes"],"sources":["../../src/FocusDictionaryContext.tsx"],"sourcesContent":["'use client';\n\nimport type { FileContent } from '@intlayer/editor';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useState,\n} 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\ntype FocusDictionaryContextType = FocusDictionaryState & FocusDictionaryActions;\n\n// Create native React context fallback\nconst FocusDictionaryReactContext = createContext<\n FocusDictionaryContextType | undefined\n>(undefined);\n\n// Create the Provider\nexport const FocusDictionaryProvider: FC<PropsWithChildren> = ({\n children,\n}) => {\n const manager = useEditorStateManager();\n const [fallbackContent, setFallbackContent] = useState<FileContent | null>(\n null\n );\n\n const setFocusedContent = useCallback(\n (value: FileContent | null) => {\n if (manager) {\n manager.focusedContent.set(value);\n } else {\n setFallbackContent(value);\n }\n },\n [manager]\n );\n\n const setFocusedContentKeyPath = useCallback(\n (keyPath: KeyPath[]) => {\n if (manager) {\n manager.setFocusedContentKeyPath(keyPath);\n } else {\n setFallbackContent((prev) => {\n if (!prev) return null;\n const filtered = keyPath.filter(\n (key) => key.type !== NodeTypes.TRANSLATION\n );\n return { ...prev, keyPath: filtered };\n });\n }\n },\n [manager]\n );\n\n return (\n <FocusDictionaryReactContext.Provider\n value={{\n focusedContent: manager?.focusedContent.value ?? fallbackContent,\n setFocusedContent,\n setFocusedContentKeyPath,\n }}\n >\n {children}\n </FocusDictionaryReactContext.Provider>\n );\n};\n\n// 3. Update the hook to consume the fallback context\nexport const useFocusDictionary = (): FocusDictionaryState &\n FocusDictionaryActions => {\n const manager = useEditorStateManager();\n const reactContext = useContext(FocusDictionaryReactContext);\n\n const [focusedContent, setFocusedContentState] = useState<FileContent | null>(\n manager?.focusedContent.value ?? reactContext?.focusedContent ?? null\n );\n\n useEffect(() => {\n if (!manager) {\n setFocusedContentState(reactContext?.focusedContent ?? null);\n return;\n }\n\n const handler = (e: Event) =>\n setFocusedContentState((e as CustomEvent<FileContent | null>).detail);\n manager.focusedContent.addEventListener('change', handler);\n\n return () => manager.focusedContent.removeEventListener('change', handler);\n }, [manager, reactContext?.focusedContent]);\n\n const setFocusedContent = useCallback(\n (value: FileContent | null) => {\n if (reactContext) {\n reactContext.setFocusedContent(value);\n } else if (manager) {\n manager.focusedContent.set(value);\n }\n },\n [reactContext, manager]\n );\n\n const setFocusedContentKeyPath = useCallback(\n (keyPath: KeyPath[]) => {\n if (reactContext) {\n reactContext.setFocusedContentKeyPath(keyPath);\n } else if (manager) {\n manager.setFocusedContentKeyPath(keyPath);\n }\n },\n [reactContext, manager]\n );\n\n return {\n focusedContent,\n setFocusedContent,\n setFocusedContentKeyPath,\n };\n};\n\nexport const useFocusDictionaryActions = (): FocusDictionaryActions => {\n const { setFocusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n return { setFocusedContent, setFocusedContentKeyPath };\n};\n"],"mappings":";;;;;;;;;;;AA8BA,MAAM,uDAEJ,OAAU;AAGZ,MAAa,2BAAkD,EAC7D,eACI;CACJ,MAAM,UAAUA,kDAAuB;CACvC,MAAM,CAAC,iBAAiB,0CACtB,KACD;CAED,MAAM,4CACH,UAA8B;EAC7B,IAAI,SACF,QAAQ,eAAe,IAAI,MAAM;OAEjC,mBAAmB,MAAM;IAG7B,CAAC,QAAQ,CACV;CAED,MAAM,mDACH,YAAuB;EACtB,IAAI,SACF,QAAQ,yBAAyB,QAAQ;OAEzC,oBAAoB,SAAS;GAC3B,IAAI,CAAC,MAAM,OAAO;GAClB,MAAM,WAAW,QAAQ,QACtB,QAAQ,IAAI,SAASC,yBAAU,YACjC;GACD,OAAO;IAAE,GAAG;IAAM,SAAS;IAAU;IACrC;IAGN,CAAC,QAAQ,CACV;CAED,OACE,2CAAC,4BAA4B,UAA7B;EACE,OAAO;GACL,gBAAgB,SAAS,eAAe,SAAS;GACjD;GACA;GACD;EAEA;EACoC;;AAK3C,MAAa,2BACe;CAC1B,MAAM,UAAUD,kDAAuB;CACvC,MAAM,qCAA0B,4BAA4B;CAE5D,MAAM,CAAC,gBAAgB,8CACrB,SAAS,eAAe,SAAS,cAAc,kBAAkB,KAClE;CAED,2BAAgB;EACd,IAAI,CAAC,SAAS;GACZ,uBAAuB,cAAc,kBAAkB,KAAK;GAC5D;;EAGF,MAAM,WAAW,MACf,uBAAwB,EAAsC,OAAO;EACvE,QAAQ,eAAe,iBAAiB,UAAU,QAAQ;EAE1D,aAAa,QAAQ,eAAe,oBAAoB,UAAU,QAAQ;IACzE,CAAC,SAAS,cAAc,eAAe,CAAC;CAwB3C,OAAO;EACL;EACA,2CAvBC,UAA8B;GAC7B,IAAI,cACF,aAAa,kBAAkB,MAAM;QAChC,IAAI,SACT,QAAQ,eAAe,IAAI,MAAM;KAGrC,CAAC,cAAc,QAAQ,CAgBN;EACjB,kDAbC,YAAuB;GACtB,IAAI,cACF,aAAa,yBAAyB,QAAQ;QACzC,IAAI,SACT,QAAQ,yBAAyB,QAAQ;KAG7C,CAAC,cAAc,QAAQ,CAMC;EACzB;;AAGH,MAAa,kCAA0D;CACrE,MAAM,EAAE,mBAAmB,6BAA6B,oBAAoB;CAC5E,OAAO;EAAE;EAAmB;EAA0B"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCrossFrameMessageListener.cjs","names":["useEditorStateManager"],"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":";;;;;;;;;;;;;;AAYA,MAAa,gCACX,KACA,kBACA,gBACG;CACH,MAAM,UAAUA,kDAAuB;AAEvC,4BAAgB;AACd,MAAI,CAAC,iBAAkB;AACvB,SAAO,SAAS,UAAU,UAAa,KAAK,iBAAiB;IAC5D;EAAC;EAAS;EAAK;EAAY,CAAC;AAE/B,SAAQ,SAAa;AACnB,WAAS,UAAU,KAAK,KAAK,KAAK"}
1
+ {"version":3,"file":"useCrossFrameMessageListener.cjs","names":["useEditorStateManager"],"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":";;;;;;;;;;;;;;AAYA,MAAa,gCACX,KACA,kBACA,gBACG;CACH,MAAM,UAAUA,kDAAuB;CAEvC,2BAAgB;EACd,IAAI,CAAC,kBAAkB;EACvB,OAAO,SAAS,UAAU,UAAa,KAAK,iBAAiB;IAC5D;EAAC;EAAS;EAAK;EAAY,CAAC;CAE/B,QAAQ,SAAa;EACnB,SAAS,UAAU,KAAK,KAAK,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCrossFrameState.cjs","names":["useEditorStateManager","CrossFrameStateManager"],"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":";;;;;;;;;;;;AAqBA,MAAa,sBACX,KACA,cACA,YACiD;CACjD,MAAM,UAAUA,kDAAuB;CAEvC,MAAM,kBACJ,OAAO,iBAAiB,aACnB,cAA0B,GAC3B;CAEN,MAAM,CAAC,OAAO,qCAA6B,gBAAqB;CAChE,MAAM,6BAAqB,gBAAqB;CAEhD,MAAM,oCAA2D,KAAK;AAEtE,4BAAgB;EACd,MAAM,EAAE,OAAO,MAAM,UAAU,SAAS,WAAW,EAAE;EACrD,MAAM,eAAe,IAAIC,wCACvB,KACA,SAAS,WACT;GACE;GACA;GACA,cAAc;GACf,CACF;AACD,kBAAgB,UAAU;EAE1B,MAAM,WAAW,MAAa;GAC5B,MAAM,WAAY,EAAqB;AACvC,YAAS,UAAU;AACnB,iBAAc,SAAS;;AAEzB,eAAa,iBAAiB,UAAU,QAAQ;AAChD,eAAa,OAAO;AAEpB,eAAa;AACX,gBAAa,oBAAoB,UAAU,QAAQ;AACnD,gBAAa,MAAM;AACnB,mBAAgB,UAAU;;IAE3B;EAAC;EAAK,SAAS;EAAW,SAAS;EAAM,SAAS;EAAQ,CAAC;CAE9D,MAAM,YAAyC,mBAAmB;AAChE,iBAAe,SAAS;GACtB,MAAM,WACJ,OAAO,mBAAmB,aACrB,eAAkC,KAAK,GACxC;AACN,YAAS,UAAU;AACnB,mBAAgB,SAAS,IAAI,SAAS;AACtC,UAAO;IACP;;CAGJ,MAAM,kBAAkB;AACtB,kBAAgB,SAAS,kBAAkB;;AAG7C,QAAO;EAAC;EAAO;EAAU;EAAU"}
1
+ {"version":3,"file":"useCrossFrameState.cjs","names":["useEditorStateManager","CrossFrameStateManager"],"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":";;;;;;;;;;;;AAqBA,MAAa,sBACX,KACA,cACA,YACiD;CACjD,MAAM,UAAUA,kDAAuB;CAEvC,MAAM,kBACJ,OAAO,iBAAiB,aACnB,cAA0B,GAC3B;CAEN,MAAM,CAAC,OAAO,qCAA6B,gBAAqB;CAChE,MAAM,6BAAqB,gBAAqB;CAEhD,MAAM,oCAA2D,KAAK;CAEtE,2BAAgB;EACd,MAAM,EAAE,OAAO,MAAM,UAAU,SAAS,WAAW,EAAE;EACrD,MAAM,eAAe,IAAIC,wCACvB,KACA,SAAS,WACT;GACE;GACA;GACA,cAAc;GACf,CACF;EACD,gBAAgB,UAAU;EAE1B,MAAM,WAAW,MAAa;GAC5B,MAAM,WAAY,EAAqB;GACvC,SAAS,UAAU;GACnB,cAAc,SAAS;;EAEzB,aAAa,iBAAiB,UAAU,QAAQ;EAChD,aAAa,OAAO;EAEpB,aAAa;GACX,aAAa,oBAAoB,UAAU,QAAQ;GACnD,aAAa,MAAM;GACnB,gBAAgB,UAAU;;IAE3B;EAAC;EAAK,SAAS;EAAW,SAAS;EAAM,SAAS;EAAQ,CAAC;CAE9D,MAAM,YAAyC,mBAAmB;EAChE,eAAe,SAAS;GACtB,MAAM,WACJ,OAAO,mBAAmB,aACrB,eAAkC,KAAK,GACxC;GACN,SAAS,UAAU;GACnB,gBAAgB,SAAS,IAAI,SAAS;GACtC,OAAO;IACP;;CAGJ,MAAM,kBAAkB;EACtB,gBAAgB,SAAS,kBAAkB;;CAG7C,OAAO;EAAC;EAAO;EAAU;EAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCrossURLPathState.cjs","names":["useCrossFrameState","MessageKey"],"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":";;;;;;;;AAQA,MAAa,wBACX,cACA,YACGA,8CAAmBC,4BAAW,qBAAqB,cAAc,QAAQ;AAE9E,MAAa,yBAAyB,iBAA0B;AAG9D,QAAO,qBAAqB,cAAc;EAAE,MAAM;EAAM,SAAS;EAAO,CAAC"}
1
+ {"version":3,"file":"useCrossURLPathState.cjs","names":["useCrossFrameState","MessageKey"],"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":";;;;;;;;AAQA,MAAa,wBACX,cACA,YACGA,8CAAmBC,4BAAW,qBAAqB,cAAc,QAAQ;AAE9E,MAAa,yBAAyB,iBAA0B;CAG9D,OAAO,qBAAqB,cAAc;EAAE,MAAM;EAAM,SAAS;EAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useEditorLocale.cjs","names":["useEditorStateManager"],"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":";;;;;;;;AAMA,MAAa,wBAA4C;CACvD,MAAM,UAAUA,kDAAuB;CACvC,MAAM,CAAC,QAAQ,iCACb,SAAS,cAAc,MACxB;AAED,4BAAgB;AACd,MAAI,CAAC,QAAS;EAEd,MAAM,WAAW,MAAa,UAAW,EAA0B,OAAO;AAC1E,UAAQ,cAAc,iBAAiB,UAAU,QAAQ;AAEzD,eAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,QAAQ,CAAC;AAEb,QAAO;;AAGT,MAAa,2BAA2B;CACtC,MAAM,UAAUA,kDAAuB;AACvC,SAAQ,WAAmB,SAAS,cAAc,IAAI,OAAO"}
1
+ {"version":3,"file":"useEditorLocale.cjs","names":["useEditorStateManager"],"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":";;;;;;;;AAMA,MAAa,wBAA4C;CACvD,MAAM,UAAUA,kDAAuB;CACvC,MAAM,CAAC,QAAQ,iCACb,SAAS,cAAc,MACxB;CAED,2BAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MAAa,UAAW,EAA0B,OAAO;EAC1E,QAAQ,cAAc,iBAAiB,UAAU,QAAQ;EAEzD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,QAAQ,CAAC;CAEb,OAAO;;AAGT,MAAa,2BAA2B;CACtC,MAAM,UAAUA,kDAAuB;CACvC,QAAQ,WAAmB,SAAS,cAAc,IAAI,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"useFocusUnmergedDictionary.cjs","names":["useDictionariesRecord","useEditorLocale","useFocusDictionary"],"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":";;;;;;;;;;;;;;;;AAqBA,MAAM,kCACJ,SACA,cACA,WACgC;AAIhC,MAAK,MAAM,cAAc,aACvB,KAAI;AAOF,wEALE,WAAW,SACX,WAAW,EAAE,EACb,OAGQ,CACR,QAAO;GAAE;GAAS,mBAAmB,WAAW;GAAS;SAErD;;AAMZ,MAAa,mCAAmC;CAC9C,MAAM,EAAE,uBAAuBA,yDAAuB;CACtD,MAAM,gBAAgBC,yCAAiB;CACvC,MAAM,EACJ,mBACA,0BACA,gBAAgB,yBACdC,mDAAoB;AAuBxB,QAAO;EACL,yCAtBuD;AACvD,OAAI,CAAC,qBAAsB,QAAO;AAClC,OAAI,CAAC,mBAAoB,QAAO;AAChC,OAAI,qBAAqB,kBAAmB,QAAO;GAEnD,MAAM,eAAe,OAAO,OAAO,mBAAmB,CAAC,QACpD,eAAe,WAAW,QAAQ,qBAAqB,cACzD;GAED,MAAM,kBAAkB,+BACtB,qBAAqB,WAAW,EAAE,EAClC,cACA,cACD;AAED,UAAO;IACL,GAAG;IACH,GAAG;IACJ;KACA;GAAC;GAAsB;GAAoB;GAAc,CAG5C;EACd;EACA;EACD"}
1
+ {"version":3,"file":"useFocusUnmergedDictionary.cjs","names":["useDictionariesRecord","useEditorLocale","useFocusDictionary"],"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":";;;;;;;;;;;;;;;;AAqBA,MAAM,kCACJ,SACA,cACA,WACgC;CAIhC,KAAK,MAAM,cAAc,cACvB,IAAI;EAOF,sEALE,WAAW,SACX,WAAW,EAAE,EACb,OAGQ,EACR,OAAO;GAAE;GAAS,mBAAmB,WAAW;GAAS;SAErD;;AAMZ,MAAa,mCAAmC;CAC9C,MAAM,EAAE,uBAAuBA,yDAAuB;CACtD,MAAM,gBAAgBC,yCAAiB;CACvC,MAAM,EACJ,mBACA,0BACA,gBAAgB,yBACdC,mDAAoB;CAuBxB,OAAO;EACL,yCAtBuD;GACvD,IAAI,CAAC,sBAAsB,OAAO;GAClC,IAAI,CAAC,oBAAoB,OAAO;GAChC,IAAI,qBAAqB,mBAAmB,OAAO;GAEnD,MAAM,eAAe,OAAO,OAAO,mBAAmB,CAAC,QACpD,eAAe,WAAW,QAAQ,qBAAqB,cACzD;GAED,MAAM,kBAAkB,+BACtB,qBAAqB,WAAW,EAAE,EAClC,cACA,cACD;GAED,OAAO;IACL,GAAG;IACH,GAAG;IACJ;KACA;GAAC;GAAsB;GAAoB;GAAc,CAG5C;EACd;EACA;EACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"useIframeClickInterceptor.cjs","names":["MessageKey","mergeIframeClick"],"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":";;;;;;;;;;;;;;AAWA,MAAa,kCAAkC;AAC7C,mEAAwCA,4BAAW,wBAAwB;;;;;;AAO7E,MAAa,6BAA6B;AACxC,mEACEA,4BAAW,yBACXC,kCACD"}
1
+ {"version":3,"file":"useIframeClickInterceptor.cjs","names":["MessageKey","mergeIframeClick"],"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":";;;;;;;;;;;;;;AAWA,MAAa,kCAAkC;CAC7C,kEAAwCA,4BAAW,wBAAwB;;;;;;AAO7E,MAAa,6BAA6B;CACxC,kEACEA,4BAAW,yBACXC,kCACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"CommunicatorContext.mjs","names":[],"sources":["../../src/CommunicatorContext.tsx"],"sourcesContent":["'use client';\n\nimport type { MessagePayload } from '@intlayer/editor';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type UseCrossPlatformStateProps = {\n postMessage: (payload: MessagePayload) => void;\n allowedOrigins?: string[];\n senderId: string;\n};\n\n/**\n * Returns the communicator API backed by the shared EditorStateManager messenger.\n */\nexport const useCommunicator = (): UseCrossPlatformStateProps => {\n const manager = useEditorStateManager();\n\n return {\n postMessage: (payload: MessagePayload) =>\n manager?.messenger.send(payload.type, payload.data),\n senderId: manager?.messenger.senderId ?? '',\n };\n};\n\n// Re-export type for backward compatibility\nexport type { MessengerConfig } from '@intlayer/editor';\n"],"mappings":";;;;;;;;AAcA,MAAa,wBAAoD;CAC/D,MAAM,UAAU,uBAAuB;AAEvC,QAAO;EACL,cAAc,YACZ,SAAS,UAAU,KAAK,QAAQ,MAAM,QAAQ,KAAK;EACrD,UAAU,SAAS,UAAU,YAAY;EAC1C"}
1
+ {"version":3,"file":"CommunicatorContext.mjs","names":[],"sources":["../../src/CommunicatorContext.tsx"],"sourcesContent":["'use client';\n\nimport type { MessagePayload } from '@intlayer/editor';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type UseCrossPlatformStateProps = {\n postMessage: (payload: MessagePayload) => void;\n allowedOrigins?: string[];\n senderId: string;\n};\n\n/**\n * Returns the communicator API backed by the shared EditorStateManager messenger.\n */\nexport const useCommunicator = (): UseCrossPlatformStateProps => {\n const manager = useEditorStateManager();\n\n return {\n postMessage: (payload: MessagePayload) =>\n manager?.messenger.send(payload.type, payload.data),\n senderId: manager?.messenger.senderId ?? '',\n };\n};\n\n// Re-export type for backward compatibility\nexport type { MessengerConfig } from '@intlayer/editor';\n"],"mappings":";;;;;;;;AAcA,MAAa,wBAAoD;CAC/D,MAAM,UAAU,uBAAuB;CAEvC,OAAO;EACL,cAAc,YACZ,SAAS,UAAU,KAAK,QAAQ,MAAM,QAAQ,KAAK;EACrD,UAAU,SAAS,UAAU,YAAY;EAC1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigurationContext.mjs","names":[],"sources":["../../src/ConfigurationContext.tsx"],"sourcesContent":["'use client';\n\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\n// 1. Create a native React context\nconst ConfigurationReactContext = createContext<IntlayerConfig | undefined>(\n undefined\n);\n\nexport type ConfigurationProviderProps = PropsWithChildren<{\n configuration?: IntlayerConfig;\n}>;\n\nexport const ConfigurationProvider: FC<ConfigurationProviderProps> = ({\n configuration,\n children,\n}) => {\n const manager = useEditorStateManager();\n\n useEffect(() => {\n if (!manager || !configuration) return;\n\n manager.configuration.set(configuration);\n }, [manager, configuration]);\n\n // 2. Wrap children in the native provider\n return (\n <ConfigurationReactContext.Provider value={configuration}>\n {children}\n </ConfigurationReactContext.Provider>\n );\n};\n\nexport const useConfiguration = (): IntlayerConfig | undefined => {\n const manager = useEditorStateManager();\n const reactConfig = useContext(ConfigurationReactContext); // 3. Consume native context\n\n const [config, setConfig] = useState<IntlayerConfig | undefined>(\n manager?.configuration.value ?? reactConfig\n );\n\n useEffect(() => {\n if (!manager) {\n setConfig(reactConfig);\n return;\n }\n\n const handler = (e: Event) => {\n const detail = (e as CustomEvent<IntlayerConfig>).detail;\n setConfig(detail ?? reactConfig);\n };\n\n manager.configuration.addEventListener('change', handler);\n return () => manager.configuration.removeEventListener('change', handler);\n }, [manager, reactConfig]);\n\n // Prefer event-driven config, fallback to React context config\n return config ?? reactConfig;\n};\n\nexport const useConfigurationState = () => {\n const manager = useEditorStateManager();\n const reactConfig = useContext(ConfigurationReactContext);\n\n const [config, setConfig] = useState<IntlayerConfig | undefined>(\n manager?.configuration.value ?? reactConfig\n );\n\n return [\n config ?? reactConfig,\n setConfig,\n () => manager?.configuration.postCurrentValue(),\n ] as const;\n};\n"],"mappings":";;;;;;;AAcA,MAAM,4BAA4B,cAChC,OACD;AAMD,MAAa,yBAAyD,EACpE,eACA,eACI;CACJ,MAAM,UAAU,uBAAuB;AAEvC,iBAAgB;AACd,MAAI,CAAC,WAAW,CAAC,cAAe;AAEhC,UAAQ,cAAc,IAAI,cAAc;IACvC,CAAC,SAAS,cAAc,CAAC;AAG5B,QACE,oBAAC,0BAA0B,UAA3B;EAAoC,OAAO;EACxC;EACkC;;AAIzC,MAAa,yBAAqD;CAChE,MAAM,UAAU,uBAAuB;CACvC,MAAM,cAAc,WAAW,0BAA0B;CAEzD,MAAM,CAAC,QAAQ,aAAa,SAC1B,SAAS,cAAc,SAAS,YACjC;AAED,iBAAgB;AACd,MAAI,CAAC,SAAS;AACZ,aAAU,YAAY;AACtB;;EAGF,MAAM,WAAW,MAAa;GAC5B,MAAM,SAAU,EAAkC;AAClD,aAAU,UAAU,YAAY;;AAGlC,UAAQ,cAAc,iBAAiB,UAAU,QAAQ;AACzD,eAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,SAAS,YAAY,CAAC;AAG1B,QAAO,UAAU;;AAGnB,MAAa,8BAA8B;CACzC,MAAM,UAAU,uBAAuB;CACvC,MAAM,cAAc,WAAW,0BAA0B;CAEzD,MAAM,CAAC,QAAQ,aAAa,SAC1B,SAAS,cAAc,SAAS,YACjC;AAED,QAAO;EACL,UAAU;EACV;QACM,SAAS,cAAc,kBAAkB;EAChD"}
1
+ {"version":3,"file":"ConfigurationContext.mjs","names":[],"sources":["../../src/ConfigurationContext.tsx"],"sourcesContent":["'use client';\n\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\n// 1. Create a native React context\nconst ConfigurationReactContext = createContext<IntlayerConfig | undefined>(\n undefined\n);\n\nexport type ConfigurationProviderProps = PropsWithChildren<{\n configuration?: IntlayerConfig;\n}>;\n\nexport const ConfigurationProvider: FC<ConfigurationProviderProps> = ({\n configuration,\n children,\n}) => {\n const manager = useEditorStateManager();\n\n useEffect(() => {\n if (!manager || !configuration) return;\n\n manager.configuration.set(configuration);\n }, [manager, configuration]);\n\n // 2. Wrap children in the native provider\n return (\n <ConfigurationReactContext.Provider value={configuration}>\n {children}\n </ConfigurationReactContext.Provider>\n );\n};\n\nexport const useConfiguration = (): IntlayerConfig | undefined => {\n const manager = useEditorStateManager();\n const reactConfig = useContext(ConfigurationReactContext); // 3. Consume native context\n\n const [config, setConfig] = useState<IntlayerConfig | undefined>(\n manager?.configuration.value ?? reactConfig\n );\n\n useEffect(() => {\n if (!manager) {\n setConfig(reactConfig);\n return;\n }\n\n const handler = (e: Event) => {\n const detail = (e as CustomEvent<IntlayerConfig>).detail;\n setConfig(detail ?? reactConfig);\n };\n\n manager.configuration.addEventListener('change', handler);\n return () => manager.configuration.removeEventListener('change', handler);\n }, [manager, reactConfig]);\n\n // Prefer event-driven config, fallback to React context config\n return config ?? reactConfig;\n};\n\nexport const useConfigurationState = () => {\n const manager = useEditorStateManager();\n const reactConfig = useContext(ConfigurationReactContext);\n\n const [config, setConfig] = useState<IntlayerConfig | undefined>(\n manager?.configuration.value ?? reactConfig\n );\n\n return [\n config ?? reactConfig,\n setConfig,\n () => manager?.configuration.postCurrentValue(),\n ] as const;\n};\n"],"mappings":";;;;;;;AAcA,MAAM,4BAA4B,cAChC,OACD;AAMD,MAAa,yBAAyD,EACpE,eACA,eACI;CACJ,MAAM,UAAU,uBAAuB;CAEvC,gBAAgB;EACd,IAAI,CAAC,WAAW,CAAC,eAAe;EAEhC,QAAQ,cAAc,IAAI,cAAc;IACvC,CAAC,SAAS,cAAc,CAAC;CAG5B,OACE,oBAAC,0BAA0B,UAA3B;EAAoC,OAAO;EACxC;EACkC;;AAIzC,MAAa,yBAAqD;CAChE,MAAM,UAAU,uBAAuB;CACvC,MAAM,cAAc,WAAW,0BAA0B;CAEzD,MAAM,CAAC,QAAQ,aAAa,SAC1B,SAAS,cAAc,SAAS,YACjC;CAED,gBAAgB;EACd,IAAI,CAAC,SAAS;GACZ,UAAU,YAAY;GACtB;;EAGF,MAAM,WAAW,MAAa;GAC5B,MAAM,SAAU,EAAkC;GAClD,UAAU,UAAU,YAAY;;EAGlC,QAAQ,cAAc,iBAAiB,UAAU,QAAQ;EACzD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,SAAS,YAAY,CAAC;CAG1B,OAAO,UAAU;;AAGnB,MAAa,8BAA8B;CACzC,MAAM,UAAU,uBAAuB;CACvC,MAAM,cAAc,WAAW,0BAA0B;CAEzD,MAAM,CAAC,QAAQ,aAAa,SAC1B,SAAS,cAAc,SAAS,YACjC;CAED,OAAO;EACL,UAAU;EACV;QACM,SAAS,cAAc,kBAAkB;EAChD"}
@@ -1 +1 @@
1
- {"version":3,"file":"DictionariesRecordContext.mjs","names":[],"sources":["../../src/DictionariesRecordContext.tsx"],"sourcesContent":["'use client';\n\nimport type { DictionaryContent } from '@intlayer/editor';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { useCallback, useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { DictionaryContent } from '@intlayer/editor';\n\ntype DictionariesRecordStatesContextType = {\n localeDictionaries: DictionaryContent;\n};\ntype DictionariesRecordActionsContextType = {\n setLocaleDictionaries: (value: DictionaryContent) => void;\n setLocaleDictionary: (dictionary: Dictionary) => void;\n};\n\nexport const useDictionariesRecord = (): DictionariesRecordStatesContextType &\n DictionariesRecordActionsContextType => {\n const manager = useEditorStateManager();\n const [localeDictionaries, setLocaleDictionariesState] =\n useState<DictionaryContent>(manager?.localeDictionaries.value ?? {});\n\n useEffect(() => {\n if (!manager) return;\n\n const handler = (e: Event) =>\n setLocaleDictionariesState(\n (e as CustomEvent<DictionaryContent>).detail ?? {}\n );\n\n manager.localeDictionaries.addEventListener('change', handler);\n\n return () =>\n manager.localeDictionaries.removeEventListener('change', handler);\n }, [manager]);\n\n const setLocaleDictionaries = useCallback(\n (value: DictionaryContent) => manager?.localeDictionaries.set(value),\n [manager]\n );\n\n const setLocaleDictionary = useCallback(\n (dictionary: Dictionary) => manager?.setLocaleDictionary(dictionary),\n [manager]\n );\n\n return { localeDictionaries, setLocaleDictionaries, setLocaleDictionary };\n};\n\nexport const useDictionariesRecordActions =\n (): DictionariesRecordActionsContextType => {\n const { setLocaleDictionaries, setLocaleDictionary } =\n useDictionariesRecord();\n return { setLocaleDictionaries, setLocaleDictionary };\n };\n"],"mappings":";;;;;;AAiBA,MAAa,8BAC6B;CACxC,MAAM,UAAU,uBAAuB;CACvC,MAAM,CAAC,oBAAoB,8BACzB,SAA4B,SAAS,mBAAmB,SAAS,EAAE,CAAC;AAEtE,iBAAgB;AACd,MAAI,CAAC,QAAS;EAEd,MAAM,WAAW,MACf,2BACG,EAAqC,UAAU,EAAE,CACnD;AAEH,UAAQ,mBAAmB,iBAAiB,UAAU,QAAQ;AAE9D,eACE,QAAQ,mBAAmB,oBAAoB,UAAU,QAAQ;IAClE,CAAC,QAAQ,CAAC;AAYb,QAAO;EAAE;EAAoB,uBAVC,aAC3B,UAA6B,SAAS,mBAAmB,IAAI,MAAM,EACpE,CAAC,QAAQ,CAQuC;EAAE,qBALxB,aACzB,eAA2B,SAAS,oBAAoB,WAAW,EACpE,CAAC,QAAQ,CAG4D;EAAE;;AAG3E,MAAa,qCACiC;CAC1C,MAAM,EAAE,uBAAuB,wBAC7B,uBAAuB;AACzB,QAAO;EAAE;EAAuB;EAAqB"}
1
+ {"version":3,"file":"DictionariesRecordContext.mjs","names":[],"sources":["../../src/DictionariesRecordContext.tsx"],"sourcesContent":["'use client';\n\nimport type { DictionaryContent } from '@intlayer/editor';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { useCallback, useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { DictionaryContent } from '@intlayer/editor';\n\ntype DictionariesRecordStatesContextType = {\n localeDictionaries: DictionaryContent;\n};\ntype DictionariesRecordActionsContextType = {\n setLocaleDictionaries: (value: DictionaryContent) => void;\n setLocaleDictionary: (dictionary: Dictionary) => void;\n};\n\nexport const useDictionariesRecord = (): DictionariesRecordStatesContextType &\n DictionariesRecordActionsContextType => {\n const manager = useEditorStateManager();\n const [localeDictionaries, setLocaleDictionariesState] =\n useState<DictionaryContent>(manager?.localeDictionaries.value ?? {});\n\n useEffect(() => {\n if (!manager) return;\n\n const handler = (e: Event) =>\n setLocaleDictionariesState(\n (e as CustomEvent<DictionaryContent>).detail ?? {}\n );\n\n manager.localeDictionaries.addEventListener('change', handler);\n\n return () =>\n manager.localeDictionaries.removeEventListener('change', handler);\n }, [manager]);\n\n const setLocaleDictionaries = useCallback(\n (value: DictionaryContent) => manager?.localeDictionaries.set(value),\n [manager]\n );\n\n const setLocaleDictionary = useCallback(\n (dictionary: Dictionary) => manager?.setLocaleDictionary(dictionary),\n [manager]\n );\n\n return { localeDictionaries, setLocaleDictionaries, setLocaleDictionary };\n};\n\nexport const useDictionariesRecordActions =\n (): DictionariesRecordActionsContextType => {\n const { setLocaleDictionaries, setLocaleDictionary } =\n useDictionariesRecord();\n return { setLocaleDictionaries, setLocaleDictionary };\n };\n"],"mappings":";;;;;;AAiBA,MAAa,8BAC6B;CACxC,MAAM,UAAU,uBAAuB;CACvC,MAAM,CAAC,oBAAoB,8BACzB,SAA4B,SAAS,mBAAmB,SAAS,EAAE,CAAC;CAEtE,gBAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MACf,2BACG,EAAqC,UAAU,EAAE,CACnD;EAEH,QAAQ,mBAAmB,iBAAiB,UAAU,QAAQ;EAE9D,aACE,QAAQ,mBAAmB,oBAAoB,UAAU,QAAQ;IAClE,CAAC,QAAQ,CAAC;CAYb,OAAO;EAAE;EAAoB,uBAVC,aAC3B,UAA6B,SAAS,mBAAmB,IAAI,MAAM,EACpE,CAAC,QAAQ,CAQuC;EAAE,qBALxB,aACzB,eAA2B,SAAS,oBAAoB,WAAW,EACpE,CAAC,QAAQ,CAG4D;EAAE;;AAG3E,MAAa,qCACiC;CAC1C,MAAM,EAAE,uBAAuB,wBAC7B,uBAAuB;CACzB,OAAO;EAAE;EAAuB;EAAqB"}
@@ -1 +1 @@
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":";;;;;;AA6CA,MAAa,gCAAiE;CAC5E,MAAM,UAAU,uBAAuB;AAEvC,QAAO;EACL,wBAAwB,UACtB,SAAS,cAAc,IAAI,MAAM;EACnC,sBAAsB,SACpB,SAAS,oBAAoB,KAAK;EACpC,mBACE,SACA,UACG,SAAS,iBAAiB,SAAS,MAAM;EAC9C,mBAAmB,SAAS,OAAO,SAAS,cAC1C,SAAS,WAAW,SAAS,OAAO,SAAS,UAAU;EACzD,sBAAsB,SAAS,QAAQ,YACrC,SAAS,cAAc,SAAS,QAAQ,QAAQ;EAClD,sBAAsB,SAAS,YAC7B,SAAS,cAAc,SAAS,QAAQ;EAC1C,uBAAuB,YAAY,SAAS,eAAe,QAAQ;EACnE,+BAA+B,YAAY,SAAS,aAAa,QAAQ;EACzE,0BAA0B,SAAS,iBAAiB;EACpD,wBAAwB,cAAc,YACpC,SAAS,gBAAgB,cAAc,QAAQ;EAClD;;AAGH,MAAa,yBAAyB;CACpC,MAAM,UAAU,uBAAuB;CACvC,MAAM,CAAC,eAAe,yBAAyB,SAE7C,SAAS,cAAc,MAAM;AAE/B,iBAAgB;AACd,MAAI,CAAC,QAAS;EACd,MAAM,WAAW,MACf,sBAAuB,EAAqC,OAAO;AACrE,UAAQ,cAAc,iBAAiB,UAAU,QAAQ;AACzD,eAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,QAAQ,CAAC;AAGb,QAAO;EAAE;EAAe,GADR,yBACkB;EAAE;;AAGtC,MAAa,6BACX,qBACG;CACH,MAAM,UAAU,uBAAuB;AACvC,iBAAgB;AACd,MAAI,CAAC,oBAAoB,CAAC,QAAS;AACnC,SAAO,QAAQ,UAAU,UACvB,wCACA,iBACD;IACA,CAAC,SAAS,iBAAiB,CAAC;;AAGjC,MAAa,iCAAiC;CAC5C,MAAM,UAAU,uBAAuB;AACvC,cAAa;AACX,WAAS,UAAU,KAAK,sCAAsC"}
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":";;;;;;AA6CA,MAAa,gCAAiE;CAC5E,MAAM,UAAU,uBAAuB;CAEvC,OAAO;EACL,wBAAwB,UACtB,SAAS,cAAc,IAAI,MAAM;EACnC,sBAAsB,SACpB,SAAS,oBAAoB,KAAK;EACpC,mBACE,SACA,UACG,SAAS,iBAAiB,SAAS,MAAM;EAC9C,mBAAmB,SAAS,OAAO,SAAS,cAC1C,SAAS,WAAW,SAAS,OAAO,SAAS,UAAU;EACzD,sBAAsB,SAAS,QAAQ,YACrC,SAAS,cAAc,SAAS,QAAQ,QAAQ;EAClD,sBAAsB,SAAS,YAC7B,SAAS,cAAc,SAAS,QAAQ;EAC1C,uBAAuB,YAAY,SAAS,eAAe,QAAQ;EACnE,+BAA+B,YAAY,SAAS,aAAa,QAAQ;EACzE,0BAA0B,SAAS,iBAAiB;EACpD,wBAAwB,cAAc,YACpC,SAAS,gBAAgB,cAAc,QAAQ;EAClD;;AAGH,MAAa,yBAAyB;CACpC,MAAM,UAAU,uBAAuB;CACvC,MAAM,CAAC,eAAe,yBAAyB,SAE7C,SAAS,cAAc,MAAM;CAE/B,gBAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,WAAW,MACf,sBAAuB,EAAqC,OAAO;EACrE,QAAQ,cAAc,iBAAiB,UAAU,QAAQ;EACzD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,QAAQ,CAAC;CAGb,OAAO;EAAE;EAAe,GADR,yBACkB;EAAE;;AAGtC,MAAa,6BACX,qBACG;CACH,MAAM,UAAU,uBAAuB;CACvC,gBAAgB;EACd,IAAI,CAAC,oBAAoB,CAAC,SAAS;EACnC,OAAO,QAAQ,UAAU,UACvB,wCACA,iBACD;IACA,CAAC,SAAS,iBAAiB,CAAC;;AAGjC,MAAa,iCAAiC;CAC5C,MAAM,UAAU,uBAAuB;CACvC,aAAa;EACX,SAAS,UAAU,KAAK,sCAAsC"}
@@ -1 +1 @@
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":";;;;;;;;;;;AAcA,MAAa,yBAAkD;CAC7D,MAAM,UAAU,uBAAuB;CACvC,MAAM,CAAC,SAAS,cAAc,SAC5B,SAAS,cAAc,SAAS,MACjC;AAED,iBAAgB;AACd,MAAI,CAAC,QAAS;EAEd,MAAM,WAAW,MACf,WAAY,EAA2B,OAAO;AAChD,UAAQ,cAAc,iBAAiB,UAAU,QAAQ;AACzD,eAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,QAAQ,CAAC;AAEb,QAAO,EAAE,SAAS;;;;;;;AAQpB,MAAa,4BAA4B,cAA2B;CAClE,MAAM,UAAU,uBAAuB;AAEvC,iBAAgB;AACd,MAAI,CAAC,UAAW;AAEhB,SAAO,SAAS,UAAU,UACxB,GAAG,WAAW,wBAAwB,OACtC,UACD;IACA,CAAC,SAAS,UAAU,CAAC;;;;;AAM1B,MAAa,kCAAkC;CAC7C,MAAM,UAAU,uBAAuB;AAEvC,SAAQ,UAAmB;AACzB,WAAS,cAAc,IAAI,MAAM;AACjC,WAAS,cAAc,kBAAkB;;;AAI7C,MAAa,8BAA8B;CACzC,MAAM,EAAE,YAAY,kBAAkB;CACtC,MAAM,UAAU,uBAAuB;CACvC,MAAM,UAAU,UAAmB,SAAS,cAAc,IAAI,MAAM;AAEpE,QAAO,CAAC,SAAS,OAAO;;;;;;AAO1B,MAAa,4BAA0C;CACrD,MAAM,UAAU,uBAAuB;AAEvC,cAAa,SAAS,YAAY"}
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":";;;;;;;;;;;AAcA,MAAa,yBAAkD;CAC7D,MAAM,UAAU,uBAAuB;CACvC,MAAM,CAAC,SAAS,cAAc,SAC5B,SAAS,cAAc,SAAS,MACjC;CAED,gBAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MACf,WAAY,EAA2B,OAAO;EAChD,QAAQ,cAAc,iBAAiB,UAAU,QAAQ;EACzD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,QAAQ,CAAC;CAEb,OAAO,EAAE,SAAS;;;;;;;AAQpB,MAAa,4BAA4B,cAA2B;CAClE,MAAM,UAAU,uBAAuB;CAEvC,gBAAgB;EACd,IAAI,CAAC,WAAW;EAEhB,OAAO,SAAS,UAAU,UACxB,GAAG,WAAW,wBAAwB,OACtC,UACD;IACA,CAAC,SAAS,UAAU,CAAC;;;;;AAM1B,MAAa,kCAAkC;CAC7C,MAAM,UAAU,uBAAuB;CAEvC,QAAQ,UAAmB;EACzB,SAAS,cAAc,IAAI,MAAM;EACjC,SAAS,cAAc,kBAAkB;;;AAI7C,MAAa,8BAA8B;CACzC,MAAM,EAAE,YAAY,kBAAkB;CACtC,MAAM,UAAU,uBAAuB;CACvC,MAAM,UAAU,UAAmB,SAAS,cAAc,IAAI,MAAM;CAEpE,OAAO,CAAC,SAAS,OAAO;;;;;;AAO1B,MAAa,4BAA0C;CACrD,MAAM,UAAU,uBAAuB;CAEvC,aAAa,SAAS,YAAY"}
@@ -1 +1 @@
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":";;;;;;;;;;;;AAsBA,MAAa,kBAA8D,EACzE,UACA,eACA,aACA,qBACI;CACJ,MAAM,aAAa,OAAkC,KAAK;AAE1D,KAAI,CAAC,WAAW,QAMd,YAAW,UAAU,IAAI,mBAAmB;EAC1C,MAAM;EACN,WAAW;GANX;GACA,eAAe;GAKW;EAC1B;EACD,CAAC;CAEJ,MAAM,UAAU,WAAW;AAE3B,iBAAgB;AACd,0BAAwB;AACxB,yBAAuB,QAAQ;AAE/B,UAAQ,OAAO;AACf,eAAa;AACX,WAAQ,MAAM;AACd,0BAAuB,KAAK;;IAE7B,CAAC,QAAQ,CAAC;AAEb,QACE,oBAAC,qBAAD;EAA8B;EAAU;EAA+B"}
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":";;;;;;;;;;;;AAsBA,MAAa,kBAA8D,EACzE,UACA,eACA,aACA,qBACI;CACJ,MAAM,aAAa,OAAkC,KAAK;CAE1D,IAAI,CAAC,WAAW,SAMd,WAAW,UAAU,IAAI,mBAAmB;EAC1C,MAAM;EACN,WAAW;GANX;GACA,eAAe;GAKW;EAC1B;EACD,CAAC;CAEJ,MAAM,UAAU,WAAW;CAE3B,gBAAgB;EACd,wBAAwB;EACxB,uBAAuB,QAAQ;EAE/B,QAAQ,OAAO;EACf,aAAa;GACX,QAAQ,MAAM;GACd,uBAAuB,KAAK;;IAE7B,CAAC,QAAQ,CAAC;CAEb,OACE,oBAAC,qBAAD;EAA8B;EAAU;EAA+B"}
@@ -49,8 +49,14 @@ const useFocusDictionary = () => {
49
49
  }, [manager, reactContext?.focusedContent]);
50
50
  return {
51
51
  focusedContent,
52
- setFocusedContent: reactContext?.setFocusedContent ?? (() => {}),
53
- setFocusedContentKeyPath: reactContext?.setFocusedContentKeyPath ?? (() => {})
52
+ setFocusedContent: useCallback((value) => {
53
+ if (reactContext) reactContext.setFocusedContent(value);
54
+ else if (manager) manager.focusedContent.set(value);
55
+ }, [reactContext, manager]),
56
+ setFocusedContentKeyPath: useCallback((keyPath) => {
57
+ if (reactContext) reactContext.setFocusedContentKeyPath(keyPath);
58
+ else if (manager) manager.setFocusedContentKeyPath(keyPath);
59
+ }, [reactContext, manager])
54
60
  };
55
61
  };
56
62
  const useFocusDictionaryActions = () => {
@@ -1 +1 @@
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 * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useState,\n} 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\ntype FocusDictionaryContextType = FocusDictionaryState & FocusDictionaryActions;\n\n// Create native React context fallback\nconst FocusDictionaryReactContext = createContext<\n FocusDictionaryContextType | undefined\n>(undefined);\n\n// Create the Provider\nexport const FocusDictionaryProvider: FC<PropsWithChildren> = ({\n children,\n}) => {\n const manager = useEditorStateManager();\n const [fallbackContent, setFallbackContent] = useState<FileContent | null>(\n null\n );\n\n const setFocusedContent = useCallback(\n (value: FileContent | null) => {\n if (manager) {\n manager.focusedContent.set(value);\n } else {\n setFallbackContent(value);\n }\n },\n [manager]\n );\n\n const setFocusedContentKeyPath = useCallback(\n (keyPath: KeyPath[]) => {\n if (manager) {\n manager.setFocusedContentKeyPath(keyPath);\n } else {\n setFallbackContent((prev) => {\n if (!prev) return null;\n const filtered = keyPath.filter(\n (key) => key.type !== NodeTypes.TRANSLATION\n );\n return { ...prev, keyPath: filtered };\n });\n }\n },\n [manager]\n );\n\n return (\n <FocusDictionaryReactContext.Provider\n value={{\n focusedContent: manager?.focusedContent.value ?? fallbackContent,\n setFocusedContent,\n setFocusedContentKeyPath,\n }}\n >\n {children}\n </FocusDictionaryReactContext.Provider>\n );\n};\n\n// 3. Update the hook to consume the fallback context\nexport const useFocusDictionary = (): FocusDictionaryState &\n FocusDictionaryActions => {\n const manager = useEditorStateManager();\n const reactContext = useContext(FocusDictionaryReactContext);\n\n const [focusedContent, setFocusedContentState] = useState<FileContent | null>(\n manager?.focusedContent.value ?? reactContext?.focusedContent ?? null\n );\n\n useEffect(() => {\n if (!manager) {\n setFocusedContentState(reactContext?.focusedContent ?? null);\n return;\n }\n\n const handler = (e: Event) =>\n setFocusedContentState((e as CustomEvent<FileContent | null>).detail);\n manager.focusedContent.addEventListener('change', handler);\n\n return () => manager.focusedContent.removeEventListener('change', handler);\n }, [manager, reactContext?.focusedContent]);\n\n return {\n focusedContent,\n setFocusedContent: reactContext?.setFocusedContent ?? (() => {}),\n setFocusedContentKeyPath:\n reactContext?.setFocusedContentKeyPath ?? (() => {}),\n };\n};\n\nexport const useFocusDictionaryActions = (): FocusDictionaryActions => {\n const { setFocusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n return { setFocusedContent, setFocusedContentKeyPath };\n};\n"],"mappings":";;;;;;;;AA8BA,MAAM,8BAA8B,cAElC,OAAU;AAGZ,MAAa,2BAAkD,EAC7D,eACI;CACJ,MAAM,UAAU,uBAAuB;CACvC,MAAM,CAAC,iBAAiB,sBAAsB,SAC5C,KACD;CAED,MAAM,oBAAoB,aACvB,UAA8B;AAC7B,MAAI,QACF,SAAQ,eAAe,IAAI,MAAM;MAEjC,oBAAmB,MAAM;IAG7B,CAAC,QAAQ,CACV;CAED,MAAM,2BAA2B,aAC9B,YAAuB;AACtB,MAAI,QACF,SAAQ,yBAAyB,QAAQ;MAEzC,qBAAoB,SAAS;AAC3B,OAAI,CAAC,KAAM,QAAO;GAClB,MAAM,WAAW,QAAQ,QACtB,QAAQ,IAAI,SAAS,UAAU,YACjC;AACD,UAAO;IAAE,GAAG;IAAM,SAAS;IAAU;IACrC;IAGN,CAAC,QAAQ,CACV;AAED,QACE,oBAAC,4BAA4B,UAA7B;EACE,OAAO;GACL,gBAAgB,SAAS,eAAe,SAAS;GACjD;GACA;GACD;EAEA;EACoC;;AAK3C,MAAa,2BACe;CAC1B,MAAM,UAAU,uBAAuB;CACvC,MAAM,eAAe,WAAW,4BAA4B;CAE5D,MAAM,CAAC,gBAAgB,0BAA0B,SAC/C,SAAS,eAAe,SAAS,cAAc,kBAAkB,KAClE;AAED,iBAAgB;AACd,MAAI,CAAC,SAAS;AACZ,0BAAuB,cAAc,kBAAkB,KAAK;AAC5D;;EAGF,MAAM,WAAW,MACf,uBAAwB,EAAsC,OAAO;AACvE,UAAQ,eAAe,iBAAiB,UAAU,QAAQ;AAE1D,eAAa,QAAQ,eAAe,oBAAoB,UAAU,QAAQ;IACzE,CAAC,SAAS,cAAc,eAAe,CAAC;AAE3C,QAAO;EACL;EACA,mBAAmB,cAAc,4BAA4B;EAC7D,0BACE,cAAc,mCAAmC;EACpD;;AAGH,MAAa,kCAA0D;CACrE,MAAM,EAAE,mBAAmB,6BAA6B,oBAAoB;AAC5E,QAAO;EAAE;EAAmB;EAA0B"}
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 * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useState,\n} 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\ntype FocusDictionaryContextType = FocusDictionaryState & FocusDictionaryActions;\n\n// Create native React context fallback\nconst FocusDictionaryReactContext = createContext<\n FocusDictionaryContextType | undefined\n>(undefined);\n\n// Create the Provider\nexport const FocusDictionaryProvider: FC<PropsWithChildren> = ({\n children,\n}) => {\n const manager = useEditorStateManager();\n const [fallbackContent, setFallbackContent] = useState<FileContent | null>(\n null\n );\n\n const setFocusedContent = useCallback(\n (value: FileContent | null) => {\n if (manager) {\n manager.focusedContent.set(value);\n } else {\n setFallbackContent(value);\n }\n },\n [manager]\n );\n\n const setFocusedContentKeyPath = useCallback(\n (keyPath: KeyPath[]) => {\n if (manager) {\n manager.setFocusedContentKeyPath(keyPath);\n } else {\n setFallbackContent((prev) => {\n if (!prev) return null;\n const filtered = keyPath.filter(\n (key) => key.type !== NodeTypes.TRANSLATION\n );\n return { ...prev, keyPath: filtered };\n });\n }\n },\n [manager]\n );\n\n return (\n <FocusDictionaryReactContext.Provider\n value={{\n focusedContent: manager?.focusedContent.value ?? fallbackContent,\n setFocusedContent,\n setFocusedContentKeyPath,\n }}\n >\n {children}\n </FocusDictionaryReactContext.Provider>\n );\n};\n\n// 3. Update the hook to consume the fallback context\nexport const useFocusDictionary = (): FocusDictionaryState &\n FocusDictionaryActions => {\n const manager = useEditorStateManager();\n const reactContext = useContext(FocusDictionaryReactContext);\n\n const [focusedContent, setFocusedContentState] = useState<FileContent | null>(\n manager?.focusedContent.value ?? reactContext?.focusedContent ?? null\n );\n\n useEffect(() => {\n if (!manager) {\n setFocusedContentState(reactContext?.focusedContent ?? null);\n return;\n }\n\n const handler = (e: Event) =>\n setFocusedContentState((e as CustomEvent<FileContent | null>).detail);\n manager.focusedContent.addEventListener('change', handler);\n\n return () => manager.focusedContent.removeEventListener('change', handler);\n }, [manager, reactContext?.focusedContent]);\n\n const setFocusedContent = useCallback(\n (value: FileContent | null) => {\n if (reactContext) {\n reactContext.setFocusedContent(value);\n } else if (manager) {\n manager.focusedContent.set(value);\n }\n },\n [reactContext, manager]\n );\n\n const setFocusedContentKeyPath = useCallback(\n (keyPath: KeyPath[]) => {\n if (reactContext) {\n reactContext.setFocusedContentKeyPath(keyPath);\n } else if (manager) {\n manager.setFocusedContentKeyPath(keyPath);\n }\n },\n [reactContext, manager]\n );\n\n return {\n focusedContent,\n setFocusedContent,\n setFocusedContentKeyPath,\n };\n};\n\nexport const useFocusDictionaryActions = (): FocusDictionaryActions => {\n const { setFocusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n return { setFocusedContent, setFocusedContentKeyPath };\n};\n"],"mappings":";;;;;;;;AA8BA,MAAM,8BAA8B,cAElC,OAAU;AAGZ,MAAa,2BAAkD,EAC7D,eACI;CACJ,MAAM,UAAU,uBAAuB;CACvC,MAAM,CAAC,iBAAiB,sBAAsB,SAC5C,KACD;CAED,MAAM,oBAAoB,aACvB,UAA8B;EAC7B,IAAI,SACF,QAAQ,eAAe,IAAI,MAAM;OAEjC,mBAAmB,MAAM;IAG7B,CAAC,QAAQ,CACV;CAED,MAAM,2BAA2B,aAC9B,YAAuB;EACtB,IAAI,SACF,QAAQ,yBAAyB,QAAQ;OAEzC,oBAAoB,SAAS;GAC3B,IAAI,CAAC,MAAM,OAAO;GAClB,MAAM,WAAW,QAAQ,QACtB,QAAQ,IAAI,SAAS,UAAU,YACjC;GACD,OAAO;IAAE,GAAG;IAAM,SAAS;IAAU;IACrC;IAGN,CAAC,QAAQ,CACV;CAED,OACE,oBAAC,4BAA4B,UAA7B;EACE,OAAO;GACL,gBAAgB,SAAS,eAAe,SAAS;GACjD;GACA;GACD;EAEA;EACoC;;AAK3C,MAAa,2BACe;CAC1B,MAAM,UAAU,uBAAuB;CACvC,MAAM,eAAe,WAAW,4BAA4B;CAE5D,MAAM,CAAC,gBAAgB,0BAA0B,SAC/C,SAAS,eAAe,SAAS,cAAc,kBAAkB,KAClE;CAED,gBAAgB;EACd,IAAI,CAAC,SAAS;GACZ,uBAAuB,cAAc,kBAAkB,KAAK;GAC5D;;EAGF,MAAM,WAAW,MACf,uBAAwB,EAAsC,OAAO;EACvE,QAAQ,eAAe,iBAAiB,UAAU,QAAQ;EAE1D,aAAa,QAAQ,eAAe,oBAAoB,UAAU,QAAQ;IACzE,CAAC,SAAS,cAAc,eAAe,CAAC;CAwB3C,OAAO;EACL;EACA,mBAxBwB,aACvB,UAA8B;GAC7B,IAAI,cACF,aAAa,kBAAkB,MAAM;QAChC,IAAI,SACT,QAAQ,eAAe,IAAI,MAAM;KAGrC,CAAC,cAAc,QAAQ,CAgBN;EACjB,0BAd+B,aAC9B,YAAuB;GACtB,IAAI,cACF,aAAa,yBAAyB,QAAQ;QACzC,IAAI,SACT,QAAQ,yBAAyB,QAAQ;KAG7C,CAAC,cAAc,QAAQ,CAMC;EACzB;;AAGH,MAAa,kCAA0D;CACrE,MAAM,EAAE,mBAAmB,6BAA6B,oBAAoB;CAC5E,OAAO;EAAE;EAAmB;EAA0B"}
@@ -1 +1 @@
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":";;;;;;;;;;;;AAYA,MAAa,gCACX,KACA,kBACA,gBACG;CACH,MAAM,UAAU,uBAAuB;AAEvC,iBAAgB;AACd,MAAI,CAAC,iBAAkB;AACvB,SAAO,SAAS,UAAU,UAAa,KAAK,iBAAiB;IAC5D;EAAC;EAAS;EAAK;EAAY,CAAC;AAE/B,SAAQ,SAAa;AACnB,WAAS,UAAU,KAAK,KAAK,KAAK"}
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":";;;;;;;;;;;;AAYA,MAAa,gCACX,KACA,kBACA,gBACG;CACH,MAAM,UAAU,uBAAuB;CAEvC,gBAAgB;EACd,IAAI,CAAC,kBAAkB;EACvB,OAAO,SAAS,UAAU,UAAa,KAAK,iBAAiB;IAC5D;EAAC;EAAS;EAAK;EAAY,CAAC;CAE/B,QAAQ,SAAa;EACnB,SAAS,UAAU,KAAK,KAAK,KAAK"}
@@ -1 +1 @@
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":";;;;;;;;;;AAqBA,MAAa,sBACX,KACA,cACA,YACiD;CACjD,MAAM,UAAU,uBAAuB;CAEvC,MAAM,kBACJ,OAAO,iBAAiB,aACnB,cAA0B,GAC3B;CAEN,MAAM,CAAC,OAAO,iBAAiB,SAAY,gBAAqB;CAChE,MAAM,WAAW,OAAU,gBAAqB;CAEhD,MAAM,kBAAkB,OAAyC,KAAK;AAEtE,iBAAgB;EACd,MAAM,EAAE,OAAO,MAAM,UAAU,SAAS,WAAW,EAAE;EACrD,MAAM,eAAe,IAAI,uBACvB,KACA,SAAS,WACT;GACE;GACA;GACA,cAAc;GACf,CACF;AACD,kBAAgB,UAAU;EAE1B,MAAM,WAAW,MAAa;GAC5B,MAAM,WAAY,EAAqB;AACvC,YAAS,UAAU;AACnB,iBAAc,SAAS;;AAEzB,eAAa,iBAAiB,UAAU,QAAQ;AAChD,eAAa,OAAO;AAEpB,eAAa;AACX,gBAAa,oBAAoB,UAAU,QAAQ;AACnD,gBAAa,MAAM;AACnB,mBAAgB,UAAU;;IAE3B;EAAC;EAAK,SAAS;EAAW,SAAS;EAAM,SAAS;EAAQ,CAAC;CAE9D,MAAM,YAAyC,mBAAmB;AAChE,iBAAe,SAAS;GACtB,MAAM,WACJ,OAAO,mBAAmB,aACrB,eAAkC,KAAK,GACxC;AACN,YAAS,UAAU;AACnB,mBAAgB,SAAS,IAAI,SAAS;AACtC,UAAO;IACP;;CAGJ,MAAM,kBAAkB;AACtB,kBAAgB,SAAS,kBAAkB;;AAG7C,QAAO;EAAC;EAAO;EAAU;EAAU"}
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":";;;;;;;;;;AAqBA,MAAa,sBACX,KACA,cACA,YACiD;CACjD,MAAM,UAAU,uBAAuB;CAEvC,MAAM,kBACJ,OAAO,iBAAiB,aACnB,cAA0B,GAC3B;CAEN,MAAM,CAAC,OAAO,iBAAiB,SAAY,gBAAqB;CAChE,MAAM,WAAW,OAAU,gBAAqB;CAEhD,MAAM,kBAAkB,OAAyC,KAAK;CAEtE,gBAAgB;EACd,MAAM,EAAE,OAAO,MAAM,UAAU,SAAS,WAAW,EAAE;EACrD,MAAM,eAAe,IAAI,uBACvB,KACA,SAAS,WACT;GACE;GACA;GACA,cAAc;GACf,CACF;EACD,gBAAgB,UAAU;EAE1B,MAAM,WAAW,MAAa;GAC5B,MAAM,WAAY,EAAqB;GACvC,SAAS,UAAU;GACnB,cAAc,SAAS;;EAEzB,aAAa,iBAAiB,UAAU,QAAQ;EAChD,aAAa,OAAO;EAEpB,aAAa;GACX,aAAa,oBAAoB,UAAU,QAAQ;GACnD,aAAa,MAAM;GACnB,gBAAgB,UAAU;;IAE3B;EAAC;EAAK,SAAS;EAAW,SAAS;EAAM,SAAS;EAAQ,CAAC;CAE9D,MAAM,YAAyC,mBAAmB;EAChE,eAAe,SAAS;GACtB,MAAM,WACJ,OAAO,mBAAmB,aACrB,eAAkC,KAAK,GACxC;GACN,SAAS,UAAU;GACnB,gBAAgB,SAAS,IAAI,SAAS;GACtC,OAAO;IACP;;CAGJ,MAAM,kBAAkB;EACtB,gBAAgB,SAAS,kBAAkB;;CAG7C,OAAO;EAAC;EAAO;EAAU;EAAU"}
@@ -1 +1 @@
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":";;;;;;AAQA,MAAa,wBACX,cACA,YACG,mBAAmB,WAAW,qBAAqB,cAAc,QAAQ;AAE9E,MAAa,yBAAyB,iBAA0B;AAG9D,QAAO,qBAAqB,cAAc;EAAE,MAAM;EAAM,SAAS;EAAO,CAAC"}
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":";;;;;;AAQA,MAAa,wBACX,cACA,YACG,mBAAmB,WAAW,qBAAqB,cAAc,QAAQ;AAE9E,MAAa,yBAAyB,iBAA0B;CAG9D,OAAO,qBAAqB,cAAc;EAAE,MAAM;EAAM,SAAS;EAAO,CAAC"}
@@ -1 +1 @@
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":";;;;;;AAMA,MAAa,wBAA4C;CACvD,MAAM,UAAU,uBAAuB;CACvC,MAAM,CAAC,QAAQ,aAAa,SAC1B,SAAS,cAAc,MACxB;AAED,iBAAgB;AACd,MAAI,CAAC,QAAS;EAEd,MAAM,WAAW,MAAa,UAAW,EAA0B,OAAO;AAC1E,UAAQ,cAAc,iBAAiB,UAAU,QAAQ;AAEzD,eAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,QAAQ,CAAC;AAEb,QAAO;;AAGT,MAAa,2BAA2B;CACtC,MAAM,UAAU,uBAAuB;AACvC,SAAQ,WAAmB,SAAS,cAAc,IAAI,OAAO"}
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":";;;;;;AAMA,MAAa,wBAA4C;CACvD,MAAM,UAAU,uBAAuB;CACvC,MAAM,CAAC,QAAQ,aAAa,SAC1B,SAAS,cAAc,MACxB;CAED,gBAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MAAa,UAAW,EAA0B,OAAO;EAC1E,QAAQ,cAAc,iBAAiB,UAAU,QAAQ;EAEzD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,QAAQ;IACxE,CAAC,QAAQ,CAAC;CAEb,OAAO;;AAGT,MAAa,2BAA2B;CACtC,MAAM,UAAU,uBAAuB;CACvC,QAAQ,WAAmB,SAAS,cAAc,IAAI,OAAO"}
@@ -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 { 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":";;;;;;;;;;;;;;AAqBA,MAAM,kCACJ,SACA,cACA,WACgC;AAIhC,MAAK,MAAM,cAAc,aACvB,KAAI;AAOF,MANe,wBACb,WAAW,SACX,WAAW,EAAE,EACb,OAGQ,CACR,QAAO;GAAE;GAAS,mBAAmB,WAAW;GAAS;SAErD;;AAMZ,MAAa,mCAAmC;CAC9C,MAAM,EAAE,uBAAuB,uBAAuB;CACtD,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,EACJ,mBACA,0BACA,gBAAgB,yBACd,oBAAoB;AAuBxB,QAAO;EACL,gBAtBqB,cAAkC;AACvD,OAAI,CAAC,qBAAsB,QAAO;AAClC,OAAI,CAAC,mBAAoB,QAAO;AAChC,OAAI,qBAAqB,kBAAmB,QAAO;GAEnD,MAAM,eAAe,OAAO,OAAO,mBAAmB,CAAC,QACpD,eAAe,WAAW,QAAQ,qBAAqB,cACzD;GAED,MAAM,kBAAkB,+BACtB,qBAAqB,WAAW,EAAE,EAClC,cACA,cACD;AAED,UAAO;IACL,GAAG;IACH,GAAG;IACJ;KACA;GAAC;GAAsB;GAAoB;GAAc,CAG5C;EACd;EACA;EACD"}
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":";;;;;;;;;;;;;;AAqBA,MAAM,kCACJ,SACA,cACA,WACgC;CAIhC,KAAK,MAAM,cAAc,cACvB,IAAI;EAOF,IANe,wBACb,WAAW,SACX,WAAW,EAAE,EACb,OAGQ,EACR,OAAO;GAAE;GAAS,mBAAmB,WAAW;GAAS;SAErD;;AAMZ,MAAa,mCAAmC;CAC9C,MAAM,EAAE,uBAAuB,uBAAuB;CACtD,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,EACJ,mBACA,0BACA,gBAAgB,yBACd,oBAAoB;CAuBxB,OAAO;EACL,gBAtBqB,cAAkC;GACvD,IAAI,CAAC,sBAAsB,OAAO;GAClC,IAAI,CAAC,oBAAoB,OAAO;GAChC,IAAI,qBAAqB,mBAAmB,OAAO;GAEnD,MAAM,eAAe,OAAO,OAAO,mBAAmB,CAAC,QACpD,eAAe,WAAW,QAAQ,qBAAqB,cACzD;GAED,MAAM,kBAAkB,+BACtB,qBAAqB,WAAW,EAAE,EAClC,cACA,cACD;GAED,OAAO;IACL,GAAG;IACH,GAAG;IACJ;KACA;GAAC;GAAsB;GAAoB;GAAc,CAG5C;EACd;EACA;EACD"}
@@ -1 +1 @@
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":";;;;;;;;;;;;AAWA,MAAa,kCAAkC;AAC7C,8BAAwC,WAAW,wBAAwB;;;;;;AAO7E,MAAa,6BAA6B;AACxC,8BACE,WAAW,yBACX,iBACD"}
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":";;;;;;;;;;;;AAWA,MAAa,kCAAkC;CAC7C,6BAAwC,WAAW,wBAAwB;;;;;;AAO7E,MAAa,6BAA6B;CACxC,6BACE,WAAW,yBACX,iBACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"FocusDictionaryContext.d.ts","names":[],"sources":["../../src/FocusDictionaryContext.tsx"],"mappings":";;;;;KAkBY,oBAAA;EACV,cAAA,EAAgB,aAAA;AAAA;AAAA,KAGN,sBAAA;EACV,iBAAA,GAAoB,KAAA,EAAO,aAAA;EAC3B,wBAAA,GAA2B,OAAA,EAAS,OAAA;AAAA;AAAA,cAWzB,uBAAA,EAAyB,EAAA,CAAG,iBAAA;AAAA,cAkD5B,kBAAA,QAAyB,oBAAA,GACpC,sBAAA;AAAA,cA6BW,yBAAA,QAAgC,sBAAA"}
1
+ {"version":3,"file":"FocusDictionaryContext.d.ts","names":[],"sources":["../../src/FocusDictionaryContext.tsx"],"mappings":";;;;;KAkBY,oBAAA;EACV,cAAA,EAAgB,aAAA;AAAA;AAAA,KAGN,sBAAA;EACV,iBAAA,GAAoB,KAAA,EAAO,aAAA;EAC3B,wBAAA,GAA2B,OAAA,EAAS,OAAA;AAAA;AAAA,cAWzB,uBAAA,EAAyB,EAAA,CAAG,iBAAA;AAAA,cAkD5B,kBAAA,QAAyB,oBAAA,GACpC,sBAAA;AAAA,cAkDW,yBAAA,QAAgC,sBAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/editor-react",
3
- "version": "8.9.2",
3
+ "version": "8.9.3",
4
4
  "private": false,
5
5
  "description": "Provides the states, contexts, hooks and components to interact with the Intlayer editor for a React application",
6
6
  "keywords": [
@@ -70,14 +70,14 @@
70
70
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
71
71
  },
72
72
  "dependencies": {
73
- "@intlayer/config": "8.9.2",
74
- "@intlayer/core": "8.9.2",
75
- "@intlayer/editor": "8.9.2",
76
- "@intlayer/types": "8.9.2",
77
- "@intlayer/unmerged-dictionaries-entry": "8.9.2"
73
+ "@intlayer/config": "8.9.3",
74
+ "@intlayer/core": "8.9.3",
75
+ "@intlayer/editor": "8.9.3",
76
+ "@intlayer/types": "8.9.3",
77
+ "@intlayer/unmerged-dictionaries-entry": "8.9.3"
78
78
  },
79
79
  "devDependencies": {
80
- "@types/node": "25.6.0",
80
+ "@types/node": "25.6.1",
81
81
  "@types/react": ">=16.0.0",
82
82
  "@types/react-dom": ">=16.0.0",
83
83
  "@utils/ts-config": "1.0.4",
@@ -86,7 +86,7 @@
86
86
  "react": ">=16.0.0",
87
87
  "react-dom": ">=16.0.0",
88
88
  "rimraf": "6.1.3",
89
- "tsdown": "0.21.10",
89
+ "tsdown": "0.22.00",
90
90
  "typescript": "6.0.3",
91
91
  "vitest": "4.1.5"
92
92
  },