intlayer-editor 2.1.12 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +9 -9
  2. package/dist/cjs/{client/ContentEditionLayout.cjs → ContentEditionLayout.cjs} +2 -2
  3. package/dist/cjs/ContentEditionLayout.cjs.map +1 -0
  4. package/dist/cjs/{client/ContentEditorProvider.cjs → ContentEditorProvider.cjs} +9 -1
  5. package/dist/cjs/ContentEditorProvider.cjs.map +1 -0
  6. package/dist/cjs/{client/ContentSelectorWrapper.cjs → ContentSelectorWrapper.cjs} +8 -10
  7. package/dist/cjs/ContentSelectorWrapper.cjs.map +1 -0
  8. package/dist/cjs/{client/DictionaryEditionDrawer → DictionaryEditionDrawer}/DictionaryEditionDrawer.cjs +47 -38
  9. package/dist/cjs/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs.map +1 -0
  10. package/dist/cjs/{client/DictionaryEditionDrawer → DictionaryEditionDrawer}/index.cjs +1 -3
  11. package/dist/cjs/DictionaryEditionDrawer/index.cjs.map +1 -0
  12. package/dist/cjs/{client/DictionaryEditionDrawer → DictionaryEditionDrawer}/useDictionaryEditionDrawer.cjs +12 -9
  13. package/dist/cjs/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs.map +1 -0
  14. package/dist/cjs/{client/DictionaryListDrawer → DictionaryListDrawer}/DictionaryListDrawer.cjs +16 -23
  15. package/dist/cjs/DictionaryListDrawer/DictionaryListDrawer.cjs.map +1 -0
  16. package/dist/cjs/DictionaryListDrawer/index.cjs.map +1 -0
  17. package/dist/cjs/DictionaryListDrawer/useDictionaryListDrawer.cjs.map +1 -0
  18. package/dist/cjs/index.cjs.map +1 -0
  19. package/dist/cjs/{client/renderContentEditor.cjs → renderContentEditor.cjs} +10 -4
  20. package/dist/cjs/renderContentEditor.cjs.map +1 -0
  21. package/dist/cjs/{client/useEditorServer.cjs → useEditorServer.cjs} +4 -4
  22. package/dist/cjs/useEditorServer.cjs.map +1 -0
  23. package/dist/esm/{client/ContentEditionLayout.mjs → ContentEditionLayout.mjs} +2 -2
  24. package/dist/esm/ContentEditionLayout.mjs.map +1 -0
  25. package/dist/esm/{client/ContentEditorProvider.mjs → ContentEditorProvider.mjs} +11 -2
  26. package/dist/esm/ContentEditorProvider.mjs.map +1 -0
  27. package/dist/esm/{client/ContentSelectorWrapper.mjs → ContentSelectorWrapper.mjs} +14 -11
  28. package/dist/esm/ContentSelectorWrapper.mjs.map +1 -0
  29. package/dist/esm/{client/DictionaryEditionDrawer → DictionaryEditionDrawer}/DictionaryEditionDrawer.mjs +50 -26
  30. package/dist/esm/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs.map +1 -0
  31. package/dist/esm/{client/DictionaryEditionDrawer → DictionaryEditionDrawer}/index.mjs +0 -1
  32. package/dist/esm/DictionaryEditionDrawer/index.mjs.map +1 -0
  33. package/dist/esm/{client/DictionaryEditionDrawer → DictionaryEditionDrawer}/useDictionaryEditionDrawer.mjs +10 -6
  34. package/dist/esm/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs.map +1 -0
  35. package/dist/esm/{client/DictionaryListDrawer → DictionaryListDrawer}/DictionaryListDrawer.mjs +17 -13
  36. package/dist/esm/DictionaryListDrawer/DictionaryListDrawer.mjs.map +1 -0
  37. package/dist/esm/DictionaryListDrawer/index.mjs.map +1 -0
  38. package/dist/esm/DictionaryListDrawer/useDictionaryListDrawer.mjs.map +1 -0
  39. package/dist/esm/index.mjs.map +1 -0
  40. package/dist/esm/{client/renderContentEditor.mjs → renderContentEditor.mjs} +10 -4
  41. package/dist/esm/renderContentEditor.mjs.map +1 -0
  42. package/dist/esm/{client/useEditorServer.mjs → useEditorServer.mjs} +3 -3
  43. package/dist/esm/useEditorServer.mjs.map +1 -0
  44. package/dist/types/ContentEditionLayout.d.ts +11 -0
  45. package/dist/types/ContentEditionLayout.d.ts.map +1 -0
  46. package/dist/types/ContentEditorProvider.d.ts +21 -0
  47. package/dist/types/ContentEditorProvider.d.ts.map +1 -0
  48. package/dist/types/ContentSelectorWrapper.d.ts +11 -0
  49. package/dist/types/ContentSelectorWrapper.d.ts.map +1 -0
  50. package/dist/types/DictionaryEditionDrawer/DictionaryEditionDrawer.d.ts +21 -0
  51. package/dist/types/DictionaryEditionDrawer/DictionaryEditionDrawer.d.ts.map +1 -0
  52. package/dist/types/DictionaryEditionDrawer/index.d.ts +3 -0
  53. package/dist/types/DictionaryEditionDrawer/index.d.ts.map +1 -0
  54. package/dist/types/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.ts +31 -0
  55. package/dist/types/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.ts.map +1 -0
  56. package/dist/types/DictionaryListDrawer/DictionaryListDrawer.d.ts +3 -0
  57. package/dist/types/DictionaryListDrawer/DictionaryListDrawer.d.ts.map +1 -0
  58. package/dist/types/DictionaryListDrawer/index.d.ts +3 -0
  59. package/dist/types/DictionaryListDrawer/index.d.ts.map +1 -0
  60. package/dist/types/DictionaryListDrawer/useDictionaryListDrawer.d.ts +7 -0
  61. package/dist/types/DictionaryListDrawer/useDictionaryListDrawer.d.ts.map +1 -0
  62. package/dist/types/index.d.ts +7 -0
  63. package/dist/types/index.d.ts.map +1 -0
  64. package/dist/types/renderContentEditor.d.ts +14 -0
  65. package/dist/types/renderContentEditor.d.ts.map +1 -0
  66. package/dist/types/useEditorServer.d.ts +4 -0
  67. package/dist/types/useEditorServer.d.ts.map +1 -0
  68. package/package.json +38 -34
  69. package/dist/cjs/client/ContentEditionLayout.cjs.map +0 -1
  70. package/dist/cjs/client/ContentEditionLayout.d.ts +0 -13
  71. package/dist/cjs/client/ContentEditorProvider.cjs.map +0 -1
  72. package/dist/cjs/client/ContentEditorProvider.d.ts +0 -23
  73. package/dist/cjs/client/ContentSelectorWrapper.cjs.map +0 -1
  74. package/dist/cjs/client/ContentSelectorWrapper.d.ts +0 -12
  75. package/dist/cjs/client/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs.map +0 -1
  76. package/dist/cjs/client/DictionaryEditionDrawer/DictionaryEditionDrawer.d.ts +0 -28
  77. package/dist/cjs/client/DictionaryEditionDrawer/index.cjs.map +0 -1
  78. package/dist/cjs/client/DictionaryEditionDrawer/index.d.ts +0 -9
  79. package/dist/cjs/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs.map +0 -1
  80. package/dist/cjs/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.ts +0 -32
  81. package/dist/cjs/client/DictionaryEditionDrawer/useEditedContentStore.cjs +0 -98
  82. package/dist/cjs/client/DictionaryEditionDrawer/useEditedContentStore.cjs.map +0 -1
  83. package/dist/cjs/client/DictionaryEditionDrawer/useEditedContentStore.d.ts +0 -28
  84. package/dist/cjs/client/DictionaryEditionDrawer/useFocusContentStore.cjs +0 -33
  85. package/dist/cjs/client/DictionaryEditionDrawer/useFocusContentStore.cjs.map +0 -1
  86. package/dist/cjs/client/DictionaryEditionDrawer/useFocusContentStore.d.ts +0 -16
  87. package/dist/cjs/client/DictionaryListDrawer/DictionaryListDrawer.cjs.map +0 -1
  88. package/dist/cjs/client/DictionaryListDrawer/DictionaryListDrawer.d.ts +0 -5
  89. package/dist/cjs/client/DictionaryListDrawer/index.cjs.map +0 -1
  90. package/dist/cjs/client/DictionaryListDrawer/index.d.ts +0 -3
  91. package/dist/cjs/client/DictionaryListDrawer/useDictionaryListDrawer.cjs.map +0 -1
  92. package/dist/cjs/client/DictionaryListDrawer/useDictionaryListDrawer.d.ts +0 -8
  93. package/dist/cjs/client/index.cjs.map +0 -1
  94. package/dist/cjs/client/index.d.ts +0 -15
  95. package/dist/cjs/client/renderContentEditor.cjs.map +0 -1
  96. package/dist/cjs/client/renderContentEditor.d.ts +0 -15
  97. package/dist/cjs/client/useEditorServer.cjs.map +0 -1
  98. package/dist/cjs/client/useEditorServer.d.ts +0 -5
  99. package/dist/cjs/server/formatPrettier.cjs +0 -51
  100. package/dist/cjs/server/formatPrettier.cjs.map +0 -1
  101. package/dist/cjs/server/formatPrettier.d.ts +0 -6
  102. package/dist/cjs/server/index.cjs +0 -68
  103. package/dist/cjs/server/index.cjs.map +0 -1
  104. package/dist/cjs/server/index.d.ts +0 -3
  105. package/dist/cjs/server/processEdition.cjs +0 -157
  106. package/dist/cjs/server/processEdition.cjs.map +0 -1
  107. package/dist/cjs/server/processEdition.d.ts +0 -12
  108. package/dist/esm/client/ContentEditionLayout.d.mts +0 -13
  109. package/dist/esm/client/ContentEditionLayout.mjs.map +0 -1
  110. package/dist/esm/client/ContentEditorProvider.d.mts +0 -23
  111. package/dist/esm/client/ContentEditorProvider.mjs.map +0 -1
  112. package/dist/esm/client/ContentSelectorWrapper.d.mts +0 -12
  113. package/dist/esm/client/ContentSelectorWrapper.mjs.map +0 -1
  114. package/dist/esm/client/DictionaryEditionDrawer/DictionaryEditionDrawer.d.mts +0 -28
  115. package/dist/esm/client/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs.map +0 -1
  116. package/dist/esm/client/DictionaryEditionDrawer/index.d.mts +0 -9
  117. package/dist/esm/client/DictionaryEditionDrawer/index.mjs.map +0 -1
  118. package/dist/esm/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.mts +0 -32
  119. package/dist/esm/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs.map +0 -1
  120. package/dist/esm/client/DictionaryEditionDrawer/useEditedContentStore.d.mts +0 -28
  121. package/dist/esm/client/DictionaryEditionDrawer/useEditedContentStore.mjs +0 -74
  122. package/dist/esm/client/DictionaryEditionDrawer/useEditedContentStore.mjs.map +0 -1
  123. package/dist/esm/client/DictionaryEditionDrawer/useFocusContentStore.d.mts +0 -16
  124. package/dist/esm/client/DictionaryEditionDrawer/useFocusContentStore.mjs +0 -9
  125. package/dist/esm/client/DictionaryEditionDrawer/useFocusContentStore.mjs.map +0 -1
  126. package/dist/esm/client/DictionaryListDrawer/DictionaryListDrawer.d.mts +0 -5
  127. package/dist/esm/client/DictionaryListDrawer/DictionaryListDrawer.mjs.map +0 -1
  128. package/dist/esm/client/DictionaryListDrawer/index.d.mts +0 -3
  129. package/dist/esm/client/DictionaryListDrawer/index.mjs.map +0 -1
  130. package/dist/esm/client/DictionaryListDrawer/useDictionaryListDrawer.d.mts +0 -8
  131. package/dist/esm/client/DictionaryListDrawer/useDictionaryListDrawer.mjs.map +0 -1
  132. package/dist/esm/client/index.d.mts +0 -15
  133. package/dist/esm/client/index.mjs.map +0 -1
  134. package/dist/esm/client/renderContentEditor.d.mts +0 -15
  135. package/dist/esm/client/renderContentEditor.mjs.map +0 -1
  136. package/dist/esm/client/useEditorServer.d.mts +0 -5
  137. package/dist/esm/client/useEditorServer.mjs.map +0 -1
  138. package/dist/esm/server/formatPrettier.d.mts +0 -6
  139. package/dist/esm/server/formatPrettier.mjs +0 -17
  140. package/dist/esm/server/formatPrettier.mjs.map +0 -1
  141. package/dist/esm/server/index.d.mts +0 -3
  142. package/dist/esm/server/index.mjs +0 -34
  143. package/dist/esm/server/index.mjs.map +0 -1
  144. package/dist/esm/server/processEdition.d.mts +0 -12
  145. package/dist/esm/server/processEdition.mjs +0 -134
  146. package/dist/esm/server/processEdition.mjs.map +0 -1
  147. /package/dist/cjs/{client/DictionaryListDrawer → DictionaryListDrawer}/index.cjs +0 -0
  148. /package/dist/cjs/{client/DictionaryListDrawer → DictionaryListDrawer}/useDictionaryListDrawer.cjs +0 -0
  149. /package/dist/cjs/{client/index.cjs → index.cjs} +0 -0
  150. /package/dist/esm/{client/DictionaryListDrawer → DictionaryListDrawer}/index.mjs +0 -0
  151. /package/dist/esm/{client/DictionaryListDrawer → DictionaryListDrawer}/useDictionaryListDrawer.mjs +0 -0
  152. /package/dist/esm/{client/index.mjs → index.mjs} +0 -0
