Skip to content

Commit 9221237

Browse files
authored
File Menu & QuickTools Visibility for editor tabs (#1292)
## Changes This PR implements visibility management for the file menu icon and adds QuickTools visibility control per tab. ### File Menu Icon (Pencil Icon) - Hides the file menu icon from header when active editor tab type is "page", otherwise show it ### QuickTools - Adds `hideQuickTools` boolean property to EditorFile (defaults to false) - Allows per-tab control of QuickTools visibility ## Usage ```javascript // Create a new tab with QuickTools hidden new EditorFile("My Tab", { hideQuickTools: true }); ```
1 parent 51efbb7 commit 9221237

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

src/handlers/quickTools.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ export default function actions(action, value) {
161161
return true;
162162

163163
case "set-height":
164-
setHeight(value);
164+
if (typeof value === "object") {
165+
setHeight(value.height, value.save);
166+
} else {
167+
setHeight(value);
168+
}
165169
return true;
166170

167171
case "search-prev":
@@ -275,12 +279,14 @@ function toggle() {
275279
focusEditor();
276280
}
277281

278-
function setHeight(height = 1) {
282+
function setHeight(height = 1, save = true) {
279283
const { $footer, $row1, $row2 } = quickTools;
280284
const { editor } = editorManager;
281285

282286
setFooterHeight(height);
283-
appSettings.update({ quickTools: height }, false);
287+
if (save) {
288+
appSettings.update({ quickTools: height }, false);
289+
}
284290
editor.resize(true);
285291

286292
if (!height) {

src/lib/editorFile.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export default class EditorFile {
4949
* @type {HTMLElement}
5050
*/
5151
#content = null;
52+
/**
53+
* Whether to hide quicktools for this tab
54+
* @type {boolean}
55+
*/
56+
hideQuickTools = false;
5257

5358
/**
5459
* Custom stylesheets for tab
@@ -186,6 +191,8 @@ export default class EditorFile {
186191
const { addFile, getFile } = editorManager;
187192
let doesExists = null;
188193

194+
this.hideQuickTools = options?.hideQuickTools || false;
195+
189196
// if options are passed
190197
if (options) {
191198
// if options doesn't contains id, and provide a new id

src/lib/editorManager.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ScrollBar from "components/scrollbar";
99
import SideButton, { sideButtonContainer } from "components/sideButton";
1010
import keyboardHandler from "handlers/keyboard";
1111
import { keydownState } from "handlers/keyboard";
12+
import actions from "handlers/quickTools";
1213
import sidebarApps from "sidebarApps";
1314
import EditorFile from "./editorFile";
1415
import appSettings from "./settings";
@@ -645,6 +646,14 @@ async function EditorManager($header, $body) {
645646

646647
manager.activeFile = file;
647648

649+
if (file.hideQuickTools) {
650+
root.classList.add("hide-floating-button");
651+
actions("set-height", { height: 0, save: false });
652+
} else {
653+
root.classList.remove("hide-floating-button");
654+
actions("set-height", appSettings.value.quickTools);
655+
}
656+
648657
if (file.type === "editor") {
649658
editor.setSession(file.session);
650659
editor.setReadOnly(!file.editable || !!file.loading);

src/lib/loadPlugins.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const THEME_IDENTIFIERS = new Set([
2121
"sweet",
2222
"moonlight",
2323
"bluloco",
24+
"acode.plugin.extra_syntax_highlights",
2425
]);
2526

2627
export default async function loadPlugins(loadOnlyTheme = false) {

src/lib/main.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,15 @@ async function loadApp() {
510510
function onEditorUpdate(mode, saveState = true) {
511511
const { activeFile } = editorManager;
512512

513-
if (!$editMenuToggler.isConnected) {
514-
$header.insertBefore($editMenuToggler, $header.lastChild);
513+
// if (!$editMenuToggler.isConnected) {
514+
// $header.insertBefore($editMenuToggler, $header.lastChild);
515+
// }
516+
if (activeFile?.type === "page") {
517+
$editMenuToggler.remove();
518+
} else {
519+
if (!$editMenuToggler.isConnected) {
520+
$header.insertBefore($editMenuToggler, $header.lastChild);
521+
}
515522
}
516523

517524
if (mode === "switch-file") {

0 commit comments

Comments
 (0)