solid-intlayer 8.3.2 → 8.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/cjs/client/index.cjs +1 -1
  2. package/dist/cjs/client/useDictionary.cjs +1 -1
  3. package/dist/cjs/client/useDictionaryAsync.cjs +1 -1
  4. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
  5. package/dist/cjs/client/useIntlayer.cjs +1 -1
  6. package/dist/cjs/editor/ContentSelectorWrapper.cjs +1 -1
  7. package/dist/cjs/editor/IntlayerEditorProvider.cjs +1 -1
  8. package/dist/cjs/editor/contexts/CommunicatorContext.cjs +1 -1
  9. package/dist/cjs/editor/contexts/ConfigurationContext.cjs +1 -1
  10. package/dist/cjs/editor/contexts/DictionariesRecordContext.cjs +1 -1
  11. package/dist/cjs/editor/contexts/EditedContentContext.cjs +1 -1
  12. package/dist/cjs/editor/contexts/EditorEnabledContext.cjs +1 -1
  13. package/dist/cjs/editor/contexts/EditorProvider.cjs +1 -1
  14. package/dist/cjs/editor/contexts/FocusDictionaryContext.cjs +1 -1
  15. package/dist/cjs/editor/contexts/index.cjs +1 -1
  16. package/dist/cjs/editor/contexts/useCrossFrameMessageListener.cjs +1 -1
  17. package/dist/cjs/editor/contexts/useCrossFrameState.cjs +1 -1
  18. package/dist/cjs/editor/contexts/useCrossURLPathState.cjs +1 -1
  19. package/dist/cjs/editor/contexts/useIframeClickInterceptor.cjs +1 -1
  20. package/dist/cjs/editor/index.cjs +1 -1
  21. package/dist/cjs/editor/useEditedContentRenderer.cjs +1 -1
  22. package/dist/cjs/getDictionary.cjs +1 -1
  23. package/dist/cjs/getIntlayer.cjs +1 -1
  24. package/dist/cjs/index.cjs +1 -1
  25. package/dist/cjs/plugins.cjs +1 -1
  26. package/dist/esm/client/index.mjs +1 -1
  27. package/dist/esm/client/useDictionary.mjs +1 -1
  28. package/dist/esm/client/useDictionaryAsync.mjs +1 -1
  29. package/dist/esm/client/useDictionaryDynamic.mjs +1 -1
  30. package/dist/esm/client/useIntlayer.mjs +1 -1
  31. package/dist/esm/editor/ContentSelectorWrapper.mjs +1 -1
  32. package/dist/esm/editor/IntlayerEditorProvider.mjs +6 -34
  33. package/dist/esm/editor/contexts/CommunicatorContext.mjs +9 -27
  34. package/dist/esm/editor/contexts/ConfigurationContext.mjs +7 -16
  35. package/dist/esm/editor/contexts/DictionariesRecordContext.mjs +14 -35
  36. package/dist/esm/editor/contexts/EditedContentContext.mjs +26 -132
  37. package/dist/esm/editor/contexts/EditorEnabledContext.mjs +18 -18
  38. package/dist/esm/editor/contexts/EditorProvider.mjs +33 -63
  39. package/dist/esm/editor/contexts/FocusDictionaryContext.mjs +13 -36
  40. package/dist/esm/editor/contexts/index.mjs +12 -11
  41. package/dist/esm/editor/contexts/useCrossFrameMessageListener.mjs +6 -28
  42. package/dist/esm/editor/contexts/useCrossFrameState.mjs +16 -36
  43. package/dist/esm/editor/contexts/useCrossURLPathState.mjs +2 -22
  44. package/dist/esm/editor/contexts/useIframeClickInterceptor.mjs +7 -14
  45. package/dist/esm/editor/index.mjs +1 -1
  46. package/dist/esm/editor/useEditedContentRenderer.mjs +12 -9
  47. package/dist/esm/getDictionary.mjs +1 -1
  48. package/dist/esm/getIntlayer.mjs +1 -1
  49. package/dist/esm/index.mjs +1 -1
  50. package/dist/esm/plugins.mjs +1 -1
  51. package/dist/getDictionary-DdbGMGJZ.mjs +197 -0
  52. package/dist/getDictionary-PBgZNa_l.js +1 -0
  53. package/dist/types/editor/ContentSelectorWrapper.d.ts +10 -0
  54. package/dist/types/editor/contexts/CommunicatorContext.d.ts +6 -7
  55. package/dist/types/editor/contexts/ConfigurationContext.d.ts +1 -7
  56. package/dist/types/editor/contexts/DictionariesRecordContext.d.ts +8 -11
  57. package/dist/types/editor/contexts/EditedContentContext.d.ts +26 -30
  58. package/dist/types/editor/contexts/EditorEnabledContext.d.ts +5 -9
  59. package/dist/types/editor/contexts/EditorProvider.d.ts +13 -3
  60. package/dist/types/editor/contexts/FocusDictionaryContext.d.ts +7 -15
  61. package/dist/types/editor/contexts/index.d.ts +1 -0
  62. package/dist/types/editor/contexts/useCrossFrameMessageListener.d.ts +0 -16
  63. package/dist/types/editor/contexts/useCrossFrameState.d.ts +1 -22
  64. package/dist/types/editor/contexts/useCrossURLPathState.d.ts +2 -3
  65. package/dist/types/editor/contexts/useIframeClickInterceptor.d.ts +1 -7
  66. package/package.json +7 -8
  67. package/dist/getDictionary-DKdSGWHu.mjs +0 -188
  68. package/dist/getDictionary-DxYuk0_0.js +0 -1
