@@ -98,6 +98,11 @@ const InlineFormButton = styled.button`
98
98
}
99
99
` ;
100
100
101
+ const LinkCopiedMessage = styled . div `
102
+ color: green;
103
+ margin-bottom: 2%;
104
+ ` ;
105
+
101
106
const popupStyles = {
102
107
padding : '0.2em 0.5em 0.2em 0.5em' ,
103
108
zIndex : '9999'
@@ -114,6 +119,7 @@ const HyperlinkModal = React.forwardRef(({ ...props }, ref) => {
114
119
const editor = useEditor ( ) ;
115
120
const [ originalSelection , setOriginalSelection ] = useState ( null ) ;
116
121
const [ canApply , setApplyStatus ] = useState ( false ) ;
122
+ const [ linkCopied , setLinkCopied ] = useState ( false ) ;
117
123
118
124
const handleClick = useCallback ( ( e ) => {
119
125
if ( ref . current && ! ref . current . contains ( e . target ) ) {
@@ -186,8 +192,10 @@ const HyperlinkModal = React.forwardRef(({ ...props }, ref) => {
186
192
const copyLink = ( ) => {
187
193
const inputLink = refHyperlinkTextInput . current . inputRef . current . value ;
188
194
const listener = ( e ) => {
189
- e . clipboardData . setData ( 'text/plain' , inputLink ) ;
195
+ e . clipboardData . setData ( 'text/plain' , validateUrl ( inputLink ) ) ;
190
196
e . preventDefault ( ) ;
197
+ setLinkCopied ( true ) ;
198
+ Transforms . select ( editor , originalSelection ) ;
191
199
} ;
192
200
193
201
document . addEventListener ( 'copy' , listener ) ;
@@ -231,6 +239,7 @@ const HyperlinkModal = React.forwardRef(({ ...props }, ref) => {
231
239
Apply
232
240
</ InlineFormButton >
233
241
</ InlineFormField >
242
+ { linkCopied && < LinkCopiedMessage > Link copied</ LinkCopiedMessage > }
234
243
< InlineFormField >
235
244
< Popup
236
245
trigger = {
0 commit comments