Clarify active-file events, editing modes, platform flags and file operations

Open Beginner friendly
#281 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Domain
documentation

Research direction

Read the existing Workspace, Editor, Mobile development and Vault guides and find where they describe these API behaviors. Add the five clarifications from the issue, keeping the generated TypeScript API pages unchanged. Done means each behavior is documented in the relevant guide and matches the observations reported for Obsidian 1.15.1.

Written by the indexing model from the issue text.

Description

Several API behaviors could use short clarifications in the existing guides:

  1. file-open follows changes to the active file, including focus changes between files already open. It doesn't fire again for the same active file.
  2. MarkdownView.getMode() returns 'source' in both Live Preview and Source mode; getState().source distinguishes them.
  3. Platform.isMobile includes desktop mobile emulation; Platform.isMobileApp doesn't.
  4. Vault.rename() doesn't update links. FileManager.renameFile() handles link updates according to the user's preferences.
  5. Bookmarks can point to missing files or folders, and stay after their target is deleted.

I checked each of these in Obsidian 1.15.1 on desktop (Windows), in a clean vault, by running the API calls and reading the results:

  1. Registered a file-open listener and opened files across split leaves. Opening a file fired once; reopening it in the same leaf, opening it in a second leaf, and switching focus between two leaves showing it fired nothing; switching focus to a leaf with a different file fired with that file; closing every leaf fired with null. active-leaf-change fired on each of the same-file focus switches.
  2. Set the view state to Live Preview, Source mode and Reading view in turn: getMode() was 'source', 'source', 'preview', and getState().source was false in Live Preview and true in Source mode.
  3. Before and after app.emulateMobile(true): isMobile went from false to true, isMobileApp stayed false, and require('fs') and require('electron') still loaded.
  4. With Automatically update internal links on, Vault.rename() left [[one]] pointing at the old name, and FileManager.renameFile() rewrote the link. With it off, renameFile() showed the "Update links" prompt (Always update, Just once, Do not update), and the link followed the choice.
  5. Bookmarked two files, a folder and a path that never existed, then deleted one file and the folder through the vault API and the other file on disk. All four bookmarks were still there.

Would additions to the Workspace, Editor, Mobile development and Vault guides be welcome? I would leave the generated TypeScript API pages unchanged.

Dominant language
JavaScript
Stars
532
Forks
174
Avg merge
3d 3h
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from obsidianmd/obsidian-developer-docs

All issues in obsidianmd/obsidian-developer-docs

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.