ce icon indicating copy to clipboard operation
ce copied to clipboard

How to remove image from cell?

Open flatsiedatsie opened this issue 2 years ago • 1 comments

I found it surprisingly difficult to remove an image from a cell.

For example, in the demo you can see that pressing backspace shows the image in a popup instead of removing it.

I resorted to hacking a "Clear cell" option into the context menu, but it would be better if backspace removed the image.

if (x) {
                        
                        
                        items.push({
                            title: 'Clear cell',
                            onclick:function() {
                                obj.updateCell(x, y, '', true);
                            }
                        });

flatsiedatsie avatar Jul 24 '23 12:07 flatsiedatsie

This modification makes the backspace work:

                                    } else if ((e.keyCode == 8) ||
                                               (e.keyCode >= 48 && e.keyCode <= 57) ||
                                               (e.keyCode >= 96 && e.keyCode <= 111) ||
                                               (e.keyCode >= 187 && e.keyCode <= 190) ||
                                               ((String.fromCharCode(e.keyCode) == e.key || String.fromCharCode(e.keyCode).toLowerCase() == e.key.toLowerCase()) && jexcel.validLetter(String.fromCharCode(e.keyCode)))) {
                                        
                                        
                                        if ((e.keyCode == 8) && jexcel.current.options.columns[columnId].type == 'image'){
                                            jexcel.current.updateCell(columnId, rowId, '', true);
                                        }
                                        
                                        // Start edition
                                        jexcel.current.openEditor(jexcel.current.records[rowId][columnId], true);

flatsiedatsie avatar Jul 24 '23 13:07 flatsiedatsie