Added "The current bibliographic style does not describe the bibliography" error

This commit is contained in:
Artur
2025-10-29 10:14:28 +03:00
parent 207e7dbc1a
commit 1f3488b937
18 changed files with 97 additions and 46 deletions

View File

@ -67,7 +67,7 @@ CitationDocService.prototype.addCitation = function (text, value) {
Value: this._citPrefix + " " + this._citSuffix + value,
Content: text,
};
if (["note", "note-ibid"].indexOf(this._styleFormat) !== -1) {
if ("note" === this._styleFormat) {
switch (this._notesStyle) {
case "footnotes":
window.Asc.plugin.callCommand(function () {

View File

@ -166,7 +166,6 @@
cslStylesManager.setDesktopApiAvailable(apis.desktop);
cslStylesManager.setRestApiAvailable(apis.online);
if (!hasFirstAnswer) {
console.log("apis", apis);
hasFirstAnswer = true;
if (!apis.desktopVersion) {
elements.useDesktopApp.classList.add("display-none");
@ -650,7 +649,7 @@
let styleFormat = cslStylesManager.getLastUsedFormat();
citationDocService.setStyleFormat(styleFormat);
bNumFormat = styleFormat == 'numeric';
if (["note", "note-ibid"].indexOf(styleFormat) !== -1) {
if ("note" === styleFormat) {
elements.notesStyleWrapper.classList.remove(displayNoneClass);
} else {
elements.notesStyleWrapper.classList.add(displayNoneClass);
@ -827,7 +826,8 @@
loadingStyle = true;
cslStylesManager.getStyle(styleName)
.then(function (text) {
res(text); loadingStyle = false;
res(text);
loadingStyle = false;
})
.catch(function (err) { rej(err); loadingStyle = false; });
});
@ -1043,7 +1043,7 @@
showError(getMessage("Language is not selected"));
return;
}
citationDocService.getAllAddinFields().then(function(arrFields) {
return citationDocService.getAllAddinFields().then(function(arrFields) {
if (!arrFields.length) {
showLoader(false);
return;
@ -1067,10 +1067,17 @@
}
elements.tempDiv.innerHTML = bibItems.join('');
} catch (e) {
console.error(e);
showError(getMessage("Failed to apply this style."));
showLoader(false);
return;
if (
false === cslStylesManager.isLastUsedStyleContainBibliography()
) {
// style does not describe the bibliography
elements.tempDiv.textContent = "";
} else {
console.error(e);
showError(getMessage("Failed to apply this style."));
showLoader(false);
return;
}
}
var bibliography = elements.tempDiv.innerText;
@ -1110,12 +1117,16 @@
if (bibField) {
updatedFields.push(bibField);
} else if (bPastBib) {
citationDocService.addBibliography(bibliography, bibFieldValue)
.then(function() {
if (!updatedFields.length) {
showLoader(false);
}
});
if (cslStylesManager.isLastUsedStyleContainBibliography()) {
citationDocService.addBibliography(bibliography, bibFieldValue)
.then(function() {
if (!updatedFields.length) {
showLoader(false);
}
});
} else {
showError(getMessage("The current bibliographic style does not describe the bibliography"));
}
}
if (updatedFields.length) {
@ -1213,13 +1224,17 @@
});
}
} else if (bUpdadeFormatter && bPastBib) {
citationDocService.addBibliography(
getMessage(bibPlaceholder),
bibFieldValue
).then(function() {
showLoader(false);
});
if (cslStylesManager.isLastUsedStyleContainBibliography()) {
citationDocService.addBibliography(
getMessage(bibPlaceholder),
bibFieldValue
).then(function() {
showLoader(false);
});
} else {
showError(getMessage("The current bibliographic style does not describe the bibliography"));
}
}
if (bUpdadeFormatter)
updateFormatter(bUpadteAll, bPastBib, bPastLink, false);

View File

@ -11,7 +11,7 @@
*/
/**
* @typedef {"note"|"numeric"|"author"|"author-date"|"label"|"note-ibid"} StyleFormat
* @typedef {"note"|"numeric"|"author"|"author-date"|"label"} StyleFormat
*/
const CslStylesParser = {
@ -81,7 +81,6 @@ const CslStylesParser = {
if (!type) throw new Error("Citation format not found");
switch (type) {
case "note":
case "note-ibid":
case "numeric":
case "author":
case "author-date":
@ -91,4 +90,11 @@ const CslStylesParser = {
throw new Error("Invalid citation format");
},
/**
* @param {string} styleContent
* @returns {boolean}
*/
isStyleContainBibliography: function (styleContent) {
return styleContent.indexOf("<bibliography") > -1;
},
};

View File

@ -14,6 +14,7 @@ function CslStylesManager() {
this._lastStyleKey = "zoteroStyleId";
this._lastNotesStyleKey = "zoteroNotesStyleId";
this._lastFormatKey = "zoteroFormatId";
this._lastUsedStyleContainBibliographyKey = "zoteroContainBibliography";
this._defaultStyles = [
"american-medical-association",
@ -69,7 +70,6 @@ CslStylesManager.prototype.getLastUsedFormat = function () {
let lastUsedFormat = localStorage.getItem(this._lastFormatKey);
switch (lastUsedFormat) {
case "note":
case "note-ibid":
case "numeric":
case "author":
case "author-date":
@ -91,7 +91,7 @@ CslStylesManager.prototype.getLastUsedNotesStyle = function () {
};
/**
* @returns {string}
* @returns {string} - style id
*/
CslStylesManager.prototype.getLastUsedStyle = function () {
let lastUsedStyle = localStorage.getItem(this._lastStyleKey);
@ -212,9 +212,19 @@ CslStylesManager.prototype.cached = function (id) {
return null;
};
/**
* @returns {boolean}
*/
CslStylesManager.prototype.isLastUsedStyleContainBibliography = function () {
let containBibliography = localStorage.getItem(
this._lastUsedStyleContainBibliographyKey
);
return containBibliography !== "false";
};
/**
* @param {string} styleName
* @returns
* @returns {boolean}
*/
CslStylesManager.prototype.isStyleDefault = function (styleName) {
return this._defaultStyles.indexOf(styleName) >= 0;
@ -222,14 +232,14 @@ CslStylesManager.prototype.isStyleDefault = function (styleName) {
/**
* @param {string} content
* @returns
* @returns {boolean}
*/
CslStylesManager.prototype._isValidCSL = function (content) {
return (
content.includes("<?xml") &&
content.includes("<style") &&
content.includes("citation") &&
content.includes("bibliography")
content.indexOf("<?xml") > -1 &&
content.indexOf("<style") > -1 &&
content.indexOf("<macro") > -1 &&
content.indexOf("citation") > -1
);
};
@ -273,6 +283,12 @@ CslStylesManager.prototype._saveLastUsedStyle = function (id, content) {
localStorage.setItem(this._lastStyleKey, id);
const currentStyleFormat = CslStylesParser.getCitationFormat(content);
localStorage.setItem(this._lastFormatKey, currentStyleFormat);
const containBibliography =
CslStylesParser.isStyleContainBibliography(content);
localStorage.setItem(
this._lastUsedStyleContainBibliographyKey,
containBibliography.toString()
);
};
/**

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "Pripojenie k Zotero zlyhalo. Přidejte externí pripojenie v Zotero. Zjistejte, aby Zotero bezočně spolčuje",
"Failed to apply this style": "Nepodarilo se aplikovat tento styl",
"Failed to upload file": "Nepodarilo se nahrát soubor",
"Work with local Zotero": "Pracovat s lokalní Zotero"
"Work with local Zotero": "Pracovat s lokalní Zotero",
"The current bibliographic style does not describe the bibliography": "Aktuální bibliografický styl neopisuje bibliografii"
}

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "Die Verbindung zu Zotero ist fehlgeschlagen. Bitte aktivieren Sie externe Verbindungen in Zotero: Bearbeiten → Einstellungen → Erweitert → Markieren Sie \"Anderen Anwendungen auf diesem Computer erlauben mit Zotero zu kommunizieren\"",
"Failed to apply this style": "Fehler beim Anwenden dieses Stils",
"Failed to upload file": "Fehler beim Hochladen des Datei",
"Work with local Zotero": "Arbeiten mit lokalem Zotero"
"Work with local Zotero": "Arbeiten mit lokalem Zotero",
"The current bibliographic style does not describe the bibliography": "Der aktuelle bibliographische Stil beschreibt die Bibliographie nicht"
}

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "Error en la conexión a Zotero. Habilite las conexiones externas en Zotero: Editar → Ajustes → Avanzadas → Marque \"Permitir que otras aplicaciones de este se comuniquen con Zotero\"",
"Failed to apply this style": "Fallo al aplicar este estilo",
"Failed to upload file": "Fallo al subir el archivo",
"Work with local Zotero": "Trabajar con Zotero local"
"Work with local Zotero": "Trabajar con Zotero local",
"The current bibliographic style does not describe the bibliography": "El estilo bibliográfico actual no describe la bibliografía"
}

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "Échec de la connexion à Zotero. Veuillez activer les connexions externes dans Zotero : Édition → Paramètres → Avancé → Cocher «Autoriser d'autres applications sur cet ordinateur à communiquer avec Zotero»",
"Failed to apply this style": "Impossible d'appliquer ce style",
"Failed to upload file": "Échec du téléchargement du fichier",
"Work with local Zotero": "Travailler avec Zotero local"
"Work with local Zotero": "Travailler avec Zotero local",
"The current bibliographic style does not describe the bibliography": "Le style bibliographique actuel ne fait pas partie de la bibliographie"
}

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "Connessione a Zotero non riuscita. Abilita le connessioni esterne in Zotero: Modifica → Impostazioni → Avanzate → Seleziona \"Allow other applications on this computer to communicate with Zotero\"",
"Failed to apply this style": "Impossibile applicare questo stile",
"Failed to upload file": "Impossibile caricare il file",
"Work with local Zotero": "Lavora con Zotero locale"
"Work with local Zotero": "Lavora con Zotero locale",
"The current bibliographic style does not describe the bibliography": "Lo stile bibliografico corrente non descrive la bibliografia"
}

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "Zoteroへの接続に失敗しました。Zoteroで外部接続を有効にしてください編集 → 設定 → 詳細設定 → \"Allow other applications on this computer to communicate with Zotero\"をチェック",
"Failed to apply this style": "このスタイルを適用できませんでした",
"Failed to upload file": "ファイルのアップロードに失敗しました",
"Work with local Zotero": "ローカルZoteroとの作業"
"Work with local Zotero": "ローカルZoteroとの作業",
"The current bibliographic style does not describe the bibliography": "現在の文献引用スタイルは、文献引用を記述していません"
}

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "Verbinding met Zotero mislukt. Schakel externe verbindingen in Zotero in: Bewerken → Instellingen → Geavanceerd → Vink \"Allow other applications on this computer to communicate with Zotero\" aan",
"Failed to apply this style": "Het is niet gelukt deze stijl toe te passen",
"Failed to upload file": "Het uploaden van het bestand is mislukt",
"Work with local Zotero": "Werk met lokale Zotero"
"Work with local Zotero": "Werk met lokale Zotero",
"The current bibliographic style does not describe the bibliography": "De huidige bibliografische stijl beschrijft de bibliografie niet"
}

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "A conexão com o Zotero falhou. Habilite as conexões externas no Zotero: Editar → Configurações → Avançado → Marque \"Permitir que outros aplicativos neste computador se comuniquem com o Zotero\"",
"Failed to apply this style": "Falha ao aplicar este estilo",
"Failed to upload file": "Falha ao carregar o arquivo",
"Work with local Zotero": "Trabalhar com o Zotero local"
"Work with local Zotero": "Trabalhar com o Zotero local",
"The current bibliographic style does not describe the bibliography": "O estilo bibliográfico atual nao descreve a bibliografia"
}

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "A ligação com o Zotero falhou. Active as ligações externas no Zotero: Editar → Definições → Avançadas → Marque \"Permitir que outros aplicativos neste computador se comuniquem com o Zotero\"",
"Failed to apply this style": "Falha ao aplicar este estilo",
"Failed to upload file": "Falha ao carregar o ficheiro",
"Work with local Zotero": "Trabalhar com o Zotero local"
"Work with local Zotero": "Trabalhar com o Zotero local",
"The current bibliographic style does not describe the bibliography": "O estilo bibliográfico actual nao descreve a bibliografia"
}

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "Не удалось установить соединение с Zotero. Пожалуйста, включите внешние соединения в Zotero. Сделайте это в разделе \"Правка → Настройки → Расширенные\": включите галочку \"Allow other applications on this computer to communicate with Zotero\"",
"Failed to apply this style": "Не удалось применить этот стиль",
"Failed to upload file": "Не удалось загрузить файл",
"Work with local Zotero": "Работа с локальным Zotero"
"Work with local Zotero": "Работа с локальным Zotero",
"The current bibliographic style does not describe the bibliography": "Текущий стиль не описывает библиографию"
}

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "Kontakti me Zotero ka qashtuar. Ju lutem aktivizoni lidhjen ekstern ne Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"",
"Failed to apply this style": "Zbatimi i këtij stili dështoi",
"Failed to upload file": "Ngarkimi i skedarit dështoi",
"Work with local Zotero": "Zgjedhni Zotero local"
"Work with local Zotero": "Zgjedhni Zotero local",
"The current bibliographic style does not describe the bibliography": "Stili bibliografik aktual nuk shfaqet bibliografia"
}

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "Повезивање са Zotero није успело. Молимо вас да омогућите екстерне везе у Zotero: Уређивање → Подешавања → Напредно → Означите \"Дозволи осталим програмима на овом рачунару да комуницирају са Zotero\"",
"Failed to apply this style": "Примена овог стила није успела",
"Failed to upload file": "Отпремање датотеке није успело",
"Work with local Zotero": "Рад са локалном Zotero"
"Work with local Zotero": "Рад са локалном Zotero",
"The current bibliographic style does not describe the bibliography": "Текући библиографски стил не описује библиографију"
}

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "Neuspelo povezivanje na Zotero. Molimo omogucite vanjske veze u Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"",
"Failed to apply this style": "Neuspelo primjena ovog stila",
"Failed to upload file": "Neuspelo preuzimanje datoteke",
"Work with local Zotero": "Rad sa lokalnim Zotero"
"Work with local Zotero": "Rad sa lokalnim Zotero",
"The current bibliographic style does not describe the bibliography": "Trenutni bibliografski stil ne opisuje bibliografiju"
}

View File

@ -32,5 +32,6 @@
"Connection to Zotero failed. Please enable external connections in Zotero: Edit → Settings → Advanced → Check \"Allow other applications on this computer to communicate with Zotero\"": "連接到 Zotero 失敗。請在 Zotero 中啟用外部連線:編輯 → 設定 → 高級 → 檢查 \"允許此電腦上的其他應用程式與 Zotero 通訊\"",
"Failed to apply this style": "無法套用此樣式",
"Failed to upload file": "上傳文件失敗",
"Work with local Zotero": "使用本地 Zotero"
"Work with local Zotero": "使用本地 Zotero",
"The current bibliographic style does not describe the bibliography": "目前的參考文献樣式未描述參考文献"
}