Show Redcloth source in ckeditor : rails3 - ruby-on-rails

I just installed ckeditor into my rails app. Now i am trying to do is, configure redcloth and ckeditor in a way that, instead of the html source i would like the ckeditor to show the redcloth source ?
Any hints on how would i achieve that ?

If you are using CKEditor just for its toolbar, I mean just just the possibility to be able to use buttons to apply formatting, I think you should not use CKEditor, which is (from what I know) absolutely not made to work with markdown. What you are looking is a markdown editor.
I recently looked for a good markdown editor, and guess what, the best solution I have found is Stackoverflow markdown editor. It is called pagedown
Note that this editor is a lot lighter than something like ckeditor since the actual element in which you are editing your content is just a textarea. You just hook pagedown to it by using javascript. In Ckeditor, you are actually writing your content into an iframe with a contentEditable="true" parameter, and CKEditor is recopying what you are writing into a hidden textarea.

Related

How to make text edit function by Rails

Same as title the following, thx~
It is called RTE, or Rich Text Editor. There're many RTEs, and one of them for rails is wysiwyg-rails, it provides the Froala WYSIWYG HTML Editor javascript and stylesheets as a Rails engine for use with the asset pipeline.
You can follow this tutorial to install it: https://github.com/froala/wysiwyg-rails

Does liquid work with wysiwyg editors? - rails

I have just found liquid and watched the Railscasts on it. The video was pretty old but from watching it, it i can see liquid is what im looking for. Problem is I'm not sure if it will work with popular wysiwyg editor gems. I don't really want my users to be using plain input fields to make the templates.
I don't know if the wysiwyg editor has to be special to work with liquid or if liquid can basically work with any wysiwyg editor gem.
Are there recommended wysiwyg editor gems that work well with liquid or if that isn't a thing are there just normal editor gems that work with liquid?
Yes. Please read this blog. You can also use newsly gem to manage your liquid template with wysiwyg editor. I used ckeditor in one of my application. It's quite easy to install.
Basically you will need to parse the content and add your own data. The editor will not automatically figure out the variables and their values. The editor will save the content with tags and later you can parse it with Liquid
Here is an example form Liquid
#template = Liquid::Template.parse("hi {{name}}") # Parses and compiles the template
#template.render('name' => 'tobi') # => "hi topi"
https://github.com/Shopify/liquid#how-to-use-liquid
And here is a blog post on how someone is using a wysiwyg with Liquid
https://customer.io/blog/Email-wysiwyg-editor-inspired-by-jekyll.html
Hope that helps

Rails needs page refresh to render correctly bootstrap markdown

I am developing an app using Ruby on Rails. In a specific view I have a textarea that uses Bootstrap Markdown.
The problem is that each time I visit that view, the textarea is rendered completely plain, without the Markdown functionality. Hitting F5 (refresh) renders the form correctly.
I tried to clear my browsers cache etc, but no luck. I always have to hit refresh to see the page correctly.
What may cause that?
Edit:
I am using this Markdown Plugin
I have also included the js files as stated in this question.
The turbolinks gem has been known to interfere with other javascript files and it's recommended that you remove it completely unless you really need it.
As Mohammad AbuShady said in his comment, you'll need to edit the part of the javascript files for your markdown that tells the page to start rendering. In your case this involves adding
$("#some-textarea").markdown({autofocus:false,savable:false})
inside page:load on the relevant pages.
In case you need turbolinks still, I found this very helpful: JQuery gets loaded only on page refresh in Rails 4 application
I had the same issue and adding jquery-turbolinks gem allowed the bootstrap-markdown editor to load perfectly for me.

Markdown live preview like stackoverflow for redcarpet on rails

I'm using Redcarpet as markdown tool and coderay for syntax highlighting in my rails app. What I want is a preview of what is being written in markdown format before posting it in database. A far better option is a live preview of what's being written like stackoveflow. I know there are many other options but is there any way to stick with redcarpet and coderay and still having a preview of my post with syntax highlighting? Most of the preview options skip the syntax highlighting portion, they even can't detect codes! At least detecting that portion as a code will do. I just need a preview of my post before publishing it. How can I achieve that? I am not interested in using any WYSIWYG editor either!
Your options are either to stick with Redcarpet and use Ajax or to switch to a javascript based markdown processor like: https://github.com/evilstreak/markdown-js and a javascript based syntax highlighter such as: https://github.com/google/code-prettify
With your current setup you'd have to send the markdown to the server via Ajax, process it with Redcarpet then send it back to the browser and inject it into a preview area. This will be much slower and more taxing on your server when traffic goes up. I wouldn't recommend it.
Switch to the js based markdown processor and syntax highlighter so you can do it all in the browser.

Is TinyMCE editor compatible with rails 2?

Is TinyMCE editor compatible with rails 2? what are better editors apart from fck editor that can be used in rails, is it compatible with rails 2 as well?
EDIT:
Is TinyMCE editor customizable? html tags can be used in the editor space?
Yes, TinyMCE is compatible with all versions of Rails, because it really has nothing to do with it, all frontend (client-side) editors are just "decorators" for textareas, meaning Rails doesn't care what's in them.
I normally avoid using editors like TinyMCE or FCK, because they force me to "reverse" my development workflow - they come with everything and I need to strip 90% of functionality down. So a better approach would be to use something like markdown and educate users on it's use.
And yes, pretty much all editors are heavily customizable - I recommend you read their respective manuals

Resources