@intlayer/editor-react 8.1.2 → 8.1.3-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/CommunicatorContext.cjs +1 -42
- package/dist/cjs/CommunicatorContext.cjs.map +1 -1
- package/dist/cjs/ConfigurationContext.cjs +1 -25
- package/dist/cjs/ConfigurationContext.cjs.map +1 -1
- package/dist/cjs/DictionariesRecordContext.cjs +1 -48
- package/dist/cjs/DictionariesRecordContext.cjs.map +1 -1
- package/dist/cjs/EditedContentContext.cjs +1 -169
- package/dist/cjs/EditedContentContext.cjs.map +1 -1
- package/dist/cjs/EditorEnabledContext.cjs +1 -33
- package/dist/cjs/EditorEnabledContext.cjs.map +1 -1
- package/dist/cjs/EditorProvider.cjs +1 -67
- package/dist/cjs/EditorProvider.cjs.map +1 -1
- package/dist/cjs/FocusDictionaryContext.cjs +1 -55
- package/dist/cjs/FocusDictionaryContext.cjs.map +1 -1
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/cjs/index.cjs +1 -53
- package/dist/cjs/useCrossFrameMessageListener.cjs +1 -78
- package/dist/cjs/useCrossFrameMessageListener.cjs.map +1 -1
- package/dist/cjs/useCrossFrameState.cjs +1 -108
- package/dist/cjs/useCrossFrameState.cjs.map +1 -1
- package/dist/cjs/useCrossURLPathState.cjs +1 -67
- package/dist/cjs/useCrossURLPathState.cjs.map +1 -1
- package/dist/cjs/useEditorLocale.cjs +1 -23
- package/dist/cjs/useEditorLocale.cjs.map +1 -1
- package/dist/cjs/useFocusUnmergedDictionary.cjs +1 -51
- package/dist/cjs/useFocusUnmergedDictionary.cjs.map +1 -1
- package/dist/cjs/useIframeClickInterceptor.cjs +1 -24
- package/dist/cjs/useIframeClickInterceptor.cjs.map +1 -1
- package/dist/esm/CommunicatorContext.mjs +1 -38
- package/dist/esm/CommunicatorContext.mjs.map +1 -1
- package/dist/esm/ConfigurationContext.mjs +1 -21
- package/dist/esm/ConfigurationContext.mjs.map +1 -1
- package/dist/esm/DictionariesRecordContext.mjs +1 -44
- package/dist/esm/DictionariesRecordContext.mjs.map +1 -1
- package/dist/esm/EditedContentContext.mjs +1 -163
- package/dist/esm/EditedContentContext.mjs.map +1 -1
- package/dist/esm/EditorEnabledContext.mjs +1 -27
- package/dist/esm/EditorEnabledContext.mjs.map +1 -1
- package/dist/esm/EditorProvider.mjs +1 -65
- package/dist/esm/EditorProvider.mjs.map +1 -1
- package/dist/esm/FocusDictionaryContext.mjs +1 -51
- package/dist/esm/FocusDictionaryContext.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -17
- package/dist/esm/useCrossFrameMessageListener.mjs +1 -76
- package/dist/esm/useCrossFrameMessageListener.mjs.map +1 -1
- package/dist/esm/useCrossFrameState.mjs +1 -106
- package/dist/esm/useCrossFrameState.mjs.map +1 -1
- package/dist/esm/useCrossURLPathState.mjs +1 -64
- package/dist/esm/useCrossURLPathState.mjs.map +1 -1
- package/dist/esm/useEditorLocale.mjs +1 -20
- package/dist/esm/useEditorLocale.mjs.map +1 -1
- package/dist/esm/useFocusUnmergedDictionary.mjs +1 -49
- package/dist/esm/useFocusUnmergedDictionary.mjs.map +1 -1
- package/dist/esm/useIframeClickInterceptor.mjs +1 -21
- package/dist/esm/useIframeClickInterceptor.mjs.map +1 -1
- package/dist/types/EditedContentContext.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/esm/index.mjs
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useCrossFrameMessageListener } from "./useCrossFrameMessageListener.mjs";
|
|
3
|
-
import { useCrossFrameState } from "./useCrossFrameState.mjs";
|
|
4
|
-
import { ConfigurationProvider, useConfiguration, useConfigurationState } from "./ConfigurationContext.mjs";
|
|
5
|
-
import { DictionariesRecordProvider, useDictionariesRecord, useDictionariesRecordActions } from "./DictionariesRecordContext.mjs";
|
|
6
|
-
import { useEditorLocale, useSetEditorLocale } from "./useEditorLocale.mjs";
|
|
7
|
-
import { EditedContentProvider, useEditedContent, useEditedContentActions, useGetEditedContentState, usePostEditedContentState } from "./EditedContentContext.mjs";
|
|
8
|
-
import { EditorEnabledProvider, useEditorEnabled, useEditorEnabledState, useGetEditorEnabledState, usePostEditorEnabledState } from "./EditorEnabledContext.mjs";
|
|
9
|
-
import { FocusDictionaryProvider, useFocusDictionary, useFocusDictionaryActions } from "./FocusDictionaryContext.mjs";
|
|
10
|
-
import { EditorProvider } from "./EditorProvider.mjs";
|
|
11
|
-
import { useCrossURLPathSetter, useCrossURLPathState } from "./useCrossURLPathState.mjs";
|
|
12
|
-
import { useFocusUnmergedDictionary } from "./useFocusUnmergedDictionary.mjs";
|
|
13
|
-
import { useIframeClickInterceptor, useIframeClickMerger } from "./useIframeClickInterceptor.mjs";
|
|
14
|
-
|
|
15
|
-
export * from "@intlayer/editor"
|
|
16
|
-
|
|
17
|
-
export { CommunicatorProvider, ConfigurationProvider, DictionariesRecordProvider, EditedContentProvider, EditorEnabledProvider, EditorProvider, FocusDictionaryProvider, useCommunicator, useConfiguration, useConfigurationState, useCrossFrameMessageListener, useCrossFrameState, useCrossURLPathSetter, useCrossURLPathState, useDictionariesRecord, useDictionariesRecordActions, useEditedContent, useEditedContentActions, useEditorEnabled, useEditorEnabledState, useEditorLocale, useFocusDictionary, useFocusDictionaryActions, useFocusUnmergedDictionary, useGetEditedContentState, useGetEditorEnabledState, useIframeClickInterceptor, useIframeClickMerger, usePostEditedContentState, usePostEditorEnabledState, useSetEditorLocale };
|
|
1
|
+
import{CommunicatorProvider as e,useCommunicator as t}from"./CommunicatorContext.mjs";import{useCrossFrameMessageListener as n}from"./useCrossFrameMessageListener.mjs";import{useCrossFrameState as r}from"./useCrossFrameState.mjs";import{ConfigurationProvider as i,useConfiguration as a,useConfigurationState as o}from"./ConfigurationContext.mjs";import{DictionariesRecordProvider as s,useDictionariesRecord as c,useDictionariesRecordActions as l}from"./DictionariesRecordContext.mjs";import{useEditorLocale as u,useSetEditorLocale as d}from"./useEditorLocale.mjs";import{EditedContentProvider as f,useEditedContent as p,useEditedContentActions as m,useGetEditedContentState as h,usePostEditedContentState as g}from"./EditedContentContext.mjs";import{EditorEnabledProvider as _,useEditorEnabled as v,useEditorEnabledState as y,useGetEditorEnabledState as b,usePostEditorEnabledState as x}from"./EditorEnabledContext.mjs";import{FocusDictionaryProvider as S,useFocusDictionary as C,useFocusDictionaryActions as w}from"./FocusDictionaryContext.mjs";import{EditorProvider as T}from"./EditorProvider.mjs";import{useCrossURLPathSetter as E,useCrossURLPathState as D}from"./useCrossURLPathState.mjs";import{useFocusUnmergedDictionary as O}from"./useFocusUnmergedDictionary.mjs";import{useIframeClickInterceptor as k,useIframeClickMerger as A}from"./useIframeClickInterceptor.mjs";export*from"@intlayer/editor";export{e as CommunicatorProvider,i as ConfigurationProvider,s as DictionariesRecordProvider,f as EditedContentProvider,_ as EditorEnabledProvider,T as EditorProvider,S as FocusDictionaryProvider,t as useCommunicator,a as useConfiguration,o as useConfigurationState,n as useCrossFrameMessageListener,r as useCrossFrameState,E as useCrossURLPathSetter,D as useCrossURLPathState,c as useDictionariesRecord,l as useDictionariesRecordActions,p as useEditedContent,m as useEditedContentActions,v as useEditorEnabled,y as useEditorEnabledState,u as useEditorLocale,C as useFocusDictionary,w as useFocusDictionaryActions,O as useFocusUnmergedDictionary,h as useGetEditedContentState,b as useGetEditorEnabledState,k as useIframeClickInterceptor,A as useIframeClickMerger,g as usePostEditedContentState,x as usePostEditorEnabledState,d as useSetEditorLocale};
|
|
@@ -1,77 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { useCommunicator } from "./CommunicatorContext.mjs";
|
|
4
|
-
import { useEffect } from "react";
|
|
5
|
-
import { compareUrls } from "@intlayer/editor";
|
|
6
|
-
|
|
7
|
-
//#region src/useCrossFrameMessageListener.tsx
|
|
8
|
-
/**
|
|
9
|
-
* useCrossFrameMessageListener
|
|
10
|
-
*
|
|
11
|
-
* This React hook listens for messages sent via the `postMessage` API and triggers a callback
|
|
12
|
-
* whenever a message of the specified type (`key`) is received. It is useful for synchronizing
|
|
13
|
-
* state or events across different windows, iframes, or contexts.
|
|
14
|
-
*
|
|
15
|
-
* @template S - The type of the data payload in the message.
|
|
16
|
-
* @param key - A unique identifier for the message type to listen for.
|
|
17
|
-
* @param [onEventTriggered] - A callback function triggered when a message
|
|
18
|
-
* @param [revalidator] - A function that re-suscribes the listener. Could be usefull if onEventTriggered depend of some state
|
|
19
|
-
* with the specified key is received. The callback receives the message data as its argument.
|
|
20
|
-
*
|
|
21
|
-
* @returns {{ postMessage: (data: S) => void }} An object containing a `postMessage` function
|
|
22
|
-
* that allows broadcasting messages with the specified key and data.
|
|
23
|
-
*/
|
|
24
|
-
const useCrossFrameMessageListener = (key, onEventTriggered, revalidator) => {
|
|
25
|
-
const { allowedOrigins, postMessage, senderId } = useCommunicator();
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (onEventTriggered) {
|
|
28
|
-
/**
|
|
29
|
-
* Message handler to process incoming messages.
|
|
30
|
-
*
|
|
31
|
-
* - **Message Filtering:** Ensures only messages with the specified `key` are processed.
|
|
32
|
-
* - **Origin Validation:** Checks that the origin of the message is within the allowed origins.
|
|
33
|
-
*
|
|
34
|
-
* @param {MessageEvent<{ type: string; data: S }>} event - The incoming message event object.
|
|
35
|
-
*/
|
|
36
|
-
const handleMessage = (event) => {
|
|
37
|
-
const { type, data, senderId: msgSenderId } = event.data;
|
|
38
|
-
if (type !== key) return;
|
|
39
|
-
if (msgSenderId === senderId) return;
|
|
40
|
-
if (typeof allowedOrigins === "undefined" || allowedOrigins?.filter((url) => ![
|
|
41
|
-
null,
|
|
42
|
-
void 0,
|
|
43
|
-
"",
|
|
44
|
-
"*"
|
|
45
|
-
].includes(url)).some((url) => compareUrls(url, event.origin)) || allowedOrigins?.includes("*")) onEventTriggered(data);
|
|
46
|
-
};
|
|
47
|
-
window.addEventListener("message", handleMessage);
|
|
48
|
-
return () => window.removeEventListener("message", handleMessage);
|
|
49
|
-
}
|
|
50
|
-
}, [
|
|
51
|
-
allowedOrigins,
|
|
52
|
-
postMessage,
|
|
53
|
-
senderId,
|
|
54
|
-
revalidator
|
|
55
|
-
]);
|
|
56
|
-
/**
|
|
57
|
-
* A wrapper function around the `postMessage` function to broadcast messages efficiently.
|
|
58
|
-
*
|
|
59
|
-
* - **Encapsulation:** Ensures the `postMessage` function is scoped to the provided key.
|
|
60
|
-
* - **Ease of Use:** Simplifies broadcasting messages with consistent type and format.
|
|
61
|
-
*
|
|
62
|
-
* @param {S} data - The data payload to include in the message.
|
|
63
|
-
* @returns {void}
|
|
64
|
-
*/
|
|
65
|
-
const postMessageWrapper = (data) => {
|
|
66
|
-
postMessage({
|
|
67
|
-
type: key,
|
|
68
|
-
data,
|
|
69
|
-
senderId
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
return postMessageWrapper;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
//#endregion
|
|
76
|
-
export { useCrossFrameMessageListener };
|
|
1
|
+
"use client";import{useCommunicator as e}from"./CommunicatorContext.mjs";import{useEffect as t}from"react";import{compareUrls as n}from"@intlayer/editor";const r=(r,i,a)=>{let{allowedOrigins:o,postMessage:s,senderId:c}=e();return t(()=>{if(i){let e=e=>{let{type:t,data:a,senderId:s}=e.data;t===r&&s!==c&&(o===void 0||o?.filter(e=>![null,void 0,``,`*`].includes(e)).some(t=>n(t,e.origin))||o?.includes(`*`))&&i(a)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)}},[o,s,c,a]),e=>{s({type:r,data:e,senderId:c})}};export{r as useCrossFrameMessageListener};
|
|
77
2
|
//# sourceMappingURL=useCrossFrameMessageListener.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossFrameMessageListener.mjs","names":[],"sources":["../../src/useCrossFrameMessageListener.tsx"],"sourcesContent":["'use client';\n\nimport { compareUrls, type MessageKey } from '@intlayer/editor';\nimport { useEffect } from 'react';\nimport { useCommunicator } from './CommunicatorContext';\n\n/**\n * useCrossFrameMessageListener\n *\n * This React hook listens for messages sent via the `postMessage` API and triggers a callback\n * whenever a message of the specified type (`key`) is received. It is useful for synchronizing\n * state or events across different windows, iframes, or contexts.\n *\n * @template S - The type of the data payload in the message.\n * @param key - A unique identifier for the message type to listen for.\n * @param [onEventTriggered] - A callback function triggered when a message\n * @param [revalidator] - A function that re-suscribes the listener. Could be usefull if onEventTriggered depend of some state\n * with the specified key is received. The callback receives the message data as its argument.\n *\n * @returns {{ postMessage: (data: S) => void }} An object containing a `postMessage` function\n * that allows broadcasting messages with the specified key and data.\n */\nexport const useCrossFrameMessageListener = <S,>(\n key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`,\n onEventTriggered?: (data: S) => void,\n revalidator?: any\n) => {\n const { allowedOrigins, postMessage, senderId } = useCommunicator();\n\n useEffect(() => {\n if (onEventTriggered) {\n /**\n * Message handler to process incoming messages.\n *\n * - **Message Filtering:** Ensures only messages with the specified `key` are processed.\n * - **Origin Validation:** Checks that the origin of the message is within the allowed origins.\n *\n * @param {MessageEvent<{ type: string; data: S }>} event - The incoming message event object.\n */\n const handleMessage = (\n event: MessageEvent<{ type: string; data: S; senderId: string }>\n ) => {\n const { type, data, senderId: msgSenderId } = event.data;\n\n // Ignore messages that do not match the current key\n if (type !== key) return;\n\n // Ignore messages from myself\n if (msgSenderId === senderId) return;\n\n // Check if the message origin is allowed\n if (\n typeof allowedOrigins === 'undefined' ||\n allowedOrigins\n ?.filter((url) => ![null, undefined, '', '*'].includes(url))\n .some((url) => compareUrls(url, event.origin)) ||\n allowedOrigins?.includes('*')\n ) {\n // Update the local state with the received data\n onEventTriggered(data);\n }\n };\n\n window.addEventListener('message', handleMessage);\n\n // Clean up the event listener on unmount\n return () => window.removeEventListener('message', handleMessage);\n }\n }, [allowedOrigins, postMessage, senderId, revalidator]);\n\n /**\n * A wrapper function around the `postMessage` function to broadcast messages efficiently.\n *\n * - **Encapsulation:** Ensures the `postMessage` function is scoped to the provided key.\n * - **Ease of Use:** Simplifies broadcasting messages with consistent type and format.\n *\n * @param {S} data - The data payload to include in the message.\n * @returns {void}\n */\n const postMessageWrapper: (data?: S) => void = (data) => {\n postMessage({ type: key, data, senderId });\n };\n\n return postMessageWrapper;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCrossFrameMessageListener.mjs","names":[],"sources":["../../src/useCrossFrameMessageListener.tsx"],"sourcesContent":["'use client';\n\nimport { compareUrls, type MessageKey } from '@intlayer/editor';\nimport { useEffect } from 'react';\nimport { useCommunicator } from './CommunicatorContext';\n\n/**\n * useCrossFrameMessageListener\n *\n * This React hook listens for messages sent via the `postMessage` API and triggers a callback\n * whenever a message of the specified type (`key`) is received. It is useful for synchronizing\n * state or events across different windows, iframes, or contexts.\n *\n * @template S - The type of the data payload in the message.\n * @param key - A unique identifier for the message type to listen for.\n * @param [onEventTriggered] - A callback function triggered when a message\n * @param [revalidator] - A function that re-suscribes the listener. Could be usefull if onEventTriggered depend of some state\n * with the specified key is received. The callback receives the message data as its argument.\n *\n * @returns {{ postMessage: (data: S) => void }} An object containing a `postMessage` function\n * that allows broadcasting messages with the specified key and data.\n */\nexport const useCrossFrameMessageListener = <S,>(\n key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`,\n onEventTriggered?: (data: S) => void,\n revalidator?: any\n) => {\n const { allowedOrigins, postMessage, senderId } = useCommunicator();\n\n useEffect(() => {\n if (onEventTriggered) {\n /**\n * Message handler to process incoming messages.\n *\n * - **Message Filtering:** Ensures only messages with the specified `key` are processed.\n * - **Origin Validation:** Checks that the origin of the message is within the allowed origins.\n *\n * @param {MessageEvent<{ type: string; data: S }>} event - The incoming message event object.\n */\n const handleMessage = (\n event: MessageEvent<{ type: string; data: S; senderId: string }>\n ) => {\n const { type, data, senderId: msgSenderId } = event.data;\n\n // Ignore messages that do not match the current key\n if (type !== key) return;\n\n // Ignore messages from myself\n if (msgSenderId === senderId) return;\n\n // Check if the message origin is allowed\n if (\n typeof allowedOrigins === 'undefined' ||\n allowedOrigins\n ?.filter((url) => ![null, undefined, '', '*'].includes(url))\n .some((url) => compareUrls(url, event.origin)) ||\n allowedOrigins?.includes('*')\n ) {\n // Update the local state with the received data\n onEventTriggered(data);\n }\n };\n\n window.addEventListener('message', handleMessage);\n\n // Clean up the event listener on unmount\n return () => window.removeEventListener('message', handleMessage);\n }\n }, [allowedOrigins, postMessage, senderId, revalidator]);\n\n /**\n * A wrapper function around the `postMessage` function to broadcast messages efficiently.\n *\n * - **Encapsulation:** Ensures the `postMessage` function is scoped to the provided key.\n * - **Ease of Use:** Simplifies broadcasting messages with consistent type and format.\n *\n * @param {S} data - The data payload to include in the message.\n * @returns {void}\n */\n const postMessageWrapper: (data?: S) => void = (data) => {\n postMessage({ type: key, data, senderId });\n };\n\n return postMessageWrapper;\n};\n"],"mappings":"0JAsBA,MAAa,GACX,EACA,EACA,IACG,CACH,GAAM,CAAE,iBAAgB,cAAa,YAAa,GAAiB,CAwDnE,OAtDA,MAAgB,CACd,GAAI,EAAkB,CASpB,IAAM,EACJ,GACG,CACH,GAAM,CAAE,OAAM,OAAM,SAAU,GAAgB,EAAM,KAGhD,IAAS,GAGT,IAAgB,IAIX,IAAmB,QAC1B,GACI,OAAQ,GAAQ,CAAC,CAAC,KAAM,IAAA,GAAW,GAAI,IAAI,CAAC,SAAS,EAAI,CAAC,CAC3D,KAAM,GAAQ,EAAY,EAAK,EAAM,OAAO,CAAC,EAChD,GAAgB,SAAS,IAAI,GAG7B,EAAiB,EAAK,EAO1B,OAHA,OAAO,iBAAiB,UAAW,EAAc,KAGpC,OAAO,oBAAoB,UAAW,EAAc,GAElE,CAAC,EAAgB,EAAa,EAAU,EAAY,CAAC,CAWR,GAAS,CACvD,EAAY,CAAE,KAAM,EAAK,OAAM,WAAU,CAAC"}
|
|
@@ -1,107 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { useCommunicator } from "./CommunicatorContext.mjs";
|
|
4
|
-
import { useCrossFrameMessageListener } from "./useCrossFrameMessageListener.mjs";
|
|
5
|
-
import { useEffect, useState } from "react";
|
|
6
|
-
|
|
7
|
-
//#region src/useCrossFrameState.tsx
|
|
8
|
-
const resolveState = (state, prevState) => typeof state === "function" ? state(prevState) : state;
|
|
9
|
-
/**
|
|
10
|
-
* Configuration options for `useCrossFrameState`.
|
|
11
|
-
* @typedef {Object} CrossFrameStateOptions
|
|
12
|
-
* @property {boolean} [emit=true] - Whether to broadcast state changes to other instances.
|
|
13
|
-
* @property {boolean} [receive=true] - Whether to listen for state updates from other instances.
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* useCrossFrameState
|
|
17
|
-
*
|
|
18
|
-
* This React hook synchronizes state across multiple instances (e.g., different iframes or windows).
|
|
19
|
-
* It uses the `postMessage` API to communicate state changes and updates between instances.
|
|
20
|
-
*
|
|
21
|
-
* @template S - The type of the state.
|
|
22
|
-
* @param key - A unique identifier for the state to synchronize.
|
|
23
|
-
* @param initialState - The initial state value or a function to compute it lazily.
|
|
24
|
-
* @param options - Configuration options to control emitting and receiving messages.
|
|
25
|
-
* - `emit` (default: true): Whether to broadcast state changes to other instances.
|
|
26
|
-
* - `receive` (default: true): Whether to listen for state updates from other instances.
|
|
27
|
-
*
|
|
28
|
-
* @returns {[S, Dispatch<SetStateAction<S>>]} An array containing the current state and a setter function.
|
|
29
|
-
*/
|
|
30
|
-
const useCrossFrameState = (key, initialState, options) => {
|
|
31
|
-
const { postMessage, senderId } = useCommunicator();
|
|
32
|
-
const { emit, receive } = options ?? {
|
|
33
|
-
emit: true,
|
|
34
|
-
receive: true
|
|
35
|
-
};
|
|
36
|
-
const handleStateChange = (state, prevState) => {
|
|
37
|
-
const resolvedState = resolveState(state, prevState);
|
|
38
|
-
if (emit && typeof postMessage === "function" && typeof resolvedState !== "undefined") postMessage({
|
|
39
|
-
type: `${key}/post`,
|
|
40
|
-
data: resolvedState,
|
|
41
|
-
senderId
|
|
42
|
-
});
|
|
43
|
-
return resolvedState;
|
|
44
|
-
};
|
|
45
|
-
const postState = () => {
|
|
46
|
-
if (typeof postMessage !== "function") return;
|
|
47
|
-
postMessage({
|
|
48
|
-
type: `${key}/post`,
|
|
49
|
-
data: state,
|
|
50
|
-
senderId
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
const [state, setState] = useState(() => handleStateChange(initialState));
|
|
54
|
-
/**
|
|
55
|
-
* A wrapper function around the `setState` function to handle messaging efficiently.
|
|
56
|
-
*
|
|
57
|
-
* This approach has several advantages over using an additional `useEffect`:
|
|
58
|
-
* - **Avoid Redundant Re-renders:** By emitting the message directly within the `setState` logic,
|
|
59
|
-
* it prevents the extra render cycle that would be triggered when using `useEffect`.
|
|
60
|
-
* - **Consistency:** Ensures the message is emitted immediately when the state is updated,
|
|
61
|
-
* avoiding potential delays caused by the asynchronous nature of `useEffect`.
|
|
62
|
-
*
|
|
63
|
-
* This function keeps the same API as `setState` and is memoized using `useCallback`
|
|
64
|
-
* to prevent unnecessary re-renders of dependent components.
|
|
65
|
-
*
|
|
66
|
-
* @template S - The type of the state.
|
|
67
|
-
* @param {SetStateAction<S>} valueOrUpdater - The new state or a function to produce it.
|
|
68
|
-
* @returns {void}
|
|
69
|
-
*/
|
|
70
|
-
const setStateWrapper = (valueOrUpdater) => setState((prevState) => handleStateChange(valueOrUpdater, prevState));
|
|
71
|
-
/**
|
|
72
|
-
* Listen for messages with the specified key and update the state accordingly.
|
|
73
|
-
*/
|
|
74
|
-
useCrossFrameMessageListener(`${key}/post`, receive ? (data) => {
|
|
75
|
-
setState(data);
|
|
76
|
-
} : void 0);
|
|
77
|
-
const onGetMessage = (_, originSenderId) => {
|
|
78
|
-
if (!emit) return;
|
|
79
|
-
if (typeof postMessage !== "function") return;
|
|
80
|
-
if (originSenderId === senderId) return;
|
|
81
|
-
if (typeof state === "undefined") return;
|
|
82
|
-
postMessage({
|
|
83
|
-
type: `${key}/post`,
|
|
84
|
-
data: state,
|
|
85
|
-
senderId
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Listen for messages request to get the state content and send it back.
|
|
90
|
-
*/
|
|
91
|
-
useCrossFrameMessageListener(`${key}/get`, emit ? onGetMessage : void 0, state);
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
if (receive && typeof postMessage === "function" && typeof state === "undefined") postMessage({
|
|
94
|
-
type: `${key}/get`,
|
|
95
|
-
senderId
|
|
96
|
-
});
|
|
97
|
-
}, []);
|
|
98
|
-
return [
|
|
99
|
-
state,
|
|
100
|
-
setStateWrapper,
|
|
101
|
-
postState
|
|
102
|
-
];
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
//#endregion
|
|
106
|
-
export { useCrossFrameState };
|
|
1
|
+
"use client";import{useCommunicator as e}from"./CommunicatorContext.mjs";import{useCrossFrameMessageListener as t}from"./useCrossFrameMessageListener.mjs";import{useEffect as n,useState as r}from"react";const i=(e,t)=>typeof e==`function`?e(t):e,a=(a,o,s)=>{let{postMessage:c,senderId:l}=e(),{emit:u,receive:d}=s??{emit:!0,receive:!0},f=(e,t)=>{let n=i(e,t);return u&&typeof c==`function`&&n!==void 0&&c({type:`${a}/post`,data:n,senderId:l}),n},p=()=>{typeof c==`function`&&c({type:`${a}/post`,data:m,senderId:l})},[m,h]=r(()=>f(o));return t(`${a}/post`,d?e=>{h(e)}:void 0),t(`${a}/get`,u?(e,t)=>{u&&typeof c==`function`&&t!==l&&m!==void 0&&c({type:`${a}/post`,data:m,senderId:l})}:void 0,m),n(()=>{d&&typeof c==`function`&&m===void 0&&c({type:`${a}/get`,senderId:l})},[]),[m,e=>h(t=>f(e,t)),p]};export{a as useCrossFrameState};
|
|
107
2
|
//# sourceMappingURL=useCrossFrameState.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossFrameState.mjs","names":[],"sources":["../../src/useCrossFrameState.tsx"],"sourcesContent":["'use client';\n\nimport type { MessageKey } from '@intlayer/editor';\nimport { type Dispatch, type SetStateAction, useEffect, useState } from 'react';\nimport { useCommunicator } from './CommunicatorContext';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\nexport type CrossFrameStateOptions = {\n emit?: boolean;\n receive?: boolean;\n};\n\nconst resolveState = <S,>(state?: SetStateAction<S>, prevState?: S): S =>\n typeof state === 'function'\n ? (state as (prevState?: S) => S)(prevState)\n : (state as S);\n\n/**\n * Configuration options for `useCrossFrameState`.\n * @typedef {Object} CrossFrameStateOptions\n * @property {boolean} [emit=true] - Whether to broadcast state changes to other instances.\n * @property {boolean} [receive=true] - Whether to listen for state updates from other instances.\n */\n\n/**\n * useCrossFrameState\n *\n * This React hook synchronizes state across multiple instances (e.g., different iframes or windows).\n * It uses the `postMessage` API to communicate state changes and updates between instances.\n *\n * @template S - The type of the state.\n * @param key - A unique identifier for the state to synchronize.\n * @param initialState - The initial state value or a function to compute it lazily.\n * @param options - Configuration options to control emitting and receiving messages.\n * - `emit` (default: true): Whether to broadcast state changes to other instances.\n * - `receive` (default: true): Whether to listen for state updates from other instances.\n *\n * @returns {[S, Dispatch<SetStateAction<S>>]} An array containing the current state and a setter function.\n */\nexport const useCrossFrameState = <S,>(\n key: `${MessageKey}`,\n initialState?: S | (() => S),\n options?: CrossFrameStateOptions\n): [S, Dispatch<SetStateAction<S>>, typeof postState] => {\n const { postMessage, senderId } = useCommunicator();\n\n const { emit, receive } = options ?? { emit: true, receive: true };\n\n const handleStateChange = (state?: SetStateAction<S>, prevState?: S) => {\n // Initialize state from the provided initial value, if defined\n const resolvedState: S = resolveState(state, prevState);\n\n // Emit the initial state if `emit` is enabled and initial state is defined\n if (\n emit &&\n typeof postMessage === 'function' &&\n typeof resolvedState !== 'undefined'\n ) {\n postMessage({ type: `${key}/post`, data: resolvedState, senderId });\n }\n\n return resolvedState;\n };\n\n const postState = () => {\n if (typeof postMessage !== 'function') return;\n postMessage({ type: `${key}/post`, data: state, senderId });\n };\n\n const [state, setState] = useState<S>(() => handleStateChange(initialState));\n\n /**\n * A wrapper function around the `setState` function to handle messaging efficiently.\n *\n * This approach has several advantages over using an additional `useEffect`:\n * - **Avoid Redundant Re-renders:** By emitting the message directly within the `setState` logic,\n * it prevents the extra render cycle that would be triggered when using `useEffect`.\n * - **Consistency:** Ensures the message is emitted immediately when the state is updated,\n * avoiding potential delays caused by the asynchronous nature of `useEffect`.\n *\n * This function keeps the same API as `setState` and is memoized using `useCallback`\n * to prevent unnecessary re-renders of dependent components.\n *\n * @template S - The type of the state.\n * @param {SetStateAction<S>} valueOrUpdater - The new state or a function to produce it.\n * @returns {void}\n */\n const setStateWrapper: Dispatch<SetStateAction<S>> = (valueOrUpdater) =>\n setState((prevState) => handleStateChange(valueOrUpdater, prevState));\n\n /**\n * Listen for messages with the specified key and update the state accordingly.\n */\n useCrossFrameMessageListener<S>(\n `${key}/post`,\n // Only activate the state listener if the `receive` option is true\n receive\n ? (data) => {\n setState(data);\n }\n : undefined\n );\n\n const onGetMessage = (_: unknown, originSenderId?: string) => {\n if (!emit) return;\n if (typeof postMessage !== 'function') return;\n if (originSenderId === senderId) return;\n if (typeof state === 'undefined') return;\n\n postMessage({ type: `${key}/post`, data: state, senderId });\n };\n\n /**\n * Listen for messages request to get the state content and send it back.\n */\n useCrossFrameMessageListener<S>(\n `${key}/get`,\n // Only activate the state listener if the `emit` option is true\n emit ? onGetMessage : undefined,\n state // Revalidate the listener if the state changes\n );\n\n useEffect(() => {\n // If the component is mounted and the hook in receive mode,\n // Request the state from the other instance\n if (\n receive &&\n typeof postMessage === 'function' &&\n typeof state === 'undefined'\n ) {\n postMessage({ type: `${key}/get`, senderId });\n }\n }, []);\n\n // Return the useState state and setter\n return [state, setStateWrapper, postState];\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCrossFrameState.mjs","names":[],"sources":["../../src/useCrossFrameState.tsx"],"sourcesContent":["'use client';\n\nimport type { MessageKey } from '@intlayer/editor';\nimport { type Dispatch, type SetStateAction, useEffect, useState } from 'react';\nimport { useCommunicator } from './CommunicatorContext';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\nexport type CrossFrameStateOptions = {\n emit?: boolean;\n receive?: boolean;\n};\n\nconst resolveState = <S,>(state?: SetStateAction<S>, prevState?: S): S =>\n typeof state === 'function'\n ? (state as (prevState?: S) => S)(prevState)\n : (state as S);\n\n/**\n * Configuration options for `useCrossFrameState`.\n * @typedef {Object} CrossFrameStateOptions\n * @property {boolean} [emit=true] - Whether to broadcast state changes to other instances.\n * @property {boolean} [receive=true] - Whether to listen for state updates from other instances.\n */\n\n/**\n * useCrossFrameState\n *\n * This React hook synchronizes state across multiple instances (e.g., different iframes or windows).\n * It uses the `postMessage` API to communicate state changes and updates between instances.\n *\n * @template S - The type of the state.\n * @param key - A unique identifier for the state to synchronize.\n * @param initialState - The initial state value or a function to compute it lazily.\n * @param options - Configuration options to control emitting and receiving messages.\n * - `emit` (default: true): Whether to broadcast state changes to other instances.\n * - `receive` (default: true): Whether to listen for state updates from other instances.\n *\n * @returns {[S, Dispatch<SetStateAction<S>>]} An array containing the current state and a setter function.\n */\nexport const useCrossFrameState = <S,>(\n key: `${MessageKey}`,\n initialState?: S | (() => S),\n options?: CrossFrameStateOptions\n): [S, Dispatch<SetStateAction<S>>, typeof postState] => {\n const { postMessage, senderId } = useCommunicator();\n\n const { emit, receive } = options ?? { emit: true, receive: true };\n\n const handleStateChange = (state?: SetStateAction<S>, prevState?: S) => {\n // Initialize state from the provided initial value, if defined\n const resolvedState: S = resolveState(state, prevState);\n\n // Emit the initial state if `emit` is enabled and initial state is defined\n if (\n emit &&\n typeof postMessage === 'function' &&\n typeof resolvedState !== 'undefined'\n ) {\n postMessage({ type: `${key}/post`, data: resolvedState, senderId });\n }\n\n return resolvedState;\n };\n\n const postState = () => {\n if (typeof postMessage !== 'function') return;\n postMessage({ type: `${key}/post`, data: state, senderId });\n };\n\n const [state, setState] = useState<S>(() => handleStateChange(initialState));\n\n /**\n * A wrapper function around the `setState` function to handle messaging efficiently.\n *\n * This approach has several advantages over using an additional `useEffect`:\n * - **Avoid Redundant Re-renders:** By emitting the message directly within the `setState` logic,\n * it prevents the extra render cycle that would be triggered when using `useEffect`.\n * - **Consistency:** Ensures the message is emitted immediately when the state is updated,\n * avoiding potential delays caused by the asynchronous nature of `useEffect`.\n *\n * This function keeps the same API as `setState` and is memoized using `useCallback`\n * to prevent unnecessary re-renders of dependent components.\n *\n * @template S - The type of the state.\n * @param {SetStateAction<S>} valueOrUpdater - The new state or a function to produce it.\n * @returns {void}\n */\n const setStateWrapper: Dispatch<SetStateAction<S>> = (valueOrUpdater) =>\n setState((prevState) => handleStateChange(valueOrUpdater, prevState));\n\n /**\n * Listen for messages with the specified key and update the state accordingly.\n */\n useCrossFrameMessageListener<S>(\n `${key}/post`,\n // Only activate the state listener if the `receive` option is true\n receive\n ? (data) => {\n setState(data);\n }\n : undefined\n );\n\n const onGetMessage = (_: unknown, originSenderId?: string) => {\n if (!emit) return;\n if (typeof postMessage !== 'function') return;\n if (originSenderId === senderId) return;\n if (typeof state === 'undefined') return;\n\n postMessage({ type: `${key}/post`, data: state, senderId });\n };\n\n /**\n * Listen for messages request to get the state content and send it back.\n */\n useCrossFrameMessageListener<S>(\n `${key}/get`,\n // Only activate the state listener if the `emit` option is true\n emit ? onGetMessage : undefined,\n state // Revalidate the listener if the state changes\n );\n\n useEffect(() => {\n // If the component is mounted and the hook in receive mode,\n // Request the state from the other instance\n if (\n receive &&\n typeof postMessage === 'function' &&\n typeof state === 'undefined'\n ) {\n postMessage({ type: `${key}/get`, senderId });\n }\n }, []);\n\n // Return the useState state and setter\n return [state, setStateWrapper, postState];\n};\n"],"mappings":"2MAYA,MAAM,GAAoB,EAA2B,IACnD,OAAO,GAAU,WACZ,EAA+B,EAAU,CACzC,EAwBM,GACX,EACA,EACA,IACuD,CACvD,GAAM,CAAE,cAAa,YAAa,GAAiB,CAE7C,CAAE,OAAM,WAAY,GAAW,CAAE,KAAM,GAAM,QAAS,GAAM,CAE5D,GAAqB,EAA2B,IAAkB,CAEtE,IAAM,EAAmB,EAAa,EAAO,EAAU,CAWvD,OAPE,GACA,OAAO,GAAgB,YAChB,IAAkB,QAEzB,EAAY,CAAE,KAAM,GAAG,EAAI,OAAQ,KAAM,EAAe,WAAU,CAAC,CAG9D,GAGH,MAAkB,CAClB,OAAO,GAAgB,YAC3B,EAAY,CAAE,KAAM,GAAG,EAAI,OAAQ,KAAM,EAAO,WAAU,CAAC,EAGvD,CAAC,EAAO,GAAY,MAAkB,EAAkB,EAAa,CAAC,CAkE5E,OA1CA,EACE,GAAG,EAAI,OAEP,EACK,GAAS,CACR,EAAS,EAAK,EAEhB,IAAA,GACL,CAcD,EACE,GAAG,EAAI,MAEP,GAfoB,EAAY,IAA4B,CACvD,GACD,OAAO,GAAgB,YACvB,IAAmB,GACZ,IAAU,QAErB,EAAY,CAAE,KAAM,GAAG,EAAI,OAAQ,KAAM,EAAO,WAAU,CAAC,EASrC,IAAA,GACtB,EACD,CAED,MAAgB,CAIZ,GACA,OAAO,GAAgB,YAChB,IAAU,QAEjB,EAAY,CAAE,KAAM,GAAG,EAAI,MAAO,WAAU,CAAC,EAE9C,EAAE,CAAC,CAGC,CAAC,EAhD8C,GACpD,EAAU,GAAc,EAAkB,EAAgB,EAAU,CAAC,CA+CvC,EAAU"}
|
|
@@ -1,65 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { useCrossFrameState } from "./useCrossFrameState.mjs";
|
|
4
|
-
import { useEffect } from "react";
|
|
5
|
-
import { MessageKey } from "@intlayer/editor";
|
|
6
|
-
|
|
7
|
-
//#region src/useCrossURLPathState.tsx
|
|
8
|
-
const useCrossURLPathState = (initialState, options) => useCrossFrameState(MessageKey.INTLAYER_URL_CHANGE, initialState, options);
|
|
9
|
-
const useCrossURLPathSetter = (initialState) => {
|
|
10
|
-
const states = useCrossURLPathState(initialState, {
|
|
11
|
-
emit: true,
|
|
12
|
-
receive: false
|
|
13
|
-
});
|
|
14
|
-
const [_state, setState] = states;
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
/**
|
|
17
|
-
* 1) Monkey patch history methods (pushState, replaceState)
|
|
18
|
-
* to dispatch a custom event whenever they are called.
|
|
19
|
-
*/
|
|
20
|
-
const originalPushState = history.pushState;
|
|
21
|
-
const originalReplaceState = history.replaceState;
|
|
22
|
-
const injectLocationChangeEvent = (method) => function(...args) {
|
|
23
|
-
method.apply(this, args);
|
|
24
|
-
window.dispatchEvent(new Event("locationchange"));
|
|
25
|
-
};
|
|
26
|
-
history.pushState = injectLocationChangeEvent(originalPushState);
|
|
27
|
-
history.replaceState = injectLocationChangeEvent(originalReplaceState);
|
|
28
|
-
/**
|
|
29
|
-
* 2) The callback to update our state whenever the URL changes.
|
|
30
|
-
*/
|
|
31
|
-
const updateURLState = () => {
|
|
32
|
-
setState(window.location.pathname);
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* 3) Attach event listeners for locationchange, popstate, hashchange.
|
|
36
|
-
* - 'locationchange' is our custom event triggered by push/replaceState overrides.
|
|
37
|
-
* - 'popstate' is fired on back/forward navigation.
|
|
38
|
-
* - 'hashchange' is for URL hash (#) changes.
|
|
39
|
-
* - 'load' is when new page is loaded
|
|
40
|
-
*/
|
|
41
|
-
window.addEventListener("locationchange", updateURLState);
|
|
42
|
-
window.addEventListener("popstate", updateURLState);
|
|
43
|
-
window.addEventListener("hashchange", updateURLState);
|
|
44
|
-
window.addEventListener("load", updateURLState);
|
|
45
|
-
updateURLState();
|
|
46
|
-
/**
|
|
47
|
-
* 4) Cleanup when the component unmounts:
|
|
48
|
-
* - Remove event listeners.
|
|
49
|
-
* - Restore original pushState & replaceState to avoid side effects.
|
|
50
|
-
*/
|
|
51
|
-
return () => {
|
|
52
|
-
window.removeEventListener("locationchange", updateURLState);
|
|
53
|
-
window.removeEventListener("popstate", updateURLState);
|
|
54
|
-
window.removeEventListener("hashchange", updateURLState);
|
|
55
|
-
window.removeEventListener("load", updateURLState);
|
|
56
|
-
history.pushState = originalPushState;
|
|
57
|
-
history.replaceState = originalReplaceState;
|
|
58
|
-
};
|
|
59
|
-
}, []);
|
|
60
|
-
return states;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
//#endregion
|
|
64
|
-
export { useCrossURLPathSetter, useCrossURLPathState };
|
|
1
|
+
"use client";import{useCrossFrameState as e}from"./useCrossFrameState.mjs";import{useEffect as t}from"react";import{MessageKey as n}from"@intlayer/editor";const r=(t,r)=>e(n.INTLAYER_URL_CHANGE,t,r),i=e=>{let n=r(e,{emit:!0,receive:!1}),[i,a]=n;return t(()=>{let e=history.pushState,t=history.replaceState,n=e=>function(...t){e.apply(this,t),window.dispatchEvent(new Event(`locationchange`))};history.pushState=n(e),history.replaceState=n(t);let r=()=>{a(window.location.pathname)};return window.addEventListener(`locationchange`,r),window.addEventListener(`popstate`,r),window.addEventListener(`hashchange`,r),window.addEventListener(`load`,r),r(),()=>{window.removeEventListener(`locationchange`,r),window.removeEventListener(`popstate`,r),window.removeEventListener(`hashchange`,r),window.removeEventListener(`load`,r),history.pushState=e,history.replaceState=t}},[]),n};export{i as useCrossURLPathSetter,r as useCrossURLPathState};
|
|
65
2
|
//# sourceMappingURL=useCrossURLPathState.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossURLPathState.mjs","names":[],"sources":["../../src/useCrossURLPathState.tsx"],"sourcesContent":["'use client';\n\nimport { MessageKey } from '@intlayer/editor';\nimport { useEffect } from 'react';\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 const states = useCrossURLPathState(initialState, {\n emit: true,\n receive: false,\n });\n const [_state, setState] = states;\n\n useEffect(() => {\n /**\n * 1) Monkey patch history methods (pushState, replaceState)\n * to dispatch a custom event whenever they are called.\n */\n const originalPushState = history.pushState;\n const originalReplaceState = history.replaceState;\n\n const injectLocationChangeEvent = (method: (...args: any[]) => void) =>\n function (this: typeof history, ...args: [any, string, string?]) {\n method.apply(this, args);\n window.dispatchEvent(new Event('locationchange'));\n };\n\n history.pushState = injectLocationChangeEvent(originalPushState);\n history.replaceState = injectLocationChangeEvent(originalReplaceState);\n\n /**\n * 2) The callback to update our state whenever the URL changes.\n */\n const updateURLState = () => {\n setState(window.location.pathname);\n };\n\n /**\n * 3) Attach event listeners for locationchange, popstate, hashchange.\n * - 'locationchange' is our custom event triggered by push/replaceState overrides.\n * - 'popstate' is fired on back/forward navigation.\n * - 'hashchange' is for URL hash (#) changes.\n * - 'load' is when new page is loaded\n */\n window.addEventListener('locationchange', updateURLState);\n window.addEventListener('popstate', updateURLState);\n window.addEventListener('hashchange', updateURLState);\n window.addEventListener('load', updateURLState);\n\n // Initialize our state immediately on mount\n updateURLState();\n\n /**\n * 4) Cleanup when the component unmounts:\n * - Remove event listeners.\n * - Restore original pushState & replaceState to avoid side effects.\n */\n return () => {\n window.removeEventListener('locationchange', updateURLState);\n window.removeEventListener('popstate', updateURLState);\n window.removeEventListener('hashchange', updateURLState);\n window.removeEventListener('load', updateURLState);\n history.pushState = originalPushState;\n history.replaceState = originalReplaceState;\n };\n }, []);\n\n return states;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCrossURLPathState.mjs","names":[],"sources":["../../src/useCrossURLPathState.tsx"],"sourcesContent":["'use client';\n\nimport { MessageKey } from '@intlayer/editor';\nimport { useEffect } from 'react';\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 const states = useCrossURLPathState(initialState, {\n emit: true,\n receive: false,\n });\n const [_state, setState] = states;\n\n useEffect(() => {\n /**\n * 1) Monkey patch history methods (pushState, replaceState)\n * to dispatch a custom event whenever they are called.\n */\n const originalPushState = history.pushState;\n const originalReplaceState = history.replaceState;\n\n const injectLocationChangeEvent = (method: (...args: any[]) => void) =>\n function (this: typeof history, ...args: [any, string, string?]) {\n method.apply(this, args);\n window.dispatchEvent(new Event('locationchange'));\n };\n\n history.pushState = injectLocationChangeEvent(originalPushState);\n history.replaceState = injectLocationChangeEvent(originalReplaceState);\n\n /**\n * 2) The callback to update our state whenever the URL changes.\n */\n const updateURLState = () => {\n setState(window.location.pathname);\n };\n\n /**\n * 3) Attach event listeners for locationchange, popstate, hashchange.\n * - 'locationchange' is our custom event triggered by push/replaceState overrides.\n * - 'popstate' is fired on back/forward navigation.\n * - 'hashchange' is for URL hash (#) changes.\n * - 'load' is when new page is loaded\n */\n window.addEventListener('locationchange', updateURLState);\n window.addEventListener('popstate', updateURLState);\n window.addEventListener('hashchange', updateURLState);\n window.addEventListener('load', updateURLState);\n\n // Initialize our state immediately on mount\n updateURLState();\n\n /**\n * 4) Cleanup when the component unmounts:\n * - Remove event listeners.\n * - Restore original pushState & replaceState to avoid side effects.\n */\n return () => {\n window.removeEventListener('locationchange', updateURLState);\n window.removeEventListener('popstate', updateURLState);\n window.removeEventListener('hashchange', updateURLState);\n window.removeEventListener('load', updateURLState);\n history.pushState = originalPushState;\n history.replaceState = originalReplaceState;\n };\n }, []);\n\n return states;\n};\n"],"mappings":"2JASA,MAAa,GACX,EACA,IACG,EAAmB,EAAW,oBAAqB,EAAc,EAAQ,CAEjE,EAAyB,GAA0B,CAC9D,IAAM,EAAS,EAAqB,EAAc,CAChD,KAAM,GACN,QAAS,GACV,CAAC,CACI,CAAC,EAAQ,GAAY,EAwD3B,OAtDA,MAAgB,CAKd,IAAM,EAAoB,QAAQ,UAC5B,EAAuB,QAAQ,aAE/B,EAA6B,GACjC,SAAgC,GAAG,EAA8B,CAC/D,EAAO,MAAM,KAAM,EAAK,CACxB,OAAO,cAAc,IAAI,MAAM,iBAAiB,CAAC,EAGrD,QAAQ,UAAY,EAA0B,EAAkB,CAChE,QAAQ,aAAe,EAA0B,EAAqB,CAKtE,IAAM,MAAuB,CAC3B,EAAS,OAAO,SAAS,SAAS,EAuBpC,OAbA,OAAO,iBAAiB,iBAAkB,EAAe,CACzD,OAAO,iBAAiB,WAAY,EAAe,CACnD,OAAO,iBAAiB,aAAc,EAAe,CACrD,OAAO,iBAAiB,OAAQ,EAAe,CAG/C,GAAgB,KAOH,CACX,OAAO,oBAAoB,iBAAkB,EAAe,CAC5D,OAAO,oBAAoB,WAAY,EAAe,CACtD,OAAO,oBAAoB,aAAc,EAAe,CACxD,OAAO,oBAAoB,OAAQ,EAAe,CAClD,QAAQ,UAAY,EACpB,QAAQ,aAAe,IAExB,EAAE,CAAC,CAEC"}
|
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { MessageKey } from "@intlayer/editor";
|
|
3
|
-
|
|
4
|
-
//#region src/useEditorLocale.tsx
|
|
5
|
-
const useEditorLocale = () => {
|
|
6
|
-
const [currentLocale] = useCrossFrameState(MessageKey.INTLAYER_CURRENT_LOCALE, void 0, {
|
|
7
|
-
receive: true,
|
|
8
|
-
emit: false
|
|
9
|
-
});
|
|
10
|
-
return currentLocale;
|
|
11
|
-
};
|
|
12
|
-
const useSetEditorLocale = () => {
|
|
13
|
-
return useCrossFrameState(MessageKey.INTLAYER_CURRENT_LOCALE, void 0, {
|
|
14
|
-
receive: true,
|
|
15
|
-
emit: false
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { useEditorLocale, useSetEditorLocale };
|
|
1
|
+
import{useCrossFrameState as e}from"./useCrossFrameState.mjs";import{MessageKey as t}from"@intlayer/editor";const n=()=>{let[n]=e(t.INTLAYER_CURRENT_LOCALE,void 0,{receive:!0,emit:!1});return n},r=()=>e(t.INTLAYER_CURRENT_LOCALE,void 0,{receive:!0,emit:!1});export{n as useEditorLocale,r as useSetEditorLocale};
|
|
21
2
|
//# sourceMappingURL=useEditorLocale.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditorLocale.mjs","names":[],"sources":["../../src/useEditorLocale.tsx"],"sourcesContent":["import { MessageKey } from '@intlayer/editor';\nimport type { Locale } from '@intlayer/types';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useEditorLocale = () => {\n const [currentLocale] = useCrossFrameState<Locale>(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n undefined,\n {\n receive: true,\n emit: false,\n }\n );\n\n return currentLocale;\n};\n\nexport const useSetEditorLocale = () => {\n const setCurrentLocale = useCrossFrameState<Locale>(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n undefined,\n {\n receive: true,\n emit: false,\n }\n );\n\n return setCurrentLocale;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEditorLocale.mjs","names":[],"sources":["../../src/useEditorLocale.tsx"],"sourcesContent":["import { MessageKey } from '@intlayer/editor';\nimport type { Locale } from '@intlayer/types';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useEditorLocale = () => {\n const [currentLocale] = useCrossFrameState<Locale>(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n undefined,\n {\n receive: true,\n emit: false,\n }\n );\n\n return currentLocale;\n};\n\nexport const useSetEditorLocale = () => {\n const setCurrentLocale = useCrossFrameState<Locale>(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n undefined,\n {\n receive: true,\n emit: false,\n }\n );\n\n return setCurrentLocale;\n};\n"],"mappings":"4GAIA,MAAa,MAAwB,CACnC,GAAM,CAAC,GAAiB,EACtB,EAAW,wBACX,IAAA,GACA,CACE,QAAS,GACT,KAAM,GACP,CACF,CAED,OAAO,GAGI,MACc,EACvB,EAAW,wBACX,IAAA,GACA,CACE,QAAS,GACT,KAAM,GACP,CACF"}
|
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { useDictionariesRecord } from "./DictionariesRecordContext.mjs";
|
|
4
|
-
import { useEditorLocale } from "./useEditorLocale.mjs";
|
|
5
|
-
import { useFocusDictionary } from "./FocusDictionaryContext.mjs";
|
|
6
|
-
import { useMemo } from "react";
|
|
7
|
-
import { getContentNodeByKeyPath } from "@intlayer/core";
|
|
8
|
-
|
|
9
|
-
//#region src/useFocusUnmergedDictionary.tsx
|
|
10
|
-
/**
|
|
11
|
-
* Converts merged keypath format to unmerged format.
|
|
12
|
-
* Merged: [{type: "translation", key: "fr"}, {type: "object", key: "title"}]
|
|
13
|
-
* Unmerged: [{type: "object", key: "title"}, {type: "translation", key: "fr"}]
|
|
14
|
-
*/
|
|
15
|
-
const mergedKeyPathToUnmergedKeyPath = (keyPath, dictionaries, locale) => {
|
|
16
|
-
for (const dictionary of dictionaries) try {
|
|
17
|
-
if (getContentNodeByKeyPath(dictionary.content, keyPath ?? [], locale)) return {
|
|
18
|
-
keyPath,
|
|
19
|
-
dictionaryLocalId: dictionary.localId
|
|
20
|
-
};
|
|
21
|
-
} catch {}
|
|
22
|
-
};
|
|
23
|
-
const useFocusUnmergedDictionary = () => {
|
|
24
|
-
const { localeDictionaries } = useDictionariesRecord();
|
|
25
|
-
const currentLocale = useEditorLocale();
|
|
26
|
-
const { setFocusedContent, setFocusedContentKeyPath, focusedContent: mergedFocusedContent } = useFocusDictionary();
|
|
27
|
-
return {
|
|
28
|
-
focusedContent: useMemo(() => {
|
|
29
|
-
if (!mergedFocusedContent) return mergedFocusedContent;
|
|
30
|
-
if (!localeDictionaries) return mergedFocusedContent;
|
|
31
|
-
if (mergedFocusedContent.dictionaryLocalId) return mergedFocusedContent;
|
|
32
|
-
const dictionaries = Object.values(localeDictionaries).filter((dictionary) => dictionary.key === mergedFocusedContent.dictionaryKey);
|
|
33
|
-
const unmergedKeyPath = mergedKeyPathToUnmergedKeyPath(mergedFocusedContent.keyPath ?? [], dictionaries, currentLocale);
|
|
34
|
-
return {
|
|
35
|
-
...mergedFocusedContent,
|
|
36
|
-
...unmergedKeyPath
|
|
37
|
-
};
|
|
38
|
-
}, [
|
|
39
|
-
mergedFocusedContent,
|
|
40
|
-
localeDictionaries,
|
|
41
|
-
currentLocale
|
|
42
|
-
]),
|
|
43
|
-
setFocusedContent,
|
|
44
|
-
setFocusedContentKeyPath
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
export { useFocusUnmergedDictionary };
|
|
1
|
+
"use client";import{useDictionariesRecord as e}from"./DictionariesRecordContext.mjs";import{useEditorLocale as t}from"./useEditorLocale.mjs";import{useFocusDictionary as n}from"./FocusDictionaryContext.mjs";import{useMemo as r}from"react";import{getContentNodeByKeyPath as i}from"@intlayer/core/dictionaryManipulator";const a=(e,t,n)=>{for(let r of t)try{if(i(r.content,e??[],n))return{keyPath:e,dictionaryLocalId:r.localId}}catch{}},o=()=>{let{localeDictionaries:i}=e(),o=t(),{setFocusedContent:s,setFocusedContentKeyPath:c,focusedContent:l}=n();return{focusedContent:r(()=>{if(!l||!i||l.dictionaryLocalId)return l;let e=Object.values(i).filter(e=>e.key===l.dictionaryKey),t=a(l.keyPath??[],e,o);return{...l,...t}},[l,i,o]),setFocusedContent:s,setFocusedContentKeyPath:c}};export{o as useFocusUnmergedDictionary};
|
|
50
2
|
//# sourceMappingURL=useFocusUnmergedDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusUnmergedDictionary.mjs","names":[],"sources":["../../src/useFocusUnmergedDictionary.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core';\nimport type {\n Dictionary,\n KeyPath,\n LocalDictionaryId,\n Locale,\n} from '@intlayer/types';\nimport { useMemo } from 'react';\nimport { useDictionariesRecord } from './DictionariesRecordContext';\nimport { type FileContent, useFocusDictionary } from './FocusDictionaryContext';\nimport { useEditorLocale } from './useEditorLocale';\n\ntype UnmergedKeyPath = {\n keyPath: KeyPath[];\n dictionaryLocalId?: LocalDictionaryId;\n};\n\n/**\n * Converts merged keypath format to unmerged format.\n * Merged: [{type: \"translation\", key: \"fr\"}, {type: \"object\", key: \"title\"}]\n * Unmerged: [{type: \"object\", key: \"title\"}, {type: \"translation\", key: \"fr\"}]\n */\nconst mergedKeyPathToUnmergedKeyPath = (\n keyPath: KeyPath[],\n dictionaries: Dictionary[],\n locale: Locale\n): UnmergedKeyPath | undefined => {\n // If we have a dictionary, verify the path exists\n // Try to find the correct position for the translation key\n // by checking which path actually exists in the dictionary\n for (const dictionary of dictionaries) {\n try {\n const result = getContentNodeByKeyPath(\n dictionary.content,\n keyPath ?? [],\n locale\n );\n\n if (result) {\n return { keyPath, dictionaryLocalId: dictionary.localId };\n }\n } catch {\n // Continue to next candidate\n }\n }\n};\n\nexport const useFocusUnmergedDictionary = () => {\n const { localeDictionaries } = useDictionariesRecord();\n const currentLocale = useEditorLocale();\n const {\n setFocusedContent,\n setFocusedContentKeyPath,\n focusedContent: mergedFocusedContent,\n } = useFocusDictionary();\n\n const focusedContent = useMemo<FileContent | null>(() => {\n if (!mergedFocusedContent) return mergedFocusedContent;\n if (!localeDictionaries) return mergedFocusedContent;\n if (mergedFocusedContent.dictionaryLocalId) return mergedFocusedContent;\n\n const dictionaries = Object.values(localeDictionaries).filter(\n (dictionary) => dictionary.key === mergedFocusedContent.dictionaryKey\n );\n\n const unmergedKeyPath = mergedKeyPathToUnmergedKeyPath(\n mergedFocusedContent.keyPath ?? [],\n dictionaries,\n currentLocale\n );\n\n return {\n ...mergedFocusedContent,\n ...unmergedKeyPath,\n };\n }, [mergedFocusedContent, localeDictionaries, currentLocale]);\n\n return {\n focusedContent,\n setFocusedContent,\n setFocusedContentKeyPath,\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFocusUnmergedDictionary.mjs","names":[],"sources":["../../src/useFocusUnmergedDictionary.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n KeyPath,\n LocalDictionaryId,\n Locale,\n} from '@intlayer/types';\nimport { useMemo } from 'react';\nimport { useDictionariesRecord } from './DictionariesRecordContext';\nimport { type FileContent, useFocusDictionary } from './FocusDictionaryContext';\nimport { useEditorLocale } from './useEditorLocale';\n\ntype UnmergedKeyPath = {\n keyPath: KeyPath[];\n dictionaryLocalId?: LocalDictionaryId;\n};\n\n/**\n * Converts merged keypath format to unmerged format.\n * Merged: [{type: \"translation\", key: \"fr\"}, {type: \"object\", key: \"title\"}]\n * Unmerged: [{type: \"object\", key: \"title\"}, {type: \"translation\", key: \"fr\"}]\n */\nconst mergedKeyPathToUnmergedKeyPath = (\n keyPath: KeyPath[],\n dictionaries: Dictionary[],\n locale: Locale\n): UnmergedKeyPath | undefined => {\n // If we have a dictionary, verify the path exists\n // Try to find the correct position for the translation key\n // by checking which path actually exists in the dictionary\n for (const dictionary of dictionaries) {\n try {\n const result = getContentNodeByKeyPath(\n dictionary.content,\n keyPath ?? [],\n locale\n );\n\n if (result) {\n return { keyPath, dictionaryLocalId: dictionary.localId };\n }\n } catch {\n // Continue to next candidate\n }\n }\n};\n\nexport const useFocusUnmergedDictionary = () => {\n const { localeDictionaries } = useDictionariesRecord();\n const currentLocale = useEditorLocale();\n const {\n setFocusedContent,\n setFocusedContentKeyPath,\n focusedContent: mergedFocusedContent,\n } = useFocusDictionary();\n\n const focusedContent = useMemo<FileContent | null>(() => {\n if (!mergedFocusedContent) return mergedFocusedContent;\n if (!localeDictionaries) return mergedFocusedContent;\n if (mergedFocusedContent.dictionaryLocalId) return mergedFocusedContent;\n\n const dictionaries = Object.values(localeDictionaries).filter(\n (dictionary) => dictionary.key === mergedFocusedContent.dictionaryKey\n );\n\n const unmergedKeyPath = mergedKeyPathToUnmergedKeyPath(\n mergedFocusedContent.keyPath ?? [],\n dictionaries,\n currentLocale\n );\n\n return {\n ...mergedFocusedContent,\n ...unmergedKeyPath,\n };\n }, [mergedFocusedContent, localeDictionaries, currentLocale]);\n\n return {\n focusedContent,\n setFocusedContent,\n setFocusedContentKeyPath,\n };\n};\n"],"mappings":"8TAwBA,MAAM,GACJ,EACA,EACA,IACgC,CAIhC,IAAK,IAAM,KAAc,EACvB,GAAI,CAOF,GANe,EACb,EAAW,QACX,GAAW,EAAE,CACb,EACD,CAGC,MAAO,CAAE,UAAS,kBAAmB,EAAW,QAAS,MAErD,IAMC,MAAmC,CAC9C,GAAM,CAAE,sBAAuB,GAAuB,CAChD,EAAgB,GAAiB,CACjC,CACJ,oBACA,2BACA,eAAgB,GACd,GAAoB,CAuBxB,MAAO,CACL,eAtBqB,MAAkC,CAGvD,GAFI,CAAC,GACD,CAAC,GACD,EAAqB,kBAAmB,OAAO,EAEnD,IAAM,EAAe,OAAO,OAAO,EAAmB,CAAC,OACpD,GAAe,EAAW,MAAQ,EAAqB,cACzD,CAEK,EAAkB,EACtB,EAAqB,SAAW,EAAE,CAClC,EACA,EACD,CAED,MAAO,CACL,GAAG,EACH,GAAG,EACJ,EACA,CAAC,EAAsB,EAAoB,EAAc,CAAC,CAI3D,oBACA,2BACD"}
|
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { useCrossFrameMessageListener } from "./useCrossFrameMessageListener.mjs";
|
|
4
|
-
import { useEffect } from "react";
|
|
5
|
-
import { MessageKey, mergeIframeClick } from "@intlayer/editor";
|
|
6
|
-
|
|
7
|
-
//#region src/useIframeClickInterceptor.tsx
|
|
8
|
-
const useIframeClickInterceptor = () => {
|
|
9
|
-
const postMessage = useCrossFrameMessageListener(MessageKey.INTLAYER_IFRAME_CLICKED);
|
|
10
|
-
const handlePostMessageEvent = () => {
|
|
11
|
-
postMessage();
|
|
12
|
-
};
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
window.addEventListener("mousedown", handlePostMessageEvent);
|
|
15
|
-
return () => window.removeEventListener("mousedown", handlePostMessageEvent);
|
|
16
|
-
}, [postMessage]);
|
|
17
|
-
};
|
|
18
|
-
const useIframeClickMerger = () => useCrossFrameMessageListener(MessageKey.INTLAYER_IFRAME_CLICKED, mergeIframeClick);
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { useIframeClickInterceptor, useIframeClickMerger };
|
|
1
|
+
"use client";import{useCrossFrameMessageListener as e}from"./useCrossFrameMessageListener.mjs";import{useEffect as t}from"react";import{MessageKey as n,mergeIframeClick as r}from"@intlayer/editor";const i=()=>{let r=e(n.INTLAYER_IFRAME_CLICKED),i=()=>{r()};t(()=>(window.addEventListener(`mousedown`,i),()=>window.removeEventListener(`mousedown`,i)),[r])},a=()=>e(n.INTLAYER_IFRAME_CLICKED,r);export{i as useIframeClickInterceptor,a as useIframeClickMerger};
|
|
22
2
|
//# sourceMappingURL=useIframeClickInterceptor.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIframeClickInterceptor.mjs","names":[],"sources":["../../src/useIframeClickInterceptor.tsx"],"sourcesContent":["'use client';\n\nimport { MessageKey, mergeIframeClick } from '@intlayer/editor';\nimport { useEffect } from 'react';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\nexport const useIframeClickInterceptor = () => {\n const postMessage = useCrossFrameMessageListener<undefined>(\n MessageKey.INTLAYER_IFRAME_CLICKED\n );\n const handlePostMessageEvent: EventListener = () => {\n postMessage();\n };\n\n useEffect(() => {\n window.addEventListener('mousedown', handlePostMessageEvent);\n\n return () =>\n window.removeEventListener('mousedown', handlePostMessageEvent);\n }, [postMessage]);\n};\n\nexport const useIframeClickMerger = () =>\n useCrossFrameMessageListener<MessageEvent>(\n MessageKey.INTLAYER_IFRAME_CLICKED,\n mergeIframeClick\n );\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIframeClickInterceptor.mjs","names":[],"sources":["../../src/useIframeClickInterceptor.tsx"],"sourcesContent":["'use client';\n\nimport { MessageKey, mergeIframeClick } from '@intlayer/editor';\nimport { useEffect } from 'react';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\nexport const useIframeClickInterceptor = () => {\n const postMessage = useCrossFrameMessageListener<undefined>(\n MessageKey.INTLAYER_IFRAME_CLICKED\n );\n const handlePostMessageEvent: EventListener = () => {\n postMessage();\n };\n\n useEffect(() => {\n window.addEventListener('mousedown', handlePostMessageEvent);\n\n return () =>\n window.removeEventListener('mousedown', handlePostMessageEvent);\n }, [postMessage]);\n};\n\nexport const useIframeClickMerger = () =>\n useCrossFrameMessageListener<MessageEvent>(\n MessageKey.INTLAYER_IFRAME_CLICKED,\n mergeIframeClick\n );\n"],"mappings":"qMAMA,MAAa,MAAkC,CAC7C,IAAM,EAAc,EAClB,EAAW,wBACZ,CACK,MAA8C,CAClD,GAAa,EAGf,OACE,OAAO,iBAAiB,YAAa,EAAuB,KAG1D,OAAO,oBAAoB,YAAa,EAAuB,EAChE,CAAC,EAAY,CAAC,EAGN,MACX,EACE,EAAW,wBACX,EACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditedContentContext.d.ts","names":[],"sources":["../../src/EditedContentContext.tsx"],"mappings":";;;;;cAuCa,yBAAA,MACX,gBAAA,IAAoB,IAAA,EAAM,CAAA,eAAU,IAAA,GAAA,CAAA;AAAA,cAOzB,wBAAA,MACX,gBAAA,IAAoB,IAAA,EAAM,CAAA,eAAU,IAAA,GAAA,CAAA;AAAA,KAOjC,+BAAA;EACH,qBAAA,GAAwB,aAAA,EAAe,iBAAA;EACvC,mBAAA,EAAqB,QAAA,CAAS,cAAA,CAAe,UAAA;EAC7C,gBAAA,GACE,iBAAA,EAAmB,iBAAA,EACnB,QAAA,EAAU,UAAA;EAEZ,gBAAA,GACE,iBAAA,EAAmB,iBAAA,EACnB,QAAA,EAAU,WAAA,OACV,OAAA,GAAU,OAAA,IACV,SAAA;EAEF,mBAAA,GACE,iBAAA,EAAmB,iBAAA,EACnB,MAAA,EAAQ,OAAA,SACR,OAAA,GAAU,OAAA;EAEZ,mBAAA,GACE,iBAAA,EAAmB,iBAAA,EACnB,OAAA,EAAS,OAAA;EAEX,oBAAA,GAAuB,iBAAA,EAAmB,iBAAA;EAC1C,4BAAA,GAA+B,iBAAA,EAAmB,iBAAA;EAClD,kBAAA;EACA,qBAAA,GACE,sBAAA,EAAwB,iBAAA,GAAoB,UAAA,kBAC5C,OAAA,EAAS,OAAA,OACN,WAAA;AAAA;AAAA,cAYM,qBAAA,EAAuB,EAAA,CAAG,iBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"EditedContentContext.d.ts","names":[],"sources":["../../src/EditedContentContext.tsx"],"mappings":";;;;;cAuCa,yBAAA,MACX,gBAAA,IAAoB,IAAA,EAAM,CAAA,eAAU,IAAA,GAAA,CAAA;AAAA,cAOzB,wBAAA,MACX,gBAAA,IAAoB,IAAA,EAAM,CAAA,eAAU,IAAA,GAAA,CAAA;AAAA,KAOjC,+BAAA;EACH,qBAAA,GAAwB,aAAA,EAAe,iBAAA;EACvC,mBAAA,EAAqB,QAAA,CAAS,cAAA,CAAe,UAAA;EAC7C,gBAAA,GACE,iBAAA,EAAmB,iBAAA,EACnB,QAAA,EAAU,UAAA;EAEZ,gBAAA,GACE,iBAAA,EAAmB,iBAAA,EACnB,QAAA,EAAU,WAAA,OACV,OAAA,GAAU,OAAA,IACV,SAAA;EAEF,mBAAA,GACE,iBAAA,EAAmB,iBAAA,EACnB,MAAA,EAAQ,OAAA,SACR,OAAA,GAAU,OAAA;EAEZ,mBAAA,GACE,iBAAA,EAAmB,iBAAA,EACnB,OAAA,EAAS,OAAA;EAEX,oBAAA,GAAuB,iBAAA,EAAmB,iBAAA;EAC1C,4BAAA,GAA+B,iBAAA,EAAmB,iBAAA;EAClD,kBAAA;EACA,qBAAA,GACE,sBAAA,EAAwB,iBAAA,GAAoB,UAAA,kBAC5C,OAAA,EAAS,OAAA,OACN,WAAA;AAAA;AAAA,cAYM,qBAAA,EAAuB,EAAA,CAAG,iBAAA;AAAA,cAgQ1B,uBAAA,QAAuB,+BAAA;AAAA,cAGvB,gBAAA;0BA1Sa,aAAA,EAAe,iBAAA;uBAClB,QAAA,CAAS,cAAA,CAAe,UAAA;qBAE3C,iBAAA,EAAmB,iBAAA,EACnB,QAAA,EAAU,UAAA;qBAGV,iBAAA,EAAmB,iBAAA,EACnB,QAAA,EAAU,WAAA,OACV,OAAA,GAAU,OAAA,IACV,SAAA;wBAGA,iBAAA,EAAmB,iBAAA,EACnB,MAAA,EAAQ,OAAA,SACR,OAAA,GAAU,OAAA;wBAGV,iBAAA,EAAmB,iBAAA,EACnB,OAAA,EAAS,OAAA;yBAEY,iBAAA,EAAmB,iBAAA;iCACX,iBAAA,EAAmB,iBAAA;;0BAGhD,sBAAA,EAAwB,iBAAA,GAAoB,UAAA,kBAC5C,OAAA,EAAS,OAAA,OACN,WAAA;iBAnDU,MAAA,CAAO,iBAAA,EAAmB,UAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/editor-react",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.3-canary.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Provides the states, contexts, hooks and components to interact with the Intlayer editor for a React application",
|
|
6
6
|
"keywords": [
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@intlayer/config": "8.1.
|
|
75
|
-
"@intlayer/core": "8.1.
|
|
76
|
-
"@intlayer/editor": "8.1.
|
|
77
|
-
"@intlayer/types": "8.1.
|
|
78
|
-
"@intlayer/unmerged-dictionaries-entry": "8.1.
|
|
74
|
+
"@intlayer/config": "8.1.3-canary.0",
|
|
75
|
+
"@intlayer/core": "8.1.3-canary.0",
|
|
76
|
+
"@intlayer/editor": "8.1.3-canary.0",
|
|
77
|
+
"@intlayer/types": "8.1.3-canary.0",
|
|
78
|
+
"@intlayer/unmerged-dictionaries-entry": "8.1.3-canary.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@types/node": "25.2.3",
|