Skip to content

Commit

Permalink
fixes to clearing link
Browse files Browse the repository at this point in the history
  • Loading branch information
GrabowskiM committed Jan 13, 2025
1 parent a1f2b9b commit 613ff3c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/bundle/Resources/public/js/CKEditor/link/link-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,24 @@ class IbexaLinkUI extends Plugin {
}

removeAttributes(writer, element) {
const { link: customAttributesLinkConfig } = getCustomAttributesConfig();
const { link: customClassesLinkConfig } = getCustomClassesConfig();

writer.removeAttribute('ibexaLinkHref', element);
writer.removeAttribute('ibexaLinkTitle', element);
writer.removeAttribute('ibexaLinkTarget', element);

if (customClassesLinkConfig) {
writer.removeAttribute('ibexaLinkClasses', element);
}

if (customAttributesLinkConfig) {
const attributes = Object.keys(customAttributesLinkConfig);

attributes.forEach((attribute) => {
writer.removeAttribute(`ibexaLink${attribute}`, element);
});
}
}

removeLink() {
Expand Down Expand Up @@ -109,7 +124,7 @@ class IbexaLinkUI extends Plugin {
};

if (customClassesLinkConfig) {
const defaultCustomClasses = this.isNew && customClassesLinkConfig ? customClassesLinkConfig.defaultValue : '';
const defaultCustomClasses = this.isNew ? customClassesLinkConfig.defaultValue : '';
const classesValue = link?.getAttribute('class') ?? defaultCustomClasses;

values.ibexaLinkClasses = classesValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class IbexaLinkFormView extends View {
this.targetSwitcherView.fieldView.isOn = !!target;
this.targetSwitcherView.fieldView.set('isEmpty', false);

if (ibexaLinkClasses) {
if (ibexaLinkClasses !== undefined) {
this.setChoiceValue(this.classesView, ibexaLinkClasses);
}

Expand Down

0 comments on commit 613ff3c

Please sign in to comment.