Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains live preview and canvas-related fixes.
Misc
utils.ts
isExcluded
is now flipped because the previous version actually checked if the given file is included or not, which was confusing (I know where it came from:isValid
).isEqualToOrChildOf
: now it doesn't iterate over ancestor folders, and instead, it uses a simple string operation.provider.ts
Provider.provide()
should return eitherstring
(meaning the provider wants to provide a display text to the given link) ornull
(i.e. do nothing), butNativeProvider
returnedundefined
when a note doesn't have amathLink
property.Live Preview
I rewrote the editor extension in
0.4.7
(#53), and basically, the main points of the update wereWorkspaceLeaf
: avoid creating a new extension for everyactive-leaf-change
Decoration
as much as possible in everyupdate
And the approach that I took to realize the second point (which was taken from
Dataview
) turned out to be too conservative and sometimes failed to update the decoration even if it should have (sorry...).For example, add three backticks
```
above a link. The decoration for the link should be removed, but it remains.So I decided to basically revert to the implementation of
0.4.6
, as well as keeping good updates introduced in0.4.7
as much as possible. For example, it still creates a single view plugin from a MathLinks plugin instance without dependingWorkspaceLeaf
.And importantly, the new implementation still successfully avoids unnecessary decoration re-rendering; it turned out that avoiding redundant re-rendering of decoration DOMs is as simple as just implementing the
MathWidget.eq
method.obsidian-mathlinks/src/links/preview.ts
Lines 43 to 46 in 207aba9
Also, I noticed that the previous version didn't respect the excluded files setting, so I also fixed this.
Canvas
Although the previous version successfully displayed MathLinks in canvas cards that are embeds of existing notes (i.e. "add note from vault" cards), it failed for non-embed cards (i.e. "add card" cards).
In this case, we need special care because
context.sourcePath
is""
state.field(editorInfoField).file
isnull
This PR fixes this problem. The details are listed below:
main.ts > registerMarkdownProcessor
:file === null
case. (Also note thatisExcluded
's output is flipped)obsidian-mathlinks/src/main.ts
Line 30 in 2597097
obsidian-mathlinks/src/main.ts
Line 30 in 207aba9
preview.ts > tryBuildDecorations
:main.ts
:obsidian-mathlinks/src/links/preview.ts
Line 124 in 207aba9
test_vault/Canvas.canvas
I've already tested it in the test vault, and it's working well. So I'm going to merge this pull request and release it as
0.5.3
.Thanks!