fix typescript
Some checks failed
Node.js build / build (20.x) (push) Has been cancelled
Node.js build / build (22.x) (push) Has been cancelled

This commit is contained in:
2026-02-27 10:12:27 -05:00
parent 7022dadd83
commit 358ddca2f0
8 changed files with 386 additions and 452 deletions

View File

@@ -7,6 +7,7 @@ import {
EditorRangeOrCaret, EditorRangeOrCaret,
EditorSelection, EditorSelection,
EditorTransaction, EditorTransaction,
MarkdownFileInfo,
MarkdownView, MarkdownView,
} from 'obsidian' } from 'obsidian'
import BindThemPlugin from './main' import BindThemPlugin from './main'
@@ -244,7 +245,7 @@ export class BetterFormatting {
*/ */
public toggleWrapper( public toggleWrapper(
editor: Editor, editor: Editor,
view: MarkdownView, view: MarkdownView | MarkdownFileInfo,
symbolStart: string, symbolStart: string,
symbolEnd?: string symbolEnd?: string
): void { ): void {

View File

@@ -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 BindThemPlugin from './main'
import { Direction } from './Entities' import { Direction } from './Entities'
import { selectionToLine, selectionToRange } from './Utils' import { selectionToLine, selectionToRange } from './Utils'
@@ -20,7 +20,7 @@ export class DirectionalCopy {
*/ */
public directionalCopy( public directionalCopy(
editor: Editor, editor: Editor,
view: MarkdownView, view: MarkdownView | MarkdownFileInfo,
direction: Direction direction: Direction
): void { ): void {
const selections = editor.listSelections() const selections = editor.listSelections()

View File

@@ -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 BindThemPlugin from './main'
import { Direction } from './Entities' import { Direction } from './Entities'
import { selectionToRange } from './Utils' import { selectionToRange } from './Utils'
@@ -20,7 +20,7 @@ export class DirectionalMove {
*/ */
public directionalMove( public directionalMove(
editor: Editor, editor: Editor,
view: MarkdownView, view: MarkdownView | MarkdownFileInfo,
direction: Direction.Left | Direction.Right direction: Direction.Left | Direction.Right
): void { ): void {
const selections = editor.listSelections() const selections = editor.listSelections()

View File

@@ -1,4 +1,4 @@
import { App, Editor, MarkdownView, Notice } from 'obsidian' import { App, Editor, MarkdownFileInfo, MarkdownView, Notice } from 'obsidian'
import BindThemPlugin from './main' import BindThemPlugin from './main'
/** /**
@@ -16,7 +16,7 @@ export class FileHelper {
/** /**
* Duplicate the current file * 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() const activeFile = this.app.workspace.getActiveFile()
if (activeFile === null) { if (activeFile === null) {
@@ -30,7 +30,9 @@ export class FileHelper {
try { try {
const newFile = await this.app.vault.copy(activeFile, newFilePath) const newFile = await this.app.vault.copy(activeFile, newFilePath)
await view.leaf.openFile(newFile) if (view instanceof MarkdownView) {
await view.leaf.openFile(newFile)
}
editor.setSelections(selections) editor.setSelections(selections)
} catch (e) { } catch (e) {
@@ -41,7 +43,7 @@ export class FileHelper {
/** /**
* Create a new file in the same directory as the current file * 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() const activeFile = this.app.workspace.getActiveFile()
if (activeFile === null) { if (activeFile === null) {
@@ -53,7 +55,9 @@ export class FileHelper {
try { try {
const newFile = await this.app.vault.create(newFilePath, '') const newFile = await this.app.vault.create(newFilePath, '')
await view.leaf.openFile(newFile) if (view instanceof MarkdownView) {
await view.leaf.openFile(newFile)
}
} catch (e) { } catch (e) {
new Notice(String(e)) new Notice(String(e))
} }

View File

@@ -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 BindThemPlugin from './main'
import { selectionToLine, selectionToRange } from './Utils' import { selectionToLine, selectionToRange } from './Utils'
@@ -17,7 +17,7 @@ export class SelectionHelper {
/** /**
* Select the current line(s) * 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 selections = editor.listSelections()
const newSelectionRanges: Array<EditorRange> = [] const newSelectionRanges: Array<EditorRange> = []
@@ -36,7 +36,7 @@ export class SelectionHelper {
/** /**
* Select the current word(s) * 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 selections = editor.listSelections()
const newSelections: Array<EditorRange> = [] const newSelections: Array<EditorRange> = []

View File

@@ -1,4 +1,4 @@
import { App, Editor, EditorPosition, MarkdownView } from 'obsidian' import { App, Editor, EditorPosition, MarkdownFileInfo, MarkdownView } from 'obsidian'
import BindThemPlugin from './main' import BindThemPlugin from './main'
import { LIST_CHARACTER_REGEX } from './Constants' import { LIST_CHARACTER_REGEX } from './Constants'
@@ -97,7 +97,7 @@ export class SentenceNavigator {
/** /**
* Delete text from cursor to sentence boundary * 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) let { cursorPosition, paragraphText } = this.getCursorAndParagraphText(editor)
const originalCursorPosition = cursorPosition const originalCursorPosition = cursorPosition
@@ -149,7 +149,7 @@ export class SentenceNavigator {
/** /**
* Select text from cursor to sentence boundary * 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) const { cursorPosition, paragraphText } = this.getCursorAndParagraphText(editor)
this.forEachSentence(paragraphText, (sentence) => { this.forEachSentence(paragraphText, (sentence) => {
const idx = sentence.index ?? 0 const idx = sentence.index ?? 0
@@ -183,7 +183,7 @@ export class SentenceNavigator {
/** /**
* Move cursor to the start of the current sentence * 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) let { cursorPosition, paragraphText } = this.getCursorAndParagraphText(editor)
if (cursorPosition.ch === 0 || this.isAtStartOfListItem(cursorPosition, paragraphText)) { if (cursorPosition.ch === 0 || this.isAtStartOfListItem(cursorPosition, paragraphText)) {
@@ -214,7 +214,7 @@ export class SentenceNavigator {
/** /**
* Move cursor to the start of the next sentence * 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) let { cursorPosition, paragraphText } = this.getCursorAndParagraphText(editor)
if (cursorPosition.ch === paragraphText.length) { if (cursorPosition.ch === paragraphText.length) {
@@ -252,7 +252,7 @@ export class SentenceNavigator {
/** /**
* Select the current sentence * 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) const { cursorPosition, paragraphText } = this.getCursorAndParagraphText(editor)
let offset = 0 let offset = 0
let text = paragraphText let text = paragraphText

View File

@@ -4,6 +4,7 @@ import {
EditorChange, EditorChange,
EditorPosition, EditorPosition,
EditorTransaction, EditorTransaction,
MarkdownFileInfo,
MarkdownView, MarkdownView,
} from 'obsidian' } from 'obsidian'
import BindThemPlugin from './main' import BindThemPlugin from './main'
@@ -69,7 +70,7 @@ export class ToggleHeading {
*/ */
public toggleHeading( public toggleHeading(
editor: Editor, editor: Editor,
view: MarkdownView, view: MarkdownView | MarkdownFileInfo,
heading: Heading heading: Heading
): void { ): void {
const selections = editor.listSelections() const selections = editor.listSelections()
@@ -111,7 +112,7 @@ export class ToggleHeading {
*/ */
public toggleHeadingWithStrip( public toggleHeadingWithStrip(
editor: Editor, editor: Editor,
view: MarkdownView, view: MarkdownView | MarkdownFileInfo,
level: number level: number
): void { ): void {
const cursor = editor.getCursor() const cursor = editor.getCursor()

File diff suppressed because it is too large Load Diff