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

Commit

Permalink
fix: inline code styles (#880)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaneFreeman authored Sep 14, 2023
1 parent 965f8e5 commit 084c689
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/core/src/widgets/markdown/plate/PlateEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
ELEMENT_TR,
ELEMENT_UL,
MARK_BOLD,
MARK_CODE,
MARK_ITALIC,
MARK_STRIKETHROUGH,
MARK_SUBSCRIPT,
Expand Down Expand Up @@ -83,6 +84,7 @@ import {
TableHeaderCellElement,
TableRowElement,
} from './components/nodes/table';
import CodeElement from './components/nodes/code/Code';
import { Toolbar } from './components/toolbar';
import editableProps from './editableProps';
import { createMdPlugins, ELEMENT_SHORTCODE } from './plateTypes';
Expand Down Expand Up @@ -171,6 +173,7 @@ const PlateEditor: FC<PlateEditorProps> = ({
[MARK_BOLD]: withProps(PlateLeaf, { as: 'strong' }),
[MARK_ITALIC]: withProps(PlateLeaf, { as: 'em' }),
[MARK_STRIKETHROUGH]: withProps(PlateLeaf, { as: 's' }),
[MARK_CODE]: CodeElement,
};

if (useMdx) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.CMS_WidgetMarkdown_Code_root {
@apply py-[0.2em]
px-[0.4em]
m-0
text-sm
whitespace-break-spaces
text-gray-700
dark:text-gray-200
bg-gray-200
dark:bg-gray-700
rounded-md
font-mono;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';

import { generateClassNames } from '@staticcms/core/lib/util/theming.util';

import type { MdValue } from '@staticcms/markdown';
import type { PlateRenderElementProps } from '@udecode/plate';
import type { FC } from 'react';

import './Code.css';

const classes = generateClassNames('WidgetMarkdown_Code', ['root']);

const CodeElement: FC<PlateRenderElementProps<MdValue>> = ({ attributes, children, nodeProps }) => {
return (
<code {...attributes} {...nodeProps} className={classes.root}>
{children}
</code>
);
};

export default CodeElement;

0 comments on commit 084c689

Please sign in to comment.