File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,9 @@ The editor component. Simply place this component in your view hierarchy to rece
106
106
* `pasteAsPlainText`
107
107
A boolean value (false as default) that determines if the clipboard paste will keep its format or it will be done as plain text
108
108
109
+ * `defaultHttps`
110
+ A boolean value (true as default) that prepends https:// to the start of links
111
+
109
112
* `onPaste`
110
113
Callback clipboard paste value
111
114
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ export default class RichTextEditor extends Component {
57
57
initialFocus,
58
58
disabled,
59
59
styleWithCSS,
60
+ defaultHttps,
60
61
} = props ;
61
62
that . state = {
62
63
html : {
@@ -83,6 +84,7 @@ export default class RichTextEditor extends Component {
83
84
firstFocusEnd,
84
85
useContainer,
85
86
styleWithCSS,
87
+ defaultHttps,
86
88
} ) ,
87
89
} ,
88
90
keyboardHeight : 0 ,
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ function createHTML(options = {}) {
41
41
firstFocusEnd = true ,
42
42
useContainer = true ,
43
43
styleWithCSS = false ,
44
+ defaultHttps = true ,
44
45
} = options ;
45
46
//ERROR: HTML height not 100%;
46
47
return `
@@ -354,8 +355,13 @@ function createHTML(options = {}) {
354
355
var url = data.url || window.prompt('Enter the link URL');
355
356
356
357
if (url) {
358
+ let href = url
359
+ if (${ defaultHttps } && !href.startsWith("http")) {
360
+ href = "https://" + href
361
+ }
362
+
357
363
var el = document.createElement("a");
358
- el.setAttribute("href", url );
364
+ el.setAttribute("href", href );
359
365
360
366
var title = data.title || sel.toString() || url;
361
367
el.text = title;
You can’t perform that action at this time.
0 commit comments