diff --git a/packages/editor/src/extensions/attachment/attachment.ts b/packages/editor/src/extensions/attachment/attachment.ts index 05312aaf4..dca9028e2 100644 --- a/packages/editor/src/extensions/attachment/attachment.ts +++ b/packages/editor/src/extensions/attachment/attachment.ts @@ -112,7 +112,8 @@ export const AttachmentNode = Node.create({ return createSelectionBasedNodeView(AttachmentComponent, { shouldUpdate: ({ attrs: prev }, { attrs: next }) => { return prev.progress !== next.progress; - } + }, + forceEnableSelection: true }); }, diff --git a/packages/editor/src/extensions/attachment/component.tsx b/packages/editor/src/extensions/attachment/component.tsx index 75c28189f..9243f3759 100644 --- a/packages/editor/src/extensions/attachment/component.tsx +++ b/packages/editor/src/extensions/attachment/component.tsx @@ -32,7 +32,7 @@ export function AttachmentComponent( const { editor, node, selected } = props; const { filename, size, progress } = node.attrs; const elementRef = useRef(); - + return ( <> | null { if (!this.options.component) return null; - const isSelected = - this.editor.isEditable && - this.isSelectedNode(this.editor.view.state.selection); + const isSelected =(this.options.forceEnableSelection || this.editor.isEditable) && this.isSelectedNode(this.editor.view.state.selection); return ( diff --git a/packages/editor/src/extensions/react/types.ts b/packages/editor/src/extensions/react/types.ts index 0b10734ff..12ad04e23 100644 --- a/packages/editor/src/extensions/react/types.ts +++ b/packages/editor/src/extensions/react/types.ts @@ -62,4 +62,5 @@ export type ReactNodeViewOptions

= { shouldUpdate?: ShouldUpdate; contentDOMFactory?: (() => ContentDOM) | boolean; wrapperFactory?: () => HTMLElement; + forceEnableSelection?: boolean; };