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.
- package/.github/workflows/tests.yml +23 -0
- package/.idea/dictionaries/v_chupurnov.xml +1 -0
- package/.idea/workspace.xml +295 -286
- package/CHANGELOG.MD +110 -24
- package/README.md +3 -3
- package/build/jodit.css +2 -2
- package/build/jodit.es2018.css +1 -1
- package/build/jodit.es2018.en.css +1 -1
- package/build/jodit.es2018.en.js +329 -210
- package/build/jodit.es2018.en.min.js +1 -1
- package/build/jodit.es2018.js +329 -210
- package/build/jodit.es2018.min.js +1 -1
- package/build/jodit.js +1066 -881
- package/build/jodit.min.css +1 -1
- package/build/jodit.min.js +1 -1
- package/package.json +1 -1
- package/src/core/async.ts +1 -1
- package/src/core/constants.ts +2 -0
- package/src/core/dom.ts +113 -99
- package/src/core/events/{events-native.ts → event-emitter.ts} +14 -9
- package/src/core/events/index.ts +1 -1
- package/src/core/global.ts +2 -2
- package/src/core/helpers/array/to-array.ts +1 -0
- package/src/core/helpers/data-bind.ts +2 -2
- package/src/core/helpers/utils/utils.ts +20 -4
- package/src/core/request/ajax.ts +212 -0
- package/src/core/request/config.ts +37 -0
- package/{build-system/minimizer/index.js → src/core/request/index.ts} +2 -1
- package/src/core/request/response.ts +39 -0
- package/src/core/selection/select.ts +59 -27
- package/src/core/selection/style/api/element-has-same-style.ts +13 -0
- package/src/core/selection/style/api/get-suit-parent.ts +1 -1
- package/src/core/selection/style/api/is-suit-element.ts +24 -4
- package/src/core/selection/style/api/unwrap-children.ts +45 -16
- package/src/core/selection/style/api/wrap-unwrapped-text.ts +28 -23
- package/src/core/selection/style/apply-style.ts +14 -8
- package/src/core/traits/elms.ts +1 -0
- package/src/core/ui/helpers/get-control-type.ts +3 -1
- package/src/core/view/view.ts +3 -3
- package/src/modules/context-menu/context-menu.ts +1 -1
- package/src/modules/file-browser/README.MD +1 -1
- package/src/modules/file-browser/data-provider.ts +22 -42
- package/src/modules/file-browser/file-browser.ts +3 -0
- package/src/modules/index.ts +1 -1
- package/src/modules/table.ts +106 -101
- package/src/modules/uploader/uploader.ts +4 -3
- package/src/plugins/fix/clean-html.ts +37 -16
- package/src/plugins/indent.ts +25 -18
- package/src/plugins/size/resize-handler.ts +1 -1
- package/src/plugins/size/size.ts +1 -3
- package/src/plugins/source/source.ts +1 -1
- package/src/plugins/table/select-cells.ts +23 -5
- package/src/types/ajax.d.ts +15 -6
- package/src/types/async.d.ts +1 -1
- package/src/types/events.d.ts +12 -12
- package/src/types/view.d.ts +2 -2
- package/types/core/async.d.ts +1 -1
- package/types/core/constants.d.ts +1 -0
- package/types/core/dom.d.ts +25 -19
- package/types/core/events/{events-native.d.ts → event-emitter.d.ts} +8 -3
- package/types/core/events/index.d.ts +1 -1
- package/types/core/global.d.ts +2 -2
- package/types/core/helpers/utils/utils.d.ts +12 -4
- package/types/core/{ajax.d.ts → request/ajax.d.ts} +4 -14
- package/types/core/request/config.d.ts +14 -0
- package/{build-system/rules/css.js → types/core/request/index.d.ts} +2 -7
- package/types/core/request/response.d.ts +16 -0
- package/types/core/selection/style/api/element-has-same-style.d.ts +4 -0
- package/types/core/selection/style/api/is-suit-element.d.ts +1 -0
- package/types/core/selection/style/api/wrap-unwrapped-text.d.ts +2 -2
- package/types/core/view/view.d.ts +2 -2
- package/types/modules/file-browser/data-provider.d.ts +1 -1
- package/types/modules/index.d.ts +1 -1
- package/types/plugins/fix/clean-html.d.ts +4 -0
- package/types/plugins/size/resize-handler.d.ts +1 -1
- package/types/plugins/source/source.d.ts +1 -1
- package/types/types/ajax.d.ts +15 -6
- package/types/types/async.d.ts +1 -1
- package/types/types/events.d.ts +12 -12
- package/types/types/view.d.ts +2 -2
- package/.editorconfig +0 -15
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -109
- package/.prettierrc.json +0 -9
- package/.stylelintrc +0 -17
- package/app.css +0 -112
- package/build-system/index.js +0 -78
- package/build-system/loaders/css-variables-prefixes.js +0 -12
- package/build-system/loaders/lang-loader.js +0 -57
- package/build-system/loaders/style.js +0 -31
- package/build-system/loaders/svg-loader.js +0 -21
- package/build-system/minimizer/css.js +0 -20
- package/build-system/minimizer/js.js +0 -41
- package/build-system/plugins/banner.js +0 -15
- package/build-system/plugins/define.js +0 -22
- package/build-system/plugins/extract-css.js +0 -14
- package/build-system/plugins/index.js +0 -31
- package/build-system/plugins/post-build.js +0 -52
- package/build-system/rules/extra-typescript.js +0 -22
- package/build-system/rules/index.js +0 -17
- package/build-system/rules/internal-typescript.js +0 -23
- package/build-system/rules/langs.js +0 -20
- package/build-system/rules/svg.js +0 -19
- package/build-system/utils/filename.js +0 -17
- package/build-system/utils/post-build.js +0 -28
- package/build-system/variables.js +0 -53
- package/composer.json +0 -12
- package/src/core/ajax.ts +0 -266
- package/src/types/core.d.ts +0 -7
- package/src/types/core.js +0 -8
- package/src/types/core.js.map +0 -1
- package/src/types/storage.d.ts +0 -13
- package/src/types/storage.js +0 -8
- package/src/types/storage.js.map +0 -1
- package/types/types/core.js +0 -8
- package/types/types/core.js.map +0 -1
- package/types/types/storage.js +0 -8
- package/types/types/storage.js.map +0 -1
|
@@ -0,0 +1,37 @@
|
|
|
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 { AjaxOptions } from '../../types';
|
|
8
|
+
import { Config } from '../../config';
|
|
9
|
+
|
|
10
|
+
declare module '../../config' {
|
|
11
|
+
interface Config {
|
|
12
|
+
/**
|
|
13
|
+
* A set of key/value pairs that configure the Ajax request. All settings are optional
|
|
14
|
+
*/
|
|
15
|
+
defaultAjaxOptions: AjaxOptions;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Config.prototype.defaultAjaxOptions = {
|
|
20
|
+
successStatuses: [200, 201, 202],
|
|
21
|
+
|
|
22
|
+
dataType: 'json',
|
|
23
|
+
method: 'GET',
|
|
24
|
+
url: '',
|
|
25
|
+
data: null,
|
|
26
|
+
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
|
|
27
|
+
|
|
28
|
+
headers: {
|
|
29
|
+
'X-REQUESTED-WITH': 'XMLHttpRequest' // compatible with jQuery
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
withCredentials: false,
|
|
33
|
+
|
|
34
|
+
xhr(): XMLHttpRequest {
|
|
35
|
+
return new XMLHttpRequest();
|
|
36
|
+
}
|
|
37
|
+
} as AjaxOptions;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { IRequest, IResponse } from '../../types';
|
|
8
|
+
|
|
9
|
+
export class Response<T> implements IResponse<T> {
|
|
10
|
+
readonly status: number;
|
|
11
|
+
readonly statusText: string;
|
|
12
|
+
|
|
13
|
+
readonly request: IRequest;
|
|
14
|
+
get url(): string {
|
|
15
|
+
return this.request.url;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private readonly body: string;
|
|
19
|
+
|
|
20
|
+
constructor(
|
|
21
|
+
request: IRequest,
|
|
22
|
+
status: number,
|
|
23
|
+
statusText: string,
|
|
24
|
+
body: string
|
|
25
|
+
) {
|
|
26
|
+
this.request = request;
|
|
27
|
+
this.status = status;
|
|
28
|
+
this.statusText = statusText;
|
|
29
|
+
this.body = body;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async json(): Promise<T> {
|
|
33
|
+
return JSON.parse(this.body);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
text(): Promise<string> {
|
|
37
|
+
return Promise.resolve(this.body);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -760,42 +760,74 @@ export class Select implements ISelect {
|
|
|
760
760
|
if (sel && sel.rangeCount) {
|
|
761
761
|
const range = sel.getRangeAt(0);
|
|
762
762
|
|
|
763
|
+
let root = range.commonAncestorContainer;
|
|
764
|
+
|
|
765
|
+
if (!Dom.isHTMLElement(root)) {
|
|
766
|
+
root = root.parentElement as HTMLElement;
|
|
767
|
+
}
|
|
768
|
+
|
|
763
769
|
const nodes: Node[] = [],
|
|
764
770
|
startOffset = range.startOffset,
|
|
765
|
-
length =
|
|
766
|
-
elementOffset = startOffset < length ? startOffset : length - 1
|
|
767
|
-
|
|
771
|
+
length = root.childNodes.length,
|
|
772
|
+
elementOffset = startOffset < length ? startOffset : length - 1;
|
|
773
|
+
|
|
774
|
+
let start: Node =
|
|
768
775
|
range.startContainer === this.area
|
|
769
|
-
?
|
|
776
|
+
? root.childNodes[elementOffset]
|
|
770
777
|
: range.startContainer,
|
|
771
778
|
end: Node =
|
|
772
779
|
range.endContainer === this.area
|
|
773
|
-
?
|
|
780
|
+
? root.childNodes[range.endOffset - 1]
|
|
774
781
|
: range.endContainer;
|
|
775
782
|
|
|
776
|
-
|
|
777
|
-
start
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
) {
|
|
785
|
-
nodes.push(node);
|
|
786
|
-
}
|
|
783
|
+
if (
|
|
784
|
+
Dom.isText(start) &&
|
|
785
|
+
start === range.startContainer &&
|
|
786
|
+
range.startOffset === start.nodeValue?.length &&
|
|
787
|
+
start.nextSibling
|
|
788
|
+
) {
|
|
789
|
+
start = start.nextSibling;
|
|
790
|
+
}
|
|
787
791
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
792
|
+
if (
|
|
793
|
+
Dom.isText(end) &&
|
|
794
|
+
end === range.endContainer &&
|
|
795
|
+
range.endOffset === 0 &&
|
|
796
|
+
end.previousSibling
|
|
797
|
+
) {
|
|
798
|
+
end = end.previousSibling;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
const checkElm = (node: Nullable<Node>) => {
|
|
802
|
+
if (
|
|
803
|
+
node &&
|
|
804
|
+
node !== root &&
|
|
805
|
+
!Dom.isEmptyTextNode(node) &&
|
|
806
|
+
!Select.isMarker(node as HTMLElement)
|
|
807
|
+
) {
|
|
808
|
+
nodes.push(node);
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
checkElm(start);
|
|
813
|
+
|
|
814
|
+
if (start !== end) {
|
|
815
|
+
Dom.find(
|
|
816
|
+
start,
|
|
817
|
+
node => {
|
|
818
|
+
checkElm(node);
|
|
819
|
+
|
|
820
|
+
// checks parentElement as well because partial selections are not equal to entire element
|
|
821
|
+
return (
|
|
822
|
+
node === end ||
|
|
823
|
+
(node && node.contains && node.contains(end))
|
|
824
|
+
);
|
|
825
|
+
},
|
|
826
|
+
<HTMLElement>root,
|
|
827
|
+
true,
|
|
828
|
+
false
|
|
829
|
+
);
|
|
830
|
+
}
|
|
799
831
|
|
|
800
832
|
const forEvery = (current: Node): void => {
|
|
801
833
|
if (!Dom.isOrContains(this.j.editor, current, true)) {
|
|
@@ -29,3 +29,16 @@ export function elementHasSameStyle(elm: Node, rules: IStyle): boolean {
|
|
|
29
29
|
})
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Element has the similar styles
|
|
35
|
+
*/
|
|
36
|
+
export function elementHasSameStyleKeys(elm: Node, rules: IStyle): boolean {
|
|
37
|
+
return Boolean(
|
|
38
|
+
!Dom.isTag(elm, 'font') &&
|
|
39
|
+
Dom.isHTMLElement(elm) &&
|
|
40
|
+
Object.keys(rules).every(
|
|
41
|
+
property => !isVoid(css(elm, property, true))
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -25,7 +25,7 @@ export function getSuitParent(
|
|
|
25
25
|
const { parentNode } = node;
|
|
26
26
|
|
|
27
27
|
if (
|
|
28
|
-
parentNode &&
|
|
28
|
+
Dom.isHTMLElement(parentNode) &&
|
|
29
29
|
!Dom.next(node, isNormalNode, parentNode) &&
|
|
30
30
|
!Dom.prev(node, isNormalNode, parentNode) &&
|
|
31
31
|
isSuitElement(style, parentNode, false) &&
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
import type { Nullable } from '../../../../types';
|
|
7
7
|
import type { CommitStyle } from '../commit-style';
|
|
8
8
|
import { isNormalNode } from './is-normal-node';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
elementHasSameStyle,
|
|
11
|
+
elementHasSameStyleKeys
|
|
12
|
+
} from './element-has-same-style';
|
|
10
13
|
import { Dom } from '../../../dom';
|
|
11
14
|
|
|
12
15
|
/**
|
|
@@ -42,9 +45,26 @@ export function isSuitElement(
|
|
|
42
45
|
return true;
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
return Boolean(
|
|
49
|
+
!elmIsSame && !strict && elementIsDefault && Dom.isInlineBlock(elm)
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function isSameStyleChild(
|
|
54
|
+
commitStyle: CommitStyle,
|
|
55
|
+
elm: Nullable<Node>
|
|
56
|
+
): elm is HTMLElement {
|
|
57
|
+
const { element, options } = commitStyle;
|
|
58
|
+
|
|
59
|
+
if (!elm || !isNormalNode(elm)) {
|
|
60
|
+
return false;
|
|
47
61
|
}
|
|
48
62
|
|
|
49
|
-
|
|
63
|
+
const elmIsSame = elm.nodeName.toLowerCase() === element;
|
|
64
|
+
|
|
65
|
+
const elmHasSameStyle = Boolean(
|
|
66
|
+
options.style && elementHasSameStyleKeys(elm, options.style)
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return elmIsSame && elmHasSameStyle;
|
|
50
70
|
}
|
|
@@ -6,39 +6,68 @@
|
|
|
6
6
|
|
|
7
7
|
import type { CommitStyle } from '../commit-style';
|
|
8
8
|
import { Dom } from '../../../dom';
|
|
9
|
-
import { isSuitElement } from './is-suit-element';
|
|
9
|
+
import { isSameStyleChild, isSuitElement } from './is-suit-element';
|
|
10
|
+
import { attr, css } from '../../../helpers';
|
|
11
|
+
import type { IDictionary } from '../../../../types';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Unwrap all suit elements inside
|
|
13
15
|
*/
|
|
14
16
|
export function unwrapChildren(style: CommitStyle, font: HTMLElement): boolean {
|
|
15
17
|
const needUnwrap: Node[] = [];
|
|
18
|
+
const needChangeStyle: any[] = [];
|
|
16
19
|
|
|
17
20
|
let firstElementSuit: boolean | undefined;
|
|
18
21
|
|
|
22
|
+
const cssStyle = style.options.style;
|
|
23
|
+
|
|
19
24
|
if (font.firstChild) {
|
|
20
|
-
Dom.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const gen = Dom.eachGen(font);
|
|
26
|
+
|
|
27
|
+
let item = gen.next();
|
|
28
|
+
|
|
29
|
+
while (!item.done) {
|
|
30
|
+
const elm = item.value;
|
|
31
|
+
|
|
32
|
+
if (isSuitElement(style, elm as HTMLElement, true)) {
|
|
33
|
+
if (firstElementSuit === undefined) {
|
|
34
|
+
firstElementSuit = true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
needUnwrap.push(elm);
|
|
38
|
+
} else if (cssStyle && isSameStyleChild(style, elm)) {
|
|
39
|
+
if (firstElementSuit === undefined) {
|
|
40
|
+
firstElementSuit = false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
needChangeStyle.push(() => {
|
|
44
|
+
css(
|
|
45
|
+
elm,
|
|
46
|
+
Object.keys(cssStyle).reduce((acc, key) => {
|
|
47
|
+
acc[key] = null;
|
|
48
|
+
return acc;
|
|
49
|
+
}, <IDictionary>{})
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
if (!attr(elm, 'style')) {
|
|
53
|
+
attr(elm, 'style', null);
|
|
26
54
|
}
|
|
27
55
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (firstElementSuit === undefined) {
|
|
31
|
-
firstElementSuit = false;
|
|
56
|
+
if (elm.nodeName.toLowerCase() === style.element) {
|
|
57
|
+
needUnwrap.push(elm);
|
|
32
58
|
}
|
|
59
|
+
});
|
|
60
|
+
} else if (!Dom.isEmptyTextNode(elm)) {
|
|
61
|
+
if (firstElementSuit === undefined) {
|
|
62
|
+
firstElementSuit = false;
|
|
33
63
|
}
|
|
64
|
+
}
|
|
34
65
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
font,
|
|
38
|
-
true
|
|
39
|
-
);
|
|
66
|
+
item = gen.next();
|
|
67
|
+
}
|
|
40
68
|
}
|
|
41
69
|
|
|
70
|
+
needChangeStyle.forEach(clb => clb());
|
|
42
71
|
needUnwrap.forEach(Dom.unwrap);
|
|
43
72
|
|
|
44
73
|
return Boolean(firstElementSuit);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type { IJodit, Nullable } from '../../../../types';
|
|
8
8
|
import type { CommitStyle } from '../commit-style';
|
|
9
9
|
import { Dom } from '../../../dom';
|
|
10
10
|
import { postProcessListElement } from './post-process-list-element';
|
|
@@ -15,35 +15,40 @@ import { postProcessListElement } from './post-process-list-element';
|
|
|
15
15
|
export function wrapUnwrappedText(
|
|
16
16
|
style: CommitStyle,
|
|
17
17
|
elm: Node,
|
|
18
|
-
|
|
19
|
-
ci: ICreate,
|
|
18
|
+
jodit: IJodit,
|
|
20
19
|
getRange: () => Range
|
|
21
20
|
): HTMLElement {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const root = jodit.editor,
|
|
22
|
+
ci = jodit.createInside,
|
|
23
|
+
edge = (n: Node, key: keyof Node = 'previousSibling') => {
|
|
24
|
+
let edgeNode: Node = n,
|
|
25
|
+
node: Nullable<Node> = n;
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
while (node) {
|
|
28
|
+
if (Dom.isTag(node, jodit.o.enter)) {
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
edgeNode = node;
|
|
33
|
+
|
|
34
|
+
if (node[key]) {
|
|
35
|
+
node = node[key] as Nullable<Node>;
|
|
36
|
+
} else {
|
|
37
|
+
node =
|
|
38
|
+
node.parentNode &&
|
|
39
|
+
!Dom.isBlock(node.parentNode) &&
|
|
40
|
+
node.parentNode !== root
|
|
41
|
+
? node.parentNode
|
|
42
|
+
: null;
|
|
43
|
+
}
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
if (Dom.isBlock(node)) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
42
48
|
}
|
|
43
|
-
}
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
return edgeNode;
|
|
51
|
+
};
|
|
47
52
|
|
|
48
53
|
const start: Node = edge(elm),
|
|
49
54
|
end: Node = edge(elm, 'nextSibling');
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type { IJodit, Nullable } from '../../../types';
|
|
8
8
|
import type { CommitStyle } from './commit-style';
|
|
9
9
|
import { Dom } from '../../dom';
|
|
10
10
|
import { attr, css, normalizeNode } from '../../helpers';
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
* Apply options to selection
|
|
24
24
|
*/
|
|
25
25
|
export function ApplyStyle(jodit: IJodit, style: CommitStyle): void {
|
|
26
|
-
const { s: sel
|
|
26
|
+
const { s: sel } = jodit,
|
|
27
27
|
rng = () => sel.createRange();
|
|
28
28
|
|
|
29
29
|
let wrap: Nullable<boolean> = null;
|
|
@@ -36,7 +36,7 @@ export function ApplyStyle(jodit: IJodit, style: CommitStyle): void {
|
|
|
36
36
|
let font = gen.next();
|
|
37
37
|
|
|
38
38
|
while (!font.done) {
|
|
39
|
-
wrap = applyToElement(style, font.value,
|
|
39
|
+
wrap = applyToElement(style, font.value, rng, jodit, wrap);
|
|
40
40
|
font = gen.next();
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -50,11 +50,12 @@ export function ApplyStyle(jodit: IJodit, style: CommitStyle): void {
|
|
|
50
50
|
function applyToElement(
|
|
51
51
|
style: CommitStyle,
|
|
52
52
|
font: HTMLElement,
|
|
53
|
-
root: HTMLElement,
|
|
54
53
|
range: () => Range,
|
|
55
|
-
|
|
54
|
+
jodit: IJodit,
|
|
56
55
|
wrap: Nullable<boolean>
|
|
57
56
|
): Nullable<boolean> {
|
|
57
|
+
const root = jodit.editor;
|
|
58
|
+
|
|
58
59
|
if (checkSpecialElements(font, root)) {
|
|
59
60
|
return wrap;
|
|
60
61
|
}
|
|
@@ -105,16 +106,21 @@ function applyToElement(
|
|
|
105
106
|
if (box) {
|
|
106
107
|
wrapper = box;
|
|
107
108
|
} else {
|
|
108
|
-
wrapper = wrapUnwrappedText(style, font,
|
|
109
|
+
wrapper = wrapUnwrappedText(style, font, jodit, range);
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
const newWrapper = Dom.replace(
|
|
113
|
+
const newWrapper = Dom.replace(
|
|
114
|
+
wrapper,
|
|
115
|
+
style.element,
|
|
116
|
+
jodit.createInside,
|
|
117
|
+
true
|
|
118
|
+
);
|
|
113
119
|
|
|
114
120
|
attr(newWrapper, 'size', null);
|
|
115
121
|
|
|
116
122
|
if (style.elementIsBlock) {
|
|
117
|
-
postProcessListElement(style, newWrapper,
|
|
123
|
+
postProcessListElement(style, newWrapper, jodit.createInside);
|
|
118
124
|
}
|
|
119
125
|
|
|
120
126
|
if (style.options.style && style.elementIsDefault) {
|
package/src/core/traits/elms.ts
CHANGED
|
@@ -23,7 +23,9 @@ export function getControlType(
|
|
|
23
23
|
): IControlTypeStrong {
|
|
24
24
|
let buttonControl: IControlTypeStrong;
|
|
25
25
|
|
|
26
|
-
if (!controls)
|
|
26
|
+
if (!controls) {
|
|
27
|
+
controls = Config.defaultOptions.controls;
|
|
28
|
+
}
|
|
27
29
|
|
|
28
30
|
if (!isString(button)) {
|
|
29
31
|
buttonControl = { name: 'empty', ...ConfigFlatten(button) };
|
package/src/core/view/view.ts
CHANGED
|
@@ -29,7 +29,7 @@ import { BASE_PATH } from '../constants';
|
|
|
29
29
|
import {
|
|
30
30
|
Component,
|
|
31
31
|
STATUSES,
|
|
32
|
-
|
|
32
|
+
EventEmitter,
|
|
33
33
|
ProgressBar,
|
|
34
34
|
Create,
|
|
35
35
|
Dom,
|
|
@@ -124,7 +124,7 @@ export abstract class View extends Component implements IViewBased, Mods, Elms {
|
|
|
124
124
|
this.__container = container;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
events!:
|
|
127
|
+
events!: EventEmitter;
|
|
128
128
|
get e(): this['events'] {
|
|
129
129
|
return this.events;
|
|
130
130
|
}
|
|
@@ -269,7 +269,7 @@ export abstract class View extends Component implements IViewBased, Mods, Elms {
|
|
|
269
269
|
this.initOptions(options);
|
|
270
270
|
this.initOwners();
|
|
271
271
|
|
|
272
|
-
this.events = new
|
|
272
|
+
this.events = new EventEmitter(this.od);
|
|
273
273
|
this.create = new Create(this.od);
|
|
274
274
|
|
|
275
275
|
this.container = this.c.div();
|
|
@@ -37,7 +37,7 @@ export class ContextMenu extends Popup implements IContextMenu {
|
|
|
37
37
|
actions: Array<false | IContextMenuAction>
|
|
38
38
|
): void {
|
|
39
39
|
const self = this,
|
|
40
|
-
content = this.j.c.div('
|
|
40
|
+
content = this.j.c.div(this.getFullElName('actions'));
|
|
41
41
|
|
|
42
42
|
if (!isArray(actions)) {
|
|
43
43
|
return;
|
|
@@ -97,7 +97,7 @@ Jodit.make('#editor', {
|
|
|
97
97
|
- filebrowser.ajax.headers={} An object of additional header key/value pairs toWYSIWYG
|
|
98
98
|
send along with requests using the `XMLHttpRequest` transport. The header `X-Requested-With: XMLHttpRequest`
|
|
99
99
|
is always added, but its default `XMLHttpRequest` value can be changed here.
|
|
100
|
-
@property {object} filebrowser.resize Settings for AJAX connections toWYSIWYG the server toWYSIWYG resize
|
|
100
|
+
@property {object} `filebrowser.resize` Settings for AJAX connections toWYSIWYG the server toWYSIWYG resize
|
|
101
101
|
image. By default, the uses {@link Jodit.defaultOptions.filebrowser.ajax|filebrowser.ajax} with argument
|
|
102
102
|
action=create
|
|
103
103
|
- filebrowser.crop Settings for AJAX connections toWYSIWYG the server toWYSIWYG crop image.
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
normalizeRelativePath,
|
|
30
30
|
set
|
|
31
31
|
} from '../../core/helpers';
|
|
32
|
-
import { Ajax } from '../../core/
|
|
32
|
+
import { Ajax } from '../../core/request';
|
|
33
33
|
import { autobind } from '../../core/decorators';
|
|
34
34
|
import { FileBrowserItem } from './builders/item';
|
|
35
35
|
|
|
@@ -66,12 +66,10 @@ export default class DataProvider implements IFileBrowserDataProvider {
|
|
|
66
66
|
return this.options;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
private ajaxInstances: Map<string, IAjax
|
|
69
|
+
private ajaxInstances: Map<string, IAjax<IFileBrowserAnswer>> = new Map();
|
|
70
70
|
|
|
71
|
-
protected get<T = IFileBrowserAnswer>(
|
|
72
|
-
name: keyof IFileBrowserOptions
|
|
73
|
-
success?: (resp: IFileBrowserAnswer) => void,
|
|
74
|
-
error?: (error: Error) => void
|
|
71
|
+
protected get<T extends IFileBrowserAnswer = IFileBrowserAnswer>(
|
|
72
|
+
name: keyof IFileBrowserOptions
|
|
75
73
|
): Promise<T> {
|
|
76
74
|
const ai = this.ajaxInstances;
|
|
77
75
|
|
|
@@ -98,33 +96,27 @@ export default class DataProvider implements IFileBrowserDataProvider {
|
|
|
98
96
|
opts.data = opts.prepareData.call(this, opts.data as IDictionary);
|
|
99
97
|
}
|
|
100
98
|
|
|
101
|
-
const ajax = new Ajax(this.parent, opts);
|
|
102
|
-
|
|
103
|
-
let promise = ajax.send();
|
|
104
|
-
|
|
99
|
+
const ajax = new Ajax<T>(this.parent, opts);
|
|
105
100
|
ai.set(name, ajax);
|
|
106
101
|
|
|
107
|
-
promise =
|
|
108
|
-
if (!this.isSuccess(resp)) {
|
|
109
|
-
throw new Error(this.getMessage(resp));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return resp;
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
if (success) {
|
|
116
|
-
promise = promise.then(success);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (error) {
|
|
120
|
-
promise = promise.catch(error);
|
|
121
|
-
}
|
|
102
|
+
const promise = ajax.send();
|
|
122
103
|
|
|
123
|
-
|
|
104
|
+
promise.finally(() => {
|
|
124
105
|
ajax.destruct();
|
|
125
106
|
ai.delete(name);
|
|
107
|
+
|
|
126
108
|
this.progressHandler(100);
|
|
127
109
|
});
|
|
110
|
+
|
|
111
|
+
return promise
|
|
112
|
+
.then(resp => resp.json())
|
|
113
|
+
.then(resp => {
|
|
114
|
+
if (resp && !this.isSuccess(resp)) {
|
|
115
|
+
throw new Error(this.getMessage(resp));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return resp;
|
|
119
|
+
});
|
|
128
120
|
}
|
|
129
121
|
|
|
130
122
|
private progressHandler = (ignore: number): void => {};
|
|
@@ -297,7 +289,7 @@ export default class DataProvider implements IFileBrowserDataProvider {
|
|
|
297
289
|
getPathByUrl(url: string): Promise<any> {
|
|
298
290
|
set('options.getLocalFileByUrl.data.url', url, this);
|
|
299
291
|
|
|
300
|
-
return this.get('getLocalFileByUrl'
|
|
292
|
+
return this.get('getLocalFileByUrl').then(resp => {
|
|
301
293
|
if (this.isSuccess(resp)) {
|
|
302
294
|
return resp.data;
|
|
303
295
|
}
|
|
@@ -396,10 +388,6 @@ export default class DataProvider implements IFileBrowserDataProvider {
|
|
|
396
388
|
resp = fr.process.call(this, resp);
|
|
397
389
|
}
|
|
398
390
|
|
|
399
|
-
if (!this.isSuccess(resp)) {
|
|
400
|
-
throw error(this.getMessage(resp));
|
|
401
|
-
}
|
|
402
|
-
|
|
403
391
|
return this.getMessage(resp);
|
|
404
392
|
});
|
|
405
393
|
}
|
|
@@ -457,10 +445,6 @@ export default class DataProvider implements IFileBrowserDataProvider {
|
|
|
457
445
|
resp = fr.process.call(self, resp);
|
|
458
446
|
}
|
|
459
447
|
|
|
460
|
-
if (!this.isSuccess(resp)) {
|
|
461
|
-
throw error(this.getMessage(resp));
|
|
462
|
-
}
|
|
463
|
-
|
|
464
448
|
return this.getMessage(resp);
|
|
465
449
|
});
|
|
466
450
|
}
|
|
@@ -496,7 +480,7 @@ export default class DataProvider implements IFileBrowserDataProvider {
|
|
|
496
480
|
name: string,
|
|
497
481
|
newname: string | void,
|
|
498
482
|
box: ImageBox | void
|
|
499
|
-
): Promise<
|
|
483
|
+
): Promise<true> {
|
|
500
484
|
if (!this.o[type]) {
|
|
501
485
|
this.o[type] = {
|
|
502
486
|
data: {}
|
|
@@ -522,12 +506,8 @@ export default class DataProvider implements IFileBrowserDataProvider {
|
|
|
522
506
|
query.data.name = name;
|
|
523
507
|
query.data.source = source;
|
|
524
508
|
|
|
525
|
-
return this.get(type).then(
|
|
526
|
-
|
|
527
|
-
return true;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
throw error(this.getMessage(resp));
|
|
509
|
+
return this.get(type).then(() => {
|
|
510
|
+
return true;
|
|
531
511
|
});
|
|
532
512
|
}
|
|
533
513
|
|