solid-intlayer 7.0.2-canary.0 → 7.0.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/editor/ContentSelectorWrapper.cjs +1 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs +1 -1
- package/dist/cjs/editor/contexts/DictionariesRecordContext.cjs +1 -1
- package/dist/cjs/editor/contexts/EditedContentContext.cjs +1 -1
- package/dist/cjs/editor/contexts/useCrossFrameMessageListener.cjs +1 -1
- package/dist/esm/editor/ContentSelectorWrapper.mjs +19 -19
- package/dist/esm/editor/IntlayerEditorProvider.mjs +31 -21
- package/dist/esm/editor/contexts/DictionariesRecordContext.mjs +1 -1
- package/dist/esm/editor/contexts/EditedContentContext.mjs +61 -59
- package/dist/esm/editor/contexts/useCrossFrameMessageListener.mjs +16 -16
- package/package.json +16 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@intlayer/core"),a=require("@intlayer/types"),r=require("solid-js");require("@intlayer/config/built");const d=require("../client/IntlayerProvider.cjs");require("@intlayer/editor");require("./contexts/ConfigurationContext.cjs");require("./contexts/DictionariesRecordContext.cjs");require("./contexts/EditedContentContext.cjs");const l=require("./contexts/EditorEnabledContext.cjs");require("./contexts/CommunicatorContext.cjs");const y=require("./contexts/FocusDictionaryContext.cjs");require("../markdown/MarkdownProvider.cjs");require("../client/useLocaleStorage.cjs");require("../client/useLocaleBase.cjs");const q=require("../UI/ContentSelector.cjs"),h=e=>{const{focusedContent:t,setFocusedContent:n}=y.useFocusDictionary(),o=r.createMemo(()=>e.keyPath.filter(s=>s.type!==a.NodeType.Translation)),i=()=>n({dictionaryKey:e.dictionaryKey,keyPath:o()}),c=r.createMemo(()=>(t?.dictionaryKey===e.dictionaryKey&&(t?.keyPath?.length??0)>0&&u.isSameKeyPath(t?.keyPath??[],o()))??!1);return r.createComponent(q.ContentSelector,{onPress:i,get isSelecting(){return c()},get children(){return e.children}})},C=e=>{const{enabled:t}=l.useEditorEnabled(),{disableEditor:n}=d.useIntlayerContext();return t()&&!n?r.createComponent(h,r.mergeProps(e,{get children(){return e.children}})):e.children};exports.ContentSelectorRenderer=C;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../web-Ch-xTpJg.js"),s=require("@intlayer/config/built"),d=require("@intlayer/unmerged-dictionaries-entry"),o=require("solid-js");require("@intlayer/editor");require("./contexts/ConfigurationContext.cjs");const a=require("./contexts/DictionariesRecordContext.cjs");require("./contexts/EditedContentContext.cjs");const u=require("./contexts/EditorEnabledContext.cjs"),l=require("./contexts/EditorProvider.cjs");require("./contexts/FocusDictionaryContext.cjs");require("./contexts/CommunicatorContext.cjs");const p=require("./contexts/useCrossURLPathState.cjs"),m=require("./contexts/useIframeClickInterceptor.cjs"),g=()=>{p.useCrossURLPathSetter(),m.useIframeClickInterceptor();const{setLocaleDictionaries:t}=a.useDictionariesRecordActions()??{};return o.onMount(()=>{const r=d.getUnmergedDictionaries(),i=Object.fromEntries(Object.values(r).flat().map(n=>[n.localId,n]));t?.(i)}),[]},{editor:e}=s,f=()=>{const{enabled:t}=u.useEditorEnabled();return t()?o.createComponent(g,{}):[]},q=t=>o.createComponent(l.EditorProvider,{postMessage:r=>{typeof window>"u"||!(window.self!==window.top)||(e.applicationURL.length>0&&window?.postMessage(r,e.applicationURL),e.editorURL.length>0&&window.parent?.postMessage(r,e.editorURL),e.cmsURL.length>0&&window.parent?.postMessage(r,e.cmsURL))},get allowedOrigins(){return[e?.editorURL,e?.cmsURL,e?.applicationURL]},configuration:s,get children(){return[o.createComponent(f,{}),c.memo(()=>t.children)]}});exports.IntlayerEditorProvider=q;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@intlayer/editor"),e=require("solid-js"),D=require("./useCrossFrameState.cjs"),s=e.createContext(void 0),c=e.createContext(void 0),C=o=>{const[t,r]=D.useCrossFrameState(l.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,void 0),a=e.createMemo(()=>({localeDictionaries:t()??{}})),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@intlayer/editor"),e=require("solid-js"),D=require("./useCrossFrameState.cjs"),s=e.createContext(void 0),c=e.createContext(void 0),C=o=>{const[t,r]=D.useCrossFrameState(l.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,void 0),a=e.createMemo(()=>({localeDictionaries:t()??{}})),d=e.createMemo(()=>({setLocaleDictionaries:r,setLocaleDictionary:i=>{r(u=>({...u,[i.localId]:i}))}}));return e.createComponent(s.Provider,{get value(){return a()},get children(){return e.createComponent(c.Provider,{get value(){return d()},get children(){return o.children}})}})},n=()=>e.useContext(c),R=()=>{const o=n(),t=e.useContext(s);if(!t)throw new Error("useDictionariesRecordStates must be used within a DictionariesRecordProvider");return{...t,...o}};exports.DictionariesRecordProvider=C;exports.useDictionariesRecord=R;exports.useDictionariesRecordActions=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@intlayer/core"),g=require("@intlayer/editor"),T=require("@intlayer/types"),E=require("solid-js"),G=require("./DictionariesRecordContext.cjs"),y=require("./useCrossFrameMessageListener.cjs"),R=require("./useCrossFrameState.cjs"),_=E.createContext(void 0),$=C=>y.useCrossFrameMessageListener(`${g.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED}/post`,C),j=C=>y.useCrossFrameMessageListener(`${g.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED}/get`,C),P=E.createContext(void 0),k=C=>{const{localeDictionaries:a}=G.useDictionariesRecord(),[D,r]=R.useCrossFrameState(g.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED),x=t=>{if(typeof t=="function")r(n=>{const e=n?.[Object.keys(n||{})[0]],s=t(e);return{...n,[s.key]:s}});else{const n=t;r(e=>({...e,[n.key]:n}))}},S=(t,n)=>{r(e=>({...e,[t]:{...e?.[t],content:n}}))},A=(t,n,e=[],s=!0)=>{r(d=>{const u=a[t]?.content,o=structuredClone(d?.[t]?.content??u);let c=e;if(!s){let N=0;const w=e.slice(0,-1),f=e[e.length-1];let h=f.key;for(;typeof l.getContentNodeByKeyPath(o,c)<"u";)N++,h=N===0?f.key:`${f.key} (${N})`,c=[...w,{...f,key:h}]}const i=l.editDictionaryByKeyPath(o,c,n);return{...d,[t]:{...d?.[t],content:i}}})},p=(t,n,e=[])=>{r(s=>{const d=a[t]?.content,u=structuredClone(s?.[t]?.content??d),o=l.renameContentNodeByKeyPath(u,n,e);return{...s,[t]:{...s?.[t],content:o}}})},q=(t,n)=>{r(e=>{const s=a[t]?.content,d=structuredClone(e?.[t]?.content??s),u=structuredClone(d),o=n.slice(0,-1),c=n[n.length-1]?.key;if(c){const i=l.getContentNodeByKeyPath(u,o.filter(N=>N.type!==T.NodeType.Translation));i&&typeof i=="object"&&c in i&&delete i[c]}return{...e,[t]:{...e?.[t],content:u}}})},F=t=>{r(n=>{const e={...n};return delete e[t],e})},I=t=>{r(n=>({...n,[t]:{...n?.[t],content:{}}}))},L=()=>{r({})},M=(t,n)=>{const e=D();if(!e)return;const s=n.filter(o=>o.type!==T.NodeType.Translation);if(t.includes(":local:")||t.includes(":remote:")){const o=e?.[t]?.content??{};return l.getContentNodeByKeyPath(o,s)}const u=Object.keys(e).filter(o=>o.startsWith(`${t}:`));for(const o of u){const c=e?.[o]?.content??{},i=l.getContentNodeByKeyPath(c,s);if(i)return i}},b={editedContent:D()},B={setEditedContentState:r,setEditedDictionary:x,setEditedContent:S,addEditedContent:A,renameEditedContent:p,removeEditedContent:q,restoreEditedContent:F,clearEditedDictionaryContent:I,clearEditedContent:L,getEditedContentValue:M};return E.createComponent(_.Provider,{value:b,get children(){return E.createComponent(P.Provider,{value:B,get children(){return C.children}})}})},m=()=>E.useContext(P),v=()=>{const C=m(),a=E.useContext(_);if(!a)throw new Error("useEditedContent must be used within a EditedContentProvider");return{...a,...C}};exports.EditedContentProvider=k;exports.useEditedContent=v;exports.useEditedContentActions=m;exports.useGetEditedContentState=j;exports.usePostEditedContentState=$;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@intlayer/editor"),d=require("solid-js"),g=require("./CommunicatorContext.cjs"),f=(o,t)=>{const n=g.useCommunicator();if(!n)throw new Error("useCrossFrameMessageListener must be used within a CommunicatorProvider");const{allowedOrigins:s,postMessage:u,senderId:i}=n;return d.onMount(()=>{if(t){const e=a=>{const{type:c,data:m,senderId:l}=a.data;c===o&&l!==i&&(typeof s>"u"||s?.filter(r=>![null,void 0,"","*"].includes(r)).some(r=>p.compareUrls(r,a.origin))||s?.includes("*"))&&t(m)};window.addEventListener("message",e),d.onCleanup(()=>window.removeEventListener("message",e))}}),e=>{u({type:o,data:e,senderId:i})}};exports.useCrossFrameMessageListener=f;
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { isSameKeyPath as
|
|
2
|
-
import {
|
|
1
|
+
import { isSameKeyPath as d } from "@intlayer/core";
|
|
2
|
+
import { NodeType as l } from "@intlayer/types";
|
|
3
|
+
import { createComponent as i, mergeProps as s, createMemo as n } from "solid-js";
|
|
3
4
|
import "@intlayer/config/built";
|
|
4
|
-
import "
|
|
5
|
-
import { useIntlayerContext as d } from "../client/IntlayerProvider.mjs";
|
|
5
|
+
import { useIntlayerContext as y } from "../client/IntlayerProvider.mjs";
|
|
6
6
|
import "@intlayer/editor";
|
|
7
7
|
import "./contexts/ConfigurationContext.mjs";
|
|
8
8
|
import "./contexts/DictionariesRecordContext.mjs";
|
|
9
9
|
import "./contexts/EditedContentContext.mjs";
|
|
10
|
-
import { useEditorEnabled as
|
|
10
|
+
import { useEditorEnabled as h } from "./contexts/EditorEnabledContext.mjs";
|
|
11
11
|
import "./contexts/CommunicatorContext.mjs";
|
|
12
|
-
import { useFocusDictionary as
|
|
12
|
+
import { useFocusDictionary as p } from "./contexts/FocusDictionaryContext.mjs";
|
|
13
13
|
import "../markdown/MarkdownProvider.mjs";
|
|
14
14
|
import "../client/useLocaleStorage.mjs";
|
|
15
15
|
import "../client/useLocaleBase.mjs";
|
|
16
|
-
import { ContentSelector as
|
|
17
|
-
const
|
|
16
|
+
import { ContentSelector as f } from "../UI/ContentSelector.mjs";
|
|
17
|
+
const u = (e) => {
|
|
18
18
|
const {
|
|
19
19
|
focusedContent: t,
|
|
20
20
|
setFocusedContent: r
|
|
21
|
-
} =
|
|
21
|
+
} = p(), o = n(() => e.keyPath.filter((a) => a.type !== l.Translation)), c = () => r({
|
|
22
22
|
dictionaryKey: e.dictionaryKey,
|
|
23
|
-
keyPath:
|
|
24
|
-
}),
|
|
25
|
-
return
|
|
26
|
-
onPress:
|
|
23
|
+
keyPath: o()
|
|
24
|
+
}), m = n(() => (t?.dictionaryKey === e.dictionaryKey && (t?.keyPath?.length ?? 0) > 0 && d(t?.keyPath ?? [], o())) ?? !1);
|
|
25
|
+
return i(f, {
|
|
26
|
+
onPress: c,
|
|
27
27
|
get isSelecting() {
|
|
28
|
-
return
|
|
28
|
+
return m();
|
|
29
29
|
},
|
|
30
30
|
get children() {
|
|
31
31
|
return e.children;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
},
|
|
34
|
+
}, W = (e) => {
|
|
35
35
|
const {
|
|
36
36
|
enabled: t
|
|
37
|
-
} =
|
|
37
|
+
} = h(), {
|
|
38
38
|
disableEditor: r
|
|
39
|
-
} =
|
|
40
|
-
return t() && !r ?
|
|
39
|
+
} = y();
|
|
40
|
+
return t() && !r ? i(u, s(e, {
|
|
41
41
|
get children() {
|
|
42
42
|
return e.children;
|
|
43
43
|
}
|
|
44
44
|
})) : e.children;
|
|
45
45
|
};
|
|
46
46
|
export {
|
|
47
|
-
|
|
47
|
+
W as ContentSelectorRenderer
|
|
48
48
|
};
|
|
@@ -1,37 +1,47 @@
|
|
|
1
|
-
import { m
|
|
2
|
-
import
|
|
1
|
+
import { m } from "../../web-mv0y5CK4.mjs";
|
|
2
|
+
import s from "@intlayer/config/built";
|
|
3
|
+
import { getUnmergedDictionaries as p } from "@intlayer/unmerged-dictionaries-entry";
|
|
4
|
+
import { createComponent as e, onMount as a } from "solid-js";
|
|
3
5
|
import "@intlayer/editor";
|
|
4
6
|
import "./contexts/ConfigurationContext.mjs";
|
|
5
|
-
import "./contexts/DictionariesRecordContext.mjs";
|
|
7
|
+
import { useDictionariesRecordActions as c } from "./contexts/DictionariesRecordContext.mjs";
|
|
6
8
|
import "./contexts/EditedContentContext.mjs";
|
|
7
|
-
import { useEditorEnabled as
|
|
8
|
-
import { EditorProvider as
|
|
9
|
+
import { useEditorEnabled as d } from "./contexts/EditorEnabledContext.mjs";
|
|
10
|
+
import { EditorProvider as f } from "./contexts/EditorProvider.mjs";
|
|
9
11
|
import "./contexts/FocusDictionaryContext.mjs";
|
|
10
|
-
import { createComponent as e } from "solid-js";
|
|
11
12
|
import "./contexts/CommunicatorContext.mjs";
|
|
12
|
-
import { useCrossURLPathSetter as
|
|
13
|
-
import { useIframeClickInterceptor as
|
|
14
|
-
const
|
|
13
|
+
import { useCrossURLPathSetter as l } from "./contexts/useCrossURLPathState.mjs";
|
|
14
|
+
import { useIframeClickInterceptor as u } from "./contexts/useIframeClickInterceptor.mjs";
|
|
15
|
+
const g = () => {
|
|
16
|
+
l(), u();
|
|
17
|
+
const {
|
|
18
|
+
setLocaleDictionaries: t
|
|
19
|
+
} = c() ?? {};
|
|
20
|
+
return a(() => {
|
|
21
|
+
const r = p(), i = Object.fromEntries(Object.values(r).flat().map((n) => [n.localId, n]));
|
|
22
|
+
t?.(i);
|
|
23
|
+
}), [];
|
|
24
|
+
}, {
|
|
15
25
|
editor: o
|
|
16
|
-
} =
|
|
26
|
+
} = s, w = () => {
|
|
17
27
|
const {
|
|
18
|
-
enabled:
|
|
19
|
-
} =
|
|
20
|
-
return
|
|
21
|
-
},
|
|
22
|
-
postMessage: (
|
|
28
|
+
enabled: t
|
|
29
|
+
} = d();
|
|
30
|
+
return t() ? e(g, {}) : [];
|
|
31
|
+
}, P = (t) => e(f, {
|
|
32
|
+
postMessage: (r) => {
|
|
23
33
|
typeof window > "u" || !(window.self !== window.top) || (o.applicationURL.length > 0 && window?.postMessage(
|
|
24
|
-
|
|
34
|
+
r,
|
|
25
35
|
// Use to restrict the origin of the editor for security reasons.
|
|
26
36
|
// Correspond to the current application URL to synchronize the locales states.
|
|
27
37
|
o.applicationURL
|
|
28
38
|
), o.editorURL.length > 0 && window.parent?.postMessage(
|
|
29
|
-
|
|
39
|
+
r,
|
|
30
40
|
// Use to restrict the origin of the editor for security reasons.
|
|
31
41
|
// Correspond to the editor URL to synchronize the locales states.
|
|
32
42
|
o.editorURL
|
|
33
43
|
), o.cmsURL.length > 0 && window.parent?.postMessage(
|
|
34
|
-
|
|
44
|
+
r,
|
|
35
45
|
// Use to restrict the origin of the CMS for security reasons.
|
|
36
46
|
// Correspond to the CMS URL.
|
|
37
47
|
o.cmsURL
|
|
@@ -40,11 +50,11 @@ const a = () => (p(), d(), []), {
|
|
|
40
50
|
get allowedOrigins() {
|
|
41
51
|
return [o?.editorURL, o?.cmsURL, o?.applicationURL];
|
|
42
52
|
},
|
|
43
|
-
configuration:
|
|
53
|
+
configuration: s,
|
|
44
54
|
get children() {
|
|
45
|
-
return [e(
|
|
55
|
+
return [e(w, {}), m(() => t.children)];
|
|
46
56
|
}
|
|
47
57
|
});
|
|
48
58
|
export {
|
|
49
|
-
|
|
59
|
+
P as IntlayerEditorProvider
|
|
50
60
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { getContentNodeByKeyPath as
|
|
1
|
+
import { getContentNodeByKeyPath as f, renameContentNodeByKeyPath as j, editDictionaryByKeyPath as B } from "@intlayer/core";
|
|
2
2
|
import { MessageKey as m } from "@intlayer/editor";
|
|
3
|
-
import {
|
|
3
|
+
import { NodeType as h } from "@intlayer/types";
|
|
4
|
+
import { createContext as g, useContext as p, createComponent as T } from "solid-js";
|
|
4
5
|
import { useDictionariesRecord as H } from "./DictionariesRecordContext.mjs";
|
|
5
6
|
import { useCrossFrameMessageListener as _ } from "./useCrossFrameMessageListener.mjs";
|
|
6
7
|
import { useCrossFrameState as W } from "./useCrossFrameState.mjs";
|
|
7
|
-
const x =
|
|
8
|
+
const x = g(void 0), Q = (u) => _(`${m.INTLAYER_EDITED_CONTENT_CHANGED}/post`, u), U = (u) => _(`${m.INTLAYER_EDITED_CONTENT_CHANGED}/get`, u), A = g(void 0), X = (u) => {
|
|
8
9
|
const {
|
|
9
|
-
localeDictionaries:
|
|
10
|
-
} = H(), [N, c] = W(m.INTLAYER_EDITED_CONTENT_CHANGED),
|
|
10
|
+
localeDictionaries: a
|
|
11
|
+
} = H(), [N, c] = W(m.INTLAYER_EDITED_CONTENT_CHANGED), P = (t) => {
|
|
11
12
|
if (typeof t == "function")
|
|
12
13
|
c((n) => {
|
|
13
14
|
const e = n?.[Object.keys(n || {})[0]], s = t(e);
|
|
@@ -31,63 +32,63 @@ const x = h(void 0), J = (C) => _(`${m.INTLAYER_EDITED_CONTENT_CHANGED}/post`, C
|
|
|
31
32
|
content: n
|
|
32
33
|
}
|
|
33
34
|
}));
|
|
34
|
-
},
|
|
35
|
-
c((
|
|
36
|
-
const
|
|
35
|
+
}, w = (t, n, e = [], s = !0) => {
|
|
36
|
+
c((d) => {
|
|
37
|
+
const C = a[t]?.content, o = structuredClone(d?.[t]?.content ?? C);
|
|
37
38
|
let r = e;
|
|
38
39
|
if (!s) {
|
|
39
|
-
let
|
|
40
|
-
const
|
|
41
|
-
let D =
|
|
42
|
-
for (; typeof
|
|
43
|
-
|
|
44
|
-
...
|
|
40
|
+
let l = 0;
|
|
41
|
+
const R = e.slice(0, -1), E = e[e.length - 1];
|
|
42
|
+
let D = E.key;
|
|
43
|
+
for (; typeof f(o, r) < "u"; )
|
|
44
|
+
l++, D = l === 0 ? E.key : `${E.key} (${l})`, r = [...R, {
|
|
45
|
+
...E,
|
|
45
46
|
key: D
|
|
46
47
|
}];
|
|
47
48
|
}
|
|
48
|
-
const
|
|
49
|
+
const i = B(o, r, n);
|
|
49
50
|
return {
|
|
50
|
-
...
|
|
51
|
+
...d,
|
|
51
52
|
[t]: {
|
|
52
|
-
...
|
|
53
|
-
content:
|
|
53
|
+
...d?.[t],
|
|
54
|
+
content: i
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
57
|
});
|
|
57
|
-
},
|
|
58
|
+
}, L = (t, n, e = []) => {
|
|
58
59
|
c((s) => {
|
|
59
|
-
const
|
|
60
|
+
const d = a[t]?.content, C = structuredClone(s?.[t]?.content ?? d), o = j(C, n, e);
|
|
60
61
|
return {
|
|
61
62
|
...s,
|
|
62
63
|
[t]: {
|
|
63
64
|
...s?.[t],
|
|
64
|
-
content:
|
|
65
|
+
content: o
|
|
65
66
|
}
|
|
66
67
|
};
|
|
67
68
|
});
|
|
68
|
-
},
|
|
69
|
+
}, S = (t, n) => {
|
|
69
70
|
c((e) => {
|
|
70
|
-
const s =
|
|
71
|
+
const s = a[t]?.content, d = structuredClone(e?.[t]?.content ?? s), C = structuredClone(d), o = n.slice(0, -1), r = n[n.length - 1]?.key;
|
|
71
72
|
if (r) {
|
|
72
|
-
const
|
|
73
|
-
|
|
73
|
+
const i = f(C, o.filter((l) => l.type !== h.Translation));
|
|
74
|
+
i && typeof i == "object" && r in i && delete i[r];
|
|
74
75
|
}
|
|
75
76
|
return {
|
|
76
77
|
...e,
|
|
77
78
|
[t]: {
|
|
78
79
|
...e?.[t],
|
|
79
|
-
content:
|
|
80
|
+
content: C
|
|
80
81
|
}
|
|
81
82
|
};
|
|
82
83
|
});
|
|
83
|
-
},
|
|
84
|
+
}, $ = (t) => {
|
|
84
85
|
c((n) => {
|
|
85
86
|
const e = {
|
|
86
87
|
...n
|
|
87
88
|
};
|
|
88
89
|
return delete e[t], e;
|
|
89
90
|
});
|
|
90
|
-
},
|
|
91
|
+
}, b = (t) => {
|
|
91
92
|
c((n) => ({
|
|
92
93
|
...n,
|
|
93
94
|
[t]: {
|
|
@@ -95,58 +96,59 @@ const x = h(void 0), J = (C) => _(`${m.INTLAYER_EDITED_CONTENT_CHANGED}/post`, C
|
|
|
95
96
|
content: {}
|
|
96
97
|
}
|
|
97
98
|
}));
|
|
98
|
-
},
|
|
99
|
+
}, k = () => {
|
|
99
100
|
c({});
|
|
100
|
-
},
|
|
101
|
+
}, y = (t, n) => {
|
|
101
102
|
const e = N();
|
|
102
103
|
if (!e) return;
|
|
104
|
+
const s = n.filter((o) => o.type !== h.Translation);
|
|
103
105
|
if (t.includes(":local:") || t.includes(":remote:")) {
|
|
104
106
|
const o = e?.[t]?.content ?? {};
|
|
105
|
-
return
|
|
107
|
+
return f(o, s);
|
|
106
108
|
}
|
|
107
|
-
const
|
|
108
|
-
for (const o of
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
109
|
+
const C = Object.keys(e).filter((o) => o.startsWith(`${t}:`));
|
|
110
|
+
for (const o of C) {
|
|
111
|
+
const r = e?.[o]?.content ?? {}, i = f(r, s);
|
|
112
|
+
if (i) return i;
|
|
111
113
|
}
|
|
112
|
-
},
|
|
114
|
+
}, F = {
|
|
113
115
|
editedContent: N()
|
|
114
|
-
},
|
|
116
|
+
}, G = {
|
|
115
117
|
setEditedContentState: c,
|
|
116
|
-
setEditedDictionary:
|
|
118
|
+
setEditedDictionary: P,
|
|
117
119
|
setEditedContent: I,
|
|
118
|
-
addEditedContent:
|
|
119
|
-
renameEditedContent:
|
|
120
|
-
removeEditedContent:
|
|
121
|
-
restoreEditedContent:
|
|
122
|
-
clearEditedDictionaryContent:
|
|
123
|
-
clearEditedContent:
|
|
124
|
-
getEditedContentValue:
|
|
120
|
+
addEditedContent: w,
|
|
121
|
+
renameEditedContent: L,
|
|
122
|
+
removeEditedContent: S,
|
|
123
|
+
restoreEditedContent: $,
|
|
124
|
+
clearEditedDictionaryContent: b,
|
|
125
|
+
clearEditedContent: k,
|
|
126
|
+
getEditedContentValue: y
|
|
125
127
|
};
|
|
126
|
-
return
|
|
127
|
-
value:
|
|
128
|
+
return T(x.Provider, {
|
|
129
|
+
value: F,
|
|
128
130
|
get children() {
|
|
129
|
-
return
|
|
130
|
-
value:
|
|
131
|
+
return T(A.Provider, {
|
|
132
|
+
value: G,
|
|
131
133
|
get children() {
|
|
132
|
-
return
|
|
134
|
+
return u.children;
|
|
133
135
|
}
|
|
134
136
|
});
|
|
135
137
|
}
|
|
136
138
|
});
|
|
137
|
-
}, Y = () =>
|
|
138
|
-
const
|
|
139
|
-
if (!
|
|
139
|
+
}, Y = () => p(A), Z = () => {
|
|
140
|
+
const u = Y(), a = p(x);
|
|
141
|
+
if (!a)
|
|
140
142
|
throw new Error("useEditedContent must be used within a EditedContentProvider");
|
|
141
143
|
return {
|
|
142
|
-
...
|
|
143
|
-
...
|
|
144
|
+
...a,
|
|
145
|
+
...u
|
|
144
146
|
};
|
|
145
147
|
};
|
|
146
148
|
export {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
X as EditedContentProvider,
|
|
150
|
+
Z as useEditedContent,
|
|
149
151
|
Y as useEditedContentActions,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
U as useGetEditedContentState,
|
|
153
|
+
Q as usePostEditedContentState
|
|
152
154
|
};
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { compareUrls as c } from "@intlayer/editor";
|
|
2
|
-
import { onMount as f, onCleanup as
|
|
3
|
-
import { useCommunicator as
|
|
4
|
-
const h = (
|
|
5
|
-
const
|
|
6
|
-
if (!
|
|
2
|
+
import { onMount as f, onCleanup as l } from "solid-js";
|
|
3
|
+
import { useCommunicator as g } from "./CommunicatorContext.mjs";
|
|
4
|
+
const h = (o, n) => {
|
|
5
|
+
const t = g();
|
|
6
|
+
if (!t)
|
|
7
7
|
throw new Error("useCrossFrameMessageListener must be used within a CommunicatorProvider");
|
|
8
8
|
const {
|
|
9
9
|
allowedOrigins: s,
|
|
10
|
-
postMessage:
|
|
11
|
-
senderId:
|
|
12
|
-
} =
|
|
10
|
+
postMessage: m,
|
|
11
|
+
senderId: i
|
|
12
|
+
} = t;
|
|
13
13
|
return f(() => {
|
|
14
|
-
if (
|
|
14
|
+
if (n) {
|
|
15
15
|
const e = (a) => {
|
|
16
16
|
const {
|
|
17
|
-
type:
|
|
18
|
-
data:
|
|
17
|
+
type: d,
|
|
18
|
+
data: u,
|
|
19
19
|
senderId: p
|
|
20
20
|
} = a.data;
|
|
21
|
-
|
|
21
|
+
d === o && p !== i && (typeof s > "u" || s?.filter((r) => ![null, void 0, "", "*"].includes(r)).some((r) => c(r, a.origin)) || s?.includes("*")) && n(u);
|
|
22
22
|
};
|
|
23
|
-
window.addEventListener("message", e),
|
|
23
|
+
window.addEventListener("message", e), l(() => window.removeEventListener("message", e));
|
|
24
24
|
}
|
|
25
25
|
}), (e) => {
|
|
26
|
-
|
|
27
|
-
type:
|
|
26
|
+
m({
|
|
27
|
+
type: o,
|
|
28
28
|
data: e,
|
|
29
|
-
senderId:
|
|
29
|
+
senderId: i
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
32
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-intlayer",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.3-canary.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Solid applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -70,22 +70,23 @@
|
|
|
70
70
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@intlayer/api": "7.0.
|
|
74
|
-
"@intlayer/config": "7.0.
|
|
75
|
-
"@intlayer/core": "7.0.
|
|
76
|
-
"@intlayer/editor": "7.0.
|
|
77
|
-
"@intlayer/types": "7.0.
|
|
73
|
+
"@intlayer/api": "7.0.3-canary.0",
|
|
74
|
+
"@intlayer/config": "7.0.3-canary.0",
|
|
75
|
+
"@intlayer/core": "7.0.3-canary.0",
|
|
76
|
+
"@intlayer/editor": "7.0.3-canary.0",
|
|
77
|
+
"@intlayer/types": "7.0.3-canary.0",
|
|
78
78
|
"js-cookie": "3.0.5"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
+
"@intlayer/unmerged-dictionaries-entry": "7.0.3-canary.0",
|
|
81
82
|
"@solidjs/testing-library": "0.8.10",
|
|
82
83
|
"@testing-library/jest-dom": "6.6.4",
|
|
83
84
|
"@testing-library/user-event": "14.6.1",
|
|
84
85
|
"@types/js-cookie": "3.0.6",
|
|
85
86
|
"@types/node": "24.9.1",
|
|
86
|
-
"@utils/ts-config": "7.0.
|
|
87
|
-
"@utils/ts-config-types": "7.0.
|
|
88
|
-
"@utils/tsdown-config": "7.0.
|
|
87
|
+
"@utils/ts-config": "7.0.3-canary.0",
|
|
88
|
+
"@utils/ts-config-types": "7.0.3-canary.0",
|
|
89
|
+
"@utils/tsdown-config": "7.0.3-canary.0",
|
|
89
90
|
"jsdom": "26.1.0",
|
|
90
91
|
"rimraf": "6.0.1",
|
|
91
92
|
"tsdown": "0.15.9",
|
|
@@ -96,11 +97,12 @@
|
|
|
96
97
|
"vitest": "4.0.3"
|
|
97
98
|
},
|
|
98
99
|
"peerDependencies": {
|
|
99
|
-
"@intlayer/api": "7.0.
|
|
100
|
-
"@intlayer/config": "7.0.
|
|
101
|
-
"@intlayer/core": "7.0.
|
|
102
|
-
"@intlayer/editor": "7.0.
|
|
103
|
-
"@intlayer/types": "7.0.
|
|
100
|
+
"@intlayer/api": "7.0.3-canary.0",
|
|
101
|
+
"@intlayer/config": "7.0.3-canary.0",
|
|
102
|
+
"@intlayer/core": "7.0.3-canary.0",
|
|
103
|
+
"@intlayer/editor": "7.0.3-canary.0",
|
|
104
|
+
"@intlayer/types": "7.0.3-canary.0",
|
|
105
|
+
"@intlayer/unmerged-dictionaries-entry": "7.0.3-canary.0",
|
|
104
106
|
"solid-js": ">=1.0.0"
|
|
105
107
|
},
|
|
106
108
|
"engines": {
|