Skip to content

createAtomWrap ​

将 atom 节点的 contentDOM 包裹进 span.qp-atom-wrap,前后各插入一个零宽空格。给光标提供落点,避免聚焦原子节点时出现选中闪烁。一般由节点扩展内部使用。

用法 ​

ts
import { createAtomWrap } from '@qingpai/utils'

const contentDOM = document.createElement('span')
dom.append(createAtomWrap(contentDOM))

参数 ​

名称类型描述
contentDOMHTMLElementatom 节点的 contentDOM
attributes?Record<string, any>附加属性;class 会与 qp-atom-wrap 合并

返回值 ​

HTMLElement — 包裹后的元素,结构为 span.qp-atom-wrap(零宽空格 + contentDOM + 零宽空格)。

轻排编辑器 — 教育领域富文本编辑器