diff --git a/editors/demo/src/HHMI/config/config.js b/editors/demo/src/HHMI/config/config.js index 70ca2465e00b04e3ad4758887c2dfbe0bc3f99ac..162052fd573df0c359984459f9aba25fbf667e51 100644 --- a/editors/demo/src/HHMI/config/config.js +++ b/editors/demo/src/HHMI/config/config.js @@ -63,6 +63,7 @@ export default { SchemaService: DefaultSchema, RulesService: [emDash, ellipsis], + ImageService: { showAlt: true }, PmPlugins: [columnResizing(), tableEditing(), invisibles([hardBreak()])], services: [ diff --git a/wax-prosemirror-services/src/ImageService/AltComponent.js b/wax-prosemirror-services/src/ImageService/AltComponent.js index 9786988c1a4a4a9e1016da4e7f989299abe598a1..35ab8914bb525affb89d9baa3d84f2a110d5faa2 100644 --- a/wax-prosemirror-services/src/ImageService/AltComponent.js +++ b/wax-prosemirror-services/src/ImageService/AltComponent.js @@ -1,3 +1,4 @@ +/* eslint-disable react/prop-types */ import React, { useContext, useLayoutEffect, useRef, useState } from 'react'; import styled from 'styled-components'; import { WaxContext } from 'wax-prosemirror-core'; @@ -65,10 +66,14 @@ export default ({ setPosition, position }) => { const imageConfig = app.config.get('config.ImageService'); const showAlt = imageConfig && imageConfig.showAlt; + const autoFocus = + activeView.state.selection && + activeView.state.selection.node && + activeView.state.selection.node.attrs.alt === ''; return !readOnly && showAlt ? ( <StyledInputAlt - autoFocus="autoFocus" + autoFocus={autoFocus} key="alt" onChange={altTextOnChange} placeholder="Alt Text"