Is it OK to use RED.editor.registerTypeEditor

Hi!

Documentation does not mention RED.editor.* APIs of the client. I wonder if it is fine to use them or if they are not a part of public APIs.

I am implementing a custom node managing a somewhat complex data structure: a list of items where each item have another list as its field, i.e:

const list = [
  { 
    name: 'foo'
    values: [
      { value: 1, unit: 'm' },
      { value: 2, unit: 'f' }
  ]}
]

I tried using nested editableList and not really satisfied with resulting UX.

I want to try using a separate editor dialog for nested list. I plan on rendering a button per item in node edit dialog per list item. When clicked, editor dialog gets replaced with a custom editor dialog for that particular item.


Could you, please, advise whether using RED.editor.* APIs is safe or if there is any alternative implementation path here?

Thanks in advance!

Hi @chudesno - Welcome to the forums

Could you, please, advise whether using RED.editor.* APIs is safe or if there is any alternative implementation path here?

I'm not sure what the answer here is, but IF the undocumented editor API's are not suitable for custom node use, you can still achieve customisation on the UX, by using JQUI Dialog.

I want to try using a separate editor dialog for nested list

Use the editableList, and include a button, for each item.
On its click - use the JQUI Dialog methods.

Dialog | jQuery UI

i use this on my Side bar to open up some advanced network operations in a Dialog.

const Settings = {
			title: 'Network Management',
			modal: true,
			width: modalWidth,
			height: modalHeight,
			maxWidth: maxModalWidth,
			resizable: true,
			draggable: true,
			close: function () {
				// Cleanup
			}
		}

$('#zwjs-advanced-editor').dialog(Settings);

this will allow some bespoke UX handling for your complex structures

This is just my approach, when dealing with complex configurations - many other ways of course

The "rule" from the core devs has always been that if an API isn't documented, it shouldn't be used since it could easily change or go away.


Having said that, I do have RED.editor.createEditor and RED.editor.editText in uibuilder for the file editor. However, that code really should be looked at as I'm not convinced it is current best practice.

1 Like

I'm even cautious about using documented ones :joy:

2 Likes

registerTypeEditor only really makes sense if it is an editor you want to reuse in multiple places.

You can use the APIs available to open a second edit tray (as the internals calls them) with whatever content you want. I don't have a ready made example for you, but it's basically a slightly lower level API than the registerTypeEditor one.

I'm away from my laptop this week for some much needed downtime. If you get stuck ping me and I can try to point to an useful places in the code to look, but a more complete response will have to wait until next week.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.