medium-editor icon indicating copy to clipboard operation
medium-editor copied to clipboard

colorpicker focus()

Open trowa88 opened this issue 11 years ago • 10 comments

this code not working IE11

In IE11, color picker focus lost....

    /**
     * Custom `color picker` extension
     */
    var ColorPickerExtension = MediumEditor.extensions.button.extend({
        name: "colorPicker",
        action: "applyForeColor",
        aria: "color picker",
        contentDefault: "<span class='editor-color-picker'>Text Color<span>",

        handleClick: function(e) {
            e.preventDefault();
            e.stopPropagation();

            this.selectionState = this.base.exportSelection();

            // If no text selected, stop here.
            if(this.selectionState && (this.selectionState.end - this.selectionState.start === 0) ) {
              return;
            }

            // colors for picker
            var pickerColors = [ 
              "#1abc9c",
              "#2ecc71",
              "#3498db",
              "#9b59b6",
              "#34495e",
              "#16a085",
              "#27ae60",
              "#2980b9",
              "#8e44ad",
              "#2c3e50",
              "#f1c40f",
              "#e67e22",
              "#e74c3c",
              "#bdc3c7",
              "#95a5a6",
              "#f39c12"
            ];

            var picker = vanillaColorPicker(this.document.querySelector(".medium-editor-toolbar-active .editor-color-picker"));
            picker.set("customColors", pickerColors);
            picker.set("positionOnTop");
            picker.openPicker();
            picker.on("colorChosen", function(color) {
              this.base.importSelection(this.selectionState);
              this.document.execCommand("styleWithCSS", false, true);
              this.document.execCommand("foreColor", false, color);
            }.bind(this));
        }
    });

trowa88 avatar Oct 14 '15 07:10 trowa88

Which version of MediumEditor are you using?

j0k3r avatar Oct 14 '15 10:10 j0k3r

version : 5.5.2 using

trowa88 avatar Oct 14 '15 23:10 trowa88

Any chance to update to the latest to see if the bug is still present?

j0k3r avatar Oct 15 '15 03:10 j0k3r

I am using latest and it seems to be working fine.

sobanhameed avatar Oct 28 '15 00:10 sobanhameed

I have the same problem using Firefox, the latest version of the medium-editor (5.13) and latest version of vanilla-color-picker (0.1.4). It works in Chrome and Opera, but in Firefox I can not select the color. The cursor changes according to the element in the background. In the screenshot, if the cursor is on the red color, the cursor will be the text selector and you can't click on the color.

Have you solved the problem already?

scrot-color-picker

stfnh avatar Jan 22 '16 10:01 stfnh

@stfnh I'm not sure I understand the issue you're describing. Specifically, could you try to explain this another way or in more detail?

The cursor changes according to the element in the background. In the screenshot, if the cursor is on the red color, the cursor will be the text selector and you can't click on the color.

nmielnik avatar Jan 28 '16 03:01 nmielnik

Thanks, @nmielnik The things is, that I can not select the color. The cursor acts as there would not be a colorpicker. It would like like this (see the cursor now):

scrot-color-picker

stfnh avatar Jan 29 '16 15:01 stfnh

@stfnh could you provide some example of this bug happening? Perhaps a jsfiddle, jsbin, codepen, etc.? I have a feeling this might be something simple, but I'd need to be able to investigate to have any idea...

nmielnik avatar Feb 22 '16 03:02 nmielnik

@nmielnik Basically, this is the point of issue. https://jsfiddle.net/6cn6epbg/ You can't see "test" alert in inner div of button on IE whatever you do.

image

kargnas avatar Apr 26 '16 14:04 kargnas

@stfnh @nmielnik Just I modify this code

var picker = vanillaColorPicker(this.document.querySelector(".medium-editor-toolbar-active .editor-color-picker"));

to this:

var picker = vanillaColorPicker(this.document.querySelector(".medium-editor-toolbar-active .editor-color-picker").parentNode);

kargnas avatar Apr 26 '16 17:04 kargnas