-
Notifications
You must be signed in to change notification settings - Fork 24
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
WIP: Prevent nested links #99
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,16 @@ var Selection = (function() { | |
return coords; | ||
}, | ||
|
||
/** | ||
* Check if a link can be added. | ||
* If the editableHost or a parent is a link element linking | ||
* should not be possible. | ||
*/ | ||
canLinkBeSet: function() { | ||
var linkParents = content.getParentsAndSelf(this.host, 'a'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @peyerluk This iterates throught all parents of the dom up to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @marcbachmann This is on purpose since nesting links should not be allowed in general. Especially in case of teasers the link tag can be outside of the editable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. It's still forbidden in HTML5 :) |
||
return linkParents.length ? false : true; | ||
}, | ||
|
||
/** | ||
* | ||
* @method link | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peyerluk, would it be possible to merge only this function if you don’t want to merge the patch below? I ask because it comes in handy in other contexts as well, e.g. avoiding
<em>
inside of a<strong>
or others.To address @marcbachmann’s concern perhaps a flag that stops traversal at a given node would be an agreeable compromise?
Lastly, I’d probably rename the function to
getAncestorsAndSelf()
to be more in line with the XPath axis ancestor-or-self.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is a bit of an odd duck currently as this is the only method that is meant to collect info outside of the host element.
It would need some polishing before we can merge it.
Would this method here help your use case? Or are you more interested in knowing which tags affect a cursor or selection within the host? For that we have the method
getTags()
in this file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peyerluk, I think I used
getTagNames()
from PR #198 in its stead.