gt-sanity 0.0.6 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/dist/index.d.mts +95 -73
- package/dist/index.d.ts +95 -73
- package/dist/index.js +6233 -1162
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6292 -1193
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -4
- package/src/adapter/core.ts +41 -4
- package/src/adapter/getLocales.ts +2 -2
- package/src/components/TranslationsProvider.tsx +942 -0
- package/src/components/page/BatchProgress.tsx +27 -0
- package/src/components/page/ImportAllDialog.tsx +51 -0
- package/src/components/page/ImportMissingDialog.tsx +55 -0
- package/src/components/page/TranslateAllDialog.tsx +55 -0
- package/src/components/page/TranslationsTable.tsx +81 -0
- package/src/components/page/TranslationsTool.tsx +299 -837
- package/src/components/shared/BaseTranslationWrapper.tsx +82 -0
- package/src/components/shared/LocaleCheckbox.tsx +47 -0
- package/src/components/shared/SingleDocumentView.tsx +108 -0
- package/src/components/tab/TranslationView.tsx +379 -0
- package/src/components/tab/TranslationsTab.tsx +25 -0
- package/src/configuration/baseDocumentLevelConfig/documentLevelPatch.ts +6 -9
- package/src/configuration/baseDocumentLevelConfig/helpers/createI18nDocAndPatchMetadata.ts +5 -24
- package/src/configuration/baseDocumentLevelConfig/helpers/patchI18nDoc.ts +3 -23
- package/src/configuration/baseDocumentLevelConfig/index.ts +16 -68
- package/src/configuration/baseFieldLevelConfig.ts +15 -50
- package/src/index.ts +29 -43
- package/src/sanity-api/findDocuments.ts +44 -0
- package/src/sanity-api/publishDocuments.ts +49 -0
- package/src/sanity-api/resolveRefs.ts +146 -0
- package/src/serialization/BaseDocumentMerger.ts +138 -0
- package/src/serialization/BaseSerializationConfig.ts +220 -0
- package/src/serialization/__tests__/BaseDocumentDeserializer/__snapshots__/documentLevelDeserialization.test.ts.snap +189 -0
- package/src/serialization/__tests__/BaseDocumentDeserializer/__snapshots__/fieldLevelDeserialization.test.ts.snap +107 -0
- package/src/serialization/__tests__/BaseDocumentDeserializer/baseDeserialization.test.ts +397 -0
- package/src/serialization/__tests__/BaseDocumentDeserializer/documentLevelDeserialization.test.ts +107 -0
- package/src/serialization/__tests__/BaseDocumentDeserializer/fieldLevelDeserialization.test.ts +107 -0
- package/src/serialization/__tests__/BaseDocumentMerger/__snapshots__/documentLevelMerge.test.ts.snap +193 -0
- package/src/serialization/__tests__/BaseDocumentMerger/__snapshots__/fieldLevelMerge.test.ts.snap +97 -0
- package/src/serialization/__tests__/BaseDocumentMerger/baseMerge.test.ts +36 -0
- package/src/serialization/__tests__/BaseDocumentMerger/documentLevelMerge.test.ts +96 -0
- package/src/serialization/__tests__/BaseDocumentMerger/fieldLevelMerge.test.ts +142 -0
- package/src/serialization/__tests__/BaseDocumentMerger/utils.ts +52 -0
- package/src/serialization/__tests__/BaseDocumentSerializer/__snapshots__/documentInlineMarks.test.ts.snap +39 -0
- package/src/serialization/__tests__/BaseDocumentSerializer/__snapshots__/documentLevelSerialization.test.ts.snap +8 -0
- package/src/serialization/__tests__/BaseDocumentSerializer/__snapshots__/fieldLevelSerialization.test.ts.snap +8 -0
- package/src/serialization/__tests__/BaseDocumentSerializer/baseSerialization.test.ts +345 -0
- package/src/serialization/__tests__/BaseDocumentSerializer/documentInlineMarks.test.ts +53 -0
- package/src/serialization/__tests__/BaseDocumentSerializer/documentLevelSerialization.test.ts +120 -0
- package/src/serialization/__tests__/BaseDocumentSerializer/fieldLevelSerialization.test.ts +153 -0
- package/src/serialization/__tests__/BaseDocumentSerializer/utils.ts +27 -0
- package/src/serialization/__tests__/README +2 -0
- package/src/serialization/__tests__/__fixtures__/annotationAndInlineBlocks.json +140 -0
- package/src/serialization/__tests__/__fixtures__/customStyles.json +62 -0
- package/src/serialization/__tests__/__fixtures__/documentInlineMarks.json +70 -0
- package/src/serialization/__tests__/__fixtures__/documentLevelArticle.json +185 -0
- package/src/serialization/__tests__/__fixtures__/fieldLevelArticle.json +107 -0
- package/src/serialization/__tests__/__fixtures__/inlineDocumentLevelArticle.json +134 -0
- package/src/serialization/__tests__/__fixtures__/inlineSchema.ts +270 -0
- package/src/serialization/__tests__/__fixtures__/messy-html.html +26 -0
- package/src/serialization/__tests__/__fixtures__/nestedLanguageFields.json +54 -0
- package/src/serialization/__tests__/__fixtures__/schema.ts +310 -0
- package/src/serialization/__tests__/global.setup.ts +40 -0
- package/src/serialization/__tests__/helpers.ts +132 -0
- package/src/serialization/data.ts +82 -0
- package/src/serialization/deserialize/BaseDocumentDeserializer.ts +171 -0
- package/src/serialization/deserialize/helpers.ts +42 -0
- package/src/serialization/helpers.ts +18 -0
- package/src/serialization/index.ts +11 -0
- package/src/serialization/serialize/fieldFilters.ts +124 -0
- package/src/serialization/serialize/index.ts +284 -0
- package/src/serialization/types.ts +41 -0
- package/src/translation/importDocument.ts +4 -5
- package/src/translation/uploadFiles.ts +1 -1
- package/src/types.ts +3 -19
- package/src/utils/batchProcessor.ts +111 -0
- package/src/utils/importUtils.ts +95 -0
- package/src/utils/serialize.ts +25 -5
- package/src/utils/shared.ts +1 -1
- package/src/adapter/index.ts +0 -13
- package/src/components/NewTask.tsx +0 -251
- package/src/components/TaskView.tsx +0 -257
- package/src/components/TranslationContext.tsx +0 -24
- package/src/components/TranslationView.tsx +0 -114
- package/src/components/TranslationsTab.tsx +0 -181
- /package/src/components/{LanguageStatus.tsx → shared/LanguageStatus.tsx} +0 -0
- /package/src/components/{ProgressBar.tsx → shared/ProgressBar.tsx} +0 -0
package/LICENSE.md
CHANGED
|
@@ -106,7 +106,7 @@ specific language governing permissions and limitations under the License.
|
|
|
106
106
|
|
|
107
107
|
## Additional Code
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
Some portions of the Software are adapted from https://github.com/sanity-io/sanity-translations-tab and https://github.com/sanity-io/sanity-naive-html-serializer. These portions are licensed under the license of the original software, listed below.
|
|
110
110
|
|
|
111
111
|
MIT License
|
|
112
112
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseDocumentMerger } from 'sanity-naive-html-serializer';
|
|
3
|
-
import { BaseDocumentSerializer } from 'sanity-naive-html-serializer';
|
|
4
|
-
import { customSerializers } from 'sanity-naive-html-serializer';
|
|
5
|
-
import { defaultStopTypes } from 'sanity-naive-html-serializer';
|
|
6
|
-
import { DeserializerRule } from '@sanity/block-tools';
|
|
1
|
+
import type { DeserializerRule } from '@portabletext/block-tools';
|
|
7
2
|
import { GT } from 'generaltranslation';
|
|
8
|
-
import {
|
|
3
|
+
import { ObjectField } from 'sanity';
|
|
9
4
|
import { Plugin as Plugin_2 } from 'sanity';
|
|
5
|
+
import { PortableTextHtmlComponents } from '@portabletext/to-html';
|
|
10
6
|
import { PortableTextTypeComponent } from '@portabletext/to-html';
|
|
7
|
+
import { default as React_2 } from 'react';
|
|
11
8
|
import { SanityClient } from 'sanity';
|
|
12
9
|
import { SanityDocument } from 'sanity';
|
|
13
10
|
import { Schema } from 'sanity';
|
|
14
|
-
import { SerializedDocument } from 'sanity-naive-html-serializer';
|
|
15
11
|
import { TypedObject } from 'sanity';
|
|
16
12
|
|
|
17
13
|
export declare interface Adapter {
|
|
@@ -35,66 +31,76 @@ export declare interface Adapter {
|
|
|
35
31
|
) => Promise<any | null>;
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
export declare function attachGTData(
|
|
35
|
+
html: string,
|
|
36
|
+
data: Record<string, any>,
|
|
37
|
+
type: 'markDef'
|
|
38
|
+
): string;
|
|
39
|
+
|
|
40
|
+
export declare const BaseDocumentDeserializer: Deserializer;
|
|
41
|
+
|
|
42
|
+
export declare const BaseDocumentMerger: Merger;
|
|
43
|
+
|
|
44
|
+
export declare const BaseDocumentSerializer: (schemas: Schema) => {
|
|
45
|
+
serializeDocument: (
|
|
46
|
+
doc: SanityDocument,
|
|
47
|
+
translationLevel?: TranslationLevel,
|
|
48
|
+
baseLang?: string,
|
|
49
|
+
stopTypes?: string[],
|
|
50
|
+
serializers?: Partial<PortableTextHtmlComponents>
|
|
51
|
+
) => {
|
|
52
|
+
name: string;
|
|
53
|
+
content: string;
|
|
54
|
+
};
|
|
55
|
+
fieldFilter: (
|
|
56
|
+
obj: Record<string, any>,
|
|
57
|
+
objFields: ObjectField[],
|
|
58
|
+
stopTypes: string[]
|
|
59
|
+
) => TypedObject;
|
|
60
|
+
languageObjectFieldFilter: (
|
|
61
|
+
obj: Record<string, any>,
|
|
62
|
+
baseLang: string
|
|
63
|
+
) => Record<string, any>;
|
|
64
|
+
serializeArray: (
|
|
65
|
+
fieldContent: Record<string, any>[],
|
|
66
|
+
fieldName: string,
|
|
67
|
+
stopTypes: string[],
|
|
68
|
+
serializers: Record<string, any>
|
|
69
|
+
) => string;
|
|
70
|
+
serializeObject: (
|
|
71
|
+
obj: TypedObject,
|
|
72
|
+
stopTypes: string[],
|
|
73
|
+
serializers: Record<string, any>
|
|
74
|
+
) => string;
|
|
75
|
+
};
|
|
43
76
|
|
|
44
|
-
declare
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
77
|
+
export declare const customSerializers: Partial<PortableTextHtmlComponents>;
|
|
78
|
+
|
|
79
|
+
export declare const defaultStopTypes: string[];
|
|
80
|
+
|
|
81
|
+
declare interface Deserializer {
|
|
82
|
+
deserializeDocument: (
|
|
83
|
+
serializedDoc: string,
|
|
84
|
+
deserializers?: Record<string, any>,
|
|
85
|
+
blockDeserializers?: Array<any>
|
|
86
|
+
) => Record<string, any>;
|
|
87
|
+
deserializeHTML: (
|
|
88
|
+
html: string,
|
|
89
|
+
deserializers: Record<string, any>,
|
|
90
|
+
blockDeserializers: Array<any>
|
|
91
|
+
) => Record<string, any> | any[];
|
|
57
92
|
}
|
|
58
93
|
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export declare const defaultFieldLevelConfig: ConfigOptions;
|
|
64
|
-
|
|
65
|
-
export { defaultStopTypes };
|
|
66
|
-
|
|
67
|
-
export declare const documentLevelPatch: (
|
|
68
|
-
docInfo: GTFile,
|
|
69
|
-
translatedFields: SanityDocument,
|
|
70
|
-
localeId: string,
|
|
71
|
-
client: SanityClient,
|
|
72
|
-
languageField?: string,
|
|
73
|
-
mergeWithTargetLocale?: boolean,
|
|
74
|
-
publish?: boolean
|
|
75
|
-
) => Promise<void>;
|
|
94
|
+
export declare function detachGTData(html: string): {
|
|
95
|
+
html: string;
|
|
96
|
+
data?: Record<'markDef', Record<string, any>>;
|
|
97
|
+
};
|
|
76
98
|
|
|
77
99
|
export declare type ExportForTranslation = (
|
|
78
100
|
documentInfo: GTFile,
|
|
79
|
-
context: TranslationFunctionContext
|
|
80
|
-
serializationOptions?: {
|
|
81
|
-
additionalStopTypes?: string[];
|
|
82
|
-
additionalSerializers?: Record<
|
|
83
|
-
string,
|
|
84
|
-
PortableTextTypeComponent | undefined
|
|
85
|
-
>;
|
|
86
|
-
},
|
|
87
|
-
languageField?: string
|
|
101
|
+
context: TranslationFunctionContext
|
|
88
102
|
) => Promise<GTSerializedDocument>;
|
|
89
103
|
|
|
90
|
-
export declare const fieldLevelPatch: (
|
|
91
|
-
docInfo: GTFile,
|
|
92
|
-
translatedFields: SanityDocument,
|
|
93
|
-
localeId: string,
|
|
94
|
-
client: SanityClient,
|
|
95
|
-
mergeWithTargetLocale?: boolean
|
|
96
|
-
) => Promise<void>;
|
|
97
|
-
|
|
98
104
|
export declare const findLatestDraft: (
|
|
99
105
|
documentId: string,
|
|
100
106
|
client: SanityClient
|
|
@@ -102,8 +108,6 @@ export declare const findLatestDraft: (
|
|
|
102
108
|
|
|
103
109
|
declare const gt: GT;
|
|
104
110
|
|
|
105
|
-
export declare const GTAdapter: Adapter;
|
|
106
|
-
|
|
107
111
|
declare type GTFile = {
|
|
108
112
|
documentId: string;
|
|
109
113
|
versionId?: string;
|
|
@@ -135,6 +139,10 @@ export declare type GTPluginConfig = Omit<
|
|
|
135
139
|
languageField?: string;
|
|
136
140
|
translateDocuments?: TranslateDocumentFilter[];
|
|
137
141
|
secretsNamespace?: string;
|
|
142
|
+
additionalStopTypes?: string[];
|
|
143
|
+
additionalSerializers?: Partial<PortableTextHtmlComponents>;
|
|
144
|
+
additionalDeserializers?: Record<string, any>;
|
|
145
|
+
additionalBlockDeserializers?: any[];
|
|
138
146
|
};
|
|
139
147
|
|
|
140
148
|
declare type GTSerializedDocument = Omit<SerializedDocument, 'name'> & GTFile;
|
|
@@ -152,18 +160,28 @@ export declare type ImportTranslation = (
|
|
|
152
160
|
localeId: string,
|
|
153
161
|
document: string,
|
|
154
162
|
context: TranslationFunctionContext,
|
|
155
|
-
serializationOptions?: {
|
|
156
|
-
additionalDeserializers?: Record<
|
|
157
|
-
string,
|
|
158
|
-
(value: HTMLElement) => TypedObject
|
|
159
|
-
>;
|
|
160
|
-
additionalBlockDeserializers?: DeserializerRule[];
|
|
161
|
-
},
|
|
162
|
-
languageField?: string,
|
|
163
163
|
mergeWithTargetLocale?: boolean,
|
|
164
164
|
publish?: boolean
|
|
165
165
|
) => Promise<void>;
|
|
166
166
|
|
|
167
|
+
declare interface Merger {
|
|
168
|
+
fieldLevelMerge: (
|
|
169
|
+
translatedFields: Record<string, any>,
|
|
170
|
+
baseDoc: SanityDocument,
|
|
171
|
+
localeId: string,
|
|
172
|
+
baseLang: string
|
|
173
|
+
) => Record<string, any>;
|
|
174
|
+
documentLevelMerge: (
|
|
175
|
+
translatedFields: Record<string, any>,
|
|
176
|
+
baseDoc: SanityDocument
|
|
177
|
+
) => Record<string, any>;
|
|
178
|
+
reconcileArray: (origArray: any[], translatedArray: any[]) => any[];
|
|
179
|
+
reconcileObject: (
|
|
180
|
+
origObject: Record<string, any>,
|
|
181
|
+
translatedObject: Record<string, any>
|
|
182
|
+
) => Record<string, any>;
|
|
183
|
+
}
|
|
184
|
+
|
|
167
185
|
export declare type Secrets = {
|
|
168
186
|
organization: string;
|
|
169
187
|
project: string;
|
|
@@ -174,7 +192,10 @@ export declare type Secrets = {
|
|
|
174
192
|
proxy?: string;
|
|
175
193
|
};
|
|
176
194
|
|
|
177
|
-
export
|
|
195
|
+
export declare type SerializedDocument = {
|
|
196
|
+
name: string;
|
|
197
|
+
content: string;
|
|
198
|
+
};
|
|
178
199
|
|
|
179
200
|
declare type TranslateDocumentFilter = {
|
|
180
201
|
documentId?: string;
|
|
@@ -186,6 +207,8 @@ export declare interface TranslationFunctionContext {
|
|
|
186
207
|
schema: Schema;
|
|
187
208
|
}
|
|
188
209
|
|
|
210
|
+
declare type TranslationLevel = 'document' | 'field';
|
|
211
|
+
|
|
189
212
|
declare type TranslationLocale = {
|
|
190
213
|
localeId: string;
|
|
191
214
|
description: string;
|
|
@@ -194,7 +217,7 @@ declare type TranslationLocale = {
|
|
|
194
217
|
|
|
195
218
|
export declare const TranslationsTab: (
|
|
196
219
|
props: TranslationTabProps
|
|
197
|
-
) => JSX.Element;
|
|
220
|
+
) => React_2.JSX.Element;
|
|
198
221
|
|
|
199
222
|
export declare type TranslationsTabConfigOptions = {
|
|
200
223
|
adapter: Adapter;
|
|
@@ -224,7 +247,6 @@ declare type TranslationTabProps = {
|
|
|
224
247
|
document: {
|
|
225
248
|
displayed: SanityDocument;
|
|
226
249
|
};
|
|
227
|
-
options: TranslationsTabConfigOptions;
|
|
228
250
|
};
|
|
229
251
|
|
|
230
252
|
declare type TranslationTask = {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseDocumentMerger } from 'sanity-naive-html-serializer';
|
|
3
|
-
import { BaseDocumentSerializer } from 'sanity-naive-html-serializer';
|
|
4
|
-
import { customSerializers } from 'sanity-naive-html-serializer';
|
|
5
|
-
import { defaultStopTypes } from 'sanity-naive-html-serializer';
|
|
6
|
-
import { DeserializerRule } from '@sanity/block-tools';
|
|
1
|
+
import type { DeserializerRule } from '@portabletext/block-tools';
|
|
7
2
|
import { GT } from 'generaltranslation';
|
|
8
|
-
import {
|
|
3
|
+
import { ObjectField } from 'sanity';
|
|
9
4
|
import { Plugin as Plugin_2 } from 'sanity';
|
|
5
|
+
import { PortableTextHtmlComponents } from '@portabletext/to-html';
|
|
10
6
|
import { PortableTextTypeComponent } from '@portabletext/to-html';
|
|
7
|
+
import { default as React_2 } from 'react';
|
|
11
8
|
import { SanityClient } from 'sanity';
|
|
12
9
|
import { SanityDocument } from 'sanity';
|
|
13
10
|
import { Schema } from 'sanity';
|
|
14
|
-
import { SerializedDocument } from 'sanity-naive-html-serializer';
|
|
15
11
|
import { TypedObject } from 'sanity';
|
|
16
12
|
|
|
17
13
|
export declare interface Adapter {
|
|
@@ -35,66 +31,76 @@ export declare interface Adapter {
|
|
|
35
31
|
) => Promise<any | null>;
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
export declare function attachGTData(
|
|
35
|
+
html: string,
|
|
36
|
+
data: Record<string, any>,
|
|
37
|
+
type: 'markDef'
|
|
38
|
+
): string;
|
|
39
|
+
|
|
40
|
+
export declare const BaseDocumentDeserializer: Deserializer;
|
|
41
|
+
|
|
42
|
+
export declare const BaseDocumentMerger: Merger;
|
|
43
|
+
|
|
44
|
+
export declare const BaseDocumentSerializer: (schemas: Schema) => {
|
|
45
|
+
serializeDocument: (
|
|
46
|
+
doc: SanityDocument,
|
|
47
|
+
translationLevel?: TranslationLevel,
|
|
48
|
+
baseLang?: string,
|
|
49
|
+
stopTypes?: string[],
|
|
50
|
+
serializers?: Partial<PortableTextHtmlComponents>
|
|
51
|
+
) => {
|
|
52
|
+
name: string;
|
|
53
|
+
content: string;
|
|
54
|
+
};
|
|
55
|
+
fieldFilter: (
|
|
56
|
+
obj: Record<string, any>,
|
|
57
|
+
objFields: ObjectField[],
|
|
58
|
+
stopTypes: string[]
|
|
59
|
+
) => TypedObject;
|
|
60
|
+
languageObjectFieldFilter: (
|
|
61
|
+
obj: Record<string, any>,
|
|
62
|
+
baseLang: string
|
|
63
|
+
) => Record<string, any>;
|
|
64
|
+
serializeArray: (
|
|
65
|
+
fieldContent: Record<string, any>[],
|
|
66
|
+
fieldName: string,
|
|
67
|
+
stopTypes: string[],
|
|
68
|
+
serializers: Record<string, any>
|
|
69
|
+
) => string;
|
|
70
|
+
serializeObject: (
|
|
71
|
+
obj: TypedObject,
|
|
72
|
+
stopTypes: string[],
|
|
73
|
+
serializers: Record<string, any>
|
|
74
|
+
) => string;
|
|
75
|
+
};
|
|
43
76
|
|
|
44
|
-
declare
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
77
|
+
export declare const customSerializers: Partial<PortableTextHtmlComponents>;
|
|
78
|
+
|
|
79
|
+
export declare const defaultStopTypes: string[];
|
|
80
|
+
|
|
81
|
+
declare interface Deserializer {
|
|
82
|
+
deserializeDocument: (
|
|
83
|
+
serializedDoc: string,
|
|
84
|
+
deserializers?: Record<string, any>,
|
|
85
|
+
blockDeserializers?: Array<any>
|
|
86
|
+
) => Record<string, any>;
|
|
87
|
+
deserializeHTML: (
|
|
88
|
+
html: string,
|
|
89
|
+
deserializers: Record<string, any>,
|
|
90
|
+
blockDeserializers: Array<any>
|
|
91
|
+
) => Record<string, any> | any[];
|
|
57
92
|
}
|
|
58
93
|
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export declare const defaultFieldLevelConfig: ConfigOptions;
|
|
64
|
-
|
|
65
|
-
export { defaultStopTypes };
|
|
66
|
-
|
|
67
|
-
export declare const documentLevelPatch: (
|
|
68
|
-
docInfo: GTFile,
|
|
69
|
-
translatedFields: SanityDocument,
|
|
70
|
-
localeId: string,
|
|
71
|
-
client: SanityClient,
|
|
72
|
-
languageField?: string,
|
|
73
|
-
mergeWithTargetLocale?: boolean,
|
|
74
|
-
publish?: boolean
|
|
75
|
-
) => Promise<void>;
|
|
94
|
+
export declare function detachGTData(html: string): {
|
|
95
|
+
html: string;
|
|
96
|
+
data?: Record<'markDef', Record<string, any>>;
|
|
97
|
+
};
|
|
76
98
|
|
|
77
99
|
export declare type ExportForTranslation = (
|
|
78
100
|
documentInfo: GTFile,
|
|
79
|
-
context: TranslationFunctionContext
|
|
80
|
-
serializationOptions?: {
|
|
81
|
-
additionalStopTypes?: string[];
|
|
82
|
-
additionalSerializers?: Record<
|
|
83
|
-
string,
|
|
84
|
-
PortableTextTypeComponent | undefined
|
|
85
|
-
>;
|
|
86
|
-
},
|
|
87
|
-
languageField?: string
|
|
101
|
+
context: TranslationFunctionContext
|
|
88
102
|
) => Promise<GTSerializedDocument>;
|
|
89
103
|
|
|
90
|
-
export declare const fieldLevelPatch: (
|
|
91
|
-
docInfo: GTFile,
|
|
92
|
-
translatedFields: SanityDocument,
|
|
93
|
-
localeId: string,
|
|
94
|
-
client: SanityClient,
|
|
95
|
-
mergeWithTargetLocale?: boolean
|
|
96
|
-
) => Promise<void>;
|
|
97
|
-
|
|
98
104
|
export declare const findLatestDraft: (
|
|
99
105
|
documentId: string,
|
|
100
106
|
client: SanityClient
|
|
@@ -102,8 +108,6 @@ export declare const findLatestDraft: (
|
|
|
102
108
|
|
|
103
109
|
declare const gt: GT;
|
|
104
110
|
|
|
105
|
-
export declare const GTAdapter: Adapter;
|
|
106
|
-
|
|
107
111
|
declare type GTFile = {
|
|
108
112
|
documentId: string;
|
|
109
113
|
versionId?: string;
|
|
@@ -135,6 +139,10 @@ export declare type GTPluginConfig = Omit<
|
|
|
135
139
|
languageField?: string;
|
|
136
140
|
translateDocuments?: TranslateDocumentFilter[];
|
|
137
141
|
secretsNamespace?: string;
|
|
142
|
+
additionalStopTypes?: string[];
|
|
143
|
+
additionalSerializers?: Partial<PortableTextHtmlComponents>;
|
|
144
|
+
additionalDeserializers?: Record<string, any>;
|
|
145
|
+
additionalBlockDeserializers?: any[];
|
|
138
146
|
};
|
|
139
147
|
|
|
140
148
|
declare type GTSerializedDocument = Omit<SerializedDocument, 'name'> & GTFile;
|
|
@@ -152,18 +160,28 @@ export declare type ImportTranslation = (
|
|
|
152
160
|
localeId: string,
|
|
153
161
|
document: string,
|
|
154
162
|
context: TranslationFunctionContext,
|
|
155
|
-
serializationOptions?: {
|
|
156
|
-
additionalDeserializers?: Record<
|
|
157
|
-
string,
|
|
158
|
-
(value: HTMLElement) => TypedObject
|
|
159
|
-
>;
|
|
160
|
-
additionalBlockDeserializers?: DeserializerRule[];
|
|
161
|
-
},
|
|
162
|
-
languageField?: string,
|
|
163
163
|
mergeWithTargetLocale?: boolean,
|
|
164
164
|
publish?: boolean
|
|
165
165
|
) => Promise<void>;
|
|
166
166
|
|
|
167
|
+
declare interface Merger {
|
|
168
|
+
fieldLevelMerge: (
|
|
169
|
+
translatedFields: Record<string, any>,
|
|
170
|
+
baseDoc: SanityDocument,
|
|
171
|
+
localeId: string,
|
|
172
|
+
baseLang: string
|
|
173
|
+
) => Record<string, any>;
|
|
174
|
+
documentLevelMerge: (
|
|
175
|
+
translatedFields: Record<string, any>,
|
|
176
|
+
baseDoc: SanityDocument
|
|
177
|
+
) => Record<string, any>;
|
|
178
|
+
reconcileArray: (origArray: any[], translatedArray: any[]) => any[];
|
|
179
|
+
reconcileObject: (
|
|
180
|
+
origObject: Record<string, any>,
|
|
181
|
+
translatedObject: Record<string, any>
|
|
182
|
+
) => Record<string, any>;
|
|
183
|
+
}
|
|
184
|
+
|
|
167
185
|
export declare type Secrets = {
|
|
168
186
|
organization: string;
|
|
169
187
|
project: string;
|
|
@@ -174,7 +192,10 @@ export declare type Secrets = {
|
|
|
174
192
|
proxy?: string;
|
|
175
193
|
};
|
|
176
194
|
|
|
177
|
-
export
|
|
195
|
+
export declare type SerializedDocument = {
|
|
196
|
+
name: string;
|
|
197
|
+
content: string;
|
|
198
|
+
};
|
|
178
199
|
|
|
179
200
|
declare type TranslateDocumentFilter = {
|
|
180
201
|
documentId?: string;
|
|
@@ -186,6 +207,8 @@ export declare interface TranslationFunctionContext {
|
|
|
186
207
|
schema: Schema;
|
|
187
208
|
}
|
|
188
209
|
|
|
210
|
+
declare type TranslationLevel = 'document' | 'field';
|
|
211
|
+
|
|
189
212
|
declare type TranslationLocale = {
|
|
190
213
|
localeId: string;
|
|
191
214
|
description: string;
|
|
@@ -194,7 +217,7 @@ declare type TranslationLocale = {
|
|
|
194
217
|
|
|
195
218
|
export declare const TranslationsTab: (
|
|
196
219
|
props: TranslationTabProps
|
|
197
|
-
) => JSX.Element;
|
|
220
|
+
) => React_2.JSX.Element;
|
|
198
221
|
|
|
199
222
|
export declare type TranslationsTabConfigOptions = {
|
|
200
223
|
adapter: Adapter;
|
|
@@ -224,7 +247,6 @@ declare type TranslationTabProps = {
|
|
|
224
247
|
document: {
|
|
225
248
|
displayed: SanityDocument;
|
|
226
249
|
};
|
|
227
|
-
options: TranslationsTabConfigOptions;
|
|
228
250
|
};
|
|
229
251
|
|
|
230
252
|
declare type TranslationTask = {
|