jodit 4.19.11 → 4.19.14
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 +19 -0
- package/es2015/jodit.css +33 -1
- package/es2015/jodit.fat.min.css +1 -1
- package/es2015/jodit.fat.min.js +11 -11
- package/es2015/jodit.js +219 -117
- package/es2015/jodit.min.css +1 -1
- package/es2015/jodit.min.js +9 -9
- 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.css +1 -1
- package/es2018/jodit.fat.min.js +9 -9
- package/es2018/jodit.min.css +1 -1
- package/es2018/jodit.min.js +9 -9
- package/es2018/plugins/debug/debug.min.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021/jodit.css +33 -1
- package/es2021/jodit.fat.min.css +1 -1
- package/es2021/jodit.fat.min.js +10 -10
- package/es2021/jodit.js +218 -115
- package/es2021/jodit.min.css +1 -1
- package/es2021/jodit.min.js +10 -10
- 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 +33 -1
- package/es2021.en/jodit.fat.min.css +1 -1
- package/es2021.en/jodit.fat.min.js +10 -10
- package/es2021.en/jodit.js +194 -91
- package/es2021.en/jodit.min.css +1 -1
- package/es2021.en/jodit.min.js +11 -11
- 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 +34 -2
- package/es5/jodit.fat.min.css +1 -1
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +261 -120
- 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 +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/core/constants.js +1 -1
- package/esm/core/global.d.ts +6 -0
- package/esm/core/global.js +21 -4
- package/esm/core/helpers/html/safe-html.js +26 -0
- package/esm/core/ui/button/tooltip/tooltip.d.ts +6 -0
- package/esm/core/ui/button/tooltip/tooltip.js +14 -3
- package/esm/core/view/view-with-toolbar.js +6 -1
- package/esm/jodit.d.ts +4 -0
- package/esm/jodit.js +5 -1
- package/esm/languages.js +7 -1
- package/esm/plugins/add-new-line/add-new-line.d.ts +5 -0
- package/esm/plugins/add-new-line/add-new-line.js +20 -3
- package/esm/plugins/delete/delete.d.ts +7 -0
- package/esm/plugins/delete/delete.js +22 -0
- package/esm/plugins/hr/hr.js +5 -0
- package/esm/plugins/media/media.js +8 -5
- package/esm/plugins/resizer/resizer.js +4 -1
- package/esm/plugins/select-cells/select-cells.d.ts +1 -0
- package/esm/plugins/select-cells/select-cells.js +12 -18
- package/package.json +1 -1
- package/types/core/global.d.ts +6 -0
- package/types/core/ui/button/tooltip/tooltip.d.ts +6 -0
- package/types/jodit.d.ts +4 -0
- package/types/plugins/add-new-line/add-new-line.d.ts +5 -0
- package/types/plugins/delete/delete.d.ts +7 -0
- package/types/plugins/select-cells/select-cells.d.ts +1 -0
package/es5/polyfills.fat.min.js
CHANGED
package/es5/polyfills.js
CHANGED
package/es5/polyfills.min.js
CHANGED
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.14";
|
|
7
7
|
// prettier-ignore
|
|
8
8
|
export const ES = "es2020";
|
|
9
9
|
export const IS_ES_MODERN = true;
|
package/esm/core/global.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ export declare const instances: IDictionary<IJodit>;
|
|
|
15
15
|
export declare function uniqueUid(): string;
|
|
16
16
|
export declare const pluginSystem: PluginSystem;
|
|
17
17
|
export declare const modules: IDictionary<Function>;
|
|
18
|
+
/**
|
|
19
|
+
* Merge language packs into the global `lang` registry
|
|
20
|
+
*
|
|
21
|
+
* `__proto__`, `constructor` and `prototype` are skipped on both levels, so a
|
|
22
|
+
* pack parsed from untrusted JSON cannot reach `Object.prototype` (CWE-1321).
|
|
23
|
+
*/
|
|
18
24
|
export declare const extendLang: (langs: IDictionary) => void;
|
|
19
25
|
/**
|
|
20
26
|
* Create unique box(HTMLCotainer) and remove it after destroy
|
package/esm/core/global.js
CHANGED
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
6
|
import { isJoditObject } from "./helpers/checker/is-jodit-object.js";
|
|
7
|
+
import { isPlainObject } from "./helpers/checker/is-plain-object.js";
|
|
7
8
|
import { isString } from "./helpers/checker/is-string.js";
|
|
8
9
|
import { isViewObject } from "./helpers/checker/is-view-object.js";
|
|
9
10
|
import { kebabCase } from "./helpers/string/kebab-case.js";
|
|
10
11
|
import { attr } from "./helpers/utils/attr.js";
|
|
11
12
|
import { css } from "./helpers/utils/css.js";
|
|
12
13
|
import { getClassName } from "./helpers/utils/get-class-name.js";
|
|
14
|
+
import { isUnsafeProtoKey } from "./helpers/utils/is-unsafe-proto-key.js";
|
|
13
15
|
import { PluginSystem } from "./plugin/plugin-system.js";
|
|
14
16
|
import { eventEmitter as globalEventEmitter } from "./event-emitter/global.js";
|
|
15
17
|
import { lang } from "./constants.js";
|
|
@@ -36,14 +38,29 @@ export const pluginSystem = new PluginSystem({
|
|
|
36
38
|
getContainer
|
|
37
39
|
});
|
|
38
40
|
export const modules = {};
|
|
41
|
+
// A CommonJS pack imported as a namespace carries the dictionary in `default`; a translation of the word is a string
|
|
42
|
+
const unwrapModule = (pack) => isPlainObject(pack) && isPlainObject(pack.default) ? pack.default : pack;
|
|
43
|
+
/**
|
|
44
|
+
* Merge language packs into the global `lang` registry
|
|
45
|
+
*
|
|
46
|
+
* `__proto__`, `constructor` and `prototype` are skipped on both levels, so a
|
|
47
|
+
* pack parsed from untrusted JSON cannot reach `Object.prototype` (CWE-1321).
|
|
48
|
+
*/
|
|
39
49
|
export const extendLang = (langs) => {
|
|
40
50
|
Object.keys(langs).forEach(key => {
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
const pack = unwrapModule(langs[key]);
|
|
52
|
+
if (isUnsafeProtoKey(key) || !isPlainObject(pack)) {
|
|
53
|
+
return;
|
|
43
54
|
}
|
|
44
|
-
|
|
45
|
-
lang[key]
|
|
55
|
+
if (!Object.prototype.hasOwnProperty.call(lang, key) ||
|
|
56
|
+
!isPlainObject(lang[key])) {
|
|
57
|
+
lang[key] = {};
|
|
46
58
|
}
|
|
59
|
+
Object.keys(pack).forEach(name => {
|
|
60
|
+
if (!isUnsafeProtoKey(name)) {
|
|
61
|
+
lang[key][name] = pack[name];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
47
64
|
});
|
|
48
65
|
};
|
|
49
66
|
const boxes = new WeakMap();
|
|
@@ -139,6 +139,18 @@ const URL_ATTRIBUTES = [
|
|
|
139
139
|
'background',
|
|
140
140
|
'xlink:href'
|
|
141
141
|
];
|
|
142
|
+
/**
|
|
143
|
+
* SVG animation elements can write a URL attribute at run time, as
|
|
144
|
+
* `<animate attributeName="href" values="javascript:…">` does, and the
|
|
145
|
+
* attributes below carry the values they write.
|
|
146
|
+
*/
|
|
147
|
+
const ANIMATION_TAGS = new Set([
|
|
148
|
+
'animate',
|
|
149
|
+
'set',
|
|
150
|
+
'animatemotion',
|
|
151
|
+
'animatetransform'
|
|
152
|
+
]);
|
|
153
|
+
const ANIMATION_VALUE_ATTRIBUTES = ['values', 'from', 'to', 'by'];
|
|
142
154
|
/**
|
|
143
155
|
* Tags that load their URL as a *document* (scripts inside run). An SVG data
|
|
144
156
|
* URL is only an XSS vector here — as an `<img>` source it renders inertly.
|
|
@@ -209,6 +221,20 @@ export function sanitizeHTMLElement(elm, { safeJavaScriptLink, removeOnError, re
|
|
|
209
221
|
effected = true;
|
|
210
222
|
}
|
|
211
223
|
}
|
|
224
|
+
// SMIL sets the attribute on click time, after the static check above:
|
|
225
|
+
// `<svg><a><animate attributeName="href" values="javascript:…">` ran
|
|
226
|
+
// in Chromium and Safari. Drop the values that hold a dangerous
|
|
227
|
+
// scheme; `values` is a `;` list. See GHSA-6wrw-v5gj-6xg7
|
|
228
|
+
if (ANIMATION_TAGS.has(tagName)) {
|
|
229
|
+
for (const name of ANIMATION_VALUE_ATTRIBUTES) {
|
|
230
|
+
const value = attrRaw(elm, name);
|
|
231
|
+
if (value &&
|
|
232
|
+
value.split(';').some(part => isDangerousUrl(part, 'a'))) {
|
|
233
|
+
attr(elm, name, null);
|
|
234
|
+
effected = true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
212
238
|
}
|
|
213
239
|
return effected;
|
|
214
240
|
}
|
|
@@ -15,6 +15,12 @@ export declare class UITooltip extends UIElement {
|
|
|
15
15
|
className(): string;
|
|
16
16
|
protected render(): string;
|
|
17
17
|
constructor(view: IViewBased);
|
|
18
|
+
private get __isEnabled();
|
|
19
|
+
/**
|
|
20
|
+
* Show tooltips for the buttons in an element outside the editor's
|
|
21
|
+
* container, such as a toolbar placed by the `toolbar` option
|
|
22
|
+
*/
|
|
23
|
+
attach(container: HTMLElement): void;
|
|
18
24
|
private __attachedContainers;
|
|
19
25
|
private __onAttach;
|
|
20
26
|
private __listenClose;
|
|
@@ -51,9 +51,7 @@ let UITooltip = UITooltip_1 = class UITooltip extends UIElement {
|
|
|
51
51
|
this.__currentTarget = null;
|
|
52
52
|
this.__delayShowTimeout = 0;
|
|
53
53
|
this.__hideTimeout = 0;
|
|
54
|
-
if (
|
|
55
|
-
view.o.showTooltip &&
|
|
56
|
-
!view.o.useNativeTooltip) {
|
|
54
|
+
if (this.__isEnabled) {
|
|
57
55
|
this.j.e.on('getContainer', (box) => {
|
|
58
56
|
this.__onAttach(box);
|
|
59
57
|
});
|
|
@@ -62,6 +60,19 @@ let UITooltip = UITooltip_1 = class UITooltip extends UIElement {
|
|
|
62
60
|
});
|
|
63
61
|
}
|
|
64
62
|
}
|
|
63
|
+
get __isEnabled() {
|
|
64
|
+
const { o } = this.j;
|
|
65
|
+
return !o.textIcons && Boolean(o.showTooltip) && !o.useNativeTooltip;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Show tooltips for the buttons in an element outside the editor's
|
|
69
|
+
* container, such as a toolbar placed by the `toolbar` option
|
|
70
|
+
*/
|
|
71
|
+
attach(container) {
|
|
72
|
+
if (this.__isEnabled) {
|
|
73
|
+
this.__onAttach(container);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
65
76
|
__onAttach(container) {
|
|
66
77
|
// TODO Move it inside __show method. Now it is here because testcase failed with capturing
|
|
67
78
|
Dom.append(getContainer(this.j, UITooltip_1), this.container);
|
|
@@ -71,7 +71,12 @@ export class ViewWithToolbar extends View {
|
|
|
71
71
|
const buttons = this.o.buttons
|
|
72
72
|
? splitArray(this.o.buttons)
|
|
73
73
|
: [];
|
|
74
|
-
|
|
74
|
+
const container = this.toolbarContainer;
|
|
75
|
+
(_a = this.toolbar) === null || _a === void 0 ? void 0 : _a.setRemoveButtons(this.o.removeButtons).build(buttons.concat(this.o.extraButtons || [])).appendTo(container);
|
|
76
|
+
// The toolbar's own element, as editors can share the one it is placed in
|
|
77
|
+
if (this.toolbar && !Dom.isOrContains(this.container, container)) {
|
|
78
|
+
this.__tooltip.attach(this.toolbar.container);
|
|
79
|
+
}
|
|
75
80
|
}
|
|
76
81
|
getRegisteredButtonGroups() {
|
|
77
82
|
return this.groupToButtons;
|
package/esm/jodit.d.ts
CHANGED
|
@@ -131,6 +131,10 @@ export declare class Jodit extends ViewWithToolbar implements IJodit, Dlgs {
|
|
|
131
131
|
static readonly constants: typeof constants;
|
|
132
132
|
static readonly instances: IDictionary<IJodit>;
|
|
133
133
|
static readonly lang: any;
|
|
134
|
+
/**
|
|
135
|
+
* Merge language packs into `Jodit.lang`; prototype keys are ignored
|
|
136
|
+
*/
|
|
137
|
+
static readonly extendLang: (langs: IDictionary) => void;
|
|
134
138
|
static readonly core: {
|
|
135
139
|
Plugin: typeof Modules.Plugin;
|
|
136
140
|
};
|
package/esm/jodit.js
CHANGED
|
@@ -17,7 +17,7 @@ var Jodit_1;
|
|
|
17
17
|
import * as constants from "./core/constants.js";
|
|
18
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
|
-
import { eventEmitter, instances, modules, pluginSystem } from "./core/global.js";
|
|
20
|
+
import { eventEmitter, extendLang, 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";
|
|
22
22
|
import { removeEmptyMarkedTags } from "./core/helpers/html/tag-scan.js";
|
|
23
23
|
import { cssInline } from "./core/helpers/utils/css.js";
|
|
@@ -1404,6 +1404,10 @@ Jodit.decorators = {};
|
|
|
1404
1404
|
Jodit.constants = constants;
|
|
1405
1405
|
Jodit.instances = instances;
|
|
1406
1406
|
Jodit.lang = lang;
|
|
1407
|
+
/**
|
|
1408
|
+
* Merge language packs into `Jodit.lang`; prototype keys are ignored
|
|
1409
|
+
*/
|
|
1410
|
+
Jodit.extendLang = extendLang;
|
|
1407
1411
|
Jodit.core = {
|
|
1408
1412
|
Plugin
|
|
1409
1413
|
};
|
package/esm/languages.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
6
|
import { isArray } from "./core/helpers/checker/is-array.js";
|
|
7
|
+
import { isPlainObject } from "./core/helpers/checker/is-plain-object.js";
|
|
7
8
|
import ar from "./langs/ar.js";
|
|
8
9
|
import az from "./langs/az.js";
|
|
9
10
|
import cs_cz from "./langs/cs_cz.js";
|
|
@@ -63,7 +64,12 @@ exp = {
|
|
|
63
64
|
zh_tw
|
|
64
65
|
};
|
|
65
66
|
/* Unpack array to hash */
|
|
66
|
-
|
|
67
|
+
// Unwrap a module (`default` is the dictionary or the packed array), but keep a dictionary whose `default` is a translation (`no.js`)
|
|
68
|
+
const get = (value) => value
|
|
69
|
+
? isArray(value.default) || isPlainObject(value.default)
|
|
70
|
+
? value.default
|
|
71
|
+
: value
|
|
72
|
+
: {}, hashLang = {};
|
|
67
73
|
if (isArray(get(keys))) {
|
|
68
74
|
get(keys).forEach((key, index) => {
|
|
69
75
|
hashLang[index] = key;
|
|
@@ -29,6 +29,11 @@ export declare class addNewLine extends Plugin {
|
|
|
29
29
|
private __canGetFocus;
|
|
30
30
|
protected afterInit(editor: IJodit): void;
|
|
31
31
|
private __addEventListeners;
|
|
32
|
+
/**
|
|
33
|
+
* An empty line with a `<br>`, as Enter makes, so it keeps its height
|
|
34
|
+
* without clean-html's fillEmptyParagraph (#1807)
|
|
35
|
+
*/
|
|
36
|
+
private __newLine;
|
|
32
37
|
private __onClickLine;
|
|
33
38
|
/**
|
|
34
39
|
* A paragraph holding only an embed has no place for the caret, so the
|
|
@@ -50,7 +50,7 @@ export class addNewLine extends Plugin {
|
|
|
50
50
|
};
|
|
51
51
|
this.__onClickLine = (e) => {
|
|
52
52
|
const editor = this.j;
|
|
53
|
-
const p =
|
|
53
|
+
const p = this.__newLine();
|
|
54
54
|
if (this.__isBeforeContent &&
|
|
55
55
|
this.__current &&
|
|
56
56
|
this.__current.parentNode) {
|
|
@@ -129,6 +129,18 @@ export class addNewLine extends Plugin {
|
|
|
129
129
|
.on(editor.container, 'mouseleave' + '.' + ns, this.__hide)
|
|
130
130
|
.on(editor.editor, 'mousemove' + '.' + ns, this.__onMouseMove);
|
|
131
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* An empty line with a `<br>`, as Enter makes, so it keeps its height
|
|
134
|
+
* without clean-html's fillEmptyParagraph (#1807)
|
|
135
|
+
*/
|
|
136
|
+
__newLine() {
|
|
137
|
+
const { j } = this;
|
|
138
|
+
const line = j.createInside.element(j.o.enter);
|
|
139
|
+
if (!Dom.isTag(line, 'br')) {
|
|
140
|
+
Dom.append(line, j.createInside.element('br'));
|
|
141
|
+
}
|
|
142
|
+
return line;
|
|
143
|
+
}
|
|
132
144
|
/**
|
|
133
145
|
* A paragraph holding only an embed has no place for the caret, so the
|
|
134
146
|
* arrow keys can't get past one that ends the content, or before one that
|
|
@@ -147,6 +159,11 @@ export class addNewLine extends Plugin {
|
|
|
147
159
|
return;
|
|
148
160
|
}
|
|
149
161
|
const { startContainer, startOffset } = editor.s.range;
|
|
162
|
+
// A caret in the editor itself, as beside a horizontal line, is in no
|
|
163
|
+
// paragraph, and the browsers can leave it there with text beyond (#1803)
|
|
164
|
+
if (startContainer === editor.editor) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
150
167
|
// Once the browser has moved the caret, if it could. With a 0 timeout
|
|
151
168
|
// Jodit would run this at once, before the browser moves it
|
|
152
169
|
editor.async.setTimeout(() => {
|
|
@@ -161,7 +178,7 @@ export class addNewLine extends Plugin {
|
|
|
161
178
|
!Dom.findNotEmptyNeighbor(block, !forward, editor.editor)) {
|
|
162
179
|
return;
|
|
163
180
|
}
|
|
164
|
-
const p =
|
|
181
|
+
const p = this.__newLine();
|
|
165
182
|
forward
|
|
166
183
|
? Dom.append(editor.editor, p)
|
|
167
184
|
: Dom.prepend(editor.editor, p);
|
|
@@ -178,7 +195,7 @@ export class addNewLine extends Plugin {
|
|
|
178
195
|
editor.s.isCollapsed()) {
|
|
179
196
|
const editorBound = offset(editor.editor, editor, editor.ed);
|
|
180
197
|
const top = e.pageY - editor.ew.scrollX;
|
|
181
|
-
const p =
|
|
198
|
+
const p = this.__newLine();
|
|
182
199
|
if (Math.abs(top - editorBound.top) <
|
|
183
200
|
Math.abs(top - (editorBound.height + editorBound.top)) &&
|
|
184
201
|
editor.editor.firstChild) {
|
|
@@ -20,6 +20,13 @@ export declare class deleteCommand extends Plugin {
|
|
|
20
20
|
*/
|
|
21
21
|
private __afterDeleteCommand;
|
|
22
22
|
private __onDeleteCommand;
|
|
23
|
+
/**
|
|
24
|
+
* Firefox selects cells whole from their row, as after a drag into or out
|
|
25
|
+
* of a table nested in a cell, and `deleteContents` would remove them. The
|
|
26
|
+
* edges move into the cells, so their content is cleared instead, as in
|
|
27
|
+
* Firefox's own delete
|
|
28
|
+
*/
|
|
29
|
+
private __moveEdgesIntoCells;
|
|
23
30
|
/**
|
|
24
31
|
* A selection that starts or ends in a table cell clears the selected part
|
|
25
32
|
* of each cell it covers and keeps the cells, as the browsers do.
|
|
@@ -83,6 +83,7 @@ export class deleteCommand extends Plugin {
|
|
|
83
83
|
}
|
|
84
84
|
jodit.s.expandSelection();
|
|
85
85
|
const range = jodit.s.range;
|
|
86
|
+
this.__moveEdgesIntoCells(range);
|
|
86
87
|
const caret = this.__clearSelectedCells(range);
|
|
87
88
|
if (caret && range.collapsed) {
|
|
88
89
|
jodit.s.selectRange(caret);
|
|
@@ -104,6 +105,27 @@ export class deleteCommand extends Plugin {
|
|
|
104
105
|
jodit.s.selectRange(caret !== null && caret !== void 0 ? caret : range);
|
|
105
106
|
return false;
|
|
106
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Firefox selects cells whole from their row, as after a drag into or out
|
|
110
|
+
* of a table nested in a cell, and `deleteContents` would remove them. The
|
|
111
|
+
* edges move into the cells, so their content is cleared instead, as in
|
|
112
|
+
* Firefox's own delete
|
|
113
|
+
*/
|
|
114
|
+
__moveEdgesIntoCells(range) {
|
|
115
|
+
const { startContainer, startOffset, endContainer, endOffset } = range;
|
|
116
|
+
const first = Dom.isTag(startContainer, 'tr')
|
|
117
|
+
? startContainer.childNodes[startOffset]
|
|
118
|
+
: null;
|
|
119
|
+
const last = Dom.isTag(endContainer, 'tr')
|
|
120
|
+
? endContainer.childNodes[endOffset - 1]
|
|
121
|
+
: null;
|
|
122
|
+
if (Dom.isCell(first)) {
|
|
123
|
+
range.setStart(first, 0);
|
|
124
|
+
}
|
|
125
|
+
if (Dom.isCell(last)) {
|
|
126
|
+
range.setEnd(last, last.childNodes.length);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
107
129
|
/**
|
|
108
130
|
* A selection that starts or ends in a table cell clears the selected part
|
|
109
131
|
* of each cell it covers and keeps the cells, as the browsers do.
|
package/esm/plugins/hr/hr.js
CHANGED
|
@@ -47,6 +47,11 @@ export function hr(editor) {
|
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
49
|
const p = editor.createInside.element(editor.o.enter);
|
|
50
|
+
// As Enter's new line has, so it keeps its height without clean-html's
|
|
51
|
+
// fillEmptyParagraph (#1807)
|
|
52
|
+
if (!Dom.isTag(p, 'br')) {
|
|
53
|
+
Dom.append(p, editor.createInside.element('br'));
|
|
54
|
+
}
|
|
50
55
|
Dom.after(elm, p);
|
|
51
56
|
editor.s.setCursorIn(p);
|
|
52
57
|
return false;
|
|
@@ -36,15 +36,18 @@ export function media(editor) {
|
|
|
36
36
|
});
|
|
37
37
|
attr(wrapper, 'style', attr(element, 'style'));
|
|
38
38
|
// The wrapper fits the media, whose size changes as its metadata loads
|
|
39
|
-
// and as it's resized.
|
|
39
|
+
// and as it's resized. It's inline, as the media is by default, so the
|
|
40
|
+
// line's text-align still places it, or a block when the media is one.
|
|
41
|
+
// A percentage width is of the line, so the wrapper is a block that
|
|
42
|
+
// takes the line, and the media in it follows the text-align it inherits
|
|
40
43
|
const fit = () => {
|
|
44
|
+
const ofLine = cssInline(media, 'width').endsWith('%');
|
|
41
45
|
css(wrapper, {
|
|
42
|
-
display:
|
|
46
|
+
display: !ofLine &&
|
|
47
|
+
/^inline/.test(css(media, 'display').toString())
|
|
43
48
|
? 'inline-block'
|
|
44
49
|
: 'block',
|
|
45
|
-
width:
|
|
46
|
-
? ''
|
|
47
|
-
: 'fit-content',
|
|
50
|
+
width: ofLine ? '' : 'fit-content',
|
|
48
51
|
height: ''
|
|
49
52
|
});
|
|
50
53
|
};
|
|
@@ -488,8 +488,11 @@ export class resizer extends Plugin {
|
|
|
488
488
|
// is nothing measurable at all, let the wrapper size itself.
|
|
489
489
|
const width = element.offsetWidth || attrPixelSize(element, 'width');
|
|
490
490
|
const height = element.offsetHeight || attrPixelSize(element, 'height');
|
|
491
|
+
// The wrapper takes the iframe's place in its line: inline, as an
|
|
492
|
+
// iframe is by default, so the line's text-align still places it,
|
|
493
|
+
// or a block when the iframe is one
|
|
491
494
|
css(wrapper, {
|
|
492
|
-
display:
|
|
495
|
+
display: /^inline/.test(css(element, 'display').toString())
|
|
493
496
|
? 'inline-block'
|
|
494
497
|
: 'block'
|
|
495
498
|
});
|
|
@@ -240,17 +240,14 @@ export class selectCells extends Plugin {
|
|
|
240
240
|
* Mouse move inside the table
|
|
241
241
|
*/
|
|
242
242
|
__onMove(table, e) {
|
|
243
|
-
var _a
|
|
243
|
+
var _a;
|
|
244
244
|
if (this.j.o.readonly && !this.j.isLocked) {
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
247
|
if (this.j.isLockedNotBy(key)) {
|
|
248
248
|
return;
|
|
249
249
|
}
|
|
250
|
-
|
|
251
|
-
// host, so the lookup must start from the shadow root
|
|
252
|
-
const node = ((_a = this.j.o.shadowRoot) !== null && _a !== void 0 ? _a : this.j.ed).elementFromPoint(e.clientX, e.clientY);
|
|
253
|
-
const cell = node && Dom.closest(node, ['td', 'th'], table);
|
|
250
|
+
const cell = this.__cellUnder(e, table);
|
|
254
251
|
if (!cell || !this.__selectedCell) {
|
|
255
252
|
return;
|
|
256
253
|
}
|
|
@@ -276,7 +273,7 @@ export class selectCells extends Plugin {
|
|
|
276
273
|
}
|
|
277
274
|
const cellsCount = this.__tableModule.getAllSelectedCells().length;
|
|
278
275
|
if (cellsCount > 1) {
|
|
279
|
-
(
|
|
276
|
+
(_a = this.j.s.sel) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
280
277
|
}
|
|
281
278
|
this.j.e.fire('hidePopup');
|
|
282
279
|
e.stopPropagation();
|
|
@@ -297,30 +294,27 @@ export class selectCells extends Plugin {
|
|
|
297
294
|
this.__isSelectionMode = false;
|
|
298
295
|
this.__selectedCell = null;
|
|
299
296
|
}
|
|
297
|
+
// The cell of this table under the pointer; over a table nested in a cell, the mouse is still in that cell
|
|
298
|
+
__cellUnder(e, table) {
|
|
299
|
+
var _a;
|
|
300
|
+
// Inside Shadow DOM `document.elementFromPoint` returns the shadow
|
|
301
|
+
// host, so the lookup must start from the shadow root
|
|
302
|
+
const node = ((_a = this.j.o.shadowRoot) !== null && _a !== void 0 ? _a : this.j.ed).elementFromPoint(e.clientX, e.clientY);
|
|
303
|
+
return Dom.closest(node, elm => Dom.isCell(elm) && !Dom.closest(elm, 'table', table), table);
|
|
304
|
+
}
|
|
300
305
|
/**
|
|
301
306
|
* Stop a selection process
|
|
302
307
|
*/
|
|
303
308
|
__onStopSelection(table, e) {
|
|
304
|
-
var _a;
|
|
305
309
|
if (!this.__selectedCell) {
|
|
306
310
|
return;
|
|
307
311
|
}
|
|
308
312
|
this.__isSelectionMode = false;
|
|
309
313
|
this.j.unlock();
|
|
310
|
-
|
|
311
|
-
// host, so the lookup must start from the shadow root
|
|
312
|
-
const node = ((_a = this.j.o.shadowRoot) !== null && _a !== void 0 ? _a : this.j.ed).elementFromPoint(e.clientX, e.clientY);
|
|
313
|
-
if (!node) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
const cell = Dom.closest(node, ['td', 'th'], table);
|
|
314
|
+
const cell = this.__cellUnder(e, table);
|
|
317
315
|
if (!cell) {
|
|
318
316
|
return;
|
|
319
317
|
}
|
|
320
|
-
const ownTable = Dom.closest(cell, 'table', table);
|
|
321
|
-
if (ownTable && ownTable !== table) {
|
|
322
|
-
return; // Nested tables
|
|
323
|
-
}
|
|
324
318
|
this.__showCellsPopup(table, [cell, this.__selectedCell]);
|
|
325
319
|
this.__stopListening();
|
|
326
320
|
}
|
package/package.json
CHANGED
package/types/core/global.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ export declare const instances: IDictionary<IJodit>;
|
|
|
15
15
|
export declare function uniqueUid(): string;
|
|
16
16
|
export declare const pluginSystem: PluginSystem;
|
|
17
17
|
export declare const modules: IDictionary<Function>;
|
|
18
|
+
/**
|
|
19
|
+
* Merge language packs into the global `lang` registry
|
|
20
|
+
*
|
|
21
|
+
* `__proto__`, `constructor` and `prototype` are skipped on both levels, so a
|
|
22
|
+
* pack parsed from untrusted JSON cannot reach `Object.prototype` (CWE-1321).
|
|
23
|
+
*/
|
|
18
24
|
export declare const extendLang: (langs: IDictionary) => void;
|
|
19
25
|
/**
|
|
20
26
|
* Create unique box(HTMLCotainer) and remove it after destroy
|
|
@@ -15,6 +15,12 @@ export declare class UITooltip extends UIElement {
|
|
|
15
15
|
className(): string;
|
|
16
16
|
protected render(): string;
|
|
17
17
|
constructor(view: IViewBased);
|
|
18
|
+
private get __isEnabled();
|
|
19
|
+
/**
|
|
20
|
+
* Show tooltips for the buttons in an element outside the editor's
|
|
21
|
+
* container, such as a toolbar placed by the `toolbar` option
|
|
22
|
+
*/
|
|
23
|
+
attach(container: HTMLElement): void;
|
|
18
24
|
private __attachedContainers;
|
|
19
25
|
private __onAttach;
|
|
20
26
|
private __listenClose;
|
package/types/jodit.d.ts
CHANGED
|
@@ -131,6 +131,10 @@ export declare class Jodit extends ViewWithToolbar implements IJodit, Dlgs {
|
|
|
131
131
|
static readonly constants: typeof constants;
|
|
132
132
|
static readonly instances: IDictionary<IJodit>;
|
|
133
133
|
static readonly lang: any;
|
|
134
|
+
/**
|
|
135
|
+
* Merge language packs into `Jodit.lang`; prototype keys are ignored
|
|
136
|
+
*/
|
|
137
|
+
static readonly extendLang: (langs: IDictionary) => void;
|
|
134
138
|
static readonly core: {
|
|
135
139
|
Plugin: typeof Modules.Plugin;
|
|
136
140
|
};
|
|
@@ -29,6 +29,11 @@ export declare class addNewLine extends Plugin {
|
|
|
29
29
|
private __canGetFocus;
|
|
30
30
|
protected afterInit(editor: IJodit): void;
|
|
31
31
|
private __addEventListeners;
|
|
32
|
+
/**
|
|
33
|
+
* An empty line with a `<br>`, as Enter makes, so it keeps its height
|
|
34
|
+
* without clean-html's fillEmptyParagraph (#1807)
|
|
35
|
+
*/
|
|
36
|
+
private __newLine;
|
|
32
37
|
private __onClickLine;
|
|
33
38
|
/**
|
|
34
39
|
* A paragraph holding only an embed has no place for the caret, so the
|
|
@@ -20,6 +20,13 @@ export declare class deleteCommand extends Plugin {
|
|
|
20
20
|
*/
|
|
21
21
|
private __afterDeleteCommand;
|
|
22
22
|
private __onDeleteCommand;
|
|
23
|
+
/**
|
|
24
|
+
* Firefox selects cells whole from their row, as after a drag into or out
|
|
25
|
+
* of a table nested in a cell, and `deleteContents` would remove them. The
|
|
26
|
+
* edges move into the cells, so their content is cleared instead, as in
|
|
27
|
+
* Firefox's own delete
|
|
28
|
+
*/
|
|
29
|
+
private __moveEdgesIntoCells;
|
|
23
30
|
/**
|
|
24
31
|
* A selection that starts or ends in a table cell clears the selected part
|
|
25
32
|
* of each cell it covers and keeps the cells, as the browsers do.
|