jodit 3.19.4 → 3.20.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/build/jodit.css +45 -42
- package/build/jodit.es2018.css +38 -36
- package/build/jodit.es2018.en.css +38 -36
- package/build/jodit.es2018.en.js +22562 -25637
- package/build/jodit.es2018.en.min.css +1 -1
- package/build/jodit.es2018.en.min.js +1 -1
- package/build/jodit.es2018.js +23105 -26181
- package/build/jodit.es2018.min.css +1 -1
- package/build/jodit.es2018.min.js +1 -1
- package/build/jodit.js +797 -386
- package/build/jodit.min.css +2 -2
- package/build/jodit.min.js +1 -1
- package/build/plugins/debug/debug.es2018.en.js +97 -0
- package/build/plugins/debug/debug.es2018.en.min.js +1 -0
- package/build/plugins/debug/debug.es2018.js +97 -0
- package/build/plugins/debug/debug.es2018.min.js +1 -0
- package/build/plugins/debug/debug.js +96 -0
- package/build/plugins/debug/debug.min.js +1 -0
- package/build/plugins/speech-recognize/speech-recognize.css +1 -1
- package/build/plugins/speech-recognize/speech-recognize.es2018.css +1 -1
- package/build/plugins/speech-recognize/speech-recognize.es2018.en.css +1 -1
- package/build/plugins/speech-recognize/speech-recognize.es2018.en.js +331 -398
- package/build/plugins/speech-recognize/speech-recognize.es2018.en.min.js +1 -1
- package/build/plugins/speech-recognize/speech-recognize.es2018.js +331 -398
- package/build/plugins/speech-recognize/speech-recognize.es2018.min.js +1 -1
- package/build/plugins/speech-recognize/speech-recognize.js +1 -1
- package/build/vdom.css +1 -1
- package/build/vdom.js +1 -1
- package/index.html +2 -2
- package/package.json +9 -4
- package/src/config.ts +4 -2
- package/src/core/constants.ts +7 -7
- package/src/core/decorators/derive/README.md +71 -0
- package/src/core/decorators/derive/derive.ts +48 -0
- package/src/core/decorators/index.ts +1 -0
- package/src/core/decorators/spy/spy.ts +5 -0
- package/src/core/dom/dom.test.js +0 -1
- package/src/core/dom/dom.ts +28 -13
- package/src/core/event-emitter/observable.ts +3 -3
- package/src/core/helpers/helpers.test.js +0 -170
- package/src/core/plugin/plugin-system.ts +20 -0
- package/src/core/selection/select.ts +27 -9
- package/src/core/selection/style/api/toggle/toggle-ordered-list.ts +5 -1
- package/src/core/selection/style/api/wrap-ordered-list.ts +5 -1
- package/src/core/selection/style/api/wrap-unwrapped-text.ts +1 -1
- package/src/core/selection/style/style.test.js +1 -1
- package/src/core/{view/panel.ts → traits/dlgs.ts} +17 -9
- package/src/core/traits/elms.ts +4 -8
- package/src/core/traits/index.ts +1 -0
- package/src/core/traits/mods.ts +17 -10
- package/src/core/ui/button/index.ts +1 -0
- package/src/{plugins → core/ui/button}/tooltip/README.md +0 -0
- package/src/{plugins → core/ui/button}/tooltip/tooltip.less +4 -4
- package/src/{plugins → core/ui/button}/tooltip/tooltip.test.js +3 -2
- package/src/core/ui/button/tooltip/tooltip.ts +132 -0
- package/src/core/ui/element.ts +5 -27
- package/src/core/ui/group/group.test.js +44 -0
- package/src/core/ui/group/group.ts +4 -4
- package/src/core/view/view-with-toolbar.ts +2 -2
- package/src/core/view/view.ts +11 -33
- package/src/jodit.ts +20 -8
- package/src/langs/ar.js +1 -1
- package/src/langs/cs_cz.js +1 -1
- package/src/langs/de.js +1 -1
- package/src/langs/es.js +1 -1
- package/src/langs/fa.js +1 -1
- package/src/langs/fr.js +1 -1
- package/src/langs/he.js +1 -1
- package/src/langs/hu.js +1 -1
- package/src/langs/i18n.test.js +170 -0
- package/src/langs/id.js +1 -1
- package/src/langs/it.js +1 -1
- package/src/langs/ja.js +1 -1
- package/src/langs/ko.js +1 -1
- package/src/langs/nl.js +1 -1
- package/src/langs/pl.js +1 -1
- package/src/langs/pt_br.js +1 -1
- package/src/langs/ru.js +1 -1
- package/src/langs/tr.js +1 -1
- package/src/langs/zh_cn.js +1 -1
- package/src/langs/zh_tw.js +1 -1
- package/src/modules/dialog/dialog.less +2 -0
- package/src/modules/dialog/dialog.ts +27 -50
- package/src/modules/file-browser/README.md +10 -10
- package/src/modules/file-browser/__image_snapshots__/file-browser-test-screenshot-js-filebrowser-screenshot-testing-open-filebrowser-works-1-snap.png +0 -0
- package/src/modules/file-browser/builders/context-menu.ts +1 -1
- package/src/modules/file-browser/file-browser.test.js +26 -13
- package/src/modules/file-browser/file-browser.test.screenshot.js +23 -0
- package/src/modules/file-browser/file-browser.ts +9 -5
- package/src/modules/history/snapshot.ts +12 -3
- package/src/modules/image-editor/__image_snapshots__/image-editor-test-screenshot-js-image-editor-screenshot-testing-open-image-editor-works-1-snap.png +0 -0
- package/src/modules/image-editor/image-editor.test.screenshot.js +25 -0
- package/src/modules/image-editor/image-editor.ts +7 -6
- package/src/modules/status-bar/status-bar.ts +5 -16
- package/src/modules/table/table.test.js +2 -1
- package/src/modules/toolbar/collection/collection.ts +6 -1
- package/src/modules/uploader/README.md +1 -1
- package/src/modules/uploader/config.ts +1 -1
- package/src/modules/uploader/uploader.test.js +96 -46
- package/src/plugins/about/about.ts +1 -1
- package/src/plugins/add-new-line/add-new-line.ts +5 -4
- package/src/plugins/backspace/backspace.test.js +33 -39
- package/src/plugins/backspace/backspace.ts +10 -4
- package/src/plugins/backspace/cases/check-remove-char.ts +36 -14
- package/src/plugins/backspace/cases/check-remove-unbreakable-element.ts +8 -0
- package/src/plugins/backspace/config.ts +1 -1
- package/src/plugins/backspace/interface.d.ts +1 -1
- package/src/plugins/clean-html/clean-html.test.js +240 -164
- package/src/plugins/clean-html/config.ts +10 -2
- package/src/plugins/clean-html/helpers/remove-format/remove-format-for-collapsed-selection.ts +3 -2
- package/src/plugins/clean-html/helpers/remove-format/remove-format-for-selection.ts +2 -2
- package/src/plugins/clean-html/helpers/visitor/filters/index.ts +1 -0
- package/src/plugins/clean-html/helpers/visitor/filters/remove-empty-text-node.ts +35 -0
- package/src/plugins/clean-html/helpers/visitor/filters/remove-inv-text-nodes.ts +2 -6
- package/src/plugins/clean-html/helpers/visitor/visit-node-walker.ts +5 -0
- package/src/plugins/debug/debug.ts +68 -0
- package/src/plugins/drag-and-drop/drag-and-drop.ts +0 -1
- package/src/plugins/drag-and-drop-element/drag-and-drop-element.test.js +37 -34
- package/src/plugins/dtd/README.md +52 -0
- package/{types/plugins/tooltip/tooltip.d.ts → src/plugins/dtd/after-insert/index.ts} +5 -4
- package/src/plugins/dtd/after-insert/remove-extra-br.ts +39 -0
- package/src/plugins/dtd/before-insert/check-block-nesting.ts +40 -0
- package/src/plugins/dtd/before-insert/index.ts +12 -0
- package/src/plugins/dtd/config.ts +67 -0
- package/src/plugins/dtd/dtd.test.js +128 -0
- package/src/plugins/dtd/dtd.ts +48 -0
- package/src/plugins/enter/enter.test.js +89 -193
- package/src/plugins/enter/enter.ts +14 -11
- package/src/plugins/enter/helpers/check-br.ts +11 -1
- package/src/plugins/enter/helpers/index.ts +1 -0
- package/src/plugins/enter/helpers/move-cursor-out-from-specal-tags.ts +32 -0
- package/src/plugins/enter/helpers/split-fragment.ts +1 -0
- package/src/plugins/fullsize/config.ts +1 -1
- package/src/plugins/fullsize/fullsize.test.js +77 -12
- package/src/plugins/fullsize/fullsize.ts +12 -1
- package/src/plugins/iframe/config.ts +1 -1
- package/src/plugins/image-properties/README.md +7 -0
- package/src/plugins/image-properties/image-properties.ts +1 -1
- package/src/plugins/index.ts +1 -1
- package/src/plugins/limit/limit.test.js +27 -0
- package/src/plugins/limit/limit.ts +4 -2
- package/src/plugins/line-height/line-height.svg +1 -1
- package/src/plugins/link/README.md +5 -0
- package/src/plugins/link/link.test.js +11 -12
- package/src/plugins/link/link.ts +1 -1
- package/src/plugins/mobile/mobile.ts +1 -1
- package/src/plugins/ordered-list/ordered-list.test.js +3 -14
- package/src/plugins/paste/config.ts +0 -7
- package/src/plugins/paste/paste.test.js +3 -3
- package/src/plugins/paste-storage/paste-storage.ts +1 -1
- package/src/plugins/preview/preview.ts +1 -1
- package/src/plugins/search/search.ts +1 -1
- package/src/plugins/select/config.ts +1 -1
- package/src/plugins/spellcheck/config.ts +1 -1
- package/src/plugins/symbols/symbols.test.js +5 -4
- package/src/plugins/table/config.ts +4 -17
- package/src/plugins/table/table.test.js +2 -2
- package/src/plugins/wrap-nodes/wrap-nodes.test.js +34 -5
- package/src/plugins/wrap-nodes/wrap-nodes.ts +59 -16
- package/src/styles/variables.less +1 -1
- package/src/types/ajax.d.ts +2 -2
- package/src/types/file-browser.d.ts +4 -2
- package/src/types/jodit.d.ts +3 -2
- package/src/types/plugin.d.ts +1 -0
- package/src/types/toolbar.d.ts +12 -6
- package/src/types/traits.d.ts +30 -1
- package/src/types/types.d.ts +1 -0
- package/src/types/view.d.ts +9 -34
- package/src/typings.d.ts +1 -0
- package/types/config.d.ts +3 -2
- package/types/core/constants.d.ts +7 -7
- package/types/core/decorators/derive/derive.d.ts +6 -0
- package/types/core/decorators/index.d.ts +1 -0
- package/types/core/dom/dom.d.ts +5 -4
- package/types/core/plugin/plugin-system.d.ts +4 -0
- package/types/core/traits/dlgs.d.ts +15 -0
- package/types/core/traits/elms.d.ts +2 -4
- package/types/core/traits/index.d.ts +1 -0
- package/types/core/traits/mods.d.ts +5 -8
- package/types/core/ui/button/index.d.ts +1 -0
- package/types/core/ui/button/tooltip/tooltip.d.ts +29 -0
- package/types/core/ui/element.d.ts +3 -9
- package/types/core/ui/group/group.d.ts +2 -2
- package/types/core/view/view-with-toolbar.d.ts +2 -2
- package/types/core/view/view.d.ts +5 -10
- package/types/jodit.d.ts +7 -4
- package/types/modules/dialog/dialog.d.ts +8 -10
- package/types/modules/file-browser/file-browser.d.ts +5 -2
- package/types/modules/history/snapshot.d.ts +3 -2
- package/types/modules/image-editor/image-editor.d.ts +4 -4
- package/types/modules/status-bar/status-bar.d.ts +3 -4
- package/types/modules/toolbar/collection/collection.d.ts +1 -0
- package/types/plugins/clean-html/config.d.ts +7 -1
- package/types/plugins/clean-html/helpers/visitor/filters/index.d.ts +1 -0
- package/types/plugins/clean-html/helpers/visitor/filters/remove-empty-text-node.d.ts +13 -0
- package/types/plugins/dtd/after-insert/index.d.ts +10 -0
- package/types/plugins/dtd/after-insert/remove-extra-br.d.ts +16 -0
- package/types/plugins/dtd/before-insert/check-block-nesting.d.ts +16 -0
- package/types/plugins/dtd/before-insert/index.d.ts +10 -0
- package/types/plugins/dtd/config.d.ts +27 -0
- package/types/plugins/dtd/dtd.d.ts +6 -0
- package/types/plugins/enter/helpers/index.d.ts +1 -0
- package/types/plugins/enter/helpers/move-cursor-out-from-specal-tags.d.ts +13 -0
- package/types/plugins/iframe/config.d.ts +1 -1
- package/types/plugins/index.d.ts +1 -1
- package/types/plugins/paste/config.d.ts +0 -4
- package/types/plugins/spellcheck/config.d.ts +1 -1
- package/types/types/ajax.d.ts +2 -2
- package/types/types/file-browser.d.ts +4 -2
- package/types/types/jodit.d.ts +3 -2
- package/types/types/plugin.d.ts +1 -0
- package/types/types/toolbar.d.ts +12 -6
- package/types/types/traits.d.ts +30 -1
- package/types/types/types.d.ts +1 -0
- package/types/types/view.d.ts +9 -34
- package/src/plugins/tooltip/tooltip.ts +0 -114
- package/types/core/view/panel.d.ts +0 -13
|
@@ -0,0 +1,132 @@
|
|
|
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-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* [[include:plugins/tooltip/README.md]]
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
* @module plugins/tooltip
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import './tooltip.less';
|
|
14
|
+
|
|
15
|
+
import type { IPoint, IViewBased } from 'jodit/types';
|
|
16
|
+
import { css, dataBind } from 'jodit/core/helpers';
|
|
17
|
+
import { getContainer } from 'jodit/core/global';
|
|
18
|
+
import { autobind } from 'jodit/core/decorators';
|
|
19
|
+
import { UIElement } from '../../element';
|
|
20
|
+
|
|
21
|
+
export class UITooltip extends UIElement {
|
|
22
|
+
private __isOpened = false;
|
|
23
|
+
|
|
24
|
+
className(): string {
|
|
25
|
+
return 'UITooltip';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
protected constructor(view: IViewBased) {
|
|
29
|
+
super(view);
|
|
30
|
+
getContainer(view, UITooltip).appendChild(this.container);
|
|
31
|
+
|
|
32
|
+
let timeout = 0;
|
|
33
|
+
|
|
34
|
+
view.e
|
|
35
|
+
.off('.tooltip')
|
|
36
|
+
.on(
|
|
37
|
+
'showTooltip.tooltip',
|
|
38
|
+
(getPoint: () => IPoint, content: string) => {
|
|
39
|
+
view.async.clearTimeout(timeout);
|
|
40
|
+
this.__open(getPoint, content);
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
.on('delayShowTooltip.tooltip', this.__delayOpen)
|
|
45
|
+
|
|
46
|
+
.on('escape.tooltip', this.__close)
|
|
47
|
+
.on(
|
|
48
|
+
'hideTooltip.tooltip change.tooltip scroll.tooltip changePlace.tooltip hidePopup.tooltip closeAllPopups.tooltip',
|
|
49
|
+
() => {
|
|
50
|
+
this.j.async.clearTimeout(this.__delayShowTimeout);
|
|
51
|
+
|
|
52
|
+
timeout = view.async.setTimeout(
|
|
53
|
+
this.__close,
|
|
54
|
+
this.j.defaultTimeout
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private __useCount: number = 1;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Creates only one instance of the tooltip for the container
|
|
64
|
+
*/
|
|
65
|
+
static make(view: IViewBased): UITooltip {
|
|
66
|
+
let instance = dataBind<UITooltip>(view, 'ui-tooltip');
|
|
67
|
+
if (instance) {
|
|
68
|
+
instance.__useCount += 1;
|
|
69
|
+
return instance;
|
|
70
|
+
}
|
|
71
|
+
instance = new UITooltip(view);
|
|
72
|
+
dataBind<UITooltip>(view, 'ui-tooltip', instance);
|
|
73
|
+
return instance;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private __delayShowTimeout: number = 0;
|
|
77
|
+
|
|
78
|
+
@autobind
|
|
79
|
+
private __delayOpen(getPoint: () => IPoint, content: string): void {
|
|
80
|
+
const to = this.j.o.showTooltipDelay || this.j.defaultTimeout;
|
|
81
|
+
|
|
82
|
+
this.j.async.clearTimeout(this.__delayShowTimeout);
|
|
83
|
+
|
|
84
|
+
this.__delayShowTimeout = this.j.async.setTimeout(
|
|
85
|
+
() => this.__open(getPoint, content),
|
|
86
|
+
{
|
|
87
|
+
timeout: to,
|
|
88
|
+
label: 'tooltip'
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private __open(getPoint: () => IPoint, content: string): void {
|
|
94
|
+
this.setMod('visible', true);
|
|
95
|
+
this.container.innerHTML = content;
|
|
96
|
+
|
|
97
|
+
this.__isOpened = true;
|
|
98
|
+
this.__setPosition(getPoint);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private __setPosition(getPoint: () => IPoint): void {
|
|
102
|
+
const point = getPoint();
|
|
103
|
+
|
|
104
|
+
css(this.container, {
|
|
105
|
+
left: point.x,
|
|
106
|
+
top: point.y
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@autobind
|
|
111
|
+
private __close(): void {
|
|
112
|
+
this.j.async.clearTimeout(this.__delayShowTimeout);
|
|
113
|
+
|
|
114
|
+
if (this.__isOpened) {
|
|
115
|
+
this.__isOpened = false;
|
|
116
|
+
this.setMod('visible', false);
|
|
117
|
+
|
|
118
|
+
css(this.container, {
|
|
119
|
+
left: -5000
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
override destruct(): void {
|
|
125
|
+
this.__useCount--;
|
|
126
|
+
if (!this.__useCount) {
|
|
127
|
+
this.j?.e.off('.tooltip');
|
|
128
|
+
this.__close();
|
|
129
|
+
super.destruct();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
package/src/core/ui/element.ts
CHANGED
|
@@ -12,15 +12,18 @@ import type {
|
|
|
12
12
|
IDictionary,
|
|
13
13
|
IUIElement,
|
|
14
14
|
IViewBased,
|
|
15
|
-
Nullable
|
|
16
|
-
ModType
|
|
15
|
+
Nullable
|
|
17
16
|
} from 'jodit/types';
|
|
18
17
|
import { Component, ViewComponent } from 'jodit/core/component';
|
|
19
18
|
import { Dom } from 'jodit/core/dom/dom';
|
|
20
19
|
import { Elms, Mods } from 'jodit/core/traits';
|
|
21
20
|
import { isString } from 'jodit/core/helpers/checker/is-string';
|
|
22
21
|
import { Icon } from 'jodit/core/ui/icon';
|
|
22
|
+
import { derive } from 'jodit/core/decorators';
|
|
23
23
|
|
|
24
|
+
export interface UIElement extends Mods, Elms {}
|
|
25
|
+
|
|
26
|
+
@derive(Mods, Elms)
|
|
24
27
|
export abstract class UIElement<T extends IViewBased = IViewBased>
|
|
25
28
|
extends ViewComponent<T>
|
|
26
29
|
implements IUIElement, Mods, Elms
|
|
@@ -112,31 +115,6 @@ export abstract class UIElement<T extends IViewBased = IViewBased>
|
|
|
112
115
|
|
|
113
116
|
readonly mods: IDictionary<string | boolean | null> = {};
|
|
114
117
|
|
|
115
|
-
/** @see [[Mods.setMod]] */
|
|
116
|
-
setMod(
|
|
117
|
-
name: string,
|
|
118
|
-
value: ModType,
|
|
119
|
-
container: HTMLElement = this.container
|
|
120
|
-
): this {
|
|
121
|
-
Mods.setMod.call(this, name, value, container);
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/** @see [[Mods.getMod]] */
|
|
126
|
-
getMod(name: string): ModType {
|
|
127
|
-
return Mods.getMod.call(this, name);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/** @see [[Elms.getElm]]*/
|
|
131
|
-
getElm(elementName: string): Nullable<HTMLElement> {
|
|
132
|
-
return Elms.getElm.call(this, elementName);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** @see [[Elms.getElms]]*/
|
|
136
|
-
getElms(elementName: string): HTMLElement[] {
|
|
137
|
-
return Elms.getElms.call(this, elementName);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
118
|
/**
|
|
141
119
|
* Update UI from state
|
|
142
120
|
*/
|
|
@@ -0,0 +1,44 @@
|
|
|
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-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
describe('Test group ui', () => {
|
|
8
|
+
const { UIGroup, UIButton } = Jodit.modules;
|
|
9
|
+
let editor;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
editor = getJodit();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('UIGroup', () => {
|
|
15
|
+
describe('setMod', () => {
|
|
16
|
+
describe('syncMod === true', () => {
|
|
17
|
+
it('should set mod for all children', () => {
|
|
18
|
+
const group = new UIGroup(editor);
|
|
19
|
+
group.syncMod = true;
|
|
20
|
+
const button = new UIButton(editor);
|
|
21
|
+
const button2 = new UIButton(editor);
|
|
22
|
+
group.append(button);
|
|
23
|
+
group.append(button2);
|
|
24
|
+
group.setMod('test', 123);
|
|
25
|
+
expect(button.getMod('test')).eq(123);
|
|
26
|
+
expect(button2.getMod('test')).eq(123);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('syncMod === false', () => {
|
|
31
|
+
it('should not set mod for all children', () => {
|
|
32
|
+
const group = new UIGroup(editor);
|
|
33
|
+
const button = new UIButton(editor);
|
|
34
|
+
const button2 = new UIButton(editor);
|
|
35
|
+
group.append(button);
|
|
36
|
+
group.append(button2);
|
|
37
|
+
group.setMod('test', 123);
|
|
38
|
+
expect(button.getMod('test')).not.eq(123);
|
|
39
|
+
expect(button2.getMod('test')).not.eq(123);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -16,7 +16,8 @@ import type {
|
|
|
16
16
|
IUIButtonState,
|
|
17
17
|
IUIElement,
|
|
18
18
|
IUIGroup,
|
|
19
|
-
IViewBased
|
|
19
|
+
IViewBased,
|
|
20
|
+
ModType
|
|
20
21
|
} from 'jodit/types';
|
|
21
22
|
import type { IDictionary } from 'jodit/types';
|
|
22
23
|
import { UIElement } from '../element';
|
|
@@ -58,6 +59,7 @@ export class UIGroup<T extends IViewBased = IViewBased>
|
|
|
58
59
|
if (isArray(elm)) {
|
|
59
60
|
stack.push(...elm);
|
|
60
61
|
} else if (Component.isInstanceOf<UIGroup>(elm, UIGroup)) {
|
|
62
|
+
// @ts-ignore
|
|
61
63
|
stack.push(...elm.elements);
|
|
62
64
|
} else {
|
|
63
65
|
elm && result.push(elm);
|
|
@@ -108,12 +110,10 @@ export class UIGroup<T extends IViewBased = IViewBased>
|
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
/** @override */
|
|
111
|
-
override
|
|
113
|
+
override afterSetMod(name: string, value: ModType): void {
|
|
112
114
|
if (this.syncMod) {
|
|
113
115
|
this.elements.forEach(elm => elm.setMod(name, value));
|
|
114
116
|
}
|
|
115
|
-
|
|
116
|
-
return super.setMod(name, value);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
@@ -29,7 +29,7 @@ import { autobind } from 'jodit/core/decorators';
|
|
|
29
29
|
|
|
30
30
|
export abstract class ViewWithToolbar extends View implements IViewWithToolbar {
|
|
31
31
|
TOOLBAR!: IToolbarCollection;
|
|
32
|
-
toolbar: this['TOOLBAR'] = makeCollection(this);
|
|
32
|
+
readonly toolbar: this['TOOLBAR'] = makeCollection(this);
|
|
33
33
|
|
|
34
34
|
private defaultToolbarContainer: HTMLElement =
|
|
35
35
|
this.c.div('jodit-toolbar__box');
|
|
@@ -154,7 +154,7 @@ export abstract class ViewWithToolbar extends View implements IViewWithToolbar {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
override isJodit: boolean = false;
|
|
157
|
+
override readonly isJodit: boolean = false;
|
|
158
158
|
|
|
159
159
|
/** @override **/
|
|
160
160
|
protected constructor(
|
package/src/core/view/view.ts
CHANGED
|
@@ -39,38 +39,21 @@ import {
|
|
|
39
39
|
Create,
|
|
40
40
|
Dom,
|
|
41
41
|
ViewComponent
|
|
42
|
-
} from '
|
|
43
|
-
import { modules } from '
|
|
44
|
-
import { hook } from 'jodit/core/decorators';
|
|
45
|
-
import { Elms, Mods } from '
|
|
46
|
-
import { EventEmitter } from '
|
|
42
|
+
} from 'jodit/modules';
|
|
43
|
+
import { modules } from 'jodit/core/global';
|
|
44
|
+
import { hook, derive } from 'jodit/core/decorators';
|
|
45
|
+
import { Elms, Mods } from 'jodit/core/traits';
|
|
46
|
+
import { EventEmitter } from 'jodit/core/event-emitter';
|
|
47
47
|
|
|
48
|
+
export interface View extends Mods, Elms {}
|
|
49
|
+
|
|
50
|
+
@derive(Mods, Elms)
|
|
48
51
|
export abstract class View extends Component implements IViewBased, Mods, Elms {
|
|
49
52
|
readonly isView = true as const;
|
|
53
|
+
parent: Nullable<IViewBased> = null;
|
|
50
54
|
|
|
51
55
|
readonly mods: IDictionary<string | boolean | null> = {};
|
|
52
56
|
|
|
53
|
-
/** @see [[Mods.setMod]] */
|
|
54
|
-
setMod(...[name, value]: Parameters<typeof Mods.setMod>): this {
|
|
55
|
-
Mods.setMod.call(this, name, value);
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** @see [[Mods.getMod]] */
|
|
60
|
-
getMod(name: string): string | boolean | null {
|
|
61
|
-
return Mods.getMod.call(this, name);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** @see [[Elms.getElm]]*/
|
|
65
|
-
getElm(elementName: string): Nullable<HTMLElement> {
|
|
66
|
-
return Elms.getElm.call(this, elementName);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** @see [[Elms.getElms]]*/
|
|
70
|
-
getElms(elementName: string): HTMLElement[] {
|
|
71
|
-
return Elms.getElms.call(this, elementName);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
57
|
/**
|
|
75
58
|
* ID attribute for source element, id add `{id}_editor` it's editor's id
|
|
76
59
|
*/
|
|
@@ -174,10 +157,7 @@ export abstract class View extends Component implements IViewBased, Mods, Elms {
|
|
|
174
157
|
}
|
|
175
158
|
|
|
176
159
|
this.__isFullSize = isFullSize;
|
|
177
|
-
|
|
178
|
-
if (this.events) {
|
|
179
|
-
this.e.fire('toggleFullSize', isFullSize);
|
|
180
|
-
}
|
|
160
|
+
this.e.fire('toggleFullSize', isFullSize);
|
|
181
161
|
}
|
|
182
162
|
|
|
183
163
|
private __whoLocked: string | false = '';
|
|
@@ -276,9 +256,7 @@ export abstract class View extends Component implements IViewBased, Mods, Elms {
|
|
|
276
256
|
this.events = new EventEmitter(this.od);
|
|
277
257
|
this.create = new Create(this.od);
|
|
278
258
|
|
|
279
|
-
this.container = this.c.div();
|
|
280
|
-
this.container.classList.add('jodit');
|
|
281
|
-
|
|
259
|
+
this.container = this.c.div(`jodit ${this.componentName}`);
|
|
282
260
|
this.progressbar = new ProgressBar(this);
|
|
283
261
|
}
|
|
284
262
|
|
package/src/jodit.ts
CHANGED
|
@@ -40,7 +40,8 @@ import {
|
|
|
40
40
|
Plugin,
|
|
41
41
|
Select,
|
|
42
42
|
StatusBar,
|
|
43
|
-
STATUSES
|
|
43
|
+
STATUSES,
|
|
44
|
+
ViewWithToolbar
|
|
44
45
|
} from './modules/';
|
|
45
46
|
|
|
46
47
|
import {
|
|
@@ -65,11 +66,10 @@ import {
|
|
|
65
66
|
|
|
66
67
|
import { Storage } from './core/storage/';
|
|
67
68
|
|
|
68
|
-
import { Panel } from './core/view/panel';
|
|
69
|
-
|
|
70
69
|
import { lang } from 'jodit/core/constants';
|
|
71
|
-
import { instances, pluginSystem, modules } from './core/global';
|
|
72
|
-
import { autobind, cache, throttle, watch } from './core/decorators';
|
|
70
|
+
import { instances, pluginSystem, modules, eventEmitter } from './core/global';
|
|
71
|
+
import { autobind, cache, throttle, watch, derive } from './core/decorators';
|
|
72
|
+
import { Dlgs } from 'jodit/core/traits';
|
|
73
73
|
|
|
74
74
|
const __defaultStyleDisplayKey = 'data-jodit-default-style-display';
|
|
75
75
|
const __defaultClassesKey = 'data-jodit-default-classes';
|
|
@@ -77,7 +77,10 @@ const __defaultClassesKey = 'data-jodit-default-classes';
|
|
|
77
77
|
/**
|
|
78
78
|
* Class Jodit. Main class
|
|
79
79
|
*/
|
|
80
|
-
export
|
|
80
|
+
export interface Jodit extends Dlgs {}
|
|
81
|
+
|
|
82
|
+
@derive(Dlgs)
|
|
83
|
+
export class Jodit extends ViewWithToolbar implements IJodit, Dlgs {
|
|
81
84
|
/** @override */
|
|
82
85
|
override className(): string {
|
|
83
86
|
return 'Jodit';
|
|
@@ -104,6 +107,12 @@ export class Jodit extends Panel implements IJodit {
|
|
|
104
107
|
});
|
|
105
108
|
}
|
|
106
109
|
|
|
110
|
+
static get ready(): Promise<IJodit> {
|
|
111
|
+
return new Promise(resolve => {
|
|
112
|
+
eventEmitter.on('oditready', resolve);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
107
116
|
/**
|
|
108
117
|
* Define if object is Jodit
|
|
109
118
|
*/
|
|
@@ -744,7 +753,7 @@ export class Jodit extends Panel implements IJodit {
|
|
|
744
753
|
* Execute command editor
|
|
745
754
|
*
|
|
746
755
|
* @param command - command. It supports all the
|
|
747
|
-
*
|
|
756
|
+
* @see https://developer.mozilla.org/ru/docs/Web/API/Document/execCommand#commands and a number of its own
|
|
748
757
|
* for example applyStyleProperty. Comand fontSize receives the second parameter px,
|
|
749
758
|
* formatBlock and can take several options
|
|
750
759
|
* @example
|
|
@@ -763,7 +772,10 @@ export class Jodit extends Panel implements IJodit {
|
|
|
763
772
|
this.s.focus();
|
|
764
773
|
}
|
|
765
774
|
|
|
766
|
-
if (
|
|
775
|
+
if (
|
|
776
|
+
this.o.readonly &&
|
|
777
|
+
!this.o.allowCommandsInReadOnly.includes(command)
|
|
778
|
+
) {
|
|
767
779
|
return;
|
|
768
780
|
}
|
|
769
781
|
|
package/src/langs/ar.js
CHANGED
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
|
17
17
|
'حقوق الطبع والنشر © XDSoft.net - Chupurnov Valeriy. كل الحقوق محفوظة.',
|
|
18
18
|
Anchor: 'مِرْساة',
|
|
19
19
|
'Open in new tab': 'فتح في نافذة جديدة',
|
|
20
|
-
'Open
|
|
20
|
+
'Open in fullsize': 'فتح المحرر في الحجم الكامل',
|
|
21
21
|
'Clear Formatting': 'مسح التنسيق',
|
|
22
22
|
'Fill color or set the text color': 'ملء اللون أو تعيين لون النص',
|
|
23
23
|
Redo: 'إعادة',
|
package/src/langs/cs_cz.js
CHANGED
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
'Copyright © XDSoft.net - Chupurnov Valeriy. Všechna práva vyhrazena.',
|
|
19
19
|
Anchor: 'Anchor',
|
|
20
20
|
'Open in new tab': 'Otevřít v nové záložce',
|
|
21
|
-
'Open
|
|
21
|
+
'Open in fullsize': 'Otevřít v celoobrazovkovém režimu',
|
|
22
22
|
'Clear Formatting': 'Vyčistit formátování',
|
|
23
23
|
'Fill color or set the text color': 'Barva výplně a písma',
|
|
24
24
|
Redo: 'Vpřed',
|
package/src/langs/de.js
CHANGED
|
@@ -19,7 +19,7 @@ module.exports = {
|
|
|
19
19
|
'Copyright © XDSoft.net - Chupurnov Valeriy. Alle Rechte vorbehalten.',
|
|
20
20
|
Anchor: 'Anker',
|
|
21
21
|
'Open in new tab': 'In neuer Registerkarte öffnen',
|
|
22
|
-
'Open
|
|
22
|
+
'Open in fullsize': 'Editor in voller Größe öffnen',
|
|
23
23
|
'Clear Formatting': 'Formatierung löschen',
|
|
24
24
|
'Fill color or set the text color': 'Füllfarbe oder Textfarbe ändern',
|
|
25
25
|
Redo: 'Wiederholen',
|
package/src/langs/es.js
CHANGED
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
'Copyright © XDSoft.net - Chupurnov Valeriy. Todos los derechos reservados.',
|
|
19
19
|
Anchor: 'Anclar',
|
|
20
20
|
'Open in new tab': 'Abrir en nueva pestaña',
|
|
21
|
-
'Open
|
|
21
|
+
'Open in fullsize': 'Abrir editor en pantalla completa',
|
|
22
22
|
'Clear Formatting': 'Limpiar formato',
|
|
23
23
|
'Fill color or set the text color': 'Color de relleno o de letra',
|
|
24
24
|
Redo: 'Rehacer',
|
package/src/langs/fa.js
CHANGED
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
'Copyright © XDSoft.net - Chupurnov Valeriy. Alle Rechte vorbehalten.',
|
|
19
19
|
Anchor: 'لینک',
|
|
20
20
|
'Open in new tab': 'بازکردن در تب جدید',
|
|
21
|
-
'Open
|
|
21
|
+
'Open in fullsize': 'تمام صفحه کردن ویرایشگر',
|
|
22
22
|
'Clear Formatting': 'پاک کردن قالب ها',
|
|
23
23
|
'Fill color or set the text color':
|
|
24
24
|
'رنگ را پر کنید یا رنگ متن را تنظیم کنید',
|
package/src/langs/fr.js
CHANGED
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
|
17
17
|
'Copyright © XDSoft.net - Chupurnov Valeriy. Tous droits réservés.',
|
|
18
18
|
Anchor: 'Ancre',
|
|
19
19
|
'Open in new tab': 'Ouvrir dans un nouvel onglet',
|
|
20
|
-
'Open
|
|
20
|
+
'Open in fullsize': "Ouvrir l'éditeur en pleine page",
|
|
21
21
|
'Clear Formatting': 'Supprimer le formattage',
|
|
22
22
|
'Fill color or set the text color':
|
|
23
23
|
'Modifier la couleur du fond ou du texte',
|
package/src/langs/he.js
CHANGED
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
'Copyright © XDSoft.net - Chupurnov Valeriy. All rights reserved.',
|
|
19
19
|
Anchor: 'מקום עיגון',
|
|
20
20
|
'Open in new tab': 'פתח בכרטיסיה חדשה',
|
|
21
|
-
'Open
|
|
21
|
+
'Open in fullsize': 'פתח את העורך בחלון חדש',
|
|
22
22
|
'Clear Formatting': 'נקה עיצוב',
|
|
23
23
|
'Fill color or set the text color': 'שנה צבע טקסט או רקע',
|
|
24
24
|
Redo: 'בצע שוב',
|
package/src/langs/hu.js
CHANGED
|
@@ -19,7 +19,7 @@ module.exports = {
|
|
|
19
19
|
'Copyright © XDSoft.net - Chupurnov Valeriy. Minden jog fenntartva.',
|
|
20
20
|
Anchor: 'Horgony',
|
|
21
21
|
'Open in new tab': 'Megnyitás új lapon',
|
|
22
|
-
'Open
|
|
22
|
+
'Open in fullsize': 'Megnyitás teljes méretben',
|
|
23
23
|
'Clear Formatting': 'Formázás törlése',
|
|
24
24
|
'Fill color or set the text color': 'Háttér/szöveg szín',
|
|
25
25
|
Redo: 'Újra',
|
package/src/langs/i18n.test.js
CHANGED
|
@@ -4,6 +4,176 @@
|
|
|
4
4
|
* Copyright (c) 2013-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
6
|
describe('Test i18n functionality', function () {
|
|
7
|
+
describe('Helper 18n', function () {
|
|
8
|
+
const i18n = Jodit.modules.Helpers.i18n;
|
|
9
|
+
|
|
10
|
+
describe('Put defined sentence', function () {
|
|
11
|
+
it('Should replace it on defined language', function () {
|
|
12
|
+
const values = [
|
|
13
|
+
'Type something',
|
|
14
|
+
'Напишите что-либо',
|
|
15
|
+
'ru',
|
|
16
|
+
|
|
17
|
+
'rename',
|
|
18
|
+
'Переименовать',
|
|
19
|
+
'ru',
|
|
20
|
+
|
|
21
|
+
'Rename',
|
|
22
|
+
'Переименовать',
|
|
23
|
+
'ru',
|
|
24
|
+
|
|
25
|
+
'About Jodit',
|
|
26
|
+
'حول جوديت',
|
|
27
|
+
'ar',
|
|
28
|
+
|
|
29
|
+
'about Jodit',
|
|
30
|
+
'حول جوديت',
|
|
31
|
+
'ar',
|
|
32
|
+
|
|
33
|
+
'British people',
|
|
34
|
+
'British people',
|
|
35
|
+
'ar'
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
for (let i = 0; i < values.length; i += 3) {
|
|
39
|
+
expect(values[i + 1]).equals(
|
|
40
|
+
i18n(
|
|
41
|
+
values[i],
|
|
42
|
+
[],
|
|
43
|
+
{
|
|
44
|
+
language: values[i + 2]
|
|
45
|
+
},
|
|
46
|
+
true
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('Put some information inside sentence', function () {
|
|
53
|
+
it('Should put this information inside new sentence', function () {
|
|
54
|
+
const values = [
|
|
55
|
+
'Chars: %d',
|
|
56
|
+
'Символов: 1',
|
|
57
|
+
'ru',
|
|
58
|
+
[1],
|
|
59
|
+
'Select %s',
|
|
60
|
+
'Выделить: Test',
|
|
61
|
+
'ru',
|
|
62
|
+
['Test'],
|
|
63
|
+
'select %s',
|
|
64
|
+
'Выделить: Test',
|
|
65
|
+
'ru',
|
|
66
|
+
['Test'],
|
|
67
|
+
'Bla %d Bla %s',
|
|
68
|
+
'Bla 1 Bla boo',
|
|
69
|
+
'ru',
|
|
70
|
+
[1, 'boo'],
|
|
71
|
+
'Bla %d Bla %s',
|
|
72
|
+
'Bla 1 Bla boo',
|
|
73
|
+
'ru1',
|
|
74
|
+
[1, 'boo']
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
for (let i = 0; i < values.length; i += 4) {
|
|
78
|
+
expect(values[i + 1]).equals(
|
|
79
|
+
i18n(
|
|
80
|
+
values[i],
|
|
81
|
+
values[i + 3],
|
|
82
|
+
{
|
|
83
|
+
language: values[i + 2]
|
|
84
|
+
},
|
|
85
|
+
true
|
|
86
|
+
)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const values = [
|
|
94
|
+
'Type something',
|
|
95
|
+
'Напишите что-либо',
|
|
96
|
+
'ru',
|
|
97
|
+
|
|
98
|
+
'About Jodit',
|
|
99
|
+
'حول جوديت',
|
|
100
|
+
'ar',
|
|
101
|
+
|
|
102
|
+
'About Jodit',
|
|
103
|
+
'{About Jodit}',
|
|
104
|
+
'ar1',
|
|
105
|
+
|
|
106
|
+
'British people',
|
|
107
|
+
'{British people}',
|
|
108
|
+
'ar'
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
for (let i = 0; i < values.length; i += 3) {
|
|
112
|
+
const [source, result, language] = [
|
|
113
|
+
values[i],
|
|
114
|
+
values[i + 1],
|
|
115
|
+
values[i + 2]
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
describe(`Debug mode for ${language}`, function () {
|
|
119
|
+
it(`Should show debug brackets for undefined keys for source ${source}`, function () {
|
|
120
|
+
expect(result).equals(
|
|
121
|
+
i18n(
|
|
122
|
+
source,
|
|
123
|
+
[],
|
|
124
|
+
{
|
|
125
|
+
language,
|
|
126
|
+
debugLanguage: true
|
|
127
|
+
},
|
|
128
|
+
true
|
|
129
|
+
)
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
describe('Define i18n property inside input options', function () {
|
|
136
|
+
it('Should use it', function () {
|
|
137
|
+
const values = [
|
|
138
|
+
'Type something',
|
|
139
|
+
'Привет',
|
|
140
|
+
'ru',
|
|
141
|
+
'About Jodit',
|
|
142
|
+
'جوديت',
|
|
143
|
+
'ar',
|
|
144
|
+
'British people',
|
|
145
|
+
'Bond',
|
|
146
|
+
'ar'
|
|
147
|
+
];
|
|
148
|
+
|
|
149
|
+
const opt = {
|
|
150
|
+
ru: {
|
|
151
|
+
'Type something': 'Привет'
|
|
152
|
+
},
|
|
153
|
+
ar: {
|
|
154
|
+
'About Jodit': 'جوديت',
|
|
155
|
+
'British people': 'Bond'
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
for (let i = 0; i < values.length; i += 3) {
|
|
160
|
+
expect(values[i + 1]).equals(
|
|
161
|
+
i18n(
|
|
162
|
+
values[i],
|
|
163
|
+
[],
|
|
164
|
+
{
|
|
165
|
+
language: values[i + 2],
|
|
166
|
+
i18n: opt,
|
|
167
|
+
debugLanguage: true
|
|
168
|
+
},
|
|
169
|
+
true
|
|
170
|
+
)
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
7
177
|
describe('Test has keys in all functionality', function () {
|
|
8
178
|
const filter = [
|
|
9
179
|
'customxxx',
|
package/src/langs/id.js
CHANGED
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
'Hak Cipta © XDSoft.net - Chupurnov Valeriy. Hak cipta dilindungi undang-undang.',
|
|
19
19
|
Anchor: 'Tautan',
|
|
20
20
|
'Open in new tab': 'Buka di tab baru',
|
|
21
|
-
'Open
|
|
21
|
+
'Open in fullsize': 'Buka editor dalam ukuran penuh',
|
|
22
22
|
'Clear Formatting': 'Hapus Pemformatan',
|
|
23
23
|
'Fill color or set the text color': 'Isi warna atau atur warna teks',
|
|
24
24
|
Redo: 'Ulangi',
|