wicket.contrib.tinymce.settings
Class TinyMCESettings

java.lang.Object
  extended by wicket.contrib.tinymce.settings.TinyMCESettings
All Implemented Interfaces:
Serializable

public class TinyMCESettings
extends Object
implements Serializable

Settings class for TinyMCE editor. User can add/remove buttons, enable/disable resizing, change positions, orientation, alignment and much more.

Author:
Iulian-Corneliu Costan ([email protected]), Frank Bille Jensen ([email protected])
See Also:
Plugin, Button, Serialized Form

Nested Class Summary
static class TinyMCESettings.Align
          This class enables you to specify the alignment of the controls.
static class TinyMCESettings.EntityEncoding
          Controls how entities/characters get processed by TinyMCE.
static class TinyMCESettings.Language
          Language enum
static class TinyMCESettings.Location
          This option enables you to specify where the toolbar should be located.
static class TinyMCESettings.Mode
          This class specifies how elements is to be converted into TinyMCE WYSIWYG editor instances.
static class TinyMCESettings.Position
          This class specifies the position of new added control.
static class TinyMCESettings.Theme
          This class enables you to specify what theme to use when rendering the TinyMCE WYSIWYG editor instances.
static class TinyMCESettings.Toolbar
          This class specifices the toolbar to add specific control to.
 
Field Summary
static Set<TinyMCESettings.Language> languages
           
static ResourceReference REFERENCE
           
static ResourceReference REFERENCE_MIN
           
 
Constructor Summary
TinyMCESettings()
           
TinyMCESettings(TinyMCESettings.Theme theme)
           
TinyMCESettings(TinyMCESettings.Theme theme, TinyMCESettings.Language lang)
           
 
Method Summary
 void add(Button button, TinyMCESettings.Toolbar toolbar, TinyMCESettings.Position position)
          Add a default button to tinymce editor.
 void addCustomSetting(String customSetting)
           
 void disableButton(Button button)
          Disable specific button in advanced theme mode.
 String getAdditionalPluginJavaScript()
          Get additional javascript from the plugins.
 boolean getAutoResize()
          Deprecated. 
 String getBlockFormats()
           
 ResourceReference getContentCss()
           
 Boolean getConvertUrls()
           
 String[] getCustomSettings()
           
 String getDocumentBaseUrl()
           
 TinyMCESettings.EntityEncoding getEntityEncoding()
           
 boolean getHorizontalResizing()
           
 TinyMCESettings.Language getLanguage()
           
 String getLoadPluginJavaScript()
           
 Boolean getRelativeUrls()
           
 Boolean getRemoveScriptHost()
           
 boolean getResizing()
           
 boolean getResizingUseCookie()
           
 TinyMCESettings.Location getStatusbarLocation()
           
 TinyMCESettings.Theme getTheme()
           
 TinyMCESettings.Align getToolbarAlign()
           
 List<Button> getToolbarButtons(TinyMCESettings.Toolbar toolbar)
           
 TinyMCESettings.Location getToolbarLocation()
           
 boolean isReadOnly()
           
static ResourceReference javaScriptReference()
           TinyMCE javascript resource.
static void lazyLoadTinyMCEResource(org.apache.wicket.markup.head.IHeaderResponse response)
           Normally, TinyMCE cannot be natively loaded lazily; you must have the 'tiny_mce.js' script rendered directly to your page instead of through an Ajax loaded component.
 void register(Plugin plugin)
          Register a tinymce plugin.
 void setAutoResize(boolean auto_resize)
          Deprecated. 
 void setBlockFormats(String blockFormats)
           
 void setContentCss(ResourceReference contentCss)
           
 void setConvertUrls(boolean convertUrls)
          This option enables you to control if TinyMCE is to be clever and restore urls to their original values.
 void setDocumentBaseUrl(String documentBaseUrl)
           
 void setEntityEncoding(TinyMCESettings.EntityEncoding entityEncoding)
           
 void setHorizontalResizing(boolean horizontalResizing)
           
 void setReadOnly(boolean readOnly)
           
 void setRelativeUrls(Boolean relativeUrls)
          If this option is set to true, all URLs returned from the MCFileManager will be relative from the specified document_base_url.
 void setRemoveScriptHost(Boolean removeScriptHost)
          If this option is enabled the protocol and host part of the URLs returned from the MCFileManager will be removed.
 void setResizing(boolean resizing)
           
 void setResizingUseCookie(boolean resizingUseCookie)
           
 void setStatusbarLocation(TinyMCESettings.Location statusbarLocation)
           
 void setToolbarAlign(TinyMCESettings.Align toolbarAlign)
           
 void setToolbarButtons(TinyMCESettings.Toolbar toolbar, List<Button> buttons)
          This option can only be used when theme is set to advanced and when the theme_advanced_layout_manager option is set to the default value of "SimpleLayout".
 void setToolbarLocation(TinyMCESettings.Location toolbarLocation)
           
 String toJavaScript(TinyMCESettings.Mode mode, Collection<Component> components)
          Generates the initialisation script.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REFERENCE

