3

Requirement: Webmaster should not have to bother about unnecessary tag when he will paste some text with design in that RTF Design tab if he wants to remove all style then just click on plugin and plugin will remove all tag and style from Design Tab only Plain text remain in that tab.

Resolution:

Created one Alchemy Plugin which will open pop up >>one text box is there >>user will insert their design text >> Click on insert Button >>Pop up will Close >> Plain text will be shown in RTF Design Tab.

Problem:

I need to fetch the RTF field Value in my PopUp Textbox but currently unable to do. Does somebody know the angulia code for fetch from CMS current RTF Field?

The following code is what I did from popup text box. Need to fetch the current RTF Field value.

enter image description here

1 Answer 1

3

If you are trying to get the RTF content of a Component from the context menu, you can do something like this:

execute: function (selection) {
    if (selection.getCount() == 1) {
        var itemType = $models.getItemType(selection.getItem(0))

        // If the item type is a Component
        if (itemType == "tcm:16") {    
            // Get the selected Component
            var item = $models.getItem(selection.getItem(0))

            // Get the content as string and parse it to get the value of the RTF
            var content = item.getContent()

            console.log(content)
        }
}

You can parse the retrieved content to get the required RTF.

enter image description here

If you are trying to retrieve the RTF from a Component view, you can do something like this:

// Get the current view
var view = $display.getView();

// If the current view is that of a Component
if (view && Tridion.OO.implementsInterface(view, "Tridion.Cme.Views.Component")) {   
    // Get the address RTF
    var address = $display.getView().properties.controls.fieldBuilder.getField("address").getValues()[0]
    console.log(address)
}

enter image description here

3
  • I am geting below error .Uncaught TypeError: n.getCount is not a function. I have used in Tridion.Controls.RibbonToolbar. at f.execute [as execute] (Component_v8.5.0.22656.180.aspx?mode=js:1621)
    – JAGAN
    Sep 27, 2018 at 11:20
  • What is n? Can you log the object n? Sep 27, 2018 at 13:23
  • Hi Sabarish, I not added log over there previous n is using as target variable instead on n i am using target variable in function(target){ } from the ribbon toolbar iam unable to achieve your code. your code might be work with context but unable to find the getcount() method ribbon toolbar button event. Please suggest any thing that i am doing wrong in this .
    – JAGAN
    Sep 28, 2018 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.