Skip to content

Commit

Permalink
Support templates and new note folders
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed Apr 28, 2021
1 parent e2a7986 commit a345578
Show file tree
Hide file tree
Showing 15 changed files with 31,477 additions and 19,504 deletions.
49,198 changes: 29,833 additions & 19,365 deletions dist/main.js

Large diffs are not rendered by default.

440 changes: 437 additions & 3 deletions dist/styles.css

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@
"@rollup/plugin-replace": "^2.4.2",
"@textcomplete/core": "^0.1.9",
"@textcomplete/textarea": "^0.1.9",
"@types/js-yaml": "^4.0.1",
"@types/react-beautiful-dnd": "^13.0.0",
"@types/react-dom": "^17.0.3",
"babel": "^6.23.0",
"choices.js": "^9.0.1",
"dotenv": "^8.2.0",
"fuse.js": "^6.4.6",
"immutability-helper": "^3.1.1",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"monkey-around": "^2.1.0",
"react": "^17.0.2",
Expand Down
72 changes: 69 additions & 3 deletions src/KanbanView.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import update from "immutability-helper";
import ReactDOM from "react-dom";
import React from "react";
import { HoverParent, HoverPopover, TextFileView, WorkspaceLeaf } from "obsidian";
import {
HoverParent,
HoverPopover,
Menu,
TextFileView,
WorkspaceLeaf,
} from "obsidian";

import { boardToMd, mdToBoard } from "./parser";
import { Kanban } from "./components/Kanban";
import { DataBridge } from "./DataBridge";
import { Board } from "./components/types";
import KanbanPlugin from "./main";
import { KanbanSettings, SettingsModal } from "./Settings";

export const kanbanViewType = "kanban";
export const kanbanIcon = "blocks";

export class KanbanView extends TextFileView implements HoverParent {
plugin: KanbanPlugin;
dataBridge: DataBridge;
hoverPopover: HoverPopover | null;

Expand All @@ -26,15 +36,71 @@ export class KanbanView extends TextFileView implements HoverParent {
return this.file?.basename || "Kanban";
}

constructor(leaf: WorkspaceLeaf) {
constructor(leaf: WorkspaceLeaf, plugin: KanbanPlugin) {
super(leaf);
this.dataBridge = new DataBridge();
this.plugin = plugin;
}

async onClose() {
ReactDOM.unmountComponentAtNode(this.contentEl);
}

getSetting(key: keyof KanbanSettings) {
const localSetting = this.dataBridge.getData().settings[key]

if (localSetting) return localSetting;

const globalSetting = this.plugin.settings[key];

if (globalSetting) return globalSetting;

return null
}

onMoreOptionsMenu(menu: Menu) {
// Add a menu item to force the board to markdown view
menu
.addItem((item) => {
item
.setTitle("Open as markdown")
.setIcon("document")
.onClick(() => {
this.plugin.kanbanFileModes[
(this.leaf as any).id || this.file.path
] = "markdown";
this.plugin.setMarkdownView(this.leaf);
});
})
.addItem((item) => {
item
.setTitle("Open board settings")
.setIcon("gear")
.onClick(() => {
const board = this.dataBridge.getData();

new SettingsModal(
this,
{
onSettingsChange: (settings) => {
this.dataBridge.setExternal(
update(board, {
settings: {
$set: settings,
},
})
);
},
},
board.settings
).open();
});
})
.addSeparator();

super.onMoreOptionsMenu(menu);
}

clear() {
this.dataBridge.reset();
}
Expand All @@ -47,7 +113,7 @@ export class KanbanView extends TextFileView implements HoverParent {
const trimmedContent = data.trim();
const board: Board = trimmedContent
? mdToBoard(trimmedContent)
: { lanes: [], archive: [] };
: { lanes: [], archive: [], settings: { "kanban-plugin": "basic" } };

if (clear) {
this.clear();
Expand Down
Loading

0 comments on commit a345578

Please sign in to comment.