Merge branch '2024.9-rc' of github.com:cryptpad/cryptpad into 2024.9-rc

This commit is contained in:
yflory 2024-09-30 17:43:51 +02:00
commit f9fdb599d9
3 changed files with 17 additions and 12 deletions

View File

@ -3,15 +3,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
define([
'/components/x2js/x2js.js',
'/diagram/util.js',
], function (
X2JS,
DiagramUtil
) {
const x2js = new X2JS();
const jsonContentAsXML = (content) => x2js.js2xml(content);
const parseDrawioStyle = (styleAttrValue) => {
if (!styleAttrValue) {
return;
@ -70,12 +65,12 @@ define([
}
return doc;
};
return {
main: function(userDoc, cb) {
delete userDoc.metadata;
const xml = jsonContentAsXML(userDoc);
const xml = DiagramUtil.jsonContentAsXML(userDoc);
let doc;
try {

View File

@ -95,11 +95,9 @@ define([
drawioFrame.contentWindow.postMessage(JSON.stringify(msg), '*');
};
const jsonContentAsXML = (content) => x2js.js2xml(content);
var onDrawioInit = function() {
drawIoInitalized = true;
var xmlStr = jsonContentAsXML(lastContent);
var xmlStr = DiagramUtil.jsonContentAsXML(lastContent);
postMessageToDrawio({
action: 'load',
xml: xmlStr,
@ -165,7 +163,7 @@ define([
// This is the function from which you will receive updates from CryptPad
framework.onContentUpdate(function (newContent) {
lastContent = newContent;
var xmlStr = jsonContentAsXML(lastContent);
var xmlStr = DiagramUtil.jsonContentAsXML(lastContent);
postMessageToDrawio({
action: 'merge',
xml: xmlStr,

View File

@ -6,12 +6,15 @@ define([
'/common/common-util.js',
'/file/file-crypto.js',
'/common/outer/cache-store.js',
'/components/x2js/x2js.js',
], function (
Util,
FileCrypto,
Cache
Cache,
X2JS,
) {
const Nacl = window.nacl;
const x2js = new X2JS();
const parseCryptPadUrl = function(href) {
const url = new URL(href);
@ -38,9 +41,18 @@ define([
return fixedBlob;
};
const jsonContentAsXML = (content) => {
// Sometimes `content` has additional fiels, that break the XML output. Only grab mxfile here.
const cleaned = { mxfile: content.mxfile };
return x2js.js2xml(cleaned);
};
return {
parseCryptPadUrl,
getCryptPadUrl,
jsonContentAsXML,
loadImage: function(href) {
return new Promise((resolve, reject) => {