Comments (13)
I think getOption("mode") will do what you want.
from codemirror5.
Unfortunately not.
>> editor.getOption("mode")
"rb"
That's the mode I set, but not the mode in use as shown by the warning I see:
No mode rb found, falling back to plain text.
from codemirror5.
Right, when trying to use a mode that wasn't loaded, it'll fall back to the null mode. Why do you need to detect this? Wouldn't it suffice to just ensure you only use modes that are loaded?
I am planning to add something that'll list loaded modes. That might help here.
from codemirror5.
Why not load all the modes and let CodeMirror figure out which mode to use?
That's how it works right now if you load all modes and pass an extension, with a few special cases.
The only problem is there's no way to figure out which mode CodeMirror picked.
from codemirror5.
Mode names are not extensions. If you want something 'clever' like this, use MIME types. Again, why do you need to find out which mode was picked?
from codemirror5.
You're already calling console.warn
in the exact case I'm asking about. Why not set a flag or variable?
from codemirror5.
Yeah, I can, but I'm trying to figure out your use case. I try to be a bit conservative in adding API functions, to keep things tidy.
from codemirror5.
I guess I'm a bit confused.
When you ask CodeMirror to use a mode, and it cannot find that mode, it falls back to the plain text mode.
However there is absolutely no way in JavaScript to know if CodeMirror found the mode you asked for.
from codemirror5.
Because you're not expected to ask for any old random mode. You have control over the modes you load, so you should know whether the mode you're trying to use is present.
from codemirror5.
So not only does CodeMirror let me give it a String mode name with no way to verify I was correct, it also stores a dictionary of modes internally as well as the current mode internally but refuses to surface this data to plugin developers.
from codemirror5.
Firstly, I talked about adding a way to list the loaded modes, and in fact have already added that (see the the current HEAD commit).
Secondly, if your tone is going to be like this, forget about itβgo bother the maintainer of some other project.
from codemirror5.
All I want is for the mode
variable you use internally to be available to plugins so I can use your sweet library on my project. And you're telling me I'm doing it wrong (even though your library does it this way) and to fuck off?
Okay, I will (and I've closed this issue), but I still vote that CodeMirror2 should let you know whether the mode you want is available or not :) Especially when writing plugins.
from codemirror5.
@marijnh: I still think it would be useful to be able to get this option. It may be possible to figure it out, but it could be a lot more convenient.
@defunkt: Listing a use case is a must for feature additions like this. He wouldn't have told you to fuck off if you would have just provided reasons why this feature should exist instead of being so stubborn. You may have thought it was implicit, but reasons why it is superior to the provided methods (given they are valid) would surely be enough to convince the maintainer to comply.
from codemirror5.
Related Issues (20)
- Add syntax highlighting / mode for Splunk (SPL) HOT 1
- Reference actions by commit SHA HOT 1
- Enforce tests to pass before merging HOT 1
- Codemirror will show error when using elements get from getElementsByClassName HOT 1
- [I Have Solution] On iPadOS with a physical keyboard, certain input methods in the editor using codemirror may shift upward HOT 8
- Strange chars inserted on chromium based engines HOT 2
- long text cause match-highlighter.js error
- closed root shadow dom support proposal HOT 2
- Java libreria
- Add dependabot to keep GitHub Actions up-to-date HOT 1
- Add Support for HCL / Terraform HOT 2
- Multiline comment color bug
- C/C++ code comment highlighting bug
- Possible memory leak in autorefresh.js
- Duotone Theme Color contrast is not up to WCAG standards for comments HOT 1
- Broken/unusable editor after foldAll command on specific file
- Syntax highlighting for GDScript HOT 1
- Crystal HEREDOCs Cause Freezing HOT 1
- Can you provide the function of indenting lines in the code, just like vscode? Thank you. HOT 1
- Codemirror data overload and lagging problem HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codemirror5.