Skip to content
Snippets Groups Projects
Commit 1339f5f5 authored by chris's avatar chris
Browse files

add alt overlay in service

parent 9c8cec92
No related branches found
No related tags found
1 merge request!413Image alt text
/* eslint-disable react/prop-types */
import React, { useContext, useLayoutEffect } from 'react';
import styled from 'styled-components';
import { WaxContext } from 'wax-prosemirror-core';
export default ({ setPosition, position }) => {
const context = useContext(WaxContext);
const {
activeView,
pmViews: { main },
} = context;
const isEditable = main.props.editable(editable => {
return editable;
});
const readOnly = !isEditable;
useLayoutEffect(() => {
const WaxSurface = activeView.dom.getBoundingClientRect();
const left = 300;
const top = 500;
setPosition({ ...position, left, top });
}, [position.left]);
if (!readOnly) {
return <input type="text" />;
}
};
...@@ -7,6 +7,7 @@ import { PlaceHolderPlugin, captionPlugin } from 'wax-prosemirror-plugins'; ...@@ -7,6 +7,7 @@ import { PlaceHolderPlugin, captionPlugin } from 'wax-prosemirror-plugins';
import Service from '../Service'; import Service from '../Service';
import Image from './Image'; import Image from './Image';
import './image.css'; import './image.css';
import AltComponent from './AltComponent';
class ImageService extends Service { class ImageService extends Service {
name = 'ImageService'; name = 'ImageService';
...@@ -22,6 +23,7 @@ class ImageService extends Service { ...@@ -22,6 +23,7 @@ class ImageService extends Service {
register() { register() {
this.container.bind('Image').to(Image); this.container.bind('Image').to(Image);
const createNode = this.container.get('CreateNode'); const createNode = this.container.get('CreateNode');
const createOverlay = this.container.get('CreateOverlay');
createNode({ createNode({
figure: figureNode, figure: figureNode,
}); });
...@@ -39,6 +41,18 @@ class ImageService extends Service { ...@@ -39,6 +41,18 @@ class ImageService extends Service {
// , // ,
// { toWaxSchema: true }, // { toWaxSchema: true },
); );
createOverlay(
AltComponent,
{},
{
nodeType: 'image',
findInParent: false,
markType: '',
followCursor: false,
selection: false,
},
);
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment