@sanity/document-internationalization 4.1.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +11 -35
- package/dist/_chunks-es/{resources.mjs → resources.js} +1 -1
- package/dist/{_chunks-cjs → _chunks-es}/resources.js.map +1 -1
- package/dist/index.d.ts +57 -88
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +997 -1305
- package/dist/index.js.map +1 -1
- package/package.json +32 -70
- package/dist/_chunks-cjs/resources.js +0 -8
- package/dist/_chunks-es/resources.mjs.map +0 -1
- package/dist/_legacy/resources.esm.js +0 -9
- package/dist/_legacy/resources.esm.js.map +0 -1
- package/dist/index.d.mts +0 -108
- package/dist/index.esm.js +0 -1625
- package/dist/index.esm.js.map +0 -1
- package/dist/index.mjs +0 -1625
- package/dist/index.mjs.map +0 -1
- package/sanity.json +0 -8
- package/src/actions/DeleteMetadataAction.tsx +0 -93
- package/src/actions/DeleteTranslationAction.tsx +0 -102
- package/src/actions/DuplicateWithTranslationsAction.tsx +0 -251
- package/src/badges/index.tsx +0 -27
- package/src/components/BulkPublish/DocumentCheck.tsx +0 -90
- package/src/components/BulkPublish/Info.tsx +0 -28
- package/src/components/BulkPublish/InfoIcon.tsx +0 -34
- package/src/components/BulkPublish/index.tsx +0 -181
- package/src/components/ConstrainedBox.tsx +0 -6
- package/src/components/DeleteTranslationDialog/DocumentPreview.tsx +0 -19
- package/src/components/DeleteTranslationDialog/index.tsx +0 -111
- package/src/components/DeleteTranslationDialog/separateReferences.ts +0 -23
- package/src/components/DeleteTranslationFooter.tsx +0 -28
- package/src/components/DocumentInternationalizationContext.tsx +0 -47
- package/src/components/DocumentInternationalizationMenu.tsx +0 -235
- package/src/components/LanguageManage.tsx +0 -108
- package/src/components/LanguageOption.tsx +0 -259
- package/src/components/LanguagePatch.tsx +0 -67
- package/src/components/OptimisticallyStrengthen/ReferencePatcher.tsx +0 -50
- package/src/components/OptimisticallyStrengthen/index.tsx +0 -34
- package/src/components/Warning.tsx +0 -18
- package/src/constants.ts +0 -16
- package/src/hooks/useLanguageMetadata.tsx +0 -26
- package/src/hooks/useOpenInNewPane.tsx +0 -33
- package/src/i18n/index.ts +0 -21
- package/src/i18n/resources.ts +0 -7
- package/src/index.ts +0 -6
- package/src/plugin.tsx +0 -239
- package/src/schema/translation/metadata.ts +0 -68
- package/src/types.ts +0 -97
- package/src/utils/createReference.ts +0 -20
- package/src/utils/excludePaths.ts +0 -123
- package/v2-incompatible.js +0 -11
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# @sanity/document-internationalization
|
|
2
2
|
|
|
3
|
-
All new rewrite exclusively for Sanity Studio v3
|
|
4
|
-
|
|
5
3
|
- [@sanity/document-internationalization](#sanitydocument-internationalization)
|
|
6
4
|
- [What this plugin solves](#what-this-plugin-solves)
|
|
7
5
|
- [Many projects use both](#many-projects-use-both)
|
|
@@ -18,10 +16,6 @@ All new rewrite exclusively for Sanity Studio v3
|
|
|
18
16
|
- [Note on document quotas](#note-on-document-quotas)
|
|
19
17
|
- [Documentation](#documentation)
|
|
20
18
|
- [License](#license)
|
|
21
|
-
- [Develop \& test](#develop--test)
|
|
22
|
-
- [Release new version](#release-new-version)
|
|
23
|
-
|
|
24
|
-

|
|
25
19
|
|
|
26
20
|
## What this plugin solves
|
|
27
21
|
|
|
@@ -42,7 +36,7 @@ This plugin adds features to the Studio to improve handling **document-level tra
|
|
|
42
36
|
- Hooks and components to use throughout your custom components to handle translations
|
|
43
37
|
- Document Badges to highlight the language version of a document
|
|
44
38
|
|
|
45
|
-
For **field-level translations** you should use the [sanity-plugin-internationalized-array](https://github.com/sanity-io/sanity-plugin-internationalized-array).
|
|
39
|
+
For **field-level translations** you should use the [sanity-plugin-internationalized-array](https://github.com/sanity-io/plugins/tree/main/plugins/sanity-plugin-internationalized-array).
|
|
46
40
|
|
|
47
41
|
### Many projects use both
|
|
48
42
|
|
|
@@ -52,7 +46,7 @@ A good use of **field-level** translation could be a `person` schema. It could h
|
|
|
52
46
|
|
|
53
47
|
## Upgrade
|
|
54
48
|
|
|
55
|
-
|
|
49
|
+
If upgrading from a previous version (v1), please see the [upgrade documentation](https://github.com/sanity-io/document-internationalization/blob/main/docs/00-upgrade-from-v1.md) in the original repository.
|
|
56
50
|
|
|
57
51
|
## Install
|
|
58
52
|
|
|
@@ -234,10 +228,7 @@ Fortunately, the Sanity GraphQL API contains a similar filter for document refer
|
|
|
234
228
|
```graphql
|
|
235
229
|
# In this example we retrieve a lesson by its `slug.current` field value
|
|
236
230
|
query GetLesson($language: String!, $slug: String!) {
|
|
237
|
-
allLesson(
|
|
238
|
-
limit: 1
|
|
239
|
-
where: {language: {eq: $language}, slug: {current: {eq: $slug}}}
|
|
240
|
-
) {
|
|
231
|
+
allLesson(limit: 1, where: {language: {eq: $language}, slug: {current: {eq: $slug}}}) {
|
|
241
232
|
_id
|
|
242
233
|
title
|
|
243
234
|
language
|
|
@@ -273,31 +264,16 @@ This means if you have 100 documents and they are all translated into 3 language
|
|
|
273
264
|
|
|
274
265
|
## Documentation
|
|
275
266
|
|
|
276
|
-
For more advanced topics see the
|
|
267
|
+
For more advanced topics see the [original repository documentation](https://github.com/sanity-io/document-internationalization/tree/main/docs).
|
|
277
268
|
|
|
278
|
-
- [Upgrade from v1](
|
|
279
|
-
- [Creating translations of singleton documents](
|
|
280
|
-
- [Importing and creating documents](
|
|
281
|
-
- [Deleting translated documents](
|
|
282
|
-
- [Importing plugin components](
|
|
283
|
-
- [Allowing the same slug on different language versions](
|
|
284
|
-
- [Remove default new document template](
|
|
269
|
+
- [Upgrade from v1](https://github.com/sanity-io/document-internationalization/blob/main/docs/00-upgrade-from-v1.md)
|
|
270
|
+
- [Creating translations of singleton documents](https://github.com/sanity-io/document-internationalization/blob/main/docs/01-singleton-documents.md)
|
|
271
|
+
- [Importing and creating documents](https://github.com/sanity-io/document-internationalization/blob/main/docs/02-importing-and-creating-documents.md)
|
|
272
|
+
- [Deleting translated documents](https://github.com/sanity-io/document-internationalization/blob/main/docs/03-deleting-translated-documents.md)
|
|
273
|
+
- [Importing plugin components](https://github.com/sanity-io/document-internationalization/blob/main/docs/04-importing-plugin-components.md)
|
|
274
|
+
- [Allowing the same slug on different language versions](https://github.com/sanity-io/document-internationalization/blob/main/docs/05-allowing-the-same-slug-for-translations.md)
|
|
275
|
+
- [Remove default new document template](https://github.com/sanity-io/document-internationalization/blob/main/docs/06-remove-default-new-document-template.md)
|
|
285
276
|
|
|
286
277
|
## License
|
|
287
278
|
|
|
288
279
|
[MIT](LICENSE) © Sanity.io
|
|
289
|
-
|
|
290
|
-
## Develop & test
|
|
291
|
-
|
|
292
|
-
This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
|
|
293
|
-
with default configuration for build & watch scripts.
|
|
294
|
-
|
|
295
|
-
See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
|
|
296
|
-
on how to run this plugin with hot reload in the studio.
|
|
297
|
-
|
|
298
|
-
### Release new version
|
|
299
|
-
|
|
300
|
-
Run ["CI & Release" workflow](https://github.com/sanity-io/sanity-plugin-workflow/actions/workflows/main.yml).
|
|
301
|
-
Make sure to select the main branch and check "Release new version".
|
|
302
|
-
|
|
303
|
-
Semantic release will only release on configured branches, so it is safe to run the release on any branch.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sources":["../../src/i18n/resources.ts"],"sourcesContent":["export default {\n 'action.duplicate.label': 'Duplicate with translations',\n 'action.duplicate.disabled.missing-metadata':\n 'The document cannot be duplicated because the metadata document is missing',\n 'action.duplicate.disabled.multiple-metadata':\n 'The document cannot be duplicated because there are multiple metadata documents',\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resources.js","sources":["../../src/i18n/resources.ts"],"sourcesContent":["export default {\n 'action.duplicate.label': 'Duplicate with translations',\n 'action.duplicate.disabled.missing-metadata':\n 'The document cannot be duplicated because the metadata document is missing',\n 'action.duplicate.disabled.multiple-metadata':\n 'The document cannot be duplicated because there are multiple metadata documents',\n}\n"],"names":[],"mappings":"AAAA,IAAA,YAAe;AAAA,EACb,0BAA0B;AAAA,EAC1B,8CACE;AAAA,EACF,+CACE;AACJ;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,92 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import * as sanity0 from "sanity";
|
|
2
|
+
import { DocumentActionComponent, FieldDefinition, KeyedObject, ObjectSchemaType, Reference, SanityClient, SanityDocument, SanityDocumentLike } from "sanity";
|
|
3
|
+
declare const DeleteTranslationAction: DocumentActionComponent;
|
|
4
|
+
declare const DuplicateWithTranslationsAction: DocumentActionComponent;
|
|
5
|
+
type Language = {
|
|
6
|
+
id: Intl.UnicodeBCP47LocaleIdentifier;
|
|
7
|
+
title: string;
|
|
8
|
+
};
|
|
9
|
+
type SupportedLanguages = Language[] | ((client: SanityClient) => Promise<Language[]>);
|
|
10
|
+
type PluginCallbackArgs = {
|
|
11
|
+
sourceDocument: SanityDocument;
|
|
12
|
+
newDocument: SanityDocument;
|
|
13
|
+
sourceLanguageId: string;
|
|
14
|
+
destinationLanguageId: string;
|
|
15
|
+
metaDocumentId: string;
|
|
16
|
+
client: SanityClient;
|
|
17
|
+
};
|
|
18
|
+
type PluginConfig = {
|
|
19
|
+
supportedLanguages: SupportedLanguages;
|
|
20
|
+
schemaTypes: string[];
|
|
21
|
+
languageField?: string;
|
|
22
|
+
weakReferences?: boolean;
|
|
23
|
+
bulkPublish?: boolean;
|
|
24
|
+
metadataFields?: FieldDefinition[];
|
|
25
|
+
apiVersion?: string;
|
|
26
|
+
allowCreateMetaDoc?: boolean;
|
|
27
|
+
callback?: ((args: PluginCallbackArgs) => Promise<void>) | null;
|
|
28
|
+
};
|
|
29
|
+
type PluginConfigContext = Required<PluginConfig> & {
|
|
30
|
+
supportedLanguages: Language[];
|
|
31
|
+
};
|
|
32
|
+
type TranslationReference = KeyedObject & {
|
|
33
|
+
_type: 'internationalizedArrayReferenceValue';
|
|
34
|
+
value: Reference;
|
|
35
|
+
};
|
|
36
|
+
type Metadata = {
|
|
37
|
+
_id: string;
|
|
38
|
+
_createdAt: string;
|
|
39
|
+
translations: TranslationReference[];
|
|
40
|
+
};
|
|
41
|
+
type MetadataDocument = SanityDocumentLike & {
|
|
42
|
+
schemaTypes: string[];
|
|
43
|
+
translations: TranslationReference[];
|
|
44
|
+
};
|
|
45
|
+
type DocumentInternationalizationMenuProps = {
|
|
46
|
+
schemaType: ObjectSchemaType;
|
|
47
|
+
documentId: string;
|
|
48
|
+
};
|
|
49
|
+
interface DocumentInternationalizationSchemaOpts {
|
|
28
50
|
documentInternationalization?: {
|
|
29
|
-
/** Set to true to disable duplication of this field or type */
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export declare const DuplicateWithTranslationsAction: DocumentActionComponent
|
|
35
|
-
|
|
36
|
-
export declare type Language = {
|
|
37
|
-
id: Intl.UnicodeBCP47LocaleIdentifier
|
|
38
|
-
title: string
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export declare type Metadata = {
|
|
42
|
-
_id: string
|
|
43
|
-
_createdAt: string
|
|
44
|
-
translations: TranslationReference[]
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export declare type MetadataDocument = SanityDocumentLike & {
|
|
48
|
-
schemaTypes: string[]
|
|
49
|
-
translations: TranslationReference[]
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export declare type PluginCallbackArgs = {
|
|
53
|
-
sourceDocument: SanityDocument
|
|
54
|
-
newDocument: SanityDocument
|
|
55
|
-
sourceLanguageId: string
|
|
56
|
-
destinationLanguageId: string
|
|
57
|
-
metaDocumentId: string
|
|
58
|
-
client: SanityClient
|
|
51
|
+
/** Set to true to disable duplication of this field or type */exclude?: boolean;
|
|
52
|
+
};
|
|
59
53
|
}
|
|
60
|
-
|
|
61
|
-
export declare type PluginConfig = {
|
|
62
|
-
supportedLanguages: SupportedLanguages
|
|
63
|
-
schemaTypes: string[]
|
|
64
|
-
languageField?: string
|
|
65
|
-
weakReferences?: boolean
|
|
66
|
-
bulkPublish?: boolean
|
|
67
|
-
metadataFields?: FieldDefinition[]
|
|
68
|
-
apiVersion?: string
|
|
69
|
-
allowCreateMetaDoc?: boolean
|
|
70
|
-
callback?: ((args: PluginCallbackArgs) => Promise<void>) | null
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export declare type PluginConfigContext = Required<PluginConfig> & {
|
|
74
|
-
supportedLanguages: Language[]
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export declare type SupportedLanguages =
|
|
78
|
-
| Language[]
|
|
79
|
-
| ((client: SanityClient) => Promise<Language[]>)
|
|
80
|
-
|
|
81
|
-
export declare type TranslationReference = KeyedObject & {
|
|
82
|
-
_type: 'internationalizedArrayReferenceValue'
|
|
83
|
-
value: Reference
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export declare function useDocumentInternationalizationContext(): PluginConfigContext
|
|
87
|
-
|
|
88
|
-
export {}
|
|
89
|
-
|
|
90
54
|
declare module 'sanity' {
|
|
91
55
|
interface ArrayOptions extends DocumentInternationalizationSchemaOpts {}
|
|
92
56
|
interface BlockOptions extends DocumentInternationalizationSchemaOpts {}
|
|
@@ -105,4 +69,9 @@ declare module 'sanity' {
|
|
|
105
69
|
interface TextOptions extends DocumentInternationalizationSchemaOpts {}
|
|
106
70
|
interface UrlOptions extends DocumentInternationalizationSchemaOpts {}
|
|
107
71
|
interface EmailOptions extends DocumentInternationalizationSchemaOpts {}
|
|
108
|
-
}
|
|
72
|
+
} //# sourceMappingURL=types.d.ts.map
|
|
73
|
+
declare function useDocumentInternationalizationContext(): PluginConfigContext;
|
|
74
|
+
declare function DocumentInternationalizationMenu(props: DocumentInternationalizationMenuProps): React.JSX.Element | null;
|
|
75
|
+
declare const documentInternationalization: sanity0.Plugin<PluginConfig>;
|
|
76
|
+
export { DeleteTranslationAction, DocumentInternationalizationMenu, DocumentInternationalizationMenuProps, DocumentInternationalizationSchemaOpts, DuplicateWithTranslationsAction, Language, Metadata, MetadataDocument, PluginCallbackArgs, PluginConfig, PluginConfigContext, SupportedLanguages, TranslationReference, documentInternationalization, useDocumentInternationalizationContext };
|
|
77
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/actions/DeleteTranslationAction.tsx","../src/actions/DuplicateWithTranslationsAction.tsx","../src/types.ts","../src/components/DocumentInternationalizationContext.tsx","../src/components/DocumentInternationalizationMenu.tsx","../src/plugin.tsx"],"mappings":";;cAUa,uBAAA,EAAyB,uBAAA;AAAA,cCiCzB,+BAAA,EAAiC,uBAAA;AAAA,KCjClC,QAAA;EACV,EAAA,EAAI,IAAA,CAAK,4BAAA;EACT,KAAA;AAAA;AAAA,KAGU,kBAAA,GAAqB,QAAA,OAAe,MAAA,EAAQ,YAAA,KAAiB,OAAA,CAAQ,QAAA;AAAA,KAErE,kBAAA;EACV,cAAA,EAAgB,cAAA;EAChB,WAAA,EAAa,cAAA;EACb,gBAAA;EACA,qBAAA;EACA,cAAA;EACA,MAAA,EAAQ,YAAA;AAAA;AAAA,KAGE,YAAA;EACV,kBAAA,EAAoB,kBAAA;EACpB,WAAA;EACA,aAAA;EACA,cAAA;EACA,WAAA;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