|
1 | 1 | import { defineType, defineField } from 'sanity'; |
| 2 | +import type { ArrayFieldProps, ObjectFieldProps, Reference } from 'sanity'; |
2 | 3 | import { NodeTree } from '../../static/NodeTree'; |
3 | 4 | import { ArrayHierarchyInput, ReferenceHierarchyInput } from 'sanity-plugin-taxonomy-manager'; |
4 | 5 | import { branchFilter, schemeFilter } from 'sanity-plugin-taxonomy-manager'; |
@@ -40,95 +41,113 @@ export default defineType({ |
40 | 41 | filter: schemeFilter({ schemeId: schemeIdWithTop, expanded: false }), |
41 | 42 | disableNew: true, |
42 | 43 | // aiAssist:{ |
43 | | - // embeddingsIndex: 'io-taxonomy', |
44 | | - // }, |
45 | | - // embeddingsIndex: { |
46 | | - // indexName: 'io-taxonomy', |
47 | | - // maxResults: 10, |
48 | | - // searchMode: 'embeddings' |
49 | | - // } |
| 44 | + // embeddingsIndex: 'io-taxonomy', |
| 45 | + // }, |
| 46 | + // embeddingsIndex: { |
| 47 | + // indexName: 'io-taxonomy', |
| 48 | + // maxResults: 10, |
| 49 | + // searchMode: 'embeddings' |
| 50 | + // } |
| 51 | + }, |
| 52 | + components: { |
| 53 | + // field: ReferenceHierarchyInput |
| 54 | + field: (props: ObjectFieldProps<Reference>) => <ReferenceHierarchyInput |
| 55 | + {...props} |
| 56 | + embeddingsIndex={{ |
| 57 | + "indexName": "io-taxonomy", |
| 58 | + "fieldReferences": ["title", "metaDescription"], |
| 59 | + "maxResults": 4, |
| 60 | + }} /> |
| 61 | + }, |
| 62 | + }), |
| 63 | + defineField({ |
| 64 | + name: 'testField', |
| 65 | + type: 'text', |
| 66 | + title: 'Test Field', |
| 67 | + rows: 1, |
| 68 | + }), |
| 69 | + defineField({ |
| 70 | + name: 'singleTermFromSchemeNoTop', |
| 71 | + title: 'Single Term Reference from Scheme, No Top Concept', |
| 72 | + type: 'reference', |
| 73 | + to: [{ type: 'skosConcept' }], |
| 74 | + options: { |
| 75 | + filter: schemeFilter({ schemeId: schemeIdNoTop }), |
| 76 | + disableNew: true, |
| 77 | + }, |
| 78 | + components: { field: ReferenceHierarchyInput }, |
| 79 | + }), |
| 80 | + defineField({ |
| 81 | + name: 'singleTermFromBranchNoTop', |
| 82 | + title: 'Single Term Reference from Branch, No Top Concept', |
| 83 | + type: 'reference', |
| 84 | + to: [{ type: 'skosConcept' }], |
| 85 | + options: { |
| 86 | + filter: branchFilter({ schemeId: schemeIdNoTop, branchId: branchIdNoTop }), |
| 87 | + disableNew: true, |
| 88 | + }, |
| 89 | + components: { field: ReferenceHierarchyInput }, |
| 90 | + }), |
| 91 | + defineField({ |
| 92 | + name: 'singleTermFromBranch', |
| 93 | + title: 'Single Term Reference from Branch with Top Concept', |
| 94 | + type: 'reference', |
| 95 | + to: [{ type: 'skosConcept' }], |
| 96 | + options: { |
| 97 | + filter: branchFilter({ schemeId: schemeIdWithTop, branchId: branchIdWithTop }), |
| 98 | + disableNew: true, |
| 99 | + }, |
| 100 | + components: { field: ReferenceHierarchyInput }, |
| 101 | + }), |
| 102 | + defineField({ |
| 103 | + name: 'arrayFromScheme', |
| 104 | + title: 'Array of Terms from Scheme', |
| 105 | + type: 'array', |
| 106 | + of: [ |
| 107 | + { |
| 108 | + type: 'reference', |
| 109 | + to: { type: 'skosConcept' }, |
| 110 | + options: { |
| 111 | + filter: schemeFilter({ schemeId: schemeIdWithTop, expanded: true, browseOnly: true }), |
| 112 | + disableNew: true, |
| 113 | + }, |
50 | 114 | }, |
51 | | - components: { |
52 | | - field: ReferenceHierarchyInput |
53 | | - // (props) => <ReferenceHierarchyInput |
54 | | - // {...props} |
55 | | - // embeddingsIndex={{ |
56 | | - // "indexName": "io-taxonomy", |
57 | | - // "fieldReferences": ["title", "metaDescription"], |
58 | | - // "maxResults": 4, |
59 | | - // }} /> |
| 115 | + ], |
| 116 | + components: { |
| 117 | + // field: ArrayHierarchyInput |
| 118 | + field: (props: ArrayFieldProps) => <ArrayHierarchyInput |
| 119 | + {...props} |
| 120 | + embeddingsIndex={{ |
| 121 | + "indexName": "io-taxonomy", |
| 122 | + "fieldReferences": ["title", "metaDescription"], |
| 123 | + "maxResults": 4, |
| 124 | + }} /> |
| 125 | + }, |
| 126 | + }), |
| 127 | + defineField({ |
| 128 | + name: 'arrayFromBranch', |
| 129 | + title: 'Array of Terms from Branch', |
| 130 | + type: 'array', |
| 131 | + of: [ |
| 132 | + { |
| 133 | + type: 'reference', |
| 134 | + to: { type: 'skosConcept' }, |
| 135 | + options: { |
| 136 | + filter: branchFilter({ schemeId: schemeIdWithTop, branchId: branchIdWithTop }), |
| 137 | + disableNew: true, |
| 138 | + }, |
60 | 139 | }, |
61 | | - }), |
62 | | - defineField({ |
63 | | - name: 'testField', |
64 | | - type: 'text', |
65 | | - title: 'Test Field', |
66 | | - rows: 1, |
67 | | - }), |
68 | | - // defineField({ |
69 | | - // name: 'singleTermFromSchemeNoTop', |
70 | | - // title: 'Single Term Reference from Scheme, No Top Concept', |
71 | | - // type: 'reference', |
72 | | - // to: [{type: 'skosConcept'}], |
73 | | - // options: { |
74 | | - // filter: schemeFilter({schemeId: schemeIdNoTop}), |
75 | | - // disableNew: true, |
76 | | - // }, |
77 | | - // components: {field: ReferenceHierarchyInput}, |
78 | | - // }), |
79 | | - // defineField({ |
80 | | - // name: 'singleTermFromBranchNoTop', |
81 | | - // title: 'Single Term Reference from Branch, No Top Concept', |
82 | | - // type: 'reference', |
83 | | - // to: [{type: 'skosConcept'}], |
84 | | - // options: { |
85 | | - // filter: branchFilter({schemeId: schemeIdNoTop, branchId: branchIdNoTop}), |
86 | | - // disableNew: true, |
87 | | - // }, |
88 | | - // components: {field: ReferenceHierarchyInput}, |
89 | | - // }), |
90 | | - // defineField({ |
91 | | - // name: 'singleTermFromBranch', |
92 | | - // title: 'Single Term Reference from Branch with Top Concept', |
93 | | - // type: 'reference', |
94 | | - // to: [{type: 'skosConcept'}], |
95 | | - // options: { |
96 | | - // filter: branchFilter({schemeId: schemeIdWithTop, branchId: branchIdWithTop}), |
97 | | - // disableNew: true, |
98 | | - // }, |
99 | | - // components: {field: ReferenceHierarchyInput}, |
100 | | - // }), |
101 | | - // defineField({ |
102 | | - // name: 'arrayFromScheme', |
103 | | - // title: 'Array of Terms from Scheme', |
104 | | - // type: 'array', |
105 | | - // of: [ |
106 | | - // { |
107 | | - // type: 'reference', |
108 | | - // to: {type: 'skosConcept'}, |
109 | | - // options: { |
110 | | - // filter: schemeFilter({schemeId: schemeIdWithTop}), |
111 | | - // disableNew: true, |
112 | | - // }, |
113 | | - // }, |
114 | | - // ], |
115 | | - // components: {field: ArrayHierarchyInput}, |
116 | | - // }), |
117 | | - // defineField({ |
118 | | - // name: 'arrayFromBranch', |
119 | | - // title: 'Array of Terms from Branch', |
120 | | - // type: 'array', |
121 | | - // of: [ |
122 | | - // { |
123 | | - // type: 'reference', |
124 | | - // to: {type: 'skosConcept'}, |
125 | | - // options: { |
126 | | - // filter: branchFilter({schemeId: schemeIdWithTop, branchId: branchIdWithTop}), |
127 | | - // disableNew: true, |
128 | | - // }, |
129 | | - // }, |
130 | | - // ], |
131 | | - // components: {field: ArrayHierarchyInput}, |
132 | | - // }), |
| 140 | + ], |
| 141 | + components: { |
| 142 | + // field: ArrayHierarchyInput |
| 143 | + field: (props: ArrayFieldProps) => <ArrayHierarchyInput |
| 144 | + {...props} |
| 145 | + embeddingsIndex={{ |
| 146 | + "indexName": "io-taxonomy", |
| 147 | + "fieldReferences": ["title", "metaDescription"], |
| 148 | + "maxResults": 4, |
| 149 | + }} /> |
| 150 | + }, |
| 151 | + }), |
133 | 152 | ], |
134 | 153 | }); |
0 commit comments