mirror of
				https://github.com/notion-enhancer/notion-enhancer.git
				synced 2025-11-04 16:18:08 +11:00 
			
		
		
		
	chore: remove integrated-titlebar (default in notion desktop v3.4.0)
This commit is contained in:
		
							parent
							
								
									736292e1b8
								
							
						
					
					
						commit
						9b03b1d9f7
					
				@ -1,74 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * notion-enhancer: titlebar
 | 
			
		||||
 * (c) 2024 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
 | 
			
		||||
 * (https://notion-enhancer.github.io/) under the MIT license
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import { Tooltip } from "../../core/islands/Tooltip.mjs";
 | 
			
		||||
import { TopbarButton } from "../../core/islands/TopbarButton.mjs";
 | 
			
		||||
 | 
			
		||||
const minimizeLabel = "Minimize window",
 | 
			
		||||
  maximizeLabel = "Maximize window",
 | 
			
		||||
  unmaximizeLabel = "Unmaximize window",
 | 
			
		||||
  closeLabel = "Close window";
 | 
			
		||||
 | 
			
		||||
const createWindowButtons = async () => {
 | 
			
		||||
  const { modDatabase } = globalThis.__enhancerApi,
 | 
			
		||||
    db = await modDatabase("a5658d03-21c6-4088-bade-fa4780459133"),
 | 
			
		||||
    minimizeIcon = await db.get("minimizeIcon"),
 | 
			
		||||
    maximizeIcon = await db.get("maximizeIcon"),
 | 
			
		||||
    unmaximizeIcon = await db.get("unmaximizeIcon"),
 | 
			
		||||
    closeIcon = await db.get("closeIcon");
 | 
			
		||||
 | 
			
		||||
  const { html, sendMessage, invokeInWorker } = globalThis.__enhancerApi,
 | 
			
		||||
    $minimize = html`<${TopbarButton}
 | 
			
		||||
      onclick=${() => sendMessage("notion-enhancer:titlebar", "minimize")}
 | 
			
		||||
      aria-label="${minimizeLabel}"
 | 
			
		||||
      innerHTML="${minimizeIcon?.content}"
 | 
			
		||||
      icon="minus"
 | 
			
		||||
    />`,
 | 
			
		||||
    $maximize = html`<${TopbarButton}
 | 
			
		||||
      onclick=${() => sendMessage("notion-enhancer:titlebar", "maximize")}
 | 
			
		||||
      aria-label="${maximizeLabel}"
 | 
			
		||||
      innerHTML="${maximizeIcon?.content}"
 | 
			
		||||
      icon="maximize"
 | 
			
		||||
    />`,
 | 
			
		||||
    $unmaximize = html`<${TopbarButton}
 | 
			
		||||
      onclick=${() => sendMessage("notion-enhancer:titlebar", "unmaximize")}
 | 
			
		||||
      aria-label="${unmaximizeLabel}"
 | 
			
		||||
      innerHTML="${unmaximizeIcon?.content}"
 | 
			
		||||
      icon="minimize"
 | 
			
		||||
    />`,
 | 
			
		||||
    $close = html`<${TopbarButton}
 | 
			
		||||
      onclick=${() => sendMessage("notion-enhancer:titlebar", "close")}
 | 
			
		||||
      class="!hover:(bg-red-600 text-white)"
 | 
			
		||||
      aria-label="${closeLabel}"
 | 
			
		||||
      innerHTML="${closeIcon?.content}"
 | 
			
		||||
      icon="x"
 | 
			
		||||
    />`;
 | 
			
		||||
  html`<${Tooltip}><b>${minimizeLabel}</b><//>`.attach($minimize, "bottom");
 | 
			
		||||
  html`<${Tooltip}><b>${maximizeLabel}</b><//>`.attach($maximize, "bottom");
 | 
			
		||||
  html`<${Tooltip}><b>${unmaximizeLabel}</b><//>`.attach($unmaximize, "bottom");
 | 
			
		||||
  html`<${Tooltip}><b>${closeLabel}</b><//>`.attach($close, "bottom");
 | 
			
		||||
 | 
			
		||||
  const resizeWindow = async () => {
 | 
			
		||||
    const isMaximized = await invokeInWorker("notion-enhancer:titlebar", {
 | 
			
		||||
      query: "is-maximized",
 | 
			
		||||
    });
 | 
			
		||||
    $maximize.style.display = isMaximized ? "none" : "";
 | 
			
		||||
    $unmaximize.style.display = isMaximized ? "" : "none";
 | 
			
		||||
  };
 | 
			
		||||
  addEventListener("resize", resizeWindow);
 | 
			
		||||
  resizeWindow();
 | 
			
		||||
 | 
			
		||||
  return html`<div class="flex flex-nowrap">${$minimize}${$maximize}${$unmaximize}${$close}</div>`;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
if (globalThis.IS_TABS) {
 | 
			
		||||
  const appendAfter = ".hide-scrollbar";
 | 
			
		||||
  createWindowButtons().then(($buttons) => {
 | 
			
		||||
    document.querySelector(appendAfter)?.after($buttons);
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export { createWindowButtons };
 | 
			
		||||
@ -1,19 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * notion-enhancer: titlebar
 | 
			
		||||
 * (c) 2024 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
 | 
			
		||||
 * (https://notion-enhancer.github.io/) under the MIT license
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
.notion-tabs,
 | 
			
		||||
.notion-topbar {
 | 
			
		||||
  user-select: none;
 | 
			
		||||
  -webkit-app-region: drag;
 | 
			
		||||
}
 | 
			
		||||
.notion-tabs :is([aria-label], [draggable], .notion-enhancer--topbar-button),
 | 
			
		||||
.notion-peek-renderer [style*="height: 44px;"] > div,
 | 
			
		||||
.notion-topbar > div > * {
 | 
			
		||||
  -webkit-app-region: no-drag;
 | 
			
		||||
}
 | 
			
		||||
.notion-tabs .notion-enhancer--topbar-button:last-child {
 | 
			
		||||
  margin-right: 12px;
 | 
			
		||||
}
 | 
			
		||||
@ -1,28 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * notion-enhancer: titlebar
 | 
			
		||||
 * (c) 2024 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
 | 
			
		||||
 * (https://notion-enhancer.github.io/) under the MIT license
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import { createWindowButtons } from "./buttons.mjs";
 | 
			
		||||
 | 
			
		||||
export default async (api, db) => {
 | 
			
		||||
  const titlebarStyle = await db.get("titlebarStyle");
 | 
			
		||||
  if (titlebarStyle === "Disabled") return;
 | 
			
		||||
 | 
			
		||||
  const { onMessage, addMutationListener, removeMutationListener } = api,
 | 
			
		||||
    $buttons = await createWindowButtons(),
 | 
			
		||||
    topbarMore = ".notion-topbar .notion-topbar-more-button",
 | 
			
		||||
    addToTopbar = () => {
 | 
			
		||||
      if (document.contains($buttons)) removeMutationListener(addToTopbar);
 | 
			
		||||
      document.querySelector(topbarMore)?.after($buttons);
 | 
			
		||||
    },
 | 
			
		||||
    showIfNoTabBar = async () => {
 | 
			
		||||
      const { isShowingTabBar } = await __electronApi.electronAppFeatures.get();
 | 
			
		||||
      $buttons.style.display = isShowingTabBar ? "none" : "";
 | 
			
		||||
    };
 | 
			
		||||
  __electronApi?.electronAppFeatures.addListener(showIfNoTabBar);
 | 
			
		||||
  showIfNoTabBar();
 | 
			
		||||
  addMutationListener(topbarMore, addToTopbar);
 | 
			
		||||
  addToTopbar(topbarMore);
 | 
			
		||||
};
 | 
			
		||||
@ -1,28 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * notion-enhancer: titlebar
 | 
			
		||||
 * (c) 2024 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
 | 
			
		||||
 * (https://notion-enhancer.github.io/) under the MIT license
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
module.exports = async ({}, db) => {
 | 
			
		||||
  Object.assign((globalThis.__notionConfig ??= {}), {
 | 
			
		||||
    titlebarStyle: "hidden",
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  const { ipcMain, BrowserWindow } = require("electron");
 | 
			
		||||
  ipcMain.on("notion-enhancer:titlebar", ({ sender }, message) => {
 | 
			
		||||
    const window = BrowserWindow.fromWebContents(sender);
 | 
			
		||||
    if (message === "minimize") window.minimize();
 | 
			
		||||
    if (message === "maximize") window.maximize();
 | 
			
		||||
    if (message === "unmaximize") window.unmaximize();
 | 
			
		||||
    if (message === "close") window.close();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  ipcMain.handle("notion-enhancer:titlebar", ({ sender }, message) => {
 | 
			
		||||
    if (message?.query !== "is-maximized") return;
 | 
			
		||||
    const window = BrowserWindow.fromWebContents(sender);
 | 
			
		||||
    return window.isMaximized();
 | 
			
		||||
  });
 | 
			
		||||
};
 | 
			
		||||
@ -1,55 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "Titlebar",
 | 
			
		||||
  "version": "0.11.1",
 | 
			
		||||
  "id": "a5658d03-21c6-4088-bade-fa4780459133",
 | 
			
		||||
  "description": "Replaces the operating system's default window titlebar with buttons inset into the app.",
 | 
			
		||||
  "thumbnail": "titlebar.jpg",
 | 
			
		||||
  "platforms": ["linux", "win32"],
 | 
			
		||||
  "tags": ["app-only", "integrated-titlebar"],
 | 
			
		||||
  "authors": [
 | 
			
		||||
    {
 | 
			
		||||
      "name": "dragonwocky",
 | 
			
		||||
      "homepage": "https://dragonwocky.me/",
 | 
			
		||||
      "avatar": "https://dragonwocky.me/avatar.jpg"
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "options": [
 | 
			
		||||
    {
 | 
			
		||||
      "type": "select",
 | 
			
		||||
      "key": "titlebarStyle",
 | 
			
		||||
      "description": "The integrated titlebar replaces the operating system's default window titlebar with buttons inset into the app's interface. Tiling window manager users may choose to fully disable the titlebar instead.",
 | 
			
		||||
      "values": ["Integrated", "Disabled"]
 | 
			
		||||
    },
 | 
			
		||||
    { "type": "heading", "label": "Icons" },
 | 
			
		||||
    {
 | 
			
		||||
      "type": "file",
 | 
			
		||||
      "key": "minimizeIcon",
 | 
			
		||||
      "description": "Replaces the icon used for the integrated titlebar's maximize button with the uploaded .svg image.",
 | 
			
		||||
      "extensions": ["svg"]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "type": "file",
 | 
			
		||||
      "key": "maximizeIcon",
 | 
			
		||||
      "description": "Replaces the icon used for the integrated titlebar's maximize button with the uploaded .svg image.",
 | 
			
		||||
      "extensions": ["svg"]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "type": "file",
 | 
			
		||||
      "key": "unmaximizeIcon",
 | 
			
		||||
      "description": "Replaces the icon used for the integrated titlebar's maximize button with the uploaded .svg image.",
 | 
			
		||||
      "extensions": ["svg"]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "type": "file",
 | 
			
		||||
      "key": "closeIcon",
 | 
			
		||||
      "description": "Replaces the icon used for the integrated titlebar's maximize button with the uploaded .svg image.",
 | 
			
		||||
      "extensions": ["svg"]
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "clientStyles": ["client.css"],
 | 
			
		||||
  "clientScripts": ["client.mjs"],
 | 
			
		||||
  "electronScripts": [
 | 
			
		||||
    [".webpack/main/index", "electron.cjs"],
 | 
			
		||||
    [".webpack/renderer/tabs/preload", "tabs.cjs"]
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
@ -1,33 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * notion-enhancer: titlebar
 | 
			
		||||
 * (c) 2024 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
 | 
			
		||||
 * (https://notion-enhancer.github.io/) under the MIT license
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
module.exports = async (api, db) => {
 | 
			
		||||
  const { html, addMutationListener } = api,
 | 
			
		||||
    { enhancerUrl, onMessage, sendMessage } = api,
 | 
			
		||||
    titlebarStyle = await db.get("titlebarStyle");
 | 
			
		||||
 | 
			
		||||
  // only make area draggable if tabs are visible:
 | 
			
		||||
  // otherwise dragarea overlaps regular app topbar
 | 
			
		||||
  const tabSelector = ".hide-scrollbar > div > div";
 | 
			
		||||
  addMutationListener(".hide-scrollbar", () => {
 | 
			
		||||
    const tabCount = document.querySelectorAll(tabSelector).length;
 | 
			
		||||
    if (tabCount > 1) document.body.classList.add("notion-tabs");
 | 
			
		||||
    else document.body.classList.remove("notion-tabs");
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  onMessage("tabs:set-state", (state) => {
 | 
			
		||||
    if (state.themeMode === "dark") document.body.classList.add("dark");
 | 
			
		||||
    else document.body.classList.remove("dark");
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  if (titlebarStyle === "Disabled") return;
 | 
			
		||||
  const $buttonsScript = document.createElement("script");
 | 
			
		||||
  $buttonsScript.type = "module";
 | 
			
		||||
  $buttonsScript.src = enhancerUrl("extensions/titlebar/buttons.mjs");
 | 
			
		||||
  document.head.append($buttonsScript);
 | 
			
		||||
};
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 8.4 KiB  | 
@ -1,6 +1,5 @@
 | 
			
		||||
[
 | 
			
		||||
  "core",
 | 
			
		||||
  "extensions/titlebar",
 | 
			
		||||
  "extensions/topbar",
 | 
			
		||||
  "extensions/scroller",
 | 
			
		||||
  "extensions/outliner",
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user