jodit 3.6.16 → 3.7.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/.eslintrc.js +1 -1
- package/{ISSUE_TEMPLATE.md → .github/ISSUE_TEMPLATE.md} +0 -0
- package/{PULL_REQUEST_TEMPLATE.md → .github/PULL_REQUEST_TEMPLATE.md} +0 -0
- package/CHANGELOG.MD +76 -5
- package/build/jodit.css +23 -19
- package/build/jodit.es2018.css +22 -18
- package/build/jodit.es2018.en.css +22 -18
- package/build/jodit.es2018.en.js +153 -99
- package/build/jodit.es2018.en.min.css +1 -1
- package/build/jodit.es2018.en.min.js +2 -2
- package/build/jodit.es2018.js +153 -99
- package/build/jodit.es2018.min.css +1 -1
- package/build/jodit.es2018.min.js +2 -2
- package/build/jodit.js +884 -809
- package/build/jodit.min.css +2 -2
- package/build/jodit.min.js +2 -2
- package/package.json +24 -24
- package/src/core/async.ts +22 -8
- package/src/core/component/component.ts +4 -2
- package/src/core/component/view-component.ts +1 -1
- package/src/core/decorators/cache.ts +1 -1
- package/src/core/decorators/component.ts +1 -1
- package/src/core/decorators/debounce.ts +5 -4
- package/src/core/decorators/idle.ts +40 -0
- package/src/core/decorators/index.ts +1 -0
- package/src/core/decorators/nonenumerable.ts +1 -1
- package/src/core/decorators/spy.ts +2 -3
- package/src/core/decorators/watch.ts +9 -5
- package/src/core/events/events-native.ts +1 -1
- package/src/core/global.ts +7 -3
- package/src/core/helpers/checker/is-plain-object.ts +1 -2
- package/src/core/helpers/checker/is-url.ts +4 -1
- package/src/core/helpers/scroll-into-view.ts +1 -1
- package/src/core/helpers/size/position.ts +1 -22
- package/src/core/helpers/string/stringify.ts +2 -2
- package/src/core/helpers/type.ts +0 -44
- package/src/core/helpers/utils/utils.ts +1 -1
- package/src/core/plugin.ts +3 -1
- package/src/core/ui/button/button/button.ts +2 -2
- package/src/core/ui/button/group/group.ts +6 -4
- package/src/core/ui/element.ts +2 -2
- package/src/core/ui/form/block/block.ts +1 -1
- package/src/core/ui/form/form.ts +5 -5
- package/src/core/ui/form/inputs/area/area.ts +3 -3
- package/src/core/ui/form/inputs/checkbox/checkbox.ts +2 -2
- package/src/core/ui/form/inputs/file/file.ts +6 -4
- package/src/core/ui/form/inputs/input/input.ts +7 -5
- package/src/core/ui/form/inputs/select/select.ts +9 -7
- package/src/core/ui/list/group.ts +4 -4
- package/src/core/ui/list/list.ts +2 -2
- package/src/core/ui/popup/popup.ts +3 -3
- package/src/core/ui/progress-bar/progress-bar.ts +3 -3
- package/src/core/view/view-with-toolbar.ts +5 -2
- package/src/core/view/view.ts +2 -2
- package/src/jodit.ts +37 -15
- package/src/modules/context-menu/context-menu.ts +1 -1
- package/src/modules/dialog/dialog.ts +4 -4
- package/src/modules/file-browser/builders/context-menu.ts +1 -1
- package/src/modules/file-browser/data-provider.ts +1 -1
- package/src/modules/file-browser/file-browser.ts +3 -3
- package/src/modules/image-editor/image-editor.ts +1 -1
- package/src/modules/observer/observer.ts +1 -1
- package/src/modules/observer/snapshot.ts +1 -1
- package/src/modules/status-bar/status-bar.ts +1 -1
- package/src/modules/table.ts +3 -1
- package/src/modules/toolbar/button/button.ts +13 -10
- package/src/modules/toolbar/button/content.ts +3 -3
- package/src/modules/toolbar/collection/collection.ts +9 -6
- package/src/modules/toolbar/collection/editor-collection.ts +26 -4
- package/src/modules/uploader/uploader.ts +1 -1
- package/src/modules/widget/file-selector/file-selector.ts +1 -1
- package/src/plugins/about/about.ts +1 -1
- package/src/plugins/class-span/class-span.ts +3 -3
- package/src/plugins/clipboard/clipboard.ts +28 -24
- package/src/plugins/clipboard/paste/helpers.ts +5 -8
- package/src/plugins/clipboard/paste/paste.ts +3 -3
- package/src/plugins/fix/clean-html.ts +3 -3
- package/src/plugins/image/helpers.ts +1 -1
- package/src/plugins/inline-popup/inline-popup.ts +1 -1
- package/src/plugins/keyboard/delete.ts +1 -1
- package/src/plugins/keyboard/enter.ts +26 -26
- package/src/plugins/limit.ts +2 -2
- package/src/plugins/link/link.ts +3 -3
- package/src/plugins/media/video/index.ts +1 -1
- package/src/plugins/ordered-list.ts +64 -61
- package/src/plugins/redo-undo.ts +3 -3
- package/src/plugins/search/search.ts +2 -2
- package/src/plugins/select.ts +3 -2
- package/src/plugins/size/resize-handler.ts +2 -2
- package/src/plugins/size/size.ts +2 -2
- package/src/plugins/source/editor/engines/ace.ts +8 -8
- package/src/plugins/source/editor/engines/area.ts +15 -13
- package/src/plugins/source/source.ts +1 -1
- package/src/plugins/symbols/symbols.ts +3 -3
- package/src/plugins/table/config.ts +3 -1
- package/src/plugins/table/resize-cells.ts +21 -16
- package/src/plugins/table/select-cells.ts +44 -6
- package/src/plugins/table/table-keyboard-navigation.ts +134 -131
- package/src/plugins/table/table.less +24 -17
- package/src/types/async.d.ts +2 -0
- package/src/types/core.ts +13 -0
- package/src/types/index.d.ts +1 -0
- package/src/types/jodit.d.ts +2 -0
- package/test/tests/acceptance/editorTest.js +37 -0
- package/test/tests/acceptance/tableTest.js +23 -14
- package/tsconfig.json +1 -0
- package/webpack.config.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jodit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.2",
|
|
4
4
|
"description": "Jodit is awesome and usefully wysiwyg editor with filebrowser",
|
|
5
5
|
"main": "build/jodit.min.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -47,43 +47,43 @@
|
|
|
47
47
|
"autobind-decorator": "^2.4.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@types/ace": "^0.0.
|
|
51
|
-
"@types/node": "^15.
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
53
|
-
"@typescript-eslint/parser": "^4.
|
|
54
|
-
"autoprefixer": "^10.2.
|
|
50
|
+
"@types/ace": "^0.0.46",
|
|
51
|
+
"@types/node": "^15.12.2",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^4.27.0",
|
|
53
|
+
"@typescript-eslint/parser": "^4.27.0",
|
|
54
|
+
"autoprefixer": "^10.2.6",
|
|
55
55
|
"chai": "^4.3.4",
|
|
56
56
|
"classlist-polyfill": "^1.2.0",
|
|
57
57
|
"compression": "^1.7.4",
|
|
58
58
|
"cross-env": "^7.0.3",
|
|
59
|
-
"css-loader": "^5.2.
|
|
60
|
-
"css-minimizer-webpack-plugin": "^3.0.
|
|
61
|
-
"cssnano-preset-advanced": "^5.
|
|
59
|
+
"css-loader": "^5.2.6",
|
|
60
|
+
"css-minimizer-webpack-plugin": "^3.0.1",
|
|
61
|
+
"cssnano-preset-advanced": "^5.1.3",
|
|
62
62
|
"es6-promise": "^4.2.8",
|
|
63
|
-
"eslint": "^7.
|
|
63
|
+
"eslint": "^7.28.0",
|
|
64
64
|
"eslint-config-prettier": "^8.3.0",
|
|
65
65
|
"eslint-plugin-header": "^3.1.1",
|
|
66
66
|
"eslint-plugin-prettier": "^3.4.0",
|
|
67
67
|
"express": "^4.17.1",
|
|
68
68
|
"file-loader": "^6.2.0",
|
|
69
69
|
"husky": "^6.0.0",
|
|
70
|
-
"karma": "^6.3.
|
|
70
|
+
"karma": "^6.3.4",
|
|
71
71
|
"karma-chai": "^0.1.0",
|
|
72
72
|
"karma-chrome-launcher": "^3.1.0",
|
|
73
|
-
"karma-firefox-launcher": "^2.1.
|
|
73
|
+
"karma-firefox-launcher": "^2.1.1",
|
|
74
74
|
"karma-mocha": "^2.0.1",
|
|
75
75
|
"karma-sourcemap-loader": "^0.3.8",
|
|
76
76
|
"karma-webpack": "^5.0.0",
|
|
77
77
|
"less": "^4.1.1",
|
|
78
|
-
"less-loader": "^9.
|
|
78
|
+
"less-loader": "^9.1.0",
|
|
79
79
|
"lint-staged": "^11.0.0",
|
|
80
80
|
"merge-stream": "^2.0.0",
|
|
81
81
|
"mini-css-extract-plugin": "^1.6.0",
|
|
82
|
-
"mocha": "^
|
|
83
|
-
"postcss": "^8.
|
|
82
|
+
"mocha": "^9.0.0",
|
|
83
|
+
"postcss": "^8.3.4",
|
|
84
84
|
"postcss-css-variables": "^0.18.0",
|
|
85
|
-
"postcss-loader": "^
|
|
86
|
-
"prettier": "^2.3.
|
|
85
|
+
"postcss-loader": "^6.1.0",
|
|
86
|
+
"prettier": "^2.3.1",
|
|
87
87
|
"raw-loader": "^4.0.2",
|
|
88
88
|
"style-loader": "^2.0.0",
|
|
89
89
|
"stylelint": "^13.13.1",
|
|
@@ -92,15 +92,15 @@
|
|
|
92
92
|
"stylelint-config-standard": "^22.0.0",
|
|
93
93
|
"stylelint-prettier": "^1.2.0",
|
|
94
94
|
"synchronous-promise": "^2.0.15",
|
|
95
|
-
"terser-webpack-plugin": "^5.1.
|
|
96
|
-
"ts-loader": "^9.
|
|
95
|
+
"terser-webpack-plugin": "^5.1.3",
|
|
96
|
+
"ts-loader": "^9.2.3",
|
|
97
97
|
"ts-private-uglifier": "^1.0.2",
|
|
98
|
-
"tslib": "^2.
|
|
99
|
-
"typescript": "^4.2
|
|
98
|
+
"tslib": "^2.3.0",
|
|
99
|
+
"typescript": "^4.3.2",
|
|
100
100
|
"url-loader": "^4.1.1",
|
|
101
|
-
"webpack": "^5.
|
|
102
|
-
"webpack-cli": "^4.7.
|
|
103
|
-
"webpack-dev-middleware": "^
|
|
101
|
+
"webpack": "^5.39.0",
|
|
102
|
+
"webpack-cli": "^4.7.2",
|
|
103
|
+
"webpack-dev-middleware": "^5.0.0",
|
|
104
104
|
"webpack-dev-server": "^3.11.2",
|
|
105
105
|
"webpack-hot-middleware": "^2.25.0",
|
|
106
106
|
"webpack-stream": "^6.1.2",
|
package/src/core/async.ts
CHANGED
|
@@ -16,7 +16,9 @@ import {
|
|
|
16
16
|
clearTimeout,
|
|
17
17
|
isFunction,
|
|
18
18
|
isPlainObject,
|
|
19
|
-
isPromise
|
|
19
|
+
isPromise,
|
|
20
|
+
isString,
|
|
21
|
+
isNumber
|
|
20
22
|
} from './helpers/';
|
|
21
23
|
|
|
22
24
|
export class Async implements IAsync {
|
|
@@ -33,14 +35,13 @@ export class Async implements IAsync {
|
|
|
33
35
|
|
|
34
36
|
let options: IAsyncParams = {};
|
|
35
37
|
|
|
36
|
-
if (
|
|
38
|
+
if (!isNumber(timeout)) {
|
|
37
39
|
options = timeout;
|
|
38
40
|
timeout = options.timeout || 0;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
if (options.label
|
|
42
|
-
|
|
43
|
-
this.timers.delete(options.label);
|
|
43
|
+
if (options.label) {
|
|
44
|
+
this.clearLabel(options.label);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
const timer = setTimeout(callback, timeout, ...args),
|
|
@@ -51,10 +52,22 @@ export class Async implements IAsync {
|
|
|
51
52
|
return timer;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
private clearLabel(label: string) {
|
|
56
|
+
if (label && this.timers.has(label)) {
|
|
57
|
+
clearTimeout(this.timers.get(label) as number);
|
|
58
|
+
this.timers.delete(label);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
56
61
|
|
|
57
|
-
|
|
62
|
+
clearTimeout(timer: number): void;
|
|
63
|
+
clearTimeout(label: string): void;
|
|
64
|
+
clearTimeout(timerOrLabel: number | string): void {
|
|
65
|
+
if (isString(timerOrLabel)) {
|
|
66
|
+
return this.clearLabel(timerOrLabel);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
clearTimeout(timerOrLabel);
|
|
70
|
+
this.timers.delete(timerOrLabel);
|
|
58
71
|
}
|
|
59
72
|
|
|
60
73
|
/**
|
|
@@ -321,6 +334,7 @@ export class Async implements IAsync {
|
|
|
321
334
|
}
|
|
322
335
|
|
|
323
336
|
isDestructed: boolean = false;
|
|
337
|
+
|
|
324
338
|
destruct(): any {
|
|
325
339
|
this.clear();
|
|
326
340
|
this.isDestructed = true;
|
|
@@ -16,8 +16,10 @@ import { kebabCase, get, getClassName, isFunction, isVoid } from '../helpers';
|
|
|
16
16
|
import { uniqueUid } from '../global';
|
|
17
17
|
import { STATUSES } from './statuses';
|
|
18
18
|
|
|
19
|
-
const StatusListHandlers: Map<
|
|
20
|
-
|
|
19
|
+
const StatusListHandlers: Map<
|
|
20
|
+
Component,
|
|
21
|
+
IDictionary<CallableFunction[]>
|
|
22
|
+
> = new Map();
|
|
21
23
|
|
|
22
24
|
export abstract class Component implements IComponent {
|
|
23
25
|
static STATUSES = STATUSES;
|
|
@@ -25,7 +25,7 @@ const cn = (elm: ComponentCompatible): string | number => {
|
|
|
25
25
|
*/
|
|
26
26
|
export function component<T extends ComponentCompatible>(
|
|
27
27
|
constructorFunction: T
|
|
28
|
-
) {
|
|
28
|
+
): T {
|
|
29
29
|
class newConstructorFunction extends constructorFunction {
|
|
30
30
|
constructor(...args: any[]) {
|
|
31
31
|
super(...args);
|
|
@@ -8,7 +8,8 @@ import type {
|
|
|
8
8
|
IDictionary,
|
|
9
9
|
IViewBased,
|
|
10
10
|
IViewComponent,
|
|
11
|
-
IAsyncParams
|
|
11
|
+
IAsyncParams,
|
|
12
|
+
DecoratorHandler
|
|
12
13
|
} from '../../types';
|
|
13
14
|
import {
|
|
14
15
|
error,
|
|
@@ -30,7 +31,7 @@ export function debounce<V = IViewComponent | IViewBased>(
|
|
|
30
31
|
timeout?: number | ((ctx: V) => number | IAsyncParams) | IAsyncParams,
|
|
31
32
|
firstCallImmediately: boolean = false,
|
|
32
33
|
method: 'debounce' | 'throttle' = 'debounce'
|
|
33
|
-
) {
|
|
34
|
+
): DecoratorHandler {
|
|
34
35
|
return <T extends Component & IDictionary>(
|
|
35
36
|
target: IDictionary,
|
|
36
37
|
propertyKey: string
|
|
@@ -67,8 +68,8 @@ export function debounce<V = IViewComponent | IViewBased>(
|
|
|
67
68
|
* @param method
|
|
68
69
|
*/
|
|
69
70
|
export function throttle<V = IViewComponent | IViewBased>(
|
|
70
|
-
timeout?: number | ((ctx: V) => number),
|
|
71
|
+
timeout?: number | ((ctx: V) => number | IAsyncParams) | IAsyncParams,
|
|
71
72
|
firstCallImmediately: boolean = false
|
|
72
|
-
) {
|
|
73
|
+
): DecoratorHandler {
|
|
73
74
|
return debounce<V>(timeout, firstCallImmediately, 'throttle');
|
|
74
75
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 {
|
|
7
|
+
DecoratorHandler,
|
|
8
|
+
IDictionary,
|
|
9
|
+
IViewBased,
|
|
10
|
+
IViewComponent
|
|
11
|
+
} from '../../types';
|
|
12
|
+
import { Component, STATUSES } from '../component';
|
|
13
|
+
import { error, isFunction, isViewObject } from '../helpers';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Wrap function in requestIdleCallback wrapper*
|
|
17
|
+
*/
|
|
18
|
+
export function idle<V = IViewComponent | IViewBased>(): DecoratorHandler {
|
|
19
|
+
return <T extends Component & IDictionary>(
|
|
20
|
+
target: IDictionary,
|
|
21
|
+
propertyKey: string
|
|
22
|
+
): void => {
|
|
23
|
+
if (!isFunction(target[propertyKey])) {
|
|
24
|
+
throw error('Handler must be a Function');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
target.hookStatus(STATUSES.ready, (component: V) => {
|
|
28
|
+
const view = isViewObject(component)
|
|
29
|
+
? component
|
|
30
|
+
: (component as unknown as IViewComponent).jodit;
|
|
31
|
+
|
|
32
|
+
const originalMethod = (component as any)[propertyKey];
|
|
33
|
+
|
|
34
|
+
(component as any)[propertyKey] = (...args: unknown[]) =>
|
|
35
|
+
view.async.requestIdleCallback(
|
|
36
|
+
originalMethod.bind(component, ...args)
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @enumerable decorator that sets the enumerable property of a class field to false.
|
|
9
9
|
* @param value true|false
|
|
10
10
|
*/
|
|
11
|
-
export const nonenumerable = (target:
|
|
11
|
+
export const nonenumerable = (target: object, propertyKey: string): void => {
|
|
12
12
|
const descriptor =
|
|
13
13
|
Object.getOwnPropertyDescriptor(target, propertyKey) || {};
|
|
14
14
|
|
|
@@ -11,13 +11,12 @@ import {
|
|
|
11
11
|
isString
|
|
12
12
|
} from '../helpers/checker';
|
|
13
13
|
import { getClassName } from '../helpers/utils';
|
|
14
|
-
import { type } from '../helpers';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Allow spy for the class
|
|
18
17
|
* @param target
|
|
19
18
|
*/
|
|
20
|
-
export const spy = function spy(target: Function) {
|
|
19
|
+
export const spy = function spy(target: Function): void {
|
|
21
20
|
const methods = Reflect.ownKeys(target.prototype);
|
|
22
21
|
|
|
23
22
|
methods.forEach(key => {
|
|
@@ -46,7 +45,7 @@ export const spy = function spy(target: Function) {
|
|
|
46
45
|
isBoolean(a) ||
|
|
47
46
|
isNumber(a)
|
|
48
47
|
? JSON.stringify(a)
|
|
49
|
-
:
|
|
48
|
+
: {}.toString.call(a)
|
|
50
49
|
)})`
|
|
51
50
|
);
|
|
52
51
|
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import type {
|
|
8
8
|
CanUndef,
|
|
9
|
+
DecoratorHandler,
|
|
9
10
|
IComponent,
|
|
10
11
|
IDictionary,
|
|
11
12
|
IViewComponent
|
|
@@ -21,7 +22,7 @@ import { ObserveObject } from '../events';
|
|
|
21
22
|
import { Component, STATUSES } from '../component';
|
|
22
23
|
|
|
23
24
|
export function getPropertyDescriptor(
|
|
24
|
-
obj:
|
|
25
|
+
obj: unknown,
|
|
25
26
|
prop: string
|
|
26
27
|
): CanUndef<PropertyDescriptor> {
|
|
27
28
|
let desc;
|
|
@@ -41,7 +42,7 @@ export function getPropertyDescriptor(
|
|
|
41
42
|
export function watch(
|
|
42
43
|
observeFields: string[] | string,
|
|
43
44
|
context?: object | ((c: IDictionary) => object)
|
|
44
|
-
) {
|
|
45
|
+
): DecoratorHandler {
|
|
45
46
|
return <T extends Component & IDictionary>(
|
|
46
47
|
target: T,
|
|
47
48
|
propertyKey: string
|
|
@@ -60,6 +61,7 @@ export function watch(
|
|
|
60
61
|
splitArray(observeFields).forEach(field => {
|
|
61
62
|
if (/:/.test(field)) {
|
|
62
63
|
const [objectPath, eventName] = field.split(':');
|
|
64
|
+
|
|
63
65
|
const view = isViewObject(component)
|
|
64
66
|
? component
|
|
65
67
|
: (component as unknown as IViewComponent).jodit;
|
|
@@ -73,9 +75,11 @@ export function watch(
|
|
|
73
75
|
context = context(component);
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
view.events
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
view.events.on(context || component, eventName, callback);
|
|
79
|
+
|
|
80
|
+
if (!context) {
|
|
81
|
+
view.events.on(eventName, callback);
|
|
82
|
+
}
|
|
79
83
|
|
|
80
84
|
view.hookStatus('beforeDestruct', () => {
|
|
81
85
|
view.events
|
|
@@ -546,7 +546,7 @@ export class EventsNative implements IEventsNative {
|
|
|
546
546
|
* ```
|
|
547
547
|
*
|
|
548
548
|
*/
|
|
549
|
-
fire(subjectOrEvents: string,
|
|
549
|
+
fire(subjectOrEvents: string, ...args: any[]): any;
|
|
550
550
|
fire(
|
|
551
551
|
subjectOrEvents: object,
|
|
552
552
|
eventsList: string | Event,
|
package/src/core/global.ts
CHANGED
|
@@ -43,7 +43,7 @@ export const pluginSystem = new PluginSystem();
|
|
|
43
43
|
export const modules: IDictionary<Function> = {};
|
|
44
44
|
|
|
45
45
|
export const lang: IDictionary<IDictionary<string>> = {};
|
|
46
|
-
export const extendLang = (langs: IDictionary) => {
|
|
46
|
+
export const extendLang = (langs: IDictionary): void => {
|
|
47
47
|
Object.keys(langs).forEach(key => {
|
|
48
48
|
if (lang[key]) {
|
|
49
49
|
Object.assign(lang[key], langs[key]);
|
|
@@ -66,7 +66,7 @@ export function getContainer<T extends HTMLTagNames = HTMLTagNames>(
|
|
|
66
66
|
jodit: IViewBased | IViewComponent,
|
|
67
67
|
classFunc: Function,
|
|
68
68
|
tag: T = 'div' as T,
|
|
69
|
-
|
|
69
|
+
createInsideEditor: boolean = false
|
|
70
70
|
): HTMLElementTagNameMap[T] {
|
|
71
71
|
const name = getClassName(classFunc.prototype);
|
|
72
72
|
|
|
@@ -79,7 +79,11 @@ export function getContainer<T extends HTMLTagNames = HTMLTagNames>(
|
|
|
79
79
|
let c = view.c,
|
|
80
80
|
body = jodit.od.body;
|
|
81
81
|
|
|
82
|
-
if (
|
|
82
|
+
if (
|
|
83
|
+
createInsideEditor &&
|
|
84
|
+
isJoditObject(jodit) &&
|
|
85
|
+
jodit.od !== jodit.ed
|
|
86
|
+
) {
|
|
83
87
|
c = jodit.createInside;
|
|
84
88
|
body = tag === 'style' ? jodit.ed.head : jodit.ed.body;
|
|
85
89
|
}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
import type { IDictionary } from '../../../types';
|
|
8
8
|
import { isWindow } from './is-window';
|
|
9
|
-
import { hasOwn } from '../type';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Check if element is simple plaint object
|
|
@@ -21,6 +20,6 @@ export function isPlainObject<T>(
|
|
|
21
20
|
|
|
22
21
|
return !(
|
|
23
22
|
obj.constructor &&
|
|
24
|
-
!
|
|
23
|
+
!{}.hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf')
|
|
25
24
|
);
|
|
26
25
|
}
|
|
@@ -19,7 +19,10 @@ export function isURL(str: string): boolean {
|
|
|
19
19
|
if (typeof URL !== 'undefined') {
|
|
20
20
|
try {
|
|
21
21
|
const url = new URL(str);
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
return ['https:', 'http:', 'ftp:', 'file:', 'rtmp:'].includes(
|
|
24
|
+
url.protocol
|
|
25
|
+
);
|
|
23
26
|
} catch (e) {
|
|
24
27
|
return false;
|
|
25
28
|
}
|
|
@@ -27,29 +27,8 @@ export function position(
|
|
|
27
27
|
jodit?: IViewBased,
|
|
28
28
|
recurse: boolean = false
|
|
29
29
|
): IBound {
|
|
30
|
-
// let xPos = 0,
|
|
31
|
-
// yPos = 0,
|
|
32
|
-
// el: HTMLElement | null = elm;
|
|
33
|
-
//
|
|
34
|
-
// const doc: Document = elm.ownerDocument || jodit?.od || document;
|
|
35
|
-
//
|
|
36
|
-
// while (el) {
|
|
37
|
-
// if (el.tagName == 'BODY') {
|
|
38
|
-
// // deal with browser quirks with body/window/document and page scroll
|
|
39
|
-
// const xScroll = el.scrollLeft || doc.documentElement.scrollLeft,
|
|
40
|
-
// yScroll = el.scrollTop || doc.documentElement.scrollTop;
|
|
41
|
-
//
|
|
42
|
-
// xPos += el.offsetLeft - xScroll + el.clientLeft;
|
|
43
|
-
// yPos += el.offsetTop - yScroll + el.clientTop;
|
|
44
|
-
// } else {
|
|
45
|
-
// // for all other non-BODY elements
|
|
46
|
-
// xPos += el.offsetLeft - el.scrollLeft + el.clientLeft;
|
|
47
|
-
// yPos += el.offsetTop - el.scrollTop + el.clientTop;
|
|
48
|
-
// }
|
|
49
|
-
//
|
|
50
|
-
// el = el.offsetParent as HTMLElement;
|
|
51
|
-
// }
|
|
52
30
|
const rect = elm.getBoundingClientRect();
|
|
31
|
+
|
|
53
32
|
let xPos = rect.left,
|
|
54
33
|
yPos = rect.top;
|
|
55
34
|
|
|
@@ -13,14 +13,14 @@ import type { CanUndef } from '../../../types';
|
|
|
13
13
|
* @param options
|
|
14
14
|
*/
|
|
15
15
|
export function stringify(
|
|
16
|
-
value:
|
|
16
|
+
value: unknown,
|
|
17
17
|
options: {
|
|
18
18
|
excludeKeys?: string[];
|
|
19
19
|
prettify?: string;
|
|
20
20
|
} = {}
|
|
21
21
|
): string {
|
|
22
22
|
if (typeof value !== 'object') {
|
|
23
|
-
return value
|
|
23
|
+
return String(value);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const excludeKeys = new Set(options.excludeKeys);
|
package/src/core/helpers/type.ts
CHANGED
|
@@ -4,50 +4,6 @@
|
|
|
4
4
|
* Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { IDictionary } from '../../types';
|
|
8
|
-
|
|
9
|
-
const class2type: IDictionary<string> = {};
|
|
10
|
-
const toString = class2type.toString;
|
|
11
|
-
export const hasOwn = class2type.hasOwnProperty;
|
|
12
|
-
|
|
13
|
-
[
|
|
14
|
-
'Boolean',
|
|
15
|
-
'Number',
|
|
16
|
-
'String',
|
|
17
|
-
'Function',
|
|
18
|
-
'Array',
|
|
19
|
-
'Date',
|
|
20
|
-
'RegExp',
|
|
21
|
-
'Object',
|
|
22
|
-
'Error',
|
|
23
|
-
'Symbol',
|
|
24
|
-
'HTMLDocument',
|
|
25
|
-
'Window',
|
|
26
|
-
'HTMLElement',
|
|
27
|
-
'HTMLBodyElement',
|
|
28
|
-
'Text',
|
|
29
|
-
'DocumentFragment',
|
|
30
|
-
'DOMStringList',
|
|
31
|
-
'HTMLCollection'
|
|
32
|
-
].forEach(name => {
|
|
33
|
-
class2type['[object ' + name + ']'] = name.toLowerCase();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Get name object's type
|
|
38
|
-
* @param obj
|
|
39
|
-
*/
|
|
40
|
-
export const type = (obj: any): string => {
|
|
41
|
-
// eslint-disable-next-line eqeqeq
|
|
42
|
-
if (obj === null) {
|
|
43
|
-
return 'null';
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return typeof obj === 'object' || typeof obj === 'function'
|
|
47
|
-
? class2type[toString.call(obj)] || 'object'
|
|
48
|
-
: typeof obj;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
7
|
/**
|
|
52
8
|
* Helper for create Error object
|
|
53
9
|
* @param message
|
package/src/core/plugin.ts
CHANGED
|
@@ -13,6 +13,8 @@ export abstract class Plugin<T extends IViewBased = IJodit>
|
|
|
13
13
|
extends ViewComponent<T>
|
|
14
14
|
implements IPlugin<T>
|
|
15
15
|
{
|
|
16
|
+
requires: string[] = [];
|
|
17
|
+
|
|
16
18
|
/** @override */
|
|
17
19
|
buttons: IPlugin['buttons'] = [];
|
|
18
20
|
|
|
@@ -52,7 +54,7 @@ export abstract class Plugin<T extends IViewBased = IJodit>
|
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
@autobind
|
|
55
|
-
destruct(): void {
|
|
57
|
+
override destruct(): void {
|
|
56
58
|
if (!this.isInDestruct) {
|
|
57
59
|
this.setStatus(STATUSES.beforeDestruct);
|
|
58
60
|
|
|
@@ -184,7 +184,7 @@ export class UIButton extends UIElement implements IUIButton {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
/** @override */
|
|
187
|
-
protected createContainer(): HTMLElement {
|
|
187
|
+
protected override createContainer(): HTMLElement {
|
|
188
188
|
const cn = this.componentName;
|
|
189
189
|
|
|
190
190
|
const button = this.j.c.element('button', {
|
|
@@ -219,7 +219,7 @@ export class UIButton extends UIElement implements IUIButton {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
destruct(): any {
|
|
222
|
+
override destruct(): any {
|
|
223
223
|
this.j.e.off(this.container);
|
|
224
224
|
return super.destruct();
|
|
225
225
|
}
|
|
@@ -18,15 +18,15 @@ import { UIButton } from '../button/button';
|
|
|
18
18
|
|
|
19
19
|
@component
|
|
20
20
|
export class UIButtonGroup extends UIGroup {
|
|
21
|
-
elements!: IUIButton[];
|
|
21
|
+
override elements!: IUIButton[];
|
|
22
22
|
|
|
23
23
|
/** @override */
|
|
24
|
-
className(): string {
|
|
24
|
+
override className(): string {
|
|
25
25
|
return 'UIButtonGroup';
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/** @override */
|
|
29
|
-
protected render(options: IDictionary): string {
|
|
29
|
+
protected override render(options: IDictionary): string {
|
|
30
30
|
return `<div>
|
|
31
31
|
<div class="&__label">~${options.label}~</div>
|
|
32
32
|
<div class="&__options"></div>
|
|
@@ -34,7 +34,9 @@ export class UIButtonGroup extends UIGroup {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/** @override */
|
|
37
|
-
protected appendChildToContainer(
|
|
37
|
+
protected override appendChildToContainer(
|
|
38
|
+
childContainer: HTMLElement
|
|
39
|
+
): void {
|
|
38
40
|
this.getElm('options').appendChild(childContainer);
|
|
39
41
|
}
|
|
40
42
|
|
package/src/core/ui/element.ts
CHANGED
|
@@ -55,7 +55,7 @@ export abstract class UIElement<T extends IViewBased = IViewBased>
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/** @override */
|
|
58
|
-
get<T>(chain: string, obj?: IDictionary): Nullable<T> {
|
|
58
|
+
override get<T>(chain: string, obj?: IDictionary): Nullable<T> {
|
|
59
59
|
return super.get(chain, obj) || (this.getElm(chain) as unknown as T);
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -198,7 +198,7 @@ export abstract class UIElement<T extends IViewBased = IViewBased>
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/** @override */
|
|
201
|
-
destruct(): any {
|
|
201
|
+
override destruct(): any {
|
|
202
202
|
Dom.safeRemove(this.container);
|
|
203
203
|
this.parentElement = null;
|
|
204
204
|
return super.destruct();
|