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

Keep class of element on formating #1635

Open
bernhardriegler opened this issue Oct 31, 2019 · 0 comments
Open

Keep class of element on formating #1635

bernhardriegler opened this issue Oct 31, 2019 · 0 comments

Comments

@bernhardriegler
Copy link
Contributor

IS:
When formatting an element (example: p to h1) all classes on the initial element are lost.
SHOULD:
keep classes on element change

Suggestion:
add a check if config says that classes should be kept and ensure classes are carried over to new element:
https://github.com/alohaeditor/Aloha-Editor/blob/dev/src/lib/aloha/jquery.aloha.js#L246

jQuery.fn.zap = function () {
    if(Aloha.settings && Aloha.settings.plugins && Aloha.settings.plugins.format && Aloha.settings.plugins.format.keepClass) {
        var elem = this.get(0);
        var parent = elem ? elem.parentElement : false;
        if (parent) {
            var classListWithoutRemoveClass = Array.prototype.slice.call(elem.classList).filter(function (className) {
                return className !== "preparedForRemoval"
            });
            classListWithoutRemoveClass.forEach(function (item) {
                parent.classList.add(item);
            });	
        }	
    }
    this.each(function () {
        jQuery(this.childNodes).insertBefore(this);
    }).remove();
};
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

1 participant