Skip to content

Commit 5054e03

Browse files
committed
changed <textarea> to <div>
1 parent 9d50605 commit 5054e03

File tree

2 files changed

+17
-29
lines changed

2 files changed

+17
-29
lines changed

index.css

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ button {
2525
border-width: 1px; /* chrome - firefox */
2626
padding: 1px 5px;
2727
}
28+
.task-formatted-textarea {
29+
white-space: pre-wrap;
30+
padding: 2px;
31+
}
2832
.task-textarea {
2933
resize: none;
3034
display: block; /* solution for space under textarea */
@@ -36,16 +40,10 @@ button {
3640
overflow-y: hidden; /* hide scrollbar */
3741
}
3842
.task-compact-textarea {
39-
resize: none;
40-
flex: 1; /*take all the available space*/
43+
white-space: pre-wrap;
44+
padding: 2px;
45+
flex: 1; /* take all the available space */
4146
margin-right: 5px;
42-
/* display: block; /* solution for space under textarea */
43-
/* vertical-align: top; /* solution for space under textarea */
44-
/* width: 100%; */
45-
border: none;
46-
background-color: silver;
47-
box-sizing: border-box;
48-
overflow-y: hidden; /* hide scrollbar */
4947
}
5048
.task-top-row-input {
5149
border: none;

index.js

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,15 @@ Vue.directive('click-outside', {
9898
// TODO::LATER completed: too soon / on time / too late --> auto priority adjustment
9999
// TODO::LATER suggested priority
100100

101-
// TODO:: #0 change <textarea> to <div contenteditable="true">
102-
// TODO:: #1 parse URL
103-
104-
// https://stackoverflow.com/questions/37684/how-to-replace-plain-urls-with-links
105-
106101
// https://stackoverflow.com/questions/19214453/rich-text-editor-replacement-for-html-textarea
107102
// https://stackoverflow.com/questions/17785845/convert-html-tag-in-textarea-to-rich-text
108103
// https://stackoverflow.com/questions/2580247/can-i-embed-html-formatting-inside-of-a-textarea-tag
109104
// https://stackoverflow.com/questions/10404312/html5-rich-text-inside-textarea
110-
111105
// https://github.com/guardian/scribe
112106

107+
// TODO:: #1 parse URL
108+
// https://stackoverflow.com/questions/37684/how-to-replace-plain-urls-with-links
109+
113110
// https://github.com/SoapBox/linkifyjs
114111
// https://github.com/nfrasser/linkify-shim/blob/master/linkify.min.js
115112
// https://github.com/phanan/vue-linkify
@@ -134,24 +131,14 @@ Vue.component('compact-task-item', {
134131

135132
template: `
136133
<div class="task-compact" v-bind:style="{ 'background-color': color }">
137-
<textarea ref="message" v-on:input="textAreaAdjust()" :value="text" @input="$emit('update:text', $event.target.value)" aria-label="Task text" class="task-compact-textarea" v-bind:style="{ 'background-color': color }"></textarea>
134+
<div aria-label="Task text" class="task-compact-textarea" v-bind:style="{ 'background-color': color }">{{ text }}</div>
138135
<button v-on:click="$emit('activity')">
139136
<img src="icons/count.png" alt="Number of times task was completed" title="Number of times task was completed" height="20" width="20">{{ activityCounter }}x
140137
</button>
141138
</div>
142139
`,
143140

144-
props: ['text', 'activityCounter', 'color'],
145-
methods: {
146-
textAreaAdjust() {
147-
var o = this.$refs.message;
148-
o.style.height = "1px";
149-
o.style.height = (o.scrollHeight)+"px";
150-
}
151-
},
152-
mounted(){
153-
this.textAreaAdjust();
154-
}
141+
props: ['text', 'activityCounter', 'color']
155142
})
156143

157144
//-------------------------------------------------------------------------
@@ -211,7 +198,8 @@ Vue.component('task-item', {
211198
<img src="icons/delete.png" alt="Delete task" title="Delete task" height="20" width="20">
212199
</button>
213200
</div>
214-
<textarea ref="message" v-on:input="textAreaAdjust()" :value="text" @input="$emit('update:text', $event.target.value)" aria-label="Task text" class="task-textarea" v-bind:style="{ 'background-color': color }"></textarea>
201+
<textarea v-if="expanded" ref="message" v-on:input="textAreaAdjust()" :value="text" @input="$emit('update:text', $event.target.value)" aria-label="Task text" class="task-textarea" v-bind:style="{ 'background-color': color }"></textarea>
202+
<div v-else aria-label="Task text" class="task-formatted-textarea" v-bind:style="{ 'background-color': color }">{{ text }}</div>
215203
</div>
216204
`,
217205

@@ -257,6 +245,7 @@ Vue.component('task-item', {
257245

258246
this.$nextTick(() => {
259247
this.inputAdjust();
248+
this.textAreaAdjust();
260249
})
261250
},
262251
onClickOutside() {
@@ -269,6 +258,7 @@ Vue.component('task-item', {
269258
var o = this.$refs.message;
270259
o.style.height = "1px";
271260
o.style.height = (o.scrollHeight)+"px";
261+
o.focus(); // TODO:: only on div click
272262
},
273263
inputAdjust() {
274264
var o = this.$refs.factor;
@@ -280,7 +270,7 @@ Vue.component('task-item', {
280270
}
281271
},
282272
mounted(){
283-
this.textAreaAdjust();
273+
// this.textAreaAdjust();
284274
}
285275
})
286276

0 commit comments

Comments
 (0)