@intlayer/editor-react 9.5.11 → 9.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/cjs/ConfigurationContext.cjs +10 -39
  2. package/dist/cjs/ConfigurationContext.cjs.map +1 -1
  3. package/dist/cjs/EditedContentContext.cjs +0 -17
  4. package/dist/cjs/EditedContentContext.cjs.map +1 -1
  5. package/dist/cjs/EditorEnabledContext.cjs +0 -32
  6. package/dist/cjs/EditorEnabledContext.cjs.map +1 -1
  7. package/dist/cjs/FocusDictionaryContext.cjs +11 -59
  8. package/dist/cjs/FocusDictionaryContext.cjs.map +1 -1
  9. package/dist/cjs/index.cjs +4 -20
  10. package/dist/cjs/useCrossFrameState.cjs +5 -50
  11. package/dist/cjs/useCrossFrameState.cjs.map +1 -1
  12. package/dist/cjs/useCrossURLPathState.cjs +4 -8
  13. package/dist/cjs/useCrossURLPathState.cjs.map +1 -1
  14. package/dist/cjs/useEditedContentPersistence.cjs +33 -0
  15. package/dist/cjs/useEditedContentPersistence.cjs.map +1 -0
  16. package/dist/cjs/useEditorLocale.cjs +0 -5
  17. package/dist/cjs/useEditorLocale.cjs.map +1 -1
  18. package/dist/esm/ConfigurationContext.mjs +12 -39
  19. package/dist/esm/ConfigurationContext.mjs.map +1 -1
  20. package/dist/esm/EditedContentContext.mjs +1 -16
  21. package/dist/esm/EditedContentContext.mjs.map +1 -1
  22. package/dist/esm/EditorEnabledContext.mjs +1 -30
  23. package/dist/esm/EditorEnabledContext.mjs.map +1 -1
  24. package/dist/esm/FocusDictionaryContext.mjs +13 -57
  25. package/dist/esm/FocusDictionaryContext.mjs.map +1 -1
  26. package/dist/esm/index.mjs +8 -10
  27. package/dist/esm/useCrossFrameState.mjs +6 -51
  28. package/dist/esm/useCrossFrameState.mjs.map +1 -1
  29. package/dist/esm/useCrossURLPathState.mjs +5 -8
  30. package/dist/esm/useCrossURLPathState.mjs.map +1 -1
  31. package/dist/esm/useEditedContentPersistence.mjs +32 -0
  32. package/dist/esm/useEditedContentPersistence.mjs.map +1 -0
  33. package/dist/esm/useEditorLocale.mjs +1 -5
  34. package/dist/esm/useEditorLocale.mjs.map +1 -1
  35. package/dist/types/ConfigurationContext.d.ts +3 -6
  36. package/dist/types/ConfigurationContext.d.ts.map +1 -1
  37. package/dist/types/EditedContentContext.d.ts +0 -6
  38. package/dist/types/EditedContentContext.d.ts.map +1 -1
  39. package/dist/types/EditorEnabledContext.d.ts +0 -11
  40. package/dist/types/EditorEnabledContext.d.ts.map +1 -1
  41. package/dist/types/FocusDictionaryContext.d.ts +6 -7
  42. package/dist/types/FocusDictionaryContext.d.ts.map +1 -1
  43. package/dist/types/index.d.ts +9 -11
  44. package/dist/types/useCrossFrameState.d.ts +2 -7
  45. package/dist/types/useCrossFrameState.d.ts.map +1 -1
  46. package/dist/types/useCrossURLPathState.d.ts +4 -3
  47. package/dist/types/useCrossURLPathState.d.ts.map +1 -1
  48. package/dist/types/useEditedContentPersistence.d.ts +8 -0
  49. package/dist/types/useEditedContentPersistence.d.ts.map +1 -0
  50. package/dist/types/useEditorLocale.d.ts +0 -1
  51. package/dist/types/useEditorLocale.d.ts.map +1 -1
  52. package/package.json +6 -6
  53. package/dist/cjs/CommunicatorContext.cjs +0 -20
  54. package/dist/cjs/CommunicatorContext.cjs.map +0 -1
  55. package/dist/cjs/_virtual/_rolldown/runtime.cjs +0 -28
  56. package/dist/cjs/useCrossFrameMessageListener.cjs +0 -31
  57. package/dist/cjs/useCrossFrameMessageListener.cjs.map +0 -1
  58. package/dist/cjs/useIframeClickInterceptor.cjs +0 -28
  59. package/dist/cjs/useIframeClickInterceptor.cjs.map +0 -1
  60. package/dist/esm/CommunicatorContext.mjs +0 -19
  61. package/dist/esm/CommunicatorContext.mjs.map +0 -1
  62. package/dist/esm/useCrossFrameMessageListener.mjs +0 -30
  63. package/dist/esm/useCrossFrameMessageListener.mjs.map +0 -1
  64. package/dist/esm/useIframeClickInterceptor.mjs +0 -26
  65. package/dist/esm/useIframeClickInterceptor.mjs.map +0 -1
  66. package/dist/types/CommunicatorContext.d.ts +0 -14
  67. package/dist/types/CommunicatorContext.d.ts.map +0 -1
  68. package/dist/types/useCrossFrameMessageListener.d.ts +0 -11
  69. package/dist/types/useCrossFrameMessageListener.d.ts.map +0 -1
  70. package/dist/types/useIframeClickInterceptor.d.ts +0 -15
  71. package/dist/types/useIframeClickInterceptor.d.ts.map +0 -1
