Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created October 5, 2023 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/d5905631c049a2a915004fe728ae3607 to your computer and use it in GitHub Desktop.
Save bjoerntx/d5905631c049a2a915004fe728ae3607 to your computer and use it in GitHub Desktop.
var dotNetObject;
export async function addEditorToElement(dotNetRef, options) {
dotNetObject = dotNetRef;
TXTextControl.init({
containerID: "txDocumentEditorContainer",
webSocketURL: options.websocketurl
});
}
export function saveDocument() {
// save the document on TXTextControl object
TXTextControl.saveDocument(TXTextControl.StreamType.InternalUnicodeFormat, function (document) {
// call the .NET method 'ProcessDocument' with the saved document data
dotNetObject.invokeMethodAsync('ProcessDocument', document.data);
});
};
export function loadDocument(document) {
// load the document back into the editor (TXTextControl)
TXTextControl.loadDocument(TXTextControl.StreamType.InternalUnicodeFormat, document);
};
export function insertTable() {
TXTextControl.tables.add(5, 5, 10, function (e) {
if (e === true) { // if added
TXTextControl.tables.getItem(function (table) {
table.cells.forEach(function (cell) {
cell.setText("Cell text");
});
}, null, 10);
}
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment