You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have a simple text that you wanna anchor, it works.
If you have a complex text, it's another story. Let's say something like : <b>this is a</b><i><b> complicated</b> <strike><b>markup</b></strike></i>
If you have specified a button class to then function createLink, it won't be taken into account because it's going to handle the wrong node. The problem is the addClassToAnchors function, which won't traverse up to the parents node :
if (el.nodeName.toLowerCase() === 'a') {
for (j = 0; j < classes.length; j += 1) {
el.classList.add(classes[j]);
}
} else {
**el = el.getElementsByTagName('a');**
for (i = 0; i < el.length; i += 1) {
for (j = 0; j < classes.length; j += 1) {
el[i].classList.add(classes[j]);
}
}
}
Steps to reproduce
Add style to your text
Select some text crossing several styles, for example select : " is a complicated mar".
Call createLink on this selection, specifying a buttonClass option.
Expected behavior: The button class you specified is added to the created a element. Actual behavior: The button class is not added to the created a element.
anna-git
changed the title
CustomClassOption to complex anchor content not working
CustomClassOption to complex anchored selected text not working
Sep 19, 2016
anna-git
changed the title
CustomClassOption to complex anchored selected text not working
CustomClassOption is not added when anchoring complex selected styled text
Sep 19, 2016
anna-git
added a commit
to anna-git/medium-editor
that referenced
this issue
Sep 19, 2016
Description
If you have a simple text that you wanna anchor, it works.
If you have a complex text, it's another story. Let's say something like :
<b>this is a</b><i><b> complicated</b> <strike><b>markup</b></strike></i>
If you have specified a button class to then function createLink, it won't be taken into account because it's going to handle the wrong node. The problem is the addClassToAnchors function, which won't traverse up to the parents node :
Steps to reproduce
Expected behavior: The button class you specified is added to the created a element.
Actual behavior: The button class is not added to the created a element.
Link to an example: https://jsfiddle.net/m63wpj5a/
![edium editor a bug - jsfiddle20160919132453](https://cloud.githubusercontent.com/assets/8353486/18630392/9f632e10-7e6c-11e6-9bcd-6c9dccfa5703.gif)
Or even more simply:
![edium editor a bug - jsfiddle20160919135501](https://cloud.githubusercontent.com/assets/8353486/18631218/f02bec0c-7e70-11e6-8020-4b052a0b1cb4.gif)
Versions
The text was updated successfully, but these errors were encountered: