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/es2021.en/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
|
*/
|
|
@@ -1843,7 +1843,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1843
1843
|
* ```
|
|
1844
1844
|
* @packageDocumentation
|
|
1845
1845
|
* @module constants
|
|
1846
|
-
*/ const APP_VERSION = "4.
|
|
1846
|
+
*/ const APP_VERSION = "4.13.5";
|
|
1847
1847
|
// prettier-ignore
|
|
1848
1848
|
const ES = "es2021";
|
|
1849
1849
|
const IS_ES_MODERN = true;
|
|
@@ -6156,7 +6156,7 @@ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
|
|
|
6156
6156
|
// markup into a live node.
|
|
6157
6157
|
const foreign = box.querySelectorAll('math *, svg *');
|
|
6158
6158
|
for(let i = 0; i < foreign.length; i++){
|
|
6159
|
-
if (foreign[i]
|
|
6159
|
+
if (box.contains(foreign[i]) && isSmuggledForeignHtml(foreign[i])) {
|
|
6160
6160
|
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.safeRemove(foreign[i]);
|
|
6161
6161
|
}
|
|
6162
6162
|
}
|
|
@@ -6264,7 +6264,8 @@ function sanitizeHTMLElement(elm, { safeJavaScriptLink, removeOnError } = {
|
|
|
6264
6264
|
// scheme (e.g. `java\tscript:`) — all of which the browser still resolves to
|
|
6265
6265
|
// `javascript:` on click. See GHSA-j839-gqq4-gf9j.
|
|
6266
6266
|
if (safeJavaScriptLink && href && isDangerousUrl(href, tagName)) {
|
|
6267
|
-
|
|
6267
|
+
const protocol = typeof location !== 'undefined' ? location.protocol : 'http:';
|
|
6268
|
+
(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.attr)(elm, 'href', protocol + '//' + href);
|
|
6268
6269
|
effected = true;
|
|
6269
6270
|
}
|
|
6270
6271
|
if (safeJavaScriptLink) {
|
|
@@ -11306,6 +11307,128 @@ class Selection {
|
|
|
11306
11307
|
}
|
|
11307
11308
|
return '';
|
|
11308
11309
|
}
|
|
11310
|
+
/**
|
|
11311
|
+
* Splits the boundaries of the current selection and wraps every
|
|
11312
|
+
* contiguous run of selected inline content (grouped by block) into a
|
|
11313
|
+
* `<font>` element, returning those wrappers in document order.
|
|
11314
|
+
*
|
|
11315
|
+
* This is a pure-DOM replacement for the old
|
|
11316
|
+
* `nativeExecCommand('fontsize', false, '7')` trick which relied on the
|
|
11317
|
+
* browser to split the selection into `<font size="7">` fragments.
|
|
11318
|
+
*/ __wrapSelectionFragments() {
|
|
11319
|
+
const range = this.range;
|
|
11320
|
+
this.__splitSelectionBoundaries(range);
|
|
11321
|
+
let root = range.commonAncestorContainer;
|
|
11322
|
+
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(root)) {
|
|
11323
|
+
root = root.parentNode;
|
|
11324
|
+
}
|
|
11325
|
+
if (!root) {
|
|
11326
|
+
return [];
|
|
11327
|
+
}
|
|
11328
|
+
return this.__wrapSelectionRuns(this.__collectContainedNodes(root, range));
|
|
11329
|
+
}
|
|
11330
|
+
/**
|
|
11331
|
+
* Splits the text nodes at both ends of the range so that its boundaries
|
|
11332
|
+
* always fall between nodes. Afterwards every node inside the range is
|
|
11333
|
+
* fully (not partially) selected.
|
|
11334
|
+
*/ __splitSelectionBoundaries(range) {
|
|
11335
|
+
let { startContainer, endContainer } = range;
|
|
11336
|
+
let { startOffset, endOffset } = range;
|
|
11337
|
+
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(endContainer) && endOffset > 0 && endOffset < (endContainer.nodeValue?.length ?? 0)) {
|
|
11338
|
+
endContainer.splitText(endOffset);
|
|
11339
|
+
endOffset = endContainer.nodeValue?.length ?? endOffset;
|
|
11340
|
+
}
|
|
11341
|
+
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(startContainer) && startOffset > 0 && startOffset < (startContainer.nodeValue?.length ?? 0)) {
|
|
11342
|
+
const middle = startContainer.splitText(startOffset);
|
|
11343
|
+
// Selection located inside a single text node - the tail we just
|
|
11344
|
+
// cut off is the actual selected fragment.
|
|
11345
|
+
if (startContainer === endContainer) {
|
|
11346
|
+
endContainer = middle;
|
|
11347
|
+
endOffset = middle.nodeValue?.length ?? 0;
|
|
11348
|
+
}
|
|
11349
|
+
startContainer = middle;
|
|
11350
|
+
startOffset = 0;
|
|
11351
|
+
}
|
|
11352
|
+
range.setStart(startContainer, startOffset);
|
|
11353
|
+
range.setEnd(endContainer, endOffset);
|
|
11354
|
+
// Normalize text-edge boundaries (e.g. `(text, 0)` or `(text, length)`)
|
|
11355
|
+
// to the element level so that containment checks based on
|
|
11356
|
+
// `selectNode()` treat a fully selected text node as contained.
|
|
11357
|
+
this.__normalizeRangeBoundary(range, true);
|
|
11358
|
+
this.__normalizeRangeBoundary(range, false);
|
|
11359
|
+
}
|
|
11360
|
+
__normalizeRangeBoundary(range, atStart) {
|
|
11361
|
+
const container = atStart ? range.startContainer : range.endContainer;
|
|
11362
|
+
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(container)) {
|
|
11363
|
+
return;
|
|
11364
|
+
}
|
|
11365
|
+
const offset = atStart ? range.startOffset : range.endOffset;
|
|
11366
|
+
const length = container.nodeValue?.length ?? 0;
|
|
11367
|
+
if (offset === 0) {
|
|
11368
|
+
atStart ? range.setStartBefore(container) : range.setEndBefore(container);
|
|
11369
|
+
} else if (offset >= length) {
|
|
11370
|
+
atStart ? range.setStartAfter(container) : range.setEndAfter(container);
|
|
11371
|
+
}
|
|
11372
|
+
}
|
|
11373
|
+
/**
|
|
11374
|
+
* Collects the highest-level nodes that are completely inside the range,
|
|
11375
|
+
* descending into nodes that are only partially selected.
|
|
11376
|
+
*/ __collectContainedNodes(root, range) {
|
|
11377
|
+
const result = [];
|
|
11378
|
+
(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.toArray)(root.childNodes).forEach((child)=>{
|
|
11379
|
+
if (this.__isFullyContained(range, child)) {
|
|
11380
|
+
result.push(child);
|
|
11381
|
+
} else if (child.childNodes.length && range.intersectsNode(child)) {
|
|
11382
|
+
result.push(...this.__collectContainedNodes(child, range));
|
|
11383
|
+
}
|
|
11384
|
+
});
|
|
11385
|
+
return result;
|
|
11386
|
+
}
|
|
11387
|
+
__isFullyContained(range, node) {
|
|
11388
|
+
const nodeRange = this.createRange();
|
|
11389
|
+
nodeRange.selectNode(node);
|
|
11390
|
+
return range.compareBoundaryPoints(Range.START_TO_START, nodeRange) <= 0 && range.compareBoundaryPoints(Range.END_TO_END, nodeRange) >= 0;
|
|
11391
|
+
}
|
|
11392
|
+
/**
|
|
11393
|
+
* Wraps every contiguous run of selected inline siblings into a `<font>`
|
|
11394
|
+
* element. Block-level nodes are never wrapped themselves - their inline
|
|
11395
|
+
* content is wrapped instead, keeping every `<font>` inside a single block.
|
|
11396
|
+
*/ __wrapSelectionRuns(nodes) {
|
|
11397
|
+
const fonts = [];
|
|
11398
|
+
let run = [];
|
|
11399
|
+
const flush = ()=>{
|
|
11400
|
+
if (run.length) {
|
|
11401
|
+
fonts.push(this.__wrapRunInFont(run));
|
|
11402
|
+
run = [];
|
|
11403
|
+
}
|
|
11404
|
+
};
|
|
11405
|
+
nodes.forEach((node)=>{
|
|
11406
|
+
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isElement(node) && this.__isOrContainsBlock(node)) {
|
|
11407
|
+
flush();
|
|
11408
|
+
fonts.push(...this.__wrapSelectionRuns((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.toArray)(node.childNodes)));
|
|
11409
|
+
} else {
|
|
11410
|
+
if (run.length && run[run.length - 1].parentNode !== node.parentNode) {
|
|
11411
|
+
flush();
|
|
11412
|
+
}
|
|
11413
|
+
run.push(node);
|
|
11414
|
+
}
|
|
11415
|
+
});
|
|
11416
|
+
flush();
|
|
11417
|
+
return fonts;
|
|
11418
|
+
}
|
|
11419
|
+
__isOrContainsBlock(node) {
|
|
11420
|
+
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isBlock(node)) {
|
|
11421
|
+
return true;
|
|
11422
|
+
}
|
|
11423
|
+
return (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.toArray)(node.childNodes).some((child)=>this.__isOrContainsBlock(child));
|
|
11424
|
+
}
|
|
11425
|
+
__wrapRunInFont(run) {
|
|
11426
|
+
const font = this.j.createInside.element('font');
|
|
11427
|
+
const [first] = run;
|
|
11428
|
+
first.parentNode?.insertBefore(font, first);
|
|
11429
|
+
run.forEach((node)=>font.appendChild(node));
|
|
11430
|
+
return font;
|
|
11431
|
+
}
|
|
11309
11432
|
/**
|
|
11310
11433
|
* Wrap all selected fragments inside Tag or apply some callback
|
|
11311
11434
|
*/ *wrapInTagGen(fakes) {
|
|
@@ -11319,20 +11442,7 @@ class Selection {
|
|
|
11319
11442
|
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.unwrap(font);
|
|
11320
11443
|
return;
|
|
11321
11444
|
}
|
|
11322
|
-
|
|
11323
|
-
(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.$$)('*[style*=font-size]', this.area).forEach((elm)=>{
|
|
11324
|
-
(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(elm, 'data-font-size', elm.style.fontSize.toString());
|
|
11325
|
-
elm.style.removeProperty('font-size');
|
|
11326
|
-
});
|
|
11327
|
-
this.j.nativeExecCommand('fontsize', false, '7');
|
|
11328
|
-
(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.$$)('*[data-font-size]', this.area).forEach((elm)=>{
|
|
11329
|
-
const fontSize = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(elm, 'data-font-size');
|
|
11330
|
-
if (fontSize) {
|
|
11331
|
-
elm.style.fontSize = fontSize;
|
|
11332
|
-
(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(elm, 'data-font-size', null);
|
|
11333
|
-
}
|
|
11334
|
-
});
|
|
11335
|
-
const elms = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.$$)('font[size="7"]', this.area);
|
|
11445
|
+
const elms = this.__wrapSelectionFragments();
|
|
11336
11446
|
for (const font of elms){
|
|
11337
11447
|
const { firstChild, lastChild } = font;
|
|
11338
11448
|
if (firstChild && firstChild === lastChild && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isMarker)(firstChild)) {
|
|
@@ -16528,9 +16638,23 @@ class ViewWithToolbar extends jodit_core_view_view__WEBPACK_IMPORTED_MODULE_11__
|
|
|
16528
16638
|
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))) {
|
|
16529
16639
|
return (0,jodit_core_helpers_utils_selector__WEBPACK_IMPORTED_MODULE_8__.resolveElement)(this.o.toolbar, this.o.shadowRoot || this.od);
|
|
16530
16640
|
}
|
|
16531
|
-
this.o.toolbar &&
|
|
16641
|
+
this.o.toolbar && this.__appendToolbarBox();
|
|
16532
16642
|
return this.__defaultToolbarContainer;
|
|
16533
16643
|
}
|
|
16644
|
+
/**
|
|
16645
|
+
* Keep the toolbar box as the first child of the container, except that
|
|
16646
|
+
* children flagged with `data-jodit-above-toolbar` (e.g. the `above`
|
|
16647
|
+
* workplace slot used for presence bars and banners) stay above it.
|
|
16648
|
+
*/ __appendToolbarBox() {
|
|
16649
|
+
const box = this.__defaultToolbarContainer;
|
|
16650
|
+
let anchor = this.container.firstElementChild;
|
|
16651
|
+
while(anchor && anchor !== box && anchor.hasAttribute('data-jodit-above-toolbar')){
|
|
16652
|
+
anchor = anchor.nextElementSibling;
|
|
16653
|
+
}
|
|
16654
|
+
if (anchor !== box) {
|
|
16655
|
+
this.container.insertBefore(box, anchor);
|
|
16656
|
+
}
|
|
16657
|
+
}
|
|
16534
16658
|
/**
|
|
16535
16659
|
* Change panel container
|
|
16536
16660
|
*/ setPanel(element) {
|
|
@@ -17804,6 +17928,12 @@ class Jodit extends jodit_modules__WEBPACK_IMPORTED_MODULE_9__.ViewWithToolbar {
|
|
|
17804
17928
|
element.style.display = 'none';
|
|
17805
17929
|
}
|
|
17806
17930
|
const SLOT = 'workplace-slot';
|
|
17931
|
+
// A slot that always stays ABOVE the toolbar (presence bars, banners…).
|
|
17932
|
+
// The `data-jodit-above-toolbar` attribute tells ViewWithToolbar to keep
|
|
17933
|
+
// the toolbar box below it when (re)attaching the toolbar container.
|
|
17934
|
+
const aboveSlot = this.c.div(this.getFullElName(SLOT, 'above'), NOEDIT);
|
|
17935
|
+
aboveSlot.setAttribute('data-jodit-above-toolbar', '');
|
|
17936
|
+
jodit_modules__WEBPACK_IMPORTED_MODULE_9__.Dom.appendChildFirst(container, aboveSlot);
|
|
17807
17937
|
const topSlot = this.c.div(this.getFullElName(SLOT, 'top'), NOEDIT);
|
|
17808
17938
|
container.appendChild(topSlot);
|
|
17809
17939
|
const centerSlot = this.c.div(this.getFullElName(SLOT, 'center'), NOEDIT);
|
|
@@ -17836,6 +17966,7 @@ class Jodit extends jodit_modules__WEBPACK_IMPORTED_MODULE_9__.ViewWithToolbar {
|
|
|
17836
17966
|
container,
|
|
17837
17967
|
workplace,
|
|
17838
17968
|
slots: {
|
|
17969
|
+
above: aboveSlot,
|
|
17839
17970
|
top: topSlot,
|
|
17840
17971
|
bottom: bottomPanel,
|
|
17841
17972
|
center: centerSlot,
|