File tree 2 files changed +36
-12
lines changed 2 files changed +36
-12
lines changed Original file line number Diff line number Diff line change 31
31
</v-list-item >
32
32
</v-list >
33
33
</v-menu >
34
- <span v-else >{{ content }}</span >
34
+ <span v-else :class = " [newline ? 'newline' : ''] " >{{ content }}</span >
35
35
</template >
36
36
37
37
<script >
@@ -56,6 +56,9 @@ export default {
56
56
type: Array ,
57
57
default : () => [],
58
58
required: true
59
+ },
60
+ newline: {
61
+ type: Boolean
59
62
}
60
63
},
61
64
data () {
@@ -142,4 +145,7 @@ export default {
142
145
-webkit-font-smoothing : subpixel-antialiased ;
143
146
letter-spacing : .1em ;
144
147
}
148
+ .newline {
149
+ width : 100% ;
150
+ }
145
151
</style >
Original file line number Diff line number Diff line change 4
4
v-for =" (chunk, i) in chunks"
5
5
:key =" i"
6
6
:content =" chunk.text"
7
+ :newline =" chunk.newline"
7
8
:label =" chunk.label"
8
9
:color =" chunk.color"
9
10
:labels =" labels"
@@ -96,16 +97,12 @@ export default {
96
97
},
97
98
98
99
chunks () {
99
- const chunks = []
100
+ let chunks = []
100
101
const entities = this .sortedEntities
101
102
let startOffset = 0
102
103
for (const entity of entities) {
103
104
// add non-entities to chunks.
104
- chunks .push ({
105
- label: null ,
106
- color: null ,
107
- text: this .text .slice (startOffset, entity .start_offset )
108
- })
105
+ chunks = chunks .concat (this .makeChunks (this .text .slice (startOffset, entity .start_offset )))
109
106
startOffset = entity .end_offset
110
107
111
108
// add entities to chunks.
@@ -118,11 +115,7 @@ export default {
118
115
})
119
116
}
120
117
// add the rest of text.
121
- chunks .push ({
122
- label: null ,
123
- color: null ,
124
- text: this .text .slice (startOffset, this .text .length )
125
- })
118
+ chunks = chunks .concat (this .makeChunks (this .text .slice (startOffset, this .text .length )))
126
119
return chunks
127
120
},
128
121
@@ -135,6 +128,31 @@ export default {
135
128
}
136
129
},
137
130
methods: {
131
+ makeChunks (text ) {
132
+ const chunks = []
133
+ const snippets = text .split (' \n ' )
134
+ for (const snippet of snippets .slice (0 , - 1 )) {
135
+ chunks .push ({
136
+ label: null ,
137
+ color: null ,
138
+ text: snippet + ' \n ' ,
139
+ newline: false
140
+ })
141
+ chunks .push ({
142
+ label: null ,
143
+ color: null ,
144
+ text: ' ' ,
145
+ newline: true
146
+ })
147
+ }
148
+ chunks .push ({
149
+ label: null ,
150
+ color: null ,
151
+ text: snippets .slice (- 1 )[0 ],
152
+ newline: false
153
+ })
154
+ return chunks
155
+ },
138
156
show (e ) {
139
157
e .preventDefault ()
140
158
this .showMenu = false
You can’t perform that action at this time.
0 commit comments