Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolbar will not show in combination with textarea #1477

Open
Job89 opened this issue Sep 27, 2015 · 2 comments
Open

Toolbar will not show in combination with textarea #1477

Job89 opened this issue Sep 27, 2015 · 2 comments

Comments

@Job89
Copy link

Job89 commented Sep 27, 2015

After updating Aloha.Editor 1.3.3 to a higher version it is not possible any more to edit a textarea. The toolbar won't show.

@Job89
Copy link
Author

Job89 commented Dec 1, 2015

Also when I look at aloha/demo/demo-app/textarea.html of the latest 1.4.1 it is still broken, the draggable toolbar won't show!

@rgies
Copy link

rgies commented Jul 19, 2018

I have found a fix for this bug after a lot of hours investment.
It is a problem at aloha/core.js in the function getEditableHost.

Insert the following code at line 522:

              if ( editable.hasChildNodes() && editable.childNodes.length > 0) {
                   var k;
                   for (k = 0; k < editable.childNodes.length; k++) {
                       if (Aloha.editables[i].originalObj[0] === editable.childNodes[k]) {
                           return Aloha.editables[i];
                       }
                   }
               }

Complete function:

	/**
	 * Gets the nearest editable parent of the DOM element contained in the
	 * given jQuery object.
	 *
	 * @param {jQuery} $element jQuery unit set containing DOM element.
	 * @return {Aloha.Editable} Editable, or null if none found.
	 */
	getEditableHost: (function () {
		var getEditableOf = function (editable) {
			var i;
			for (i = 0; i < Aloha.editables.length; i++) {
				if (Aloha.editables[i].originalObj[0] === editable) {
					return Aloha.editables[i];
				}

                if ( editable.hasChildNodes() && editable.childNodes.length > 0) {
                    var k;
                    for (k = 0; k < editable.childNodes.length; k++) {
                        if (Aloha.editables[i].originalObj[0] === editable.childNodes[k]) {
                            return Aloha.editables[i];
                        }
                    }
                }
            }
			return null;
		};

		return function ($element) {
			if (!$element || 0 === $element.length) {
				return null;
			}
			var editable = getEditableOf($element[0]);
			if (!editable) {
				$element.parents().each(function (__unused__, node) {
					editable = getEditableOf(node);
					if (editable) {
						return false;
					}
				});
			}
			return editable;
		};
	}()),

Great if anyone can implement this fix at the next release!

rgies added a commit to rgies/Aloha-Editor that referenced this issue Jul 19, 2018
Fix for issue alohaeditor#1477 with textarea problems
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants