@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.
- package/dist/cjs/ConfigurationContext.cjs +10 -39
- package/dist/cjs/ConfigurationContext.cjs.map +1 -1
- package/dist/cjs/EditedContentContext.cjs +0 -17
- package/dist/cjs/EditedContentContext.cjs.map +1 -1
- package/dist/cjs/EditorEnabledContext.cjs +0 -32
- package/dist/cjs/EditorEnabledContext.cjs.map +1 -1
- package/dist/cjs/FocusDictionaryContext.cjs +11 -59
- package/dist/cjs/FocusDictionaryContext.cjs.map +1 -1
- package/dist/cjs/index.cjs +4 -20
- package/dist/cjs/useCrossFrameState.cjs +5 -50
- package/dist/cjs/useCrossFrameState.cjs.map +1 -1
- package/dist/cjs/useCrossURLPathState.cjs +4 -8
- package/dist/cjs/useCrossURLPathState.cjs.map +1 -1
- package/dist/cjs/useEditedContentPersistence.cjs +33 -0
- package/dist/cjs/useEditedContentPersistence.cjs.map +1 -0
- package/dist/cjs/useEditorLocale.cjs +0 -5
- package/dist/cjs/useEditorLocale.cjs.map +1 -1
- package/dist/esm/ConfigurationContext.mjs +12 -39
- package/dist/esm/ConfigurationContext.mjs.map +1 -1
- package/dist/esm/EditedContentContext.mjs +1 -16
- package/dist/esm/EditedContentContext.mjs.map +1 -1
- package/dist/esm/EditorEnabledContext.mjs +1 -30
- package/dist/esm/EditorEnabledContext.mjs.map +1 -1
- package/dist/esm/FocusDictionaryContext.mjs +13 -57
- package/dist/esm/FocusDictionaryContext.mjs.map +1 -1
- package/dist/esm/index.mjs +8 -10
- package/dist/esm/useCrossFrameState.mjs +6 -51
- package/dist/esm/useCrossFrameState.mjs.map +1 -1
- package/dist/esm/useCrossURLPathState.mjs +5 -8
- package/dist/esm/useCrossURLPathState.mjs.map +1 -1
- package/dist/esm/useEditedContentPersistence.mjs +32 -0
- package/dist/esm/useEditedContentPersistence.mjs.map +1 -0
- package/dist/esm/useEditorLocale.mjs +1 -5
- package/dist/esm/useEditorLocale.mjs.map +1 -1
- package/dist/types/ConfigurationContext.d.ts +3 -6
- package/dist/types/ConfigurationContext.d.ts.map +1 -1
- package/dist/types/EditedContentContext.d.ts +0 -6
- package/dist/types/EditedContentContext.d.ts.map +1 -1
- package/dist/types/EditorEnabledContext.d.ts +0 -11
- package/dist/types/EditorEnabledContext.d.ts.map +1 -1
- package/dist/types/FocusDictionaryContext.d.ts +6 -7
- package/dist/types/FocusDictionaryContext.d.ts.map +1 -1
- package/dist/types/index.d.ts +9 -11
- package/dist/types/useCrossFrameState.d.ts +2 -7
- package/dist/types/useCrossFrameState.d.ts.map +1 -1
- package/dist/types/useCrossURLPathState.d.ts +4 -3
- package/dist/types/useCrossURLPathState.d.ts.map +1 -1
- package/dist/types/useEditedContentPersistence.d.ts +8 -0
- package/dist/types/useEditedContentPersistence.d.ts.map +1 -0
- package/dist/types/useEditorLocale.d.ts +0 -1
- package/dist/types/useEditorLocale.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/cjs/CommunicatorContext.cjs +0 -20
- package/dist/cjs/CommunicatorContext.cjs.map +0 -1
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +0 -28
- package/dist/cjs/useCrossFrameMessageListener.cjs +0 -31
- package/dist/cjs/useCrossFrameMessageListener.cjs.map +0 -1
- package/dist/cjs/useIframeClickInterceptor.cjs +0 -28
- package/dist/cjs/useIframeClickInterceptor.cjs.map +0 -1
- package/dist/esm/CommunicatorContext.mjs +0 -19
- package/dist/esm/CommunicatorContext.mjs.map +0 -1
- package/dist/esm/useCrossFrameMessageListener.mjs +0 -30
- package/dist/esm/useCrossFrameMessageListener.mjs.map +0 -1
- package/dist/esm/useIframeClickInterceptor.mjs +0 -26
- package/dist/esm/useIframeClickInterceptor.mjs.map +0 -1
- package/dist/types/CommunicatorContext.d.ts +0 -14
- package/dist/types/CommunicatorContext.d.ts.map +0 -1
- package/dist/types/useCrossFrameMessageListener.d.ts +0 -11
- package/dist/types/useCrossFrameMessageListener.d.ts.map +0 -1
- package/dist/types/useIframeClickInterceptor.d.ts +0 -15
- 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 {
|
|
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
|
|
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
|
|
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,
|
|
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 {
|
|
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 {
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
|
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"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -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 {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { useEditorLocale
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
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 {
|
|
11
|
+
import { useFocusDictionary } from "./FocusDictionaryContext.mjs";
|
|
14
12
|
import { useFocusUnmergedDictionary } from "./useFocusUnmergedDictionary.mjs";
|
|
15
13
|
import { MessageKey } from "@intlayer/editor";
|
|
16
14
|
|
|
17
|
-
export {
|
|
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,
|
|
5
|
-
import { CrossFrameStateManager } from "@intlayer/editor";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
6
5
|
|
|
7
6
|
//#region src/useCrossFrameState.tsx
|
|
8
7
|
/**
|
|
9
|
-
*
|
|
8
|
+
* Returns the latest value another frame posted under `key`.
|
|
10
9
|
*/
|
|
11
|
-
const useCrossFrameState = (key,
|
|
10
|
+
const useCrossFrameState = (key, initialValue) => {
|
|
12
11
|
const manager = useEditorStateManager();
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
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 {
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 {
|
|
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 {
|
|
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
|
|
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
|
|
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
|
-
|
|
5
|
-
|
|
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":"
|
|
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
|
|
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":";
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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":"
|
|
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"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
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
|
|
5
|
-
import { EditorEnabledStateProps, useEditorEnabled,
|
|
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,
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { useEditorLocale
|
|
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 {
|
|
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
|
-
*
|
|
4
|
+
* Returns the latest value another frame posted under `key`.
|
|
10
5
|
*/
|
|
11
|
-
export declare const useCrossFrameState: <
|
|
6
|
+
export declare const useCrossFrameState: <Value>(key: `${MessageKey}`, initialValue: Value) => Value;
|
|
12
7
|
//#endregion
|
|
13
8
|
//# sourceMappingURL=useCrossFrameState.d.ts.map
|