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

{add,update}Language aren't static #65

Open
anna-is-cute opened this issue May 7, 2018 · 3 comments
Open

{add,update}Language aren't static #65

anna-is-cute opened this issue May 7, 2018 · 3 comments

Comments

@anna-is-cute
Copy link

In the process of updating to 1.0, I realized that I would need to tell CodeFlask how to use all the languages that Prism has, doing something similar to the following:

// load prism.js after codeflask so it doesn't get overwritten
for (var lang of Object.entries(Prism.languages)) {
  flask.addLanguage(lang[0], lang[1]);
}

To do this, I need to have already created an editor, but as someone who frequently will have multiple editors on the page (dynamically added, as well), it doesn't really make sense for this to be a function on an editor instance. My first instinct was to call it as CodeFlask.addLanguage().

Is there a reason that this is an instance function?

@kazzkiq
Copy link
Owner

kazzkiq commented May 7, 2018

Is there a reason that this is an instance function?

Not there isn't.

In fact, at least at first sight, everything Prism-related should be static, making easier to configure it once and affect all CodeFlask instances.

I will elaborate it in #66.

@trasherdk
Copy link

I'm still trying to figure out how to add ex. pug to one instance, and JSON to another, on a single page.

@trasherdk
Copy link

Okay. I got it.

<script src="https://unpkg.com/codeflask/build/codeflask.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/components/prism-pug.js"></script>

Adding the language component after codeflask did the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants