fix: 复制列表会导致列表多层嵌套

This commit is contained in:
yanmao 2021-12-04 23:37:09 +08:00
parent f831bd3868
commit d26d96a8a9
1 changed files with 7 additions and 1 deletions

View File

@ -256,7 +256,13 @@ export default class Clipboard implements ClipboardInterface {
let parent: NodeInterface | Node | null | undefined = let parent: NodeInterface | Node | null | undefined =
curentElement?.parentElement; curentElement?.parentElement;
parent = parent ? $(parent.cloneNode(false)) : null; parent = parent ? $(parent.cloneNode(false)) : null;
if (curentElement && parent && node.isList(parent)) { const childParent = child.parentElement;
if (
curentElement &&
parent &&
node.isList(parent) &&
(!childParent || !node.isList(childParent))
) {
if (parent.name === 'ol') { if (parent.name === 'ol') {
// 设置复制位置的 start 属性,默认不设置 // 设置复制位置的 start 属性,默认不设置
// let start = parseInt(parent.attributes('start') || '0', 10) // let start = parseInt(parent.attributes('start') || '0', 10)