fix typescript
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
EditorRangeOrCaret,
|
||||
EditorSelection,
|
||||
EditorTransaction,
|
||||
MarkdownFileInfo,
|
||||
MarkdownView,
|
||||
} from 'obsidian'
|
||||
import BindThemPlugin from './main'
|
||||
@@ -244,7 +245,7 @@ export class BetterFormatting {
|
||||
*/
|
||||
public toggleWrapper(
|
||||
editor: Editor,
|
||||
view: MarkdownView,
|
||||
view: MarkdownView | MarkdownFileInfo,
|
||||
symbolStart: string,
|
||||
symbolEnd?: string
|
||||
): void {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { App, Editor, EditorChange, EditorTransaction, MarkdownView } from 'obsidian'
|
||||
import { App, Editor, EditorChange, EditorTransaction, MarkdownFileInfo, MarkdownView } from 'obsidian'
|
||||
import BindThemPlugin from './main'
|
||||
import { Direction } from './Entities'
|
||||
import { selectionToLine, selectionToRange } from './Utils'
|
||||
@@ -20,7 +20,7 @@ export class DirectionalCopy {
|
||||
*/
|
||||
public directionalCopy(
|
||||
editor: Editor,
|
||||
view: MarkdownView,
|
||||
view: MarkdownView | MarkdownFileInfo,
|
||||
direction: Direction
|
||||
): void {
|
||||
const selections = editor.listSelections()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { App, Editor, EditorChange, EditorTransaction, MarkdownView } from 'obsidian'
|
||||
import { App, Editor, EditorChange, EditorTransaction, MarkdownFileInfo, MarkdownView } from 'obsidian'
|
||||
import BindThemPlugin from './main'
|
||||
import { Direction } from './Entities'
|
||||
import { selectionToRange } from './Utils'
|
||||
@@ -20,7 +20,7 @@ export class DirectionalMove {
|
||||
*/
|
||||
public directionalMove(
|
||||
editor: Editor,
|
||||
view: MarkdownView,
|
||||
view: MarkdownView | MarkdownFileInfo,
|
||||
direction: Direction.Left | Direction.Right
|
||||
): void {
|
||||
const selections = editor.listSelections()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { App, Editor, MarkdownView, Notice } from 'obsidian'
|
||||
import { App, Editor, MarkdownFileInfo, MarkdownView, Notice } from 'obsidian'
|
||||
import BindThemPlugin from './main'
|
||||
|
||||
/**
|
||||
@@ -16,7 +16,7 @@ export class FileHelper {
|
||||
/**
|
||||
* Duplicate the current file
|
||||
*/
|
||||
public async duplicateFile(editor: Editor, view: MarkdownView): Promise<void> {
|
||||
public async duplicateFile(editor: Editor, view: MarkdownView | MarkdownFileInfo): Promise<void> {
|
||||
const activeFile = this.app.workspace.getActiveFile()
|
||||
|
||||
if (activeFile === null) {
|
||||
@@ -30,7 +30,9 @@ export class FileHelper {
|
||||
|
||||
try {
|
||||
const newFile = await this.app.vault.copy(activeFile, newFilePath)
|
||||
if (view instanceof MarkdownView) {
|
||||
await view.leaf.openFile(newFile)
|
||||
}
|
||||
|
||||
editor.setSelections(selections)
|
||||
} catch (e) {
|
||||
@@ -41,7 +43,7 @@ export class FileHelper {
|
||||
/**
|
||||
* Create a new file in the same directory as the current file
|
||||
*/
|
||||
public async newAdjacentFile(editor: Editor, view: MarkdownView): Promise<void> {
|
||||
public async newAdjacentFile(editor: Editor, view: MarkdownView | MarkdownFileInfo): Promise<void> {
|
||||
const activeFile = this.app.workspace.getActiveFile()
|
||||
|
||||
if (activeFile === null) {
|
||||
@@ -53,7 +55,9 @@ export class FileHelper {
|
||||
|
||||
try {
|
||||
const newFile = await this.app.vault.create(newFilePath, '')
|
||||
if (view instanceof MarkdownView) {
|
||||
await view.leaf.openFile(newFile)
|
||||
}
|
||||
} catch (e) {
|
||||
new Notice(String(e))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { App, Editor, EditorRange, EditorTransaction, MarkdownView } from 'obsidian'
|
||||
import { App, Editor, EditorRange, EditorTransaction, MarkdownFileInfo, MarkdownView } from 'obsidian'
|
||||
import BindThemPlugin from './main'
|
||||
import { selectionToLine, selectionToRange } from './Utils'
|
||||
|
||||
@@ -17,7 +17,7 @@ export class SelectionHelper {
|
||||
/**
|
||||
* Select the current line(s)
|
||||
*/
|
||||
public selectLine(editor: Editor, view: MarkdownView): void {
|
||||
public selectLine(editor: Editor, view: MarkdownView | MarkdownFileInfo): void {
|
||||
const selections = editor.listSelections()
|
||||
|
||||
const newSelectionRanges: Array<EditorRange> = []
|
||||
@@ -36,7 +36,7 @@ export class SelectionHelper {
|
||||
/**
|
||||
* Select the current word(s)
|
||||
*/
|
||||
public selectWord(editor: Editor, view: MarkdownView): void {
|
||||
public selectWord(editor: Editor, view: MarkdownView | MarkdownFileInfo): void {
|
||||
const selections = editor.listSelections()
|
||||
|
||||
const newSelections: Array<EditorRange> = []
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { App, Editor, EditorPosition, MarkdownView } from 'obsidian'
|
||||
import { App, Editor, EditorPosition, MarkdownFileInfo, MarkdownView } from 'obsidian'
|
||||
import BindThemPlugin from './main'
|
||||
import { LIST_CHARACTER_REGEX } from './Constants'
|
||||
|
||||
@@ -97,7 +97,7 @@ export class SentenceNavigator {
|
||||
/**
|
||||
* Delete text from cursor to sentence boundary
|
||||
*/
|
||||
public deleteToBoundary(editor: Editor, view: MarkdownView, boundary: 'start' | 'end'): void {
|
||||
public deleteToBoundary(editor: Editor, view: MarkdownView | MarkdownFileInfo, boundary: 'start' | 'end'): void {
|
||||
let { cursorPosition, paragraphText } = this.getCursorAndParagraphText(editor)
|
||||
const originalCursorPosition = cursorPosition
|
||||
|
||||
@@ -149,7 +149,7 @@ export class SentenceNavigator {
|
||||
/**
|
||||
* Select text from cursor to sentence boundary
|
||||
*/
|
||||
public selectToBoundary(editor: Editor, view: MarkdownView, boundary: 'start' | 'end'): void {
|
||||
public selectToBoundary(editor: Editor, view: MarkdownView | MarkdownFileInfo, boundary: 'start' | 'end'): void {
|
||||
const { cursorPosition, paragraphText } = this.getCursorAndParagraphText(editor)
|
||||
this.forEachSentence(paragraphText, (sentence) => {
|
||||
const idx = sentence.index ?? 0
|
||||
@@ -183,7 +183,7 @@ export class SentenceNavigator {
|
||||
/**
|
||||
* Move cursor to the start of the current sentence
|
||||
*/
|
||||
public moveToStartOfCurrentSentence(editor: Editor, view: MarkdownView): void {
|
||||
public moveToStartOfCurrentSentence(editor: Editor, view: MarkdownView | MarkdownFileInfo): void {
|
||||
let { cursorPosition, paragraphText } = this.getCursorAndParagraphText(editor)
|
||||
|
||||
if (cursorPosition.ch === 0 || this.isAtStartOfListItem(cursorPosition, paragraphText)) {
|
||||
@@ -214,7 +214,7 @@ export class SentenceNavigator {
|
||||
/**
|
||||
* Move cursor to the start of the next sentence
|
||||
*/
|
||||
public moveToStartOfNextSentence(editor: Editor, view: MarkdownView): void {
|
||||
public moveToStartOfNextSentence(editor: Editor, view: MarkdownView | MarkdownFileInfo): void {
|
||||
let { cursorPosition, paragraphText } = this.getCursorAndParagraphText(editor)
|
||||
|
||||
if (cursorPosition.ch === paragraphText.length) {
|
||||
@@ -252,7 +252,7 @@ export class SentenceNavigator {
|
||||
/**
|
||||
* Select the current sentence
|
||||
*/
|
||||
public selectSentence(editor: Editor, view: MarkdownView): void {
|
||||
public selectSentence(editor: Editor, view: MarkdownView | MarkdownFileInfo): void {
|
||||
const { cursorPosition, paragraphText } = this.getCursorAndParagraphText(editor)
|
||||
let offset = 0
|
||||
let text = paragraphText
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
EditorChange,
|
||||
EditorPosition,
|
||||
EditorTransaction,
|
||||
MarkdownFileInfo,
|
||||
MarkdownView,
|
||||
} from 'obsidian'
|
||||
import BindThemPlugin from './main'
|
||||
@@ -69,7 +70,7 @@ export class ToggleHeading {
|
||||
*/
|
||||
public toggleHeading(
|
||||
editor: Editor,
|
||||
view: MarkdownView,
|
||||
view: MarkdownView | MarkdownFileInfo,
|
||||
heading: Heading
|
||||
): void {
|
||||
const selections = editor.listSelections()
|
||||
@@ -111,7 +112,7 @@ export class ToggleHeading {
|
||||
*/
|
||||
public toggleHeadingWithStrip(
|
||||
editor: Editor,
|
||||
view: MarkdownView,
|
||||
view: MarkdownView | MarkdownFileInfo,
|
||||
level: number
|
||||
): void {
|
||||
const cursor = editor.getCursor()
|
||||
|
||||
784
src/main.ts
784
src/main.ts
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user