jodit 4.12.44 → 4.13.5
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 +23 -1
- package/es2015/jodit.css +6 -1
- package/es2015/jodit.fat.min.css +1 -1
- package/es2015/jodit.fat.min.js +14 -14
- package/es2015/jodit.js +159 -19
- package/es2015/jodit.min.css +1 -1
- package/es2015/jodit.min.js +5 -5
- 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 +3 -3
- package/es2018/jodit.min.css +1 -1
- package/es2018/jodit.min.js +5 -5
- package/es2018/plugins/debug/debug.min.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021/jodit.css +6 -1
- package/es2021/jodit.fat.min.css +1 -1
- package/es2021/jodit.fat.min.js +5 -5
- package/es2021/jodit.js +150 -19
- package/es2021/jodit.min.css +1 -1
- package/es2021/jodit.min.js +7 -7
- 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 +6 -1
- package/es2021.en/jodit.fat.min.css +1 -1
- package/es2021.en/jodit.fat.min.js +6 -6
- package/es2021.en/jodit.js +150 -19
- package/es2021.en/jodit.min.css +1 -1
- package/es2021.en/jodit.min.js +6 -6
- 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 +7 -2
- package/es5/jodit.fat.min.css +1 -1
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +195 -19
- 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/helpers/html/safe-html.js +3 -2
- package/esm/core/selection/selection.d.ts +31 -0
- package/esm/core/selection/selection.js +143 -14
- package/esm/core/view/view-with-toolbar.d.ts +6 -0
- package/esm/core/view/view-with-toolbar.js +18 -2
- package/esm/jodit.js +7 -0
- package/esm/types/jodit.d.ts +2 -0
- package/package.json +1 -1
- package/types/core/selection/selection.d.ts +31 -0
- package/types/core/view/view-with-toolbar.d.ts +6 -0
- package/types/types/jodit.d.ts +2 -0
package/es2015/jodit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
|
|
3
3
|
* Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
|
|
4
|
-
* Version: v4.
|
|
4
|
+
* Version: v4.13.5
|
|
5
5
|
* Url: https://xdsoft.net/jodit/
|
|
6
6
|
* License(s): MIT
|
|
7
7
|
*/
|
|
@@ -1849,7 +1849,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1849
1849
|
* ```
|
|
1850
1850
|
* @packageDocumentation
|
|
1851
1851
|
* @module constants
|
|
1852
|
-
*/ const APP_VERSION = "4.
|
|
1852
|
+
*/ const APP_VERSION = "4.13.5";
|
|
1853
1853
|
// prettier-ignore
|
|
1854
1854
|
const ES = "es2015";
|
|
1855
1855
|
const IS_ES_MODERN = true;
|
|
@@ -6179,7 +6179,7 @@ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
|
|
|
6179
6179
|
// markup into a live node.
|
|
6180
6180
|
const foreign = box.querySelectorAll('math *, svg *');
|
|
6181
6181
|
for(let i = 0; i < foreign.length; i++){
|
|
6182
|
-
if (foreign[i]
|
|
6182
|
+
if (box.contains(foreign[i]) && isSmuggledForeignHtml(foreign[i])) {
|
|
6183
6183
|
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.safeRemove(foreign[i]);
|
|
6184
6184
|
}
|
|
6185
6185
|
}
|
|
@@ -6287,7 +6287,8 @@ function sanitizeHTMLElement(elm, { safeJavaScriptLink, removeOnError } = {
|
|
|
6287
6287
|
// scheme (e.g. `java\tscript:`) — all of which the browser still resolves to
|
|
6288
6288
|
// `javascript:` on click. See GHSA-j839-gqq4-gf9j.
|
|
6289
6289
|
if (safeJavaScriptLink && href && isDangerousUrl(href, tagName)) {
|
|
6290
|
-
|
|
6290
|
+
const protocol = typeof location !== 'undefined' ? location.protocol : 'http:';
|
|
6291
|
+
(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.attr)(elm, 'href', protocol + '//' + href);
|
|
6291
6292
|
effected = true;
|
|
6292
6293
|
}
|
|
6293
6294
|
if (safeJavaScriptLink) {
|
|
@@ -11370,6 +11371,137 @@ class Selection {
|
|
|
11370
11371
|
}
|
|
11371
11372
|
return '';
|
|
11372
11373
|
}
|
|
11374
|
+
/**
|
|
11375
|
+
* Splits the boundaries of the current selection and wraps every
|
|
11376
|
+
* contiguous run of selected inline content (grouped by block) into a
|
|
11377
|
+
* `<font>` element, returning those wrappers in document order.
|
|
11378
|
+
*
|
|
11379
|
+
* This is a pure-DOM replacement for the old
|
|
11380
|
+
* `nativeExecCommand('fontsize', false, '7')` trick which relied on the
|
|
11381
|
+
* browser to split the selection into `<font size="7">` fragments.
|
|
11382
|
+
*/ __wrapSelectionFragments() {
|
|
11383
|
+
const range = this.range;
|
|
11384
|
+
this.__splitSelectionBoundaries(range);
|
|
11385
|
+
let root = range.commonAncestorContainer;
|
|
11386
|
+
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(root)) {
|
|
11387
|
+
root = root.parentNode;
|
|
11388
|
+
}
|
|
11389
|
+
if (!root) {
|
|
11390
|
+
return [];
|
|
11391
|
+
}
|
|
11392
|
+
return this.__wrapSelectionRuns(this.__collectContainedNodes(root, range));
|
|
11393
|
+
}
|
|
11394
|
+
/**
|
|
11395
|
+
* Splits the text nodes at both ends of the range so that its boundaries
|
|
11396
|
+
* always fall between nodes. Afterwards every node inside the range is
|
|
11397
|
+
* fully (not partially) selected.
|
|
11398
|
+
*/ __splitSelectionBoundaries(range) {
|
|
11399
|
+
var _ref, _ref1;
|
|
11400
|
+
var _endContainer_nodeValue, _startContainer_nodeValue;
|
|
11401
|
+
let { startContainer, endContainer } = range;
|
|
11402
|
+
let { startOffset, endOffset } = range;
|
|
11403
|
+
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(endContainer) && endOffset > 0 && endOffset < ((_ref = (_endContainer_nodeValue = endContainer.nodeValue) === null || _endContainer_nodeValue === void 0 ? void 0 : _endContainer_nodeValue.length) !== null && _ref !== void 0 ? _ref : 0)) {
|
|
11404
|
+
var _ref2;
|
|
11405
|
+
var _endContainer_nodeValue1;
|
|
11406
|
+
endContainer.splitText(endOffset);
|
|
11407
|
+
endOffset = (_ref2 = (_endContainer_nodeValue1 = endContainer.nodeValue) === null || _endContainer_nodeValue1 === void 0 ? void 0 : _endContainer_nodeValue1.length) !== null && _ref2 !== void 0 ? _ref2 : endOffset;
|
|
11408
|
+
}
|
|
11409
|
+
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(startContainer) && startOffset > 0 && startOffset < ((_ref1 = (_startContainer_nodeValue = startContainer.nodeValue) === null || _startContainer_nodeValue === void 0 ? void 0 : _startContainer_nodeValue.length) !== null && _ref1 !== void 0 ? _ref1 : 0)) {
|
|
11410
|
+
const middle = startContainer.splitText(startOffset);
|
|
11411
|
+
// Selection located inside a single text node - the tail we just
|
|
11412
|
+
// cut off is the actual selected fragment.
|
|
11413
|
+
if (startContainer === endContainer) {
|
|
11414
|
+
var _ref3;
|
|
11415
|
+
var _middle_nodeValue;
|
|
11416
|
+
endContainer = middle;
|
|
11417
|
+
endOffset = (_ref3 = (_middle_nodeValue = middle.nodeValue) === null || _middle_nodeValue === void 0 ? void 0 : _middle_nodeValue.length) !== null && _ref3 !== void 0 ? _ref3 : 0;
|
|
11418
|
+
}
|
|
11419
|
+
startContainer = middle;
|
|
11420
|
+
startOffset = 0;
|
|
11421
|
+
}
|
|
11422
|
+
range.setStart(startContainer, startOffset);
|
|
11423
|
+
range.setEnd(endContainer, endOffset);
|
|
11424
|
+
// Normalize text-edge boundaries (e.g. `(text, 0)` or `(text, length)`)
|
|
11425
|
+
// to the element level so that containment checks based on
|
|
11426
|
+
// `selectNode()` treat a fully selected text node as contained.
|
|
11427
|
+
this.__normalizeRangeBoundary(range, true);
|
|
11428
|
+
this.__normalizeRangeBoundary(range, false);
|
|
11429
|
+
}
|
|
11430
|
+
__normalizeRangeBoundary(range, atStart) {
|
|
11431
|
+
var _ref;
|
|
11432
|
+
var _container_nodeValue;
|
|
11433
|
+
const container = atStart ? range.startContainer : range.endContainer;
|
|
11434
|
+
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(container)) {
|
|
11435
|
+
return;
|
|
11436
|
+
}
|
|
11437
|
+
const offset = atStart ? range.startOffset : range.endOffset;
|
|
11438
|
+
const length = (_ref = (_container_nodeValue = container.nodeValue) === null || _container_nodeValue === void 0 ? void 0 : _container_nodeValue.length) !== null && _ref !== void 0 ? _ref : 0;
|
|
11439
|
+
if (offset === 0) {
|
|
11440
|
+
atStart ? range.setStartBefore(container) : range.setEndBefore(container);
|
|
11441
|
+
} else if (offset >= length) {
|
|
11442
|
+
atStart ? range.setStartAfter(container) : range.setEndAfter(container);
|
|
11443
|
+
}
|
|
11444
|
+
}
|
|
11445
|
+
/**
|
|
11446
|
+
* Collects the highest-level nodes that are completely inside the range,
|
|
11447
|
+
* descending into nodes that are only partially selected.
|
|
11448
|
+
*/ __collectContainedNodes(root, range) {
|
|
11449
|
+
const result = [];
|
|
11450
|
+
(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.toArray)(root.childNodes).forEach((child)=>{
|
|
11451
|
+
if (this.__isFullyContained(range, child)) {
|
|
11452
|
+
result.push(child);
|
|
11453
|
+
} else if (child.childNodes.length && range.intersectsNode(child)) {
|
|
11454
|
+
result.push(...this.__collectContainedNodes(child, range));
|
|
11455
|
+
}
|
|
11456
|
+
});
|
|
11457
|
+
return result;
|
|
11458
|
+
}
|
|
11459
|
+
__isFullyContained(range, node) {
|
|
11460
|
+
const nodeRange = this.createRange();
|
|
11461
|
+
nodeRange.selectNode(node);
|
|
11462
|
+
return range.compareBoundaryPoints(Range.START_TO_START, nodeRange) <= 0 && range.compareBoundaryPoints(Range.END_TO_END, nodeRange) >= 0;
|
|
11463
|
+
}
|
|
11464
|
+
/**
|
|
11465
|
+
* Wraps every contiguous run of selected inline siblings into a `<font>`
|
|
11466
|
+
* element. Block-level nodes are never wrapped themselves - their inline
|
|
11467
|
+
* content is wrapped instead, keeping every `<font>` inside a single block.
|
|
11468
|
+
*/ __wrapSelectionRuns(nodes) {
|
|
11469
|
+
const fonts = [];
|
|
11470
|
+
let run = [];
|
|
11471
|
+
const flush = ()=>{
|
|
11472
|
+
if (run.length) {
|
|
11473
|
+
fonts.push(this.__wrapRunInFont(run));
|
|
11474
|
+
run = [];
|
|
11475
|
+
}
|
|
11476
|
+
};
|
|
11477
|
+
nodes.forEach((node)=>{
|
|
11478
|
+
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isElement(node) && this.__isOrContainsBlock(node)) {
|
|
11479
|
+
flush();
|
|
11480
|
+
fonts.push(...this.__wrapSelectionRuns((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.toArray)(node.childNodes)));
|
|
11481
|
+
} else {
|
|
11482
|
+
if (run.length && run[run.length - 1].parentNode !== node.parentNode) {
|
|
11483
|
+
flush();
|
|
11484
|
+
}
|
|
11485
|
+
run.push(node);
|
|
11486
|
+
}
|
|
11487
|
+
});
|
|
11488
|
+
flush();
|
|
11489
|
+
return fonts;
|
|
11490
|
+
}
|
|
11491
|
+
__isOrContainsBlock(node) {
|
|
11492
|
+
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isBlock(node)) {
|
|
11493
|
+
return true;
|
|
11494
|
+
}
|
|
11495
|
+
return (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.toArray)(node.childNodes).some((child)=>this.__isOrContainsBlock(child));
|
|
11496
|
+
}
|
|
11497
|
+
__wrapRunInFont(run) {
|
|
11498
|
+
var _first_parentNode;
|
|
11499
|
+
const font = this.j.createInside.element('font');
|
|
11500
|
+
const [first] = run;
|
|
11501
|
+
(_first_parentNode = first.parentNode) === null || _first_parentNode === void 0 ? void 0 : _first_parentNode.insertBefore(font, first);
|
|
11502
|
+
run.forEach((node)=>font.appendChild(node));
|
|
11503
|
+
return font;
|
|
11504
|
+
}
|
|
11373
11505
|
/**
|
|
11374
11506
|
* Wrap all selected fragments inside Tag or apply some callback
|
|
11375
11507
|
*/ *wrapInTagGen(fakes) {
|
|
@@ -11383,20 +11515,7 @@ class Selection {
|
|
|
11383
11515
|
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.unwrap(font);
|
|
11384
11516
|
return;
|
|
11385
11517
|
}
|
|
11386
|
-
|
|
11387
|
-
(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.$$)('*[style*=font-size]', this.area).forEach((elm)=>{
|
|
11388
|
-
(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(elm, 'data-font-size', elm.style.fontSize.toString());
|
|
11389
|
-
elm.style.removeProperty('font-size');
|
|
11390
|
-
});
|
|
11391
|
-
this.j.nativeExecCommand('fontsize', false, '7');
|
|
11392
|
-
(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.$$)('*[data-font-size]', this.area).forEach((elm)=>{
|
|
11393
|
-
const fontSize = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(elm, 'data-font-size');
|
|
11394
|
-
if (fontSize) {
|
|
11395
|
-
elm.style.fontSize = fontSize;
|
|
11396
|
-
(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(elm, 'data-font-size', null);
|
|
11397
|
-
}
|
|
11398
|
-
});
|
|
11399
|
-
const elms = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.$$)('font[size="7"]', this.area);
|
|
11518
|
+
const elms = this.__wrapSelectionFragments();
|
|
11400
11519
|
for (const font of elms){
|
|
11401
11520
|
const { firstChild, lastChild } = font;
|
|
11402
11521
|
if (firstChild && firstChild === lastChild && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isMarker)(firstChild)) {
|
|
@@ -16650,9 +16769,23 @@ class ViewWithToolbar extends jodit_core_view_view__WEBPACK_IMPORTED_MODULE_11__
|
|
|
16650
16769
|
if (!this.o.fullsize && ((0,jodit_core_helpers_checker_is_string__WEBPACK_IMPORTED_MODULE_7__.isString)(this.o.toolbar) || jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.isHTMLElement(this.o.toolbar))) {
|
|
16651
16770
|
return (0,jodit_core_helpers_utils_selector__WEBPACK_IMPORTED_MODULE_8__.resolveElement)(this.o.toolbar, this.o.shadowRoot || this.od);
|
|
16652
16771
|
}
|
|
16653
|
-
this.o.toolbar &&
|
|
16772
|
+
this.o.toolbar && this.__appendToolbarBox();
|
|
16654
16773
|
return this.__defaultToolbarContainer;
|
|
16655
16774
|
}
|
|
16775
|
+
/**
|
|
16776
|
+
* Keep the toolbar box as the first child of the container, except that
|
|
16777
|
+
* children flagged with `data-jodit-above-toolbar` (e.g. the `above`
|
|
16778
|
+
* workplace slot used for presence bars and banners) stay above it.
|
|
16779
|
+
*/ __appendToolbarBox() {
|
|
16780
|
+
const box = this.__defaultToolbarContainer;
|
|
16781
|
+
let anchor = this.container.firstElementChild;
|
|
16782
|
+
while(anchor && anchor !== box && anchor.hasAttribute('data-jodit-above-toolbar')){
|
|
16783
|
+
anchor = anchor.nextElementSibling;
|
|
16784
|
+
}
|
|
16785
|
+
if (anchor !== box) {
|
|
16786
|
+
this.container.insertBefore(box, anchor);
|
|
16787
|
+
}
|
|
16788
|
+
}
|
|
16656
16789
|
/**
|
|
16657
16790
|
* Change panel container
|
|
16658
16791
|
*/ setPanel(element) {
|
|
@@ -17934,6 +18067,12 @@ class Jodit extends jodit_modules__WEBPACK_IMPORTED_MODULE_10__.ViewWithToolbar
|
|
|
17934
18067
|
element.style.display = 'none';
|
|
17935
18068
|
}
|
|
17936
18069
|
const SLOT = 'workplace-slot';
|
|
18070
|
+
// A slot that always stays ABOVE the toolbar (presence bars, banners…).
|
|
18071
|
+
// The `data-jodit-above-toolbar` attribute tells ViewWithToolbar to keep
|
|
18072
|
+
// the toolbar box below it when (re)attaching the toolbar container.
|
|
18073
|
+
const aboveSlot = this.c.div(this.getFullElName(SLOT, 'above'), NOEDIT);
|
|
18074
|
+
aboveSlot.setAttribute('data-jodit-above-toolbar', '');
|
|
18075
|
+
jodit_modules__WEBPACK_IMPORTED_MODULE_10__.Dom.appendChildFirst(container, aboveSlot);
|
|
17937
18076
|
const topSlot = this.c.div(this.getFullElName(SLOT, 'top'), NOEDIT);
|
|
17938
18077
|
container.appendChild(topSlot);
|
|
17939
18078
|
const centerSlot = this.c.div(this.getFullElName(SLOT, 'center'), NOEDIT);
|
|
@@ -17966,6 +18105,7 @@ class Jodit extends jodit_modules__WEBPACK_IMPORTED_MODULE_10__.ViewWithToolbar
|
|
|
17966
18105
|
container,
|
|
17967
18106
|
workplace,
|
|
17968
18107
|
slots: {
|
|
18108
|
+
above: aboveSlot,
|
|
17969
18109
|
top: topSlot,
|
|
17970
18110
|
bottom: bottomPanel,
|
|
17971
18111
|
center: centerSlot,
|