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 in tinymce support #1231

Closed
wants to merge 1 commit into from

Conversation

rovermicrover
Copy link
Contributor

Added in TinyMCE support. Tested with the tinymce-rails gem.

The set up is very simliar to how code-mirror works.

The only major difference is the defaults have to be set like bellow.

window.tinyMCEPreInit = {
  base: options['base'],
  theme: options['theme'],
  suffix: '',
  mode: "specific_textareas"
}

Also because the jquery version is loaded, two different scripts must be loaded, with the second as a call back, and then the load events as yet another call back for the second script load.

$.getScript options['jspath'], (script, textStatus, jqXHR) =>
  $.getScript options['jqpath'], (script, textStatus, jqXHR) =>
    gotinyMCE(@arraytmc)

The options are as follows

register_instance_option(:tinymce) do
  false
end

register_instance_option(:tinymce_js_location) do
  "/assets/tinymce/tiny_mce_jquery_src.js"
end

register_instance_option(:tinymce_jquery_location) do
  "/assets/tinymce/jquery.tinymce.js"
end

register_instance_option(:tinymce_theme_options) do
  "advanced"
end

register_instance_option(:tinymce_options) do
  {}
end

register_instance_option(:tinymce_base_location) do
  '/assets/tinymce'
end

The theme option is really just the default theme option, and once again because the jquery version is being used two scripts must be loaded, so there are two options for script location.

From what I have been able to test everything seems to work fine, but about every 10th load or so TinyMCE will just refuse to load. I tried forcing a wait to make sure it wasn't an issue with TinyMCE getting called before all the corresponding files where loaded, even with the nested callbacks. But I wasn't able to find the root cause of the issue.

I hope this helps, and let me know if anything is explained poorly or you have any questions.

PS: I also changed the array variable name for each of the editor setups in the coffee script, just to make things clearer.

@travisbot
Copy link

This pull request fails (merged 5a34643 into e08adbe).

@mshibuya
Copy link
Member

mshibuya commented Jul 4, 2012

I've tested this using Chrome, but TinyMCE doesn't appear in 1 out of 3 forced reloads, every normal reloads and every pjax navigations. Looks like the loading problem still persists.
Can you please fix it?

@rovermicrover
Copy link
Contributor Author

I will have sometime this weekend to look at it again. When you say "1 out of 3 forced reloads, every normal reloads and every pjax navigations" Do you mean it doesn't works 1/3rd of the time on forced reloads, and none at all on the other two. OR Do you mean that it doesn't works 1/3 of the time no matter how you try to load it?

@mshibuya
Copy link
Member

mshibuya commented Jul 6, 2012

Sorry I didn't make it clear.
After a little further investigation,

  • not shows up in 1 out of 3 forced reloads
  • never shows up with normal reloads
  • with pjax navigations(i.e. clicking the 'edit' link in other pages)
    • when first page load was made by forced reload, works fine until non-pjax page transition occurs
    • when first page load was made by normal reload, never shows up

Is this really working for you?

@rovermicrover
Copy link
Contributor Author

It was, but I was testing it on my old computer while it was stilling having the issue that lead to this stupid pull request.
#1229

What ever was going on caused the above, issue, made it so I couldn't get ember.js to run at all when I tried it out this weekend, and clearly didn't help with this pull request either. And generally made me waste a lot of time that would have other wise been productive.

This weekend or next when I get sometime I am just going to scrap everything and try again from scratch on a new computer, sorry about this I should have noticed quicker that it was a bug on my OS.

@rovermicrover
Copy link
Contributor Author

Got stuck under a pile of work, still planning on doing this atm, just not right away.

@mshibuya
Copy link
Member

Closing this for now.
Please open another one if you come up with a solution!

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.

None yet

3 participants