@@ -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 as IntlayerConfig | undefined) ?? 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 as IntlayerConfig | undefined) ?? reactConfig\n );\n\n return [\n config ?? reactConfig,\n setConfig,\n () => manager?.configuration.postCurrentValue(),\n ] as const;\n};\n"],"mappings":";;;;;;;AAcA,MAAM,4BAA4B,cAChC,MACF;AAMA,MAAa,yBAAyD,EACpE,eACA,eACI;CACJ,MAAM,UAAU,sBAAsB;CAEtC,gBAAgB;EACd,IAAI,CAAC,WAAW,CAAC,eAAe;EAEhC,QAAQ,cAAc,IAAI,aAAa;CACzC,GAAG,CAAC,SAAS,aAAa,CAAC;CAG3B,OACE,oBAAC,0BAA0B,UAA3B;EAAoC,OAAO;EACxC;CACiC;AAExC;AAEA,MAAa,yBAAqD;CAChE,MAAM,UAAU,sBAAsB;CACtC,MAAM,cAAc,WAAW,yBAAyB;CAExD,MAAM,CAAC,QAAQ,aAAa,SACzB,SAAS,cAAc,SAAwC,WAClE;CAEA,gBAAgB;EACd,IAAI,CAAC,SAAS;GACZ,UAAU,WAAW;GACrB;EACF;EAEA,MAAM,WAAW,MAAa;GAC5B,MAAM,SAAU,EAAkC;GAClD,UAAU,UAAU,WAAW;EACjC;EAEA,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EACxD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,SAAS,WAAW,CAAC;CAGzB,OAAO,UAAU;AACnB;AAEA,MAAa,8BAA8B;CACzC,MAAM,UAAU,sBAAsB;CACtC,MAAM,cAAc,WAAW,yBAAyB;CAExD,MAAM,CAAC,QAAQ,aAAa,SACzB,SAAS,cAAc,SAAwC,WAClE;CAEA,OAAO;EACL,UAAU;EACV;QACM,SAAS,cAAc,iBAAiB;CAChD;AACF"}
1
+ {"version":3,"file":"ConfigurationContext.mjs","names":[],"sources":["../../src/ConfigurationContext.tsx"],"sourcesContent":["'use client';\n\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\n/**\n * Returns the Intlayer configuration held by the editor state manager.\n */\nexport const useConfiguration = (): IntlayerConfig | undefined => {\n const manager = useEditorStateManager();\n const [configuration, setConfiguration] = useState<\n IntlayerConfig | undefined\n >(manager?.configuration.value as IntlayerConfig | undefined);\n\n useEffect(() => {\n if (!manager) return;\n\n const handleChange = (event: Event) =>\n setConfiguration((event as CustomEvent<IntlayerConfig>).detail);\n\n manager.configuration.addEventListener('change', handleChange);\n\n return () =>\n manager.configuration.removeEventListener('change', handleChange);\n }, [manager]);\n\n return configuration;\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,yBAAqD;CAChE,MAAM,UAAU,sBAAsB;CACtC,MAAM,CAAC,eAAe,oBAAoB,SAExC,SAAS,cAAc,KAAmC;CAE5D,gBAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,gBAAgB,UACpB,iBAAkB,MAAsC,MAAM;EAEhE,QAAQ,cAAc,iBAAiB,UAAU,YAAY;EAE7D,aACE,QAAQ,cAAc,oBAAoB,UAAU,YAAY;CACpE,GAAG,CAAC,OAAO,CAAC;CAEZ,OAAO;AACT"}
@@ -14,8 +14,6 @@ const useEditedContentActions = () => {
14
14
  renameEditedContent: (localId, newKey, keyPath) => manager?.renameContent(localId, newKey, keyPath),
15
15
  removeEditedContent: (localId, keyPath) => manager?.removeContent(localId, keyPath),
16
16
  restoreEditedContent: (localId) => manager?.restoreContent(localId),
17
- clearEditedDictionaryContent: (localId) => manager?.clearContent(localId),
18
- clearEditedContent: () => manager?.clearAllContent(),
19
17
  getEditedContentValue: (localIdOrKey, keyPath) => manager?.getContentValue(localIdOrKey, keyPath)
20
18
  };
21
19
  };
@@ -33,20 +31,7 @@ const useEditedContent = () => {
33
31
  ...useEditedContentActions()
34
32
  };
35
33
  };
36
- const usePostEditedContentState = (onEventTriggered) => {
37
- const manager = useEditorStateManager();
38
- useEffect(() => {
39
- if (!onEventTriggered || !manager) return;
40
- return manager.messenger.subscribe(`INTLAYER_EDITED_CONTENT_CHANGED/post`, onEventTriggered);
41
- }, [manager, onEventTriggered]);
42
- };
43
- const useGetEditedContentState = () => {
44
- const manager = useEditorStateManager();
45
- return () => {
46
- manager?.messenger.send("INTLAYER_EDITED_CONTENT_CHANGED/get");
47
- };
48
- };
49
34
 
50
35
  //#endregion
51
- export { useEditedContent, useEditedContentActions, useGetEditedContentState, usePostEditedContentState };
36
+ export { useEditedContent, useEditedContentActions };
52
37
  //# sourceMappingURL=EditedContentContext.mjs.map
@@ -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,sBAAsB;CAEtC,OAAO;EACL,wBAAwB,UACtB,SAAS,cAAc,IAAI,KAAK;EAClC,sBAAsB,SACpB,SAAS,oBAAoB,IAAI;EACnC,mBACE,SACA,UACG,SAAS,iBAAiB,SAAS,KAAK;EAC7C,mBAAmB,SAAS,OAAO,SAAS,cAC1C,SAAS,WAAW,SAAS,OAAO,SAAS,SAAS;EACxD,sBAAsB,SAAS,QAAQ,YACrC,SAAS,cAAc,SAAS,QAAQ,OAAO;EACjD,sBAAsB,SAAS,YAC7B,SAAS,cAAc,SAAS,OAAO;EACzC,uBAAuB,YAAY,SAAS,eAAe,OAAO;EAClE,+BAA+B,YAAY,SAAS,aAAa,OAAO;EACxE,0BAA0B,SAAS,gBAAgB;EACnD,wBAAwB,cAAc,YACpC,SAAS,gBAAgB,cAAc,OAAO;CAClD;AACF;AAEA,MAAa,yBAAyB;CACpC,MAAM,UAAU,sBAAsB;CACtC,MAAM,CAAC,eAAe,yBAAyB,SAE7C,SAAS,cAAc,KAAK;CAE9B,gBAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,WAAW,MACf,sBAAuB,EAAqC,MAAM;EACpE,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EACxD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAGZ,OAAO;EAAE;EAAe,GADR,wBACiB;CAAE;AACrC;AAEA,MAAa,6BACX,qBACG;CACH,MAAM,UAAU,sBAAsB;CACtC,gBAAgB;EACd,IAAI,CAAC,oBAAoB,CAAC,SAAS;EACnC,OAAO,QAAQ,UAAU,UACvB,wCACA,gBACF;CACF,GAAG,CAAC,SAAS,gBAAgB,CAAC;AAChC;AAEA,MAAa,iCAAiC;CAC5C,MAAM,UAAU,sBAAsB;CACtC,aAAa;EACX,SAAS,UAAU,KAAK,qCAAqC;CAC/D;AACF"}
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 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 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"],"mappings":";;;;;;AA2CA,MAAa,gCAAiE;CAC5E,MAAM,UAAU,sBAAsB;CAEtC,OAAO;EACL,wBAAwB,UACtB,SAAS,cAAc,IAAI,KAAK;EAClC,sBAAsB,SACpB,SAAS,oBAAoB,IAAI;EACnC,mBACE,SACA,UACG,SAAS,iBAAiB,SAAS,KAAK;EAC7C,mBAAmB,SAAS,OAAO,SAAS,cAC1C,SAAS,WAAW,SAAS,OAAO,SAAS,SAAS;EACxD,sBAAsB,SAAS,QAAQ,YACrC,SAAS,cAAc,SAAS,QAAQ,OAAO;EACjD,sBAAsB,SAAS,YAC7B,SAAS,cAAc,SAAS,OAAO;EACzC,uBAAuB,YAAY,SAAS,eAAe,OAAO;EAClE,wBAAwB,cAAc,YACpC,SAAS,gBAAgB,cAAc,OAAO;CAClD;AACF;AAEA,MAAa,yBAAyB;CACpC,MAAM,UAAU,sBAAsB;CACtC,MAAM,CAAC,eAAe,yBAAyB,SAE7C,SAAS,cAAc,KAAK;CAE9B,gBAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,WAAW,MACf,sBAAuB,EAAqC,MAAM;EACpE,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EACxD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAGZ,OAAO;EAAE;EAAe,GADR,wBACiB;CAAE;AACrC"}
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { useEditorStateManager } from "./EditorStateContext.mjs";
4
4
  import { useEffect, useState } from "react";
5
- import { MessageKey } from "@intlayer/editor";
6
5
 
7
6
  //#region src/EditorEnabledContext.tsx
