intlayer-editor 2.0.0 → 2.1.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.
Files changed (127) hide show
  1. package/README.md +51 -135
  2. package/dist/cjs/client/ContentEditionLayout.cjs +5 -3
  3. package/dist/cjs/client/ContentEditionLayout.cjs.map +1 -1
  4. package/dist/cjs/client/ContentSelectorWrapper.cjs +14 -10
  5. package/dist/cjs/client/ContentSelectorWrapper.cjs.map +1 -1
  6. package/dist/cjs/client/ContentSelectorWrapper.d.ts +2 -2
  7. package/dist/cjs/client/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs +135 -0
  8. package/dist/cjs/client/DictionaryEditionDrawer/DictionaryEditionDrawer.cjs.map +1 -0
  9. package/dist/cjs/client/DictionaryEditionDrawer/DictionaryEditionDrawer.d.ts +28 -0
  10. package/dist/cjs/client/DictionaryEditionDrawer/index.cjs +27 -0
  11. package/dist/cjs/client/DictionaryEditionDrawer/index.cjs.map +1 -0
  12. package/dist/cjs/client/DictionaryEditionDrawer/index.d.ts +9 -0
  13. package/dist/cjs/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs +103 -0
  14. package/dist/cjs/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.cjs.map +1 -0
  15. package/dist/cjs/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.ts +32 -0
  16. package/dist/cjs/client/{EditionPanel → DictionaryEditionDrawer}/useEditedContentStore.cjs +19 -11
  17. package/dist/cjs/client/DictionaryEditionDrawer/useEditedContentStore.cjs.map +1 -0
  18. package/dist/cjs/client/{EditionPanel/useEditionPanelStore.cjs → DictionaryEditionDrawer/useFocusContentStore.cjs} +4 -4
  19. package/dist/cjs/client/DictionaryEditionDrawer/useFocusContentStore.cjs.map +1 -0
  20. package/dist/cjs/client/{EditionPanel/useEditionPanelStore.d.ts → DictionaryEditionDrawer/useFocusContentStore.d.ts} +1 -1
  21. package/dist/cjs/client/DictionaryListDrawer/DictionaryListDrawer.cjs +74 -0
  22. package/dist/cjs/client/DictionaryListDrawer/DictionaryListDrawer.cjs.map +1 -0
  23. package/dist/cjs/client/DictionaryListDrawer/DictionaryListDrawer.d.ts +5 -0
  24. package/dist/cjs/client/{EditionPanel → DictionaryListDrawer}/index.cjs +6 -8
  25. package/dist/cjs/client/DictionaryListDrawer/index.cjs.map +1 -0
  26. package/dist/cjs/client/DictionaryListDrawer/index.d.ts +3 -0
  27. package/dist/cjs/client/{renderContentSelector.cjs → DictionaryListDrawer/useDictionaryListDrawer.cjs} +11 -17
  28. package/dist/cjs/client/DictionaryListDrawer/useDictionaryListDrawer.cjs.map +1 -0
  29. package/dist/cjs/client/DictionaryListDrawer/useDictionaryListDrawer.d.ts +8 -0
  30. package/dist/cjs/client/index.cjs +7 -5
  31. package/dist/cjs/client/index.cjs.map +1 -1
  32. package/dist/cjs/client/index.d.ts +8 -7
  33. package/dist/cjs/client/renderContentEditor.cjs +48 -0
  34. package/dist/cjs/client/renderContentEditor.cjs.map +1 -0
  35. package/dist/cjs/client/renderContentEditor.d.ts +15 -0
  36. package/dist/cjs/client/useEditorServer.cjs +5 -2
  37. package/dist/cjs/client/useEditorServer.cjs.map +1 -1
  38. package/dist/cjs/server/formatPrettier.cjs +51 -0
  39. package/dist/cjs/server/formatPrettier.cjs.map +1 -0
  40. package/dist/cjs/server/formatPrettier.d.ts +6 -0
  41. package/dist/cjs/server/index.cjs +2 -2
  42. package/dist/cjs/server/index.cjs.map +1 -1
  43. package/dist/cjs/server/{content-editor.cjs → processEdition.cjs} +41 -38
  44. package/dist/cjs/server/processEdition.cjs.map +1 -0
  45. package/dist/cjs/server/processEdition.d.ts +12 -0
  46. package/dist/esm/client/ContentEditionLayout.mjs +5 -3
  47. package/dist/esm/client/ContentEditionLayout.mjs.map +1 -1
  48. package/dist/esm/client/ContentSelectorWrapper.d.mts +2 -2
  49. package/dist/esm/client/ContentSelectorWrapper.mjs +14 -10
  50. package/dist/esm/client/ContentSelectorWrapper.mjs.map +1 -1
  51. package/dist/esm/client/DictionaryEditionDrawer/DictionaryEditionDrawer.d.mts +28 -0
  52. package/dist/esm/client/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs +104 -0
  53. package/dist/esm/client/DictionaryEditionDrawer/DictionaryEditionDrawer.mjs.map +1 -0
  54. package/dist/esm/client/DictionaryEditionDrawer/index.d.mts +9 -0
  55. package/dist/esm/client/DictionaryEditionDrawer/index.mjs +4 -0
  56. package/dist/esm/client/DictionaryEditionDrawer/index.mjs.map +1 -0
  57. package/dist/esm/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.d.mts +32 -0
  58. package/dist/esm/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs +80 -0
  59. package/dist/esm/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.mjs.map +1 -0
  60. package/dist/esm/client/{EditionPanel → DictionaryEditionDrawer}/useEditedContentStore.mjs +17 -9
  61. package/dist/esm/client/DictionaryEditionDrawer/useEditedContentStore.mjs.map +1 -0
  62. package/dist/esm/client/{EditionPanel/useEditionPanelStore.d.mts → DictionaryEditionDrawer/useFocusContentStore.d.mts} +1 -1
  63. package/dist/esm/client/{EditionPanel/useEditionPanelStore.mjs → DictionaryEditionDrawer/useFocusContentStore.mjs} +1 -1
  64. package/dist/esm/client/DictionaryEditionDrawer/useFocusContentStore.mjs.map +1 -0
  65. package/dist/esm/client/DictionaryListDrawer/DictionaryListDrawer.d.mts +5 -0
  66. package/dist/esm/client/DictionaryListDrawer/DictionaryListDrawer.mjs +46 -0
  67. package/dist/esm/client/DictionaryListDrawer/DictionaryListDrawer.mjs.map +1 -0
  68. package/dist/esm/client/DictionaryListDrawer/index.d.mts +3 -0
  69. package/dist/esm/client/DictionaryListDrawer/index.mjs +3 -0
  70. package/dist/esm/client/DictionaryListDrawer/index.mjs.map +1 -0
  71. package/dist/esm/client/DictionaryListDrawer/useDictionaryListDrawer.d.mts +8 -0
  72. package/dist/esm/client/DictionaryListDrawer/useDictionaryListDrawer.mjs +8 -0
  73. package/dist/esm/client/DictionaryListDrawer/useDictionaryListDrawer.mjs.map +1 -0
  74. package/dist/esm/client/index.d.mts +8 -7
  75. package/dist/esm/client/index.mjs +3 -2
  76. package/dist/esm/client/index.mjs.map +1 -1
  77. package/dist/esm/client/renderContentEditor.d.mts +15 -0
  78. package/dist/esm/client/renderContentEditor.mjs +24 -0
  79. package/dist/esm/client/renderContentEditor.mjs.map +1 -0
  80. package/dist/esm/client/useEditorServer.mjs +5 -2
  81. package/dist/esm/client/useEditorServer.mjs.map +1 -1
  82. package/dist/esm/server/formatPrettier.d.mts +6 -0
  83. package/dist/esm/server/formatPrettier.mjs +17 -0
  84. package/dist/esm/server/formatPrettier.mjs.map +1 -0
  85. package/dist/esm/server/index.mjs +2 -2
  86. package/dist/esm/server/index.mjs.map +1 -1
  87. package/dist/esm/server/processEdition.d.mts +12 -0
  88. package/dist/esm/server/{content-editor.mjs → processEdition.mjs} +36 -23
  89. package/dist/esm/server/processEdition.mjs.map +1 -0
  90. package/package.json +6 -7
  91. package/dist/cjs/client/EditionPanel/EditionPanel.cjs +0 -101
  92. package/dist/cjs/client/EditionPanel/EditionPanel.cjs.map +0 -1
  93. package/dist/cjs/client/EditionPanel/EditionPanel.d.ts +0 -11
  94. package/dist/cjs/client/EditionPanel/index.cjs.map +0 -1
  95. package/dist/cjs/client/EditionPanel/index.d.ts +0 -9
  96. package/dist/cjs/client/EditionPanel/useEditedContentStore.cjs.map +0 -1
  97. package/dist/cjs/client/EditionPanel/useEditionPanelStore.cjs.map +0 -1
  98. package/dist/cjs/client/renderContentSelector.cjs.map +0 -1
  99. package/dist/cjs/client/renderContentSelector.d.ts +0 -6
  100. package/dist/cjs/server/content-editor.cjs.map +0 -1
  101. package/dist/cjs/server/content-editor.d.ts +0 -12
  102. package/dist/esm/client/EditionPanel/EditionPanel.d.mts +0 -11
  103. package/dist/esm/client/EditionPanel/EditionPanel.mjs +0 -72
  104. package/dist/esm/client/EditionPanel/EditionPanel.mjs.map +0 -1
  105. package/dist/esm/client/EditionPanel/index.d.mts +0 -9
  106. package/dist/esm/client/EditionPanel/index.mjs +0 -4
  107. package/dist/esm/client/EditionPanel/index.mjs.map +0 -1
  108. package/dist/esm/client/EditionPanel/useEditedContentStore.mjs.map +0 -1
  109. package/dist/esm/client/EditionPanel/useEditionPanelStore.mjs.map +0 -1
  110. package/dist/esm/client/renderContentSelector.d.mts +0 -6
  111. package/dist/esm/client/renderContentSelector.mjs +0 -15
  112. package/dist/esm/client/renderContentSelector.mjs.map +0 -1
  113. package/dist/esm/server/content-editor.d.mts +0 -12
  114. package/dist/esm/server/content-editor.mjs.map +0 -1
  115. package/src/client/ContentEditionLayout.tsx +0 -26
  116. package/src/client/ContentSelectorWrapper.tsx +0 -38
  117. package/src/client/EditionPanel/EditionPanel.tsx +0 -90
  118. package/src/client/EditionPanel/index.ts +0 -3
  119. package/src/client/EditionPanel/useEditedContentStore.ts +0 -98
  120. package/src/client/EditionPanel/useEditionPanelStore.ts +0 -19
  121. package/src/client/index.ts +0 -4
  122. package/src/client/renderContentSelector.tsx +0 -17
  123. package/src/client/useEditorServer.ts +0 -31
  124. package/src/server/content-editor.ts +0 -209
  125. package/src/server/index.ts +0 -40
  126. /package/dist/cjs/client/{EditionPanel → DictionaryEditionDrawer}/useEditedContentStore.d.ts +0 -0
  127. /package/dist/esm/client/{EditionPanel → DictionaryEditionDrawer}/useEditedContentStore.d.mts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/client/DictionaryEditionDrawer/useDictionaryEditionDrawer.ts"],"sourcesContent":["import type { KeyPath } from '@intlayer/core';\nimport { useRightDrawerStore } from '@intlayer/design-system';\nimport { useEditorServer } from '../useEditorServer';\nimport { getDrawerIdentifier } from './DictionaryEditionDrawer';\nimport {\n type EditedContent,\n useEditedContentStore,\n} from './useEditedContentStore';\nimport { useEditionPanelStore } from './useFocusContentStore';\n\ntype DictionaryPath = string;\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: EditedContent;\n addEditedContent: (\n dictionaryPath: DictionaryPath,\n keyPath: KeyPath[],\n newValue: string\n ) => void;\n getEditedContentValue: (\n dictionaryPath: DictionaryPath,\n keyPath: KeyPath[]\n ) => string | 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 getEditedContentValue,\n addEditedContent,\n clearEditedDictionaryContent,\n } = useEditedContentStore((s) => ({\n editedContent: s.editedContent,\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 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;AACA,2BAAoC;AACpC,6BAAgC;AAChC,qCAAoC;AACpC,mCAGO;AACP,kCAAqC;AAmC9B,MAAM,6BAA6B,CACxC,iBAC4B;AAC5B,QAAM,SAAK,oDAAoB,YAAY;AAC3C,QAAM,EAAE,QAAQ,MAAM,MAAM,QAAI,0CAAoB,EAAE,EAAE;AACxD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,oDAAsB,CAAC,OAAO;AAAA,IAChC,eAAe,EAAE;AAAA,IACjB,kBAAkB,EAAE;AAAA,IACpB,uBAAuB,EAAE;AAAA,IACzB,8BAA8B,EAAE;AAAA,EAClC,EAAE;AACF,QAAM,EAAE,mBAAmB,eAAe,QAAI,kDAAqB,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,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAOO,MAAM,oCACX,MAAsC;AACpC,QAAM,wBAAoB,kDAAqB,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,SAAK,oDAAoB,YAAY;AAE3C,kDAAoB,EAAE,EAAE,SAAS,EAAE,KAAK;AAAA,EAC1C;AAEA,QAAM,QAAQ,CAAC,iBAAyB;AACtC,UAAM,SAAK,oDAAoB,YAAY;AAE3C,kDAAoB,EAAE,EAAE,SAAS,EAAE,MAAM;AAAA,EAC3C;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["dictionaryId"]}
@@ -0,0 +1,32 @@
1
+ import { KeyPath } from '@intlayer/core';
2
+ import { EditedContent } from './useEditedContentStore.js';
3
+ import 'zustand/middleware';
4
+ import 'zustand';
5
+ import '@intlayer/design-system';
6
+
7
+ type DictionaryPath = string;
8
+ type FileContent = {
9
+ dictionaryPath: DictionaryPath;
10
+ dictionaryId: string;
11
+ keyPath?: KeyPath[];
12
+ };
13
+ type DictionaryEditionDrawer = {
14
+ focusedContent: FileContent | null;
15
+ setFocusedContent: (content: FileContent | null) => void;
16
+ isOpen: boolean;
17
+ open: (content: FileContent) => void;
18
+ close: () => void;
19
+ editContentRequest: () => Promise<void>;
20
+ editedContent: EditedContent;
21
+ addEditedContent: (dictionaryPath: DictionaryPath, keyPath: KeyPath[], newValue: string) => void;
22
+ getEditedContentValue: (dictionaryPath: DictionaryPath, keyPath: KeyPath[]) => string | undefined;
23
+ clearEditedDictionaryContent: (dictionaryPath: DictionaryPath) => void;
24
+ };
25
+ declare const useDictionaryEditionDrawer: (dictionaryId: string) => DictionaryEditionDrawer;
26
+ type DictionaryEditionDrawerControl = {
27
+ open: (content: FileContent) => void;
28
+ close: (dictionaryId: string) => void;
29
+ };
30
+ declare const useDictionaryEditionDrawerControl: () => DictionaryEditionDrawerControl;
31
+
32
+ export { type FileContent, useDictionaryEditionDrawer, useDictionaryEditionDrawerControl };
@@ -21,11 +21,9 @@ __export(useEditedContentStore_exports, {
21
21
  useEditedContentStore: () => useEditedContentStore
22
22
  });
23
23
  module.exports = __toCommonJS(useEditedContentStore_exports);
24
+ var import_core = require("@intlayer/core");
24
25
  var import_zustand = require("zustand");
25
26
  var import_middleware = require("zustand/middleware");
26
- const isSameKeyPath = (keyPath1, keyPath2) => keyPath1.every(
27
- (element, index) => keyPath2[index] && keyPath2[index].key === element.key && keyPath2[index].type === element.type
28
- );
29
27
  const useEditedContentStore = (0, import_zustand.create)(
30
28
  (0, import_middleware.persist)(
31
29
  (set, get) => ({
@@ -38,7 +36,7 @@ const useEditedContentStore = (0, import_zustand.create)(
38
36
  ...state.editedContent,
39
37
  [dictionaryPath]: [
40
38
  ...editedContent.filter(
41
- (content) => !isSameKeyPath(content.keyPath, keyPath)
39
+ (content) => !(0, import_core.isSameKeyPath)(content.keyPath, keyPath)
42
40
  ),
43
41
  {
44
42
  keyPath,
@@ -63,18 +61,28 @@ const useEditedContentStore = (0, import_zustand.create)(
63
61
  });
64
62
  },
65
63
  clearEditedDictionaryContent: (dictionaryPath) => {
66
- set((state) => ({
67
- editedContent: {
68
- ...state.editedContent,
69
- [dictionaryPath]: []
70
- }
71
- }));
64
+ set((state) => {
65
+ const filteredEditedContent = Object.entries(
66
+ state.editedContent
67
+ ).reduce((acc, [path, content]) => {
68
+ if (path === dictionaryPath) {
69
+ return acc;
70
+ }
71
+ return {
72
+ ...acc,
73
+ [path]: content
74
+ };
75
+ }, {});
76
+ return {
77
+ editedContent: filteredEditedContent
78
+ };
79
+ });
72
80
  },
73
81
  clearEditedContent: () => {
74
82
  set({ editedContent: {} });
75
83
  },
76
84
  getEditedContentValue: (dictionaryPath, keyPath) => get().editedContent[dictionaryPath]?.find(
77
- (content) => isSameKeyPath(content.keyPath, keyPath)
85
+ (content) => (0, import_core.isSameKeyPath)(content.keyPath, keyPath)
78
86
  )?.newValue
79
87
  }),
80
88
  {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/client/DictionaryEditionDrawer/useEditedContentStore.ts"],"sourcesContent":["import { type KeyPath, isSameKeyPath } from '@intlayer/core';\nimport type { FileContent } from '@intlayer/design-system';\nimport { create } from 'zustand';\nimport { persist, createJSONStorage } from 'zustand/middleware';\n\ntype DictionaryPath = string;\n\nexport type EditedContent = Record<DictionaryPath, FileContent[]>;\n\ntype EditedContentStore = {\n editedContent: EditedContent;\n addEditedContent: (\n dictionaryPath: DictionaryPath,\n keyPath: KeyPath[],\n newValue: string\n ) => void;\n removeEditedContent: (\n dictionaryPath: DictionaryPath,\n keyPath: KeyPath[]\n ) => void;\n clearEditedDictionaryContent: (dictionaryPath: DictionaryPath) => void;\n clearEditedContent: () => void;\n getEditedContentValue: (\n dictionaryPath: DictionaryPath,\n keyPath: KeyPath[]\n ) => string | undefined;\n};\n\nexport const useEditedContentStore = create(\n persist<EditedContentStore>(\n (set, get) => ({\n editedContent: {},\n addEditedContent: (dictionaryPath, keyPath, newValue) => {\n set((state) => {\n const editedContent = state.editedContent[dictionaryPath] ?? [];\n return {\n editedContent: {\n ...state.editedContent,\n [dictionaryPath]: [\n ...editedContent.filter(\n (content) => !isSameKeyPath(content.keyPath, keyPath)\n ),\n {\n keyPath,\n newValue,\n },\n ],\n },\n };\n });\n },\n\n removeEditedContent: (dictionaryPath, keyPath) => {\n set((state) => {\n const editedContent = state.editedContent[dictionaryPath] ?? [];\n return {\n editedContent: {\n ...state.editedContent,\n [dictionaryPath]: editedContent.filter(\n (content) => content.keyPath !== keyPath\n ),\n },\n };\n });\n },\n\n clearEditedDictionaryContent: (dictionaryPath) => {\n set((state) => {\n const filteredEditedContent = Object.entries(\n state.editedContent\n ).reduce((acc, [path, content]) => {\n if (path === dictionaryPath) {\n return acc;\n }\n\n return {\n ...acc,\n [path]: content,\n };\n }, {});\n\n return {\n editedContent: filteredEditedContent,\n };\n });\n },\n\n clearEditedContent: () => {\n set({ editedContent: {} });\n },\n\n getEditedContentValue: (dictionaryPath, keyPath): string | undefined =>\n get().editedContent[dictionaryPath]?.find((content) =>\n isSameKeyPath(content.keyPath, keyPath)\n )?.newValue,\n }),\n {\n name: 'edited-content-store',\n storage: createJSONStorage(() => sessionStorage),\n }\n )\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4C;AAE5C,qBAAuB;AACvB,wBAA2C;AAyBpC,MAAM,4BAAwB;AAAA,MACnC;AAAA,IACE,CAAC,KAAK,SAAS;AAAA,MACb,eAAe,CAAC;AAAA,MAChB,kBAAkB,CAAC,gBAAgB,SAAS,aAAa;AACvD,YAAI,CAAC,UAAU;AACb,gBAAM,gBAAgB,MAAM,cAAc,cAAc,KAAK,CAAC;AAC9D,iBAAO;AAAA,YACL,eAAe;AAAA,cACb,GAAG,MAAM;AAAA,cACT,CAAC,cAAc,GAAG;AAAA,gBAChB,GAAG,cAAc;AAAA,kBACf,CAAC,YAAY,KAAC,2BAAc,QAAQ,SAAS,OAAO;AAAA,gBACtD;AAAA,gBACA;AAAA,kBACE;AAAA,kBACA;AAAA,gBACF;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MAEA,qBAAqB,CAAC,gBAAgB,YAAY;AAChD,YAAI,CAAC,UAAU;AACb,gBAAM,gBAAgB,MAAM,cAAc,cAAc,KAAK,CAAC;AAC9D,iBAAO;AAAA,YACL,eAAe;AAAA,cACb,GAAG,MAAM;AAAA,cACT,CAAC,cAAc,GAAG,cAAc;AAAA,gBAC9B,CAAC,YAAY,QAAQ,YAAY;AAAA,cACnC;AAAA,YACF;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MAEA,8BAA8B,CAAC,mBAAmB;AAChD,YAAI,CAAC,UAAU;AACb,gBAAM,wBAAwB,OAAO;AAAA,YACnC,MAAM;AAAA,UACR,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,OAAO,MAAM;AACjC,gBAAI,SAAS,gBAAgB;AAC3B,qBAAO;AAAA,YACT;AAEA,mBAAO;AAAA,cACL,GAAG;AAAA,cACH,CAAC,IAAI,GAAG;AAAA,YACV;AAAA,UACF,GAAG,CAAC,CAAC;AAEL,iBAAO;AAAA,YACL,eAAe;AAAA,UACjB;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MAEA,oBAAoB,MAAM;AACxB,YAAI,EAAE,eAAe,CAAC,EAAE,CAAC;AAAA,MAC3B;AAAA,MAEA,uBAAuB,CAAC,gBAAgB,YACtC,IAAI,EAAE,cAAc,cAAc,GAAG;AAAA,QAAK,CAAC,gBACzC,2BAAc,QAAQ,SAAS,OAAO;AAAA,MACxC,GAAG;AAAA,IACP;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,aAAS,qCAAkB,MAAM,cAAc;AAAA,IACjD;AAAA,EACF;AACF;","names":[]}
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useEditionPanelStore_exports = {};
20
- __export(useEditionPanelStore_exports, {
19
+ var useFocusContentStore_exports = {};
20
+ __export(useFocusContentStore_exports, {
21
21
  useEditionPanelStore: () => useEditionPanelStore
22
22
  });
23
- module.exports = __toCommonJS(useEditionPanelStore_exports);
23
+ module.exports = __toCommonJS(useFocusContentStore_exports);
24
24
  var import_zustand = require("zustand");
25
25
  const useEditionPanelStore = (0, import_zustand.create)((set) => ({
26
26
  focusedContent: null,
@@ -30,4 +30,4 @@ const useEditionPanelStore = (0, import_zustand.create)((set) => ({
30
30
  0 && (module.exports = {
31
31
  useEditionPanelStore
32
32
  });
33
- //# sourceMappingURL=useEditionPanelStore.cjs.map
33
+ //# sourceMappingURL=useFocusContentStore.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/client/DictionaryEditionDrawer/useFocusContentStore.ts"],"sourcesContent":["import type { KeyPath } from '@intlayer/core';\nimport { create } from 'zustand';\n\ntype DictionaryPath = string;\ntype FileContent = {\n dictionaryPath: DictionaryPath;\n dictionaryId: string;\n keyPath?: KeyPath[];\n};\n\ntype EditionPanelStore = {\n focusedContent: FileContent | null;\n setFocusedContent: (content: FileContent | null) => void;\n};\n\nexport const useEditionPanelStore = create<EditionPanelStore>((set) => ({\n focusedContent: null,\n setFocusedContent: (content) => set({ focusedContent: content }),\n}));\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAAuB;AAchB,MAAM,2BAAuB,uBAA0B,CAAC,SAAS;AAAA,EACtE,gBAAgB;AAAA,EAChB,mBAAmB,CAAC,YAAY,IAAI,EAAE,gBAAgB,QAAQ,CAAC;AACjE,EAAE;","names":[]}
@@ -5,7 +5,7 @@ type DictionaryPath = string;
5
5
  type FileContent = {
6
6
  dictionaryPath: DictionaryPath;
7
7
  dictionaryId: string;
8
- keyPath: KeyPath[];
8
+ keyPath?: KeyPath[];
9
9
  };
10
10
  type EditionPanelStore = {
11
11
  focusedContent: FileContent | null;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var DictionaryListDrawer_exports = {};
30
+ __export(DictionaryListDrawer_exports, {
31
+ DictionaryListDrawer: () => DictionaryListDrawer
32
+ });
33
+ module.exports = __toCommonJS(DictionaryListDrawer_exports);
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var import_design_system = require("@intlayer/design-system");
36
+ var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
37
+ var import_DictionaryEditionDrawer = require('../DictionaryEditionDrawer/index.cjs');
38
+ var import_useDictionaryListDrawer = require('./useDictionaryListDrawer.cjs');
39
+ const DictionaryListDrawer = () => {
40
+ const dictionaryKeyList = Object.keys(import_dictionaries_entry.default);
41
+ const { open: openDictionaryEditionDrawer } = (0, import_DictionaryEditionDrawer.useDictionaryEditionDrawerControl)();
42
+ const { close } = (0, import_useDictionaryListDrawer.useDictionaryListDrawer)();
43
+ const editedContent = (0, import_DictionaryEditionDrawer.useEditedContentStore)((s) => s.editedContent);
44
+ const handleClickDictionary = (dictionaryId) => {
45
+ const { filePath } = import_dictionaries_entry.default[dictionaryId];
46
+ close();
47
+ openDictionaryEditionDrawer({ dictionaryId, dictionaryPath: filePath });
48
+ };
49
+ const isDictionaryEdited = (dictionaryId) => {
50
+ const dictionaryPath = import_dictionaries_entry.default[dictionaryId].filePath;
51
+ return Object.keys(editedContent).includes(dictionaryPath);
52
+ };
53
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
54
+ import_design_system.RightDrawer,
55
+ {
56
+ title: "Dictionary list",
57
+ identifier: import_useDictionaryListDrawer.dictionaryListDrawerIdentifier,
58
+ children: dictionaryKeyList.map((dictionaryId) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
59
+ import_design_system.RedirectionButton,
60
+ {
61
+ label: `Open dictionary editor ${dictionaryId}`,
62
+ onClick: () => handleClickDictionary(dictionaryId),
63
+ children: isDictionaryEdited(dictionaryId) ? `\u270E ${dictionaryId}` : dictionaryId
64
+ },
65
+ dictionaryId
66
+ ))
67
+ }
68
+ );
69
+ };
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ DictionaryListDrawer
73
+ });
74
+ //# sourceMappingURL=DictionaryListDrawer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/client/DictionaryListDrawer/DictionaryListDrawer.tsx"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport { RightDrawer, RedirectionButton } from '@intlayer/design-system';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { FC } from 'react';\nimport {\n useDictionaryEditionDrawerControl,\n useEditedContentStore,\n} from '../DictionaryEditionDrawer/index';\nimport {\n dictionaryListDrawerIdentifier,\n useDictionaryListDrawer,\n} from './useDictionaryListDrawer';\n\nexport const DictionaryListDrawer: FC = () => {\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 const dictionaryPath = dictionaries[dictionaryId].filePath;\n\n return Object.keys(editedContent).includes(dictionaryPath);\n };\n\n return (\n <RightDrawer\n title=\"Dictionary list\"\n identifier={dictionaryListDrawerIdentifier}\n >\n {dictionaryKeyList.map((dictionaryId) => (\n <RedirectionButton\n key={dictionaryId}\n label={`Open dictionary editor ${dictionaryId}`}\n onClick={() => handleClickDictionary(dictionaryId)}\n >\n {isDictionaryEdited(dictionaryId)\n ? `✎ ${dictionaryId}`\n : dictionaryId}\n </RedirectionButton>\n ))}\n </RightDrawer>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4CQ;AA3CR,2BAA+C;AAM/C,gCAAyB;AAEzB,qCAGO;AACP,qCAGO;AAEA,MAAM,uBAA2B,MAAM;AAC5C,QAAM,oBAAoB,OAAO,KAAK,0BAAAA,OAAY;AAClD,QAAM,EAAE,MAAM,4BAA4B,QACxC,kEAAkC;AACpC,QAAM,EAAE,MAAM,QAAI,wDAAwB;AAC1C,QAAM,oBAAgB,sDAAsB,CAAC,MAAM,EAAE,aAAa;AAElE,QAAM,wBAAwB,CAAC,iBAAyB;AACtD,UAAM,EAAE,SAAS,IAAI,0BAAAA,QAAa,YAAY;AAE9C,UAAM;AACN,gCAA4B,EAAE,cAAc,gBAAgB,SAAS,CAAC;AAAA,EACxE;AAEA,QAAM,qBAAqB,CAAC,iBAAyB;AACnD,UAAM,iBAAiB,0BAAAA,QAAa,YAAY,EAAE;AAElD,WAAO,OAAO,KAAK,aAAa,EAAE,SAAS,cAAc;AAAA,EAC3D;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAM;AAAA,MACN,YAAY;AAAA,MAEX,4BAAkB,IAAI,CAAC,iBACtB;AAAA,QAAC;AAAA;AAAA,UAEC,OAAO,0BAA0B,YAAY;AAAA,UAC7C,SAAS,MAAM,sBAAsB,YAAY;AAAA,UAEhD,6BAAmB,YAAY,IAC5B,UAAK,YAAY,KACjB;AAAA;AAAA,QANC;AAAA,MAOP,CACD;AAAA;AAAA,EACH;AAEJ;","names":["dictionaries"]}
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+
3
+ declare const DictionaryListDrawer: FC;
4
+
5
+ export { DictionaryListDrawer };
@@ -13,15 +13,13 @@ var __copyProps = (to, from, except, desc) => {
13
13
  };
14
14
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
15
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var EditionPanel_exports = {};
17
- module.exports = __toCommonJS(EditionPanel_exports);
18
- __reExport(EditionPanel_exports, require('./EditionPanel.cjs'), module.exports);
19
- __reExport(EditionPanel_exports, require('./useEditionPanelStore.cjs'), module.exports);
20
- __reExport(EditionPanel_exports, require('./useEditedContentStore.cjs'), module.exports);
16
+ var DictionaryListDrawer_exports = {};
17
+ module.exports = __toCommonJS(DictionaryListDrawer_exports);
18
+ __reExport(DictionaryListDrawer_exports, require('./DictionaryListDrawer.cjs'), module.exports);
19
+ __reExport(DictionaryListDrawer_exports, require('./useDictionaryListDrawer.cjs'), module.exports);
21
20
  // Annotate the CommonJS export names for ESM import in node:
22
21
  0 && (module.exports = {
23
- ...require('./EditionPanel.cjs'),
24
- ...require('./useEditionPanelStore.cjs'),
25
- ...require('./useEditedContentStore.cjs')
22
+ ...require('./DictionaryListDrawer.cjs'),
23
+ ...require('./useDictionaryListDrawer.cjs')
26
24
  });
27
25
  //# sourceMappingURL=index.cjs.map
@@ -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,3 @@
1
+ export { DictionaryListDrawer } from './DictionaryListDrawer.js';
2
+ export { dictionaryListDrawerIdentifier, useDictionaryListDrawer } from './useDictionaryListDrawer.js';
3
+ import 'react';
@@ -16,24 +16,18 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var renderContentSelector_exports = {};
20
- __export(renderContentSelector_exports, {
21
- renderContentEditor: () => renderContentEditor
19
+ var useDictionaryListDrawer_exports = {};
20
+ __export(useDictionaryListDrawer_exports, {
21
+ dictionaryListDrawerIdentifier: () => dictionaryListDrawerIdentifier,
22
+ useDictionaryListDrawer: () => useDictionaryListDrawer
22
23
  });
23
- module.exports = __toCommonJS(renderContentSelector_exports);
24
- var import_jsx_runtime = require("react/jsx-runtime");
25
- var import_ContentSelectorWrapper = require('./ContentSelectorWrapper.cjs');
26
- const renderContentEditor = (content, dictionaryId, dictionaryPath, keyPath) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
27
- import_ContentSelectorWrapper.ContentSelectorWrapper,
28
- {
29
- dictionaryId,
30
- dictionaryPath,
31
- keyPath,
32
- children: content
33
- }
34
- );
24
+ module.exports = __toCommonJS(useDictionaryListDrawer_exports);
25
+ var import_design_system = require("@intlayer/design-system");
26
+ const dictionaryListDrawerIdentifier = "dictionaryList";
27
+ const useDictionaryListDrawer = () => (0, import_design_system.useRightDrawerStore)(dictionaryListDrawerIdentifier)();
35
28
  // Annotate the CommonJS export names for ESM import in node:
36
29
  0 && (module.exports = {
37
- renderContentEditor
30
+ dictionaryListDrawerIdentifier,
31
+ useDictionaryListDrawer
38
32
  });
39
- //# sourceMappingURL=renderContentSelector.cjs.map
33
+ //# sourceMappingURL=useDictionaryListDrawer.cjs.map
@@ -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,8 @@
1
+ declare const dictionaryListDrawerIdentifier = "dictionaryList";
2
+ declare const useDictionaryListDrawer: () => {
3
+ isOpen: boolean;
4
+ open: () => void;
5
+ close: () => void;
6
+ };
7
+
8
+ export { dictionaryListDrawerIdentifier, useDictionaryListDrawer };
@@ -15,15 +15,17 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
15
15
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
16
  var client_exports = {};
17
17
  module.exports = __toCommonJS(client_exports);
18
- __reExport(client_exports, require('./renderContentSelector.cjs'), module.exports);
19
- __reExport(client_exports, require('./EditionPanel/index.cjs'), module.exports);
18
+ __reExport(client_exports, require('./DictionaryEditionDrawer/index.cjs'), module.exports);
19
+ __reExport(client_exports, require('./DictionaryListDrawer/index.cjs'), module.exports);
20
20
  __reExport(client_exports, require('./ContentEditionLayout.cjs'), module.exports);
21
21
  __reExport(client_exports, require('./useEditorServer.cjs'), module.exports);
22
+ __reExport(client_exports, require('./renderContentEditor.cjs'), module.exports);
22
23
  // Annotate the CommonJS export names for ESM import in node:
23
24
  0 && (module.exports = {
24
- ...require('./renderContentSelector.cjs'),
25
- ...require('./EditionPanel/index.cjs'),
25
+ ...require('./DictionaryEditionDrawer/index.cjs'),
26
+ ...require('./DictionaryListDrawer/index.cjs'),
26
27
  ...require('./ContentEditionLayout.cjs'),
27
- ...require('./useEditorServer.cjs')
28
+ ...require('./useEditorServer.cjs'),
29
+ ...require('./renderContentEditor.cjs')
28
30
  });
29
31
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export * from './renderContentSelector';\nexport * from './EditionPanel/index';\nexport * from './ContentEditionLayout';\nexport * from './useEditorServer';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,2BAAc,oCAAd;AACA,2BAAc,iCADd;AAEA,2BAAc,mCAFd;AAGA,2BAAc,8BAHd;","names":[]}
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';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,2BAAc,4CAAd;AACA,2BAAc,yCADd;AAEA,2BAAc,mCAFd;AAGA,2BAAc,8BAHd;AAIA,2BAAc,kCAJd;","names":[]}
@@ -1,13 +1,14 @@
1
- export { renderContentEditor } from './renderContentSelector.js';
2
- export { EditionPanel } from './EditionPanel/EditionPanel.js';
3
- export { useEditionPanelStore } from './EditionPanel/useEditionPanelStore.js';
4
- export { EditedContent, useEditedContentStore } from './EditionPanel/useEditedContentStore.js';
1
+ export { DictionaryEditionDrawer, DictionaryEditionDrawerContent, DictionaryEditionDrawerController, getDrawerIdentifier } from './DictionaryEditionDrawer/DictionaryEditionDrawer.js';
2
+ export { FileContent, useDictionaryEditionDrawer, useDictionaryEditionDrawerControl } from './DictionaryEditionDrawer/useDictionaryEditionDrawer.js';
3
+ export { EditedContent, useEditedContentStore } from './DictionaryEditionDrawer/useEditedContentStore.js';
4
+ export { DictionaryListDrawer } from './DictionaryListDrawer/DictionaryListDrawer.js';
5
+ export { dictionaryListDrawerIdentifier, useDictionaryListDrawer } from './DictionaryListDrawer/useDictionaryListDrawer.js';
5
6
  export { ContentEditionLayout, ContentEditionLayoutProps } from './ContentEditionLayout.js';
6
7
  export { useEditorServer } from './useEditorServer.js';
7
- import 'react/jsx-runtime';
8
- import '@intlayer/core';
8
+ export { IntlayerEditorElementProps, renderIntlayerEditor } from './renderContentEditor.js';
9
9
  import '@intlayer/config/client';
10
10
  import 'react';
11
- import 'zustand';
11
+ import '@intlayer/core';
12
12
  import 'zustand/middleware';
13
+ import 'zustand';
13
14
  import '@intlayer/design-system';
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var renderContentEditor_exports = {};
20
+ __export(renderContentEditor_exports, {
21
+ renderIntlayerEditor: () => renderIntlayerEditor
22
+ });
23
+ module.exports = __toCommonJS(renderContentEditor_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_client = require("@intlayer/config/client");
26
+ var import_ContentSelectorWrapper = require('./ContentSelectorWrapper.cjs');
27
+ const {
28
+ editor: { enabled }
29
+ } = (0, import_client.getConfiguration)();
30
+ const IntlayerEditorElement = ({
31
+ content,
32
+ ...props
33
+ }) => {
34
+ if (enabled) {
35
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentSelectorWrapper.ContentSelectorWrapper, { ...props, children: content });
36
+ }
37
+ return content;
38
+ };
39
+ IntlayerEditorElement.content = "";
40
+ const renderIntlayerEditor = (data) => {
41
+ const Result = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerEditorElement, { ...data });
42
+ return { ...Result, value: data.content };
43
+ };
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ renderIntlayerEditor
47
+ });
48
+ //# sourceMappingURL=renderContentEditor.cjs.map
@@ -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 { 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};\n\ntype RenderIntlayerEditorResult = ReactNode & { value: string };\n\nconst IntlayerEditorElement = ({\n content,\n ...props\n}: IntlayerEditorElementProps) => {\n if (enabled) {\n return (\n <ContentSelectorWrapper {...props}>{content}</ContentSelectorWrapper>\n );\n }\n return content;\n};\n\nIntlayerEditorElement.content = '';\n\nexport const renderIntlayerEditor = (\n data: IntlayerEditorElementProps\n): RenderIntlayerEditorResult => {\n const Result = <IntlayerEditorElement {...data} />;\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;AAWrB,MAAM,wBAAwB,CAAC;AAAA,EAC7B;AAAA,EACA,GAAG;AACL,MAAkC;AAChC,MAAI,SAAS;AACX,WACE,4CAAC,wDAAwB,GAAG,OAAQ,mBAAQ;AAAA,EAEhD;AACA,SAAO;AACT;AAEA,sBAAsB,UAAU;AAEzB,MAAM,uBAAuB,CAClC,SAC+B;AAC/B,QAAM,SAAS,4CAAC,yBAAuB,GAAG,MAAM;AAEhD,SAAO,EAAE,GAAG,QAAQ,OAAO,KAAK,QAAQ;AAC1C;","names":[]}
@@ -0,0 +1,15 @@
1
+ import { KeyPath } from '@intlayer/core';
2
+ import { ReactNode } from 'react';
3
+
4
+ type IntlayerEditorElementProps = {
5
+ content: string;
6
+ dictionaryId: string;
7
+ dictionaryPath: string;
8
+ keyPath: KeyPath[];
9
+ };
10
+ type RenderIntlayerEditorResult = ReactNode & {
11
+ value: string;
12
+ };
13
+ declare const renderIntlayerEditor: (data: IntlayerEditorElementProps) => RenderIntlayerEditorResult;
14
+
15
+ export { type IntlayerEditorElementProps, renderIntlayerEditor };
@@ -22,9 +22,12 @@ __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('./EditionPanel/useEditedContentStore.cjs');
25
+ var import_useEditedContentStore = require('./DictionaryEditionDrawer/useEditedContentStore.cjs');
26
26
  const useEditorServer = () => {
27
- const { editedContent, clearEditedContent } = (0, import_useEditedContentStore.useEditedContentStore)();
27
+ const { editedContent, clearEditedContent } = (0, import_useEditedContentStore.useEditedContentStore)((s) => ({
28
+ editedContent: s.editedContent,
29
+ clearEditedContent: s.clearEditedContent
30
+ }));
28
31
  const editContentRequest = async () => {
29
32
  const {
30
33
  editor: { port }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useEditorServer.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport { useEditedContentStore } from './EditionPanel/useEditedContentStore';\n\nexport const useEditorServer = () => {\n const { editedContent, clearEditedContent } = useEditedContentStore();\n\n const editContentRequest = async () => {\n const {\n editor: { port },\n } = getConfiguration();\n\n await fetch(`http://localhost:${port}`, {\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,mCAAsC;AAE/B,MAAM,kBAAkB,MAAM;AACnC,QAAM,EAAE,eAAe,mBAAmB,QAAI,oDAAsB;AAEpE,QAAM,qBAAqB,YAAY;AACrC,UAAM;AAAA,MACJ,QAAQ,EAAE,KAAK;AAAA,IACjB,QAAI,gCAAiB;AAErB,UAAM,MAAM,oBAAoB,IAAI,IAAI;AAAA,MACtC,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":[]}
1
+ {"version":3,"sources":["../../../src/client/useEditorServer.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport { useEditedContentStore } from './DictionaryEditionDrawer/useEditedContentStore';\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: { port },\n } = getConfiguration();\n\n await fetch(`http://localhost:${port}`, {\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,mCAAsC;AAE/B,MAAM,kBAAkB,MAAM;AACnC,QAAM,EAAE,eAAe,mBAAmB,QAAI,oDAAsB,CAAC,OAAO;AAAA,IAC1E,eAAe,EAAE;AAAA,IACjB,oBAAoB,EAAE;AAAA,EACxB,EAAE;AAEF,QAAM,qBAAqB,YAAY;AACrC,UAAM;AAAA,MACJ,QAAQ,EAAE,KAAK;AAAA,IACjB,QAAI,gCAAiB;AAErB,UAAM,MAAM,oBAAoB,IAAI,IAAI;AAAA,MACtC,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":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var formatPrettier_exports = {};
30
+ __export(formatPrettier_exports, {
31
+ format: () => format
32
+ });
33
+ module.exports = __toCommonJS(formatPrettier_exports);
34
+ var import_prettier = __toESM(require("prettier"));
35
+ const format = async (content) => {
36
+ let options = {};
37
+ try {
38
+ options = await import_prettier.default.resolveConfig(content, {
39
+ editorconfig: true
40
+ }) ?? {};
41
+ } catch (error) {
42
+ console.error("Failed to resolve Prettier configuration:", error);
43
+ }
44
+ const config = { ...options, parser: "typescript" };
45
+ return import_prettier.default.format(content, config);
46
+ };
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ format
50
+ });
51
+ //# sourceMappingURL=formatPrettier.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/server/formatPrettier.ts"],"sourcesContent":["import prettier from 'prettier';\n\n/**\n * Format the content with Prettier\n */\nexport const format = async (content: string) => {\n // Resolve the configuration from the project\n let options: prettier.Options = {};\n\n try {\n // Resolve the prettier configuration from the project\n options =\n (await prettier.resolveConfig(content, {\n editorconfig: true,\n })) ?? {};\n } catch (error) {\n console.error('Failed to resolve Prettier configuration:', error);\n }\n\n // Add the parser option to the resolved config\n const config: prettier.Options = { ...options, parser: 'typescript' };\n\n return prettier.format(content, config);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AAKd,MAAM,SAAS,OAAO,YAAoB;AAE/C,MAAI,UAA4B,CAAC;AAEjC,MAAI;AAEF,cACG,MAAM,gBAAAA,QAAS,cAAc,SAAS;AAAA,MACrC,cAAc;AAAA,IAChB,CAAC,KAAM,CAAC;AAAA,EACZ,SAAS,OAAO;AACd,YAAQ,MAAM,6CAA6C,KAAK;AAAA,EAClE;AAGA,QAAM,SAA2B,EAAE,GAAG,SAAS,QAAQ,aAAa;AAEpE,SAAO,gBAAAA,QAAS,OAAO,SAAS,MAAM;AACxC;","names":["prettier"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Format the content with Prettier
3
+ */
4
+ declare const format: (content: string) => Promise<string>;
5
+
6
+ export { format };
@@ -34,7 +34,7 @@ module.exports = __toCommonJS(server_exports);
34
34
  var import_config = require("@intlayer/config");
35
35
  var import_body_parser = __toESM(require("body-parser"));
36
36
  var import_express = __toESM(require("express"));
37
- var import_content_editor = require('./content-editor.cjs');
37
+ var import_processEdition = require('./processEdition.cjs');
38
38
  const startIntlayerEditor = () => {
39
39
  const app = (0, import_express.default)();
40
40
  const {
@@ -47,7 +47,7 @@ const startIntlayerEditor = () => {
47
47
  async (req, res) => {
48
48
  const editedContent = req.body;
49
49
  try {
50
- await (0, import_content_editor.editContent)(editedContent);
50
+ await (0, import_processEdition.processEdition)(editedContent);
51
51
  res.send({ success: true, editedContent });
52
52
  } catch (error) {
53
53
  console.error(error);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport bodyParser from 'body-parser';\nimport express, { type Request, type Response } from 'express';\nimport type { EditedContent } from '../client';\nimport { editContent } from './content-editor';\n\nexport const startIntlayerEditor = () => {\n const app = express();\n const {\n editor: { port },\n } = getConfiguration();\n\n app.use(bodyParser.json());\n app.use(bodyParser.urlencoded({ extended: true }));\n\n app.post(\n '/',\n async (\n req: Request<undefined, undefined, EditedContent>,\n res: Response\n ) => {\n const editedContent = req.body;\n\n try {\n await editContent(editedContent);\n\n res.send({ success: true, editedContent });\n } catch (error) {\n console.error(error);\n res.status(500).send({ success: false });\n }\n }\n );\n\n app.listen(port, () => {\n console.info(\n `Intlayer editor server is running on http://localhost:${port}`\n );\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,yBAAuB;AACvB,qBAAqD;AAErD,4BAA4B;AAErB,MAAM,sBAAsB,MAAM;AACvC,QAAM,UAAM,eAAAA,SAAQ;AACpB,QAAM;AAAA,IACJ,QAAQ,EAAE,KAAK;AAAA,EACjB,QAAI,gCAAiB;AAErB,MAAI,IAAI,mBAAAC,QAAW,KAAK,CAAC;AACzB,MAAI,IAAI,mBAAAA,QAAW,WAAW,EAAE,UAAU,KAAK,CAAC,CAAC;AAEjD,MAAI;AAAA,IACF;AAAA,IACA,OACE,KACA,QACG;AACH,YAAM,gBAAgB,IAAI;AAE1B,UAAI;AACF,kBAAM,mCAAY,aAAa;AAE/B,YAAI,KAAK,EAAE,SAAS,MAAM,cAAc,CAAC;AAAA,MAC3C,SAAS,OAAO;AACd,gBAAQ,MAAM,KAAK;AACnB,YAAI,OAAO,GAAG,EAAE,KAAK,EAAE,SAAS,MAAM,CAAC;AAAA,MACzC;AAAA,IACF;AAAA,EACF;AAEA,MAAI,OAAO,MAAM,MAAM;AACrB,YAAQ;AAAA,MACN,yDAAyD,IAAI;AAAA,IAC/D;AAAA,EACF,CAAC;AACH;","names":["express","bodyParser"]}
1
+ {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport bodyParser from 'body-parser';\nimport express, { type Request, type Response } from 'express';\nimport type { EditedContent } from '../client';\nimport { processEdition } from './processEdition';\n\nexport const startIntlayerEditor = () => {\n const app = express();\n const {\n editor: { port },\n } = getConfiguration();\n\n app.use(bodyParser.json());\n app.use(bodyParser.urlencoded({ extended: true }));\n\n app.post(\n '/',\n async (\n req: Request<undefined, undefined, EditedContent>,\n res: Response\n ) => {\n const editedContent = req.body;\n\n try {\n await processEdition(editedContent);\n\n res.send({ success: true, editedContent });\n } catch (error) {\n console.error(error);\n res.status(500).send({ success: false });\n }\n }\n );\n\n app.listen(port, () => {\n console.info(\n `Intlayer editor server is running on http://localhost:${port}`\n );\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,yBAAuB;AACvB,qBAAqD;AAErD,4BAA+B;AAExB,MAAM,sBAAsB,MAAM;AACvC,QAAM,UAAM,eAAAA,SAAQ;AACpB,QAAM;AAAA,IACJ,QAAQ,EAAE,KAAK;AAAA,EACjB,QAAI,gCAAiB;AAErB,MAAI,IAAI,mBAAAC,QAAW,KAAK,CAAC;AACzB,MAAI,IAAI,mBAAAA,QAAW,WAAW,EAAE,UAAU,KAAK,CAAC,CAAC;AAEjD,MAAI;AAAA,IACF;AAAA,IACA,OACE,KACA,QACG;AACH,YAAM,gBAAgB,IAAI;AAE1B,UAAI;AACF,kBAAM,sCAAe,aAAa;AAElC,YAAI,KAAK,EAAE,SAAS,MAAM,cAAc,CAAC;AAAA,MAC3C,SAAS,OAAO;AACd,gBAAQ,MAAM,KAAK;AACnB,YAAI,OAAO,GAAG,EAAE,KAAK,EAAE,SAAS,MAAM,CAAC;AAAA,MACzC;AAAA,IACF;AAAA,EACF;AAEA,MAAI,OAAO,MAAM,MAAM;AACrB,YAAQ;AAAA,MACN,yDAAyD,IAAI;AAAA,IAC/D;AAAA,EACF,CAAC;AACH;","names":["express","bodyParser"]}