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.
Files changed (175) hide show
  1. package/README.md +4 -4
  2. package/build/jodit.css +8 -3
  3. package/build/jodit.es2018.css +7 -2
  4. package/build/jodit.es2018.en.css +7 -2
  5. package/build/jodit.es2018.en.js +8384 -7869
  6. package/build/jodit.es2018.en.min.css +1 -1
  7. package/build/jodit.es2018.en.min.js +1 -1
  8. package/build/jodit.es2018.js +8384 -7869
  9. package/build/jodit.es2018.min.css +1 -1
  10. package/build/jodit.es2018.min.js +1 -1
  11. package/build/jodit.js +2954 -2414
  12. package/build/jodit.min.css +2 -2
  13. package/build/jodit.min.js +1 -1
  14. package/build/plugins/debug/debug.es2018.en.js +8 -8
  15. package/build/plugins/debug/debug.es2018.en.min.js +1 -1
  16. package/build/plugins/debug/debug.es2018.js +8 -8
  17. package/build/plugins/debug/debug.es2018.min.js +1 -1
  18. package/build/plugins/debug/debug.js +8 -8
  19. package/build/plugins/debug/debug.min.js +1 -1
  20. package/build/plugins/speech-recognize/speech-recognize.css +1 -1
  21. package/build/plugins/speech-recognize/speech-recognize.es2018.css +1 -1
  22. package/build/plugins/speech-recognize/speech-recognize.es2018.en.css +1 -1
  23. package/build/plugins/speech-recognize/speech-recognize.es2018.en.js +38 -38
  24. package/build/plugins/speech-recognize/speech-recognize.es2018.en.min.js +1 -1
  25. package/build/plugins/speech-recognize/speech-recognize.es2018.js +38 -38
  26. package/build/plugins/speech-recognize/speech-recognize.es2018.min.js +1 -1
  27. package/build/plugins/speech-recognize/speech-recognize.js +30 -30
  28. package/build/plugins/speech-recognize/speech-recognize.min.js +1 -1
  29. package/build/vdom.css +12 -1
  30. package/build/vdom.js +1445 -41
  31. package/package.json +23 -23
  32. package/src/core/constants.ts +10 -8
  33. package/src/core/dom/dom.test.js +25 -0
  34. package/src/core/dom/dom.ts +90 -41
  35. package/src/core/helpers/checker/has-browser-color-picker.ts +2 -2
  36. package/src/core/helpers/checker/index.ts +1 -0
  37. package/src/core/helpers/checker/is-boolean.ts +1 -1
  38. package/src/core/helpers/checker/is-marker.ts +20 -0
  39. package/src/core/helpers/normalize/normalize-css-value.ts +19 -0
  40. package/src/core/helpers/normalize/normalize-node.ts +2 -2
  41. package/src/core/helpers/size/position.test.js +198 -187
  42. package/src/core/helpers/utils/css.ts +7 -14
  43. package/src/core/plugin/plugin.ts +1 -1
  44. package/src/core/selection/interface.ts +24 -0
  45. package/src/core/selection/select.ts +69 -29
  46. package/src/core/selection/selection.test.js +5 -17
  47. package/src/core/selection/style/api/extract.ts +6 -7
  48. package/src/core/selection/style/api/finite-state-machine.ts +40 -35
  49. package/src/core/selection/style/api/get-suit-child.ts +3 -4
  50. package/src/core/selection/style/api/get-suit-parent.ts +3 -4
  51. package/src/core/selection/style/api/{element-has-same-style.ts → has-same-style.ts} +25 -6
  52. package/src/core/selection/style/api/index.ts +6 -6
  53. package/src/core/selection/style/api/is-inside-invisible-element.ts +1 -1
  54. package/src/core/selection/style/api/is-normal-node.ts +3 -3
  55. package/src/core/selection/style/api/is-same-attributes.ts +56 -0
  56. package/src/core/selection/style/api/is-suit-element.ts +22 -12
  57. package/src/core/selection/style/api/list/toggle-ordered-list.ts +100 -0
  58. package/src/core/selection/style/api/list/wrap-list.ts +71 -0
  59. package/src/core/selection/style/api/toggle-attributes.ts +251 -0
  60. package/src/core/selection/style/api/unwrap-children.ts +10 -8
  61. package/src/core/selection/style/api/wrap-unwrapped-text.ts +7 -8
  62. package/src/core/selection/style/api/{wrap-and-commit-style.ts → wrap.ts} +8 -11
  63. package/src/core/selection/style/apply-style.ts +32 -181
  64. package/src/core/selection/style/commit-style.ts +79 -4
  65. package/src/core/selection/style/style.test.js +457 -128
  66. package/src/core/selection/style/transactions.ts +256 -0
  67. package/src/core/ui/button/tooltip/tooltip.test.js +95 -76
  68. package/src/core/ui/popup/popup.test.js +158 -153
  69. package/src/{plugins/backspace/interface.d.ts → core/vdom/on-demand.ts} +7 -5
  70. package/src/core/vdom/render/index.ts +2 -4
  71. package/src/core/vdom/render/patcher.ts +14 -0
  72. package/src/core/vdom/v-dom-jodit.less +17 -0
  73. package/src/core/vdom/v-dom-jodit.ts +102 -3
  74. package/src/core/view/view.ts +2 -2
  75. package/src/index.ts +2 -0
  76. package/src/jodit.ts +5 -1
  77. package/src/langs/i18n.test.js +221 -216
  78. package/src/modules/dialog/dialog.less +9 -1
  79. package/src/modules/dialog/dialog.ts +25 -16
  80. package/src/modules/file-browser/data-provider.ts +44 -12
  81. package/src/modules/file-browser/file-browser.test.js +1019 -958
  82. package/src/modules/file-browser/file-browser.ts +0 -1
  83. package/src/modules/messages/messages.ts +3 -8
  84. package/src/plugins/backspace/backspace.test.js +2 -9
  85. package/src/plugins/backspace/backspace.ts +5 -0
  86. package/src/plugins/backspace/cases/check-join-neighbors.ts +7 -1
  87. package/src/plugins/backspace/cases/check-join-two-lists.ts +2 -1
  88. package/src/plugins/backspace/helpers.ts +9 -1
  89. package/src/plugins/backspace/interface.ts +31 -0
  90. package/src/plugins/clean-html/helpers/visitor/filters/fill-empty-paragraph.ts +2 -1
  91. package/src/plugins/color/color.test.js +122 -119
  92. package/src/plugins/enter/enter.test.js +18 -5
  93. package/src/plugins/enter/enter.ts +9 -5
  94. package/src/plugins/enter/interface.ts +41 -0
  95. package/src/plugins/font/config.ts +8 -8
  96. package/src/plugins/font/font.test.js +18 -23
  97. package/src/plugins/hotkeys/hotkeys.test.js +35 -47
  98. package/src/plugins/iframe/iframe.test.js +206 -195
  99. package/src/plugins/image/image.ts +1 -1
  100. package/src/plugins/image-properties/config.ts +22 -0
  101. package/src/plugins/image-properties/image-properties.test.js +174 -93
  102. package/src/plugins/image-properties/templates/position-tab.ts +22 -1
  103. package/src/plugins/indent/indent.test.js +2 -8
  104. package/src/plugins/link/link.test.js +19 -0
  105. package/src/plugins/link/link.ts +25 -15
  106. package/src/plugins/placeholder/placeholder.ts +8 -7
  107. package/src/plugins/size/size.test.js +239 -225
  108. package/src/plugins/tab/cases/on-tab-inside-li.ts +131 -22
  109. package/src/plugins/tab/tab.test.js +95 -11
  110. package/src/plugins/tab/tab.ts +22 -2
  111. package/src/plugins/wrap-nodes/config.ts +11 -0
  112. package/src/plugins/wrap-nodes/wrap-nodes.ts +0 -1
  113. package/src/types/events.d.ts +4 -0
  114. package/src/types/file-browser.d.ts +17 -10
  115. package/src/types/select.d.ts +6 -1
  116. package/src/types/style.d.ts +72 -5
  117. package/src/types/uploader.d.ts +14 -0
  118. package/src/types/view.d.ts +2 -2
  119. package/types/core/async/async.d.ts +1 -1
  120. package/types/core/constants.d.ts +3 -3
  121. package/types/core/dom/dom.d.ts +6 -3
  122. package/types/core/helpers/checker/index.d.ts +1 -0
  123. package/types/core/helpers/checker/is-boolean.d.ts +1 -1
  124. package/types/core/helpers/checker/is-marker.d.ts +10 -0
  125. package/types/core/helpers/html/safe-html.d.ts +1 -1
  126. package/types/core/helpers/normalize/normalize-css-value.d.ts +2 -0
  127. package/types/core/helpers/normalize/normalize-node.d.ts +1 -1
  128. package/types/core/helpers/utils/append-script.d.ts +1 -1
  129. package/types/core/selection/interface.d.ts +19 -0
  130. package/types/core/selection/select.d.ts +22 -5
  131. package/types/core/selection/style/api/finite-state-machine.d.ts +10 -9
  132. package/types/core/selection/style/api/get-suit-child.d.ts +2 -3
  133. package/types/core/selection/style/api/get-suit-parent.d.ts +2 -3
  134. package/types/core/selection/style/api/{element-has-same-style.d.ts → has-same-style.d.ts} +2 -2
  135. package/types/core/selection/style/api/index.d.ts +6 -6
  136. package/types/core/selection/style/api/is-same-attributes.d.ts +12 -0
  137. package/types/core/selection/style/api/is-suit-element.d.ts +4 -4
  138. package/types/core/selection/style/api/{toggle → list}/toggle-ordered-list.d.ts +2 -3
  139. package/types/core/selection/style/api/{wrap-ordered-list.d.ts → list/wrap-list.d.ts} +2 -3
  140. package/types/core/selection/style/api/toggle-attributes.d.ts +11 -0
  141. package/types/core/selection/style/api/unwrap-children.d.ts +2 -2
  142. package/types/core/selection/style/api/wrap-unwrapped-text.d.ts +2 -3
  143. package/types/core/selection/style/api/{wrap-and-commit-style.d.ts → wrap.d.ts} +2 -3
  144. package/types/core/selection/style/apply-style.d.ts +3 -3
  145. package/types/core/selection/style/commit-style.d.ts +6 -2
  146. package/types/core/selection/style/transactions.d.ts +29 -0
  147. package/types/core/ui/popup/popup.d.ts +1 -1
  148. package/types/core/view/view.d.ts +1 -1
  149. package/types/index.d.ts +2 -0
  150. package/types/modules/file-browser/builders/elements-map.d.ts +1 -1
  151. package/types/modules/file-browser/data-provider.d.ts +5 -0
  152. package/types/modules/messages/messages.d.ts +2 -1
  153. package/types/plugins/backspace/helpers.d.ts +5 -1
  154. package/types/plugins/backspace/interface.d.ts +21 -0
  155. package/types/plugins/enter/enter.d.ts +2 -0
  156. package/types/plugins/enter/interface.d.ts +32 -0
  157. package/types/plugins/image-properties/config.d.ts +19 -0
  158. package/types/plugins/link/link.d.ts +1 -1
  159. package/types/plugins/paste/interface.d.ts +2 -2
  160. package/types/plugins/tab/cases/on-tab-inside-li.d.ts +1 -1
  161. package/types/plugins/wrap-nodes/config.d.ts +10 -0
  162. package/types/types/events.d.ts +4 -0
  163. package/types/types/file-browser.d.ts +17 -10
  164. package/types/types/select.d.ts +6 -1
  165. package/types/types/storage.d.ts +1 -1
  166. package/types/types/style.d.ts +72 -5
  167. package/types/types/uploader.d.ts +14 -0
  168. package/types/types/view.d.ts +2 -2
  169. package/vdom.html +20 -0
  170. package/src/core/selection/style/api/toggle/toggle-css.ts +0 -136
  171. package/src/core/selection/style/api/toggle/toggle-ordered-list.ts +0 -54
  172. package/src/core/selection/style/api/toggle-commit-styles.ts +0 -35
  173. package/src/core/selection/style/api/wrap-ordered-list.ts +0 -42
  174. package/types/core/selection/style/api/toggle/toggle-css.d.ts +0 -12
  175. 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
