diff --git a/web/src/pages/Edit/components/NodeHyperlink.vue b/web/src/pages/Edit/components/NodeHyperlink.vue
index 0ce20506..0692b0e0 100644
--- a/web/src/pages/Edit/components/NodeHyperlink.vue
+++ b/web/src/pages/Edit/components/NodeHyperlink.vue
@@ -13,7 +13,14 @@
placeholder="http://xxxx.com/"
@keyup.native.stop
@keydown.native.stop
- >
+ @blur="handleUrl()"
+ >
+
+
+
+
+
+
{{ $t('nodeHyperlink.name') }}
@@ -46,7 +53,8 @@ export default {
dialogVisible: false,
link: '',
linkTitle: '',
- activeNodes: []
+ activeNodes: [],
+ protocol: 'https'
}
},
created() {
@@ -63,6 +71,7 @@ export default {
if (this.activeNodes.length > 0) {
let firstNode = this.activeNodes[0]
this.link = firstNode.getData('hyperlink')
+ this.handleUrl(true)
this.linkTitle = firstNode.getData('hyperlinkTitle')
} else {
this.link = ''
@@ -70,6 +79,20 @@ export default {
}
},
+ removeProtocol(url) {
+ return url.replace(/^https?:\/\//, '')
+ },
+
+ handleUrl(setProtocolNoneIfNotExist) {
+ const res = this.link.match(/^(https?):\/\//)
+ if (res && res[1]) {
+ this.protocol = res[1]
+ } else if (setProtocolNoneIfNotExist) {
+ this.protocol = 'none'
+ }
+ this.link = this.removeProtocol(this.link)
+ },
+
handleShowNodeLink() {
this.activeNodes[0].mindMap.keyCommand.pause()
this.$bus.$emit('startTextEdit')
@@ -94,7 +117,10 @@ export default {
*/
confirm() {
this.activeNodes.forEach(node => {
- node.setHyperlink(this.link, this.linkTitle)
+ node.setHyperlink(
+ (this.protocol === 'none' ? '' : this.protocol + '://') + this.link,
+ this.linkTitle
+ )
this.cancel()
})
}