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);
nodes.forEach(function (node) {
var clone = node.clone();
var existingFieldNames = parentNode.getFieldNames();
clone.field = util.findUniqueName(node.field, existingFieldNames);
if (parentNode.type === 'object') {
var existingFieldNames = parentNode.getFieldNames();
clone.field = util.findUniqueName(node.field, existingFieldNames);
}
parentNode.insertAfter(clone, afterNode);
afterNode = clone;
});

View File

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