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#DataAdapter TypeScript Examples
The following examples show how to use
obsidian#DataAdapter.
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: replaceImages.ts From obsidian-ReadItLater with MIT License | 5 votes |
async function chooseFileName(
adapter: DataAdapter,
dir: string,
baseName: string,
link: string,
contentData: ArrayBuffer,
fileExtension: string | false,
): Promise<{ fileName: string; needWrite: boolean }> {
if (!fileExtension) {
return { fileName: '', needWrite: false };
}
// if there is no anchor try get file name from url
if (!baseName) {
const parsedUrl = new URL(link);
baseName = basename(parsedUrl.pathname);
}
// if there is no part for file name from url use name template
if (!baseName) {
baseName = FILENAME_TEMPLATE;
}
// if filename already ends with correct extension, remove it to work with base name
if (baseName.endsWith(`.${fileExtension}`)) {
baseName = baseName.slice(0, -1 * (fileExtension.length + 1));
}
baseName = normalizeFilename(baseName);
let fileName = '';
let needWrite = true;
let index = 0;
while (!fileName && index < MAX_FILENAME_INDEX) {
const suggestedName = index
? pathJoin(dir, `${baseName}-${index}.${fileExtension}`)
: pathJoin(dir, `${baseName}.${fileExtension}`);
if (await adapter.exists(suggestedName, false)) {
linkHashes.ensureHashGenerated(link, contentData);
const fileData = await adapter.readBinary(suggestedName);
if (linkHashes.isSame(link, fileData)) {
fileName = suggestedName;
needWrite = false;
}
} else {
fileName = suggestedName;
}
index++;
}
if (!fileName) {
throw new Error('Failed to generate file name for media file.');
}
linkHashes.ensureHashGenerated(link, contentData);
return { fileName, needWrite };
}
Example #2
Source File: main.ts From obsidian-readwise with GNU General Public License v3.0 | 5 votes |
fs: DataAdapter;