Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/bundle/Resources/public/js/CKEditor/helpers/url-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const getSplitedUrl = (url) => {
const splitedUrl = url.split('?');

return {
baseUrl: splitedUrl[0],
queryString: splitedUrl[1],
};
};

const decodeUrlQuery = (url) => {
const { baseUrl, queryString } = getSplitedUrl(url);

if (!queryString) {
return url;
}

return `${baseUrl}?${decodeURI(queryString)}`;
};

const encodeUrlQuery = (url) => {
const { baseUrl, queryString } = getSplitedUrl(url);

if (!queryString) {
return url;
}

return `${baseUrl}?${encodeURI(queryString)}`;
};

export { decodeUrlQuery, encodeUrlQuery };
3 changes: 2 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 @@ -6,6 +6,7 @@ import findAttributeRange from '@ckeditor/ckeditor5-typing/src/utils/findattribu
import IbexaLinkFormView from './ui/link-form-view';
import IbexaButtonView from '../common/button-view/button-view';
import { getCustomAttributesConfig, getCustomClassesConfig } from '../custom-attributes/helpers/config-helper';
import { encodeUrlQuery } from '../helpers/url-helper';

const { Translator } = window;

Expand Down Expand Up @@ -59,7 +60,7 @@ class IbexaLinkUI extends Plugin {

this.isNew = false;

this.editor.execute('insertIbexaLink', { href: url, title, target, ibexaLinkClasses, ibexaLinkAttributes });
this.editor.execute('insertIbexaLink', { href: encodeUrlQuery(url), title, target, ibexaLinkClasses, ibexaLinkAttributes });
this.hideForm();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { addListToDropdown } from '@ckeditor/ckeditor5-ui/src/dropdown/utils';
import { createLabeledSwitchButton } from '../../common/switch-button/utils';
import { createLabeledInputNumber } from '../../common/input-number/utils';
import { getCustomAttributesConfig, getCustomClassesConfig } from '../../custom-attributes/helpers/config-helper';

import { decodeUrlQuery } from '../../helpers/url-helper';
class IbexaLinkFormView extends View {
constructor(props) {
super(props);
Expand Down Expand Up @@ -122,7 +122,7 @@ class IbexaLinkFormView extends View {
}

setValues({ url, title, target, ibexaLinkClasses, ibexaLinkAttributes = {} }) {
this.setStringValue(this.urlInputView, url);
this.setStringValue(this.urlInputView, decodeUrlQuery(url));
this.setStringValue(this.titleView, title);

this.targetSwitcherView.fieldView.element.value = !!target;
Expand Down
Loading