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
package/src/plugins/indent.ts
CHANGED
|
@@ -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 { IControlType,
|
|
7
|
+
import type { IControlType, IJodit } from '../types/';
|
|
8
8
|
import { Config } from '../config';
|
|
9
9
|
import { BR, PARAGRAPH } from '../core/constants';
|
|
10
10
|
import { Dom } from '../core/dom';
|
|
@@ -17,8 +17,13 @@ Config.prototype.controls.indent = {
|
|
|
17
17
|
/**
|
|
18
18
|
* Get style rule key for current direction
|
|
19
19
|
*/
|
|
20
|
-
const getKey = (
|
|
21
|
-
direction
|
|
20
|
+
const getKey = (
|
|
21
|
+
direction: string,
|
|
22
|
+
box: HTMLElement
|
|
23
|
+
): 'marginLeft' | 'marginRight' | 'paddingLeft' | 'paddingRight' =>
|
|
24
|
+
`${Dom.isCell(box) ? 'padding' : 'margin'}${
|
|
25
|
+
direction === 'rtl' ? 'Right' : 'Left'
|
|
26
|
+
}`;
|
|
22
27
|
|
|
23
28
|
Config.prototype.controls.outdent = {
|
|
24
29
|
isDisabled: (editor: IJodit): boolean => {
|
|
@@ -27,10 +32,12 @@ Config.prototype.controls.outdent = {
|
|
|
27
32
|
if (current) {
|
|
28
33
|
const currentBox = Dom.closest(current, Dom.isBlock, editor.editor);
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
if (currentBox) {
|
|
36
|
+
const arrow = getKey(editor.o.direction, currentBox);
|
|
37
|
+
return (
|
|
38
|
+
!currentBox.style[arrow] ||
|
|
39
|
+
parseInt(currentBox.style[arrow], 10) <= 0
|
|
40
|
+
);
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
|
|
@@ -54,8 +61,6 @@ Config.prototype.indentMargin = 10;
|
|
|
54
61
|
* Indents the line containing the selection or insertion point.
|
|
55
62
|
*/
|
|
56
63
|
export function indent(editor: IJodit): void {
|
|
57
|
-
const key = getKey(editor.o.direction);
|
|
58
|
-
|
|
59
64
|
editor
|
|
60
65
|
.registerButton({
|
|
61
66
|
name: 'indent',
|
|
@@ -67,21 +72,21 @@ export function indent(editor: IJodit): void {
|
|
|
67
72
|
});
|
|
68
73
|
|
|
69
74
|
const callback = (command: string): void | false => {
|
|
70
|
-
const
|
|
75
|
+
const processedElements: HTMLElement[] = [];
|
|
71
76
|
|
|
72
|
-
editor.s.eachSelection((current
|
|
77
|
+
editor.s.eachSelection((current): false | void => {
|
|
73
78
|
editor.s.save();
|
|
74
79
|
|
|
75
80
|
let currentBox = current
|
|
76
|
-
?
|
|
81
|
+
? Dom.up(current, Dom.isBlock, editor.editor)
|
|
77
82
|
: false;
|
|
78
83
|
|
|
79
|
-
const enter = editor.o
|
|
84
|
+
const { enter } = editor.o;
|
|
80
85
|
|
|
81
86
|
if (!currentBox && current) {
|
|
82
87
|
currentBox = Dom.wrapInline(
|
|
83
88
|
current,
|
|
84
|
-
enter !== BR ?
|
|
89
|
+
enter !== BR ? enter : PARAGRAPH,
|
|
85
90
|
editor
|
|
86
91
|
);
|
|
87
92
|
}
|
|
@@ -91,10 +96,12 @@ export function indent(editor: IJodit): void {
|
|
|
91
96
|
return false;
|
|
92
97
|
}
|
|
93
98
|
|
|
94
|
-
const alreadyIndented =
|
|
99
|
+
const alreadyIndented = processedElements.includes(currentBox);
|
|
100
|
+
|
|
101
|
+
if (currentBox && !alreadyIndented) {
|
|
102
|
+
const key = getKey(editor.o.direction, currentBox);
|
|
95
103
|
|
|
96
|
-
|
|
97
|
-
indentedBoxes.push(currentBox);
|
|
104
|
+
processedElements.push(currentBox);
|
|
98
105
|
|
|
99
106
|
let value = currentBox.style[key]
|
|
100
107
|
? parseInt(currentBox.style[key], 10)
|
|
@@ -106,7 +113,7 @@ export function indent(editor: IJodit): void {
|
|
|
106
113
|
currentBox.style[key] = value > 0 ? value + 'px' : '';
|
|
107
114
|
|
|
108
115
|
if (!attr(currentBox, 'style')) {
|
|
109
|
-
currentBox
|
|
116
|
+
attr(currentBox, 'style', null);
|
|
110
117
|
}
|
|
111
118
|
}
|
|
112
119
|
|
|
@@ -118,7 +118,7 @@ export class resizeHandler extends Plugin {
|
|
|
118
118
|
);
|
|
119
119
|
|
|
120
120
|
/** @override **/
|
|
121
|
-
protected beforeDestruct(
|
|
121
|
+
protected beforeDestruct(): void {
|
|
122
122
|
Dom.safeRemove(this.handle);
|
|
123
123
|
|
|
124
124
|
this.j.e.off(this.j.ow, 'mouseup touchsend', this.onHandleResizeEnd);
|
package/src/plugins/size/size.ts
CHANGED
|
@@ -184,8 +184,6 @@ export class size extends Plugin {
|
|
|
184
184
|
|
|
185
185
|
/** @override **/
|
|
186
186
|
protected beforeDestruct(jodit: IJodit): void {
|
|
187
|
-
this.
|
|
188
|
-
.off(this.j.ow, 'load.size', this.resizeWorkspaces)
|
|
189
|
-
.off('.size');
|
|
187
|
+
jodit.e.off(jodit.ow, 'load.size', this.resizeWorkspaces).off('.size');
|
|
190
188
|
}
|
|
191
189
|
}
|
|
@@ -357,14 +357,32 @@ export class selectCells extends Plugin {
|
|
|
357
357
|
break;
|
|
358
358
|
|
|
359
359
|
case 'binrow':
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
360
|
+
new Set(
|
|
361
|
+
cells.map(
|
|
362
|
+
td => td.parentNode as HTMLTableRowElement
|
|
363
|
+
)
|
|
364
|
+
).forEach(row => {
|
|
365
|
+
Table.removeRow(table, row.rowIndex);
|
|
366
|
+
});
|
|
367
|
+
|
|
364
368
|
break;
|
|
365
369
|
|
|
366
370
|
case 'bincolumn':
|
|
367
|
-
|
|
371
|
+
{
|
|
372
|
+
const columnsSet = new Set<number>(),
|
|
373
|
+
columns = cells.reduce((acc, td) => {
|
|
374
|
+
if (!columnsSet.has(td.cellIndex)) {
|
|
375
|
+
acc.push(td);
|
|
376
|
+
columnsSet.add(td.cellIndex);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return acc;
|
|
380
|
+
}, <HTMLTableCellElement[]>[]);
|
|
381
|
+
|
|
382
|
+
columns.forEach(td => {
|
|
383
|
+
Table.removeColumn(table, td.cellIndex);
|
|
384
|
+
});
|
|
385
|
+
}
|
|
368
386
|
break;
|
|
369
387
|
|
|
370
388
|
case 'addcolumnafter':
|
package/src/types/ajax.d.ts
CHANGED
|
@@ -20,24 +20,33 @@ export interface IRequest {
|
|
|
20
20
|
data: DataVariant;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export interface IAjax extends IDestructible {
|
|
24
|
-
status: number;
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
export interface IResponse<T> {
|
|
25
|
+
readonly status: number;
|
|
26
|
+
readonly statusText: string;
|
|
27
|
+
readonly url: string;
|
|
28
|
+
readonly request: IRequest;
|
|
27
29
|
|
|
30
|
+
json(): Promise<T>;
|
|
31
|
+
text(): Promise<string>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface IAjax<T> extends IDestructible {
|
|
28
35
|
options: AjaxOptions;
|
|
29
36
|
o: this['options'];
|
|
30
37
|
|
|
31
38
|
jodit: IViewBased;
|
|
32
39
|
|
|
33
|
-
abort(): IAjax
|
|
40
|
+
abort(): IAjax<T>;
|
|
34
41
|
|
|
35
|
-
send(): Promise<
|
|
42
|
+
send(): Promise<IResponse<T>>;
|
|
36
43
|
|
|
37
44
|
prepareRequest(): IRequest;
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
export interface AjaxOptions {
|
|
48
|
+
successStatuses: number[];
|
|
49
|
+
|
|
41
50
|
/**
|
|
42
51
|
* json or text The type of data that you're expecting back
|
|
43
52
|
* from the server. if `json` the return value passes through the `JSON.parse`
|
|
@@ -80,7 +89,7 @@ export interface AjaxOptions {
|
|
|
80
89
|
withCredentials?: boolean;
|
|
81
90
|
|
|
82
91
|
queryBuild?: (
|
|
83
|
-
this: IAjax
|
|
92
|
+
this: IAjax<any>,
|
|
84
93
|
obj: string | IDictionary<string | object> | FormData,
|
|
85
94
|
prefix?: string
|
|
86
95
|
) => string | FormData;
|
package/src/types/async.d.ts
CHANGED
package/src/types/events.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import type { CallbackFunction, IDestructible } from './types';
|
|
10
10
|
|
|
11
|
-
interface
|
|
11
|
+
interface IEventEmitter extends IDestructible {
|
|
12
12
|
/**
|
|
13
13
|
* Get current event name
|
|
14
14
|
*
|
|
@@ -29,7 +29,7 @@ interface IEventsNative extends IDestructible {
|
|
|
29
29
|
/**
|
|
30
30
|
* Doesn't start any handler
|
|
31
31
|
*/
|
|
32
|
-
mute(event?: string):
|
|
32
|
+
mute(event?: string): IEventEmitter;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* No handlers are triggered for the event
|
|
@@ -39,7 +39,7 @@ interface IEventsNative extends IDestructible {
|
|
|
39
39
|
/**
|
|
40
40
|
* Returns event handling
|
|
41
41
|
*/
|
|
42
|
-
unmute(event?: string):
|
|
42
|
+
unmute(event?: string): IEventEmitter;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Sets the handler for the specified event ( Event List ) for a given element .
|
|
@@ -70,30 +70,30 @@ interface IEventsNative extends IDestructible {
|
|
|
70
70
|
handler: CallbackFunction,
|
|
71
71
|
handlerOrSelector?: void,
|
|
72
72
|
onTop?: boolean
|
|
73
|
-
):
|
|
73
|
+
): IEventEmitter;
|
|
74
74
|
|
|
75
75
|
on(
|
|
76
76
|
subject: HTMLElement,
|
|
77
77
|
events: string,
|
|
78
78
|
handler: CallbackFunction,
|
|
79
79
|
onTop?: boolean
|
|
80
|
-
):
|
|
80
|
+
): IEventEmitter;
|
|
81
81
|
|
|
82
82
|
on(
|
|
83
83
|
subject: object,
|
|
84
84
|
events: string,
|
|
85
85
|
handler: CallbackFunction,
|
|
86
86
|
onTop?: boolean
|
|
87
|
-
):
|
|
87
|
+
): IEventEmitter;
|
|
88
88
|
|
|
89
89
|
on(
|
|
90
90
|
subjectOrEvents: object | string,
|
|
91
91
|
eventsOrCallback: string | CallbackFunction,
|
|
92
92
|
handlerOrSelector?: CallbackFunction | void,
|
|
93
93
|
onTop?: boolean
|
|
94
|
-
):
|
|
94
|
+
): IEventEmitter;
|
|
95
95
|
|
|
96
|
-
one(...args: Parameters<
|
|
96
|
+
one(...args: Parameters<IEventEmitter['on']>): IEventEmitter;
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* Disable all handlers specified event ( Event List ) for a given element. Either a specific event handler.
|
|
@@ -129,17 +129,17 @@ interface IEventsNative extends IDestructible {
|
|
|
129
129
|
off(
|
|
130
130
|
subjectOrEvents: string,
|
|
131
131
|
eventsOrCallback?: CallbackFunction
|
|
132
|
-
):
|
|
132
|
+
): IEventEmitter;
|
|
133
133
|
off(
|
|
134
134
|
subjectOrEvents: object,
|
|
135
135
|
eventsOrCallback?: string,
|
|
136
136
|
handler?: CallbackFunction
|
|
137
|
-
):
|
|
137
|
+
): IEventEmitter;
|
|
138
138
|
off(
|
|
139
139
|
subjectOrEvents: object | string,
|
|
140
140
|
eventsOrCallback?: string | (() => void),
|
|
141
141
|
handler?: CallbackFunction
|
|
142
|
-
):
|
|
142
|
+
): IEventEmitter;
|
|
143
143
|
|
|
144
144
|
stopPropagation(
|
|
145
145
|
subjectOrEvents: object | string,
|
|
@@ -163,7 +163,7 @@ interface IEventsNative extends IDestructible {
|
|
|
163
163
|
* ```
|
|
164
164
|
* or you can trigger native browser listener
|
|
165
165
|
* ```javascript
|
|
166
|
-
* var events = new Jodit.modules.
|
|
166
|
+
* var events = new Jodit.modules.EventEmitter();
|
|
167
167
|
* events.on(document.body, 'click',function (event) {
|
|
168
168
|
* alert('click on ' + event.target.id );
|
|
169
169
|
* });
|
package/src/types/view.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import type { Attributes, ICreate } from './create';
|
|
|
18
18
|
import type { IStorage } from './storage';
|
|
19
19
|
import type { IAsync } from './async';
|
|
20
20
|
import type { IUIButtonState } from './ui';
|
|
21
|
-
import type {
|
|
21
|
+
import type { IEventEmitter } from './events';
|
|
22
22
|
import type { IPluginButton } from './plugin';
|
|
23
23
|
import type { Mods, Elms } from '../core/traits';
|
|
24
24
|
|
|
@@ -108,7 +108,7 @@ interface IViewBased<T = IViewOptions>
|
|
|
108
108
|
|
|
109
109
|
progressbar: IProgressBar;
|
|
110
110
|
|
|
111
|
-
events:
|
|
111
|
+
events: IEventEmitter;
|
|
112
112
|
e: this['events'];
|
|
113
113
|
|
|
114
114
|
async: IAsync;
|
package/types/core/async.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare class Async implements IAsync {
|
|
|
38
38
|
*/
|
|
39
39
|
throttle(fn: CallbackFunction, timeout: ITimeout | IAsyncParams, ignore?: boolean): CallbackFunction;
|
|
40
40
|
private promisesRejections;
|
|
41
|
-
promise<T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject
|
|
41
|
+
promise<T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): RejectablePromise<T>;
|
|
42
42
|
/**
|
|
43
43
|
* Get Promise status
|
|
44
44
|
*/
|
package/types/core/dom.d.ts
CHANGED
|
@@ -24,22 +24,6 @@ export declare class Dom {
|
|
|
24
24
|
* Remove parent of node and insert this node instead that parent
|
|
25
25
|
*/
|
|
26
26
|
static unwrap(node: Node): void;
|
|
27
|
-
/**
|
|
28
|
-
* It goes through all the internal elements of the node, causing a callback function
|
|
29
|
-
*
|
|
30
|
-
* @param elm - the element whose children and descendants you want to iterate over
|
|
31
|
-
* @param callback - It called for each item found
|
|
32
|
-
* @example
|
|
33
|
-
* ```javascript
|
|
34
|
-
* Jodit.modules.Dom.each(parent.s.current(), function (node) {
|
|
35
|
-
* if (node.nodeType === Node.TEXT_NODE) {
|
|
36
|
-
* node.nodeValue = node.nodeValue.replace(Jodit.INVISIBLE_SPACE_REG_EX, '') // remove all of
|
|
37
|
-
* the text element codes invisible character
|
|
38
|
-
* }
|
|
39
|
-
* });
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
static each(elm: Node | HTMLElement, callback: (node: Node) => void | boolean): boolean;
|
|
43
27
|
/**
|
|
44
28
|
* Call function for all nodes between `start` and `end`
|
|
45
29
|
*/
|
|
@@ -113,17 +97,39 @@ export declare class Dom {
|
|
|
113
97
|
/**
|
|
114
98
|
* Find previous node
|
|
115
99
|
*/
|
|
116
|
-
static prev(node: Node, condition: NodeCondition, root:
|
|
100
|
+
static prev<T extends Node = Node>(node: Node, condition: NodeCondition, root: HTMLElement, withChild?: boolean): Nullable<T>;
|
|
117
101
|
/**
|
|
118
102
|
* Find next node what `condition(next) === true`
|
|
119
103
|
*/
|
|
120
|
-
static next(node: Node, condition: NodeCondition, root:
|
|
104
|
+
static next<T extends Node = Node>(node: Node, condition: NodeCondition, root: HTMLElement, withChild?: boolean): Nullable<T>;
|
|
121
105
|
static prevWithClass(node: HTMLElement, className: string): Nullable<HTMLElement>;
|
|
122
106
|
static nextWithClass(node: HTMLElement, className: string): Nullable<HTMLElement>;
|
|
123
107
|
/**
|
|
124
108
|
* Find next/prev node what `condition(next) === true`
|
|
125
109
|
*/
|
|
126
|
-
static find(node: Node, condition: NodeCondition, root:
|
|
110
|
+
static find<T extends Node = Node>(node: Node, condition: NodeCondition, root: HTMLElement, leftToRight?: boolean, withChild?: boolean): Nullable<T>;
|
|
111
|
+
/**
|
|
112
|
+
* Find next/prev node what `condition(next) === true`
|
|
113
|
+
*/
|
|
114
|
+
static nextGen(start: Node, root: HTMLElement, leftToRight?: boolean, withChild?: boolean): Generator<Node>;
|
|
115
|
+
/**
|
|
116
|
+
* It goes through all the internal elements of the node, causing a callback function
|
|
117
|
+
*
|
|
118
|
+
* @param elm - the element whose children and descendants you want to iterate over
|
|
119
|
+
* @param callback - It called for each item found
|
|
120
|
+
* @example
|
|
121
|
+
* ```javascript
|
|
122
|
+
* Jodit.modules.Dom.each(parent.s.current(), function (node) {
|
|
123
|
+
* if (node.nodeType === Node.TEXT_NODE) {
|
|
124
|
+
* node.nodeValue = node.nodeValue.replace(Jodit.INVISIBLE_SPACE_REG_EX, '') // remove all of
|
|
125
|
+
* the text element codes invisible character
|
|
126
|
+
* }
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
static each(elm: Node, callback: (node: Node) => void | boolean, leftToRight?: boolean): boolean;
|
|
131
|
+
static eachGen(root: Node, leftToRight?: boolean): Generator<Node>;
|
|
132
|
+
private static runInStack;
|
|
127
133
|
/**
|
|
128
134
|
* Find next/prev node what `condition(next) === true`
|
|
129
135
|
*/
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
4
|
* Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
+
import type { CallbackFunction, IEventEmitter } from '../../types';
|
|
6
7
|
/**
|
|
7
8
|
* The module editor's event manager
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
-
export declare class EventsNative implements IEventsNative {
|
|
10
|
+
export declare class EventEmitter implements IEventEmitter {
|
|
11
11
|
private mutedEvents;
|
|
12
12
|
mute(event?: string): this;
|
|
13
13
|
isMuted(event?: string): boolean;
|
|
@@ -121,7 +121,7 @@ export declare class EventsNative implements IEventsNative {
|
|
|
121
121
|
* ```
|
|
122
122
|
* or you can trigger native browser listener
|
|
123
123
|
* ```javascript
|
|
124
|
-
* var events = new Jodit.modules.
|
|
124
|
+
* var events = new Jodit.modules.EventEmitter();
|
|
125
125
|
* events.on(document.body, 'click',function (event) {
|
|
126
126
|
* alert('click on ' + event.target.id );
|
|
127
127
|
* });
|
|
@@ -135,3 +135,8 @@ export declare class EventsNative implements IEventsNative {
|
|
|
135
135
|
constructor(doc?: Document);
|
|
136
136
|
destruct(): void;
|
|
137
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* @deprecated Use `EventEmitter` instead
|
|
140
|
+
*/
|
|
141
|
+
export declare class EventsNative extends EventEmitter implements IEventEmitter {
|
|
142
|
+
}
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
4
|
* Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './event-emitter';
|
|
7
7
|
export * from './observe-object';
|
|
8
8
|
export * from './store';
|
package/types/core/global.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { HTMLTagNames, IDictionary, IJodit, IViewBased, IViewComponent } from '../types';
|
|
7
7
|
import { PluginSystem } from './plugin-system';
|
|
8
|
-
import {
|
|
8
|
+
import { EventEmitter } from './events';
|
|
9
9
|
export declare const instances: IDictionary<IJodit>;
|
|
10
10
|
/**
|
|
11
11
|
* Generate global unique uid
|
|
@@ -22,4 +22,4 @@ export declare function getContainer<T extends HTMLTagNames = HTMLTagNames>(jodi
|
|
|
22
22
|
/**
|
|
23
23
|
* Global event emitter
|
|
24
24
|
*/
|
|
25
|
-
export declare const eventEmitter:
|
|
25
|
+
export declare const eventEmitter: EventEmitter;
|
|
@@ -15,12 +15,20 @@ import type { CanPromise, IControlType, IDictionary, IViewBased, Nullable, IJodi
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function call<T extends any[], R>(func: (...args: T) => R, ...args: T): R;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
* it will also check `data-{key}` attribute
|
|
20
|
-
* if set `value` it is alias for setAttribute with same logic
|
|
18
|
+
* Get attribute
|
|
21
19
|
*/
|
|
22
20
|
export declare function attr(elm: Element, key: string): null | string;
|
|
23
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Remove attribute
|
|
23
|
+
*/
|
|
24
|
+
export declare function attr(elm: Element, key: string, value: null): null | string;
|
|
25
|
+
/**
|
|
26
|
+
* Set attribute
|
|
27
|
+
*/
|
|
28
|
+
export declare function attr(elm: Element, key: string, value: string | number | boolean | undefined | null): null;
|
|
29
|
+
/**
|
|
30
|
+
* Set or remove several attributes
|
|
31
|
+
*/
|
|
24
32
|
export declare function attr(elm: Element, attributes: IDictionary<string | number | boolean | null>): null;
|
|
25
33
|
/**
|
|
26
34
|
* Mark element for debugging
|
|
@@ -3,23 +3,13 @@
|
|
|
3
3
|
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
4
|
* Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
-
import type { IRequest, IViewBased, AjaxOptions, IAjax } from '
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A set of key/value pairs that configure the Ajax request. All settings are optional
|
|
11
|
-
*/
|
|
12
|
-
defaultAjaxOptions: AjaxOptions;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export declare class Ajax implements IAjax {
|
|
6
|
+
import type { IRequest, IViewBased, AjaxOptions, IAjax, RejectablePromise, IResponse } from '../../types';
|
|
7
|
+
import './config';
|
|
8
|
+
export declare class Ajax<T extends object = any> implements IAjax<T> {
|
|
16
9
|
readonly jodit: IViewBased;
|
|
17
10
|
static log: IRequest[];
|
|
18
11
|
private readonly xhr;
|
|
19
|
-
private successResponseCodes;
|
|
20
12
|
private __buildParams;
|
|
21
|
-
status: number;
|
|
22
|
-
response: string;
|
|
23
13
|
options: AjaxOptions;
|
|
24
14
|
get o(): this['options'];
|
|
25
15
|
/**
|
|
@@ -29,7 +19,7 @@ export declare class Ajax implements IAjax {
|
|
|
29
19
|
abort(): Ajax;
|
|
30
20
|
private resolved;
|
|
31
21
|
private activated;
|
|
32
|
-
send
|
|
22
|
+
send(): RejectablePromise<IResponse<T>>;
|
|
33
23
|
prepareRequest(): IRequest;
|
|
34
24
|
constructor(jodit: IViewBased, options: Partial<AjaxOptions>);
|
|
35
25
|
destruct(): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { AjaxOptions } from '../../types';
|
|
7
|
+
declare module '../../config' {
|
|
8
|
+
interface Config {
|
|
9
|
+
/**
|
|
10
|
+
* A set of key/value pairs that configure the Ajax request. All settings are optional
|
|
11
|
+
*/
|
|
12
|
+
defaultAjaxOptions: AjaxOptions;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -3,10 +3,5 @@
|
|
|
3
3
|
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
4
|
* Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return {
|
|
9
|
-
test: /\.less$/,
|
|
10
|
-
use: require('../loaders/style')(vars)
|
|
11
|
-
};
|
|
12
|
-
};
|
|
6
|
+
export * from './ajax';
|
|
7
|
+
export * from './response';
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { IRequest, IResponse } from '../../types';
|
|
7
|
+
export declare class Response<T> implements IResponse<T> {
|
|
8
|
+
readonly status: number;
|
|
9
|
+
readonly statusText: string;
|
|
10
|
+
readonly request: IRequest;
|
|
11
|
+
get url(): string;
|
|
12
|
+
private readonly body;
|
|
13
|
+
constructor(request: IRequest, status: number, statusText: string, body: string);
|
|
14
|
+
json(): Promise<T>;
|
|
15
|
+
text(): Promise<string>;
|
|
16
|
+
}
|
|
@@ -8,3 +8,7 @@ import type { IStyle } from '../../../../types';
|
|
|
8
8
|
* Element has the same styles as in the commit
|
|
9
9
|
*/
|
|
10
10
|
export declare function elementHasSameStyle(elm: Node, rules: IStyle): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Element has the similar styles
|
|
13
|
+
*/
|
|
14
|
+
export declare function elementHasSameStyleKeys(elm: Node, rules: IStyle): boolean;
|
|
@@ -15,3 +15,4 @@ import type { CommitStyle } from '../commit-style';
|
|
|
15
15
|
* @param strict - strict mode - false - the default tag is suitable for us if it is also in the commit
|
|
16
16
|
*/
|
|
17
17
|
export declare function isSuitElement(commitStyle: CommitStyle, elm: Nullable<Node>, strict: boolean): elm is HTMLElement;
|
|
18
|
+
export declare function isSameStyleChild(commitStyle: CommitStyle, elm: Nullable<Node>): elm is HTMLElement;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
4
|
* Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { IJodit } from '../../../../types';
|
|
7
7
|
import type { CommitStyle } from '../commit-style';
|
|
8
8
|
/**
|
|
9
9
|
* Wrap text or inline elements inside Block element
|
|
10
10
|
*/
|
|
11
|
-
export declare function wrapUnwrappedText(style: CommitStyle, elm: Node,
|
|
11
|
+
export declare function wrapUnwrappedText(style: CommitStyle, elm: Node, jodit: IJodit, getRange: () => Range): HTMLElement;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
6
|
import type { IAsync, IComponent, ICreate, IProgressBar, IStorage, IViewBased, IViewOptions, IDictionary } from '../../types';
|
|
7
|
-
import { Component,
|
|
7
|
+
import { Component, EventEmitter } from '../../modules';
|
|
8
8
|
import { Elms, Mods } from '../traits';
|
|
9
9
|
export declare abstract class View extends Component implements IViewBased, Mods, Elms {
|
|
10
10
|
readonly isJodit: boolean;
|
|
@@ -51,7 +51,7 @@ export declare abstract class View extends Component implements IViewBased, Mods
|
|
|
51
51
|
private __container;
|
|
52
52
|
get container(): HTMLDivElement;
|
|
53
53
|
set container(container: HTMLDivElement);
|
|
54
|
-
events:
|
|
54
|
+
events: EventEmitter;
|
|
55
55
|
get e(): this['events'];
|
|
56
56
|
/**
|
|
57
57
|
* progress_bar Progress bar
|
|
@@ -15,7 +15,7 @@ export default class DataProvider implements IFileBrowserDataProvider {
|
|
|
15
15
|
*/
|
|
16
16
|
get o(): this['options'];
|
|
17
17
|
private ajaxInstances;
|
|
18
|
-
protected get<T = IFileBrowserAnswer>(name: keyof IFileBrowserOptions
|
|
18
|
+
protected get<T extends IFileBrowserAnswer = IFileBrowserAnswer>(name: keyof IFileBrowserOptions): Promise<T>;
|
|
19
19
|
private progressHandler;
|
|
20
20
|
onProgress(callback: (percentage: number) => void): void;
|
|
21
21
|
/**
|
package/types/modules/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export * from '../core/events';
|
|
7
7
|
export { Async } from '../core/async';
|
|
8
|
-
export
|
|
8
|
+
export * from '../core/request';
|
|
9
9
|
export { Component, ViewComponent, STATUSES } from '../core/component';
|
|
10
10
|
export { ContextMenu } from './context-menu/context-menu';
|
|
11
11
|
export { Alert, Confirm, Prompt, Dialog } from './dialog/';
|