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

Commit 46d650b

Browse files
committed
Merge branch '257-split-pane-options-missing'
2 parents e6f1eb9 + 5ec708d commit 46d650b

File tree

6 files changed

+221
-100
lines changed

6 files changed

+221
-100
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"eslint": "8.21.0",
4040
"jest": "28.1.3",
4141
"jest-mock-extended": "2.0.7",
42-
"obsidian": "0.15.4",
42+
"obsidian": "0.15.9",
4343
"rollup": "2.77.0",
4444
"rollup-plugin-typescript2": "0.32.1",
4545
"rollup-plugin-terser": "7.0.2",

src/DatabaseView.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { DbFolderException } from "errors/AbstractException";
1515
import { DatabaseCore, InputType, StyleClasses } from "helpers/Constants";
1616
import obtainInitialType from "helpers/InitialType";
1717
import { adapterTFilesToRows, isDatabaseNote } from "helpers/VaultManagement";
18+
import { getParentWindow } from "helpers/WindowElement";
1819
import DBFolderPlugin from "main";
1920

2021
import {
@@ -46,6 +47,13 @@ export class DatabaseView extends TextFileView implements HoverParent {
4647
constructor(leaf: WorkspaceLeaf, plugin: DBFolderPlugin) {
4748
super(leaf);
4849
this.plugin = plugin;
50+
51+
this.register(
52+
this.containerEl.onWindowMigrated(() => {
53+
this.plugin.removeView(this);
54+
this.plugin.addView(this, this.data, this.isPrimary);
55+
})
56+
);
4957
}
5058

5159
/**
@@ -84,6 +92,11 @@ export class DatabaseView extends TextFileView implements HoverParent {
8492
get isPrimary(): boolean {
8593
return this.plugin.getStateManager(this.file)?.getAView() === this;
8694
}
95+
96+
getWindow() {
97+
return getParentWindow(this.containerEl) as Window & typeof globalThis;
98+
}
99+
87100
onPaneMenu(menu: Menu, source: string, callSuper: boolean = true): void {
88101
if (source !== "more-options") {
89102
super.onPaneMenu(menu, source);

src/api/plugin-api.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/helpers/VaultManagement.ts

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RowDataType, NormalizedPath, TableDataType, TableColumn } from 'cdm/FolderModel';
1+
import { RowDataType, NormalizedPath, TableColumn } from 'cdm/FolderModel';
22
import { Notice, TFile } from 'obsidian';
33
import { VaultManagerDB } from 'services/FileManagerService';
44
import { LOGGER } from "services/Logger";
@@ -12,7 +12,6 @@ import { DatabaseYaml } from 'cdm/DatabaseModel';
1212
import { Literal } from 'obsidian-dataview/lib/data-model/value';
1313
import { DataArray } from 'obsidian-dataview/lib/api/data-array';
1414
import { EditionError } from 'errors/ErrorTypes';
15-
import { TableStateInterface } from 'cdm/TableStateInterface';
1615
import { LocalSettings } from 'cdm/SettingsModel';
1716

1817
const noBreakSpace = /\u00A0/g;
@@ -22,35 +21,34 @@ const noBreakSpace = /\u00A0/g;
2221
* @param data
2322
* @returns
2423
*/
25-
export function hasFrontmatterKey(data: string | TFile): boolean {
24+
export function hasFrontmatter(data: string): boolean {
2625
if (!data) return false;
2726

28-
if (typeof data === 'string') {
29-
const frontmatterRegex = /^---[\s\S]+?---/g;
30-
return frontmatterRegex.test(data);
31-
}
27+
const frontmatterRegex = /^---[\s\S]+?---/g;
28+
return frontmatterRegex.test(data);
29+
}
3230

31+
/** Check if file is a database note */
32+
export function isDatabaseNote(data: string | TFile) {
3333
if (data instanceof TFile) {
34+
if (!data) return false;
35+
3436
const cache = app.metadataCache.getFileCache(data);
35-
return !!cache?.frontmatter && !!cache?.frontmatter['kanban-plugin'];
36-
}
3737

38-
return false;
39-
}
38+
return !!cache?.frontmatter && !!cache?.frontmatter[DatabaseCore.FRONTMATTER_KEY];
39+
} else {
40+
const match = data.match(/---\s+([\w\W]+?)\s+---/);
4041

41-
/** Check if file is a database note */
42-
export function isDatabaseNote(data: string): boolean {
43-
if (!data) return false;
44-
const match = data.match(/---\s+([\w\W]+?)\s+---/);
42+
if (!match) {
43+
return false;
44+
}
4545

46-
if (!match) {
47-
return false;
48-
}
46+
if (!match[1].contains(DatabaseCore.FRONTMATTER_KEY)) {
47+
return false;
48+
}
4949

50-
if (!match[1].contains(DatabaseCore.FRONTMATTER_KEY)) {
51-
return false;
50+
return true;
5251
}
53-
return true;
5452
}
5553

5654
export function getNormalizedPath(path: string): NormalizedPath {
@@ -336,7 +334,7 @@ export async function updateRowFile(file: TFile, columnId: string, newValue: Lit
336334
// Execute action
337335
if (updateOptions[option]) {
338336
// Check if file has frontmatter
339-
if (!hasFrontmatterKey(content)) {
337+
if (!hasFrontmatter(content)) {
340338
// If not, add it
341339
await addFrontmatter();
342340
}

src/helpers/WindowElement.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function getParentWindow(el: Element) {
2+
return el.win;
3+
}
4+
5+
export function getParentBodyElement(el: Element) {
6+
return el.doc.body;
7+
}

0 commit comments

Comments
 (0)