jodit 4.20.5 → 4.21.1
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 +28 -0
- package/README.md +0 -1
- package/es2015/jodit.css +2 -2
- package/es2015/jodit.fat.min.css +1 -1
- package/es2015/jodit.fat.min.js +12 -12
- package/es2015/jodit.js +558 -210
- package/es2015/jodit.min.css +1 -1
- package/es2015/jodit.min.js +12 -12
- package/es2015/plugins/debug/debug.css +1 -1
- package/es2015/plugins/debug/debug.js +2 -2
- package/es2015/plugins/debug/debug.min.js +2 -2
- package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.js +2 -2
- package/es2015/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es2018/jodit.fat.min.css +1 -1
- package/es2018/jodit.fat.min.js +12 -12
- package/es2018/jodit.min.css +1 -1
- package/es2018/jodit.min.js +12 -12
- package/es2018/plugins/debug/debug.min.js +2 -2
- package/es2018/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es2021/jodit.css +2 -2
- package/es2021/jodit.fat.min.css +1 -1
- package/es2021/jodit.fat.min.js +17 -17
- package/es2021/jodit.js +550 -203
- package/es2021/jodit.min.css +1 -1
- package/es2021/jodit.min.js +17 -17
- package/es2021/plugins/debug/debug.css +1 -1
- package/es2021/plugins/debug/debug.js +2 -2
- package/es2021/plugins/debug/debug.min.js +2 -2
- package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.js +2 -2
- package/es2021/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es2021.en/jodit.css +2 -2
- package/es2021.en/jodit.fat.min.css +1 -1
- package/es2021.en/jodit.fat.min.js +17 -17
- package/es2021.en/jodit.js +550 -203
- package/es2021.en/jodit.min.css +1 -1
- package/es2021.en/jodit.min.js +32 -32
- package/es2021.en/plugins/debug/debug.css +1 -1
- package/es2021.en/plugins/debug/debug.js +2 -2
- package/es2021.en/plugins/debug/debug.min.js +2 -2
- package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.js +2 -2
- package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es5/jodit.css +3 -3
- package/es5/jodit.fat.min.css +1 -1
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +595 -177
- package/es5/jodit.min.css +3 -3
- package/es5/jodit.min.js +2 -2
- package/es5/plugins/debug/debug.css +1 -1
- package/es5/plugins/debug/debug.js +2 -2
- package/es5/plugins/debug/debug.min.js +2 -2
- package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.js +2 -2
- package/es5/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es5/polyfills.fat.min.js +2 -2
- package/es5/polyfills.js +1 -29
- package/es5/polyfills.min.js +2 -2
- package/esm/config.d.ts +18 -0
- package/esm/core/constants.d.ts +6 -0
- package/esm/core/constants.js +18 -1
- package/esm/core/helpers/html/clean-from-word.d.ts +3 -1
- package/esm/core/helpers/html/clean-from-word.js +87 -11
- package/esm/core/helpers/utils/selector.js +4 -3
- package/esm/plugins/hr/hr.js +290 -1
- package/esm/plugins/inline-popup/config/config.js +2 -0
- package/esm/plugins/inline-popup/config/items/hr.d.ts +11 -0
- package/esm/plugins/inline-popup/config/items/hr.js +15 -0
- package/esm/plugins/key-arrow-outside/key-arrow-outside.js +2 -2
- package/esm/plugins/link/config.d.ts +7 -0
- package/esm/plugins/link/config.js +1 -0
- package/esm/plugins/link/link.js +20 -16
- package/esm/plugins/paste/config.d.ts +5 -0
- package/esm/plugins/paste/config.js +2 -1
- package/esm/plugins/paste/paste.js +1 -1
- package/esm/plugins/paste-from-word/paste-from-word.js +2 -2
- package/esm/plugins/symbols/config.d.ts +6 -0
- package/esm/plugins/symbols/config.js +1 -0
- package/esm/plugins/symbols/symbols.d.ts +0 -1
- package/esm/plugins/symbols/symbols.js +12 -10
- package/package.json +1 -1
- package/types/config.d.ts +18 -0
- package/types/core/constants.d.ts +6 -0
- package/types/core/helpers/html/clean-from-word.d.ts +3 -1
- package/types/plugins/inline-popup/config/items/hr.d.ts +11 -0
- package/types/plugins/link/config.d.ts +7 -0
- package/types/plugins/paste/config.d.ts +5 -0
- package/types/plugins/symbols/config.d.ts +6 -0
- package/types/plugins/symbols/symbols.d.ts +0 -1
package/esm/plugins/hr/hr.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
4
|
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
+
import { BR, KEY_BACKSPACE, KEY_DELETE, KEY_DOWN, KEY_ENTER, KEY_LEFT, KEY_RIGHT, KEY_UP } from "../../core/constants.js";
|
|
6
7
|
import { Dom } from "../../core/dom/index.js";
|
|
7
|
-
import { pluginSystem } from "../../core/global.js";
|
|
8
|
+
import { getContainer, pluginSystem } from "../../core/global.js";
|
|
9
|
+
import { cssPath, position, toArray } from "../../core/helpers/index.js";
|
|
8
10
|
import { Icon } from "../../core/ui/icon.js";
|
|
9
11
|
import { Config } from "../../config.js";
|
|
10
12
|
import hrIcon from "./hr.svg.js";
|
|
@@ -55,5 +57,292 @@ export function hr(editor) {
|
|
|
55
57
|
editor.s.setCursorIn(p);
|
|
56
58
|
return false;
|
|
57
59
|
});
|
|
60
|
+
// A horizontal line is selected whole, as an image is: by a click on it,
|
|
61
|
+
// or by an arrow key that comes to it (#1802)
|
|
62
|
+
const nearest = (node, forward) => {
|
|
63
|
+
while (node && Dom.isEmptyTextNode(node)) {
|
|
64
|
+
node = forward ? node.nextSibling : node.previousSibling;
|
|
65
|
+
}
|
|
66
|
+
return node;
|
|
67
|
+
};
|
|
68
|
+
const beside = (node, forward) => nearest(forward ? node.nextSibling : node.previousSibling, forward);
|
|
69
|
+
// A line between blocks, where the caret beside it isn't in a line of
|
|
70
|
+
// text, as it is in a list item or a table cell (#1606)
|
|
71
|
+
const isLoose = (node) => Dom.isTag(node, 'hr') &&
|
|
72
|
+
node.parentNode === editor.editor &&
|
|
73
|
+
editor.o.enter.toLowerCase() !== BR;
|
|
74
|
+
// The line a range holds, and nothing else
|
|
75
|
+
const lineIn = (range) => {
|
|
76
|
+
const { startContainer: box, startOffset } = range;
|
|
77
|
+
const node = box.childNodes[startOffset];
|
|
78
|
+
return box === range.endContainer &&
|
|
79
|
+
range.endOffset === startOffset + 1 &&
|
|
80
|
+
Dom.isTag(node, 'hr') &&
|
|
81
|
+
editor.editor.contains(node)
|
|
82
|
+
? node
|
|
83
|
+
: null;
|
|
84
|
+
};
|
|
85
|
+
// The browsers don't draw a selection round a line, so a rule in the
|
|
86
|
+
// editor's document frames it, as the table module marks cells
|
|
87
|
+
let framed = null;
|
|
88
|
+
const frame = (line) => {
|
|
89
|
+
if (line === framed) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
framed = line;
|
|
93
|
+
const path = line && cssPath(line);
|
|
94
|
+
getContainer(editor, 'hr', 'style', true).innerHTML = path
|
|
95
|
+
? `${path}{outline:3px solid var(--jd-resizer-border-color,#98c1f1);outline-offset:3px}`
|
|
96
|
+
: '';
|
|
97
|
+
};
|
|
98
|
+
const editable = () => !editor.o.readonly && !editor.isLocked;
|
|
99
|
+
const plain = (e) => !e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey;
|
|
100
|
+
const newLine = (node, after) => {
|
|
101
|
+
const p = editor.createInside.element(editor.o.enter);
|
|
102
|
+
const br = editor.createInside.element('br');
|
|
103
|
+
p.appendChild(br);
|
|
104
|
+
after ? Dom.after(node, p) : Dom.before(node, p);
|
|
105
|
+
editor.s.setCursorBefore(br);
|
|
106
|
+
};
|
|
107
|
+
// On from a line the way an arrow key goes: to the next line in a row,
|
|
108
|
+
// which is selected in turn, or into the text beyond, or into a new
|
|
109
|
+
// paragraph at the start or end of the content
|
|
110
|
+
const pass = (line, forward) => {
|
|
111
|
+
const next = beside(line, forward);
|
|
112
|
+
if (Dom.isTag(next, 'hr')) {
|
|
113
|
+
editor.s.select(next);
|
|
114
|
+
}
|
|
115
|
+
else if (next) {
|
|
116
|
+
editor.s.setCursorIn(next, forward);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
newLine(line, forward);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
// Only the line goes, without joining the lines either side. Backspace
|
|
123
|
+
// leaves the caret at the end of the line before, Delete at the start of
|
|
124
|
+
// the line after, or the other side at the start or end of the content
|
|
125
|
+
const remove = (line, forward) => {
|
|
126
|
+
const before = beside(line, false);
|
|
127
|
+
const after = beside(line, true);
|
|
128
|
+
const next = forward ? (after !== null && after !== void 0 ? after : before) : (before !== null && before !== void 0 ? before : after);
|
|
129
|
+
if (!next) {
|
|
130
|
+
newLine(line, true);
|
|
131
|
+
}
|
|
132
|
+
editor.s.removeNode(line);
|
|
133
|
+
if (Dom.isTag(next, 'hr')) {
|
|
134
|
+
editor.s.select(next);
|
|
135
|
+
}
|
|
136
|
+
else if (next) {
|
|
137
|
+
editor.s.setCursorIn(next, next === after);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
// The nodes either side of a caret left beside a line in the editor
|
|
141
|
+
// itself, outside any line of text, as a click beside the line, Jodit's
|
|
142
|
+
// own delete or a paste leaves it
|
|
143
|
+
const around = (range) => {
|
|
144
|
+
var _a, _b;
|
|
145
|
+
const { startContainer: box, startOffset } = range;
|
|
146
|
+
if (!range.collapsed || box !== editor.editor) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
const before = nearest((_a = box.childNodes[startOffset - 1]) !== null && _a !== void 0 ? _a : null, false);
|
|
150
|
+
const after = nearest((_b = box.childNodes[startOffset]) !== null && _b !== void 0 ? _b : null, true);
|
|
151
|
+
return isLoose(before) || isLoose(after) ? [before, after] : null;
|
|
152
|
+
};
|
|
153
|
+
// After a click beside a line, off it, the caret goes to the nearest line
|
|
154
|
+
// of text: the one above for a click above the line, the one below for a
|
|
155
|
+
// click below
|
|
156
|
+
const leave = () => {
|
|
157
|
+
const sides = around(editor.s.range);
|
|
158
|
+
if (!sides || !editable()) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const [before, after] = sides;
|
|
162
|
+
const forward = !isLoose(after);
|
|
163
|
+
let edge = forward ? before : after;
|
|
164
|
+
let next = forward ? after : before;
|
|
165
|
+
while (isLoose(next)) {
|
|
166
|
+
edge = next;
|
|
167
|
+
next = beside(next, forward);
|
|
168
|
+
}
|
|
169
|
+
if (next) {
|
|
170
|
+
editor.s.setCursorIn(next, forward);
|
|
171
|
+
}
|
|
172
|
+
else if (edge) {
|
|
173
|
+
newLine(edge, forward);
|
|
174
|
+
editor.synchronizeValues();
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
// The browsers stop the caret beside a line, so an arrow key that takes
|
|
178
|
+
// the caret out of a block towards a line selects the line instead
|
|
179
|
+
const arriveAt = (from, forward) => {
|
|
180
|
+
const top = Dom.up(from.startContainer, node => (node === null || node === void 0 ? void 0 : node.parentNode) === editor.editor, editor.editor);
|
|
181
|
+
const next = top && beside(top, forward);
|
|
182
|
+
if (!top || !isLoose(next)) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
// Once the browser has moved the caret
|
|
186
|
+
editor.async.setTimeout(() => {
|
|
187
|
+
const { range } = editor.s;
|
|
188
|
+
if (range.collapsed &&
|
|
189
|
+
!top.contains(range.startContainer) &&
|
|
190
|
+
editor.editor.contains(next)) {
|
|
191
|
+
editor.s.select(next);
|
|
192
|
+
}
|
|
193
|
+
}, 1);
|
|
194
|
+
};
|
|
195
|
+
// Delete or Backspace in an empty block next to a line removes the block
|
|
196
|
+
// and selects the line, as it was before Enter on it. Jodit's own delete
|
|
197
|
+
// would leave the caret beside the line
|
|
198
|
+
const deleteEmpty = (range, forward) => {
|
|
199
|
+
const block = Dom.closest(range.startContainer, Dom.isBlock, editor.editor);
|
|
200
|
+
const next = block && beside(block, forward);
|
|
201
|
+
if (!block ||
|
|
202
|
+
block.parentNode !== editor.editor ||
|
|
203
|
+
!isLoose(next) ||
|
|
204
|
+
!Dom.isEmpty(block)) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
Dom.safeRemove(block);
|
|
208
|
+
editor.s.select(next);
|
|
209
|
+
return true;
|
|
210
|
+
};
|
|
211
|
+
// A key with the caret in a line of text, or beside a line: an arrow
|
|
212
|
+
// key, Delete or Backspace that goes to a line selects it
|
|
213
|
+
const atCaret = (e, range) => {
|
|
214
|
+
const deleting = e.key === KEY_BACKSPACE || e.key === KEY_DELETE;
|
|
215
|
+
const forward = e.key === KEY_DOWN || e.key === KEY_RIGHT || e.key === KEY_DELETE;
|
|
216
|
+
const arrow = forward
|
|
217
|
+
? e.key !== KEY_DELETE
|
|
218
|
+
: e.key === KEY_UP || e.key === KEY_LEFT;
|
|
219
|
+
if (!range.collapsed || !plain(e) || !(arrow || deleting)) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
const sides = around(range);
|
|
223
|
+
if (!sides) {
|
|
224
|
+
if (arrow) {
|
|
225
|
+
arriveAt(range, forward);
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
return deleteEmpty(range, forward);
|
|
229
|
+
}
|
|
230
|
+
const [before, after] = sides;
|
|
231
|
+
const next = forward ? after : before;
|
|
232
|
+
if (isLoose(next)) {
|
|
233
|
+
editor.s.select(next);
|
|
234
|
+
}
|
|
235
|
+
else if (deleting) {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
else if (next) {
|
|
239
|
+
editor.s.setCursorIn(next, forward);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
newLine((forward ? before : after), forward);
|
|
243
|
+
}
|
|
244
|
+
return true;
|
|
245
|
+
};
|
|
246
|
+
// A key with a line selected
|
|
247
|
+
const onLine = (e, line) => {
|
|
248
|
+
var _a;
|
|
249
|
+
const back = e.key === KEY_UP || e.key === KEY_LEFT;
|
|
250
|
+
if (plain(e) && (back || e.key === KEY_DOWN || e.key === KEY_RIGHT)) {
|
|
251
|
+
pass(line, !back);
|
|
252
|
+
}
|
|
253
|
+
else if (e.key === KEY_BACKSPACE || e.key === KEY_DELETE) {
|
|
254
|
+
remove(line, e.key === KEY_DELETE);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
// Typing starts a new paragraph after the line, and the browser
|
|
258
|
+
// types the letter into it
|
|
259
|
+
if (((_a = e.key) === null || _a === void 0 ? void 0 : _a.length) === 1 && !e.ctrlKey && !e.metaKey) {
|
|
260
|
+
newLine(line, true);
|
|
261
|
+
}
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
return true;
|
|
265
|
+
};
|
|
266
|
+
// Enter with a line selected adds a paragraph after the line, and
|
|
267
|
+
// Shift+Enter one before it, between the Enter plugin's own events. The
|
|
268
|
+
// plugin itself would delete the line
|
|
269
|
+
const enter = (e, line) => {
|
|
270
|
+
const result = editor.e.fire('beforeEnter', e);
|
|
271
|
+
if (result !== undefined) {
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
editor.history.snapshot.transaction(() => {
|
|
275
|
+
newLine(line, !e.shiftKey);
|
|
276
|
+
editor.e.fire('afterEnter', e);
|
|
277
|
+
});
|
|
278
|
+
editor.synchronizeValues();
|
|
279
|
+
return false;
|
|
280
|
+
};
|
|
281
|
+
// How far above or below a line a click still selects it
|
|
282
|
+
const slack = 6;
|
|
283
|
+
// The press that selected a line, for its click to open the popup
|
|
284
|
+
let pressed = null;
|
|
285
|
+
editor.e
|
|
286
|
+
.on('afterInit', () => {
|
|
287
|
+
editor.e.on(editor.ed, 'selectionchange', () => {
|
|
288
|
+
const { sel } = editor.s;
|
|
289
|
+
frame((sel === null || sel === void 0 ? void 0 : sel.rangeCount) ? lineIn(sel.getRangeAt(0)) : null);
|
|
290
|
+
});
|
|
291
|
+
})
|
|
292
|
+
.on('keydown', (e) => {
|
|
293
|
+
if (!editable() || e.isComposing) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const { range } = editor.s;
|
|
297
|
+
const line = lineIn(range);
|
|
298
|
+
if (line && e.key === KEY_ENTER) {
|
|
299
|
+
editor.e.stopPropagation('keydown');
|
|
300
|
+
return enter(e, line);
|
|
301
|
+
}
|
|
302
|
+
if (line ? !onLine(e, line) : !atCaret(e, range)) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
editor.e.stopPropagation('keydown');
|
|
306
|
+
editor.synchronizeValues();
|
|
307
|
+
return false;
|
|
308
|
+
}, { top: true })
|
|
309
|
+
.on('mousedown', (e) => {
|
|
310
|
+
pressed = null;
|
|
311
|
+
if (!editable() || e.button !== 0 || e.shiftKey) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const line = toArray(editor.editor.getElementsByTagName('hr')).find(line => {
|
|
315
|
+
if (e.target !== line && e.target !== line.parentNode) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
const box = line.getBoundingClientRect();
|
|
319
|
+
return (e.clientX >= box.left &&
|
|
320
|
+
e.clientX <= box.right &&
|
|
321
|
+
e.clientY >= box.top - slack &&
|
|
322
|
+
e.clientY <= box.bottom + slack);
|
|
323
|
+
});
|
|
324
|
+
if (line) {
|
|
325
|
+
// The browser's own press would put the caret beside the line
|
|
326
|
+
e.preventDefault();
|
|
327
|
+
pressed = line;
|
|
328
|
+
editor.s.select(line);
|
|
329
|
+
}
|
|
330
|
+
})
|
|
331
|
+
.on('click', () => {
|
|
332
|
+
const line = pressed;
|
|
333
|
+
pressed = null;
|
|
334
|
+
// After the click's own handlers, which close the popups
|
|
335
|
+
line &&
|
|
336
|
+
editor.async.setTimeout(() => editor.e.fire('showPopup', line, () => position(line, editor), 'hr'), 1);
|
|
337
|
+
})
|
|
338
|
+
.on('mouseup', () => {
|
|
339
|
+
editor.async.setTimeout(leave, 1);
|
|
340
|
+
})
|
|
341
|
+
.on('deleteHorizontalRule', (line) => {
|
|
342
|
+
if (editable()) {
|
|
343
|
+
remove(line, true);
|
|
344
|
+
editor.synchronizeValues();
|
|
345
|
+
}
|
|
346
|
+
});
|
|
58
347
|
}
|
|
59
348
|
pluginSystem.add('hr', hr);
|
|
@@ -8,6 +8,7 @@ import { Icon } from "../../../core/ui/icon.js";
|
|
|
8
8
|
import { Config } from "../../../config.js";
|
|
9
9
|
import a from "./items/a.js";
|
|
10
10
|
import cells from "./items/cells.js";
|
|
11
|
+
import hr from "./items/hr.js";
|
|
11
12
|
import jodit from "./items/iframe.js";
|
|
12
13
|
import img from "./items/img.js";
|
|
13
14
|
import toolbar from "./items/toolbar.js";
|
|
@@ -46,6 +47,7 @@ Config.prototype.popup = {
|
|
|
46
47
|
a,
|
|
47
48
|
img,
|
|
48
49
|
cells,
|
|
50
|
+
hr,
|
|
49
51
|
toolbar,
|
|
50
52
|
jodit,
|
|
51
53
|
iframe: jodit,
|
|
@@ -0,0 +1,11 @@
|
|
|
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-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @module plugins/inline-popup
|
|
8
|
+
*/
|
|
9
|
+
import type { IControlType } from "../../../../types/index";
|
|
10
|
+
declare const _default: Array<IControlType | string>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
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-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
export default [
|
|
7
|
+
{
|
|
8
|
+
name: 'delete',
|
|
9
|
+
icon: 'bin',
|
|
10
|
+
tooltip: 'Delete',
|
|
11
|
+
exec: (editor, line) => {
|
|
12
|
+
line && editor.e.fire('deleteHorizontalRule', line);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
];
|
|
@@ -13,7 +13,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
13
13
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14
14
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
15
|
};
|
|
16
|
-
import { KEY_RIGHT
|
|
16
|
+
import { KEY_RIGHT } from "../../core/constants.js";
|
|
17
17
|
import { watch } from "../../core/decorators/index.js";
|
|
18
18
|
import { Dom } from "../../core/dom/dom.js";
|
|
19
19
|
import { pluginSystem } from "../../core/global.js";
|
|
@@ -37,7 +37,7 @@ export class keyArrowOutside extends Plugin {
|
|
|
37
37
|
const { parentNode } = endContainer;
|
|
38
38
|
if (Dom.isInlineBlock(parentNode) &&
|
|
39
39
|
!Dom.findNotEmptyNeighbor(parentNode, false, this.j.editor)) {
|
|
40
|
-
Dom.after(parentNode, this.j.createInside.
|
|
40
|
+
Dom.after(parentNode, this.j.createInside.fake());
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -102,6 +102,13 @@ declare module 'jodit/config' {
|
|
|
102
102
|
* The list of the option for the select (to use with modeClassName="select")
|
|
103
103
|
*/
|
|
104
104
|
selectOptionsClassName: IUIOption[];
|
|
105
|
+
/**
|
|
106
|
+
* With modeClassName="select", keep the link's classes that the list
|
|
107
|
+
* doesn't offer, such as one an integration gives some of its links,
|
|
108
|
+
* and change only the listed ones. Off, the form sets the link's
|
|
109
|
+
* classes to the selected ones alone
|
|
110
|
+
*/
|
|
111
|
+
selectKeepOtherClassNames: boolean;
|
|
105
112
|
hotkeys: string[];
|
|
106
113
|
/**
|
|
107
114
|
* Prevent navigation to the link if it is readonly. Default: true
|
package/esm/plugins/link/link.js
CHANGED
|
@@ -19,6 +19,7 @@ import { Dom } from "../../core/dom/index.js";
|
|
|
19
19
|
import { pluginSystem, uniqueUid } from "../../core/global.js";
|
|
20
20
|
import { attr, call, convertMediaUrlToVideoEmbed, getAnchorName, getAnchors, htmlspecialchars, isString, isURL, position, prepareEmbedCode, refs, safeHTML, stripTags } from "../../core/helpers/index.js";
|
|
21
21
|
import { Plugin } from "../../core/plugin/index.js";
|
|
22
|
+
import { UIButton } from "../../core/ui/button/index.js";
|
|
22
23
|
import { UIElement } from "../../core/ui/element.js";
|
|
23
24
|
import { Icon } from "../../core/ui/icon.js";
|
|
24
25
|
import { Popup } from "../../core/ui/popup/popup.js";
|
|
@@ -137,7 +138,7 @@ export class link extends Plugin {
|
|
|
137
138
|
__generateForm(current, close) {
|
|
138
139
|
const { jodit } = this;
|
|
139
140
|
const i18n = jodit.i18n.bind(jodit);
|
|
140
|
-
const { openInNewTabCheckbox, openInNewTabCheckboxDefaultChecked, noFollowCheckbox, formTemplate, formClassName, modeClassName, contentMode } = jodit.o.link;
|
|
141
|
+
const { openInNewTabCheckbox, openInNewTabCheckboxDefaultChecked, noFollowCheckbox, formTemplate, formClassName, modeClassName, contentMode, selectKeepOtherClassNames } = jodit.o.link;
|
|
141
142
|
const html = formTemplate(jodit);
|
|
142
143
|
const form = isString(html)
|
|
143
144
|
? jodit.c.fromHTML(html, {
|
|
@@ -200,7 +201,14 @@ export class link extends Plugin {
|
|
|
200
201
|
.split(/\s+/)
|
|
201
202
|
.includes('nofollow');
|
|
202
203
|
}
|
|
203
|
-
|
|
204
|
+
// Through the button's state, so its text keeps its own element and styles
|
|
205
|
+
const insertButton = UIElement.closestElement(insert, UIButton);
|
|
206
|
+
if (insertButton) {
|
|
207
|
+
insertButton.state.text = 'Update';
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
insert.textContent = i18n('Update');
|
|
211
|
+
}
|
|
204
212
|
}
|
|
205
213
|
else {
|
|
206
214
|
Dom.hide(unlink);
|
|
@@ -268,7 +276,7 @@ export class link extends Plugin {
|
|
|
268
276
|
}
|
|
269
277
|
links.forEach(a => {
|
|
270
278
|
attr(a, 'href', url_input.value);
|
|
271
|
-
writeClasses(modeClassName, className_input, className_select, a);
|
|
279
|
+
writeClasses(modeClassName, className_input, className_select, a, selectKeepOtherClassNames);
|
|
272
280
|
if (!isImageContent) {
|
|
273
281
|
writeContent(jodit, a, content_input.value, contentWasChanged, url_input.value, contentMode);
|
|
274
282
|
}
|
|
@@ -635,8 +643,7 @@ function guessUrlFromText(text) {
|
|
|
635
643
|
}
|
|
636
644
|
return '';
|
|
637
645
|
}
|
|
638
|
-
function writeClasses(modeClassName, className_input, className_select, a) {
|
|
639
|
-
var _a;
|
|
646
|
+
function writeClasses(modeClassName, className_input, className_select, a, keepOtherClassNames) {
|
|
640
647
|
if (modeClassName && (className_input !== null && className_input !== void 0 ? className_input : className_select)) {
|
|
641
648
|
if (modeClassName === 'input') {
|
|
642
649
|
if (className_input.value === '' && a.hasAttribute('class')) {
|
|
@@ -647,19 +654,16 @@ function writeClasses(modeClassName, className_input, className_select, a) {
|
|
|
647
654
|
}
|
|
648
655
|
}
|
|
649
656
|
else if (modeClassName === 'select') {
|
|
650
|
-
|
|
657
|
+
const classes = (option) => option.value.split(/\s+/).filter(cn => cn.trim().length > 0);
|
|
658
|
+
if (keepOtherClassNames) {
|
|
659
|
+
Array.from(className_select.options).forEach(option => classes(option).forEach(cn => a.classList.remove(cn)));
|
|
660
|
+
}
|
|
661
|
+
else {
|
|
651
662
|
attr(a, 'class', null);
|
|
652
663
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
className
|
|
657
|
-
.split(/\s+/)
|
|
658
|
-
.filter(cn => cn.trim().length > 0)
|
|
659
|
-
.forEach(cn => {
|
|
660
|
-
a.classList.add(cn);
|
|
661
|
-
});
|
|
662
|
-
}
|
|
664
|
+
Array.from(className_select.selectedOptions).forEach(option => classes(option).forEach(cn => a.classList.add(cn)));
|
|
665
|
+
if (!a.classList.length) {
|
|
666
|
+
attr(a, 'class', null);
|
|
663
667
|
}
|
|
664
668
|
}
|
|
665
669
|
}
|
|
@@ -30,6 +30,11 @@ declare module 'jodit/config' {
|
|
|
30
30
|
* List of tags that will not be removed from the pasted HTML with INSERT_AS_TEXT mode
|
|
31
31
|
*/
|
|
32
32
|
pasteExcludeStripTags: HTMLTagNames[];
|
|
33
|
+
/**
|
|
34
|
+
* The attributes a clean paste (INSERT_CLEAR_HTML, and Clean for HTML
|
|
35
|
+
* from Word) keeps. It removes every other attribute, and every style
|
|
36
|
+
*/
|
|
37
|
+
pasteKeepAttributes: string[];
|
|
33
38
|
/**
|
|
34
39
|
* Options when inserting HTML string
|
|
35
40
|
*/
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
4
|
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
-
import { CLIPBOARD_ID, INSERT_AS_HTML, INSERT_AS_TEXT, INSERT_ONLY_TEXT, IS_PROD, TEXT_HTML, TEXT_PLAIN } from "../../core/constants.js";
|
|
6
|
+
import { CLIPBOARD_ID, INSERT_AS_HTML, INSERT_AS_TEXT, INSERT_ONLY_TEXT, IS_PROD, PASTE_KEEP_ATTRIBUTES, TEXT_HTML, TEXT_PLAIN } from "../../core/constants.js";
|
|
7
7
|
import { Config } from "../../config.js";
|
|
8
8
|
import { pasteInsertHtml } from "./helpers.js";
|
|
9
9
|
Config.prototype.askBeforePasteHTML = true;
|
|
10
10
|
Config.prototype.processPasteHTML = true;
|
|
11
11
|
Config.prototype.scrollToPastedContent = true;
|
|
12
12
|
Config.prototype.pasteExcludeStripTags = ['br', 'hr'];
|
|
13
|
+
Config.prototype.pasteKeepAttributes = [...PASTE_KEEP_ATTRIBUTES];
|
|
13
14
|
Config.prototype.pasteHTMLActionList = [
|
|
14
15
|
{ value: INSERT_AS_HTML, text: 'Keep' },
|
|
15
16
|
{ value: INSERT_AS_TEXT, text: 'Insert as Text' },
|
|
@@ -143,7 +143,7 @@ export class paste extends Plugin {
|
|
|
143
143
|
this.j.buffer.set(CLIPBOARD_ID, html);
|
|
144
144
|
switch (action) {
|
|
145
145
|
case INSERT_CLEAR_HTML:
|
|
146
|
-
html = cleanFromWord(removeGoogleDocsWrapper(html));
|
|
146
|
+
html = cleanFromWord(removeGoogleDocsWrapper(html), this.j.o.pasteKeepAttributes);
|
|
147
147
|
break;
|
|
148
148
|
case INSERT_ONLY_TEXT:
|
|
149
149
|
html = stripTags(html, this.j.ed, new Set(this.j.o.pasteExcludeStripTags), this.j.o.nl2brInPlainText);
|
|
@@ -57,11 +57,11 @@ export class pasteFromWord extends Plugin {
|
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
59
59
|
case INSERT_AS_TEXT: {
|
|
60
|
-
html = cleanFromWord(html);
|
|
60
|
+
html = cleanFromWord(html, this.j.o.pasteKeepAttributes);
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
63
|
case INSERT_ONLY_TEXT: {
|
|
64
|
-
html = stripTags(cleanFromWord(html), this.j.ed, new Set(this.j.o.pasteExcludeStripTags), this.j.o.nl2brInPlainText);
|
|
64
|
+
html = stripTags(cleanFromWord(html, this.j.o.pasteKeepAttributes), this.j.ed, new Set(this.j.o.pasteExcludeStripTags), this.j.o.nl2brInPlainText);
|
|
65
65
|
break;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -13,6 +13,12 @@ declare module 'jodit/config' {
|
|
|
13
13
|
* When true, show the special-characters picker as a toolbar popup instead of a modal dialog
|
|
14
14
|
*/
|
|
15
15
|
usePopupForSpecialCharacters: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* How many characters each row of the special-characters picker holds.
|
|
18
|
+
* The picker widens or narrows to fit them. Anything but a positive
|
|
19
|
+
* whole number falls back to 17.
|
|
20
|
+
*/
|
|
21
|
+
specialCharactersColumns: number;
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
24
|
export {};
|
|
@@ -8,6 +8,7 @@ import { Icon } from "../../core/ui/icon.js";
|
|
|
8
8
|
import { Config } from "../../config.js";
|
|
9
9
|
import symbolsIcon from "./symbols.svg.js";
|
|
10
10
|
Config.prototype.usePopupForSpecialCharacters = false;
|
|
11
|
+
Config.prototype.specialCharactersColumns = 17;
|
|
11
12
|
Config.prototype.specialCharacters = [
|
|
12
13
|
'!',
|
|
13
14
|
'"',
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { KEY_DOWN, KEY_ENTER, KEY_LEFT, KEY_RIGHT, KEY_UP } from "../../core/constants.js";
|
|
7
7
|
import { Dom } from "../../core/dom/dom.js";
|
|
8
8
|
import { extendLang, pluginSystem } from "../../core/global.js";
|
|
9
|
+
import { isInt } from "../../core/helpers/checker/index.js";
|
|
9
10
|
import { attr } from "../../core/helpers/utils/index.js";
|
|
10
11
|
import { Plugin } from "../../core/plugin/plugin.js";
|
|
11
12
|
import "./config.js";
|
|
@@ -22,11 +23,14 @@ export class symbols extends Plugin {
|
|
|
22
23
|
group: 'insert'
|
|
23
24
|
}
|
|
24
25
|
];
|
|
25
|
-
this.__countInRow = 17;
|
|
26
26
|
extendLang(langs);
|
|
27
27
|
}
|
|
28
28
|
afterInit(jodit) {
|
|
29
29
|
jodit.e.on('generateSpecialCharactersTable.symbols', () => {
|
|
30
|
+
const { specialCharactersColumns } = jodit.o;
|
|
31
|
+
const columns = isInt(specialCharactersColumns) && specialCharactersColumns > 0
|
|
32
|
+
? Number(specialCharactersColumns)
|
|
33
|
+
: 17;
|
|
30
34
|
const container = jodit.c.fromHTML(`<div class="jodit-symbols__container">
|
|
31
35
|
<div class="jodit-symbols__container_table">
|
|
32
36
|
<table class="jodit-symbols__table"><tbody></tbody></table>
|
|
@@ -35,6 +39,7 @@ export class symbols extends Plugin {
|
|
|
35
39
|
<div class="jodit-symbols__preview"></div>
|
|
36
40
|
</div>
|
|
37
41
|
</div>`);
|
|
42
|
+
container.style.setProperty('--jd-symbols-columns', String(columns));
|
|
38
43
|
const preview = Dom.first(container, node => Dom.isHTMLElement(node) &&
|
|
39
44
|
node.classList.contains('jodit-symbols__preview'));
|
|
40
45
|
const table = Dom.first(container, node => Dom.isTag(node, 'table'));
|
|
@@ -42,8 +47,7 @@ export class symbols extends Plugin {
|
|
|
42
47
|
const chars = [];
|
|
43
48
|
for (let i = 0; i < jodit.o.specialCharacters.length;) {
|
|
44
49
|
const tr = jodit.c.element('tr');
|
|
45
|
-
for (let j = 0; j <
|
|
46
|
-
i < jodit.o.specialCharacters.length; j += 1, i += 1) {
|
|
50
|
+
for (let j = 0; j < columns && i < jodit.o.specialCharacters.length; j += 1, i += 1) {
|
|
47
51
|
const td = jodit.c.element('td'), a = jodit.c.fromHTML(`<a
|
|
48
52
|
data-index="${i}"
|
|
49
53
|
data-index-j="${j}"
|
|
@@ -56,7 +60,6 @@ export class symbols extends Plugin {
|
|
|
56
60
|
}
|
|
57
61
|
Dom.append(body, tr);
|
|
58
62
|
}
|
|
59
|
-
const self = this;
|
|
60
63
|
jodit.e
|
|
61
64
|
.on(chars, 'focus', function () {
|
|
62
65
|
preview.innerHTML = this.innerHTML;
|
|
@@ -87,18 +90,17 @@ export class symbols extends Plugin {
|
|
|
87
90
|
case KEY_DOWN:
|
|
88
91
|
newIndex =
|
|
89
92
|
e.key === KEY_UP
|
|
90
|
-
? index -
|
|
91
|
-
: index +
|
|
93
|
+
? index - columns
|
|
94
|
+
: index + columns;
|
|
92
95
|
if (chars[newIndex] === undefined) {
|
|
93
96
|
newIndex =
|
|
94
97
|
e.key === KEY_UP
|
|
95
|
-
? Math.floor(chars.length /
|
|
96
|
-
|
|
97
|
-
self.__countInRow +
|
|
98
|
+
? Math.floor(chars.length / columns) *
|
|
99
|
+
columns +
|
|
98
100
|
jIndex
|
|
99
101
|
: jIndex;
|
|
100
102
|
if (newIndex > chars.length - 1) {
|
|
101
|
-
newIndex -=
|
|
103
|
+
newIndex -= columns;
|
|
102
104
|
}
|
|
103
105
|
}
|
|
104
106
|
chars[newIndex] && chars[newIndex].focus();
|