@intlayer/editor 8.4.4 → 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
package/dist/cjs/core/index.cjs
CHANGED
|
@@ -1 +1,20 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_core_globalManager = require('./globalManager.cjs');
|
|
3
|
+
const require_core_CrossFrameMessenger = require('./CrossFrameMessenger.cjs');
|
|
4
|
+
const require_core_CrossFrameStateManager = require('./CrossFrameStateManager.cjs');
|
|
5
|
+
const require_core_IframeClickInterceptor = require('./IframeClickInterceptor.cjs');
|
|
6
|
+
const require_core_UrlStateManager = require('./UrlStateManager.cjs');
|
|
7
|
+
const require_core_EditorStateManager = require('./EditorStateManager.cjs');
|
|
8
|
+
const require_core_initEditorClient = require('./initEditorClient.cjs');
|
|
9
|
+
|
|
10
|
+
exports.CrossFrameMessenger = require_core_CrossFrameMessenger.CrossFrameMessenger;
|
|
11
|
+
exports.CrossFrameStateManager = require_core_CrossFrameStateManager.CrossFrameStateManager;
|
|
12
|
+
exports.EditorStateManager = require_core_EditorStateManager.EditorStateManager;
|
|
13
|
+
exports.IframeClickInterceptor = require_core_IframeClickInterceptor.IframeClickInterceptor;
|
|
14
|
+
exports.UrlStateManager = require_core_UrlStateManager.UrlStateManager;
|
|
15
|
+
exports.buildClientMessengerConfig = require_core_initEditorClient.buildClientMessengerConfig;
|
|
16
|
+
exports.getGlobalEditorManager = require_core_globalManager.getGlobalEditorManager;
|
|
17
|
+
exports.initEditorClient = require_core_initEditorClient.initEditorClient;
|
|
18
|
+
exports.onGlobalEditorManagerChange = require_core_globalManager.onGlobalEditorManagerChange;
|
|
19
|
+
exports.setGlobalEditorManager = require_core_globalManager.setGlobalEditorManager;
|
|
20
|
+
exports.stopEditorClient = require_core_initEditorClient.stopEditorClient;
|
|
@@ -1 +1,58 @@
|
|
|
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_core_globalManager = require('./globalManager.cjs');
|
|
4
|
+
const require_core_EditorStateManager = require('./EditorStateManager.cjs');
|
|
5
|
+
const require_components_ContentSelector = require('../components/ContentSelector.cjs');
|
|
6
|
+
let _intlayer_config_built = require("@intlayer/config/built");
|
|
7
|
+
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
8
|
+
|
|
9
|
+
//#region src/core/initEditorClient.ts
|
|
10
|
+
const buildClientMessengerConfig = () => {
|
|
11
|
+
const { editor } = _intlayer_config_built.default ?? {};
|
|
12
|
+
return {
|
|
13
|
+
allowedOrigins: [editor?.editorURL, editor?.cmsURL].filter(Boolean),
|
|
14
|
+
postMessageFn: (payload, origin) => {
|
|
15
|
+
if (typeof window === "undefined") return;
|
|
16
|
+
if (!(window.self !== window.top)) return;
|
|
17
|
+
window.parent?.postMessage(payload, origin);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/** Reference count — tracks how many providers have called initEditorClient. */
|
|
22
|
+
let _clientRefCount = 0;
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the Intlayer editor client singleton.
|
|
25
|
+
* Safe to call multiple times — returns the existing manager if already initialized.
|
|
26
|
+
* Increments a reference counter so nested providers don't destroy the manager
|
|
27
|
+
* prematurely when the inner provider unmounts.
|
|
28
|
+
*/
|
|
29
|
+
const initEditorClient = () => {
|
|
30
|
+
_clientRefCount++;
|
|
31
|
+
const existing = require_core_globalManager.getGlobalEditorManager();
|
|
32
|
+
if (existing) return existing;
|
|
33
|
+
const manager = new require_core_EditorStateManager.EditorStateManager({
|
|
34
|
+
mode: "client",
|
|
35
|
+
messenger: buildClientMessengerConfig(),
|
|
36
|
+
configuration: _intlayer_config_built.default
|
|
37
|
+
});
|
|
38
|
+
require_core_globalManager.setGlobalEditorManager(manager);
|
|
39
|
+
require_components_ContentSelector.defineIntlayerElements();
|
|
40
|
+
manager.start();
|
|
41
|
+
return manager;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Decrement the reference count and stop the global editor client singleton
|
|
45
|
+
* only when the last provider unmounts.
|
|
46
|
+
*/
|
|
47
|
+
const stopEditorClient = () => {
|
|
48
|
+
_clientRefCount = Math.max(0, _clientRefCount - 1);
|
|
49
|
+
if (_clientRefCount > 0) return;
|
|
50
|
+
require_core_globalManager.getGlobalEditorManager()?.stop();
|
|
51
|
+
require_core_globalManager.setGlobalEditorManager(null);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
exports.buildClientMessengerConfig = buildClientMessengerConfig;
|
|
56
|
+
exports.initEditorClient = initEditorClient;
|
|
57
|
+
exports.stopEditorClient = stopEditorClient;
|
|
58
|
+
//# sourceMappingURL=initEditorClient.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initEditorClient.cjs","names":["configuration","getGlobalEditorManager","EditorStateManager"],"sources":["../../../src/core/initEditorClient.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { defineIntlayerElements } from '../components';\nimport type { MessengerConfig } from './CrossFrameMessenger';\nimport { EditorStateManager } from './EditorStateManager';\nimport {\n getGlobalEditorManager,\n setGlobalEditorManager,\n} from './globalManager';\n\nexport const buildClientMessengerConfig = (): MessengerConfig => {\n const { editor } = configuration ?? {};\n\n return {\n allowedOrigins: [editor?.editorURL, editor?.cmsURL].filter(\n Boolean\n ) as string[],\n postMessageFn: (payload: unknown, origin: string) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n\n if (!isInIframe) return;\n window.parent?.postMessage(payload, origin);\n },\n };\n};\n\n/** Reference count — tracks how many providers have called initEditorClient. */\nlet _clientRefCount = 0;\n\n/**\n * Initialize the Intlayer editor client singleton.\n * Safe to call multiple times — returns the existing manager if already initialized.\n * Increments a reference counter so nested providers don't destroy the manager\n * prematurely when the inner provider unmounts.\n */\nexport const initEditorClient = (): EditorStateManager => {\n _clientRefCount++;\n\n const existing = getGlobalEditorManager();\n if (existing) return existing;\n\n const manager = new EditorStateManager({\n mode: 'client',\n messenger: buildClientMessengerConfig(),\n configuration,\n });\n\n setGlobalEditorManager(manager);\n defineIntlayerElements();\n manager.start();\n\n return manager;\n};\n\n/**\n * Decrement the reference count and stop the global editor client singleton\n * only when the last provider unmounts.\n */\nexport const stopEditorClient = (): void => {\n _clientRefCount = Math.max(0, _clientRefCount - 1);\n\n if (_clientRefCount > 0) return;\n\n const manager = getGlobalEditorManager();\n manager?.stop();\n setGlobalEditorManager(null);\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,mCAAoD;CAC/D,MAAM,EAAE,WAAWA,kCAAiB,EAAE;AAEtC,QAAO;EACL,gBAAgB,CAAC,QAAQ,WAAW,QAAQ,OAAO,CAAC,OAClD,QACD;EACD,gBAAgB,SAAkB,WAAmB;AACnD,OAAI,OAAO,WAAW,YAAa;AAInC,OAAI,EAFe,OAAO,SAAS,OAAO,KAEzB;AACjB,UAAO,QAAQ,YAAY,SAAS,OAAO;;EAE9C;;;AAIH,IAAI,kBAAkB;;;;;;;AAQtB,MAAa,yBAA6C;AACxD;CAEA,MAAM,WAAWC,mDAAwB;AACzC,KAAI,SAAU,QAAO;CAErB,MAAM,UAAU,IAAIC,mDAAmB;EACrC,MAAM;EACN,WAAW,4BAA4B;EACvC;EACD,CAAC;AAEF,mDAAuB,QAAQ;AAC/B,4DAAwB;AACxB,SAAQ,OAAO;AAEf,QAAO;;;;;;AAOT,MAAa,yBAA+B;AAC1C,mBAAkB,KAAK,IAAI,GAAG,kBAAkB,EAAE;AAElD,KAAI,kBAAkB,EAAG;AAGzB,CADgBD,mDAAwB,EAC/B,MAAM;AACf,mDAAuB,KAAK"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1,38 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_compareUrls = require('./compareUrls.cjs');
|
|
3
|
+
const require_messageKey = require('./messageKey.cjs');
|
|
4
|
+
const require_mergeIframeClick = require('./mergeIframeClick.cjs');
|
|
5
|
+
const require_core_globalManager = require('./core/globalManager.cjs');
|
|
6
|
+
const require_components_ContentSelectorWrapper = require('./components/ContentSelectorWrapper.cjs');
|
|
7
|
+
const require_components_EditedContent = require('./components/EditedContent.cjs');
|
|
8
|
+
const require_core_CrossFrameMessenger = require('./core/CrossFrameMessenger.cjs');
|
|
9
|
+
const require_core_CrossFrameStateManager = require('./core/CrossFrameStateManager.cjs');
|
|
10
|
+
const require_core_IframeClickInterceptor = require('./core/IframeClickInterceptor.cjs');
|
|
11
|
+
const require_core_UrlStateManager = require('./core/UrlStateManager.cjs');
|
|
12
|
+
const require_core_EditorStateManager = require('./core/EditorStateManager.cjs');
|
|
13
|
+
const require_core_initEditorClient = require('./core/initEditorClient.cjs');
|
|
14
|
+
const require_components_IntlayerEditor = require('./components/IntlayerEditor.cjs');
|
|
15
|
+
const require_components_ContentSelector = require('./components/ContentSelector.cjs');
|
|
16
|
+
|
|
17
|
+
exports.CrossFrameMessenger = require_core_CrossFrameMessenger.CrossFrameMessenger;
|
|
18
|
+
exports.CrossFrameStateManager = require_core_CrossFrameStateManager.CrossFrameStateManager;
|
|
19
|
+
exports.EditorStateManager = require_core_EditorStateManager.EditorStateManager;
|
|
20
|
+
exports.IframeClickInterceptor = require_core_IframeClickInterceptor.IframeClickInterceptor;
|
|
21
|
+
exports.IntlayerContentSelectorElement = require_components_ContentSelector.IntlayerContentSelectorElement;
|
|
22
|
+
exports.IntlayerContentSelectorWrapperElement = require_components_ContentSelectorWrapper.IntlayerContentSelectorWrapperElement;
|
|
23
|
+
exports.IntlayerEditedContentElement = require_components_EditedContent.IntlayerEditedContentElement;
|
|
24
|
+
exports.IntlayerEditorElement = require_components_IntlayerEditor.IntlayerEditorElement;
|
|
25
|
+
exports.MessageKey = require_messageKey.MessageKey;
|
|
26
|
+
exports.UrlStateManager = require_core_UrlStateManager.UrlStateManager;
|
|
27
|
+
exports.buildClientMessengerConfig = require_core_initEditorClient.buildClientMessengerConfig;
|
|
28
|
+
exports.compareUrls = require_compareUrls.compareUrls;
|
|
29
|
+
exports.defineIntlayerContentSelectorWrapper = require_components_ContentSelectorWrapper.defineIntlayerContentSelectorWrapper;
|
|
30
|
+
exports.defineIntlayerEditedContent = require_components_EditedContent.defineIntlayerEditedContent;
|
|
31
|
+
exports.defineIntlayerEditorElement = require_components_IntlayerEditor.defineIntlayerEditorElement;
|
|
32
|
+
exports.defineIntlayerElements = require_components_ContentSelector.defineIntlayerElements;
|
|
33
|
+
exports.getGlobalEditorManager = require_core_globalManager.getGlobalEditorManager;
|
|
34
|
+
exports.initEditorClient = require_core_initEditorClient.initEditorClient;
|
|
35
|
+
exports.mergeIframeClick = require_mergeIframeClick.mergeIframeClick;
|
|
36
|
+
exports.onGlobalEditorManagerChange = require_core_globalManager.onGlobalEditorManagerChange;
|
|
37
|
+
exports.setGlobalEditorManager = require_core_globalManager.setGlobalEditorManager;
|
|
38
|
+
exports.stopEditorClient = require_core_initEditorClient.stopEditorClient;
|
package/dist/cjs/isEnabled.cjs
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
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
|
+
let _intlayer_config_built = require("@intlayer/config/built");
|
|
4
|
+
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
5
|
+
|
|
6
|
+
//#region src/isEnabled.ts
|
|
7
|
+
const isEnabled = _intlayer_config_built.default.editor?.enabled && typeof window !== "undefined" && window.self !== window.top;
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.isEnabled = isEnabled;
|
|
2
11
|
//# sourceMappingURL=isEnabled.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEnabled.cjs","names":["configuration"],"sources":["../../src/isEnabled.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nexport const isEnabled =\n configuration.editor?.enabled && // Editor enabled in config\n typeof window !== 'undefined' && // Client side\n window.self !== window.top; // Is in iframe\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"isEnabled.cjs","names":["configuration"],"sources":["../../src/isEnabled.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nexport const isEnabled =\n configuration.editor?.enabled && // Editor enabled in config\n typeof window !== 'undefined' && // Client side\n window.self !== window.top; // Is in iframe\n"],"mappings":";;;;;;AAEA,MAAa,YACXA,+BAAc,QAAQ,WACtB,OAAO,WAAW,eAClB,OAAO,SAAS,OAAO"}
|
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
//#region src/mergeIframeClick.ts
|
|
4
|
+
const mergeIframeClick = (event) => {
|
|
5
|
+
const simulatedMouseDownEvent = new MouseEvent("mousedown", {
|
|
6
|
+
bubbles: true,
|
|
7
|
+
cancelable: true,
|
|
8
|
+
view: window
|
|
9
|
+
});
|
|
10
|
+
const simulatedClickEvent = new MouseEvent("click", {
|
|
11
|
+
bubbles: true,
|
|
12
|
+
cancelable: true,
|
|
13
|
+
view: window
|
|
14
|
+
});
|
|
15
|
+
Object.assign(simulatedClickEvent, { iframeData: event });
|
|
16
|
+
Object.assign(simulatedMouseDownEvent, { iframeData: event });
|
|
17
|
+
window.dispatchEvent(simulatedClickEvent);
|
|
18
|
+
window.dispatchEvent(simulatedMouseDownEvent);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.mergeIframeClick = mergeIframeClick;
|
|
2
23
|
//# sourceMappingURL=mergeIframeClick.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeIframeClick.cjs","names":[],"sources":["../../src/mergeIframeClick.ts"],"sourcesContent":["// Listener for messages from the iframe\nexport const mergeIframeClick = (event: MessageEvent) => {\n // Simulate or merge the iframe message with a click event\n const simulatedMouseDownEvent = new MouseEvent('mousedown', {\n bubbles: true,\n cancelable: true,\n view: window,\n });\n const simulatedClickEvent = new MouseEvent('click', {\n bubbles: true,\n cancelable: true,\n view: window,\n });\n\n // Optionally attach additional properties from the iframe message\n Object.assign(simulatedClickEvent, { iframeData: event });\n Object.assign(simulatedMouseDownEvent, { iframeData: event });\n\n // Dispatch the simulated click event on the window or a specific element\n window.dispatchEvent(simulatedClickEvent);\n window.dispatchEvent(simulatedMouseDownEvent);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mergeIframeClick.cjs","names":[],"sources":["../../src/mergeIframeClick.ts"],"sourcesContent":["// Listener for messages from the iframe\nexport const mergeIframeClick = (event: MessageEvent) => {\n // Simulate or merge the iframe message with a click event\n const simulatedMouseDownEvent = new MouseEvent('mousedown', {\n bubbles: true,\n cancelable: true,\n view: window,\n });\n const simulatedClickEvent = new MouseEvent('click', {\n bubbles: true,\n cancelable: true,\n view: window,\n });\n\n // Optionally attach additional properties from the iframe message\n Object.assign(simulatedClickEvent, { iframeData: event });\n Object.assign(simulatedMouseDownEvent, { iframeData: event });\n\n // Dispatch the simulated click event on the window or a specific element\n window.dispatchEvent(simulatedClickEvent);\n window.dispatchEvent(simulatedMouseDownEvent);\n};\n"],"mappings":";;;AACA,MAAa,oBAAoB,UAAwB;CAEvD,MAAM,0BAA0B,IAAI,WAAW,aAAa;EAC1D,SAAS;EACT,YAAY;EACZ,MAAM;EACP,CAAC;CACF,MAAM,sBAAsB,IAAI,WAAW,SAAS;EAClD,SAAS;EACT,YAAY;EACZ,MAAM;EACP,CAAC;AAGF,QAAO,OAAO,qBAAqB,EAAE,YAAY,OAAO,CAAC;AACzD,QAAO,OAAO,yBAAyB,EAAE,YAAY,OAAO,CAAC;AAG7D,QAAO,cAAc,oBAAoB;AACzC,QAAO,cAAc,wBAAwB"}
|
package/dist/cjs/messageKey.cjs
CHANGED
|
@@ -1,2 +1,31 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
//#region src/messageKey.ts
|
|
4
|
+
let MessageKey = /* @__PURE__ */ function(MessageKey) {
|
|
5
|
+
/** Client → editor: announces the client is ready (also used as response to ARE_YOU_THERE) */
|
|
6
|
+
MessageKey["INTLAYER_CLIENT_READY"] = "INTLAYER_CLIENT_READY";
|
|
7
|
+
/** Editor → client: asks if the client is still alive */
|
|
8
|
+
MessageKey["INTLAYER_ARE_YOU_THERE"] = "INTLAYER_ARE_YOU_THERE";
|
|
9
|
+
/** Editor → client: instructs the client to activate the editor selector */
|
|
10
|
+
MessageKey["INTLAYER_EDITOR_ACTIVATE"] = "INTLAYER_EDITOR_ACTIVATE";
|
|
11
|
+
/** Client → editor: instructs the editor that the client is enabled */
|
|
12
|
+
MessageKey["INTLAYER_EDITOR_ENABLED"] = "INTLAYER_EDITOR_ENABLED";
|
|
13
|
+
/** Client → editor: send information related the app */
|
|
14
|
+
MessageKey["INTLAYER_CONFIGURATION"] = "INTLAYER_CONFIGURATION";
|
|
15
|
+
MessageKey["INTLAYER_CURRENT_LOCALE"] = "INTLAYER_CURRENT_LOCALE";
|
|
16
|
+
MessageKey["INTLAYER_URL_CHANGE"] = "INTLAYER_URL_CHANGE";
|
|
17
|
+
/** Client → editor: load and update content */
|
|
18
|
+
MessageKey["INTLAYER_LOCALE_DICTIONARIES_CHANGED"] = "INTLAYER_LOCALE_DICTIONARIES_CHANGED";
|
|
19
|
+
MessageKey["INTLAYER_DISTANT_DICTIONARIES_CHANGED"] = "INTLAYER_DISTANT_DICTIONARIES_CHANGED";
|
|
20
|
+
/** Client → editor & Editor → client: Update focus and changed content */
|
|
21
|
+
MessageKey["INTLAYER_HOVERED_CONTENT_CHANGED"] = "INTLAYER_HOVERED_CONTENT_CHANGED";
|
|
22
|
+
MessageKey["INTLAYER_FOCUSED_CONTENT_CHANGED"] = "INTLAYER_FOCUSED_CONTENT_CHANGED";
|
|
23
|
+
MessageKey["INTLAYER_EDITED_CONTENT_CHANGED"] = "INTLAYER_EDITED_CONTENT_CHANGED";
|
|
24
|
+
/** Client → editor: Helper to sync iframe client reactivity on click client */
|
|
25
|
+
MessageKey["INTLAYER_IFRAME_CLICKED"] = "INTLAYER_IFRAME_CLICKED";
|
|
26
|
+
return MessageKey;
|
|
27
|
+
}({});
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.MessageKey = MessageKey;
|
|
2
31
|
//# sourceMappingURL=messageKey.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageKey.cjs","names":[],"sources":["../../src/messageKey.ts"],"sourcesContent":["export enum MessageKey {\n /** Client → editor: announces the client is ready (also used as response to ARE_YOU_THERE) */\n INTLAYER_CLIENT_READY = 'INTLAYER_CLIENT_READY',\n /** Editor → client: asks if the client is still alive */\n INTLAYER_ARE_YOU_THERE = 'INTLAYER_ARE_YOU_THERE',\n /** Editor → client: instructs the client to activate the editor selector */\n INTLAYER_EDITOR_ACTIVATE = 'INTLAYER_EDITOR_ACTIVATE',\n /** Client → editor: instructs the editor that the client is enabled */\n INTLAYER_EDITOR_ENABLED = 'INTLAYER_EDITOR_ENABLED',\n\n /** Client → editor: send information related the app */\n INTLAYER_CONFIGURATION = 'INTLAYER_CONFIGURATION',\n INTLAYER_CURRENT_LOCALE = 'INTLAYER_CURRENT_LOCALE',\n INTLAYER_URL_CHANGE = 'INTLAYER_URL_CHANGE',\n\n /** Client → editor: load and update content */\n INTLAYER_LOCALE_DICTIONARIES_CHANGED = 'INTLAYER_LOCALE_DICTIONARIES_CHANGED',\n INTLAYER_DISTANT_DICTIONARIES_CHANGED = 'INTLAYER_DISTANT_DICTIONARIES_CHANGED',\n\n /** Client → editor & Editor → client: Update focus and changed content */\n INTLAYER_HOVERED_CONTENT_CHANGED = 'INTLAYER_HOVERED_CONTENT_CHANGED',\n INTLAYER_FOCUSED_CONTENT_CHANGED = 'INTLAYER_FOCUSED_CONTENT_CHANGED',\n INTLAYER_EDITED_CONTENT_CHANGED = 'INTLAYER_EDITED_CONTENT_CHANGED',\n\n /** Client → editor: Helper to sync iframe client reactivity on click client */\n INTLAYER_IFRAME_CLICKED = 'INTLAYER_IFRAME_CLICKED',\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"messageKey.cjs","names":[],"sources":["../../src/messageKey.ts"],"sourcesContent":["export enum MessageKey {\n /** Client → editor: announces the client is ready (also used as response to ARE_YOU_THERE) */\n INTLAYER_CLIENT_READY = 'INTLAYER_CLIENT_READY',\n /** Editor → client: asks if the client is still alive */\n INTLAYER_ARE_YOU_THERE = 'INTLAYER_ARE_YOU_THERE',\n /** Editor → client: instructs the client to activate the editor selector */\n INTLAYER_EDITOR_ACTIVATE = 'INTLAYER_EDITOR_ACTIVATE',\n /** Client → editor: instructs the editor that the client is enabled */\n INTLAYER_EDITOR_ENABLED = 'INTLAYER_EDITOR_ENABLED',\n\n /** Client → editor: send information related the app */\n INTLAYER_CONFIGURATION = 'INTLAYER_CONFIGURATION',\n INTLAYER_CURRENT_LOCALE = 'INTLAYER_CURRENT_LOCALE',\n INTLAYER_URL_CHANGE = 'INTLAYER_URL_CHANGE',\n\n /** Client → editor: load and update content */\n INTLAYER_LOCALE_DICTIONARIES_CHANGED = 'INTLAYER_LOCALE_DICTIONARIES_CHANGED',\n INTLAYER_DISTANT_DICTIONARIES_CHANGED = 'INTLAYER_DISTANT_DICTIONARIES_CHANGED',\n\n /** Client → editor & Editor → client: Update focus and changed content */\n INTLAYER_HOVERED_CONTENT_CHANGED = 'INTLAYER_HOVERED_CONTENT_CHANGED',\n INTLAYER_FOCUSED_CONTENT_CHANGED = 'INTLAYER_FOCUSED_CONTENT_CHANGED',\n INTLAYER_EDITED_CONTENT_CHANGED = 'INTLAYER_EDITED_CONTENT_CHANGED',\n\n /** Client → editor: Helper to sync iframe client reactivity on click client */\n INTLAYER_IFRAME_CLICKED = 'INTLAYER_IFRAME_CLICKED',\n}\n"],"mappings":";;;AAAA,IAAY,aAAL;;AAEL;;AAEA;;AAEA;;AAEA;;AAGA;AACA;AACA;;AAGA;AACA;;AAGA;AACA;AACA;;AAGA;;KACD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/decorate.js
|
|
2
|
+
function __decorate(decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { __decorate };
|
package/dist/esm/compareUrls.mjs
CHANGED
|
@@ -1,2 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/compareUrls.ts
|
|
2
|
+
/**
|
|
3
|
+
* Compare two URLs for equality.
|
|
4
|
+
* This function is used to determine if a message originates from the same origin.
|
|
5
|
+
*
|
|
6
|
+
* ```js
|
|
7
|
+
* // Example usage
|
|
8
|
+
* console.log(compareUrls("http://localhost:5173/", "http://localhost:5173")); // true
|
|
9
|
+
* console.log(compareUrls("http://localhost:5173", "http://localhost:5173?myParam=true")); // true
|
|
10
|
+
* console.log(compareUrls("http://localhost:5173/subpath", "http://localhost:5173")); // true
|
|
11
|
+
* console.log(compareUrls("http://localhost:5172", "http://localhost:5173")); // false
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param url1 - The first URL to compare.
|
|
15
|
+
* @param url2 - The second URL to compare.
|
|
16
|
+
* @returns Whether the two URLs are equal.
|
|
17
|
+
*/
|
|
18
|
+
const compareUrls = (url1, url2) => {
|
|
19
|
+
try {
|
|
20
|
+
const parsedUrl1 = new URL(url1);
|
|
21
|
+
const parsedUrl2 = new URL(url2);
|
|
22
|
+
if (parsedUrl1.protocol !== parsedUrl2.protocol || parsedUrl1.hostname !== parsedUrl2.hostname || parsedUrl1.port !== parsedUrl2.port) return false;
|
|
23
|
+
const path1 = parsedUrl1.pathname.replace(/\/$/, "");
|
|
24
|
+
const path2 = parsedUrl2.pathname.replace(/\/$/, "");
|
|
25
|
+
if (path1 !== "" && path2 !== "" && path1 !== path2) return false;
|
|
26
|
+
return true;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error("Invalid URL(s)", error, {
|
|
29
|
+
url1,
|
|
30
|
+
url2
|
|
31
|
+
});
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { compareUrls };
|
|
2
38
|
//# sourceMappingURL=compareUrls.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareUrls.mjs","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,
|
|
1
|
+
{"version":3,"file":"compareUrls.mjs","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,165 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs";
|
|
2
|
+
import { defineIntlayerContentSelectorWrapper } from "./ContentSelectorWrapper.mjs";
|
|
3
|
+
import { defineIntlayerEditedContent } from "./EditedContent.mjs";
|
|
4
|
+
import { defineIntlayerEditorElement } from "./IntlayerEditor.mjs";
|
|
5
|
+
import { LitElement, css, html } from "lit";
|
|
6
|
+
import { property, query, state } from "lit/decorators.js";
|
|
7
|
+
|
|
8
|
+
//#region src/components/ContentSelector.ts
|
|
9
|
+
const DEFAULT_PRESS_DURATION = 250;
|
|
10
|
+
/**
|
|
11
|
+
* <intlayer-content-selector>
|
|
12
|
+
*
|
|
13
|
+
* A framework-agnostic web component that wraps content with Intlayer editor
|
|
14
|
+
* selection UI (hover outline, long-press to select, click-outside to deselect).
|
|
15
|
+
*
|
|
16
|
+
* Replaces the per-framework ContentSelector components (React, Svelte, Vue, Solid).
|
|
17
|
+
*
|
|
18
|
+
* @fires intlayer:press - Fired after a long press (pressDuration ms). Bubbles.
|
|
19
|
+
* @fires intlayer:hover - Fired on mouseenter. Bubbles.
|
|
20
|
+
* @fires intlayer:unhover - Fired on mouseleave / mouseup. Bubbles.
|
|
21
|
+
* @fires intlayer:click-outside - Fired when a click occurs outside the element. Bubbles.
|
|
22
|
+
*
|
|
23
|
+
* @prop {boolean} isSelecting - Whether this element is currently selected (external state)
|
|
24
|
+
* @prop {number} pressDuration - Long-press threshold in ms. Default: 250
|
|
25
|
+
*/
|
|
26
|
+
var IntlayerContentSelectorElement = class extends LitElement {
|
|
27
|
+
constructor(..._args) {
|
|
28
|
+
super(..._args);
|
|
29
|
+
this.isSelecting = false;
|
|
30
|
+
this.pressDuration = DEFAULT_PRESS_DURATION;
|
|
31
|
+
this._isHovered = false;
|
|
32
|
+
this._isSelectingState = false;
|
|
33
|
+
this._pressTimer = null;
|
|
34
|
+
this._clickOutsideHandler = null;
|
|
35
|
+
}
|
|
36
|
+
static {
|
|
37
|
+
this.styles = css`
|
|
38
|
+
:host {
|
|
39
|
+
display: contents;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.wrapper {
|
|
43
|
+
display: inline-block;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
user-select: none;
|
|
46
|
+
border-radius: 0.375rem;
|
|
47
|
+
outline-width: 2px;
|
|
48
|
+
outline-offset: 4px;
|
|
49
|
+
outline-style: solid;
|
|
50
|
+
outline-color: transparent;
|
|
51
|
+
transition: all 100ms 50ms ease-in-out;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.wrapper[data-active] {
|
|
55
|
+
outline-color: inherit;
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
connectedCallback() {
|
|
60
|
+
super.connectedCallback();
|
|
61
|
+
this._clickOutsideHandler = (e) => {
|
|
62
|
+
if (!e.composedPath().includes(this)) {
|
|
63
|
+
this._isSelectingState = false;
|
|
64
|
+
this._dispatch("intlayer:click-outside");
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
document.addEventListener("mousedown", this._clickOutsideHandler);
|
|
68
|
+
}
|
|
69
|
+
disconnectedCallback() {
|
|
70
|
+
super.disconnectedCallback();
|
|
71
|
+
if (this._clickOutsideHandler) {
|
|
72
|
+
document.removeEventListener("mousedown", this._clickOutsideHandler);
|
|
73
|
+
this._clickOutsideHandler = null;
|
|
74
|
+
}
|
|
75
|
+
this._clearPressTimer();
|
|
76
|
+
}
|
|
77
|
+
_clearPressTimer() {
|
|
78
|
+
if (this._pressTimer !== null) {
|
|
79
|
+
clearTimeout(this._pressTimer);
|
|
80
|
+
this._pressTimer = null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
_dispatch(eventName) {
|
|
84
|
+
this.dispatchEvent(new CustomEvent(eventName, {
|
|
85
|
+
bubbles: true,
|
|
86
|
+
composed: true
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
_handleMouseDown() {
|
|
90
|
+
this._clearPressTimer();
|
|
91
|
+
this._pressTimer = setTimeout(() => {
|
|
92
|
+
this._isSelectingState = true;
|
|
93
|
+
this._dispatch("intlayer:press");
|
|
94
|
+
}, this.pressDuration);
|
|
95
|
+
}
|
|
96
|
+
_handleMouseEnter() {
|
|
97
|
+
this._isHovered = true;
|
|
98
|
+
this._dispatch("intlayer:hover");
|
|
99
|
+
}
|
|
100
|
+
_handleMouseUpOrLeave() {
|
|
101
|
+
if (this._isHovered) {
|
|
102
|
+
this._isHovered = false;
|
|
103
|
+
this._dispatch("intlayer:unhover");
|
|
104
|
+
}
|
|
105
|
+
this._clearPressTimer();
|
|
106
|
+
}
|
|
107
|
+
_handleClick(e) {
|
|
108
|
+
if (this.isSelecting || this._isSelectingState) {
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
e.stopPropagation();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
_handleBlur() {
|
|
114
|
+
this._isSelectingState = false;
|
|
115
|
+
}
|
|
116
|
+
render() {
|
|
117
|
+
return html`
|
|
118
|
+
<span
|
|
119
|
+
class="wrapper"
|
|
120
|
+
?data-active=${this.isSelecting || this._isSelectingState || this._isHovered}
|
|
121
|
+
role="button"
|
|
122
|
+
tabindex="0"
|
|
123
|
+
@mousedown=${this._handleMouseDown}
|
|
124
|
+
@mouseup=${this._handleMouseUpOrLeave}
|
|
125
|
+
@mouseleave=${this._handleMouseUpOrLeave}
|
|
126
|
+
@mouseenter=${this._handleMouseEnter}
|
|
127
|
+
@click=${this._handleClick}
|
|
128
|
+
@touchstart=${this._handleMouseDown}
|
|
129
|
+
@touchend=${this._handleMouseUpOrLeave}
|
|
130
|
+
@touchcancel=${this._handleMouseUpOrLeave}
|
|
131
|
+
@blur=${this._handleBlur}
|
|
132
|
+
@keyup=${() => {}}
|
|
133
|
+
>
|
|
134
|
+
<slot></slot>
|
|
135
|
+
</span>
|
|
136
|
+
`;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
__decorate([property({
|
|
140
|
+
type: Boolean,
|
|
141
|
+
attribute: "is-selecting"
|
|
142
|
+
})], IntlayerContentSelectorElement.prototype, "isSelecting", void 0);
|
|
143
|
+
__decorate([property({
|
|
144
|
+
type: Number,
|
|
145
|
+
attribute: "press-duration"
|
|
146
|
+
})], IntlayerContentSelectorElement.prototype, "pressDuration", void 0);
|
|
147
|
+
__decorate([state()], IntlayerContentSelectorElement.prototype, "_isHovered", void 0);
|
|
148
|
+
__decorate([state()], IntlayerContentSelectorElement.prototype, "_isSelectingState", void 0);
|
|
149
|
+
__decorate([query(".wrapper")], IntlayerContentSelectorElement.prototype, "_wrapper", void 0);
|
|
150
|
+
/**
|
|
151
|
+
* Register all Intlayer custom elements.
|
|
152
|
+
* Call this once at application startup (inside IntlayerEditorProvider or similar).
|
|
153
|
+
* Safe to call multiple times — only registers elements that are not yet defined.
|
|
154
|
+
*/
|
|
155
|
+
const defineIntlayerElements = () => {
|
|
156
|
+
if (typeof customElements === "undefined") return;
|
|
157
|
+
if (!customElements.get("intlayer-content-selector")) customElements.define("intlayer-content-selector", IntlayerContentSelectorElement);
|
|
158
|
+
defineIntlayerContentSelectorWrapper();
|
|
159
|
+
defineIntlayerEditedContent();
|
|
160
|
+
defineIntlayerEditorElement();
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
export { IntlayerContentSelectorElement, defineIntlayerElements };
|
|
165
|
+
//# sourceMappingURL=ContentSelector.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentSelector.mjs","names":[],"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,cAAoD,WAAW;;;qBAwB/C;uBAGE;oBAEc;2BACO;qBAIuB;8BACK;;;gBAlCjD,GAAG;;;;;;;;;;;;;;;;;;;;;;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,IAAI;;;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;;;;;;;YAlGvB,SAAS;CAAE,MAAM;CAAS,WAAW;CAAgB,CAAC;YAGtD,SAAS;CAAE,MAAM;CAAQ,WAAW;CAAkB,CAAC;YAGvD,OAAO;YACP,OAAO;YAEP,MAAM,WAAW;;;;;;AAsGpB,MAAa,+BAAqC;AAChD,KAAI,OAAO,mBAAmB,YAAa;AAC3C,KAAI,CAAC,eAAe,IAAI,4BAA4B,CAClD,gBAAe,OACb,6BACA,+BACD;AAEH,uCAAsC;AACtC,8BAA6B;AAC7B,8BAA6B"}
|