|
|
@@ -0,0 +1,72 @@
|
|
|
+<template>
|
|
|
+ <div class="width">
|
|
|
+ <div class="linkline" v-for="n in links.length">
|
|
|
+ <input class="line" type="text" @input="change(n, $event.target.value)" :ref="n"/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ //TODO: Add validation, a link should match a regex.
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ links: [''],
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getContent() {
|
|
|
+ let links = [...this.links]
|
|
|
+ links.splice(links.length -1, 1)
|
|
|
+ return links
|
|
|
+ },
|
|
|
+ change(index, content) {
|
|
|
+ this.links[index-1] = content
|
|
|
+
|
|
|
+ if(content === '') {
|
|
|
+ if(this.links.length > 1) {
|
|
|
+ this.links.splice(index-1, 1)
|
|
|
+ this.updateFields()
|
|
|
+ }
|
|
|
+ } else if(index === this.links.length) {
|
|
|
+ this.links.push('')
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$emit('update')
|
|
|
+ },
|
|
|
+ updateFields() {
|
|
|
+ let counter = 0
|
|
|
+ for(let i = 1; i <= this.links.length; i++) {
|
|
|
+ let el = this.$refs[i][0]
|
|
|
+ el.value = this.links[counter++]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ isOkay() {
|
|
|
+ return true
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+ .line {
|
|
|
+ width: 100%;
|
|
|
+ min-height: 1.2em;
|
|
|
+ resize: vertical;
|
|
|
+ margin: auto;
|
|
|
+ margin-top: 2px;
|
|
|
+
|
|
|
+ color: #fff;
|
|
|
+ border: 1px solid #aaa;
|
|
|
+ background-color: #222;
|
|
|
+
|
|
|
+ height: 1.2em;
|
|
|
+ }
|
|
|
+
|
|
|
+ .width {
|
|
|
+ width: 100%;
|
|
|
+ max-width: 60em;
|
|
|
+ }
|
|
|
+</style>
|