Status bar widgets are disabled for HTML output
This commit is contained in:
parent
ff45f61b68
commit
1b3d55f051
@ -449,6 +449,11 @@
|
|||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cm-status-bar .disabled {
|
||||||
|
background-color: unset !important;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
/* Dropup Button */
|
/* Dropup Button */
|
||||||
.cm-status-bar-select-btn {
|
.cm-status-bar-select-btn {
|
||||||
border: none;
|
border: none;
|
||||||
|
@ -22,6 +22,7 @@ class StatusBarPanel {
|
|||||||
this.eolHandler = opts.eolHandler;
|
this.eolHandler = opts.eolHandler;
|
||||||
this.chrEncHandler = opts.chrEncHandler;
|
this.chrEncHandler = opts.chrEncHandler;
|
||||||
this.chrEncGetter = opts.chrEncGetter;
|
this.chrEncGetter = opts.chrEncGetter;
|
||||||
|
this.htmlOutput = opts.htmlOutput;
|
||||||
|
|
||||||
this.eolVal = null;
|
this.eolVal = null;
|
||||||
this.chrEncVal = null;
|
this.chrEncVal = null;
|
||||||
@ -65,6 +66,9 @@ class StatusBarPanel {
|
|||||||
const el = e.target
|
const el = e.target
|
||||||
.closest(".cm-status-bar-select")
|
.closest(".cm-status-bar-select")
|
||||||
.querySelector(".cm-status-bar-select-content");
|
.querySelector(".cm-status-bar-select-content");
|
||||||
|
const btn = e.target.closest(".cm-status-bar-select-btn");
|
||||||
|
|
||||||
|
if (btn.classList.contains("disabled")) return;
|
||||||
|
|
||||||
el.classList.add("show");
|
el.classList.add("show");
|
||||||
|
|
||||||
@ -269,6 +273,30 @@ class StatusBarPanel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether there is HTML output requiring some widgets to be disabled
|
||||||
|
*/
|
||||||
|
monitorHTMLOutput() {
|
||||||
|
if (!this.htmlOutput?.changed) return;
|
||||||
|
|
||||||
|
if (this.htmlOutput?.html === "") {
|
||||||
|
// Enable all controls
|
||||||
|
this.dom.querySelectorAll(".disabled").forEach(el => {
|
||||||
|
el.classList.remove("disabled");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Disable chrenc, length, selection etc.
|
||||||
|
this.dom.querySelectorAll(".cm-status-bar-select-btn").forEach(el => {
|
||||||
|
el.classList.add("disabled");
|
||||||
|
});
|
||||||
|
|
||||||
|
this.dom.querySelector(".stats-length-value").parentNode.classList.add("disabled");
|
||||||
|
this.dom.querySelector(".stats-lines-value").parentNode.classList.add("disabled");
|
||||||
|
this.dom.querySelector(".sel-info").classList.add("disabled");
|
||||||
|
this.dom.querySelector(".cur-offset-info").classList.add("disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the Left-hand-side widgets
|
* Builds the Left-hand-side widgets
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
@ -404,6 +432,7 @@ function makePanel(opts) {
|
|||||||
sbPanel.updateBakeStats();
|
sbPanel.updateBakeStats();
|
||||||
sbPanel.updateStats(view.state.doc);
|
sbPanel.updateStats(view.state.doc);
|
||||||
sbPanel.updateSelection(view.state, false);
|
sbPanel.updateSelection(view.state, false);
|
||||||
|
sbPanel.monitorHTMLOutput();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"dom": sbPanel.dom,
|
"dom": sbPanel.dom,
|
||||||
@ -412,6 +441,7 @@ function makePanel(opts) {
|
|||||||
sbPanel.updateCharEnc();
|
sbPanel.updateCharEnc();
|
||||||
sbPanel.updateSelection(update.state, update.selectionSet);
|
sbPanel.updateSelection(update.state, update.selectionSet);
|
||||||
sbPanel.updateBakeStats();
|
sbPanel.updateBakeStats();
|
||||||
|
sbPanel.monitorHTMLOutput();
|
||||||
if (update.geometryChanged) {
|
if (update.geometryChanged) {
|
||||||
sbPanel.updateSizing(update.view);
|
sbPanel.updateSizing(update.view);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,8 @@ class OutputWaiter {
|
|||||||
bakeStats: this.bakeStats,
|
bakeStats: this.bakeStats,
|
||||||
eolHandler: this.eolChange.bind(this),
|
eolHandler: this.eolChange.bind(this),
|
||||||
chrEncHandler: this.chrEncChange.bind(this),
|
chrEncHandler: this.chrEncChange.bind(this),
|
||||||
chrEncGetter: this.getChrEnc.bind(this)
|
chrEncGetter: this.getChrEnc.bind(this),
|
||||||
|
htmlOutput: this.htmlOutput
|
||||||
}),
|
}),
|
||||||
htmlPlugin(this.htmlOutput),
|
htmlPlugin(this.htmlOutput),
|
||||||
copyOverride(),
|
copyOverride(),
|
||||||
@ -564,9 +565,6 @@ class OutputWaiter {
|
|||||||
|
|
||||||
switch (output.data.type) {
|
switch (output.data.type) {
|
||||||
case "html":
|
case "html":
|
||||||
// TODO what if the HTML content needs to be in a certain character encoding?
|
|
||||||
// Grey out chr enc selection? Set back to Raw Bytes?
|
|
||||||
|
|
||||||
this.setHTMLOutput(output.data.result);
|
this.setHTMLOutput(output.data.result);
|
||||||
break;
|
break;
|
||||||
case "ArrayBuffer":
|
case "ArrayBuffer":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user