Skip to content

Commit

Permalink
New version 4.1.11 Read more https://github.com/xdan/jodit/blob/main/…
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan committed Apr 14, 2024
1 parent 4a3c8c1 commit e71b608
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 18 deletions.
14 changes: 9 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
> - :house: [Internal]
> - :nail_care: [Polish]
## 4.1.11

- Fixed a bug within the FileBrowser module. The issue was due to the import order; the Ajax configuration was applied after the module had been initialized.

## 4.1.9

- Added `AbortError` to the `Jodit.modules` namespace. This is a custom error that is thrown when the user cancels the operation.
Expand Down Expand Up @@ -2553,11 +2557,11 @@ Related with https://github.com/xdan/jodit/issues/574. In some cases need to lim
- @property {IUIOption[]} link.selectOptionsClassName=[] The list of the option for the select (to use with
modeClassName="select")
- ex: [
- { value: "", text: "" },
- { value: "val1", text: "text1" },
- { value: "val2", text: "text2" },
- { value: "val3", text: "text3" }
- ]
- { value: "", text: "" },
- { value: "val1", text: "text1" },
- { value: "val2", text: "text2" },
- { value: "val3", text: "text3" }
- ]
PR: https://github.com/xdan/jodit/pull/577 Thanks @s-renier-taonix-fr
##### New option `statusbar: boolean = true`
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jodit",
"version": "4.1.10",
"version": "4.1.11",
"description": "Jodit is an awesome and useful wysiwyg editor with filebrowser",
"main": "build/jodit.min.js",
"types": "./types/index.d.ts",
Expand Down
19 changes: 19 additions & 0 deletions src/core/request/ajax.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/

describe('Ajax module', () => {
describe('Constructor', () => {
it('Should allow to expand options', () => {
const async = new Jodit.modules.Ajax({ someField: 1, timeout: 10 });
expect(async.options.timeout).equals(10);
expect(async.options.headers).deep.equals({
'X-REQUESTED-WITH': 'XMLHttpRequest'
});
expect(async.options.successStatuses).deep.equals([200, 201, 202]);
expect(async.options.someField).equals(1);
});
});
});
1 change: 1 addition & 0 deletions src/modules/file-browser/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {
IUploader,
IViewBased
} from 'jodit/types';
import 'jodit/core/request/config';
import { isArray, isString } from 'jodit/core/helpers/checker';
import { humanSizeToBytes } from 'jodit/core/helpers/utils/human-size-to-bytes';
import { UIFileInput } from 'jodit/core/ui/form/inputs/file/file';
Expand Down
18 changes: 9 additions & 9 deletions src/modules/file-browser/data-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ export default class DataProvider implements IFileBrowserDataProvider {
return this.options;
}

private ajaxInstances: Map<string, IAjax<IFileBrowserAnswer>> = new Map();
private __ajaxInstances: Map<string, IAjax<IFileBrowserAnswer>> = new Map();

protected get<T extends IFileBrowserAnswer = IFileBrowserAnswer>(
name: keyof IFileBrowserOptions
): Promise<T> {
const ai = this.ajaxInstances;
const instances = this.__ajaxInstances;

if (ai.has(name)) {
const ajax = ai.get(name);
if (instances.has(name)) {
const ajax = instances.get(name);
ajax?.abort();
ai.delete(name);
instances.delete(name);
}

const opts = <IFileBrowserAjaxOptions>ConfigProto(
Expand All @@ -102,14 +102,14 @@ export default class DataProvider implements IFileBrowserDataProvider {
}

const ajax = new Ajax<T>(opts);
ai.set(name, ajax);
instances.set(name, ajax);

const promise = ajax.send();

promise
.finally(() => {
ajax.destruct();
ai.delete(name);
instances.delete(name);

this.progressHandler(100);
})
Expand Down Expand Up @@ -590,7 +590,7 @@ export default class DataProvider implements IFileBrowserDataProvider {
}

destruct(): any {
this.ajaxInstances.forEach(a => a.destruct());
this.ajaxInstances.clear();
this.__ajaxInstances.forEach(a => a.destruct());
this.__ajaxInstances.clear();
}
}
25 changes: 25 additions & 0 deletions src/modules/file-browser/file-browser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,31 @@ function getFirstItem(fb, index = 0, file = false) {
});
});

describe('Expand AJAX options', () => {
it('Should not change other default options', () => {
unmockPromise();

const filebrowser = new Jodit.modules.FileBrowser({
ajax: {
url: 'https://xdsoft.net/jodit/connector/index.php',
method: 'GET'
}
});

filebrowser.dataProvider.get('permissions');

const perm =
filebrowser.dataProvider.__ajaxInstances.get(
'permissions'
);
expect(perm.options.headers).deep.equals({});
expect(perm.options.successStatuses).deep.equals([
200, 201, 202
]);
filebrowser.destruct();
});
});

describe('Use POST method', function () {
it('Should add params only into body', function (done) {
const filebrowser = new Jodit.modules.FileBrowser({
Expand Down
2 changes: 1 addition & 1 deletion test/loader.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e71b608

Please sign in to comment.