feat(): 增加 data-id 重复的容错性
This commit is contained in:
parent
5c513e470d
commit
fa3a2fd06f
|
@ -283,7 +283,7 @@ class Block implements BlockModelInterface {
|
||||||
|
|
||||||
if (hasLeft) {
|
if (hasLeft) {
|
||||||
const parent = firstNodeParent;
|
const parent = firstNodeParent;
|
||||||
leftParent = node.clone(parent, false);
|
leftParent = node.clone(parent, false, false);
|
||||||
parent.before(leftParent);
|
parent.before(leftParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ class Block implements BlockModelInterface {
|
||||||
if (hasRight) {
|
if (hasRight) {
|
||||||
const _parent = blocks[blocks.length - 1].node.parent();
|
const _parent = blocks[blocks.length - 1].node.parent();
|
||||||
if (_parent) {
|
if (_parent) {
|
||||||
rightParent = node.clone(_parent, false);
|
rightParent = node.clone(_parent, false, false);
|
||||||
_parent?.after(rightParent);
|
_parent?.after(rightParent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1119,7 +1119,7 @@ class Block implements BlockModelInterface {
|
||||||
: newRange.extractContents();
|
: newRange.extractContents();
|
||||||
const cloneBlock = keepDataId
|
const cloneBlock = keepDataId
|
||||||
? block.clone(false)
|
? block.clone(false)
|
||||||
: this.editor.node.clone(block, false);
|
: this.editor.node.clone(block, false, false);
|
||||||
cloneBlock.append(fragement);
|
cloneBlock.append(fragement);
|
||||||
if (clone) {
|
if (clone) {
|
||||||
cloneBlock.find(CARD_SELECTOR).each((card) => {
|
cloneBlock.find(CARD_SELECTOR).each((card) => {
|
||||||
|
@ -1206,7 +1206,7 @@ class Block implements BlockModelInterface {
|
||||||
parentNode.name !== block.name)
|
parentNode.name !== block.name)
|
||||||
) {
|
) {
|
||||||
//复制节点
|
//复制节点
|
||||||
const cloneNode = node.clone(parentNode, false);
|
const cloneNode = node.clone(parentNode, false, false);
|
||||||
//追加到复制的节点
|
//追加到复制的节点
|
||||||
cloneNode.append(block);
|
cloneNode.append(block);
|
||||||
//设置新的节点
|
//设置新的节点
|
||||||
|
@ -1216,7 +1216,7 @@ class Block implements BlockModelInterface {
|
||||||
} else {
|
} else {
|
||||||
block = node.replace(
|
block = node.replace(
|
||||||
block,
|
block,
|
||||||
node.clone(this.findTop(parentNode, block), false),
|
node.clone(this.findTop(parentNode, block), false, false),
|
||||||
);
|
);
|
||||||
parentNode.before(block);
|
parentNode.before(block);
|
||||||
}
|
}
|
||||||
|
@ -1262,7 +1262,7 @@ class Block implements BlockModelInterface {
|
||||||
const next = node.next();
|
const next = node.next();
|
||||||
if (!container || node.name === 'br') {
|
if (!container || node.name === 'br') {
|
||||||
prevContainer = container;
|
prevContainer = container;
|
||||||
container = this.editor.node.clone(block, false);
|
container = this.editor.node.clone(block, false, false);
|
||||||
block.before(container);
|
block.before(container);
|
||||||
}
|
}
|
||||||
if (node.name !== 'br') {
|
if (node.name !== 'br') {
|
||||||
|
@ -1305,13 +1305,13 @@ class Block implements BlockModelInterface {
|
||||||
marks.forEach((mark) => {
|
marks.forEach((mark) => {
|
||||||
// 回车后,默认是否复制makr样式
|
// 回车后,默认是否复制makr样式
|
||||||
const plugin = editor.mark.findPlugin(mark);
|
const plugin = editor.mark.findPlugin(mark);
|
||||||
mark = nodeApi.clone(mark);
|
mark = nodeApi.clone(mark, false, false);
|
||||||
//插件判断
|
//插件判断
|
||||||
if (
|
if (
|
||||||
plugin?.copyOnEnter !== false &&
|
plugin?.copyOnEnter !== false &&
|
||||||
plugin?.followStyle !== false
|
plugin?.followStyle !== false
|
||||||
) {
|
) {
|
||||||
mark = nodeApi.clone(mark);
|
mark = nodeApi.clone(mark, false, false);
|
||||||
node.before(mark);
|
node.before(mark);
|
||||||
mark.append(node);
|
mark.append(node);
|
||||||
node = mark;
|
node = mark;
|
||||||
|
|
|
@ -422,7 +422,10 @@ class ChangeModel implements ChangeInterface {
|
||||||
mergeTags.indexOf(element.name) < 0 &&
|
mergeTags.indexOf(element.name) < 0 &&
|
||||||
element.closest(mergeNode.name).length === 0
|
element.closest(mergeNode.name).length === 0
|
||||||
) {
|
) {
|
||||||
nodeApi.wrap(element, nodeApi.clone(mergeNode, false));
|
nodeApi.wrap(
|
||||||
|
element,
|
||||||
|
nodeApi.clone(mergeNode, false, false),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ class Inline implements InlineModelInterface {
|
||||||
inlineClone[0].childNodes.length !== 0 &&
|
inlineClone[0].childNodes.length !== 0 &&
|
||||||
!!inlineClone.parent()
|
!!inlineClone.parent()
|
||||||
) {
|
) {
|
||||||
inlineClone = node.clone(inlineClone, false);
|
inlineClone = node.clone(inlineClone, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -964,7 +964,7 @@ class Inline implements InlineModelInterface {
|
||||||
if (prev && prev.isText()) {
|
if (prev && prev.isText()) {
|
||||||
prev.text(prevText + '\u200b');
|
prev.text(prevText + '\u200b');
|
||||||
} else {
|
} else {
|
||||||
node.before(nodeApi.clone(zeroNode, true));
|
node.before(nodeApi.clone(zeroNode, true, false));
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
prev &&
|
prev &&
|
||||||
|
@ -990,7 +990,7 @@ class Inline implements InlineModelInterface {
|
||||||
if (next && next.isText()) {
|
if (next && next.isText()) {
|
||||||
next.text('\u200b' + next.text());
|
next.text('\u200b' + next.text());
|
||||||
} else {
|
} else {
|
||||||
node.after(this.editor.node.clone(zeroNode, true));
|
node.after(this.editor.node.clone(zeroNode, true, false));
|
||||||
if (next?.name === 'br') {
|
if (next?.name === 'br') {
|
||||||
next.remove();
|
next.remove();
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,7 +270,7 @@ class List implements ListModelInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block.name === 'li') {
|
if (block.name === 'li') {
|
||||||
const toBlock = node.clone(normalBlock, false);
|
const toBlock = node.clone(normalBlock, false, false);
|
||||||
if (indent !== 0) {
|
if (indent !== 0) {
|
||||||
toBlock.css('text-indent', indent * 2 + 'em');
|
toBlock.css('text-indent', indent * 2 + 'em');
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ class NodeModel implements NodeModelInterface {
|
||||||
// 包裹样式节点
|
// 包裹样式节点
|
||||||
if (mergeSame && this.isMark(outer)) {
|
if (mergeSame && this.isMark(outer)) {
|
||||||
//合并属性和样式值
|
//合并属性和样式值
|
||||||
const outerClone = node.clone(outer, false);
|
const outerClone = node.clone(outer, false, false);
|
||||||
if (source.name === outer.name) {
|
if (source.name === outer.name) {
|
||||||
const attributes = source.attributes();
|
const attributes = source.attributes();
|
||||||
delete attributes.style;
|
delete attributes.style;
|
||||||
|
@ -270,9 +270,9 @@ class NodeModel implements NodeModelInterface {
|
||||||
Object.keys(styles).forEach((key) => {
|
Object.keys(styles).forEach((key) => {
|
||||||
if (!outer.css(key)) outer.css(key, styles[key]);
|
if (!outer.css(key)) outer.css(key, styles[key]);
|
||||||
});
|
});
|
||||||
outer.append(node.clone(source, true).children());
|
outer.append(node.clone(source, true, false).children());
|
||||||
} else {
|
} else {
|
||||||
outer.append(node.clone(source, true));
|
outer.append(node.clone(source, true, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
const children = outer.allChildren();
|
const children = outer.allChildren();
|
||||||
|
@ -288,7 +288,7 @@ class NodeModel implements NodeModelInterface {
|
||||||
return source.replaceWith(outer);
|
return source.replaceWith(outer);
|
||||||
}
|
}
|
||||||
// 其它情况
|
// 其它情况
|
||||||
const shadowNode = node.clone(source, false);
|
const shadowNode = node.clone(source, false, false);
|
||||||
source.after(shadowNode);
|
source.after(shadowNode);
|
||||||
outer.append(source);
|
outer.append(source);
|
||||||
return shadowNode.replaceWith(outer);
|
return shadowNode.replaceWith(outer);
|
||||||
|
|
|
@ -127,7 +127,7 @@ export default class extends Plugin<Options> {
|
||||||
paintMarks(activeMarks: NodeInterface[]) {
|
paintMarks(activeMarks: NodeInterface[]) {
|
||||||
const { mark } = this.editor!;
|
const { mark } = this.editor!;
|
||||||
activeMarks.forEach((node) => {
|
activeMarks.forEach((node) => {
|
||||||
mark.wrap(this.editor.node.clone(node));
|
mark.wrap(this.editor.node.clone(node, false, false));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue