Commit 993c2f4 1 parent 354c8e9 commit 993c2f4 Copy full SHA for 993c2f4
File tree 5 files changed +41
-2
lines changed
5 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 129
129
box-shadow : 0 0 0 1.5px var (--color-gray-7 );
130
130
transition : box-shadow var (--easing-fast );
131
131
}
132
+
133
+ ._legoEditor_inserted ,
134
+ ._legoEditor_deleted {
135
+ text-decoration : none;
136
+ }
137
+
138
+ ._legoEditor_inserted * {
139
+ background-color : var (--color-green-1 );
140
+ color : var (--color-green-6 );
141
+ }
142
+
143
+ ._legoEditor_deleted * {
144
+ background-color : var (--color-red-1 );
145
+ color : var (--danger-color );
146
+ }
Original file line number Diff line number Diff line change @@ -29,7 +29,9 @@ export type Elements =
29
29
| 'figure'
30
30
| 'image'
31
31
| 'image_caption'
32
- | 'quote' ;
32
+ | 'quote'
33
+ | 'ins'
34
+ | 'del' ;
33
35
34
36
export type CustomText = { text : string } & {
35
37
[ key in Mark ] ?: boolean ;
@@ -75,6 +77,14 @@ export type ListElement = {
75
77
type : 'ol_list' | 'ul_list' ;
76
78
children : ( ListElement | ListItemElement ) [ ] ;
77
79
} ;
80
+ export type InsertedElement = {
81
+ type : 'ins' ;
82
+ children : CustomText [ ] ;
83
+ } ;
84
+ export type DeletedElement = {
85
+ type : 'del' ;
86
+ children : CustomText [ ] ;
87
+ } ;
78
88
79
89
type CustomElement =
80
90
| ListElement
@@ -85,7 +95,9 @@ type CustomElement =
85
95
| FigureElement
86
96
| QuoteElement
87
97
| CodeBlockElement
88
- | LinkElement ;
98
+ | LinkElement
99
+ | InsertedElement
100
+ | DeletedElement ;
89
101
90
102
export interface ExtendedEditor extends BaseEditor {
91
103
savedSelection ?: BaseRange ;
Original file line number Diff line number Diff line change @@ -186,6 +186,10 @@ const renderElement = (props: RenderElementProps): JSX.Element => {
186
186
{ children }
187
187
</ a >
188
188
) ;
189
+ case 'ins' :
190
+ return < ins className = "_legoEditor_inserted" > { children } </ ins > ;
191
+ case 'del' :
192
+ return < del className = "_legoEditor_deleted" > { children } </ del > ;
189
193
default :
190
194
return < p { ...attributes } > { children } </ p > ;
191
195
}
Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ const TEXT_BLOCKS: Elements[] = [
99
99
'paragraph' ,
100
100
'code_block' ,
101
101
'quote' ,
102
+ 'ins' ,
103
+ 'del' ,
102
104
] ;
103
105
104
106
/**
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ const ELEMENT_TAGS: TAGS = {
24
24
figcaption : 'image_caption' ,
25
25
a : 'link' ,
26
26
blockquote : 'quote' ,
27
+ ins : 'ins' ,
28
+ del : 'del' ,
27
29
} ;
28
30
29
31
const MARK_TAGS = {
@@ -118,6 +120,10 @@ export const serialize = (node: SlateNode): string => {
118
120
return `<a ${ isInternalLink ( node . url ) ? '' : 'target="_blank" ' } href="${ node . url } ">${ children } </a>` ;
119
121
case 'quote' :
120
122
return `<blockquote>${ children } </blockquote>` ;
123
+ case 'ins' :
124
+ return `<ins>${ children } </ins>` ;
125
+ case 'del' :
126
+ return `<del>${ children } </del>` ;
121
127
default :
122
128
return children ;
123
129
}
You can’t perform that action at this time.
0 commit comments