Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Replacing TinyMCE - World of hurt?

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 24861 Views
  • Dig
    Avatar
    Community Member
    29 Posts

    Replacing TinyMCE - World of hurt? Link to this post

    I would like to replace TinyMCE with a commercial WYSIWYG editor that I have licensed. This is for a number of reasons including tidier interface, better CSS options, cleaner code output etc.,

    I was just wanting to know how deeply embedded TinyMCE is. It is a case of replacing Tiny's scripts with my own and changing the cms code in a couple of places to use the new editor, or has Tiny been heavily customised to work with SilverStripe.

    Obviosuly I can find this out by getting my hands dirty but just an indication before I start of how big the job might be will help prioritise the changes I'm wanting to make

    Cheers,
    Nick

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Replacing TinyMCE - World of hurt? Link to this post

    There's been a lot of work in creating custom link and image inserters based around TinyMCE. If you want to use another editor, then you will lose these.

    But apart from that, it should be doable. However, to get to a satisfactory result, you'll have to muck with a bunch of code in the core packages, which will make it hard to upgrade.

    The place where all this is controlled is HTMLEditorField. You should be able to edit that class to load your own editor javascript into the system.

    If you stop including the TinyMCE javascript files, you will run into some javascript bugs in the CMS - particularly when you ajax-load a page. Your best bet is probably to use firebug to see where the code is tripping up, and commenting the TinyMCE-specific stuff out.

    You should update LeftAndMain.php, to use Requirements::javascript() to include your editor's script files.

    You'll also need to remove the WYSIWYG toolbar from the top panel, by editing the .ss templates for the CMS.

    If you would like to make it easier to upgrade in the future, you might want to consider extending the system so that it has a configuration option to choose alternative editor implementations. Provided the code followed our coding standards, it would be a good candidate for merge into the mainline system - meaning you could continue to upgrade your site.

  • Dig
    Avatar
    Community Member
    29 Posts

    Re: Replacing TinyMCE - World of hurt? Link to this post

    Excellent I'll get stuck into those and may give you all an update on my progress later on.

    Thanks for the detailed information

    Nick

  • Dig
    Avatar
    Community Member
    29 Posts

    Re: Replacing TinyMCE - World of hurt? Link to this post

    Ok I'm a little stuck basically my editor integrates with the following concept (in short):

    <textarea id="myHTMLArea">Some content</textarea>
    <script>
    createHTMLEditor("myHTMLArea");
    </script>

    This is obviously different to how TinyMCE is implemented in SilverStripe. Works fine when visiting a page on a full refresh but when selecting a new page the innerHTML obviously changes but the script isn't executed.

    I wrote an additional script to scan for class="htmlarea" and change that after an AJAX update and it found it but broke the whole page any time I put it anywhere. Most likely because I was adding it in the wrong place and it seemed to get stuck in a loop somewhere along the lines.

    So, I need to run a script to change the HTMLArea afters it been updated by AJAX where should I put this so its run after the page has been updated?

    Cheers,
    Nick
    (Other than that I'm making good progress a full refresh on each page with f5 give me a spanky new editor ).

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Replacing TinyMCE - World of hurt? Link to this post

    Use our built-in behaviour class to apply the script. Put this into a separately-included JS file:

    Behaviour.register({
    'textarea.yourClass' : {
    initialize: function() {
    createHTMLEditor(this.id); // this == the textarea DOM element
    }
    }
    });

    It will be applied on load, and reapplied on ajax load

  • Dig
    Avatar
    Community Member
    29 Posts

    Re: Replacing TinyMCE - World of hurt? Link to this post

    Thank you so much

    24861 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.