public static final ResourceReference REFERENCE

REFERENCE_MIN

public static final ResourceReference REFERENCE_MIN

languages

public static final Set<TinyMCESettings.Language> languages
Constructor Detail

TinyMCESettings

public TinyMCESettings()

TinyMCESettings

public TinyMCESettings(TinyMCESettings.Theme theme)

TinyMCESettings

public TinyMCESettings(TinyMCESettings.Theme theme,
                       TinyMCESettings.Language lang)
Method Detail

getTheme

public TinyMCESettings.Theme getTheme()

getLanguage

public TinyMCESettings.Language getLanguage()

getDocumentBaseUrl

public String getDocumentBaseUrl()

setDocumentBaseUrl

public void setDocumentBaseUrl(String documentBaseUrl)

addCustomSetting

public void addCustomSetting(String customSetting)

getCustomSettings

public String[] getCustomSettings()

getContentCss

public ResourceReference getContentCss()

setContentCss

public void setContentCss(ResourceReference contentCss)

getAutoResize

@Deprecated
public boolean getAutoResize()
Deprecated. 


setAutoResize

@Deprecated
public void setAutoResize(boolean auto_resize)
Deprecated. 

Obsolete feature; replaced by AutoResizePlugin in TinyMCE v.3.2.5

Parameters:
auto_resize -

getBlockFormats

public String getBlockFormats()

setBlockFormats

public void setBlockFormats(String blockFormats)

setToolbarLocation

public void setToolbarLocation(TinyMCESettings.Location toolbarLocation)

getToolbarLocation

public TinyMCESettings.Location getToolbarLocation()

setStatusbarLocation

public void setStatusbarLocation(TinyMCESettings.Location statusbarLocation)

getStatusbarLocation

public TinyMCESettings.Location getStatusbarLocation()

setToolbarAlign

public void setToolbarAlign(TinyMCESettings.Align toolbarAlign)

getToolbarAlign

public TinyMCESettings.Align getToolbarAlign()

setEntityEncoding

public void setEntityEncoding(TinyMCESettings.EntityEncoding entityEncoding)

getEntityEncoding

public TinyMCESettings.EntityEncoding getEntityEncoding()

setReadOnly

public void setReadOnly(boolean readOnly)

isReadOnly

public boolean isReadOnly()

setResizing

public void setResizing(boolean resizing)

getResizing

public boolean getResizing()

setHorizontalResizing

public void setHorizontalResizing(boolean horizontalResizing)

getHorizontalResizing

public boolean getHorizontalResizing()

getResizingUseCookie

public boolean getResizingUseCookie()

setResizingUseCookie

public void setResizingUseCookie(boolean resizingUseCookie)

setConvertUrls

public void setConvertUrls(boolean convertUrls)
This option enables you to control if TinyMCE is to be clever and restore urls to their original values. URLs are auto converted/messed up by default since the built in browser logic works this way, there is no way to get the real URL unless you store it away. If you set this option to false it will try to keep these URLs intact. This option is set to true by default that means URLs will be forced absolute or relative depending on the state of relative_urls.

Parameters:
convertUrls -

getConvertUrls

public Boolean getConvertUrls()

setRemoveScriptHost

