Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .editorconfig
100644 → 100755
Empty file.
Empty file modified .eslintignore
100644 → 100755
Empty file.
Empty file modified .eslintrc
100644 → 100755
Empty file.
7 changes: 7 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"rules": {
"@typescript-eslint/no-unused-vars": ["error", {
"varsIgnorePattern": "^h$"
}]
}
}
Empty file modified .github/ISSUE_TEMPLATE/bug_report.yml
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/feature_request.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/release.yml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .npmrc
100644 → 100755
Empty file.
Empty file modified LICENSE.md
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified manifest.json
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions package-lock.json
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified package.json
100644 → 100755
Empty file.
32 changes: 2 additions & 30 deletions scripts/esbuild.config.mjs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import builtins from "builtin-modules";
import alias from "esbuild-plugin-alias";
import { sassPlugin } from "esbuild-sass-plugin";
import { createRequire } from "module";
import { renameSync, copyFileSync, appendFileSync } from "fs";
import { appendFileSync } from "fs";
const require = createRequire(import.meta.url);

const banner = `/*
Expand Down Expand Up @@ -85,35 +85,7 @@ esbuild
}
});
},
},
{
name: "Move output",
setup(build) {
build.onEnd(() => {
setTimeout(
() => {
try {
copyFileSync(
"styles.css",
"../../vault/.obsidian/plugins/cmdr/styles.css"
);
copyFileSync(
"main.js",
"../../vault/.obsidian/plugins/cmdr/main.js"
);
copyFileSync(
"manifest.json",
"../../vault/.obsidian/plugins/cmdr/manifest.json"
);
} catch (error) {
console.error(error);
}
},
prod ? 5000 : 500
);
});
},
},
}
],
})
.catch(() => process.exit(1));
Empty file modified scripts/update-icon-list.mjs
100644 → 100755
Empty file.
Empty file modified scripts/version-bump.mjs
100644 → 100755
Empty file.
Empty file modified src/assets/commander-logo-christmas.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/assets/commander-logo-halloween.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/assets/commander-logo.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/constants.ts
100644 → 100755
Empty file.
Empty file modified src/custom.d.ts
100644 → 100755
Empty file.
Empty file modified src/l10n.ts
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/main.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export default class CommanderPlugin extends Plugin {
this.getCommands().forEach((c) => {
if (
this.settings.advancedToolbar.mappedIcons.find(
(m) => m.commandID === c.id
(m) => m.commandID === `cmdr:${c.id}`
)
) {
commands.push(c);
Expand Down
Empty file modified src/manager/commands/commandManager.ts
100644 → 100755
Empty file.
Empty file modified src/manager/commands/explorerManager.ts
100644 → 100755
Empty file.
Empty file modified src/manager/commands/index.ts
100644 → 100755
Empty file.
Empty file modified src/manager/commands/leftRibbonManager.ts
100644 → 100755
Empty file.
Empty file modified src/manager/commands/menuManager.ts
100644 → 100755
Empty file.
Empty file modified src/manager/commands/pageHeaderManager.ts
100644 → 100755
Empty file.
Empty file modified src/manager/commands/statusBarManager.ts
100644 → 100755
Empty file.
Empty file modified src/manager/commands/titleBarManager.ts
100644 → 100755
Empty file.
Empty file modified src/styles/advanced-toolbar.scss
100644 → 100755
Empty file.
Empty file modified src/styles/styles.scss
100644 → 100755
Empty file.
132 changes: 73 additions & 59 deletions src/types.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,75 @@
import { h } from "preact";
import { App, Command, Plugin, PluginManifest } from "obsidian";
import { JSX } from "preact";

/* eslint-disable no-unused-vars */
declare module "obsidian" {
interface MenuItem {
dom: HTMLElement;
}

interface App {
commands: {
commands: {
[id: string]: Command;
};
executeCommandById: (id: string) => void;
};
plugins: {
manifests: {
[id: string]: PluginManifest;
};
};
statusBar: {
containerEl: HTMLElement;
};
appId: string;
isMobile: boolean;
setting: {
closeActiveTab: () => void;
openTabById: (id: string) => void;
activeTab: {
containerEl: HTMLElement;
};
};
}

interface WorkspaceRibbon {
orderedRibbonActions: {
icon: string;
title: string;
callback: () => void;
}[];
collapseButtonEl: HTMLElement;
ribbonItemsEl: HTMLElement;
addRibbonItemButton: (
icon: string,
name: string,
callback: (event: MouseEvent) => void
) => void;
makeRibbonItemButton: (
icon: string,
name: string,
callback: (event: MouseEvent) => void
) => HTMLElement;
}

interface WorkspaceLeaf {
containerEl: HTMLElement;
}
}

export interface CommanderPlugin extends Plugin {
app: App;
settings: CommanderSettings;
addCommand: (command: {
id: string;
name: string;
callback: () => void;
icon?: string;
}) => Command;
saveSettings: () => Promise<void>;
executeMacro: (id: number) => void;
}

export enum Action {
COMMAND,
Expand Down Expand Up @@ -57,7 +128,7 @@ export interface AdvancedToolbarSettings {

export interface Tab {
name: string;
tab: h.JSX.Element;
tab: JSX.Element;
}

export type Mode = "desktop" | "any" | "mobile" | string;
Expand All @@ -69,60 +140,3 @@ export interface CommandIconPair {
mode: Mode;
color?: string;
}

/* eslint-disable no-unused-vars */
declare module "obsidian" {
interface MenuItem {
dom: HTMLElement;
}

interface App {
commands: {
commands: {
[id: string]: Command;
};
executeCommandById: (id: string) => void;
};
plugins: {
manifests: {
[id: string]: PluginManifest;
};
};
statusBar: {
containerEl: HTMLElement;
};
appId: string;
isMobile: boolean;
setting: {
closeActiveTab: () => void;
openTabById: (id: string) => void;
activeTab: {
containerEl: HTMLElement;
};
};
}

interface WorkspaceRibbon {
orderedRibbonActions: {
icon: string;
title: string;
callback: () => void;
}[];
collapseButtonEl: HTMLElement;
ribbonItemsEl: HTMLElement;
addRibbonItemButton: (
icon: string,
name: string,
callback: (event: MouseEvent) => void
) => void;
makeRibbonItemButton: (
icon: string,
name: string,
callback: (event: MouseEvent) => void
) => HTMLElement;
}

interface WorkspaceLeaf {
containerEl: HTMLElement;
}
}
Empty file modified src/ui/addCommandModal.ts
100644 → 100755
Empty file.
Empty file modified src/ui/chooseCustomNameModal.ts
100644 → 100755
Empty file.
Empty file modified src/ui/chooseIconModal.ts
100644 → 100755
Empty file.
Empty file modified src/ui/components/About.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/Accordion.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/AdvancedToolbarSettings.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/ChangeableText.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/ColorPicker/ColorPicker.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/ColorPicker/index.ts
100644 → 100755
Empty file.
Empty file modified src/ui/components/Credits.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/Logo.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/MacroBuilder.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/MacroBuilderModal.ts
100644 → 100755
Empty file.
Empty file modified src/ui/components/MacroViewer.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/commandComponent.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/commandViewerComponent.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/confirmDeleteComponent.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/hidingViewer.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/mobileModifyComponent.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/settingComponent.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/components/settingTabComponent.tsx
100644 → 100755
Empty file.
Empty file modified src/ui/confirmDeleteModal.ts
100644 → 100755
Empty file.
Empty file modified src/ui/icons.ts
100644 → 100755
Empty file.
Empty file modified src/ui/mobileModifyModal.ts
100644 → 100755
Empty file.
Empty file modified src/ui/settingTab.ts
100644 → 100755
Empty file.
Empty file modified src/ui/settingTabModal.ts
100644 → 100755
Empty file.
69 changes: 46 additions & 23 deletions src/util.tsx
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import AddCommandModal from "./ui/addCommandModal";
import ChooseIconModal from "./ui/chooseIconModal";
import { Command, Platform, setIcon } from "obsidian";
import ChooseCustomNameModal from "./ui/chooseCustomNameModal";
import { ComponentProps, h } from "preact";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { ComponentProps, h, JSX } from "preact";
/** @jsx h */
import { useRef, useLayoutEffect } from "preact/hooks";
import confetti from "canvas-confetti";

Expand Down Expand Up @@ -55,7 +57,7 @@ export function ObsidianIcon({
icon,
size,
...props
}: ObsidianIconProps): h.JSX.Element {
}: ObsidianIconProps): JSX.Element {
const iconEl = useRef<HTMLDivElement>(null);

useLayoutEffect(() => {
Expand Down Expand Up @@ -88,19 +90,17 @@ export function updateHiderStylesheet(settings: CommanderSettings): void {
document.head.querySelector("style#cmdr")?.remove();

if (style) {
document.head.appendChild(
createEl("style", {
attr: { id: "cmdr" },
text: style,
type: "text/css",
})
);
const styleEl = document.createElement("style");
styleEl.id = "cmdr";
styleEl.type = "text/css";
styleEl.textContent = style;
document.head.appendChild(styleEl);
}
}

export async function showConfetti({ target }: MouseEvent): Promise<void> {
const myCanvas = activeDocument.createElement("canvas");
activeDocument.body.appendChild(myCanvas);
const myCanvas = document.createElement("canvas");
document.body.appendChild(myCanvas);
myCanvas.style.position = "fixed";
myCanvas.style.width = "100vw";
myCanvas.style.height = "100vh";
Expand All @@ -126,16 +126,16 @@ export async function showConfetti({ target }: MouseEvent): Promise<void> {
ticks: 250,
origin: {
//Center of the target component using values from 0 to 1
x: (pos.x + pos.width / 2) / activeWindow.innerWidth,
y: (pos.y + pos.height / 2) / activeWindow.innerHeight,
x: (pos.x + pos.width / 2) / window.innerWidth,
y: (pos.y + pos.height / 2) / window.innerHeight,
},
});

myCanvas.remove();
}

export function updateSpacing(spacing: number): void {
activeDocument.body.style.setProperty("--cmdr-spacing", `${spacing}px`);
document.body.style.setProperty("--cmdr-spacing", `${spacing}px`);
}

export function updateMacroCommands(plugin: CommanderPlugin): void {
Expand All @@ -144,22 +144,44 @@ export function updateMacroCommands(plugin: CommanderPlugin): void {
);
for (const command of oldCommands) {
//@ts-ignore
app.commands.removeCommand(command);
plugin.app.commands.removeCommand(command);
}

const macros = plugin.settings.macros;
for (const [idx, macro] of Object.entries(macros)) {
for (const [idx, macro] of macros.entries()) {
const commandId = `macro-${idx}`;

// Create the command with direct icon assignment
plugin.addCommand({
id: `macro-${idx}`,
id: commandId,
name: macro.name,
icon: macro.icon, // Set icon directly on the command
callback: () => {
plugin.executeMacro(parseInt(idx));
plugin.executeMacro(Number(idx));
},
});

// Also maintain icon mapping for mobile toolbar compatibility
if (macro.icon) {
const existingMapping = plugin.settings.advancedToolbar.mappedIcons.find(
m => m.commandID === `cmdr:${commandId}`
);
if (existingMapping) {
existingMapping.iconID = macro.icon;
} else {
plugin.settings.advancedToolbar.mappedIcons.push({
commandID: `cmdr:${commandId}`,
iconID: macro.icon
});
}
}
}

// Save the updated settings
void plugin.saveSettings();
}

export function updateStyles(settings: AdvancedToolbarSettings) {
export function updateStyles(settings: AdvancedToolbarSettings): void {
const { classList: c, style: s } = document.body;
s.setProperty("--at-button-height", (settings.rowHeight ?? 48) + "px");
s.setProperty("--at-button-width", (settings.buttonWidth ?? 48) + "px");
Expand All @@ -172,7 +194,7 @@ export function updateStyles(settings: AdvancedToolbarSettings) {
c.toggle("AT-no-toolbar", settings.rowCount === 0);
}

export function removeStyles() {
export function removeStyles(): void {
const { classList: c, style: s } = document.body;
s.removeProperty("--at-button-height");
s.removeProperty("--at-button-width");
Expand All @@ -189,13 +211,14 @@ export function removeStyles() {
export function injectIcons(
settings: AdvancedToolbarSettings,
plugin: CommanderPlugin
) {
): void {
settings.mappedIcons.forEach((mapped) => {
const command = plugin.app.commands.commands[mapped.commandID];
const commandId = mapped.commandID.replace('cmdr:', '');
const command = plugin.app.commands.commands[commandId];
if (command) {
command.icon = mapped.iconID;
} else {
settings.mappedIcons.remove(mapped);
settings.mappedIcons = settings.mappedIcons.filter(m => m !== mapped);
}
});
}
Empty file modified tailwind.config.js
100644 → 100755
Empty file.
7 changes: 6 additions & 1 deletion tsconfig.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
"importHelpers": true,
"isolatedModules": true,
"strictNullChecks": true,
"lib": ["DOM", "ES5", "ES6", "ES7", "DOM.Iterable"],
"lib": ["DOM", "ES5", "ES6", "ES7", "DOM.Iterable", "ESNext"],
"types": ["node"],
"paths": {
"obsidian": ["node_modules/obsidian/obsidian.d.ts"],
"preact": ["node_modules/preact/dist/preact.d.ts"]
},
"jsx": "react",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment",
Expand Down
Empty file modified versions.json
100644 → 100755
Empty file.