Open ADTC opened 1 month ago
For (1), docs are here: https://polotno.com/docs/toolbar. Overwriting TextAiWrite
component.
For (2), I would need to think about it. It should be possible, but I am not sure about API yet. Make a public React component? Make a documented server API? Something else?
Make a documented server API
I believe that would just be exporting the rewrite
function and documenting the arguments it takes. The user may need to implement their own UI in this case. But you can also export the existing UI as a new component, as described below.
Make a public React component
You can generalize the UI part of the component of TextAIWrite
into a new component that accepts as a callback function prop, the function to change the text, then we can reuse the new component anywhere we like with a different callback function prop which uses the above server API to generate new text and use it however it sees fit.
This will be my first approach, but there could be others. For example, you can do something similar to the above, but instead of the callback function prop accepting the arguments for rewrite
function, the new component itself can call the rewrite
function and then the callback function prop can accept the final rewritten text, which it can then do whatever it wants with the text. (In case of TextAIWrite
component, it will replace the text in the Text element. In other cases, the user can code it to replace the text inside an input text box component for example.)
This way, you no longer need to export the rewrite
function and document it, and instead you can continue to keep it private. This will be my second more refined approach.
2.14.0
? Since it's very new, I suppose there's no documentation update for it yet. For those who want to, how do we hide it or remove it? (In our case, we like it and want to keep it so this question is just for doc's sake.)A mockup of a side panel with a text box that has AI Write button.