jodit 3.23.3 → 3.24.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/README.md +4 -4
- package/build/jodit.css +8 -3
- package/build/jodit.es2018.css +7 -2
- package/build/jodit.es2018.en.css +7 -2
- package/build/jodit.es2018.en.js +8384 -7869
- package/build/jodit.es2018.en.min.css +1 -1
- package/build/jodit.es2018.en.min.js +1 -1
- package/build/jodit.es2018.js +8384 -7869
- package/build/jodit.es2018.min.css +1 -1
- package/build/jodit.es2018.min.js +1 -1
- package/build/jodit.js +2954 -2414
- package/build/jodit.min.css +2 -2
- package/build/jodit.min.js +1 -1
- package/build/plugins/debug/debug.es2018.en.js +8 -8
- package/build/plugins/debug/debug.es2018.en.min.js +1 -1
- package/build/plugins/debug/debug.es2018.js +8 -8
- package/build/plugins/debug/debug.es2018.min.js +1 -1
- package/build/plugins/debug/debug.js +8 -8
- package/build/plugins/debug/debug.min.js +1 -1
- 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 +38 -38
- package/build/plugins/speech-recognize/speech-recognize.es2018.en.min.js +1 -1
- package/build/plugins/speech-recognize/speech-recognize.es2018.js +38 -38
- package/build/plugins/speech-recognize/speech-recognize.es2018.min.js +1 -1
- package/build/plugins/speech-recognize/speech-recognize.js +30 -30
- package/build/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/build/vdom.css +12 -1
- package/build/vdom.js +1445 -41
- package/package.json +23 -23
- package/src/core/constants.ts +10 -8
- package/src/core/dom/dom.test.js +25 -0
- package/src/core/dom/dom.ts +90 -41
- package/src/core/helpers/checker/has-browser-color-picker.ts +2 -2
- package/src/core/helpers/checker/index.ts +1 -0
- package/src/core/helpers/checker/is-boolean.ts +1 -1
- package/src/core/helpers/checker/is-marker.ts +20 -0
- package/src/core/helpers/normalize/normalize-css-value.ts +19 -0
- package/src/core/helpers/normalize/normalize-node.ts +2 -2
- package/src/core/helpers/size/position.test.js +198 -187
- package/src/core/helpers/utils/css.ts +7 -14
- package/src/core/plugin/plugin.ts +1 -1
- package/src/core/selection/interface.ts +24 -0
- package/src/core/selection/select.ts +69 -29
- package/src/core/selection/selection.test.js +5 -17
- package/src/core/selection/style/api/extract.ts +6 -7
- package/src/core/selection/style/api/finite-state-machine.ts +40 -35
- package/src/core/selection/style/api/get-suit-child.ts +3 -4
- package/src/core/selection/style/api/get-suit-parent.ts +3 -4
- package/src/core/selection/style/api/{element-has-same-style.ts → has-same-style.ts} +25 -6
- package/src/core/selection/style/api/index.ts +6 -6
- package/src/core/selection/style/api/is-inside-invisible-element.ts +1 -1
- package/src/core/selection/style/api/is-normal-node.ts +3 -3
- package/src/core/selection/style/api/is-same-attributes.ts +56 -0
- package/src/core/selection/style/api/is-suit-element.ts +22 -12
- package/src/core/selection/style/api/list/toggle-ordered-list.ts +100 -0
- package/src/core/selection/style/api/list/wrap-list.ts +71 -0
- package/src/core/selection/style/api/toggle-attributes.ts +251 -0
- package/src/core/selection/style/api/unwrap-children.ts +10 -8
- package/src/core/selection/style/api/wrap-unwrapped-text.ts +7 -8
- package/src/core/selection/style/api/{wrap-and-commit-style.ts → wrap.ts} +8 -11
- package/src/core/selection/style/apply-style.ts +32 -181
- package/src/core/selection/style/commit-style.ts +79 -4
- package/src/core/selection/style/style.test.js +457 -128
- package/src/core/selection/style/transactions.ts +256 -0
- package/src/core/ui/button/tooltip/tooltip.test.js +95 -76
- package/src/core/ui/popup/popup.test.js +158 -153
- package/src/{plugins/backspace/interface.d.ts → core/vdom/on-demand.ts} +7 -5
- package/src/core/vdom/render/index.ts +2 -4
- package/src/core/vdom/render/patcher.ts +14 -0
- package/src/core/vdom/v-dom-jodit.less +17 -0
- package/src/core/vdom/v-dom-jodit.ts +102 -3
- package/src/core/view/view.ts +2 -2
- package/src/index.ts +2 -0
- package/src/jodit.ts +5 -1
- package/src/langs/i18n.test.js +221 -216
- package/src/modules/dialog/dialog.less +9 -1
- package/src/modules/dialog/dialog.ts +25 -16
- package/src/modules/file-browser/data-provider.ts +44 -12
- package/src/modules/file-browser/file-browser.test.js +1019 -958
- package/src/modules/file-browser/file-browser.ts +0 -1
- package/src/modules/messages/messages.ts +3 -8
- package/src/plugins/backspace/backspace.test.js +2 -9
- package/src/plugins/backspace/backspace.ts +5 -0
- package/src/plugins/backspace/cases/check-join-neighbors.ts +7 -1
- package/src/plugins/backspace/cases/check-join-two-lists.ts +2 -1
- package/src/plugins/backspace/helpers.ts +9 -1
- package/src/plugins/backspace/interface.ts +31 -0
- package/src/plugins/clean-html/helpers/visitor/filters/fill-empty-paragraph.ts +2 -1
- package/src/plugins/color/color.test.js +122 -119
- package/src/plugins/enter/enter.test.js +18 -5
- package/src/plugins/enter/enter.ts +9 -5
- package/src/plugins/enter/interface.ts +41 -0
- package/src/plugins/font/config.ts +8 -8
- package/src/plugins/font/font.test.js +18 -23
- package/src/plugins/hotkeys/hotkeys.test.js +35 -47
- package/src/plugins/iframe/iframe.test.js +206 -195
- package/src/plugins/image/image.ts +1 -1
- package/src/plugins/image-properties/config.ts +22 -0
- package/src/plugins/image-properties/image-properties.test.js +174 -93
- package/src/plugins/image-properties/templates/position-tab.ts +22 -1
- package/src/plugins/indent/indent.test.js +2 -8
- package/src/plugins/link/link.test.js +19 -0
- package/src/plugins/link/link.ts +25 -15
- package/src/plugins/placeholder/placeholder.ts +8 -7
- package/src/plugins/size/size.test.js +239 -225
- package/src/plugins/tab/cases/on-tab-inside-li.ts +131 -22
- package/src/plugins/tab/tab.test.js +95 -11
- package/src/plugins/tab/tab.ts +22 -2
- package/src/plugins/wrap-nodes/config.ts +11 -0
- package/src/plugins/wrap-nodes/wrap-nodes.ts +0 -1
- package/src/types/events.d.ts +4 -0
- package/src/types/file-browser.d.ts +17 -10
- package/src/types/select.d.ts +6 -1
- package/src/types/style.d.ts +72 -5
- package/src/types/uploader.d.ts +14 -0
- package/src/types/view.d.ts +2 -2
- package/types/core/async/async.d.ts +1 -1
- package/types/core/constants.d.ts +3 -3
- package/types/core/dom/dom.d.ts +6 -3
- package/types/core/helpers/checker/index.d.ts +1 -0
- package/types/core/helpers/checker/is-boolean.d.ts +1 -1
- package/types/core/helpers/checker/is-marker.d.ts +10 -0
- package/types/core/helpers/html/safe-html.d.ts +1 -1
- package/types/core/helpers/normalize/normalize-css-value.d.ts +2 -0
- package/types/core/helpers/normalize/normalize-node.d.ts +1 -1
- package/types/core/helpers/utils/append-script.d.ts +1 -1
- package/types/core/selection/interface.d.ts +19 -0
- package/types/core/selection/select.d.ts +22 -5
- package/types/core/selection/style/api/finite-state-machine.d.ts +10 -9
- package/types/core/selection/style/api/get-suit-child.d.ts +2 -3
- package/types/core/selection/style/api/get-suit-parent.d.ts +2 -3
- package/types/core/selection/style/api/{element-has-same-style.d.ts → has-same-style.d.ts} +2 -2
- package/types/core/selection/style/api/index.d.ts +6 -6
- package/types/core/selection/style/api/is-same-attributes.d.ts +12 -0
- package/types/core/selection/style/api/is-suit-element.d.ts +4 -4
- package/types/core/selection/style/api/{toggle → list}/toggle-ordered-list.d.ts +2 -3
- package/types/core/selection/style/api/{wrap-ordered-list.d.ts → list/wrap-list.d.ts} +2 -3
- package/types/core/selection/style/api/toggle-attributes.d.ts +11 -0
- package/types/core/selection/style/api/unwrap-children.d.ts +2 -2
- package/types/core/selection/style/api/wrap-unwrapped-text.d.ts +2 -3
- package/types/core/selection/style/api/{wrap-and-commit-style.d.ts → wrap.d.ts} +2 -3
- package/types/core/selection/style/apply-style.d.ts +3 -3
- package/types/core/selection/style/commit-style.d.ts +6 -2
- package/types/core/selection/style/transactions.d.ts +29 -0
- package/types/core/ui/popup/popup.d.ts +1 -1
- package/types/core/view/view.d.ts +1 -1
- package/types/index.d.ts +2 -0
- package/types/modules/file-browser/builders/elements-map.d.ts +1 -1
- package/types/modules/file-browser/data-provider.d.ts +5 -0
- package/types/modules/messages/messages.d.ts +2 -1
- package/types/plugins/backspace/helpers.d.ts +5 -1
- package/types/plugins/backspace/interface.d.ts +21 -0
- package/types/plugins/enter/enter.d.ts +2 -0
- package/types/plugins/enter/interface.d.ts +32 -0
- package/types/plugins/image-properties/config.d.ts +19 -0
- package/types/plugins/link/link.d.ts +1 -1
- package/types/plugins/paste/interface.d.ts +2 -2
- package/types/plugins/tab/cases/on-tab-inside-li.d.ts +1 -1
- package/types/plugins/wrap-nodes/config.d.ts +10 -0
- package/types/types/events.d.ts +4 -0
- package/types/types/file-browser.d.ts +17 -10
- package/types/types/select.d.ts +6 -1
- package/types/types/storage.d.ts +1 -1
- package/types/types/style.d.ts +72 -5
- package/types/types/uploader.d.ts +14 -0
- package/types/types/view.d.ts +2 -2
- package/vdom.html +20 -0
- package/src/core/selection/style/api/toggle/toggle-css.ts +0 -136
- package/src/core/selection/style/api/toggle/toggle-ordered-list.ts +0 -54
- package/src/core/selection/style/api/toggle-commit-styles.ts +0 -35
- package/src/core/selection/style/api/wrap-ordered-list.ts +0 -42
- package/types/core/selection/style/api/toggle/toggle-css.d.ts +0 -12
- package/types/core/selection/style/api/toggle-commit-styles.d.ts +0 -13
|
@@ -3,126 +3,101 @@
|
|
|
3
3
|
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
4
|
* Copyright (c) 2013-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
6
|
+
('popup' in window.skipTest ? describe.skip : describe)(
|
|
7
|
+
'Test popup',
|
|
8
|
+
function () {
|
|
9
|
+
const position = Jodit.modules.Helpers.position;
|
|
10
|
+
|
|
11
|
+
let textBox;
|
|
12
|
+
const elms = [];
|
|
13
|
+
|
|
14
|
+
beforeEach(function () {
|
|
15
|
+
textBox = document.createElement('div');
|
|
16
|
+
Object.assign(textBox.style, {
|
|
17
|
+
position: 'fixed',
|
|
18
|
+
display: 'flex',
|
|
19
|
+
flexWrap: 'wrap',
|
|
20
|
+
top: 0,
|
|
21
|
+
left: 0,
|
|
22
|
+
width: '100%',
|
|
23
|
+
height: '100%',
|
|
24
|
+
background: 'red'
|
|
25
|
+
});
|
|
26
|
+
document.body.appendChild(textBox);
|
|
27
|
+
|
|
28
|
+
for (let i = 0; i < 4; i += 1) {
|
|
29
|
+
for (let j = 0; j < 4; j += 1) {
|
|
30
|
+
const elmBox = document.createElement('div');
|
|
31
|
+
|
|
32
|
+
Object.assign(elmBox.style, {
|
|
33
|
+
width: '25%',
|
|
34
|
+
height: '25%',
|
|
35
|
+
background:
|
|
36
|
+
'rgb(' +
|
|
37
|
+
(i * 30 + 128) +
|
|
38
|
+
',' +
|
|
39
|
+
(j * 30 + 28) +
|
|
40
|
+
', ' +
|
|
41
|
+
(i * 10 + j * 10 + 100) +
|
|
42
|
+
')'
|
|
43
|
+
});
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
textBox.appendChild(elmBox);
|
|
46
|
+
elms.push(elmBox);
|
|
47
|
+
}
|
|
45
48
|
}
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
afterEach(function () {
|
|
50
|
-
textBox && textBox.remove();
|
|
51
|
-
elms.length = 0;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const aliases = {
|
|
55
|
-
leftTop: function () {
|
|
56
|
-
return elms[0];
|
|
57
|
-
},
|
|
58
|
-
rightTop: function () {
|
|
59
|
-
return elms[3];
|
|
60
|
-
},
|
|
61
|
-
leftBottom: function () {
|
|
62
|
-
return elms[12];
|
|
63
|
-
},
|
|
64
|
-
rightBottom: function () {
|
|
65
|
-
return elms[15];
|
|
66
|
-
},
|
|
67
|
-
center: function () {
|
|
68
|
-
return elms[5];
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const openPopup = function (getBound, content, strategy) {
|
|
73
|
-
const editor = getJodit();
|
|
74
|
-
|
|
75
|
-
const popup = new Jodit.modules.Popup(editor);
|
|
76
|
-
|
|
77
|
-
if (strategy) {
|
|
78
|
-
popup.strategy = strategy;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
popup.setContent(content || 'Test content').open(getBound);
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
left: parseInt(popup.container.style.left, 10),
|
|
85
|
-
top: parseInt(popup.container.style.top, 10),
|
|
86
|
-
width: popup.container.offsetWidth,
|
|
87
|
-
height: popup.container.offsetHeight
|
|
88
|
-
};
|
|
89
|
-
};
|
|
49
|
+
});
|
|
90
50
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
div.innerText = 'test';
|
|
51
|
+
afterEach(function () {
|
|
52
|
+
textBox && textBox.remove();
|
|
53
|
+
elms.length = 0;
|
|
54
|
+
});
|
|
96
55
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
56
|
+
const aliases = {
|
|
57
|
+
leftTop: function () {
|
|
58
|
+
return elms[0];
|
|
59
|
+
},
|
|
60
|
+
rightTop: function () {
|
|
61
|
+
return elms[3];
|
|
62
|
+
},
|
|
63
|
+
leftBottom: function () {
|
|
64
|
+
return elms[12];
|
|
65
|
+
},
|
|
66
|
+
rightBottom: function () {
|
|
67
|
+
return elms[15];
|
|
68
|
+
},
|
|
69
|
+
center: function () {
|
|
70
|
+
return elms[5];
|
|
71
|
+
}
|
|
72
|
+
};
|
|
100
73
|
|
|
101
|
-
|
|
74
|
+
const openPopup = function (getBound, content, strategy) {
|
|
75
|
+
const editor = getJodit();
|
|
102
76
|
|
|
103
|
-
|
|
104
|
-
expect(pos.top).equals(gb().top + gb().height);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
77
|
+
const popup = new Jodit.modules.Popup(editor);
|
|
107
78
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const gb = function () {
|
|
112
|
-
return position(aliases.center());
|
|
113
|
-
};
|
|
79
|
+
if (strategy) {
|
|
80
|
+
popup.strategy = strategy;
|
|
81
|
+
}
|
|
114
82
|
|
|
115
|
-
|
|
83
|
+
popup.setContent(content || 'Test content').open(getBound);
|
|
116
84
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
85
|
+
return {
|
|
86
|
+
left: parseInt(popup.container.style.left, 10),
|
|
87
|
+
top: parseInt(popup.container.style.top, 10),
|
|
88
|
+
width: popup.container.offsetWidth,
|
|
89
|
+
height: popup.container.offsetHeight
|
|
90
|
+
};
|
|
91
|
+
};
|
|
121
92
|
|
|
122
|
-
|
|
93
|
+
describe('Open popup on some target', function () {
|
|
94
|
+
describe('Usual case - there is enough space under element', function () {
|
|
123
95
|
it('should show popup under element', function () {
|
|
96
|
+
const div = appendTestDiv();
|
|
97
|
+
div.innerText = 'test';
|
|
98
|
+
|
|
124
99
|
const gb = function () {
|
|
125
|
-
return position(
|
|
100
|
+
return position(div);
|
|
126
101
|
};
|
|
127
102
|
|
|
128
103
|
const pos = openPopup(gb);
|
|
@@ -132,80 +107,110 @@ describe('Test popup', function () {
|
|
|
132
107
|
});
|
|
133
108
|
});
|
|
134
109
|
|
|
135
|
-
describe('
|
|
136
|
-
describe('
|
|
137
|
-
it('should show popup
|
|
110
|
+
describe('Corners', function () {
|
|
111
|
+
describe('Change default strategy', function () {
|
|
112
|
+
it('should show popup to match the strategy', function () {
|
|
138
113
|
const gb = function () {
|
|
139
|
-
return position(aliases.
|
|
114
|
+
return position(aliases.center());
|
|
140
115
|
};
|
|
141
116
|
|
|
142
|
-
const pos = openPopup(gb);
|
|
117
|
+
const pos = openPopup(gb, false, 'rightBottom');
|
|
143
118
|
|
|
144
|
-
expect(pos.left).equals(
|
|
119
|
+
expect(pos.left + pos.width).equals(
|
|
120
|
+
gb().left + gb().width
|
|
121
|
+
);
|
|
145
122
|
expect(pos.top).equals(gb().top + gb().height);
|
|
146
123
|
});
|
|
147
124
|
});
|
|
148
125
|
|
|
149
|
-
describe('
|
|
150
|
-
it(
|
|
126
|
+
describe('Left-Top', function () {
|
|
127
|
+
it('should show popup under element', function () {
|
|
151
128
|
const gb = function () {
|
|
152
|
-
return position(aliases.
|
|
129
|
+
return position(aliases.leftTop());
|
|
153
130
|
};
|
|
154
131
|
|
|
155
|
-
const pos = openPopup(gb
|
|
132
|
+
const pos = openPopup(gb);
|
|
156
133
|
|
|
157
|
-
expect(pos.left
|
|
158
|
-
gb().left + gb().width
|
|
159
|
-
);
|
|
134
|
+
expect(pos.left).equals(gb().left);
|
|
160
135
|
expect(pos.top).equals(gb().top + gb().height);
|
|
161
136
|
});
|
|
162
137
|
});
|
|
163
|
-
});
|
|
164
138
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
139
|
+
describe('Right-Top', function () {
|
|
140
|
+
describe('Small popup', function () {
|
|
141
|
+
it('should show popup under element', function () {
|
|
142
|
+
const gb = function () {
|
|
143
|
+
return position(aliases.rightTop());
|
|
144
|
+
};
|
|
171
145
|
|
|
172
|
-
|
|
146
|
+
const pos = openPopup(gb);
|
|
173
147
|
|
|
174
|
-
|
|
175
|
-
|
|
148
|
+
expect(pos.left).equals(gb().left);
|
|
149
|
+
expect(pos.top).equals(gb().top + gb().height);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
describe('Big popup', function () {
|
|
154
|
+
it("should show popup under element but right corner should be under target's right-bottom corner", function () {
|
|
155
|
+
const gb = function () {
|
|
156
|
+
return position(aliases.rightTop());
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const pos = openPopup(gb, 'testO'.repeat(30));
|
|
160
|
+
|
|
161
|
+
expect(pos.left + pos.width).equals(
|
|
162
|
+
gb().left + gb().width
|
|
163
|
+
);
|
|
164
|
+
expect(pos.top).equals(gb().top + gb().height);
|
|
165
|
+
});
|
|
176
166
|
});
|
|
177
167
|
});
|
|
178
|
-
});
|
|
179
168
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
169
|
+
describe('Left-Bottom', function () {
|
|
170
|
+
describe('Small popup', function () {
|
|
171
|
+
it('should show popup above element', function () {
|
|
172
|
+
const gb = function () {
|
|
173
|
+
return position(aliases.leftBottom());
|
|
174
|
+
};
|
|
186
175
|
|
|
187
|
-
|
|
176
|
+
const pos = openPopup(gb);
|
|
188
177
|
|
|
189
|
-
|
|
190
|
-
|
|
178
|
+
expect(pos.left).equals(gb().left);
|
|
179
|
+
expect(pos.top + pos.height).equals(gb().top);
|
|
180
|
+
});
|
|
191
181
|
});
|
|
192
182
|
});
|
|
193
183
|
|
|
194
|
-
describe('
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
184
|
+
describe('Right-Bottom', function () {
|
|
185
|
+
describe('Small popup', function () {
|
|
186
|
+
it('should show popup above element', function () {
|
|
187
|
+
const gb = function () {
|
|
188
|
+
return position(aliases.rightBottom());
|
|
189
|
+
};
|
|
199
190
|
|
|
200
|
-
|
|
191
|
+
const pos = openPopup(gb);
|
|
201
192
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
);
|
|
205
|
-
|
|
193
|
+
expect(pos.left).equals(gb().left);
|
|
194
|
+
expect(pos.top + pos.height).equals(gb().top);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
describe('Big popup', function () {
|
|
199
|
+
it("should show popup above the element but right corner should be above target's right-top corner", function () {
|
|
200
|
+
const gb = function () {
|
|
201
|
+
return position(aliases.rightBottom());
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const pos = openPopup(gb, 'testO'.repeat(30));
|
|
205
|
+
|
|
206
|
+
expect(pos.left + pos.width).equals(
|
|
207
|
+
gb().left + gb().width
|
|
208
|
+
);
|
|
209
|
+
expect(pos.top + pos.height).equals(gb().top);
|
|
210
|
+
});
|
|
206
211
|
});
|
|
207
212
|
});
|
|
208
213
|
});
|
|
209
214
|
});
|
|
210
|
-
}
|
|
211
|
-
|
|
215
|
+
}
|
|
216
|
+
);
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* Copyright (c) 2013-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
class OnDemand {
|
|
8
|
+
state: {
|
|
9
|
+
cursor: {
|
|
10
|
+
startContainer;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -98,7 +98,7 @@ export class VDomRender {
|
|
|
98
98
|
|
|
99
99
|
private commitDeletion(fiber: CanUndef<IFiber>, domParent: Node): void {
|
|
100
100
|
if (fiber?.dom) {
|
|
101
|
-
domParent.removeChild(fiber.dom);
|
|
101
|
+
fiber.dom.isConnected && domParent.removeChild(fiber.dom);
|
|
102
102
|
} else {
|
|
103
103
|
this.commitDeletion(fiber?.child, domParent);
|
|
104
104
|
}
|
|
@@ -232,8 +232,6 @@ export class VDomRender {
|
|
|
232
232
|
const box = document.createElement('div');
|
|
233
233
|
box.innerHTML = html;
|
|
234
234
|
|
|
235
|
-
return domToVDom(
|
|
236
|
-
box.children.length > 1 || !box.firstChild ? box : box.firstChild
|
|
237
|
-
);
|
|
235
|
+
return domToVDom(box);
|
|
238
236
|
}
|
|
239
237
|
}
|
|
@@ -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-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { VDomRender } from './index';
|
|
8
|
+
|
|
9
|
+
export class Patcher {
|
|
10
|
+
constructor(
|
|
11
|
+
private readonly render: VDomRender,
|
|
12
|
+
private readonly updateWip: () => void
|
|
13
|
+
) {}
|
|
14
|
+
}
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
.jodit-v-dom-container {
|
|
2
|
+
display: flex;
|
|
2
3
|
min-height: 100px;
|
|
3
4
|
padding: 10px;
|
|
4
5
|
border: 1px solid #ccc;
|
|
5
6
|
|
|
7
|
+
> * {
|
|
8
|
+
width: 33.3333%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
> *:not(:nth-child(1)) {
|
|
12
|
+
padding-left: 10px;
|
|
13
|
+
border-left: 1px solid #ccc;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.jodit-v-dom-editor {
|
|
17
|
+
outline: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.jodit-v-dom-ast-mirror {
|
|
21
|
+
}
|
|
22
|
+
|
|
6
23
|
&:empty {
|
|
7
24
|
&:before {
|
|
8
25
|
content: 'Test';
|
|
@@ -6,28 +6,67 @@
|
|
|
6
6
|
|
|
7
7
|
import './v-dom-jodit.less';
|
|
8
8
|
|
|
9
|
+
import type { IEventEmitter } from '../../types';
|
|
9
10
|
import type { IVDom } from './interface';
|
|
10
11
|
import { VDomRender } from './render';
|
|
12
|
+
import { EventEmitter } from '../event-emitter';
|
|
11
13
|
|
|
12
14
|
export class VDomJodit {
|
|
13
15
|
private container: HTMLElement;
|
|
16
|
+
private editor: HTMLElement;
|
|
17
|
+
private mirror: HTMLElement;
|
|
18
|
+
private astMirror: HTMLElement;
|
|
14
19
|
|
|
15
20
|
private vdom!: IVDom;
|
|
16
21
|
|
|
17
22
|
private render: VDomRender = new VDomRender();
|
|
23
|
+
private render2: VDomRender = new VDomRender();
|
|
24
|
+
private event: IEventEmitter = new EventEmitter();
|
|
18
25
|
|
|
19
26
|
set value(v: string) {
|
|
20
27
|
this.vdom = this.render.htmlToVDom(v);
|
|
21
|
-
this.render.render(this.vdom, this.
|
|
28
|
+
this.render.render(this.vdom, this.editor);
|
|
22
29
|
}
|
|
23
30
|
|
|
24
31
|
private constructor(elm: HTMLInputElement) {
|
|
25
32
|
this.container = document.createElement('div');
|
|
33
|
+
this.editor = document.createElement('div');
|
|
34
|
+
this.mirror = document.createElement('div');
|
|
35
|
+
this.astMirror = document.createElement('pre');
|
|
26
36
|
elm.style.display = 'none';
|
|
27
37
|
elm.parentElement?.insertBefore(this.container, elm);
|
|
28
|
-
this.
|
|
38
|
+
this.editor.setAttribute('contenteditable', 'true');
|
|
39
|
+
|
|
29
40
|
this.container.classList.add('jodit-v-dom-container');
|
|
41
|
+
this.editor.classList.add('jodit-v-dom-editor');
|
|
42
|
+
this.astMirror.classList.add('jodit-v-dom-ast-mirror');
|
|
43
|
+
this.container.appendChild(this.editor);
|
|
44
|
+
this.container.appendChild(this.astMirror);
|
|
45
|
+
this.container.appendChild(this.mirror);
|
|
30
46
|
this.value = elm.value;
|
|
47
|
+
this.event.on(document, 'selectionchange', () => {
|
|
48
|
+
console.log(111);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
document.execCommand('defaultParagraphSeparator', false, 'p');
|
|
52
|
+
|
|
53
|
+
const config = {
|
|
54
|
+
attributes: true,
|
|
55
|
+
childList: true,
|
|
56
|
+
subtree: true,
|
|
57
|
+
characterData: true
|
|
58
|
+
};
|
|
59
|
+
const callback = (mutationList: MutationRecord[]): void => {
|
|
60
|
+
for (const mutation of mutationList) {
|
|
61
|
+
console.log(mutation);
|
|
62
|
+
}
|
|
63
|
+
const vdom = this.render2.htmlToVDom(this.editor.innerHTML);
|
|
64
|
+
this.astMirror.textContent = JSON.stringify(vdom, null, ' ');
|
|
65
|
+
|
|
66
|
+
this.render2.render(vdom, this.mirror);
|
|
67
|
+
};
|
|
68
|
+
const observer = new MutationObserver(callback);
|
|
69
|
+
observer.observe(this.editor, config);
|
|
31
70
|
|
|
32
71
|
this.preventAllInputEvents();
|
|
33
72
|
}
|
|
@@ -38,7 +77,67 @@ export class VDomJodit {
|
|
|
38
77
|
|
|
39
78
|
private preventAllInputEvents(): void {
|
|
40
79
|
this.container.addEventListener('keydown', e => {
|
|
41
|
-
e.preventDefault();
|
|
80
|
+
// e.preventDefault();
|
|
42
81
|
});
|
|
43
82
|
}
|
|
44
83
|
}
|
|
84
|
+
|
|
85
|
+
const vdom = {
|
|
86
|
+
type: 'div',
|
|
87
|
+
props: {
|
|
88
|
+
children: [
|
|
89
|
+
{
|
|
90
|
+
type: 'h1',
|
|
91
|
+
props: {
|
|
92
|
+
style: { color: '#f00' },
|
|
93
|
+
children: [
|
|
94
|
+
{
|
|
95
|
+
type: 'TEXT_ELEMENT',
|
|
96
|
+
props: {
|
|
97
|
+
nodeValue: 'This is a title'
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
type: 'p',
|
|
105
|
+
props: {
|
|
106
|
+
className: 'test',
|
|
107
|
+
children: [
|
|
108
|
+
{
|
|
109
|
+
type: 'TEXT_ELEMENT',
|
|
110
|
+
props: {
|
|
111
|
+
nodeValue: 'This is a paragraph'
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const state = {
|
|
121
|
+
cursor: {
|
|
122
|
+
startContainer: vdom.props.children[0].props.children[0],
|
|
123
|
+
startOffset: 0
|
|
124
|
+
},
|
|
125
|
+
vdom
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export function insertChar(char: string): void {
|
|
129
|
+
const { startContainer, startOffset } = state.cursor;
|
|
130
|
+
const text = startContainer.props.nodeValue;
|
|
131
|
+
const before = text.slice(0, startOffset);
|
|
132
|
+
const after = text.slice(startOffset);
|
|
133
|
+
startContainer.props.nodeValue = before + char + after;
|
|
134
|
+
state.cursor.startOffset += 1;
|
|
135
|
+
|
|
136
|
+
// wipRoot = {
|
|
137
|
+
// dom: startContainer.dom,
|
|
138
|
+
// props: startContainer.props,
|
|
139
|
+
// }
|
|
140
|
+
//
|
|
141
|
+
// nextUnitOfWork = wipRoot
|
|
142
|
+
// deletions = []
|
|
143
|
+
}
|
package/src/core/view/view.ts
CHANGED
|
@@ -94,7 +94,7 @@ export abstract class View extends Component implements IViewBased, Mods, Elms {
|
|
|
94
94
|
*/
|
|
95
95
|
readonly buffer: IStorage = Storage.makeStorage();
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
message: IMessages;
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Container for persistent set/get value
|
|
@@ -262,7 +262,7 @@ export abstract class View extends Component implements IViewBased, Mods, Elms {
|
|
|
262
262
|
|
|
263
263
|
this.container = this.c.div(`jodit ${this.componentName}`);
|
|
264
264
|
this.progressbar = new ProgressBar(this);
|
|
265
|
-
this.message = new UIMessages(this);
|
|
265
|
+
this.message = new UIMessages(this, this.container);
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
private __modulesInstances: Map<string, IComponent> = new Map();
|
package/src/index.ts
CHANGED
package/src/jodit.ts
CHANGED
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
Select,
|
|
46
46
|
StatusBar,
|
|
47
47
|
STATUSES,
|
|
48
|
+
UIMessages,
|
|
48
49
|
ViewWithToolbar
|
|
49
50
|
} from 'jodit/modules/';
|
|
50
51
|
|
|
@@ -169,7 +170,7 @@ export class Jodit extends ViewWithToolbar implements IJodit, Dlgs {
|
|
|
169
170
|
* Factory for creating Jodit instance
|
|
170
171
|
*/
|
|
171
172
|
static make(element: HTMLElement | string, options?: object): Jodit {
|
|
172
|
-
return new
|
|
173
|
+
return new this(element, options);
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
/**
|
|
@@ -1359,6 +1360,9 @@ export class Jodit extends ViewWithToolbar implements IJodit, Dlgs {
|
|
|
1359
1360
|
|
|
1360
1361
|
container.appendChild(workplace);
|
|
1361
1362
|
|
|
1363
|
+
this.message.destruct();
|
|
1364
|
+
this.message = new UIMessages(this, workplace);
|
|
1365
|
+
|
|
1362
1366
|
if (element.parentNode && element !== container) {
|
|
1363
1367
|
element.parentNode.insertBefore(container, element);
|
|
1364
1368
|
}
|