1

I tried to copy and past from Word document to text field using Ruby on Rails.

But all formatting( spaces, bold and other) are disappeared on text filed.

I've just got the simple lines of text without any formatting.

I've read that need to use Simple format tool... but I want that a user be able just to copy and past a text to text field without doing any adjustments. I mean, I want make all adjustment in advance and the user could just copy and past the text and got all formatting, the same as in Word doc.

The link to file with text field as below. https://gist.github.com/tatyana12/2f9d39c2f6e4f8fabea5e70e11eaf310

Also I have Application.html.erb file:

https://gist.github.com/tatyana12/15c27d542091b04f3c3adfdfd252b7f4

How to initialize editor if I don't have id = "edit" right now?

How to put some code extra style to this file?

2
  • take a look github.com/froala/wysiwyg-rails, or something similar. Commented Sep 1, 2016 at 19:35
  • I took a look on link that you provide but could not find what changes need to be done with my existing file to make formatting. It looks we have different root structure and you don't have file in share folder as I do. Commented Sep 1, 2016 at 21:55

2 Answers 2

1

Have a go at wrapping your field in your show.html.erb or wherever you want to display it with simple_format, for example:

<%= simple_format(@object.description) %>

See http://apidock.com/rails/ActionView/Helpers/TextHelper/simple_format for more info.

Sign up to request clarification or add additional context in comments.

3 Comments

How could i change the existing file to get formatting(see link to file in my post)?
I add. sample format(see comment in the link on my post) but it still doesn't do any formatting.... Should i add something in Gemfile or do something else?
It looks like you've applied that to you form. Instead, leave the form as it is and add the simple_format thing to your views. I use this on my textareas to maintain line breaks. Looking at your question again, you might be better off looking at a wysiwyfg solution as @fanta is suggesting above.
0

I've solved this problem by implementing SKEditor. There is a lot of tutorial how to implement this editor. I (as a lot of other users) have problem that my text wasn't formatted because this editor is not compatible with turbo links. So, I disable turbo links in some files, and as result I have the text formatted.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.