Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 1x 1x 1x 1x 1x 1x 1x 1x 1x | /**
* @description elem to html
* @author wangfupeng
*/
import { SlateElement } from '@wangeditor/editor'
import { SwiperCardElement } from './custom-types'
// 生成 html 的函数
function swiperCardToHtml(elem: SlateElement, childrenHtml: string): string {
const { imgs = '' } = elem as SwiperCardElement
const imgsArr: Array<string> = JSON.parse(imgs)
let temp: string = ''
for (const img of imgsArr) {
temp += `<img src="${img}" />`
}
const html = `<div data-w-e-type="swiper-card" class="editer-swiper" data-w-e-is-void data-imgs="${imgs}">
<div class="swiper-item">
${temp}
</div>
</div>`
return html
}
// 配置
const conf = {
type: 'swiper-card', // 节点 type ,重要!!!
elemToHtml: swiperCardToHtml,
}
export default conf
|