obsidian#EmbedCache TypeScript Examples

The following examples show how to use obsidian#EmbedCache. 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: fileCachedMetadata.fixture.ts    From obsidian-switcher-plus with GNU General Public License v3.0 6 votes vote down vote up
function getEmbeds(): EmbedCache[] {
  const e1 = makeLink(
    'google.jpg',
    '![[google.jpg]]',
    'google.jpg',
    makeLoc(16, 0, 303),
    makeLoc(16, 15, 318),
  );

  return [e1];
}
Example #2
Source File: links-handler.ts    From obsidian-consistent-attachments-and-links with MIT License 6 votes vote down vote up
getAllCachedEmbedsToFile(filePath: string): { [notePath: string]: EmbedCache[]; } {
		let allEmbeds: { [notePath: string]: EmbedCache[]; } = {};
		let notes = this.app.vault.getMarkdownFiles();

		if (notes) {
			for (let note of notes) {
				if (note.path == filePath)
					continue;

				//!!! this can return undefined if note was just updated
				let embeds = this.app.metadataCache.getCache(note.path)?.embeds;

				if (embeds) {
					for (let embed of embeds) {
						let linkFullPath = this.getFullPathForLink(embed.link, note.path);
						if (linkFullPath == filePath) {
							if (!allEmbeds[note.path])
								allEmbeds[note.path] = [];
							allEmbeds[note.path].push(embed);
						}
					}
				}
			}
		}

		return allEmbeds;
	}
Example #3
Source File: links-handler.ts    From obsidian-consistent-attachments-and-links with MIT License 6 votes vote down vote up
getAllBadEmbeds(): { [notePath: string]: EmbedCache[]; } {
		let allEmbeds: { [notePath: string]: EmbedCache[]; } = {};
		let notes = this.app.vault.getMarkdownFiles();

		if (notes) {
			for (let note of notes) {
				if (this.isPathIgnored(note.path))
					continue;

				//!!! this can return undefined if note was just updated
				let embeds = this.app.metadataCache.getCache(note.path)?.embeds;

				if (embeds) {
					for (let embed of embeds) {
						if (this.checkIsCorrectWikiEmbed(embed.original))
							continue;

						let file = this.getFileByLink(embed.link, note.path);
						if (!file) {
							if (!allEmbeds[note.path])
								allEmbeds[note.path] = [];
							allEmbeds[note.path].push(embed);
						}
					}
				}
			}
		}

		return allEmbeds;
	}
Example #4
Source File: links-handler.ts    From obsidian-consistent-attachments-and-links with MIT License 6 votes vote down vote up
getAllGoodEmbeds(): { [notePath: string]: EmbedCache[]; } {
		let allEmbeds: { [notePath: string]: EmbedCache[]; } = {};
		let notes = this.app.vault.getMarkdownFiles();

		if (notes) {
			for (let note of notes) {
				if (this.isPathIgnored(note.path))
					continue;

				//!!! this can return undefined if note was just updated
				let embeds = this.app.metadataCache.getCache(note.path)?.embeds;

				if (embeds) {
					for (let embed of embeds) {
						if (this.checkIsCorrectWikiEmbed(embed.original))
							continue;

						let file = this.getFileByLink(embed.link, note.path);
						if (file) {
							if (!allEmbeds[note.path])
								allEmbeds[note.path] = [];
							allEmbeds[note.path].push(embed);
						}
					}
				}
			}
		}

		return allEmbeds;
	}
Example #5
Source File: links-handler.ts    From obsidian-consistent-attachments-and-links with MIT License 6 votes vote down vote up
getAllWikiEmbeds(): { [notePath: string]: EmbedCache[]; } {
		let allEmbeds: { [notePath: string]: EmbedCache[]; } = {};
		let notes = this.app.vault.getMarkdownFiles();

		if (notes) {
			for (let note of notes) {
				if (this.isPathIgnored(note.path))
					continue;

				//!!! this can return undefined if note was just updated
				let embeds = this.app.metadataCache.getCache(note.path)?.embeds;

				if (embeds) {
					for (let embed of embeds) {
						if (!this.checkIsCorrectWikiEmbed(embed.original))
							continue;

						if (!allEmbeds[note.path])
							allEmbeds[note.path] = [];
						allEmbeds[note.path].push(embed);
					}
				}
			}
		}

		return allEmbeds;
	}