Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

How can I set "bounds" to be the current element #145

Closed
chenlijun99 opened this issue Mar 11, 2018 · 8 comments
Closed

How can I set "bounds" to be the current element #145

chenlijun99 opened this issue Mar 11, 2018 · 8 comments

Comments

@chenlijun99
Copy link

In order to fix this issue I need to set "bounds" to the current element.

@KillerCodeMonkey
Copy link
Owner

it is not possible for now. to set this initially, because the element is created on the fly.

you can simply try to wrap the quill-editor in another div (without special stylings) and set the bounds to that element.

@KillerCodeMonkey
Copy link
Owner

is this working for you?

@chenlijun99
Copy link
Author

Sorry I haven't tried yet.
This evening I should have time to test it.

I'll let you know.

@chenlijun99
Copy link
Author

I've tried but it doesn't work

@chenlijun99
Copy link
Author

chenlijun99 commented Mar 13, 2018

This is the code of the directive

var app = angular.module("myModule")
	.directive("richEdit", RichEditDirective);

function RichEditDirective() {
	return {
		restrict: "E",
		templateUrl: "views/RichEdit.html",
		compile: compile,
		scope: true,
	};

	function compile($element) {
		// pass all attributes to the inner ng-quill-editor we're encapsulating

		// get the actual dom element from the jqLite object $element
		var domElement = $element[0];

		var editor = $element.find("ng-quill-editor");

		// copy all the attributes to ng-quill-editor
		angular.forEach(domElement.attributes, function(attribute) {
			editor.attr(attribute.name, attribute.value);
		});

		editor.attr("bounds", "$element");

		// remove all the attributes on current element
		while(domElement.attributes.length > 0) {
			domElement.removeAttribute(domElement.attributes[0].name);
		}

		return function($scope, $element) {
			$scope.$element = editor[0];
		};
	}
}

@KillerCodeMonkey
Copy link
Owner

try the latest release 3.6.0 and pass bounds="self" to the editor tag

@chenlijun99
Copy link
Author

Thank you very much. I've tried and it works!
I only want to point out that it should be bounds="'self'", since its a binding of type "<" and not "@".

@KillerCodeMonkey
Copy link
Owner

jarp, you are right :)

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

2 participants