Commit fc8ffc4793ed40b2a9fdb57fed87b203763cf2df

Authored by ly525
1 parent be68baec

fix: #155

#!zh: 文字组件 h1 的样式 编辑模式和预览模式不一致
#!en: text component appears differently inedit mode and preview mode
front-end/h5/src/components/plugins/lbp-text.js
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: ly525 2 * @Author: ly525
3 * @Date: 2019-11-24 18:51:58 3 * @Date: 2019-11-24 18:51:58
4 * @LastEditors: ly525 4 * @LastEditors: ly525
5 - * @LastEditTime: 2019-11-30 23:01:55 5 + * @LastEditTime: 2020-04-25 11:14:38
6 * @FilePath: /luban-h5/front-end/h5/src/components/plugins/lbp-text.js 6 * @FilePath: /luban-h5/front-end/h5/src/components/plugins/lbp-text.js
7 * @Github: https://github.com/ly525/luban-h5 7 * @Github: https://github.com/ly525/luban-h5
8 * @Description: luban-h5 text component/plugin 8 * @Description: luban-h5 text component/plugin
@@ -27,7 +27,13 @@ export default { @@ -27,7 +27,13 @@ export default {
27 border: `${this.borderWidth}px solid ${this.borderColor}`, 27 border: `${this.borderWidth}px solid ${this.borderColor}`,
28 borderRadius: `${this.borderRadius}px` 28 borderRadius: `${this.borderRadius}px`
29 } 29 }
30 - const pureText = <div domPropsInnerHTML={this.text} class="ql-editor ql-container"></div> 30 + /**
  31 + * https://github.com/ly525/luban-h5/issues/155
  32 + * 需要给预览模式的文字添加 ql-snow 样式原因:文字样式和文字编辑器(ql-editor)的 theme 有关系
  33 + * 比如编辑模式 h1 样式为:.ql-snow .ql-editor h1 {font-size: 2em;}
  34 + * 因此预览模式的文字内容也需要加上 div.ql-snow > div.ql-editor 作为wrapper
  35 + */
  36 + const previewText = <div class="ql-snow"><div domPropsInnerHTML={this.text} class="ql-editor ql-container"></div></div>
31 return ( 37 return (
32 <div 38 <div
33 onDblclick={e => { 39 onDblclick={e => {
@@ -68,7 +74,7 @@ export default { @@ -68,7 +74,7 @@ export default {
68 }) 74 })
69 }}> 75 }}>
70 </quillEditor> 76 </quillEditor>
71 - : pureText 77 + : previewText
72 } 78 }
73 </div> 79 </div>
74 ) 80 )