Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Popup window with Advanced Editor

steamsteam www.planamigo.org - #1 foro planes amigo

Hi,

I have popup window with Advanced Editor, I show window like

echo anchor(sprite('SpInbox', 'Sprite Sprite16').' '.t('Send PM'), url(SignInUrl($ReturnUrl), true), 'PM Popup', array('class' => 'Popup', 'rel' => 'nofollow'));

Bold and other edit options do not work

When the popup window is displayed with editor, it does not work and sent message is saved and displayed without the format in a single line.

If you send private message without popup window everything works.

Thanks, for any suggestion

Comments

  • steamsteam www.planamigo.org - #1 foro planes amigo

    No one has a similar bug with popup window and editor?

  • R_JR_J Ex-Fanboy Munich Admin

    I guess no one has tried to do that ;)

    Based on the problems you are describing, I would think that some JavaScript selectors are set to elements which are not available when the editor is in a popup. For example, I see a "editor-active" class in the body tag, when I inspect this element.

    Maybe the javascript error console shows up any hints...?

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited June 2017

    Yes @R_J

    I found this error in javascript console:

    TypeError: sel.nativeSelection is null[Saber más] wysihtml5-0.4.0pre.js:2973:17

    on wysihtml5-0.4.0pre.js file line:

    sel._ranges.length = sel.rangeCount = sel.nativeSelection.rangeCount;

    sel.nativeSelection is null, something goes wrong with editor when popup is opened ... :(

  • R_JR_J Ex-Fanboy Munich Admin

    You would have to do some debugging: try to find out where "sel" is defined. It should look similar to var sel = .... Afterwards you might be able to see what would be missing to make it rum.

  • steamsteam www.planamigo.org - #1 foro planes amigo

    @R_J dijo:
    You would have to do some debugging: try to find out where "sel" is defined. It should look similar to var sel = .... Afterwards you might be able to see what would be missing to make it rum.

    Is declared in this function:

    api.getSelection = function(win) {
            win = win || window;
            var sel = win[windowPropertyName];
            var nativeSel = getSelection(win), docSel = implementsDocSelection ? getDocSelection(win) : null;
            if (sel) {
                sel.nativeSelection = nativeSel;
                sel.docSelection = docSel;
                sel.refresh(win);
            } else {
                sel = new WrappedSelection(nativeSel, docSel, win); // Then come by here
                win[windowPropertyName] = sel;
            }
            return sel;
        };
    

    I have debugged with the javascript console of firefox ... It's a bit confusing and I do not really understand this javascript code.

    I'll send you a user and link by private message, to see if at first glance you see something strange. I know that it is a complicated error, I thank you very much if you can take a look at least above.

  • R_JR_J Ex-Fanboy Munich Admin

    Not sure if it helps, but I found this
    It seems to be quite similar to your problem:when page is loaded and editor is hidden, the result is an error.

    You should try changing line 2973 in /plugins/editor/js/wysihtml5-0.4.0pre.js
    Comment out the line (by adding // at the beginning of the line) and insert sel._ranges.length = sel.rangeCount = (sel.nativeSelection ? sel.nativeSelection.rangeCount : 0); below the old line.

    Please report back if that has solved your problem!

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited June 2017

    @R_J dijo:
    Not sure if it helps, but I found this
    It seems to be quite similar to your problem:when page is loaded and editor is hidden, the result is an error.

    You should try changing line 2973 in /plugins/editor/js/wysihtml5-0.4.0pre.js
    Comment out the line (by adding // at the beginning of the line) and insert sel._ranges.length = sel.rangeCount = (sel.nativeSelection ? sel.nativeSelection.rangeCount : 0); below the old line.

    Please report back if that has solved your problem!

    I also found this page with this solution ;)
    But it does not work.
    Does not give the error "sel.nativeSelection is null", but is looped the editor javascript in this line and still does not work in the popup window :(

    I did leave the javascript code as it was.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    How did you create the popup? Did you simply add to it the class Popup ? it should work just like that without adding js.. I have a popup for onlinenow plugin and it shows the editor works fine.

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited June 2017

    @vrijvlinder dijo:
    How did you create the popup? Did you simply add to it the class Popup ? it should work just like that without adding js.. I have a popup for onlinenow plugin and it shows the editor works fine.

    Hi @vrijvlinder,

    On the code:
    echo anchor(sprite('SpInbox', 'Sprite Sprite16').' '.t('Send PM'), url(SignInUrl($ReturnUrl), true), 'PM Popup', array('class' => 'Popup', 'rel' => 'nofollow', 'title' => 'enviar mensaje privado a: '.$Args['Author']->Name));

    That is printed in html:
    <a href="http://web.org/messages/add/antonio" class="PM Popup" rel="nofollow" title="enviar mensaje privado a: antonio"><span class="Sprite Sprite16 SpInbox"></span> Mensaje privado</a>

    Thanks

  • steamsteam www.planamigo.org - #1 foro planes amigo

    I was wrong about the code that makes the link private message, sorry, this is it:

    echo anchor(sprite('SpInbox', 'Sprite Sprite16').' '.t('Send PM'), url('/messages/add/'.$Args['Author']->Name, true), 'PM Popup', array('rel' => 'nofollow', 'title' => 'enviar mensaje privado a: '.$Args['Author']->Name));

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited June 2017

    I have discovered one thing ...

    If I delete with the browser html editor main editor, and then I open popup window the editor that is in the popup works!

    The problem has to be in the javascript wysihtml5-0.4.0pre.js or forms.

    And I found this - https://github.com/jhollingworth/bootstrap-wysihtml5/issues/14

Sign In or Register to comment.