- describe('Test popup', function () {
7
- const position = Jodit.modules.Helpers.position;
8
-
9
- let textBox;
10
- const elms = [];
11
-
12
- beforeEach(function () {
13
- textBox = document.createElement('div');
14
- Object.assign(textBox.style, {
15
- position: 'fixed',
16
- display: 'flex',
17
- flexWrap: 'wrap',
18
- top: 0,
19
- left: 0,
20
- width: '100%',
21
- height: '100%',
22
- background: 'red'
23
- });
24
- document.body.appendChild(textBox);
25
-
26
- for (let i = 0; i < 4; i += 1) {
27
- for (let j = 0; j < 4; j += 1) {
28
- const elmBox = document.createElement('div');
29
-
30
- Object.assign(elmBox.style, {
31
- width: '25%',
32
- height: '25%',
33
- background:
34
- 'rgb(' +
35
- (i * 30 + 128) +
36
- ',' +
37
- (j * 30 + 28) +
38
- ', ' +
39
- (i * 10 + j * 10 + 100) +
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
- textBox.appendChild(elmBox);
44
- elms.push(elmBox);
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
- describe('Open popup on some target', function () {
92
- describe('Usual case - there is enough space under element', function () {
93
- it('should show popup under element', function () {
94
- const div = appendTestDiv();
95
- div.innerText = 'test';
51
+ afterEach(function () {
52
+ textBox && textBox.remove();
53
+ elms.length = 0;
54
+ });
96
55
 
97
- const gb = function () {
98
- return position(div);
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
- const pos = openPopup(gb);
74
+ const openPopup = function (getBound, content, strategy) {
75
+ const editor = getJodit();
102
76
 
103
- expect(pos.left).equals(gb().left);
104
- expect(pos.top).equals(gb().top + gb().height);
105
- });
106
- });
77
+ const popup = new Jodit.modules.Popup(editor);
107
78
 
108
- describe('Corners', function () {
109
- describe('Change default strategy', function () {
110
- it('should show popup to match the strategy', function () {
111
- const gb = function () {
112
- return position(aliases.center());
113
- };
79
+ if (strategy) {
80
+ popup.strategy = strategy;
81
+ }
114
82
 
115
- const pos = openPopup(gb, false, 'rightBottom');
83
+ popup.setContent(content || 'Test content').open(getBound);
116
84
 
117
- expect(pos.left + pos.width).equals(gb().left + gb().width);
118
- expect(pos.top).equals(gb().top + gb().height);
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
- describe('Left-Top', function () {
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(aliases.leftTop());
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('Right-Top', function () {
136
- describe('Small popup', function () {
137
- it('should show popup under element', function () {
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.rightTop());
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(gb().left);
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('Big popup', function () {
150
- it("should show popup under element but right corner should be under target's right-bottom corner", function () {
126
+ describe('Left-Top', function () {
127
+ it('should show popup under element', function () {
151
128
  const gb = function () {
152
- return position(aliases.rightTop());
129
+ return position(aliases.leftTop());
153
130
  };
154
131
 
155
- const pos = openPopup(gb, 'testO'.repeat(30));
132
+ const pos = openPopup(gb);
156
133
 
157
- expect(pos.left + pos.width).equals(
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
- describe('Left-Bottom', function () {
166
- describe('Small popup', function () {
167
- it('should show popup above element', function () {
168
- const gb = function () {
169
- return position(aliases.leftBottom());
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
- const pos = openPopup(gb);
146
+ const pos = openPopup(gb);
173
147
 
174
- expect(pos.left).equals(gb().left);
175
- expect(pos.top + pos.height).equals(gb().top);
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
- describe('Right-Bottom', function () {
181
- describe('Small popup', function () {
182
- it('should show popup above element', function () {
183
- const gb = function () {
184
- return position(aliases.rightBottom());
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
- const pos = openPopup(gb);
176
+ const pos = openPopup(gb);
188
177
 
189
- expect(pos.left).equals(gb().left);
190
- expect(pos.top + pos.height).equals(gb().top);
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('Big popup', function () {
195
- it("should show popup above the element but right corner should be above target's right-top corner", function () {
196
- const gb = function () {
197
- return position(aliases.rightBottom());
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
- const pos = openPopup(gb, 'testO'.repeat(30));
191
+ const pos = openPopup(gb);
201
192
 
202
- expect(pos.left + pos.width).equals(
203
- gb().left + gb().width
204
- );
205
- expect(pos.top + pos.height).equals(gb().top);
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
- * @module plugins/backspace
9
- */
10
-
11
- export type DeleteMode = 'char' | 'word' | 'sentence';
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.container);
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.container.setAttribute('contenteditable', 'true');
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
+ }
@@ -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
- readonly message: IMessages;
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
@@ -74,3 +74,5 @@ Object.keys(Languages)
74
74
  });
75
75
 
76
76
  export { DefaultJodit as Jodit };
77
+
78
+ export class CommitMode {}
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 Jodit(element, options);
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
  }