jodit 4.4.7 → 4.4.8
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/CHANGELOG.md +6 -0
- package/es2015/jodit.css +1 -1
- package/es2015/jodit.fat.min.js +2 -2
- package/es2015/jodit.js +71 -35
- package/es2015/jodit.min.js +2 -2
- package/es2015/plugins/debug/debug.css +1 -1
- package/es2015/plugins/debug/debug.js +1 -1
- package/es2015/plugins/debug/debug.min.js +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2018/jodit.css +1 -1
- package/es2018/jodit.fat.min.js +2 -2
- package/es2018/jodit.js +71 -35
- package/es2018/jodit.min.js +2 -2
- package/es2018/plugins/debug/debug.css +1 -1
- package/es2018/plugins/debug/debug.js +1 -1
- package/es2018/plugins/debug/debug.min.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021/jodit.css +1 -1
- package/es2021/jodit.fat.min.js +2 -2
- package/es2021/jodit.js +71 -35
- package/es2021/jodit.min.js +2 -2
- package/es2021/plugins/debug/debug.css +1 -1
- package/es2021/plugins/debug/debug.js +1 -1
- package/es2021/plugins/debug/debug.min.js +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021.en/jodit.css +1 -1
- package/es2021.en/jodit.fat.min.js +2 -2
- package/es2021.en/jodit.js +71 -35
- package/es2021.en/jodit.min.js +2 -2
- package/es2021.en/plugins/debug/debug.css +1 -1
- package/es2021.en/plugins/debug/debug.js +1 -1
- package/es2021.en/plugins/debug/debug.min.js +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es5/5.fat.min.js +1 -1
- package/es5/5.min.js +1 -1
- package/es5/975.fat.min.js +1 -1
- package/es5/975.min.js +1 -1
- package/es5/jodit.css +2 -2
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +71 -35
- package/es5/jodit.min.css +2 -2
- package/es5/jodit.min.js +2 -2
- package/es5/plugins/debug/debug.css +1 -1
- package/es5/plugins/debug/debug.js +1 -1
- package/es5/plugins/debug/debug.min.js +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/esm/core/constants.js +1 -1
- package/esm/core/dom/dom.d.ts +5 -0
- package/esm/core/dom/dom.js +36 -12
- package/esm/plugins/indent/indent.js +34 -22
- package/package.json +1 -1
- package/types/core/dom/dom.d.ts +5 -0
package/esm/core/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
4
|
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
-
export const APP_VERSION = "4.4.
|
|
6
|
+
export const APP_VERSION = "4.4.8";
|
|
7
7
|
// prettier-ignore
|
|
8
8
|
export const ES = "es2020";
|
|
9
9
|
export const IS_ES_MODERN = true;
|
package/esm/core/dom/dom.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export declare class Dom {
|
|
|
18
18
|
* Remove all content from element
|
|
19
19
|
*/
|
|
20
20
|
static detach(node: Nullable<Node>): void;
|
|
21
|
+
/**
|
|
22
|
+
* Wrap all inline next siblings
|
|
23
|
+
*/
|
|
24
|
+
static wrapNextInline(current: Node, tag: Node | HTMLTagNames, editor: IJodit): HTMLElement;
|
|
25
|
+
private static __wrapElements;
|
|
21
26
|
/**
|
|
22
27
|
* Wrap all inline siblings
|
|
23
28
|
*/
|
package/esm/core/dom/dom.js
CHANGED
|
@@ -25,28 +25,25 @@ export class Dom {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Wrap all inline siblings
|
|
28
|
+
* Wrap all inline next siblings
|
|
29
29
|
*/
|
|
30
|
-
static
|
|
31
|
-
let tmp
|
|
30
|
+
static wrapNextInline(current, tag, editor) {
|
|
31
|
+
let tmp;
|
|
32
|
+
const first = current;
|
|
33
|
+
let last = current;
|
|
32
34
|
editor.s.save();
|
|
33
35
|
let needFindNext = false;
|
|
34
|
-
do {
|
|
35
|
-
needFindNext = false;
|
|
36
|
-
tmp = first.previousSibling;
|
|
37
|
-
if (tmp && !Dom.isBlock(tmp)) {
|
|
38
|
-
needFindNext = true;
|
|
39
|
-
first = tmp;
|
|
40
|
-
}
|
|
41
|
-
} while (needFindNext);
|
|
42
36
|
do {
|
|
43
37
|
needFindNext = false;
|
|
44
38
|
tmp = last.nextSibling;
|
|
45
|
-
if (tmp && !Dom.isBlock(tmp)) {
|
|
39
|
+
if (tmp && !Dom.isBlock(tmp) && !Dom.isTag(tmp, 'br')) {
|
|
46
40
|
needFindNext = true;
|
|
47
41
|
last = tmp;
|
|
48
42
|
}
|
|
49
43
|
} while (needFindNext);
|
|
44
|
+
return Dom.__wrapElements(tag, editor, first, last);
|
|
45
|
+
}
|
|
46
|
+
static __wrapElements(tag, editor, first, last) {
|
|
50
47
|
const wrapper = isString(tag) ? editor.createInside.element(tag) : tag;
|
|
51
48
|
if (first.parentNode) {
|
|
52
49
|
first.parentNode.insertBefore(wrapper, first);
|
|
@@ -63,6 +60,33 @@ export class Dom {
|
|
|
63
60
|
editor.s.restore();
|
|
64
61
|
return wrapper;
|
|
65
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Wrap all inline siblings
|
|
65
|
+
*/
|
|
66
|
+
static wrapInline(current, tag, editor) {
|
|
67
|
+
let tmp;
|
|
68
|
+
let first = current;
|
|
69
|
+
let last = current;
|
|
70
|
+
editor.s.save();
|
|
71
|
+
let needFindNext = false;
|
|
72
|
+
do {
|
|
73
|
+
needFindNext = false;
|
|
74
|
+
tmp = first.previousSibling;
|
|
75
|
+
if (tmp && !Dom.isBlock(tmp)) {
|
|
76
|
+
needFindNext = true;
|
|
77
|
+
first = tmp;
|
|
78
|
+
}
|
|
79
|
+
} while (needFindNext);
|
|
80
|
+
do {
|
|
81
|
+
needFindNext = false;
|
|
82
|
+
tmp = last.nextSibling;
|
|
83
|
+
if (tmp && !Dom.isBlock(tmp)) {
|
|
84
|
+
needFindNext = true;
|
|
85
|
+
last = tmp;
|
|
86
|
+
}
|
|
87
|
+
} while (needFindNext);
|
|
88
|
+
return Dom.__wrapElements(tag, editor, first, last);
|
|
89
|
+
}
|
|
66
90
|
/**
|
|
67
91
|
* Wrap node inside another node
|
|
68
92
|
*/
|
|
@@ -3,12 +3,28 @@
|
|
|
3
3
|
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
4
|
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
-
import { BR
|
|
6
|
+
import { BR } from "../../core/constants.js";
|
|
7
7
|
import { Dom } from "../../core/dom/index.js";
|
|
8
8
|
import { pluginSystem } from "../../core/global.js";
|
|
9
|
-
import { attr } from "../../core/helpers/index.js";
|
|
9
|
+
import { attr, call } from "../../core/helpers/utils/index.js";
|
|
10
10
|
import "./config.js";
|
|
11
11
|
import { getKey } from "./helpers.js";
|
|
12
|
+
const applyIndentToBox = (processedElements, currentBox, editor, command) => {
|
|
13
|
+
if (!currentBox) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (processedElements.has(currentBox)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const key = getKey(editor.o.direction, currentBox);
|
|
20
|
+
processedElements.add(currentBox);
|
|
21
|
+
let value = currentBox.style[key] ? parseInt(currentBox.style[key], 10) : 0;
|
|
22
|
+
value += editor.o.indentMargin * (command === 'outdent' ? -1 : 1);
|
|
23
|
+
currentBox.style[key] = value > 0 ? value + 'px' : '';
|
|
24
|
+
if (!attr(currentBox, 'style')) {
|
|
25
|
+
attr(currentBox, 'style', null);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
12
28
|
/**
|
|
13
29
|
* Indents the line containing the selection or insertion point.
|
|
14
30
|
*/
|
|
@@ -22,46 +38,42 @@ export function indent(editor) {
|
|
|
22
38
|
name: 'outdent',
|
|
23
39
|
group: 'indent'
|
|
24
40
|
});
|
|
25
|
-
const
|
|
26
|
-
const processedElements =
|
|
41
|
+
const indentCommand = (command) => {
|
|
42
|
+
const processedElements = new Set();
|
|
43
|
+
const { enter, enterBlock } = editor.o;
|
|
44
|
+
const isBrMode = enter.toLowerCase() === BR;
|
|
45
|
+
const current = editor.s.current();
|
|
46
|
+
if (isBrMode && editor.s.isCollapsed()) {
|
|
47
|
+
if (current) {
|
|
48
|
+
const box = Dom.wrapNextInline(current, enterBlock, editor);
|
|
49
|
+
applyIndentToBox(processedElements, box, editor, command);
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
27
53
|
editor.s.eachSelection((current) => {
|
|
28
54
|
editor.s.save();
|
|
29
55
|
let currentBox = current
|
|
30
56
|
? Dom.up(current, Dom.isBlock, editor.editor)
|
|
31
57
|
: false;
|
|
32
|
-
const { enter } = editor.o;
|
|
33
58
|
if (!currentBox && current) {
|
|
34
|
-
currentBox = Dom.wrapInline
|
|
59
|
+
currentBox = call(!isBrMode ? Dom.wrapInline : Dom.wrapNextInline, current, !isBrMode ? enter.toLowerCase() : enterBlock, editor);
|
|
35
60
|
}
|
|
36
61
|
if (!currentBox) {
|
|
37
62
|
editor.s.restore();
|
|
38
63
|
return false;
|
|
39
64
|
}
|
|
40
|
-
|
|
41
|
-
if (currentBox && !alreadyIndented) {
|
|
42
|
-
const key = getKey(editor.o.direction, currentBox);
|
|
43
|
-
processedElements.push(currentBox);
|
|
44
|
-
let value = currentBox.style[key]
|
|
45
|
-
? parseInt(currentBox.style[key], 10)
|
|
46
|
-
: 0;
|
|
47
|
-
value +=
|
|
48
|
-
editor.o.indentMargin * (command === 'outdent' ? -1 : 1);
|
|
49
|
-
currentBox.style[key] = value > 0 ? value + 'px' : '';
|
|
50
|
-
if (!attr(currentBox, 'style')) {
|
|
51
|
-
attr(currentBox, 'style', null);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
65
|
+
applyIndentToBox(processedElements, currentBox, editor, command);
|
|
54
66
|
editor.s.restore();
|
|
55
67
|
});
|
|
56
68
|
editor.synchronizeValues();
|
|
57
69
|
return false;
|
|
58
70
|
};
|
|
59
71
|
editor.registerCommand('indent', {
|
|
60
|
-
exec:
|
|
72
|
+
exec: indentCommand,
|
|
61
73
|
hotkeys: ['ctrl+]', 'cmd+]']
|
|
62
74
|
});
|
|
63
75
|
editor.registerCommand('outdent', {
|
|
64
|
-
exec:
|
|
76
|
+
exec: indentCommand,
|
|
65
77
|
hotkeys: ['ctrl+[', 'cmd+[']
|
|
66
78
|
});
|
|
67
79
|
}
|
package/package.json
CHANGED
package/types/core/dom/dom.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export declare class Dom {
|
|
|
18
18
|
* Remove all content from element
|
|
19
19
|
*/
|
|
20
20
|
static detach(node: Nullable<Node>): void;
|
|
21
|
+
/**
|
|
22
|
+
* Wrap all inline next siblings
|
|
23
|
+
*/
|
|
24
|
+
static wrapNextInline(current: Node, tag: Node | HTMLTagNames, editor: IJodit): HTMLElement;
|
|
25
|
+
private static __wrapElements;
|
|
21
26
|
/**
|
|
22
27
|
* Wrap all inline siblings
|
|
23
28
|
*/
|