import { Editor } from "obsidian" ; import { DEFAULT_SETTINGS } from 'settings' ; export class CheckIf { public static isMarkdownLinkAlready ( editor ) { let cursor = editor . getCursor ( ) ; var titleEnd = editor . getRange ( { ch : cursor . ch - 2 , line : cursor . line } , { ch : cursor . ch , line : cursor . line } ) ; return titleEnd == "](" ; } public static isAfterQuote ( editor ) { let cursor = editor . getCursor ( ) ; var beforeChar = editor . getRange ( { ch : cursor . ch - 1 , line : cursor . line } , { ch : cursor . ch , line : cursor . line } ) ; return beforeChar == "\"" || beforeChar == "'" ; } public static isUrl ( text ) { let urlRegex = new RegExp ( DEFAULT_SETTINGS . regex ) ; return urlRegex . test ( text ) ; } public static isImage ( text ) { let imageRegex = new RegExp ( DEFAULT_SETTINGS . imageRegex ) ; return imageRegex . test ( text ) ; } public static isLinkedUrl ( text ) { let urlRegex = new RegExp ( DEFAULT_SETTINGS . linkRegex ) ; return urlRegex . test ( text ) ; } }