1
1
<template >
2
2
<div class =" form-group" >
3
- <label v-uni-for =" label" >{{label}} </label >
3
+ <label v-uni-for =" label" >{{ label }} </label >
4
4
<div v-if =" richtext" :class =" classList" v-uni-id =" label" >
5
5
<div v-if =" readonly" v-html =" value" ></div >
6
6
<div v-else >
7
7
<editor
8
- class =" editor"
9
8
v-if =" !readonly && editorActive"
10
- v-bind =" $attrs"
9
+ class =" editor"
10
+ v-bind =" objectOfAttrs"
11
11
:value =" value"
12
12
:init =" editorSettings"
13
13
:name =" name"
17
17
</div >
18
18
<textarea
19
19
v-else
20
- v-bind =" $attrs"
21
- :rows =" rows"
22
- :readonly =" readonly"
23
20
v-uni-id =" label"
21
+ v-bind =" objectOfAttrs"
24
22
class =" form-control"
23
+ :rows =" rows"
24
+ :readonly =" readonly"
25
25
:class =" classList"
26
26
:name =" name"
27
27
:value =" value"
28
28
@input =" $emit('input', $event.target.value)"
29
29
/>
30
- <display-errors v-if =" error || (validator && validator.errorCount)" :name =" name" :error =" error" :validator =" validator" />
31
- <small v-if =' helper' class =' form-text text-muted' >{{helper}}</small >
30
+ <display-errors
31
+ v-if =" error || (validator && validator.errorCount)"
32
+ :name =" name"
33
+ :error =" error"
34
+ :validator =" validator"
35
+ />
36
+ <small v-if =" helper" class =" form-text text-muted" >{{ helper }}</small >
32
37
</div >
33
38
</template >
34
39
35
40
<script >
36
- import { createUniqIdsMixin } from ' vue-uniq-ids'
37
- import ValidationMixin from ' ./mixins/validation '
38
- import DataFormatMixin from ' ./mixins/DataFormat ' ;
39
- import DisplayErrors from ' ./common/DisplayErrors ' ;
40
- import Editor from ' ./Editor '
41
- import throttle from ' lodash/throttle ' ;
41
+ import { createUniqIdsMixin } from " vue-uniq-ids" ;
42
+ import throttle from " lodash/throttle " ;
43
+ import ValidationMixin from " ./mixins/validation " ;
44
+ import DataFormatMixin from " ./mixins/DataFormat " ;
45
+ import DisplayErrors from " ./common/DisplayErrors " ;
46
+ import Editor from " ./Editor " ;
42
47
43
48
const uniqIdsMixin = createUniqIdsMixin ();
44
49
45
50
export default {
46
- inheritAttrs: false ,
47
51
components: {
48
52
DisplayErrors,
49
53
Editor
50
54
},
51
55
mixins: [uniqIdsMixin, ValidationMixin, DataFormatMixin],
52
-
56
+ inheritAttrs : false ,
53
57
props: [
54
- ' label' ,
55
- ' error' ,
56
- ' name' ,
57
- ' value' ,
58
- ' helper' ,
59
- ' controlClass' ,
60
- ' richtext' ,
61
- ' readonly' ,
62
- ' rows'
58
+ " label" ,
59
+ " error" ,
60
+ " name" ,
61
+ " value" ,
62
+ " helper" ,
63
+ " controlClass" ,
64
+ " richtext" ,
65
+ " readonly" ,
66
+ " rows"
63
67
],
68
+ data () {
69
+ return {
70
+ objectOfAttrs: {
71
+ placeholder: this .$attrs .placeholder ,
72
+ " aria-label" : this .$attrs [" aria-label" ],
73
+ " data-cy" : this .$attrs [" data-cy" ],
74
+ tabindex: this .$attrs .tabindex
75
+ },
76
+ editorSettings: {
77
+ inline: false ,
78
+ statusbar: false ,
79
+ content_style:
80
+ " body { font-family: Arial; } .pagebreak { border: 1px solid #ccc; }" ,
81
+ menubar: false ,
82
+ plugins: [" link" , " lists" , " image" ],
83
+ toolbar: ` undo redo | link image pagebreak | styleselect | bold italic forecolor |
84
+ alignleft aligncenter alignright alignjustify | bullist numlist outdent indent` ,
85
+ skin: false ,
86
+ content_css: false ,
87
+ relative_urls: false ,
88
+ remove_script_host: false ,
89
+ init_instance_callback : (editor ) => {
90
+ this .editorInstance = editor;
91
+ this .setHeight ();
92
+ },
93
+ setup : (editor ) => {
94
+ editor .ui .registry .addButton (" pagebreak" , {
95
+ tooltip: this .$t (" Insert Page Break For PDF" ),
96
+ icon: " page-break" ,
97
+ onAction : function (_ ) {
98
+ editor .insertContent (
99
+ " <hr class='pagebreak' style='page-break-after: always;' />"
100
+ );
101
+ }
102
+ });
103
+ }
104
+ },
105
+ editorInstance: null ,
106
+ editorActive: true
107
+ };
108
+ },
64
109
computed: {
65
110
classList () {
66
111
return {
67
- ' is-invalid' : (this .validator && this .validator .errorCount ) || this .error ,
112
+ " is-invalid" :
113
+ (this .validator && this .validator .errorCount ) || this .error ,
68
114
[this .controlClass ]: !! this .controlClass ,
69
- ' richtext' : this .richtext && ! this .readonly ,
115
+ richtext: this .richtext && ! this .readonly
70
116
};
71
117
},
72
118
height () {
73
119
if (! this .rows ) {
74
120
return false ;
75
121
}
76
- return String (parseInt (this .rows ) * 55 ) + ' px ' ;
122
+ return String (parseInt (this .rows ) * 55 ) + " px " ;
77
123
}
78
124
},
79
125
watch: {
80
126
rows: {
81
127
handler () {
82
128
this .setHeight ();
83
129
},
84
- immediate: true ,
130
+ immediate: true
85
131
},
86
132
name () {
87
133
this .rebootEditor ();
88
- },
134
+ }
89
135
},
90
136
created () {
91
137
this .rebootEditor = throttle (() => {
92
138
this .editorActive = false ;
93
139
this .$nextTick (() => {
94
- this .editorActive = true
140
+ this .editorActive = true ;
95
141
});
96
142
}, 500 );
97
143
},
98
144
mounted () {
99
- window .ProcessMaker .EventBus .$on (' modal-shown' , () => {
145
+ window .ProcessMaker .EventBus .$on (" modal-shown" , () => {
100
146
this .rebootEditor ();
101
147
});
102
148
},
@@ -105,47 +151,18 @@ export default {
105
151
if (! this .editorInstance ) {
106
152
return ;
107
153
}
108
-
109
154
if (! this .rows ) {
110
155
return ;
111
156
}
112
- if (this .editorInstance .getContainer () && this .editorInstance .getContainer ().style ) {
113
- this .editorInstance .getContainer ().style .height = this .height ;
157
+ if (
158
+ this .editorInstance .getContainer () &&
159
+ this .editorInstance .getContainer ().style
160
+ ) {
161
+ this .editorInstance .getContainer ().style .height = this .height ;
114
162
}
115
163
}
116
- },
117
- data () {
118
- return {
119
- editorSettings: {
120
- inline: false ,
121
- statusbar: false ,
122
- content_style: ' body { font-family: Arial; } .pagebreak { border: 1px solid #ccc; }' ,
123
- menubar: false ,
124
- plugins: [ ' link' , ' lists' , ' image' ],
125
- toolbar: ' undo redo | link image pagebreak | styleselect | bold italic forecolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent' ,
126
- skin: false ,
127
- content_css: false ,
128
- relative_urls: false ,
129
- remove_script_host: false ,
130
- init_instance_callback : (editor ) => {
131
- this .editorInstance = editor;
132
- this .setHeight ();
133
- },
134
- setup : (editor ) => {
135
- editor .ui .registry .addButton (' pagebreak' , {
136
- tooltip: this .$t (' Insert Page Break For PDF' ),
137
- icon: ' page-break' ,
138
- onAction : function (_ ) {
139
- editor .insertContent (" <hr class='pagebreak' style='page-break-after: always;' />" );
140
- }
141
- });
142
- },
143
- },
144
- editorInstance: null ,
145
- editorActive: true ,
146
- }
147
164
}
148
- }
165
+ };
149
166
</script >
150
167
151
168
<style lang="scss">
0 commit comments