Adds license headers, fixes indentation

This commit is contained in:
Simon Schödler 2023-04-04 10:50:20 +02:00
parent 63b8949f20
commit 8638b49812
17 changed files with 214 additions and 114 deletions

View file

@ -5,6 +5,6 @@ root = true
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4
tab_width = 4
indent_style = space
indent_size = 2
tab_width = 2

View file

@ -23,7 +23,6 @@ which will insert the following link:
![image](https://user-images.githubusercontent.com/38029550/229280048-fe7a8e31-8cbf-4090-a7f0-4bf0b83814d7.png)
## How to install manually
1. Clone this repo.

View file

@ -3,8 +3,8 @@
"name": "Crossbow",
"version": "1.0.0",
"minAppVersion": "0.15.0",
"description": "Obsidian plugin to find possible backlinks in your notes.",
"author": "Obsidian",
"description": "Plugin to find possible backlinks in your notes.",
"author": "shoedler",
"authorUrl": "https://github.com/shoedler",
"isDesktopOnly": false
}

View file

@ -9,7 +9,7 @@
"version": "node version-bump.mjs && git add manifest.json versions.json"
},
"keywords": [],
"author": "",
"author": "shoedler",
"license": "MIT",
"devDependencies": {
"@types/node": "^16.11.6",

View file

@ -1,3 +1,15 @@
// Copyright (C) 2023 - shoedler - github.com/shoedler
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
import { Editor, EditorPosition } from 'obsidian';
import { stripMarkdown } from './util';

View file

@ -1,3 +1,15 @@
// Copyright (C) 2023 - shoedler - github.com/shoedler
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
import { addIcon } from 'obsidian';
const crossbowIcon = {

View file

@ -1,3 +1,15 @@
// Copyright (C) 2023 - shoedler - github.com/shoedler
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
import { CrossbowView } from './view/view';
import { registerCrossbowIcons } from './icons';
import {
@ -6,7 +18,6 @@ import {
MarkdownView,
Plugin,
TFile,
EditorPosition,
CachedMetadata,
} from 'obsidian';
import { CrossbowSettingTab } from './settings';

View file

@ -1,3 +1,15 @@
// Copyright (C) 2023 - shoedler - github.com/shoedler
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
import { App, PluginSettingTab, Setting } from 'obsidian';
import CrossbowPlugin, { CrossbowPluginSettings } from './main';

View file

@ -1,3 +1,15 @@
// Copyright (C) 2023 - shoedler - github.com/shoedler
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
import { EditorPosition } from 'obsidian';
import { CacheMatch } from './main';
import { TreeItem, TreeItemBase } from './view/treeItem';
@ -17,8 +29,9 @@ export class Suggestion extends TreeItem<string> {
return this.value;
}
public getChildren = () =>
Array.from(this.childrenWrapper.children) as Occurrence[];
public getChildren() {
return Array.from(this.childrenWrapper.children) as Occurrence[];
}
public sortChildren(): void {
this.getChildren()
@ -45,8 +58,9 @@ export class Occurrence extends TreeItem<EditorPosition> {
return `On line ${this.value.line}:${this.value.ch}`;
}
public getChildren = () =>
Array.from(this.childrenWrapper.children) as Match[];
public getChildren() {
return Array.from(this.childrenWrapper.children) as Match[];
}
public sortChildren(): void {
this.getChildren().sort(

View file

@ -1,3 +1,15 @@
// Copyright (C) 2023 - shoedler - github.com/shoedler
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Credit: https://github.com/stiang/remove-markdown
export interface StripMarkdownOptions {

View file

@ -1,3 +1,15 @@
// Copyright (C) 2023 - shoedler - github.com/shoedler
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
import { ButtonComponent, getIcon } from 'obsidian';
export abstract class TreeItemBase<TData> extends HTMLElement {
@ -37,15 +49,17 @@ export abstract class TreeItemBase<TData> extends HTMLElement {
}
public connectedCallback() {
console.log(this.text, this.parentElement, this.parentNode);
this.inner.setText(this.text);
}
public abstract sortChildren(): void;
public setDisable = () => {
public setDisable() {
this.mainWrapper.style.textDecoration = 'line-through';
this.buttons.forEach((button) => button.setDisabled(true));
};
}
public addOnClick = (
listener: (this: HTMLDivElement, ev: HTMLElementEventMap['click']) => any
@ -87,10 +101,10 @@ export abstract class TreeItem<TData> extends TreeItemBase<TData> {
this.addClass('is-collapsed');
this.mainWrapper.addClass('mod-collapsible');
this.childrenWrapper = createEl('div', { cls: 'tree-item-children' });
this.childrenWrapper = this.createDiv({ cls: 'tree-item-children' });
this.childrenWrapper.style.display = 'none';
this.iconWrapper = createEl('div', {
this.iconWrapper = this.createDiv({
cls: ['tree-item-icon', 'collapse-icon'],
});
this.iconWrapper.appendChild(getIcon('right-triangle')!);
@ -106,31 +120,29 @@ export abstract class TreeItem<TData> extends TreeItemBase<TData> {
public abstract getChildren(): TreeItemBase<any>[];
public isCollapsed = () => this.hasClass('is-collapsed');
public isCollapsed() {
return this.hasClass('is-collapsed');
}
public expand = () => {
public expand() {
this.removeClass('is-collapsed');
this.childrenWrapper.style.display = 'block';
};
}
public collapse = () => {
public collapse() {
this.addClass('is-collapsed');
this.childrenWrapper.style.display = 'none';
};
}
public setDisable = () => {
public setDisable() {
super.setDisable();
this.mainWrapper.style.textDecoration = 'line-through';
Array.from(this.childrenWrapper.children).forEach((child) =>
(child as TreeItemBase<any>).setDisable()
);
};
public addChildren = (children: TreeItemBase<any>[]) => {
console.log('addChildren', this.childrenWrapper, children);
children.forEach((child) => {
this.childrenWrapper.appendChild(child);
});
};
}
public addChildren(children: TreeItemBase<any>[]) {
this.childrenWrapper.replaceChildren(...children);
}
}

View file

@ -1,3 +1,15 @@
// Copyright (C) 2023 - shoedler - github.com/shoedler
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
import { EditorPosition, ItemView, WorkspaceLeaf } from 'obsidian';
import { Match, Occurrence, Suggestion } from 'src/suggestion';
import CrossbowPlugin, { CacheMatch } from 'src/main';
@ -185,6 +197,10 @@ export class CrossbowView extends ItemView {
suggestion.addChildren(occurrences);
const w = window as any;
w.suggestions = w.suggestions || [];
w.suggestions.push({ suggestion, occurrences });
return suggestion;
};
}