Global option to save all new files as uncompressed
I found out about the compressed="false" attribute here: https://github.com/jgraph/drawio-desktop/issues/79
Cool. So my understanding is that in order to convert an existing diagram to uncompressed text, I need to do the following:
- Open
foo.drawioin a text editor - Add
compressed="false"to themxfilenode and save - Open
foo.drawioin Draw.io. - Hit cmd+s to save
I have about 600 existing .drawio files that I would like to convert to plain text. This is a bit annoying, but doable in a pseudo automatic way.
In addition to that, I will have to perform this procedure every time I create a new diagram, right? Because there's no way to set compressed="false" by default?
It would be great if there was a checkbox somewhere to save all files as uncompressed.
In case you're interested, the use case I have in mind is annotating my diagrams with additional info via a rewrite script that runs in the background periodically. For example coloring nodes based on how recently they were modified. It's a lot easier to perform this sort of operation on uncompressed files.
I guess I might as well leave this here:
const fs = require('fs')
const path = require('path')
const expand_home_dir = require('expand-home-dir');
const glob = require("glob")
function convert_all_files_to_uncompressed(root_dir_path) {
glob.glob(path.join(root_dir_path, '**/*.drawio'), function (er, paths) {
for(let i = 0; i < paths.length; i++) {
console.log('path:', paths[i]);
fs.readFile(paths[i], 'utf8', function(err, text) {
text = text.replace('<mxfile', '<mxfile compressed="false"')
fs.writeFile(paths[i], text, function() {
console.log('wrote:', paths[i]);
});
});
}
});
}
convert_all_files_to_uncompressed(expand_home_dir('~/Dropbox/diagrams'));
Then you can do:
find . | grep drawio > out.sh
then you add open before each line and run the script in batches of fifty.
Then you just have to hit cmd+s and close the window 50 times per batch haha.
It took me about 15 minutes to convert all my diagrams.
I still don't have a good solution for new diagrams though.
I tried writing a looping background script that runs periodically, setting compressed=false for all diagrams in order to solve the problem of new diagrams saving as compressed. But if the drawio file is currently open the synchronization operation discards the new compressed attribute. If synchronization preserved the compressed attribute that would solve my problem.
To set the default to not compress files. From Extras -> draw.io Configuration... Add the following JSON config:
{
"compressXml": false
}
In next version, there will be also an option in Extras menu to compress/decompress the currently open file.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. See the FAQ for more information.
Literally nobody seems to want compression, so we'll default to uncompressed in the next release.