@@ -1,68 +1,38 @@
1
- import { CommunicatorProvider as e } from "./CommunicatorContext.mjs";
2
- import { ConfigurationProvider as t } from "./ConfigurationContext.mjs";
3
- import { DictionariesRecordProvider as n } from "./DictionariesRecordContext.mjs";
4
- import { EditedContentProvider as r, useGetEditedContentState as i } from "./EditedContentContext.mjs";
5
- import { EditorEnabledProvider as a, useEditorEnabled as o, useGetEditorEnabledState as s } from "./EditorEnabledContext.mjs";
6
- import { FocusDictionaryProvider as c } from "./FocusDictionaryContext.mjs";
7
- import { createComponent as l, memo as u } from "solid-js/web";
8
- import { createEffect as d, createSignal as f } from "solid-js";
1
+ import { createComponent as e } from "solid-js/web";
2
+ import t from "@intlayer/config/built";
3
+ import { EditorStateManager as n, defineIntlayerElements as r } from "@intlayer/editor";
4
+ import { createContext as i, onCleanup as a, onMount as o, useContext as s } from "solid-js";
9
5
  //#region src/editor/contexts/EditorProvider.tsx
10
- var p = (e) => {
11
- let t = i();
12
- return d(() => {
13
- t();
14
- }), l(n, { get children() {
15
- return l(r, { get children() {
16
- return l(c, { get children() {
17
- return e.children;
18
- } });
19
- } });
20
- } });
21
- }, m = (e) => {
22
- let t = s(), { enabled: n } = o();
23
- return d(() => {
24
- n() || t();
25
- }), u(() => u(() => !!n())() ? e.children : e.fallback);
26
- }, h = (e) => {
27
- let [t, n] = f(!1);
28
- return d(() => {
29
- n(window.self !== window.top);
30
- }), u(() => u(() => !!t())() ? e.children : e.fallback);
31
- }, g = (n) => l(a, { get children() {
32
- return l(t, {
33
- get configuration() {
34
- return n.configuration;
35
- },
6
+ var { editor: c } = t ?? {}, l = () => ({
7
+ allowedOrigins: [
8
+ c?.applicationURL,
9
+ c?.editorURL,
10
+ c?.cmsURL
11
+ ].filter(Boolean),
12
+ postMessageFn: (e, t) => {
13
+ typeof window > "u" || window.self !== window.top && (window.parent?.postMessage(e, t), window.postMessage(e, t));
14
+ }
15
+ }), u = i(null), d = () => {
16
+ let e = s(u);
17
+ if (!e) throw Error("useEditorStateManager: no EditorProvider found");
18
+ return e;
19
+ }, f = (i) => {
20
+ let s = i.postMessage || i.allowedOrigins ? {
21
+ allowedOrigins: i.allowedOrigins ?? ["*"],
22
+ postMessageFn: i.postMessage ? (e) => i.postMessage(e) : l().postMessageFn
23
+ } : l(), c = new n({
24
+ mode: i.mode ?? "client",
25
+ messenger: s,
26
+ configuration: i.configuration ?? t
27
+ });
28
+ return o(() => {
29
+ r(), c.start();
30
+ }), a(() => c.stop()), e(u.Provider, {
31
+ value: c,
36
32
  get children() {
37
- return l(h, {
38
- get fallback() {
39
- return n.children;
40
- },
41
- get children() {
42
- return l(e, {
43
- get postMessage() {
44
- return n.postMessage;
45
- },
46
- get allowedOrigins() {
47
- return n.allowedOrigins;
48
- },
49
- get children() {
50
- return l(m, {
51
- get fallback() {
52
- return n.children;
53
- },
54
- get children() {
55
- return l(p, { get children() {
56
- return n.children;
57
- } });
58
- }
59
- });
60
- }
61
- });
62
- }
63
- });
33
+ return i.children;
64
34
  }
65
35
  });
66
- } });
36
+ };
67
37
  //#endregion
68
- export { g as EditorProvider };
38
+ export { f as EditorProvider, d as useEditorStateManager };
@@ -1,42 +1,19 @@
1
- import { useCrossFrameState as e } from "./useCrossFrameState.mjs";
2
- import { createComponent as t } from "solid-js/web";
3
- import { createContext as n, useContext as r } from "solid-js";
4
- import { MessageKey as i } from "@intlayer/editor";
1
+ import { useEditorStateManager as e } from "./EditorProvider.mjs";
2
+ import { createSignal as t, onCleanup as n } from "solid-js";
5
3
  //#region src/editor/contexts/FocusDictionaryContext.tsx
6
- var a = n(void 0), o = n(void 0), s = (n) => {
7
- let [r, s] = e(i.INTLAYER_FOCUSED_CONTENT_CHANGED, null), c = (e) => {
8
- s((t) => t && {
9
- ...t,
10
- keyPath: e
11
- });
4
+ var r = () => {
5
+ let r = e(), [i, a] = t(r.focusedContent.value ?? null), o = (e) => a(e.detail);
6
+ return r.focusedContent.addEventListener("change", o), n(() => r.focusedContent.removeEventListener("change", o)), {
7
+ focusedContent: i,
8
+ setFocusedContent: (e) => r.focusedContent.set(e),
9
+ setFocusedContentKeyPath: (e) => r.setFocusedContentKeyPath(e)
12
10
  };
13
- return t(a.Provider, {
14
- get value() {
15
- return { focusedContent: r() };
16
- },
17
- get children() {
18
- return t(o.Provider, {
19
- value: {
20
- setFocusedContent: s,
21
- setFocusedContentKeyPath: c
22
- },
23
- get children() {
24
- return n.children;
25
- }
26
- });
27
- }
28
- });
29
- }, c = () => {
30
- let e = r(o);
31
- if (e === void 0) throw Error("useFocusDictionaryActions must be used within a FocusDictionaryProvider");
32
- return e;
33
- }, l = () => {
34
- let e = c(), t = r(a);
35
- if (t === void 0) throw Error("useFocusDictionaryState must be used within a FocusDictionaryProvider");
11
+ }, i = () => {
12
+ let { setFocusedContent: e, setFocusedContentKeyPath: t } = r();
36
13
  return {
37
- ...t,
38
- ...e
14
+ setFocusedContent: e,
15
+ setFocusedContentKeyPath: t
39
16
  };
40
17
  };
41
18
  //#endregion
42
- export { s as FocusDictionaryProvider, l as useFocusDictionary, c as useFocusDictionaryActions };
19
+ export { r as useFocusDictionary, i as useFocusDictionaryActions };
@@ -1,12 +1,13 @@
1
- import { useCrossFrameMessageListener as e } from "./useCrossFrameMessageListener.mjs";
2
- import { useCrossFrameState as t } from "./useCrossFrameState.mjs";
3
- import { ConfigurationProvider as n, useConfiguration as r, useConfigurationState as i } from "./ConfigurationContext.mjs";
4
- import { DictionariesRecordProvider as a, useDictionariesRecord as o, useDictionariesRecordActions as s } from "./DictionariesRecordContext.mjs";
5
- import { EditedContentProvider as c, useEditedContent as l, useEditedContentActions as u, useGetEditedContentState as d, usePostEditedContentState as f } from "./EditedContentContext.mjs";
6
- import { EditorEnabledProvider as p, useEditorEnabled as m, useEditorEnabledState as h, useGetEditorEnabledState as g, usePostEditorEnabledState as _ } from "./EditorEnabledContext.mjs";
7
- import { FocusDictionaryProvider as v, useFocusDictionary as y, useFocusDictionaryActions as b } from "./FocusDictionaryContext.mjs";
8
- import { EditorProvider as x } from "./EditorProvider.mjs";
9
- import { useCrossURLPathSetter as S, useCrossURLPathState as C } from "./useCrossURLPathState.mjs";
10
- import { useIframeClickInterceptor as w, useIframeClickMerger as T } from "./useIframeClickInterceptor.mjs";
1
+ import { EditorProvider as e, useEditorStateManager as t } from "./EditorProvider.mjs";
2
+ import { useCommunicator as n } from "./CommunicatorContext.mjs";
3
+ import { useConfiguration as r } from "./ConfigurationContext.mjs";
4
+ import { useDictionariesRecord as i, useDictionariesRecordActions as a } from "./DictionariesRecordContext.mjs";
5
+ import { useEditedContent as o, useEditedContentActions as s, useGetEditedContentState as c, usePostEditedContentState as l } from "./EditedContentContext.mjs";
6
+ import { useEditorEnabled as u, useEditorEnabledState as d, useGetEditorEnabledState as f, usePostEditorEnabledState as p } from "./EditorEnabledContext.mjs";
7
+ import { useFocusDictionary as m, useFocusDictionaryActions as h } from "./FocusDictionaryContext.mjs";
8
+ import { useCrossFrameMessageListener as g } from "./useCrossFrameMessageListener.mjs";
9
+ import { useCrossFrameState as _ } from "./useCrossFrameState.mjs";
10
+ import { useCrossURLPathSetter as v, useCrossURLPathState as y } from "./useCrossURLPathState.mjs";
11
+ import { useIframeClickInterceptor as b, useIframeClickMerger as x } from "./useIframeClickInterceptor.mjs";
11
12
  export * from "@intlayer/editor";
12
- export { n as ConfigurationProvider, a as DictionariesRecordProvider, c as EditedContentProvider, p as EditorEnabledProvider, x as EditorProvider, v as FocusDictionaryProvider, r as useConfiguration, i as useConfigurationState, e as useCrossFrameMessageListener, t as useCrossFrameState, S as useCrossURLPathSetter, C as useCrossURLPathState, o as useDictionariesRecord, s as useDictionariesRecordActions, l as useEditedContent, u as useEditedContentActions, m as useEditorEnabled, h as useEditorEnabledState, y as useFocusDictionary, b as useFocusDictionaryActions, d as useGetEditedContentState, g as useGetEditorEnabledState, w as useIframeClickInterceptor, T as useIframeClickMerger, f as usePostEditedContentState, _ as usePostEditorEnabledState };
13
+ export { e as EditorProvider, n as useCommunicator, r as useConfiguration, g as useCrossFrameMessageListener, _ as useCrossFrameState, v as useCrossURLPathSetter, y as useCrossURLPathState, i as useDictionariesRecord, a as useDictionariesRecordActions, o as useEditedContent, s as useEditedContentActions, u as useEditorEnabled, d as useEditorEnabledState, t as useEditorStateManager, m as useFocusDictionary, h as useFocusDictionaryActions, c as useGetEditedContentState, f as useGetEditorEnabledState, b as useIframeClickInterceptor, x as useIframeClickMerger, l as usePostEditedContentState, p as usePostEditorEnabledState };
@@ -1,31 +1,9 @@
1
- import { useCommunicator as e } from "./CommunicatorContext.mjs";
2
- import { onCleanup as t, onMount as n } from "solid-js";
3
- import { compareUrls as r } from "@intlayer/editor";
1
+ import { useEditorStateManager as e } from "./EditorProvider.mjs";
2
+ import { onCleanup as t } from "solid-js";
4
3
  //#region src/editor/contexts/useCrossFrameMessageListener.tsx
5
- var i = (i, a) => {
6
- let o = e();
7
- if (!o) throw Error("useCrossFrameMessageListener must be used within a CommunicatorProvider");
8
- let { allowedOrigins: s, postMessage: c, senderId: l } = o;
9
- return n(() => {
10
- if (a) {
11
- let e = (e) => {
12
- let { type: t, data: n, senderId: o } = e.data;
13
- t === i && o !== l && (s === void 0 || s?.filter((e) => ![
14
- null,
15
- void 0,
16
- "",
17
- "*"
18
- ].includes(e)).some((t) => r(t, e.origin)) || s?.includes("*")) && a(n);
19
- };
20
- window.addEventListener("message", e), t(() => window.removeEventListener("message", e));
21
- }
22
- }), (e) => {
23
- c({
24
- type: i,
25
- data: e,
26
- senderId: l
27
- });
28
- };
4
+ var n = (n, r) => {
5
+ let i = e();
6
+ return r && t(i.messenger.subscribe(n, r)), (e) => i.messenger.send(n, e);
29
7
  };
30
8
  //#endregion
31
- export { i as useCrossFrameMessageListener };
9
+ export { n as useCrossFrameMessageListener };
@@ -1,44 +1,24 @@
1
- import { useCommunicator as e } from "./CommunicatorContext.mjs";
2
- import { useCrossFrameMessageListener as t } from "./useCrossFrameMessageListener.mjs";
3
- import { createEffect as n, createSignal as r } from "solid-js";
1
+ import { useEditorStateManager as e } from "./EditorProvider.mjs";
2
+ import { CrossFrameStateManager as t } from "@intlayer/editor";
3
+ import { createSignal as n, onCleanup as r } from "solid-js";
4
4
  //#region src/editor/contexts/useCrossFrameState.tsx
5
5
  var i = (i, a, o) => {
6
- let { postMessage: s, senderId: c } = e() ?? {}, { emit: l, receive: u } = o ?? {
7
- emit: !0,
8
- receive: !0
9
- }, [d, f] = r(typeof a == "function" ? a() : a);
10
- return t(`${i}/post`, u ? (e) => {
11
- f(() => e);
12
- } : void 0), t(`${i}/get`, l ? (e, t) => {
13
- l && typeof s == "function" && t !== c && d() !== void 0 && s({
14
- type: `${i}/post`,
15
- data: d(),
16
- senderId: c
17
- });
18
- } : void 0), n(() => {
19
- u && typeof s == "function" && d() === void 0 && s({
20
- type: `${i}/get`,
21
- senderId: c
22
- });
23
- }), [
6
+ let s = e(), { emit: c = !0, receive: l = !0 } = o ?? {}, u = new t(i, s.messenger, {
7
+ emit: c,
8
+ receive: l,
9
+ initialValue: a
10
+ });
11
+ u.start(), r(() => u.stop());
12
+ let [d, f] = n(u.value, { equals: !1 }), p = (e) => {
13
+ f(() => e.detail);
14
+ };
15
+ return u.addEventListener("change", p), r(() => u.removeEventListener("change", p)), [
24
16
  d,
25
17
  (e) => {
26
- f((t) => {
27
- let n = typeof e == "function" ? e(t) : e;
28
- return l && typeof s == "function" && n !== void 0 && s({
29
- type: `${i}/post`,
30
- data: n,
31
- senderId: c
32
- }), n;
33
- });
18
+ let t = typeof e == "function" ? e(d()) : e;
19
+ u.set(t);
34
20
  },
35
- () => {
36
- typeof s == "function" && s({
37
- type: `${i}/post`,
38
- data: d(),
39
- senderId: c
40
- });
41
- }
21
+ () => u.postCurrentValue()
42
22
  ];
43
23
  };
44
24
  //#endregion
@@ -1,24 +1,4 @@
1
- import { useCrossFrameState as e } from "./useCrossFrameState.mjs";
2
- import { onCleanup as t, onMount as n } from "solid-js";
3
- import { MessageKey as r } from "@intlayer/editor";
4
1
  //#region src/editor/contexts/useCrossURLPathState.tsx
5
- var i = (t, n) => e(r.INTLAYER_URL_CHANGE, t, n), a = (e) => {
6
- let r = i(e, {
7
- emit: !0,
8
- receive: !1
9
- }), [a, o] = r;
10
- return n(() => {
11
- let e = history.pushState, n = history.replaceState, r = (e) => function(...t) {
12
- e.apply(this, t), window.dispatchEvent(new Event("locationchange"));
13
- };
14
- history.pushState = r(e), history.replaceState = r(n);
15
- let i = () => {
16
- o(window.location.pathname);
17
- };
18
- window.addEventListener("locationchange", i), window.addEventListener("popstate", i), window.addEventListener("hashchange", i), window.addEventListener("load", i), i(), t(() => {
19
- window.removeEventListener("locationchange", i), window.removeEventListener("popstate", i), window.removeEventListener("hashchange", i), window.removeEventListener("load", i), history.pushState = e, history.replaceState = n;
20
- });
21
- }), r;
22
- };
2
+ var e = () => {}, t = () => {};
23
3
  //#endregion
24
- export { a as useCrossURLPathSetter, i as useCrossURLPathState };
4
+ export { e as useCrossURLPathSetter, t as useCrossURLPathState };
@@ -1,17 +1,10 @@
1
1
  import { useCrossFrameMessageListener as e } from "./useCrossFrameMessageListener.mjs";
2
- import { onCleanup as t, onMount as n } from "solid-js";
3
- import { MessageKey as r, mergeIframeClick as i } from "@intlayer/editor";
2
+ import { MessageKey as t, mergeIframeClick as n } from "@intlayer/editor";
4
3
  //#region src/editor/contexts/useIframeClickInterceptor.tsx
5
- var a = () => {
6
- let i = e(r.INTLAYER_IFRAME_CLICKED);
7
- n(() => {
8
- let e = (e) => {
9
- i();
10
- };
11
- document.addEventListener("mousedown", e), t(() => {
12
- document.removeEventListener("mousedown", e);
13
- });
14
- });
15
- }, o = () => e(r.INTLAYER_IFRAME_CLICKED, i);
4
+ var r = () => {
5
+ e(t.INTLAYER_IFRAME_CLICKED);
6
+ }, i = () => {
7
+ e(t.INTLAYER_IFRAME_CLICKED, n);
8
+ };
16
9
  //#endregion
17
- export { a as useIframeClickInterceptor, o as useIframeClickMerger };
10
+ export { r as useIframeClickInterceptor, i as useIframeClickMerger };
@@ -1,2 +1,2 @@
1
- import { l as e } from "../../getDictionary-DKdSGWHu.mjs";
1
+ import { l as e } from "../../getDictionary-DdbGMGJZ.mjs";
2
2
  export { e as ContentSelectorRenderer };
@@ -1,16 +1,19 @@
1
1
  import { useEditedContentActions as e } from "./contexts/EditedContentContext.mjs";
2
- import { getContent as t } from "@intlayer/core/interpreter";
2
+ import { getBasePlugins as t, getContent as n } from "@intlayer/core/interpreter";
3
3
  //#region src/editor/useEditedContentRenderer.tsx
4
- var n = ({ dictionaryKey: t, keyPath: n, children: r }) => {
4
+ var r = ({ dictionaryKey: t, keyPath: n, children: r }) => {
5
5
  let i = e();
6
6
  return i ? i.getEditedContentValue(t, n) ?? r : r;
7
- }, r = (e) => {
8
- let r = n(e);
9
- if (typeof r == "object") {
10
- let n = t(r, e, e.locale);
11
- return typeof n == "string" ? n : (console.error(`Incorrect edited content format. Content type: ${typeof n}. Expected string. Value ${JSON.stringify(n)}`), e.children);
7
+ }, i = (e) => {
8
+ let i = r(e);
9
+ if (typeof i == "object") {
10
+ let r = n(i, {
11
+ ...e,
12
+ locale: e.locale
13
+ }, t(e.locale));
14
+ return typeof r == "string" ? r : (console.error(`Incorrect edited content format. Content type: ${typeof r}. Expected string. Value ${JSON.stringify(r)}`), e.children);
12
15
  }
13
- return r;
16
+ return i;
14
17
  };
15
18
  //#endregion
16
- export { r as EditedContentRenderer, n as useEditedContentRenderer };
19
+ export { i as EditedContentRenderer, r as useEditedContentRenderer };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../getDictionary-DKdSGWHu.mjs";
1
+ import { t as e } from "../getDictionary-DdbGMGJZ.mjs";
2
2
  export { e as getDictionary };
@@ -1,2 +1,2 @@
1
- import { d as e } from "../getDictionary-DKdSGWHu.mjs";
1
+ import { d as e } from "../getDictionary-DdbGMGJZ.mjs";
2
2
  export { e as getIntlayer };
@@ -3,7 +3,7 @@ import { IntlayerClientContext as o, IntlayerProvider as s, IntlayerProviderCont
3
3
  import { useIntl as u } from "./client/format/useIntl.mjs";
4
4
  import { getBrowserLocale as d } from "./client/getBrowserLocale.mjs";
5
5
  import { t as f } from "./client/t.mjs";
6
- import { d as p, f as m, m as h, p as g, t as _, u as v } from "../getDictionary-DKdSGWHu.mjs";
6
+ import { d as p, f as m, m as h, p as g, t as _, u as v } from "../getDictionary-DdbGMGJZ.mjs";
7
7
  import { useLoadDynamic as y } from "./client/useLoadDynamic.mjs";
8
8
  import { useLocale as b } from "./client/useLocale.mjs";
9
9
  import { useLocaleBase as x } from "./client/useLocaleBase.mjs";
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, i as n, n as r, o as i, r as a, s as o } from "../getDictionary-DKdSGWHu.mjs";
1
+ import { a as e, c as t, i as n, n as r, o as i, r as a, s as o } from "../getDictionary-DdbGMGJZ.mjs";
2
2
  export { r as getPlugins, a as htmlPlugin, n as insertionPlugin, e as intlayerNodePlugins, i as markdownPlugin, o as markdownStringPlugin, t as solidNodePlugins };
@@ -0,0 +1,197 @@
1
+ import { renderIntlayerNode as e } from "./esm/IntlayerNode.mjs";
2
+ import { useEditorStateManager as t } from "./esm/editor/contexts/EditorProvider.mjs";
3
+ import { useEditorEnabled as n } from "./esm/editor/contexts/EditorEnabledContext.mjs";
4
+ import { useFocusDictionary as r } from "./esm/editor/contexts/FocusDictionaryContext.mjs";
5
+ import { IntlayerClientContext as i, useIntlayerContext as a } from "./esm/client/IntlayerProvider.mjs";
6
+ import { useLoadDynamic as o } from "./esm/client/useLoadDynamic.mjs";
7
+ import { EditedContentRenderer as s } from "./esm/editor/useEditedContentRenderer.mjs";
8
+ import { MarkdownMetadataRenderer as c, MarkdownRenderer as l } from "./esm/markdown/MarkdownRenderer.mjs";
9
+ import { renderSolidElement as u } from "./esm/solidElement/renderSolidElement.mjs";
10
+ import { conditionPlugin as d, enumerationPlugin as f, filePlugin as p, genderPlugin as m, getDictionary as ee, getHTML as h, getIntlayer as g, nestedPlugin as _, splitInsertionTemplate as v, translationPlugin as y } from "@intlayer/core/interpreter";
11
+ import { Dynamic as te, createComponent as b, effect as x, getOwner as S, insert as C, mergeProps as w, template as T, use as E } from "solid-js/web";
12
+ import D from "@intlayer/config/built";
13
+ import { getMarkdownMetadata as O } from "@intlayer/core/markdown";
14
+ import { HTML_TAGS as ne } from "@intlayer/core/transpiler";
15
+ import { NodeType as k } from "@intlayer/types/nodeType";
16
+ import { isSameKeyPath as A } from "@intlayer/core/utils";
17
+ import { MessageKey as j, defineIntlayerElements as M } from "@intlayer/editor";
18
+ import { createMemo as N, onCleanup as P, onMount as F, useContext as I } from "solid-js";
19
+ //#region src/client/useDictionary.ts
20
+ var L = (e, t) => {
21
+ let n = I(i);
22
+ return N(() => $(e, t ?? n?.locale?.()));
23
+ }, R = async (e, t) => {
24
+ let { locale: n } = I(i), r = D?.internationalization.defaultLocale, a = t ?? n() ?? r;
25
+ return L(await e[a]?.(), a);
26
+ }, z = (e, t, n) => {
27
+ let { locale: r } = I(i) ?? {}, a = D?.internationalization.defaultLocale, s = n ?? r?.() ?? a;
28
+ return L(o(`${String(t)}.${s}`, e[s]?.()), s);
29
+ }, B = (e, t) => g(e, t, Q(t)), V = (e, t) => {
30
+ let n = I(i);
31
+ return N(() => {
32
+ let r = n?.locale();
33
+ return B(e, t ?? r);
34
+ });
35
+ }, H = /* @__PURE__ */ T("<intlayer-content-selector>", !0, !1, !1), U = (e) => {
36
+ let { focusedContent: n, setFocusedContent: i } = r(), a = t(), o = N(() => e.keyPath.filter((e) => e.type !== k.Translation)), s = N(() => (n()?.dictionaryKey === e.dictionaryKey && (n()?.keyPath?.length ?? 0) > 0 && A(n()?.keyPath ?? [], o())) ?? !1), c, l = () => {
37
+ i({
38
+ dictionaryKey: e.dictionaryKey,
39
+ keyPath: o()
40
+ });
41
+ }, u = () => {
42
+ a.messenger.send(`${j.INTLAYER_HOVERED_CONTENT_CHANGED}/post`, {
43
+ dictionaryKey: e.dictionaryKey,
44
+ keyPath: o()
45
+ });
46
+ }, d = () => {
47
+ a.messenger.send(`${j.INTLAYER_HOVERED_CONTENT_CHANGED}/post`, null);
48
+ };
49
+ return F(() => {
50
+ c && (c.addEventListener("intlayer:press", l), c.addEventListener("intlayer:hover", u), c.addEventListener("intlayer:unhover", d), P(() => {
51
+ c?.removeEventListener("intlayer:press", l), c?.removeEventListener("intlayer:hover", u), c?.removeEventListener("intlayer:unhover", d);
52
+ }));
53
+ }), (() => {
54
+ var t = H(), n = c;
55
+ return typeof n == "function" ? E(n, t) : c = t, t._$owner = S(), C(t, () => e.children), x(() => t.isSelecting = s() || void 0), t;
56
+ })();
57
+ }, W = (e) => {
58
+ let { enabled: t } = n(), { disableEditor: r } = a();
59
+ return F(() => M()), t() && !r ? b(U, w(e, { get children() {
60
+ return e.children;
61
+ } })) : e.children;
62
+ }, G = {
63
+ id: "intlayer-node-plugin",
64
+ canHandle: (e) => typeof e == "bigint" || typeof e == "string" || typeof e == "number",
65
+ transform: (t, { plugins: n, ...r }) => e({
66
+ ...r,
67
+ value: r.children,
68
+ children: D?.editor.enabled ? b(W, w(r, { get children() {
69
+ return b(s, w(r, { get children() {
70
+ return r.children;
71
+ } }));
72
+ } })) : r.children
73
+ })
74
+ }, K = {
75
+ id: "solid-node-plugin",
76
+ canHandle: (e) => typeof e == "object" && e?.props !== void 0 || typeof Node < "u" && e instanceof Node,
77
+ transform: (t, { plugins: n, ...r }) => e({
78
+ ...r,
79
+ value: "[[solid-element]]",
80
+ children: D?.editor.enabled ? b(W, w(r, { get children() {
81
+ return typeof Node < "u" && t instanceof Node ? t : u(t);
82
+ } })) : typeof Node < "u" && t instanceof Node ? t : u(t)
83
+ })
84
+ }, q = (e, t) => {
85
+ let n = v(e, t);
86
+ return n.isSimple, n.parts;
87
+ }, J = {
88
+ id: "insertion-plugin",
89
+ canHandle: (e) => typeof e == "object" && e?.nodeType === k.Insertion,
90
+ transform: (e, t, n) => {
91
+ let r = [...t.keyPath, { type: k.Insertion }], i = e[k.Insertion];
92
+ return (e) => {
93
+ let a = {
94
+ id: "insertion-string-plugin",
95
+ canHandle: (e) => typeof e == "string",
96
+ transform: (n, r, i) => {
97
+ let a = q(i(n, {
98
+ ...r,
99
+ children: n,
100
+ plugins: [...(t.plugins ?? []).filter((e) => e.id !== "intlayer-node-plugin")]
101
+ }), e);
102
+ return i(a, {
103
+ ...r,
104
+ plugins: t.plugins,
105
+ children: a
106
+ });
107
+ }
108
+ };
109
+ return n(i, {
110
+ ...t,
111
+ children: i,
112
+ keyPath: r,
113
+ plugins: [a, ...t.plugins ?? []]
114
+ });
115
+ };
116
+ }
117
+ }, Y = {
118
+ id: "markdown-string-plugin",
119
+ canHandle: (e) => typeof e == "string",
120
+ transform: (t, n, r) => {
121
+ let { plugins: i, ...a } = n, o = r(O(t), {
122
+ plugins: [{
123
+ id: "markdown-metadata-plugin",
124
+ canHandle: (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || !e,
125
+ transform: (n, r) => e({
126
+ ...r,
127
+ value: n,
128
+ children: b(W, w(a, { get children() {
129
+ return b(c, w(a, {
130
+ get metadataKeyPath() {
131
+ return r.keyPath;
132
+ },
133
+ children: t
134
+ }));
135
+ } }))
136
+ })
137
+ }],
138
+ dictionaryKey: a.dictionaryKey,
139
+ keyPath: []
140
+ }), s = (r) => e({
141
+ ...n,
142
+ value: t,
143
+ children: b(W, w(a, { get children() {
144
+ return b(l, w(a, {
145
+ components: r,
146
+ children: t
147
+ }));
148
+ } })),
149
+ additionalProps: { metadata: o }
150
+ }), u = s();
151
+ return new Proxy(u, { get(e, n, r) {
152
+ return n === "value" ? t : n === "metadata" ? o : n === "use" ? (e) => s(e) : Reflect.get(e, n, r);
153
+ } });
154
+ }
155
+ }, X = {
156
+ id: "markdown-plugin",
157
+ canHandle: (e) => typeof e == "object" && e?.nodeType === k.Markdown,
158
+ transform: (e, t, n) => {
159
+ let r = [...t.keyPath, { type: k.Markdown }], i = e[k.Markdown];
160
+ return n(i, {
161
+ ...t,
162
+ children: i,
163
+ keyPath: r,
164
+ plugins: [Y, ...t.plugins ?? []]
165
+ });
166
+ }
167
+ }, re = (() => {
168
+ let e = {};
169
+ for (let t of ne) e[t] = ({ children: e, ...n }) => b(te, w({ component: t }, n, { children: e }));
170
+ return e;
171
+ })(), Z = {
172
+ id: "html-plugin",
173
+ canHandle: (e) => typeof e == "object" && e?.nodeType === k.HTML,
174
+ transform: (e) => {
175
+ let t = e[k.HTML], n = (e) => h(t, {
176
+ ...re,
177
+ ...e
178
+ }), r = [n()];
179
+ return new Proxy(r, { get(e, r, i) {
180
+ return r === "value" ? t : r === "use" ? (e) => n(e) : Reflect.get(e, r, i);
181
+ } });
182
+ }
183
+ }, Q = (e, t = !0) => [
184
+ y(e ?? D.internationalization.defaultLocale, t ? D.internationalization.defaultLocale : void 0),
185
+ f,
186
+ d,
187
+ _(e ?? D.internationalization.defaultLocale),
188
+ p,
189
+ m,
190
+ G,
191
+ K,
192
+ J,
193
+ X,
194
+ Z
195
+ ], $ = (e, t) => ee(e, t, Q(t));
196
+ //#endregion
197
+ export { G as a, K as c, B as d, z as f, J as i, W as l, L as m, Q as n, X as o, R as p, Z as r, Y as s, $ as t, V as u };
@@ -0,0 +1 @@
1
+ const e=require(`./chunk-C91j1N6u.js`),t=require(`./cjs/IntlayerNode.cjs`),n=require(`./cjs/editor/contexts/EditorProvider.cjs`),r=require(`./cjs/editor/contexts/EditorEnabledContext.cjs`),i=require(`./cjs/editor/contexts/FocusDictionaryContext.cjs`),a=require(`./cjs/client/IntlayerProvider.cjs`),o=require(`./cjs/client/useLoadDynamic.cjs`),s=require(`./cjs/editor/useEditedContentRenderer.cjs`),c=require(`./cjs/markdown/MarkdownRenderer.cjs`),l=require(`./cjs/solidElement/renderSolidElement.cjs`);let u=require(`@intlayer/core/interpreter`),d=require(`solid-js/web`),f=require(`@intlayer/config/built`);f=e.t(f);let p=require(`@intlayer/core/markdown`),m=require(`@intlayer/core/transpiler`),h=require(`@intlayer/types/nodeType`),g=require(`@intlayer/core/utils`),_=require(`@intlayer/editor`),v=require(`solid-js`);var y=(e,t)=>{let n=(0,v.useContext)(a.IntlayerClientContext);return(0,v.createMemo)(()=>I(e,t??n?.locale?.()))},b=async(e,t)=>{let{locale:n}=(0,v.useContext)(a.IntlayerClientContext),r=f.default?.internationalization.defaultLocale,i=t??n()??r;return y(await e[i]?.(),i)},x=(e,t,n)=>{let{locale:r}=(0,v.useContext)(a.IntlayerClientContext)??{},i=f.default?.internationalization.defaultLocale,s=n??r?.()??i;return y(o.useLoadDynamic(`${String(t)}.${s}`,e[s]?.()),s)},S=(e,t)=>(0,u.getIntlayer)(e,t,F(t)),C=(e,t)=>{let n=(0,v.useContext)(a.IntlayerClientContext);return(0,v.createMemo)(()=>{let r=n?.locale();return S(e,t??r)})},w=(0,d.template)(`<intlayer-content-selector>`,!0,!1,!1),T=e=>{let{focusedContent:t,setFocusedContent:r}=i.useFocusDictionary(),a=n.useEditorStateManager(),o=(0,v.createMemo)(()=>e.keyPath.filter(e=>e.type!==h.NodeType.Translation)),s=(0,v.createMemo)(()=>(t()?.dictionaryKey===e.dictionaryKey&&(t()?.keyPath?.length??0)>0&&(0,g.isSameKeyPath)(t()?.keyPath??[],o()))??!1),c,l=()=>{r({dictionaryKey:e.dictionaryKey,keyPath:o()})},u=()=>{a.messenger.send(`${_.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,{dictionaryKey:e.dictionaryKey,keyPath:o()})},f=()=>{a.messenger.send(`${_.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,null)};return(0,v.onMount)(()=>{c&&(c.addEventListener(`intlayer:press`,l),c.addEventListener(`intlayer:hover`,u),c.addEventListener(`intlayer:unhover`,f),(0,v.onCleanup)(()=>{c?.removeEventListener(`intlayer:press`,l),c?.removeEventListener(`intlayer:hover`,u),c?.removeEventListener(`intlayer:unhover`,f)}))}),(()=>{var t=w(),n=c;return typeof n==`function`?(0,d.use)(n,t):c=t,t._$owner=(0,d.getOwner)(),(0,d.insert)(t,()=>e.children),(0,d.effect)(()=>t.isSelecting=s()||void 0),t})()},E=e=>{let{enabled:t}=r.useEditorEnabled(),{disableEditor:n}=a.useIntlayerContext();return(0,v.onMount)(()=>(0,_.defineIntlayerElements)()),t()&&!n?(0,d.createComponent)(T,(0,d.mergeProps)(e,{get children(){return e.children}})):e.children},D={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{plugins:n,...r})=>t.renderIntlayerNode({...r,value:r.children,children:f.default?.editor.enabled?(0,d.createComponent)(E,(0,d.mergeProps)(r,{get children(){return(0,d.createComponent)(s.EditedContentRenderer,(0,d.mergeProps)(r,{get children(){return r.children}}))}})):r.children})},O={id:`solid-node-plugin`,canHandle:e=>typeof e==`object`&&e?.props!==void 0||typeof Node<`u`&&e instanceof Node,transform:(e,{plugins:n,...r})=>t.renderIntlayerNode({...r,value:`[[solid-element]]`,children:f.default?.editor.enabled?(0,d.createComponent)(E,(0,d.mergeProps)(r,{get children(){return typeof Node<`u`&&e instanceof Node?e:l.renderSolidElement(e)}})):typeof Node<`u`&&e instanceof Node?e:l.renderSolidElement(e)})},k=(e,t)=>{let n=(0,u.splitInsertionTemplate)(e,t);return n.isSimple,n.parts},A={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.NodeType.Insertion,transform:(e,t,n)=>{let r=[...t.keyPath,{type:h.NodeType.Insertion}],i=e[h.NodeType.Insertion];return e=>{let a={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`,transform:(n,r,i)=>{let a=k(i(n,{...r,children:n,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]}),e);return i(a,{...r,plugins:t.plugins,children:a})}};return n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]})}}},j={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,r)=>{let{plugins:i,...a}=n,o=r((0,p.getMarkdownMetadata)(e),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(n,r)=>t.renderIntlayerNode({...r,value:n,children:(0,d.createComponent)(E,(0,d.mergeProps)(a,{get children(){return(0,d.createComponent)(c.MarkdownMetadataRenderer,(0,d.mergeProps)(a,{get metadataKeyPath(){return r.keyPath},children:e}))}}))})}],dictionaryKey:a.dictionaryKey,keyPath:[]}),s=r=>t.renderIntlayerNode({...n,value:e,children:(0,d.createComponent)(E,(0,d.mergeProps)(a,{get children(){return(0,d.createComponent)(c.MarkdownRenderer,(0,d.mergeProps)(a,{components:r,children:e}))}})),additionalProps:{metadata:o}}),l=s();return new Proxy(l,{get(t,n,r){return n===`value`?e:n===`metadata`?o:n===`use`?e=>s(e):Reflect.get(t,n,r)}})}},M={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.NodeType.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:h.NodeType.Markdown}],i=e[h.NodeType.Markdown];return n(i,{...t,children:i,keyPath:r,plugins:[j,...t.plugins??[]]})}},N=(()=>{let e={};for(let t of m.HTML_TAGS)e[t]=({children:e,...n})=>(0,d.createComponent)(d.Dynamic,(0,d.mergeProps)({component:t},n,{children:e}));return e})(),P={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.NodeType.HTML,transform:e=>{let t=e[h.NodeType.HTML],n=e=>(0,u.getHTML)(t,{...N,...e}),r=[n()];return new Proxy(r,{get(e,r,i){return r===`value`?t:r===`use`?e=>n(e):Reflect.get(e,r,i)}})}},F=(e,t=!0)=>[(0,u.translationPlugin)(e??f.default.internationalization.defaultLocale,t?f.default.internationalization.defaultLocale:void 0),u.enumerationPlugin,u.conditionPlugin,(0,u.nestedPlugin)(e??f.default.internationalization.defaultLocale),u.filePlugin,u.genderPlugin,D,O,A,M,P],I=(e,t)=>(0,u.getDictionary)(e,t,F(t));Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return C}});
@@ -1,5 +1,15 @@
1
1
  import { NodeProps } from '@intlayer/core/interpreter';
2
2
  import { Component, JSX } from 'solid-js';
3
+ declare module 'solid-js' {
4
+ namespace JSX {
5
+ interface IntrinsicElements {
6
+ 'intlayer-content-selector': JSX.HTMLAttributes<HTMLElement> & {
7
+ 'is-selecting'?: boolean | undefined;
8
+ 'press-duration'?: number;
9
+ };
10
+ }
11
+ }
12
+ }
3
13
  export type ContentSelectorWrapperProps = NodeProps & Omit<JSX.HTMLAttributes<HTMLDivElement>, 'children'> & {
4
14
  children?: JSX.Element;
5
15
  };