mirror of
https://github.com/ONLYOFFICE/onlyoffice.github.io.git
synced 2026-04-07 14:04:30 +08:00
modal window
This commit is contained in:
1808
sdkjs-plugins/content/zotero/dist/bundle.es5.js
vendored
1808
sdkjs-plugins/content/zotero/dist/bundle.es5.js
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
1688
sdkjs-plugins/content/zotero/dist/bundle.modern.js
vendored
1688
sdkjs-plugins/content/zotero/dist/bundle.modern.js
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
87
sdkjs-plugins/content/zotero/info-window.html
Normal file
87
sdkjs-plugins/content/zotero/info-window.html
Normal file
@ -0,0 +1,87 @@
|
||||
<!--
|
||||
(c) Copyright Ascensio System SIA 2010-2025
|
||||
|
||||
This program is a free software product. You can redistribute it and/or
|
||||
modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
version 3 as published by the Free Software Foundation. In accordance with
|
||||
Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
of any third-party rights.
|
||||
|
||||
This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
street, Riga, Latvia, EU, LV-1050.
|
||||
|
||||
The interactive user interfaces in modified source and object code versions
|
||||
of the Program must display Appropriate Legal Notices, as required under
|
||||
Section 5 of the GNU AGPL version 3.
|
||||
|
||||
Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
grant you any rights under trademark law for use of our trademarks.
|
||||
|
||||
All the Product's GUI elements, including illustrations and icon sets, as
|
||||
well as technical writing content are licensed under the terms of the
|
||||
Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>Summarization</title>
|
||||
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.js"></script>
|
||||
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins-ui.js"></script>
|
||||
<link rel="stylesheet" href="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body class="noselect">
|
||||
<div class="content">
|
||||
<p>
|
||||
You have modified this citation since Zotero generated it. Do you want to keep your modifications and
|
||||
prevent future updates?
|
||||
</p>
|
||||
<p>
|
||||
Clicking "Yes" will prevent Zotero from updating this citation if you add additional citations, switch
|
||||
styles, or modify the item to which it refers.
|
||||
Clicking "No" will erase your changes.
|
||||
</p>
|
||||
</div>
|
||||
<div id="loader" class="loader-container loader-container-main hidden">
|
||||
<div class="loader-bg"></div>
|
||||
<div class="loader-body">
|
||||
<svg class="loader-image" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
<circle cx="10" cy="10" fill="none" stroke="currentColor" stroke-width="1.5" r="7.25"
|
||||
stroke-dasharray="160%, 40%" />
|
||||
</svg>
|
||||
<div class="loader-title i18n">Loading...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function (window, undefined) {
|
||||
window.Asc.plugin.init = function (data) {
|
||||
console.log("init", data);
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when a button in the plugin's UI is clicked.
|
||||
* @param {number} id - The ordinal number of the button that was clicked.
|
||||
*/
|
||||
window.Asc.plugin.button = function (id) {
|
||||
console.log("button", id);
|
||||
window.Asc.plugin.executeCommand("close", "");
|
||||
};
|
||||
|
||||
})(window, undefined);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -45,48 +45,50 @@
|
||||
import { CitationDocService } from "./citation-doc-service";
|
||||
import { translate } from "./translate-service";
|
||||
import { CSLCitation, CSLCitationStorage } from "../csl/citation";
|
||||
import { AdditionalWindow } from "../shared/ui";
|
||||
|
||||
/**
|
||||
* @param {LocalesManager} localesManager
|
||||
* @param {CslStylesManager} cslStylesManager
|
||||
* @param {ZoteroSdk} sdk
|
||||
*/
|
||||
function CitationService(localesManager, cslStylesManager, sdk) {
|
||||
this._bibPlaceholderIfEmpty =
|
||||
"Please insert some citation into the document.";
|
||||
this._citPrefixNew = "ZOTERO_ITEM";
|
||||
this._citSuffixNew = "CSL_CITATION";
|
||||
this._citPrefix = "ZOTERO_CITATION";
|
||||
this._bibPrefixNew = "ZOTERO_BIBL";
|
||||
this._bibSuffixNew = "CSL_BIBLIOGRAPHY";
|
||||
this._bibPrefix = "ZOTERO_BIBLIOGRAPHY";
|
||||
this._sdk = sdk;
|
||||
this._localesManager = localesManager;
|
||||
this._cslStylesManager = cslStylesManager;
|
||||
this._storage = new CSLCitationStorage();
|
||||
/** @type {CSL.Engine} */
|
||||
this._formatter;
|
||||
this.citationDocService = new CitationDocService(
|
||||
this._citPrefixNew,
|
||||
this._citSuffixNew,
|
||||
this._bibPrefixNew,
|
||||
this._bibSuffixNew
|
||||
);
|
||||
/** @type {NoteStyle} */
|
||||
this._notesStyle;
|
||||
/** @type {StyleFormat} */
|
||||
this._styleFormat;
|
||||
}
|
||||
class CitationService {
|
||||
#onUserEditCitationManuallyWindow;
|
||||
|
||||
CitationService.prototype = {
|
||||
constructor: CitationService,
|
||||
/**
|
||||
* @param {LocalesManager} localesManager
|
||||
* @param {CslStylesManager} cslStylesManager
|
||||
* @param {ZoteroSdk} sdk
|
||||
*/
|
||||
constructor(localesManager, cslStylesManager, sdk) {
|
||||
this._bibPlaceholderIfEmpty =
|
||||
"Please insert some citation into the document.";
|
||||
this._citPrefixNew = "ZOTERO_ITEM";
|
||||
this._citSuffixNew = "CSL_CITATION";
|
||||
this._citPrefix = "ZOTERO_CITATION";
|
||||
this._bibPrefixNew = "ZOTERO_BIBL";
|
||||
this._bibSuffixNew = "CSL_BIBLIOGRAPHY";
|
||||
this._bibPrefix = "ZOTERO_BIBLIOGRAPHY";
|
||||
this._sdk = sdk;
|
||||
this._localesManager = localesManager;
|
||||
this._cslStylesManager = cslStylesManager;
|
||||
this._storage = new CSLCitationStorage();
|
||||
/** @type {CSL.Engine} */
|
||||
this._formatter;
|
||||
this.citationDocService = new CitationDocService(
|
||||
this._citPrefixNew,
|
||||
this._citSuffixNew,
|
||||
this._bibPrefixNew,
|
||||
this._bibSuffixNew
|
||||
);
|
||||
/** @type {NoteStyle} */
|
||||
this._notesStyle;
|
||||
/** @type {StyleFormat} */
|
||||
this._styleFormat;
|
||||
this.#onUserEditCitationManuallyWindow = new AdditionalWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} cslCitation
|
||||
* @returns {Promise<Array<string|number>>}
|
||||
*/
|
||||
_formatInsertLink: function (cslCitation) {
|
||||
#formatInsertLink(cslCitation) {
|
||||
const self = this;
|
||||
let bUpdateItems = false;
|
||||
/** @type {Array<string|number>} */
|
||||
@ -138,13 +140,13 @@ CitationService.prototype = {
|
||||
.then(function () {
|
||||
return keys;
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<any>} items
|
||||
* @returns {Promise<Array<SearchResultItem>>}
|
||||
*/
|
||||
_getSelectedInJsonFormat: function (items) {
|
||||
#getSelectedInJsonFormat(items) {
|
||||
var arrUsrItems = [];
|
||||
/** @type {Object<string, string[]>} */
|
||||
var arrGroupsItems = {};
|
||||
@ -201,9 +203,9 @@ CitationService.prototype = {
|
||||
});
|
||||
return items;
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
_makeBibliography: function () {
|
||||
#makeBibliography() {
|
||||
const self = this;
|
||||
const fragment = document.createDocumentFragment();
|
||||
const tempElement = document.createElement("div");
|
||||
@ -247,10 +249,10 @@ CitationService.prototype = {
|
||||
}
|
||||
}
|
||||
return tempElement.innerText;
|
||||
},
|
||||
}
|
||||
|
||||
/** @param {CustomField} field */
|
||||
_extractField: function (field) {
|
||||
#extractField(field) {
|
||||
let citationObject;
|
||||
const citationStartIndex = field.Value.indexOf("{");
|
||||
const citationEndIndex = field.Value.lastIndexOf("}");
|
||||
@ -262,13 +264,13 @@ CitationService.prototype = {
|
||||
citationObject = JSON.parse(citationString);
|
||||
}
|
||||
return citationObject;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Promise<{bibField: CustomField | undefined, fields: CustomField[], updatedFields: CustomField[], bibFieldValue: string}>}
|
||||
*/
|
||||
_synchronizeStorageWithDocItems: function () {
|
||||
#synchronizeStorageWithDocItems() {
|
||||
const self = this;
|
||||
return this.citationDocService
|
||||
.getAddinZoteroFields()
|
||||
@ -288,7 +290,7 @@ CitationService.prototype = {
|
||||
);
|
||||
});
|
||||
if (bibField) {
|
||||
let citationObject = self._extractField(bibField);
|
||||
let citationObject = self.#extractField(bibField);
|
||||
if (
|
||||
typeof citationObject === "object" &&
|
||||
Object.keys(citationObject).length > 0
|
||||
@ -304,7 +306,7 @@ CitationService.prototype = {
|
||||
);
|
||||
});
|
||||
const fieldsWithCitations = fields.map(function (field) {
|
||||
let citationObject = self._extractField(field);
|
||||
let citationObject = self.#extractField(field);
|
||||
|
||||
let citationID = ""; // old format
|
||||
if (field.Value.indexOf(self._citPrefix) === -1) {
|
||||
@ -320,17 +322,30 @@ CitationService.prototype = {
|
||||
return { field: { ...field }, cslCitation: cslCitation };
|
||||
});
|
||||
|
||||
self._updateFormatter();
|
||||
self.#updateFormatter();
|
||||
|
||||
/** @type {CustomField[]} */
|
||||
const updatedFields = fieldsWithCitations.map(function ({
|
||||
field,
|
||||
cslCitation,
|
||||
}, index) {
|
||||
const updatedFields = fieldsWithCitations.map(function (
|
||||
{ field, cslCitation },
|
||||
index
|
||||
) {
|
||||
let keysL = cslCitation.getInfoForCitationCluster();
|
||||
tempElement.innerHTML =
|
||||
self._formatter.makeCitationCluster(keysL);
|
||||
field["Content"] = tempElement.innerText;
|
||||
const oldContent = field["Content"];
|
||||
const newContent = tempElement.innerText;
|
||||
|
||||
if (oldContent !== newContent) {
|
||||
field["Content"] = newContent;
|
||||
/* self.#onUserEditCitationManuallyWindow.show(
|
||||
"info-window",
|
||||
"Zotero Citation",
|
||||
newContent
|
||||
);*/
|
||||
}
|
||||
|
||||
console.log(cslCitation.getDoNotUpdate());
|
||||
|
||||
// cslCitation.addPlainCitation(field["Content"]);
|
||||
if (cslCitation) {
|
||||
field["Value"] =
|
||||
@ -350,9 +365,9 @@ CitationService.prototype = {
|
||||
bibFieldValue: bibFieldValue,
|
||||
};
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
_updateFormatter: function () {
|
||||
#updateFormatter() {
|
||||
const self = this;
|
||||
|
||||
/** @type {string[]} */
|
||||
@ -389,34 +404,34 @@ CitationService.prototype = {
|
||||
}
|
||||
|
||||
return;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
saveAsText: function () {
|
||||
saveAsText() {
|
||||
return this.citationDocService.saveAsText();
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {NoteStyle} notesStyle
|
||||
*/
|
||||
setNotesStyle: function (notesStyle) {
|
||||
setNotesStyle(notesStyle) {
|
||||
this._notesStyle = notesStyle;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {StyleFormat} styleFormat
|
||||
*/
|
||||
setStyleFormat: function (styleFormat) {
|
||||
setStyleFormat(styleFormat) {
|
||||
this._styleFormat = styleFormat;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<SearchResultItem>} items
|
||||
* @returns {Promise<Array<string|number>>}
|
||||
*/
|
||||
insertSelectedCitations: function (items) {
|
||||
insertSelectedCitations(items) {
|
||||
const self = this;
|
||||
|
||||
var cslCitation = new CSLCitation(self._storage.size, "");
|
||||
@ -426,13 +441,13 @@ CitationService.prototype = {
|
||||
cslCitation.fillFromObject(item);
|
||||
}
|
||||
|
||||
return this._getSelectedInJsonFormat(items).then(function (items) {
|
||||
return this.#getSelectedInJsonFormat(items).then(function (items) {
|
||||
items.forEach(function (item) {
|
||||
cslCitation.fillFromObject(item);
|
||||
});
|
||||
return self._formatInsertLink(cslCitation);
|
||||
return self.#formatInsertLink(cslCitation);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
// onInit (0,0)
|
||||
// Insert Citation (0,0)
|
||||
@ -443,11 +458,11 @@ CitationService.prototype = {
|
||||
* @param {boolean} bPastBib
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
updateCslItems: function (bUpdateAll, bPastBib) {
|
||||
updateCslItems(bUpdateAll, bPastBib) {
|
||||
this._storage.clear();
|
||||
const self = this;
|
||||
|
||||
return this._synchronizeStorageWithDocItems()
|
||||
return this.#synchronizeStorageWithDocItems()
|
||||
.then(function (info) {
|
||||
const { fields, updatedFields, bibField, bibFieldValue } = info;
|
||||
|
||||
@ -460,10 +475,13 @@ CitationService.prototype = {
|
||||
bibField["Content"] = translate(
|
||||
self._bibPlaceholderIfEmpty
|
||||
);
|
||||
} else {
|
||||
let bibliography = self.#makeBibliography();
|
||||
bibField["Content"] = bibliography;
|
||||
}
|
||||
updatedFields.push(bibField);
|
||||
} else if (bPastBib) {
|
||||
let bibliography = self._makeBibliography();
|
||||
let bibliography = self.#makeBibliography();
|
||||
if (updatedFields.length === 0) {
|
||||
bibliography = translate(self._bibPlaceholderIfEmpty);
|
||||
}
|
||||
@ -490,7 +508,7 @@ CitationService.prototype = {
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export { CitationService };
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
// @ts-check
|
||||
|
||||
/// <reference path="../../types-global.js" />
|
||||
|
||||
class AdditionalWindow {
|
||||
constructor() {
|
||||
this._window = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} fileName
|
||||
* @param {string} description
|
||||
* @param {string} text
|
||||
*/
|
||||
show(fileName, description, text) {
|
||||
const self = this;
|
||||
let variation = {
|
||||
url: fileName + ".html",
|
||||
description: window.Asc.plugin.tr(description),
|
||||
isVisual: true,
|
||||
/*buttons: [
|
||||
{
|
||||
text: window.Asc.plugin.tr("Yes"),
|
||||
primary: true,
|
||||
isViewer: false,
|
||||
},
|
||||
{ text: window.Asc.plugin.tr("No"), primary: false },
|
||||
],*/
|
||||
isModal: false,
|
||||
EditorsSupport: ["word"],
|
||||
size: [400, 310],
|
||||
isViewer: true,
|
||||
isDisplayedInViewer: false,
|
||||
isInsideMode: false,
|
||||
};
|
||||
|
||||
this._window = new window.Asc.PluginWindow();
|
||||
|
||||
this._window.show(variation);
|
||||
|
||||
this._window.button = function (id) {
|
||||
console.log("button", id);
|
||||
window.Asc.plugin.executeCommand("close", "");
|
||||
};
|
||||
}
|
||||
|
||||
hide() {}
|
||||
}
|
||||
|
||||
export { AdditionalWindow };
|
||||
@ -1,2 +1,3 @@
|
||||
export { SearchFilterComponents } from "./search-filter.js";
|
||||
export { SelectCitationsComponent } from "./select-citation.js";
|
||||
export { AdditionalWindow } from "./additional-window.js";
|
||||
|
||||
@ -442,6 +442,7 @@ var AscSimpleRequest = window.AscSimpleRequest;
|
||||
* @typedef {Object} Asc
|
||||
* @property {AscPlugin} plugin
|
||||
* @property {{positions: Array<SupSubPositions>}} scope
|
||||
* @property {any} PluginWindow
|
||||
*/
|
||||
|
||||
/** @type {Asc} */
|
||||
|
||||
Reference in New Issue
Block a user