8
7
  /**
@@ -21,34 +20,6 @@ const useEditorEnabled = () => {
21
20
  return { enabled };
22
21
  };
23
22
  /**
24
- * Subscribes to incoming "get" requests for editor-enabled state and calls
25
- * the provided callback so the caller can respond.
26
- * Used by the editor side to respond when the client asks for the current state.
27
- */
28
- const useGetEditorEnabledState = (onRequest) => {
29
- const manager = useEditorStateManager();
30
- useEffect(() => {
31
- if (!onRequest) return;
32
- return manager?.messenger.subscribe(`${MessageKey.INTLAYER_EDITOR_ENABLED}/get`, onRequest);
33
- }, [manager, onRequest]);
34
- };
35
- /**
36
- * Returns a function that sets the editor-enabled state and broadcasts it.
37
- */
38
- const usePostEditorEnabledState = () => {
39
- const manager = useEditorStateManager();
40
- return (value) => {
41
- manager?.editorEnabled.set(value);
42
- manager?.editorEnabled.postCurrentValue();
43
- };
44
- };
45
- const useEditorEnabledState = () => {
46
- const { enabled } = useEditorEnabled();
47
- const manager = useEditorStateManager();
48
- const setter = (value) => manager?.editorEnabled.set(value);
49
- return [enabled, setter];
50
- };
51
- /**
52
23
  * Returns a function that re-pings the client via ARE_YOU_THERE.
53
24
  * Use this as the onClick for an "Enable Editor" / reconnect button.
54
25
  */
@@ -58,5 +29,5 @@ const useEditorPingClient = () => {
58
29
  };
59
30
 
60
31
  //#endregion
61
- export { useEditorEnabled, useEditorEnabledState, useEditorPingClient, useGetEditorEnabledState, usePostEditorEnabledState };
32
+ export { useEditorEnabled, useEditorPingClient };
62
33
  //# sourceMappingURL=EditorEnabledContext.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditorEnabledContext.mjs","names":[],"sources":["../../src/EditorEnabledContext.tsx"],"sourcesContent":["'use client';\n\nimport { MessageKey } from '@intlayer/editor';\nimport { 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,sBAAsB;CACtC,MAAM,CAAC,SAAS,cAAc,SAC5B,SAAS,cAAc,SAAS,KAClC;CAEA,gBAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MACf,WAAY,EAA2B,MAAM;EAC/C,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EACxD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAEZ,OAAO,EAAE,QAAQ;AACnB;;;;;;AAOA,MAAa,4BAA4B,cAA2B;CAClE,MAAM,UAAU,sBAAsB;CAEtC,gBAAgB;EACd,IAAI,CAAC,WAAW;EAEhB,OAAO,SAAS,UAAU,UACxB,GAAG,WAAW,wBAAwB,OACtC,SACF;CACF,GAAG,CAAC,SAAS,SAAS,CAAC;AACzB;;;;AAKA,MAAa,kCAAkC;CAC7C,MAAM,UAAU,sBAAsB;CAEtC,QAAQ,UAAmB;EACzB,SAAS,cAAc,IAAI,KAAK;EAChC,SAAS,cAAc,iBAAiB;CAC1C;AACF;AAEA,MAAa,8BAA8B;CACzC,MAAM,EAAE,YAAY,iBAAiB;CACrC,MAAM,UAAU,sBAAsB;CACtC,MAAM,UAAU,UAAmB,SAAS,cAAc,IAAI,KAAK;CAEnE,OAAO,CAAC,SAAS,MAAM;AACzB;;;;;AAMA,MAAa,4BAA0C;CACrD,MAAM,UAAU,sBAAsB;CAEtC,aAAa,SAAS,WAAW;AACnC"}
1
+ {"version":3,"file":"EditorEnabledContext.mjs","names":[],"sources":["../../src/EditorEnabledContext.tsx"],"sourcesContent":["'use client';\n\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 * 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":";;;;;;;;;;AAaA,MAAa,yBAAkD;CAC7D,MAAM,UAAU,sBAAsB;CACtC,MAAM,CAAC,SAAS,cAAc,SAC5B,SAAS,cAAc,SAAS,KAClC;CAEA,gBAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MACf,WAAY,EAA2B,MAAM;EAC/C,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EACxD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAEZ,OAAO,EAAE,QAAQ;AACnB;;;;;AAMA,MAAa,4BAA0C;CACrD,MAAM,UAAU,sBAAsB;CAEtC,aAAa,SAAS,WAAW;AACnC"}
@@ -1,72 +1,28 @@
1
1
  'use client';
2
2
 
3
3
  import { useEditorStateManager } from "./EditorStateContext.mjs";
4
- import { createContext, useCallback, useContext, useEffect, useState } from "react";
5
- import { jsx } from "react/jsx-runtime";
6
- import * as NodeTypes from "@intlayer/types/nodeType";
4
+ import { useCallback, useEffect, useState } from "react";
7
5
 
8
6
  //#region src/FocusDictionaryContext.tsx
9
- const FocusDictionaryReactContext = createContext(void 0);
10
- const FocusDictionaryProvider = ({ children }) => {
11
- const manager = useEditorStateManager();
12
- const [fallbackContent, setFallbackContent] = useState(null);
13
- const setFocusedContent = useCallback((value) => {
14
- if (manager) manager.focusedContent.set(value);
15
- else setFallbackContent(value);
16
- }, [manager]);
17
- const setFocusedContentKeyPath = useCallback((keyPath) => {
18
- if (manager) manager.setFocusedContentKeyPath(keyPath);
19
- else setFallbackContent((prev) => {
20
- if (!prev) return null;
21
- const filtered = keyPath.filter((key) => key.type !== NodeTypes.TRANSLATION);
22
- return {
23
- ...prev,
24
- keyPath: filtered
25
- };
26
- });
27
- }, [manager]);
28
- return /* @__PURE__ */ jsx(FocusDictionaryReactContext.Provider, {
29
- value: {
30
- focusedContent: manager?.focusedContent.value ?? fallbackContent,
31
- setFocusedContent,
32
- setFocusedContentKeyPath
33
- },
34
- children
35
- });
36
- };
7
+ /**
8
+ * Returns the content focused in the editor, shared with the client frame.
9
+ */
37
10
  const useFocusDictionary = () => {
38
11
  const manager = useEditorStateManager();
39
- const reactContext = useContext(FocusDictionaryReactContext);
40
- const [focusedContent, setFocusedContentState] = useState(manager?.focusedContent.value ?? reactContext?.focusedContent ?? null);
12
+ const [focusedContent, setFocusedContentState] = useState(manager?.focusedContent.value ?? null);
41
13
  useEffect(() => {
42
- if (!manager) {
43
- setFocusedContentState(reactContext?.focusedContent ?? null);
44
- return;
45
- }
46
- const handler = (e) => setFocusedContentState(e.detail);
47
- manager.focusedContent.addEventListener("change", handler);
48
- return () => manager.focusedContent.removeEventListener("change", handler);
49
- }, [manager, reactContext?.focusedContent]);
14
+ if (!manager) return;
15
+ const handleChange = (event) => setFocusedContentState(event.detail);
16
+ manager.focusedContent.addEventListener("change", handleChange);
17
+ return () => manager.focusedContent.removeEventListener("change", handleChange);
18
+ }, [manager]);
50
19
  return {
51
20
  focusedContent,
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])
60
- };
61
- };
62
- const useFocusDictionaryActions = () => {
63
- const { setFocusedContent, setFocusedContentKeyPath } = useFocusDictionary();
64
- return {
65
- setFocusedContent,
66
- setFocusedContentKeyPath
21
+ setFocusedContent: useCallback((value) => manager?.focusedContent.set(value), [manager]),
22
+ setFocusedContentKeyPath: useCallback((keyPath) => manager?.setFocusedContentKeyPath(keyPath), [manager])
67
23
  };
68
24
  };
69
25
 
70
26
  //#endregion
