Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change persistence property of cq:inplaceEditing

I wish to use cq:inplaceEditing to modify a property on my JCR whenever it is used by the AEM authors. Unfortunately, I do not know how to modify the name of the property that it actually modifies in the JCR. It appears that it only modifies the value of the property "text" by default.

For my purposes, I want to use its rich-text-editing for properties that have names I define, not just the default name "text."

The image at this link shows the tree which contains the cq:inplaceEditing (courtesy of CRXDE):

enter image description here

These are the attributes of cq:editConfig:

enter image description here

These are the attributes of cq:inplaceEditing:

enter image description here

...and this is what a content node of my JCR looks like when I use the inplaceEditor. I've blotted out the names of some properties for potential security reasons. Note that the "text" property below was changed when I used the inplaceEditor. Also note that I want to be able to define the property name that the inplaceEditor changes, rather than just the "text" property:

enter image description here

Is there a way to use a different property name instead of "text"?

-----------EDIT----------

After changing the property "textPropertyName" to the property that I am searching for, it still doesn't appear to actually modify the behavior of the inplaceEditor. It still only modifies the "text" property of my JCR nodes instead of the one that I put in the "textPropertyName" attribute.

This picture contains the attributes of my cq:InplaceEditingConfig:

enter image description here

The picture below contains the attributes of the JCR node at the path specified in the "configPath" variable in the picture above. Note that I set the textPropertyName attribute in this node and the text component still modifies the default attribute "text" instead of the one specified:

enter image description here

Finally, the picture below shows the contents of my JCR tree inside of the text component.

enter image description here

-----------ANOTHER EDIT----------

I discovered that the inline text editor was persisting the correct property after I had switched to the classic UI. For some reason, it doesn't work correctly with the touch UI.

like image 820
idungotnosn Avatar asked Dec 04 '22 03:12

idungotnosn


1 Answers

How to find it

The inplace editing capability is defined by subclasses of CQ.ipe.InplaceEditing function. You can find it easily by just searching for editorType through the CRXDE tool.

Searching for the CQ.ipe.InplaceEditing returns multiple results such as CQ.ipe.TextEditor that at the very end of the script registers desired editorType i.e.: CQ.ipe.InplaceEditing.register("text", CQ.ipe.TextEditor);

The answer

Reading through the editor code you can find the first configurable property called textPropertyName which according to it's documentation is just what you are looking for. Combining it with the inplace configuration node (see Adobe's documentation) it is the solution for your case.

An example

You can try it by yourself on an instance of Geometrixx component.

  1. First go to CRXDE and find Geometrixx Text component: /apps/geometrixx-gov/components/text.
  2. Notice /apps/geometrixx-gov/components/text/cq:editConfig/cq:inplaceEditing@configPath property value.
  3. Find /apps/geometrixx-gov/components/text/dialog/items/tab1/items/text resource and add new property: textPropertyName=myPropertyName.
  4. Then just open the Geometrixx Gov page add Geometrixx Text component, edit it inplace and look into the Network console. You'll notice POST request with the altered parameter name

edit after TouchUI clarification

TouchUI case

If you want to achieve the same for TouchUI interface it doesn't go so easy, unfortunately. The text inplace editor for TouchUI is defined by /libs/cq/gui/components/authoring/clientlibs/editor/js/editors/InlineTextEditor.js.

Searching for "text" gives you an overview how hardcoded is this property. For AEM 6.1 (on which I'm testing it) you can find it's occurence in the ns.persistence.readParagraphContent function where the initialContent is extracted from the resource JSON map. Another occurence can be found in finishInlineEdit and addHistoryStep methods. Changing all three occurences of "text" to your value brings expected outcome.

This is obviously non-acceptable - it's a platform-wide change and will affect other (incl. ootb) components where it might no be expected. The simplest would be to just copy-paste whole editor into your clientlib and register the editor into a new name - see last couple of lines: ns.editor.register. If you feel comfortable in JS, it might be worth to extend this editor and alter just three methods that are affected.

like image 193
Mateusz Chromiński Avatar answered Feb 01 '23 13:02

Mateusz Chromiński