Replies: 2 comments 3 replies
-
I have been thinking about this. Now that the PR with interfaces/types for data has been merged, it might make it easier to discuss this. Most common actions on messages would be constant and do not change irrespective of the In case of copy, what if instead of having a generic copy action, we something more specific like - Also, what are the other actions do you anticipate which may vary by |
Beta Was this translation helpful? Give feedback.
-
I think we can close this discussion as we decided to provide |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When designing the
MessageCanvas
component to handle actions such as copy, delete, or edit, it's crucial to account for the diverse message formats it may render. Each message format may require different actions, and thus, a flexible configuration approach is necessary.One approach is to define a
messageConfig
object, which maps each message format to specific actions and their corresponding properties. For instance:We could also store the messageConfig object in a separate JSON file or retrieve it from an API request, providing more flexibility and easier maintenance. In this configuration, the keys represent different message formats (e.g., text, codeSnippet, image). Each format is associated with an object specifying actions and their properties. For the copy action, the property specifies what data to copy. It could be a single string, an array of strings representing multiple data properties to combine, or an objects containing both data properties and their corresponding tooltip labels.
For example, if we want to copy both the URL and description of an image, along with a custom tooltip label, the configuration could look like this:
This configuration specifies a custom tooltip label ('Copy Image Info') and identifies the properties ('url' and 'description') to be copied.
Alternatively, if a tooltip label is unnecessary but we still want to copy multiple properties, a simpler configuration suffices:
The messageConfig object can accommodate other actions such as editing. For editing functions, we can specify the editable properties or set the value to false if editing is not allowed. For instance:
By adopting such a configurable approach, we can maintain code clarity, extendibility, and versatility in handling diverse message formats and their associated actions. Additionally, this approach facilitates future enhancements or modifications to action handling without the need for extensive code changes.
Another option is having a function (if/else statement) for each action to decide what should be changed.
We welcome suggestions and feedback from the community on how to handle actions effectively.
Beta Was this translation helpful? Give feedback.
All reactions