Selection-js icon indicating copy to clipboard operation
Selection-js copied to clipboard

Add ability to create custom features through config

Open Jondyr opened this issue 5 years ago • 0 comments

This adds a config parameter to add custom buttons to the popup. Issue reference https://github.com/prateekkalra/Selection-js/issues/2#issuecomment-394264090

The config parameter "customActions" takes an array of objects with two properties:

  • callback A callback called when the custom button is clicked. The callback function takes a parameter with the selection as a string.
  • icon HTML string with the icon.

Currently all custom buttons will be appended on the right side of the selection popup view.

A very basic working example is included in index.html:

selection.config({
    customActions: [
        {
            "callback": (selection) => {alert(selection)}, 
            "icon": customSvg
        }
    ]
})

Looking for feedback

Jondyr avatar Oct 01 '19 11:10 Jondyr