Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options for katex-plugin not possible #622

Closed
smartnio opened this issue Aug 7, 2024 · 2 comments
Closed

Options for katex-plugin not possible #622

smartnio opened this issue Aug 7, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@smartnio
Copy link

smartnio commented Aug 7, 2024

Describe the issue

Hi,
i just wanna know how to set options for the katex-plugin within the md-editor-v3 config. I followed the docs with configurating the markdownItPlugins section in the README. But i can't figure out, how to change options for the katex plugin, because the katex options is a vue reactive katexRef which is not available on configuration start.

I want to set e.g. the strict mode of the plugin to get rid of warnings. They are inside p.options.katexRef.value.SETTINGS_SCHEMA

config({
  markdownItPlugins(plugins) {
    return plugins.map((p) => {
      if (p.type === 'katex') {
          //not available on startup
          //stores a ref
          console.log(p.options.katexRef)
          //undefined
          console.log(p.options.katexRef.value)      
          
          //available, but of course, not settable after configuration is already initiated
        setTimeout(() => {
          //filled with SETTINGS_SCHEMA
          console.log(p.options.katexRef.value)
        }, 2000)
      }
    })
  }
});

If not an issue, can be moved to discussion. But thanks for the help!

Procedure version

4.18..0

Reproduction link

No response

@imzbf
Copy link
Owner

imzbf commented Aug 8, 2024

When using CDN, we cannot obtain an instance of katex here, and it's currently not possible to get it here either. I will try to enhance it later.

Currently, installing via dependencies works:

npm i katex
import { config } from 'md-editor-v3';
import katex from 'katex';

config({
  markdownItPlugins(plugins, { editorId }) {
    return plugins.map((item) => {
      if (item.type === 'katex') {
        // will not be undefined
        console.log('katexRef', item.options.katexRef.value);
      }

      return item;
    });
  },
  editorExtensions: {
    katex: {
        instance: katex
    }
  }
})

@imzbf imzbf added the enhancement New feature or request label Aug 8, 2024
@imzbf
Copy link
Owner

imzbf commented Aug 19, 2024

4.19.0中优化了这个问题,参考https://imzbf.github.io/md-editor-v3/zh-CN/docs#%F0%9F%94%A7%20katexConfig

@imzbf imzbf closed this as completed Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants