TextEditor.getFontBox

Syntax

getFontBox();

Description

The getFontBox method returns the control used to set up text parameters.

Comments

The method returns an object of the FontBox type.

Example

To execute the example, the page must contain TextEditor component named textEditor (see description of TextEditor constructor). Change transparency of font panel and update controls. Set new value of text area width, set new text with bold font, and show HTML view of this text. Set a hyperlink and output it to the browser console:

// Change font panel transparency
textEditor.getFontBox().setOpacity(0.5);
// Set text area width
textEditor.getTextArea().setWidth(300);
// Set new text
textEditor.setText("Hyperlink");
// Set bold font
textEditor.setIsBold(true);
// Update controls
textEditor.updateControls();
// Show text as HTML view
console.log("HTML view of the text: " + textEditor.getFormattedText());
// Set hyperlink
textEditor.insertHyperlink("http://localhost", PP.Ui.TextEditor.HyperlinkTarget.New);
// Show hyperlink URL
console.log("URL: " + textEditor.getHyperlinkUrl());

After executing the example, font panel transparency is changed, text area width is changed, and new text with bold font is set. A hyperlink is set for the text. After the text is deselected, the text editor looks like following:

The browser console also displays HTML view of the text and hyperlink URL:

Text HTML view: <span style="font-weight: bold;">Hyperlink</span>

URL: http://localhost/

Select text, remove hyperlink and disable text editing:

// Select all text
textEditor.selectAll();
// Remove hyperlink
textEditor.removeHyperlink();
// Disable text editing
textEditor.setReadOnly(true);

As a result, the hyperlink is removed, text in editor becomes read-only:

See also:

TextEditor