From 8d74ace917651a307acd61198f09b5050289f55f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rge=20N=C3=A6ss?= Date: Tue, 20 Dec 2022 12:58:06 +0100 Subject: [PATCH] fix(schema): add help id to blockeditor schema warnings --- .../src/sanity/validation/createValidationResult.ts | 1 + .../schema/src/sanity/validation/types/block.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/@sanity/schema/src/sanity/validation/createValidationResult.ts b/packages/@sanity/schema/src/sanity/validation/createValidationResult.ts index 862fd87a910..2f77f863542 100644 --- a/packages/@sanity/schema/src/sanity/validation/createValidationResult.ts +++ b/packages/@sanity/schema/src/sanity/validation/createValidationResult.ts @@ -27,6 +27,7 @@ export const HELP_IDS = { SLUG_SLUGIFY_FN_RENAMED: 'slug-slugifyfn-renamed', ASSET_METADATA_FIELD_INVALID: 'asset-metadata-field-invalid', CROSS_DATASET_REFERENCE_INVALID: 'cross-dataset-reference-invalid', + DEPRECATED_BLOCKEDITOR_KEY: 'schema-deprecated-blockeditor-key', } function createValidationResult( diff --git a/packages/@sanity/schema/src/sanity/validation/types/block.ts b/packages/@sanity/schema/src/sanity/validation/types/block.ts index 59efb9bf187..34e331d93e2 100644 --- a/packages/@sanity/schema/src/sanity/validation/types/block.ts +++ b/packages/@sanity/schema/src/sanity/validation/types/block.ts @@ -1,6 +1,6 @@ import {omit, isPlainObject} from 'lodash' import humanizeList from 'humanize-list' -import {error, warning} from '../createValidationResult' +import {error, HELP_IDS, warning} from '../createValidationResult' import {isJSONTypeOf} from '../utils/isJSONTypeOf' const getTypeOf = (thing) => (Array.isArray(thing) ? 'array' : typeof thing) @@ -197,7 +197,8 @@ function validateStyles(styles, visitorContext, problems) { if (typeof style.blockEditor !== 'undefined') { problems.push( warning( - `Style has deprecated key "blockEditor", please refer to the documentation on how to configure the block type for version 3.` + `Style has deprecated key "blockEditor", please refer to the documentation on how to configure the block type for version 3.`, + HELP_IDS.DEPRECATED_BLOCKEDITOR_KEY ) ) // TODO remove this backward compatibility at some point. @@ -245,7 +246,8 @@ function validateDecorators(decorators, visitorContext, problems) { if (typeof decorator.blockEditor !== 'undefined') { problems.push( warning( - `Decorator "${name}" has deprecated key "blockEditor", please refer to the documentation on how to configure the block type for version 3.` + `Decorator "${name}" has deprecated key "blockEditor", please refer to the documentation on how to configure the block type for version 3.`, + HELP_IDS.DEPRECATED_BLOCKEDITOR_KEY ) ) // TODO remove this backward compatibility at some point. @@ -278,7 +280,8 @@ function validateAnnotations(annotations, visitorContext, problems) { if (typeof annotation.blockEditor !== 'undefined') { problems.push( warning( - `Annotation has deprecated key "blockEditor", please refer to the documentation on how to configure the block type for version 3.` + `Annotation has deprecated key "blockEditor", please refer to the documentation on how to configure the block type for version 3.`, + HELP_IDS.DEPRECATED_BLOCKEDITOR_KEY ) ) // TODO remove this backward compatibility at some point.