sanity-plugin-studio-smartling 1.1.6 → 1.4.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/dist/adapter/createTask.d.ts +1 -1
- package/dist/helpers.d.ts +5 -0
- package/dist/index.d.ts +4 -4
- package/dist/sanity-plugin-studio-smartling.cjs.development.js +296 -28
- package/dist/sanity-plugin-studio-smartling.cjs.development.js.map +1 -1
- package/dist/sanity-plugin-studio-smartling.cjs.production.min.js +1 -1
- package/dist/sanity-plugin-studio-smartling.cjs.production.min.js.map +1 -1
- package/dist/sanity-plugin-studio-smartling.esm.js +294 -28
- package/dist/sanity-plugin-studio-smartling.esm.js.map +1 -1
- package/package.json +4 -4
- package/src/3rdparty-typings/sanity-parts.d.ts +1 -0
- package/src/adapter/createTask.ts +27 -8
- package/src/adapter/getTranslationTask.ts +1 -1
- package/src/helpers.ts +116 -0
- package/src/index.ts +24 -28
package/src/index.ts
CHANGED
|
@@ -2,48 +2,44 @@ import { TranslationsTab } from 'sanity-translations-tab'
|
|
|
2
2
|
import {
|
|
3
3
|
BaseDocumentDeserializer,
|
|
4
4
|
BaseDocumentSerializer,
|
|
5
|
-
|
|
5
|
+
BaseDocumentMerger,
|
|
6
6
|
defaultStopTypes,
|
|
7
7
|
customSerializers,
|
|
8
8
|
} from 'sanity-naive-html-serializer'
|
|
9
9
|
import { SmartlingAdapter } from './adapter'
|
|
10
|
+
import { findLatestDraft, documentLevelPatch, fieldLevelPatch } from './helpers'
|
|
11
|
+
import { SanityDocument } from '@sanity/types'
|
|
10
12
|
|
|
11
13
|
const defaultDocumentLevelConfig = {
|
|
12
|
-
exportForTranslation: (id: string) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
),
|
|
14
|
+
exportForTranslation: async (id: string) => {
|
|
15
|
+
const doc = await findLatestDraft(id)
|
|
16
|
+
const serialized = BaseDocumentSerializer.serializeDocument(doc, 'document')
|
|
17
|
+
//needed for lookup by translation tab
|
|
18
|
+
serialized.name = id
|
|
19
|
+
return serialized
|
|
20
|
+
},
|
|
20
21
|
importTranslation: (id: string, localeId: string, document: string) => {
|
|
21
|
-
|
|
22
|
-
id,
|
|
22
|
+
const deserialized = BaseDocumentDeserializer.deserializeDocument(
|
|
23
23
|
document
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
)
|
|
24
|
+
) as SanityDocument
|
|
25
|
+
documentLevelPatch(id, deserialized, localeId)
|
|
27
26
|
},
|
|
28
27
|
adapter: SmartlingAdapter,
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
const defaultFieldLevelConfig = {
|
|
32
|
-
exportForTranslation: (id: string) =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
),
|
|
31
|
+
exportForTranslation: async (id: string) => {
|
|
32
|
+
const doc = await findLatestDraft(id)
|
|
33
|
+
const serialized = BaseDocumentSerializer.serializeDocument(doc, 'field')
|
|
34
|
+
//needed for lookup by translation tab
|
|
35
|
+
serialized.name = id
|
|
36
|
+
return serialized
|
|
37
|
+
},
|
|
40
38
|
importTranslation: (id: string, localeId: string, document: string) => {
|
|
41
|
-
|
|
42
|
-
id,
|
|
39
|
+
const deserialized = BaseDocumentDeserializer.deserializeDocument(
|
|
43
40
|
document
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
)
|
|
41
|
+
) as SanityDocument
|
|
42
|
+
fieldLevelPatch(id, deserialized, localeId)
|
|
47
43
|
},
|
|
48
44
|
adapter: SmartlingAdapter,
|
|
49
45
|
}
|
|
@@ -52,7 +48,7 @@ export {
|
|
|
52
48
|
TranslationsTab,
|
|
53
49
|
BaseDocumentDeserializer,
|
|
54
50
|
BaseDocumentSerializer,
|
|
55
|
-
|
|
51
|
+
BaseDocumentMerger,
|
|
56
52
|
defaultStopTypes,
|
|
57
53
|
customSerializers,
|
|
58
54
|
SmartlingAdapter,
|