Same functionality as previous commit, but newlines now parsed in tagsbox.xml instead of addTag() function, just like creator newlines are parsed in itembox.xml
This commit is contained in:
parent
9285b0cfb1
commit
86fa29bf14
2 changed files with 15 additions and 12 deletions
|
@ -430,8 +430,10 @@
|
||||||
// Tag id encoded as 'tag-1234'
|
// Tag id encoded as 'tag-1234'
|
||||||
var id = row.getAttribute('id').split('-')[1];
|
var id = row.getAttribute('id').split('-')[1];
|
||||||
|
|
||||||
|
var newlinePresent = (value.search('\r') > -1 || value.search('\n') > -1);
|
||||||
|
|
||||||
if (saveChanges) {
|
if (saveChanges) {
|
||||||
if (id) {
|
if (id && newlinePresent != true) {
|
||||||
if (value) {
|
if (value) {
|
||||||
// If trying to replace with another existing tag
|
// If trying to replace with another existing tag
|
||||||
// (which causes a delete of the row),
|
// (which causes a delete of the row),
|
||||||
|
@ -453,7 +455,18 @@
|
||||||
}
|
}
|
||||||
// New tag
|
// New tag
|
||||||
else {
|
else {
|
||||||
var id = tagsbox.add(value);
|
//Check for newlines or carriage returns used as delimiters
|
||||||
|
//in a series of tags added at once. Add each tag
|
||||||
|
//separately.
|
||||||
|
if (newlinePresent) {
|
||||||
|
value = value.replace('\r\n','\n');
|
||||||
|
value = value.replace('\r','\n');
|
||||||
|
var nameArray = value.split('\n');
|
||||||
|
id = this.item.addTags(nameArray);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
id = tagsbox.add(value);
|
||||||
|
}
|
||||||
if (!id) {
|
if (!id) {
|
||||||
this._lastTabIndex--;
|
this._lastTabIndex--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3479,16 +3479,6 @@ Zotero.Item.prototype.addTag = function(name, type) {
|
||||||
throw ('Cannot add tag to unsaved item in Item.addTag()');
|
throw ('Cannot add tag to unsaved item in Item.addTag()');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check for newlines or carriage returns used as delimiters
|
|
||||||
//in a series of tags added at once. Add each tag
|
|
||||||
//separately.
|
|
||||||
if (name.search('\r') > -1 || name.search('\n') > -1) {
|
|
||||||
name = name.replace('\r\n','\n');
|
|
||||||
name = name.replace('\r','\n');
|
|
||||||
var nameArray = name.split('\n');
|
|
||||||
return this.addTags(nameArray,type);
|
|
||||||
}
|
|
||||||
|
|
||||||
name = Zotero.Utilities.trim(name);
|
name = Zotero.Utilities.trim(name);
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
|
|
Loading…
Reference in a new issue