jodit 3.8.8 → 3.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/.github/workflows/tests.yml +23 -0
  2. package/.idea/dictionaries/v_chupurnov.xml +1 -0
  3. package/.idea/workspace.xml +295 -286
  4. package/CHANGELOG.MD +110 -24
  5. package/README.md +3 -3
  6. package/build/jodit.css +2 -2
  7. package/build/jodit.es2018.css +1 -1
  8. package/build/jodit.es2018.en.css +1 -1
  9. package/build/jodit.es2018.en.js +329 -210
  10. package/build/jodit.es2018.en.min.js +1 -1
  11. package/build/jodit.es2018.js +329 -210
  12. package/build/jodit.es2018.min.js +1 -1
  13. package/build/jodit.js +1066 -881
  14. package/build/jodit.min.css +1 -1
  15. package/build/jodit.min.js +1 -1
  16. package/package.json +1 -1
  17. package/src/core/async.ts +1 -1
  18. package/src/core/constants.ts +2 -0
  19. package/src/core/dom.ts +113 -99
  20. package/src/core/events/{events-native.ts → event-emitter.ts} +14 -9
  21. package/src/core/events/index.ts +1 -1
  22. package/src/core/global.ts +2 -2
  23. package/src/core/helpers/array/to-array.ts +1 -0
  24. package/src/core/helpers/data-bind.ts +2 -2
  25. package/src/core/helpers/utils/utils.ts +20 -4
  26. package/src/core/request/ajax.ts +212 -0
  27. package/src/core/request/config.ts +37 -0
  28. package/{build-system/minimizer/index.js → src/core/request/index.ts} +2 -1
  29. package/src/core/request/response.ts +39 -0
  30. package/src/core/selection/select.ts +59 -27
  31. package/src/core/selection/style/api/element-has-same-style.ts +13 -0
  32. package/src/core/selection/style/api/get-suit-parent.ts +1 -1
  33. package/src/core/selection/style/api/is-suit-element.ts +24 -4
  34. package/src/core/selection/style/api/unwrap-children.ts +45 -16
  35. package/src/core/selection/style/api/wrap-unwrapped-text.ts +28 -23
  36. package/src/core/selection/style/apply-style.ts +14 -8
  37. package/src/core/traits/elms.ts +1 -0
  38. package/src/core/ui/helpers/get-control-type.ts +3 -1
  39. package/src/core/view/view.ts +3 -3
  40. package/src/modules/context-menu/context-menu.ts +1 -1
  41. package/src/modules/file-browser/README.MD +1 -1
  42. package/src/modules/file-browser/data-provider.ts +22 -42
  43. package/src/modules/file-browser/file-browser.ts +3 -0
  44. package/src/modules/index.ts +1 -1
  45. package/src/modules/table.ts +106 -101
  46. package/src/modules/uploader/uploader.ts +4 -3
  47. package/src/plugins/fix/clean-html.ts +37 -16
  48. package/src/plugins/indent.ts +25 -18
  49. package/src/plugins/size/resize-handler.ts +1 -1
  50. package/src/plugins/size/size.ts +1 -3
  51. package/src/plugins/source/source.ts +1 -1
  52. package/src/plugins/table/select-cells.ts +23 -5
  53. package/src/types/ajax.d.ts +15 -6
  54. package/src/types/async.d.ts +1 -1
  55. package/src/types/events.d.ts +12 -12
  56. package/src/types/view.d.ts +2 -2
  57. package/types/core/async.d.ts +1 -1
  58. package/types/core/constants.d.ts +1 -0
  59. package/types/core/dom.d.ts +25 -19
  60. package/types/core/events/{events-native.d.ts → event-emitter.d.ts} +8 -3
  61. package/types/core/events/index.d.ts +1 -1
  62. package/types/core/global.d.ts +2 -2
  63. package/types/core/helpers/utils/utils.d.ts +12 -4
  64. package/types/core/{ajax.d.ts → request/ajax.d.ts} +4 -14
  65. package/types/core/request/config.d.ts +14 -0
  66. package/{build-system/rules/css.js → types/core/request/index.d.ts} +2 -7
  67. package/types/core/request/response.d.ts +16 -0
  68. package/types/core/selection/style/api/element-has-same-style.d.ts +4 -0
  69. package/types/core/selection/style/api/is-suit-element.d.ts +1 -0
  70. package/types/core/selection/style/api/wrap-unwrapped-text.d.ts +2 -2
  71. package/types/core/view/view.d.ts +2 -2
  72. package/types/modules/file-browser/data-provider.d.ts +1 -1
  73. package/types/modules/index.d.ts +1 -1
  74. package/types/plugins/fix/clean-html.d.ts +4 -0
  75. package/types/plugins/size/resize-handler.d.ts +1 -1
  76. package/types/plugins/source/source.d.ts +1 -1
  77. package/types/types/ajax.d.ts +15 -6
  78. package/types/types/async.d.ts +1 -1
  79. package/types/types/events.d.ts +12 -12
  80. package/types/types/view.d.ts +2 -2
  81. package/.editorconfig +0 -15
  82. package/.eslintignore +0 -3
  83. package/.eslintrc.js +0 -109
  84. package/.prettierrc.json +0 -9
  85. package/.stylelintrc +0 -17
  86. package/app.css +0 -112
  87. package/build-system/index.js +0 -78
  88. package/build-system/loaders/css-variables-prefixes.js +0 -12
  89. package/build-system/loaders/lang-loader.js +0 -57
  90. package/build-system/loaders/style.js +0 -31
  91. package/build-system/loaders/svg-loader.js +0 -21
  92. package/build-system/minimizer/css.js +0 -20
  93. package/build-system/minimizer/js.js +0 -41
  94. package/build-system/plugins/banner.js +0 -15
  95. package/build-system/plugins/define.js +0 -22
  96. package/build-system/plugins/extract-css.js +0 -14
  97. package/build-system/plugins/index.js +0 -31
  98. package/build-system/plugins/post-build.js +0 -52
  99. package/build-system/rules/extra-typescript.js +0 -22
  100. package/build-system/rules/index.js +0 -17
  101. package/build-system/rules/internal-typescript.js +0 -23
  102. package/build-system/rules/langs.js +0 -20
  103. package/build-system/rules/svg.js +0 -19
  104. package/build-system/utils/filename.js +0 -17
  105. package/build-system/utils/post-build.js +0 -28
  106. package/build-system/variables.js +0 -53
  107. package/composer.json +0 -12
  108. package/src/core/ajax.ts +0 -266
  109. package/src/types/core.d.ts +0 -7
  110. package/src/types/core.js +0 -8
  111. package/src/types/core.js.map +0 -1
  112. package/src/types/storage.d.ts +0 -13
  113. package/src/types/storage.js +0 -8
  114. package/src/types/storage.js.map +0 -1
  115. package/types/types/core.js +0 -8
  116. package/types/types/core.js.map +0 -1
  117. package/types/types/storage.js +0 -8
  118. package/types/types/storage.js.map +0 -1
