feat: optimize some display options and update README

This commit is contained in:
MizarZh 2024-05-10 21:09:04 +02:00
parent 9e3a95a5f6
commit e448972c93
6 changed files with 50 additions and 44 deletions

View file

@ -1,9 +1,17 @@
# obsidian-mathlive-codemirror
Feature:
- [x] General input
[Mathlive](https://github.com/arnog/mathlive) input inside the obsidian codemirror editor.
## Feature
- [x] Basic input function
- [x] Toggle mathlive display
- [ ] Switch between mathlive and builtin mathjax
- [ ] Different position for mathlive
- [ ] Different display modes
Bug to be fixed:
- [x] When empty, a command input \ will prevent the input of mathlive element. (half fixed)
## Usage
![example.gif](./assets/example.gif)
Edit the equation in mathlive block below the latex display block.
It is also possible to assign a hotkey to toggle the display of mathlive block.

BIN
assets/example.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 KiB

View file

@ -1,7 +1,7 @@
{
"id": "obsidian-mathlive-codemirror",
"name": "Obsidian Mathlive Codemirror Plugin",
"version": "0.1.1",
"id": "obsidian-mathlive-codemirrorf",
"name": "Obsidian Mathlive Codemirror Pluginf",
"version": "0.1.2",
"minAppVersion": "0.15.0",
"description": "Mathlive widget in codemirror editor",
"author": "Obsidian",

View file

@ -1,6 +1,6 @@
{
"name": "obsidian-mathlive-codemirror",
"version": "0.1.1",
"version": "0.1.2",
"description": "Obsidian Mathlive Codemirror Plugin",
"main": "main.js",
"scripts": {

View file

@ -21,7 +21,6 @@ export const mathliveListFieldWrapper = (
transaction: Transaction
): DecorationSet {
const builder = new RangeSetBuilder<Decoration>();
// if (settings.display) {
let begin: number, end: number;
syntaxTree(transaction.state).iterate({
enter(node) {
@ -42,8 +41,8 @@ export const mathliveListFieldWrapper = (
) {
end = node.from;
builder.add(
end + 3,
end + 3,
end + 2,
end + 2,
Decoration.widget({
widget: new MathliveWidget(
{ from: begin, to: end },
@ -51,14 +50,13 @@ export const mathliveListFieldWrapper = (
settings.display
),
block: true,
side: 100,
side: 10,
})
);
begin = end = -1;
}
},
});
// }
return builder.finish();
},
provide(field: StateField<DecorationSet>): Extension {

File diff suppressed because one or more lines are too long