Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 526591b

Browse files
committed
new icon!
1 parent 8b65595 commit 526591b

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/DatabaseView.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import DatabaseInfo from "services/DatabaseInfo";
3232
import { LOGGER } from "services/Logger";
3333
import { SettingsModal } from "Settings";
3434
import StateManager from "StateManager";
35-
export const databaseIcon = "blocks";
3635

3736
export class DatabaseView extends TextFileView implements HoverParent {
3837
plugin: DBFolderPlugin;

src/helpers/Constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,5 +331,12 @@ export const SUGGESTER_REGEX = Object.freeze({
331331

332332
LINK_BLOCK: /\B\[\[([^#\]]+)#?\^([^\]]*)$/,
333333
EMBED_BLOCK: /\B!\[\[([^#\]]+)#?\^([^\]]*)$/
334+
});
334335

336+
/******************************************************************************
337+
* ICONS CONSTANTS
338+
******************************************************************************/
339+
export const DB_ICONS = Object.freeze({
340+
NAME: 'database-folder-icon',
341+
ICON: `<g transform="matrix(0.06 0 0 0.05 52 52)"><path stroke="currentColor" fill="#fff" vector-effect="non-scaling-stroke" transform=" translate(-896, -896)" d="M 896 768 q 237 0 443 -43 t 325 -127 v 170 q 0 69 -103 128 t -280 93.5 t -385 34.5 t -385 -34.5 t -280 -93.5 t -103 -128 v -170 q 119 84 325 127 t 443 43 z m 0 768 q 237 0 443 -43 t 325 -127 v 170 q 0 69 -103 128 t -280 93.5 t -385 34.5 t -385 -34.5 t -280 -93.5 t -103 -128 v -170 q 119 84 325 127 t 443 43 z m 0 -384 q 237 0 443 -43 t 325 -127 v 170 q 0 69 -103 128 t -280 93.5 t -385 34.5 t -385 -34.5 t -280 -93.5 t -103 -128 v -170 q 119 84 325 127 t 443 43 z m 0 -1152 q 208 0 385 34.5 t 280 93.5 t 103 128 v 128 q 0 69 -103 128 t -280 93.5 t -385 34.5 t -385 -34.5 t -280 -93.5 t -103 -128 v -128 q 0 -69 103 -128 t 280 -93.5 t 385 -34.5 z" stroke-linecap="round" /></g>`
335342
});

src/main.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
ViewState,
88
Platform,
99
MarkdownView,
10+
addIcon,
1011
} from 'obsidian';
1112

1213
import {
1314
DatabaseView,
14-
databaseIcon,
1515
} from 'DatabaseView';
1616

1717
import {
@@ -28,7 +28,7 @@ import { DatabaseSettings, LocalSettings } from 'cdm/SettingsModel';
2828
import StateManager from 'StateManager';
2929
import { around } from 'monkey-around';
3030
import { LOGGER } from 'services/Logger';
31-
import { DatabaseCore, DatabaseFrontmatterOptions, DEFAULT_SETTINGS, YAML_INDENT } from 'helpers/Constants';
31+
import { DatabaseCore, DB_ICONS, DEFAULT_SETTINGS, YAML_INDENT } from 'helpers/Constants';
3232
import { PreviewDatabaseModeService } from 'services/MarkdownPostProcessorService';
3333
import { unmountComponentAtNode } from 'react-dom';
3434
import { isDatabaseNote } from 'helpers/VaultManagement';
@@ -66,7 +66,7 @@ export default class DBFolderPlugin extends Plugin {
6666

6767
async onload(): Promise<void> {
6868
await this.load_settings();
69-
69+
addIcon(DB_ICONS.NAME, DB_ICONS.ICON);
7070
this.registerEvent(
7171
app.workspace.on('window-open', (_: any, win: Window) => {
7272
this.mount(win);
@@ -331,7 +331,7 @@ export default class DBFolderPlugin extends Plugin {
331331
menu.addItem((item) => {
332332
item
333333
.setTitle('New database folder')
334-
.setIcon(databaseIcon)
334+
.setIcon(DB_ICONS.NAME)
335335
.onClick(() => generateNewDatabase(
336336
generateDbConfiguration(this.settings.local_settings),
337337
file
@@ -361,7 +361,7 @@ export default class DBFolderPlugin extends Plugin {
361361
menu.addItem((item) => {
362362
item
363363
.setTitle('Open as database folder')
364-
.setIcon(databaseIcon)
364+
.setIcon(DB_ICONS.NAME)
365365
.setSection('pane')
366366
.onClick(() => {
367367
this.databaseFileModes[(leaf as any).id || file.path] =
@@ -382,7 +382,7 @@ export default class DBFolderPlugin extends Plugin {
382382
menu.addItem((item) => {
383383
item
384384
.setTitle('Open as database folder')
385-
.setIcon(databaseIcon)
385+
.setIcon(DB_ICONS.NAME)
386386
.setSection('pane')
387387
.onClick(() => {
388388
this.databaseFileModes[(leaf as any).id || file.path] =
@@ -401,6 +401,10 @@ export default class DBFolderPlugin extends Plugin {
401401
name: 'Create a new database table',
402402
callback: () => new DatabaseHelperCreationModal(this.settings.local_settings).open(),
403403
});
404+
405+
this.addRibbonIcon(DB_ICONS.NAME, "Create a new database table", async (e) => {
406+
new DatabaseHelperCreationModal(this.settings.local_settings).open()
407+
});
404408
}
405409
/**
406410
* Displays a transcluded .excalidraw image in markdown preview mode

0 commit comments

Comments
 (0)