71
- export { FocusDictionaryProvider, useFocusDictionary, useFocusDictionaryActions };
27
+ export { useFocusDictionary };
72
28
  //# sourceMappingURL=FocusDictionaryContext.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"FocusDictionaryContext.mjs","names":[],"sources":["../../src/FocusDictionaryContext.tsx"],"sourcesContent":["'use client';\n\nimport type { CrossFrameStateAction, 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 /** Accepts a value or an updater — `setFocusedContent(prev => …)`. */\n setFocusedContent: (value: CrossFrameStateAction<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: CrossFrameStateAction<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: CrossFrameStateAction<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":";;;;;;;;AA+BA,MAAM,8BAA8B,cAElC,MAAS;AAGX,MAAa,2BAAkD,EAC7D,eACI;CACJ,MAAM,UAAU,sBAAsB;CACtC,MAAM,CAAC,iBAAiB,sBAAsB,SAC5C,IACF;CAEA,MAAM,oBAAoB,aACvB,UAAqD;EACpD,IAAI,SACF,QAAQ,eAAe,IAAI,KAAK;OAEhC,mBAAmB,KAAK;CAE5B,GACA,CAAC,OAAO,CACV;CAEA,MAAM,2BAA2B,aAC9B,YAAuB;EACtB,IAAI,SACF,QAAQ,yBAAyB,OAAO;OAExC,oBAAoB,SAAS;GAC3B,IAAI,CAAC,MAAM,OAAO;GAClB,MAAM,WAAW,QAAQ,QACtB,QAAQ,IAAI,SAAS,UAAU,WAClC;GACA,OAAO;IAAE,GAAG;IAAM,SAAS;GAAS;EACtC,CAAC;CAEL,GACA,CAAC,OAAO,CACV;CAEA,OACE,oBAAC,4BAA4B,UAA7B;EACE,OAAO;GACL,gBAAgB,SAAS,eAAe,SAAS;GACjD;GACA;EACF;EAEC;CACmC;AAE1C;AAGA,MAAa,2BACe;CAC1B,MAAM,UAAU,sBAAsB;CACtC,MAAM,eAAe,WAAW,2BAA2B;CAE3D,MAAM,CAAC,gBAAgB,0BAA0B,SAC/C,SAAS,eAAe,SAAS,cAAc,kBAAkB,IACnE;CAEA,gBAAgB;EACd,IAAI,CAAC,SAAS;GACZ,uBAAuB,cAAc,kBAAkB,IAAI;GAC3D;EACF;EAEA,MAAM,WAAW,MACf,uBAAwB,EAAsC,MAAM;EACtE,QAAQ,eAAe,iBAAiB,UAAU,OAAO;EAEzD,aAAa,QAAQ,eAAe,oBAAoB,UAAU,OAAO;CAC3E,GAAG,CAAC,SAAS,cAAc,cAAc,CAAC;CAwB1C,OAAO;EACL;EACA,mBAxBwB,aACvB,UAAqD;GACpD,IAAI,cACF,aAAa,kBAAkB,KAAK;QAC/B,IAAI,SACT,QAAQ,eAAe,IAAI,KAAK;EAEpC,GACA,CAAC,cAAc,OAAO,CAgBN;EAChB,0BAd+B,aAC9B,YAAuB;GACtB,IAAI,cACF,aAAa,yBAAyB,OAAO;QACxC,IAAI,SACT,QAAQ,yBAAyB,OAAO;EAE5C,GACA,CAAC,cAAc,OAAO,CAMC;CACzB;AACF;AAEA,MAAa,kCAA0D;CACrE,MAAM,EAAE,mBAAmB,6BAA6B,mBAAmB;CAC3E,OAAO;EAAE;EAAmB;CAAyB;AACvD"}
1
+ {"version":3,"file":"FocusDictionaryContext.mjs","names":[],"sources":["../../src/FocusDictionaryContext.tsx"],"sourcesContent":["'use client';\n\nimport type { CrossFrameStateAction, FileContent } from '@intlayer/editor';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { useCallback, useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { FileContent } from '@intlayer/editor';\n\nexport type FocusDictionaryActions = {\n /** Accepts a value or an updater — `setFocusedContent(prev => …)`. */\n setFocusedContent: (value: CrossFrameStateAction<FileContent | null>) => void;\n setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;\n};\n\n/**\n * Returns the content focused in the editor, shared with the client frame.\n */\nexport const useFocusDictionary = (): FocusDictionaryActions & {\n focusedContent: FileContent | null;\n} => {\n const manager = useEditorStateManager();\n const [focusedContent, setFocusedContentState] = useState<FileContent | null>(\n manager?.focusedContent.value ?? null\n );\n\n useEffect(() => {\n if (!manager) return;\n\n const handleChange = (event: Event) =>\n setFocusedContentState((event as CustomEvent<FileContent | null>).detail);\n manager.focusedContent.addEventListener('change', handleChange);\n\n return () =>\n manager.focusedContent.removeEventListener('change', handleChange);\n }, [manager]);\n\n const setFocusedContent = useCallback(\n (value: CrossFrameStateAction<FileContent | null>) =>\n manager?.focusedContent.set(value),\n [manager]\n );\n\n const setFocusedContentKeyPath = useCallback(\n (keyPath: KeyPath[]) => manager?.setFocusedContentKeyPath(keyPath),\n [manager]\n );\n\n return { focusedContent, setFocusedContent, setFocusedContentKeyPath };\n};\n"],"mappings":";;;;;;;;;AAkBA,MAAa,2BAER;CACH,MAAM,UAAU,sBAAsB;CACtC,MAAM,CAAC,gBAAgB,0BAA0B,SAC/C,SAAS,eAAe,SAAS,IACnC;CAEA,gBAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,gBAAgB,UACpB,uBAAwB,MAA0C,MAAM;EAC1E,QAAQ,eAAe,iBAAiB,UAAU,YAAY;EAE9D,aACE,QAAQ,eAAe,oBAAoB,UAAU,YAAY;CACrE,GAAG,CAAC,OAAO,CAAC;CAaZ,OAAO;EAAE;EAAgB,mBAXC,aACvB,UACC,SAAS,eAAe,IAAI,KAAK,GACnC,CAAC,OAAO,CAQ+B;EAAG,0BALX,aAC9B,YAAuB,SAAS,yBAAyB,OAAO,GACjE,CAAC,OAAO,CAGyD;CAAE;AACvE"}
@@ -1,17 +1,15 @@
1
1
  import { EditorStateProvider, useEditorStateManager } from "./EditorStateContext.mjs";
2
2
  import { useDictionariesRecord, useDictionariesRecordActions } from "./DictionariesRecordContext.mjs";
3
3
  import { useCrossFrameState } from "./useCrossFrameState.mjs";
4
- import { useCrossURLPathSetter, useCrossURLPathState } from "./useCrossURLPathState.mjs";
5
- import { useCrossFrameMessageListener } from "./useCrossFrameMessageListener.mjs";
6
- import { useIframeClickInterceptor, useIframeClickMerger } from "./useIframeClickInterceptor.mjs";
7
- import { useEditorLocale, useSetEditorLocale } from "./useEditorLocale.mjs";
8
- import { useCommunicator } from "./CommunicatorContext.mjs";
9
- import { ConfigurationProvider, useConfiguration, useConfigurationState } from "./ConfigurationContext.mjs";
10
- import { useEditedContent, useEditedContentActions, useGetEditedContentState, usePostEditedContentState } from "./EditedContentContext.mjs";
11
- import { useEditorEnabled, useEditorEnabledState, useEditorPingClient, useGetEditorEnabledState, usePostEditorEnabledState } from "./EditorEnabledContext.mjs";
4
+ import { useCrossURLPathState } from "./useCrossURLPathState.mjs";
5
+ import { useEditedContent, useEditedContentActions } from "./EditedContentContext.mjs";
6
+ import { useEditedContentPersistence } from "./useEditedContentPersistence.mjs";
7
+ import { useEditorLocale } from "./useEditorLocale.mjs";
8
+ import { useConfiguration } from "./ConfigurationContext.mjs";
9
+ import { useEditorEnabled, useEditorPingClient } from "./EditorEnabledContext.mjs";
12
10
  import { EditorProvider } from "./EditorProvider.mjs";
