Last active
February 12, 2021 20:58
-
-
Save bjoerntx/e8831521581f8e40663da81f6cc53a65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var TXHelper = (function (tx) { | |
tx.textFormFields = { | |
convertFromSelection: function (name, id) { | |
// get current selection | |
var sel = TXTextControl.selection; | |
sel.getLength(function(selLength) { | |
if (selLength > 0) { // text is selected | |
sel.getText(function(selText) { | |
// store text | |
var text = selText; | |
sel.setText(""); // remove selected text | |
TXTextControl.formFields.getCanAdd(canAdd => { | |
if (canAdd) { // can add the field here? | |
// add form field | |
TXTextControl.formFields.addTextFormField(600, ff => { | |
ff.setText(text); | |
// set field properties | |
if (name) ff.setName(name); | |
if (id) ff.setID(id); | |
}); | |
} else { // there is a field at that location | |
console.log("A field cannot be added at this location."); | |
} | |
}); | |
}); | |
} | |
else { // no text is selected | |
console.log("Nothing is selected."); | |
} | |
}); | |
}, | |
}; | |
return tx; | |
} ( TXHelper || {} )); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment