Skip to content

Commit 682cd4a

Browse files
committed
After CR
1 parent bcb6315 commit 682cd4a

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const getSplitedUrl = (url) => {
2+
const splitedUrl = url.split('?');
3+
4+
return {
5+
baseUrl: splitedUrl[0],
6+
queryString: splitedUrl[1],
7+
};
8+
};
9+
10+
const decodeUrlQuery = (url) => {
11+
const { baseUrl, queryString } = getSplitedUrl(url);
12+
13+
if (!queryString) {
14+
return url;
15+
}
16+
17+
return `${baseUrl}?${decodeURI(queryString)}`;
18+
};
19+
20+
const encodeUrlQuery = (url) => {
21+
const { baseUrl, queryString } = getSplitedUrl(url);
22+
23+
if (!queryString) {
24+
return url;
25+
}
26+
27+
return `${baseUrl}?${encodeURI(queryString)}`;
28+
};
29+
30+
export { decodeUrlQuery, encodeUrlQuery };

src/bundle/Resources/public/js/CKEditor/link/link-ui.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import findAttributeRange from '@ckeditor/ckeditor5-typing/src/utils/findattribu
66
import IbexaLinkFormView from './ui/link-form-view';
77
import IbexaButtonView from '../common/button-view/button-view';
88
import { getCustomAttributesConfig, getCustomClassesConfig } from '../custom-attributes/helpers/config-helper';
9+
import { encodeUrlQuery } from '../helpers/url-helper';
910

1011
const { Translator } = window;
1112

@@ -59,7 +60,7 @@ class IbexaLinkUI extends Plugin {
5960

6061
this.isNew = false;
6162

62-
this.editor.execute('insertIbexaLink', { href: encodeURI(url), title, target, ibexaLinkClasses, ibexaLinkAttributes });
63+
this.editor.execute('insertIbexaLink', { href: encodeUrlQuery(url), title, target, ibexaLinkClasses, ibexaLinkAttributes });
6364
this.hideForm();
6465
});
6566

src/bundle/Resources/public/js/CKEditor/link/ui/link-form-view.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { addListToDropdown } from '@ckeditor/ckeditor5-ui/src/dropdown/utils';
99
import { createLabeledSwitchButton } from '../../common/switch-button/utils';
1010
import { createLabeledInputNumber } from '../../common/input-number/utils';
1111
import { getCustomAttributesConfig, getCustomClassesConfig } from '../../custom-attributes/helpers/config-helper';
12-
12+
import { decodeUrlQuery } from '../../helpers/url-helper';
1313
class IbexaLinkFormView extends View {
1414
constructor(props) {
1515
super(props);
@@ -122,7 +122,7 @@ class IbexaLinkFormView extends View {
122122
}
123123

124124
setValues({ url, title, target, ibexaLinkClasses, ibexaLinkAttributes = {} }) {
125-
this.setStringValue(this.urlInputView, decodeURI(url));
125+
this.setStringValue(this.urlInputView, decodeUrlQuery(url));
126126
this.setStringValue(this.titleView, title);
127127

128128
this.targetSwitcherView.fieldView.element.value = !!target;

0 commit comments

Comments
 (0)