Javascript: TXTextControl.load Method
Description
Loads text in a certain format. The complete contents of the web editor are replaced.
Syntax
<void> TXTextControl.load(<StreamType> streamType, <string> base64Data, <LoadDocumentCallback> callback, [<LoadSettings> loadSettings], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| streamType | Specifies one of the numerical StreamType values. |
| base64Data | Base64 encoded document data. For encoding strings containing characters outside of the Latin1 range use TXTextControl.btoaUTF8. |
| callback | Receives information about the loaded data when the loading is finished. |
| loadSettings | Optional. Additional settings for loading the data. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example shows how to load a short unicode HTML snippet into the web editor.
var html = "<h3>This is some <em>HTML</em> text. Стоял он, дум великих полн, И вдаль глядел.</h3>";
var encoded = TXTextControl.btoaUTF8(html);
TXTextControl.load(TXTextControl.StreamType.HTMLFormat, encoded);The following example demonstrates TXTextControl.load in a practical document-editing workflow. It loads text in a certain format. The complete contents of the web editor are replaced.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.load(
TXTextControl.StreamType.HTMLFormat,
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAFgAH/qbPzWQAAAABJRU5ErkJggg==",
function(result) {
if (!result) {
console.warn("No load document callback data was returned.");
return;
}
console.log("load result:", result);
},
{ loadImages: true, loadHypertextLinks: true },
onTxError
);