@@ -1,41 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- const MinimizeJSPlugin = require('terser-webpack-plugin');
8
-
9
- module.exports = ({ ESNext, isTest, banner }) =>
10
- new MinimizeJSPlugin({
11
- parallel: true,
12
- extractComments: false,
13
-
14
- exclude: './src/langs',
15
- terserOptions: {
16
- ecma: ESNext ? 8 : 5,
17
-
18
- mangle: {
19
- reserved: ['Jodit']
20
- },
21
-
22
- compress: {
23
- unsafe_arrows: ESNext,
24
- unsafe_methods: ESNext,
25
- unsafe: ESNext,
26
-
27
- drop_console: !isTest,
28
- drop_debugger: !isTest,
29
-
30
- pure_getters: true,
31
- unsafe_comps: true,
32
- passes: 7
33
- },
34
-
35
- output: {
36
- comments: false,
37
- beautify: false,
38
- preamble: banner
39
- }
40
- }
41
- });
@@ -1,15 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- const webpack = require('webpack');
8
-
9
- module.exports = ({ banner }) => {
10
- return new webpack.BannerPlugin({
11
- banner,
12
- raw: true,
13
- entryOnly: true
14
- });
15
- };
@@ -1,22 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- const webpack = require('webpack');
8
-
9
- module.exports = ({ pkg, isProd, ESNext, isTest, ES, mode, excludeLangs }) => {
10
- return new webpack.DefinePlugin({
11
- appVersion: JSON.stringify(pkg.version),
12
- isProd,
13
- isTest,
14
- isESNext: ESNext,
15
- 'process.env': {
16
- HOMEPAGE: JSON.stringify(pkg.homepage),
17
- TARGET_ES: JSON.stringify(ES),
18
- NODE_ENV: JSON.stringify(mode),
19
- EXCLUDE_LANGS: JSON.stringify(excludeLangs)
20
- }
21
- });
22
- };
@@ -1,14 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
8
- const { fileName } = require('../utils/filename');
9
-
10
- module.exports = vars => {
11
- return new MiniCssExtractPlugin({
12
- filename: fileName(vars)('[name]') + '.css'
13
- });
14
- };
@@ -1,31 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- const webpack = require('webpack');
8
-
9
- module.exports = vars => {
10
- const plugins = [new webpack.ProgressPlugin(), require('./define')(vars)];
11
-
12
- const { isProd, ESNext, onlyTS, debug } = vars;
13
-
14
- if (debug) {
15
- plugins.push(new webpack.HotModuleReplacementPlugin());
16
- }
17
-
18
- if (isProd) {
19
- if (!onlyTS) {
20
- plugins.push(require('./extract-css')(vars));
21
- }
22
-
23
- plugins.push(require('./banner')(vars));
24
-
25
- if (!ESNext && !onlyTS) {
26
- plugins.push(require('./post-build')(vars));
27
- }
28
- }
29
-
30
- return plugins;
31
- };
@@ -1,52 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- const PostBuild = require('../utils/post-build');
8
- const postcss = require('postcss');
9
- const path = require('path');
10
- const { fileName } = require('../utils/filename');
11
- const fs = require('fs');
12
-
13
- module.exports = ({
14
- argv,
15
- ES,
16
- isTest,
17
- excludeLangs,
18
- uglify,
19
- outputPath,
20
- banner
21
- }) => {
22
- return new PostBuild(() => {
23
- const processor = postcss([
24
- require('autoprefixer')({
25
- overrideBrowserslist: [
26
- '>1%',
27
- 'last 4 versions',
28
- 'Firefox ESR',
29
- 'ie >= 11'
30
- ]
31
- }),
32
- require('postcss-css-variables')
33
- ]);
34
-
35
- const file = path.resolve(
36
- outputPath,
37
- fileName({ argv, ES, isTest, excludeLangs, uglify })('jodit') +
38
- '.css'
39
- );
40
-
41
- fs.readFile(file, (err, css) => {
42
- if (err) {
43
- console.log(err);
44
- return;
45
- }
46
-
47
- processor.process(css, { from: file, to: file }).then(result => {
48
- fs.writeFile(file, banner + result.css, () => true);
49
- });
50
- });
51
- });
52
- };
@@ -1,22 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- const path = require('path');
8
-
9
- module.exports = ({ ES, superDirname }) => {
10
- return {
11
- test: /\.(js|ts)$/,
12
- loader: 'ts-loader',
13
- options: {
14
- transpileOnly: true,
15
- allowTsInNodeModules: true,
16
- compilerOptions: {
17
- target: ES
18
- }
19
- },
20
- include: [path.resolve(superDirname, './node_modules')]
21
- };
22
- };
@@ -1,17 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- const path = require('path');
8
-
9
- module.exports = variables => {
10
- return [
11
- require('./css')(variables),
12
- require('./extra-typescript')(variables),
13
- require('./langs')(variables),
14
- require('./internal-typescript')(variables),
15
- require('./svg')(variables)
16
- ];
17
- };
@@ -1,23 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- const path = require('path');
8
-
9
- module.exports = ({ superDirname, uglify, ES }) => {
10
- return {
11
- test: /\.ts$/,
12
- loader: 'ts-loader',
13
- options: {
14
- transpileOnly: uglify,
15
- allowTsInNodeModules: true,
16
- compilerOptions: {
17
- target: ES
18
- }
19
- },
20
- include: [path.resolve(superDirname, './src/')],
21
- exclude: [/langs\/[a-z]{2}\.ts/, /langs\/[a-z]{2}_[a-z]{2}\.ts/]
22
- };
23
- };
@@ -1,20 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- const path = require('path');
8
-
9
- module.exports = ({ superDirname }) => {
10
- return {
11
- test: /\.(ts)$/,
12
- use: [
13
- {
14
- loader: path.resolve(__dirname, '../loaders/lang-loader')
15
- }
16
- ],
17
- include: path.resolve(superDirname, './src/langs'),
18
- exclude: path.resolve(superDirname, './src/langs/index.ts')
19
- };
20
- };
@@ -1,19 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- const path = require('path');
8
-
9
- module.exports = ({ superDirname }) => {
10
- return {
11
- test: /\.svg$/i,
12
- use: {
13
- loader: path.resolve(
14
- superDirname,
15
- './build-system/loaders/svg-loader'
16
- )
17
- }
18
- };
19
- };
@@ -1,17 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- module.exports.fileName = ({ argv, ES, isTest, excludeLangs, uglify }) => {
8
- if (argv.filename) {
9
- return argv.filename;
10
- }
11
-
12
- return name =>
13
- name +
14
- (ES === 'es5' || isTest ? '' : '.' + ES) +
15
- (excludeLangs ? '.en' : '') +
16
- (uglify ? '.min' : '');
17
- };
@@ -1,28 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
- module.exports = class PostBuild {
7
- constructor(fn) {
8
- this.fn = fn;
9
- }
10
-
11
- apply(compiler) {
12
- const handler = stats => {
13
- if (typeof this.fn === 'function') {
14
- try {
15
- this.fn(stats);
16
- } catch (e) {
17
- console.log(e);
18
- }
19
- }
20
- };
21
-
22
- if (compiler.hooks) {
23
- compiler.hooks.done.tap('PostBuild', handler);
24
- } else {
25
- compiler.plugin('done', handler);
26
- }
27
- }
28
- };
@@ -1,53 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- const path = require('path');
8
-
9
- module.exports.variables = (argv, dir) => {
10
- const pkg = require(path.resolve(dir, './package.json'));
11
-
12
- const banner = `/*!
13
- * ${pkg.name} - ${pkg.description}
14
- * Author: ${pkg.author}
15
- * Version: v${pkg.version}
16
- * Url: ${pkg.homepage}
17
- * License(s): ${pkg.license}
18
- */
19
- `;
20
-
21
- const debug = !argv || !argv.mode || !argv.mode.match(/production/);
22
-
23
- const isTest = Boolean(argv && argv.isTest);
24
-
25
- const mode = debug ? 'development' : argv.mode;
26
- const isProd = mode === 'production';
27
- const uglify = !debug && argv && Boolean(argv.uglify);
28
- const excludeLangs = Boolean(argv.excludeLangs) || false;
29
-
30
- const ES = argv && ['es5', 'es2018'].includes(argv.es) ? argv.es : 'es2018';
31
-
32
- const ESNext = ES === 'es2018';
33
- const dirname = dir;
34
- const superDirname = path.resolve(__dirname, '..');
35
- const outputPath = path.join(dir, 'build');
36
-
37
- return {
38
- argv,
39
- superDirname,
40
- outputPath,
41
- banner,
42
- dirname,
43
- pkg,
44
- debug,
45
- isTest,
46
- isProd,
47
- uglify,
48
- excludeLangs,
49
- mode,
50
- ES,
51
- ESNext
52
- };
53
- };
package/composer.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "name": "xdan/jodit",
3
- "description": "Awesome WYSIWYG editor and FileBrowser",
4
- "type": "library",
5
- "license": "MIT",
6
- "authors": [
7
- {
8
- "name": "Chupurnov Valeriy",
9
- "email": "chupurnov@gmail.com"
10
- }
11
- ]
12
- }
package/src/core/ajax.ts DELETED
@@ -1,266 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- import type {
8
- IDictionary,
9
- IRequest,
10
- IViewBased,
11
- AjaxOptions,
12
- IAjax
13
- } from '../types';
14
- import { Config } from '../config';
15
- import {
16
- each,
17
- error,
18
- isPlainObject,
19
- parseQuery,
20
- buildQuery,
21
- isString,
22
- isFunction,
23
- ConfigProto
24
- } from './helpers';
25
-
26
- declare module '../config' {
27
- interface Config {
28
- /**
29
- * A set of key/value pairs that configure the Ajax request. All settings are optional
30
- */
31
- defaultAjaxOptions: AjaxOptions;
32
- }
33
- }
34
-
35
- Config.prototype.defaultAjaxOptions = {
36
- dataType: 'json',
37
- method: 'GET',
38
- url: '',
39
- data: null,
40
- contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
41
-
42
- headers: {
43
- 'X-REQUESTED-WITH': 'XMLHttpRequest' // compatible with jQuery
44
- },
45
-
46
- withCredentials: false,
47
-
48
- xhr(): XMLHttpRequest {
49
- return new XMLHttpRequest();
50
- }
51
- } as AjaxOptions;
52
-
53
- export class Ajax implements IAjax {
54
- static log: IRequest[] = [];
55
-
56
- private readonly xhr!: XMLHttpRequest;
57
-
58
- private successResponseCodes = [200, 201, 202];
59
-
60
- private __buildParams(
61
- obj: string | IDictionary<string | object> | FormData,
62
- prefix?: string
63
- ): string | FormData {
64
- if (isFunction(this.o.queryBuild)) {
65
- return this.o.queryBuild.call(this, obj, prefix);
66
- }
67
-
68
- if (
69
- isString(obj) ||
70
- ((this.j.ow as any).FormData &&
71
- obj instanceof (this.j.ow as any).FormData)
72
- ) {
73
- return obj as string | FormData;
74
- }
75
-
76
- return buildQuery(obj);
77
- }
78
-
79
- status!: number;
80
-
81
- response!: string;
82
-
83
- options: AjaxOptions;
84
- get o(): this['options'] {
85
- return this.options;
86
- }
87
-
88
- /**
89
- * Alias for this.jodit
90
- */
91
- get j(): this['jodit'] {
92
- return this.jodit;
93
- }
94
-
95
- abort(): Ajax {
96
- try {
97
- this.xhr.abort();
98
- } catch {}
99
-
100
- return this;
101
- }
102
-
103
- private resolved = false;
104
- private activated = false;
105
-
106
- send<T = any>(): Promise<T> {
107
- this.activated = true;
108
-
109
- return new Promise(
110
- (
111
- resolve: (this: XMLHttpRequest, resp: T) => any,
112
- reject: (error: Error) => any
113
- ) => {
114
- const __parse = (resp: string): T => {
115
- let result: T | null = null;
116
-
117
- if (this.o.dataType === 'json') {
118
- result = JSON.parse(resp);
119
- }
120
-
121
- if (!result) {
122
- throw error('No JSON format');
123
- }
124
-
125
- return result;
126
- };
127
-
128
- this.xhr.onabort = () => {
129
- reject(error(this.xhr.statusText));
130
- };
131
-
132
- this.xhr.onerror = () => {
133
- reject(error(this.xhr.statusText));
134
- };
135
-
136
- this.xhr.ontimeout = () => {
137
- reject(error(this.xhr.statusText));
138
- };
139
-
140
- this.xhr.onload = () => {
141
- this.response = this.xhr.responseText;
142
- this.status = this.xhr.status;
143
- this.resolved = true;
144
-
145
- resolve.call(this.xhr, __parse(this.response) || ({} as T));
146
- };
147
-
148
- this.xhr.onprogress = (e): void => {
149
- let percentComplete = 0;
150
-
151
- if (e.lengthComputable) {
152
- percentComplete = (e.loaded / e.total) * 100;
153
- }
154
-
155
- this.options.onProgress?.(percentComplete);
156
- };
157
-
158
- this.xhr.onreadystatechange = () => {
159
- this.options.onProgress?.(10);
160
-
161
- if (this.xhr.readyState === XMLHttpRequest.DONE) {
162
- const resp = this.xhr.responseText;
163
-
164
- this.response = resp;
165
- this.status = this.xhr.status;
166
- this.resolved = true;
167
-
168
- if (
169
- this.successResponseCodes.indexOf(this.xhr.status) >
170
- -1
171
- ) {
172
- resolve.call(this.xhr, __parse(resp));
173
- } else {
174
- reject.call(
175
- this.xhr,
176
- error(
177
- this.xhr.statusText ||
178
- this.j.i18n('Connection error!')
179
- )
180
- );
181
- }
182
- }
183
- };
184
-
185
- this.xhr.withCredentials = this.o.withCredentials || false;
186
-
187
- const { url, data, method } = this.prepareRequest();
188
-
189
- this.xhr.open(method, url, true);
190
-
191
- if (this.o.contentType && this.xhr.setRequestHeader) {
192
- this.xhr.setRequestHeader(
193
- 'Content-type',
194
- this.o.contentType
195
- );
196
- }
197
-
198
- if (this.o.headers && this.xhr.setRequestHeader) {
199
- each(this.o.headers, (key, value) => {
200
- this.xhr.setRequestHeader(key, value);
201
- });
202
- }
203
-
204
- // IE
205
- this.j.async.setTimeout(() => {
206
- this.xhr.send(data ? this.__buildParams(data) : undefined);
207
- }, 0);
208
- }
209
- );
210
- }
211
-
212
- prepareRequest(): IRequest {
213
- if (!this.o.url) {
214
- throw error('Need URL for AJAX request');
215
- }
216
-
217
- let url: string = this.o.url;
218
-
219
- const data = this.o.data;
220
- const method = (this.o.method || 'get').toLowerCase();
221
-
222
- if (method === 'get' && data && isPlainObject(data)) {
223
- const qIndex = url.indexOf('?');
224
-
225
- if (qIndex !== -1) {
226
- const urlData = parseQuery(url);
227
-
228
- url =
229
- url.substr(0, qIndex) +
230
- '?' +
231
- buildQuery({ ...urlData, ...(data as IDictionary) });
232
- } else {
233
- url += '?' + buildQuery(this.o.data as IDictionary);
234
- }
235
- }
236
-
237
- const request = {
238
- url,
239
- method,
240
- data
241
- };
242
-
243
- Ajax.log.splice(100);
244
- Ajax.log.push(request);
245
-
246
- return request;
247
- }
248
-
249
- constructor(readonly jodit: IViewBased, options: Partial<AjaxOptions>) {
250
- this.options = ConfigProto(
251
- options || {},
252
- Config.prototype.defaultAjaxOptions
253
- ) as AjaxOptions;
254
-
255
- this.xhr = this.o.xhr ? this.o.xhr() : new XMLHttpRequest();
256
-
257
- jodit && jodit.e && jodit.e.on('beforeDestruct', () => this.abort());
258
- }
259
-
260
- destruct(): void {
261
- if (this.activated && !this.resolved) {
262
- this.abort();
263
- this.resolved = true;
264
- }
265
- }
266
- }
@@ -1,7 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
- import type { IComponent, IDictionary } from './types';
7
- export declare type DecoratorHandler = <T extends IComponent & IDictionary>(target: T, propertyKey: string) => void;
package/src/types/core.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Jodit Editor (https://xdsoft.net/jodit/)
4
- * Released under MIT see LICENSE.txt in the project root for license information.
5
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- //# sourceMappingURL=core.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["core.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}