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