Commit 07d1210409cda2697897aca6ff14a89012118106

Authored by ly525
1 parent cee04c99

update text-component with quil editor

front-end/h5/src/components/plugins/lbp-text.js
1 -import LbpTextAlign from '@luban-h5/lbs-text-align'  
2 -import MediumEditor from 'vue2-medium-editor'  
3 -import 'medium-editor/dist/css/medium-editor.css'  
4 -import 'medium-editor/dist/css/themes/default.css' 1 +import { quillEditor } from 'vue-quill-editor'
  2 +// require styles
  3 +import 'quill/dist/quill.core.css'
  4 +import 'quill/dist/quill.snow.css'
  5 +import './styles/text-overwrite-quil-snow-theme.scss'
5 6
6 export default { 7 export default {
7 render (h) { 8 render (h) {
@@ -41,78 +42,34 @@ export default { @@ -41,78 +42,34 @@ export default {
41 > 42 >
42 { 43 {
43 this.canEdit 44 this.canEdit
44 - ? <MediumEditor  
45 - text={this.text} 45 + ? <quillEditor
  46 + content={this.text}
46 options={{ 47 options={{
47 - toolbar: {  
48 - /* These are the default options for the toolbar,  
49 - if nothing is passed this is what is used */  
50 - allowMultiParagraphSelection: true,  
51 - buttons: ['bold', 'italic', 'underline', 'anchor', 'h2', 'h3', 'quote', 'justifyCenter'],  
52 - diffLeft: 0,  
53 - diffTop: -10,  
54 - firstButtonClass: 'medium-editor-button-first',  
55 - lastButtonClass: 'medium-editor-button-last',  
56 - relativeContainer: null,  
57 - standardizeSelectionStart: false,  
58 - static: true,  
59 -  
60 - /* options which only apply when static is true */  
61 - align: 'center',  
62 - sticky: true,  
63 - updateOnEmptySelection: false  
64 - }  
65 - }}  
66 - onEdit={(ev) => {  
67 - if (this.canEdit) {  
68 - // ev.preventDefault()  
69 - // ev.stopPropagation()  
70 - }  
71 - if (ev.event.target) {  
72 - this.text = ev.event.target.innerHTML  
73 - }  
74 - // this.$emit('input', {  
75 - // value: ev.event.target.innerHTML,  
76 - // pluginName: 'lbp-text'  
77 - // }) 48 + modules: {
  49 + // toolbar: '#toolbar-wrapper'
  50 + toolbar: [
  51 + ['bold', 'italic', 'underline', 'strike'], // 切换按钮
  52 + [{ 'list': 'ordered' }, { 'list': 'bullet' }],
  53 + [{ 'color': [] }, { 'background': [] }], // 主题默认下拉,使用主题提供的值
  54 + [{ 'align': [] }],
  55 + ['clean'], // 清除格式
  56 + [{ 'header': [1, 2, 3, 4, 5, 6, false] }]
  57 + // https://github.com/quilljs/quill/issues/1208
  58 + ]
  59 + },
  60 + theme: 'snow'
78 }} 61 }}
79 - custom-tag='div'>  
80 - </MediumEditor> 62 + onChange={({ quill, html, text }) => {
  63 + this.$emit('input', {
  64 + value: html,
  65 + pluginName: 'lbp-text'
  66 + })
  67 + }}>
  68 + </quillEditor>
81 : pureText 69 : pureText
82 } 70 }
83 </div> 71 </div>
84 ) 72 )
85 - // return h('div', {  
86 - // style,  
87 - // on: {  
88 - // dblclick () {  
89 - // self.canEdit = true  
90 - // }  
91 - // }  
92 - // }, [  
93 - // h('div', {  
94 - // ref: 'editableText',  
95 - // style: {  
96 - // height: '100%'  
97 - // },  
98 - // domProps: {  
99 - // innerHTML: self.innerText,  
100 - // contentEditable: self.canEdit  
101 - // },  
102 - // on: {  
103 - // blur () {  
104 - // self.canEdit = false  
105 - // },  
106 - // input () {  
107 - // self.$emit('input', {  
108 - // value: self.$refs.editableText.innerHTML,  
109 - // pluginName: 'lbp-text'  
110 - // })  
111 - // }  
112 - // }  
113 - // })  
114 -  
115 - // ])  
116 }, 73 },
117 name: 'lbp-text', 74 name: 'lbp-text',
118 data () { 75 data () {
@@ -126,18 +83,6 @@ export default { @@ -126,18 +83,6 @@ export default {
126 type: String, 83 type: String,
127 default: '双击修改文字' 84 default: '双击修改文字'
128 }, 85 },
129 - type: {  
130 - type: String,  
131 - default: 'text'  
132 - },  
133 - placeholder: {  
134 - type: String,  
135 - default: '请填写提示文字'  
136 - },  
137 - required: {  
138 - type: Boolean,  
139 - default: false  
140 - },  
141 disabled: { 86 disabled: {
142 type: Boolean, 87 type: Boolean,
143 default: false 88 default: false
@@ -146,14 +91,6 @@ export default { @@ -146,14 +91,6 @@ export default {
146 type: String, 91 type: String,
147 default: 'transparent' 92 default: 'transparent'
148 }, 93 },
149 - color: {  
150 - type: String,  
151 - default: 'black'  
152 - },  
153 - fontSize: {  
154 - type: Number,  
155 - default: 14  
156 - },  
157 lineHeight: { 94 lineHeight: {
158 type: Number, 95 type: Number,
159 default: 1 96 default: 1
@@ -173,50 +110,10 @@ export default { @@ -173,50 +110,10 @@ export default {
173 borderStyle: { 110 borderStyle: {
174 type: String, 111 type: String,
175 default: 'solid' 112 default: 'solid'
176 - },  
177 - textAlign: {  
178 - type: String,  
179 - default: 'center'  
180 } 113 }
181 }, 114 },
182 editorConfig: { 115 editorConfig: {
183 propsConfig: { 116 propsConfig: {
184 - // text: {  
185 - // type: 'a-input',  
186 - // label: '按钮文字',  
187 - // require: true,  
188 - // defaultPropValue: '双击修改文字'  
189 - // },  
190 - fontSize: {  
191 - type: 'a-input-number',  
192 - label: '字号(px)',  
193 - require: true,  
194 - prop: {  
195 - step: 1,  
196 - min: 12,  
197 - max: 144  
198 - },  
199 - defaultPropValue: 14  
200 - },  
201 - color: {  
202 - type: 'a-input',  
203 - label: '文字颜色',  
204 - // !#zh 为编辑组件指定 prop  
205 - prop: {  
206 - type: 'color'  
207 - },  
208 - require: true,  
209 - defaultPropValue: 'black'  
210 - },  
211 - backgroundColor: {  
212 - type: 'a-input', // lbs-color-picker  
213 - label: '背景颜色',  
214 - prop: {  
215 - type: 'color'  
216 - },  
217 - require: true,  
218 - defaultPropValue: '#ffffff' // TODO why logogram for color does't work?  
219 - },  
220 borderColor: { 117 borderColor: {
221 type: 'a-input', // lbs-color-picker 118 type: 'a-input', // lbs-color-picker
222 label: '边框颜色', 119 label: '边框颜色',
@@ -264,62 +161,6 @@ export default { @@ -264,62 +161,6 @@ export default {
264 max: 10 161 max: 10
265 }, 162 },
266 defaultPropValue: 1 163 defaultPropValue: 1
267 - },  
268 - textAlign: {  
269 - type: 'lbs-text-align',  
270 - label: '文字对齐',  
271 - require: true,  
272 - defaultPropValue: 'center'  
273 - }  
274 - },  
275 - components: {  
276 - 'lbs-text-align': LbpTextAlign,  
277 - 'lbs-select-input-type': {  
278 - props: ['value'],  
279 - computed: {  
280 - value_: {  
281 - get () {  
282 - return this.value  
283 - },  
284 - set (val) {  
285 - this.$emit('input', val)  
286 - }  
287 - }  
288 - },  
289 - template: `  
290 - <a-select v-model="value_" placeholder="类型">  
291 - <a-option  
292 - v-for="item in options"  
293 - :key="item.value"  
294 - :label="item.label"  
295 - :value="item.value">  
296 - </a-option>  
297 - </a-select>  
298 - `,  
299 - data: () => ({  
300 - options: [  
301 - {  
302 - label: '文字',  
303 - value: 'text'  
304 - },  
305 - {  
306 - label: '密码',  
307 - value: 'password'  
308 - },  
309 - {  
310 - label: '日期',  
311 - value: 'date'  
312 - },  
313 - {  
314 - label: '邮箱',  
315 - value: 'email'  
316 - },  
317 - {  
318 - label: '手机号',  
319 - value: 'tel'  
320 - }  
321 - ]  
322 - })  
323 } 164 }
324 } 165 }
325 } 166 }
front-end/h5/src/components/plugins/styles/text-overwrite-quil-snow-theme.scss 0 → 100644
  1 +.quill-editor {
  2 + width: 100%;
  3 + height: 100%;
  4 +}
  5 +
  6 +.ql-toolbar.ql-snow {
  7 + position: absolute;
  8 + top: -70px;
  9 + height: 70px;
  10 + width: 300px;
  11 + padding: 0;
  12 +}
  13 +
  14 +.ql-toolbar.ql-snow .ql-formats {
  15 + margin: 0;
  16 +}
0 \ No newline at end of file 17 \ No newline at end of file