gt-sanity 2.0.2 → 2.0.3
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.d.mts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +56 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/src/documentInternationalization.ts +14 -0
- package/src/index.ts +55 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { DeserializerRule } from '@portabletext/block-tools';
|
|
2
2
|
import { DocumentActionComponent } from 'sanity';
|
|
3
|
+
import { documentInternationalization } from '@sanity/document-internationalization';
|
|
4
|
+
import { PluginConfig as DocumentInternationalizationConfig } from '@sanity/document-internationalization';
|
|
5
|
+
import { DocumentInternationalizationMenu } from '@sanity/document-internationalization';
|
|
3
6
|
import { GT } from 'generaltranslation';
|
|
7
|
+
import { Language } from '@sanity/document-internationalization';
|
|
8
|
+
import { Metadata } from '@sanity/document-internationalization';
|
|
4
9
|
import { ObjectField } from 'sanity';
|
|
5
10
|
import { Plugin as Plugin_2 } from 'sanity';
|
|
6
11
|
import { PortableTextHtmlComponents } from '@portabletext/to-html';
|
|
@@ -9,7 +14,11 @@ import { default as React_2 } from 'react';
|
|
|
9
14
|
import { SanityClient } from 'sanity';
|
|
10
15
|
import { SanityDocument } from 'sanity';
|
|
11
16
|
import { Schema } from 'sanity';
|
|
17
|
+
import { TranslationReference } from '@sanity/document-internationalization';
|
|
12
18
|
import { TypedObject } from 'sanity';
|
|
19
|
+
import { useDeleteTranslationAction } from '@sanity/document-internationalization';
|
|
20
|
+
import { useDocumentInternationalizationContext } from '@sanity/document-internationalization';
|
|
21
|
+
import { useDuplicateWithTranslationsAction } from '@sanity/document-internationalization';
|
|
13
22
|
|
|
14
23
|
export declare interface Adapter {
|
|
15
24
|
getLocales: (secrets: Secrets | null) => Promise<TranslationLocale[]>;
|
|
@@ -97,6 +106,12 @@ export declare function detachGTData(html: string): {
|
|
|
97
106
|
data?: Record<'markDef', Record<string, any>>;
|
|
98
107
|
};
|
|
99
108
|
|
|
109
|
+
export { documentInternationalization };
|
|
110
|
+
|
|
111
|
+
export { DocumentInternationalizationConfig };
|
|
112
|
+
|
|
113
|
+
export { DocumentInternationalizationMenu };
|
|
114
|
+
|
|
100
115
|
export declare type ExportForTranslation = (
|
|
101
116
|
documentInfo: GTFile,
|
|
102
117
|
context: TranslationFunctionContext
|
|
@@ -140,12 +155,13 @@ export declare type GTPluginConfig = Omit<
|
|
|
140
155
|
ignoreFields?: IgnoreFields[];
|
|
141
156
|
skipFields?: SkipFields[];
|
|
142
157
|
languageField?: string;
|
|
143
|
-
translateDocuments?: TranslateDocumentFilter[];
|
|
158
|
+
translateDocuments?: TranslateDocumentFilter[] | string[];
|
|
144
159
|
secretsNamespace?: string;
|
|
145
160
|
additionalStopTypes?: string[];
|
|
146
161
|
additionalSerializers?: Partial<PortableTextHtmlComponents>;
|
|
147
162
|
additionalDeserializers?: Record<string, any>;
|
|
148
163
|
additionalBlockDeserializers?: any[];
|
|
164
|
+
showDocumentInternationalization?: boolean;
|
|
149
165
|
};
|
|
150
166
|
|
|
151
167
|
declare type GTSerializedDocument = Omit<SerializedDocument, 'name'> & GTFile;
|
|
@@ -167,6 +183,8 @@ export declare type ImportTranslation = (
|
|
|
167
183
|
publish?: boolean
|
|
168
184
|
) => Promise<void>;
|
|
169
185
|
|
|
186
|
+
export { Language };
|
|
187
|
+
|
|
170
188
|
declare interface Merger {
|
|
171
189
|
fieldLevelMerge: (
|
|
172
190
|
translatedFields: Record<string, any>,
|
|
@@ -185,6 +203,8 @@ declare interface Merger {
|
|
|
185
203
|
) => Record<string, any>;
|
|
186
204
|
}
|
|
187
205
|
|
|
206
|
+
export { Metadata };
|
|
207
|
+
|
|
188
208
|
export declare type Secrets = {
|
|
189
209
|
organization: string;
|
|
190
210
|
project: string;
|
|
@@ -228,6 +248,8 @@ declare type TranslationLocale = {
|
|
|
228
248
|
enabled?: boolean;
|
|
229
249
|
};
|
|
230
250
|
|
|
251
|
+
export { TranslationReference };
|
|
252
|
+
|
|
231
253
|
export declare const TranslationsTab: (
|
|
232
254
|
props: TranslationTabProps
|
|
233
255
|
) => React_2.JSX.Element;
|
|
@@ -273,6 +295,12 @@ declare type TranslationTaskLocaleStatus = {
|
|
|
273
295
|
progress: number;
|
|
274
296
|
};
|
|
275
297
|
|
|
298
|
+
export { useDeleteTranslationAction };
|
|
299
|
+
|
|
300
|
+
export { useDocumentInternationalizationContext };
|
|
301
|
+
|
|
302
|
+
export { useDuplicateWithTranslationsAction };
|
|
303
|
+
|
|
276
304
|
declare type WorkflowIdentifiers = {
|
|
277
305
|
workflowUid: string;
|
|
278
306
|
workflowName: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { DeserializerRule } from '@portabletext/block-tools';
|
|
2
2
|
import { DocumentActionComponent } from 'sanity';
|
|
3
|
+
import { documentInternationalization } from '@sanity/document-internationalization';
|
|
4
|
+
import { PluginConfig as DocumentInternationalizationConfig } from '@sanity/document-internationalization';
|
|
5
|
+
import { DocumentInternationalizationMenu } from '@sanity/document-internationalization';
|
|
3
6
|
import { GT } from 'generaltranslation';
|
|
7
|
+
import { Language } from '@sanity/document-internationalization';
|
|
8
|
+
import { Metadata } from '@sanity/document-internationalization';
|
|
4
9
|
import { ObjectField } from 'sanity';
|
|
5
10
|
import { Plugin as Plugin_2 } from 'sanity';
|
|
6
11
|
import { PortableTextHtmlComponents } from '@portabletext/to-html';
|
|
@@ -9,7 +14,11 @@ import { default as React_2 } from 'react';
|
|
|
9
14
|
import { SanityClient } from 'sanity';
|
|
10
15
|
import { SanityDocument } from 'sanity';
|
|
11
16
|
import { Schema } from 'sanity';
|
|
17
|
+
import { TranslationReference } from '@sanity/document-internationalization';
|
|
12
18
|
import { TypedObject } from 'sanity';
|
|
19
|
+
import { useDeleteTranslationAction } from '@sanity/document-internationalization';
|
|
20
|
+
import { useDocumentInternationalizationContext } from '@sanity/document-internationalization';
|
|
21
|
+
import { useDuplicateWithTranslationsAction } from '@sanity/document-internationalization';
|
|
13
22
|
|
|
14
23
|
export declare interface Adapter {
|
|
15
24
|
getLocales: (secrets: Secrets | null) => Promise<TranslationLocale[]>;
|
|
@@ -97,6 +106,12 @@ export declare function detachGTData(html: string): {
|
|
|
97
106
|
data?: Record<'markDef', Record<string, any>>;
|
|
98
107
|
};
|
|
99
108
|
|
|
109
|
+
export { documentInternationalization };
|
|
110
|
+
|
|
111
|
+
export { DocumentInternationalizationConfig };
|
|
112
|
+
|
|
113
|
+
export { DocumentInternationalizationMenu };
|
|
114
|
+
|
|
100
115
|
export declare type ExportForTranslation = (
|
|
101
116
|
documentInfo: GTFile,
|
|
102
117
|
context: TranslationFunctionContext
|
|
@@ -140,12 +155,13 @@ export declare type GTPluginConfig = Omit<
|
|
|
140
155
|
ignoreFields?: IgnoreFields[];
|
|
141
156
|
skipFields?: SkipFields[];
|
|
142
157
|
languageField?: string;
|
|
143
|
-
translateDocuments?: TranslateDocumentFilter[];
|
|
158
|
+
translateDocuments?: TranslateDocumentFilter[] | string[];
|
|
144
159
|
secretsNamespace?: string;
|
|
145
160
|
additionalStopTypes?: string[];
|
|
146
161
|
additionalSerializers?: Partial<PortableTextHtmlComponents>;
|
|
147
162
|
additionalDeserializers?: Record<string, any>;
|
|
148
163
|
additionalBlockDeserializers?: any[];
|
|
164
|
+
showDocumentInternationalization?: boolean;
|
|
149
165
|
};
|
|
150
166
|
|
|
151
167
|
declare type GTSerializedDocument = Omit<SerializedDocument, 'name'> & GTFile;
|
|
@@ -167,6 +183,8 @@ export declare type ImportTranslation = (
|
|
|
167
183
|
publish?: boolean
|
|
168
184
|
) => Promise<void>;
|
|
169
185
|
|
|
186
|
+
export { Language };
|
|
187
|
+
|
|
170
188
|
declare interface Merger {
|
|
171
189
|
fieldLevelMerge: (
|
|
172
190
|
translatedFields: Record<string, any>,
|
|
@@ -185,6 +203,8 @@ declare interface Merger {
|
|
|
185
203
|
) => Record<string, any>;
|
|
186
204
|
}
|
|
187
205
|
|
|
206
|
+
export { Metadata };
|
|
207
|
+
|
|
188
208
|
export declare type Secrets = {
|
|
189
209
|
organization: string;
|
|
190
210
|
project: string;
|
|
@@ -228,6 +248,8 @@ declare type TranslationLocale = {
|
|
|
228
248
|
enabled?: boolean;
|
|
229
249
|
};
|
|
230
250
|
|
|
251
|
+
export { TranslationReference };
|
|
252
|
+
|
|
231
253
|
export declare const TranslationsTab: (
|
|
232
254
|
props: TranslationTabProps
|
|
233
255
|
) => React_2.JSX.Element;
|
|
@@ -273,6 +295,12 @@ declare type TranslationTaskLocaleStatus = {
|
|
|
273
295
|
progress: number;
|
|
274
296
|
};
|
|
275
297
|
|
|
298
|
+
export { useDeleteTranslationAction };
|
|
299
|
+
|
|
300
|
+
export { useDocumentInternationalizationContext };
|
|
301
|
+
|
|
302
|
+
export { useDuplicateWithTranslationsAction };
|
|
303
|
+
|
|
276
304
|
declare type WorkflowIdentifiers = {
|
|
277
305
|
workflowUid: string;
|
|
278
306
|
workflowName: string;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var 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");
|
|
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
4
|
function _interopDefaultCompat(e) {
|
|
5
5
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
6
|
}
|
|
@@ -3703,10 +3703,12 @@ const WrapText = dt(ui.Box)`
|
|
|
3703
3703
|
additionalStopTypes = [],
|
|
3704
3704
|
additionalSerializers = {},
|
|
3705
3705
|
additionalDeserializers = {},
|
|
3706
|
-
additionalBlockDeserializers = []
|
|
3706
|
+
additionalBlockDeserializers = [],
|
|
3707
|
+
showDocumentInternationalization = !0
|
|
3707
3708
|
}) => {
|
|
3708
3709
|
const resolvedSourceLocale = sourceLocale ?? defaultLocale ?? internal.libraryDefaultLocale;
|
|
3709
|
-
|
|
3710
|
+
let normalizedTranslateDocuments;
|
|
3711
|
+
translateDocuments && (normalizedTranslateDocuments = translateDocuments.map((entry) => typeof entry == "string" ? { type: entry } : entry).filter((filter2) => filter2.documentId || filter2.type)), pluginConfig.init(
|
|
3710
3712
|
secretsNamespace,
|
|
3711
3713
|
languageField,
|
|
3712
3714
|
resolvedSourceLocale,
|
|
@@ -3716,7 +3718,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3716
3718
|
singletonMapping || ((sourceDocumentId, locale) => `${sourceDocumentId}-${locale}`),
|
|
3717
3719
|
ignoreFields || [],
|
|
3718
3720
|
skipFields || [],
|
|
3719
|
-
|
|
3721
|
+
normalizedTranslateDocuments || [],
|
|
3720
3722
|
additionalStopTypes,
|
|
3721
3723
|
additionalSerializers,
|
|
3722
3724
|
additionalDeserializers,
|
|
@@ -3726,8 +3728,27 @@ const WrapText = dt(ui.Box)`
|
|
|
3726
3728
|
customMapping,
|
|
3727
3729
|
apiKey,
|
|
3728
3730
|
projectId
|
|
3729
|
-
})
|
|
3731
|
+
});
|
|
3732
|
+
const plugins = [];
|
|
3733
|
+
if (showDocumentInternationalization) {
|
|
3734
|
+
const schemaTypes = normalizedTranslateDocuments?.map((filter2) => filter2.type).filter((type) => !!type) ?? [];
|
|
3735
|
+
if (schemaTypes.length > 0) {
|
|
3736
|
+
const supportedLanguages = [resolvedSourceLocale, ...locales].map((locale) => {
|
|
3737
|
+
const props = generaltranslation.getLocaleProperties(locale, resolvedSourceLocale);
|
|
3738
|
+
return { id: locale, title: props.name };
|
|
3739
|
+
});
|
|
3740
|
+
plugins.push(
|
|
3741
|
+
documentInternationalization.documentInternationalization({
|
|
3742
|
+
supportedLanguages,
|
|
3743
|
+
schemaTypes,
|
|
3744
|
+
languageField
|
|
3745
|
+
})
|
|
3746
|
+
);
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3749
|
+
return {
|
|
3730
3750
|
name: "gt-sanity",
|
|
3751
|
+
plugins,
|
|
3731
3752
|
tools: [
|
|
3732
3753
|
{
|
|
3733
3754
|
name: "translations",
|
|
@@ -3742,6 +3763,36 @@ const WrapText = dt(ui.Box)`
|
|
|
3742
3763
|
};
|
|
3743
3764
|
}
|
|
3744
3765
|
);
|
|
3766
|
+
Object.defineProperty(exports, "DocumentInternationalizationMenu", {
|
|
3767
|
+
enumerable: !0,
|
|
3768
|
+
get: function() {
|
|
3769
|
+
return documentInternationalization.DocumentInternationalizationMenu;
|
|
3770
|
+
}
|
|
3771
|
+
});
|
|
3772
|
+
Object.defineProperty(exports, "documentInternationalization", {
|
|
3773
|
+
enumerable: !0,
|
|
3774
|
+
get: function() {
|
|
3775
|
+
return documentInternationalization.documentInternationalization;
|
|
3776
|
+
}
|
|
3777
|
+
});
|
|
3778
|
+
Object.defineProperty(exports, "useDeleteTranslationAction", {
|
|
3779
|
+
enumerable: !0,
|
|
3780
|
+
get: function() {
|
|
3781
|
+
return documentInternationalization.useDeleteTranslationAction;
|
|
3782
|
+
}
|
|
3783
|
+
});
|
|
3784
|
+
Object.defineProperty(exports, "useDocumentInternationalizationContext", {
|
|
3785
|
+
enumerable: !0,
|
|
3786
|
+
get: function() {
|
|
3787
|
+
return documentInternationalization.useDocumentInternationalizationContext;
|
|
3788
|
+
}
|
|
3789
|
+
});
|
|
3790
|
+
Object.defineProperty(exports, "useDuplicateWithTranslationsAction", {
|
|
3791
|
+
enumerable: !0,
|
|
3792
|
+
get: function() {
|
|
3793
|
+
return documentInternationalization.useDuplicateWithTranslationsAction;
|
|
3794
|
+
}
|
|
3795
|
+
});
|
|
3745
3796
|
exports.BaseDocumentDeserializer = BaseDocumentDeserializer;
|
|
3746
3797
|
exports.BaseDocumentMerger = BaseDocumentMerger;
|
|
3747
3798
|
exports.BaseDocumentSerializer = BaseDocumentSerializer;
|