intlayer-editor 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +175 -0
- package/bin/start-server.js +16 -0
- package/dist/cjs/client/ContentEditionLayout.cjs +46 -0
- package/dist/cjs/client/ContentEditionLayout.cjs.map +1 -0
- package/dist/cjs/client/ContentEditionLayout.d.ts +12 -0
- package/dist/cjs/client/ContentSelectorWrapper.cjs +49 -0
- package/dist/cjs/client/ContentSelectorWrapper.cjs.map +1 -0
- package/dist/cjs/client/ContentSelectorWrapper.d.ts +12 -0
- package/dist/cjs/client/EditionPanel/EditionPanel.cjs +101 -0
- package/dist/cjs/client/EditionPanel/EditionPanel.cjs.map +1 -0
- package/dist/cjs/client/EditionPanel/EditionPanel.d.ts +11 -0
- package/dist/cjs/client/EditionPanel/index.cjs +27 -0
- package/dist/cjs/client/EditionPanel/index.cjs.map +1 -0
- package/dist/cjs/client/EditionPanel/index.d.ts +9 -0
- package/dist/cjs/client/EditionPanel/useEditedContentStore.cjs +90 -0
- package/dist/cjs/client/EditionPanel/useEditedContentStore.cjs.map +1 -0
- package/dist/cjs/client/EditionPanel/useEditedContentStore.d.ts +28 -0
- package/dist/cjs/client/EditionPanel/useEditionPanelStore.cjs +33 -0
- package/dist/cjs/client/EditionPanel/useEditionPanelStore.cjs.map +1 -0
- package/dist/cjs/client/EditionPanel/useEditionPanelStore.d.ts +16 -0
- package/dist/cjs/client/index.cjs +29 -0
- package/dist/cjs/client/index.cjs.map +1 -0
- package/dist/cjs/client/index.d.ts +13 -0
- package/dist/cjs/client/renderContentSelector.cjs +39 -0
- package/dist/cjs/client/renderContentSelector.cjs.map +1 -0
- package/dist/cjs/client/renderContentSelector.d.ts +6 -0
- package/dist/cjs/client/useEditorServer.cjs +53 -0
- package/dist/cjs/client/useEditorServer.cjs.map +1 -0
- package/dist/cjs/client/useEditorServer.d.ts +5 -0
- package/dist/cjs/server/content-editor.cjs +156 -0
- package/dist/cjs/server/content-editor.cjs.map +1 -0
- package/dist/cjs/server/content-editor.d.ts +12 -0
- package/dist/cjs/server/index.cjs +68 -0
- package/dist/cjs/server/index.cjs.map +1 -0
- package/dist/cjs/server/index.d.ts +3 -0
- package/dist/esm/client/ContentEditionLayout.d.mts +12 -0
- package/dist/esm/client/ContentEditionLayout.mjs +22 -0
- package/dist/esm/client/ContentEditionLayout.mjs.map +1 -0
- package/dist/esm/client/ContentSelectorWrapper.d.mts +12 -0
- package/dist/esm/client/ContentSelectorWrapper.mjs +25 -0
- package/dist/esm/client/ContentSelectorWrapper.mjs.map +1 -0
- package/dist/esm/client/EditionPanel/EditionPanel.d.mts +11 -0
- package/dist/esm/client/EditionPanel/EditionPanel.mjs +72 -0
- package/dist/esm/client/EditionPanel/EditionPanel.mjs.map +1 -0
- package/dist/esm/client/EditionPanel/index.d.mts +9 -0
- package/dist/esm/client/EditionPanel/index.mjs +4 -0
- package/dist/esm/client/EditionPanel/index.mjs.map +1 -0
- package/dist/esm/client/EditionPanel/useEditedContentStore.d.mts +28 -0
- package/dist/esm/client/EditionPanel/useEditedContentStore.mjs +66 -0
- package/dist/esm/client/EditionPanel/useEditedContentStore.mjs.map +1 -0
- package/dist/esm/client/EditionPanel/useEditionPanelStore.d.mts +16 -0
- package/dist/esm/client/EditionPanel/useEditionPanelStore.mjs +9 -0
- package/dist/esm/client/EditionPanel/useEditionPanelStore.mjs.map +1 -0
- package/dist/esm/client/index.d.mts +13 -0
- package/dist/esm/client/index.mjs +5 -0
- package/dist/esm/client/index.mjs.map +1 -0
- package/dist/esm/client/renderContentSelector.d.mts +6 -0
- package/dist/esm/client/renderContentSelector.mjs +15 -0
- package/dist/esm/client/renderContentSelector.mjs.map +1 -0
- package/dist/esm/client/useEditorServer.d.mts +5 -0
- package/dist/esm/client/useEditorServer.mjs +29 -0
- package/dist/esm/client/useEditorServer.mjs.map +1 -0
- package/dist/esm/server/content-editor.d.mts +12 -0
- package/dist/esm/server/content-editor.mjs +123 -0
- package/dist/esm/server/content-editor.mjs.map +1 -0
- package/dist/esm/server/index.d.mts +3 -0
- package/dist/esm/server/index.mjs +34 -0
- package/dist/esm/server/index.mjs.map +1 -0
- package/package.json +109 -0
- package/src/client/ContentEditionLayout.tsx +26 -0
- package/src/client/ContentSelectorWrapper.tsx +38 -0
- package/src/client/EditionPanel/EditionPanel.tsx +90 -0
- package/src/client/EditionPanel/index.ts +3 -0
- package/src/client/EditionPanel/useEditedContentStore.ts +98 -0
- package/src/client/EditionPanel/useEditionPanelStore.ts +19 -0
- package/src/client/index.ts +4 -0
- package/src/client/renderContentSelector.tsx +17 -0
- package/src/client/useEditorServer.ts +31 -0
- package/src/server/content-editor.ts +209 -0
- package/src/server/index.ts +40 -0
|
@@ -0,0 +1,33 @@
|
|
|
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 useEditionPanelStore_exports = {};
|
|
20
|
+
__export(useEditionPanelStore_exports, {
|
|
21
|
+
useEditionPanelStore: () => useEditionPanelStore
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useEditionPanelStore_exports);
|
|
24
|
+
var import_zustand = require("zustand");
|
|
25
|
+
const useEditionPanelStore = (0, import_zustand.create)((set) => ({
|
|
26
|
+
focusedContent: null,
|
|
27
|
+
setFocusedContent: (content) => set({ focusedContent: content })
|
|
28
|
+
}));
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
useEditionPanelStore
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=useEditionPanelStore.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/EditionPanel/useEditionPanelStore.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":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as zustand from 'zustand';
|
|
2
|
+
import { KeyPath } from '@intlayer/core';
|
|
3
|
+
|
|
4
|
+
type DictionaryPath = string;
|
|
5
|
+
type FileContent = {
|
|
6
|
+
dictionaryPath: DictionaryPath;
|
|
7
|
+
dictionaryId: string;
|
|
8
|
+
keyPath: KeyPath[];
|
|
9
|
+
};
|
|
10
|
+
type EditionPanelStore = {
|
|
11
|
+
focusedContent: FileContent | null;
|
|
12
|
+
setFocusedContent: (content: FileContent | null) => void;
|
|
13
|
+
};
|
|
14
|
+
declare const useEditionPanelStore: zustand.UseBoundStore<zustand.StoreApi<EditionPanelStore>>;
|
|
15
|
+
|
|
16
|
+
export { useEditionPanelStore };
|
|
@@ -0,0 +1,29 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var client_exports = {};
|
|
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);
|
|
20
|
+
__reExport(client_exports, require('./ContentEditionLayout.cjs'), module.exports);
|
|
21
|
+
__reExport(client_exports, require('./useEditorServer.cjs'), module.exports);
|
|
22
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
23
|
+
0 && (module.exports = {
|
|
24
|
+
...require('./renderContentSelector.cjs'),
|
|
25
|
+
...require('./EditionPanel/index.cjs'),
|
|
26
|
+
...require('./ContentEditionLayout.cjs'),
|
|
27
|
+
...require('./useEditorServer.cjs')
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +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":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
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';
|
|
5
|
+
export { ContentEditionLayout, ContentEditionLayoutProps } from './ContentEditionLayout.js';
|
|
6
|
+
export { useEditorServer } from './useEditorServer.js';
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
import '@intlayer/core';
|
|
9
|
+
import '@intlayer/config/client';
|
|
10
|
+
import 'react';
|
|
11
|
+
import 'zustand';
|
|
12
|
+
import 'zustand/middleware';
|
|
13
|
+
import '@intlayer/design-system';
|
|
@@ -0,0 +1,39 @@
|
|
|
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 renderContentSelector_exports = {};
|
|
20
|
+
__export(renderContentSelector_exports, {
|
|
21
|
+
renderContentEditor: () => renderContentEditor
|
|
22
|
+
});
|
|
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
|
+
);
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
renderContentEditor
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=renderContentSelector.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/renderContentSelector.tsx"],"sourcesContent":["import type { KeyPath } from '@intlayer/core';\nimport { ContentSelectorWrapper } from './ContentSelectorWrapper';\n\nexport const renderContentEditor = (\n content: string,\n dictionaryId: string,\n dictionaryPath: string,\n keyPath: KeyPath[]\n) => (\n <ContentSelectorWrapper\n dictionaryId={dictionaryId}\n dictionaryPath={dictionaryPath}\n keyPath={keyPath}\n >\n {content}\n </ContentSelectorWrapper>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASE;AARF,oCAAuC;AAEhC,MAAM,sBAAsB,CACjC,SACA,cACA,gBACA,YAEA;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IAEC;AAAA;AACH;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { KeyPath } from '@intlayer/core';
|
|
3
|
+
|
|
4
|
+
declare const renderContentEditor: (content: string, dictionaryId: string, dictionaryPath: string, keyPath: KeyPath[]) => react_jsx_runtime.JSX.Element;
|
|
5
|
+
|
|
6
|
+
export { renderContentEditor };
|
|
@@ -0,0 +1,53 @@
|
|
|
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 useEditorServer_exports = {};
|
|
20
|
+
__export(useEditorServer_exports, {
|
|
21
|
+
useEditorServer: () => useEditorServer
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useEditorServer_exports);
|
|
24
|
+
var import_client = require("@intlayer/config/client");
|
|
25
|
+
var import_useEditedContentStore = require('./EditionPanel/useEditedContentStore.cjs');
|
|
26
|
+
const useEditorServer = () => {
|
|
27
|
+
const { editedContent, clearEditedContent } = (0, import_useEditedContentStore.useEditedContentStore)();
|
|
28
|
+
const editContentRequest = async () => {
|
|
29
|
+
const {
|
|
30
|
+
editor: { port }
|
|
31
|
+
} = (0, import_client.getConfiguration)();
|
|
32
|
+
await fetch(`http://localhost:${port}`, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: {
|
|
35
|
+
"Content-Type": "application/json"
|
|
36
|
+
},
|
|
37
|
+
body: JSON.stringify(editedContent)
|
|
38
|
+
}).then((response) => {
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
throw new Error("Failed to edit content");
|
|
41
|
+
}
|
|
42
|
+
clearEditedContent();
|
|
43
|
+
}).catch((error) => {
|
|
44
|
+
console.error("Failed to edit content:", error);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
return { editContentRequest };
|
|
48
|
+
};
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
useEditorServer
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=useEditorServer.cjs.map
|
|
@@ -0,0 +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":[]}
|
|
@@ -0,0 +1,156 @@
|
|
|
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 content_editor_exports = {};
|
|
30
|
+
__export(content_editor_exports, {
|
|
31
|
+
editContent: () => editContent
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(content_editor_exports);
|
|
34
|
+
var import_fs = require("fs");
|
|
35
|
+
var import_module = require("module");
|
|
36
|
+
var import_parser = require("@babel/parser");
|
|
37
|
+
var import_core = require("@intlayer/core");
|
|
38
|
+
var import_prettier = __toESM(require("prettier"));
|
|
39
|
+
const import_meta = {};
|
|
40
|
+
const requireFunction = typeof import_meta.url === "undefined" ? require : (0, import_module.createRequire)(import_meta.url);
|
|
41
|
+
const { default: generate } = requireFunction("@babel/generator");
|
|
42
|
+
const findNestedProperty = (obj, keyPath) => {
|
|
43
|
+
let currentObj = obj;
|
|
44
|
+
for (const key of keyPath) {
|
|
45
|
+
let foundProperty;
|
|
46
|
+
if (
|
|
47
|
+
// if the keyPath is an object, select the related node
|
|
48
|
+
key.type === "ObjectExpression"
|
|
49
|
+
) {
|
|
50
|
+
foundProperty = currentObj.properties.find(
|
|
51
|
+
(prop) => "key" in prop && prop.key.name === key.key
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
if (
|
|
55
|
+
// if the keypath is a translation or enumeration node, go across the function and select the related node
|
|
56
|
+
Object.values(import_core.NodeType).includes(
|
|
57
|
+
key.type
|
|
58
|
+
)
|
|
59
|
+
) {
|
|
60
|
+
foundProperty = currentObj.arguments[0].properties.find(
|
|
61
|
+
(prop) => "key" in prop && prop.key.name === key.key
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
if (foundProperty && "value" in foundProperty) {
|
|
65
|
+
currentObj = foundProperty.value;
|
|
66
|
+
} else {
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return currentObj;
|
|
71
|
+
};
|
|
72
|
+
const findAndUpdate = (objExpr, keyPath, newValue) => {
|
|
73
|
+
const lastKey = keyPath[keyPath.length - 1];
|
|
74
|
+
if (lastKey) {
|
|
75
|
+
const propertyToUpdate = findNestedProperty(objExpr, keyPath);
|
|
76
|
+
if (propertyToUpdate && "value" in propertyToUpdate) {
|
|
77
|
+
propertyToUpdate.value = newValue;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const traverseNode = (node, keyPath, newValue) => {
|
|
82
|
+
if (Array.isArray(node.body)) {
|
|
83
|
+
node.body.forEach(
|
|
84
|
+
(subNode) => traverseNode(subNode, keyPath, newValue)
|
|
85
|
+
);
|
|
86
|
+
} else if (node.body) {
|
|
87
|
+
traverseNode(node.body, keyPath, newValue);
|
|
88
|
+
}
|
|
89
|
+
if (
|
|
90
|
+
// For ES Module (e.g., `const variable = ...; export default variable`)
|
|
91
|
+
"declarations" in node
|
|
92
|
+
) {
|
|
93
|
+
node.declarations.forEach((declaration) => {
|
|
94
|
+
if (declaration.init?.type === "ObjectExpression") {
|
|
95
|
+
findAndUpdate(declaration.init, keyPath, newValue);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (
|
|
100
|
+
// For ES Module (e.g., `export default { ... }`)
|
|
101
|
+
"declaration" in node && node.declaration.type === "ObjectExpression"
|
|
102
|
+
) {
|
|
103
|
+
return findAndUpdate(
|
|
104
|
+
node.declaration,
|
|
105
|
+
keyPath,
|
|
106
|
+
newValue
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
if (
|
|
110
|
+
// For CommonJS (e.g., `module.exports = ...`)
|
|
111
|
+
"expression" in node && node.expression.right.type === "ObjectExpression"
|
|
112
|
+
) {
|
|
113
|
+
return findAndUpdate(
|
|
114
|
+
node.expression.right,
|
|
115
|
+
keyPath,
|
|
116
|
+
newValue
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const format = async (content) => {
|
|
121
|
+
let options = {};
|
|
122
|
+
try {
|
|
123
|
+
options = await import_prettier.default.resolveConfig(content, {
|
|
124
|
+
editorconfig: true
|
|
125
|
+
}) ?? {};
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.error("Failed to resolve Prettier configuration:", error);
|
|
128
|
+
}
|
|
129
|
+
const config = { ...options, parser: "typescript" };
|
|
130
|
+
return import_prettier.default.format(content, config);
|
|
131
|
+
};
|
|
132
|
+
const editContent = async (editedContent) => {
|
|
133
|
+
for (const dictionaryPath of Object.keys(editedContent)) {
|
|
134
|
+
const fileContent = (0, import_fs.readFileSync)(dictionaryPath, "utf-8");
|
|
135
|
+
const parsed = (0, import_parser.parse)(fileContent, {
|
|
136
|
+
sourceType: "module",
|
|
137
|
+
plugins: ["jsx", "typescript"]
|
|
138
|
+
});
|
|
139
|
+
for (const { keyPath, newValue } of editedContent[dictionaryPath]) {
|
|
140
|
+
traverseNode(parsed.program, keyPath, newValue);
|
|
141
|
+
}
|
|
142
|
+
const updatedContent = generate(parsed).code;
|
|
143
|
+
if (fileContent === updatedContent) {
|
|
144
|
+
console.info(`Could not find specified key path in ${dictionaryPath}.`);
|
|
145
|
+
} else {
|
|
146
|
+
const formattedContent = await format(updatedContent);
|
|
147
|
+
(0, import_fs.writeFileSync)(dictionaryPath, formattedContent, "utf-8");
|
|
148
|
+
console.info("Updated the file successfully.");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
153
|
+
0 && (module.exports = {
|
|
154
|
+
editContent
|
|
155
|
+
});
|
|
156
|
+
//# sourceMappingURL=content-editor.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/content-editor.ts"],"sourcesContent":["import { readFileSync, writeFileSync } from 'fs';\nimport { createRequire } from 'module';\nimport { parse } from '@babel/parser';\nimport type {\n ObjectExpression,\n VariableDeclarator,\n Program,\n Identifier,\n StringLiteral,\n AssignmentExpression,\n ObjectProperty,\n CallExpression,\n ObjectMethod,\n SpreadElement,\n} from '@babel/types';\nimport {\n NodeType,\n type KeyPath,\n type ObjectExpressionNode,\n type TranslationOrEnumerationNode,\n} from '@intlayer/core';\nimport prettier from 'prettier';\nimport type { EditedContent } from '../client/index';\n\nconst requireFunction =\n typeof import.meta.url === 'undefined'\n ? require\n : createRequire(import.meta.url);\n\nconst { default: generate } = requireFunction('@babel/generator');\n\n/**\n * Helper function to find a nested property in an ObjectExpression based on a key path\n */\nconst findNestedProperty = (\n obj: ObjectExpression,\n keyPath: KeyPath[]\n): ObjectExpression | undefined => {\n let currentObj = obj;\n for (const key of keyPath) {\n let foundProperty:\n | ObjectProperty\n | ObjectMethod\n | SpreadElement\n | undefined;\n\n if (\n // if the keyPath is an object, select the related node\n (key as ObjectExpressionNode).type === 'ObjectExpression'\n ) {\n foundProperty = currentObj.properties.find(\n (prop) =>\n 'key' in prop &&\n (prop.key as Identifier).name === (key as ObjectExpressionNode).key\n );\n }\n\n if (\n // if the keypath is a translation or enumeration node, go across the function and select the related node\n Object.values(NodeType).includes(\n (key as TranslationOrEnumerationNode).type\n )\n ) {\n foundProperty = (\n (currentObj as unknown as CallExpression)\n .arguments[0] as ObjectExpression\n ).properties.find(\n (prop) => 'key' in prop && (prop.key as Identifier).name === key.key\n );\n }\n\n if (foundProperty && 'value' in foundProperty) {\n currentObj = foundProperty.value as ObjectExpression;\n } else {\n return undefined;\n }\n }\n\n return currentObj;\n};\n\n/**\n * Find and update specific content based on key path\n */\nconst findAndUpdate = (\n objExpr: ObjectExpression,\n keyPath: KeyPath[],\n newValue: string\n) => {\n const lastKey = keyPath[keyPath.length - 1]; // Get the last key in the path\n\n if (lastKey) {\n const propertyToUpdate = findNestedProperty(objExpr, keyPath); // Traverse the key path\n\n if (propertyToUpdate && 'value' in propertyToUpdate) {\n (propertyToUpdate as unknown as StringLiteral).value = newValue; // Update the value of the specified key\n }\n }\n};\n\n/**\n * Traverse the AST and update based on key path and new value\n */\nconst traverseNode = (node: Program, keyPath: KeyPath[], newValue: string) => {\n if (Array.isArray(node.body)) {\n (node.body as unknown as Program[]).forEach((subNode) =>\n traverseNode(subNode, keyPath, newValue)\n );\n } else if (node.body) {\n traverseNode(node.body, keyPath, newValue);\n }\n\n if (\n // For ES Module (e.g., `const variable = ...; export default variable`)\n 'declarations' in node\n ) {\n (node.declarations as VariableDeclarator[]).forEach((declaration) => {\n if (declaration.init?.type === 'ObjectExpression') {\n findAndUpdate(declaration.init, keyPath, newValue);\n }\n });\n }\n\n if (\n // For ES Module (e.g., `export default { ... }`)\n 'declaration' in node &&\n (node.declaration as ObjectExpression).type === 'ObjectExpression'\n ) {\n return findAndUpdate(\n node.declaration as ObjectExpression,\n keyPath,\n newValue\n );\n }\n\n if (\n // For CommonJS (e.g., `module.exports = ...`)\n 'expression' in node &&\n (node.expression as AssignmentExpression).right.type === 'ObjectExpression'\n ) {\n return findAndUpdate(\n (node.expression as AssignmentExpression).right as ObjectExpression,\n keyPath,\n newValue\n );\n }\n\n // throw new Error('Could not find the specified key path in the AST.');\n};\n\n/**\n * Format the content with Prettier\n */\nconst 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\n/**\n * Edit the content of a file based on the key path and new value\n */\nexport const editContent = async (editedContent: EditedContent) => {\n // Loop into each dictionary path\n for (const dictionaryPath of Object.keys(editedContent)) {\n // Read the file\n const fileContent = readFileSync(dictionaryPath, 'utf-8');\n\n // Parse the content with TypeScript support\n const parsed = parse(fileContent, {\n sourceType: 'module',\n plugins: ['jsx', 'typescript'],\n });\n\n // Loop into each key path and new value\n for (const { keyPath, newValue } of editedContent[dictionaryPath]) {\n // Update values based on key paths\n traverseNode(parsed.program, keyPath, newValue);\n }\n\n // Generate the updated code\n const updatedContent = generate(parsed).code;\n\n if (fileContent === updatedContent) {\n console.info(`Could not find specified key path in ${dictionaryPath}.`);\n } else {\n const formattedContent = await format(updatedContent);\n\n // Write back to the file\n writeFileSync(dictionaryPath, formattedContent, 'utf-8');\n\n console.info('Updated the file successfully.');\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA4C;AAC5C,oBAA8B;AAC9B,oBAAsB;AAatB,kBAKO;AACP,sBAAqB;AArBrB;AAwBA,MAAM,kBACJ,OAAO,YAAY,QAAQ,cACvB,cACA,6BAAc,YAAY,GAAG;AAEnC,MAAM,EAAE,SAAS,SAAS,IAAI,gBAAgB,kBAAkB;AAKhE,MAAM,qBAAqB,CACzB,KACA,YACiC;AACjC,MAAI,aAAa;AACjB,aAAW,OAAO,SAAS;AACzB,QAAI;AAMJ;AAAA;AAAA,MAEG,IAA6B,SAAS;AAAA,MACvC;AACA,sBAAgB,WAAW,WAAW;AAAA,QACpC,CAAC,SACC,SAAS,QACR,KAAK,IAAmB,SAAU,IAA6B;AAAA,MACpE;AAAA,IACF;AAEA;AAAA;AAAA,MAEE,OAAO,OAAO,oBAAQ,EAAE;AAAA,QACrB,IAAqC;AAAA,MACxC;AAAA,MACA;AACA,sBACG,WACE,UAAU,CAAC,EACd,WAAW;AAAA,QACX,CAAC,SAAS,SAAS,QAAS,KAAK,IAAmB,SAAS,IAAI;AAAA,MACnE;AAAA,IACF;AAEA,QAAI,iBAAiB,WAAW,eAAe;AAC7C,mBAAa,cAAc;AAAA,IAC7B,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAKA,MAAM,gBAAgB,CACpB,SACA,SACA,aACG;AACH,QAAM,UAAU,QAAQ,QAAQ,SAAS,CAAC;AAE1C,MAAI,SAAS;AACX,UAAM,mBAAmB,mBAAmB,SAAS,OAAO;AAE5D,QAAI,oBAAoB,WAAW,kBAAkB;AACnD,MAAC,iBAA8C,QAAQ;AAAA,IACzD;AAAA,EACF;AACF;AAKA,MAAM,eAAe,CAAC,MAAe,SAAoB,aAAqB;AAC5E,MAAI,MAAM,QAAQ,KAAK,IAAI,GAAG;AAC5B,IAAC,KAAK,KAA8B;AAAA,MAAQ,CAAC,YAC3C,aAAa,SAAS,SAAS,QAAQ;AAAA,IACzC;AAAA,EACF,WAAW,KAAK,MAAM;AACpB,iBAAa,KAAK,MAAM,SAAS,QAAQ;AAAA,EAC3C;AAEA;AAAA;AAAA,IAEE,kBAAkB;AAAA,IAClB;AACA,IAAC,KAAK,aAAsC,QAAQ,CAAC,gBAAgB;AACnE,UAAI,YAAY,MAAM,SAAS,oBAAoB;AACjD,sBAAc,YAAY,MAAM,SAAS,QAAQ;AAAA,MACnD;AAAA,IACF,CAAC;AAAA,EACH;AAEA;AAAA;AAAA,IAEE,iBAAiB,QAChB,KAAK,YAAiC,SAAS;AAAA,IAChD;AACA,WAAO;AAAA,MACL,KAAK;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA;AAAA;AAAA,IAEE,gBAAgB,QACf,KAAK,WAAoC,MAAM,SAAS;AAAA,IACzD;AACA,WAAO;AAAA,MACJ,KAAK,WAAoC;AAAA,MAC1C;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGF;AAKA,MAAM,SAAS,OAAO,YAAoB;AAExC,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;AAKO,MAAM,cAAc,OAAO,kBAAiC;AAEjE,aAAW,kBAAkB,OAAO,KAAK,aAAa,GAAG;AAEvD,UAAM,kBAAc,wBAAa,gBAAgB,OAAO;AAGxD,UAAM,aAAS,qBAAM,aAAa;AAAA,MAChC,YAAY;AAAA,MACZ,SAAS,CAAC,OAAO,YAAY;AAAA,IAC/B,CAAC;AAGD,eAAW,EAAE,SAAS,SAAS,KAAK,cAAc,cAAc,GAAG;AAEjE,mBAAa,OAAO,SAAS,SAAS,QAAQ;AAAA,IAChD;AAGA,UAAM,iBAAiB,SAAS,MAAM,EAAE;AAExC,QAAI,gBAAgB,gBAAgB;AAClC,cAAQ,KAAK,wCAAwC,cAAc,GAAG;AAAA,IACxE,OAAO;AACL,YAAM,mBAAmB,MAAM,OAAO,cAAc;AAGpD,mCAAc,gBAAgB,kBAAkB,OAAO;AAEvD,cAAQ,KAAK,gCAAgC;AAAA,IAC/C;AAAA,EACF;AACF;","names":["prettier"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EditedContent } from '../client/EditionPanel/useEditedContentStore.js';
|
|
2
|
+
import 'zustand/middleware';
|
|
3
|
+
import 'zustand';
|
|
4
|
+
import '@intlayer/core';
|
|
5
|
+
import '@intlayer/design-system';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Edit the content of a file based on the key path and new value
|
|
9
|
+
*/
|
|
10
|
+
declare const editContent: (editedContent: EditedContent) => Promise<void>;
|
|
11
|
+
|
|
12
|
+
export { editContent };
|
|
@@ -0,0 +1,68 @@
|
|
|
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 server_exports = {};
|
|
30
|
+
__export(server_exports, {
|
|
31
|
+
startIntlayerEditor: () => startIntlayerEditor
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(server_exports);
|
|
34
|
+
var import_config = require("@intlayer/config");
|
|
35
|
+
var import_body_parser = __toESM(require("body-parser"));
|
|
36
|
+
var import_express = __toESM(require("express"));
|
|
37
|
+
var import_content_editor = require('./content-editor.cjs');
|
|
38
|
+
const startIntlayerEditor = () => {
|
|
39
|
+
const app = (0, import_express.default)();
|
|
40
|
+
const {
|
|
41
|
+
editor: { port }
|
|
42
|
+
} = (0, import_config.getConfiguration)();
|
|
43
|
+
app.use(import_body_parser.default.json());
|
|
44
|
+
app.use(import_body_parser.default.urlencoded({ extended: true }));
|
|
45
|
+
app.post(
|
|
46
|
+
"/",
|
|
47
|
+
async (req, res) => {
|
|
48
|
+
const editedContent = req.body;
|
|
49
|
+
try {
|
|
50
|
+
await (0, import_content_editor.editContent)(editedContent);
|
|
51
|
+
res.send({ success: true, editedContent });
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error(error);
|
|
54
|
+
res.status(500).send({ success: false });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
app.listen(port, () => {
|
|
59
|
+
console.info(
|
|
60
|
+
`Intlayer editor server is running on http://localhost:${port}`
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
startIntlayerEditor
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Locales } from '@intlayer/config/client';
|
|
2
|
+
import { ReactNode, FC } from 'react';
|
|
3
|
+
|
|
4
|
+
type ContentEditionLayoutProps = {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
locale: Locales;
|
|
7
|
+
localeList: Locales[];
|
|
8
|
+
setLocale: (locale: Locales) => void;
|
|
9
|
+
};
|
|
10
|
+
declare const ContentEditionLayout: FC<ContentEditionLayoutProps>;
|
|
11
|
+
|
|
12
|
+
export { ContentEditionLayout, type ContentEditionLayoutProps };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { EditionPanel } from './EditionPanel/index.mjs';
|
|
3
|
+
const ContentEditionLayout = ({
|
|
4
|
+
children,
|
|
5
|
+
locale,
|
|
6
|
+
setLocale,
|
|
7
|
+
localeList
|
|
8
|
+
}) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
9
|
+
children,
|
|
10
|
+
/* @__PURE__ */ jsx(
|
|
11
|
+
EditionPanel,
|
|
12
|
+
{
|
|
13
|
+
locale,
|
|
14
|
+
localeList,
|
|
15
|
+
setLocale
|
|
16
|
+
}
|
|
17
|
+
)
|
|
18
|
+
] });
|
|
19
|
+
export {
|
|
20
|
+
ContentEditionLayout
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=ContentEditionLayout.mjs.map
|
|
@@ -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 { EditionPanel } from './EditionPanel/index';\n\nexport type ContentEditionLayoutProps = {\n children?: ReactNode;\n locale: Locales;\n localeList: Locales[];\n setLocale: (locale: Locales) => void;\n};\n\nexport const ContentEditionLayout: FC<ContentEditionLayoutProps> = ({\n children,\n locale,\n setLocale,\n localeList,\n}) => (\n <>\n {children}\n <EditionPanel\n locale={locale}\n localeList={localeList}\n setLocale={setLocale}\n />\n </>\n);\n"],"mappings":"AAiBE,mBAEE,KAFF;AAfF,SAAS,oBAAoB;AAStB,MAAM,uBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MACE,iCACG;AAAA;AAAA,EACD;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAAA,GACF;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { KeyPath } from '@intlayer/core';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
|
|
4
|
+
type ContentSelectorWrapperProps = {
|
|
5
|
+
children: string;
|
|
6
|
+
dictionaryId: string;
|
|
7
|
+
dictionaryPath: string;
|
|
8
|
+
keyPath: KeyPath[];
|
|
9
|
+
};
|
|
10
|
+
declare const ContentSelectorWrapper: FC<ContentSelectorWrapperProps>;
|
|
11
|
+
|
|
12
|
+
export { ContentSelectorWrapper };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { ContentSelector } from "@intlayer/design-system";
|
|
4
|
+
import { useEditedContentStore } from './EditionPanel/useEditedContentStore.mjs';
|
|
5
|
+
import { useEditionPanelStore } from './EditionPanel/useEditionPanelStore.mjs';
|
|
6
|
+
const ContentSelectorWrapper = ({
|
|
7
|
+
children,
|
|
8
|
+
dictionaryId,
|
|
9
|
+
dictionaryPath,
|
|
10
|
+
keyPath
|
|
11
|
+
}) => {
|
|
12
|
+
const { setFocusedContent } = useEditionPanelStore();
|
|
13
|
+
const handleSelect = () => setFocusedContent({
|
|
14
|
+
dictionaryId,
|
|
15
|
+
dictionaryPath,
|
|
16
|
+
keyPath
|
|
17
|
+
});
|
|
18
|
+
const { getEditedContentValue } = useEditedContentStore();
|
|
19
|
+
const editedValue = getEditedContentValue(dictionaryPath, keyPath);
|
|
20
|
+
return /* @__PURE__ */ jsx(ContentSelector, { onSelect: handleSelect, children: editedValue ?? children });
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
ContentSelectorWrapper
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=ContentSelectorWrapper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport type { KeyPath } from '@intlayer/core';\nimport { ContentSelector } from '@intlayer/design-system';\nimport type { FC } from 'react';\nimport { useEditedContentStore } from './EditionPanel/useEditedContentStore';\nimport { useEditionPanelStore } from './EditionPanel/useEditionPanelStore';\n\ntype ContentSelectorWrapperProps = {\n children: string;\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 { setFocusedContent } = useEditionPanelStore();\n const handleSelect = () =>\n setFocusedContent({\n dictionaryId,\n dictionaryPath,\n keyPath,\n });\n\n const { getEditedContentValue } = useEditedContentStore();\n const editedValue = getEditedContentValue(dictionaryPath, keyPath);\n\n return (\n <ContentSelector onSelect={handleSelect}>\n {editedValue ?? children}\n </ContentSelector>\n );\n};\n"],"mappings":";AAiCI;AA9BJ,SAAS,uBAAuB;AAEhC,SAAS,6BAA6B;AACtC,SAAS,4BAA4B;AAS9B,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,kBAAkB,IAAI,qBAAqB;AACnD,QAAM,eAAe,MACnB,kBAAkB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAEH,QAAM,EAAE,sBAAsB,IAAI,sBAAsB;AACxD,QAAM,cAAc,sBAAsB,gBAAgB,OAAO;AAEjE,SACE,oBAAC,mBAAgB,UAAU,cACxB,yBAAe,UAClB;AAEJ;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Locales } from '@intlayer/config/client';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
|
|
4
|
+
type EditionPanelProps = {
|
|
5
|
+
locale: Locales;
|
|
6
|
+
localeList: Locales[];
|
|
7
|
+
setLocale: (locale: Locales) => void;
|
|
8
|
+
};
|
|
9
|
+
declare const EditionPanel: FC<EditionPanelProps>;
|
|
10
|
+
|
|
11
|
+
export { EditionPanel };
|