11<template >
22 <div class =" form-group" >
3- <label v-uni-for =" label" >{{label}} </label >
3+ <label v-uni-for =" label" >{{ label }} </label >
44 <div v-if =" richtext" :class =" classList" v-uni-id =" label" >
55 <div v-if =" readonly" v-html =" value" ></div >
66 <div v-else >
77 <editor
8- class =" editor"
98 v-if =" !readonly && editorActive"
10- v-bind =" $attrs"
9+ class =" editor"
10+ v-bind =" objectOfAttrs"
1111 :value =" value"
1212 :init =" editorSettings"
1313 :name =" name"
1717 </div >
1818 <textarea
1919 v-else
20- v-bind =" $attrs"
21- :rows =" rows"
22- :readonly =" readonly"
2320 v-uni-id =" label"
21+ v-bind =" objectOfAttrs"
2422 class =" form-control"
23+ :rows =" rows"
24+ :readonly =" readonly"
2525 :class =" classList"
2626 :name =" name"
2727 :value =" value"
2828 @input =" $emit('input', $event.target.value)"
2929 />
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 >
3237 </div >
3338</template >
3439
3540<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 " ;
4247
4348const uniqIdsMixin = createUniqIdsMixin ();
4449
4550export default {
46- inheritAttrs: false ,
4751 components: {
4852 DisplayErrors,
4953 Editor
5054 },
5155 mixins: [uniqIdsMixin, ValidationMixin, DataFormatMixin],
52-
56+ inheritAttrs : false ,
5357 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"
6367 ],
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+ },
64109 computed: {
65110 classList () {
66111 return {
67- ' is-invalid' : (this .validator && this .validator .errorCount ) || this .error ,
112+ " is-invalid" :
113+ (this .validator && this .validator .errorCount ) || this .error ,
68114 [this .controlClass ]: !! this .controlClass ,
69- ' richtext' : this .richtext && ! this .readonly ,
115+ richtext: this .richtext && ! this .readonly
70116 };
71117 },
72118 height () {
73119 if (! this .rows ) {
74120 return false ;
75121 }
76- return String (parseInt (this .rows ) * 55 ) + ' px ' ;
122+ return String (parseInt (this .rows ) * 55 ) + " px " ;
77123 }
78124 },
79125 watch: {
80126 rows: {
81127 handler () {
82128 this .setHeight ();
83129 },
84- immediate: true ,
130+ immediate: true
85131 },
86132 name () {
87133 this .rebootEditor ();
88- },
134+ }
89135 },
90136 created () {
91137 this .rebootEditor = throttle (() => {
92138 this .editorActive = false ;
93139 this .$nextTick (() => {
94- this .editorActive = true
140+ this .editorActive = true ;
95141 });
96142 }, 500 );
97143 },
98144 mounted () {
99- window .ProcessMaker .EventBus .$on (' modal-shown' , () => {
145+ window .ProcessMaker .EventBus .$on (" modal-shown" , () => {
100146 this .rebootEditor ();
101147 });
102148 },
@@ -105,47 +151,18 @@ export default {
105151 if (! this .editorInstance ) {
106152 return ;
107153 }
108-
109154 if (! this .rows ) {
110155 return ;
111156 }
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 ;
114162 }
115163 }
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- }
147164 }
148- }
165+ };
149166 </script >
150167
151168<style lang="scss">
0 commit comments