summernote-rails icon indicating copy to clipboard operation
summernote-rails copied to clipboard

Add imageSize75

Open johndavemanuel opened this issue 7 years ago • 5 comments

Is it possible to add option imageSize75?

I try to use this summernote-image-attributes.js but it does not work

johndavemanuel avatar Oct 02 '18 07:10 johndavemanuel

I also would like to know hos to add the imageSize75.

I already did the following: $(document).ready(function() { $('#summernote').summernote({ popover: { image: [ ['custom', ['imageAttributes']], ['imagesize', ['imageSize100', 'imageSize75', 'imageSize50', 'imageSize25']], ['float', ['floatLeft', 'floatRight', 'floatNone']], ['remove', ['removeMedia']] ], }, lang: 'en-US', // Change to your chosen language imageAttributes:{ icon:'', removeEmpty:false, // true = remove attributes | false = leave empty if present disableUpload: false // true = don't display Upload Options | Display Upload Options } });

});

And in summernote.js I added this popover: { image: [ ['imagesize', ['imageSize100', 'imageSize75','imageSize50', 'imageSize25']], ['float', ['floatLeft', 'floatRight', 'floatNone']], ['remove', ['removeMedia']] ],

And this in the Buttons.prototype.addImagePopoverButtons = function () { var _this = this; section

    this.context.memo('button.imageSize75', function () {
        return _this.button({
            contents: '<span class="note-fontsize-10">75%</span>',
            tooltip: _this.lang.image.resizeHalf,
            click: _this.context.createInvokeHandler('editor.resize', '0.75')
        }).render();
    });

But when clicking on the image in the editor only 100%, 50% and 25% appears.

What more needs to be done?

Thierig avatar Nov 05 '18 08:11 Thierig

It seems we need someone from the team for this? I have tried a lot of stuff to make it work, but still no luck

johndavemanuel avatar Nov 07 '18 01:11 johndavemanuel

Hi John,

did you find solution for this ?

sandeepsangole avatar May 09 '19 20:05 sandeepsangole

Hi Sandeep!

Sorry but no luck for this

johndavemanuel avatar May 10 '19 00:05 johndavemanuel

Hey, guys! Have solution.

var ImageResize75PercentButton = function(context) {
    return $.summernote.ui.button({
        contents: '<span class="note-fontsize-10">75%</span>',
        tooltip: 'Уменьшить до 75%',
        click: context.createInvokeHandler("editor.resize", "0.75")
    }).render()
}

$.summernote.options.buttons['resize75'] = ImageResize75PercentButton

$.summernote.options.popover.image = [
    ["resize", ["resizeFull", "resize75", "resizeHalf", "resizeQuarter", "resizeNone"]],
    ["float", ["floatLeft", "floatRight", "floatNone"]],
    ["remove", ["removeMedia"]],
]

Add it as Summernote JS plugin.

DAVIDhaker avatar Mar 01 '23 18:03 DAVIDhaker