obsidian APIs
- Plugin
- PluginSettingTab
- Setting
- App
- TFile
- Notice
- MarkdownView
- Modal
- Editor
- Vault
- addIcon
- WorkspaceLeaf
- TFolder
- TAbstractFile
- MarkdownPostProcessorContext
- Platform
- Menu
- normalizePath
- FuzzySuggestModal
- ButtonComponent
- FuzzyMatch
- MarkdownRenderer
- debounce
- TextComponent
- EditorPosition
- ItemView
- moment
- request
- DropdownComponent
- TextAreaComponent
- FileSystemAdapter
- CachedMetadata
- Scope
- MetadataCache
- ToggleComponent
- MarkdownRenderChild
- SuggestModal
- setIcon
- HeadingCache
- getAllTags
- EditorSuggest
- EditorSuggestContext
- EditorSuggestTriggerInfo
- FrontMatterCache
- FileView
- Component
- parseYaml
- Workspace
- LinkCache
- editorViewField
- EventRef
- View
- PluginManifest
- Pos
- Debouncer
- requestUrl
- ExtraButtonComponent
- MarkdownPostProcessor
- DataAdapter
- ListedFiles
- parseLinktext
- MenuItem
- ISuggestOwner
- OpenViewState
- FileManager
- ObsidianProtocolData
- Events
- SearchComponent
- ViewState
- renderResults
- Command
- Keymap
- Loc
- TagCache
- SearchMatches
- EmbedCache
- parseFrontMatterTags
- AbstractTextComponent
- Point
- MarkdownPreviewRenderer
- getLinkpath
- requireApiVersion
- resolveSubpath
- EditorRangeOrCaret
- EditorTransaction
- FolderItem
- ClipboardManager
- DragManager
- FileExplorerView
- AFItem
- Modifier
- EditorRange
- FileStats
- finishRenderMath
- loadMathJax
- renderMath
- fuzzySearch
- InstalledPlugin
- InternalPlugins
- prepareQuery
- CommandPalettePluginInstance
- PreparedQuery
- WorkspaceItem
- WorkspaceSplit
- ViewRegistry
- SearchResult
- StarredPluginInstance
- FileStarredItem
- StarredPluginItem
- ReferenceCache
- WorkspacesPluginInstance
- sortSearchResults
- SearchStarredItem
- Plugin_2
- QuickSwitcherOptions
- QuickSwitcherPluginInstance
- Chooser
- Hotkey
- KeymapContext
- KeymapEventListener
- RequestUrlResponse
- MarkdownPreviewView
- PopoverSuggest
- BlockCache
- stringifyYaml
- UserEvent
- renderMatches
- SearchMatchPart
- TextFileView
- ViewStateResult
- htmlToMarkdown
- MomentFormatComponent
- RequestUrlParam
- EditorSelection
- EditorSelectionOrCaret
- editorLivePreviewField
Other Related APIs
obsidian#resolveSubpath TypeScript Examples
The following examples show how to use
obsidian#resolveSubpath.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InternalModuleFile.ts From Templater with GNU Affero General Public License v3.0 | 5 votes |
generate_include(): (include_link: string | TFile) => Promise<string> {
return async (include_link: string | TFile) => {
// TODO: Add mutex for this, this may currently lead to a race condition.
// While not very impactful, that could still be annoying.
this.include_depth += 1;
if (this.include_depth > DEPTH_LIMIT) {
this.include_depth -= 1;
throw new TemplaterError(
"Reached inclusion depth limit (max = 10)"
);
}
let inc_file_content: string;
if (include_link instanceof TFile) {
inc_file_content = await this.app.vault.read(include_link);
} else {
let match;
if ((match = this.linkpath_regex.exec(include_link)) === null) {
this.include_depth -= 1;
throw new TemplaterError(
"Invalid file format, provide an obsidian link between quotes."
);
}
const { path, subpath } = parseLinktext(match[1]);
const inc_file = this.app.metadataCache.getFirstLinkpathDest(
path,
""
);
if (!inc_file) {
this.include_depth -= 1;
throw new TemplaterError(
`File ${include_link} doesn't exist`
);
}
inc_file_content = await this.app.vault.read(inc_file);
if (subpath) {
const cache = this.app.metadataCache.getFileCache(inc_file);
if (cache) {
const result = resolveSubpath(cache, subpath);
if (result) {
inc_file_content = inc_file_content.slice(
result.start.offset,
result.end?.offset
);
}
}
}
}
try {
const parsed_content =
await this.plugin.templater.parser.parse_commands(
inc_file_content,
this.plugin.templater.current_functions_object
);
this.include_depth -= 1;
return parsed_content;
} catch (e) {
this.include_depth -= 1;
throw e;
}
};
}