-
Notifications
You must be signed in to change notification settings - Fork 53
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
Themes and addons in CodeMirror #73
Comments
I tried adding this JavaScript to my project, but it didn't load... I'm probably doing something wrong.
|
Hmm, So I take it it's currently impossible to use themes and any of the other add-ons (unlike Ace). Do you think they could be added to the |
CodeMirror support was added in #27 and was never really first class (I started with Ace). It would probably be good to reconsider how the files are loaded. |
The difference is that for ace all code is loaded as static asset and for codemirror this is currently not done, only the required files are imported. Maybe we should also switch for codemirror to the same behaviour? |
Yeah, that sounds like a good idea. I just did a quick and dirty integration of CodeMirror so it would be good to do it correctly :) |
Seems reasonable. The alternative would be to add some way of triggering the dynamic loading of desired modules by some user specification. But there aren't a ton of standard modules, so loading them all is probably not horrible (and certainly simpler). |
As static assets they are only loaded if an user requires them, so this is not a big issue. However then the user is able to load them. I will include this change in the pull request tomorrow and publish it if there are no issues. |
Oh, I see. Sounds perfect! Looking forward to switching to CM in my app. |
I'm probably missing something obvious, or there's a problem with some
|
It seems to be related to this: meteor/meteor#5270 Maybe you have another package requiring Could you try to manually update the package by changing |
That helped, thanks! I added |
Hey, thanks for the work guys!
I would like to import mode files on the client, but I keep getting "Cannot find module" errors on variations of
If I load that in a script then the expected "CodeMirror is not defined" error occurs when that file is evaluated. I feel like I must be missing something key about the module system.. |
I do not know if there is really a way to import static assets from a module. Maybe we should ask this on the official meteor forum. This might be related: meteor/meteor#6098 |
Being able to load static assets from a module might work. My direct question is: how do I get language modes to work in meteor-sharejs-codemirror? The README.md seems to make that clear for ace. I'd be happy to add documentation for using codemirror modes if I knew the best way to do it. |
I'm also confused about how we're supposed to load the new static .js files. Most of CodeMirror's documentation suggests directly including JavaScript via script tags; not sure what makes sense in Meteor. A mentioned alternative is to use I'm also curious about how to use the .css theme files... I thought these were all going to be included? |
Static Assets are not included on default. But they are available to be included either direct or be loaded as a module. The problem is that often external libraries as codemirror do not support the same module system as meteor. This might result in some difficulties. I have seen them in the ace editor, where ace provided an alternative require function which overwrote the meteor provided require method. In my opinion there is at the moment no best way. I hope this changes in the future. |
Would you consider just dumping all the CodeMirror code (js and css) into the client when using the CodeMirror package? At least then we could use all the features, until there is a better way... |
What do you mean with dumping all CodeMirror code to the client? Should be all js and css loaded. But how to choose then which css and extensions should be used? At the moment everything is provided for the user to be included. However the user have to load the js and css which he wants to load. |
The css themes and js modules of CodeMirror are not automatically engaged; each adds a feature to the CodeMirror base, which are then selected by setting options on the CodeMirror object (e.g., ol-c and I have so far failed to include the js/css as it is included now, though we'd be happy to learn how... |
In my opinion, this issue should be re-opened. I recently figured out how to get access to Meteor-ShareJS's CodeMirror: Strangely, I cannot require any other CodeMirror modules by a similarly constructed path. But I did finally have luck including CodeMirror modules into Meteor-ShareJS by copying the extension code into my codebase (in a The question remains: what is the "right" way to do this? I think a good solution would be |
The problem is that the npm package of codemirror ships without these dependencies. It only contains the main js file and the css style sheet: https://github.com/codemirror/CodeMirror/blob/master/package.json#L4-L9 I do not have experience with codemirror, such I am not sure of a way to include the required modes. But I am open to pull request closing this issue. |
@DavidSichau That's not quite right. |
@edemaine |
@DavidSichau Sure thing: here is a repository, based on a pared-down version of your demo. This is the line that I want to work, to enable the markdown mode of CodeMirror (for example). Instead what I've had to do is copy the CodeMirror module and its dependencies, while replacing the opening lines with an import of Meteor-ShareJS's CodeMirror module. I've tried a lot of combinations over the months, but this is the only one I found that worked... To see that the mode is loading correctly, type |
I now understand your problem but I have not the knowledge how to solve it. The Problem is that the codemirror files are added as static assets, e.g., they can be accessed via this url:
However with import you cannot import urls: http://stackoverflow.com/questions/34607252/es6-import-module-from-url I do not know of a way how one can add a npm package and meteor handles it in a way that all files are loaded into the package. At the moment I believe that meteor only takes the files specified in package.json into account. |
Is there any way to actually apply a mode and theme to CodeMirror editor? |
I tried setting
editor.setOption 'theme', 'blackboard'
but the colors didn't change. From the CodeMirror docs, it looks like I need to also manually include the relevant CSS (theme/blackboard.css
). Similarly, add-on loading seems to be manually by including the relevant JavaScript. (With Ace, this inclusion was automatic.) Should I be adding<script>
and<link>
tags to my Meteor code to do this?The text was updated successfully, but these errors were encountered: