Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit c6472e3

Browse files
committed
fix: inline code styles
1 parent 965f8e5 commit c6472e3

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

packages/core/src/widgets/markdown/plate/PlateEditor.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
ELEMENT_TR,
4141
ELEMENT_UL,
4242
MARK_BOLD,
43+
MARK_CODE,
4344
MARK_ITALIC,
4445
MARK_STRIKETHROUGH,
4546
MARK_SUBSCRIPT,
@@ -83,6 +84,7 @@ import {
8384
TableHeaderCellElement,
8485
TableRowElement,
8586
} from './components/nodes/table';
87+
import CodeElement from './components/nodes/code/Code';
8688
import { Toolbar } from './components/toolbar';
8789
import editableProps from './editableProps';
8890
import { createMdPlugins, ELEMENT_SHORTCODE } from './plateTypes';
@@ -171,6 +173,7 @@ const PlateEditor: FC<PlateEditorProps> = ({
171173
[MARK_BOLD]: withProps(PlateLeaf, { as: 'strong' }),
172174
[MARK_ITALIC]: withProps(PlateLeaf, { as: 'em' }),
173175
[MARK_STRIKETHROUGH]: withProps(PlateLeaf, { as: 's' }),
176+
[MARK_CODE]: CodeElement,
174177
};
175178

176179
if (useMdx) {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.CMS_WidgetMarkdown_Code_root {
2+
@apply py-[0.2em]
3+
px-[0.4em]
4+
m-0
5+
text-sm
6+
whitespace-break-spaces
7+
text-gray-700
8+
dark:text-gray-200
9+
bg-gray-100
10+
dark:bg-gray-700
11+
rounded-md
12+
font-mono;
13+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
3+
import { generateClassNames } from '@staticcms/core/lib/util/theming.util';
4+
5+
import type { MdValue } from '@staticcms/markdown';
6+
import type { PlateRenderElementProps } from '@udecode/plate';
7+
import type { FC } from 'react';
8+
9+
import './Code.css';
10+
11+
const classes = generateClassNames('WidgetMarkdown_Code', ['root']);
12+
13+
const CodeElement: FC<PlateRenderElementProps<MdValue>> = ({ attributes, children, nodeProps }) => {
14+
return (
15+
<code {...attributes} {...nodeProps} className={classes.root}>
16+
{children}
17+
</code>
18+
);
19+
};
20+
21+
export default CodeElement;

0 commit comments

Comments
 (0)