@intlayer/next-i18next 9.5.3 → 9.5.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 (105) hide show
  1. package/README.md +8 -8
  2. package/dist/cjs/index.cjs +1 -1
  3. package/dist/esm/index.mjs +1 -1
  4. package/package.json +13 -12
  5. package/dist/cjs/packages/@intlayer/editor/dist/esm/compareUrls.cjs +0 -39
  6. package/dist/cjs/packages/@intlayer/editor/dist/esm/compareUrls.cjs.map +0 -1
  7. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelector.cjs +0 -161
  8. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelector.cjs.map +0 -1
  9. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.cjs +0 -269
  10. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.cjs.map +0 -1
  11. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/EditedContent.cjs +0 -161
  12. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/EditedContent.cjs.map +0 -1
  13. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.cjs +0 -88
  14. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.cjs.map +0 -1
  15. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.cjs +0 -27
  16. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.cjs.map +0 -1
  17. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.cjs +0 -80
  18. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.cjs.map +0 -1
  19. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.cjs +0 -75
  20. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.cjs.map +0 -1
  21. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/EditorStateManager.cjs +0 -383
  22. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/EditorStateManager.cjs.map +0 -1
  23. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.cjs +0 -45
  24. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.cjs.map +0 -1
  25. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/UrlStateManager.cjs +0 -59
  26. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/UrlStateManager.cjs.map +0 -1
  27. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/editedContentBus.cjs +0 -36
  28. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/editedContentBus.cjs.map +0 -1
  29. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/focusedContentBus.cjs +0 -42
  30. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/focusedContentBus.cjs.map +0 -1
  31. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/globalManager.cjs +0 -82
  32. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/globalManager.cjs.map +0 -1
  33. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/initEditorClient.cjs +0 -55
  34. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/initEditorClient.cjs.map +0 -1
  35. package/dist/cjs/packages/@intlayer/editor/dist/esm/index.cjs +0 -19
  36. package/dist/cjs/packages/@intlayer/editor/dist/esm/isEnabled.cjs +0 -9
  37. package/dist/cjs/packages/@intlayer/editor/dist/esm/isEnabled.cjs.map +0 -1
  38. package/dist/cjs/packages/@intlayer/editor/dist/esm/mergeIframeClick.cjs +0 -22
  39. package/dist/cjs/packages/@intlayer/editor/dist/esm/mergeIframeClick.cjs.map +0 -1
  40. package/dist/cjs/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.cjs +0 -32
  41. package/dist/cjs/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.cjs.map +0 -1
  42. package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerContext.cjs +0 -25
  43. package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerContext.cjs.map +0 -1
  44. package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerProvider.cjs +0 -78
  45. package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerProvider.cjs.map +0 -1
  46. package/dist/cjs/packages/react-intlayer/dist/esm/client/useLocaleStorage.cjs +0 -24
  47. package/dist/cjs/packages/react-intlayer/dist/esm/client/useLocaleStorage.cjs.map +0 -1
  48. package/dist/cjs/packages/react-intlayer/dist/esm/editor/EditorProvider.cjs +0 -11
  49. package/dist/cjs/packages/react-intlayer/dist/esm/editor/EditorProvider.cjs.map +0 -1
  50. package/dist/cjs/packages/react-intlayer/dist/esm/editor/useEditor.cjs +0 -39
  51. package/dist/cjs/packages/react-intlayer/dist/esm/editor/useEditor.cjs.map +0 -1
  52. package/dist/cjs/warnUnsupported.cjs +0 -28
  53. package/dist/cjs/warnUnsupported.cjs.map +0 -1
  54. package/dist/esm/_virtual/_rolldown/runtime.mjs +0 -8
  55. package/dist/esm/packages/@intlayer/editor/dist/esm/compareUrls.mjs +0 -38
  56. package/dist/esm/packages/@intlayer/editor/dist/esm/compareUrls.mjs.map +0 -1
  57. package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs +0 -160
  58. package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs.map +0 -1
  59. package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs +0 -266
  60. package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs.map +0 -1
  61. package/dist/esm/packages/@intlayer/editor/dist/esm/components/EditedContent.mjs +0 -159
  62. package/dist/esm/packages/@intlayer/editor/dist/esm/components/EditedContent.mjs.map +0 -1
  63. package/dist/esm/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.mjs +0 -88
  64. package/dist/esm/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.mjs.map +0 -1
  65. package/dist/esm/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.mjs +0 -26
  66. package/dist/esm/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.mjs.map +0 -1
  67. package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.mjs +0 -80
  68. package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.mjs.map +0 -1
  69. package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.mjs +0 -74
  70. package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.mjs.map +0 -1
  71. package/dist/esm/packages/@intlayer/editor/dist/esm/core/EditorStateManager.mjs +0 -381
  72. package/dist/esm/packages/@intlayer/editor/dist/esm/core/EditorStateManager.mjs.map +0 -1
  73. package/dist/esm/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.mjs +0 -45
  74. package/dist/esm/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.mjs.map +0 -1
  75. package/dist/esm/packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs +0 -58
  76. package/dist/esm/packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs.map +0 -1
  77. package/dist/esm/packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs +0 -33
  78. package/dist/esm/packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs.map +0 -1
  79. package/dist/esm/packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs +0 -39
  80. package/dist/esm/packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs.map +0 -1
  81. package/dist/esm/packages/@intlayer/editor/dist/esm/core/globalManager.mjs +0 -79
  82. package/dist/esm/packages/@intlayer/editor/dist/esm/core/globalManager.mjs.map +0 -1
  83. package/dist/esm/packages/@intlayer/editor/dist/esm/core/initEditorClient.mjs +0 -52
  84. package/dist/esm/packages/@intlayer/editor/dist/esm/core/initEditorClient.mjs.map +0 -1
  85. package/dist/esm/packages/@intlayer/editor/dist/esm/index.mjs +0 -18
  86. package/dist/esm/packages/@intlayer/editor/dist/esm/isEnabled.mjs +0 -8
  87. package/dist/esm/packages/@intlayer/editor/dist/esm/isEnabled.mjs.map +0 -1
  88. package/dist/esm/packages/@intlayer/editor/dist/esm/mergeIframeClick.mjs +0 -21
  89. package/dist/esm/packages/@intlayer/editor/dist/esm/mergeIframeClick.mjs.map +0 -1
  90. package/dist/esm/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.browser.mjs +0 -6
  91. package/dist/esm/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.browser.mjs.map +0 -1
  92. package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerContext.mjs +0 -23
  93. package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerContext.mjs.map +0 -1
  94. package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerProvider.mjs +0 -77
  95. package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerProvider.mjs.map +0 -1
  96. package/dist/esm/packages/react-intlayer/dist/esm/client/useLocaleStorage.mjs +0 -22
  97. package/dist/esm/packages/react-intlayer/dist/esm/client/useLocaleStorage.mjs.map +0 -1
  98. package/dist/esm/packages/react-intlayer/dist/esm/editor/EditorProvider.mjs +0 -11
  99. package/dist/esm/packages/react-intlayer/dist/esm/editor/EditorProvider.mjs.map +0 -1
  100. package/dist/esm/packages/react-intlayer/dist/esm/editor/useEditor.mjs +0 -38
  101. package/dist/esm/packages/react-intlayer/dist/esm/editor/useEditor.mjs.map +0 -1
  102. package/dist/esm/warnUnsupported.mjs +0 -27
  103. package/dist/esm/warnUnsupported.mjs.map +0 -1
  104. package/dist/types/warnUnsupported.d.ts +0 -18
  105. package/dist/types/warnUnsupported.d.ts.map +0 -1