13
- import { FocusDictionaryProvider, useFocusDictionary, useFocusDictionaryActions } from "./FocusDictionaryContext.mjs";
11
+ import { useFocusDictionary } from "./FocusDictionaryContext.mjs";
14
12
  import { useFocusUnmergedDictionary } from "./useFocusUnmergedDictionary.mjs";
15
13
  import { MessageKey } from "@intlayer/editor";
16
14
 
17
- export { ConfigurationProvider, EditorProvider, EditorStateProvider, FocusDictionaryProvider, MessageKey, useCommunicator, useConfiguration, useConfigurationState, useCrossFrameMessageListener, useCrossFrameState, useCrossURLPathSetter, useCrossURLPathState, useDictionariesRecord, useDictionariesRecordActions, useEditedContent, useEditedContentActions, useEditorEnabled, useEditorEnabledState, useEditorLocale, useEditorPingClient, useEditorStateManager, useFocusDictionary, useFocusDictionaryActions, useFocusUnmergedDictionary, useGetEditedContentState, useGetEditorEnabledState, useIframeClickInterceptor, useIframeClickMerger, usePostEditedContentState, usePostEditorEnabledState, useSetEditorLocale };
15
+ export { EditorProvider, EditorStateProvider, MessageKey, useConfiguration, useCrossFrameState, useCrossURLPathState, useDictionariesRecord, useDictionariesRecordActions, useEditedContent, useEditedContentActions, useEditedContentPersistence, useEditorEnabled, useEditorLocale, useEditorPingClient, useEditorStateManager, useFocusDictionary, useFocusUnmergedDictionary };
@@ -1,62 +1,17 @@
1
1
  'use client';
2
2
 
3
3
  import { useEditorStateManager } from "./EditorStateContext.mjs";
4
- import { useEffect, useRef, useState } from "react";
5
- import { CrossFrameStateManager } from "@intlayer/editor";
4
+ import { useEffect, useState } from "react";
6
5
 
7
6
  //#region src/useCrossFrameState.tsx
8
7
  /**
9
- * Synchronizes a React state value across frames using CrossFrameStateManager.
8
+ * Returns the latest value another frame posted under `key`.
10
9
  */
