Note
In the code examples below, wym is a variable which refers to the WYMeditor instance, and which must be initialized.
box
Return the WYMeditor container.
html(sHtml)
Get or set the editor’s HTML value.
Example:
wym.html("<p>Hello, World.</p>");
xhtml
Get the cleaned up editor’s HTML value.
exec(cmd)
Execute a command.
Supported command identifiers
paste(data)
Parameters
Description
Paste raw text, inserting new paragraphs.
insert(data)
Parameters
Description
Insert XHTML string at the cursor position. If there’s a selection, it is replaced by data.
Example:
wym.insert('<strong>Hello, World.</strong>');
wrap(left, right)
Parameters
Description
Wrap the inline selection with XHTML.
Example:
wym.wrap('<span class="city">', '</span>');
unwrap()
Unwrap the selection, by removing inline elements but keeping the selected text.
container(sType)
Get or set the selected container.
Example: switch the container to Heading 1.
wym.container('H1');
Example: get the selected container.
wym.status(wym.container().tagName);
toggleClass(sClass, jqexpr)
Set or remove the class sClass on the selected container/parent matching the jQuery expression jqexpr.
Example: set the class my-class on the selected paragraph with the class my-other-class.
wym.toggleClass('.my-class', 'P.my-other-class')
status(sMessage)
Update the HTML value of WYMeditor’ status bar.
Example:
wym.status("This is the status bar.");
update
Update the value of the element replaced by WYMeditor and the value of the HTML source textarea.
dialog(sType)
Open a dialog of type sType.
Supported values: Link, Image, Table, Paste_From_Word.
Example:
wym.dialog('Link');
toggleHtml
Show/hide the HTML source.
replaceStrings(sVal)
Localize the strings included in sVal.
encloseString(sVal)
Enclose a string in string delimiters.
jQuery.wymeditors(i)
Returns the WYMeditor instance with index i (zero-based).
Example:
jQuery.wymeditors(0).toggleHtml();