編輯器導(dǎo)出內(nèi)容支持帶標(biāo)簽的 html和純文本的 text,編輯器內(nèi)部采用 delta 格式進(jìn)行存儲。
通過setContents接口設(shè)置內(nèi)容時,解析插入的 html 可能會由于一些非法標(biāo)簽導(dǎo)致解析錯誤,建議開發(fā)者在小程序內(nèi)使用時通過 delta 進(jìn)行插入。
富文本組件內(nèi)部引入了一些基本的樣式使得內(nèi)容可以正確的展示,開發(fā)時可以進(jìn)行覆蓋。需要注意的是,在其它組件或環(huán)境中使用富文本組件導(dǎo)出的html時,需要額外引入 這段樣式,并維護(hù)<ql-container><ql-editor></ql-editor></ql-container>的結(jié)構(gòu)。
圖片控件僅初始化時設(shè)置有效。
相關(guān) api:EditorContext
屬性 | 類型 | 默認(rèn)值 | 必填 | 說明 | 最低版本 |
---|---|---|---|---|---|
read-only | boolean | false | 否 | 設(shè)置編輯器為只讀 | 2.7.0 |
placeholder | string | 否 | 提示信息 | 2.7.0 | |
show-img-size | boolean | false | 否 | 點擊圖片時顯示圖片大小控件 | 2.7.0 |
show-img-toolbar | boolean | false | 否 | 點擊圖片時顯示工具欄控件 | 2.7.0 |
show-img-resize | boolean | false | 否 | 點擊圖片時顯示修改尺寸控件 | 2.7.0 |
bindready | eventhandle | 否 | 編輯器初始化完成時觸發(fā) | 2.7.0 | |
bindfocus | eventhandle | 否 | 編輯器聚焦時觸發(fā),event.detail = {html, text, delta} | 2.7.0 | |
bindblur | eventhandle | 否 | 編輯器失去焦點時觸發(fā),detail = {html, text, delta} | 2.7.0 | |
bindinput | eventhandle | 否 | 編輯器內(nèi)容改變時觸發(fā),detail = {html, text, delta} | 2.7.0 | |
bindstatuschange | eventhandle | 否 | 通過 Context 方法改變編輯器內(nèi)樣式時觸發(fā),返回選區(qū)已設(shè)置的樣式 | 2.7.0 |
編輯器內(nèi)支持部分 HTML 標(biāo)簽和內(nèi)聯(lián)樣式,不支持class和id
支持的標(biāo)簽
不滿足的標(biāo)簽會被忽略,<div>會被轉(zhuǎn)行為<p>儲存。
類型 | 節(jié)點 |
---|---|
行內(nèi)元素 | <span> <strong> <b> <ins> <em> <i>
<u> <a> <del> <s> <sub> <sup>
<img> |
塊級元素 | <p> <h1> <h2> <h3> <h4> <h5>
<h6> <hr> <ol> <ul>
<li> |
支持的內(nèi)聯(lián)樣式
內(nèi)聯(lián)樣式僅能設(shè)置在行內(nèi)元素或塊級元素上,不能同時設(shè)置。例如 font-size 歸類為行內(nèi)元素屬性,在 p 標(biāo)簽上設(shè)置是無效的。
類型 | 樣式 |
---|---|
塊級樣式 | text-align direction margin margin-top margin-left margin-right margin-bottom padding padding-top padding-left padding-right padding-bottom line-height text-indent |
行內(nèi)樣式 | font font-size font-style font-variant font-weight font-family letter-spacing text-decoration color background-color |