package/README.md CHANGED
@@ -21,7 +21,7 @@
21
21
 
22
22
  The Intlayer Editor is a tool that transforms your application into a visual editor. With Intlayer Editor, your teams can manage your site's content in all configured languages.
23
23
 
24
- ![Intlayer Editor Interface](https://github.com/aypineau/intlayer/blob/main/docs/assets/enabledpletion.png)
24
+ ![Intlayer Editor Interface](https://github.com/aymericzip/intlayer/blob/main/docs/assets/enabledpletion.png)
25
25
 
26
26
  The `intlayer-editor` package is based on Intlayer and is available for JavaScript applications, such as React (Create React App), Vite + React, and Next.js.
27
27
 
@@ -29,19 +29,19 @@ For more details on how to install the package, see the relevant section below:
29
29
 
30
30
  ### Integrating with Next.js
31
31
 
32
- For integration with Next.js, refer to the [setup guide](https://github.com/aypineau/intlayer/blob/main/docs/docs/intlayer_with_nextjs_en.md).
32
+ For integration with Next.js, refer to the [setup guide](https://github.com/aymericzip/intlayer/blob/main/docs/docs/intlayer_with_nextjs_en.md).
33
33
 
34
34
  ### Integrating with Create React App
35
35
 
36
- For integration with Create React App, refer to the [setup guide](https://github.com/aypineau/intlayer/blob/main/docs/docs/intlayer_with_create_react_app_en.md).
36
+ For integration with Create React App, refer to the [setup guide](https://github.com/aymericzip/intlayer/blob/main/docs/docs/intlayer_with_create_react_app_en.md).
37
37
 
38
38
  ### Integrating with Vite + React
39
39
 
40
- For integration with Vite + React, refer to the [setup guide](https://github.com/aypineau/intlayer/blob/main/docs/docs/intlayer_with_vite+react_en.md).
40
+ For integration with Vite + React, refer to the [setup guide](https://github.com/aymericzip/intlayer/blob/main/docs/docs/intlayer_with_vite+react_en.md).
41
41
 
42
42
  ## How Intlayer Editor Works
43
43
 
44
- Each time you make a change using Intlayer Editor, the server automatically inserts your changes into your [Intlayer declaration files](https://github.com/aypineau/intlayer/blob/main/docs/docs/content_declaration/get_started_en.md), wherever these files are declared in your project.
44
+ Each time you make a change using Intlayer Editor, the server automatically inserts your changes into your [Intlayer declaration files](https://github.com/aymericzip/intlayer/blob/main/docs/docs/content_declaration/get_started_en.md), wherever these files are declared in your project.
45
45
 
46
46
  In this way, you don't have to worry about where the file is declared or about finding your key in your dictionary collection.
47
47
 
@@ -54,11 +54,11 @@ npm install intlayer-editor -D
54
54
  ```
55
55
 
56
56
  ```bash
57
- yarn install intlayer-editor -D
57
+ yarn add intlayer-editor -D
58
58
  ```
59
59
 
60
60
  ```bash
61
- pnpm install intlayer-editor -D
61
+ pnpm add intlayer-editor -D
62
62
  ```
63
63
 
64
64
  In your Intlayer configuration file, you can customize the editor settings:
@@ -73,7 +73,7 @@ const config: IntlayerConfig = {
73
73
  };
74
74
  ```
75
75
 
76
- To see all available parameters, refer to the [configuration documentation](https://github.com/aypineau/intlayer/blob/main/docs/docs/configuration_en.md).
76
+ To see all available parameters, refer to the [configuration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/configuration_en.md).
77
77
 
78
78
  ### Start Editing
79
79
 
@@ -105,6 +105,6 @@ To start both the Next.js server and the Intlayer Editor simultaneously, you can
105
105
 
106
106
  When the editor is installed, enabled, and started, you can view each field indexed by Intlayer by hovering over your content with your cursor.
107
107
 
108
- ![Hovering over content](https://github.com/aypineau/intlayer/blob/main/docs/assets/intlayer_editor_hover_content.png)
108
+ ![Hovering over content](https://github.com/aymericzip/intlayer/blob/main/docs/assets/intlayer_editor_hover_content.png)
109
109
 
110
110
  If your content is outlined, you can long-press it to display the edit drawer.
@@ -32,7 +32,7 @@ const ContentEditionLayout = ({
32
32
  localeList,
33
33
  editorEnabled = true
34
34
  }) => {
35
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ContentEditorProvider.IntlayerEditorProvider, { editorEnabled, children: [
35
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ContentEditorProvider.IntlayerEditorProvider, { editorEnabled, children: [
36
36
  children,
37
37
  editorEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
38
38
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -45,7 +45,7 @@ const ContentEditionLayout = ({
45
45
  ),
46
46
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DictionaryListDrawer.DictionaryListDrawer, {})
47
47
  ] })
48
- ] }) });
48
+ ] });
49
49
  };
50
50
  // Annotate the CommonJS export names for ESM import in node:
51
51
  0 && (module.exports = {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/ContentEditionLayout.tsx"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { FC, ReactNode } from 'react';\nimport { IntlayerEditorProvider } from './ContentEditorProvider';\nimport { DictionaryEditionDrawerController } from './DictionaryEditionDrawer/index';\nimport { DictionaryListDrawer } from './DictionaryListDrawer/index';\n\nexport type ContentEditionLayoutProps = {\n children?: ReactNode;\n locale: Locales;\n localeList: Locales[];\n setLocale: (locale: Locales) => void;\n editorEnabled?: boolean;\n};\n\nexport const ContentEditionLayout: FC<ContentEditionLayoutProps> = ({\n children,\n locale,\n setLocale,\n localeList,\n editorEnabled = true,\n}) => {\n return (\n <IntlayerEditorProvider editorEnabled={editorEnabled}>\n {children}\n\n {editorEnabled && (\n <>\n <DictionaryEditionDrawerController\n locale={locale}\n localeList={localeList}\n setLocale={setLocale}\n />\n <DictionaryListDrawer />\n </>\n )}\n </IntlayerEditorProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BQ;AAxBR,mCAAuC;AACvC,qCAAkD;AAClD,kCAAqC;AAU9B,MAAM,uBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAClB,MAAM;AACJ,SACE,6CAAC,uDAAuB,eACrB;AAAA;AAAA,IAEA,iBACC,4EACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACF;AAAA,MACA,4CAAC,oDAAqB;AAAA,OACxB;AAAA,KAEJ;AAEJ;","names":[]}
@@ -37,7 +37,15 @@ const {
37
37
  const IntlayerEditorProvider = ({
38
38
  children,
39
39
  editorEnabled = enabled
40
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerEditorContext.Provider, { value: { editorEnabled }, children });
40
+ }) => {
41
+ const memoValue = (0, import_react.useMemo)(
42
+ () => ({
43
+ editorEnabled
44
+ }),
45
+ [editorEnabled]
46
+ );
47
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerEditorContext.Provider, { value: memoValue, children });
48
+ };
41
49
  // Annotate the CommonJS export names for ESM import in node:
42
50
  0 && (module.exports = {
43
51
  IntlayerEditorContext,
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/ContentEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n type FC,\n useMemo,\n} from 'react';\n\ntype IntlayerEditorValue = {\n editorEnabled: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerEditorContext = createContext<IntlayerEditorValue>({\n editorEnabled: false,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerEditorContext = () => useContext(IntlayerEditorContext);\n\nexport type IntlayerEditorProviderProps = PropsWithChildren<{\n editorEnabled?: boolean;\n}>;\n\nconst {\n editor: { enabled },\n} = getConfiguration();\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerEditorProvider: FC<IntlayerEditorProviderProps> = ({\n children,\n editorEnabled = enabled,\n}) => {\n const memoValue = useMemo(\n () => ({\n editorEnabled,\n }),\n [editorEnabled]\n );\n\n return (\n <IntlayerEditorContext.Provider value={memoValue}>\n {children}\n </IntlayerEditorContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkDI;AAhDJ,oBAAiC;AACjC,mBAMO;AASA,MAAM,4BAAwB,4BAAmC;AAAA,EACtE,eAAe;AACjB,CAAC;AAKM,MAAM,2BAA2B,UAAM,yBAAW,qBAAqB;AAM9E,MAAM;AAAA,EACJ,QAAQ,EAAE,QAAQ;AACpB,QAAI,gCAAiB;AAKd,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,gBAAgB;AAClB,MAAM;AACJ,QAAM,gBAAY;AAAA,IAChB,OAAO;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,aAAa;AAAA,EAChB;AAEA,SACE,4CAAC,sBAAsB,UAAtB,EAA+B,OAAO,WACpC,UACH;AAEJ;","names":[]}
@@ -35,8 +35,9 @@ const ContentSelectorWrapper = ({
35
35
  keyPath
36
36
  }) => {
37
37
  const { open, getEditedContentValue, focusedContent, isOpen } = (0, import_useDictionaryEditionDrawer.useDictionaryEditionDrawer)(dictionaryId);
38
- const editedValue = getEditedContentValue(dictionaryPath, keyPath);
38
+ const editedValue = getEditedContentValue(dictionaryId, keyPath);
39
39
  const { editorEnabled } = (0, import_react.useContext)(import_ContentEditorProvider.IntlayerEditorContext);
40
+ const [displayedChildren, setDisplayedChildren] = (0, import_react.useState)(children);
40
41
  const handleSelect = (0, import_react.useCallback)(
41
42
  () => open({
42
43
  dictionaryId,
@@ -46,18 +47,15 @@ const ContentSelectorWrapper = ({
46
47
  [dictionaryId, dictionaryPath, keyPath, open]
47
48
  );
48
49
  const isSelected = (isOpen && (focusedContent?.keyPath?.length ?? 0) > 0 && (0, import_core.isSameKeyPath)(focusedContent?.keyPath ?? [], keyPath)) ?? false;
50
+ (0, import_react.useEffect)(() => {
51
+ if (editorEnabled && editedValue && typeof editedValue === "string") {
52
+ setDisplayedChildren(editedValue);
53
+ }
54
+ }, [editedValue, editorEnabled]);
49
55
  if (!editorEnabled) {
50
56
  return children;
51
57
  }
52
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
53
- import_design_system.ContentSelector,
54
- {
55
- onSelect: handleSelect,
56
- isSelecting: isSelected,
57
- popoverContent: "Long press to edit",
58
- children: editedValue ?? children
59
- }
60
- );
58
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.ContentSelector, { onSelect: handleSelect, isSelecting: isSelected, children: displayedChildren });
61
59
  };
62
60
  // Annotate the CommonJS export names for ESM import in node:
63
61
  0 && (module.exports = {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { isSameKeyPath, type KeyPath } from '@intlayer/core';\nimport { ContentSelector } from '@intlayer/design-system';\nimport {\n useCallback,\n useContext,\n useEffect,\n useState,\n type FC,\n type ReactNode,\n} from 'react';\nimport { IntlayerEditorContext } from './ContentEditorProvider';\nimport { useDictionaryEditionDrawer } from './DictionaryEditionDrawer/useDictionaryEditionDrawer';\n\ntype ContentSelectorWrapperProps = {\n children: ReactNode;\n dictionaryId: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n};\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryId,\n dictionaryPath,\n keyPath,\n}) => {\n const { open, getEditedContentValue, focusedContent, isOpen } =\n useDictionaryEditionDrawer(dictionaryId);\n const editedValue = getEditedContentValue(dictionaryId, keyPath);\n const { editorEnabled } = useContext(IntlayerEditorContext);\n const [displayedChildren, setDisplayedChildren] =\n useState<ReactNode>(children);\n\n const handleSelect = useCallback(\n () =>\n open({\n dictionaryId,\n dictionaryPath,\n keyPath,\n }),\n [dictionaryId, dictionaryPath, keyPath, open]\n );\n\n const isSelected =\n (isOpen &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false;\n\n useEffect(() => {\n // Use useEffect to avoid 'Text content does not match server-rendered HTML' error\n if (editorEnabled && editedValue && typeof editedValue === 'string') {\n setDisplayedChildren(editedValue);\n }\n }, [editedValue, editorEnabled]);\n\n if (!editorEnabled) {\n return children;\n }\n\n return (\n <ContentSelector onSelect={handleSelect} isSelecting={isSelected}>\n {displayedChildren}\n </ContentSelector>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+DI;AA7DJ,kBAA4C;AAC5C,2BAAgC;AAChC,mBAOO;AACP,mCAAsC;AACtC,wCAA2C;AASpC,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,MAAM,uBAAuB,gBAAgB,OAAO,QAC1D,8DAA2B,YAAY;AACzC,QAAM,cAAc,sBAAsB,cAAc,OAAO;AAC/D,QAAM,EAAE,cAAc,QAAI,yBAAW,kDAAqB;AAC1D,QAAM,CAAC,mBAAmB,oBAAoB,QAC5C,uBAAoB,QAAQ;AAE9B,QAAM,mBAAe;AAAA,IACnB,MACE,KAAK;AAAA,MACH;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,cAAc,gBAAgB,SAAS,IAAI;AAAA,EAC9C;AAEA,QAAM,cACH,WACE,gBAAgB,SAAS,UAAU,KAAK,SACzC,2BAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAEF,8BAAU,MAAM;AAEd,QAAI,iBAAiB,eAAe,OAAO,gBAAgB,UAAU;AACnE,2BAAqB,WAAW;AAAA,IAClC;AAAA,EACF,GAAG,CAAC,aAAa,aAAa,CAAC;AAE/B,MAAI,CAAC,eAAe;AAClB,WAAO;AAAA,EACT;AAEA,SACE,4CAAC,wCAAgB,UAAU,cAAc,aAAa,YACnD,6BACH;AAEJ;","names":[]}
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  "use client";
3
- var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
7
  var __export = (target, all) => {
10
8
  for (var name in all)
@@ -18,65 +16,77 @@ var __copyProps = (to, from, except, desc) => {
18
16
  }
19
17
  return to;
20
18
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
20
  var DictionaryEditionDrawer_exports = {};
31
21
  __export(DictionaryEditionDrawer_exports, {
32
22
  DictionaryEditionDrawer: () => DictionaryEditionDrawer,
33
23
  DictionaryEditionDrawerContent: () => DictionaryEditionDrawerContent,
34
- DictionaryEditionDrawerController: () => DictionaryEditionDrawerController,
35
- getDrawerIdentifier: () => getDrawerIdentifier
24
+ DictionaryEditionDrawerController: () => DictionaryEditionDrawerController
36
25
  });
37
26
  module.exports = __toCommonJS(DictionaryEditionDrawer_exports);
38
27
  var import_jsx_runtime = require("react/jsx-runtime");
39
28
  var import_design_system = require("@intlayer/design-system");
40
- var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
41
- var import_DictionaryListDrawer = require('../DictionaryListDrawer/index.cjs');
29
+ var import_hooks = require("@intlayer/design-system/hooks");
30
+ var import_react = require("react");
31
+ var import_useDictionaryListDrawer = require('../DictionaryListDrawer/useDictionaryListDrawer.cjs');
42
32
  var import_useDictionaryEditionDrawer = require('./useDictionaryEditionDrawer.cjs');
43
- var import_useFocusContentStore = require('./useFocusContentStore.cjs');
44
- const DictionaryEditionDrawerContent = ({ focusedContent, locale, identifier }) => {
33
+ const DictionaryEditionDrawerContent = ({ locale, identifier }) => {
34
+ const [keyPathEditionModal, setKeyPathEditionModal] = (0, import_react.useState)(null);
45
35
  const {
46
36
  setFocusedContent,
37
+ setDictionariesRecord,
47
38
  editContentRequest,
48
39
  editedContent,
40
+ focusedContent,
49
41
  addEditedContent,
50
42
  clearEditedDictionaryContent
51
43
  } = (0, import_useDictionaryEditionDrawer.useDictionaryEditionDrawer)(identifier);
52
- const dictionaryId = focusedContent.dictionaryId;
53
- const dictionary = import_dictionaries_entry.default[dictionaryId];
54
- const dictionaryPath = dictionary.filePath;
55
- const editedDictionaryContent = editedContent[dictionaryPath];
56
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
57
- import_design_system.DictionaryEditor,
58
- {
59
- dictionary,
60
- locale,
61
- focusedKeyPath: focusedContent.keyPath,
62
- editedContent: editedDictionaryContent,
63
- onFocusKeyPath: (keyPath) => setFocusedContent({ ...focusedContent, keyPath }),
64
- onContentChange: (keyPath, newValue) => addEditedContent(dictionaryPath, keyPath, newValue),
65
- onValidEdition: editContentRequest,
66
- onCancelEdition: () => clearEditedDictionaryContent(dictionaryPath)
44
+ const { all: dictionaries } = (0, import_hooks.useGetAllDictionaries)();
45
+ (0, import_react.useEffect)(() => {
46
+ if (dictionaries) {
47
+ setDictionariesRecord(dictionaries);
67
48
  }
68
- );
49
+ }, [setDictionariesRecord, dictionaries]);
50
+ const dictionaryId = focusedContent?.dictionaryId;
51
+ if (!dictionaryId) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "No dictionary focused" });
52
+ const dictionary = dictionaries[dictionaryId];
53
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
54
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
55
+ import_design_system.Modal,
56
+ {
57
+ isOpen: keyPathEditionModal !== null,
58
+ onClose: () => setKeyPathEditionModal(null),
59
+ hasCloseButton: true,
60
+ title: "Edit field",
61
+ size: "xl",
62
+ children: dictionary && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.DictionaryFieldEditor, { dictionary })
63
+ }
64
+ ),
65
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
66
+ import_design_system.DictionaryEditor,
67
+ {
68
+ dictionary,
69
+ locale,
70
+ focusedKeyPath: focusedContent.keyPath,
71
+ editedContent: editedContent[dictionaryId],
72
+ onFocusKeyPath: (keyPath) => setFocusedContent({ ...focusedContent, keyPath }),
73
+ onContentChange: (keyPath, newValue) => addEditedContent(dictionaryId, newValue, keyPath),
74
+ onValidEdition: editContentRequest,
75
+ onCancelEdition: () => clearEditedDictionaryContent(dictionaryId),
76
+ onClickEdit: setKeyPathEditionModal
77
+ }
78
+ )
79
+ ] });
69
80
  };
70
- const getDrawerIdentifier = (dictionaryId) => `dictionary_edition_${dictionaryId}`;
71
81
  const DictionaryEditionDrawer = ({
72
82
  locale,
73
83
  localeList,
74
84
  setLocale,
75
85
  dictionaryId
76
86
  }) => {
77
- const id = getDrawerIdentifier(dictionaryId);
87
+ const id = (0, import_useDictionaryEditionDrawer.getDrawerIdentifier)(dictionaryId);
78
88
  const { focusedContent, close } = (0, import_useDictionaryEditionDrawer.useDictionaryEditionDrawer)(dictionaryId);
79
- const { open: openDictionaryListDrawer } = (0, import_DictionaryListDrawer.useDictionaryListDrawer)();
89
+ const { open: openDictionaryListDrawer } = (0, import_useDictionaryListDrawer.useDictionaryListDrawer)();
80
90
  const handleOnBack = () => {
81
91
  close();
82
92
  openDictionaryListDrawer();
@@ -110,7 +120,7 @@ const DictionaryEditionDrawer = ({
110
120
  );
111
121
  };
112
122
  const DictionaryEditionDrawerController = ({ locale, localeList, setLocale }) => {
113
- const focusedContent = (0, import_useFocusContentStore.useEditionPanelStore)((s) => s.focusedContent);
123
+ const focusedContent = (0, import_design_system.useEditionPanelStore)((s) => s.focusedContent);
114
124
  const dictionaryId = focusedContent?.dictionaryId;
115
125
  if (!dictionaryId) {
116
126
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
@@ -129,7 +139,6 @@ const DictionaryEditionDrawerController = ({ locale, localeList, setLocale }) =>
129
139
  0 && (module.exports = {
130
140
  DictionaryEditionDrawer,
131
141
  DictionaryEditionDrawerContent,
132
- DictionaryEditionDrawerController,
133
- getDrawerIdentifier
142
+ DictionaryEditionDrawerController
134
143
  });
135
144
  //# sourceMappingURL=DictionaryEditionDrawer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/DictionaryEditionDrawer/DictionaryEditionDrawer.tsx"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport type { Dictionary, KeyPath } from '@intlayer/core';\nimport {\n RightDrawer,\n DictionaryEditor,\n LocaleSwitcher,\n Modal,\n useEditionPanelStore,\n DictionaryFieldEditor,\n} from '@intlayer/design-system';\nimport { useGetAllDictionaries } from '@intlayer/design-system/hooks';\nimport { useEffect, useState, type FC } from 'react';\nimport { useDictionaryListDrawer } from '../DictionaryListDrawer/useDictionaryListDrawer';\nimport {\n type FileContent as FileContentWithDictionaryPath,\n useDictionaryEditionDrawer,\n getDrawerIdentifier,\n} from './useDictionaryEditionDrawer';\n\ntype DictionaryEditionDrawerContentProps = {\n focusedContent: FileContentWithDictionaryPath;\n locale: Locales;\n identifier: string;\n};\n\nexport const DictionaryEditionDrawerContent: FC<\n DictionaryEditionDrawerContentProps\n> = ({ locale, identifier }) => {\n const [keyPathEditionModal, setKeyPathEditionModal] = useState<\n KeyPath[] | null\n >(null);\n const {\n setFocusedContent,\n setDictionariesRecord,\n editContentRequest,\n editedContent,\n focusedContent,\n addEditedContent,\n clearEditedDictionaryContent,\n } = useDictionaryEditionDrawer(identifier);\n const { all: dictionaries } = useGetAllDictionaries();\n\n useEffect(() => {\n if (dictionaries) {\n setDictionariesRecord(dictionaries);\n }\n }, [setDictionariesRecord, dictionaries]);\n\n const dictionaryId = focusedContent?.dictionaryId;\n\n if (!dictionaryId) return <>No dictionary focused</>;\n\n const dictionary: Dictionary = dictionaries[dictionaryId];\n\n return (\n <>\n <Modal\n isOpen={keyPathEditionModal !== null}\n onClose={() => setKeyPathEditionModal(null)}\n hasCloseButton\n title=\"Edit field\"\n size=\"xl\"\n >\n {dictionary && <DictionaryFieldEditor dictionary={dictionary} />}\n </Modal>\n <DictionaryEditor\n dictionary={dictionary}\n locale={locale}\n focusedKeyPath={focusedContent.keyPath}\n editedContent={editedContent[dictionaryId]}\n onFocusKeyPath={(keyPath) =>\n setFocusedContent({ ...focusedContent, keyPath })\n }\n onContentChange={(keyPath, newValue) =>\n addEditedContent(dictionaryId, newValue, keyPath)\n }\n onValidEdition={editContentRequest}\n onCancelEdition={() => clearEditedDictionaryContent(dictionaryId)}\n onClickEdit={setKeyPathEditionModal}\n />\n </>\n );\n};\n\ntype DictionaryEditionDrawerProps = DictionaryEditionDrawerControllerProps & {\n dictionaryId: string;\n};\n\nexport const DictionaryEditionDrawer: FC<DictionaryEditionDrawerProps> = ({\n locale,\n localeList,\n setLocale,\n dictionaryId,\n}) => {\n const id = getDrawerIdentifier(dictionaryId);\n\n const { focusedContent, close } = useDictionaryEditionDrawer(dictionaryId);\n const { open: openDictionaryListDrawer } = useDictionaryListDrawer();\n\n const handleOnBack = () => {\n close();\n openDictionaryListDrawer();\n };\n\n return (\n <RightDrawer\n title={dictionaryId}\n identifier={id}\n header={\n <LocaleSwitcher\n setLocale={setLocale}\n locale={locale}\n localeList={localeList}\n />\n }\n backButton={{\n onBack: handleOnBack,\n text: 'Dictionary list',\n }}\n >\n {focusedContent && (\n <DictionaryEditionDrawerContent\n focusedContent={focusedContent}\n locale={locale}\n identifier={id}\n />\n )}\n </RightDrawer>\n );\n};\n\ntype DictionaryEditionDrawerControllerProps = {\n locale: Locales;\n localeList: Locales[];\n setLocale: (locale: Locales) => void;\n};\n\nexport const DictionaryEditionDrawerController: FC<\n DictionaryEditionDrawerControllerProps\n> = ({ locale, localeList, setLocale }) => {\n const focusedContent = useEditionPanelStore((s) => s.focusedContent);\n const dictionaryId: string | undefined = focusedContent?.dictionaryId;\n\n if (!dictionaryId) {\n return <></>;\n }\n\n return (\n <DictionaryEditionDrawer\n locale={locale}\n localeList={localeList}\n setLocale={setLocale}\n dictionaryId={dictionaryId}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoD4B;AAhD5B,2BAOO;AACP,mBAAsC;AACtC,mBAA6C;AAC7C,qCAAwC;AACxC,wCAIO;AAQA,MAAM,iCAET,CAAC,EAAE,QAAQ,WAAW,MAAM;AAC9B,QAAM,CAAC,qBAAqB,sBAAsB,QAAI,uBAEpD,IAAI;AACN,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,8DAA2B,UAAU;AACzC,QAAM,EAAE,KAAK,aAAa,QAAI,oCAAsB;AAEpD,8BAAU,MAAM;AACd,QAAI,cAAc;AAChB,4BAAsB,YAAY;AAAA,IACpC;AAAA,EACF,GAAG,CAAC,uBAAuB,YAAY,CAAC;AAExC,QAAM,eAAe,gBAAgB;AAErC,MAAI,CAAC,aAAc,QAAO,2EAAE,mCAAqB;AAEjD,QAAM,aAAyB,aAAa,YAAY;AAExD,SACE,4EACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ,wBAAwB;AAAA,QAChC,SAAS,MAAM,uBAAuB,IAAI;AAAA,QAC1C,gBAAc;AAAA,QACd,OAAM;AAAA,QACN,MAAK;AAAA,QAEJ,wBAAc,4CAAC,8CAAsB,YAAwB;AAAA;AAAA,IAChE;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA,gBAAgB,eAAe;AAAA,QAC/B,eAAe,cAAc,YAAY;AAAA,QACzC,gBAAgB,CAAC,YACf,kBAAkB,EAAE,GAAG,gBAAgB,QAAQ,CAAC;AAAA,QAElD,iBAAiB,CAAC,SAAS,aACzB,iBAAiB,cAAc,UAAU,OAAO;AAAA,QAElD,gBAAgB;AAAA,QAChB,iBAAiB,MAAM,6BAA6B,YAAY;AAAA,QAChE,aAAa;AAAA;AAAA,IACf;AAAA,KACF;AAEJ;AAMO,MAAM,0BAA4D,CAAC;AAAA,EACxE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,SAAK,uDAAoB,YAAY;AAE3C,QAAM,EAAE,gBAAgB,MAAM,QAAI,8DAA2B,YAAY;AACzE,QAAM,EAAE,MAAM,yBAAyB,QAAI,wDAAwB;AAEnE,QAAM,eAAe,MAAM;AACzB,UAAM;AACN,6BAAyB;AAAA,EAC3B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,QACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACF;AAAA,MAEF,YAAY;AAAA,QACV,QAAQ;AAAA,QACR,MAAM;AAAA,MACR;AAAA,MAEC,4BACC;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA,YAAY;AAAA;AAAA,MACd;AAAA;AAAA,EAEJ;AAEJ;AAQO,MAAM,oCAET,CAAC,EAAE,QAAQ,YAAY,UAAU,MAAM;AACzC,QAAM,qBAAiB,2CAAqB,CAAC,MAAM,EAAE,cAAc;AACnE,QAAM,eAAmC,gBAAgB;AAEzD,MAAI,CAAC,cAAc;AACjB,WAAO,2EAAE;AAAA,EACX;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;","names":[]}
@@ -17,11 +17,9 @@ var DictionaryEditionDrawer_exports = {};
17
17
  module.exports = __toCommonJS(DictionaryEditionDrawer_exports);
18
18
  __reExport(DictionaryEditionDrawer_exports, require('./DictionaryEditionDrawer.cjs'), module.exports);
19
19
  __reExport(DictionaryEditionDrawer_exports, require('./useDictionaryEditionDrawer.cjs'), module.exports);
20
- __reExport(DictionaryEditionDrawer_exports, require('./useEditedContentStore.cjs'), module.exports);
21
20
  // Annotate the CommonJS export names for ESM import in node:
22
21
  0 && (module.exports = {
23
22
  ...require('./DictionaryEditionDrawer.cjs'),
24
- ...require('./useDictionaryEditionDrawer.cjs'),
25
- ...require('./useEditedContentStore.cjs')
23
+ ...require('./useDictionaryEditionDrawer.cjs')
26
24
  });
27
25
  //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/DictionaryEditionDrawer/index.ts"],"sourcesContent":["export * from './DictionaryEditionDrawer';\nexport * from './useDictionaryEditionDrawer';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4CAAc,sCAAd;AACA,4CAAc,yCADd;","names":[]}
@@ -18,30 +18,31 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var useDictionaryEditionDrawer_exports = {};
20
20
  __export(useDictionaryEditionDrawer_exports, {
21
+ getDrawerIdentifier: () => getDrawerIdentifier,
21
22
  useDictionaryEditionDrawer: () => useDictionaryEditionDrawer,
22
23
  useDictionaryEditionDrawerControl: () => useDictionaryEditionDrawerControl
23
24
  });
24
25
  module.exports = __toCommonJS(useDictionaryEditionDrawer_exports);
25
26
  var import_design_system = require("@intlayer/design-system");
26
27
  var import_useEditorServer = require('../useEditorServer.cjs');
27
- var import_DictionaryEditionDrawer = require('./DictionaryEditionDrawer.cjs');
28
- var import_useEditedContentStore = require('./useEditedContentStore.cjs');
29
- var import_useFocusContentStore = require('./useFocusContentStore.cjs');
28
+ const getDrawerIdentifier = (dictionaryId) => `dictionary_edition_${dictionaryId}`;
30
29
  const useDictionaryEditionDrawer = (dictionaryId) => {
31
- const id = (0, import_DictionaryEditionDrawer.getDrawerIdentifier)(dictionaryId);
30
+ const id = getDrawerIdentifier(dictionaryId);
32
31
  const { isOpen, open, close } = (0, import_design_system.useRightDrawerStore)(id)();
33
32
  const {
34
33
  editedContent,
34
+ setDictionariesRecord,
35
35
  getEditedContentValue,
36
36
  addEditedContent,
37
37
  clearEditedDictionaryContent
38
- } = (0, import_useEditedContentStore.useEditedContentStore)((s) => ({
38
+ } = (0, import_design_system.useEditedContentStore)((s) => ({
39
39
  editedContent: s.editedContent,
40
+ setDictionariesRecord: s.setDictionariesRecord,
40
41
  addEditedContent: s.addEditedContent,
41
42
  getEditedContentValue: s.getEditedContentValue,
42
43
  clearEditedDictionaryContent: s.clearEditedDictionaryContent
43
44
  }));
44
- const { setFocusedContent, focusedContent } = (0, import_useFocusContentStore.useEditionPanelStore)((s) => ({
45
+ const { setFocusedContent, focusedContent } = (0, import_design_system.useEditionPanelStore)((s) => ({
45
46
  focusedContent: s.focusedContent,
46
47
  setFocusedContent: s.setFocusedContent
47
48
  }));
@@ -62,6 +63,7 @@ const useDictionaryEditionDrawer = (dictionaryId) => {
62
63
  isOpen,
63
64
  focusedContent,
64
65
  setFocusedContent,
66
+ setDictionariesRecord,
65
67
  open: openDictionaryEditionDrawer,
66
68
  close,
67
69
  getEditedContentValue,
@@ -72,7 +74,7 @@ const useDictionaryEditionDrawer = (dictionaryId) => {
72
74
  };
73
75
  };
74
76
  const useDictionaryEditionDrawerControl = () => {
75
- const setFocusedContent = (0, import_useFocusContentStore.useEditionPanelStore)((s) => s.setFocusedContent);
77
+ const setFocusedContent = (0, import_design_system.useEditionPanelStore)((s) => s.setFocusedContent);
76
78
  const open = ({
77
79
  dictionaryId,
78
80
  dictionaryPath,
@@ -83,11 +85,11 @@ const useDictionaryEditionDrawerControl = () => {
83
85
  dictionaryPath,
84
86
  keyPath
85
87
  });
86
- const id = (0, import_DictionaryEditionDrawer.getDrawerIdentifier)(dictionaryId);
88
+ const id = getDrawerIdentifier(dictionaryId);
87
89
  (0, import_design_system.useRightDrawerStore)(id).getState().open();
88
90
  };
89
91
  const close = (dictionaryId) => {
90
- const id = (0, import_DictionaryEditionDrawer.getDrawerIdentifier)(dictionaryId);
92
+ const id = getDrawerIdentifier(dictionaryId);
91
93
  (0, import_design_system.useRightDrawerStore)(id).getState().close();
92
94
  };
93
95
  return {
@@ -97,6 +99,7 @@ const useDictionaryEditionDrawerControl = () => {
97
99
  };
98
100
  // Annotate the CommonJS export names for ESM import in node:
99
101
  0 && (module.exports = {
102
+ getDrawerIdentifier,
100
103
  useDictionaryEditionDrawer,
101
104
  useDictionaryEditionDrawerControl
102
105
  });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.ts"],"sourcesContent":["import type { Dictionary, DictionaryValue, KeyPath } from '@intlayer/core';\nimport {\n useRightDrawerStore,\n useEditedContentStore,\n useEditionPanelStore,\n type DictionaryContent,\n} from '@intlayer/design-system';\nimport { useEditorServer } from '../useEditorServer';\n\nexport const getDrawerIdentifier = (dictionaryId: string) =>\n `dictionary_edition_${dictionaryId}`;\n\ntype DictionaryId = string;\ntype DictionaryPath = string;\n\nexport type FileContent = {\n dictionaryPath?: DictionaryPath;\n dictionaryId: string;\n keyPath?: KeyPath[];\n};\n\ntype DictionaryEditionDrawer = {\n focusedContent: FileContent | null;\n setFocusedContent: (content: FileContent | null) => void;\n isOpen: boolean;\n open: (content: FileContent) => void;\n close: () => void;\n editContentRequest: () => Promise<void>;\n editedContent: DictionaryContent;\n addEditedContent: (\n dictionaryId: DictionaryId,\n newValue: DictionaryValue,\n keyPath: KeyPath[]\n ) => void;\n setDictionariesRecord: (\n dictionariesRecord: Record<DictionaryId, Dictionary>\n ) => void;\n getEditedContentValue: (\n dictionaryId: DictionaryId,\n keyPath: KeyPath[]\n ) => DictionaryValue | undefined;\n clearEditedDictionaryContent: (dictionaryPath: DictionaryPath) => void;\n};\n\ntype OpenDictionaryEditionDrawerProps = {\n dictionaryId: string;\n dictionaryPath?: string;\n keyPath?: KeyPath[];\n};\n\nexport const useDictionaryEditionDrawer = (\n dictionaryId: string\n): DictionaryEditionDrawer => {\n const id = getDrawerIdentifier(dictionaryId);\n const { isOpen, open, close } = useRightDrawerStore(id)();\n const {\n editedContent,\n setDictionariesRecord,\n getEditedContentValue,\n addEditedContent,\n clearEditedDictionaryContent,\n } = useEditedContentStore((s) => ({\n editedContent: s.editedContent,\n setDictionariesRecord: s.setDictionariesRecord,\n addEditedContent: s.addEditedContent,\n getEditedContentValue: s.getEditedContentValue,\n clearEditedDictionaryContent: s.clearEditedDictionaryContent,\n }));\n const { setFocusedContent, focusedContent } = useEditionPanelStore((s) => ({\n focusedContent: s.focusedContent,\n setFocusedContent: s.setFocusedContent,\n }));\n const { editContentRequest } = useEditorServer();\n\n const openDictionaryEditionDrawer = ({\n dictionaryId,\n dictionaryPath,\n keyPath = [],\n }: OpenDictionaryEditionDrawerProps) => {\n setFocusedContent({\n dictionaryId,\n dictionaryPath,\n keyPath,\n });\n\n open();\n };\n\n return {\n isOpen,\n focusedContent,\n setFocusedContent,\n setDictionariesRecord,\n open: openDictionaryEditionDrawer,\n close,\n getEditedContentValue,\n editContentRequest,\n editedContent,\n addEditedContent,\n clearEditedDictionaryContent,\n };\n};\n\ntype DictionaryEditionDrawerControl = {\n open: (content: FileContent) => void;\n close: (dictionaryId: string) => void;\n};\n\nexport const useDictionaryEditionDrawerControl =\n (): DictionaryEditionDrawerControl => {\n const setFocusedContent = useEditionPanelStore((s) => s.setFocusedContent);\n\n const open = ({\n dictionaryId,\n dictionaryPath,\n keyPath = [],\n }: OpenDictionaryEditionDrawerProps) => {\n setFocusedContent({\n dictionaryId,\n dictionaryPath,\n keyPath,\n });\n\n const id = getDrawerIdentifier(dictionaryId);\n\n useRightDrawerStore(id).getState().open();\n };\n\n const close = (dictionaryId: string) => {\n const id = getDrawerIdentifier(dictionaryId);\n\n useRightDrawerStore(id).getState().close();\n };\n\n return {\n open,\n close,\n };\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,2BAKO;AACP,6BAAgC;AAEzB,MAAM,sBAAsB,CAAC,iBAClC,sBAAsB,YAAY;AAwC7B,MAAM,6BAA6B,CACxC,iBAC4B;AAC5B,QAAM,KAAK,oBAAoB,YAAY;AAC3C,QAAM,EAAE,QAAQ,MAAM,MAAM,QAAI,0CAAoB,EAAE,EAAE;AACxD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,4CAAsB,CAAC,OAAO;AAAA,IAChC,eAAe,EAAE;AAAA,IACjB,uBAAuB,EAAE;AAAA,IACzB,kBAAkB,EAAE;AAAA,IACpB,uBAAuB,EAAE;AAAA,IACzB,8BAA8B,EAAE;AAAA,EAClC,EAAE;AACF,QAAM,EAAE,mBAAmB,eAAe,QAAI,2CAAqB,CAAC,OAAO;AAAA,IACzE,gBAAgB,EAAE;AAAA,IAClB,mBAAmB,EAAE;AAAA,EACvB,EAAE;AACF,QAAM,EAAE,mBAAmB,QAAI,wCAAgB;AAE/C,QAAM,8BAA8B,CAAC;AAAA,IACnC,cAAAA;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,EACb,MAAwC;AACtC,sBAAkB;AAAA,MAChB,cAAAA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,SAAK;AAAA,EACP;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAOO,MAAM,oCACX,MAAsC;AACpC,QAAM,wBAAoB,2CAAqB,CAAC,MAAM,EAAE,iBAAiB;AAEzE,QAAM,OAAO,CAAC;AAAA,IACZ;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,EACb,MAAwC;AACtC,sBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,UAAM,KAAK,oBAAoB,YAAY;AAE3C,kDAAoB,EAAE,EAAE,SAAS,EAAE,KAAK;AAAA,EAC1C;AAEA,QAAM,QAAQ,CAAC,iBAAyB;AACtC,UAAM,KAAK,oBAAoB,YAAY;AAE3C,kDAAoB,EAAE,EAAE,SAAS,EAAE,MAAM;AAAA,EAC3C;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["dictionaryId"]}
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var DictionaryListDrawer_exports = {};
30
20
  __export(DictionaryListDrawer_exports, {
@@ -33,37 +23,40 @@ __export(DictionaryListDrawer_exports, {
33
23
  module.exports = __toCommonJS(DictionaryListDrawer_exports);
34
24
  var import_jsx_runtime = require("react/jsx-runtime");
35
25
  var import_design_system = require("@intlayer/design-system");
36
- var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
26
+ var import_hooks = require("@intlayer/design-system/hooks");
27
+ var import_lucide_react = require("lucide-react");
37
28
  var import_DictionaryEditionDrawer = require('../DictionaryEditionDrawer/index.cjs');
38
29
  var import_useDictionaryListDrawer = require('./useDictionaryListDrawer.cjs');
39
30
  const DictionaryListDrawer = () => {
40
- const dictionaryKeyList = Object.keys(import_dictionaries_entry.default);
31
+ const { all: dictionaries } = (0, import_hooks.useGetAllDictionaries)();
32
+ const dictionaryKeyList = Object.keys(dictionaries);
41
33
  const { open: openDictionaryEditionDrawer } = (0, import_DictionaryEditionDrawer.useDictionaryEditionDrawerControl)();
42
34
  const { close } = (0, import_useDictionaryListDrawer.useDictionaryListDrawer)();
43
- const editedContent = (0, import_DictionaryEditionDrawer.useEditedContentStore)((s) => s.editedContent);
35
+ const editedContent = (0, import_design_system.useEditedContentStore)((s) => s.editedContent);
44
36
  const handleClickDictionary = (dictionaryId) => {
45
- const { filePath } = import_dictionaries_entry.default[dictionaryId];
37
+ const { filePath } = dictionaries[dictionaryId];
46
38
  close();
47
39
  openDictionaryEditionDrawer({ dictionaryId, dictionaryPath: filePath });
48
40
  };
49
- const isDictionaryEdited = (dictionaryId) => {
50
- const dictionaryPath = import_dictionaries_entry.default[dictionaryId].filePath;
51
- return Object.keys(editedContent).includes(dictionaryPath);
52
- };
41
+ const isDictionaryEdited = (dictionaryId) => Object.keys(editedContent).includes(dictionaryId);
53
42
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
54
43
  import_design_system.RightDrawer,
55
44
  {
56
45
  title: "Dictionary list",
57
46
  identifier: import_useDictionaryListDrawer.dictionaryListDrawerIdentifier,
58
- children: dictionaryKeyList.map((dictionaryId) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
59
- import_design_system.RedirectionButton,
47
+ children: dictionaryKeyList.map((dictionaryId) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
48
+ import_design_system.Button,
60
49
  {
61
50
  label: `Open dictionary editor ${dictionaryId}`,
62
51
  onClick: () => handleClickDictionary(dictionaryId),
52
+ variant: "hoverable",
53
+ color: "text",
54
+ IconRight: import_lucide_react.ChevronRight,
55
+ size: "md",
56
+ isFullWidth: true,
63
57
  children: isDictionaryEdited(dictionaryId) ? `\u270E ${dictionaryId}` : dictionaryId
64
- },
65
- dictionaryId
66
- ))
58
+ }
59
+ ) }, dictionaryId))
67
60
  }
68
61
  );
69
62
  };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/DictionaryListDrawer/DictionaryListDrawer.tsx"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n RightDrawer,\n Button,\n useEditedContentStore,\n} from '@intlayer/design-system';\nimport { useGetAllDictionaries } from '@intlayer/design-system/hooks';\nimport { ChevronRight } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useDictionaryEditionDrawerControl } from '../DictionaryEditionDrawer/index';\nimport {\n dictionaryListDrawerIdentifier,\n useDictionaryListDrawer,\n} from './useDictionaryListDrawer';\n\nexport const DictionaryListDrawer: FC = () => {\n const { all: dictionaries } = useGetAllDictionaries();\n const dictionaryKeyList = Object.keys(dictionaries) as Locales[];\n const { open: openDictionaryEditionDrawer } =\n useDictionaryEditionDrawerControl();\n const { close } = useDictionaryListDrawer();\n const editedContent = useEditedContentStore((s) => s.editedContent);\n\n const handleClickDictionary = (dictionaryId: string) => {\n const { filePath } = dictionaries[dictionaryId];\n\n close();\n openDictionaryEditionDrawer({ dictionaryId, dictionaryPath: filePath });\n };\n\n const isDictionaryEdited = (dictionaryId: string) =>\n Object.keys(editedContent).includes(dictionaryId);\n\n return (\n <RightDrawer\n title=\"Dictionary list\"\n identifier={dictionaryListDrawerIdentifier}\n >\n {dictionaryKeyList.map((dictionaryId) => (\n <div key={dictionaryId}>\n <Button\n label={`Open dictionary editor ${dictionaryId}`}\n onClick={() => handleClickDictionary(dictionaryId)}\n variant=\"hoverable\"\n color=\"text\"\n IconRight={ChevronRight}\n size=\"md\"\n isFullWidth\n >\n {isDictionaryEdited(dictionaryId)\n ? `✎ ${dictionaryId}`\n : dictionaryId}\n </Button>\n </div>\n ))}\n </RightDrawer>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwCU;AAvCV,2BAIO;AACP,mBAAsC;AACtC,0BAA6B;AAE7B,qCAAkD;AAClD,qCAGO;AAEA,MAAM,uBAA2B,MAAM;AAC5C,QAAM,EAAE,KAAK,aAAa,QAAI,oCAAsB;AACpD,QAAM,oBAAoB,OAAO,KAAK,YAAY;AAClD,QAAM,EAAE,MAAM,4BAA4B,QACxC,kEAAkC;AACpC,QAAM,EAAE,MAAM,QAAI,wDAAwB;AAC1C,QAAM,oBAAgB,4CAAsB,CAAC,MAAM,EAAE,aAAa;AAElE,QAAM,wBAAwB,CAAC,iBAAyB;AACtD,UAAM,EAAE,SAAS,IAAI,aAAa,YAAY;AAE9C,UAAM;AACN,gCAA4B,EAAE,cAAc,gBAAgB,SAAS,CAAC;AAAA,EACxE;AAEA,QAAM,qBAAqB,CAAC,iBAC1B,OAAO,KAAK,aAAa,EAAE,SAAS,YAAY;AAElD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAM;AAAA,MACN,YAAY;AAAA,MAEX,4BAAkB,IAAI,CAAC,iBACtB,4CAAC,SACC;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,0BAA0B,YAAY;AAAA,UAC7C,SAAS,MAAM,sBAAsB,YAAY;AAAA,UACjD,SAAQ;AAAA,UACR,OAAM;AAAA,UACN,WAAW;AAAA,UACX,MAAK;AAAA,UACL,aAAW;AAAA,UAEV,6BAAmB,YAAY,IAC5B,UAAK,YAAY,KACjB;AAAA;AAAA,MACN,KAbQ,YAcV,CACD;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/DictionaryListDrawer/index.ts"],"sourcesContent":["export * from './DictionaryListDrawer';\nexport * from './useDictionaryListDrawer';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,yCAAc,mCAAd;AACA,yCAAc,sCADd;","names":[]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/DictionaryListDrawer/useDictionaryListDrawer.ts"],"sourcesContent":["import { useRightDrawerStore } from '@intlayer/design-system';\n\nexport const dictionaryListDrawerIdentifier = 'dictionaryList';\n\nexport const useDictionaryListDrawer = () =>\n useRightDrawerStore(dictionaryListDrawerIdentifier)();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAoC;AAE7B,MAAM,iCAAiC;AAEvC,MAAM,0BAA0B,UACrC,0CAAoB,8BAA8B,EAAE;","names":[]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["export * from './DictionaryEditionDrawer/index';\nexport * from './DictionaryListDrawer/index';\nexport * from './ContentEditionLayout';\nexport * from './useEditorServer';\nexport * from './renderContentEditor';\nexport * from './ContentEditorProvider';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,2BAAc,4CAAd;AACA,2BAAc,yCADd;AAEA,2BAAc,mCAFd;AAGA,2BAAc,8BAHd;AAIA,2BAAc,kCAJd;AAKA,2BAAc,oCALd;","names":[]}
@@ -29,16 +29,22 @@ const {
29
29
  } = (0, import_client.getConfiguration)();
30
30
  const IntlayerEditorElement = ({
31
31
  content,
32
+ isContentSelectable,
32
33
  ...props
33
34
  }) => {
34
- if (enabled) {
35
+ if (enabled && isContentSelectable) {
35
36
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentSelectorWrapper.ContentSelectorWrapper, { ...props, children: content });
36
37
  }
37
38
  return content;
38
39
  };
39
- IntlayerEditorElement.content = "";
40
- const renderIntlayerEditor = (data) => {
41
- const Result = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerEditorElement, { ...data });
40
+ const renderIntlayerEditor = (data, isContentSelectable) => {
41
+ const Result = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
42
+ IntlayerEditorElement,
43
+ {
44
+ ...data,
45
+ isContentSelectable
46
+ }
47
+ );
42
48
  return { ...Result, value: data.content };
43
49
  };
44
50
  // Annotate the CommonJS export names for ESM import in node:
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/renderContentEditor.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport type { KeyPath } from '@intlayer/core';\nimport type { FC, ReactNode } from 'react';\nimport { ContentSelectorWrapper } from './ContentSelectorWrapper';\n\nconst {\n editor: { enabled },\n} = getConfiguration();\n\nexport type IntlayerEditorElementProps = {\n content: string;\n dictionaryId: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n isContentSelectable: boolean;\n};\n\nconst IntlayerEditorElement: FC<IntlayerEditorElementProps> = ({\n content,\n isContentSelectable,\n ...props\n}) => {\n if (enabled && isContentSelectable) {\n return (\n <ContentSelectorWrapper {...props}>{content}</ContentSelectorWrapper>\n );\n }\n return content;\n};\n\nexport type RenderIntlayerEditorResult = ReactNode & { value: string };\n\nexport const renderIntlayerEditor = (\n data: IntlayerEditorElementProps,\n isContentSelectable: boolean\n): RenderIntlayerEditorResult => {\n const Result = (\n <IntlayerEditorElement\n {...data}\n isContentSelectable={isContentSelectable}\n />\n );\n\n return { ...Result, value: data.content };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBM;AAxBN,oBAAiC;AAGjC,oCAAuC;AAEvC,MAAM;AAAA,EACJ,QAAQ,EAAE,QAAQ;AACpB,QAAI,gCAAiB;AAUrB,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,MAAI,WAAW,qBAAqB;AAClC,WACE,4CAAC,wDAAwB,GAAG,OAAQ,mBAAQ;AAAA,EAEhD;AACA,SAAO;AACT;AAIO,MAAM,uBAAuB,CAClC,MACA,wBAC+B;AAC/B,QAAM,SACJ;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA;AAAA,EACF;AAGF,SAAO,EAAE,GAAG,QAAQ,OAAO,KAAK,QAAQ;AAC1C;","names":[]}
@@ -22,17 +22,17 @@ __export(useEditorServer_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(useEditorServer_exports);
24
24
  var import_client = require("@intlayer/config/client");
25
- var import_useEditedContentStore = require('./DictionaryEditionDrawer/useEditedContentStore.cjs');
25
+ var import_design_system = require("@intlayer/design-system");
26
26
  const useEditorServer = () => {
27
- const { editedContent, clearEditedContent } = (0, import_useEditedContentStore.useEditedContentStore)((s) => ({
27
+ const { editedContent, clearEditedContent } = (0, import_design_system.useEditedContentStore)((s) => ({
28
28
  editedContent: s.editedContent,
29
29
  clearEditedContent: s.clearEditedContent
30
30
  }));
31
31
  const editContentRequest = async () => {
32
32
  const {
33
- editor: { port }
33
+ editor: { backendURL }
34
34
  } = (0, import_client.getConfiguration)();
35
- await fetch(`http://localhost:${port}`, {
35
+ await fetch(backendURL, {
36
36
  method: "POST",
37
37
  headers: {
38
38
  "Content-Type": "application/json"
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/useEditorServer.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport { useEditedContentStore } from '@intlayer/design-system';\n\nexport const useEditorServer = () => {\n const { editedContent, clearEditedContent } = useEditedContentStore((s) => ({\n editedContent: s.editedContent,\n clearEditedContent: s.clearEditedContent,\n }));\n\n const editContentRequest = async () => {\n const {\n editor: { backendURL },\n } = getConfiguration();\n\n await fetch(backendURL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(editedContent),\n })\n .then((response) => {\n if (!response.ok) {\n throw new Error('Failed to edit content');\n }\n clearEditedContent();\n })\n .catch((error) => {\n console.error('Failed to edit content:', error);\n });\n };\n\n return { editContentRequest };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,2BAAsC;AAE/B,MAAM,kBAAkB,MAAM;AACnC,QAAM,EAAE,eAAe,mBAAmB,QAAI,4CAAsB,CAAC,OAAO;AAAA,IAC1E,eAAe,EAAE;AAAA,IACjB,oBAAoB,EAAE;AAAA,EACxB,EAAE;AAEF,QAAM,qBAAqB,YAAY;AACrC,UAAM;AAAA,MACJ,QAAQ,EAAE,WAAW;AAAA,IACvB,QAAI,gCAAiB;AAErB,UAAM,MAAM,YAAY;AAAA,MACtB,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU,aAAa;AAAA,IACpC,CAAC,EACE,KAAK,CAAC,aAAa;AAClB,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,IAAI,MAAM,wBAAwB;AAAA,MAC1C;AACA,yBAAmB;AAAA,IACrB,CAAC,EACA,MAAM,CAAC,UAAU;AAChB,cAAQ,MAAM,2BAA2B,KAAK;AAAA,IAChD,CAAC;AAAA,EACL;AAEA,SAAO,EAAE,mBAAmB;AAC9B;","names":[]}
@@ -9,7 +9,7 @@ const ContentEditionLayout = ({
9
9
  localeList,
10
10
  editorEnabled = true
11
11
  }) => {
12
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(IntlayerEditorProvider, { editorEnabled, children: [
12
+ return /* @__PURE__ */ jsxs(IntlayerEditorProvider, { editorEnabled, children: [
13
13
  children,
14
14
  editorEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [
15
15
  /* @__PURE__ */ jsx(
@@ -22,7 +22,7 @@ const ContentEditionLayout = ({
22
22
  ),
23
23
  /* @__PURE__ */ jsx(DictionaryListDrawer, {})
24
24
  ] })
25
- ] }) });
25
+ ] });
26
26
  };
27
27
  export {
28
28
  ContentEditionLayout
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/ContentEditionLayout.tsx"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { FC, ReactNode } from 'react';\nimport { IntlayerEditorProvider } from './ContentEditorProvider';\nimport { DictionaryEditionDrawerController } from './DictionaryEditionDrawer/index';\nimport { DictionaryListDrawer } from './DictionaryListDrawer/index';\n\nexport type ContentEditionLayoutProps = {\n children?: ReactNode;\n locale: Locales;\n localeList: Locales[];\n setLocale: (locale: Locales) => void;\n editorEnabled?: boolean;\n};\n\nexport const ContentEditionLayout: FC<ContentEditionLayoutProps> = ({\n children,\n locale,\n setLocale,\n localeList,\n editorEnabled = true,\n}) => {\n return (\n <IntlayerEditorProvider editorEnabled={editorEnabled}>\n {children}\n\n {editorEnabled && (\n <>\n <DictionaryEditionDrawerController\n locale={locale}\n localeList={localeList}\n setLocale={setLocale}\n />\n <DictionaryListDrawer />\n </>\n )}\n </IntlayerEditorProvider>\n );\n};\n"],"mappings":"AA0BQ,mBACE,KADF;AAxBR,SAAS,8BAA8B;AACvC,SAAS,yCAAyC;AAClD,SAAS,4BAA4B;AAU9B,MAAM,uBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAClB,MAAM;AACJ,SACE,qBAAC,0BAAuB,eACrB;AAAA;AAAA,IAEA,iBACC,iCACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACF;AAAA,MACA,oBAAC,wBAAqB;AAAA,OACxB;AAAA,KAEJ;AAEJ;","names":[]}