1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
<script>
import { __ } from '~/locale';
export default {
props: {
title: {
type: String,
required: false,
default: '',
},
placeholder: {
type: String,
required: false,
default: __('Add a title...'),
},
disabled: {
type: Boolean,
required: false,
default: false,
},
},
methods: {
handleBlur({ target }) {
this.$emit('title-changed', target.innerText);
},
handleInput({ target }) {
this.$emit('title-input', target.innerText);
},
handleSubmit() {
this.$refs.titleEl.blur();
},
},
};
</script>
<template>
<h2
class="gl-font-weight-normal gl-sm-font-weight-bold gl-mb-5 gl-mt-0 gl-w-full"
:class="{ 'gl-cursor-text': disabled }"
aria-labelledby="item-title"
>
<div
id="item-title"
ref="titleEl"
role="textbox"
:aria-label="__('Title')"
:data-placeholder="placeholder"
:contenteditable="!disabled"
class="gl-px-4 gl-py-3 gl-ml-n4 gl-border gl-border-white gl-rounded-base"
:class="{ 'gl-hover-border-gray-200 gl-pseudo-placeholder': !disabled }"
@blur="handleBlur"
@keyup="handleInput"
@keydown.enter.exact="handleSubmit"
@keydown.ctrl.u.prevent
@keydown.meta.u.prevent
@keydown.ctrl.b.prevent
@keydown.meta.b.prevent
>
{{ title }}
</div>
</h2>
</template>
|