style: modify image style.

This commit is contained in:
jaywcjlove
2022-09-02 17:36:05 +08:00
parent e9b3b60f6d
commit e0fed4783a
2 changed files with 6 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ import { Context, themes } from '../../store/context';
import data from '../../../README.md';
const Warpper = styled.div`
height: calc(100vh - 2.8rem);
height: calc(100vh - 2.9rem);
`;
export const HomePage = () => {
@@ -25,7 +25,7 @@ export const HomePage = () => {
extensions={[EditorView.lineWrapping]}
renderPreview={Preview}
visible={true}
height="calc(100vh - 4.9rem)"
height="calc(100vh - 4.92rem)"
/>
</Warpper>
);

View File

@@ -90,8 +90,10 @@ export const footnotesLabel = (node: Element) => {
}
export const imagesStyle = (node: Element, parent: Root | Element | null) => {
if (parent?.type === 'element' && parent.tagName === 'p' && node?.type === 'element' && node.tagName === 'img') {
parent.tagName = 'figure';
if (parent?.type === 'element' && /(p|a)/.test(parent.tagName) && node?.type === 'element' && node.tagName === 'img') {
if (parent.tagName === 'p') {
parent.tagName = 'figure'
}
if (!parent.properties) parent.properties = {}
parent.properties.className = ['image-warpper']
if (!node.properties) node.properties = {}