public void setRemoveScriptHost(Boolean removeScriptHost)
If this option is enabled the protocol and host part of the URLs returned from the MCFileManager will be removed. This option is only used if the relative_urls option is set to false. This option is set to true by default. URL:s will be returned in this format: "/somedir/somefile.htm" instead of the default mode: "http://www.somesite.com/somedir/somefile.htm".

Parameters:
removeScriptHost -

getRemoveScriptHost

public Boolean getRemoveScriptHost()

setRelativeUrls

public void setRelativeUrls(Boolean relativeUrls)
If this option is set to true, all URLs returned from the MCFileManager will be relative from the specified document_base_url. If it's set to false all URLs will be converted to absolute URLs. This option is set to true by default.

Parameters:
relativeUrls -

getRelativeUrls

public Boolean getRelativeUrls()

add

public void add(Button button,
                TinyMCESettings.Toolbar toolbar,
                TinyMCESettings.Position position)
Add a default button to tinymce editor. These plugins are defined by tinymce editor and are ready to use. TODO: I'm not sure this works for anything except the fourth toolbar. TODO: Why doesn't it interact with the 'toolbars' variable?

Parameters:
button - - button to be added
toolbar - - the toolbar where to add this button to
position - - position of this button

disableButton

public void disableButton(Button button)
Disable specific button in advanced theme mode.

Parameters:
button - button to be disabled

setToolbarButtons

public void setToolbarButtons(TinyMCESettings.Toolbar toolbar,
                              List<Button> buttons)
This option can only be used when theme is set to advanced and when the theme_advanced_layout_manager option is set to the default value of "SimpleLayout". TODO: Does this fail for the fourth toolbar? Seems like it will.

Parameters:
toolbar - the toolbar to define buttons for
buttons - A list of buttons to show as that toolbar. An empty list will remove (make invisible) the toolbar in tinymce. Passing null will remove the setting for the toolbar.

getToolbarButtons

public List<Button> getToolbarButtons(TinyMCESettings.Toolbar toolbar)
Parameters:
toolbar - The toolbar to return the defined buttons for
Returns:
The buttons that should be shown for that toolbar (empty list for invisible toolbar, null for no settings for that toolbar)

register

public void register(Plugin plugin)
Register a tinymce plugin. In order to reuse a existing plugin it has to be registered before. Usually plugins are registered automatically when a plugin button is added, but there are some plugins that contains no buttons. This method is used to register those plugins. (eg AutoSave)

Parameters:
plugin -

toJavaScript

public final String toJavaScript(TinyMCESettings.Mode mode,
                                 Collection<Component> components)
Generates the initialisation script. Internal API, do not call.


getLoadPluginJavaScript

public String getLoadPluginJavaScript()

getAdditionalPluginJavaScript

public String getAdditionalPluginJavaScript()
Get additional javascript from the plugins.

Returns:
The different plugins additional javascript.

javaScriptReference

public static ResourceReference javaScriptReference()

TinyMCE javascript resource.

Note: The TinyMCE source cannot be lazily loaded via ajax. Therefore, adding this in a IHeaderContributor.renderHead(IHeaderResponse) must be done in a component that is not rendered via Ajax. If you wish to load this via Ajax, you can use the very hacky workaround lazyLoadTinyMCEResource(IHeaderResponse).

Returns:

lazyLoadTinyMCEResource

public static void lazyLoadTinyMCEResource(org.apache.wicket.markup.head.IHeaderResponse response)

Normally, TinyMCE cannot be natively loaded lazily; you must have the 'tiny_mce.js' script rendered directly to your page instead of through an Ajax loaded component. This method provides a workaround similar to the one described on:

   http://tinymce.moxiecode.com/forum/viewtopic.php?pid=66531#p66531
 

Presumably, before you encountered this method, you had:

 public void renderHead(IHeaderResponse response)
 {
        response.renderJavascriptReference(TinyMCESettings.javaScriptReference());
 }
 

in some component that resided on the page before the panel that loaded the textarea (with TinyMCEBehavior) via ajax. Now, that panel can simply call:

 public void renderHead(IHeaderResponse response)
 {
        TinyMCESettings.lazyLoadTinyMCEResource(response);
 }
 
TODO: This has not been extensively tested.

Parameters:
response -


Copyright © 2004–2014. All rights reserved.