Fix duplicate not working for arrays anymore

This commit is contained in:
jos 2019-03-30 14:15:24 +01:00
parent 6ccf5c651d
commit 19a625fa6e
2 changed files with 8 additions and 4 deletions

View File

@ -123,8 +123,10 @@ function History (editor) {
var nodes = params.paths.map(findNode); var nodes = params.paths.map(findNode);
nodes.forEach(function (node) { nodes.forEach(function (node) {
var clone = node.clone(); var clone = node.clone();
var existingFieldNames = parentNode.getFieldNames(); if (parentNode.type === 'object') {
clone.field = util.findUniqueName(node.field, existingFieldNames); var existingFieldNames = parentNode.getFieldNames();
clone.field = util.findUniqueName(node.field, existingFieldNames);
}
parentNode.insertAfter(clone, afterNode); parentNode.insertAfter(clone, afterNode);
afterNode = clone; afterNode = clone;
}); });

View File

@ -3508,8 +3508,10 @@ Node.onDuplicate = function(nodes) {
var afterNode = lastNode; var afterNode = lastNode;
var clones = nodes.map(function (node) { var clones = nodes.map(function (node) {
var clone = node.clone(); var clone = node.clone();
var existingFieldNames = node.parent.getFieldNames(); if (node.parent.type === 'object') {
clone.field = util.findUniqueName(node.field, existingFieldNames); var existingFieldNames = node.parent.getFieldNames();
clone.field = util.findUniqueName(node.field, existingFieldNames);
}
parent.insertAfter(clone, afterNode); parent.insertAfter(clone, afterNode);
afterNode = clone; afterNode = clone;
return clone; return clone;