mirror of
https://github.com/shoedler/crossbow.git
synced 2026-07-22 07:40:26 +00:00
Adds license headers, fixes indentation
This commit is contained in:
parent
63b8949f20
commit
8638b49812
17 changed files with 214 additions and 114 deletions
|
|
@ -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
|
||||
|
|
|
|||
44
.eslintrc
44
.eslintrc
|
|
@ -1,23 +1,23 @@
|
|||
{
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"env": { "node": true },
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"no-prototype-builtins": "off",
|
||||
"@typescript-eslint/no-empty-function": "off"
|
||||
}
|
||||
}
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"env": { "node": true },
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"no-prototype-builtins": "off",
|
||||
"@typescript-eslint/no-empty-function": "off"
|
||||
}
|
||||
}
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -19,4 +19,4 @@ main.js
|
|||
data.json
|
||||
|
||||
# Exclude macOS Finder (System Explorer) View States
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false
|
||||
}
|
||||
|
|
@ -23,7 +23,6 @@ which will insert the following link:
|
|||
|
||||

|
||||
|
||||
|
||||
## How to install manually
|
||||
|
||||
1. Clone this repo.
|
||||
|
|
|
|||
|
|
@ -12,31 +12,31 @@ if you want to view the source, please visit the github repository of this plugi
|
|||
const prod = (process.argv[2] === 'production');
|
||||
|
||||
esbuild.build({
|
||||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
entryPoints: ['src/main.ts'],
|
||||
bundle: true,
|
||||
external: [
|
||||
'obsidian',
|
||||
'electron',
|
||||
'@codemirror/autocomplete',
|
||||
'@codemirror/collab',
|
||||
'@codemirror/commands',
|
||||
'@codemirror/language',
|
||||
'@codemirror/lint',
|
||||
'@codemirror/search',
|
||||
'@codemirror/state',
|
||||
'@codemirror/view',
|
||||
'@lezer/common',
|
||||
'@lezer/highlight',
|
||||
'@lezer/lr',
|
||||
...builtins],
|
||||
format: 'cjs',
|
||||
watch: !prod,
|
||||
target: 'es2018',
|
||||
logLevel: "info",
|
||||
sourcemap: prod ? false : 'inline',
|
||||
treeShaking: true,
|
||||
outfile: './main.js',
|
||||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
entryPoints: ['src/main.ts'],
|
||||
bundle: true,
|
||||
external: [
|
||||
'obsidian',
|
||||
'electron',
|
||||
'@codemirror/autocomplete',
|
||||
'@codemirror/collab',
|
||||
'@codemirror/commands',
|
||||
'@codemirror/language',
|
||||
'@codemirror/lint',
|
||||
'@codemirror/search',
|
||||
'@codemirror/state',
|
||||
'@codemirror/view',
|
||||
'@lezer/common',
|
||||
'@lezer/highlight',
|
||||
'@lezer/lr',
|
||||
...builtins],
|
||||
format: 'cjs',
|
||||
watch: !prod,
|
||||
target: 'es2018',
|
||||
logLevel: "info",
|
||||
sourcemap: prod ? false : 'inline',
|
||||
treeShaking: true,
|
||||
outfile: './main.js',
|
||||
}).catch(() => process.exit(1));
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"id": "crossbow",
|
||||
"name": "Crossbow",
|
||||
"version": "1.0.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Obsidian plugin to find possible backlinks in your notes.",
|
||||
"author": "Obsidian",
|
||||
"authorUrl": "https://github.com/shoedler",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
"id": "crossbow",
|
||||
"name": "Crossbow",
|
||||
"version": "1.0.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Plugin to find possible backlinks in your notes.",
|
||||
"author": "shoedler",
|
||||
"authorUrl": "https://github.com/shoedler",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
46
package.json
46
package.json
|
|
@ -1,24 +1,24 @@
|
|||
{
|
||||
"name": "crossbow",
|
||||
"version": "1.0.0",
|
||||
"description": "Obsidian plugin to find possible backlinks in your notes (https://obsidian.md)",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"dev": "node esbuild.config.mjs",
|
||||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
||||
"version": "node version-bump.mjs && git add manifest.json versions.json"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.6",
|
||||
"@typescript-eslint/eslint-plugin": "5.29.0",
|
||||
"@typescript-eslint/parser": "5.29.0",
|
||||
"builtin-modules": "3.3.0",
|
||||
"esbuild": "0.14.47",
|
||||
"obsidian": "latest",
|
||||
"tslib": "2.4.0",
|
||||
"typescript": "4.7.4"
|
||||
}
|
||||
}
|
||||
"name": "crossbow",
|
||||
"version": "1.0.0",
|
||||
"description": "Obsidian plugin to find possible backlinks in your notes (https://obsidian.md)",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"dev": "node esbuild.config.mjs",
|
||||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
||||
"version": "node version-bump.mjs && git add manifest.json versions.json"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "shoedler",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.6",
|
||||
"@typescript-eslint/eslint-plugin": "5.29.0",
|
||||
"@typescript-eslint/parser": "5.29.0",
|
||||
"builtin-modules": "3.3.0",
|
||||
"esbuild": "0.14.47",
|
||||
"obsidian": "latest",
|
||||
"tslib": "2.4.0",
|
||||
"typescript": "4.7.4"
|
||||
}
|
||||
}
|
||||
|
|
@ -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';
|
||||
|
||||
|
|
|
|||
12
src/icons.ts
12
src/icons.ts
|
|
@ -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 = {
|
||||
|
|
|
|||
13
src/main.ts
13
src/main.ts
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
12
src/util.ts
12
src/util.ts
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"1.0.0": "0.15.0"
|
||||
}
|
||||
"1.0.0": "0.15.0"
|
||||
}
|
||||
Loading…
Reference in a new issue