@intlayer/next-i18next 9.5.2 → 9.5.4-canary.0
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/README.md +9 -9
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/package.json +13 -12
- package/dist/cjs/packages/@intlayer/editor/dist/esm/compareUrls.cjs +0 -39
- package/dist/cjs/packages/@intlayer/editor/dist/esm/compareUrls.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelector.cjs +0 -161
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelector.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.cjs +0 -269
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/EditedContent.cjs +0 -161
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/EditedContent.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.cjs +0 -88
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.cjs +0 -27
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.cjs +0 -80
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.cjs +0 -75
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/EditorStateManager.cjs +0 -383
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/EditorStateManager.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.cjs +0 -45
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/UrlStateManager.cjs +0 -59
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/UrlStateManager.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/editedContentBus.cjs +0 -36
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/editedContentBus.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/focusedContentBus.cjs +0 -42
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/focusedContentBus.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/globalManager.cjs +0 -82
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/globalManager.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/initEditorClient.cjs +0 -55
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/initEditorClient.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/index.cjs +0 -19
- package/dist/cjs/packages/@intlayer/editor/dist/esm/isEnabled.cjs +0 -9
- package/dist/cjs/packages/@intlayer/editor/dist/esm/isEnabled.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/mergeIframeClick.cjs +0 -22
- package/dist/cjs/packages/@intlayer/editor/dist/esm/mergeIframeClick.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.cjs +0 -32
- package/dist/cjs/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.cjs.map +0 -1
- package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerContext.cjs +0 -25
- package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerContext.cjs.map +0 -1
- package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerProvider.cjs +0 -78
- package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerProvider.cjs.map +0 -1
- package/dist/cjs/packages/react-intlayer/dist/esm/client/useLocaleStorage.cjs +0 -24
- package/dist/cjs/packages/react-intlayer/dist/esm/client/useLocaleStorage.cjs.map +0 -1
- package/dist/cjs/packages/react-intlayer/dist/esm/editor/EditorProvider.cjs +0 -11
- package/dist/cjs/packages/react-intlayer/dist/esm/editor/EditorProvider.cjs.map +0 -1
- package/dist/cjs/packages/react-intlayer/dist/esm/editor/useEditor.cjs +0 -39
- package/dist/cjs/packages/react-intlayer/dist/esm/editor/useEditor.cjs.map +0 -1
- package/dist/cjs/warnUnsupported.cjs +0 -28
- package/dist/cjs/warnUnsupported.cjs.map +0 -1
- package/dist/esm/_virtual/_rolldown/runtime.mjs +0 -8
- package/dist/esm/packages/@intlayer/editor/dist/esm/compareUrls.mjs +0 -38
- package/dist/esm/packages/@intlayer/editor/dist/esm/compareUrls.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs +0 -160
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs +0 -266
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/EditedContent.mjs +0 -159
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/EditedContent.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.mjs +0 -88
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.mjs +0 -26
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.mjs +0 -80
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.mjs +0 -74
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/EditorStateManager.mjs +0 -381
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/EditorStateManager.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.mjs +0 -45
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs +0 -58
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs +0 -33
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs +0 -39
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/globalManager.mjs +0 -79
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/globalManager.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/initEditorClient.mjs +0 -52
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/initEditorClient.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/index.mjs +0 -18
- package/dist/esm/packages/@intlayer/editor/dist/esm/isEnabled.mjs +0 -8
- package/dist/esm/packages/@intlayer/editor/dist/esm/isEnabled.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/mergeIframeClick.mjs +0 -21
- package/dist/esm/packages/@intlayer/editor/dist/esm/mergeIframeClick.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.browser.mjs +0 -6
- package/dist/esm/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.browser.mjs.map +0 -1
- package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerContext.mjs +0 -23
- package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerContext.mjs.map +0 -1
- package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerProvider.mjs +0 -77
- package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerProvider.mjs.map +0 -1
- package/dist/esm/packages/react-intlayer/dist/esm/client/useLocaleStorage.mjs +0 -22
- package/dist/esm/packages/react-intlayer/dist/esm/client/useLocaleStorage.mjs.map +0 -1
- package/dist/esm/packages/react-intlayer/dist/esm/editor/EditorProvider.mjs +0 -11
- package/dist/esm/packages/react-intlayer/dist/esm/editor/EditorProvider.mjs.map +0 -1
- package/dist/esm/packages/react-intlayer/dist/esm/editor/useEditor.mjs +0 -38
- package/dist/esm/packages/react-intlayer/dist/esm/editor/useEditor.mjs.map +0 -1
- package/dist/esm/warnUnsupported.mjs +0 -27
- package/dist/esm/warnUnsupported.mjs.map +0 -1
- package/dist/types/warnUnsupported.d.ts +0 -18
- package/dist/types/warnUnsupported.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://intlayer.org" rel="">
|
|
3
|
-
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.
|
|
3
|
+
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.webp" width="60%" alt="Intlayer Logo" />
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
@@ -49,10 +49,10 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
|
|
|
49
49
|
|
|
50
50
|
| Feature | Description |
|
|
51
51
|
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.
|
|
52
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.webp?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
|
|
53
53
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
|
|
54
54
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
|
|
55
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.
|
|
55
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.webp?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
|
|
56
56
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
57
57
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
58
58
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
|
|
@@ -60,12 +60,12 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
|
|
|
60
60
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
|
|
61
61
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
62
62
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
|
|
63
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.
|
|
64
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.
|
|
65
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.
|
|
63
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.webp?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
|
|
64
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.webp?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
|
|
65
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.webp?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
66
66
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
|
|
67
67
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
|
|
68
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.
|
|
68
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.webp?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
|
|
69
69
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) <br> - [Intlayer compat adapters](https://intlayer.org/doc/compatibility) |
|
|
70
70
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
|
|
71
71
|
|
|
@@ -262,7 +262,7 @@ Intlayer connects **developers**, **copywriters**, and **AI agents** in one work
|
|
|
262
262
|
- Feature flags
|
|
263
263
|
- Headless CMSs (e.g. Contentful, Strapi, Sanity)
|
|
264
264
|
|
|
265
|
-

|
|
266
266
|
|
|
267
267
|
## 🌐 Readme in other languages
|
|
268
268
|
|
|
@@ -328,4 +328,4 @@ Contribute on [GitHub](https://github.com/aymericzip/intlayer), [GitLab](https:/
|
|
|
328
328
|
|
|
329
329
|
If you like Intlayer, give us a ⭐ on GitHub. It helps others discover the project! [See why GitHub Stars matter](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md#why-github-stars-matter-).
|
|
330
330
|
|
|
331
|
-
[](https://
|
|
331
|
+
[](https://star-history.com/#aymericzip/intlayer&Date)
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_appWithTranslation = require('./appWithTranslation.cjs');
|
|
3
2
|
const require_serverSideTranslations = require('./serverSideTranslations.cjs');
|
|
3
|
+
const require_appWithTranslation = require('./appWithTranslation.cjs');
|
|
4
4
|
let _intlayer_i18next = require("@intlayer/i18next");
|
|
5
5
|
let _intlayer_react_i18next = require("@intlayer/react-i18next");
|
|
6
6
|
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { appWithTranslation } from "./appWithTranslation.mjs";
|
|
2
1
|
import { serverSideTranslations } from "./serverSideTranslations.mjs";
|
|
2
|
+
import { appWithTranslation } from "./appWithTranslation.mjs";
|
|
3
3
|
import { i18next } from "@intlayer/i18next";
|
|
4
4
|
import { I18nContext, I18nextProvider, Trans, Translation, initReactI18next, useDictionary, useDictionaryDynamic, useTranslation, withTranslation } from "@intlayer/react-i18next";
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/next-i18next",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.4-canary.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "next-i18next API adapter for intlayer — serverSideTranslations, appWithTranslation, useTranslation backed by next-intlayer",
|
|
6
6
|
"keywords": [
|
|
@@ -73,20 +73,21 @@
|
|
|
73
73
|
"prepublish": "cp -f ../../README.md ./README.md",
|
|
74
74
|
"publish": "bun publish || true",
|
|
75
75
|
"publish:canary": "bun publish --access public --tag canary || true",
|
|
76
|
+
"publish:ci": "bun ../../scripts/publish-package.mjs",
|
|
76
77
|
"publish:latest": "bun publish --access public --tag latest || true",
|
|
77
78
|
"test": "bun --bun vitest run",
|
|
78
79
|
"test:watch": "bun --bun vitest",
|
|
79
80
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
80
81
|
},
|
|
81
82
|
"dependencies": {
|
|
82
|
-
"@intlayer/config": "9.5.
|
|
83
|
-
"@intlayer/core": "9.5.
|
|
84
|
-
"@intlayer/engine": "9.5.
|
|
85
|
-
"@intlayer/i18next": "9.5.
|
|
86
|
-
"@intlayer/react-i18next": "9.5.
|
|
87
|
-
"@intlayer/types": "9.5.
|
|
88
|
-
"next-intlayer": "9.5.
|
|
89
|
-
"react-intlayer": "9.5.
|
|
83
|
+
"@intlayer/config": "9.5.4-canary.0",
|
|
84
|
+
"@intlayer/core": "9.5.4-canary.0",
|
|
85
|
+
"@intlayer/engine": "9.5.4-canary.0",
|
|
86
|
+
"@intlayer/i18next": "9.5.4-canary.0",
|
|
87
|
+
"@intlayer/react-i18next": "9.5.4-canary.0",
|
|
88
|
+
"@intlayer/types": "9.5.4-canary.0",
|
|
89
|
+
"next-intlayer": "9.5.4-canary.0",
|
|
90
|
+
"react-intlayer": "9.5.4-canary.0"
|
|
90
91
|
},
|
|
91
92
|
"devDependencies": {
|
|
92
93
|
"@types/node": "^22",
|
|
@@ -95,12 +96,12 @@
|
|
|
95
96
|
"@utils/ts-config-types": "1.0.4",
|
|
96
97
|
"@utils/tsdown-config": "1.0.4",
|
|
97
98
|
"i18next": "26.4.2",
|
|
98
|
-
"next-i18next": "16.
|
|
99
|
-
"react-i18next": "17.0.
|
|
99
|
+
"next-i18next": "16.3.1",
|
|
100
|
+
"react-i18next": "17.0.14",
|
|
100
101
|
"rimraf": "6.1.3",
|
|
101
102
|
"tsdown": "0.23.0",
|
|
102
103
|
"typescript": "7.0.2",
|
|
103
|
-
"vitest": "5.0.
|
|
104
|
+
"vitest": "5.0.1"
|
|
104
105
|
},
|
|
105
106
|
"peerDependencies": {
|
|
106
107
|
"i18next": ">=20.0.0",
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../../packages/@intlayer/editor/dist/esm/compareUrls.mjs
|
|
3
|
-
/**
|
|
4
|
-
* Compare two URLs for equality.
|
|
5
|
-
* This function is used to determine if a message originates from the same origin.
|
|
6
|
-
*
|
|
7
|
-
* ```js
|
|
8
|
-
* // Example usage
|
|
9
|
-
* console.log(compareUrls("http://localhost:5173/", "http://localhost:5173")); // true
|
|
10
|
-
* console.log(compareUrls("http://localhost:5173", "http://localhost:5173?myParam=true")); // true
|
|
11
|
-
* console.log(compareUrls("http://localhost:5173/subpath", "http://localhost:5173")); // true
|
|
12
|
-
* console.log(compareUrls("http://localhost:5172", "http://localhost:5173")); // false
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* @param url1 - The first URL to compare.
|
|
16
|
-
* @param url2 - The second URL to compare.
|
|
17
|
-
* @returns Whether the two URLs are equal.
|
|
18
|
-
*/
|
|
19
|
-
const compareUrls = (url1, url2) => {
|
|
20
|
-
try {
|
|
21
|
-
const parsedUrl1 = new URL(url1);
|
|
22
|
-
const parsedUrl2 = new URL(url2);
|
|
23
|
-
if (parsedUrl1.protocol !== parsedUrl2.protocol || parsedUrl1.hostname !== parsedUrl2.hostname || parsedUrl1.port !== parsedUrl2.port) return false;
|
|
24
|
-
const path1 = parsedUrl1.pathname.replace(/\/$/, "");
|
|
25
|
-
const path2 = parsedUrl2.pathname.replace(/\/$/, "");
|
|
26
|
-
if (path1 !== "" && path2 !== "" && path1 !== path2) return false;
|
|
27
|
-
return true;
|
|
28
|
-
} catch (error) {
|
|
29
|
-
console.error("Invalid URL(s)", error, {
|
|
30
|
-
url1,
|
|
31
|
-
url2
|
|
32
|
-
});
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
//#endregion
|
|
38
|
-
exports.compareUrls = compareUrls;
|
|
39
|
-
//# sourceMappingURL=compareUrls.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compareUrls.cjs","names":[],"sources":["../../../../../../../../../packages/@intlayer/editor/dist/esm/compareUrls.mjs"],"sourcesContent":["//#region src/compareUrls.ts\n/**\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*/\nconst compareUrls = (url1, url2) => {\n\ttry {\n\t\tconst parsedUrl1 = new URL(url1);\n\t\tconst parsedUrl2 = new URL(url2);\n\t\tif (parsedUrl1.protocol !== parsedUrl2.protocol || parsedUrl1.hostname !== parsedUrl2.hostname || parsedUrl1.port !== parsedUrl2.port) return false;\n\t\tconst path1 = parsedUrl1.pathname.replace(/\\/$/, \"\");\n\t\tconst path2 = parsedUrl2.pathname.replace(/\\/$/, \"\");\n\t\tif (path1 !== \"\" && path2 !== \"\" && path1 !== path2) return false;\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"Invalid URL(s)\", error, {\n\t\t\turl1,\n\t\t\turl2\n\t\t});\n\t\treturn false;\n\t}\n};\n\n//#endregion\nexport { compareUrls };\n//# sourceMappingURL=compareUrls.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAM,eAAe,MAAM,SAAS;AACnC,KAAI;EACH,MAAM,aAAa,IAAI,IAAI,KAAK;EAChC,MAAM,aAAa,IAAI,IAAI,KAAK;AAChC,MAAI,WAAW,aAAa,WAAW,YAAY,WAAW,aAAa,WAAW,YAAY,WAAW,SAAS,WAAW,KAAM,QAAO;EAC9I,MAAM,QAAQ,WAAW,SAAS,QAAQ,OAAO,GAAG;EACpD,MAAM,QAAQ,WAAW,SAAS,QAAQ,OAAO,GAAG;AACpD,MAAI,UAAU,MAAM,UAAU,MAAM,UAAU,MAAO,QAAO;AAC5D,SAAO;UACC,OAAO;AACf,UAAQ,MAAM,kBAAkB,OAAO;GACtC;GACA;GACA,CAAC;AACF,SAAO"}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../../packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs
|
|
3
|
-
const DEFAULT_PRESS_DURATION = 250;
|
|
4
|
-
const STYLES = `
|
|
5
|
-
:host {
|
|
6
|
-
display: contents;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.wrapper {
|
|
10
|
-
display: inline-block;
|
|
11
|
-
cursor: pointer;
|
|
12
|
-
user-select: none;
|
|
13
|
-
border-radius: 0.375rem;
|
|
14
|
-
outline-width: 2px;
|
|
15
|
-
outline-offset: 4px;
|
|
16
|
-
outline-style: solid;
|
|
17
|
-
outline-color: transparent;
|
|
18
|
-
transition: all 100ms 50ms ease-in-out;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.wrapper[data-active] {
|
|
22
|
-
outline-color: inherit;
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
const _HTMLElement = typeof HTMLElement !== "undefined" ? HTMLElement : class {};
|
|
26
|
-
/**
|
|
27
|
-
* <intlayer-content-selector>
|
|
28
|
-
*
|
|
29
|
-
* A framework-agnostic web component that wraps content with Intlayer editor
|
|
30
|
-
* selection UI (hover outline, long-press to select, click-outside to deselect).
|
|
31
|
-
*
|
|
32
|
-
* @fires intlayer:press - Fired after a long press (pressDuration ms). Bubbles.
|
|
33
|
-
* @fires intlayer:hover - Fired on mouseenter. Bubbles.
|
|
34
|
-
* @fires intlayer:unhover - Fired on mouseleave / mouseup. Bubbles.
|
|
35
|
-
* @fires intlayer:click-outside - Fired when a click occurs outside the element. Bubbles.
|
|
36
|
-
*
|
|
37
|
-
* @prop {boolean} isSelecting - Whether this element is currently selected (external state)
|
|
38
|
-
* @prop {number} pressDuration - Long-press threshold in ms. Default: 250
|
|
39
|
-
*/
|
|
40
|
-
var IntlayerContentSelectorElement = class extends _HTMLElement {
|
|
41
|
-
_isSelecting = false;
|
|
42
|
-
_pressDuration = DEFAULT_PRESS_DURATION;
|
|
43
|
-
_isHovered = false;
|
|
44
|
-
_isSelectingState = false;
|
|
45
|
-
_wrapper;
|
|
46
|
-
_pressTimer = null;
|
|
47
|
-
_clickOutsideHandler = null;
|
|
48
|
-
static get observedAttributes() {
|
|
49
|
-
return ["is-selecting", "press-duration"];
|
|
50
|
-
}
|
|
51
|
-
get isSelecting() {
|
|
52
|
-
return this._isSelecting;
|
|
53
|
-
}
|
|
54
|
-
set isSelecting(v) {
|
|
55
|
-
this._isSelecting = v;
|
|
56
|
-
this._updateActiveState();
|
|
57
|
-
}
|
|
58
|
-
get pressDuration() {
|
|
59
|
-
return this._pressDuration;
|
|
60
|
-
}
|
|
61
|
-
set pressDuration(v) {
|
|
62
|
-
this._pressDuration = v;
|
|
63
|
-
}
|
|
64
|
-
constructor() {
|
|
65
|
-
super();
|
|
66
|
-
const shadow = this.attachShadow({ mode: "open" });
|
|
67
|
-
const style = document.createElement("style");
|
|
68
|
-
style.textContent = STYLES;
|
|
69
|
-
shadow.appendChild(style);
|
|
70
|
-
const wrapper = document.createElement("span");
|
|
71
|
-
wrapper.className = "wrapper";
|
|
72
|
-
wrapper.setAttribute("role", "button");
|
|
73
|
-
wrapper.setAttribute("tabindex", "0");
|
|
74
|
-
wrapper.appendChild(document.createElement("slot"));
|
|
75
|
-
shadow.appendChild(wrapper);
|
|
76
|
-
this._wrapper = wrapper;
|
|
77
|
-
wrapper.addEventListener("mousedown", () => this._handleMouseDown());
|
|
78
|
-
wrapper.addEventListener("mouseup", () => this._handleMouseUpOrLeave());
|
|
79
|
-
wrapper.addEventListener("mouseleave", () => this._handleMouseUpOrLeave());
|
|
80
|
-
wrapper.addEventListener("mouseenter", () => this._handleMouseEnter());
|
|
81
|
-
wrapper.addEventListener("click", (e) => this._handleClick(e));
|
|
82
|
-
wrapper.addEventListener("touchstart", () => this._handleMouseDown());
|
|
83
|
-
wrapper.addEventListener("touchend", () => this._handleMouseUpOrLeave());
|
|
84
|
-
wrapper.addEventListener("touchcancel", () => this._handleMouseUpOrLeave());
|
|
85
|
-
wrapper.addEventListener("blur", () => this._handleBlur());
|
|
86
|
-
}
|
|
87
|
-
attributeChangedCallback(name, _oldVal, newVal) {
|
|
88
|
-
if (name === "is-selecting") {
|
|
89
|
-
this._isSelecting = newVal !== null;
|
|
90
|
-
this._updateActiveState();
|
|
91
|
-
} else if (name === "press-duration") this._pressDuration = newVal !== null ? parseInt(newVal, 10) : DEFAULT_PRESS_DURATION;
|
|
92
|
-
}
|
|
93
|
-
connectedCallback() {
|
|
94
|
-
this._clickOutsideHandler = (e) => {
|
|
95
|
-
if (!e.composedPath().includes(this)) {
|
|
96
|
-
this._isSelectingState = false;
|
|
97
|
-
this._dispatch("intlayer:click-outside");
|
|
98
|
-
this._updateActiveState();
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
document.addEventListener("mousedown", this._clickOutsideHandler);
|
|
102
|
-
}
|
|
103
|
-
disconnectedCallback() {
|
|
104
|
-
if (this._clickOutsideHandler) {
|
|
105
|
-
document.removeEventListener("mousedown", this._clickOutsideHandler);
|
|
106
|
-
this._clickOutsideHandler = null;
|
|
107
|
-
}
|
|
108
|
-
this._clearPressTimer();
|
|
109
|
-
}
|
|
110
|
-
_updateActiveState() {
|
|
111
|
-
if (this._isSelecting || this._isSelectingState || this._isHovered) this._wrapper.setAttribute("data-active", "");
|
|
112
|
-
else this._wrapper.removeAttribute("data-active");
|
|
113
|
-
}
|
|
114
|
-
_clearPressTimer() {
|
|
115
|
-
if (this._pressTimer !== null) {
|
|
116
|
-
clearTimeout(this._pressTimer);
|
|
117
|
-
this._pressTimer = null;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
_dispatch(eventName) {
|
|
121
|
-
this.dispatchEvent(new CustomEvent(eventName, {
|
|
122
|
-
bubbles: true,
|
|
123
|
-
composed: true
|
|
124
|
-
}));
|
|
125
|
-
}
|
|
126
|
-
_handleMouseDown() {
|
|
127
|
-
this._clearPressTimer();
|
|
128
|
-
this._pressTimer = setTimeout(() => {
|
|
129
|
-
this._isSelectingState = true;
|
|
130
|
-
this._updateActiveState();
|
|
131
|
-
this._dispatch("intlayer:press");
|
|
132
|
-
}, this._pressDuration);
|
|
133
|
-
}
|
|
134
|
-
_handleMouseEnter() {
|
|
135
|
-
this._isHovered = true;
|
|
136
|
-
this._updateActiveState();
|
|
137
|
-
this._dispatch("intlayer:hover");
|
|
138
|
-
}
|
|
139
|
-
_handleMouseUpOrLeave() {
|
|
140
|
-
if (this._isHovered) {
|
|
141
|
-
this._isHovered = false;
|
|
142
|
-
this._dispatch("intlayer:unhover");
|
|
143
|
-
}
|
|
144
|
-
this._clearPressTimer();
|
|
145
|
-
this._updateActiveState();
|
|
146
|
-
}
|
|
147
|
-
_handleClick(e) {
|
|
148
|
-
if (this._isSelecting || this._isSelectingState) {
|
|
149
|
-
e.preventDefault();
|
|
150
|
-
e.stopPropagation();
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
_handleBlur() {
|
|
154
|
-
this._isSelectingState = false;
|
|
155
|
-
this._updateActiveState();
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
//#endregion
|
|
160
|
-
exports.IntlayerContentSelectorElement = IntlayerContentSelectorElement;
|
|
161
|
-
//# sourceMappingURL=ContentSelector.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.cjs","names":[],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs"],"sourcesContent":["//#region src/components/ContentSelector.ts\nconst DEFAULT_PRESS_DURATION = 250;\nconst STYLES = `\n :host {\n display: contents;\n }\n\n .wrapper {\n display: inline-block;\n cursor: pointer;\n user-select: none;\n border-radius: 0.375rem;\n outline-width: 2px;\n outline-offset: 4px;\n outline-style: solid;\n outline-color: transparent;\n transition: all 100ms 50ms ease-in-out;\n }\n\n .wrapper[data-active] {\n outline-color: inherit;\n }\n`;\nconst _HTMLElement = typeof HTMLElement !== \"undefined\" ? HTMLElement : class {};\n/**\n* <intlayer-content-selector>\n*\n* A framework-agnostic web component that wraps content with Intlayer editor\n* selection UI (hover outline, long-press to select, click-outside to deselect).\n*\n* @fires intlayer:press - Fired after a long press (pressDuration ms). Bubbles.\n* @fires intlayer:hover - Fired on mouseenter. Bubbles.\n* @fires intlayer:unhover - Fired on mouseleave / mouseup. Bubbles.\n* @fires intlayer:click-outside - Fired when a click occurs outside the element. Bubbles.\n*\n* @prop {boolean} isSelecting - Whether this element is currently selected (external state)\n* @prop {number} pressDuration - Long-press threshold in ms. Default: 250\n*/\nvar IntlayerContentSelectorElement = class extends _HTMLElement {\n\t_isSelecting = false;\n\t_pressDuration = DEFAULT_PRESS_DURATION;\n\t_isHovered = false;\n\t_isSelectingState = false;\n\t_wrapper;\n\t_pressTimer = null;\n\t_clickOutsideHandler = null;\n\tstatic get observedAttributes() {\n\t\treturn [\"is-selecting\", \"press-duration\"];\n\t}\n\tget isSelecting() {\n\t\treturn this._isSelecting;\n\t}\n\tset isSelecting(v) {\n\t\tthis._isSelecting = v;\n\t\tthis._updateActiveState();\n\t}\n\tget pressDuration() {\n\t\treturn this._pressDuration;\n\t}\n\tset pressDuration(v) {\n\t\tthis._pressDuration = v;\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tconst shadow = this.attachShadow({ mode: \"open\" });\n\t\tconst style = document.createElement(\"style\");\n\t\tstyle.textContent = STYLES;\n\t\tshadow.appendChild(style);\n\t\tconst wrapper = document.createElement(\"span\");\n\t\twrapper.className = \"wrapper\";\n\t\twrapper.setAttribute(\"role\", \"button\");\n\t\twrapper.setAttribute(\"tabindex\", \"0\");\n\t\twrapper.appendChild(document.createElement(\"slot\"));\n\t\tshadow.appendChild(wrapper);\n\t\tthis._wrapper = wrapper;\n\t\twrapper.addEventListener(\"mousedown\", () => this._handleMouseDown());\n\t\twrapper.addEventListener(\"mouseup\", () => this._handleMouseUpOrLeave());\n\t\twrapper.addEventListener(\"mouseleave\", () => this._handleMouseUpOrLeave());\n\t\twrapper.addEventListener(\"mouseenter\", () => this._handleMouseEnter());\n\t\twrapper.addEventListener(\"click\", (e) => this._handleClick(e));\n\t\twrapper.addEventListener(\"touchstart\", () => this._handleMouseDown());\n\t\twrapper.addEventListener(\"touchend\", () => this._handleMouseUpOrLeave());\n\t\twrapper.addEventListener(\"touchcancel\", () => this._handleMouseUpOrLeave());\n\t\twrapper.addEventListener(\"blur\", () => this._handleBlur());\n\t}\n\tattributeChangedCallback(name, _oldVal, newVal) {\n\t\tif (name === \"is-selecting\") {\n\t\t\tthis._isSelecting = newVal !== null;\n\t\t\tthis._updateActiveState();\n\t\t} else if (name === \"press-duration\") this._pressDuration = newVal !== null ? parseInt(newVal, 10) : DEFAULT_PRESS_DURATION;\n\t}\n\tconnectedCallback() {\n\t\tthis._clickOutsideHandler = (e) => {\n\t\t\tif (!e.composedPath().includes(this)) {\n\t\t\t\tthis._isSelectingState = false;\n\t\t\t\tthis._dispatch(\"intlayer:click-outside\");\n\t\t\t\tthis._updateActiveState();\n\t\t\t}\n\t\t};\n\t\tdocument.addEventListener(\"mousedown\", this._clickOutsideHandler);\n\t}\n\tdisconnectedCallback() {\n\t\tif (this._clickOutsideHandler) {\n\t\t\tdocument.removeEventListener(\"mousedown\", this._clickOutsideHandler);\n\t\t\tthis._clickOutsideHandler = null;\n\t\t}\n\t\tthis._clearPressTimer();\n\t}\n\t_updateActiveState() {\n\t\tif (this._isSelecting || this._isSelectingState || this._isHovered) this._wrapper.setAttribute(\"data-active\", \"\");\n\t\telse this._wrapper.removeAttribute(\"data-active\");\n\t}\n\t_clearPressTimer() {\n\t\tif (this._pressTimer !== null) {\n\t\t\tclearTimeout(this._pressTimer);\n\t\t\tthis._pressTimer = null;\n\t\t}\n\t}\n\t_dispatch(eventName) {\n\t\tthis.dispatchEvent(new CustomEvent(eventName, {\n\t\t\tbubbles: true,\n\t\t\tcomposed: true\n\t\t}));\n\t}\n\t_handleMouseDown() {\n\t\tthis._clearPressTimer();\n\t\tthis._pressTimer = setTimeout(() => {\n\t\t\tthis._isSelectingState = true;\n\t\t\tthis._updateActiveState();\n\t\t\tthis._dispatch(\"intlayer:press\");\n\t\t}, this._pressDuration);\n\t}\n\t_handleMouseEnter() {\n\t\tthis._isHovered = true;\n\t\tthis._updateActiveState();\n\t\tthis._dispatch(\"intlayer:hover\");\n\t}\n\t_handleMouseUpOrLeave() {\n\t\tif (this._isHovered) {\n\t\t\tthis._isHovered = false;\n\t\t\tthis._dispatch(\"intlayer:unhover\");\n\t\t}\n\t\tthis._clearPressTimer();\n\t\tthis._updateActiveState();\n\t}\n\t_handleClick(e) {\n\t\tif (this._isSelecting || this._isSelectingState) {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t}\n\t}\n\t_handleBlur() {\n\t\tthis._isSelectingState = false;\n\t\tthis._updateActiveState();\n\t}\n};\n\n//#endregion\nexport { IntlayerContentSelectorElement };\n//# sourceMappingURL=ContentSelector.mjs.map"],"mappings":"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"}
|
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
const require_globalManager = require('../core/globalManager.cjs');
|
|
3
|
-
let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
|
|
4
|
-
_intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType, 1);
|
|
5
|
-
let _intlayer_core_utils = require("@intlayer/core/utils");
|
|
6
|
-
|
|
7
|
-
//#region ../../packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs
|
|
8
|
-
const _HTMLElement = typeof HTMLElement !== "undefined" ? HTMLElement : class {};
|
|
9
|
-
/**
|
|
10
|
-
* <intlayer-content-selector-wrapper>
|
|
11
|
-
*
|
|
12
|
-
* Framework-agnostic web component that wraps content with the Intlayer editor
|
|
13
|
-
* selection UI. It replaces the per-framework ContentSelectorWrapper components
|
|
14
|
-
* (Vue, Svelte, Solid, Preact).
|
|
15
|
-
*
|
|
16
|
-
* It reads from the global EditorStateManager singleton (set by initEditorClient)
|
|
17
|
-
* and conditionally renders <intlayer-content-selector> around its slot content
|
|
18
|
-
* when the editor is active and the app is running inside an iframe.
|
|
19
|
-
*
|
|
20
|
-
* @attr {string} key-path - JSON-serialized KeyPath[] for this content node
|
|
21
|
-
* @attr {string} dictionary-key - The dictionary key owning this content node
|
|
22
|
-
*/
|
|
23
|
-
var IntlayerContentSelectorWrapperElement = class extends _HTMLElement {
|
|
24
|
-
_keyPathJson = "[]";
|
|
25
|
-
_dictionaryKey = "";
|
|
26
|
-
_editorEnabled = false;
|
|
27
|
-
_isInIframe = false;
|
|
28
|
-
_isSelected = false;
|
|
29
|
-
_editedValue = void 0;
|
|
30
|
-
_renderState = null;
|
|
31
|
-
_selector = null;
|
|
32
|
-
_unsubManager = null;
|
|
33
|
-
_unsubEnabled = null;
|
|
34
|
-
_unsubFocused = null;
|
|
35
|
-
_unsubEditedContent = null;
|
|
36
|
-
static get observedAttributes() {
|
|
37
|
-
return ["key-path", "dictionary-key"];
|
|
38
|
-
}
|
|
39
|
-
get keyPathJson() {
|
|
40
|
-
return this._keyPathJson;
|
|
41
|
-
}
|
|
42
|
-
set keyPathJson(v) {
|
|
43
|
-
this._keyPathJson = v;
|
|
44
|
-
const manager = require_globalManager.getGlobalEditorManager();
|
|
45
|
-
if (manager) this._updateEditedValue(manager);
|
|
46
|
-
}
|
|
47
|
-
get dictionaryKey() {
|
|
48
|
-
return this._dictionaryKey;
|
|
49
|
-
}
|
|
50
|
-
set dictionaryKey(v) {
|
|
51
|
-
this._dictionaryKey = v;
|
|
52
|
-
const manager = require_globalManager.getGlobalEditorManager();
|
|
53
|
-
if (manager) this._updateEditedValue(manager);
|
|
54
|
-
}
|
|
55
|
-
constructor() {
|
|
56
|
-
super();
|
|
57
|
-
const shadow = this.attachShadow({ mode: "open" });
|
|
58
|
-
const style = document.createElement("style");
|
|
59
|
-
style.textContent = ":host { display: contents; }";
|
|
60
|
-
shadow.appendChild(style);
|
|
61
|
-
}
|
|
62
|
-
attributeChangedCallback(name, _oldVal, newVal) {
|
|
63
|
-
if (name === "key-path") {
|
|
64
|
-
this._keyPathJson = newVal ?? "[]";
|
|
65
|
-
const manager = require_globalManager.getGlobalEditorManager();
|
|
66
|
-
if (manager) this._updateEditedValue(manager);
|
|
67
|
-
} else if (name === "dictionary-key") {
|
|
68
|
-
this._dictionaryKey = newVal ?? "";
|
|
69
|
-
const manager = require_globalManager.getGlobalEditorManager();
|
|
70
|
-
if (manager) this._updateEditedValue(manager);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
connectedCallback() {
|
|
74
|
-
if (typeof window !== "undefined") this._isInIframe = window.self !== window.top;
|
|
75
|
-
this._subscribeToManager();
|
|
76
|
-
this._render();
|
|
77
|
-
}
|
|
78
|
-
disconnectedCallback() {
|
|
79
|
-
this._teardown();
|
|
80
|
-
}
|
|
81
|
-
_teardown() {
|
|
82
|
-
this._unsubManager?.();
|
|
83
|
-
this._unsubEnabled?.();
|
|
84
|
-
this._unsubFocused?.();
|
|
85
|
-
this._unsubEditedContent?.();
|
|
86
|
-
this._unsubManager = null;
|
|
87
|
-
this._unsubEnabled = null;
|
|
88
|
-
this._unsubFocused = null;
|
|
89
|
-
this._unsubEditedContent = null;
|
|
90
|
-
}
|
|
91
|
-
_getRawKeyPath() {
|
|
92
|
-
try {
|
|
93
|
-
return JSON.parse(this._keyPathJson);
|
|
94
|
-
} catch {
|
|
95
|
-
return [];
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
_getFilteredKeyPath() {
|
|
99
|
-
return this._getRawKeyPath().filter((keyPath) => keyPath.type !== _intlayer_types_nodeType.TRANSLATION);
|
|
100
|
-
}
|
|
101
|
-
_updateEditedValue(manager) {
|
|
102
|
-
const filteredKeyPath = this._getFilteredKeyPath();
|
|
103
|
-
if (!this._dictionaryKey || filteredKeyPath.length === 0) {
|
|
104
|
-
this._editedValue = void 0;
|
|
105
|
-
this._render();
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
const rawKeyPath = this._getRawKeyPath();
|
|
109
|
-
const lastStepType = rawKeyPath[rawKeyPath.length - 1]?.type;
|
|
110
|
-
if (lastStepType === _intlayer_types_nodeType.MARKDOWN || lastStepType === _intlayer_types_nodeType.HTML || lastStepType === _intlayer_types_nodeType.INSERTION || lastStepType === _intlayer_types_nodeType.FILE) {
|
|
111
|
-
this._editedValue = void 0;
|
|
112
|
-
this._render();
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
let value = manager.getContentValue(this._dictionaryKey, filteredKeyPath);
|
|
116
|
-
if (value !== null && value !== void 0 && typeof value === "object" && value.nodeType === _intlayer_types_nodeType.TRANSLATION) {
|
|
117
|
-
const locale = manager.currentLocale.value;
|
|
118
|
-
value = locale ? value[_intlayer_types_nodeType.TRANSLATION][locale] : void 0;
|
|
119
|
-
}
|
|
120
|
-
this._editedValue = value;
|
|
121
|
-
this._render();
|
|
122
|
-
}
|
|
123
|
-
_updateIsSelected(focusedContent) {
|
|
124
|
-
if (!focusedContent) {
|
|
125
|
-
this._isSelected = false;
|
|
126
|
-
this._updateSelectorAttr();
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const keyPath = this._getFilteredKeyPath();
|
|
130
|
-
const wasSelected = this._isSelected;
|
|
131
|
-
this._isSelected = focusedContent.dictionaryKey === this._dictionaryKey && (focusedContent.keyPath?.length ?? 0) > 0 && (0, _intlayer_core_utils.isSameKeyPath)(focusedContent.keyPath ?? [], keyPath);
|
|
132
|
-
this._updateSelectorAttr();
|
|
133
|
-
if (this._isSelected && !wasSelected) this._scrollIntoViewIfNeeded();
|
|
134
|
-
}
|
|
135
|
-
_scrollIntoViewIfNeeded() {
|
|
136
|
-
try {
|
|
137
|
-
let rect;
|
|
138
|
-
if (this._selector) {
|
|
139
|
-
const innerWrapper = this._selector.shadowRoot?.querySelector(".wrapper");
|
|
140
|
-
if (innerWrapper) {
|
|
141
|
-
const r = innerWrapper.getBoundingClientRect();
|
|
142
|
-
if (r.width > 0 || r.height > 0) rect = r;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
if (!rect && this.childNodes.length > 0) {
|
|
146
|
-
const range = document.createRange();
|
|
147
|
-
range.selectNodeContents(this);
|
|
148
|
-
const r = range.getBoundingClientRect();
|
|
149
|
-
if (r.width > 0 || r.height > 0) rect = r;
|
|
150
|
-
}
|
|
151
|
-
if (!rect) rect = this.getBoundingClientRect();
|
|
152
|
-
const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
153
|
-
const viewportWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
154
|
-
if (!(rect.width > 0 && rect.height > 0 && rect.bottom > 0 && rect.right > 0 && rect.top < viewportHeight && rect.left < viewportWidth)) {
|
|
155
|
-
const scrollY = window.scrollY ?? document.documentElement.scrollTop;
|
|
156
|
-
const targetScrollY = rect.top + scrollY - viewportHeight * .25;
|
|
157
|
-
window.scrollTo({
|
|
158
|
-
top: Math.max(0, targetScrollY),
|
|
159
|
-
behavior: "smooth"
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
} catch {}
|
|
163
|
-
}
|
|
164
|
-
_updateSelectorAttr() {
|
|
165
|
-
if (!this._selector) return;
|
|
166
|
-
if (this._isSelected) this._selector.setAttribute("is-selecting", "");
|
|
167
|
-
else this._selector.removeAttribute("is-selecting");
|
|
168
|
-
}
|
|
169
|
-
_subscribeToManager() {
|
|
170
|
-
const manager = require_globalManager.getGlobalEditorManager();
|
|
171
|
-
if (manager) this._setupManagerSubscriptions(manager);
|
|
172
|
-
this._unsubManager = require_globalManager.onGlobalEditorManagerChange((m) => {
|
|
173
|
-
this._unsubEnabled?.();
|
|
174
|
-
this._unsubFocused?.();
|
|
175
|
-
this._unsubEditedContent?.();
|
|
176
|
-
this._unsubEnabled = null;
|
|
177
|
-
this._unsubFocused = null;
|
|
178
|
-
this._unsubEditedContent = null;
|
|
179
|
-
if (m) this._setupManagerSubscriptions(m);
|
|
180
|
-
else {
|
|
181
|
-
this._editorEnabled = false;
|
|
182
|
-
this._isSelected = false;
|
|
183
|
-
this._editedValue = void 0;
|
|
184
|
-
this._render();
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
_setupManagerSubscriptions(manager) {
|
|
189
|
-
this._editorEnabled = manager.editorEnabled.value ?? false;
|
|
190
|
-
this._updateIsSelected(manager.focusedContent.value);
|
|
191
|
-
this._updateEditedValue(manager);
|
|
192
|
-
const handleEnabledChange = (e) => {
|
|
193
|
-
this._editorEnabled = e.detail;
|
|
194
|
-
this._render();
|
|
195
|
-
};
|
|
196
|
-
const handleFocusedChange = (e) => {
|
|
197
|
-
this._updateIsSelected(e.detail);
|
|
198
|
-
};
|
|
199
|
-
const handleEditedContentChange = () => {
|
|
200
|
-
this._updateEditedValue(manager);
|
|
201
|
-
};
|
|
202
|
-
manager.editorEnabled.addEventListener("change", handleEnabledChange);
|
|
203
|
-
manager.focusedContent.addEventListener("change", handleFocusedChange);
|
|
204
|
-
manager.editedContent.addEventListener("change", handleEditedContentChange);
|
|
205
|
-
this._unsubEnabled = () => manager.editorEnabled.removeEventListener("change", handleEnabledChange);
|
|
206
|
-
this._unsubFocused = () => manager.focusedContent.removeEventListener("change", handleFocusedChange);
|
|
207
|
-
this._unsubEditedContent = () => manager.editedContent.removeEventListener("change", handleEditedContentChange);
|
|
208
|
-
}
|
|
209
|
-
_handlePress(e) {
|
|
210
|
-
e.stopPropagation();
|
|
211
|
-
const manager = require_globalManager.getGlobalEditorManager();
|
|
212
|
-
if (!manager) return;
|
|
213
|
-
manager.focusedContent.set({
|
|
214
|
-
dictionaryKey: this._dictionaryKey,
|
|
215
|
-
keyPath: this._getFilteredKeyPath()
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
_handleHover(e) {
|
|
219
|
-
e.stopPropagation();
|
|
220
|
-
require_globalManager.getGlobalEditorManager()?.messenger.send(`INTLAYER_HOVERED_CONTENT_CHANGED/post`, {
|
|
221
|
-
dictionaryKey: this._dictionaryKey,
|
|
222
|
-
keyPath: this._getFilteredKeyPath()
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
_handleUnhover(e) {
|
|
226
|
-
e.stopPropagation();
|
|
227
|
-
require_globalManager.getGlobalEditorManager()?.messenger.send(`INTLAYER_HOVERED_CONTENT_CHANGED/post`, null);
|
|
228
|
-
}
|
|
229
|
-
_render() {
|
|
230
|
-
const useWrapper = this._isInIframe && this._editorEnabled;
|
|
231
|
-
const editedValue = this._editedValue;
|
|
232
|
-
const newState = !useWrapper ? "simple" : typeof editedValue === "string" || typeof editedValue === "number" || typeof editedValue === "boolean" ? "wrapped-text" : "wrapped-slot";
|
|
233
|
-
if (this._renderState !== newState) {
|
|
234
|
-
this._rebuildContent(newState);
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
if (newState !== "simple" && this._selector) {
|
|
238
|
-
this._updateSelectorAttr();
|
|
239
|
-
if (newState === "wrapped-text" && this._selector.firstChild?.nodeType === Node.TEXT_NODE) this._selector.firstChild.data = String(editedValue);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
_rebuildContent(state) {
|
|
243
|
-
const shadow = this.shadowRoot;
|
|
244
|
-
while (shadow.childNodes.length > 1) shadow.removeChild(shadow.lastChild);
|
|
245
|
-
this._selector = null;
|
|
246
|
-
if (state === "simple") shadow.appendChild(document.createElement("slot"));
|
|
247
|
-
else {
|
|
248
|
-
const selector = document.createElement("intlayer-content-selector");
|
|
249
|
-
this._selector = selector;
|
|
250
|
-
if (this._isSelected) selector.setAttribute("is-selecting", "");
|
|
251
|
-
selector.addEventListener("intlayer:press", (e) => this._handlePress(e));
|
|
252
|
-
selector.addEventListener("intlayer:hover", (e) => this._handleHover(e));
|
|
253
|
-
selector.addEventListener("intlayer:unhover", (e) => this._handleUnhover(e));
|
|
254
|
-
if (state === "wrapped-text") selector.appendChild(document.createTextNode(String(this._editedValue)));
|
|
255
|
-
else selector.appendChild(document.createElement("slot"));
|
|
256
|
-
shadow.appendChild(selector);
|
|
257
|
-
}
|
|
258
|
-
this._renderState = state;
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
const defineIntlayerContentSelectorWrapper = () => {
|
|
262
|
-
if (typeof customElements === "undefined") return;
|
|
263
|
-
if (!customElements.get("intlayer-content-selector-wrapper")) customElements.define("intlayer-content-selector-wrapper", IntlayerContentSelectorWrapperElement);
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
//#endregion
|
|
267
|
-
exports.IntlayerContentSelectorWrapperElement = IntlayerContentSelectorWrapperElement;
|
|
268
|
-
exports.defineIntlayerContentSelectorWrapper = defineIntlayerContentSelectorWrapper;
|
|
269
|
-
//# sourceMappingURL=ContentSelectorWrapper.cjs.map
|