@intlayer/editor 9.5.10 → 9.5.12

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 (75) hide show
  1. package/dist/cjs/components/ContentSelector.cjs +0 -4
  2. package/dist/cjs/components/ContentSelector.cjs.map +1 -1
  3. package/dist/cjs/components/ContentSelectorWrapper.cjs +72 -76
  4. package/dist/cjs/components/ContentSelectorWrapper.cjs.map +1 -1
  5. package/dist/cjs/components/index.cjs +0 -6
  6. package/dist/cjs/core/EditorStateManager.cjs +32 -75
  7. package/dist/cjs/core/EditorStateManager.cjs.map +1 -1
  8. package/dist/cjs/core/IframeClickInterceptor.cjs +15 -9
  9. package/dist/cjs/core/IframeClickInterceptor.cjs.map +1 -1
  10. package/dist/cjs/core/index.cjs +3 -10
  11. package/dist/cjs/core/initEditorClient.cjs +1 -2
  12. package/dist/cjs/core/initEditorClient.cjs.map +1 -1
  13. package/dist/cjs/core/sharedWindowState.cjs +49 -0
  14. package/dist/cjs/core/sharedWindowState.cjs.map +1 -0
  15. package/dist/cjs/index.cjs +4 -21
  16. package/dist/esm/components/ContentSelector.mjs +0 -4
  17. package/dist/esm/components/ContentSelector.mjs.map +1 -1
  18. package/dist/esm/components/ContentSelectorWrapper.mjs +72 -76
  19. package/dist/esm/components/ContentSelectorWrapper.mjs.map +1 -1
  20. package/dist/esm/components/index.mjs +1 -3
  21. package/dist/esm/core/EditorStateManager.mjs +32 -75
  22. package/dist/esm/core/EditorStateManager.mjs.map +1 -1
  23. package/dist/esm/core/IframeClickInterceptor.mjs +15 -9
  24. package/dist/esm/core/IframeClickInterceptor.mjs.map +1 -1
  25. package/dist/esm/core/index.mjs +3 -4
  26. package/dist/esm/core/initEditorClient.mjs +2 -2
  27. package/dist/esm/core/initEditorClient.mjs.map +1 -1
  28. package/dist/esm/core/sharedWindowState.mjs +48 -0
  29. package/dist/esm/core/sharedWindowState.mjs.map +1 -0
  30. package/dist/esm/index.mjs +4 -9
  31. package/dist/types/components/ContentSelector.d.ts.map +1 -1
  32. package/dist/types/components/ContentSelectorWrapper.d.ts +12 -9
  33. package/dist/types/components/ContentSelectorWrapper.d.ts.map +1 -1
  34. package/dist/types/components/index.d.ts +1 -3
  35. package/dist/types/core/EditorStateManager.d.ts +7 -13
  36. package/dist/types/core/EditorStateManager.d.ts.map +1 -1
  37. package/dist/types/core/IframeClickInterceptor.d.ts +3 -7
  38. package/dist/types/core/IframeClickInterceptor.d.ts.map +1 -1
  39. package/dist/types/core/index.d.ts +3 -4
  40. package/dist/types/core/initEditorClient.d.ts +0 -2
  41. package/dist/types/core/initEditorClient.d.ts.map +1 -1
  42. package/dist/types/core/sharedWindowState.d.ts +18 -0
  43. package/dist/types/core/sharedWindowState.d.ts.map +1 -0
  44. package/dist/types/index.d.ts +3 -9
  45. package/package.json +5 -5
  46. package/dist/cjs/components/EditedContent.cjs +0 -161
  47. package/dist/cjs/components/EditedContent.cjs.map +0 -1
  48. package/dist/cjs/components/IntlayerEditor.cjs +0 -94
  49. package/dist/cjs/components/IntlayerEditor.cjs.map +0 -1
  50. package/dist/cjs/core/editedContentBus.cjs +0 -36
  51. package/dist/cjs/core/editedContentBus.cjs.map +0 -1
  52. package/dist/cjs/core/focusedContentBus.cjs +0 -42
  53. package/dist/cjs/core/focusedContentBus.cjs.map +0 -1
  54. package/dist/cjs/mergeIframeClick.cjs +0 -22
  55. package/dist/cjs/mergeIframeClick.cjs.map +0 -1
  56. package/dist/esm/components/EditedContent.mjs +0 -159
  57. package/dist/esm/components/EditedContent.mjs.map +0 -1
  58. package/dist/esm/components/IntlayerEditor.mjs +0 -92
  59. package/dist/esm/components/IntlayerEditor.mjs.map +0 -1
  60. package/dist/esm/core/editedContentBus.mjs +0 -33
  61. package/dist/esm/core/editedContentBus.mjs.map +0 -1
  62. package/dist/esm/core/focusedContentBus.mjs +0 -39
  63. package/dist/esm/core/focusedContentBus.mjs.map +0 -1
  64. package/dist/esm/mergeIframeClick.mjs +0 -21
  65. package/dist/esm/mergeIframeClick.mjs.map +0 -1
  66. package/dist/types/components/EditedContent.d.ts +0 -49
  67. package/dist/types/components/EditedContent.d.ts.map +0 -1
  68. package/dist/types/components/IntlayerEditor.d.ts +0 -44
  69. package/dist/types/components/IntlayerEditor.d.ts.map +0 -1
  70. package/dist/types/core/editedContentBus.d.ts +0 -7
  71. package/dist/types/core/editedContentBus.d.ts.map +0 -1
  72. package/dist/types/core/focusedContentBus.d.ts +0 -7
  73. package/dist/types/core/focusedContentBus.d.ts.map +0 -1
  74. package/dist/types/mergeIframeClick.d.ts +0 -4
  75. package/dist/types/mergeIframeClick.d.ts.map +0 -1
@@ -1,94 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_core_globalManager = require('../core/globalManager.cjs');
3
- const require_core_initEditorClient = require('../core/initEditorClient.cjs');
4
-
5
- //#region src/components/IntlayerEditor.ts
6
- const _HTMLElement = typeof HTMLElement !== "undefined" ? HTMLElement : class {};
7
- /**
8
- * <intlayer-editor>
9
- *
10
- * A framework-agnostic web component that manages the Intlayer editor singleton
11
- * lifecycle and keeps the current locale in sync with the EditorStateManager.
12
- *
13
- * Drop this element once at the root of your application to activate the editor.
14
- * It renders no UI.
15
- *
16
- * @prop {IntlayerConfig} configuration - The Intlayer config (required; set as JS property, not attribute)
17
- * @prop {string} locale - The active application locale (attribute/property)
18
- *
19
- * @example
20
- * // Svelte
21
- * <intlayer-editor .configuration={config} locale={$locale} />
22
- *
23
- * // Vue
24
- * <intlayer-editor :configuration="config" :locale="currentLocale" />
25
- */
26
- var IntlayerEditorElement = class extends _HTMLElement {
27
- _configuration = void 0;
28
- _locale = void 0;
29
- _initialized = false;
30
- _unsubManager = null;
31
- static get observedAttributes() {
32
- return ["locale"];
33
- }
34
- get configuration() {
35
- return this._configuration;
36
- }
37
- set configuration(v) {
38
- this._configuration = v;
39
- if (!this._initialized) this._init();
40
- }
41
- get locale() {
42
- return this._locale;
43
- }
44
- set locale(v) {
45
- this._locale = v;
46
- if (v && this._initialized) this._syncLocale(v);
47
- }
48
- attributeChangedCallback(name, _oldVal, newVal) {
49
- if (name === "locale" && newVal !== null) {
50
- this._locale = newVal;
51
- if (this._initialized) this._syncLocale(newVal);
52
- }
53
- }
54
- connectedCallback() {
55
- this._init();
56
- }
57
- disconnectedCallback() {
58
- this._unsubManager?.();
59
- this._unsubManager = null;
60
- if (this._initialized) {
61
- require_core_initEditorClient.stopEditorClient();
62
- this._initialized = false;
63
- }
64
- }
65
- _init() {
66
- if (this._initialized) return;
67
- require_core_initEditorClient.initEditorClient();
68
- this._initialized = true;
69
- if (this._locale) this._syncLocale(this._locale);
70
- }
71
- _syncLocale(locale) {
72
- const manager = require_core_globalManager.getGlobalEditorManager();
73
- if (manager) manager.currentLocale.set(locale);
74
- else {
75
- this._unsubManager?.();
76
- this._unsubManager = require_core_globalManager.onGlobalEditorManagerChange((m) => {
77
- if (m) {
78
- this._unsubManager?.();
79
- this._unsubManager = null;
80
- m.currentLocale.set(locale);
81
- }
82
- });
83
- }
84
- }
85
- };
86
- const defineIntlayerEditorElement = () => {
87
- if (typeof customElements === "undefined") return;
88
- if (!customElements.get("intlayer-editor")) customElements.define("intlayer-editor", IntlayerEditorElement);
89
- };
90
-
91
- //#endregion
92
- exports.IntlayerEditorElement = IntlayerEditorElement;
93
- exports.defineIntlayerEditorElement = defineIntlayerEditorElement;
94
- //# sourceMappingURL=IntlayerEditor.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlayerEditor.cjs","names":["getGlobalEditorManager","onGlobalEditorManagerChange"],"sources":["../../../src/components/IntlayerEditor.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport {\n getGlobalEditorManager,\n onGlobalEditorManagerChange,\n} from '../core/globalManager';\nimport { initEditorClient, stopEditorClient } from '../core/initEditorClient';\n\nconst _HTMLElement =\n typeof HTMLElement !== 'undefined'\n ? HTMLElement\n : (class {} as unknown as typeof HTMLElement);\n\n/**\n * <intlayer-editor>\n *\n * A framework-agnostic web component that manages the Intlayer editor singleton\n * lifecycle and keeps the current locale in sync with the EditorStateManager.\n *\n * Drop this element once at the root of your application to activate the editor.\n * It renders no UI.\n *\n * @prop {IntlayerConfig} configuration - The Intlayer config (required; set as JS property, not attribute)\n * @prop {string} locale - The active application locale (attribute/property)\n *\n * @example\n * // Svelte\n * <intlayer-editor .configuration={config} locale={$locale} />\n *\n * // Vue\n * <intlayer-editor :configuration=\"config\" :locale=\"currentLocale\" />\n */\nexport class IntlayerEditorElement extends _HTMLElement {\n private _configuration: IntlayerConfig | undefined = undefined;\n private _locale: string | undefined = undefined;\n private _initialized = false;\n private _unsubManager: (() => void) | null = null;\n\n static get observedAttributes(): string[] {\n return ['locale'];\n }\n\n get configuration(): IntlayerConfig | undefined {\n return this._configuration;\n }\n set configuration(v: IntlayerConfig | undefined) {\n this._configuration = v;\n if (!this._initialized) this._init();\n }\n\n get locale(): string | undefined {\n return this._locale;\n }\n set locale(v: string | undefined) {\n this._locale = v;\n if (v && this._initialized) this._syncLocale(v);\n }\n\n attributeChangedCallback(\n name: string,\n _oldVal: string | null,\n newVal: string | null\n ): void {\n if (name === 'locale' && newVal !== null) {\n this._locale = newVal;\n if (this._initialized) this._syncLocale(newVal);\n }\n }\n\n connectedCallback(): void {\n this._init();\n }\n\n disconnectedCallback(): void {\n this._unsubManager?.();\n this._unsubManager = null;\n if (this._initialized) {\n stopEditorClient();\n this._initialized = false;\n }\n }\n\n private _init(): void {\n if (this._initialized) return;\n initEditorClient();\n this._initialized = true;\n if (this._locale) this._syncLocale(this._locale);\n }\n\n private _syncLocale(locale: string): void {\n const manager = getGlobalEditorManager();\n if (manager) {\n manager.currentLocale.set(locale as Locale);\n } else {\n // Manager may not be ready yet — wait for it\n this._unsubManager?.();\n this._unsubManager = onGlobalEditorManagerChange((m) => {\n if (m) {\n this._unsubManager?.();\n this._unsubManager = null;\n m.currentLocale.set(locale as Locale);\n }\n });\n }\n }\n}\n\nexport const defineIntlayerEditorElement = (): void => {\n if (typeof customElements === 'undefined') return;\n if (!customElements.get('intlayer-editor')) {\n customElements.define('intlayer-editor', IntlayerEditorElement);\n }\n};\n"],"mappings":";;;;;AAQA,MAAM,eACJ,OAAO,gBAAgB,cACnB,cACC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;AAqBd,IAAa,wBAAb,cAA2C,aAAa;CACtD,AAAQ,iBAA6C;CACrD,AAAQ,UAA8B;CACtC,AAAQ,eAAe;CACvB,AAAQ,gBAAqC;CAE7C,WAAW,qBAA+B;EACxC,OAAO,CAAC,QAAQ;CAClB;CAEA,IAAI,gBAA4C;EAC9C,OAAO,KAAK;CACd;CACA,IAAI,cAAc,GAA+B;EAC/C,KAAK,iBAAiB;EACtB,IAAI,CAAC,KAAK,cAAc,KAAK,MAAM;CACrC;CAEA,IAAI,SAA6B;EAC/B,OAAO,KAAK;CACd;CACA,IAAI,OAAO,GAAuB;EAChC,KAAK,UAAU;EACf,IAAI,KAAK,KAAK,cAAc,KAAK,YAAY,CAAC;CAChD;CAEA,yBACE,MACA,SACA,QACM;EACN,IAAI,SAAS,YAAY,WAAW,MAAM;GACxC,KAAK,UAAU;GACf,IAAI,KAAK,cAAc,KAAK,YAAY,MAAM;EAChD;CACF;CAEA,oBAA0B;EACxB,KAAK,MAAM;CACb;CAEA,uBAA6B;EAC3B,KAAK,gBAAgB;EACrB,KAAK,gBAAgB;EACrB,IAAI,KAAK,cAAc;GACrB,+CAAiB;GACjB,KAAK,eAAe;EACtB;CACF;CAEA,AAAQ,QAAc;EACpB,IAAI,KAAK,cAAc;EACvB,+CAAiB;EACjB,KAAK,eAAe;EACpB,IAAI,KAAK,SAAS,KAAK,YAAY,KAAK,OAAO;CACjD;CAEA,AAAQ,YAAY,QAAsB;EACxC,MAAM,UAAUA,kDAAuB;EACvC,IAAI,SACF,QAAQ,cAAc,IAAI,MAAgB;OACrC;GAEL,KAAK,gBAAgB;GACrB,KAAK,gBAAgBC,wDAA6B,MAAM;IACtD,IAAI,GAAG;KACL,KAAK,gBAAgB;KACrB,KAAK,gBAAgB;KACrB,EAAE,cAAc,IAAI,MAAgB;IACtC;GACF,CAAC;EACH;CACF;AACF;AAEA,MAAa,oCAA0C;CACrD,IAAI,OAAO,mBAAmB,aAAa;CAC3C,IAAI,CAAC,eAAe,IAAI,iBAAiB,GACvC,eAAe,OAAO,mBAAmB,qBAAqB;AAElE"}
@@ -1,36 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- //#region src/core/editedContentBus.ts
3
- const BUS_KEY = "__intlayer_edited_content_bus__";
4
- const BUS_EVENTS_KEY = "__intlayer_edited_content_bus_events__";
5
- const getBusTarget = () => {
6
- if (typeof window === "undefined") return new EventTarget();
7
- const w = window;
8
- if (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();
9
- return w[BUS_EVENTS_KEY];
10
- };
11
- const getGlobalEditedContent = () => {
12
- if (typeof window === "undefined") return {};
13
- return window[BUS_KEY] ?? {};
14
- };
15
- const setGlobalEditedContent = (content, sourceId) => {
16
- if (typeof window !== "undefined") window[BUS_KEY] = content;
17
- getBusTarget().dispatchEvent(new CustomEvent("change", { detail: {
18
- content,
19
- sourceId
20
- } }));
21
- };
22
- const subscribeToGlobalEditedContent = (cb) => {
23
- const handler = (e) => {
24
- const { content, sourceId } = e.detail;
25
- cb(content, sourceId);
26
- };
27
- const target = getBusTarget();
28
- target.addEventListener("change", handler);
29
- return () => target.removeEventListener("change", handler);
30
- };
31
-
32
- //#endregion
33
- exports.getGlobalEditedContent = getGlobalEditedContent;
34
- exports.setGlobalEditedContent = setGlobalEditedContent;
35
- exports.subscribeToGlobalEditedContent = subscribeToGlobalEditedContent;
36
- //# sourceMappingURL=editedContentBus.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editedContentBus.cjs","names":[],"sources":["../../../src/core/editedContentBus.ts"],"sourcesContent":["import type { DictionaryContent } from './EditorStateManager';\n\nconst BUS_KEY = '__intlayer_edited_content_bus__';\nconst BUS_EVENTS_KEY = '__intlayer_edited_content_bus_events__';\n\ntype WindowWithBus = typeof window & {\n [BUS_KEY]?: DictionaryContent;\n [BUS_EVENTS_KEY]?: EventTarget;\n};\n\ntype BusEvent = { content: DictionaryContent; sourceId?: string };\n\nconst getBusTarget = (): EventTarget => {\n if (typeof window === 'undefined') return new EventTarget();\n const w = window as WindowWithBus;\n if (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();\n return w[BUS_EVENTS_KEY]!;\n};\n\nexport const getGlobalEditedContent = (): DictionaryContent => {\n if (typeof window === 'undefined') return {};\n return (window as WindowWithBus)[BUS_KEY] ?? {};\n};\n\nexport const setGlobalEditedContent = (\n content: DictionaryContent,\n sourceId?: string\n): void => {\n if (typeof window !== 'undefined') {\n (window as WindowWithBus)[BUS_KEY] = content;\n }\n getBusTarget().dispatchEvent(\n new CustomEvent<BusEvent>('change', { detail: { content, sourceId } })\n );\n};\n\nexport const subscribeToGlobalEditedContent = (\n cb: (content: DictionaryContent, sourceId?: string) => void\n): (() => void) => {\n const handler = (e: Event) => {\n const { content, sourceId } = (e as CustomEvent<BusEvent>).detail;\n cb(content, sourceId);\n };\n const target = getBusTarget();\n target.addEventListener('change', handler);\n return () => target.removeEventListener('change', handler);\n};\n"],"mappings":";;AAEA,MAAM,UAAU;AAChB,MAAM,iBAAiB;AASvB,MAAM,qBAAkC;CACtC,IAAI,OAAO,WAAW,aAAa,OAAO,IAAI,YAAY;CAC1D,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,iBAAiB,EAAE,kBAAkB,IAAI,YAAY;CAC5D,OAAO,EAAE;AACX;AAEA,MAAa,+BAAkD;CAC7D,IAAI,OAAO,WAAW,aAAa,OAAO,CAAC;CAC3C,OAAQ,OAAyB,YAAY,CAAC;AAChD;AAEA,MAAa,0BACX,SACA,aACS;CACT,IAAI,OAAO,WAAW,aACpB,AAAC,OAAyB,WAAW;CAEvC,aAAa,CAAC,CAAC,cACb,IAAI,YAAsB,UAAU,EAAE,QAAQ;EAAE;EAAS;CAAS,EAAE,CAAC,CACvE;AACF;AAEA,MAAa,kCACX,OACiB;CACjB,MAAM,WAAW,MAAa;EAC5B,MAAM,EAAE,SAAS,aAAc,EAA4B;EAC3D,GAAG,SAAS,QAAQ;CACtB;CACA,MAAM,SAAS,aAAa;CAC5B,OAAO,iBAAiB,UAAU,OAAO;CACzC,aAAa,OAAO,oBAAoB,UAAU,OAAO;AAC3D"}
@@ -1,42 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- //#region src/core/focusedContentBus.ts
3
- const BUS_KEY = "__intlayer_focused_content_bus__";
4
- const BUS_EVENTS_KEY = "__intlayer_focused_content_bus_events__";
5
- const getBusTarget = () => {
6
- if (typeof window === "undefined") return new EventTarget();
7
- const w = window;
8
- if (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();
9
- return w[BUS_EVENTS_KEY];
10
- };
11
- const getGlobalFocusedContent = () => {
12
- if (typeof window === "undefined") return void 0;
13
- const w = window;
14
- if (!w.__intlayer_focused_content_bus_set__) return void 0;
15
- return w[BUS_KEY] ?? null;
16
- };
17
- const setGlobalFocusedContent = (content, sourceId) => {
18
- if (typeof window !== "undefined") {
19
- const w = window;
20
- w[BUS_KEY] = content;
21
- w.__intlayer_focused_content_bus_set__ = true;
22
- }
23
- getBusTarget().dispatchEvent(new CustomEvent("change", { detail: {
24
- content,
25
- sourceId
26
- } }));
27
- };
28
- const subscribeToGlobalFocusedContent = (cb) => {
29
- const handler = (e) => {
30
- const { content, sourceId } = e.detail;
31
- cb(content, sourceId);
32
- };
33
- const target = getBusTarget();
34
- target.addEventListener("change", handler);
35
- return () => target.removeEventListener("change", handler);
36
- };
37
-
38
- //#endregion
39
- exports.getGlobalFocusedContent = getGlobalFocusedContent;
40
- exports.setGlobalFocusedContent = setGlobalFocusedContent;
41
- exports.subscribeToGlobalFocusedContent = subscribeToGlobalFocusedContent;
42
- //# sourceMappingURL=focusedContentBus.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"focusedContentBus.cjs","names":[],"sources":["../../../src/core/focusedContentBus.ts"],"sourcesContent":["import type { FileContent } from './EditorStateManager';\n\nconst BUS_KEY = '__intlayer_focused_content_bus__';\nconst BUS_EVENTS_KEY = '__intlayer_focused_content_bus_events__';\n\ntype WindowWithBus = typeof window & {\n [BUS_KEY]?: FileContent | null;\n [BUS_EVENTS_KEY]?: EventTarget;\n __intlayer_focused_content_bus_set__?: boolean;\n};\n\ntype BusEvent = { content: FileContent | null; sourceId?: string };\n\nconst getBusTarget = (): EventTarget => {\n if (typeof window === 'undefined') return new EventTarget();\n const w = window as WindowWithBus;\n if (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();\n return w[BUS_EVENTS_KEY]!;\n};\n\nexport const getGlobalFocusedContent = (): FileContent | null | undefined => {\n if (typeof window === 'undefined') return undefined;\n const w = window as WindowWithBus;\n if (!w.__intlayer_focused_content_bus_set__) return undefined;\n return w[BUS_KEY] ?? null;\n};\n\nexport const setGlobalFocusedContent = (\n content: FileContent | null,\n sourceId?: string\n): void => {\n if (typeof window !== 'undefined') {\n const w = window as WindowWithBus;\n w[BUS_KEY] = content;\n w.__intlayer_focused_content_bus_set__ = true;\n }\n getBusTarget().dispatchEvent(\n new CustomEvent<BusEvent>('change', { detail: { content, sourceId } })\n );\n};\n\nexport const subscribeToGlobalFocusedContent = (\n cb: (content: FileContent | null, sourceId?: string) => void\n): (() => void) => {\n const handler = (e: Event) => {\n const { content, sourceId } = (e as CustomEvent<BusEvent>).detail;\n cb(content, sourceId);\n };\n const target = getBusTarget();\n target.addEventListener('change', handler);\n return () => target.removeEventListener('change', handler);\n};\n"],"mappings":";;AAEA,MAAM,UAAU;AAChB,MAAM,iBAAiB;AAUvB,MAAM,qBAAkC;CACtC,IAAI,OAAO,WAAW,aAAa,OAAO,IAAI,YAAY;CAC1D,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,iBAAiB,EAAE,kBAAkB,IAAI,YAAY;CAC5D,OAAO,EAAE;AACX;AAEA,MAAa,gCAAgE;CAC3E,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,sCAAsC,OAAO;CACpD,OAAO,EAAE,YAAY;AACvB;AAEA,MAAa,2BACX,SACA,aACS;CACT,IAAI,OAAO,WAAW,aAAa;EACjC,MAAM,IAAI;EACV,EAAE,WAAW;EACb,EAAE,uCAAuC;CAC3C;CACA,aAAa,CAAC,CAAC,cACb,IAAI,YAAsB,UAAU,EAAE,QAAQ;EAAE;EAAS;CAAS,EAAE,CAAC,CACvE;AACF;AAEA,MAAa,mCACX,OACiB;CACjB,MAAM,WAAW,MAAa;EAC5B,MAAM,EAAE,SAAS,aAAc,EAA4B;EAC3D,GAAG,SAAS,QAAQ;CACtB;CACA,MAAM,SAAS,aAAa;CAC5B,OAAO,iBAAiB,UAAU,OAAO;CACzC,aAAa,OAAO,oBAAoB,UAAU,OAAO;AAC3D"}
@@ -1,22 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- //#region src/mergeIframeClick.ts
3
- const mergeIframeClick = (event) => {
4
- const simulatedMouseDownEvent = new MouseEvent("mousedown", {
5
- bubbles: true,
6
- cancelable: true,
7
- view: window
8
- });
9
- const simulatedClickEvent = new MouseEvent("click", {
10
- bubbles: true,
11
- cancelable: true,
12
- view: window
13
- });
14
- Object.assign(simulatedClickEvent, { iframeData: event });
15
- Object.assign(simulatedMouseDownEvent, { iframeData: event });
16
- window.dispatchEvent(simulatedClickEvent);
17
- window.dispatchEvent(simulatedMouseDownEvent);
18
- };
19
-
20
- //#endregion
21
- exports.mergeIframeClick = mergeIframeClick;
22
- //# sourceMappingURL=mergeIframeClick.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeIframeClick.cjs","names":[],"sources":["../../src/mergeIframeClick.ts"],"sourcesContent":["// Listener for messages from the iframe\nexport const mergeIframeClick = (event: MessageEvent) => {\n // Simulate or merge the iframe message with a click event\n const simulatedMouseDownEvent = new MouseEvent('mousedown', {\n bubbles: true,\n cancelable: true,\n view: window,\n });\n const simulatedClickEvent = new MouseEvent('click', {\n bubbles: true,\n cancelable: true,\n view: window,\n });\n\n // Optionally attach additional properties from the iframe message\n Object.assign(simulatedClickEvent, { iframeData: event });\n Object.assign(simulatedMouseDownEvent, { iframeData: event });\n\n // Dispatch the simulated click event on the window or a specific element\n window.dispatchEvent(simulatedClickEvent);\n window.dispatchEvent(simulatedMouseDownEvent);\n};\n"],"mappings":";;AACA,MAAa,oBAAoB,UAAwB;CAEvD,MAAM,0BAA0B,IAAI,WAAW,aAAa;EAC1D,SAAS;EACT,YAAY;EACZ,MAAM;CACR,CAAC;CACD,MAAM,sBAAsB,IAAI,WAAW,SAAS;EAClD,SAAS;EACT,YAAY;EACZ,MAAM;CACR,CAAC;CAGD,OAAO,OAAO,qBAAqB,EAAE,YAAY,MAAM,CAAC;CACxD,OAAO,OAAO,yBAAyB,EAAE,YAAY,MAAM,CAAC;CAG5D,OAAO,cAAc,mBAAmB;CACxC,OAAO,cAAc,uBAAuB;AAC9C"}
@@ -1,159 +0,0 @@
1
- import { getGlobalEditorManager, onGlobalEditorManagerChange } from "../core/globalManager.mjs";
2
- import { getBasePlugins, getContent } from "@intlayer/core/interpreter";
3
-
4
- //#region src/components/EditedContent.ts
5
- const _HTMLElement = typeof HTMLElement !== "undefined" ? HTMLElement : class {};
6
- /**
7
- * <intlayer-edited-content>
8
- *
9
- * Framework-agnostic web component that displays edited content from the Intlayer
10
- * editor. When the editor has an edited value for the given dictionary key and
11
- * key path, it renders the edited value; otherwise it renders the original
12
- * content via a slot.
13
- *
14
- * Always wraps content in <intlayer-content-selector-wrapper> for selection UI.
15
- *
16
- * @attr {string} dictionary-key - The dictionary key owning this content node
17
- * @attr {string} key-path - JSON-serialized KeyPath[] for this content node
18
- * @attr {string} locale - The current locale string
19
- */
20
- var IntlayerEditedContentElement = class extends _HTMLElement {
21
- _dictionaryKey = "";
22
- _keyPathJson = "[]";
23
- _locale = "";
24
- _editedText = null;
25
- _unsubManager = null;
26
- _unsubEditedContent = null;
27
- _selectorWrapper;
28
- _slot;
29
- static get observedAttributes() {
30
- return [
31
- "dictionary-key",
32
- "key-path",
33
- "locale"
34
- ];
35
- }
36
- get dictionaryKey() {
37
- return this._dictionaryKey;
38
- }
39
- set dictionaryKey(v) {
40
- this._dictionaryKey = v;
41
- this._selectorWrapper.setAttribute("dictionary-key", v);
42
- }
43
- get keyPathJson() {
44
- return this._keyPathJson;
45
- }
46
- set keyPathJson(v) {
47
- this._keyPathJson = v;
48
- this._selectorWrapper.setAttribute("key-path", v);
49
- }
50
- get locale() {
51
- return this._locale;
52
- }
53
- set locale(v) {
54
- this._locale = v;
55
- }
56
- constructor() {
57
- super();
58
- const shadow = this.attachShadow({ mode: "open" });
59
- const style = document.createElement("style");
60
- style.textContent = ":host { display: contents; }";
61
- shadow.appendChild(style);
62
- this._selectorWrapper = document.createElement("intlayer-content-selector-wrapper");
63
- this._slot = document.createElement("slot");
64
- this._selectorWrapper.appendChild(this._slot);
65
- shadow.appendChild(this._selectorWrapper);
66
- }
67
- attributeChangedCallback(name, _oldVal, newVal) {
68
- const val = newVal ?? "";
69
- if (name === "dictionary-key") {
70
- this._dictionaryKey = val;
71
- this._selectorWrapper.setAttribute("dictionary-key", val);
72
- } else if (name === "key-path") {
73
- this._keyPathJson = val || "[]";
74
- this._selectorWrapper.setAttribute("key-path", this._keyPathJson);
75
- } else if (name === "locale") this._locale = val;
76
- }
77
- connectedCallback() {
78
- this._subscribeToManager();
79
- }
80
- disconnectedCallback() {
81
- this._teardown();
82
- }
83
- _teardown() {
84
- this._unsubManager?.();
85
- this._unsubEditedContent?.();
86
- this._unsubManager = null;
87
- this._unsubEditedContent = null;
88
- }
89
- _getKeyPath() {
90
- try {
91
- return JSON.parse(this._keyPathJson);
92
- } catch {
93
- return [];
94
- }
95
- }
96
- _render() {
97
- while (this._selectorWrapper.firstChild) this._selectorWrapper.removeChild(this._selectorWrapper.firstChild);
98
- if (this._editedText !== null) this._selectorWrapper.appendChild(document.createTextNode(this._editedText));
99
- else this._selectorWrapper.appendChild(this._slot);
100
- }
101
- _resolveEditedText(manager) {
102
- const keyPath = this._getKeyPath();
103
- const editedValue = manager.getContentValue(this._dictionaryKey, keyPath);
104
- if (editedValue === void 0 || editedValue === null) {
105
- this._editedText = null;
106
- this._render();
107
- return;
108
- }
109
- if (typeof editedValue === "string" || typeof editedValue === "number") {
110
- this._editedText = String(editedValue);
111
- this._render();
112
- return;
113
- }
114
- if (typeof editedValue === "object") {
115
- const locale = this._locale || void 0;
116
- const transformed = getContent(editedValue, {
117
- locale,
118
- dictionaryKey: this._dictionaryKey,
119
- keyPath
120
- }, getBasePlugins(locale));
121
- if (typeof transformed === "string" || typeof transformed === "number") this._editedText = String(transformed);
122
- else {
123
- console.error(`[intlayer-edited-content] Incorrect edited content format. Expected string. Value: ${JSON.stringify(transformed)}`);
124
- this._editedText = null;
125
- }
126
- this._render();
127
- return;
128
- }
129
- this._editedText = null;
130
- this._render();
131
- }
132
- _setupManagerSubscriptions(manager) {
133
- this._resolveEditedText(manager);
134
- const handleChange = () => this._resolveEditedText(manager);
135
- manager.editedContent.addEventListener("change", handleChange);
136
- this._unsubEditedContent = () => manager.editedContent.removeEventListener("change", handleChange);
137
- }
138
- _subscribeToManager() {
139
- const manager = getGlobalEditorManager();
140
- if (manager) this._setupManagerSubscriptions(manager);
141
- this._unsubManager = onGlobalEditorManagerChange((m) => {
142
- this._unsubEditedContent?.();
143
- this._unsubEditedContent = null;
144
- if (m) this._setupManagerSubscriptions(m);
145
- else {
146
- this._editedText = null;
147
- this._render();
148
- }
149
- });
150
- }
151
- };
152
- const defineIntlayerEditedContent = () => {
153
- if (typeof customElements === "undefined") return;
154
- if (!customElements.get("intlayer-edited-content")) customElements.define("intlayer-edited-content", IntlayerEditedContentElement);
155
- };
156
-
157
- //#endregion
158
- export { IntlayerEditedContentElement, defineIntlayerEditedContent };
159
- //# sourceMappingURL=EditedContent.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EditedContent.mjs","names":[],"sources":["../../../src/components/EditedContent.ts"],"sourcesContent":["import { getBasePlugins, getContent } from '@intlayer/core/interpreter';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { EditorStateManager } from '../core/EditorStateManager';\nimport {\n getGlobalEditorManager,\n onGlobalEditorManagerChange,\n} from '../core/globalManager';\n\nconst _HTMLElement =\n typeof HTMLElement !== 'undefined'\n ? HTMLElement\n : (class {} as unknown as typeof HTMLElement);\n\n/**\n * <intlayer-edited-content>\n *\n * Framework-agnostic web component that displays edited content from the Intlayer\n * editor. When the editor has an edited value for the given dictionary key and\n * key path, it renders the edited value; otherwise it renders the original\n * content via a slot.\n *\n * Always wraps content in <intlayer-content-selector-wrapper> for selection UI.\n *\n * @attr {string} dictionary-key - The dictionary key owning this content node\n * @attr {string} key-path - JSON-serialized KeyPath[] for this content node\n * @attr {string} locale - The current locale string\n */\nexport class IntlayerEditedContentElement extends _HTMLElement {\n private _dictionaryKey = '';\n private _keyPathJson = '[]';\n private _locale = '';\n private _editedText: string | null = null;\n\n private _unsubManager: (() => void) | null = null;\n private _unsubEditedContent: (() => void) | null = null;\n\n private _selectorWrapper: HTMLElement;\n private _slot: HTMLSlotElement;\n\n static get observedAttributes(): string[] {\n return ['dictionary-key', 'key-path', 'locale'];\n }\n\n get dictionaryKey(): string {\n return this._dictionaryKey;\n }\n set dictionaryKey(v: string) {\n this._dictionaryKey = v;\n this._selectorWrapper.setAttribute('dictionary-key', v);\n }\n\n get keyPathJson(): string {\n return this._keyPathJson;\n }\n set keyPathJson(v: string) {\n this._keyPathJson = v;\n this._selectorWrapper.setAttribute('key-path', v);\n }\n\n get locale(): string {\n return this._locale;\n }\n set locale(v: string) {\n this._locale = v;\n }\n\n constructor() {\n super();\n const shadow = this.attachShadow({ mode: 'open' });\n\n const style = document.createElement('style');\n style.textContent = ':host { display: contents; }';\n shadow.appendChild(style);\n\n this._selectorWrapper = document.createElement(\n 'intlayer-content-selector-wrapper'\n );\n this._slot = document.createElement('slot') as HTMLSlotElement;\n this._selectorWrapper.appendChild(this._slot);\n shadow.appendChild(this._selectorWrapper);\n }\n\n attributeChangedCallback(\n name: string,\n _oldVal: string | null,\n newVal: string | null\n ): void {\n const val = newVal ?? '';\n if (name === 'dictionary-key') {\n this._dictionaryKey = val;\n this._selectorWrapper.setAttribute('dictionary-key', val);\n } else if (name === 'key-path') {\n this._keyPathJson = val || '[]';\n this._selectorWrapper.setAttribute('key-path', this._keyPathJson);\n } else if (name === 'locale') {\n this._locale = val;\n }\n }\n\n connectedCallback(): void {\n this._subscribeToManager();\n }\n\n disconnectedCallback(): void {\n this._teardown();\n }\n\n private _teardown(): void {\n this._unsubManager?.();\n this._unsubEditedContent?.();\n this._unsubManager = null;\n this._unsubEditedContent = null;\n }\n\n private _getKeyPath(): KeyPath[] {\n try {\n return JSON.parse(this._keyPathJson);\n } catch {\n return [];\n }\n }\n\n private _render(): void {\n while (this._selectorWrapper.firstChild) {\n this._selectorWrapper.removeChild(this._selectorWrapper.firstChild);\n }\n if (this._editedText !== null) {\n this._selectorWrapper.appendChild(\n document.createTextNode(this._editedText)\n );\n } else {\n this._selectorWrapper.appendChild(this._slot);\n }\n }\n\n private _resolveEditedText(manager: EditorStateManager): void {\n const keyPath = this._getKeyPath();\n const editedValue = manager.getContentValue(this._dictionaryKey, keyPath);\n\n if (editedValue === undefined || editedValue === null) {\n this._editedText = null;\n this._render();\n return;\n }\n\n if (typeof editedValue === 'string' || typeof editedValue === 'number') {\n this._editedText = String(editedValue);\n this._render();\n return;\n }\n\n if (typeof editedValue === 'object') {\n const locale = this._locale || undefined;\n const transformed = getContent(\n editedValue,\n {\n locale: locale as any,\n dictionaryKey: this._dictionaryKey,\n keyPath,\n },\n getBasePlugins(locale)\n );\n if (typeof transformed === 'string' || typeof transformed === 'number') {\n this._editedText = String(transformed);\n } else {\n console.error(\n `[intlayer-edited-content] Incorrect edited content format. Expected string. Value: ${JSON.stringify(transformed)}`\n );\n this._editedText = null;\n }\n this._render();\n return;\n }\n\n this._editedText = null;\n this._render();\n }\n\n private _setupManagerSubscriptions(manager: EditorStateManager): void {\n this._resolveEditedText(manager);\n\n const handleChange = () => this._resolveEditedText(manager);\n manager.editedContent.addEventListener('change', handleChange);\n\n this._unsubEditedContent = () =>\n manager.editedContent.removeEventListener('change', handleChange);\n }\n\n private _subscribeToManager(): void {\n const manager = getGlobalEditorManager();\n if (manager) {\n this._setupManagerSubscriptions(manager);\n }\n\n this._unsubManager = onGlobalEditorManagerChange((m) => {\n this._unsubEditedContent?.();\n this._unsubEditedContent = null;\n if (m) {\n this._setupManagerSubscriptions(m);\n } else {\n this._editedText = null;\n this._render();\n }\n });\n }\n}\n\nexport const defineIntlayerEditedContent = (): void => {\n if (typeof customElements === 'undefined') return;\n\n if (!customElements.get('intlayer-edited-content')) {\n customElements.define(\n 'intlayer-edited-content',\n IntlayerEditedContentElement\n );\n }\n};\n"],"mappings":";;;;AAQA,MAAM,eACJ,OAAO,gBAAgB,cACnB,cACC,MAAM,CAAC;;;;;;;;;;;;;;;AAgBd,IAAa,+BAAb,cAAkD,aAAa;CAC7D,AAAQ,iBAAiB;CACzB,AAAQ,eAAe;CACvB,AAAQ,UAAU;CAClB,AAAQ,cAA6B;CAErC,AAAQ,gBAAqC;CAC7C,AAAQ,sBAA2C;CAEnD,AAAQ;CACR,AAAQ;CAER,WAAW,qBAA+B;EACxC,OAAO;GAAC;GAAkB;GAAY;EAAQ;CAChD;CAEA,IAAI,gBAAwB;EAC1B,OAAO,KAAK;CACd;CACA,IAAI,cAAc,GAAW;EAC3B,KAAK,iBAAiB;EACtB,KAAK,iBAAiB,aAAa,kBAAkB,CAAC;CACxD;CAEA,IAAI,cAAsB;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EACF,CAAC;CACH;AACF;AAEA,MAAa,oCAA0C;CACrD,IAAI,OAAO,mBAAmB,aAAa;CAE3C,IAAI,CAAC,eAAe,IAAI,yBAAyB,GAC/C,eAAe,OACb,2BACA,4BACF;AAEJ"}
@@ -1,92 +0,0 @@
1
- import { getGlobalEditorManager, onGlobalEditorManagerChange } from "../core/globalManager.mjs";
2
- import { initEditorClient, stopEditorClient } from "../core/initEditorClient.mjs";
3
-
4
- //#region src/components/IntlayerEditor.ts
5
- const _HTMLElement = typeof HTMLElement !== "undefined" ? HTMLElement : class {};
6
- /**
7
- * <intlayer-editor>
8
- *
9
- * A framework-agnostic web component that manages the Intlayer editor singleton
10
- * lifecycle and keeps the current locale in sync with the EditorStateManager.
11
- *
12
- * Drop this element once at the root of your application to activate the editor.
13
- * It renders no UI.
14
- *
15
- * @prop {IntlayerConfig} configuration - The Intlayer config (required; set as JS property, not attribute)
16
- * @prop {string} locale - The active application locale (attribute/property)
17
- *
18
- * @example
19
- * // Svelte
20
- * <intlayer-editor .configuration={config} locale={$locale} />
21
- *
22
- * // Vue
23
- * <intlayer-editor :configuration="config" :locale="currentLocale" />
24
- */
25
- var IntlayerEditorElement = class extends _HTMLElement {
26
- _configuration = void 0;
27
- _locale = void 0;
28
- _initialized = false;
29
- _unsubManager = null;
30
- static get observedAttributes() {
31
- return ["locale"];
32
- }
33
- get configuration() {
34
- return this._configuration;
35
- }
36
- set configuration(v) {
37
- this._configuration = v;
38
- if (!this._initialized) this._init();
39
- }
40
- get locale() {
41
- return this._locale;
42
- }
43
- set locale(v) {
44
- this._locale = v;
45
- if (v && this._initialized) this._syncLocale(v);
46
- }
47
- attributeChangedCallback(name, _oldVal, newVal) {
48
- if (name === "locale" && newVal !== null) {
49
- this._locale = newVal;
50
- if (this._initialized) this._syncLocale(newVal);
51
- }
52
- }
53
- connectedCallback() {
54
- this._init();
55
- }
56
- disconnectedCallback() {
57
- this._unsubManager?.();
58
- this._unsubManager = null;
59
- if (this._initialized) {
60
- stopEditorClient();
61
- this._initialized = false;
62
- }
63
- }
64
- _init() {
65
- if (this._initialized) return;
66
- initEditorClient();
67
- this._initialized = true;
68
- if (this._locale) this._syncLocale(this._locale);
69
- }
70
- _syncLocale(locale) {
71
- const manager = getGlobalEditorManager();
72
- if (manager) manager.currentLocale.set(locale);
73
- else {
74
- this._unsubManager?.();
75
- this._unsubManager = onGlobalEditorManagerChange((m) => {
76
- if (m) {
77
- this._unsubManager?.();
78
- this._unsubManager = null;
79
- m.currentLocale.set(locale);
80
- }
81
- });
82
- }
83
- }
84
- };
85
- const defineIntlayerEditorElement = () => {
86
- if (typeof customElements === "undefined") return;
87
- if (!customElements.get("intlayer-editor")) customElements.define("intlayer-editor", IntlayerEditorElement);
88
- };
89
-
90
- //#endregion
91
- export { IntlayerEditorElement, defineIntlayerEditorElement };
92
- //# sourceMappingURL=IntlayerEditor.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlayerEditor.mjs","names":[],"sources":["../../../src/components/IntlayerEditor.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport {\n getGlobalEditorManager,\n onGlobalEditorManagerChange,\n} from '../core/globalManager';\nimport { initEditorClient, stopEditorClient } from '../core/initEditorClient';\n\nconst _HTMLElement =\n typeof HTMLElement !== 'undefined'\n ? HTMLElement\n : (class {} as unknown as typeof HTMLElement);\n\n/**\n * <intlayer-editor>\n *\n * A framework-agnostic web component that manages the Intlayer editor singleton\n * lifecycle and keeps the current locale in sync with the EditorStateManager.\n *\n * Drop this element once at the root of your application to activate the editor.\n * It renders no UI.\n *\n * @prop {IntlayerConfig} configuration - The Intlayer config (required; set as JS property, not attribute)\n * @prop {string} locale - The active application locale (attribute/property)\n *\n * @example\n * // Svelte\n * <intlayer-editor .configuration={config} locale={$locale} />\n *\n * // Vue\n * <intlayer-editor :configuration=\"config\" :locale=\"currentLocale\" />\n */\nexport class IntlayerEditorElement extends _HTMLElement {\n private _configuration: IntlayerConfig | undefined = undefined;\n private _locale: string | undefined = undefined;\n private _initialized = false;\n private _unsubManager: (() => void) | null = null;\n\n static get observedAttributes(): string[] {\n return ['locale'];\n }\n\n get configuration(): IntlayerConfig | undefined {\n return this._configuration;\n }\n set configuration(v: IntlayerConfig | undefined) {\n this._configuration = v;\n if (!this._initialized) this._init();\n }\n\n get locale(): string | undefined {\n return this._locale;\n }\n set locale(v: string | undefined) {\n this._locale = v;\n if (v && this._initialized) this._syncLocale(v);\n }\n\n attributeChangedCallback(\n name: string,\n _oldVal: string | null,\n newVal: string | null\n ): void {\n if (name === 'locale' && newVal !== null) {\n this._locale = newVal;\n if (this._initialized) this._syncLocale(newVal);\n }\n }\n\n connectedCallback(): void {\n this._init();\n }\n\n disconnectedCallback(): void {\n this._unsubManager?.();\n this._unsubManager = null;\n if (this._initialized) {\n stopEditorClient();\n this._initialized = false;\n }\n }\n\n private _init(): void {\n if (this._initialized) return;\n initEditorClient();\n this._initialized = true;\n if (this._locale) this._syncLocale(this._locale);\n }\n\n private _syncLocale(locale: string): void {\n const manager = getGlobalEditorManager();\n if (manager) {\n manager.currentLocale.set(locale as Locale);\n } else {\n // Manager may not be ready yet — wait for it\n this._unsubManager?.();\n this._unsubManager = onGlobalEditorManagerChange((m) => {\n if (m) {\n this._unsubManager?.();\n this._unsubManager = null;\n m.currentLocale.set(locale as Locale);\n }\n });\n }\n }\n}\n\nexport const defineIntlayerEditorElement = (): void => {\n if (typeof customElements === 'undefined') return;\n if (!customElements.get('intlayer-editor')) {\n customElements.define('intlayer-editor', IntlayerEditorElement);\n }\n};\n"],"mappings":";;;;AAQA,MAAM,eACJ,OAAO,gBAAgB,cACnB,cACC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;AAqBd,IAAa,wBAAb,cAA2C,aAAa;CACtD,AAAQ,iBAA6C;CACrD,AAAQ,UAA8B;CACtC,AAAQ,eAAe;CACvB,AAAQ,gBAAqC;CAE7C,WAAW,qBAA+B;EACxC,OAA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Y = "__intlayer_edited_content_bus_events__";
4
- const getBusTarget = () => {
5
- if (typeof window === "undefined") return new EventTarget();
6
- const w = window;
7
- if (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();
8
- return w[BUS_EVENTS_KEY];
9
- };
10
- const getGlobalEditedContent = () => {
11
- if (typeof window === "undefined") return {};
12
- return window[BUS_KEY] ?? {};
13
- };
14
- const setGlobalEditedContent = (content, sourceId) => {
15
- if (typeof window !== "undefined") window[BUS_KEY] = content;
16
- getBusTarget().dispatchEvent(new CustomEvent("change", { detail: {
17
- content,
18
- sourceId
19
- } }));
20
- };
21
- const subscribeToGlobalEditedContent = (cb) => {
22
- const handler = (e) => {
23
- const { content, sourceId } = e.detail;
24
- cb(content, sourceId);
25
- };
26
- const target = getBusTarget();
27
- target.addEventListener("change", handler);
28
- return () => target.removeEventListener("change", handler);
29
- };
30
-
31
- //#endregion
32
- export { getGlobalEditedContent, setGlobalEditedContent, subscribeToGlobalEditedContent };
33
- //# sourceMappingURL=editedContentBus.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editedContentBus.mjs","names":[],"sources":["../../../src/core/editedContentBus.ts"],"sourcesContent":["import type { DictionaryContent } from './EditorStateManager';\n\nconst BUS_KEY = '__intlayer_edited_content_bus__';\nconst BUS_EVENTS_KEY = '__intlayer_edited_content_bus_events__';\n\ntype WindowWithBus = typeof window & {\n [BUS_KEY]?: DictionaryContent;\n [BUS_EVENTS_KEY]?: EventTarget;\n};\n\ntype BusEvent = { content: DictionaryContent; sourceId?: string };\n\nconst getBusTarget = (): EventTarget => {\n if (typeof window === 'undefined') return new EventTarget();\n const w = window as WindowWithBus;\n if (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();\n return w[BUS_EVENTS_KEY]!;\n};\n\nexport const getGlobalEditedContent = (): DictionaryContent => {\n if (typeof window === 'undefined') return {};\n return (window as WindowWithBus)[BUS_KEY] ?? {};\n};\n\nexport const setGlobalEditedContent = (\n content: DictionaryContent,\n sourceId?: string\n): void => {\n if (typeof window !== 'undefined') {\n (window as WindowWithBus)[BUS_KEY] = content;\n }\n getBusTarget().dispatchEvent(\n new CustomEvent<BusEvent>('change', { detail: { content, sourceId } })\n );\n};\n\nexport const subscribeToGlobalEditedContent = (\n cb: (content: DictionaryContent, sourceId?: string) => void\n): (() => void) => {\n const handler = (e: Event) => {\n const { content, sourceId } = (e as CustomEvent<BusEvent>).detail;\n cb(content, sourceId);\n };\n const target = getBusTarget();\n target.addEventListener('change', handler);\n return () => target.removeEventListener('change', handler);\n};\n"],"mappings":";AAEA,MAAM,UAAU;AAChB,MAAM,iBAAiB;AASvB,MAAM,qBAAkC;CACtC,IAAI,OAAO,WAAW,aAAa,OAAO,IAAI,YAAY;CAC1D,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,iBAAiB,EAAE,kBAAkB,IAAI,YAAY;CAC5D,OAAO,EAAE;AACX;AAEA,MAAa,+BAAkD;CAC7D,IAAI,OAAO,WAAW,aAAa,OAAO,CAAC;CAC3C,OAAQ,OAAyB,YAAY,CAAC;AAChD;AAEA,MAAa,0BACX,SACA,aACS;CACT,IAAI,OAAO,WAAW,aACpB,AAAC,OAAyB,WAAW;CAEvC,aAAa,CAAC,CAAC,cACb,IAAI,YAAsB,UAAU,EAAE,QAAQ;EAAE;EAAS;CAAS,EAAE,CAAC,CACvE;AACF;AAEA,MAAa,kCACX,OACiB;CACjB,MAAM,WAAW,MAAa;EAC5B,MAAM,EAAE,SAAS,aAAc,EAA4B;EAC3D,GAAG,SAAS,QAAQ;CACtB;CACA,MAAM,SAAS,aAAa;CAC5B,OAAO,iBAAiB,UAAU,OAAO;CACzC,aAAa,OAAO,oBAAoB,UAAU,OAAO;AAC3D"}
@@ -1,39 +0,0 @@
1
- //#region src/core/focusedContentBus.ts
2
- const BUS_KEY = "__intlayer_focused_content_bus__";
3
- const BUS_EVENTS_KEY = "__intlayer_focused_content_bus_events__";
4
- const getBusTarget = () => {
5
- if (typeof window === "undefined") return new EventTarget();
6
- const w = window;
7
- if (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();
8
- return w[BUS_EVENTS_KEY];
9
- };
10
- const getGlobalFocusedContent = () => {
11
- if (typeof window === "undefined") return void 0;
12
- const w = window;
13
- if (!w.__intlayer_focused_content_bus_set__) return void 0;
14
- return w[BUS_KEY] ?? null;
15
- };
16
- const setGlobalFocusedContent = (content, sourceId) => {
17
- if (typeof window !== "undefined") {
18
- const w = window;
19
- w[BUS_KEY] = content;
20
- w.__intlayer_focused_content_bus_set__ = true;
21
- }
22
- getBusTarget().dispatchEvent(new CustomEvent("change", { detail: {
23
- content,
24
- sourceId
25
- } }));
26
- };
27
- const subscribeToGlobalFocusedContent = (cb) => {
28
- const handler = (e) => {
29
- const { content, sourceId } = e.detail;
30
- cb(content, sourceId);
31
- };
32
- const target = getBusTarget();
33
- target.addEventListener("change", handler);
34
- return () => target.removeEventListener("change", handler);
35
- };
36
-
37
- //#endregion
38
- export { getGlobalFocusedContent, setGlobalFocusedContent, subscribeToGlobalFocusedContent };
39
- //# sourceMappingURL=focusedContentBus.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"focusedContentBus.mjs","names":[],"sources":["../../../src/core/focusedContentBus.ts"],"sourcesContent":["import type { FileContent } from './EditorStateManager';\n\nconst BUS_KEY = '__intlayer_focused_content_bus__';\nconst BUS_EVENTS_KEY = '__intlayer_focused_content_bus_events__';\n\ntype WindowWithBus = typeof window & {\n [BUS_KEY]?: FileContent | null;\n [BUS_EVENTS_KEY]?: EventTarget;\n __intlayer_focused_content_bus_set__?: boolean;\n};\n\ntype BusEvent = { content: FileContent | null; sourceId?: string };\n\nconst getBusTarget = (): EventTarget => {\n if (typeof window === 'undefined') return new EventTarget();\n const w = window as WindowWithBus;\n if (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();\n return w[BUS_EVENTS_KEY]!;\n};\n\nexport const getGlobalFocusedContent = (): FileContent | null | undefined => {\n if (typeof window === 'undefined') return undefined;\n const w = window as WindowWithBus;\n if (!w.__intlayer_focused_content_bus_set__) return undefined;\n return w[BUS_KEY] ?? null;\n};\n\nexport const setGlobalFocusedContent = (\n content: FileContent | null,\n sourceId?: string\n): void => {\n if (typeof window !== 'undefined') {\n const w = window as WindowWithBus;\n w[BUS_KEY] = content;\n w.__intlayer_focused_content_bus_set__ = true;\n }\n getBusTarget().dispatchEvent(\n new CustomEvent<BusEvent>('change', { detail: { content, sourceId } })\n );\n};\n\nexport const subscribeToGlobalFocusedContent = (\n cb: (content: FileContent | null, sourceId?: string) => void\n): (() => void) => {\n const handler = (e: Event) => {\n const { content, sourceId } = (e as CustomEvent<BusEvent>).detail;\n cb(content, sourceId);\n };\n const target = getBusTarget();\n target.addEventListener('change', handler);\n return () => target.removeEventListener('change', handler);\n};\n"],"mappings":";AAEA,MAAM,UAAU;AAChB,MAAM,iBAAiB;AAUvB,MAAM,qBAAkC;CACtC,IAAI,OAAO,WAAW,aAAa,OAAO,IAAI,YAAY;CAC1D,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,iBAAiB,EAAE,kBAAkB,IAAI,YAAY;CAC5D,OAAO,EAAE;AACX;AAEA,MAAa,gCAAgE;CAC3E,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,sCAAsC,OAAO;CACpD,OAAO,EAAE,YAAY;AACvB;AAEA,MAAa,2BACX,SACA,aACS;CACT,IAAI,OAAO,WAAW,aAAa;EACjC,MAAM,IAAI;EACV,EAAE,WAAW;EACb,EAAE,uCAAuC;CAC3C;CACA,aAAa,CAAC,CAAC,cACb,IAAI,YAAsB,UAAU,EAAE,QAAQ;EAAE;EAAS;CAAS,EAAE,CAAC,CACvE;AACF;AAEA,MAAa,mCACX,OACiB;CACjB,MAAM,WAAW,MAAa;EAC5B,MAAM,EAAE,SAAS,aAAc,EAA4B;EAC3D,GAAG,SAAS,QAAQ;CACtB;CACA,MAAM,SAAS,aAAa;CAC5B,OAAO,iBAAiB,UAAU,OAAO;CACzC,aAAa,OAAO,oBAAoB,UAAU,OAAO;AAC3D"}
@@ -1,21 +0,0 @@
1
- //#region src/mergeIframeClick.ts
2
- const mergeIframeClick = (event) => {
3
- const simulatedMouseDownEvent = new MouseEvent("mousedown", {
4
- bubbles: true,
5
- cancelable: true,
6
- view: window
7
- });
8
- const simulatedClickEvent = new MouseEvent("click", {
9
- bubbles: true,
10
- cancelable: true,
11
- view: window
12
- });
13
- Object.assign(simulatedClickEvent, { iframeData: event });
14
- Object.assign(simulatedMouseDownEvent, { iframeData: event });
15
- window.dispatchEvent(simulatedClickEvent);
16
- window.dispatchEvent(simulatedMouseDownEvent);
17
- };
18
-
19
- //#endregion
20
- export { mergeIframeClick };
21
- //# sourceMappingURL=mergeIframeClick.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeIframeClick.mjs","names":[],"sources":["../../src/mergeIframeClick.ts"],"sourcesContent":["// Listener for messages from the iframe\nexport const mergeIframeClick = (event: MessageEvent) => {\n // Simulate or merge the iframe message with a click event\n const simulatedMouseDownEvent = new MouseEvent('mousedown', {\n bubbles: true,\n cancelable: true,\n view: window,\n });\n const simulatedClickEvent = new MouseEvent('click', {\n bubbles: true,\n cancelable: true,\n view: window,\n });\n\n // Optionally attach additional properties from the iframe message\n Object.assign(simulatedClickEvent, { iframeData: event });\n Object.assign(simulatedMouseDownEvent, { iframeData: event });\n\n // Dispatch the simulated click event on the window or a specific element\n window.dispatchEvent(simulatedClickEvent);\n window.dispatchEvent(simulatedMouseDownEvent);\n};\n"],"mappings":";AACA,MAAa,oBAAoB,UAAwB;CAEvD,MAAM,0BAA0B,IAAI,WAAW,aAAa;EAC1D,SAAS;EACT,YAAY;EACZ,MAAM;CACR,CAAC;CACD,MAAM,sBAAsB,IAAI,WAAW,SAAS;EAClD,SAAS;EACT,YAAY;EACZ,MAAM;CACR,CAAC;CAGD,OAAO,OAAO,qBAAqB,EAAE,YAAY,MAAM,CAAC;CACxD,OAAO,OAAO,yBAAyB,EAAE,YAAY,MAAM,CAAC;CAG5D,OAAO,cAAc,mBAAmB;CACxC,OAAO,cAAc,uBAAuB;AAC9C"}