diff --git a/.changeset/quiet-seahorses-listen.md b/.changeset/quiet-seahorses-listen.md new file mode 100644 index 000000000..4feb4ad24 --- /dev/null +++ b/.changeset/quiet-seahorses-listen.md @@ -0,0 +1,5 @@ +--- +'@keystatic/core': patch +--- + +Fix disabling images in `fields.markdoc` and `fields.mdx` diff --git a/packages/keystatic/src/form/fields/markdoc/editor/Toolbar.tsx b/packages/keystatic/src/form/fields/markdoc/editor/Toolbar.tsx index 6b9535eca..114f49441 100644 --- a/packages/keystatic/src/form/fields/markdoc/editor/Toolbar.tsx +++ b/packages/keystatic/src/form/fields/markdoc/editor/Toolbar.tsx @@ -261,7 +261,7 @@ export const Toolbar = memo(function Toolbar( )} - + {nodes.image && } diff --git a/packages/keystatic/src/form/fields/markdoc/editor/custom-components.tsx b/packages/keystatic/src/form/fields/markdoc/editor/custom-components.tsx index 15be0a02d..61f6bbef0 100644 --- a/packages/keystatic/src/form/fields/markdoc/editor/custom-components.tsx +++ b/packages/keystatic/src/form/fields/markdoc/editor/custom-components.tsx @@ -417,7 +417,7 @@ export function getCustomNodeSpecs( }; } else if (component.kind === 'inline') { spec = { - group: 'inline inline_component', + group: 'inline', inline: true, attrs: { props: { diff --git a/packages/keystatic/src/form/fields/markdoc/editor/images.tsx b/packages/keystatic/src/form/fields/markdoc/editor/images.tsx index 147304161..95d5c254b 100644 --- a/packages/keystatic/src/form/fields/markdoc/editor/images.tsx +++ b/packages/keystatic/src/form/fields/markdoc/editor/images.tsx @@ -25,7 +25,6 @@ export function getSrcPrefixForImageBlock( } export function imageDropPlugin(schema: EditorSchema) { - if (!schema.nodes.image) return new Plugin({}); const imageType = schema.nodes.image; return new Plugin({ props: { @@ -69,7 +68,7 @@ export function imageDropPlugin(schema: EditorSchema) { })(); return true; } - if (file.type.startsWith('image/')) { + if (file.type.startsWith('image/') && imageType) { (async () => { const slice = Slice.maxOpen( Fragment.from( @@ -109,7 +108,7 @@ export function imageDropPlugin(schema: EditorSchema) { })(); return true; } - if (file.type.startsWith('image/')) { + if (file.type.startsWith('image/') && imageType) { (async () => { view.dispatch( view.state.tr.replaceSelectionWith( diff --git a/packages/keystatic/src/form/fields/markdoc/editor/schema.tsx b/packages/keystatic/src/form/fields/markdoc/editor/schema.tsx index 7ae753a23..5bbe2b149 100644 --- a/packages/keystatic/src/form/fields/markdoc/editor/schema.tsx +++ b/packages/keystatic/src/form/fields/markdoc/editor/schema.tsx @@ -85,7 +85,7 @@ export type EditorNodeSpec = NodeSpec & WithInsertMenuNodeSpec & WithReactNodeViewSpec; -const inlineContent = `(text | inline_component | hard_break)*`; +const inlineContent = `inline*`; const levelsMeta = [ { description: 'Use this for a top level heading', icon: heading1Icon }, @@ -310,7 +310,7 @@ const nodeSpecs = { }, image: { content: '', - group: 'inline inline_component', + group: 'inline', inline: true, attrs: { src: {},