@@ -1,160 +0,0 @@
1
- //#region ../../packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs
2
- const DEFAULT_PRESS_DURATION = 250;
3
- const STYLES = `
4
- :host {
5
- display: contents;
6
- }
7
-
8
- .wrapper {
9
- display: inline-block;
10
- cursor: pointer;
11
- user-select: none;
12
- border-radius: 0.375rem;
13
- outline-width: 2px;
14
- outline-offset: 4px;
15
- outline-style: solid;
16
- outline-color: transparent;
17
- transition: all 100ms 50ms ease-in-out;
18
- }
19
-
20
- .wrapper[data-active] {
21
- outline-color: inherit;
22
- }
23
- `;
24
- const _HTMLElement = typeof HTMLElement !== "undefined" ? HTMLElement : class {};
25
- /**
26
- * <intlayer-content-selector>
27
- *
28
- * A framework-agnostic web component that wraps content with Intlayer editor
29
- * selection UI (hover outline, long-press to select, click-outside to deselect).
30
- *
31
- * @fires intlayer:press - Fired after a long press (pressDuration ms). Bubbles.
32
- * @fires intlayer:hover - Fired on mouseenter. Bubbles.
33
- * @fires intlayer:unhover - Fired on mouseleave / mouseup. Bubbles.
34
- * @fires intlayer:click-outside - Fired when a click occurs outside the element. Bubbles.
35
- *
36
- * @prop {boolean} isSelecting - Whether this element is currently selected (external state)
37
- * @prop {number} pressDuration - Long-press threshold in ms. Default: 250
38
- */
39
- var IntlayerContentSelectorElement = class extends _HTMLElement {
40
- _isSelecting = false;
41
- _pressDuration = DEFAULT_PRESS_DURATION;
42
- _isHovered = false;
43
- _isSelectingState = false;
44
- _wrapper;
45
- _pressTimer = null;
46
- _clickOutsideHandler = null;
47
- static get observedAttributes() {
48
- return ["is-selecting", "press-duration"];
49
- }
50
- get isSelecting() {
51
- return this._isSelecting;
52
- }
53
- set isSelecting(v) {
54
- this._isSelecting = v;
55
- this._updateActiveState();
56
- }
57
- get pressDuration() {
58
- return this._pressDuration;
59
- }
60
- set pressDuration(v) {
61
- this._pressDuration = v;
62
- }
63
- constructor() {
64
- super();
65
- const shadow = this.attachShadow({ mode: "open" });
66
- const style = document.createElement("style");
67
- style.textContent = STYLES;
68
- shadow.appendChild(style);
69
- const wrapper = document.createElement("span");
70
- wrapper.className = "wrapper";
71
- wrapper.setAttribute("role", "button");
72
- wrapper.setAttribute("tabindex", "0");
73
- wrapper.appendChild(document.createElement("slot"));
74
- shadow.appendChild(wrapper);
75
- this._wrapper = wrapper;
76
- wrapper.addEventListener("mousedown", () => this._handleMouseDown());
77
- wrapper.addEventListener("mouseup", () => this._handleMouseUpOrLeave());
78
- wrapper.addEventListener("mouseleave", () => this._handleMouseUpOrLeave());
79
- wrapper.addEventListener("mouseenter", () => this._handleMouseEnter());
80
- wrapper.addEventListener("click", (e) => this._handleClick(e));
81
- wrapper.addEventListener("touchstart", () => this._handleMouseDown());
82
- wrapper.addEventListener("touchend", () => this._handleMouseUpOrLeave());
83
- wrapper.addEventListener("touchcancel", () => this._handleMouseUpOrLeave());
84
- wrapper.addEventListener("blur", () => this._handleBlur());
85
- }
86
- attributeChangedCallback(name, _oldVal, newVal) {
87
- if (name === "is-selecting") {
88
- this._isSelecting = newVal !== null;
89
- this._updateActiveState();
90
- } else if (name === "press-duration") this._pressDuration = newVal !== null ? parseInt(newVal, 10) : DEFAULT_PRESS_DURATION;
91
- }
92
- connectedCallback() {
93
- this._clickOutsideHandler = (e) => {
94
- if (!e.composedPath().includes(this)) {
95
- this._isSelectingState = false;
96
- this._dispatch("intlayer:click-outside");
97
- this._updateActiveState();
98
- }
99
- };
100
- document.addEventListener("mousedown", this._clickOutsideHandler);
101
- }
102
- disconnectedCallback() {
103
- if (this._clickOutsideHandler) {
104
- document.removeEventListener("mousedown", this._clickOutsideHandler);
105
- this._clickOutsideHandler = null;
106
- }
107
- this._clearPressTimer();
108
- }
109
- _updateActiveState() {
110
- if (this._isSelecting || this._isSelectingState || this._isHovered) this._wrapper.setAttribute("data-active", "");
111
- else this._wrapper.removeAttribute("data-active");
112
- }
113
- _clearPressTimer() {
114
- if (this._pressTimer !== null) {
115
- clearTimeout(this._pressTimer);
116
- this._pressTimer = null;
117
- }
118
- }
119
- _dispatch(eventName) {
120
- this.dispatchEvent(new CustomEvent(eventName, {
121
- bubbles: true,
122
- composed: true
123
- }));
124
- }
125
- _handleMouseDown() {
126
- this._clearPressTimer();
127
- this._pressTimer = setTimeout(() => {
128
- this._isSelectingState = true;
129
- this._updateActiveState();
130
- this._dispatch("intlayer:press");
131
- }, this._pressDuration);
132
- }
133
- _handleMouseEnter() {
134
- this._isHovered = true;
135
- this._updateActiveState();
136
- this._dispatch("intlayer:hover");
137
- }
138
- _handleMouseUpOrLeave() {
139
- if (this._isHovered) {
140
- this._isHovered = false;
141
- this._dispatch("intlayer:unhover");
142
- }
143
- this._clearPressTimer();
144
- this._updateActiveState();
145
- }
146
- _handleClick(e) {
147
- if (this._isSelecting || this._isSelectingState) {
148
- e.preventDefault();
149
- e.stopPropagation();
150
- }
151
- }
152
- _handleBlur() {
153
- this._isSelectingState = false;
154
- this._updateActiveState();
155
- }
156
- };
157
-
158
- //#endregion
159
- export { IntlayerContentSelectorElement };
160
- //# sourceMappingURL=ContentSelector.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs"],"sourcesContent":["//#region src/components/ContentSelector.ts\nconst DEFAULT_PRESS_DURATION = 250;\nconst STYLES = `\n :host {\n display: contents;\n }\n\n .wrapper {\n display: inline-block;\n cursor: pointer;\n user-select: none;\n border-radius: 0.375rem;\n outline-width: 2px;\n outline-offset: 4px;\n outline-style: solid;\n outline-color: transparent;\n transition: all 100ms 50ms ease-in-out;\n }\n\n .wrapper[data-active] {\n outline-color: inherit;\n }\n`;\nconst _HTMLElement = typeof HTMLElement !== \"undefined\" ? HTMLElement : class {};\n/**\n* <intlayer-content-selector>\n*\n* A framework-agnostic web component that wraps content with Intlayer editor\n* selection UI (hover outline, long-press to select, click-outside to deselect).\n*\n* @fires intlayer:press - Fired after a long press (pressDuration ms). Bubbles.\n* @fires intlayer:hover - Fired on mouseenter. Bubbles.\n* @fires intlayer:unhover - Fired on mouseleave / mouseup. Bubbles.\n* @fires intlayer:click-outside - Fired when a click occurs outside the element. Bubbles.\n*\n* @prop {boolean} isSelecting - Whether this element is currently selected (external state)\n* @prop {number} pressDuration - Long-press threshold in ms. Default: 250\n*/\nvar IntlayerContentSelectorElement = class extends _HTMLElement {\n\t_isSelecting = false;\n\t_pressDuration = DEFAULT_PRESS_DURATION;\n\t_isHovered = false;\n\t_isSelectingState = false;\n\t_wrapper;\n\t_pressTimer = null;\n\t_clickOutsideHandler = null;\n\tstatic get observedAttributes() {\n\t\treturn [\"is-selecting\", \"press-duration\"];\n\t}\n\tget isSelecting() {\n\t\treturn this._isSelecting;\n\t}\n\tset isSelecting(v) {\n\t\tthis._isSelecting = v;\n\t\tthis._updateActiveState();\n\t}\n\tget pressDuration() {\n\t\treturn this._pressDuration;\n\t}\n\tset pressDuration(v) {\n\t\tthis._pressDuration = v;\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tconst shadow = this.attachShadow({ mode: \"open\" });\n\t\tconst style = document.createElement(\"style\");\n\t\tstyle.textContent = STYLES;\n\t\tshadow.appendChild(style);\n\t\tconst wrapper = document.createElement(\"span\");\n\t\twrapper.className = \"wrapper\";\n\t\twrapper.setAttribute(\"role\", \"button\");\n\t\twrapper.setAttribute(\"tabindex\", \"0\");\n\t\twrapper.appendChild(document.createElement(\"slot\"));\n\t\tshadow.appendChild(wrapper);\n\t\tthis._wrapper = wrapper;\n\t\twrapper.addEventListener(\"mousedown\", () => this._handleMouseDown());\n\t\twrapper.addEventListener(\"mouseup\", () => this._handleMouseUpOrLeave());\n\t\twrapper.addEventListener(\"mouseleave\", () => this._handleMouseUpOrLeave());\n\t\twrapper.addEventListener(\"mouseenter\", () => this._handleMouseEnter());\n\t\twrapper.addEventListener(\"click\", (e) => this._handleClick(e));\n\t\twrapper.addEventListener(\"touchstart\", () => this._handleMouseDown());\n\t\twrapper.addEventListener(\"touchend\", () => this._handleMouseUpOrLeave());\n\t\twrapper.addEventListener(\"touchcancel\", () => this._handleMouseUpOrLeave());\n\t\twrapper.addEventListener(\"blur\", () => this._handleBlur());\n\t}\n\tattributeChangedCallback(name, _oldVal, newVal) {\n\t\tif (name === \"is-selecting\") {\n\t\t\tthis._isSelecting = newVal !== null;\n\t\t\tthis._updateActiveState();\n\t\t} else if (name === \"press-duration\") this._pressDuration = newVal !== null ? parseInt(newVal, 10) : DEFAULT_PRESS_DURATION;\n\t}\n\tconnectedCallback() {\n\t\tthis._clickOutsideHandler = (e) => {\n\t\t\tif (!e.composedPath().includes(this)) {\n\t\t\t\tthis._isSelectingState = false;\n\t\t\t\tthis._dispatch(\"intlayer:click-outside\");\n\t\t\t\tthis._updateActiveState();\n\t\t\t}\n\t\t};\n\t\tdocument.addEventListener(\"mousedown\", this._clickOutsideHandler);\n\t}\n\tdisconnectedCallback() {\n\t\tif (this._clickOutsideHandler) {\n\t\t\tdocument.removeEventListener(\"mousedown\", this._clickOutsideHandler);\n\t\t\tthis._clickOutsideHandler = null;\n\t\t}\n\t\tthis._clearPressTimer();\n\t}\n\t_updateActiveState() {\n\t\tif (this._isSelecting || this._isSelectingState || this._isHovered) this._wrapper.setAttribute(\"data-active\", \"\");\n\t\telse this._wrapper.removeAttribute(\"data-active\");\n\t}\n\t_clearPressTimer() {\n\t\tif (this._pressTimer !== null) {\n\t\t\tclearTimeout(this._pressTimer);\n\t\t\tthis._pressTimer = null;\n\t\t}\n\t}\n\t_dispatch(eventName) {\n\t\tthis.dispatchEvent(new CustomEvent(eventName, {\n\t\t\tbubbles: true,\n\t\t\tcomposed: true\n\t\t}));\n\t}\n\t_handleMouseDown() {\n\t\tthis._clearPressTimer();\n\t\tthis._pressTimer = setTimeout(() => {\n\t\t\tthis._isSelectingState = true;\n\t\t\tthis._updateActiveState();\n\t\t\tthis._dispatch(\"intlayer:press\");\n\t\t}, this._pressDuration);\n\t}\n\t_handleMouseEnter() {\n\t\tthis._isHovered = true;\n\t\tthis._updateActiveState();\n\t\tthis._dispatch(\"intlayer:hover\");\n\t}\n\t_handleMouseUpOrLeave() {\n\t\tif (this._isHovered) {\n\t\t\tthis._isHovered = false;\n\t\t\tthis._dispatch(\"intlayer:unhover\");\n\t\t}\n\t\tthis._clearPressTimer();\n\t\tthis._updateActiveState();\n\t}\n\t_handleClick(e) {\n\t\tif (this._isSelecting || this._isSelectingState) {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t}\n\t}\n\t_handleBlur() {\n\t\tthis._isSelectingState = false;\n\t\tthis._updateActiveState();\n\t}\n};\n\n//#endregion\nexport { IntlayerContentSelectorElement };\n//# sourceMappingURL=ContentSelector.mjs.map"],"mappings":";AACA,MAAM,yBAAyB;AAC/B,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;AAqBf,MAAM,eAAe,OAAO,gBAAgB,cAAc,cAAc,MAAM;;;;;;;;;;;;;;;AAe9E,IAAI,iCAAiC,cAAc,aAAa;CAC/D,eAAe;CACf,iBAAiB;CACjB,aAAa;CACb,oBAAoB;CACpB;CACA,cAAc;CACd,uBAAuB;CACvB,WAAW,qBAAqB;AAC/B,SAAO,CAAC,gBAAgB,iBAAiB;;CAE1C,IAAI,cAAc;AACjB,SAAO,KAAK;;CAEb,IAAI,YAAY,GAAG;AAClB,OAAK,eAAe;AACpB,OAAK,oBAAoB;;CAE1B,IAAI,gBAAgB;AACnB,SAAO,KAAK;;CAEb,IAAI,cAAc,GAAG;AACpB,OAAK,iBAAiB;;CAEvB,cAAc;AACb,SAAO;EACP,MAAM,SAAS,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;EAClD,MAAM,QAAQ,SAAS,cAAc,QAAQ;AAC7C,QAAM,cAAc;AACpB,SAAO,YAAY,MAAM;EACzB,MAAM,UAAU,SAAS,cAAc,OAAO;AAC9C,UAAQ,YAAY;AACpB,UAAQ,aAAa,QAAQ,SAAS;AACtC,UAAQ,aAAa,YAAY,IAAI;AACrC,UAAQ,YAAY,SAAS,cAAc,OAAO,CAAC;AACnD,SAAO,YAAY,QAAQ;AAC3B,OAAK,WAAW;AAChB,UAAQ,iBAAiB,mBAAmB,KAAK,kBAAkB,CAAC;AACpE,UAAQ,iB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CAAC;;CAEJ,mBAAmB;AAClB,OAAK,kBAAkB;AACvB,OAAK,cAAc,iBAAiB;AACnC,QAAK,oBAAoB;AACzB,QAAK,oBAAoB;AACzB,QAAK,UAAU,iBAAiB;KAC9B,KAAK,eAAe;;CAExB,oBAAoB;AACnB,OAAK,aAAa;AAClB,OAAK,oBAAoB;AACzB,OAAK,UAAU,iBAAiB;;CAEjC,wBAAwB;AACvB,MAAI,KAAK,YAAY;AACpB,QAAK,aAAa;AAClB,QAAK,UAAU,mBAAmB;;AAEnC,OAAK,kBAAkB;AACvB,OAAK,oBAAoB;;CAE1B,aAAa,GAAG;AACf,MAAI,KAAK,gBAAgB,KAAK,mBAAmB;AAChD,KAAE,gBAAgB;AAClB,KAAE,iBAAiB;;;CAGrB,cAAc;AACb,OAAK,oBAAoB;AACzB,OAAK,oBAAoB"}
@@ -1,266 +0,0 @@
1
- import { getGlobalEditorManager, onGlobalEditorManagerChange } from "../core/globalManager.mjs";
2
- import * as NodeTypes from "@intlayer/types/nodeType";
3
- import { isSameKeyPath } from "@intlayer/core/utils";
4
-
5
- //#region ../../packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs
6
- const _HTMLElement = typeof HTMLElement !== "undefined" ? HTMLElement : class {};
7
- /**
8
- * <intlayer-content-selector-wrapper>
9
- *
10
- * Framework-agnostic web component that wraps content with the Intlayer editor
11
- * selection UI. It replaces the per-framework ContentSelectorWrapper components
12
- * (Vue, Svelte, Solid, Preact).
13
- *
14
- * It reads from the global EditorStateManager singleton (set by initEditorClient)
15
- * and conditionally renders <intlayer-content-selector> around its slot content
16
- * when the editor is active and the app is running inside an iframe.
17
- *
18
- * @attr {string} key-path - JSON-serialized KeyPath[] for this content node
19
- * @attr {string} dictionary-key - The dictionary key owning this content node
20
- */
21
- var IntlayerContentSelectorWrapperElement = class extends _HTMLElement {
22
- _keyPathJson = "[]";
23
- _dictionaryKey = "";
24
- _editorEnabled = false;
25
- _isInIframe = false;
26
- _isSelected = false;
27
- _editedValue = void 0;
28
- _renderState = null;
29
- _selector = null;
30
- _unsubManager = null;
31
- _unsubEnabled = null;
32
- _unsubFocused = null;
33
- _unsubEditedContent = null;
34
- static get observedAttributes() {
35
- return ["key-path", "dictionary-key"];
36
- }
37
- get keyPathJson() {
38
- return this._keyPathJson;
39
- }
40
- set keyPathJson(v) {
41
- this._keyPathJson = v;
42
- const manager = getGlobalEditorManager();
43
- if (manager) this._updateEditedValue(manager);
44
- }
45
- get dictionaryKey() {
46
- return this._dictionaryKey;
47
- }
48
- set dictionaryKey(v) {
49
- this._dictionaryKey = v;
50
- const manager = getGlobalEditorManager();
51
- if (manager) this._updateEditedValue(manager);
52
- }
53
- constructor() {
54
- super();
55
- const shadow = this.attachShadow({ mode: "open" });
56
- const style = document.createElement("style");
57
- style.textContent = ":host { display: contents; }";
58
- shadow.appendChild(style);
59
- }
60
- attributeChangedCallback(name, _oldVal, newVal) {
61
- if (name === "key-path") {
62
- this._keyPathJson = newVal ?? "[]";
63
- const manager = getGlobalEditorManager();
64
- if (manager) this._updateEditedValue(manager);
65
- } else if (name === "dictionary-key") {
66
- this._dictionaryKey = newVal ?? "";
67
- const manager = getGlobalEditorManager();
68
- if (manager) this._updateEditedValue(manager);
69
- }
70
- }
71
- connectedCallback() {
72
- if (typeof window !== "undefined") this._isInIframe = window.self !== window.top;
73
- this._subscribeToManager();
74
- this._render();
75
- }
76
- disconnectedCallback() {
77
- this._teardown();
78
- }
79
- _teardown() {
80
- this._unsubManager?.();
81
- this._unsubEnabled?.();
82
- this._unsubFocused?.();
83
- this._unsubEditedContent?.();
84
- this._unsubManager = null;
85
- this._unsubEnabled = null;
86
- this._unsubFocused = null;
87
- this._unsubEditedContent = null;
88
- }
89
- _getRawKeyPath() {
90
- try {
91
- return JSON.parse(this._keyPathJson);
92
- } catch {
93
- return [];
94
- }
95
- }
96
- _getFilteredKeyPath() {
97
- return this._getRawKeyPath().filter((keyPath) => keyPath.type !== NodeTypes.TRANSLATION);
98
- }
99
- _updateEditedValue(manager) {
100
- const filteredKeyPath = this._getFilteredKeyPath();
101
- if (!this._dictionaryKey || filteredKeyPath.length === 0) {
102
- this._editedValue = void 0;
103
- this._render();
104
- return;
105
- }
106
- const rawKeyPath = this._getRawKeyPath();
107
- const lastStepType = rawKeyPath[rawKeyPath.length - 1]?.type;
108
- if (lastStepType === NodeTypes.MARKDOWN || lastStepType === NodeTypes.HTML || lastStepType === NodeTypes.INSERTION || lastStepType === NodeTypes.FILE) {
109
- this._editedValue = void 0;
110
- this._render();
111
- return;
112
- }
113
- let value = manager.getContentValue(this._dictionaryKey, filteredKeyPath);
114
- if (value !== null && value !== void 0 && typeof value === "object" && value.nodeType === NodeTypes.TRANSLATION) {
115
- const locale = manager.currentLocale.value;
116
- value = locale ? value[NodeTypes.TRANSLATION][locale] : void 0;
117
- }
118
- this._editedValue = value;
119
- this._render();
120
- }
121
- _updateIsSelected(focusedContent) {
122
- if (!focusedContent) {
123
- this._isSelected = false;
124
- this._updateSelectorAttr();
125
- return;
126
- }
127
- const keyPath = this._getFilteredKeyPath();
128
- const wasSelected = this._isSelected;
129
- this._isSelected = focusedContent.dictionaryKey === this._dictionaryKey && (focusedContent.keyPath?.length ?? 0) > 0 && isSameKeyPath(focusedContent.keyPath ?? [], keyPath);
130
- this._updateSelectorAttr();
131
- if (this._isSelected && !wasSelected) this._scrollIntoViewIfNeeded();
132
- }
133
- _scrollIntoViewIfNeeded() {
134
- try {
135
- let rect;
136
- if (this._selector) {
137
- const innerWrapper = this._selector.shadowRoot?.querySelector(".wrapper");
138
- if (innerWrapper) {
139
- const r = innerWrapper.getBoundingClientRect();
140
- if (r.width > 0 || r.height > 0) rect = r;
141
- }
142
- }
143
- if (!rect && this.childNodes.length > 0) {
144
- const range = document.createRange();
145
- range.selectNodeContents(this);
146
- const r = range.getBoundingClientRect();
147
- if (r.width > 0 || r.height > 0) rect = r;
148
- }
149
- if (!rect) rect = this.getBoundingClientRect();
150
- const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
151
- const viewportWidth = window.innerWidth || document.documentElement.clientWidth;
152
- if (!(rect.width > 0 && rect.height > 0 && rect.bottom > 0 && rect.right > 0 && rect.top < viewportHeight && rect.left < viewportWidth)) {
153
- const scrollY = window.scrollY ?? document.documentElement.scrollTop;
154
- const targetScrollY = rect.top + scrollY - viewportHeight * .25;
155
- window.scrollTo({
156
- top: Math.max(0, targetScrollY),
157
- behavior: "smooth"
158
- });
159
- }
160
- } catch {}
161
- }
162
- _updateSelectorAttr() {
163
- if (!this._selector) return;
164
- if (this._isSelected) this._selector.setAttribute("is-selecting", "");
165
- else this._selector.removeAttribute("is-selecting");
166
- }
167
- _subscribeToManager() {
168
- const manager = getGlobalEditorManager();
169
- if (manager) this._setupManagerSubscriptions(manager);
170
- this._unsubManager = onGlobalEditorManagerChange((m) => {
171
- this._unsubEnabled?.();
172
- this._unsubFocused?.();
173
- this._unsubEditedContent?.();
174
- this._unsubEnabled = null;
175
- this._unsubFocused = null;
176
- this._unsubEditedContent = null;
177
- if (m) this._setupManagerSubscriptions(m);
178
- else {
179
- this._editorEnabled = false;
180
- this._isSelected = false;
181
- this._editedValue = void 0;
182
- this._render();
183
- }
184
- });
185
- }
186
- _setupManagerSubscriptions(manager) {
187
- this._editorEnabled = manager.editorEnabled.value ?? false;
188
- this._updateIsSelected(manager.focusedContent.value);
189
- this._updateEditedValue(manager);
190
- const handleEnabledChange = (e) => {
191
- this._editorEnabled = e.detail;
192
- this._render();
193
- };
194
- const handleFocusedChange = (e) => {
195
- this._updateIsSelected(e.detail);
196
- };
197
- const handleEditedContentChange = () => {
198
- this._updateEditedValue(manager);
199
- };
200
- manager.editorEnabled.addEventListener("change", handleEnabledChange);
201
- manager.focusedContent.addEventListener("change", handleFocusedChange);
202
- manager.editedContent.addEventListener("change", handleEditedContentChange);
203
- this._unsubEnabled = () => manager.editorEnabled.removeEventListener("change", handleEnabledChange);
204
- this._unsubFocused = () => manager.focusedContent.removeEventListener("change", handleFocusedChange);
205
- this._unsubEditedContent = () => manager.editedContent.removeEventListener("change", handleEditedContentChange);
206
- }
207
- _handlePress(e) {
208
- e.stopPropagation();
209
- const manager = getGlobalEditorManager();
210
- if (!manager) return;
211
- manager.focusedContent.set({
212
- dictionaryKey: this._dictionaryKey,
213
- keyPath: this._getFilteredKeyPath()
214
- });
215
- }
216
- _handleHover(e) {
217
- e.stopPropagation();
218
- getGlobalEditorManager()?.messenger.send(`INTLAYER_HOVERED_CONTENT_CHANGED/post`, {
219
- dictionaryKey: this._dictionaryKey,
220
- keyPath: this._getFilteredKeyPath()
221
- });
222
- }
223
- _handleUnhover(e) {
224
- e.stopPropagation();
225
- getGlobalEditorManager()?.messenger.send(`INTLAYER_HOVERED_CONTENT_CHANGED/post`, null);
226
- }
227
- _render() {
228
- const useWrapper = this._isInIframe && this._editorEnabled;
229
- const editedValue = this._editedValue;
230
- const newState = !useWrapper ? "simple" : typeof editedValue === "string" || typeof editedValue === "number" || typeof editedValue === "boolean" ? "wrapped-text" : "wrapped-slot";
231
- if (this._renderState !== newState) {
232
- this._rebuildContent(newState);
233
- return;
234
- }
235
- if (newState !== "simple" && this._selector) {
236
- this._updateSelectorAttr();
237
- if (newState === "wrapped-text" && this._selector.firstChild?.nodeType === Node.TEXT_NODE) this._selector.firstChild.data = String(editedValue);
238
- }
239
- }
240
- _rebuildContent(state) {
241
- const shadow = this.shadowRoot;
242
- while (shadow.childNodes.length > 1) shadow.removeChild(shadow.lastChild);
243
- this._selector = null;
244
- if (state === "simple") shadow.appendChild(document.createElement("slot"));
245
- else {
246
- const selector = document.createElement("intlayer-content-selector");
247
- this._selector = selector;
248
- if (this._isSelected) selector.setAttribute("is-selecting", "");
249
- selector.addEventListener("intlayer:press", (e) => this._handlePress(e));
250
- selector.addEventListener("intlayer:hover", (e) => this._handleHover(e));
251
- selector.addEventListener("intlayer:unhover", (e) => this._handleUnhover(e));
252
- if (state === "wrapped-text") selector.appendChild(document.createTextNode(String(this._editedValue)));
253
- else selector.appendChild(document.createElement("slot"));
254
- shadow.appendChild(selector);
255
- }
256
- this._renderState = state;
257
- }
258
- };
259
- const defineIntlayerContentSelectorWrapper = () => {
260
- if (typeof customElements === "undefined") return;
261
- if (!customElements.get("intlayer-content-selector-wrapper")) customElements.define("intlayer-content-selector-wrapper", IntlayerContentSelectorWrapperElement);
262
- };
263
-
264
- //#endregion
265
- export { IntlayerContentSelectorWrapperElement, defineIntlayerContentSelectorWrapper };
266
- //# sourceMappingURL=ContentSelectorWrapper.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContentSelectorWrapper.mjs","names":[],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs"],"sourcesContent":["import { MessageKey } from \"../messageKey.mjs\";\nimport { getGlobalEditorManager, onGlobalEditorManagerChange } from \"../core/globalManager.mjs\";\nimport { isSameKeyPath } from \"@intlayer/core/utils\";\nimport * as NodeTypes from \"@intlayer/types/nodeType\";\n\n//#region src/components/ContentSelectorWrapper.ts\nconst _HTMLElement = typeof HTMLElement !== \"undefined\" ? HTMLElement : class {};\n/**\n* <intlayer-content-selector-wrapper>\n*\n* Framework-agnostic web component that wraps content with the Intlayer editor\n* selection UI. It replaces the per-framework ContentSelectorWrapper components\n* (Vue, Svelte, Solid, Preact).\n*\n* It reads from the global EditorStateManager singleton (set by initEditorClient)\n* and conditionally renders <intlayer-content-selector> around its slot content\n* when the editor is active and the app is running inside an iframe.\n*\n* @attr {string} key-path - JSON-serialized KeyPath[] for this content node\n* @attr {string} dictionary-key - The dictionary key owning this content node\n*/\nvar IntlayerContentSelectorWrapperElement = class extends _HTMLElement {\n\t_keyPathJson = \"[]\";\n\t_dictionaryKey = \"\";\n\t_editorEnabled = false;\n\t_isInIframe = false;\n\t_isSelected = false;\n\t_editedValue = void 0;\n\t_renderState = null;\n\t_selector = null;\n\t_unsubManager = null;\n\t_unsubEnabled = null;\n\t_unsubFocused = null;\n\t_unsubEditedContent = null;\n\tstatic get observedAttributes() {\n\t\treturn [\"key-path\", \"dictionary-key\"];\n\t}\n\tget keyPathJson() {\n\t\treturn this._keyPathJson;\n\t}\n\tset keyPathJson(v) {\n\t\tthis._keyPathJson = v;\n\t\tconst manager = getGlobalEditorManager();\n\t\tif (manager) this._updateEditedValue(manager);\n\t}\n\tget dictionaryKey() {\n\t\treturn this._dictionaryKey;\n\t}\n\tset dictionaryKey(v) {\n\t\tthis._dictionaryKey = v;\n\t\tconst manager = getGlobalEditorManager();\n\t\tif (manager) this._updateEditedValue(manager);\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tconst shadow = this.attachShadow({ mode: \"open\" });\n\t\tconst style = document.createElement(\"style\");\n\t\tstyle.textContent = \":host { display: contents; }\";\n\t\tshadow.appendChild(style);\n\t}\n\tattributeChangedCallback(name, _oldVal, newVal) {\n\t\tif (name === \"key-path\") {\n\t\t\tthis._keyPathJson = newVal ?? \"[]\";\n\t\t\tconst manager = getGlobalEditorManager();\n\t\t\tif (manager) this._updateEditedValue(manager);\n\t\t} else if (name === \"dictionary-key\") {\n\t\t\tthis._dictionaryKey = newVal ?? \"\";\n\t\t\tconst manager = getGlobalEditorManager();\n\t\t\tif (manager) this._updateEditedValue(manager);\n\t\t}\n\t}\n\tconnectedCallback() {\n\t\tif (typeof window !== \"undefined\") this._isInIframe = window.self !== window.top;\n\t\tthis._subscribeToManager();\n\t\tthis._render();\n\t}\n\tdisconnectedCallback() {\n\t\tthis._teardown();\n\t}\n\t_teardown() {\n\t\tthis._unsubManager?.();\n\t\tthis._unsubEnabled?.();\n\t\tthis._unsubFocused?.();\n\t\tthis._unsubEditedContent?.();\n\t\tthis._unsubManager = null;\n\t\tthis._unsubEnabled = null;\n\t\tthis._unsubFocused = null;\n\t\tthis._unsubEditedContent = null;\n\t}\n\t_getRawKeyPath() {\n\t\ttry {\n\t\t\treturn JSON.parse(this._keyPathJson);\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n\t_getFilteredKeyPath() {\n\t\treturn this._getRawKeyPath().filter((keyPath) => keyPath.type !== NodeTypes.TRANSLATION);\n\t}\n\t_updateEditedValue(manager) {\n\t\tconst filteredKeyPath = this._getFilteredKeyPath();\n\t\tif (!this._dictionaryKey || filteredKeyPath.length === 0) {\n\t\t\tthis._editedValue = void 0;\n\t\t\tthis._render();\n\t\t\treturn;\n\t\t}\n\t\tconst rawKeyPath = this._getRawKeyPath();\n\t\tconst lastStepType = rawKeyPath[rawKeyPath.length - 1]?.type;\n\t\tif (lastStepType === NodeTypes.MARKDOWN || lastStepType === NodeTypes.HTML || lastStepType === NodeTypes.INSERTION || lastStepType === NodeTypes.FILE) {\n\t\t\tthis._editedValue = void 0;\n\t\t\tthis._render();\n\t\t\treturn;\n\t\t}\n\t\tlet value = manager.getContentValue(this._dictionaryKey, filteredKeyPath);\n\t\tif (value !== null && value !== void 0 && typeof value === \"object\" && value.nodeType === NodeTypes.TRANSLATION) {\n\t\t\tconst locale = manager.currentLocale.value;\n\t\t\tvalue = locale ? value[NodeTypes.TRANSLATION][locale] : void 0;\n\t\t}\n\t\tthis._editedValue = value;\n\t\tthis._render();\n\t}\n\t_updateIsSelected(focusedContent) {\n\t\tif (!focusedContent) {\n\t\t\tthis._isSelected = false;\n\t\t\tthis._updateSelectorAttr();\n\t\t\treturn;\n\t\t}\n\t\tconst keyPath = this._getFilteredKeyPath();\n\t\tconst wasSelected = this._isSelected;\n\t\tthis._isSelected = focusedContent.dictionaryKey === this._dictionaryKey && (focusedContent.keyPath?.length ?? 0) > 0 && isSameKeyPath(focusedContent.keyPath ?? [], keyPath);\n\t\tthis._updateSelectorAttr();\n\t\tif (this._isSelected && !wasSelected) this._scrollIntoViewIfNeeded();\n\t}\n\t_scrollIntoViewIfNeeded() {\n\t\ttry {\n\t\t\tlet rect;\n\t\t\tif (this._selector) {\n\t\t\t\tconst innerWrapper = this._selector.shadowRoot?.querySelector(\".wrapper\");\n\t\t\t\tif (innerWrapper) {\n\t\t\t\t\tconst r = innerWrapper.getBoundingClientRect();\n\t\t\t\t\tif (r.width > 0 || r.height > 0) rect = r;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!rect && this.childNodes.length > 0) {\n\t\t\t\tconst range = document.createRange();\n\t\t\t\trange.selectNodeContents(this);\n\t\t\t\tconst r = range.getBoundingClientRect();\n\t\t\t\tif (r.width > 0 || r.height > 0) rect = r;\n\t\t\t}\n\t\t\tif (!rect) rect = this.getBoundingClientRect();\n\t\t\tconst viewportHeight = window.innerHeight || document.documentElement.clientHeight;\n\t\t\tconst viewportWidth = window.innerWidth || document.documentElement.clientWidth;\n\t\t\tif (!(rect.width > 0 && rect.height > 0 && rect.bottom > 0 && rect.right > 0 && rect.top < viewportHeight && rect.left < viewportWidth)) {\n\t\t\t\tconst scrollY = window.scrollY ?? document.documentElement.scrollTop;\n\t\t\t\tconst targetScrollY = rect.top + scrollY - viewportHeight * .25;\n\t\t\t\twindow.scrollTo({\n\t\t\t\t\ttop: Math.max(0, targetScrollY),\n\t\t\t\t\tbehavior: \"smooth\"\n\t\t\t\t});\n\t\t\t}\n\t\t} catch {}\n\t}\n\t_updateSelectorAttr() {\n\t\tif (!this._selector) return;\n\t\tif (this._isSelected) this._selector.setAttribute(\"is-selecting\", \"\");\n\t\telse this._selector.removeAttribute(\"is-selecting\");\n\t}\n\t_subscribeToManager() {\n\t\tconst manager = getGlobalEditorManager();\n\t\tif (manager) this._setupManagerSubscriptions(manager);\n\t\tthis._unsubManager = onGlobalEditorManagerChange((m) => {\n\t\t\tthis._unsubEnabled?.();\n\t\t\tthis._unsubFocused?.();\n\t\t\tthis._unsubEditedContent?.();\n\t\t\tthis._unsubEnabled = null;\n\t\t\tthis._unsubFocused = null;\n\t\t\tthis._unsubEditedContent = null;\n\t\t\tif (m) this._setupManagerSubscriptions(m);\n\t\t\telse {\n\t\t\t\tthis._editorEnabled = false;\n\t\t\t\tthis._isSelected = false;\n\t\t\t\tthis._editedValue = void 0;\n\t\t\t\tthis._render();\n\t\t\t}\n\t\t});\n\t}\n\t_setupManagerSubscriptions(manager) {\n\t\tthis._editorEnabled = manager.editorEnabled.value ?? false;\n\t\tthis._updateIsSelected(manager.focusedContent.value);\n\t\tthis._updateEditedValue(manager);\n\t\tconst handleEnabledChange = (e) => {\n\t\t\tthis._editorEnabled = e.detail;\n\t\t\tthis._render();\n\t\t};\n\t\tconst handleFocusedChange = (e) => {\n\t\t\tthis._updateIsSelected(e.detail);\n\t\t};\n\t\tconst handleEditedContentChange = () => {\n\t\t\tthis._updateEditedValue(manager);\n\t\t};\n\t\tmanager.editorEnabled.addEventListener(\"change\", handleEnabledChange);\n\t\tmanager.focusedContent.addEventListener(\"change\", handleFocusedChange);\n\t\tmanager.editedContent.addEventListener(\"change\", handleEditedContentChange);\n\t\tthis._unsubEnabled = () => manager.editorEnabled.removeEventListener(\"change\", handleEnabledChange);\n\t\tthis._unsubFocused = () => manager.focusedContent.removeEventListener(\"change\", handleFocusedChange);\n\t\tthis._unsubEditedContent = () => manager.editedContent.removeEventListener(\"change\", handleEditedContentChange);\n\t}\n\t_handlePress(e) {\n\t\te.stopPropagation();\n\t\tconst manager = getGlobalEditorManager();\n\t\tif (!manager) return;\n\t\tmanager.focusedContent.set({\n\t\t\tdictionaryKey: this._dictionaryKey,\n\t\t\tkeyPath: this._getFilteredKeyPath()\n\t\t});\n\t}\n\t_handleHover(e) {\n\t\te.stopPropagation();\n\t\tgetGlobalEditorManager()?.messenger.send(`${\"INTLAYER_HOVERED_CONTENT_CHANGED\"}/post`, {\n\t\t\tdictionaryKey: this._dictionaryKey,\n\t\t\tkeyPath: this._getFilteredKeyPath()\n\t\t});\n\t}\n\t_handleUnhover(e) {\n\t\te.stopPropagation();\n\t\tgetGlobalEditorManager()?.messenger.send(`${\"INTLAYER_HOVERED_CONTENT_CHANGED\"}/post`, null);\n\t}\n\t_render() {\n\t\tconst useWrapper = this._isInIframe && this._editorEnabled;\n\t\tconst editedValue = this._editedValue;\n\t\tconst newState = !useWrapper ? \"simple\" : typeof editedValue === \"string\" || typeof editedValue === \"number\" || typeof editedValue === \"boolean\" ? \"wrapped-text\" : \"wrapped-slot\";\n\t\tif (this._renderState !== newState) {\n\t\t\tthis._rebuildContent(newState);\n\t\t\treturn;\n\t\t}\n\t\tif (newState !== \"simple\" && this._selector) {\n\t\t\tthis._updateSelectorAttr();\n\t\t\tif (newState === \"wrapped-text\" && this._selector.firstChild?.nodeType === Node.TEXT_NODE) this._selector.firstChild.data = String(editedValue);\n\t\t}\n\t}\n\t_rebuildContent(state) {\n\t\tconst shadow = this.shadowRoot;\n\t\twhile (shadow.childNodes.length > 1) shadow.removeChild(shadow.lastChild);\n\t\tthis._selector = null;\n\t\tif (state === \"simple\") shadow.appendChild(document.createElement(\"slot\"));\n\t\telse {\n\t\t\tconst selector = document.createElement(\"intlayer-content-selector\");\n\t\t\tthis._selector = selector;\n\t\t\tif (this._isSelected) selector.setAttribute(\"is-selecting\", \"\");\n\t\t\tselector.addEventListener(\"intlayer:press\", (e) => this._handlePress(e));\n\t\t\tselector.addEventListener(\"intlayer:hover\", (e) => this._handleHover(e));\n\t\t\tselector.addEventListener(\"intlayer:unhover\", (e) => this._handleUnhover(e));\n\t\t\tif (state === \"wrapped-text\") selector.appendChild(document.createTextNode(String(this._editedValue)));\n\t\t\telse selector.appendChild(document.createElement(\"slot\"));\n\t\t\tshadow.appendChild(selector);\n\t\t}\n\t\tthis._renderState = state;\n\t}\n};\nconst defineIntlayerContentSelectorWrapper = () => {\n\tif (typeof customElements === \"undefined\") return;\n\tif (!customElements.get(\"intlayer-content-selector-wrapper\")) customElements.define(\"intlayer-content-selector-wrapper\", IntlayerContentSelectorWrapperElement);\n};\n\n//#endregion\nexport { IntlayerContentSelectorWrapperElement, defineIntlayerContentSelectorWrapper };\n//# sourceMappingURL=ContentSelectorWrapper.mjs.map"],"mappings":";;;;;AAMA,MAAM,eAAe,OAAO,gBAAgB,cAAc,cAAc,MAAM;;;;;;;;;;;;;;;AAe9E,IAAI,wCAAwC,cAAc,aAAa;CACtE,eAA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,YAAY,OAAO,gBAAgB,YAAY,OAAO,gBAAgB,YAAY,iBAAiB;AACpK,MAAI,KAAK,iBAAiB,UAAU;AACnC,QAAK,gBAAgB,SAAS;AAC9B;;AAED,MAAI,aAAa,YAAY,KAAK,WAAW;AAC5C,QAAK,qBAAqB;AAC1B,OAAI,aAAa,kBAAkB,KAAK,UAAU,YAAY,aAAa,KAAK,UAAW,MAAK,UAAU,WAAW,OAAO,OAAO,YAAY;;;CAGjJ,gBAAgB,OAAO;EACtB,MAAM,SAAS,KAAK;AACpB,SAAO,OAAO,WAAW,SAAS,EAAG,QAAO,YAAY,OAAO,UAAU;AACzE,OAAK,YAAY;AACjB,MAAI,UAAU,SAAU,QAAO,YAAY,SAAS,cAAc,OAAO,CAAC;OACrE;GACJ,MAAM,WAAW,SAAS,cAAc,4BAA4B;AACpE,QAAK,YAAY;AACjB,OAAI,KAAK,YAAa,UAAS,aAAa,gBAAgB,GAAG;AAC/D,YAAS,iBAAiB,mBAAmB,MAAM,KAAK,aAAa,EAAE,CAAC;AACxE,YAAS,iBAAiB,mBAAmB,MAAM,KAAK,aAAa,EAAE,CAAC;AACxE,YAAS,iBAAiB,qBAAqB,MAAM,KAAK,eAAe,EAAE,CAAC;AAC5E,OAAI,UAAU,eAAgB,UAAS,YAAY,SAAS,eAAe,OAAO,KAAK,aAAa,CAAC,CAAC;OACjG,UAAS,YAAY,SAAS,cAAc,OAAO,CAAC;AACzD,UAAO,YAAY,SAAS;;AAE7B,OAAK,eAAe;;;AAGtB,MAAM,6CAA6C;AAClD,KAAI,OAAO,mBAAmB,YAAa;AAC3C,KAAI,CAAC,eAAe,IAAI,oCAAoC,CAAE,gBAAe,OAAO,qCAAqC,sCAAsC"}
@@ -1,159 +0,0 @@
1
- import { getGlobalEditorManager, onGlobalEditorManagerChange } from "../core/globalManager.mjs";
2
- import { getBasePlugins, getContent } from "@intlayer/core/interpreter";
3
-
4
- //#region ../../packages/@intlayer/editor/dist/esm/components/EditedContent.mjs
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":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/components/EditedContent.mjs"],"sourcesContent":["import { getGlobalEditorManager, onGlobalEditorManagerChange } from \"../core/globalManager.mjs\";\nimport { getBasePlugins, getContent } from \"@intlayer/core/interpreter\";\n\n//#region src/components/EditedContent.ts\nconst _HTMLElement = typeof HTMLElement !== \"undefined\" ? HTMLElement : class {};\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*/\nvar IntlayerEditedContentElement = class extends _HTMLElement {\n\t_dictionaryKey = \"\";\n\t_keyPathJson = \"[]\";\n\t_locale = \"\";\n\t_editedText = null;\n\t_unsubManager = null;\n\t_unsubEditedContent = null;\n\t_selectorWrapper;\n\t_slot;\n\tstatic get observedAttributes() {\n\t\treturn [\n\t\t\t\"dictionary-key\",\n\t\t\t\"key-path\",\n\t\t\t\"locale\"\n\t\t];\n\t}\n\tget dictionaryKey() {\n\t\treturn this._dictionaryKey;\n\t}\n\tset dictionaryKey(v) {\n\t\tthis._dictionaryKey = v;\n\t\tthis._selectorWrapper.setAttribute(\"dictionary-key\", v);\n\t}\n\tget keyPathJson() {\n\t\treturn this._keyPathJson;\n\t}\n\tset keyPathJson(v) {\n\t\tthis._keyPathJson = v;\n\t\tthis._selectorWrapper.setAttribute(\"key-path\", v);\n\t}\n\tget locale() {\n\t\treturn this._locale;\n\t}\n\tset locale(v) {\n\t\tthis._locale = v;\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tconst shadow = this.attachShadow({ mode: \"open\" });\n\t\tconst style = document.createElement(\"style\");\n\t\tstyle.textContent = \":host { display: contents; }\";\n\t\tshadow.appendChild(style);\n\t\tthis._selectorWrapper = document.createElement(\"intlayer-content-selector-wrapper\");\n\t\tthis._slot = document.createElement(\"slot\");\n\t\tthis._selectorWrapper.appendChild(this._slot);\n\t\tshadow.appendChild(this._selectorWrapper);\n\t}\n\tattributeChangedCallback(name, _oldVal, newVal) {\n\t\tconst val = newVal ?? \"\";\n\t\tif (name === \"dictionary-key\") {\n\t\t\tthis._dictionaryKey = val;\n\t\t\tthis._selectorWrapper.setAttribute(\"dictionary-key\", val);\n\t\t} else if (name === \"key-path\") {\n\t\t\tthis._keyPathJson = val || \"[]\";\n\t\t\tthis._selectorWrapper.setAttribute(\"key-path\", this._keyPathJson);\n\t\t} else if (name === \"locale\") this._locale = val;\n\t}\n\tconnectedCallback() {\n\t\tthis._subscribeToManager();\n\t}\n\tdisconnectedCallback() {\n\t\tthis._teardown();\n\t}\n\t_teardown() {\n\t\tthis._unsubManager?.();\n\t\tthis._unsubEditedContent?.();\n\t\tthis._unsubManager = null;\n\t\tthis._unsubEditedContent = null;\n\t}\n\t_getKeyPath() {\n\t\ttry {\n\t\t\treturn JSON.parse(this._keyPathJson);\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n\t_render() {\n\t\twhile (this._selectorWrapper.firstChild) this._selectorWrapper.removeChild(this._selectorWrapper.firstChild);\n\t\tif (this._editedText !== null) this._selectorWrapper.appendChild(document.createTextNode(this._editedText));\n\t\telse this._selectorWrapper.appendChild(this._slot);\n\t}\n\t_resolveEditedText(manager) {\n\t\tconst keyPath = this._getKeyPath();\n\t\tconst editedValue = manager.getContentValue(this._dictionaryKey, keyPath);\n\t\tif (editedValue === void 0 || editedValue === null) {\n\t\t\tthis._editedText = null;\n\t\t\tthis._render();\n\t\t\treturn;\n\t\t}\n\t\tif (typeof editedValue === \"string\" || typeof editedValue === \"number\") {\n\t\t\tthis._editedText = String(editedValue);\n\t\t\tthis._render();\n\t\t\treturn;\n\t\t}\n\t\tif (typeof editedValue === \"object\") {\n\t\t\tconst locale = this._locale || void 0;\n\t\t\tconst transformed = getContent(editedValue, {\n\t\t\t\tlocale,\n\t\t\t\tdictionaryKey: this._dictionaryKey,\n\t\t\t\tkeyPath\n\t\t\t}, getBasePlugins(locale));\n\t\t\tif (typeof transformed === \"string\" || typeof transformed === \"number\") this._editedText = String(transformed);\n\t\t\telse {\n\t\t\t\tconsole.error(`[intlayer-edited-content] Incorrect edited content format. Expected string. Value: ${JSON.stringify(transformed)}`);\n\t\t\t\tthis._editedText = null;\n\t\t\t}\n\t\t\tthis._render();\n\t\t\treturn;\n\t\t}\n\t\tthis._editedText = null;\n\t\tthis._render();\n\t}\n\t_setupManagerSubscriptions(manager) {\n\t\tthis._resolveEditedText(manager);\n\t\tconst handleChange = () => this._resolveEditedText(manager);\n\t\tmanager.editedContent.addEventListener(\"change\", handleChange);\n\t\tthis._unsubEditedContent = () => manager.editedContent.removeEventListener(\"change\", handleChange);\n\t}\n\t_subscribeToManager() {\n\t\tconst manager = getGlobalEditorManager();\n\t\tif (manager) this._setupManagerSubscriptions(manager);\n\t\tthis._unsubManager = onGlobalEditorManagerChange((m) => {\n\t\t\tthis._unsubEditedContent?.();\n\t\t\tthis._unsubEditedContent = null;\n\t\t\tif (m) this._setupManagerSubscriptions(m);\n\t\t\telse {\n\t\t\t\tthis._editedText = null;\n\t\t\t\tthis._render();\n\t\t\t}\n\t\t});\n\t}\n};\nconst defineIntlayerEditedContent = () => {\n\tif (typeof customElements === \"undefined\") return;\n\tif (!customElements.get(\"intlayer-edited-content\")) customElements.define(\"intlayer-edited-content\", IntlayerEditedContentElement);\n};\n\n//#endregion\nexport { IntlayerEditedContentElement, defineIntlayerEditedContent };\n//# sourceMappingURL=EditedContent.mjs.map"],"mappings":";;;;AAIA,MAAM,eAAe,OAAO,gBAAgB,cAAc,cAAc,MAAM;;;;;;;;;;;;;;;AAe9E,IAAI,+BAA+B,cAAc,aAAa;CAC7D,iBAAiB;CACjB,eAAe;CACf,UAAU;CACV,cAAc;CACd,gBAAgB;CAChB,sBAAsB;CACtB;CACA;CACA,WAAW,qBAAqB;AAC/B,SAAO;GACN;GACA;GACA;GACA;;CAEF,IAAI,gBAAgB;AACnB,SAAO,KAAK;;CAEb,IAAI,cAAc,GAAG;AACpB,OAAK,iBAAiB;AACtB,OAAK,iBAAiB,aAAa,kBAAkB,EAAE;;CAExD,IAAI,cAAc;AACjB,SAAO,KAAK;;CAEb,IAAI,YAAY,GAAG;AAClB,OAAK,eAAe;AACpB,OAAK,iBAAiB,aAAa,YAAY,EAAE;;CAElD,IAAI,SAAS;AACZ,SAAO,KAAK;;CAEb,IAAI,OAAO,GAAG;AACb,OAAK,UAAU;;CAEhB,cAAc;AACb,SAAO;EACP,MAAM,SAAS,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;EAClD,MAAM,QAAQ,SAAS,cAAc,QAAQ;AAC7C,QAAM,cAAc;AACpB,SAAO,YAAY,MAAM;AACzB,OAAK,mBAAmB,SAAS,cAAc,oCAAoC;AACnF,OAAK,QAAQ,SAAS,cAAc,OAAO;AAC3C,OAAK,iBAAiB,YAAY,KAAK,MAAM;AAC7C,SAAO,YAAY,KAAK,iBAAiB;;CAE1C,yBAAyB,MAAM,SAAS,QAAQ;EAC/C,MAAM,MAAM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