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

Added the ability to do codemirror true on a text field and have a codem... #1164

Merged
merged 1 commit into from
May 27, 2012

Conversation

rovermicrover
Copy link
Contributor

Sorry about the one before forgot to add a topic branch and rebase everything. Tested again with "bundle exec rake spec" and worked fine.


These commits should allow for something like this.

field :css, :text do
    codemirror true
end

requires
https://github.com/fixlr/codemirror-rails

The commits also add the following options for setting up ckeditor.

#Use this if you want to point to a cloud instances of CKeditor
register_instance_option(:ckeditor_location) do
  '/assets/ckeditor/ckeditor.js'
end

#Use this if you want to point to a cloud instances of the base CKeditor
register_instance_option(:ckeditor_base_location) do
  '/assets/ckeditor/'
end

Then for Codemirror the options are

# Codemirror is disabled by default and CKEditor takes presedence
register_instance_option(:codemirror) do
  false
end

#Pass the theme and mode for Codemirror
register_instance_option(:codemirror_config) do
  {
    :mode => 'css',
    :theme => 'night'
  }
end

register_instance_option(:codemirror_assets) do
  {
    :mode => '/assets/codemirror/modes/css.js',  
    :theme => '/assets/codemirror/themes/night.css'
  }
end

#Use this if you want to point to a cloud instances of CodeMirror
register_instance_option(:codemirror_js_location) do
  '/assets/codemirror.js'
end

#Use this if you want to point to a cloud instances of CodeMirror
register_instance_option(:codemirror_css_location) do
  '/assets/codemirror.css'
end

Some Notes:
I had to remove @import "bootstrap/code"; from imports.css.scss.erb because it was conflicting with the basic code mirror styling.

I have tested

codemirror true
ckeditor true

Both still work with one or more instances.

I have though had a tough time testing the configs I added. I guess I must not be setting them correctly or something because I can't get them to be anything but the default.

Inspired by:
The following issue posted by https://github.com/kennyadsl
#871

Implementation via binding on a project I worked a little bit on with
https://github.com/nthj

I hope this helps!

…demirror.js instances how up. Also added custom install location options for CKEDITOR

forgot to add in codemirror commits"
@travisbot
Copy link

This pull request passes (merged 61a7e0e into 8d7d7bc).

mshibuya added a commit that referenced this pull request May 27, 2012
Added the ability to do codemirror true on a text field and have a codem...
@mshibuya mshibuya merged commit b499e16 into railsadminteam:master May 27, 2012
@mshibuya
Copy link
Member

This is neat.
Thanks for the request!

@rikkipitt
Copy link
Contributor

Hey guys, are multiple instances of CodeMirror doable on the same page? Example: a css and js field. It seems like only the second code mirrored field works, are the settings overridden by the second field?

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

Successfully merging this pull request may close these issues.

4 participants