11
- const useCrossFrameState = (key, initialState, options) => {
10
+ const useCrossFrameState = (key, initialValue) => {
12
11
  const manager = useEditorStateManager();
13
- const resolvedInitial = typeof initialState === "function" ? initialState() : initialState;
14
- const [value, setValueState] = useState(resolvedInitial);
15
- const valueRef = useRef(resolvedInitial);
16
- const stateManagerRef = useRef(null);
17
- useEffect(() => {
18
- const { emit = true, receive = true } = options ?? {};
19
- if (!manager?.messenger) return;
20
- const stateManager = new CrossFrameStateManager(key, manager?.messenger, {
21
- emit,
22
- receive,
23
- initialValue: resolvedInitial
24
- });
25
- stateManagerRef.current = stateManager;
26
- const handler = (e) => {
27
- const newValue = e.detail;
28
- valueRef.current = newValue;
29
- setValueState(newValue);
30
- };
31
- stateManager.addEventListener("change", handler);
32
- stateManager.start();
33
- return () => {
34
- stateManager.removeEventListener("change", handler);
35
- stateManager.stop();
36
- stateManagerRef.current = null;
37
- };
38
- }, [
39
- key,
40
- manager?.messenger,
41
- options?.emit,
42
- options?.receive
43
- ]);
44
- const setValue = (valueOrUpdater) => {
45
- setValueState((prev) => {
46
- const newValue = typeof valueOrUpdater === "function" ? valueOrUpdater(prev) : valueOrUpdater;
47
- valueRef.current = newValue;
48
- stateManagerRef.current?.set(newValue);
49
- return newValue;
50
- });
51
- };
52
- const postState = () => {
53
- stateManagerRef.current?.postCurrentValue();
54
- };
55
- return [
56
- value,
57
- setValue,
58
- postState
59
- ];
12
+ const [value, setValue] = useState(initialValue);
13
+ useEffect(() => manager?.messenger.subscribe(`${key}/post`, (postedValue) => setValue(() => postedValue)), [manager, key]);
14
+ return value;
60
15
  };
61
16
 
62
17
  //#endregion
@@ -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\n if (!manager?.messenger) return;\n\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,sBAAsB;CAEtC,MAAM,kBACJ,OAAO,iBAAiB,aACnB,aAAyB,IAC1B;CAEN,MAAM,CAAC,OAAO,iBAAiB,SAAY,eAAoB;CAC/D,MAAM,WAAW,OAAU,eAAoB;CAE/C,MAAM,kBAAkB,OAAyC,IAAI;CAErE,gBAAgB;EACd,MAAM,EAAE,OAAO,MAAM,UAAU,SAAS,WAAW,CAAC;EAEpD,IAAI,CAAC,SAAS,WAAW;EAEzB,MAAM,eAAe,IAAI,uBACvB,KACA,SAAS,WACT;GACE;GACA;GACA,cAAc;EAChB,CACF;EACA,gBAAgB,UAAU;EAE1B,MAAM,WAAW,MAAa;GAC5B,MAAM,WAAY,EAAqB;GACvC,SAAS,UAAU;GACnB,cAAc,QAAQ;EACxB;EACA,aAAa,iBAAiB,UAAU,OAAO;EAC/C,aAAa,MAAM;EAEnB,aAAa;GACX,aAAa,oBAAoB,UAAU,OAAO;GAClD,aAAa,KAAK;GAClB,gBAAgB,UAAU;EAC5B;CACF,GAAG;EAAC;EAAK,SAAS;EAAW,SAAS;EAAM,SAAS;CAAO,CAAC;CAE7D,MAAM,YAAyC,mBAAmB;EAChE,eAAe,SAAS;GACtB,MAAM,WACJ,OAAO,mBAAmB,aACrB,eAAkC,IAAI,IACvC;GACN,SAAS,UAAU;GACnB,gBAAgB,SAAS,IAAI,QAAQ;GACrC,OAAO;EACT,CAAC;CACH;CAEA,MAAM,kBAAkB;EACtB,gBAAgB,SAAS,iBAAiB;CAC5C;CAEA,OAAO;EAAC;EAAO;EAAU;CAAS;AACpC"}
1
+ {"version":3,"file":"useCrossFrameState.mjs","names":[],"sources":["../../src/useCrossFrameState.tsx"],"sourcesContent":["'use client';\n\nimport type { MessageKey } from '@intlayer/editor';\nimport { useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\n/**\n * Returns the latest value another frame posted under `key`.\n */\nexport const useCrossFrameState = <Value,>(\n key: `${MessageKey}`,\n initialValue: Value\n): Value => {\n const manager = useEditorStateManager();\n const [value, setValue] = useState<Value>(initialValue);\n\n useEffect(\n () =>\n manager?.messenger.subscribe<Value>(`${key}/post`, (postedValue) =>\n setValue(() => postedValue)\n ),\n [manager, key]\n );\n\n return value;\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,sBACX,KACA,iBACU;CACV,MAAM,UAAU,sBAAsB;CACtC,MAAM,CAAC,OAAO,YAAY,SAAgB,YAAY;CAEtD,gBAEI,SAAS,UAAU,UAAiB,GAAG,IAAI,SAAS,gBAClD,eAAe,WAAW,CAC5B,GACF,CAAC,SAAS,GAAG,CACf;CAEA,OAAO;AACT"}
@@ -4,14 +4,11 @@ import { useCrossFrameState } from "./useCrossFrameState.mjs";
4
4
  import { MessageKey } from "@intlayer/editor";
5
5
 
6
6
  //#region src/useCrossURLPathState.tsx
7
- const useCrossURLPathState = (initialState, options) => useCrossFrameState(MessageKey.INTLAYER_URL_CHANGE, initialState, options);
8
- const useCrossURLPathSetter = (initialState) => {
9
- return useCrossURLPathState(initialState, {
10
- emit: true,
11
- receive: false
12
- });
13
- };
7
+ /**
8
+ * Returns the path currently displayed by the client application.
9
+ */
10
+ const useCrossURLPathState = () => useCrossFrameState(MessageKey.INTLAYER_URL_CHANGE, void 0);
14
11
 
15
12
  //#endregion
16
- export { useCrossURLPathSetter, useCrossURLPathState };
13
+ export { useCrossURLPathState };
17
14
  //# sourceMappingURL=useCrossURLPathState.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCrossURLPathState.mjs","names":[],"sources":["../../src/useCrossURLPathState.tsx"],"sourcesContent":["'use client';\n\nimport { MessageKey } from '@intlayer/editor';\nimport {\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,OAAO;AAE7E,MAAa,yBAAyB,iBAA0B;CAG9D,OAAO,qBAAqB,cAAc;EAAE,MAAM;EAAM,SAAS;CAAM,CAAC;AAC1E"}
1
+ {"version":3,"file":"useCrossURLPathState.mjs","names":[],"sources":["../../src/useCrossURLPathState.tsx"],"sourcesContent":["'use client';\n\nimport { MessageKey } from '@intlayer/editor';\nimport { useCrossFrameState } from './useCrossFrameState';\n\n/**\n * Returns the path currently displayed by the client application.\n */\nexport const useCrossURLPathState = (): string | undefined =>\n useCrossFrameState<string | undefined>(\n MessageKey.INTLAYER_URL_CHANGE,\n undefined\n );\n"],"mappings":";;;;;;;;;AAQA,MAAa,6BACX,mBACE,WAAW,qBACX,MACF"}
@@ -0,0 +1,32 @@
1
+ 'use client';
2
+
3
+ import { useEditedContent } from "./EditedContentContext.mjs";
4
+ import { useEffect } from "react";
5
+
6
+ //#region src/useEditedContentPersistence.tsx
7
+ const EDITED_CONTENT_STORAGE_KEY = "INTLAYER_EDITED_CONTENT_CHANGED";
8
+ /**
9
+ * Persists the edited content in localStorage, and restores it on mount so
10
+ * unsaved edits survive a page reload.
11
+ */
12
+ const useEditedContentPersistence = () => {
13
+ const { editedContent, setEditedContentState } = useEditedContent();
14
+ useEffect(() => {
15
+ if (editedContent !== void 0) return;
16
+ const persistedState = localStorage.getItem(EDITED_CONTENT_STORAGE_KEY);
17
+ if (!persistedState) return;
18
+ try {
19
+ setEditedContentState(JSON.parse(persistedState));
20
+ } catch (error) {
21
+ console.error(error);
22
+ }
23
+ }, []);
24
+ useEffect(() => {
25
+ if (editedContent === void 0) return;
26
+ localStorage.setItem(EDITED_CONTENT_STORAGE_KEY, JSON.stringify(editedContent));
27
+ }, [editedContent]);
28
+ };
29
+
30
+ //#endregion
31
+ export { useEditedContentPersistence };
32
+ //# sourceMappingURL=useEditedContentPersistence.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEditedContentPersistence.mjs","names":[],"sources":["../../src/useEditedContentPersistence.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { useEditedContent } from './EditedContentContext';\n\nconst EDITED_CONTENT_STORAGE_KEY = 'INTLAYER_EDITED_CONTENT_CHANGED';\n\n/**\n * Persists the edited content in localStorage, and restores it on mount so\n * unsaved edits survive a page reload.\n */\nexport const useEditedContentPersistence = (): void => {\n const { editedContent, setEditedContentState } = useEditedContent();\n\n useEffect(() => {\n if (editedContent !== undefined) return;\n\n const persistedState = localStorage.getItem(EDITED_CONTENT_STORAGE_KEY);\n if (!persistedState) return;\n\n try {\n setEditedContentState(JSON.parse(persistedState));\n } catch (error) {\n console.error(error);\n }\n }, []);\n\n useEffect(() => {\n if (editedContent === undefined) return;\n\n localStorage.setItem(\n EDITED_CONTENT_STORAGE_KEY,\n JSON.stringify(editedContent)\n );\n }, [editedContent]);\n};\n"],"mappings":";;;;;;AAKA,MAAM,6BAA6B;;;;;AAMnC,MAAa,oCAA0C;CACrD,MAAM,EAAE,eAAe,0BAA0B,iBAAiB;CAElE,gBAAgB;EACd,IAAI,kBAAkB,QAAW;EAEjC,MAAM,iBAAiB,aAAa,QAAQ,0BAA0B;EACtE,IAAI,CAAC,gBAAgB;EAErB,IAAI;GACF,sBAAsB,KAAK,MAAM,cAAc,CAAC;EAClD,SAAS,OAAO;GACd,QAAQ,MAAM,KAAK;EACrB;CACF,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd,IAAI,kBAAkB,QAAW;EAEjC,aAAa,QACX,4BACA,KAAK,UAAU,aAAa,CAC9B;CACF,GAAG,CAAC,aAAa,CAAC;AACpB"}
@@ -15,11 +15,7 @@ const useEditorLocale = () => {
15
15
  }, [manager]);
16
16
  return locale;
17
17
  };
18
- const useSetEditorLocale = () => {
19
- const manager = useEditorStateManager();
20
- return (locale) => manager?.currentLocale.set(locale);
21
- };
22
18
 
23
19
  //#endregion
24
- export { useEditorLocale, useSetEditorLocale };
20
+ export { useEditorLocale };
25
21
  //# sourceMappingURL=useEditorLocale.mjs.map
@@ -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,sBAAsB;CACtC,MAAM,CAAC,QAAQ,aAAa,SAC1B,SAAS,cAAc,KACzB;CAEA,gBAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MAAa,UAAW,EAA0B,MAAM;EACzE,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EAExD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAEZ,OAAO;AACT;AAEA,MAAa,2BAA2B;CACtC,MAAM,UAAU,sBAAsB;CACtC,QAAQ,WAAmB,SAAS,cAAc,IAAI,MAAM;AAC9D"}
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"],"mappings":";;;;;;AAMA,MAAa,wBAA4C;CACvD,MAAM,UAAU,sBAAsB;CACtC,MAAM,CAAC,QAAQ,aAAa,SAC1B,SAAS,cAAc,KACzB;CAEA,gBAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MAAa,UAAW,EAA0B,MAAM;EACzE,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EAExD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAEZ,OAAO;AACT"}
@@ -1,11 +1,8 @@
1
1
  import { IntlayerConfig } from "@intlayer/types/config";
