josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON
https://jsoneditoronline.org
Other
814 stars 108 forks source link

feat: force context menu #396

Closed 1pone closed 3 months ago

1pone commented 5 months ago

With the release of onRenderContextMenu, users have the opportunity to define a variety of menus based on their needs, which may be more than just editing-related, and which are currently not presented when in readOnly mode.

josdejong commented 5 months ago

Thanks, good idea. Right now the context menu is simply not rendered when read only.

I was thinking. When a user sees this new property forceContextMenu, it may not be clear what it exactly is and that it is related to a combination of onRenderContextMenu and readOnly. Maybe we can instead extend onRenderContextMenu: always render it (also when readOnly), unless the function returns false for example. We can pass readOnly along with the context object (2nd argument). The default implementation of onRenderContextMenu can return false when readOnly is true to maintain the current behavior. What do you think?

1pone commented 5 months ago

You make a good point, the new property forceContextMenu introduced will make the logic more difficult to understand. Maybe I'll try the solution you're talking about.