@sanity/assist 1.2.6 → 1.2.8
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.esm.js +7 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/fieldActions/assistFieldActions.tsx +5 -1
- package/src/plugin.tsx +4 -1
- package/src/schemas/serialize/serializeSchema.test.ts +49 -0
- package/src/schemas/serialize/serializeSchema.ts +2 -1
package/dist/index.js
CHANGED
|
@@ -179,7 +179,7 @@ function isUnsupportedType(type) {
|
|
|
179
179
|
}
|
|
180
180
|
const inlineTypes = ["document", "object", "image", "file"];
|
|
181
181
|
function serializeSchema(schema, options) {
|
|
182
|
-
const list = schema.getTypeNames().filter(t => !(hiddenTypes.includes(t) || t.startsWith("sanity."))).map(t => schema.get(t)).filter(t => !!t).filter(t => !t.hidden && !t.readOnly).map(t => getSchemaStub(t, schema, options)).filter(t => {
|
|
182
|
+
const list = schema.getTypeNames().filter(t => !(hiddenTypes.includes(t) || t.startsWith("sanity."))).map(t => schema.get(t)).filter(t => !!t).filter(t => isAssistSupported(t)).filter(t => !t.hidden && !t.readOnly).map(t => getSchemaStub(t, schema, options)).filter(t => {
|
|
183
183
|
if ("to" in t && t.to && !t.to.length) {
|
|
184
184
|
return false;
|
|
185
185
|
}
|
|
@@ -223,7 +223,7 @@ function getBaseFields(schema, type, typeName, options) {
|
|
|
223
223
|
options: imagePromptField ? {
|
|
224
224
|
imagePromptField
|
|
225
225
|
} : void 0,
|
|
226
|
-
values: ((_b = type == null ? void 0 : type.options) == null ? void 0 : _b.list) ? (_c = type == null ? void 0 : type.options) == null ? void 0 : _c.list.map(v => {
|
|
226
|
+
values: Array.isArray((_b = type == null ? void 0 : type.options) == null ? void 0 : _b.list) ? (_c = type == null ? void 0 : type.options) == null ? void 0 : _c.list.map(v => {
|
|
227
227
|
var _a2;
|
|
228
228
|
return typeof v === "string" ? v : (_a2 = v.value) != null ? _a2 : "".concat(v.title);
|
|
229
229
|
}) : void 0,
|
|
@@ -4435,7 +4435,7 @@ const assistFieldActions = {
|
|
|
4435
4435
|
isDocAssistable: documentIsAssistable != null ? documentIsAssistable : false
|
|
4436
4436
|
});
|
|
4437
4437
|
const isSelectable = !!useSelectedField(documentSchemaType, typePath);
|
|
4438
|
-
const assistSupported = useAssistSupported(props.path, schemaType) && isSelectable;
|
|
4438
|
+
const assistSupported = useAssistSupported(props.path, schemaType) && isSelectable && isSchemaAssistEnabled(documentSchemaType);
|
|
4439
4439
|
const fieldAssist = react.useMemo(() => {
|
|
4440
4440
|
var _a;
|
|
4441
4441
|
return ((_a = assistDocument == null ? void 0 : assistDocument.fields) != null ? _a : []).find(f => f.path === typePath || pathKey === documentRootKey && f.path === pathKey);
|
|
@@ -4727,7 +4727,10 @@ const assist = sanity.definePlugin(config => {
|
|
|
4727
4727
|
schemaType
|
|
4728
4728
|
} = _ref17;
|
|
4729
4729
|
const docSchema = schema.get(schemaType);
|
|
4730
|
-
|
|
4730
|
+
if (isSchemaAssistEnabled(docSchema)) {
|
|
4731
|
+
return [...prev, createAssistDocumentPresence(documentId, docSchema)];
|
|
4732
|
+
}
|
|
4733
|
+
return prev;
|
|
4731
4734
|
}
|
|
4732
4735
|
},
|
|
4733
4736
|
studio: {
|