renderAttachment.js
547 Bytes
import { h } from 'snabbdom'
/**
* 渲染“附件”元素到编辑器
* @param elem 附件元素,即上文的 myResume
* @param children 元素子节点,void 元素可忽略
* @param editor 编辑器实例
* @returns vnode 节点(通过 snabbdom.js 的 h 函数生成)
*/
export function renderAttachment(elem, children, editor) {
const { name = '' } = elem
const Vnode = h(
'span',
{
props: { contentEditable: false },
style: { color: '#5f5efb' }
},
// 子节点
[name]
)
return Vnode
}