Is it possible to render an expression not as a simple text but as a disabled text line?
render an expression (cell) as something different than <TextOutput /> (see widget) is not possible by modelling.
Even code customization could get complicated since the DefaultFormModelMap.ExpressionCell is using the TextOutput widget from the DefaultComponentMap which you can not overwrite.
So for code customization you have to re-create all the logic of DefaultFormModelMap.ExpressionCell on your own or maybe you can try to create static markup (ReactDOMServer.renderToStaticMarkup) from the component and parse it back by yourself ¯_(ツ)_/¯
In addition to @markus-agile-fog’s answer:
The expression output so far is always a String with HTML markup that we pass through React (after sanitization for security
).
Even if you could modify the widget via the standard customization APIs (WidgetMap) you would still get this HTML string as a prop. It would then need to be reverse engineered into a String without HTML markup (if that is even possible). I don’t think that’s a good solution.
Since you can’t really use any fancy formatting if you want to render your expression as a TextLine, maybe it would be possible to use a Kernel computation instead of a Form Model expression to generate your output string.
The computation is what we are going with currently, it’s just more annoying because you have to do it twice if you have initial values (as the computation only triggers on change) and it also means having display logic inside the document model