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

Switch Back to Plaintext Language Mode #4

Closed
jsilfver opened this issue Nov 26, 2024 · 1 comment
Closed

Switch Back to Plaintext Language Mode #4

jsilfver opened this issue Nov 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jsilfver
Copy link

jsilfver commented Nov 26, 2024

The default value for the API parameter [language] is an empty string (''), which sets the editor to plaintext mode. When the [language] parameter is updated, the editor switches to the corresponding language mode. However, it appears that once a language is selected, it is not possible to revert the editor back to plaintext mode by setting [language] to an empty string ('').

Allowing users to switch back to plaintext mode is useful, especially when they test a language that turns out to be unsuitable for the editor’s content.

Ref forum: https://discuss.codemirror.net/t/switching-between-plaintext-and-a-language-throws-error/3104

Ref code-editor:

setLanguage(lang: string) {
    if (!lang) {
      return;
    }
    if (this.languages.length === 0) {
      if (this.view) {
        console.error('No supported languages. Please set the `languages` prop at first.');
      }
      return;
    }
    const langDesc = this._findLanguage(lang);
    langDesc?.load().then(lang => {
      this._dispatchEffects(this._languageConf.reconfigure([lang]));
    });
  }
@nzbin nzbin added the bug Something isn't working label Nov 27, 2024
@nzbin
Copy link
Member

nzbin commented Dec 2, 2024

0.5.1 has fixed.

@nzbin nzbin closed this as completed Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants