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

CustomClassOption is not added when anchoring complex selected styled text #1216

Closed
anna-git opened this issue Sep 19, 2016 · 0 comments
Closed
Labels

Comments

@anna-git
Copy link
Contributor

anna-git commented 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 :

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

  1. Add style to your text
  2. Select some text crossing several styles, for example select : " is a complicated mar".
  3. 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.

Link to an example: https://jsfiddle.net/m63wpj5a/
edium editor a bug - jsfiddle20160919132453

Or even more simply:
edium editor a bug - jsfiddle20160919135501

Versions

  • medium-editor: current
  • browser:chrome (but any will do)
anna-git added a commit to anna-git/medium-editor that referenced this issue Sep 19, 2016
@anna-git 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 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
This reverts commit f5e7756.
nmielnik added a commit that referenced this issue Feb 8, 2017
nmielnik added a commit that referenced this issue Feb 8, 2017
@nmielnik nmielnik added the bug label Feb 8, 2017
@j0k3r j0k3r closed this as completed in ba69260 Feb 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants