Class CKEDITOR.htmlWriter
Defined in: plugins/htmlwriter/plugin.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Class used to write HTML data.
|
Field Attributes | Field Name and Description |
---|---|
The characters to be used for each identation step.
|
|
The characters to be used for line breaks.
|
|
The characters to be used to close "self-closing" elements, like "br" or
"img".
|
Method Attributes | Method Name and Description |
---|---|
attribute(attName, attValue)
Writes an attribute.
|
|
closeTag(tagName)
Writes a closer tag.
|
|
comment(comment)
Writes a comment.
|
|
getHtml(reset)
Empties the current output buffer.
|
|
Writes the current indentation chars.
|
|
Writes a line break.
|
|
openTag(tagName, attributes)
Writes the tag opening part for a opener tag.
|
|
openTagClose(tagName, isSelfClose)
Writes the tag closing part for a opener tag.
|
|
reset()
Empties the current output buffer.
|
|
setRules(tagName, rules)
Sets formatting rules for a give element.
|
|
text(text)
Writes text.
|
Class Detail
CKEDITOR.htmlWriter()
Since:
3.0
Class used to write HTML data.
var writer = new CKEDITOR.htmlWriter(); writer.openTag( 'p' ); writer.attribute( 'class', 'MyClass' ); writer.openTagClose( 'p' ); writer.text( 'Hello' ); writer.closeTag( 'p' ); alert( writer.getHtml() ); "<p class="MyClass">Hello</p>"
Field Detail
{String}
indentationChars
Since:
3.0
The characters to be used for each identation step.
// Use two spaces for indentation. editorInstance.dataProcessor.writer.indentationChars = ' ';
- Default Value:
- "\t" (tab)
{String}
lineBreakChars
Since:
3.0
The characters to be used for line breaks.
// Use CRLF for line breaks. editorInstance.dataProcessor.writer.lineBreakChars = '\r\n';
- Default Value:
- "\n" (LF)
{String}
selfClosingEnd
Since:
3.0
The characters to be used to close "self-closing" elements, like "br" or
"img".
// Use HTML4 notation for self-closing elements. editorInstance.dataProcessor.writer.selfClosingEnd = '>';
- Default Value:
- " />"
Method Detail
{Undefined}
attribute(attName, attValue)
Since:
3.0
Writes an attribute. This function should be called after opening the
tag with #openTagClose.
// Writes ' class="MyClass"'. writer.attribute( 'class', 'MyClass' );
- Parameters:
- {String} attName
- The attribute name.
- {String} attValue
- The attribute value.
{Undefined}
closeTag(tagName)
Since:
3.0
Writes a closer tag.
// Writes "</p>". writer.closeTag( 'p' );
- Parameters:
- {String} tagName
- The element name for this tag.
{Undefined}
comment(comment)
Since:
3.0
Writes a comment.
// Writes "<!-- My comment -->". writer.comment( ' My comment ' );
- Parameters:
- {String} comment
- The comment text.
{String}
getHtml(reset)
Since:
3.0
Empties the current output buffer.
var html = writer.getHtml();
- Parameters:
- {Boolean} reset
- Indicates that the reset function is to be automatically called after retrieving the HTML.
- Returns:
- {String} The HTML written to the writer so far.
{Undefined}
indentation()
Since:
3.0
Writes the current indentation chars. It uses the
#indentationChars property, repeating it for the current
intentation steps.
// Writes "\t" (e.g.). writer.indentation();
{Undefined}
lineBreak()
Since:
3.0
Writes a line break. It uses the #lineBreakChars property for it.
// Writes "\n" (e.g.). writer.lineBreak();
{Undefined}
openTag(tagName, attributes)
Since:
3.0
Writes the tag opening part for a opener tag.
// Writes "<p". writer.openTag( 'p', { class : 'MyClass', id : 'MyId' } );
- Parameters:
- {String} tagName
- The element name for this tag.
- {Object} attributes
- The attributes defined for this tag. The attributes could be used to inspect the tag.
{Undefined}
openTagClose(tagName, isSelfClose)
Since:
3.0
Writes the tag closing part for a opener tag.
// Writes ">". writer.openTagClose( 'p', false );
// Writes " />". writer.openTagClose( 'br', true );
- Parameters:
- {String} tagName
- The element name for this tag.
- {Boolean} isSelfClose
- Indicates that this is a self-closing tag, like "br" or "img".
{Undefined}
reset()
Since:
3.0
Empties the current output buffer.
writer.reset();
{Undefined}
setRules(tagName, rules)
Since:
3.0
Sets formatting rules for a give element. The possible rules are:
- indent: indent the element contents.
- breakBeforeOpen: break line before the opener tag for this element.
- breakAfterOpen: break line after the opener tag for this element.
- breakBeforeClose: break line before the closer tag for this element.
- breakAfterClose: break line after the closer tag for this element.
// Break line before and after "img" tags. writer.setRules( 'img', { breakBeforeOpen : true breakAfterOpen : true });
// Reset the rules for the "h1" tag. writer.setRules( 'h1', {} );
- Parameters:
- {String} tagName
- The element name to which set the rules.
- {Object} rules
- An object containing the element rules.
{Undefined}
text(text)
Since:
3.0
Writes text.
// Writes "Hello Word". writer.text( 'Hello Word' );
- Parameters:
- {String} text
- The text value