Skip to content

Commit

Permalink
refactor: Move Views under correct folder
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jan 15, 2022
1 parent b7e83c7 commit 5137253
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 81 deletions.
106 changes: 57 additions & 49 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3629,6 +3629,14 @@ const DEFAULT_SETTINGS = {
visClosed: "Real",
visAll: "All",
wikilinkIndex: true,
impliedRelations: {
siblingIdentity: false,
sameParentIsSibling: false,
siblingsSiblingIsSibling: false,
parentsSiblingsIsParents: false,
parentsParentsIsParent: false,
cousinsIsSibling: false,
},
};

var graphology_umd_min = createCommonjsModule(function (module, exports) {
Expand Down Expand Up @@ -29888,6 +29896,54 @@ async function writeBCsToAllFiles(plugin) {
}
}

class FieldSuggestor extends obsidian.EditorSuggest {
constructor(plugin) {
super(plugin.app);
this.getSuggestions = (context) => {
const { query } = context;
return BC_FIELDS_INFO.map((sug) => sug.field).filter((sug) => sug.includes(query));
};
this.plugin = plugin;
}
onTrigger(cursor, editor, _) {
var _a;
if (this.plugin.settings.fieldSuggestor) {
const sub = editor.getLine(cursor.line).substring(0, cursor.ch);
const match = (_a = sub.match(/^BC-(.*)$/)) === null || _a === void 0 ? void 0 : _a[1];
if (match !== undefined) {
return {
end: cursor,
start: {
ch: sub.lastIndexOf(match),
line: cursor.line,
},
query: match,
};
}
}
return null;
}
renderSuggestion(suggestion, el) {
var _a;
el.createDiv({
text: suggestion.replace("BC-", ""),
cls: "BC-suggester-container",
attr: {
"aria-label": (_a = BC_FIELDS_INFO.find((f) => f.field === suggestion)) === null || _a === void 0 ? void 0 : _a.desc,
"aria-label-position": "right",
},
});
}
selectSuggestion(suggestion) {
var _a;
const { context } = this;
if (context) {
const replacement = `${suggestion}${(_a = BC_FIELDS_INFO.find((f) => f.field === suggestion)) === null || _a === void 0 ? void 0 : _a.after}`;
context.editor.replaceRange(replacement, { ch: 0, line: context.start.line }, context.end);
}
}
}

/* node_modules\svelte-icons\fa\FaInfo.svelte generated by Svelte v3.35.0 */

function create_default_slot$2(ctx) {
Expand Down Expand Up @@ -30276,54 +30332,6 @@ class DucksView extends obsidian.ItemView {
}
}

class FieldSuggestor extends obsidian.EditorSuggest {
constructor(plugin) {
super(plugin.app);
this.getSuggestions = (context) => {
const { query } = context;
return BC_FIELDS_INFO.map((sug) => sug.field).filter((sug) => sug.includes(query));
};
this.plugin = plugin;
}
onTrigger(cursor, editor, _) {
var _a;
if (this.plugin.settings.fieldSuggestor) {
const sub = editor.getLine(cursor.line).substring(0, cursor.ch);
const match = (_a = sub.match(/^BC-(.*)$/)) === null || _a === void 0 ? void 0 : _a[1];
if (match !== undefined) {
return {
end: cursor,
start: {
ch: sub.lastIndexOf(match),
line: cursor.line,
},
query: match,
};
}
}
return null;
}
renderSuggestion(suggestion, el) {
var _a;
el.createDiv({
text: suggestion.replace("BC-", ""),
cls: "BC-suggester-container",
attr: {
"aria-label": (_a = BC_FIELDS_INFO.find((f) => f.field === suggestion)) === null || _a === void 0 ? void 0 : _a.desc,
"aria-label-position": "right",
},
});
}
selectSuggestion(suggestion) {
var _a;
const { context } = this;
if (context) {
const replacement = `${suggestion}${(_a = BC_FIELDS_INFO.find((f) => f.field === suggestion)) === null || _a === void 0 ? void 0 : _a.after}`;
context.editor.replaceRange(replacement, { ch: 0, line: context.start.line }, context.end);
}
}
}

/* src\Components\Stats.svelte generated by Svelte v3.35.0 */

function add_css$1() {
Expand Down Expand Up @@ -54243,11 +54251,11 @@ class BCPlugin extends obsidian.Plugin {
await this.loadSettings();
const { settings } = this;
this.addSettingTab(new BCSettingTab(this.app, this));
// Prevent breaking change
if (typeof settings.debugMode === "boolean") {
settings.debugMode = settings.debugMode ? "DEBUG" : "WARN";
await this.saveSettings();
}
// Prevent breaking change
//@ts-ignore
const { userHierarchies } = settings;
if (userHierarchies !== undefined && userHierarchies.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/BreadcrumbsSettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from "./constants";
import type { DebugLevel, Relations, visTypes } from "./interfaces";
import type BCPlugin from "./main";
import MatrixView from "./MatrixView";
import MatrixView from "./Views/MatrixView";
import { getFields, splitAndTrim, strToRegex } from "./sharedFunctions";
import { drawTrail } from "./Views/TrailView";

Expand Down
2 changes: 1 addition & 1 deletion src/Components/Ducks.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import type { App } from "obsidian";
import { hoverPreview, openOrSwitch } from "obsidian-community-lib";
import type DucksView from "../DucksView";
import type DucksView from "../Views/DucksView";
import type BCPlugin from "../main";
import FaInfo from "svelte-icons/fa/FaInfo.svelte";
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Lists.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { hoverPreview, openOrSwitch } from "obsidian-community-lib";
import { dropPathNDendron } from "../sharedFunctions";
import type { BCSettings, SquareProps } from "../interfaces";
import type MatrixView from "../MatrixView";
import type MatrixView from "../Views/MatrixView";
export let filteredSquaresArr: SquareProps[][];
export let currFile: TFile;
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Matrix.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { App, TFile } from "obsidian";
import { hoverPreview, openOrSwitch } from "obsidian-community-lib";
import type { BCSettings, SquareProps } from "../interfaces";
import type MatrixView from "../MatrixView";
import type MatrixView from "../Views/MatrixView";
import { dropPathNDendron } from "../sharedFunctions";
export let filteredSquaresArr: SquareProps[][];
Expand Down
2 changes: 1 addition & 1 deletion src/Components/SideTree.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import type BCPlugin from "../main";
import { refreshIndex } from "../refreshIndex";
import { dropDendron } from "../sharedFunctions";
import type TreeView from "../TreeView";
import type TreeView from "../Views/TreeView";
export let plugin: BCPlugin;
export let view: TreeView;
Expand Down
6 changes: 3 additions & 3 deletions src/DucksView.ts → src/Views/DucksView.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ItemView, WorkspaceLeaf } from "obsidian";
import Ducks from "./Components/Ducks.svelte";
import { DUCK_ICON, DUCK_VIEW } from "./constants";
import type BCPlugin from "./main";
import Ducks from "../Components/Ducks.svelte";
import { DUCK_ICON, DUCK_VIEW } from "../constants";
import type BCPlugin from "../main";

export default class DucksView extends ItemView {
private plugin: BCPlugin;
Expand Down
16 changes: 8 additions & 8 deletions src/MatrixView.ts → src/Views/MatrixView.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { error, info } from "loglevel";
import { ItemView, TFile, WorkspaceLeaf } from "obsidian";
import { refreshIndex } from "./refreshIndex";
import { Debugger } from "src/Debugger";
import Lists from "./Components/Lists.svelte";
import Matrix from "./Components/Matrix.svelte";
import Lists from "../Components/Lists.svelte";
import Matrix from "../Components/Matrix.svelte";
import {
ARROW_DIRECTIONS,
blankRealNImplied,
MATRIX_VIEW,
TRAIL_ICON,
} from "./constants";
import { getOppDir, getReflexiveClosure, getSubInDirs } from "./graphUtils";
} from "../constants";
import { getOppDir, getReflexiveClosure, getSubInDirs } from "../graphUtils";
import type {
Directions,
internalLinkObj,
SquareProps,
UserHier,
} from "./interfaces";
import type BCPlugin from "./main";
import { getRealnImplied, linkClass, splitAndTrim } from "./sharedFunctions";
} from "../interfaces";
import type BCPlugin from "../main";
import { refreshIndex } from "../refreshIndex";
import { getRealnImplied, linkClass, splitAndTrim } from "../sharedFunctions";

export default class MatrixView extends ItemView {
private plugin: BCPlugin;
Expand Down
6 changes: 3 additions & 3 deletions src/StatsView.ts → src/Views/StatsView.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ItemView, WorkspaceLeaf } from "obsidian";
import { STATS_VIEW } from "./constants";
import type BCPlugin from "./main";
import Stats from "./Components/Stats.svelte";
import { STATS_VIEW } from "../constants";
import type BCPlugin from "../main";
import Stats from "../Components/Stats.svelte";

export default class StatsView extends ItemView {
private plugin: BCPlugin;
Expand Down
6 changes: 3 additions & 3 deletions src/TreeView.ts → src/Views/TreeView.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ItemView, WorkspaceLeaf } from "obsidian";
import { addFeatherIcon } from "obsidian-community-lib";
import SideTree from "./Components/SideTree.svelte";
import { TREE_VIEW } from "./constants";
import type BCPlugin from "./main";
import SideTree from "../Components/SideTree.svelte";
import { TREE_VIEW } from "../constants";
import type BCPlugin from "../../main";

export default class TreeView extends ItemView {
private plugin: BCPlugin;
Expand Down
8 changes: 8 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,12 @@ export const DEFAULT_SETTINGS: BCSettings = {
visClosed: "Real",
visAll: "All",
wikilinkIndex: true,
impliedRelations: {
siblingIdentity: false,
sameParentIsSibling: false,
siblingsSiblingIsSibling: false,
parentsSiblingsIsParents: false,
parentsParentsIsParent: false,
cousinsIsSibling: false,
},
};
9 changes: 5 additions & 4 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { MultiGraph } from "graphology";
import type { LogLevel } from "loglevel";
import type { Constructor, FrontMatterCache, Pos, TFile } from "obsidian";
import type TreeView from "./TreeView";
import type TreeView from "./Views/TreeView";
import type {
CODEBLOCK_FIELDS,
CODEBLOCK_TYPES,
DIRECTIONS,
} from "./constants";
import type DucksView from "./DucksView";
import type MatrixView from "./MatrixView";
import type StatsView from "./StatsView";
import type DucksView from "./Views/DucksView";
import type MatrixView from "./Views/MatrixView";
import type StatsView from "./Views/StatsView";
import type { IJugglSettings } from "juggl-api";

export type DebugLevel = keyof LogLevel;
Expand All @@ -35,6 +35,7 @@ export interface BCSettings {
heatmapColour: string;
hierarchyNotes: string[];
HNUpField: string;
/** WARNING: The defaults for this feature are all `false`! */
impliedRelations: {
/** Has it's own toggle already */
siblingIdentity: boolean;
Expand Down
12 changes: 6 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { MultiGraph } from "graphology";
import { addIcon, EventRef, MarkdownView, Notice, Plugin } from "obsidian";
import { addIcon, EventRef, MarkdownView, Plugin } from "obsidian";
import {
addFeatherIcon,
openView,
Expand All @@ -25,15 +25,15 @@ import {
TRAIL_ICON_SVG,
TREE_VIEW,
} from "./constants";
import DucksView from "./DucksView";
import { FieldSuggestor } from "./FieldSuggestor";
import type { BCSettings, Directions, MyView, ViewInfo } from "./interfaces";
import MatrixView from "./MatrixView";
import { initGraphs, refreshIndex } from "./refreshIndex";
import { getFields } from "./sharedFunctions";
import StatsView from "./StatsView";
import TreeView from "./TreeView";
import DucksView from "./Views/DucksView";
import MatrixView from "./Views/MatrixView";
import StatsView from "./Views/StatsView";
import { drawTrail } from "./Views/TrailView";
import TreeView from "./Views/TreeView";
import { VisModal } from "./VisModal";

export default class BCPlugin extends Plugin {
Expand Down Expand Up @@ -92,12 +92,12 @@ export default class BCPlugin extends Plugin {
const { settings } = this;
this.addSettingTab(new BCSettingTab(this.app, this));

// Prevent breaking change
if (typeof settings.debugMode === "boolean") {
settings.debugMode = settings.debugMode ? "DEBUG" : "WARN";
await this.saveSettings();
}

// Prevent breaking change
//@ts-ignore
const { userHierarchies } = settings;
if (userHierarchies !== undefined && userHierarchies.length > 0) {
Expand Down

0 comments on commit 5137253

Please sign in to comment.