move more things from code into config defaults

pull/1/head
Nicholas Bollweg 2020-05-25 15:16:25 -04:00
rodzic 1625ee401d
commit c3a8924148
2 zmienionych plików z 14 dodań i 33 usunięć

Wyświetl plik

@ -23,18 +23,23 @@
"description": "URL parameters for the drawio iframe https://desk.draw.io/support/solutions/articles/16000042546-supported-url-parameters",
"$ref": "#/definitions/drawio-url-params",
"default": {
"stealth": 1,
"gapi": 0,
"od": 0,
"tr": 0,
"gl": 0,
"noExitBtn": 1
"noExitBtn": 1,
"od": 0,
"stealth": 1,
"tr": 0,
"ui": "min"
}
},
"drawioConfig": {
"description": "Configuration options sent to each drawio editor. https://desk.draw.io/support/solutions/articles/16000058316",
"$ref": "#/definitions/drawio-config",
"default": {}
"default": {
"compressXML": false,
"showStartScreen": false,
"override": true
}
}
},
"definitions": {

Wyświetl plik

@ -45,25 +45,6 @@ const CORE_EMBED_PARAMS = {
configure: 1,
};
/**
* Default embed params, mostly to turn off third-party javascript
*/
const DEFAULT_EMBED_PARAMS = {
gapi: 0, // google
od: 0, // onedrive
tr: 0, // trello
gl: 0, // gitlab
stealth: 1, // just to be sure
noExitBtn: 1, // looks/acts weird
};
const DEFAULT_CONFIG = {
compressXml: false, // bigger size, _maybe_ diffable
debug: DEBUG, // a lot going on
showStartScreen: false, // looks weird
override: true, // might help
};
/**
* Additional capabilities to allow to sandbox
*/
@ -210,10 +191,9 @@ export class DrawioWidget extends DocumentWidget<IFrame> {
}
private configureDrawio() {
let userConfig = this._settings?.drawioConfig as ReadonlyPartialJSONObject;
let settingsConfig = this._settings?.drawioConfig as ReadonlyPartialJSONObject;
const config = {
...DEFAULT_CONFIG,
...(userConfig || {}),
...(settingsConfig || {}),
version: `${+new Date()}`,
};
DEBUG && console.warn("configuring drawio", config);
@ -229,14 +209,10 @@ export class DrawioWidget extends DocumentWidget<IFrame> {
private reloadFrame(force: boolean = false) {
const query = new URLSearchParams();
const userUrlParams = this._settings
const settingsUrlParams = this._settings
?.drawioUrlParams as ReadonlyPartialJSONObject;
const params = {
...DEFAULT_EMBED_PARAMS,
ui: document.querySelector('body[data-jp-theme-light="true"]')
? "kennedy"
: "dark",
...(userUrlParams || {}),
...(settingsUrlParams || {}),
...CORE_EMBED_PARAMS,
};
for (const p in params) {