This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree 1 file changed +13
-5
lines changed
1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,12 @@ class TuiEditor extends React.Component {
31
31
// this.editorInst.off(eventName);
32
32
this . editorInst . on ( eventName , props [ key ] ) ;
33
33
} ) ;
34
+
35
+ // always add `https` to the links if link was added without `http` or `https`
36
+ this . editorInst . on ( 'convertorAfterHtmlToMarkdownConverted' , ( inputMarkdown ) => {
37
+ const outputMarkdown = inputMarkdown . replace ( / \[ ( [ ^ \] ] * ) \] \( (? ! h t t p s ? ) ( [ ^ \) ] + ) \) / g, "[$1](https://$2)" )
38
+ return outputMarkdown ;
39
+ } ) ;
34
40
}
35
41
36
42
componentDidMount ( ) {
@@ -44,11 +50,13 @@ class TuiEditor extends React.Component {
44
50
45
51
componentWillUnmount ( ) {
46
52
Object . keys ( this . props )
47
- . filter ( ( key ) => / ^ o n [ A - Z ] [ a - z A - Z ] + / . test ( key ) )
48
- . forEach ( ( key ) => {
49
- const eventName = key [ 2 ] . toLowerCase ( ) + key . slice ( 3 ) ;
50
- this . editorInst . off ( eventName ) ;
51
- } ) ;
53
+ . filter ( ( key ) => / ^ o n [ A - Z ] [ a - z A - Z ] + / . test ( key ) )
54
+ . forEach ( ( key ) => {
55
+ const eventName = key [ 2 ] . toLowerCase ( ) + key . slice ( 3 ) ;
56
+ this . editorInst . off ( eventName ) ;
57
+ } ) ;
58
+
59
+ this . editorInst . off ( 'convertorAfterHtmlToMarkdownConverted' ) ;
52
60
}
53
61
54
62
shouldComponentUpdate ( nextProps ) {
You can’t perform that action at this time.
0 commit comments