jodit 4.19.5 → 4.19.7
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 +32 -0
- package/es2015/jodit.css +1 -1
- package/es2015/jodit.fat.min.js +21 -8
- package/es2015/jodit.js +847 -155
- package/es2015/jodit.min.js +21 -8
- 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.fat.min.js +20 -7
- package/es2018/jodit.min.js +21 -8
- package/es2018/plugins/debug/debug.min.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 +21 -8
- package/es2021/jodit.js +832 -154
- package/es2021/jodit.min.js +69 -56
- 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 +31 -18
- package/es2021.en/jodit.js +832 -154
- package/es2021.en/jodit.min.js +31 -18
- 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/jodit.css +2 -2
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +947 -166
- 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/es5/polyfills.fat.min.js +1 -1
- package/es5/polyfills.js +1 -1
- package/es5/polyfills.min.js +1 -1
- package/esm/config.d.ts +31 -0
- package/esm/core/constants.js +1 -1
- package/esm/core/selection/helpers/move-node-inside-start.js +5 -2
- package/esm/core/selection/style/apply-style.js +31 -2
- package/esm/jodit.js +14 -2
- package/esm/plugins/backspace/cases/check-join-neighbors.js +36 -7
- package/esm/plugins/backspace/cases/check-remove-empty-parent.js +3 -1
- package/esm/plugins/bold/bold.js +4 -1
- package/esm/plugins/delete/delete.d.ts +12 -0
- package/esm/plugins/delete/delete.js +50 -1
- package/esm/plugins/link/config.d.ts +31 -0
- package/esm/plugins/link/config.js +3 -0
- package/esm/plugins/link/link.d.ts +27 -0
- package/esm/plugins/link/link.js +144 -2
- package/esm/plugins/link/tlds.d.ts +18 -0
- package/esm/plugins/link/tlds.js +33 -0
- package/esm/plugins/link/typed-link.d.ts +23 -0
- package/esm/plugins/link/typed-link.js +92 -0
- package/esm/plugins/resize-cells/resize-cells.d.ts +25 -1
- package/esm/plugins/resize-cells/resize-cells.js +84 -15
- package/esm/plugins/select/select.d.ts +35 -0
- package/esm/plugins/select/select.js +153 -1
- package/esm/plugins/select-cells/select-cells.d.ts +24 -0
- package/esm/plugins/select-cells/select-cells.js +81 -18
- package/esm/types/style.d.ts +5 -0
- package/package.json +1 -1
- package/types/config.d.ts +31 -0
- package/types/plugins/delete/delete.d.ts +12 -0
- package/types/plugins/link/config.d.ts +31 -0
- package/types/plugins/link/link.d.ts +27 -0
- package/types/plugins/link/tlds.d.ts +18 -0
- package/types/plugins/link/typed-link.d.ts +23 -0
- package/types/plugins/resize-cells/resize-cells.d.ts +25 -1
- package/types/plugins/select/select.d.ts +35 -0
- package/types/plugins/select-cells/select-cells.d.ts +24 -0
- package/types/types/style.d.ts +5 -0
package/es5/polyfills.fat.min.js
CHANGED
package/es5/polyfills.js
CHANGED
package/es5/polyfills.min.js
CHANGED
package/esm/config.d.ts
CHANGED
|
@@ -1564,6 +1564,37 @@ interface Config {
|
|
|
1564
1564
|
* Wrap inserted link
|
|
1565
1565
|
*/
|
|
1566
1566
|
processPastedLink: boolean;
|
|
1567
|
+
/**
|
|
1568
|
+
* Link an address when the space, Enter or Tab after it is typed:
|
|
1569
|
+
* one with a scheme (`https://…`), one that starts with `www.` or a
|
|
1570
|
+
* bare domain such as `example.com` or `education.govt.nz`, which
|
|
1571
|
+
* get `https://`, or an email address, which gets `mailto:`.
|
|
1572
|
+
* Punctuation that ends a sentence stays outside the link, and
|
|
1573
|
+
* Backspace or Undo straight after takes the link off. Not inside a
|
|
1574
|
+
* link, `<pre>` or `<code>`. Default: false.
|
|
1575
|
+
*/
|
|
1576
|
+
processTypedLink: boolean;
|
|
1577
|
+
/**
|
|
1578
|
+
* With `processTypedLink`, more endings a bare domain links with,
|
|
1579
|
+
* in lower case and without the dot, as `['gle', 'school']` for
|
|
1580
|
+
* `forms.gle` and `example.school`. Built in are every two-letter
|
|
1581
|
+
* ending, such as `nz` and `io`, and the generic ones of at least 1
|
|
1582
|
+
* in 1,000 of the most visited sites, such as `com`, `org`, `edu`
|
|
1583
|
+
* and `app`. IANA lists them all:
|
|
1584
|
+
* https://data.iana.org/TLD/tlds-alpha-by-domain.txt
|
|
1585
|
+
* Default: `[]`.
|
|
1586
|
+
*/
|
|
1587
|
+
typedLinkTlds: string[];
|
|
1588
|
+
/**
|
|
1589
|
+
* With `processTypedLink`, the endings a bare domain doesn't link
|
|
1590
|
+
* with, as they're more often a file's: `photos.zip`, `README.md`,
|
|
1591
|
+
* even when `typedLinkTlds` has them. In lower case, without the
|
|
1592
|
+
* dot. A plain list replaces this one entry by entry from the
|
|
1593
|
+
* start, so use `Jodit.atom` to replace the whole list.
|
|
1594
|
+
* `Jodit.atom([])` lets every ending link.
|
|
1595
|
+
* Default: `['zip', 'mov', 'md', 'py', 'sh', 'pub']`.
|
|
1596
|
+
*/
|
|
1597
|
+
typedLinkFileEndings: string[];
|
|
1567
1598
|
/**
|
|
1568
1599
|
* When opening the link dialog for a new link with an empty URL field,
|
|
1569
1600
|
* pre-fill it from the selected text if that text looks like a URL or
|
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-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
-
export const APP_VERSION = "4.19.
|
|
6
|
+
export const APP_VERSION = "4.19.7";
|
|
7
7
|
// prettier-ignore
|
|
8
8
|
export const ES = "es2020";
|
|
9
9
|
export const IS_ES_MODERN = true;
|
|
@@ -3,7 +3,7 @@
|
|
|
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 { INSEPARABLE_TAGS } from "../../constants.js";
|
|
6
|
+
import { INSEPARABLE_TAGS, NBSP_SPACE } from "../../constants.js";
|
|
7
7
|
import { Dom } from "../../dom/dom.js";
|
|
8
8
|
/**
|
|
9
9
|
* Moves the fake node inside the adjacent element if it lies next to it but not inside.
|
|
@@ -11,7 +11,10 @@ import { Dom } from "../../dom/dom.js";
|
|
|
11
11
|
* @private
|
|
12
12
|
*/
|
|
13
13
|
export function moveNodeInsideStart(j, node, start) {
|
|
14
|
-
|
|
14
|
+
// A text node of non-breaking spaces trims to nothing, but it's text the
|
|
15
|
+
// node mustn't move past
|
|
16
|
+
const isContent = (n) => { var _a; return !Dom.isEmptyTextNode(n) || Boolean((_a = n.nodeValue) === null || _a === void 0 ? void 0 : _a.includes(NBSP_SPACE)); };
|
|
17
|
+
let sibling = Dom.findSibling(node, start, isContent), anotherSibling = Dom.findSibling(node, !start, isContent);
|
|
15
18
|
while (Dom.isElement(sibling) &&
|
|
16
19
|
!Dom.isTag(sibling, INSEPARABLE_TAGS) &&
|
|
17
20
|
Dom.isContentEditable(sibling, j.editor) &&
|
|
@@ -3,12 +3,38 @@
|
|
|
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 {
|
|
6
|
+
import { Dom } from "../../dom/dom.js";
|
|
7
|
+
import { $$ } from "../../helpers/utils/selector.js";
|
|
8
|
+
import { extractSelectedPart, FiniteStateMachine } from "./api/index.js";
|
|
7
9
|
import { INITIAL } from "./constants.js";
|
|
8
10
|
import { states, transactions } from "./transactions.js";
|
|
11
|
+
/**
|
|
12
|
+
* Take a selected fragment out of the elements its style takes the place
|
|
13
|
+
* of: one around it is split, so the fragment leaves it, and one in it is
|
|
14
|
+
* unwrapped
|
|
15
|
+
*/
|
|
16
|
+
function takeOutOf(jodit, font, tags) {
|
|
17
|
+
const range = jodit.s.createRange();
|
|
18
|
+
let outer = Dom.closest(font.parentNode, tags, jodit.editor);
|
|
19
|
+
while (outer) {
|
|
20
|
+
range.selectNodeContents(outer);
|
|
21
|
+
range.setEndBefore(font);
|
|
22
|
+
const before = range.cloneContents();
|
|
23
|
+
range.selectNodeContents(outer);
|
|
24
|
+
range.setStartAfter(font);
|
|
25
|
+
// Split only when there's more in it, as a split leaves empty copies
|
|
26
|
+
// of the elements between
|
|
27
|
+
if (!Dom.isEmpty(before) || !Dom.isEmpty(range.cloneContents())) {
|
|
28
|
+
extractSelectedPart(outer, font, jodit);
|
|
29
|
+
}
|
|
30
|
+
Dom.unwrap(outer);
|
|
31
|
+
outer = Dom.closest(font.parentNode, tags, jodit.editor);
|
|
32
|
+
}
|
|
33
|
+
$$(tags.join(','), font).forEach(inner => Dom.unwrap(inner));
|
|
34
|
+
}
|
|
9
35
|
/** @internal */
|
|
10
36
|
export function ApplyStyle(jodit, cs) {
|
|
11
|
-
var _a;
|
|
37
|
+
var _a, _b;
|
|
12
38
|
const { s: sel, editor } = jodit;
|
|
13
39
|
(_a = editor.firstChild) === null || _a === void 0 ? void 0 : _a.normalize(); // FF fix for test "commandsTest - Exec command "bold"
|
|
14
40
|
const fakes = sel.fakes();
|
|
@@ -18,6 +44,9 @@ export function ApplyStyle(jodit, cs) {
|
|
|
18
44
|
// for...of closes the generator on an exception, releasing every
|
|
19
45
|
// temporary wrapper before the selection is restored in finally.
|
|
20
46
|
for (const font of sel.wrapInTagGen(fakes)) {
|
|
47
|
+
if ((_b = cs.options.exclude) === null || _b === void 0 ? void 0 : _b.length) {
|
|
48
|
+
takeOutOf(jodit, font, cs.options.exclude);
|
|
49
|
+
}
|
|
21
50
|
let state = {
|
|
22
51
|
collapsed,
|
|
23
52
|
mode,
|
package/esm/jodit.js
CHANGED
|
@@ -15,7 +15,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
15
15
|
};
|
|
16
16
|
var Jodit_1;
|
|
17
17
|
import * as constants from "./core/constants.js";
|
|
18
|
-
import { FAT_MODE, IS_PROD, lang } from "./core/constants.js";
|
|
18
|
+
import { FAT_MODE, IS_PROD, KEY_BACKSPACE, KEY_DELETE, KEY_ENTER, lang } from "./core/constants.js";
|
|
19
19
|
import { autobind, cache, cached, derive, throttle, watch } from "./core/decorators/index.js";
|
|
20
20
|
import { eventEmitter, instances, modules, pluginSystem } from "./core/global.js";
|
|
21
21
|
import { asArray, attr, callPromise, ConfigMerge, ConfigProto, css, error, isFunction, isJoditObject, isNumber, isPromise, isString, isVoid, kebabCase, markAsAtomic, normalizeKeyAliases, resolveElement, toArray, ucfirst } from "./core/helpers/index.js";
|
|
@@ -25,6 +25,18 @@ import { Dlgs } from "./core/traits/dlgs.js";
|
|
|
25
25
|
import { Config } from "./config.js";
|
|
26
26
|
import { Create, Dom, History, Plugin, Selection, StatusBar, STATUSES, ViewWithToolbar } from "./modules/index.js";
|
|
27
27
|
const FOCUS_EVENTS = new Set(['focus', 'blur', 'focusin', 'focusout']);
|
|
28
|
+
const EDITING_KEYS = new Set([KEY_ENTER, KEY_BACKSPACE, KEY_DELETE]);
|
|
29
|
+
/**
|
|
30
|
+
* Whether the input method (IME) is using the key. Safari fires the keydown
|
|
31
|
+
* that ends a composition, as the Enter that confirms Japanese text, after
|
|
32
|
+
* `compositionend`, and types Korean without one, so `isComposing` is false and
|
|
33
|
+
* only keyCode 229 tells. Only the keys the editor turns into edits are held
|
|
34
|
+
* back: the handlers that follow typing still see the rest.
|
|
35
|
+
*/
|
|
36
|
+
function isInputMethodKey(event) {
|
|
37
|
+
return (event.isComposing ||
|
|
38
|
+
(event.keyCode === 229 && EDITING_KEYS.has(event.key)));
|
|
39
|
+
}
|
|
28
40
|
const __defaultStyleDisplayKey = 'data-jodit-default-style-display';
|
|
29
41
|
const __defaultClassesKey = 'data-jodit-default-classes';
|
|
30
42
|
const NOEDIT = {
|
|
@@ -1264,7 +1276,7 @@ let Jodit = Jodit_1 = class Jodit extends ViewWithToolbar {
|
|
|
1264
1276
|
}
|
|
1265
1277
|
const w = this.ew;
|
|
1266
1278
|
if (event instanceof w.KeyboardEvent &&
|
|
1267
|
-
event
|
|
1279
|
+
isInputMethodKey(event)) {
|
|
1268
1280
|
return;
|
|
1269
1281
|
}
|
|
1270
1282
|
if (this.e && this.e.fire) {
|
|
@@ -20,6 +20,14 @@ function joinNeighbors(jodit, fakeNode, backspace, moved) {
|
|
|
20
20
|
if (checkJoinBareText(jodit, fakeNode, backspace)) {
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
|
+
// Old content can have an inline element round blocks beside the text:
|
|
24
|
+
// moved inside them, the line joins the block as it would bare text
|
|
25
|
+
// (#1781)
|
|
26
|
+
const inline = Dom.findNotEmptySibling(fakeNode, backspace);
|
|
27
|
+
if (joinsBareText(jodit, edgeBlock(inline, backspace)) &&
|
|
28
|
+
moveInlineInside(inline, jodit.editor)) {
|
|
29
|
+
return joinNeighbors(jodit, fakeNode, backspace, moved);
|
|
30
|
+
}
|
|
23
31
|
let nextBox = fakeNode, mainClosestBox = nextBox;
|
|
24
32
|
// Find the main big closest element
|
|
25
33
|
while (nextBox &&
|
|
@@ -350,13 +358,7 @@ function checkJoinInlineSibling(jodit, box, sibling, backspace) {
|
|
|
350
358
|
*/
|
|
351
359
|
function checkJoinBareText(jodit, fakeNode, backspace) {
|
|
352
360
|
const block = Dom.findNotEmptySibling(fakeNode, backspace);
|
|
353
|
-
if (!
|
|
354
|
-
!Dom.isBlock(block) ||
|
|
355
|
-
Dom.isList(block) ||
|
|
356
|
-
Dom.isTag(block, 'table') ||
|
|
357
|
-
Dom.isCell(block) ||
|
|
358
|
-
!Dom.isContentEditable(block, jodit.editor) ||
|
|
359
|
-
Array.from(block.childNodes).some(node => Dom.isBlock(node))) {
|
|
361
|
+
if (!joinsBareText(jodit, block)) {
|
|
360
362
|
return false;
|
|
361
363
|
}
|
|
362
364
|
const filter = getMoveFilter(jodit);
|
|
@@ -384,6 +386,33 @@ function checkJoinBareText(jodit, fakeNode, backspace) {
|
|
|
384
386
|
jodit.s.setCursorBefore(fakeNode);
|
|
385
387
|
return true;
|
|
386
388
|
}
|
|
389
|
+
/**
|
|
390
|
+
* Whether a block joins the bare text beside it: not a list, a table or a
|
|
391
|
+
* cell, and holding no block of its own
|
|
392
|
+
*/
|
|
393
|
+
function joinsBareText(jodit, block) {
|
|
394
|
+
return (Dom.isElement(block) &&
|
|
395
|
+
Dom.isBlock(block) &&
|
|
396
|
+
!Dom.isList(block) &&
|
|
397
|
+
!Dom.isTag(block, 'table') &&
|
|
398
|
+
!Dom.isCell(block) &&
|
|
399
|
+
Dom.isContentEditable(block, jodit.editor) &&
|
|
400
|
+
!Array.from(block.childNodes).some(node => Dom.isBlock(node)));
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* The block an inline element holds on its side facing the caret, through
|
|
404
|
+
* the inline elements in it: the `<p>` of `<span><strong><p>…</p></strong></span>`
|
|
405
|
+
*/
|
|
406
|
+
function edgeBlock(node, backspace) {
|
|
407
|
+
var _a;
|
|
408
|
+
let edge = node;
|
|
409
|
+
while (Dom.isElement(edge) && !Dom.isBlock(edge)) {
|
|
410
|
+
const children = Array.from(edge.childNodes).filter(child => !Dom.isEmptyTextNode(child));
|
|
411
|
+
edge =
|
|
412
|
+
(_a = (backspace ? children[children.length - 1] : children[0])) !== null && _a !== void 0 ? _a : null;
|
|
413
|
+
}
|
|
414
|
+
return edge === node ? null : edge;
|
|
415
|
+
}
|
|
387
416
|
function checkMoveListContent(jodit, mainClosestBox, sibling, backspace) {
|
|
388
417
|
// Process UL/LI/OL cases
|
|
389
418
|
const siblingIsList = Dom.isTag(sibling, LIST_TAGS);
|
|
@@ -27,7 +27,6 @@ export function checkRemoveEmptyParent(jodit, fakeNode, backspace) {
|
|
|
27
27
|
if (!prn || !Dom.isEmpty(prn)) {
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
|
-
const neighbor = Dom.findNotEmptyNeighbor(fakeNode, backspace, jodit.editor);
|
|
31
30
|
do {
|
|
32
31
|
if (prn && Dom.isEmpty(prn) && !Dom.isCell(prn)) {
|
|
33
32
|
Dom.after(prn, fakeNode);
|
|
@@ -43,6 +42,9 @@ export function checkRemoveEmptyParent(jodit, fakeNode, backspace) {
|
|
|
43
42
|
if (found && checkJoinTwoLists(jodit, fakeNode, backspace)) {
|
|
44
43
|
return true;
|
|
45
44
|
}
|
|
45
|
+
// Looked for once the empty elements have gone, as the one beside the
|
|
46
|
+
// caret can be in them: the `<br>` that Delete in `<p>|<br></p>` leaves
|
|
47
|
+
const neighbor = Dom.findNotEmptyNeighbor(fakeNode, backspace, jodit.editor);
|
|
46
48
|
if (neighbor &&
|
|
47
49
|
!Dom.isText(neighbor) &&
|
|
48
50
|
!Dom.isTag(neighbor, INSEPARABLE_TAGS)) {
|
package/esm/plugins/bold/bold.js
CHANGED
|
@@ -32,8 +32,11 @@ export function bold(editor) {
|
|
|
32
32
|
? cssOptions[key][0]
|
|
33
33
|
: cssOptions[key];
|
|
34
34
|
});
|
|
35
|
+
const element = control.tags ? control.tags[0] : undefined;
|
|
35
36
|
editor.s.commitStyle({
|
|
36
|
-
element
|
|
37
|
+
element,
|
|
38
|
+
// As in the browsers and Word, each takes the other's place
|
|
39
|
+
exclude: element === 'sub' ? ['sup'] : element === 'sup' ? ['sub'] : []
|
|
37
40
|
});
|
|
38
41
|
editor.synchronizeValues();
|
|
39
42
|
return false;
|
|
@@ -31,6 +31,18 @@ export declare class deleteCommand extends Plugin {
|
|
|
31
31
|
*/
|
|
32
32
|
private __clearSelectedCells;
|
|
33
33
|
private __moveContentInLeftSibling;
|
|
34
|
+
/**
|
|
35
|
+
* A plain space the deletion leaves at an edge of the block, before a line
|
|
36
|
+
* break or next to another space isn't shown, and the browser drops it when
|
|
37
|
+
* the next char is typed. It becomes non-breaking, as in the browsers' own
|
|
38
|
+
* delete and in Backspace without a selection (#1522)
|
|
39
|
+
*/
|
|
40
|
+
private __keepSpacesVisible;
|
|
41
|
+
/**
|
|
42
|
+
* The text, line break or other element next to the caret in its block,
|
|
43
|
+
* looking inside inline elements
|
|
44
|
+
*/
|
|
45
|
+
private __findNeighbor;
|
|
34
46
|
/**
|
|
35
47
|
* If left sibling is list - return last leaf
|
|
36
48
|
*/
|
|
@@ -3,9 +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 { NBSP_SPACE } from "../../core/constants.js";
|
|
6
7
|
import { Dom } from "../../core/dom/index.js";
|
|
7
8
|
import { pluginSystem } from "../../core/global.js";
|
|
8
|
-
import { toArray } from "../../core/helpers/index.js";
|
|
9
|
+
import { call, toArray, trimInv } from "../../core/helpers/index.js";
|
|
9
10
|
import { trim } from "../../core/helpers/string/trim.js";
|
|
10
11
|
import { Plugin } from "../../core/plugin/index.js";
|
|
11
12
|
import "./interface.js";
|
|
@@ -16,6 +17,18 @@ const NOT_EMPTY_CONTENT_TAGS = new Set([
|
|
|
16
17
|
'iframe',
|
|
17
18
|
'hr'
|
|
18
19
|
]);
|
|
20
|
+
const KEEPS_SPACES = new Set(['pre', 'pre-wrap', 'break-spaces']);
|
|
21
|
+
/**
|
|
22
|
+
* A plain space beside this neighbor isn't shown: there is none, or it's a
|
|
23
|
+
* line break, a block or text starting (or ending) with a plain space
|
|
24
|
+
*/
|
|
25
|
+
function hidesSpace(neighbor, edge) {
|
|
26
|
+
var _a;
|
|
27
|
+
return (!neighbor ||
|
|
28
|
+
Dom.isTag(neighbor, 'br') ||
|
|
29
|
+
Dom.isBlock(neighbor) ||
|
|
30
|
+
(Dom.isText(neighbor) && edge.test((_a = neighbor.nodeValue) !== null && _a !== void 0 ? _a : '')));
|
|
31
|
+
}
|
|
19
32
|
export class deleteCommand extends Plugin {
|
|
20
33
|
afterInit(jodit) {
|
|
21
34
|
jodit.e.on('afterCommand.delete', (command) => {
|
|
@@ -67,6 +80,7 @@ export class deleteCommand extends Plugin {
|
|
|
67
80
|
const leftSibling = Dom.findSibling(fake, true);
|
|
68
81
|
const rightSibling = Dom.findSibling(fake, false);
|
|
69
82
|
this.__moveContentInLeftSibling(fake, leftSibling, rightSibling);
|
|
83
|
+
this.__keepSpacesVisible(fake);
|
|
70
84
|
range.setStartBefore(fake);
|
|
71
85
|
range.collapse(true);
|
|
72
86
|
this.__moveCursorInEditableSibling(jodit, leftSibling, fake, range);
|
|
@@ -170,6 +184,41 @@ export class deleteCommand extends Plugin {
|
|
|
170
184
|
}
|
|
171
185
|
}
|
|
172
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* A plain space the deletion leaves at an edge of the block, before a line
|
|
189
|
+
* break or next to another space isn't shown, and the browser drops it when
|
|
190
|
+
* the next char is typed. It becomes non-breaking, as in the browsers' own
|
|
191
|
+
* delete and in Backspace without a selection (#1522)
|
|
192
|
+
*/
|
|
193
|
+
__keepSpacesVisible(fake) {
|
|
194
|
+
var _a;
|
|
195
|
+
const { jodit } = this;
|
|
196
|
+
const block = (_a = Dom.closest(fake, Dom.isBlock, jodit.editor)) !== null && _a !== void 0 ? _a : jodit.editor;
|
|
197
|
+
if (KEEPS_SPACES.has(jodit.ew.getComputedStyle(block).whiteSpace)) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const before = this.__findNeighbor(fake, true, block);
|
|
201
|
+
const after = this.__findNeighbor(fake, false, block);
|
|
202
|
+
if (Dom.isText(before) && hidesSpace(after, /^ /)) {
|
|
203
|
+
before.nodeValue = before.nodeValue.replace(/ +$/, spaces => NBSP_SPACE.repeat(spaces.length));
|
|
204
|
+
}
|
|
205
|
+
if (Dom.isText(after) && hidesSpace(before, / $/)) {
|
|
206
|
+
after.nodeValue = after.nodeValue.replace(/^ +/, spaces => NBSP_SPACE.repeat(spaces.length));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The text, line break or other element next to the caret in its block,
|
|
211
|
+
* looking inside inline elements
|
|
212
|
+
*/
|
|
213
|
+
__findNeighbor(fake, left, block) {
|
|
214
|
+
return call(left ? Dom.prev : Dom.next, fake, (node) => {
|
|
215
|
+
var _a;
|
|
216
|
+
return Dom.isText(node)
|
|
217
|
+
? trimInv((_a = node.nodeValue) !== null && _a !== void 0 ? _a : '').length > 0
|
|
218
|
+
: !Dom.isComment(node) &&
|
|
219
|
+
!(Dom.isInlineBlock(node) && node.firstChild);
|
|
220
|
+
}, block);
|
|
221
|
+
}
|
|
173
222
|
/**
|
|
174
223
|
* If left sibling is list - return last leaf
|
|
175
224
|
*/
|
|
@@ -27,6 +27,37 @@ declare module 'jodit/config' {
|
|
|
27
27
|
* Wrap inserted link
|
|
28
28
|
*/
|
|
29
29
|
processPastedLink: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Link an address when the space, Enter or Tab after it is typed:
|
|
32
|
+
* one with a scheme (`https://…`), one that starts with `www.` or a
|
|
33
|
+
* bare domain such as `example.com` or `education.govt.nz`, which
|
|
34
|
+
* get `https://`, or an email address, which gets `mailto:`.
|
|
35
|
+
* Punctuation that ends a sentence stays outside the link, and
|
|
36
|
+
* Backspace or Undo straight after takes the link off. Not inside a
|
|
37
|
+
* link, `<pre>` or `<code>`. Default: false.
|
|
38
|
+
*/
|
|
39
|
+
processTypedLink: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* With `processTypedLink`, more endings a bare domain links with,
|
|
42
|
+
* in lower case and without the dot, as `['gle', 'school']` for
|
|
43
|
+
* `forms.gle` and `example.school`. Built in are every two-letter
|
|
44
|
+
* ending, such as `nz` and `io`, and the generic ones of at least 1
|
|
45
|
+
* in 1,000 of the most visited sites, such as `com`, `org`, `edu`
|
|
46
|
+
* and `app`. IANA lists them all:
|
|
47
|
+
* https://data.iana.org/TLD/tlds-alpha-by-domain.txt
|
|
48
|
+
* Default: `[]`.
|
|
49
|
+
*/
|
|
50
|
+
typedLinkTlds: string[];
|
|
51
|
+
/**
|
|
52
|
+
* With `processTypedLink`, the endings a bare domain doesn't link
|
|
53
|
+
* with, as they're more often a file's: `photos.zip`, `README.md`,
|
|
54
|
+
* even when `typedLinkTlds` has them. In lower case, without the
|
|
55
|
+
* dot. A plain list replaces this one entry by entry from the
|
|
56
|
+
* start, so use `Jodit.atom` to replace the whole list.
|
|
57
|
+
* `Jodit.atom([])` lets every ending link.
|
|
58
|
+
* Default: `['zip', 'mov', 'md', 'py', 'sh', 'pub']`.
|
|
59
|
+
*/
|
|
60
|
+
typedLinkFileEndings: string[];
|
|
30
61
|
/**
|
|
31
62
|
* When opening the link dialog for a new link with an empty URL field,
|
|
32
63
|
* pre-fill it from the selected text if that text looks like a URL or
|
|
@@ -14,6 +14,9 @@ Config.prototype.link = {
|
|
|
14
14
|
followOnDblClick: false,
|
|
15
15
|
processVideoLink: true,
|
|
16
16
|
processPastedLink: true,
|
|
17
|
+
processTypedLink: false,
|
|
18
|
+
typedLinkTlds: [],
|
|
19
|
+
typedLinkFileEndings: ['zip', 'mov', 'md', 'py', 'sh', 'pub'],
|
|
17
20
|
deriveUrlFromText: false,
|
|
18
21
|
noFollowCheckbox: true,
|
|
19
22
|
openInNewTabCheckbox: true,
|
|
@@ -24,5 +24,32 @@ export declare class link extends Plugin {
|
|
|
24
24
|
private __generateForm;
|
|
25
25
|
/** @override */
|
|
26
26
|
protected beforeDestruct(jodit: IJodit): void;
|
|
27
|
+
private __onTypedSpace;
|
|
28
|
+
/**
|
|
29
|
+
* Where the caret was when Enter was pressed. Enter splits the line in a
|
|
30
|
+
* history transaction, so the link waits until it's over
|
|
31
|
+
*/
|
|
32
|
+
private __enteredAt;
|
|
33
|
+
private __linkAfterEnter;
|
|
34
|
+
private __onBeforeEnter;
|
|
35
|
+
private __onAfterEnter;
|
|
36
|
+
/**
|
|
37
|
+
* The link just made, which Backspace straight after takes off again, as
|
|
38
|
+
* in CKEditor 5. Any other key but a modifier, a click or a command
|
|
39
|
+
* forgets it
|
|
40
|
+
*/
|
|
41
|
+
private __justLinked;
|
|
42
|
+
private __forgetLink;
|
|
43
|
+
private __onKeyDown;
|
|
44
|
+
/**
|
|
45
|
+
* Links the address that ends at `end` in a text node, as a step of its
|
|
46
|
+
* own in the history, so Undo straight after takes the link off and
|
|
47
|
+
* leaves the text
|
|
48
|
+
*/
|
|
49
|
+
private __linkTyped;
|
|
50
|
+
/**
|
|
51
|
+
* Reports what's changed and makes it a history step of its own
|
|
52
|
+
*/
|
|
53
|
+
private __recordStep;
|
|
27
54
|
private __onClickReadOnlyLink;
|
|
28
55
|
}
|