This repository was archived by the owner on Sep 9, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed
packages/core/src/widgets/markdown/plate Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ import {
40
40
ELEMENT_TR ,
41
41
ELEMENT_UL ,
42
42
MARK_BOLD ,
43
+ MARK_CODE ,
43
44
MARK_ITALIC ,
44
45
MARK_STRIKETHROUGH ,
45
46
MARK_SUBSCRIPT ,
@@ -83,6 +84,7 @@ import {
83
84
TableHeaderCellElement ,
84
85
TableRowElement ,
85
86
} from './components/nodes/table' ;
87
+ import CodeElement from './components/nodes/code/Code' ;
86
88
import { Toolbar } from './components/toolbar' ;
87
89
import editableProps from './editableProps' ;
88
90
import { createMdPlugins , ELEMENT_SHORTCODE } from './plateTypes' ;
@@ -171,6 +173,7 @@ const PlateEditor: FC<PlateEditorProps> = ({
171
173
[ MARK_BOLD ] : withProps ( PlateLeaf , { as : 'strong' } ) ,
172
174
[ MARK_ITALIC ] : withProps ( PlateLeaf , { as : 'em' } ) ,
173
175
[ MARK_STRIKETHROUGH ] : withProps ( PlateLeaf , { as : 's' } ) ,
176
+ [ MARK_CODE ] : CodeElement ,
174
177
} ;
175
178
176
179
if ( useMdx ) {
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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 ;
You can’t perform that action at this time.
0 commit comments