Custom Widget: Code Snippets

I would like to be able to have a custom widget for Code Snippets, so that there is auto formatting. It would also be great if I could run that code too. If it only works for python that would be okay too, since I have python code snippets, and since Grist runs on Python I think it may not be a huge challenge?

Say for example I want to store my solutions to Leetcode problems, e.g. Loading... I can have a column in the table with the code, but instead of having to go to LeetCode to run my solution, I could run it with the custom widget.

class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        from collections import defaultdict
        map = defaultdict(int)
        for i in range(0, len(nums)):
            if target-nums[i] in map:
                return [i,map[]]
            map[nums[i]] = target-nums[i]

If not being able to run it, at least having code formatting would be nice, like this forum supports.

1 Like