How to transfer output from callback command to inputField ‘textboxarea_url’. like let’s say i want set test value from callcommand to ‘textboxarea_url’ text area present in pane. please advise.
function (function (window, undefined) {
window.privateReplaceNext = function(ee) {
var inputField = document.getElementById("textboxarea_url");
inputField.value = ee;
return;
};
window.Asc.plugin.init = function()
{
Asc.scope.st=Errormsg;
if (isInitialized) {
return; }
window.Asc.plugin.callCommand(function () {
var test=“New”;
}
}, false);
privateReplaceNext(test);
};
})(window, undefined);
Hello @sanjeevareddy.nagire
Please take a look at this example plugin:
When pressing Get All Content Controls button on left panel it prints out the content of callback function with info about all Content Control in the document. You can take it as a reference for your plugin.
Thank you That helps. Also in the same plugin I am trying to parse through an existing document using window.Asc.plugin.executeMethod (“GetFileHTML”, null, function (res) {
console.log (res) where document is not having any content controls as of now. i want to parse through each element of the document and add a content control to some part of each paragraph text. Able to get paragraph text using below. but then how to add content control for paragraph or for a selected text (LIke let’s say i have part of text in another varible:").please advise.
for(let i=0;i<oDocument.GetElementsCount();i++)
{
var ephara=oDocument.GetElement(i);
var paratext=ephara.GetText();
}
Plugin example that I’ve provided also demonstrates how to place selected text into a Content Control too. For that you need to select paragraph and press Change Field State button.
Hello Constataine, thank you for the response. Here is my complete scenario. current document that is opened through editor doesn’t have any content controls but has text let’s say “Hello World”. I wants to make text “Hello World” to have content control or replace “Hello World” with text “Hello World” but wants to have content control associated to “Hello World” . But there is no output to below . It’s not really working as expected. Am i missing anything?
var myText = “Hello World”; // The text you want to replace
var oControlPrContent = {
“Props”: {
“Id”: 100,
“Tag”: “CC_Tag”,
“Lock”: 3
},
“Script”: “var oDocument = Api.GetDocument(); var oSearchResults = oDocument.SearchAndReplace('” + myText + “‘, ‘’, true, true, false); var oParagraph = Api.CreateParagraph(); oParagraph.AddText(’” + myText + “'); var arrDocuments1 = [{ ‘Props’: { ‘Id’: 100, ‘Tag’: ‘CC_Tag’, ‘Lock’: 3 }, ‘Script’: 'var oParagraph = Api.CreateParagraph(); oParagraph.AddText("” + myText + “"); Api.GetDocument().InsertContent([oParagraph]);’ }]; window.Asc.plugin.executeMethod(‘InsertAndReplaceContentControls’, [arrDocuments1]);”
};
window.Asc.plugin.executeMethod(“ExecuteScript”, [oControlPrContent.Script]);
You can simply use AddContentControl method to convert selected text into Content Control the same way as provided test plugin does when pressing Change Field State button:
window.Asc.plugin.executeMethod("AddContentControl", [1/*1 - block, 2 - inline*/, {"Id" : 7/*own id*/, "Lock" : 0, "Tag" : "{some text}"}]);
If you want to convert only specific part of the paragraph content into Content Control use inline
Content Control type parameter as per description.