2
- import { FC, PropsWithChildren } from "react";
3
2
  //#region src/ConfigurationContext.d.ts
4
- export type ConfigurationProviderProps = PropsWithChildren<{
5
- configuration?: IntlayerConfig;
6
- }>;
7
- export declare const ConfigurationProvider: FC<ConfigurationProviderProps>;
3
+ /**
4
+ * Returns the Intlayer configuration held by the editor state manager.
5
+ */
8
6
  export declare const useConfiguration: () => IntlayerConfig | undefined;
9
- export declare const useConfigurationState: () => readonly [IntlayerConfig, import("react").Dispatch<import("react").SetStateAction<IntlayerConfig>>, () => void];
10
7
  //#endregion
11
8
  //# sourceMappingURL=ConfigurationContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigurationContext.d.ts","names":[],"sources":["../../src/ConfigurationContext.tsx"],"mappings":";;;YAkBY,6BAA6B;EACvC,gBAAgB;;qBAGL,uBAAuB,GAAG;qBAoB1B,wBAAuB;qBA2BvB,uCAAqB,gCAAA,yBAAA,eAAA"}
1
+ {"version":3,"file":"ConfigurationContext.d.ts","names":[],"sources":["../../src/ConfigurationContext.tsx"],"mappings":";;;;;qBASa,wBAAuB"}
@@ -10,8 +10,6 @@ type EditedContentActionsContextType = {
10
10
  renameEditedContent: (localDictionaryId: LocalDictionaryId, newKey: KeyPath['key'], keyPath?: KeyPath[]) => void;
11
11
  removeEditedContent: (localDictionaryId: LocalDictionaryId, keyPath: KeyPath[]) => void;
12
12
  restoreEditedContent: (localDictionaryId: LocalDictionaryId) => void;
13
- clearEditedDictionaryContent: (localDictionaryId: LocalDictionaryId) => void;
14
- clearEditedContent: () => void;
15
13
  getEditedContentValue: (localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string, keyPath: KeyPath[]) => ContentNode | undefined;
16
14
  };
17
15
  export declare const useEditedContentActions: () => EditedContentActionsContextType;
@@ -23,13 +21,9 @@ export declare const useEditedContent: () => {
23
21
  renameEditedContent: (localDictionaryId: LocalDictionaryId, newKey: KeyPath['key'], keyPath?: KeyPath[]) => void;
24
22
  removeEditedContent: (localDictionaryId: LocalDictionaryId, keyPath: KeyPath[]) => void;
25
23
  restoreEditedContent: (localDictionaryId: LocalDictionaryId) => void;
26
- clearEditedDictionaryContent: (localDictionaryId: LocalDictionaryId) => void;
27
- clearEditedContent: () => void;
28
24
  getEditedContentValue: (localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string, keyPath: KeyPath[]) => ContentNode | undefined;
29
25
  editedContent: DictionaryContent$1;
30
26
  };
31
- export declare const usePostEditedContentState: <S>(onEventTriggered?: (data: S) => void) => void;
32
- export declare const useGetEditedContentState: () => () => void;
33
27
  //#endregion
34
28
  export type { DictionaryContent };
35
29
  //# sourceMappingURL=EditedContentContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditedContentContext.d.ts","names":[],"sources":["../../src/EditedContentContext.tsx"],"mappings":";;;;KAcK;EACH,wBAAwB,eAAe;EACvC,sBAAsB,MAAM;EAC5B,mBACE,mBAAmB,mBACnB,UAAU;EAEZ,mBACE,mBAAmB,mBACnB,UAAU,kBACV,UAAU,WACV;EAEF,sBACE,mBAAmB,mBACnB,QAAQ,gBACR,UAAU;EAEZ,sBACE,mBAAmB,mBACnB,SAAS;EAEX,uBAAuB,mBAAmB;EAC1C,+BAA+B,mBAAmB;EAClD;EACA,wBACE,wBAAwB,oBAAoB,4BAC5C,SAAS,cACN;;qBAGM,+BAA8B;qBA0B9B;EAxDY,wBAAC,eAAe;EAClB,sBAAC,MAAM;EACV,mBAChB,mBAAmB,mBACnB,UAAU;EAEM,mBAChB,mBAAmB,mBACnB,UAAU,kBACV,UAAU,WACV;EAEmB,sBACnB,mBAAmB,mBACnB,QAAQ,gBACR,UAAU;EAES,sBACnB,mBAAmB,mBACnB,SAAS;EAEW,uBAAC,mBAAmB;EACZ,+BAAC,mBAAmB;EAC9B;EACG,wBACrB,wBAAwB,oBAAoB,4BAC5C,SAAS,cACN;;;qBA+CM,4BAA6B,GAAC,oBACrB,MAAM;qBAYf"}
1
+ {"version":3,"file":"EditedContentContext.d.ts","names":[],"sources":["../../src/EditedContentContext.tsx"],"mappings":";;;;KAcK;EACH,wBAAwB,eAAe;EACvC,sBAAsB,MAAM;EAC5B,mBACE,mBAAmB,mBACnB,UAAU;EAEZ,mBACE,mBAAmB,mBACnB,UAAU,kBACV,UAAU,WACV;EAEF,sBACE,mBAAmB,mBACnB,QAAQ,gBACR,UAAU;EAEZ,sBACE,mBAAmB,mBACnB,SAAS;EAEX,uBAAuB,mBAAmB;EAC1C,wBACE,wBAAwB,oBAAoB,4BAC5C,SAAS,cACN;;qBAGM,+BAA8B;qBAwB9B;EApDY,wBAAC,eAAe;EAClB,sBAAC,MAAM;EACV,mBAChB,mBAAmB,mBACnB,UAAU;EAEM,mBAChB,mBAAmB,mBACnB,UAAU,kBACV,UAAU,WACV;EAEmB,sBACnB,mBAAmB,mBACnB,QAAQ,gBACR,UAAU;EAES,sBACnB,mBAAmB,mBACnB,SAAS;EAEW,uBAAC,mBAAmB;EACnB,wBACrB,wBAAwB,oBAAoB,4BAC5C,SAAS,cACN"}
@@ -7,17 +7,6 @@ export type EditorEnabledStateProps = {
7
7
  * EditorStateManager. Replaces the old EditorEnabledContext + EditorEnabledProvider.
8
8
  */
9
9
  export declare const useEditorEnabled: () => EditorEnabledStateProps;
10
- /**
11
- * Subscribes to incoming "get" requests for editor-enabled state and calls
12
- * the provided callback so the caller can respond.
13
- * Used by the editor side to respond when the client asks for the current state.
14
- */
15
- export declare const useGetEditorEnabledState: (onRequest?: () => void) => void;
16
- /**
17
- * Returns a function that sets the editor-enabled state and broadcasts it.
18
- */
19
- export declare const usePostEditorEnabledState: () => (value: boolean) => void;
20
- export declare const useEditorEnabledState: () => readonly [boolean, (value: boolean) => void];
21
10
  /**
22
11
  * Returns a function that re-pings the client via ARE_YOU_THERE.
23
12
  * Use this as the onClick for an "Enable Editor" / reconnect button.
@@ -1 +1 @@
1
- {"version":3,"file":"EditorEnabledContext.d.ts","names":[],"sources":["../../src/EditorEnabledContext.tsx"],"mappings":";YAMY;EACV;;;;;;qBAOW,wBAAuB;;;;;;qBAuBvB,2BAAwB;;;;qBAgBxB,kCAAyB;qBASzB,iDAAqB;;;;;qBAYrB"}
1
+ {"version":3,"file":"EditorEnabledContext.d.ts","names":[],"sources":["../../src/EditorEnabledContext.tsx"],"mappings":";YAKY;EACV;;;;;;qBAOW,wBAAuB;;;;;qBAsBvB"}
@@ -1,18 +1,17 @@
1
1
  import { CrossFrameStateAction, FileContent, FileContent as FileContent$1 } from "@intlayer/editor";
2
- import { FC, PropsWithChildren } from "react";
3
2
  import { KeyPath } from "@intlayer/types/keyPath";
4
3
  //#region src/FocusDictionaryContext.d.ts
5
- export type FocusDictionaryState = {
6
- focusedContent: FileContent$1 | null;
7
- };
8
4
  export type FocusDictionaryActions = {
9
5
  /** Accepts a value or an updater — `setFocusedContent(prev => …)`. */
10
6
  setFocusedContent: (value: CrossFrameStateAction<FileContent$1 | null>) => void;
11
7
  setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;
12
8
  };
13
- export declare const FocusDictionaryProvider: FC<PropsWithChildren>;
14
- export declare const useFocusDictionary: () => FocusDictionaryState & FocusDictionaryActions;
15
- export declare const useFocusDictionaryActions: () => FocusDictionaryActions;
9
+ /**
10
+ * Returns the content focused in the editor, shared with the client frame.
11
+ */
12
+ export declare const useFocusDictionary: () => FocusDictionaryActions & {
13
+ focusedContent: FileContent$1 | null;
14
+ };
16
15
  //#endregion
17
16
  export type { FileContent };
18
17
  //# sourceMappingURL=FocusDictionaryContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FocusDictionaryContext.d.ts","names":[],"sources":["../../src/FocusDictionaryContext.tsx"],"mappings":";;;;YAkBY;EACV,gBAAgB;;YAGN;;EAEV,oBAAoB,OAAO,sBAAsB;EACjD,2BAA2B,SAAS;;qBAWzB,yBAAyB,GAAG;qBAkD5B,0BAAyB,uBACpC;qBAkDW,iCAAgC"}
1
+ {"version":3,"file":"FocusDictionaryContext.d.ts","names":[],"sources":["../../src/FocusDictionaryContext.tsx"],"mappings":";;;YASY;;EAEV,oBAAoB,OAAO,sBAAsB;EACjD,2BAA2B,SAAS;;;;;qBAMzB,0BAAyB;EACpC,gBAAgB"}
@@ -1,16 +1,14 @@
1
- import { MessengerConfig, UseCrossPlatformStateProps, useCommunicator } from "./CommunicatorContext.js";
2
- import { ConfigurationProvider, ConfigurationProviderProps, useConfiguration, useConfigurationState } from "./ConfigurationContext.js";
1
+ import { useConfiguration } from "./ConfigurationContext.js";
3
2
  import { DictionaryContent as DictionaryContent$1, useDictionariesRecord, useDictionariesRecordActions } from "./DictionariesRecordContext.js";
4
- import { useEditedContent, useEditedContentActions, useGetEditedContentState, usePostEditedContentState } from "./EditedContentContext.js";
5
- import { EditorEnabledStateProps, useEditorEnabled, useEditorEnabledState, useEditorPingClient, useGetEditorEnabledState, usePostEditorEnabledState } from "./EditorEnabledContext.js";
3
+ import { useEditedContent, useEditedContentActions } from "./EditedContentContext.js";
4
+ import { EditorEnabledStateProps, useEditorEnabled, useEditorPingClient } from "./EditorEnabledContext.js";
6
5
  import { EditorProvider, EditorProviderProps } from "./EditorProvider.js";
7
6
  import { EditorStateProvider, useEditorStateManager } from "./EditorStateContext.js";
8
- import { FileContent, FocusDictionaryActions, FocusDictionaryProvider, FocusDictionaryState, useFocusDictionary, useFocusDictionaryActions } from "./FocusDictionaryContext.js";
9
- import { useCrossFrameMessageListener } from "./useCrossFrameMessageListener.js";
10
- import { CrossFrameStateOptions, useCrossFrameState } from "./useCrossFrameState.js";
11
- import { useCrossURLPathSetter, useCrossURLPathState } from "./useCrossURLPathState.js";
12
- import { useEditorLocale, useSetEditorLocale } from "./useEditorLocale.js";
7
+ import { FileContent, FocusDictionaryActions, useFocusDictionary } from "./FocusDictionaryContext.js";
8
+ import { useCrossFrameState } from "./useCrossFrameState.js";
9
+ import { useCrossURLPathState } from "./useCrossURLPathState.js";
10
+ import { useEditedContentPersistence } from "./useEditedContentPersistence.js";
11
+ import { useEditorLocale } from "./useEditorLocale.js";
13
12
  import { useFocusUnmergedDictionary } from "./useFocusUnmergedDictionary.js";
14
- import { useIframeClickInterceptor, useIframeClickMerger } from "./useIframeClickInterceptor.js";
15
13
  import { MessageKey } from "@intlayer/editor";
16
- export { ConfigurationProvider, ConfigurationProviderProps, CrossFrameStateOptions, EditorEnabledStateProps, EditorProvider, EditorProviderProps, EditorStateProvider, type FileContent, FocusDictionaryActions, FocusDictionaryProvider, FocusDictionaryState, MessageKey, type MessengerConfig, UseCrossPlatformStateProps, useCommunicator, useConfiguration, useConfigurationState, useCrossFrameMessageListener, useCrossFrameState, useCrossURLPathSetter, useCrossURLPathState, useDictionariesRecord, useDictionariesRecordActions, useEditedContent, useEditedContentActions, useEditorEnabled, useEditorEnabledState, useEditorLocale, useEditorPingClient, useEditorStateManager, useFocusDictionary, useFocusDictionaryActions, useFocusUnmergedDictionary, useGetEditedContentState, useGetEditorEnabledState, useIframeClickInterceptor, useIframeClickMerger, usePostEditedContentState, usePostEditorEnabledState, useSetEditorLocale };
14
+ export { EditorEnabledStateProps, EditorProvider, EditorProviderProps, EditorStateProvider, type FileContent, FocusDictionaryActions, MessageKey, useConfiguration, useCrossFrameState, useCrossURLPathState, useDictionariesRecord, useDictionariesRecordActions, useEditedContent, useEditedContentActions, useEditedContentPersistence, useEditorEnabled, useEditorLocale, useEditorPingClient, useEditorStateManager, useFocusDictionary, useFocusUnmergedDictionary };
@@ -1,13 +1,8 @@
1
1
  import { MessageKey } from "@intlayer/editor";
2
- import { Dispatch, SetStateAction } from "react";
3
2
  //#region src/useCrossFrameState.d.ts
4
- export type CrossFrameStateOptions = {
5
- emit?: boolean;
6
- receive?: boolean;
7
- };
8
3
  /**
9
- * Synchronizes a React state value across frames using CrossFrameStateManager.
4
+ * Returns the latest value another frame posted under `key`.
10
5
  */
11
- export declare const useCrossFrameState: <S>(key: `${MessageKey}`, initialState?: S | (() => S), options?: CrossFrameStateOptions) => [S, Dispatch<SetStateAction<S>>, () => void];
6
+ export declare const useCrossFrameState: <Value>(key: `${MessageKey}`, initialValue: Value) => Value;
12
7
  //#endregion
13
8
  //# sourceMappingURL=useCrossFrameState.d.ts.map