Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Status of the hallolink plugin #183

Closed
lambdazen opened this issue Jun 23, 2013 · 14 comments
Closed

Status of the hallolink plugin #183

lambdazen opened this issue Jun 23, 2013 · 14 comments

Comments

@lambdazen
Copy link

Hi,

I am using HalloEditor to build a programmable Wiki, and am very happy with how it works.

I would like to use the link feature (hallolink) to allow users to create links. I see from your project documentation that this feature doesn't work currently.

What is the problem with the plugin? How would you suggest that I proceed? I can help fix the problem, if I can.

Regards,

Sridhar.

@styks1987
Copy link

I am also interested in a solution for this.

@grobmeier
Copy link
Collaborator

+1

@couresel
Copy link

If you feel comfortable modifying the .js file, there's a line that resembles "dialog.dialog('close');" around line# 251

Move that line up to so that it is above line# 230 which reads "widget.options.editable.restoreSelection(widget.lastSelection);"

The result function should look something like this:

      dialog.dialog('close');
      widget.options.editable.restoreSelection(widget.lastSelection);
      if (isEmptyLink(link)) {
        selectionStart = widget.lastSelection.startContainer;
        if (widget.lastSelection.collapsed) {
          widget.lastSelection.setStartBefore(selectionStart);
          widget.lastSelection.setEndAfter(selectionStart);
          window.getSelection().addRange(widget.lastSelection);
        }
        document.execCommand("unlink", null, "");
      } else {
        if (!(/:\/\//.test(link)) && !(/^mailto:/.test(link))) {
          link = 'http://' + link;
        }
        if (widget.lastSelection.startContainer.parentNode.href === void 0) {
          document.execCommand("createLink", null, link);
        } else {
          widget.lastSelection.startContainer.parentNode.href = link;
        }
      }
      widget.options.editable.element.trigger('change');
      widget.options.editable.removeAllSelections();
      return false;

Please let me/us know if this works for you.

@marcobarbosa
Copy link
Contributor

"What is the problem with the plugin? How would you suggest that I proceed?"

+1

I'll take a look at @couresel code above but it would be good to know what's missing or what the problem is. I'm also in the need for this as soon as possible.

@openinformation
Copy link

I guess the code above is from the 1.02 release?

We are using the latest version from master: here inserting the first link works fine, but trying to insert a second link throws the following error:

TypeError: widget.lastSelection.startContainer.parentNode is null (Line 1719)

The workaround is to click outside the editable and then inside again... Not sure whether this is a problem with rangy or the way hallo.js handles selections.

@couresel
Copy link

The change above has been committed to the project, however you will have to compile the coffee script src. I am assuming that the js file in the project is from a previous stable commit.

It might be worth building the js from the coffee scripts in the src directory; I have not tried that just yet.

@openinformation
Copy link

I took the examples/hallo.js file from master, which indicates it has been recently build. But I can build from coffee script and try again.

@lambdazen
Copy link
Author

Is anyone getting this error while closing the dialog?

Uncaught SyntaxError: Invalid regular expression: /(^|.)dialog-overlay(.|$)/: Stack overflow

It looks like an infinite loop in jquery.event.remove(). I doesn't matter where I do the dialog.dialog('close').

If anyone has got the link window to close, please let me know which version of jquery you are using. I am on 1.8.3 which may be old.

@lambdazen
Copy link
Author

Update: The issue in my last post (infinite loop in jquery.event.remove) seems to be in jQuery.

In the jquery.js file, I had to add

    // Detach an event or set of events from an element
    remove: function( elem, types, handler, selector, mappedTypes ) {
        ...
        // Unbind all events (on this namespace, if provided) for the element
        if ( !type ) {
            for ( type in events ) {
                if (type) { // Added a check here
                jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
            }
        }
        ...

After this change the link editing seems to work fine. I am using dialogs elsewhere, but didn't run into this problem. I'm not sure why closing the dialog created an issue in hallo.

@couresel

I couldn't see a difference in behavior when moving the dialog close up from 251 to 230. I think I'm missing something. What was the problem that this change addressed?

@lambdazen
Copy link
Author

I have put up this jsfiddle for everyone's reference: http://jsfiddle.net/f5XYV/2/

This shows the link feature working without any changes. I think the issue I faced with jquery might have to do with some interaction with bootstrap or my application code. At this point, the link feature works from my point of view. I have not done heavy testing of the fiddle, so we might still have issues.

@marcobarbosa, @styks1987, @grobmeier, @couresel , @openinformation : If all of you are OK, we can close this issue.

@grobmeier
Copy link
Collaborator

@lambdazen Yeah I think you can close this. I can confirm its working with the tip version.

@bergie
Copy link
Owner

bergie commented Aug 1, 2013

@grobmeier cool!

@marcobarbosa
Copy link
Contributor

Yep, all good! Thanks!

@couresel
Copy link

couresel commented Aug 1, 2013

No complaints here. Feel free to close as deemed appropriate.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants