gt-sanity 2.0.14 → 2.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index.mjs → index.cjs} +478 -398
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.mts → index.d.cts} +81 -65
- package/dist/index.d.ts +81 -65
- package/dist/index.js +465 -409
- package/dist/index.js.map +1 -1
- package/package.json +15 -11
- package/sanity.json +1 -1
- package/src/adapter/core.ts +8 -7
- package/src/adapter/types.ts +1 -1
- package/src/components/TranslationsProvider.tsx +22 -7
- package/src/configuration/baseDocumentLevelConfig/documentLevelPatch.test.ts +10 -2
- package/src/configuration/baseDocumentLevelConfig/documentLevelPatch.ts +17 -6
- package/src/configuration/baseDocumentLevelConfig/helpers/createI18nDocAndPatchMetadata.ts +1 -1
- package/src/configuration/baseDocumentLevelConfig/helpers/patchI18nDoc.test.ts +2 -1
- package/src/configuration/baseDocumentLevelConfig/helpers/patchI18nDoc.ts +3 -3
- package/src/hooks/useSecrets.ts +1 -1
- package/src/index.ts +3 -2
- package/src/sanity-api/resolveRefs.ts +21 -10
- package/src/serialization/BaseDocumentMerger.ts +56 -32
- package/src/serialization/BaseSerializationConfig.ts +30 -11
- package/src/serialization/__tests__/BaseDocumentDeserializer/baseDeserialization.test.ts +75 -69
- package/src/serialization/__tests__/BaseDocumentDeserializer/documentLevelDeserialization.test.ts +10 -14
- package/src/serialization/__tests__/BaseDocumentDeserializer/fieldLevelDeserialization.test.ts +10 -14
- package/src/serialization/__tests__/BaseDocumentMerger/baseMerge.test.ts +5 -9
- package/src/serialization/__tests__/BaseDocumentMerger/documentLevelMerge.test.ts +17 -19
- package/src/serialization/__tests__/BaseDocumentMerger/fieldLevelMerge.test.ts +33 -26
- package/src/serialization/__tests__/BaseDocumentMerger/utils.ts +20 -23
- package/src/serialization/__tests__/BaseDocumentSerializer/baseSerialization.test.ts +23 -23
- package/src/serialization/__tests__/BaseDocumentSerializer/documentLevelSerialization.test.ts +6 -6
- package/src/serialization/__tests__/BaseDocumentSerializer/fieldLevelSerialization.test.ts +8 -8
- package/src/serialization/__tests__/BaseDocumentSerializer/utils.ts +12 -10
- package/src/serialization/__tests__/__fixtures__/inlineSchema.ts +4 -1
- package/src/serialization/__tests__/__fixtures__/schema.ts +15 -6
- package/src/serialization/__tests__/global.setup.ts +7 -3
- package/src/serialization/__tests__/helpers.ts +11 -11
- package/src/serialization/data.ts +3 -3
- package/src/serialization/deserialize/BaseDocumentDeserializer.ts +41 -29
- package/src/serialization/index.ts +6 -1
- package/src/serialization/serialize/fieldFilters.ts +52 -30
- package/src/serialization/serialize/index.ts +48 -21
- package/src/serialization/types.ts +32 -17
- package/src/types.ts +1 -1
- package/src/utils/__tests__/documentIds.test.ts +2 -1
- package/src/utils/__tests__/forEachMatchingField.test.ts +1 -1
- package/src/utils/applyDocuments.ts +16 -14
- package/src/utils/batchProcessor.ts +21 -18
- package/src/utils/importUtils.ts +16 -10
- package/src/utils/serialize.ts +2 -1
- package/{v2-incompatible.js → v2-incompatible.cjs} +2 -2
- package/dist/index.mjs.map +0 -1
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { libraryDefaultLocale } from "generaltranslation/internal";
|
|
10
|
-
import { htmlToBlocks } from "@portabletext/block-tools";
|
|
11
|
-
import { Schema } from "@sanity/schema";
|
|
12
|
-
import { toHTML } from "@portabletext/to-html";
|
|
13
|
-
import merge from "lodash.merge";
|
|
14
|
-
import { JSONPath } from "jsonpath-plus";
|
|
15
|
-
import JSONPointer from "jsonpointer";
|
|
16
|
-
import { extractWithPath, arrayToJSONMatchPath } from "@sanity/mutator";
|
|
17
|
-
import { CheckmarkCircleIcon, DownloadIcon, LinkIcon, PublishIcon, TranslateIcon } from "@sanity/icons";
|
|
18
|
-
import { Link, route } from "sanity/router";
|
|
19
|
-
const useClient = () => useClient$1({ apiVersion: "2025-09-15" });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
+
var documentInternationalization = require("@sanity/document-internationalization"), jsxRuntime = require("react/jsx-runtime"), ui = require("@sanity/ui"), theme$1 = require("@sanity/ui/theme"), o = require("react"), sanity = require("sanity"), generaltranslation = require("generaltranslation"), internal = require("generaltranslation/internal"), blockTools = require("@portabletext/block-tools"), schema = require("@sanity/schema"), toHtml = require("@portabletext/to-html"), merge = require("lodash.merge"), jsonpathPlus = require("jsonpath-plus"), JSONPointer = require("jsonpointer"), mutator = require("@sanity/mutator"), icons = require("@sanity/icons"), router = require("sanity/router");
|
|
4
|
+
function _interopDefaultCompat(e) {
|
|
5
|
+
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
|
+
}
|
|
7
|
+
var o__default = /* @__PURE__ */ _interopDefaultCompat(o), merge__default = /* @__PURE__ */ _interopDefaultCompat(merge), JSONPointer__default = /* @__PURE__ */ _interopDefaultCompat(JSONPointer);
|
|
8
|
+
const useClient = () => sanity.useClient({ apiVersion: "2025-09-15" });
|
|
20
9
|
function useSecrets(id) {
|
|
21
|
-
const [loading, setLoading] = useState(!0), [secrets, setSecrets] = useState(null), client = useClient();
|
|
22
|
-
return useEffect(() => {
|
|
10
|
+
const [loading, setLoading] = o.useState(!0), [secrets, setSecrets] = o.useState(null), client = useClient();
|
|
11
|
+
return o.useEffect(() => {
|
|
23
12
|
function fetchData() {
|
|
24
13
|
client.fetch("* [_id == $id][0]", { id }).then((doc) => {
|
|
25
14
|
const result = {};
|
|
@@ -31,7 +20,7 @@ function useSecrets(id) {
|
|
|
31
20
|
fetchData();
|
|
32
21
|
}, [id, client]), { loading, secrets };
|
|
33
22
|
}
|
|
34
|
-
const SECRETS_NAMESPACE = "generaltranslation.secrets", gt = new GT();
|
|
23
|
+
const SECRETS_NAMESPACE = "generaltranslation.secrets", gt = new generaltranslation.GT();
|
|
35
24
|
function overrideConfig(secrets) {
|
|
36
25
|
gt.setConfig({
|
|
37
26
|
...secrets?.project && { projectId: secrets?.project },
|
|
@@ -54,14 +43,14 @@ class GTConfig {
|
|
|
54
43
|
additionalDeserializers;
|
|
55
44
|
additionalBlockDeserializers;
|
|
56
45
|
static instance;
|
|
57
|
-
constructor(secretsNamespace, languageField, sourceLocale, locales, singletons, singletonMapping, ignoreFields, dedupeFields, skipFields, translateDocuments, additionalStopTypes = [], additionalSerializers = {}, additionalDeserializers = {}, additionalBlockDeserializers = []) {
|
|
46
|
+
constructor(secretsNamespace, languageField, sourceLocale, locales, singletons, singletonMapping, ignoreFields, dedupeFields, skipFields, translateDocuments, additionalStopTypes = [], additionalSerializers = {}, additionalDeserializers = { types: {} }, additionalBlockDeserializers = []) {
|
|
58
47
|
this.secretsNamespace = secretsNamespace, this.languageField = languageField, this.sourceLocale = sourceLocale, this.locales = locales, this.singletons = singletons, this.singletonMapping = singletonMapping, this.ignoreFields = ignoreFields, this.dedupeFields = dedupeFields, this.skipFields = skipFields, this.translateDocuments = translateDocuments, this.additionalStopTypes = additionalStopTypes, this.additionalSerializers = additionalSerializers, this.additionalDeserializers = additionalDeserializers, this.additionalBlockDeserializers = additionalBlockDeserializers;
|
|
59
48
|
}
|
|
60
49
|
static getInstance() {
|
|
61
50
|
return this.instance || (this.instance = new GTConfig(
|
|
62
51
|
SECRETS_NAMESPACE,
|
|
63
52
|
"language",
|
|
64
|
-
gt.sourceLocale || libraryDefaultLocale,
|
|
53
|
+
gt.sourceLocale || internal.libraryDefaultLocale,
|
|
65
54
|
[],
|
|
66
55
|
[],
|
|
67
56
|
() => "",
|
|
@@ -70,12 +59,12 @@ class GTConfig {
|
|
|
70
59
|
[],
|
|
71
60
|
[],
|
|
72
61
|
[],
|
|
73
|
-
{},
|
|
62
|
+
{ types: {} },
|
|
74
63
|
{},
|
|
75
64
|
[]
|
|
76
65
|
)), this.instance;
|
|
77
66
|
}
|
|
78
|
-
init(secretsNamespace, languageField, sourceLocale, locales, singletons, singletonMapping, ignoreFields, dedupeFields, skipFields, translateDocuments, additionalStopTypes = [], additionalSerializers = {}, additionalDeserializers = {}, additionalBlockDeserializers = []) {
|
|
67
|
+
init(secretsNamespace, languageField, sourceLocale, locales, singletons, singletonMapping, ignoreFields, dedupeFields, skipFields, translateDocuments, additionalStopTypes = [], additionalSerializers = {}, additionalDeserializers = { types: {} }, additionalBlockDeserializers = []) {
|
|
79
68
|
this.secretsNamespace = secretsNamespace, this.languageField = languageField, this.sourceLocale = sourceLocale, this.locales = locales, this.singletons = singletons, this.singletonMapping = singletonMapping, this.ignoreFields = ignoreFields, this.dedupeFields = dedupeFields, this.skipFields = skipFields, this.translateDocuments = translateDocuments, this.additionalStopTypes = additionalStopTypes, this.additionalSerializers = additionalSerializers, this.additionalDeserializers = additionalDeserializers, this.additionalBlockDeserializers = additionalBlockDeserializers;
|
|
80
69
|
}
|
|
81
70
|
getSecretsNamespace() {
|
|
@@ -121,59 +110,68 @@ class GTConfig {
|
|
|
121
110
|
return this.additionalBlockDeserializers;
|
|
122
111
|
}
|
|
123
112
|
}
|
|
124
|
-
const pluginConfig = GTConfig.getInstance(), theme = buildTheme(), BaseTranslationWrapper = ({
|
|
113
|
+
const pluginConfig = GTConfig.getInstance(), theme = theme$1.buildTheme(), BaseTranslationWrapper = ({
|
|
125
114
|
children,
|
|
126
115
|
secretsNamespace = pluginConfig.getSecretsNamespace(),
|
|
127
116
|
padding = 4,
|
|
128
117
|
showContainer = !0
|
|
129
118
|
}) => {
|
|
130
|
-
const { loading: loadingSecrets, secrets } = useSecrets(secretsNamespace), content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
131
|
-
loadingSecrets && /* @__PURE__ */ jsx(Flex, { padding: 5, align: "center", justify: "center", children: /* @__PURE__ */ jsx(Spinner, {}) }),
|
|
132
|
-
!loadingSecrets && !secrets && /* @__PURE__ */ jsx(Box, { padding, children: /* @__PURE__ */ jsx(Card, { tone: "caution", padding: [2, 3, 4, 4], shadow: 1, radius: 2, children: /* @__PURE__ */ jsx(Text, { children: "Can't find secrets for your translation service. Did you load them into this dataset?" }) }) }),
|
|
119
|
+
const { loading: loadingSecrets, secrets } = useSecrets(secretsNamespace), content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
120
|
+
loadingSecrets && /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { padding: 5, align: "center", justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, {}) }),
|
|
121
|
+
!loadingSecrets && !secrets && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { tone: "caution", padding: [2, 3, 4, 4], shadow: 1, radius: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Can't find secrets for your translation service. Did you load them into this dataset?" }) }) }),
|
|
133
122
|
!loadingSecrets && secrets && children
|
|
134
123
|
] });
|
|
135
|
-
return /* @__PURE__ */ jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsx(ToastProvider, { paddingY: 7, children: showContainer ? /* @__PURE__ */ jsx(Box, { padding, children: content }) : content }) });
|
|
136
|
-
}, reconcileArray = (origArray, translatedArray) => {
|
|
124
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.ThemeProvider, { theme, children: /* @__PURE__ */ jsxRuntime.jsx(ui.ToastProvider, { paddingY: 7, children: showContainer ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding, children: content }) : content }) });
|
|
125
|
+
}, isRecord$4 = (value) => typeof value == "object" && value !== null && !Array.isArray(value), reconcileArray = (origArray, translatedArray) => {
|
|
137
126
|
if (translatedArray && translatedArray.some((el) => typeof el == "string"))
|
|
138
127
|
return translatedArray;
|
|
139
128
|
const combined = JSON.parse(JSON.stringify(origArray));
|
|
140
|
-
return translatedArray.forEach((
|
|
141
|
-
if (!
|
|
129
|
+
return translatedArray.forEach((translatedItem) => {
|
|
130
|
+
if (!isRecord$4(translatedItem) || !translatedItem._key)
|
|
142
131
|
return;
|
|
143
132
|
const foundBlockIdx = origArray.findIndex(
|
|
144
|
-
(origBlock) => origBlock._key ===
|
|
133
|
+
(origBlock) => isRecord$4(origBlock) && origBlock._key === translatedItem._key
|
|
145
134
|
);
|
|
146
135
|
foundBlockIdx < 0 ? console.warn(
|
|
147
136
|
`This block no longer exists on the original document. Was it removed? ${JSON.stringify(
|
|
148
|
-
|
|
137
|
+
translatedItem
|
|
149
138
|
)}`
|
|
150
|
-
) : origArray[foundBlockIdx]._type === "block" || origArray[foundBlockIdx]._type === "span" ? combined[foundBlockIdx] =
|
|
139
|
+
) : isRecord$4(origArray[foundBlockIdx]) && (origArray[foundBlockIdx]._type === "block" || origArray[foundBlockIdx]._type === "span") ? combined[foundBlockIdx] = translatedItem : isRecord$4(origArray[foundBlockIdx]) && (combined[foundBlockIdx] = reconcileObject(
|
|
151
140
|
origArray[foundBlockIdx],
|
|
152
|
-
|
|
153
|
-
);
|
|
141
|
+
translatedItem
|
|
142
|
+
));
|
|
154
143
|
}), combined;
|
|
155
144
|
}, reconcileObject = (origObject, translatedObject) => {
|
|
156
145
|
if (typeof translatedObject != "object" || !Object.keys(translatedObject).length)
|
|
157
146
|
return origObject;
|
|
158
147
|
const updatedObj = JSON.parse(JSON.stringify(origObject));
|
|
159
148
|
return Object.entries(translatedObject).forEach(([key, value]) => {
|
|
160
|
-
!value || key[0] === "_" || (typeof value == "string" ? updatedObj[key] = value : Array.isArray(value) ? updatedObj[key] = reconcileArray(
|
|
149
|
+
!value || key[0] === "_" || (typeof value == "string" ? updatedObj[key] = value : Array.isArray(value) ? updatedObj[key] = reconcileArray(
|
|
150
|
+
Array.isArray(origObject[key]) ? origObject[key] : [],
|
|
151
|
+
value
|
|
152
|
+
) : isRecord$4(value) && (updatedObj[key] = reconcileObject(
|
|
153
|
+
isRecord$4(origObject[key]) ? origObject[key] : {},
|
|
154
|
+
value
|
|
155
|
+
)));
|
|
161
156
|
}), updatedObj;
|
|
162
157
|
}, fieldLevelMerge = (translatedFields, baseDoc, localeId, baseLang = "en") => {
|
|
163
158
|
const merged = {};
|
|
164
159
|
return ["_rev", "_id", "_type"].forEach((metaKey) => {
|
|
165
160
|
translatedFields[metaKey] && (merged[metaKey] = translatedFields[metaKey]);
|
|
166
|
-
}), extractWithPath(`..${baseLang}`, translatedFields).forEach((match2) => {
|
|
167
|
-
const origVal = extractWithPath(
|
|
168
|
-
arrayToJSONMatchPath(match2.path),
|
|
161
|
+
}), mutator.extractWithPath(`..${baseLang}`, translatedFields).forEach((match2) => {
|
|
162
|
+
const origVal = mutator.extractWithPath(
|
|
163
|
+
mutator.arrayToJSONMatchPath(match2.path),
|
|
169
164
|
baseDoc
|
|
170
|
-
)[0].value, translatedVal = extractWithPath(
|
|
171
|
-
arrayToJSONMatchPath(match2.path),
|
|
165
|
+
)[0].value, translatedVal = mutator.extractWithPath(
|
|
166
|
+
mutator.arrayToJSONMatchPath(match2.path),
|
|
172
167
|
translatedFields
|
|
173
168
|
)[0].value;
|
|
174
169
|
let valToPatch;
|
|
175
|
-
typeof translatedVal == "string" ? valToPatch = translatedVal : Array.isArray(translatedVal) && translatedVal.length ? valToPatch = reconcileArray(
|
|
176
|
-
origVal ??
|
|
170
|
+
typeof translatedVal == "string" ? valToPatch = translatedVal : Array.isArray(translatedVal) && translatedVal.length ? valToPatch = reconcileArray(
|
|
171
|
+
origVal ?? [],
|
|
172
|
+
translatedVal
|
|
173
|
+
) : typeof translatedVal == "object" && Object.keys(translatedVal).length && (valToPatch = reconcileObject(
|
|
174
|
+
isRecord$4(origVal) ? origVal : {},
|
|
177
175
|
translatedVal
|
|
178
176
|
));
|
|
179
177
|
const destinationPath = [
|
|
@@ -182,14 +180,17 @@ const pluginConfig = GTConfig.getInstance(), theme = buildTheme(), BaseTranslati
|
|
|
182
180
|
localeId.replace("-", "_")
|
|
183
181
|
// replace it with our locale
|
|
184
182
|
];
|
|
185
|
-
merged[arrayToJSONMatchPath(destinationPath)] = valToPatch;
|
|
183
|
+
merged[mutator.arrayToJSONMatchPath(destinationPath)] = valToPatch;
|
|
186
184
|
}), merged;
|
|
187
|
-
}, documentLevelMerge = (translatedFields, baseDoc) => reconcileObject(
|
|
185
|
+
}, documentLevelMerge = (translatedFields, baseDoc) => reconcileObject(
|
|
186
|
+
baseDoc,
|
|
187
|
+
translatedFields
|
|
188
|
+
), BaseDocumentMerger = {
|
|
188
189
|
fieldLevelMerge,
|
|
189
190
|
documentLevelMerge,
|
|
190
191
|
reconcileArray,
|
|
191
192
|
reconcileObject
|
|
192
|
-
}, defaultSchema = Schema.compile({
|
|
193
|
+
}, defaultSchema = schema.Schema.compile({
|
|
193
194
|
name: "default",
|
|
194
195
|
types: [
|
|
195
196
|
{
|
|
@@ -205,7 +206,7 @@ const pluginConfig = GTConfig.getInstance(), theme = buildTheme(), BaseTranslati
|
|
|
205
206
|
}
|
|
206
207
|
]
|
|
207
208
|
}), blockContentType = defaultSchema.get("default").fields.find((field) => field.name === "block").type, preprocess = (html) => {
|
|
208
|
-
const intermediateBlocks = htmlToBlocks(
|
|
209
|
+
const intermediateBlocks = blockTools.htmlToBlocks(
|
|
209
210
|
`<p>${html}</p>`,
|
|
210
211
|
blockContentType
|
|
211
212
|
);
|
|
@@ -251,7 +252,7 @@ function decode(base64) {
|
|
|
251
252
|
bytes[i] = binary.charCodeAt(i);
|
|
252
253
|
return new TextDecoder().decode(bytes);
|
|
253
254
|
}
|
|
254
|
-
const defaultStopTypes = [
|
|
255
|
+
const isRecord$3 = (value) => typeof value == "object" && value !== null && !Array.isArray(value), defaultStopTypes = [
|
|
255
256
|
"reference",
|
|
256
257
|
"date",
|
|
257
258
|
"datetime",
|
|
@@ -294,13 +295,19 @@ const defaultStopTypes = [
|
|
|
294
295
|
}, customDeserializers = { types: {} }, customBlockDeserializers = [
|
|
295
296
|
// handle marks with data-gt-internal
|
|
296
297
|
{
|
|
297
|
-
deserialize(
|
|
298
|
+
deserialize(node2, next2) {
|
|
299
|
+
if (node2.nodeType !== 1)
|
|
300
|
+
return;
|
|
301
|
+
const el = node2;
|
|
298
302
|
if (!el.hasChildNodes() || !el.getAttribute("data-gt-internal"))
|
|
299
303
|
return;
|
|
300
|
-
const { html, data } = detachGTData(el.outerHTML), block = htmlToBlocks(html, blockContentType)[0], children = next2(el.childNodes);
|
|
304
|
+
const { html, data } = detachGTData(el.outerHTML), block = blockTools.htmlToBlocks(html, blockContentType)[0], children = next2(el.childNodes);
|
|
301
305
|
let markDefs = [];
|
|
302
|
-
return "markDefs" in block && (markDefs = block.markDefs ?? []), data?.markDef && markDefs.push(data.markDef), children && children.forEach((child) => {
|
|
303
|
-
|
|
306
|
+
return "markDefs" in block && (markDefs = block.markDefs ?? []), data?.markDef && markDefs.push(data.markDef), Array.isArray(children) && children.forEach((child) => {
|
|
307
|
+
if (!isRecord$3(child))
|
|
308
|
+
return;
|
|
309
|
+
const marks = Array.isArray(child.marks) ? child.marks : [];
|
|
310
|
+
child.marks = data?.markDef?._key ? [...marks, data.markDef._key] : marks;
|
|
304
311
|
}), {
|
|
305
312
|
...block,
|
|
306
313
|
markDefs,
|
|
@@ -310,12 +317,15 @@ const defaultStopTypes = [
|
|
|
310
317
|
},
|
|
311
318
|
//handle undeclared styles
|
|
312
319
|
{
|
|
313
|
-
deserialize(
|
|
320
|
+
deserialize(node2, next2) {
|
|
321
|
+
if (node2.nodeType !== 1)
|
|
322
|
+
return;
|
|
323
|
+
const el = node2;
|
|
314
324
|
if (!el.hasChildNodes() || el.getAttribute("data-type") !== "unknown-block-style")
|
|
315
325
|
return;
|
|
316
326
|
const style = el.getAttribute("data-style") ?? "";
|
|
317
327
|
return {
|
|
318
|
-
...htmlToBlocks(el.outerHTML, blockContentType)[0],
|
|
328
|
+
...blockTools.htmlToBlocks(el.outerHTML, blockContentType)[0],
|
|
319
329
|
style,
|
|
320
330
|
children: next2(el.childNodes)
|
|
321
331
|
};
|
|
@@ -323,7 +333,10 @@ const defaultStopTypes = [
|
|
|
323
333
|
},
|
|
324
334
|
//handle list items
|
|
325
335
|
{
|
|
326
|
-
deserialize(
|
|
336
|
+
deserialize(node2, next2) {
|
|
337
|
+
if (node2.nodeType !== 1)
|
|
338
|
+
return;
|
|
339
|
+
const el = node2;
|
|
327
340
|
if (!el.hasChildNodes() || el.tagName.toLowerCase() !== "li")
|
|
328
341
|
return;
|
|
329
342
|
const tagsToStyle = {
|
|
@@ -336,10 +349,10 @@ const defaultStopTypes = [
|
|
|
336
349
|
if (!listItem)
|
|
337
350
|
return;
|
|
338
351
|
const level = el.getAttribute("data-level") && parseInt(el.getAttribute("data-level") || "0", 10), _key = el.id;
|
|
339
|
-
let block = htmlToBlocks(parent.outerHTML, blockContentType)[0];
|
|
352
|
+
let block = blockTools.htmlToBlocks(parent.outerHTML, blockContentType)[0];
|
|
340
353
|
const customStyle = el.children?.[0]?.getAttribute("data-style");
|
|
341
354
|
if (new RegExp(/<("[^"]*"|'[^']*'|[^'">])*>/).test(el.innerHTML)) {
|
|
342
|
-
const newBlock = htmlToBlocks(el.innerHTML, blockContentType)[0];
|
|
355
|
+
const newBlock = blockTools.htmlToBlocks(el.innerHTML, blockContentType)[0];
|
|
343
356
|
if (newBlock && (block = {
|
|
344
357
|
...block,
|
|
345
358
|
...newBlock,
|
|
@@ -357,7 +370,7 @@ const defaultStopTypes = [
|
|
|
357
370
|
};
|
|
358
371
|
}
|
|
359
372
|
}
|
|
360
|
-
], META_FIELDS$1 = ["_key", "_type", "_id"], languageObjectFieldFilter = (obj, baseLang) => {
|
|
373
|
+
], META_FIELDS$1 = ["_key", "_type", "_id"], isRecord$2 = (value) => typeof value == "object" && value !== null && !Array.isArray(value), languageObjectFieldFilter = (obj, baseLang) => {
|
|
361
374
|
const filterToLangField = (childObj) => {
|
|
362
375
|
const filteredObj = {};
|
|
363
376
|
return filteredObj[baseLang] = childObj[baseLang], META_FIELDS$1.forEach((field) => {
|
|
@@ -371,24 +384,29 @@ const defaultStopTypes = [
|
|
|
371
384
|
for (const key in childObj)
|
|
372
385
|
if (childObj.hasOwnProperty(key)) {
|
|
373
386
|
const value = childObj[key];
|
|
374
|
-
if (value.
|
|
387
|
+
if (isRecord$2(value) && Object.hasOwn(value, baseLang))
|
|
375
388
|
filteredObj[key] = filterToLangField(value);
|
|
376
389
|
else if (Array.isArray(value) && value.length && typeof value[0] == "object") {
|
|
377
|
-
const validLangObjects = value.reduce(
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
+
const validLangObjects = value.reduce(
|
|
391
|
+
(validArr, objInArray) => {
|
|
392
|
+
if (!isRecord$2(objInArray))
|
|
393
|
+
return validArr;
|
|
394
|
+
if (objInArray._type === "block")
|
|
395
|
+
validArr.push(objInArray);
|
|
396
|
+
else if (Object.hasOwn(objInArray, baseLang))
|
|
397
|
+
validArr.push(filterToLangField(objInArray));
|
|
398
|
+
else {
|
|
399
|
+
const filtered = findBaseLang(objInArray);
|
|
400
|
+
Object.keys(filtered).filter(
|
|
401
|
+
(objInArrayKey) => META_FIELDS$1.indexOf(objInArrayKey) === -1
|
|
402
|
+
).length && validArr.push(filtered);
|
|
403
|
+
}
|
|
404
|
+
return validArr;
|
|
405
|
+
},
|
|
406
|
+
[]
|
|
407
|
+
);
|
|
390
408
|
validLangObjects.length && (filteredObj[key] = validLangObjects);
|
|
391
|
-
} else if (
|
|
409
|
+
} else if (isRecord$2(value)) {
|
|
392
410
|
const nestedLangObj = findBaseLang(value);
|
|
393
411
|
Object.keys(nestedLangObj).filter(
|
|
394
412
|
(nestedObjKey) => META_FIELDS$1.indexOf(nestedObjKey) === -1
|
|
@@ -399,24 +417,30 @@ const defaultStopTypes = [
|
|
|
399
417
|
};
|
|
400
418
|
return findBaseLang(obj);
|
|
401
419
|
}, fieldFilter = (obj, objFields, stopTypes) => {
|
|
402
|
-
const filteredObj = {
|
|
420
|
+
const filteredObj = {
|
|
421
|
+
_type: typeof obj._type == "string" ? obj._type : ""
|
|
422
|
+
}, fieldFilterFunc = (field) => {
|
|
423
|
+
const fieldMetadata = field, fieldType = typeof fieldMetadata.type == "string" ? fieldMetadata.type : fieldMetadata.type?.name;
|
|
424
|
+
return fieldMetadata.localize === !1 ? !1 : fieldType === "string" || fieldType === "text" || Array.isArray(obj[field.name]) ? !0 : !!(fieldType && !stopTypes.includes(fieldType));
|
|
425
|
+
};
|
|
403
426
|
return [
|
|
404
427
|
...META_FIELDS$1,
|
|
405
428
|
...objFields.filter(fieldFilterFunc).map((field) => field.name)
|
|
406
429
|
].forEach((field) => {
|
|
407
430
|
obj[field] && (filteredObj[field] = obj[field]);
|
|
408
431
|
}), filteredObj;
|
|
409
|
-
}, META_FIELDS = ["_key", "_type", "_id", "_weak"], BaseDocumentSerializer = (schemas) => {
|
|
432
|
+
}, META_FIELDS = ["_key", "_type", "_id", "_weak"], isRecord$1 = (value) => typeof value == "object" && value !== null && !Array.isArray(value), BaseDocumentSerializer = (schemas) => {
|
|
410
433
|
const getSchema = (name) => schemas?._original?.types.find((s) => s.name === name), serializeObject = (obj, stopTypes, serializers) => {
|
|
411
434
|
if (stopTypes.includes(obj._type))
|
|
412
435
|
return "";
|
|
413
|
-
|
|
414
|
-
|
|
436
|
+
const typeSerializers = isRecord$1(serializers.types) ? serializers.types : {};
|
|
437
|
+
if (Object.keys(typeSerializers).includes(obj._type))
|
|
438
|
+
return toHtml.toHTML([obj], { components: serializers });
|
|
415
439
|
if (obj._type === "span" || obj._type === "block")
|
|
416
|
-
return toHTML(obj, { components: serializers });
|
|
440
|
+
return toHtml.toHTML(obj, { components: serializers });
|
|
417
441
|
let fieldNames = Object.keys(obj).filter((key) => key !== "_type");
|
|
418
|
-
const
|
|
419
|
-
|
|
442
|
+
const schema2 = getSchema(obj._type);
|
|
443
|
+
schema2 && schema2.fields && (fieldNames = schema2.fields.map((field) => field.name).filter((schemaKey) => Object.keys(obj).includes(schemaKey))), typeof obj == "object" && !obj._type && (obj._type = "");
|
|
420
444
|
const newSerializationMethods = {}, tempType = `${obj._type}__temp_type__${Math.random().toString(36).substring(7)}`, objToSerialize = { _type: tempType };
|
|
421
445
|
META_FIELDS.filter((f2) => f2 !== "_type").forEach((field) => {
|
|
422
446
|
objToSerialize[field] = obj[field];
|
|
@@ -431,9 +455,9 @@ const defaultStopTypes = [
|
|
|
431
455
|
else if (Array.isArray(value))
|
|
432
456
|
htmlField = serializeArray(value, fieldName, stopTypes, {
|
|
433
457
|
...serializers,
|
|
434
|
-
types: { ...
|
|
458
|
+
types: { ...typeSerializers }
|
|
435
459
|
});
|
|
436
|
-
else {
|
|
460
|
+
else if (isRecord$1(value)) {
|
|
437
461
|
const embeddedObject = value, embeddedObjectSchema = getSchema(embeddedObject._type);
|
|
438
462
|
let toTranslate = embeddedObject;
|
|
439
463
|
embeddedObjectSchema && embeddedObjectSchema.fields && (toTranslate = fieldFilter(
|
|
@@ -443,7 +467,7 @@ const defaultStopTypes = [
|
|
|
443
467
|
));
|
|
444
468
|
const objHTML = serializeObject(toTranslate, stopTypes, {
|
|
445
469
|
...serializers,
|
|
446
|
-
types: { ...
|
|
470
|
+
types: { ...typeSerializers }
|
|
447
471
|
});
|
|
448
472
|
htmlField = `<div class="${fieldName}" data-level="field">${objHTML}</div>`;
|
|
449
473
|
}
|
|
@@ -457,11 +481,11 @@ const defaultStopTypes = [
|
|
|
457
481
|
};
|
|
458
482
|
let serializedBlock = "";
|
|
459
483
|
try {
|
|
460
|
-
serializedBlock = toHTML(objToSerialize, {
|
|
484
|
+
serializedBlock = toHtml.toHTML(objToSerialize, {
|
|
461
485
|
components: {
|
|
462
486
|
...serializers,
|
|
463
487
|
types: {
|
|
464
|
-
...
|
|
488
|
+
...typeSerializers,
|
|
465
489
|
...newSerializationMethods
|
|
466
490
|
}
|
|
467
491
|
}
|
|
@@ -474,18 +498,22 @@ const defaultStopTypes = [
|
|
|
474
498
|
return serializedBlock;
|
|
475
499
|
}, serializeArray = (fieldContent, fieldName, stopTypes, serializers) => {
|
|
476
500
|
const output = fieldContent.filter(
|
|
477
|
-
(block) => !stopTypes.includes(block._type)
|
|
501
|
+
(block) => typeof block == "string" || typeof block._type != "string" || !stopTypes.includes(block._type)
|
|
478
502
|
).map((block) => {
|
|
479
|
-
|
|
480
|
-
|
|
503
|
+
if (typeof block == "string")
|
|
504
|
+
return block;
|
|
505
|
+
const schema2 = getSchema(
|
|
506
|
+
typeof block._type == "string" ? block._type : ""
|
|
507
|
+
);
|
|
508
|
+
return schema2 && schema2.fields ? fieldFilter(block, schema2.fields, stopTypes) : block;
|
|
481
509
|
}).map((obj) => typeof obj == "string" ? `<span>${obj}</span>` : serializeObject(obj, stopTypes, serializers));
|
|
482
510
|
return `<div class="${fieldName}" data-type="array">${output.join("")}</div>`;
|
|
483
511
|
};
|
|
484
512
|
return {
|
|
485
513
|
serializeDocument: (doc, translationLevel = "document", baseLang = "en", stopTypes = defaultStopTypes, serializers = customSerializers) => {
|
|
486
|
-
const
|
|
514
|
+
const schema2 = getSchema(doc._type);
|
|
487
515
|
let filteredObj = {};
|
|
488
|
-
translationLevel === "field" ? filteredObj = languageObjectFieldFilter(doc, baseLang) : filteredObj = fieldFilter(doc,
|
|
516
|
+
translationLevel === "field" ? filteredObj = languageObjectFieldFilter(doc, baseLang) : filteredObj = fieldFilter(doc, schema2?.fields ?? [], stopTypes);
|
|
489
517
|
const serializedFields = {};
|
|
490
518
|
for (const key in filteredObj) {
|
|
491
519
|
if (filteredObj.hasOwnProperty(key) === !1) continue;
|
|
@@ -494,12 +522,14 @@ const defaultStopTypes = [
|
|
|
494
522
|
serializedFields[key] = value;
|
|
495
523
|
else if (Array.isArray(value))
|
|
496
524
|
serializedFields[key] = serializeArray(
|
|
497
|
-
value
|
|
525
|
+
value.filter(
|
|
526
|
+
(item) => typeof item == "string" || isRecord$1(item)
|
|
527
|
+
),
|
|
498
528
|
key,
|
|
499
529
|
stopTypes,
|
|
500
530
|
serializers
|
|
501
531
|
);
|
|
502
|
-
else if (value && !stopTypes.find((stopType) => stopType == value?._type)) {
|
|
532
|
+
else if (value && isRecord$1(value) && !stopTypes.find((stopType) => stopType == value?._type)) {
|
|
503
533
|
const serialized = serializeObject(
|
|
504
534
|
value,
|
|
505
535
|
stopTypes,
|
|
@@ -545,13 +575,22 @@ const deserializeArray = (arrayHTML, deserializers = customDeserializers, blockD
|
|
|
545
575
|
return Array.from(arrayHTML.children).forEach((child) => {
|
|
546
576
|
let deserializedObject;
|
|
547
577
|
try {
|
|
548
|
-
child.tagName?.toLowerCase() === "span"
|
|
549
|
-
child
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
578
|
+
if (child.tagName?.toLowerCase() === "span")
|
|
579
|
+
deserializedObject = preprocess(child.innerHTML);
|
|
580
|
+
else if (child.className || child.getAttribute("data-type") === "object")
|
|
581
|
+
deserializedObject = deserializeObject(
|
|
582
|
+
child,
|
|
583
|
+
deserializers,
|
|
584
|
+
blockDeserializers
|
|
585
|
+
), deserializedObject && typeof deserializedObject == "object" && !Array.isArray(deserializedObject) && (deserializedObject._key = child.id);
|
|
586
|
+
else {
|
|
587
|
+
const blocks = blockTools.htmlToBlocks(child.outerHTML, blockContentType, {
|
|
588
|
+
rules: blockDeserializers
|
|
589
|
+
});
|
|
590
|
+
deserializedObject = mergeBlocks(
|
|
591
|
+
blocks
|
|
592
|
+
), deserializedObject._key = child.id;
|
|
593
|
+
}
|
|
555
594
|
} catch (e) {
|
|
556
595
|
console.debug(
|
|
557
596
|
`Tried to deserialize block: ${child.outerHTML} in an array but failed to identify it! Error: ${e}`
|
|
@@ -560,7 +599,7 @@ const deserializeArray = (arrayHTML, deserializers = customDeserializers, blockD
|
|
|
560
599
|
output.push(deserializedObject);
|
|
561
600
|
}), output;
|
|
562
601
|
}, deserializeObject = (objectHTML, deserializers = customDeserializers, blockDeserializers = customBlockDeserializers) => {
|
|
563
|
-
const deserialize = deserializers.types[objectHTML.className];
|
|
602
|
+
const deserialize = deserializers.types?.[objectHTML.className];
|
|
564
603
|
if (deserialize)
|
|
565
604
|
return deserialize(objectHTML);
|
|
566
605
|
const output = {};
|
|
@@ -587,7 +626,7 @@ const deserializeArray = (arrayHTML, deserializers = customDeserializers, blockD
|
|
|
587
626
|
if (HTMLnode?.getAttribute("data-level") === "field" && (HTMLnode = HTMLnode.children[0]), !HTMLnode)
|
|
588
627
|
return {};
|
|
589
628
|
let output;
|
|
590
|
-
const deserialize = deserializers.types[HTMLnode.className];
|
|
629
|
+
const deserialize = deserializers.types?.[HTMLnode.className];
|
|
591
630
|
return deserialize ? output = deserialize(HTMLnode) : HTMLnode.getAttribute("data-type") === "object" ? output = deserializeObject(HTMLnode, deserializers, blockDeserializers) : HTMLnode.getAttribute("data-type") === "array" ? output = deserializeArray(HTMLnode, deserializers, blockDeserializers) : (output = {}, console.debug(
|
|
592
631
|
`Tried to deserialize block ${HTMLnode.outerHTML} but failed to identify it!`
|
|
593
632
|
)), output;
|
|
@@ -617,7 +656,7 @@ function forEachMatchingField(documentId, document2, fields, callback) {
|
|
|
617
656
|
for (const field of entry.fields) {
|
|
618
657
|
const { property, type } = field;
|
|
619
658
|
try {
|
|
620
|
-
const results = JSONPath({
|
|
659
|
+
const results = jsonpathPlus.JSONPath({
|
|
621
660
|
json: document2,
|
|
622
661
|
path: property,
|
|
623
662
|
resultType: "all",
|
|
@@ -626,7 +665,7 @@ function forEachMatchingField(documentId, document2, fields, callback) {
|
|
|
626
665
|
});
|
|
627
666
|
results && results.length > 0 && results.forEach(
|
|
628
667
|
(result) => {
|
|
629
|
-
type !== void 0 ? typeof result.value == "object" && result.value !== null && result.value._type === type && callback(result) : callback(result);
|
|
668
|
+
type !== void 0 ? typeof result.value == "object" && result.value !== null && !Array.isArray(result.value) && result.value._type === type && callback(result) : callback(result);
|
|
630
669
|
}
|
|
631
670
|
);
|
|
632
671
|
} catch (error) {
|
|
@@ -650,9 +689,9 @@ function applyDocuments(documentId, sourceDocument, targetDocument, ignore, skip
|
|
|
650
689
|
for (const [key, value] of Object.entries(clonedTarget))
|
|
651
690
|
mergedDocument[key] = value;
|
|
652
691
|
return forEachMatchingField(documentId, sourceDocument, ignore, (result) => {
|
|
653
|
-
|
|
692
|
+
JSONPointer__default.default.set(mergedDocument, result.pointer, result.value);
|
|
654
693
|
}), forEachMatchingField(documentId, sourceDocument, dedupe, (result) => {
|
|
655
|
-
|
|
694
|
+
JSONPointer__default.default.set(
|
|
656
695
|
mergedDocument,
|
|
657
696
|
result.pointer,
|
|
658
697
|
dedupeFieldValue(result.value, localeId)
|
|
@@ -660,10 +699,17 @@ function applyDocuments(documentId, sourceDocument, targetDocument, ignore, skip
|
|
|
660
699
|
}), deleteMatchingFields(documentId, mergedDocument, skip), mergedDocument;
|
|
661
700
|
}
|
|
662
701
|
function dedupeFieldValue(value, localeId) {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
702
|
+
if (!localeId) return value;
|
|
703
|
+
if (typeof value == "string")
|
|
704
|
+
return appendLocaleSuffix(value, localeId);
|
|
705
|
+
if (value && typeof value == "object" && !Array.isArray(value) && typeof value.current == "string") {
|
|
706
|
+
const slug = value;
|
|
707
|
+
return {
|
|
708
|
+
...slug,
|
|
709
|
+
current: appendLocaleSuffix(slug.current, localeId)
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
return value;
|
|
667
713
|
}
|
|
668
714
|
function appendLocaleSuffix(value, localeId) {
|
|
669
715
|
if (!value) return value;
|
|
@@ -697,7 +743,7 @@ function createStableTranslationKey(branchId, documentId, localeId) {
|
|
|
697
743
|
return branchId ? `${branchId}:${publishedId}:${localeId}` : `${publishedId}:${localeId}`;
|
|
698
744
|
}
|
|
699
745
|
function deserializeDocument(document2) {
|
|
700
|
-
const deserializers =
|
|
746
|
+
const deserializers = merge__default.default(
|
|
701
747
|
{ types: {} },
|
|
702
748
|
pluginConfig.getAdditionalDeserializers()
|
|
703
749
|
), blockDeserializers = [
|
|
@@ -710,11 +756,11 @@ function deserializeDocument(document2) {
|
|
|
710
756
|
blockDeserializers
|
|
711
757
|
);
|
|
712
758
|
}
|
|
713
|
-
function serializeDocument(document2,
|
|
759
|
+
function serializeDocument(document2, schema2, baseLanguage) {
|
|
714
760
|
const stopTypes = [
|
|
715
761
|
...defaultStopTypes,
|
|
716
762
|
...pluginConfig.getAdditionalStopTypes()
|
|
717
|
-
], serializers =
|
|
763
|
+
], serializers = merge__default.default(
|
|
718
764
|
customSerializers,
|
|
719
765
|
pluginConfig.getAdditionalSerializers()
|
|
720
766
|
), docToSerialize = stripIgnoredFields(
|
|
@@ -722,7 +768,7 @@ function serializeDocument(document2, schema, baseLanguage) {
|
|
|
722
768
|
pluginConfig.getIgnoreFields(),
|
|
723
769
|
pluginConfig.getDedupeFields()
|
|
724
770
|
);
|
|
725
|
-
return BaseDocumentSerializer(
|
|
771
|
+
return BaseDocumentSerializer(schema2).serializeDocument(
|
|
726
772
|
docToSerialize,
|
|
727
773
|
"document",
|
|
728
774
|
baseLanguage,
|
|
@@ -748,12 +794,12 @@ async function uploadFiles(documents, secrets) {
|
|
|
748
794
|
fileName: `sanity/${info.documentId}`,
|
|
749
795
|
fileId: info.documentId,
|
|
750
796
|
fileFormat: "HTML",
|
|
751
|
-
locale: gt.sourceLocale || libraryDefaultLocale,
|
|
797
|
+
locale: gt.sourceLocale || internal.libraryDefaultLocale,
|
|
752
798
|
versionId: info.versionId || void 0
|
|
753
799
|
}
|
|
754
800
|
})),
|
|
755
801
|
{
|
|
756
|
-
sourceLocale: gt.sourceLocale || libraryDefaultLocale
|
|
802
|
+
sourceLocale: gt.sourceLocale || internal.libraryDefaultLocale
|
|
757
803
|
}
|
|
758
804
|
);
|
|
759
805
|
}
|
|
@@ -791,7 +837,7 @@ async function initProject(uploadResult, options, secrets) {
|
|
|
791
837
|
}
|
|
792
838
|
async function createJobs(uploadResult, localeIds, secrets) {
|
|
793
839
|
return overrideConfig(secrets), await gt.enqueueFiles(uploadResult.uploadedFiles, {
|
|
794
|
-
sourceLocale: gt.sourceLocale || libraryDefaultLocale,
|
|
840
|
+
sourceLocale: gt.sourceLocale || internal.libraryDefaultLocale,
|
|
795
841
|
targetLocales: localeIds
|
|
796
842
|
});
|
|
797
843
|
}
|
|
@@ -970,7 +1016,7 @@ async function patchI18nDoc(sourceDocumentId, i18nDocId, sourceDocument, mergedD
|
|
|
970
1016
|
existingDocument,
|
|
971
1017
|
dedupeFields,
|
|
972
1018
|
(result) => {
|
|
973
|
-
|
|
1019
|
+
JSONPointer__default.default.set(appliedDocument, result.pointer, result.value);
|
|
974
1020
|
}
|
|
975
1021
|
), await client.patch(i18nDocId, { set: appliedDocument }).commit();
|
|
976
1022
|
}
|
|
@@ -987,7 +1033,9 @@ const documentLevelPatch = async (docInfo, translatedFields, localeId, client, l
|
|
|
987
1033
|
baseDoc,
|
|
988
1034
|
client,
|
|
989
1035
|
baseLanguage
|
|
990
|
-
)).translations.find(
|
|
1036
|
+
)).translations.find(
|
|
1037
|
+
(translation) => translation.language === localeId
|
|
1038
|
+
)?.value?._ref;
|
|
991
1039
|
i18nDocId && (i18nDoc = await findLatestDraft(i18nDocId, client)), mergeWithTargetLocale && i18nDoc ? baseDoc = i18nDoc : docInfo.documentId && docInfo.versionId && (baseDoc = await findDocumentAtRevision(
|
|
992
1040
|
docInfo.documentId,
|
|
993
1041
|
docInfo.versionId,
|
|
@@ -1013,7 +1061,9 @@ const documentLevelPatch = async (docInfo, translatedFields, localeId, client, l
|
|
|
1013
1061
|
baseDoc,
|
|
1014
1062
|
client,
|
|
1015
1063
|
baseLanguage
|
|
1016
|
-
), freshI18nDocId = freshTranslationMetadata.translations.find(
|
|
1064
|
+
), freshI18nDocId = freshTranslationMetadata.translations.find(
|
|
1065
|
+
(translation) => translation.language === localeId
|
|
1066
|
+
)?.value?._ref;
|
|
1017
1067
|
if (freshI18nDocId) {
|
|
1018
1068
|
const freshI18nDoc = await findLatestDraft(freshI18nDocId, client);
|
|
1019
1069
|
await patchI18nDoc(
|
|
@@ -1050,6 +1100,7 @@ async function importDocument(docInfo, localeId, document2, context, mergeWithTa
|
|
|
1050
1100
|
mergeWithTargetLocale
|
|
1051
1101
|
);
|
|
1052
1102
|
}
|
|
1103
|
+
const isRecord = (value) => typeof value == "object" && value !== null && !Array.isArray(value), isReference = (value) => isRecord(value) && value._type === "reference" && typeof value._ref == "string";
|
|
1053
1104
|
async function resolveRefs(doc, locale, client) {
|
|
1054
1105
|
const references = findReferences(doc);
|
|
1055
1106
|
if (references.length === 0)
|
|
@@ -1065,9 +1116,9 @@ function findReferences(obj, path = []) {
|
|
|
1065
1116
|
if (!obj || typeof obj != "object")
|
|
1066
1117
|
return [];
|
|
1067
1118
|
const references = [];
|
|
1068
|
-
return obj
|
|
1119
|
+
return isReference(obj) && references.push({ ref: obj, path }), Array.isArray(obj) ? obj.forEach((item, index) => {
|
|
1069
1120
|
references.push(...findReferences(item, [...path, index.toString()]));
|
|
1070
|
-
}) : Object.keys(obj).forEach((key) => {
|
|
1121
|
+
}) : isRecord(obj) && Object.keys(obj).forEach((key) => {
|
|
1071
1122
|
references.push(...findReferences(obj[key], [...path, key]));
|
|
1072
1123
|
}), references;
|
|
1073
1124
|
}
|
|
@@ -1091,7 +1142,7 @@ function updateDocumentReferences(doc, translatedRefs) {
|
|
|
1091
1142
|
function updateReferencesRecursive(obj, translatedRefs) {
|
|
1092
1143
|
if (!obj || typeof obj != "object")
|
|
1093
1144
|
return obj;
|
|
1094
|
-
if (obj
|
|
1145
|
+
if (isReference(obj) && translatedRefs.has(obj._ref))
|
|
1095
1146
|
return {
|
|
1096
1147
|
...obj,
|
|
1097
1148
|
_ref: translatedRefs.get(obj._ref)
|
|
@@ -1100,7 +1151,10 @@ function updateReferencesRecursive(obj, translatedRefs) {
|
|
|
1100
1151
|
return obj.map((item) => updateReferencesRecursive(item, translatedRefs));
|
|
1101
1152
|
const updated = {};
|
|
1102
1153
|
return Object.keys(obj).forEach((key) => {
|
|
1103
|
-
updated[key] = updateReferencesRecursive(
|
|
1154
|
+
updated[key] = updateReferencesRecursive(
|
|
1155
|
+
obj[key],
|
|
1156
|
+
translatedRefs
|
|
1157
|
+
);
|
|
1104
1158
|
}), updated;
|
|
1105
1159
|
}
|
|
1106
1160
|
async function findTranslatedDocumentForLocale(sourceDocumentId, localeId, client) {
|
|
@@ -1213,16 +1267,19 @@ async function getReadyFilesForImport(translationStatuses, options = {}) {
|
|
|
1213
1267
|
async function importTranslations(readyFiles, secrets, translationContext, options = {}) {
|
|
1214
1268
|
if (readyFiles.length === 0)
|
|
1215
1269
|
return { successCount: 0, failureCount: 0, successfulImports: [] };
|
|
1216
|
-
const importItems = (await downloadTranslations(readyFiles, secrets)).map((file) =>
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1270
|
+
const importItems = (await downloadTranslations(readyFiles, secrets)).map((file) => {
|
|
1271
|
+
const data = typeof file.data == "string" ? file.data : JSON.stringify(file.data ?? "");
|
|
1272
|
+
return {
|
|
1273
|
+
docInfo: {
|
|
1274
|
+
documentId: file.fileId,
|
|
1275
|
+
versionId: file.versionId
|
|
1276
|
+
},
|
|
1277
|
+
locale: file.locale,
|
|
1278
|
+
data,
|
|
1279
|
+
translationContext,
|
|
1280
|
+
key: `${file.branchId}:${file.fileId}:${file.versionId}:${file.locale}`
|
|
1281
|
+
};
|
|
1282
|
+
}), result = await processImportBatch(importItems, {
|
|
1226
1283
|
onProgress: options.onProgress,
|
|
1227
1284
|
onItemSuccess: (item, key) => {
|
|
1228
1285
|
options.onImportSuccess?.(key);
|
|
@@ -1267,8 +1324,8 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1267
1324
|
localeId: locale,
|
|
1268
1325
|
description: gt.getLocaleProperties(locale).name,
|
|
1269
1326
|
enabled: !0
|
|
1270
|
-
})), TranslationsContext = createContext(null), useTranslations = () => {
|
|
1271
|
-
const context = useContext(TranslationsContext);
|
|
1327
|
+
})), TranslationsContext = o.createContext(null), useTranslations = () => {
|
|
1328
|
+
const context = o.useContext(TranslationsContext);
|
|
1272
1329
|
if (!context)
|
|
1273
1330
|
throw new Error("useTranslations must be used within TranslationsProvider");
|
|
1274
1331
|
return context;
|
|
@@ -1276,25 +1333,25 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1276
1333
|
children,
|
|
1277
1334
|
singleDocument
|
|
1278
1335
|
}) => {
|
|
1279
|
-
const [isBusy, setIsBusy] = useState(!1), [documents, setDocuments] = useState([]), [locales, setLocales] = useState([]), [autoRefresh, setAutoRefresh] = useState(!1), [autoImport, setAutoImport] = useState(!1), [autoPatchReferences, setAutoPatchReferences] = useState(!1), [autoPublish, setAutoPublish] = useState(!1), [loadingDocuments, setLoadingDocuments] = useState(!1), [importProgress, setImportProgress] = useState({
|
|
1336
|
+
const [isBusy, setIsBusy] = o.useState(!1), [documents, setDocuments] = o.useState([]), [locales, setLocales] = o.useState([]), [autoRefresh, setAutoRefresh] = o.useState(!1), [autoImport, setAutoImport] = o.useState(!1), [autoPatchReferences, setAutoPatchReferences] = o.useState(!1), [autoPublish, setAutoPublish] = o.useState(!1), [loadingDocuments, setLoadingDocuments] = o.useState(!1), [importProgress, setImportProgress] = o.useState({
|
|
1280
1337
|
current: 0,
|
|
1281
1338
|
total: 0,
|
|
1282
1339
|
isImporting: !1
|
|
1283
|
-
}), [importedTranslations, setImportedTranslations] = useState(
|
|
1340
|
+
}), [importedTranslations, setImportedTranslations] = o.useState(
|
|
1284
1341
|
/* @__PURE__ */ new Set()
|
|
1285
|
-
), [existingTranslations, setExistingTranslations] = useState(
|
|
1342
|
+
), [existingTranslations, setExistingTranslations] = o.useState(
|
|
1286
1343
|
/* @__PURE__ */ new Set()
|
|
1287
|
-
), [downloadStatus, setDownloadStatus] = useState({
|
|
1344
|
+
), [downloadStatus, setDownloadStatus] = o.useState({
|
|
1288
1345
|
downloaded: /* @__PURE__ */ new Set(),
|
|
1289
1346
|
failed: /* @__PURE__ */ new Set(),
|
|
1290
1347
|
skipped: /* @__PURE__ */ new Set()
|
|
1291
|
-
}), downloadStatusRef = useRef(downloadStatus), [translationStatuses, setTranslationStatuses] = useState(/* @__PURE__ */ new Map()), [isRefreshing, setIsRefreshing] = useState(!1), client = useClient(),
|
|
1348
|
+
}), downloadStatusRef = o.useRef(downloadStatus), [translationStatuses, setTranslationStatuses] = o.useState(/* @__PURE__ */ new Map()), [isRefreshing, setIsRefreshing] = o.useState(!1), client = useClient(), schema2 = sanity.useSchema(), translationContext = { client, schema: schema2 }, toast = ui.useToast(), { loading: loadingSecrets, secrets } = useSecrets(
|
|
1292
1349
|
pluginConfig.getSecretsNamespace()
|
|
1293
|
-
), [branchId, setBranchId] = useState(void 0);
|
|
1294
|
-
useEffect(() => {
|
|
1350
|
+
), [branchId, setBranchId] = o.useState(void 0);
|
|
1351
|
+
o.useEffect(() => {
|
|
1295
1352
|
downloadStatusRef.current = downloadStatus;
|
|
1296
1353
|
}, [downloadStatus]);
|
|
1297
|
-
const fetchDocuments = useCallback(async () => {
|
|
1354
|
+
const fetchDocuments = o.useCallback(async () => {
|
|
1298
1355
|
setLoadingDocuments(!0);
|
|
1299
1356
|
try {
|
|
1300
1357
|
if (singleDocument) {
|
|
@@ -1315,7 +1372,7 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1315
1372
|
} finally {
|
|
1316
1373
|
setLoadingDocuments(!1);
|
|
1317
1374
|
}
|
|
1318
|
-
}, [client, singleDocument]), fetchLocales = useCallback(async () => {
|
|
1375
|
+
}, [client, singleDocument]), fetchLocales = o.useCallback(async () => {
|
|
1319
1376
|
if (secrets)
|
|
1320
1377
|
try {
|
|
1321
1378
|
const availableLocales = await getLocales(secrets);
|
|
@@ -1327,7 +1384,7 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1327
1384
|
closable: !0
|
|
1328
1385
|
});
|
|
1329
1386
|
}
|
|
1330
|
-
}, [secrets]), fetchExistingTranslations = useCallback(async () => {
|
|
1387
|
+
}, [secrets]), fetchExistingTranslations = o.useCallback(async () => {
|
|
1331
1388
|
if (!(!documents.length || !locales.length))
|
|
1332
1389
|
try {
|
|
1333
1390
|
const sourceLocale = pluginConfig.getSourceLocale(), availableLocaleIds = locales.filter((locale) => locale.enabled !== !1).map((locale) => locale.localeId), documentIds = documents.map(getDocumentPublishedId), existingMetadata = await client.fetch(`*[
|
|
@@ -1359,7 +1416,7 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1359
1416
|
closable: !0
|
|
1360
1417
|
});
|
|
1361
1418
|
}
|
|
1362
|
-
}, [documents, locales, client]), handleTranslateAll = useCallback(async () => {
|
|
1419
|
+
}, [documents, locales, client]), handleTranslateAll = o.useCallback(async () => {
|
|
1363
1420
|
if (!(!secrets || documents.length === 0)) {
|
|
1364
1421
|
setIsBusy(!0);
|
|
1365
1422
|
try {
|
|
@@ -1368,7 +1425,7 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1368
1425
|
try {
|
|
1369
1426
|
const serialized = serializeDocument(
|
|
1370
1427
|
cleanDoc,
|
|
1371
|
-
|
|
1428
|
+
schema2,
|
|
1372
1429
|
baseLanguage
|
|
1373
1430
|
);
|
|
1374
1431
|
return {
|
|
@@ -1398,7 +1455,7 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1398
1455
|
setIsBusy(!1);
|
|
1399
1456
|
}
|
|
1400
1457
|
}
|
|
1401
|
-
}, [secrets, documents, locales,
|
|
1458
|
+
}, [secrets, documents, locales, schema2]), handleImportAll = o.useCallback(async () => {
|
|
1402
1459
|
if (!(!secrets || documents.length === 0 || !branchId)) {
|
|
1403
1460
|
setIsBusy(!0);
|
|
1404
1461
|
try {
|
|
@@ -1461,7 +1518,7 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1461
1518
|
downloadStatus,
|
|
1462
1519
|
translationContext,
|
|
1463
1520
|
branchId
|
|
1464
|
-
]), getExistingTranslations = useCallback(
|
|
1521
|
+
]), getExistingTranslations = o.useCallback(
|
|
1465
1522
|
async (documentIds, localeIds, branchId2) => {
|
|
1466
1523
|
const sourceLocale = pluginConfig.getSourceLocale(), existingMetadata = await client.fetch(`*[
|
|
1467
1524
|
_type == 'translation.metadata' &&
|
|
@@ -1488,7 +1545,7 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1488
1545
|
}), existing;
|
|
1489
1546
|
},
|
|
1490
1547
|
[client]
|
|
1491
|
-
), handleImportMissing = useCallback(async () => {
|
|
1548
|
+
), handleImportMissing = o.useCallback(async () => {
|
|
1492
1549
|
if (!(!secrets || documents.length === 0 || !branchId)) {
|
|
1493
1550
|
setIsBusy(!0);
|
|
1494
1551
|
try {
|
|
@@ -1565,7 +1622,7 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1565
1622
|
translationContext,
|
|
1566
1623
|
getExistingTranslations,
|
|
1567
1624
|
branchId
|
|
1568
|
-
]), handleGetBranchId = useCallback(
|
|
1625
|
+
]), handleGetBranchId = o.useCallback(
|
|
1569
1626
|
async (secrets2) => {
|
|
1570
1627
|
overrideConfig(secrets2);
|
|
1571
1628
|
const defaultBranch = await gt.createBranch({
|
|
@@ -1575,7 +1632,7 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1575
1632
|
setBranchId(defaultBranch.branch.id);
|
|
1576
1633
|
},
|
|
1577
1634
|
[secrets]
|
|
1578
|
-
), handleRefreshAll = useCallback(async () => {
|
|
1635
|
+
), handleRefreshAll = o.useCallback(async () => {
|
|
1579
1636
|
if (!(!secrets || documents.length === 0 || !branchId)) {
|
|
1580
1637
|
setIsRefreshing(!0);
|
|
1581
1638
|
try {
|
|
@@ -1642,7 +1699,7 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1642
1699
|
setIsRefreshing(!1);
|
|
1643
1700
|
}
|
|
1644
1701
|
}
|
|
1645
|
-
}, [secrets, documents, locales, branchId]), handleImportDocument = useCallback(
|
|
1702
|
+
}, [secrets, documents, locales, branchId]), handleImportDocument = o.useCallback(
|
|
1646
1703
|
async (documentId, versionId, localeId) => {
|
|
1647
1704
|
if (!secrets) return;
|
|
1648
1705
|
const key = createTranslationStatusKey(
|
|
@@ -1729,7 +1786,7 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1729
1786
|
}
|
|
1730
1787
|
},
|
|
1731
1788
|
[secrets, documents, translationContext, translationStatuses, branchId]
|
|
1732
|
-
), handlePatchDocumentReferences = useCallback(async () => {
|
|
1789
|
+
), handlePatchDocumentReferences = o.useCallback(async () => {
|
|
1733
1790
|
if (!secrets || documents.length === 0) return 0;
|
|
1734
1791
|
setIsBusy(!0);
|
|
1735
1792
|
try {
|
|
@@ -1803,7 +1860,7 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1803
1860
|
} finally {
|
|
1804
1861
|
setIsBusy(!1), setImportProgress({ current: 0, total: 0, isImporting: !1 });
|
|
1805
1862
|
}
|
|
1806
|
-
}, [secrets, documents, locales, client, branchId]), handlePublishAllTranslations = useCallback(async () => {
|
|
1863
|
+
}, [secrets, documents, locales, client, branchId]), handlePublishAllTranslations = o.useCallback(async () => {
|
|
1807
1864
|
if (!secrets || documents.length === 0) return 0;
|
|
1808
1865
|
setIsBusy(!0);
|
|
1809
1866
|
try {
|
|
@@ -1859,13 +1916,13 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1859
1916
|
setIsBusy(!1);
|
|
1860
1917
|
}
|
|
1861
1918
|
}, [secrets, documents, client, branchId]);
|
|
1862
|
-
useEffect(() => {
|
|
1919
|
+
o.useEffect(() => {
|
|
1863
1920
|
fetchDocuments();
|
|
1864
|
-
}, [fetchDocuments]), useEffect(() => {
|
|
1921
|
+
}, [fetchDocuments]), o.useEffect(() => {
|
|
1865
1922
|
secrets && fetchLocales();
|
|
1866
|
-
}, [fetchLocales, secrets]), useEffect(() => {
|
|
1923
|
+
}, [fetchLocales, secrets]), o.useEffect(() => {
|
|
1867
1924
|
documents.length > 0 && locales.length > 0 && fetchExistingTranslations();
|
|
1868
|
-
}, [fetchExistingTranslations]), useEffect(() => {
|
|
1925
|
+
}, [fetchExistingTranslations]), o.useEffect(() => {
|
|
1869
1926
|
documents.length > 0 && locales.length > 0 && secrets && !loadingDocuments && branchId && handleRefreshAll();
|
|
1870
1927
|
}, [
|
|
1871
1928
|
documents,
|
|
@@ -1874,15 +1931,15 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1874
1931
|
loadingDocuments,
|
|
1875
1932
|
branchId,
|
|
1876
1933
|
handleRefreshAll
|
|
1877
|
-
]), useEffect(() => {
|
|
1934
|
+
]), o.useEffect(() => {
|
|
1878
1935
|
if (!autoRefresh || documents.length === 0 || !secrets) return;
|
|
1879
1936
|
const interval = setInterval(async () => {
|
|
1880
1937
|
await handleRefreshAll();
|
|
1881
1938
|
}, 1e4);
|
|
1882
1939
|
return () => clearInterval(interval);
|
|
1883
|
-
}, [autoRefresh, documents.length, secrets, handleRefreshAll]), useEffect(() => {
|
|
1940
|
+
}, [autoRefresh, documents.length, secrets, handleRefreshAll]), o.useEffect(() => {
|
|
1884
1941
|
setImportedTranslations(new Set(downloadStatus.downloaded));
|
|
1885
|
-
}, [downloadStatus.downloaded]), useEffect(() => {
|
|
1942
|
+
}, [downloadStatus.downloaded]), o.useEffect(() => {
|
|
1886
1943
|
secrets && handleGetBranchId(secrets);
|
|
1887
1944
|
}, [secrets, handleGetBranchId]);
|
|
1888
1945
|
const contextValue = {
|
|
@@ -1918,12 +1975,12 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1918
1975
|
handlePatchDocumentReferences,
|
|
1919
1976
|
handlePublishAllTranslations
|
|
1920
1977
|
};
|
|
1921
|
-
return /* @__PURE__ */ jsx(TranslationsContext.Provider, { value: contextValue, children });
|
|
1978
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TranslationsContext.Provider, { value: contextValue, children });
|
|
1922
1979
|
};
|
|
1923
1980
|
function ProgressBar({ progress }) {
|
|
1924
|
-
return typeof progress > "u" ? (console.warn("No progress prop passed to ProgressBar"), null) : /* @__PURE__ */ jsxs(Card, { border: !0, radius: 2, style: { width: "100%", position: "relative" }, children: [
|
|
1925
|
-
/* @__PURE__ */ jsx(
|
|
1926
|
-
Flex,
|
|
1981
|
+
return typeof progress > "u" ? (console.warn("No progress prop passed to ProgressBar"), null) : /* @__PURE__ */ jsxRuntime.jsxs(ui.Card, { border: !0, radius: 2, style: { width: "100%", position: "relative" }, children: [
|
|
1982
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1983
|
+
ui.Flex,
|
|
1927
1984
|
{
|
|
1928
1985
|
style: {
|
|
1929
1986
|
position: "absolute",
|
|
@@ -1935,14 +1992,14 @@ function ProgressBar({ progress }) {
|
|
|
1935
1992
|
},
|
|
1936
1993
|
align: "center",
|
|
1937
1994
|
justify: "center",
|
|
1938
|
-
children: /* @__PURE__ */ jsxs(Label, { size: 1, children: [
|
|
1995
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Label, { size: 1, children: [
|
|
1939
1996
|
progress,
|
|
1940
1997
|
"%"
|
|
1941
1998
|
] })
|
|
1942
1999
|
}
|
|
1943
2000
|
),
|
|
1944
|
-
/* @__PURE__ */ jsx(
|
|
1945
|
-
Card,
|
|
2001
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2002
|
+
ui.Card,
|
|
1946
2003
|
{
|
|
1947
2004
|
style: {
|
|
1948
2005
|
width: "100%",
|
|
@@ -1963,7 +2020,7 @@ const LanguageStatus = ({
|
|
|
1963
2020
|
importFile,
|
|
1964
2021
|
isImported = !1
|
|
1965
2022
|
}) => {
|
|
1966
|
-
const [isBusy, setIsBusy] = useState(!1), displayedProgress = isImported && progress < 100 ? 100 : progress, handleImport = useCallback(async () => {
|
|
2023
|
+
const [isBusy, setIsBusy] = o.useState(!1), displayedProgress = isImported && progress < 100 ? 100 : progress, handleImport = o.useCallback(async () => {
|
|
1967
2024
|
setIsBusy(!0);
|
|
1968
2025
|
try {
|
|
1969
2026
|
await importFile();
|
|
@@ -1971,20 +2028,20 @@ const LanguageStatus = ({
|
|
|
1971
2028
|
setIsBusy(!1);
|
|
1972
2029
|
}
|
|
1973
2030
|
}, [importFile, setIsBusy]);
|
|
1974
|
-
return /* @__PURE__ */ jsx(Card, { shadow: 1, children: /* @__PURE__ */ jsxs(Grid, { columns: 5, gap: 3, padding: 3, children: [
|
|
1975
|
-
/* @__PURE__ */ jsx(Flex, { columnStart: 1, columnEnd: 3, align: "center", children: /* @__PURE__ */ jsx(Text, { weight: "bold", size: 1, children: title }) }),
|
|
1976
|
-
typeof displayedProgress == "number" ? /* @__PURE__ */ jsx(Flex, { columnStart: 3, columnEnd: 5, align: "center", children: /* @__PURE__ */ jsx(ProgressBar, { progress: displayedProgress }) }) : null,
|
|
1977
|
-
/* @__PURE__ */ jsx(Box, { columnStart: 5, columnEnd: 6, children: isImported ? /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "center", style: { color: "green" }, children: [
|
|
1978
|
-
/* @__PURE__ */ jsx(CheckmarkCircleIcon, {}),
|
|
1979
|
-
/* @__PURE__ */ jsx(Text, { size: 1, style: { marginLeft: "4px" }, children: "Imported" })
|
|
1980
|
-
] }) : /* @__PURE__ */ jsx(
|
|
1981
|
-
Button,
|
|
2031
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { shadow: 1, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Grid, { columns: 5, gap: 3, padding: 3, children: [
|
|
2032
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { columnStart: 1, columnEnd: 3, align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "bold", size: 1, children: title }) }),
|
|
2033
|
+
typeof displayedProgress == "number" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { columnStart: 3, columnEnd: 5, align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(ProgressBar, { progress: displayedProgress }) }) : null,
|
|
2034
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { columnStart: 5, columnEnd: 6, children: isImported ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", justify: "center", style: { color: "green" }, children: [
|
|
2035
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.CheckmarkCircleIcon, {}),
|
|
2036
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, style: { marginLeft: "4px" }, children: "Imported" })
|
|
2037
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2038
|
+
ui.Button,
|
|
1982
2039
|
{
|
|
1983
2040
|
style: { width: "100%" },
|
|
1984
2041
|
mode: "ghost",
|
|
1985
2042
|
onClick: handleImport,
|
|
1986
2043
|
text: isBusy ? "Importing..." : "Import",
|
|
1987
|
-
icon: isBusy ? null : DownloadIcon,
|
|
2044
|
+
icon: isBusy ? null : icons.DownloadIcon,
|
|
1988
2045
|
disabled: isBusy || !progress || progress < 100
|
|
1989
2046
|
}
|
|
1990
2047
|
) })
|
|
@@ -2588,7 +2645,7 @@ var unitlessKeys = {
|
|
|
2588
2645
|
}, f = typeof process < "u" && process.env !== void 0 && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || "data-styled", m = "active", y = "data-styled-version", v = "6.1.19", g = `/*!sc*/
|
|
2589
2646
|
`, S = typeof window < "u" && typeof document < "u", w = !!(typeof SC_DISABLE_SPEEDY == "boolean" ? SC_DISABLE_SPEEDY : typeof process < "u" && process.env !== void 0 && process.env.REACT_APP_SC_DISABLE_SPEEDY !== void 0 && process.env.REACT_APP_SC_DISABLE_SPEEDY !== "" ? process.env.REACT_APP_SC_DISABLE_SPEEDY !== "false" && process.env.REACT_APP_SC_DISABLE_SPEEDY : typeof process < "u" && process.env !== void 0 && process.env.SC_DISABLE_SPEEDY !== void 0 && process.env.SC_DISABLE_SPEEDY !== "" ? process.env.SC_DISABLE_SPEEDY !== "false" && process.env.SC_DISABLE_SPEEDY : process.env.NODE_ENV !== "production"), E = /invalid hook call/i, N = /* @__PURE__ */ new Set(), P = function(t, n) {
|
|
2590
2647
|
if (process.env.NODE_ENV !== "production") {
|
|
2591
|
-
var
|
|
2648
|
+
var o$1 = n ? ' with the id of "'.concat(n, '"') : "", s = "The component ".concat(t).concat(o$1, ` has been created dynamically.
|
|
2592
2649
|
`) + `You may see this warning because you've called styled inside another component.
|
|
2593
2650
|
To resolve this only create new StyledComponents outside of any render method and function component.
|
|
2594
2651
|
See https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.
|
|
@@ -2596,9 +2653,9 @@ See https://styled-components.com/docs/basics#define-styled-components-outside-o
|
|
|
2596
2653
|
try {
|
|
2597
2654
|
var a = !0;
|
|
2598
2655
|
console.error = function(t2) {
|
|
2599
|
-
for (var n2 = [],
|
|
2656
|
+
for (var n2 = [], o2 = 1; o2 < arguments.length; o2++) n2[o2 - 1] = arguments[o2];
|
|
2600
2657
|
E.test(t2) ? (a = !1, N.delete(s)) : i.apply(void 0, __spreadArray([t2], n2, !1));
|
|
2601
|
-
}, useRef(), a && !N.has(s) && (console.warn(s), N.add(s));
|
|
2658
|
+
}, o.useRef(), a && !N.has(s) && (console.warn(s), N.add(s));
|
|
2602
2659
|
} catch (e) {
|
|
2603
2660
|
E.test(e.message) && N.delete(s);
|
|
2604
2661
|
} finally {
|
|
@@ -2936,10 +2993,10 @@ function Fe(e) {
|
|
|
2936
2993
|
return t2.name || he(15), z(e2, t2.name);
|
|
2937
2994
|
}, F).toString() : "", p;
|
|
2938
2995
|
}
|
|
2939
|
-
var ze = new ke(), Me = Fe(), $e =
|
|
2940
|
-
|
|
2996
|
+
var ze = new ke(), Me = Fe(), $e = o__default.default.createContext({ shouldForwardProp: void 0, styleSheet: ze, stylis: Me });
|
|
2997
|
+
o__default.default.createContext(void 0);
|
|
2941
2998
|
function Le() {
|
|
2942
|
-
return useContext($e);
|
|
2999
|
+
return o.useContext($e);
|
|
2943
3000
|
}
|
|
2944
3001
|
var qe = (function() {
|
|
2945
3002
|
function e(e2, t) {
|
|
@@ -3027,7 +3084,7 @@ var Ke = M(v), Qe = (function() {
|
|
|
3027
3084
|
}
|
|
3028
3085
|
return o2;
|
|
3029
3086
|
}, e;
|
|
3030
|
-
})(), et =
|
|
3087
|
+
})(), et = o__default.default.createContext(void 0), rt = {}, st = /* @__PURE__ */ new Set();
|
|
3031
3088
|
function it(e, r, s) {
|
|
3032
3089
|
var i = se(e), a = e, c = !G(e), p = r.attrs, d = p === void 0 ? _ : p, h = r.componentId, f2 = h === void 0 ? (function(e2, t) {
|
|
3033
3090
|
var n = typeof e2 != "string" ? "sc" : R(e2);
|
|
@@ -3049,8 +3106,8 @@ function it(e, r, s) {
|
|
|
3049
3106
|
var N2 = new Qe(s, g2, i ? a.componentStyle : void 0);
|
|
3050
3107
|
function O2(e2, r2) {
|
|
3051
3108
|
return (function(e3, r3, s2) {
|
|
3052
|
-
var i2 = e3.attrs, a2 = e3.componentStyle, c2 = e3.defaultProps, p2 = e3.foldedComponentIds, d2 = e3.styledComponentId, h2 = e3.target, f3 =
|
|
3053
|
-
process.env.NODE_ENV !== "production" && useDebugValue(d2);
|
|
3109
|
+
var i2 = e3.attrs, a2 = e3.componentStyle, c2 = e3.defaultProps, p2 = e3.foldedComponentIds, d2 = e3.styledComponentId, h2 = e3.target, f3 = o__default.default.useContext(et), m3 = Le(), y3 = e3.shouldForwardProp || m3.shouldForwardProp;
|
|
3110
|
+
process.env.NODE_ENV !== "production" && o.useDebugValue(d2);
|
|
3054
3111
|
var v2 = I(r3, f3, c2) || C, g3 = (function(e4, n, o2) {
|
|
3055
3112
|
for (var r4, s3 = __assign(__assign({}, n), { className: void 0, theme: o2 }), i3 = 0; i3 < e4.length; i3 += 1) {
|
|
3056
3113
|
var a3 = re(r4 = e4[i3]) ? r4(s3) : r4;
|
|
@@ -3060,16 +3117,16 @@ function it(e, r, s) {
|
|
|
3060
3117
|
})(i2, r3, v2), S3 = g3.as || h2, w3 = {};
|
|
3061
3118
|
for (var b2 in g3) g3[b2] === void 0 || b2[0] === "$" || b2 === "as" || b2 === "theme" && g3.theme === v2 || (b2 === "forwardedAs" ? w3.as = g3.forwardedAs : y3 && !y3(b2, S3) || (w3[b2] = g3[b2], y3 || process.env.NODE_ENV !== "development" || isPropValid(b2) || st.has(b2) || !A.has(S3) || (st.add(b2), console.warn('styled-components: it looks like an unknown prop "'.concat(b2, '" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));
|
|
3062
3119
|
var E3 = (function(e4, t) {
|
|
3063
|
-
var n = Le(),
|
|
3064
|
-
return process.env.NODE_ENV !== "production" && useDebugValue(
|
|
3120
|
+
var n = Le(), o$1 = e4.generateAndInjectStyles(t, n.styleSheet, n.stylis);
|
|
3121
|
+
return process.env.NODE_ENV !== "production" && o.useDebugValue(o$1), o$1;
|
|
3065
3122
|
})(a2, g3);
|
|
3066
3123
|
process.env.NODE_ENV !== "production" && e3.warnTooManyClasses && e3.warnTooManyClasses(E3);
|
|
3067
3124
|
var N3 = ie(p2, d2);
|
|
3068
|
-
return E3 && (N3 += " " + E3), g3.className && (N3 += " " + g3.className), w3[G(S3) && !A.has(S3) ? "class" : "className"] = N3, s2 && (w3.ref = s2), createElement(S3, w3);
|
|
3125
|
+
return E3 && (N3 += " " + E3), g3.className && (N3 += " " + g3.className), w3[G(S3) && !A.has(S3) ? "class" : "className"] = N3, s2 && (w3.ref = s2), o.createElement(S3, w3);
|
|
3069
3126
|
})(D2, e2, r2);
|
|
3070
3127
|
}
|
|
3071
3128
|
O2.displayName = y2;
|
|
3072
|
-
var D2 =
|
|
3129
|
+
var D2 = o__default.default.forwardRef(O2);
|
|
3073
3130
|
return D2.attrs = S2, D2.componentStyle = N2, D2.displayName = y2, D2.shouldForwardProp = w2, D2.foldedComponentIds = i ? ie(a.foldedComponentIds, a.styledComponentId) : "", D2.styledComponentId = g2, D2.target = i ? a.target : e, Object.defineProperty(D2, "defaultProps", { get: function() {
|
|
3074
3131
|
return this._foldedDefaultProps;
|
|
3075
3132
|
}, set: function(e2) {
|
|
@@ -3137,34 +3194,34 @@ var wt = "__sc-".concat(f, "__");
|
|
|
3137
3194
|
process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && typeof window < "u" && (window[wt] || (window[wt] = 0), window[wt] === 1 && console.warn(`It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.
|
|
3138
3195
|
|
|
3139
3196
|
See https://s-c.sh/2BAXzed for more info.`), window[wt] += 1);
|
|
3140
|
-
const WrapText = dt(Box)`
|
|
3197
|
+
const WrapText = dt(ui.Box)`
|
|
3141
3198
|
white-space: normal;
|
|
3142
3199
|
`, LocaleCheckbox = ({
|
|
3143
3200
|
locale,
|
|
3144
3201
|
toggle,
|
|
3145
3202
|
checked
|
|
3146
3203
|
}) => {
|
|
3147
|
-
const onClick = useCallback(
|
|
3204
|
+
const onClick = o.useCallback(
|
|
3148
3205
|
() => toggle(locale.localeId, !checked),
|
|
3149
3206
|
[locale.localeId, toggle, checked]
|
|
3150
3207
|
);
|
|
3151
|
-
return /* @__PURE__ */ jsx(
|
|
3152
|
-
Button,
|
|
3208
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3209
|
+
ui.Button,
|
|
3153
3210
|
{
|
|
3154
3211
|
mode: "ghost",
|
|
3155
3212
|
onClick,
|
|
3156
3213
|
style: { cursor: "pointer" },
|
|
3157
3214
|
radius: 2,
|
|
3158
|
-
children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 3, children: [
|
|
3159
|
-
/* @__PURE__ */ jsx(
|
|
3160
|
-
Switch,
|
|
3215
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 3, children: [
|
|
3216
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3217
|
+
ui.Switch,
|
|
3161
3218
|
{
|
|
3162
3219
|
style: { pointerEvents: "none" },
|
|
3163
3220
|
onChange: onClick,
|
|
3164
3221
|
checked
|
|
3165
3222
|
}
|
|
3166
3223
|
),
|
|
3167
|
-
/* @__PURE__ */ jsx(WrapText, { children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children: locale.description }) })
|
|
3224
|
+
/* @__PURE__ */ jsxRuntime.jsx(WrapText, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "semibold", children: locale.description }) })
|
|
3168
3225
|
] })
|
|
3169
3226
|
}
|
|
3170
3227
|
);
|
|
@@ -3191,16 +3248,16 @@ const WrapText = dt(Box)`
|
|
|
3191
3248
|
setAutoPatchReferences,
|
|
3192
3249
|
autoPublish,
|
|
3193
3250
|
setAutoPublish
|
|
3194
|
-
} = useTranslations(), [isImporting, setIsImporting] = useState(!1), [isPublishing, setIsPublishing] = useState(!1), toast = useToast(), document2 = documents[0], currentDocumentLanguage = useMemo(() => {
|
|
3251
|
+
} = useTranslations(), [isImporting, setIsImporting] = o.useState(!1), [isPublishing, setIsPublishing] = o.useState(!1), toast = ui.useToast(), document2 = documents[0], currentDocumentLanguage = o.useMemo(() => {
|
|
3195
3252
|
if (!document2) return null;
|
|
3196
3253
|
const languageField = pluginConfig.getLanguageField();
|
|
3197
3254
|
return document2[languageField] || pluginConfig.getSourceLocale();
|
|
3198
|
-
}, [document2]), shouldShowTranslationComponents = useMemo(() => currentDocumentLanguage ? currentDocumentLanguage === pluginConfig.getSourceLocale() : !1, [currentDocumentLanguage]), availableLocales = useMemo(() => {
|
|
3255
|
+
}, [document2]), shouldShowTranslationComponents = o.useMemo(() => currentDocumentLanguage ? currentDocumentLanguage === pluginConfig.getSourceLocale() : !1, [currentDocumentLanguage]), availableLocales = o.useMemo(() => {
|
|
3199
3256
|
const sourceLocale = pluginConfig.getSourceLocale();
|
|
3200
3257
|
return locales.filter(
|
|
3201
3258
|
(locale) => locale.enabled !== !1 && locale.localeId !== sourceLocale
|
|
3202
3259
|
);
|
|
3203
|
-
}, [locales]), documentId = useMemo(() => document2 ? getDocumentPublishedId(document2) : null, [document2]), handleImportTranslations = useCallback(
|
|
3260
|
+
}, [locales]), documentId = o.useMemo(() => document2 ? getDocumentPublishedId(document2) : null, [document2]), handleImportTranslations = o.useCallback(
|
|
3204
3261
|
async (options = {}) => {
|
|
3205
3262
|
const { autoOnly = !1 } = options;
|
|
3206
3263
|
if (isImporting || !documentId || autoOnly && !autoImport) return;
|
|
@@ -3241,12 +3298,12 @@ const WrapText = dt(Box)`
|
|
|
3241
3298
|
toast
|
|
3242
3299
|
]
|
|
3243
3300
|
);
|
|
3244
|
-
useEffect(() => {
|
|
3301
|
+
o.useEffect(() => {
|
|
3245
3302
|
handleImportTranslations({ autoOnly: !0 });
|
|
3246
|
-
}, [handleImportTranslations]), useEffect(() => {
|
|
3303
|
+
}, [handleImportTranslations]), o.useEffect(() => {
|
|
3247
3304
|
setAutoRefresh(!0), setAutoPatchReferences(!0), setAutoPublish(!0);
|
|
3248
3305
|
}, [setAutoRefresh, setAutoPatchReferences, setAutoPublish]);
|
|
3249
|
-
const toggleLocale = useCallback(
|
|
3306
|
+
const toggleLocale = o.useCallback(
|
|
3250
3307
|
(localeId, shouldEnable) => {
|
|
3251
3308
|
const updatedLocales = locales.map(
|
|
3252
3309
|
(locale) => locale.localeId === localeId ? { ...locale, enabled: shouldEnable } : locale
|
|
@@ -3254,7 +3311,7 @@ const WrapText = dt(Box)`
|
|
|
3254
3311
|
setLocales(updatedLocales);
|
|
3255
3312
|
},
|
|
3256
3313
|
[locales, setLocales]
|
|
3257
|
-
), toggleAllLocales = useCallback(() => {
|
|
3314
|
+
), toggleAllLocales = o.useCallback(() => {
|
|
3258
3315
|
const sourceLocale = pluginConfig.getSourceLocale(), allEnabled = locales.filter(
|
|
3259
3316
|
(locale) => locale.localeId !== sourceLocale
|
|
3260
3317
|
).every(
|
|
@@ -3264,14 +3321,14 @@ const WrapText = dt(Box)`
|
|
|
3264
3321
|
);
|
|
3265
3322
|
setLocales(updatedLocales);
|
|
3266
3323
|
}, [locales, setLocales]);
|
|
3267
|
-
return shouldShowTranslationComponents ? /* @__PURE__ */ jsxs(Stack, { space: 6, padding: 4, children: [
|
|
3268
|
-
/* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
3269
|
-
/* @__PURE__ */ jsx(Text, { as: "h2", weight: "semibold", size: 2, children: "Generate Translations" }),
|
|
3270
|
-
/* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3271
|
-
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", children: [
|
|
3272
|
-
/* @__PURE__ */ jsx(Text, { weight: "semibold", size: 1, children: availableLocales.length === 1 ? "Select locale" : "Select locales" }),
|
|
3273
|
-
/* @__PURE__ */ jsx(
|
|
3274
|
-
Button,
|
|
3324
|
+
return shouldShowTranslationComponents ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 6, padding: 4, children: [
|
|
3325
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
|
|
3326
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "h2", weight: "semibold", size: 2, children: "Generate Translations" }),
|
|
3327
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
3328
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", justify: "space-between", children: [
|
|
3329
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "semibold", size: 1, children: availableLocales.length === 1 ? "Select locale" : "Select locales" }),
|
|
3330
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3331
|
+
ui.Button,
|
|
3275
3332
|
{
|
|
3276
3333
|
fontSize: 1,
|
|
3277
3334
|
padding: 2,
|
|
@@ -3280,9 +3337,9 @@ const WrapText = dt(Box)`
|
|
|
3280
3337
|
}
|
|
3281
3338
|
)
|
|
3282
3339
|
] }),
|
|
3283
|
-
/* @__PURE__ */ jsx(Grid, { columns: [1, 1, 2, 3], gap: 1, children: locales.filter(
|
|
3340
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Grid, { columns: [1, 1, 2, 3], gap: 1, children: locales.filter(
|
|
3284
3341
|
(locale) => locale.localeId !== pluginConfig.getSourceLocale()
|
|
3285
|
-
).map((locale) => /* @__PURE__ */ jsx(
|
|
3342
|
+
).map((locale) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3286
3343
|
LocaleCheckbox,
|
|
3287
3344
|
{
|
|
3288
3345
|
locale,
|
|
@@ -3292,8 +3349,8 @@ const WrapText = dt(Box)`
|
|
|
3292
3349
|
locale.localeId
|
|
3293
3350
|
)) })
|
|
3294
3351
|
] }),
|
|
3295
|
-
/* @__PURE__ */ jsx(
|
|
3296
|
-
Button,
|
|
3352
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3353
|
+
ui.Button,
|
|
3297
3354
|
{
|
|
3298
3355
|
onClick: () => {
|
|
3299
3356
|
setAutoImport(!0), handleTranslateAll();
|
|
@@ -3304,22 +3361,22 @@ const WrapText = dt(Box)`
|
|
|
3304
3361
|
}
|
|
3305
3362
|
)
|
|
3306
3363
|
] }),
|
|
3307
|
-
documentId && availableLocales.length > 0 && /* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
3308
|
-
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", children: [
|
|
3309
|
-
/* @__PURE__ */ jsx(Text, { as: "h2", weight: "semibold", size: 2, children: "Translation Status" }),
|
|
3310
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 3, align: "center", children: [
|
|
3311
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3312
|
-
/* @__PURE__ */ jsx(Text, { size: 1, children: "Auto-refresh" }),
|
|
3313
|
-
/* @__PURE__ */ jsx(
|
|
3314
|
-
Switch,
|
|
3364
|
+
documentId && availableLocales.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
|
|
3365
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", justify: "space-between", children: [
|
|
3366
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "h2", weight: "semibold", size: 2, children: "Translation Status" }),
|
|
3367
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, align: "center", children: [
|
|
3368
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", children: [
|
|
3369
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "Auto-refresh" }),
|
|
3370
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3371
|
+
ui.Switch,
|
|
3315
3372
|
{
|
|
3316
3373
|
checked: autoRefresh,
|
|
3317
3374
|
onChange: () => setAutoRefresh(!autoRefresh)
|
|
3318
3375
|
}
|
|
3319
3376
|
)
|
|
3320
3377
|
] }),
|
|
3321
|
-
/* @__PURE__ */ jsx(
|
|
3322
|
-
Button,
|
|
3378
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3379
|
+
ui.Button,
|
|
3323
3380
|
{
|
|
3324
3381
|
fontSize: 1,
|
|
3325
3382
|
padding: 2,
|
|
@@ -3330,14 +3387,14 @@ const WrapText = dt(Box)`
|
|
|
3330
3387
|
)
|
|
3331
3388
|
] })
|
|
3332
3389
|
] }),
|
|
3333
|
-
/* @__PURE__ */ jsx(Box, { children: availableLocales.map((locale) => {
|
|
3390
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: availableLocales.map((locale) => {
|
|
3334
3391
|
const key = createTranslationStatusKey(
|
|
3335
3392
|
branchId,
|
|
3336
3393
|
documentId,
|
|
3337
3394
|
document2._rev,
|
|
3338
3395
|
locale.localeId
|
|
3339
3396
|
), status = translationStatuses.get(key), progress = status?.progress || 0, isImported = importedTranslations.has(key);
|
|
3340
|
-
return /* @__PURE__ */ jsx(
|
|
3397
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3341
3398
|
LanguageStatus,
|
|
3342
3399
|
{
|
|
3343
3400
|
title: locale.description,
|
|
@@ -3354,17 +3411,17 @@ const WrapText = dt(Box)`
|
|
|
3354
3411
|
key
|
|
3355
3412
|
);
|
|
3356
3413
|
}) }),
|
|
3357
|
-
/* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3358
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 3, align: "center", justify: "space-between", children: [
|
|
3359
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3360
|
-
/* @__PURE__ */ jsx(
|
|
3361
|
-
Button,
|
|
3414
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
3415
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, align: "center", justify: "space-between", children: [
|
|
3416
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", children: [
|
|
3417
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3418
|
+
ui.Button,
|
|
3362
3419
|
{
|
|
3363
3420
|
mode: "ghost",
|
|
3364
3421
|
tone: "primary",
|
|
3365
3422
|
onClick: () => handleImportTranslations(),
|
|
3366
3423
|
text: isImporting ? "Importing..." : "Import All",
|
|
3367
|
-
icon: DownloadIcon,
|
|
3424
|
+
icon: icons.DownloadIcon,
|
|
3368
3425
|
disabled: isImporting || availableLocales.every((locale) => {
|
|
3369
3426
|
const key = createTranslationStatusKey(
|
|
3370
3427
|
branchId,
|
|
@@ -3377,19 +3434,19 @@ const WrapText = dt(Box)`
|
|
|
3377
3434
|
style: { minWidth: "180px" }
|
|
3378
3435
|
}
|
|
3379
3436
|
),
|
|
3380
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3381
|
-
/* @__PURE__ */ jsx(
|
|
3382
|
-
Switch,
|
|
3437
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", children: [
|
|
3438
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3439
|
+
ui.Switch,
|
|
3383
3440
|
{
|
|
3384
3441
|
checked: autoImport,
|
|
3385
3442
|
onChange: () => setAutoImport(!autoImport),
|
|
3386
3443
|
disabled: isImporting
|
|
3387
3444
|
}
|
|
3388
3445
|
),
|
|
3389
|
-
/* @__PURE__ */ jsx(Text, { size: 1, children: "Auto-import when complete" })
|
|
3446
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "Auto-import when complete" })
|
|
3390
3447
|
] })
|
|
3391
3448
|
] }),
|
|
3392
|
-
/* @__PURE__ */ jsxs(Text, { size: 1, muted: !0, children: [
|
|
3449
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, muted: !0, children: [
|
|
3393
3450
|
"Imported",
|
|
3394
3451
|
" ",
|
|
3395
3452
|
availableLocales.filter((locale) => {
|
|
@@ -3413,14 +3470,14 @@ const WrapText = dt(Box)`
|
|
|
3413
3470
|
}).length
|
|
3414
3471
|
] })
|
|
3415
3472
|
] }),
|
|
3416
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", justify: "flex-start", children: [
|
|
3417
|
-
/* @__PURE__ */ jsx(
|
|
3418
|
-
Tooltip,
|
|
3473
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", justify: "flex-start", children: [
|
|
3474
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3475
|
+
ui.Tooltip,
|
|
3419
3476
|
{
|
|
3420
3477
|
placement: "top",
|
|
3421
3478
|
content: `Replaces references to ${pluginConfig.getSourceLocale()} documents in this document with the corresponding translated document reference`,
|
|
3422
|
-
children: /* @__PURE__ */ jsx(
|
|
3423
|
-
Button,
|
|
3479
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3480
|
+
ui.Button,
|
|
3424
3481
|
{
|
|
3425
3482
|
mode: "ghost",
|
|
3426
3483
|
tone: "caution",
|
|
@@ -3428,33 +3485,33 @@ const WrapText = dt(Box)`
|
|
|
3428
3485
|
await handlePatchDocumentReferences();
|
|
3429
3486
|
},
|
|
3430
3487
|
text: isBusy ? "Patching..." : "Patch References",
|
|
3431
|
-
icon: isBusy ? null : LinkIcon,
|
|
3488
|
+
icon: isBusy ? null : icons.LinkIcon,
|
|
3432
3489
|
disabled: isBusy || isImporting,
|
|
3433
3490
|
style: { minWidth: "180px" }
|
|
3434
3491
|
}
|
|
3435
3492
|
)
|
|
3436
3493
|
}
|
|
3437
3494
|
),
|
|
3438
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3439
|
-
/* @__PURE__ */ jsx(
|
|
3440
|
-
Switch,
|
|
3495
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", children: [
|
|
3496
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3497
|
+
ui.Switch,
|
|
3441
3498
|
{
|
|
3442
3499
|
checked: autoPatchReferences,
|
|
3443
3500
|
onChange: () => setAutoPatchReferences(!autoPatchReferences),
|
|
3444
3501
|
disabled: isImporting || isBusy
|
|
3445
3502
|
}
|
|
3446
3503
|
),
|
|
3447
|
-
/* @__PURE__ */ jsx(Text, { size: 1, children: "Auto-patch after import" })
|
|
3504
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "Auto-patch after import" })
|
|
3448
3505
|
] })
|
|
3449
3506
|
] }),
|
|
3450
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", justify: "flex-start", children: [
|
|
3451
|
-
/* @__PURE__ */ jsx(
|
|
3452
|
-
Tooltip,
|
|
3507
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", justify: "flex-start", children: [
|
|
3508
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3509
|
+
ui.Tooltip,
|
|
3453
3510
|
{
|
|
3454
3511
|
placement: "top",
|
|
3455
3512
|
content: "Publishes all translations (if the source document is published)",
|
|
3456
|
-
children: /* @__PURE__ */ jsx(
|
|
3457
|
-
Button,
|
|
3513
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3514
|
+
ui.Button,
|
|
3458
3515
|
{
|
|
3459
3516
|
mode: "ghost",
|
|
3460
3517
|
tone: "positive",
|
|
@@ -3467,48 +3524,48 @@ const WrapText = dt(Box)`
|
|
|
3467
3524
|
}
|
|
3468
3525
|
},
|
|
3469
3526
|
text: isPublishing ? "Publishing..." : "Publish Translations",
|
|
3470
|
-
icon: isPublishing ? null : PublishIcon,
|
|
3527
|
+
icon: isPublishing ? null : icons.PublishIcon,
|
|
3471
3528
|
disabled: isBusy || isPublishing || isImporting,
|
|
3472
3529
|
style: { minWidth: "180px" }
|
|
3473
3530
|
}
|
|
3474
3531
|
)
|
|
3475
3532
|
}
|
|
3476
3533
|
),
|
|
3477
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3478
|
-
/* @__PURE__ */ jsx(
|
|
3479
|
-
Switch,
|
|
3534
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", children: [
|
|
3535
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3536
|
+
ui.Switch,
|
|
3480
3537
|
{
|
|
3481
3538
|
checked: autoPublish,
|
|
3482
3539
|
onChange: () => setAutoPublish(!autoPublish),
|
|
3483
3540
|
disabled: isPublishing || isImporting || isBusy
|
|
3484
3541
|
}
|
|
3485
3542
|
),
|
|
3486
|
-
/* @__PURE__ */ jsx(Text, { size: 1, children: "Auto-publish after import" })
|
|
3543
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "Auto-publish after import" })
|
|
3487
3544
|
] })
|
|
3488
3545
|
] })
|
|
3489
3546
|
] })
|
|
3490
3547
|
] })
|
|
3491
|
-
] }) : /* @__PURE__ */ jsx(Card, { padding: 4, tone: "neutral", border: !0, children: /* @__PURE__ */ jsxs(Text, { size: 1, muted: !0, children: [
|
|
3548
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { padding: 4, tone: "neutral", border: !0, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, muted: !0, children: [
|
|
3492
3549
|
"Translation tools are only available for",
|
|
3493
3550
|
" ",
|
|
3494
|
-
/* @__PURE__ */ jsx("code", { children: pluginConfig.getSourceLocale() }),
|
|
3551
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { children: pluginConfig.getSourceLocale() }),
|
|
3495
3552
|
" documents."
|
|
3496
3553
|
] }) });
|
|
3497
3554
|
}, TranslationTab = (props) => {
|
|
3498
3555
|
const { displayed } = props.document;
|
|
3499
|
-
return /* @__PURE__ */ jsx(BaseTranslationWrapper, { showContainer: !1, children: /* @__PURE__ */ jsx(TranslationsProvider, { singleDocument: displayed, children: /* @__PURE__ */ jsx(TranslationView, {}) }) });
|
|
3556
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BaseTranslationWrapper, { showContainer: !1, children: /* @__PURE__ */ jsxRuntime.jsx(TranslationsProvider, { singleDocument: displayed, children: /* @__PURE__ */ jsxRuntime.jsx(TranslationView, {}) }) });
|
|
3500
3557
|
}, translateAction = (props) => {
|
|
3501
|
-
const [dialogOpen, setDialogOpen] = useState(!1), document2 = props.draft || props.published;
|
|
3558
|
+
const [dialogOpen, setDialogOpen] = o.useState(!1), document2 = props.draft || props.published;
|
|
3502
3559
|
return {
|
|
3503
3560
|
label: "Translate",
|
|
3504
|
-
icon: TranslateIcon,
|
|
3561
|
+
icon: icons.TranslateIcon,
|
|
3505
3562
|
tone: "primary",
|
|
3506
3563
|
onHandle: () => setDialogOpen(!0),
|
|
3507
3564
|
dialog: dialogOpen ? {
|
|
3508
3565
|
type: "dialog",
|
|
3509
3566
|
header: "Translations",
|
|
3510
3567
|
onClose: () => setDialogOpen(!1),
|
|
3511
|
-
content: /* @__PURE__ */ jsx(BaseTranslationWrapper, { showContainer: !1, children: /* @__PURE__ */ jsx(TranslationsProvider, { singleDocument: document2, children: /* @__PURE__ */ jsx(TranslationView, {}) }) })
|
|
3568
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(BaseTranslationWrapper, { showContainer: !1, children: /* @__PURE__ */ jsxRuntime.jsx(TranslationsProvider, { singleDocument: document2, children: /* @__PURE__ */ jsxRuntime.jsx(TranslationView, {}) }) })
|
|
3512
3569
|
} : null
|
|
3513
3570
|
};
|
|
3514
3571
|
}, TranslationsTable = () => {
|
|
@@ -3522,19 +3579,19 @@ const WrapText = dt(Box)`
|
|
|
3522
3579
|
handleImportDocument,
|
|
3523
3580
|
branchId
|
|
3524
3581
|
} = useTranslations();
|
|
3525
|
-
return loadingDocuments ? /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", padding: 4, children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx(Box, { style: { maxHeight: "60vh", overflowY: "auto" }, children: /* @__PURE__ */ jsx(Stack, { space: 2, children: documents.map((document2) => /* @__PURE__ */ jsx(Card, { shadow: 1, padding: 3, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3526
|
-
/* @__PURE__ */ jsx(Flex, { justify: "space-between", align: "flex-start", children: /* @__PURE__ */ jsxs(Box, { flex: 1, children: [
|
|
3527
|
-
/* @__PURE__ */ jsx(Text, { weight: "semibold", size: 1, children: getDocumentPublishedId(document2) }),
|
|
3528
|
-
/* @__PURE__ */ jsx(Text, { size: 0, muted: !0, style: { marginTop: "2px" }, children: document2._type })
|
|
3582
|
+
return loadingDocuments ? /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { align: "center", justify: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, {}) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { maxHeight: "60vh", overflowY: "auto" }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: documents.map((document2) => /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { shadow: 1, padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
3583
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "space-between", align: "flex-start", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { flex: 1, children: [
|
|
3584
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "semibold", size: 1, children: getDocumentPublishedId(document2) }),
|
|
3585
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 0, muted: !0, style: { marginTop: "2px" }, children: document2._type })
|
|
3529
3586
|
] }) }),
|
|
3530
|
-
/* @__PURE__ */ jsx(Stack, { space: 2, children: locales.length > 0 ? locales.filter((locale) => locale.enabled !== !1).map((locale) => {
|
|
3587
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: locales.length > 0 ? locales.filter((locale) => locale.enabled !== !1).map((locale) => {
|
|
3531
3588
|
const documentId = getDocumentPublishedId(document2), key = createTranslationStatusKey(
|
|
3532
3589
|
branchId,
|
|
3533
3590
|
documentId,
|
|
3534
3591
|
document2._rev,
|
|
3535
3592
|
locale.localeId
|
|
3536
3593
|
), status = translationStatuses.get(key), isDownloaded = downloadStatus.downloaded.has(key), isImported = importedTranslations.has(key);
|
|
3537
|
-
return /* @__PURE__ */ jsx(
|
|
3594
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3538
3595
|
LanguageStatus,
|
|
3539
3596
|
{
|
|
3540
3597
|
title: locale.description || locale.localeId,
|
|
@@ -3550,40 +3607,40 @@ const WrapText = dt(Box)`
|
|
|
3550
3607
|
},
|
|
3551
3608
|
`${document2._id}-${document2._rev}-${locale.localeId}`
|
|
3552
3609
|
);
|
|
3553
|
-
}) : /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "No locales configured" }) })
|
|
3610
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: "No locales configured" }) })
|
|
3554
3611
|
] }) }, document2._id)) }) });
|
|
3555
3612
|
}, TranslateAllDialog = ({
|
|
3556
3613
|
isOpen,
|
|
3557
3614
|
onClose
|
|
3558
3615
|
}) => {
|
|
3559
|
-
const { documents, handleTranslateAll } = useTranslations()
|
|
3560
|
-
|
|
3561
|
-
|
|
3616
|
+
const { documents, handleTranslateAll } = useTranslations(), handleConfirm = async () => {
|
|
3617
|
+
onClose(), await handleTranslateAll();
|
|
3618
|
+
};
|
|
3619
|
+
return isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3620
|
+
ui.Dialog,
|
|
3562
3621
|
{
|
|
3563
3622
|
header: "Confirm Translation",
|
|
3564
3623
|
id: "translate-all-dialog",
|
|
3565
3624
|
onClose,
|
|
3566
|
-
footer: /* @__PURE__ */ jsx(Box, { padding: 3, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
3567
|
-
/* @__PURE__ */ jsx(Button, { text: "Cancel", mode: "ghost", onClick: onClose }),
|
|
3568
|
-
/* @__PURE__ */ jsx(
|
|
3569
|
-
Button,
|
|
3625
|
+
footer: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, children: [
|
|
3626
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Cancel", mode: "ghost", onClick: onClose }),
|
|
3627
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3628
|
+
ui.Button,
|
|
3570
3629
|
{
|
|
3571
3630
|
text: "Translate All",
|
|
3572
3631
|
tone: "critical",
|
|
3573
|
-
onClick:
|
|
3574
|
-
onClose(), await handleTranslateAll();
|
|
3575
|
-
}
|
|
3632
|
+
onClick: handleConfirm
|
|
3576
3633
|
}
|
|
3577
3634
|
)
|
|
3578
3635
|
] }) }),
|
|
3579
|
-
children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3580
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
3636
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
3637
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { children: [
|
|
3581
3638
|
"Are you sure you want to create translations for all",
|
|
3582
3639
|
" ",
|
|
3583
3640
|
documents.length,
|
|
3584
3641
|
" documents?"
|
|
3585
3642
|
] }),
|
|
3586
|
-
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "This will submit all documents to General Translation for processing." })
|
|
3643
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: "This will submit all documents to General Translation for processing." })
|
|
3587
3644
|
] }) })
|
|
3588
3645
|
}
|
|
3589
3646
|
) : null;
|
|
@@ -3591,27 +3648,27 @@ const WrapText = dt(Box)`
|
|
|
3591
3648
|
isOpen,
|
|
3592
3649
|
onClose
|
|
3593
3650
|
}) => {
|
|
3594
|
-
const { documents, handleImportAll } = useTranslations()
|
|
3595
|
-
|
|
3596
|
-
|
|
3651
|
+
const { documents, handleImportAll } = useTranslations(), handleConfirm = async () => {
|
|
3652
|
+
onClose(), await handleImportAll();
|
|
3653
|
+
};
|
|
3654
|
+
return isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3655
|
+
ui.Dialog,
|
|
3597
3656
|
{
|
|
3598
3657
|
header: "Confirm Import",
|
|
3599
3658
|
id: "import-all-dialog",
|
|
3600
3659
|
onClose,
|
|
3601
|
-
footer: /* @__PURE__ */ jsx(Box, { padding: 3, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
3602
|
-
/* @__PURE__ */ jsx(Button, { text: "Cancel", mode: "ghost", onClick: onClose }),
|
|
3603
|
-
/* @__PURE__ */ jsx(Button, { text: "Import All", tone: "critical", onClick:
|
|
3604
|
-
onClose(), await handleImportAll();
|
|
3605
|
-
} })
|
|
3660
|
+
footer: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, children: [
|
|
3661
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Cancel", mode: "ghost", onClick: onClose }),
|
|
3662
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Import All", tone: "critical", onClick: handleConfirm })
|
|
3606
3663
|
] }) }),
|
|
3607
|
-
children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3608
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
3664
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
3665
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { children: [
|
|
3609
3666
|
"Are you sure you want to import translations for all",
|
|
3610
3667
|
" ",
|
|
3611
3668
|
documents.length,
|
|
3612
3669
|
" documents?"
|
|
3613
3670
|
] }),
|
|
3614
|
-
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "This will download and apply translated content to your documents. Note that this will overwrite any existing translations!" })
|
|
3671
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: "This will download and apply translated content to your documents. Note that this will overwrite any existing translations!" })
|
|
3615
3672
|
] }) })
|
|
3616
3673
|
}
|
|
3617
3674
|
) : null;
|
|
@@ -3619,29 +3676,29 @@ const WrapText = dt(Box)`
|
|
|
3619
3676
|
isOpen,
|
|
3620
3677
|
onClose
|
|
3621
3678
|
}) => {
|
|
3622
|
-
const { handleImportMissing } = useTranslations()
|
|
3623
|
-
|
|
3624
|
-
|
|
3679
|
+
const { handleImportMissing } = useTranslations(), handleConfirm = async () => {
|
|
3680
|
+
onClose(), await handleImportMissing();
|
|
3681
|
+
};
|
|
3682
|
+
return isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3683
|
+
ui.Dialog,
|
|
3625
3684
|
{
|
|
3626
3685
|
header: "Confirm Import Missing",
|
|
3627
3686
|
id: "import-missing-dialog",
|
|
3628
3687
|
onClose,
|
|
3629
|
-
footer: /* @__PURE__ */ jsx(Box, { padding: 3, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
3630
|
-
/* @__PURE__ */ jsx(Button, { text: "Cancel", mode: "ghost", onClick: onClose }),
|
|
3631
|
-
/* @__PURE__ */ jsx(
|
|
3632
|
-
Button,
|
|
3688
|
+
footer: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, children: [
|
|
3689
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Cancel", mode: "ghost", onClick: onClose }),
|
|
3690
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3691
|
+
ui.Button,
|
|
3633
3692
|
{
|
|
3634
3693
|
text: "Import Missing",
|
|
3635
3694
|
tone: "primary",
|
|
3636
|
-
onClick:
|
|
3637
|
-
onClose(), await handleImportMissing();
|
|
3638
|
-
}
|
|
3695
|
+
onClick: handleConfirm
|
|
3639
3696
|
}
|
|
3640
3697
|
)
|
|
3641
3698
|
] }) }),
|
|
3642
|
-
children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3643
|
-
/* @__PURE__ */ jsx(Text, { children: "Import only the missing translations (translations that are ready but haven't been imported to Sanity yet)?" }),
|
|
3644
|
-
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "This will check existing translation metadata and only import translations that don't already exist in your dataset." })
|
|
3699
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
3700
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Import only the missing translations (translations that are ready but haven't been imported to Sanity yet)?" }),
|
|
3701
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: "This will check existing translation metadata and only import translations that don't already exist in your dataset." })
|
|
3645
3702
|
] }) })
|
|
3646
3703
|
}
|
|
3647
3704
|
) : null;
|
|
@@ -3650,9 +3707,9 @@ const WrapText = dt(Box)`
|
|
|
3650
3707
|
current,
|
|
3651
3708
|
total,
|
|
3652
3709
|
operationName
|
|
3653
|
-
}) => isActive ? /* @__PURE__ */ jsxs(Flex, { justify: "center", align: "center", gap: 3, children: [
|
|
3654
|
-
/* @__PURE__ */ jsx(Spinner, { size: 1 }),
|
|
3655
|
-
/* @__PURE__ */ jsxs(Text, { size: 1, children: [
|
|
3710
|
+
}) => isActive ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { justify: "center", align: "center", gap: 3, children: [
|
|
3711
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { size: 1 }),
|
|
3712
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, children: [
|
|
3656
3713
|
operationName,
|
|
3657
3714
|
" ",
|
|
3658
3715
|
current,
|
|
@@ -3661,7 +3718,7 @@ const WrapText = dt(Box)`
|
|
|
3661
3718
|
"..."
|
|
3662
3719
|
] })
|
|
3663
3720
|
] }) : null, TranslationsToolContent = () => {
|
|
3664
|
-
const [isTranslateAllDialogOpen, setIsTranslateAllDialogOpen] = useState(!1), [isImportAllDialogOpen, setIsImportAllDialogOpen] = useState(!1), [isImportMissingDialogOpen, setIsImportMissingDialogOpen] = useState(!1), {
|
|
3721
|
+
const [isTranslateAllDialogOpen, setIsTranslateAllDialogOpen] = o.useState(!1), [isImportAllDialogOpen, setIsImportAllDialogOpen] = o.useState(!1), [isImportMissingDialogOpen, setIsImportMissingDialogOpen] = o.useState(!1), {
|
|
3665
3722
|
isBusy,
|
|
3666
3723
|
documents,
|
|
3667
3724
|
locales,
|
|
@@ -3674,7 +3731,7 @@ const WrapText = dt(Box)`
|
|
|
3674
3731
|
handleRefreshAll,
|
|
3675
3732
|
handlePatchDocumentReferences,
|
|
3676
3733
|
handlePublishAllTranslations
|
|
3677
|
-
} = useTranslations(), [currentOperation, setCurrentOperation] = useState(null), getOperationText = (operationName, isProcessing) => {
|
|
3734
|
+
} = useTranslations(), [currentOperation, setCurrentOperation] = o.useState(null), getOperationText = (operationName, isProcessing) => {
|
|
3678
3735
|
if (!isProcessing || !operationName) return operationName;
|
|
3679
3736
|
switch (operationName) {
|
|
3680
3737
|
case "Translate All":
|
|
@@ -3704,28 +3761,28 @@ const WrapText = dt(Box)`
|
|
|
3704
3761
|
return "Processing";
|
|
3705
3762
|
}
|
|
3706
3763
|
};
|
|
3707
|
-
return
|
|
3764
|
+
return o__default.default.useEffect(() => {
|
|
3708
3765
|
!isBusy && !importProgress.isImporting && setCurrentOperation(null);
|
|
3709
|
-
}, [isBusy, importProgress.isImporting]), /* @__PURE__ */ jsxs(Container, { width: 2, children: [
|
|
3710
|
-
/* @__PURE__ */ jsx(Box, { padding: 4, marginTop: 5, children: /* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
3711
|
-
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", children: [
|
|
3712
|
-
/* @__PURE__ */ jsxs(Stack, { space: 2, children: [
|
|
3713
|
-
/* @__PURE__ */ jsx(Heading, { as: "h2", size: 3, children: "Translations" }),
|
|
3714
|
-
/* @__PURE__ */ jsx(Text, { size: 2, children: "Manage your document translations from this centralized location." })
|
|
3766
|
+
}, [isBusy, importProgress.isImporting]), /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { width: 2, children: [
|
|
3767
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
|
|
3768
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", justify: "space-between", children: [
|
|
3769
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
3770
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { as: "h2", size: 3, children: "Translations" }),
|
|
3771
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 2, children: "Manage your document translations from this centralized location." })
|
|
3715
3772
|
] }),
|
|
3716
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 3, align: "center", children: [
|
|
3717
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3718
|
-
/* @__PURE__ */ jsx(Text, { size: 1, children: "Auto-refresh" }),
|
|
3719
|
-
/* @__PURE__ */ jsx(
|
|
3720
|
-
Switch,
|
|
3773
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, align: "center", children: [
|
|
3774
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", children: [
|
|
3775
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "Auto-refresh" }),
|
|
3776
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3777
|
+
ui.Switch,
|
|
3721
3778
|
{
|
|
3722
3779
|
checked: autoRefresh,
|
|
3723
3780
|
onChange: () => setAutoRefresh(!autoRefresh)
|
|
3724
3781
|
}
|
|
3725
3782
|
)
|
|
3726
3783
|
] }),
|
|
3727
|
-
/* @__PURE__ */ jsx(
|
|
3728
|
-
Button,
|
|
3784
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3785
|
+
ui.Button,
|
|
3729
3786
|
{
|
|
3730
3787
|
fontSize: 1,
|
|
3731
3788
|
padding: 2,
|
|
@@ -3736,10 +3793,10 @@ const WrapText = dt(Box)`
|
|
|
3736
3793
|
)
|
|
3737
3794
|
] })
|
|
3738
3795
|
] }),
|
|
3739
|
-
/* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
3740
|
-
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: loadingDocuments ? "Loading documents..." : `Found ${documents.length} documents available for translation` }) }),
|
|
3741
|
-
/* @__PURE__ */ jsx(Flex, { justify: "center", children: /* @__PURE__ */ jsx(
|
|
3742
|
-
Button,
|
|
3796
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
|
|
3797
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: loadingDocuments ? "Loading documents..." : `Found ${documents.length} documents available for translation` }) }),
|
|
3798
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3799
|
+
ui.Button,
|
|
3743
3800
|
{
|
|
3744
3801
|
style: { width: "200px" },
|
|
3745
3802
|
tone: "critical",
|
|
@@ -3753,17 +3810,17 @@ const WrapText = dt(Box)`
|
|
|
3753
3810
|
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
3754
3811
|
}
|
|
3755
3812
|
) }),
|
|
3756
|
-
/* @__PURE__ */ jsx(TranslationsTable, {}),
|
|
3757
|
-
/* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3758
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 3, align: "center", justify: "space-between", children: [
|
|
3759
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3760
|
-
/* @__PURE__ */ jsx(
|
|
3761
|
-
Tooltip,
|
|
3813
|
+
/* @__PURE__ */ jsxRuntime.jsx(TranslationsTable, {}),
|
|
3814
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
3815
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, align: "center", justify: "space-between", children: [
|
|
3816
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", children: [
|
|
3817
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3818
|
+
ui.Tooltip,
|
|
3762
3819
|
{
|
|
3763
3820
|
placement: "top",
|
|
3764
3821
|
content: "Imports and overrides all translations",
|
|
3765
|
-
children: /* @__PURE__ */ jsx(
|
|
3766
|
-
Button,
|
|
3822
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3823
|
+
ui.Button,
|
|
3767
3824
|
{
|
|
3768
3825
|
mode: "ghost",
|
|
3769
3826
|
onClick: () => {
|
|
@@ -3773,19 +3830,19 @@ const WrapText = dt(Box)`
|
|
|
3773
3830
|
"Import All",
|
|
3774
3831
|
isBusy && currentOperation === "Import All"
|
|
3775
3832
|
),
|
|
3776
|
-
icon: isBusy && currentOperation === "Import All" ? null : DownloadIcon,
|
|
3833
|
+
icon: isBusy && currentOperation === "Import All" ? null : icons.DownloadIcon,
|
|
3777
3834
|
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
3778
3835
|
}
|
|
3779
3836
|
)
|
|
3780
3837
|
}
|
|
3781
3838
|
),
|
|
3782
|
-
/* @__PURE__ */ jsx(
|
|
3783
|
-
Tooltip,
|
|
3839
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3840
|
+
ui.Tooltip,
|
|
3784
3841
|
{
|
|
3785
3842
|
placement: "top",
|
|
3786
3843
|
content: "Imports all translations that are not yet imported (according to the source document's translation.metadata document)",
|
|
3787
|
-
children: /* @__PURE__ */ jsx(
|
|
3788
|
-
Button,
|
|
3844
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3845
|
+
ui.Button,
|
|
3789
3846
|
{
|
|
3790
3847
|
mode: "ghost",
|
|
3791
3848
|
tone: "primary",
|
|
@@ -3796,19 +3853,19 @@ const WrapText = dt(Box)`
|
|
|
3796
3853
|
"Import Missing",
|
|
3797
3854
|
isBusy && currentOperation === "Import Missing"
|
|
3798
3855
|
),
|
|
3799
|
-
icon: isBusy && currentOperation === "Import Missing" ? null : DownloadIcon,
|
|
3856
|
+
icon: isBusy && currentOperation === "Import Missing" ? null : icons.DownloadIcon,
|
|
3800
3857
|
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
3801
3858
|
}
|
|
3802
3859
|
)
|
|
3803
3860
|
}
|
|
3804
3861
|
),
|
|
3805
|
-
/* @__PURE__ */ jsx(
|
|
3806
|
-
Tooltip,
|
|
3862
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3863
|
+
ui.Tooltip,
|
|
3807
3864
|
{
|
|
3808
3865
|
placement: "top",
|
|
3809
3866
|
content: "Replaces references in documents with the corresponding translated document reference",
|
|
3810
|
-
children: /* @__PURE__ */ jsx(
|
|
3811
|
-
Button,
|
|
3867
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3868
|
+
ui.Button,
|
|
3812
3869
|
{
|
|
3813
3870
|
mode: "ghost",
|
|
3814
3871
|
tone: "caution",
|
|
@@ -3819,19 +3876,19 @@ const WrapText = dt(Box)`
|
|
|
3819
3876
|
"Patch Document References",
|
|
3820
3877
|
isBusy && currentOperation === "Patch Document References"
|
|
3821
3878
|
),
|
|
3822
|
-
icon: isBusy && currentOperation === "Patch Document References" ? null : LinkIcon,
|
|
3879
|
+
icon: isBusy && currentOperation === "Patch Document References" ? null : icons.LinkIcon,
|
|
3823
3880
|
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
3824
3881
|
}
|
|
3825
3882
|
)
|
|
3826
3883
|
}
|
|
3827
3884
|
),
|
|
3828
|
-
/* @__PURE__ */ jsx(
|
|
3829
|
-
Tooltip,
|
|
3885
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3886
|
+
ui.Tooltip,
|
|
3830
3887
|
{
|
|
3831
3888
|
placement: "top",
|
|
3832
3889
|
content: "Publishes all translations whose source document is published",
|
|
3833
|
-
children: /* @__PURE__ */ jsx(
|
|
3834
|
-
Button,
|
|
3890
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3891
|
+
ui.Button,
|
|
3835
3892
|
{
|
|
3836
3893
|
mode: "ghost",
|
|
3837
3894
|
tone: "positive",
|
|
@@ -3842,17 +3899,17 @@ const WrapText = dt(Box)`
|
|
|
3842
3899
|
"Publish Translations",
|
|
3843
3900
|
isBusy && currentOperation === "Publish Translations"
|
|
3844
3901
|
),
|
|
3845
|
-
icon: isBusy && currentOperation === "Publish Translations" ? null : PublishIcon,
|
|
3902
|
+
icon: isBusy && currentOperation === "Publish Translations" ? null : icons.PublishIcon,
|
|
3846
3903
|
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
3847
3904
|
}
|
|
3848
3905
|
)
|
|
3849
3906
|
}
|
|
3850
3907
|
),
|
|
3851
|
-
importedTranslations.size === documents.length * locales.filter((l) => l.enabled !== !1).length && documents.length > 0 && locales.length > 0 && /* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", style: { color: "green" }, children: [
|
|
3852
|
-
/* @__PURE__ */ jsx(CheckmarkCircleIcon, {}),
|
|
3853
|
-
/* @__PURE__ */ jsx(Text, { size: 1, children: "All translations imported" })
|
|
3908
|
+
importedTranslations.size === documents.length * locales.filter((l) => l.enabled !== !1).length && documents.length > 0 && locales.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", style: { color: "green" }, children: [
|
|
3909
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.CheckmarkCircleIcon, {}),
|
|
3910
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "All translations imported" })
|
|
3854
3911
|
] }),
|
|
3855
|
-
importedTranslations.size > 0 && importedTranslations.size < documents.length * locales.filter((l) => l.enabled !== !1).length && /* @__PURE__ */ jsxs(Text, { size: 1, style: { color: "#666" }, children: [
|
|
3912
|
+
importedTranslations.size > 0 && importedTranslations.size < documents.length * locales.filter((l) => l.enabled !== !1).length && /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, style: { color: "#666" }, children: [
|
|
3856
3913
|
importedTranslations.size,
|
|
3857
3914
|
"/",
|
|
3858
3915
|
documents.length * locales.filter((l) => l.enabled !== !1).length,
|
|
@@ -3860,9 +3917,9 @@ const WrapText = dt(Box)`
|
|
|
3860
3917
|
"imported"
|
|
3861
3918
|
] })
|
|
3862
3919
|
] }),
|
|
3863
|
-
/* @__PURE__ */ jsx(Box, {})
|
|
3920
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, {})
|
|
3864
3921
|
] }),
|
|
3865
|
-
/* @__PURE__ */ jsx(
|
|
3922
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3866
3923
|
BatchProgress,
|
|
3867
3924
|
{
|
|
3868
3925
|
isActive: importProgress.isImporting,
|
|
@@ -3873,28 +3930,28 @@ const WrapText = dt(Box)`
|
|
|
3873
3930
|
)
|
|
3874
3931
|
] })
|
|
3875
3932
|
] }),
|
|
3876
|
-
/* @__PURE__ */ jsxs(Text, { size: 2, children: [
|
|
3933
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 2, children: [
|
|
3877
3934
|
"For more information, see the",
|
|
3878
3935
|
" ",
|
|
3879
|
-
/* @__PURE__ */ jsx(Link, { href: "https://dash.generaltranslation.com", children: "General Translation Dashboard" }),
|
|
3936
|
+
/* @__PURE__ */ jsxRuntime.jsx(router.Link, { href: "https://dash.generaltranslation.com", children: "General Translation Dashboard" }),
|
|
3880
3937
|
"."
|
|
3881
3938
|
] })
|
|
3882
3939
|
] }) }),
|
|
3883
|
-
/* @__PURE__ */ jsx(
|
|
3940
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3884
3941
|
TranslateAllDialog,
|
|
3885
3942
|
{
|
|
3886
3943
|
isOpen: isTranslateAllDialogOpen,
|
|
3887
3944
|
onClose: () => setIsTranslateAllDialogOpen(!1)
|
|
3888
3945
|
}
|
|
3889
3946
|
),
|
|
3890
|
-
/* @__PURE__ */ jsx(
|
|
3947
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3891
3948
|
ImportAllDialog,
|
|
3892
3949
|
{
|
|
3893
3950
|
isOpen: isImportAllDialogOpen,
|
|
3894
3951
|
onClose: () => setIsImportAllDialogOpen(!1)
|
|
3895
3952
|
}
|
|
3896
3953
|
),
|
|
3897
|
-
/* @__PURE__ */ jsx(
|
|
3954
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3898
3955
|
ImportMissingDialog,
|
|
3899
3956
|
{
|
|
3900
3957
|
isOpen: isImportMissingDialogOpen,
|
|
@@ -3902,7 +3959,7 @@ const WrapText = dt(Box)`
|
|
|
3902
3959
|
}
|
|
3903
3960
|
)
|
|
3904
3961
|
] });
|
|
3905
|
-
}, TranslationsTool = () => /* @__PURE__ */ jsx(BaseTranslationWrapper, { showContainer: !1, children: /* @__PURE__ */ jsx(TranslationsProvider, { children: /* @__PURE__ */ jsx(TranslationsToolContent, {}) }) }), gtPlugin = definePlugin(
|
|
3962
|
+
}, TranslationsTool = () => /* @__PURE__ */ jsxRuntime.jsx(BaseTranslationWrapper, { showContainer: !1, children: /* @__PURE__ */ jsxRuntime.jsx(TranslationsProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(TranslationsToolContent, {}) }) }), gtPlugin = sanity.definePlugin(
|
|
3906
3963
|
({
|
|
3907
3964
|
languageField = "language",
|
|
3908
3965
|
sourceLocale,
|
|
@@ -3924,7 +3981,7 @@ const WrapText = dt(Box)`
|
|
|
3924
3981
|
additionalBlockDeserializers = [],
|
|
3925
3982
|
showDocumentInternationalization = !0
|
|
3926
3983
|
}) => {
|
|
3927
|
-
const resolvedSourceLocale = sourceLocale ?? defaultLocale ?? libraryDefaultLocale;
|
|
3984
|
+
const resolvedSourceLocale = sourceLocale ?? defaultLocale ?? internal.libraryDefaultLocale;
|
|
3928
3985
|
let normalizedTranslateDocuments;
|
|
3929
3986
|
translateDocuments && (normalizedTranslateDocuments = translateDocuments.map((entry) => typeof entry == "string" ? { type: entry } : entry).filter((filter2) => filter2.documentId || filter2.type)), pluginConfig.init(
|
|
3930
3987
|
secretsNamespace,
|
|
@@ -3953,11 +4010,11 @@ const WrapText = dt(Box)`
|
|
|
3953
4010
|
const schemaTypes = normalizedTranslateDocuments?.map((filter2) => filter2.type).filter((type) => !!type) ?? [];
|
|
3954
4011
|
if (schemaTypes.length > 0) {
|
|
3955
4012
|
const supportedLanguages = [resolvedSourceLocale, ...locales].map((locale) => {
|
|
3956
|
-
const props = getLocaleProperties(locale, resolvedSourceLocale);
|
|
4013
|
+
const props = generaltranslation.getLocaleProperties(locale, resolvedSourceLocale);
|
|
3957
4014
|
return { id: locale, title: props.name };
|
|
3958
4015
|
});
|
|
3959
4016
|
plugins.push(
|
|
3960
|
-
documentInternationalization({
|
|
4017
|
+
documentInternationalization.documentInternationalization({
|
|
3961
4018
|
supportedLanguages,
|
|
3962
4019
|
schemaTypes,
|
|
3963
4020
|
languageField
|
|
@@ -3973,7 +4030,7 @@ const WrapText = dt(Box)`
|
|
|
3973
4030
|
name: "translations",
|
|
3974
4031
|
title: "Translations",
|
|
3975
4032
|
component: TranslationsTool,
|
|
3976
|
-
router: route.create("/*")
|
|
4033
|
+
router: router.route.create("/*")
|
|
3977
4034
|
}
|
|
3978
4035
|
],
|
|
3979
4036
|
document: {
|
|
@@ -3982,22 +4039,45 @@ const WrapText = dt(Box)`
|
|
|
3982
4039
|
};
|
|
3983
4040
|
}
|
|
3984
4041
|
);
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
};
|
|
4003
|
-
|
|
4042
|
+
Object.defineProperty(exports, "DocumentInternationalizationMenu", {
|
|
4043
|
+
enumerable: !0,
|
|
4044
|
+
get: function() {
|
|
4045
|
+
return documentInternationalization.DocumentInternationalizationMenu;
|
|
4046
|
+
}
|
|
4047
|
+
});
|
|
4048
|
+
Object.defineProperty(exports, "documentInternationalization", {
|
|
4049
|
+
enumerable: !0,
|
|
4050
|
+
get: function() {
|
|
4051
|
+
return documentInternationalization.documentInternationalization;
|
|
4052
|
+
}
|
|
4053
|
+
});
|
|
4054
|
+
Object.defineProperty(exports, "useDeleteTranslationAction", {
|
|
4055
|
+
enumerable: !0,
|
|
4056
|
+
get: function() {
|
|
4057
|
+
return documentInternationalization.useDeleteTranslationAction;
|
|
4058
|
+
}
|
|
4059
|
+
});
|
|
4060
|
+
Object.defineProperty(exports, "useDocumentInternationalizationContext", {
|
|
4061
|
+
enumerable: !0,
|
|
4062
|
+
get: function() {
|
|
4063
|
+
return documentInternationalization.useDocumentInternationalizationContext;
|
|
4064
|
+
}
|
|
4065
|
+
});
|
|
4066
|
+
Object.defineProperty(exports, "useDuplicateWithTranslationsAction", {
|
|
4067
|
+
enumerable: !0,
|
|
4068
|
+
get: function() {
|
|
4069
|
+
return documentInternationalization.useDuplicateWithTranslationsAction;
|
|
4070
|
+
}
|
|
4071
|
+
});
|
|
4072
|
+
exports.BaseDocumentDeserializer = BaseDocumentDeserializer;
|
|
4073
|
+
exports.BaseDocumentMerger = BaseDocumentMerger;
|
|
4074
|
+
exports.BaseDocumentSerializer = BaseDocumentSerializer;
|
|
4075
|
+
exports.TranslationsTab = TranslationTab;
|
|
4076
|
+
exports.attachGTData = attachGTData;
|
|
4077
|
+
exports.customSerializers = customSerializers;
|
|
4078
|
+
exports.defaultStopTypes = defaultStopTypes;
|
|
4079
|
+
exports.detachGTData = detachGTData;
|
|
4080
|
+
exports.findLatestDraft = findLatestDraft;
|
|
4081
|
+
exports.gtPlugin = gtPlugin;
|
|
4082
|
+
exports.translateAction = translateAction;
|
|
4083
|
+
//# sourceMappingURL=index.cjs.map
|