@intlayer/editor 8.4.3 → 8.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs +11 -0
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/cjs/compareUrls.cjs +39 -1
- package/dist/cjs/compareUrls.cjs.map +1 -1
- package/dist/cjs/components/ContentSelector.cjs +168 -1
- package/dist/cjs/components/ContentSelector.cjs.map +1 -0
- package/dist/cjs/components/ContentSelectorWrapper.cjs +193 -4
- package/dist/cjs/components/ContentSelectorWrapper.cjs.map +1 -1
- package/dist/cjs/components/EditedContent.cjs +128 -4
- package/dist/cjs/components/EditedContent.cjs.map +1 -1
- package/dist/cjs/components/IntlayerEditor.cjs +87 -1
- package/dist/cjs/components/IntlayerEditor.cjs.map +1 -0
- package/dist/cjs/components/index.cjs +14 -1
- package/dist/cjs/core/CrossFrameMessenger.cjs +77 -1
- package/dist/cjs/core/CrossFrameMessenger.cjs.map +1 -1
- package/dist/cjs/core/CrossFrameStateManager.cjs +71 -1
- package/dist/cjs/core/CrossFrameStateManager.cjs.map +1 -1
- package/dist/cjs/core/EditorStateManager.cjs +258 -1
- package/dist/cjs/core/EditorStateManager.cjs.map +1 -1
- package/dist/cjs/core/IframeClickInterceptor.cjs +45 -1
- package/dist/cjs/core/IframeClickInterceptor.cjs.map +1 -1
- package/dist/cjs/core/UrlStateManager.cjs +59 -1
- package/dist/cjs/core/UrlStateManager.cjs.map +1 -1
- package/dist/cjs/core/globalManager.cjs +82 -1
- package/dist/cjs/core/globalManager.cjs.map +1 -1
- package/dist/cjs/core/index.cjs +20 -1
- package/dist/cjs/core/initEditorClient.cjs +58 -1
- package/dist/cjs/core/initEditorClient.cjs.map +1 -0
- package/dist/cjs/index.cjs +38 -1
- package/dist/cjs/isEnabled.cjs +10 -1
- package/dist/cjs/isEnabled.cjs.map +1 -1
- package/dist/cjs/mergeIframeClick.cjs +22 -1
- package/dist/cjs/mergeIframeClick.cjs.map +1 -1
- package/dist/cjs/messageKey.cjs +30 -1
- package/dist/cjs/messageKey.cjs.map +1 -1
- package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs +10 -0
- package/dist/esm/compareUrls.mjs +37 -1
- package/dist/esm/compareUrls.mjs.map +1 -1
- package/dist/esm/components/ContentSelector.mjs +165 -1
- package/dist/esm/components/ContentSelector.mjs.map +1 -0
- package/dist/esm/components/ContentSelectorWrapper.mjs +189 -4
- package/dist/esm/components/ContentSelectorWrapper.mjs.map +1 -1
- package/dist/esm/components/EditedContent.mjs +125 -4
- package/dist/esm/components/EditedContent.mjs.map +1 -1
- package/dist/esm/components/IntlayerEditor.mjs +84 -1
- package/dist/esm/components/IntlayerEditor.mjs.map +1 -0
- package/dist/esm/components/index.mjs +6 -1
- package/dist/esm/core/CrossFrameMessenger.mjs +76 -1
- package/dist/esm/core/CrossFrameMessenger.mjs.map +1 -1
- package/dist/esm/core/CrossFrameStateManager.mjs +69 -1
- package/dist/esm/core/CrossFrameStateManager.mjs.map +1 -1
- package/dist/esm/core/EditorStateManager.mjs +255 -1
- package/dist/esm/core/EditorStateManager.mjs.map +1 -1
- package/dist/esm/core/IframeClickInterceptor.mjs +44 -1
- package/dist/esm/core/IframeClickInterceptor.mjs.map +1 -1
- package/dist/esm/core/UrlStateManager.mjs +58 -1
- package/dist/esm/core/UrlStateManager.mjs.map +1 -1
- package/dist/esm/core/globalManager.mjs +78 -1
- package/dist/esm/core/globalManager.mjs.map +1 -1
- package/dist/esm/core/index.mjs +9 -1
- package/dist/esm/core/initEditorClient.mjs +53 -1
- package/dist/esm/core/initEditorClient.mjs.map +1 -0
- package/dist/esm/index.mjs +16 -1
- package/dist/esm/isEnabled.mjs +7 -1
- package/dist/esm/isEnabled.mjs.map +1 -1
- package/dist/esm/mergeIframeClick.mjs +20 -1
- package/dist/esm/mergeIframeClick.mjs.map +1 -1
- package/dist/esm/messageKey.mjs +28 -1
- package/dist/esm/messageKey.mjs.map +1 -1
- package/dist/types/components/ContentSelector.d.ts +49 -2
- package/dist/types/components/ContentSelector.d.ts.map +1 -0
- package/dist/types/components/ContentSelectorWrapper.d.ts +49 -2
- package/dist/types/components/ContentSelectorWrapper.d.ts.map +1 -0
- package/dist/types/components/EditedContent.d.ts +39 -2
- package/dist/types/components/EditedContent.d.ts.map +1 -0
- package/dist/types/components/IntlayerEditor.d.ts +40 -2
- package/dist/types/components/IntlayerEditor.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +4 -4
- package/dist/types/core/CrossFrameMessenger.d.ts +51 -2
- package/dist/types/core/CrossFrameMessenger.d.ts.map +1 -0
- package/dist/types/core/CrossFrameStateManager.d.ts +44 -2
- package/dist/types/core/CrossFrameStateManager.d.ts.map +1 -0
- package/dist/types/core/EditorStateManager.d.ts +73 -2
- package/dist/types/core/EditorStateManager.d.ts.map +1 -0
- package/dist/types/core/IframeClickInterceptor.d.ts +26 -2
- package/dist/types/core/IframeClickInterceptor.d.ts.map +1 -0
- package/dist/types/core/UrlStateManager.d.ts +21 -2
- package/dist/types/core/UrlStateManager.d.ts.map +1 -0
- package/dist/types/core/globalManager.d.ts +39 -2
- package/dist/types/core/globalManager.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +7 -7
- package/dist/types/core/initEditorClient.d.ts +20 -2
- package/dist/types/core/initEditorClient.d.ts.map +1 -0
- package/dist/types/index.d.ts +11 -11
- package/package.json +5 -5
- package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
- package/dist/cjs/components-DWu35JEb.cjs +0 -41
- package/dist/cjs/components-DWu35JEb.cjs.map +0 -1
- package/dist/cjs/decorate-Bg73f0d3.cjs +0 -1
- package/dist/esm/components-RtOXxg9h.mjs +0 -41
- package/dist/esm/components-RtOXxg9h.mjs.map +0 -1
- package/dist/esm/decorate-BWURH4oJ.mjs +0 -1
- package/dist/types/ContentSelector-sIfZu4Dd.d.ts +0 -49
- package/dist/types/ContentSelector-sIfZu4Dd.d.ts.map +0 -1
- package/dist/types/ContentSelectorWrapper-CID6anMf.d.ts +0 -49
- package/dist/types/ContentSelectorWrapper-CID6anMf.d.ts.map +0 -1
- package/dist/types/CrossFrameMessenger-CPt3Bu8S.d.ts +0 -51
- package/dist/types/CrossFrameMessenger-CPt3Bu8S.d.ts.map +0 -1
- package/dist/types/CrossFrameStateManager-CW1DPY_Z.d.ts +0 -44
- package/dist/types/CrossFrameStateManager-CW1DPY_Z.d.ts.map +0 -1
- package/dist/types/EditedContent-2kq4wk4R.d.ts +0 -39
- package/dist/types/EditedContent-2kq4wk4R.d.ts.map +0 -1
- package/dist/types/EditorStateManager-Y9j0SYCd.d.ts +0 -73
- package/dist/types/EditorStateManager-Y9j0SYCd.d.ts.map +0 -1
- package/dist/types/IframeClickInterceptor-Cm89LRcI.d.ts +0 -26
- package/dist/types/IframeClickInterceptor-Cm89LRcI.d.ts.map +0 -1
- package/dist/types/IntlayerEditor-ePRSIuBI.d.ts +0 -40
- package/dist/types/IntlayerEditor-ePRSIuBI.d.ts.map +0 -1
- package/dist/types/UrlStateManager-CIOVEeTq.d.ts +0 -21
- package/dist/types/UrlStateManager-CIOVEeTq.d.ts.map +0 -1
- package/dist/types/globalManager-BD6UaK_1.d.ts +0 -39
- package/dist/types/globalManager-BD6UaK_1.d.ts.map +0 -1
- package/dist/types/initEditorClient-ovRVUf_n.d.ts +0 -20
- package/dist/types/initEditorClient-ovRVUf_n.d.ts.map +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/decorate.js
|
|
3
|
+
function __decorate(decorators, target, key, desc) {
|
|
4
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.__decorate = __decorate;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
package/dist/cjs/compareUrls.cjs
CHANGED
|
@@ -1,2 +1,40 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
//#region src/compareUrls.ts
|
|
4
|
+
/**
|
|
5
|
+
* Compare two URLs for equality.
|
|
6
|
+
* This function is used to determine if a message originates from the same origin.
|
|
7
|
+
*
|
|
8
|
+
* ```js
|
|
9
|
+
* // Example usage
|
|
10
|
+
* console.log(compareUrls("http://localhost:5173/", "http://localhost:5173")); // true
|
|
11
|
+
* console.log(compareUrls("http://localhost:5173", "http://localhost:5173?myParam=true")); // true
|
|
12
|
+
* console.log(compareUrls("http://localhost:5173/subpath", "http://localhost:5173")); // true
|
|
13
|
+
* console.log(compareUrls("http://localhost:5172", "http://localhost:5173")); // false
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param url1 - The first URL to compare.
|
|
17
|
+
* @param url2 - The second URL to compare.
|
|
18
|
+
* @returns Whether the two URLs are equal.
|
|
19
|
+
*/
|
|
20
|
+
const compareUrls = (url1, url2) => {
|
|
21
|
+
try {
|
|
22
|
+
const parsedUrl1 = new URL(url1);
|
|
23
|
+
const parsedUrl2 = new URL(url2);
|
|
24
|
+
if (parsedUrl1.protocol !== parsedUrl2.protocol || parsedUrl1.hostname !== parsedUrl2.hostname || parsedUrl1.port !== parsedUrl2.port) return false;
|
|
25
|
+
const path1 = parsedUrl1.pathname.replace(/\/$/, "");
|
|
26
|
+
const path2 = parsedUrl2.pathname.replace(/\/$/, "");
|
|
27
|
+
if (path1 !== "" && path2 !== "" && path1 !== path2) return false;
|
|
28
|
+
return true;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error("Invalid URL(s)", error, {
|
|
31
|
+
url1,
|
|
32
|
+
url2
|
|
33
|
+
});
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.compareUrls = compareUrls;
|
|
2
40
|
//# sourceMappingURL=compareUrls.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareUrls.cjs","names":[],"sources":["../../src/compareUrls.ts"],"sourcesContent":["/**\n * Compare two URLs for equality.\n * This function is used to determine if a message originates from the same origin.\n *\n * ```js\n * // Example usage\n * console.log(compareUrls(\"http://localhost:5173/\", \"http://localhost:5173\")); // true\n * console.log(compareUrls(\"http://localhost:5173\", \"http://localhost:5173?myParam=true\")); // true\n * console.log(compareUrls(\"http://localhost:5173/subpath\", \"http://localhost:5173\")); // true\n * console.log(compareUrls(\"http://localhost:5172\", \"http://localhost:5173\")); // false\n * ```\n *\n * @param url1 - The first URL to compare.\n * @param url2 - The second URL to compare.\n * @returns Whether the two URLs are equal.\n */\nexport const compareUrls = (url1: string, url2: string): boolean => {\n try {\n const parsedUrl1 = new URL(url1);\n const parsedUrl2 = new URL(url2);\n\n // Compare protocol, hostname, and port\n if (\n parsedUrl1.protocol !== parsedUrl2.protocol ||\n parsedUrl1.hostname !== parsedUrl2.hostname ||\n parsedUrl1.port !== parsedUrl2.port\n ) {\n return false;\n }\n\n // One URL should not have a subpath while the other does\n const path1 = parsedUrl1.pathname.replace(/\\/$/, ''); // Remove trailing slash\n const path2 = parsedUrl2.pathname.replace(/\\/$/, '');\n\n if (path1 !== '' && path2 !== '' && path1 !== path2) {\n return false;\n }\n\n return true;\n } catch (error) {\n console.error('Invalid URL(s)', error, { url1, url2 });\n return false;\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"compareUrls.cjs","names":[],"sources":["../../src/compareUrls.ts"],"sourcesContent":["/**\n * Compare two URLs for equality.\n * This function is used to determine if a message originates from the same origin.\n *\n * ```js\n * // Example usage\n * console.log(compareUrls(\"http://localhost:5173/\", \"http://localhost:5173\")); // true\n * console.log(compareUrls(\"http://localhost:5173\", \"http://localhost:5173?myParam=true\")); // true\n * console.log(compareUrls(\"http://localhost:5173/subpath\", \"http://localhost:5173\")); // true\n * console.log(compareUrls(\"http://localhost:5172\", \"http://localhost:5173\")); // false\n * ```\n *\n * @param url1 - The first URL to compare.\n * @param url2 - The second URL to compare.\n * @returns Whether the two URLs are equal.\n */\nexport const compareUrls = (url1: string, url2: string): boolean => {\n try {\n const parsedUrl1 = new URL(url1);\n const parsedUrl2 = new URL(url2);\n\n // Compare protocol, hostname, and port\n if (\n parsedUrl1.protocol !== parsedUrl2.protocol ||\n parsedUrl1.hostname !== parsedUrl2.hostname ||\n parsedUrl1.port !== parsedUrl2.port\n ) {\n return false;\n }\n\n // One URL should not have a subpath while the other does\n const path1 = parsedUrl1.pathname.replace(/\\/$/, ''); // Remove trailing slash\n const path2 = parsedUrl2.pathname.replace(/\\/$/, '');\n\n if (path1 !== '' && path2 !== '' && path1 !== path2) {\n return false;\n }\n\n return true;\n } catch (error) {\n console.error('Invalid URL(s)', error, { url1, url2 });\n return false;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA,MAAa,eAAe,MAAc,SAA0B;AAClE,KAAI;EACF,MAAM,aAAa,IAAI,IAAI,KAAK;EAChC,MAAM,aAAa,IAAI,IAAI,KAAK;AAGhC,MACE,WAAW,aAAa,WAAW,YACnC,WAAW,aAAa,WAAW,YACnC,WAAW,SAAS,WAAW,KAE/B,QAAO;EAIT,MAAM,QAAQ,WAAW,SAAS,QAAQ,OAAO,GAAG;EACpD,MAAM,QAAQ,WAAW,SAAS,QAAQ,OAAO,GAAG;AAEpD,MAAI,UAAU,MAAM,UAAU,MAAM,UAAU,MAC5C,QAAO;AAGT,SAAO;UACA,OAAO;AACd,UAAQ,MAAM,kBAAkB,OAAO;GAAE;GAAM;GAAM,CAAC;AACtD,SAAO"}
|
|
@@ -1 +1,168 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_decorate = require('../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs');
|
|
4
|
+
const require_components_ContentSelectorWrapper = require('./ContentSelectorWrapper.cjs');
|
|
5
|
+
const require_components_EditedContent = require('./EditedContent.cjs');
|
|
6
|
+
const require_components_IntlayerEditor = require('./IntlayerEditor.cjs');
|
|
7
|
+
let lit = require("lit");
|
|
8
|
+
let lit_decorators_js = require("lit/decorators.js");
|
|
9
|
+
|
|
10
|
+
//#region src/components/ContentSelector.ts
|
|
11
|
+
const DEFAULT_PRESS_DURATION = 250;
|
|
12
|
+
/**
|
|
13
|
+
* <intlayer-content-selector>
|
|
14
|
+
*
|
|
15
|
+
* A framework-agnostic web component that wraps content with Intlayer editor
|
|
16
|
+
* selection UI (hover outline, long-press to select, click-outside to deselect).
|
|
17
|
+
*
|
|
18
|
+
* Replaces the per-framework ContentSelector components (React, Svelte, Vue, Solid).
|
|
19
|
+
*
|
|
20
|
+
* @fires intlayer:press - Fired after a long press (pressDuration ms). Bubbles.
|
|
21
|
+
* @fires intlayer:hover - Fired on mouseenter. Bubbles.
|
|
22
|
+
* @fires intlayer:unhover - Fired on mouseleave / mouseup. Bubbles.
|
|
23
|
+
* @fires intlayer:click-outside - Fired when a click occurs outside the element. Bubbles.
|
|
24
|
+
*
|
|
25
|
+
* @prop {boolean} isSelecting - Whether this element is currently selected (external state)
|
|
26
|
+
* @prop {number} pressDuration - Long-press threshold in ms. Default: 250
|
|
27
|
+
*/
|
|
28
|
+
var IntlayerContentSelectorElement = class extends lit.LitElement {
|
|
29
|
+
constructor(..._args) {
|
|
30
|
+
super(..._args);
|
|
31
|
+
this.isSelecting = false;
|
|
32
|
+
this.pressDuration = DEFAULT_PRESS_DURATION;
|
|
33
|
+
this._isHovered = false;
|
|
34
|
+
this._isSelectingState = false;
|
|
35
|
+
this._pressTimer = null;
|
|
36
|
+
this._clickOutsideHandler = null;
|
|
37
|
+
}
|
|
38
|
+
static {
|
|
39
|
+
this.styles = lit.css`
|
|
40
|
+
:host {
|
|
41
|
+
display: contents;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.wrapper {
|
|
45
|
+
display: inline-block;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
user-select: none;
|
|
48
|
+
border-radius: 0.375rem;
|
|
49
|
+
outline-width: 2px;
|
|
50
|
+
outline-offset: 4px;
|
|
51
|
+
outline-style: solid;
|
|
52
|
+
outline-color: transparent;
|
|
53
|
+
transition: all 100ms 50ms ease-in-out;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.wrapper[data-active] {
|
|
57
|
+
outline-color: inherit;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
connectedCallback() {
|
|
62
|
+
super.connectedCallback();
|
|
63
|
+
this._clickOutsideHandler = (e) => {
|
|
64
|
+
if (!e.composedPath().includes(this)) {
|
|
65
|
+
this._isSelectingState = false;
|
|
66
|
+
this._dispatch("intlayer:click-outside");
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
document.addEventListener("mousedown", this._clickOutsideHandler);
|
|
70
|
+
}
|
|
71
|
+
disconnectedCallback() {
|
|
72
|
+
super.disconnectedCallback();
|
|
73
|
+
if (this._clickOutsideHandler) {
|
|
74
|
+
document.removeEventListener("mousedown", this._clickOutsideHandler);
|
|
75
|
+
this._clickOutsideHandler = null;
|
|
76
|
+
}
|
|
77
|
+
this._clearPressTimer();
|
|
78
|
+
}
|
|
79
|
+
_clearPressTimer() {
|
|
80
|
+
if (this._pressTimer !== null) {
|
|
81
|
+
clearTimeout(this._pressTimer);
|
|
82
|
+
this._pressTimer = null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
_dispatch(eventName) {
|
|
86
|
+
this.dispatchEvent(new CustomEvent(eventName, {
|
|
87
|
+
bubbles: true,
|
|
88
|
+
composed: true
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
_handleMouseDown() {
|
|
92
|
+
this._clearPressTimer();
|
|
93
|
+
this._pressTimer = setTimeout(() => {
|
|
94
|
+
this._isSelectingState = true;
|
|
95
|
+
this._dispatch("intlayer:press");
|
|
96
|
+
}, this.pressDuration);
|
|
97
|
+
}
|
|
98
|
+
_handleMouseEnter() {
|
|
99
|
+
this._isHovered = true;
|
|
100
|
+
this._dispatch("intlayer:hover");
|
|
101
|
+
}
|
|
102
|
+
_handleMouseUpOrLeave() {
|
|
103
|
+
if (this._isHovered) {
|
|
104
|
+
this._isHovered = false;
|
|
105
|
+
this._dispatch("intlayer:unhover");
|
|
106
|
+
}
|
|
107
|
+
this._clearPressTimer();
|
|
108
|
+
}
|
|
109
|
+
_handleClick(e) {
|
|
110
|
+
if (this.isSelecting || this._isSelectingState) {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
e.stopPropagation();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
_handleBlur() {
|
|
116
|
+
this._isSelectingState = false;
|
|
117
|
+
}
|
|
118
|
+
render() {
|
|
119
|
+
return lit.html`
|
|
120
|
+
<span
|
|
121
|
+
class="wrapper"
|
|
122
|
+
?data-active=${this.isSelecting || this._isSelectingState || this._isHovered}
|
|
123
|
+
role="button"
|
|
124
|
+
tabindex="0"
|
|
125
|
+
@mousedown=${this._handleMouseDown}
|
|
126
|
+
@mouseup=${this._handleMouseUpOrLeave}
|
|
127
|
+
@mouseleave=${this._handleMouseUpOrLeave}
|
|
128
|
+
@mouseenter=${this._handleMouseEnter}
|
|
129
|
+
@click=${this._handleClick}
|
|
130
|
+
@touchstart=${this._handleMouseDown}
|
|
131
|
+
@touchend=${this._handleMouseUpOrLeave}
|
|
132
|
+
@touchcancel=${this._handleMouseUpOrLeave}
|
|
133
|
+
@blur=${this._handleBlur}
|
|
134
|
+
@keyup=${() => {}}
|
|
135
|
+
>
|
|
136
|
+
<slot></slot>
|
|
137
|
+
</span>
|
|
138
|
+
`;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
require_decorate.__decorate([(0, lit_decorators_js.property)({
|
|
142
|
+
type: Boolean,
|
|
143
|
+
attribute: "is-selecting"
|
|
144
|
+
})], IntlayerContentSelectorElement.prototype, "isSelecting", void 0);
|
|
145
|
+
require_decorate.__decorate([(0, lit_decorators_js.property)({
|
|
146
|
+
type: Number,
|
|
147
|
+
attribute: "press-duration"
|
|
148
|
+
})], IntlayerContentSelectorElement.prototype, "pressDuration", void 0);
|
|
149
|
+
require_decorate.__decorate([(0, lit_decorators_js.state)()], IntlayerContentSelectorElement.prototype, "_isHovered", void 0);
|
|
150
|
+
require_decorate.__decorate([(0, lit_decorators_js.state)()], IntlayerContentSelectorElement.prototype, "_isSelectingState", void 0);
|
|
151
|
+
require_decorate.__decorate([(0, lit_decorators_js.query)(".wrapper")], IntlayerContentSelectorElement.prototype, "_wrapper", void 0);
|
|
152
|
+
/**
|
|
153
|
+
* Register all Intlayer custom elements.
|
|
154
|
+
* Call this once at application startup (inside IntlayerEditorProvider or similar).
|
|
155
|
+
* Safe to call multiple times — only registers elements that are not yet defined.
|
|
156
|
+
*/
|
|
157
|
+
const defineIntlayerElements = () => {
|
|
158
|
+
if (typeof customElements === "undefined") return;
|
|
159
|
+
if (!customElements.get("intlayer-content-selector")) customElements.define("intlayer-content-selector", IntlayerContentSelectorElement);
|
|
160
|
+
require_components_ContentSelectorWrapper.defineIntlayerContentSelectorWrapper();
|
|
161
|
+
require_components_EditedContent.defineIntlayerEditedContent();
|
|
162
|
+
require_components_IntlayerEditor.defineIntlayerEditorElement();
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
//#endregion
|
|
166
|
+
exports.IntlayerContentSelectorElement = IntlayerContentSelectorElement;
|
|
167
|
+
exports.defineIntlayerElements = defineIntlayerElements;
|
|
168
|
+
//# sourceMappingURL=ContentSelector.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentSelector.cjs","names":["LitElement"],"sources":["../../../src/components/ContentSelector.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { defineIntlayerContentSelectorWrapper } from './ContentSelectorWrapper';\nimport { defineIntlayerEditedContent } from './EditedContent';\nimport { defineIntlayerEditorElement } from './IntlayerEditor';\n\nconst DEFAULT_PRESS_DURATION = 250;\n\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 * Replaces the per-framework ContentSelector components (React, Svelte, Vue, Solid).\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 */\nexport class IntlayerContentSelectorElement extends LitElement {\n static styles = css`\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 `;\n\n @property({ type: Boolean, attribute: 'is-selecting' })\n isSelecting = false;\n\n @property({ type: Number, attribute: 'press-duration' })\n pressDuration = DEFAULT_PRESS_DURATION;\n\n @state() private _isHovered = false;\n @state() private _isSelectingState = false;\n\n @query('.wrapper') private _wrapper!: HTMLSpanElement;\n\n private _pressTimer: ReturnType<typeof setTimeout> | null = null;\n private _clickOutsideHandler: ((e: MouseEvent) => void) | null = null;\n\n connectedCallback(): void {\n super.connectedCallback();\n this._clickOutsideHandler = (e: MouseEvent) => {\n // composedPath() pierces shadow boundaries\n if (!e.composedPath().includes(this)) {\n this._isSelectingState = false;\n this._dispatch('intlayer:click-outside');\n }\n };\n document.addEventListener('mousedown', this._clickOutsideHandler);\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this._clickOutsideHandler) {\n document.removeEventListener('mousedown', this._clickOutsideHandler);\n this._clickOutsideHandler = null;\n }\n this._clearPressTimer();\n }\n\n private _clearPressTimer(): void {\n if (this._pressTimer !== null) {\n clearTimeout(this._pressTimer);\n this._pressTimer = null;\n }\n }\n\n private _dispatch(eventName: string): void {\n this.dispatchEvent(\n new CustomEvent(eventName, { bubbles: true, composed: true })\n );\n }\n\n private _handleMouseDown(): void {\n this._clearPressTimer();\n this._pressTimer = setTimeout(() => {\n this._isSelectingState = true;\n this._dispatch('intlayer:press');\n }, this.pressDuration);\n }\n\n private _handleMouseEnter(): void {\n this._isHovered = true;\n this._dispatch('intlayer:hover');\n }\n\n private _handleMouseUpOrLeave(): void {\n if (this._isHovered) {\n this._isHovered = false;\n this._dispatch('intlayer:unhover');\n }\n this._clearPressTimer();\n }\n\n private _handleClick(e: MouseEvent): void {\n if (this.isSelecting || this._isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n }\n\n private _handleBlur(): void {\n this._isSelectingState = false;\n }\n\n render() {\n const isActive =\n this.isSelecting || this._isSelectingState || this._isHovered;\n return html`\n <span\n class=\"wrapper\"\n ?data-active=${isActive}\n role=\"button\"\n tabindex=\"0\"\n @mousedown=${this._handleMouseDown}\n @mouseup=${this._handleMouseUpOrLeave}\n @mouseleave=${this._handleMouseUpOrLeave}\n @mouseenter=${this._handleMouseEnter}\n @click=${this._handleClick}\n @touchstart=${this._handleMouseDown}\n @touchend=${this._handleMouseUpOrLeave}\n @touchcancel=${this._handleMouseUpOrLeave}\n @blur=${this._handleBlur}\n @keyup=${() => {}}\n >\n <slot></slot>\n </span>\n `;\n }\n}\n\n/**\n * Register all Intlayer custom elements.\n * Call this once at application startup (inside IntlayerEditorProvider or similar).\n * Safe to call multiple times — only registers elements that are not yet defined.\n */\nexport const defineIntlayerElements = (): void => {\n if (typeof customElements === 'undefined') return;\n if (!customElements.get('intlayer-content-selector')) {\n customElements.define(\n 'intlayer-content-selector',\n IntlayerContentSelectorElement\n );\n }\n defineIntlayerContentSelectorWrapper();\n defineIntlayerEditedContent();\n defineIntlayerEditorElement();\n};\n"],"mappings":";;;;;;;;;;AAMA,MAAM,yBAAyB;;;;;;;;;;;;;;;;;AAkB/B,IAAa,iCAAb,cAAoDA,eAAW;;;qBAwB/C;uBAGE;oBAEc;2BACO;qBAIuB;8BACK;;;gBAlCjD,OAAG;;;;;;;;;;;;;;;;;;;;;;CAoCnB,oBAA0B;AACxB,QAAM,mBAAmB;AACzB,OAAK,wBAAwB,MAAkB;AAE7C,OAAI,CAAC,EAAE,cAAc,CAAC,SAAS,KAAK,EAAE;AACpC,SAAK,oBAAoB;AACzB,SAAK,UAAU,yBAAyB;;;AAG5C,WAAS,iBAAiB,aAAa,KAAK,qBAAqB;;CAGnE,uBAA6B;AAC3B,QAAM,sBAAsB;AAC5B,MAAI,KAAK,sBAAsB;AAC7B,YAAS,oBAAoB,aAAa,KAAK,qBAAqB;AACpE,QAAK,uBAAuB;;AAE9B,OAAK,kBAAkB;;CAGzB,AAAQ,mBAAyB;AAC/B,MAAI,KAAK,gBAAgB,MAAM;AAC7B,gBAAa,KAAK,YAAY;AAC9B,QAAK,cAAc;;;CAIvB,AAAQ,UAAU,WAAyB;AACzC,OAAK,cACH,IAAI,YAAY,WAAW;GAAE,SAAS;GAAM,UAAU;GAAM,CAAC,CAC9D;;CAGH,AAAQ,mBAAyB;AAC/B,OAAK,kBAAkB;AACvB,OAAK,cAAc,iBAAiB;AAClC,QAAK,oBAAoB;AACzB,QAAK,UAAU,iBAAiB;KAC/B,KAAK,cAAc;;CAGxB,AAAQ,oBAA0B;AAChC,OAAK,aAAa;AAClB,OAAK,UAAU,iBAAiB;;CAGlC,AAAQ,wBAA8B;AACpC,MAAI,KAAK,YAAY;AACnB,QAAK,aAAa;AAClB,QAAK,UAAU,mBAAmB;;AAEpC,OAAK,kBAAkB;;CAGzB,AAAQ,aAAa,GAAqB;AACxC,MAAI,KAAK,eAAe,KAAK,mBAAmB;AAC9C,KAAE,gBAAgB;AAClB,KAAE,iBAAiB;;;CAIvB,AAAQ,cAAoB;AAC1B,OAAK,oBAAoB;;CAG3B,SAAS;AAGP,SAAO,QAAI;;;uBADT,KAAK,eAAe,KAAK,qBAAqB,KAAK,WAIzB;;;qBAGX,KAAK,iBAAiB;mBACxB,KAAK,sBAAsB;sBACxB,KAAK,sBAAsB;sBAC3B,KAAK,kBAAkB;iBAC5B,KAAK,aAAa;sBACb,KAAK,iBAAiB;oBACxB,KAAK,sBAAsB;uBACxB,KAAK,sBAAsB;gBAClC,KAAK,YAAY;uBACV,GAAG;;;;;;;6DAlGd;CAAE,MAAM;CAAS,WAAW;CAAgB,CAAC;6DAG7C;CAAE,MAAM;CAAQ,WAAW;CAAkB,CAAC;2DAGhD;2DACA;0DAED,WAAW;;;;;;AAsGpB,MAAa,+BAAqC;AAChD,KAAI,OAAO,mBAAmB,YAAa;AAC3C,KAAI,CAAC,eAAe,IAAI,4BAA4B,CAClD,gBAAe,OACb,6BACA,+BACD;AAEH,iFAAsC;AACtC,+DAA6B;AAC7B,gEAA6B"}
|
|
@@ -1,15 +1,204 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_messageKey = require('../messageKey.cjs');
|
|
4
|
+
const require_core_globalManager = require('../core/globalManager.cjs');
|
|
5
|
+
const require_decorate = require('../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs');
|
|
6
|
+
let lit = require("lit");
|
|
7
|
+
let lit_decorators_js = require("lit/decorators.js");
|
|
8
|
+
let _intlayer_core_utils = require("@intlayer/core/utils");
|
|
9
|
+
let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
|
|
10
|
+
_intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType);
|
|
11
|
+
|
|
12
|
+
//#region src/components/ContentSelectorWrapper.ts
|
|
13
|
+
/**
|
|
14
|
+
* <intlayer-content-selector-wrapper>
|
|
15
|
+
*
|
|
16
|
+
* Framework-agnostic Lit element that wraps content with the Intlayer editor
|
|
17
|
+
* selection UI. It replaces the per-framework ContentSelectorWrapper components
|
|
18
|
+
* (Vue, Svelte, Solid, Preact).
|
|
19
|
+
*
|
|
20
|
+
* It reads from the global EditorStateManager singleton (set by initEditorClient)
|
|
21
|
+
* and conditionally renders <intlayer-content-selector> around its slot content
|
|
22
|
+
* when the editor is active and the app is running inside an iframe.
|
|
23
|
+
*
|
|
24
|
+
* @attr {string} key-path - JSON-serialized KeyPath[] for this content node
|
|
25
|
+
* @attr {string} dictionary-key - The dictionary key owning this content node
|
|
26
|
+
*/
|
|
27
|
+
var IntlayerContentSelectorWrapperElement = class extends lit.LitElement {
|
|
28
|
+
constructor(..._args) {
|
|
29
|
+
super(..._args);
|
|
30
|
+
this.keyPathJson = "[]";
|
|
31
|
+
this.dictionaryKey = "";
|
|
32
|
+
this._editorEnabled = false;
|
|
33
|
+
this._isInIframe = false;
|
|
34
|
+
this._isSelected = false;
|
|
35
|
+
this._editedValue = void 0;
|
|
36
|
+
this._unsubManager = null;
|
|
37
|
+
this._unsubEnabled = null;
|
|
38
|
+
this._unsubFocused = null;
|
|
39
|
+
this._unsubEditedContent = null;
|
|
40
|
+
}
|
|
41
|
+
static {
|
|
42
|
+
this.styles = lit.css`
|
|
2
43
|
:host {
|
|
3
44
|
display: contents;
|
|
4
45
|
}
|
|
5
|
-
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
connectedCallback() {
|
|
49
|
+
super.connectedCallback();
|
|
50
|
+
if (typeof window !== "undefined") this._isInIframe = window.self !== window.top;
|
|
51
|
+
this._subscribeToManager();
|
|
52
|
+
}
|
|
53
|
+
disconnectedCallback() {
|
|
54
|
+
super.disconnectedCallback();
|
|
55
|
+
this._teardown();
|
|
56
|
+
}
|
|
57
|
+
updated(changedProperties) {
|
|
58
|
+
if (changedProperties.has("keyPathJson") || changedProperties.has("dictionaryKey")) {
|
|
59
|
+
const manager = require_core_globalManager.getGlobalEditorManager();
|
|
60
|
+
if (manager) this._updateEditedValue(manager);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
_teardown() {
|
|
64
|
+
this._unsubManager?.();
|
|
65
|
+
this._unsubEnabled?.();
|
|
66
|
+
this._unsubFocused?.();
|
|
67
|
+
this._unsubEditedContent?.();
|
|
68
|
+
this._unsubManager = null;
|
|
69
|
+
this._unsubEnabled = null;
|
|
70
|
+
this._unsubFocused = null;
|
|
71
|
+
this._unsubEditedContent = null;
|
|
72
|
+
}
|
|
73
|
+
_subscribeToManager() {
|
|
74
|
+
const manager = require_core_globalManager.getGlobalEditorManager();
|
|
75
|
+
if (manager) this._setupManagerSubscriptions(manager);
|
|
76
|
+
this._unsubManager = require_core_globalManager.onGlobalEditorManagerChange((m) => {
|
|
77
|
+
this._unsubEnabled?.();
|
|
78
|
+
this._unsubFocused?.();
|
|
79
|
+
this._unsubEditedContent?.();
|
|
80
|
+
this._unsubEnabled = null;
|
|
81
|
+
this._unsubFocused = null;
|
|
82
|
+
this._unsubEditedContent = null;
|
|
83
|
+
if (m) this._setupManagerSubscriptions(m);
|
|
84
|
+
else {
|
|
85
|
+
this._editorEnabled = false;
|
|
86
|
+
this._isSelected = false;
|
|
87
|
+
this._editedValue = void 0;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
_setupManagerSubscriptions(manager) {
|
|
92
|
+
this._editorEnabled = manager.editorEnabled.value ?? false;
|
|
93
|
+
this._updateIsSelected(manager.focusedContent.value);
|
|
94
|
+
this._updateEditedValue(manager);
|
|
95
|
+
const handleEnabledChange = (e) => {
|
|
96
|
+
this._editorEnabled = e.detail;
|
|
97
|
+
};
|
|
98
|
+
const handleFocusedChange = (e) => {
|
|
99
|
+
this._updateIsSelected(e.detail);
|
|
100
|
+
};
|
|
101
|
+
const handleEditedContentChange = () => {
|
|
102
|
+
this._updateEditedValue(manager);
|
|
103
|
+
};
|
|
104
|
+
manager.editorEnabled.addEventListener("change", handleEnabledChange);
|
|
105
|
+
manager.focusedContent.addEventListener("change", handleFocusedChange);
|
|
106
|
+
manager.editedContent.addEventListener("change", handleEditedContentChange);
|
|
107
|
+
this._unsubEnabled = () => manager.editorEnabled.removeEventListener("change", handleEnabledChange);
|
|
108
|
+
this._unsubFocused = () => manager.focusedContent.removeEventListener("change", handleFocusedChange);
|
|
109
|
+
this._unsubEditedContent = () => manager.editedContent.removeEventListener("change", handleEditedContentChange);
|
|
110
|
+
}
|
|
111
|
+
_getRawKeyPath() {
|
|
112
|
+
try {
|
|
113
|
+
return JSON.parse(this.keyPathJson);
|
|
114
|
+
} catch {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
_getFilteredKeyPath() {
|
|
119
|
+
return this._getRawKeyPath().filter((k) => k.type !== _intlayer_types_nodeType.TRANSLATION);
|
|
120
|
+
}
|
|
121
|
+
_updateEditedValue(manager) {
|
|
122
|
+
const filteredKeyPath = this._getFilteredKeyPath();
|
|
123
|
+
if (!this.dictionaryKey || filteredKeyPath.length === 0) {
|
|
124
|
+
this._editedValue = void 0;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const rawKeyPath = this._getRawKeyPath();
|
|
128
|
+
const lastStepType = rawKeyPath[rawKeyPath.length - 1]?.type;
|
|
129
|
+
if (lastStepType === _intlayer_types_nodeType.MARKDOWN || lastStepType === _intlayer_types_nodeType.HTML || lastStepType === _intlayer_types_nodeType.INSERTION || lastStepType === _intlayer_types_nodeType.FILE) {
|
|
130
|
+
this._editedValue = void 0;
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
let value = manager.getContentValue(this.dictionaryKey, filteredKeyPath);
|
|
134
|
+
if (value !== null && value !== void 0 && typeof value === "object" && value.nodeType === _intlayer_types_nodeType.TRANSLATION) {
|
|
135
|
+
const locale = manager.currentLocale.value;
|
|
136
|
+
value = locale ? value[_intlayer_types_nodeType.TRANSLATION][locale] : void 0;
|
|
137
|
+
}
|
|
138
|
+
this._editedValue = value;
|
|
139
|
+
}
|
|
140
|
+
_updateIsSelected(focusedContent) {
|
|
141
|
+
if (!focusedContent) {
|
|
142
|
+
this._isSelected = false;
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const keyPath = this._getFilteredKeyPath();
|
|
146
|
+
this._isSelected = focusedContent.dictionaryKey === this.dictionaryKey && (focusedContent.keyPath?.length ?? 0) > 0 && (0, _intlayer_core_utils.isSameKeyPath)(focusedContent.keyPath ?? [], keyPath);
|
|
147
|
+
}
|
|
148
|
+
_handlePress(e) {
|
|
149
|
+
e.stopPropagation();
|
|
150
|
+
const manager = require_core_globalManager.getGlobalEditorManager();
|
|
151
|
+
if (!manager) return;
|
|
152
|
+
manager.focusedContent.set({
|
|
153
|
+
dictionaryKey: this.dictionaryKey,
|
|
154
|
+
keyPath: this._getFilteredKeyPath()
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
_handleHover(e) {
|
|
158
|
+
e.stopPropagation();
|
|
159
|
+
require_core_globalManager.getGlobalEditorManager()?.messenger.send(`${require_messageKey.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`, {
|
|
160
|
+
dictionaryKey: this.dictionaryKey,
|
|
161
|
+
keyPath: this._getFilteredKeyPath()
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
_handleUnhover(e) {
|
|
165
|
+
e.stopPropagation();
|
|
166
|
+
require_core_globalManager.getGlobalEditorManager()?.messenger.send(`${require_messageKey.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`, null);
|
|
167
|
+
}
|
|
168
|
+
render() {
|
|
169
|
+
if (!this._isInIframe || !this._editorEnabled) return lit.html`<slot></slot>`;
|
|
170
|
+
const editedValue = this._editedValue;
|
|
171
|
+
const displayedContent = typeof editedValue === "string" || typeof editedValue === "number" || typeof editedValue === "boolean" ? editedValue : lit.html`<slot></slot>`;
|
|
172
|
+
return lit.html`
|
|
6
173
|
<intlayer-content-selector
|
|
7
174
|
?is-selecting=${this._isSelected}
|
|
8
175
|
@intlayer:press=${this._handlePress}
|
|
9
176
|
@intlayer:hover=${this._handleHover}
|
|
10
177
|
@intlayer:unhover=${this._handleUnhover}
|
|
11
178
|
>
|
|
12
|
-
${
|
|
179
|
+
${displayedContent}
|
|
13
180
|
</intlayer-content-selector>
|
|
14
|
-
|
|
181
|
+
`;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
require_decorate.__decorate([(0, lit_decorators_js.property)({
|
|
185
|
+
type: String,
|
|
186
|
+
attribute: "key-path"
|
|
187
|
+
})], IntlayerContentSelectorWrapperElement.prototype, "keyPathJson", void 0);
|
|
188
|
+
require_decorate.__decorate([(0, lit_decorators_js.property)({
|
|
189
|
+
type: String,
|
|
190
|
+
attribute: "dictionary-key"
|
|
191
|
+
})], IntlayerContentSelectorWrapperElement.prototype, "dictionaryKey", void 0);
|
|
192
|
+
require_decorate.__decorate([(0, lit_decorators_js.state)()], IntlayerContentSelectorWrapperElement.prototype, "_editorEnabled", void 0);
|
|
193
|
+
require_decorate.__decorate([(0, lit_decorators_js.state)()], IntlayerContentSelectorWrapperElement.prototype, "_isInIframe", void 0);
|
|
194
|
+
require_decorate.__decorate([(0, lit_decorators_js.state)()], IntlayerContentSelectorWrapperElement.prototype, "_isSelected", void 0);
|
|
195
|
+
require_decorate.__decorate([(0, lit_decorators_js.state)()], IntlayerContentSelectorWrapperElement.prototype, "_editedValue", void 0);
|
|
196
|
+
const defineIntlayerContentSelectorWrapper = () => {
|
|
197
|
+
if (typeof customElements === "undefined") return;
|
|
198
|
+
if (!customElements.get("intlayer-content-selector-wrapper")) customElements.define("intlayer-content-selector-wrapper", IntlayerContentSelectorWrapperElement);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
exports.IntlayerContentSelectorWrapperElement = IntlayerContentSelectorWrapperElement;
|
|
203
|
+
exports.defineIntlayerContentSelectorWrapper = defineIntlayerContentSelectorWrapper;
|
|
15
204
|
//# sourceMappingURL=ContentSelectorWrapper.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelectorWrapper.cjs","names":["LitElement","getGlobalEditorManager","onGlobalEditorManagerChange","NodeType","MessageKey"],"sources":["../../../src/components/ContentSelectorWrapper.ts"],"sourcesContent":["import { isSameKeyPath } from '@intlayer/core/utils';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { NodeType, type TypedNodeModel } from '@intlayer/types/nodeType';\nimport { css, html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport type {\n EditorStateManager,\n FileContent,\n} from '../core/EditorStateManager';\nimport {\n getGlobalEditorManager,\n onGlobalEditorManagerChange,\n} from '../core/globalManager';\nimport { MessageKey } from '../messageKey';\n\n/**\n * <intlayer-content-selector-wrapper>\n *\n * Framework-agnostic Lit element 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 */\nexport class IntlayerContentSelectorWrapperElement extends LitElement {\n static styles = css`\n :host {\n display: contents;\n }\n `;\n\n @property({ type: String, attribute: 'key-path' }) keyPathJson = '[]';\n @property({ type: String, attribute: 'dictionary-key' }) dictionaryKey = '';\n\n @state() private _editorEnabled = false;\n @state() private _isInIframe = false;\n @state() private _isSelected = false;\n @state() private _editedValue: ContentNode | undefined = undefined;\n\n private _unsubManager: (() => void) | null = null;\n private _unsubEnabled: (() => void) | null = null;\n private _unsubFocused: (() => void) | null = null;\n private _unsubEditedContent: (() => void) | null = null;\n\n connectedCallback(): void {\n super.connectedCallback();\n if (typeof window !== 'undefined') {\n this._isInIframe = window.self !== window.top;\n }\n this._subscribeToManager();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this._teardown();\n }\n\n updated(changedProperties: Map<string, unknown>): void {\n if (\n changedProperties.has('keyPathJson') ||\n changedProperties.has('dictionaryKey')\n ) {\n const manager = getGlobalEditorManager();\n if (manager) this._updateEditedValue(manager);\n }\n }\n\n private _teardown(): void {\n this._unsubManager?.();\n this._unsubEnabled?.();\n this._unsubFocused?.();\n this._unsubEditedContent?.();\n this._unsubManager = null;\n this._unsubEnabled = null;\n this._unsubFocused = null;\n this._unsubEditedContent = null;\n }\n\n private _subscribeToManager(): void {\n const manager = getGlobalEditorManager();\n if (manager) {\n this._setupManagerSubscriptions(manager);\n }\n // Keep listening for manager changes (handles stop + re-init cycles)\n this._unsubManager = onGlobalEditorManagerChange((m) => {\n this._unsubEnabled?.();\n this._unsubFocused?.();\n this._unsubEditedContent?.();\n this._unsubEnabled = null;\n this._unsubFocused = null;\n this._unsubEditedContent = null;\n if (m) {\n this._setupManagerSubscriptions(m);\n } else {\n this._editorEnabled = false;\n this._isSelected = false;\n this._editedValue = undefined;\n }\n });\n }\n\n private _setupManagerSubscriptions(manager: EditorStateManager): void {\n this._editorEnabled = manager.editorEnabled.value ?? false;\n this._updateIsSelected(manager.focusedContent.value);\n this._updateEditedValue(manager);\n\n const handleEnabledChange = (e: Event) => {\n this._editorEnabled = (e as CustomEvent<boolean>).detail;\n };\n const handleFocusedChange = (e: Event) => {\n this._updateIsSelected((e as CustomEvent<FileContent | null>).detail);\n };\n const handleEditedContentChange = () => {\n this._updateEditedValue(manager);\n };\n\n manager.editorEnabled.addEventListener('change', handleEnabledChange);\n manager.focusedContent.addEventListener('change', handleFocusedChange);\n manager.editedContent.addEventListener('change', handleEditedContentChange);\n\n this._unsubEnabled = () =>\n manager.editorEnabled.removeEventListener('change', handleEnabledChange);\n this._unsubFocused = () =>\n manager.focusedContent.removeEventListener('change', handleFocusedChange);\n this._unsubEditedContent = () =>\n manager.editedContent.removeEventListener(\n 'change',\n handleEditedContentChange\n );\n }\n\n private _getRawKeyPath(): KeyPath[] {\n try {\n return JSON.parse(this.keyPathJson) as KeyPath[];\n } catch {\n return [];\n }\n }\n\n private _getFilteredKeyPath(): KeyPath[] {\n return this._getRawKeyPath().filter((k) => k.type !== NodeType.Translation);\n }\n\n private _updateEditedValue(manager: EditorStateManager): void {\n const filteredKeyPath = this._getFilteredKeyPath();\n if (!this.dictionaryKey || filteredKeyPath.length === 0) {\n this._editedValue = undefined;\n return;\n }\n\n // Node types whose display requires framework-level rendering (markdown,\n // HTML, insertion, file): do not override the slot — the framework handles\n // those. Only plain / translated strings can be substituted here.\n const rawKeyPath = this._getRawKeyPath();\n const lastStepType = rawKeyPath[rawKeyPath.length - 1]?.type;\n if (\n lastStepType === NodeType.Markdown ||\n lastStepType === NodeType.HTML ||\n lastStepType === NodeType.Insertion ||\n lastStepType === NodeType.File\n ) {\n this._editedValue = undefined;\n return;\n }\n\n let value = manager.getContentValue(this.dictionaryKey, filteredKeyPath);\n\n // getContentNodeByKeyPath resolves translation nodes only at intermediate\n // steps, not the final leaf. Resolve manually when the returned value is\n // still a translation object (happens when Translation steps are filtered\n // out and the leaf IS the translation object).\n if (\n value !== null &&\n value !== undefined &&\n typeof value === 'object' &&\n value.nodeType === NodeType.Translation\n ) {\n const locale = manager.currentLocale.value as string | undefined;\n // TypedNodeModel<Translation, …> structurally satisfies TypedNode<BaseNode>\n // (both have nodeType), so this narrowing cast is sound.\n const node = value as TypedNodeModel<\n typeof NodeType.Translation,\n Record<string, ContentNode>\n >;\n value = locale ? node[NodeType.Translation][locale] : undefined;\n }\n\n this._editedValue = value;\n }\n\n private _updateIsSelected(\n focusedContent: FileContent | null | undefined\n ): void {\n if (!focusedContent) {\n this._isSelected = false;\n return;\n }\n const keyPath = this._getFilteredKeyPath();\n this._isSelected =\n focusedContent.dictionaryKey === this.dictionaryKey &&\n (focusedContent.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent.keyPath ?? [], keyPath);\n }\n\n private _handlePress(e: Event): void {\n // Stop propagation so nested wrappers don't also fire (composed + bubbles)\n e.stopPropagation();\n const manager = getGlobalEditorManager();\n if (!manager) return;\n manager.focusedContent.set({\n dictionaryKey: this.dictionaryKey,\n keyPath: this._getFilteredKeyPath(),\n });\n }\n\n private _handleHover(e: Event): void {\n e.stopPropagation();\n getGlobalEditorManager()?.messenger.send(\n `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n { dictionaryKey: this.dictionaryKey, keyPath: this._getFilteredKeyPath() }\n );\n }\n\n private _handleUnhover(e: Event): void {\n e.stopPropagation();\n getGlobalEditorManager()?.messenger.send(\n `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n null\n );\n }\n\n render() {\n if (!this._isInIframe || !this._editorEnabled) {\n return html`<slot></slot>`;\n }\n\n const editedValue = this._editedValue;\n const displayedContent =\n typeof editedValue === 'string' ||\n typeof editedValue === 'number' ||\n typeof editedValue === 'boolean'\n ? editedValue\n : html`<slot></slot>`;\n\n return html`\n <intlayer-content-selector\n ?is-selecting=${this._isSelected}\n @intlayer:press=${this._handlePress}\n @intlayer:hover=${this._handleHover}\n @intlayer:unhover=${this._handleUnhover}\n >\n ${displayedContent}\n </intlayer-content-selector>\n `;\n }\n}\n\nexport const defineIntlayerContentSelectorWrapper = (): void => {\n if (typeof customElements === 'undefined') return;\n\n if (!customElements.get('intlayer-content-selector-wrapper')) {\n customElements.define(\n 'intlayer-content-selector-wrapper',\n IntlayerContentSelectorWrapperElement\n );\n }\n};\n"],"mappings":"kVA8BA,IAAa,EAAb,cAA2DA,EAAAA,UAAW,gDAOH,wBACQ,uBAEvC,oBACH,oBACA,qBAC0B,IAAA,sBAEZ,wBACA,wBACA,8BACM,wBAjBnC,EAAA,GAAG;;;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Element","getGlobalEditorManager","onGlobalEditorManagerChange","NodeTypes","MessageKey"],"sources":["../../../src/components/ContentSelectorWrapper.ts"],"sourcesContent":["import { isSameKeyPath } from '@intlayer/core/utils';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { css, html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport type {\n EditorStateManager,\n FileContent,\n} from '../core/EditorStateManager';\nimport {\n getGlobalEditorManager,\n onGlobalEditorManagerChange,\n} from '../core/globalManager';\nimport { MessageKey } from '../messageKey';\n\n/**\n * <intlayer-content-selector-wrapper>\n *\n * Framework-agnostic Lit element 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 */\nexport class IntlayerContentSelectorWrapperElement extends LitElement {\n static styles = css`\n :host {\n display: contents;\n }\n `;\n\n @property({ type: String, attribute: 'key-path' }) keyPathJson = '[]';\n @property({ type: String, attribute: 'dictionary-key' }) dictionaryKey = '';\n\n @state() private _editorEnabled = false;\n @state() private _isInIframe = false;\n @state() private _isSelected = false;\n @state() private _editedValue: ContentNode | undefined = undefined;\n\n private _unsubManager: (() => void) | null = null;\n private _unsubEnabled: (() => void) | null = null;\n private _unsubFocused: (() => void) | null = null;\n private _unsubEditedContent: (() => void) | null = null;\n\n connectedCallback(): void {\n super.connectedCallback();\n if (typeof window !== 'undefined') {\n this._isInIframe = window.self !== window.top;\n }\n this._subscribeToManager();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this._teardown();\n }\n\n updated(changedProperties: Map<string, unknown>): void {\n if (\n changedProperties.has('keyPathJson') ||\n changedProperties.has('dictionaryKey')\n ) {\n const manager = getGlobalEditorManager();\n if (manager) this._updateEditedValue(manager);\n }\n }\n\n private _teardown(): void {\n this._unsubManager?.();\n this._unsubEnabled?.();\n this._unsubFocused?.();\n this._unsubEditedContent?.();\n this._unsubManager = null;\n this._unsubEnabled = null;\n this._unsubFocused = null;\n this._unsubEditedContent = null;\n }\n\n private _subscribeToManager(): void {\n const manager = getGlobalEditorManager();\n if (manager) {\n this._setupManagerSubscriptions(manager);\n }\n // Keep listening for manager changes (handles stop + re-init cycles)\n this._unsubManager = onGlobalEditorManagerChange((m) => {\n this._unsubEnabled?.();\n this._unsubFocused?.();\n this._unsubEditedContent?.();\n this._unsubEnabled = null;\n this._unsubFocused = null;\n this._unsubEditedContent = null;\n if (m) {\n this._setupManagerSubscriptions(m);\n } else {\n this._editorEnabled = false;\n this._isSelected = false;\n this._editedValue = undefined;\n }\n });\n }\n\n private _setupManagerSubscriptions(manager: EditorStateManager): void {\n this._editorEnabled = manager.editorEnabled.value ?? false;\n this._updateIsSelected(manager.focusedContent.value);\n this._updateEditedValue(manager);\n\n const handleEnabledChange = (e: Event) => {\n this._editorEnabled = (e as CustomEvent<boolean>).detail;\n };\n const handleFocusedChange = (e: Event) => {\n this._updateIsSelected((e as CustomEvent<FileContent | null>).detail);\n };\n const handleEditedContentChange = () => {\n this._updateEditedValue(manager);\n };\n\n manager.editorEnabled.addEventListener('change', handleEnabledChange);\n manager.focusedContent.addEventListener('change', handleFocusedChange);\n manager.editedContent.addEventListener('change', handleEditedContentChange);\n\n this._unsubEnabled = () =>\n manager.editorEnabled.removeEventListener('change', handleEnabledChange);\n this._unsubFocused = () =>\n manager.focusedContent.removeEventListener('change', handleFocusedChange);\n this._unsubEditedContent = () =>\n manager.editedContent.removeEventListener(\n 'change',\n handleEditedContentChange\n );\n }\n\n private _getRawKeyPath(): KeyPath[] {\n try {\n return JSON.parse(this.keyPathJson) as KeyPath[];\n } catch {\n return [];\n }\n }\n\n private _getFilteredKeyPath(): KeyPath[] {\n return this._getRawKeyPath().filter(\n (k) => k.type !== NodeTypes.TRANSLATION\n );\n }\n\n private _updateEditedValue(manager: EditorStateManager): void {\n const filteredKeyPath = this._getFilteredKeyPath();\n if (!this.dictionaryKey || filteredKeyPath.length === 0) {\n this._editedValue = undefined;\n return;\n }\n\n // Node types whose display requires framework-level rendering (markdown,\n // HTML, insertion, file): do not override the slot — the framework handles\n // those. Only plain / translated strings can be substituted here.\n const rawKeyPath = this._getRawKeyPath();\n const lastStepType = rawKeyPath[rawKeyPath.length - 1]?.type;\n if (\n lastStepType === NodeTypes.MARKDOWN ||\n lastStepType === NodeTypes.HTML ||\n lastStepType === NodeTypes.INSERTION ||\n lastStepType === NodeTypes.FILE\n ) {\n this._editedValue = undefined;\n return;\n }\n\n let value = manager.getContentValue(this.dictionaryKey, filteredKeyPath);\n\n // getContentNodeByKeyPath resolves translation nodes only at intermediate\n // steps, not the final leaf. Resolve manually when the returned value is\n // still a translation object (happens when Translation steps are filtered\n // out and the leaf IS the translation object).\n if (\n value !== null &&\n value !== undefined &&\n typeof value === 'object' &&\n value.nodeType === NodeTypes.TRANSLATION\n ) {\n const locale = manager.currentLocale.value as string | undefined;\n // TypedNodeModel<Translation, …> structurally satisfies TypedNode<BaseNode>\n // (both have nodeType), so this narrowing cast is sound.\n const node = value as TypedNodeModel<\n typeof NodeTypes.TRANSLATION,\n Record<string, ContentNode>\n >;\n value = locale ? node[NodeTypes.TRANSLATION][locale] : undefined;\n }\n\n this._editedValue = value;\n }\n\n private _updateIsSelected(\n focusedContent: FileContent | null | undefined\n ): void {\n if (!focusedContent) {\n this._isSelected = false;\n return;\n }\n const keyPath = this._getFilteredKeyPath();\n this._isSelected =\n focusedContent.dictionaryKey === this.dictionaryKey &&\n (focusedContent.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent.keyPath ?? [], keyPath);\n }\n\n private _handlePress(e: Event): void {\n // Stop propagation so nested wrappers don't also fire (composed + bubbles)\n e.stopPropagation();\n const manager = getGlobalEditorManager();\n if (!manager) return;\n manager.focusedContent.set({\n dictionaryKey: this.dictionaryKey,\n keyPath: this._getFilteredKeyPath(),\n });\n }\n\n private _handleHover(e: Event): void {\n e.stopPropagation();\n getGlobalEditorManager()?.messenger.send(\n `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n { dictionaryKey: this.dictionaryKey, keyPath: this._getFilteredKeyPath() }\n );\n }\n\n private _handleUnhover(e: Event): void {\n e.stopPropagation();\n getGlobalEditorManager()?.messenger.send(\n `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n null\n );\n }\n\n render() {\n if (!this._isInIframe || !this._editorEnabled) {\n return html`<slot></slot>`;\n }\n\n const editedValue = this._editedValue;\n const displayedContent =\n typeof editedValue === 'string' ||\n typeof editedValue === 'number' ||\n typeof editedValue === 'boolean'\n ? editedValue\n : html`<slot></slot>`;\n\n return html`\n <intlayer-content-selector\n ?is-selecting=${this._isSelected}\n @intlayer:press=${this._handlePress}\n @intlayer:hover=${this._handleHover}\n @intlayer:unhover=${this._handleUnhover}\n >\n ${displayedContent}\n </intlayer-content-selector>\n `;\n }\n}\n\nexport const defineIntlayerContentSelectorWrapper = (): void => {\n if (typeof customElements === 'undefined') return;\n\n if (!customElements.get('intlayer-content-selector-wrapper')) {\n customElements.define(\n 'intlayer-content-selector-wrapper',\n IntlayerContentSelectorWrapperElement\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAa,wCAAb,cAA2DA,eAAW;;;qBAOH;uBACQ;wBAEvC;qBACH;qBACA;sBAC0B;uBAEZ;uBACA;uBACA;6BACM;;;gBAjBnC,OAAG;;;;;;CAmBnB,oBAA0B;AACxB,QAAM,mBAAmB;AACzB,MAAI,OAAO,WAAW,YACpB,MAAK,cAAc,OAAO,SAAS,OAAO;AAE5C,OAAK,qBAAqB;;CAG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