File tree Expand file tree Collapse file tree 6 files changed +88
-1
lines changed
decap-cms-widget-markdown/src/MarkdownControl
decap-cms-widget-richtext/src/RichtextControl Expand file tree Collapse file tree 6 files changed +88
-1
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ const StyledTable = styled.table`
9797` ;
9898
9999const StyledTd = styled . td `
100- border : 2 px solid black;
100+ border : 1 px solid black;
101101 padding : 8px ;
102102 text-align : left;
103103` ;
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import BlockquoteElement from './components/Element/BlockquoteElement';
2727import LinkElement from './components/Element/LinkElement' ;
2828import ExtendedBlockquotePlugin from './plugins/ExtendedBlockquotePlugin' ;
2929import ShortcodePlugin from './plugins/ShortcodePlugin' ;
30+ import { TablePlugin , TableRowPlugin , TableCellPlugin } from './plugins/TablePlugin' ;
3031import defaultEmptyBlock from './defaultEmptyBlock' ;
3132import { mergeMediaConfig } from './mergeMediaConfig' ;
3233import { handleLinkClick } from './linkHandler' ;
@@ -146,6 +147,9 @@ export default function VisualEditor(props) {
146147 node : { component : BlockquoteElement } ,
147148 } ) ,
148149 ShortcodePlugin ,
150+ TablePlugin ,
151+ TableRowPlugin ,
152+ TableCellPlugin ,
149153 ] ,
150154 value : initialValue ,
151155 } ) ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import styled from '@emotion/styled' ;
3+
4+ const StyledTd = styled . td `
5+ border: 1px solid black;
6+ padding: 8px;
7+ text-align: left;
8+ ` ;
9+
10+ function TableCellElement ( { children, attributes, nodeProps } ) {
11+ return (
12+ < StyledTd { ...attributes } { ...nodeProps } >
13+ { children }
14+ </ StyledTd >
15+ ) ;
16+ }
17+
18+ export default TableCellElement ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import styled from '@emotion/styled' ;
3+
4+ const StyledTable = styled . table `
5+ border-collapse: collapse;
6+ margin-bottom: 16px;
7+ width: 100%;
8+ ` ;
9+
10+ function TableElement ( { children, attributes, nodeProps } ) {
11+ return (
12+ < StyledTable { ...attributes } { ...nodeProps } >
13+ < tbody > { children } </ tbody >
14+ </ StyledTable >
15+ ) ;
16+ }
17+
18+ export default TableElement ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+
3+ function TableRowElement ( { children, attributes, nodeProps } ) {
4+ return (
5+ < tr { ...attributes } { ...nodeProps } >
6+ { children }
7+ </ tr >
8+ ) ;
9+ }
10+
11+ export default TableRowElement ;
Original file line number Diff line number Diff line change 1+ import { createSlatePlugin } from 'platejs' ;
2+ import { toPlatePlugin } from 'platejs/react' ;
3+
4+ import TableElement from '../components/Element/TableElement' ;
5+ import TableRowElement from '../components/Element/TableRowElement' ;
6+ import TableCellElement from '../components/Element/TableCellElement' ;
7+
8+ const tablePlugin = createSlatePlugin ( {
9+ key : 'table' ,
10+ node : {
11+ isElement : true ,
12+ component : TableElement ,
13+ } ,
14+ } ) ;
15+
16+ const tableRowPlugin = createSlatePlugin ( {
17+ key : 'table-row' ,
18+ node : {
19+ isElement : true ,
20+ component : TableRowElement ,
21+ } ,
22+ } ) ;
23+
24+ const tableCellPlugin = createSlatePlugin ( {
25+ key : 'table-cell' ,
26+ node : {
27+ isElement : true ,
28+ component : TableCellElement ,
29+ } ,
30+ } ) ;
31+
32+ const TablePlugin = toPlatePlugin ( tablePlugin ) ;
33+ const TableRowPlugin = toPlatePlugin ( tableRowPlugin ) ;
34+ const TableCellPlugin = toPlatePlugin ( tableCellPlugin ) ;
35+
36+ export { TablePlugin , TableRowPlugin , TableCellPlugin } ;
You can’t perform that action at this time.
0 commit comments