-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Description
问题描述
请输入遇到的问题...
wangEditor 版本
v5+
confirmBtn.addEventListener('click', (e) => {
e.preventDefault();
const inputValue = input.value.trim();
const selection = editor.getSelectionText();
if (inputValue === '') {
return;
}
const node = SlateEditor.nodes(editor);
console.log('🚀 ~ MyModalMenu ~ getModalContentElem ~ node:', node);
editor.clear();
const styledNode = {
type: 'span', // inline 节点类型(v5 支持 span 原生标签)
style: {
color: 'red !important',
textDecoration: 'underline !important',
},
children: [{ text: '12333' }], // 必须包含 text 子节点(v5 文本节点规范)
};
editor.hidePanelOrModal();
// editor.deleteFragment();
// 第二步:在原选区位置插入带样式节点(v5 正确 API:insertNode)
editor.insertNode(styledNode);
// editor.restoreSelection(); // 恢复选区
// editor.insertText(' ');
});
自定义了一个弹窗菜单 去给选中文本添加下滑虚线,支持设置虚线的粗细,给弹窗提交按钮绑定了事件,但是调用了文档上的api 大多都不生效,比如 addMark, editor.deleteFragment();等等,上面这段代码是按钮点击回调事件,看看是什么原因引起的。。。。
是否查阅了文档 ?
(文档链接 www.wangeditor.com )
是
最小成本的复现步骤
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels