jodit 4.14.2 → 4.14.4
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 +28 -0
- package/es2015/jodit.css +1 -1
- package/es2015/jodit.fat.min.js +13 -13
- package/es2015/jodit.js +692 -540
- package/es2015/jodit.min.js +13 -13
- package/es2015/plugins/debug/debug.css +1 -1
- package/es2015/plugins/debug/debug.js +2 -2
- package/es2015/plugins/debug/debug.min.js +2 -2
- package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.js +50 -50
- package/es2015/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es2018/jodit.fat.min.js +13 -13
- package/es2018/jodit.min.js +13 -13
- package/es2018/plugins/debug/debug.min.js +2 -2
- package/es2018/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es2021/jodit.css +1 -1
- package/es2021/jodit.fat.min.js +16 -16
- package/es2021/jodit.js +679 -531
- package/es2021/jodit.min.js +15 -15
- package/es2021/plugins/debug/debug.css +1 -1
- package/es2021/plugins/debug/debug.js +2 -2
- package/es2021/plugins/debug/debug.min.js +2 -2
- package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.js +50 -50
- package/es2021/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es2021.en/jodit.css +1 -1
- package/es2021.en/jodit.fat.min.js +14 -14
- package/es2021.en/jodit.js +457 -296
- package/es2021.en/jodit.min.js +14 -14
- package/es2021.en/plugins/debug/debug.css +1 -1
- package/es2021.en/plugins/debug/debug.js +2 -2
- package/es2021.en/plugins/debug/debug.min.js +2 -2
- package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.js +2 -2
- package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es5/jodit.css +2 -2
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +915 -609
- 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 +2 -2
- package/es5/plugins/debug/debug.min.js +2 -2
- package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.js +50 -50
- package/es5/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es5/polyfills.fat.min.js +2 -2
- package/es5/polyfills.js +32 -57
- package/es5/polyfills.min.js +2 -2
- package/esm/core/constants.js +1 -1
- package/esm/core/selection/helpers/index.js +5 -2
- package/esm/core/selection/selection.d.ts +8 -5
- package/esm/core/selection/selection.js +267 -159
- package/esm/core/selection/style/api/extract.js +1 -3
- package/esm/core/selection/style/api/is-same-attributes.js +5 -2
- package/esm/core/selection/style/api/toggle-attributes.js +27 -10
- package/esm/core/selection/style/api/unwrap-children.js +39 -33
- package/esm/core/selection/style/apply-style.js +23 -25
- package/esm/core/selection/style/commit-style.js +3 -0
- package/esm/core/selection/style/transactions.js +2 -1
- package/esm/langs/az.d.ts +223 -0
- package/esm/langs/az.js +240 -0
- package/esm/languages.js +2 -0
- package/esm/modules/history/snapshot.js +45 -20
- package/esm/types/style.d.ts +2 -2
- package/esm/types/types.d.ts +3 -0
- package/package.json +1 -1
- package/types/core/selection/selection.d.ts +8 -5
- package/types/langs/az.d.ts +223 -0
- package/types/types/style.d.ts +2 -2
- package/types/types/types.d.ts +3 -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.14.
|
|
4
|
+
* Version: v4.14.4
|
|
5
5
|
* Url: https://xdsoft.net/jodit/
|
|
6
6
|
* License(s): MIT
|
|
7
7
|
*/
|
|
@@ -1779,7 +1779,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1779
1779
|
* ```
|
|
1780
1780
|
* @packageDocumentation
|
|
1781
1781
|
* @module constants
|
|
1782
|
-
*/ const APP_VERSION = "4.14.
|
|
1782
|
+
*/ const APP_VERSION = "4.14.4";
|
|
1783
1783
|
// prettier-ignore
|
|
1784
1784
|
const ES = "es2021";
|
|
1785
1785
|
const IS_ES_MODERN = true;
|
|
@@ -10516,13 +10516,16 @@ function findCorrectCurrentNode(node, range, rightMode, isCollapsed, checkChild,
|
|
|
10516
10516
|
if (!rightMode && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.isText(node.previousSibling)) {
|
|
10517
10517
|
node = node.previousSibling;
|
|
10518
10518
|
} else if (checkChild) {
|
|
10519
|
-
|
|
10519
|
+
// The fallback to the previous child changes the traversal direction
|
|
10520
|
+
// before the caller receives the updated rightMode.
|
|
10521
|
+
const nextChild = (nd)=>rightMode ? nd.lastChild : child(nd);
|
|
10522
|
+
let current = nextChild(node);
|
|
10520
10523
|
while(current){
|
|
10521
10524
|
if (current && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.isText(current)) {
|
|
10522
10525
|
node = current;
|
|
10523
10526
|
break;
|
|
10524
10527
|
}
|
|
10525
|
-
current =
|
|
10528
|
+
current = nextChild(current);
|
|
10526
10529
|
}
|
|
10527
10530
|
}
|
|
10528
10531
|
}
|
|
@@ -10730,8 +10733,15 @@ class Selection {
|
|
|
10730
10733
|
* Checks if the selected text is currently inside the editor
|
|
10731
10734
|
*/ get isInsideArea() {
|
|
10732
10735
|
const { sel } = this;
|
|
10733
|
-
|
|
10734
|
-
|
|
10736
|
+
if (!sel?.rangeCount) {
|
|
10737
|
+
return false;
|
|
10738
|
+
}
|
|
10739
|
+
for(let i = 0; i < sel.rangeCount; i += 1){
|
|
10740
|
+
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, sel.getRangeAt(i).commonAncestorContainer)) {
|
|
10741
|
+
return false;
|
|
10742
|
+
}
|
|
10743
|
+
}
|
|
10744
|
+
return true;
|
|
10735
10745
|
}
|
|
10736
10746
|
/**
|
|
10737
10747
|
* Return current selection object
|
|
@@ -10749,8 +10759,11 @@ class Selection {
|
|
|
10749
10759
|
const sel = this.sel, current = this.current();
|
|
10750
10760
|
if (sel && current) {
|
|
10751
10761
|
for(let i = 0; i < sel.rangeCount; i += 1){
|
|
10752
|
-
sel.getRangeAt(i)
|
|
10753
|
-
|
|
10762
|
+
const range = sel.getRangeAt(i);
|
|
10763
|
+
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, range.commonAncestorContainer)) {
|
|
10764
|
+
range.deleteContents();
|
|
10765
|
+
range.collapse(true);
|
|
10766
|
+
}
|
|
10754
10767
|
}
|
|
10755
10768
|
}
|
|
10756
10769
|
}
|
|
@@ -10777,25 +10790,23 @@ class Selection {
|
|
|
10777
10790
|
* @param y - Coordinate by vertical
|
|
10778
10791
|
* @returns false - Something went wrong
|
|
10779
10792
|
*/ insertCursorAtPoint(x, y) {
|
|
10780
|
-
this.removeMarkers();
|
|
10781
10793
|
try {
|
|
10782
|
-
const
|
|
10783
|
-
(
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
this.selectRange(rng);
|
|
10794
|
+
const range = this.createRange();
|
|
10795
|
+
const position = this.doc.caretPositionFromPoint?.(x, y);
|
|
10796
|
+
const caret = position ? null : this.doc.caretRangeFromPoint?.(x, y);
|
|
10797
|
+
if (position) {
|
|
10798
|
+
range.setStart(position.offsetNode, position.offset);
|
|
10799
|
+
} else if (caret) {
|
|
10800
|
+
range.setStart(caret.startContainer, caret.startOffset);
|
|
10801
|
+
} else {
|
|
10802
|
+
return false;
|
|
10803
|
+
}
|
|
10804
|
+
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, range.startContainer)) {
|
|
10805
|
+
return false;
|
|
10806
|
+
}
|
|
10807
|
+
range.collapse(true);
|
|
10808
|
+
this.removeMarkers();
|
|
10809
|
+
this.selectRange(range);
|
|
10799
10810
|
return true;
|
|
10800
10811
|
} catch {}
|
|
10801
10812
|
return false;
|
|
@@ -10845,83 +10856,127 @@ class Selection {
|
|
|
10845
10856
|
/**
|
|
10846
10857
|
* Restores user selections using marker invisible elements in the DOM.
|
|
10847
10858
|
*/ restore() {
|
|
10848
|
-
|
|
10849
|
-
const
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10859
|
+
const markers = this.markers;
|
|
10860
|
+
const byId = new Map(markers.map((marker)=>[
|
|
10861
|
+
marker.id,
|
|
10862
|
+
marker
|
|
10863
|
+
]));
|
|
10864
|
+
const ranges = [];
|
|
10865
|
+
let backward = false;
|
|
10866
|
+
for(let i = 0; i < markers.length; i += 1){
|
|
10867
|
+
const start = markers[i];
|
|
10868
|
+
if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(start, 'data-' + jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.MARKER_CLASS) !== 'start') {
|
|
10869
|
+
continue;
|
|
10870
|
+
}
|
|
10871
|
+
backward ||= (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(start, 'data-selection-backward') === 'true';
|
|
10872
|
+
const endId = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(start, 'data-selection-end');
|
|
10873
|
+
let end = endId ? byId.get(endId) : undefined;
|
|
10874
|
+
if (!endId && markers[i + 1] && (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(markers[i + 1], 'data-' + jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.MARKER_CLASS) === 'end') {
|
|
10875
|
+
end = markers[i + 1];
|
|
10876
|
+
}
|
|
10877
|
+
const range = this.createRange();
|
|
10878
|
+
if (end) {
|
|
10879
|
+
range.setStartAfter(start);
|
|
10880
|
+
range.setEndBefore(end);
|
|
10860
10881
|
} else {
|
|
10861
|
-
|
|
10882
|
+
const previous = start.previousSibling;
|
|
10883
|
+
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(previous)) {
|
|
10884
|
+
range.setStart(previous, previous.nodeValue?.length ?? 0);
|
|
10885
|
+
} else {
|
|
10886
|
+
range.setStartBefore(start);
|
|
10887
|
+
}
|
|
10888
|
+
range.collapse(true);
|
|
10862
10889
|
}
|
|
10863
|
-
|
|
10864
|
-
range.collapse(true);
|
|
10865
|
-
} else {
|
|
10866
|
-
range.setStartAfter(start);
|
|
10867
|
-
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeRemove(start);
|
|
10868
|
-
range.setEndBefore(end);
|
|
10869
|
-
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeRemove(end);
|
|
10890
|
+
ranges.push(range);
|
|
10870
10891
|
}
|
|
10871
|
-
|
|
10872
|
-
|
|
10892
|
+
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeRemove(...markers);
|
|
10893
|
+
if (ranges.length) {
|
|
10894
|
+
this.__selectRanges(ranges, backward);
|
|
10873
10895
|
}
|
|
10874
10896
|
}
|
|
10897
|
+
__isBackward() {
|
|
10898
|
+
const sel = this.sel;
|
|
10899
|
+
return Boolean(sel && sel.rangeCount === 1 && !sel.isCollapsed && sel.anchorNode === sel.getRangeAt(0).endContainer && sel.anchorOffset === sel.getRangeAt(0).endOffset);
|
|
10900
|
+
}
|
|
10901
|
+
__ranges() {
|
|
10902
|
+
const sel = this.sel;
|
|
10903
|
+
return sel ? Array.from({
|
|
10904
|
+
length: sel.rangeCount
|
|
10905
|
+
}, (_, i)=>sel.getRangeAt(i).cloneRange()) : [];
|
|
10906
|
+
}
|
|
10875
10907
|
/**
|
|
10876
10908
|
* Inserts invisible fake nodes on the boundaries of the current selection
|
|
10877
|
-
* and returns
|
|
10909
|
+
* and returns the first pair as a restoration handle for all ranges. Unlike [[Select.save]] the selection stays valid while
|
|
10878
10910
|
* the DOM around it is being modified. Restore it later with [[Select.restoreFakes]].
|
|
10879
10911
|
*/ fakes() {
|
|
10880
|
-
|
|
10881
|
-
if (!sel || !sel.rangeCount) {
|
|
10912
|
+
if (!this.isInsideArea) {
|
|
10882
10913
|
return [];
|
|
10883
10914
|
}
|
|
10884
|
-
const
|
|
10885
|
-
|
|
10886
|
-
const
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
fakeLeft
|
|
10893
|
-
|
|
10894
|
-
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10915
|
+
const backward = this.__isBackward();
|
|
10916
|
+
const ranges = this.__ranges();
|
|
10917
|
+
const pairs = ranges.map((range)=>{
|
|
10918
|
+
const collapsed = range.collapsed;
|
|
10919
|
+
const left = range.cloneRange();
|
|
10920
|
+
left.collapse(true);
|
|
10921
|
+
const fakeLeft = this.j.createInside.fake();
|
|
10922
|
+
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeInsertNode(left, fakeLeft);
|
|
10923
|
+
range.setStartBefore(fakeLeft);
|
|
10924
|
+
const pair = [
|
|
10925
|
+
fakeLeft
|
|
10926
|
+
];
|
|
10927
|
+
if (!collapsed) {
|
|
10928
|
+
const right = range.cloneRange();
|
|
10929
|
+
right.collapse(false);
|
|
10930
|
+
const fakeRight = this.j.createInside.fake();
|
|
10931
|
+
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeInsertNode(right, fakeRight);
|
|
10932
|
+
range.setEndAfter(fakeRight);
|
|
10933
|
+
pair.push(fakeRight);
|
|
10934
|
+
} else {
|
|
10935
|
+
range.collapse(true);
|
|
10936
|
+
}
|
|
10937
|
+
return pair;
|
|
10938
|
+
});
|
|
10939
|
+
this.__fakeSelections.set(pairs[0][0], {
|
|
10940
|
+
pairs,
|
|
10941
|
+
backward
|
|
10942
|
+
});
|
|
10943
|
+
this.__selectRanges(ranges, backward);
|
|
10944
|
+
return pairs[0];
|
|
10904
10945
|
}
|
|
10905
|
-
/**
|
|
10906
|
-
|
|
10907
|
-
* and removes the fake nodes (disconnected fakes are ignored).
|
|
10908
|
-
*/ restoreFakes(fakes) {
|
|
10909
|
-
const nodes = fakes.filter((n)=>n.isConnected);
|
|
10910
|
-
if (!nodes.length) {
|
|
10946
|
+
/** Restore all ranges associated with the returned fake pair. */ restoreFakes(fakes) {
|
|
10947
|
+
if (!fakes.length) {
|
|
10911
10948
|
return;
|
|
10912
10949
|
}
|
|
10913
|
-
const
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
range.setEndBefore(fakeRight);
|
|
10950
|
+
const saved = this.__fakeSelections.get(fakes[0]);
|
|
10951
|
+
this.__fakeSelections.delete(fakes[0]);
|
|
10952
|
+
if (this.j.isInDestruct) {
|
|
10953
|
+
return;
|
|
10918
10954
|
}
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
10955
|
+
const ranges = [];
|
|
10956
|
+
for (const pair of saved?.pairs ?? [
|
|
10957
|
+
fakes
|
|
10958
|
+
]){
|
|
10959
|
+
const nodes = pair.filter((n)=>n.isConnected && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, n, true));
|
|
10960
|
+
if (!nodes.length) {
|
|
10961
|
+
continue;
|
|
10962
|
+
}
|
|
10963
|
+
const [left, right] = nodes;
|
|
10964
|
+
const range = this.createRange();
|
|
10965
|
+
range.setStartAfter(left);
|
|
10966
|
+
if (right) {
|
|
10967
|
+
range.setEndBefore(right);
|
|
10968
|
+
} else {
|
|
10969
|
+
range.collapse(true);
|
|
10970
|
+
}
|
|
10971
|
+
for (const node of nodes){
|
|
10972
|
+
if (node.parentNode?.firstChild !== node.parentNode?.lastChild) {
|
|
10973
|
+
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeRemove(node);
|
|
10974
|
+
}
|
|
10975
|
+
}
|
|
10976
|
+
ranges.push(range);
|
|
10922
10977
|
}
|
|
10923
|
-
if (
|
|
10924
|
-
|
|
10978
|
+
if (ranges.length) {
|
|
10979
|
+
this.__selectRanges(ranges, saved?.backward);
|
|
10925
10980
|
}
|
|
10926
10981
|
}
|
|
10927
10982
|
/**
|
|
@@ -10935,9 +10990,15 @@ class Selection {
|
|
|
10935
10990
|
if (!sel || !sel.rangeCount) {
|
|
10936
10991
|
return [];
|
|
10937
10992
|
}
|
|
10993
|
+
const backward = this.__isBackward();
|
|
10938
10994
|
const info = [], length = sel.rangeCount, ranges = [];
|
|
10939
10995
|
for(let i = 0; i < length; i += 1){
|
|
10940
10996
|
ranges[i] = sel.getRangeAt(i);
|
|
10997
|
+
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, ranges[i].commonAncestorContainer)) {
|
|
10998
|
+
return [];
|
|
10999
|
+
}
|
|
11000
|
+
}
|
|
11001
|
+
for(let i = 0; i < length; i += 1){
|
|
10941
11002
|
if (ranges[i].collapsed) {
|
|
10942
11003
|
const start = this.marker(true, ranges[i]);
|
|
10943
11004
|
info[i] = {
|
|
@@ -10948,6 +11009,12 @@ class Selection {
|
|
|
10948
11009
|
} else {
|
|
10949
11010
|
const start = this.marker(true, ranges[i]);
|
|
10950
11011
|
const end = this.marker(false, ranges[i]);
|
|
11012
|
+
if (length > 1) {
|
|
11013
|
+
(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(start, 'data-selection-end', end.id);
|
|
11014
|
+
}
|
|
11015
|
+
if (backward) {
|
|
11016
|
+
(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(start, 'data-selection-backward', 'true');
|
|
11017
|
+
}
|
|
10951
11018
|
info[i] = {
|
|
10952
11019
|
startId: start.id,
|
|
10953
11020
|
endId: end.id,
|
|
@@ -10960,7 +11027,7 @@ class Selection {
|
|
|
10960
11027
|
if (!silent) {
|
|
10961
11028
|
sel.removeAllRanges();
|
|
10962
11029
|
for(let i = length - 1; i >= 0; --i){
|
|
10963
|
-
const startElm = this.
|
|
11030
|
+
const startElm = this.area.querySelector('#' + info[i].startId);
|
|
10964
11031
|
if (!startElm) {
|
|
10965
11032
|
continue;
|
|
10966
11033
|
}
|
|
@@ -10970,7 +11037,7 @@ class Selection {
|
|
|
10970
11037
|
} else {
|
|
10971
11038
|
ranges[i].setStartBefore(startElm);
|
|
10972
11039
|
if (info[i].endId) {
|
|
10973
|
-
const endElm = this.
|
|
11040
|
+
const endElm = this.area.querySelector('#' + info[i].endId);
|
|
10974
11041
|
if (endElm) {
|
|
10975
11042
|
ranges[i].setEndAfter(endElm);
|
|
10976
11043
|
}
|
|
@@ -11044,6 +11111,9 @@ class Selection {
|
|
|
11044
11111
|
const range = sel.getRangeAt(0);
|
|
11045
11112
|
let node = range.startContainer;
|
|
11046
11113
|
let rightMode = false;
|
|
11114
|
+
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, node)) {
|
|
11115
|
+
return null;
|
|
11116
|
+
}
|
|
11047
11117
|
const child = (nd)=>rightMode ? nd.lastChild : nd.firstChild;
|
|
11048
11118
|
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isTag(node, 'br') && sel.isCollapsed) {
|
|
11049
11119
|
return node;
|
|
@@ -11067,8 +11137,11 @@ class Selection {
|
|
|
11067
11137
|
* @param fireChange - After insert, editor fire change event. You can prevent this behavior
|
|
11068
11138
|
*/ insertNode(node, insertCursorAfter = true, fireChange = true) {
|
|
11069
11139
|
this.errorNode(node);
|
|
11070
|
-
const child = jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isFragment(node) ? node.lastChild : node;
|
|
11071
11140
|
this.j.e.fire('safeHTML', node);
|
|
11141
|
+
let child = jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isFragment(node) ? node.lastChild : node;
|
|
11142
|
+
if (!child || this.j.isInDestruct) {
|
|
11143
|
+
return;
|
|
11144
|
+
}
|
|
11072
11145
|
if (!this.isFocused() && this.j.isEditorMode()) {
|
|
11073
11146
|
this.focus();
|
|
11074
11147
|
this.restore();
|
|
@@ -11079,6 +11152,10 @@ class Selection {
|
|
|
11079
11152
|
this.j.execCommand('Delete');
|
|
11080
11153
|
}
|
|
11081
11154
|
this.j.e.fire('beforeInsertNode', node);
|
|
11155
|
+
child = jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isFragment(node) ? node.lastChild : node;
|
|
11156
|
+
if (!child || this.j.isInDestruct) {
|
|
11157
|
+
return;
|
|
11158
|
+
}
|
|
11082
11159
|
if (sel && sel.rangeCount) {
|
|
11083
11160
|
const range = sel.getRangeAt(0);
|
|
11084
11161
|
const { firstChild } = node;
|
|
@@ -11211,13 +11288,21 @@ class Selection {
|
|
|
11211
11288
|
}
|
|
11212
11289
|
/**
|
|
11213
11290
|
* Call callback for all selection node
|
|
11214
|
-
*/
|
|
11215
|
-
|
|
11216
|
-
const
|
|
11217
|
-
|
|
11218
|
-
|
|
11291
|
+
*/ eachSelection(callback) {
|
|
11292
|
+
const seen = new Set();
|
|
11293
|
+
for (const range of this.__ranges()){
|
|
11294
|
+
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, range.commonAncestorContainer)) {
|
|
11295
|
+
continue;
|
|
11296
|
+
}
|
|
11297
|
+
this.__eachRange(range, (node)=>{
|
|
11298
|
+
if (!seen.has(node)) {
|
|
11299
|
+
seen.add(node);
|
|
11300
|
+
callback(node);
|
|
11301
|
+
}
|
|
11302
|
+
});
|
|
11219
11303
|
}
|
|
11220
|
-
|
|
11304
|
+
}
|
|
11305
|
+
__eachRange(range, callback) {
|
|
11221
11306
|
let root = range.commonAncestorContainer;
|
|
11222
11307
|
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isHTMLElement(root)) {
|
|
11223
11308
|
root = root.parentElement;
|
|
@@ -11286,12 +11371,15 @@ class Selection {
|
|
|
11286
11371
|
* @returns true - the cursor is at the end(start) block, null - cursor somewhere outside
|
|
11287
11372
|
*/ cursorInTheEdge(start, parentBlock, fake = null) {
|
|
11288
11373
|
const end = !start, sel = this.sel, range = sel?.rangeCount ? sel.getRangeAt(0) : null;
|
|
11289
|
-
|
|
11290
|
-
if (!range || !fake || !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(parentBlock, fake, true)) {
|
|
11374
|
+
if (!range) {
|
|
11291
11375
|
return null;
|
|
11292
11376
|
}
|
|
11293
11377
|
const container = start ? range.startContainer : range.endContainer;
|
|
11294
11378
|
const offset = start ? range.startOffset : range.endOffset;
|
|
11379
|
+
fake ??= container;
|
|
11380
|
+
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(parentBlock, container) || !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(parentBlock, fake)) {
|
|
11381
|
+
return null;
|
|
11382
|
+
}
|
|
11295
11383
|
const isSignificant = (elm)=>Boolean(elm && !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isTag(elm, 'br') && !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isEmptyTextNode(elm) && !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isTemporary(elm) && !(jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isElement(elm) && this.j.e.fire('isInvisibleForCursor', elm) === true));
|
|
11296
11384
|
// check right offset
|
|
11297
11385
|
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(container)) {
|
|
@@ -11299,13 +11387,10 @@ class Selection {
|
|
|
11299
11387
|
return false;
|
|
11300
11388
|
}
|
|
11301
11389
|
} else {
|
|
11302
|
-
const children =
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
}
|
|
11307
|
-
} else {
|
|
11308
|
-
if (children.slice(0, offset).some(isSignificant)) {
|
|
11390
|
+
const children = container.childNodes;
|
|
11391
|
+
const limit = end ? children.length : offset;
|
|
11392
|
+
for(let i = end ? offset : 0; i < limit; i += 1){
|
|
11393
|
+
if (isSignificant(children[i])) {
|
|
11309
11394
|
return false;
|
|
11310
11395
|
}
|
|
11311
11396
|
}
|
|
@@ -11318,7 +11403,7 @@ class Selection {
|
|
|
11318
11403
|
continue;
|
|
11319
11404
|
}
|
|
11320
11405
|
next = nextOne;
|
|
11321
|
-
if (
|
|
11406
|
+
if (isSignificant(next)) {
|
|
11322
11407
|
return false;
|
|
11323
11408
|
}
|
|
11324
11409
|
}
|
|
@@ -11350,7 +11435,7 @@ class Selection {
|
|
|
11350
11435
|
* Add fake node for new cursor position
|
|
11351
11436
|
*/ setCursorNearWith(node, inStart) {
|
|
11352
11437
|
this.errorNode(node);
|
|
11353
|
-
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.
|
|
11438
|
+
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, node, true)) {
|
|
11354
11439
|
throw (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.error)('Node element must be in editor');
|
|
11355
11440
|
}
|
|
11356
11441
|
const range = this.createRange();
|
|
@@ -11413,13 +11498,22 @@ class Selection {
|
|
|
11413
11498
|
/**
|
|
11414
11499
|
* Set range selection
|
|
11415
11500
|
*/ selectRange(range, focus = true) {
|
|
11501
|
+
return this.__selectRanges([
|
|
11502
|
+
range
|
|
11503
|
+
], false, focus);
|
|
11504
|
+
}
|
|
11505
|
+
__selectRanges(ranges, backward = false, focus = true) {
|
|
11416
11506
|
const sel = this.sel;
|
|
11417
11507
|
if (focus && !this.isFocused() && this.j.e.current !== 'focus') {
|
|
11418
11508
|
this.focus();
|
|
11419
11509
|
}
|
|
11420
11510
|
if (sel) {
|
|
11421
11511
|
sel.removeAllRanges();
|
|
11422
|
-
sel.addRange(range);
|
|
11512
|
+
ranges.forEach((range)=>sel.addRange(range));
|
|
11513
|
+
if (backward && ranges.length === 1) {
|
|
11514
|
+
const range = ranges[0];
|
|
11515
|
+
sel.setBaseAndExtent(range.endContainer, range.endOffset, range.startContainer, range.startOffset);
|
|
11516
|
+
}
|
|
11423
11517
|
}
|
|
11424
11518
|
/**
|
|
11425
11519
|
* Fired after change selection
|
|
@@ -11436,7 +11530,7 @@ class Selection {
|
|
|
11436
11530
|
throw (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.error)('Node element must be in editor');
|
|
11437
11531
|
}
|
|
11438
11532
|
const range = this.createRange();
|
|
11439
|
-
range[inward ? 'selectNodeContents' : 'selectNode'](node);
|
|
11533
|
+
range[inward || node === this.area ? 'selectNodeContents' : 'selectNode'](node);
|
|
11440
11534
|
return this.selectRange(range);
|
|
11441
11535
|
}
|
|
11442
11536
|
/**
|
|
@@ -11450,10 +11544,8 @@ class Selection {
|
|
|
11450
11544
|
*/ get html() {
|
|
11451
11545
|
const sel = this.sel;
|
|
11452
11546
|
if (sel && sel.rangeCount > 0) {
|
|
11453
|
-
const range = sel.getRangeAt(0);
|
|
11454
|
-
const clonedSelection = range.cloneContents();
|
|
11455
11547
|
const div = this.j.createInside.div();
|
|
11456
|
-
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.append(div,
|
|
11548
|
+
this.__ranges().forEach((range)=>jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.append(div, range.cloneContents()));
|
|
11457
11549
|
return div.innerHTML;
|
|
11458
11550
|
}
|
|
11459
11551
|
return '';
|
|
@@ -11466,8 +11558,7 @@ class Selection {
|
|
|
11466
11558
|
* This is a pure-DOM replacement for the old
|
|
11467
11559
|
* `nativeExecCommand('fontsize', false, '7')` trick which relied on the
|
|
11468
11560
|
* browser to split the selection into `<font size="7">` fragments.
|
|
11469
|
-
*/ __wrapSelectionFragments() {
|
|
11470
|
-
const range = this.range;
|
|
11561
|
+
*/ __wrapSelectionFragments(range) {
|
|
11471
11562
|
this.__splitSelectionBoundaries(range);
|
|
11472
11563
|
let root = range.commonAncestorContainer;
|
|
11473
11564
|
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(root)) {
|
|
@@ -11483,25 +11574,17 @@ class Selection {
|
|
|
11483
11574
|
* always fall between nodes. Afterwards every node inside the range is
|
|
11484
11575
|
* fully (not partially) selected.
|
|
11485
11576
|
*/ __splitSelectionBoundaries(range) {
|
|
11486
|
-
|
|
11487
|
-
let { startOffset, endOffset } = range;
|
|
11577
|
+
const { endContainer, endOffset } = range;
|
|
11488
11578
|
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(endContainer) && endOffset > 0 && endOffset < (endContainer.nodeValue?.length ?? 0)) {
|
|
11489
11579
|
endContainer.splitText(endOffset);
|
|
11490
|
-
endOffset = endContainer.nodeValue?.length ?? endOffset;
|
|
11491
11580
|
}
|
|
11581
|
+
const { startContainer, startOffset } = range;
|
|
11492
11582
|
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(startContainer) && startOffset > 0 && startOffset < (startContainer.nodeValue?.length ?? 0)) {
|
|
11493
11583
|
const middle = startContainer.splitText(startOffset);
|
|
11494
|
-
//
|
|
11495
|
-
//
|
|
11496
|
-
|
|
11497
|
-
endContainer = middle;
|
|
11498
|
-
endOffset = middle.nodeValue?.length ?? 0;
|
|
11499
|
-
}
|
|
11500
|
-
startContainer = middle;
|
|
11501
|
-
startOffset = 0;
|
|
11584
|
+
// splitText updates the live range, including element end offsets.
|
|
11585
|
+
// Only the start at the split point needs to move to the new node.
|
|
11586
|
+
range.setStart(middle, 0);
|
|
11502
11587
|
}
|
|
11503
|
-
range.setStart(startContainer, startOffset);
|
|
11504
|
-
range.setEnd(endContainer, endOffset);
|
|
11505
11588
|
// Normalize text-edge boundaries (e.g. `(text, 0)` or `(text, length)`)
|
|
11506
11589
|
// to the element level so that containment checks based on
|
|
11507
11590
|
// `selectNode()` treat a fully selected text node as contained.
|
|
@@ -11524,19 +11607,18 @@ class Selection {
|
|
|
11524
11607
|
/**
|
|
11525
11608
|
* Collects the highest-level nodes that are completely inside the range,
|
|
11526
11609
|
* descending into nodes that are only partially selected.
|
|
11527
|
-
*/ __collectContainedNodes(root, range) {
|
|
11610
|
+
*/ __collectContainedNodes(root, range, scratch = this.createRange()) {
|
|
11528
11611
|
const result = [];
|
|
11529
11612
|
(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.toArray)(root.childNodes).forEach((child)=>{
|
|
11530
|
-
if (this.__isFullyContained(range, child)) {
|
|
11613
|
+
if (this.__isFullyContained(range, child, scratch)) {
|
|
11531
11614
|
result.push(child);
|
|
11532
11615
|
} else if (child.childNodes.length && range.intersectsNode(child)) {
|
|
11533
|
-
result.push(...this.__collectContainedNodes(child, range));
|
|
11616
|
+
result.push(...this.__collectContainedNodes(child, range, scratch));
|
|
11534
11617
|
}
|
|
11535
11618
|
});
|
|
11536
11619
|
return result;
|
|
11537
11620
|
}
|
|
11538
|
-
__isFullyContained(range, node) {
|
|
11539
|
-
const nodeRange = this.createRange();
|
|
11621
|
+
__isFullyContained(range, node, nodeRange) {
|
|
11540
11622
|
nodeRange.selectNode(node);
|
|
11541
11623
|
return range.compareBoundaryPoints(Range.START_TO_START, nodeRange) <= 0 && range.compareBoundaryPoints(Range.END_TO_END, nodeRange) >= 0;
|
|
11542
11624
|
}
|
|
@@ -11583,31 +11665,46 @@ class Selection {
|
|
|
11583
11665
|
/**
|
|
11584
11666
|
* Wrap all selected fragments inside Tag or apply some callback
|
|
11585
11667
|
*/ *wrapInTagGen(fakes) {
|
|
11668
|
+
if (this.sel?.rangeCount && !this.isInsideArea) {
|
|
11669
|
+
return;
|
|
11670
|
+
}
|
|
11586
11671
|
if (this.isCollapsed()) {
|
|
11587
11672
|
const font = this.jodit.createInside.element('font', jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.INVISIBLE_SPACE);
|
|
11588
11673
|
this.insertNode(font, false, false);
|
|
11589
11674
|
if (fakes && fakes[0]) {
|
|
11590
11675
|
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.append(font, fakes[0]);
|
|
11591
11676
|
}
|
|
11592
|
-
|
|
11593
|
-
|
|
11677
|
+
try {
|
|
11678
|
+
yield font;
|
|
11679
|
+
} finally{
|
|
11680
|
+
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.unwrap(font);
|
|
11681
|
+
}
|
|
11594
11682
|
return;
|
|
11595
11683
|
}
|
|
11596
|
-
const elms = this.__wrapSelectionFragments();
|
|
11597
|
-
|
|
11598
|
-
const
|
|
11599
|
-
|
|
11684
|
+
const elms = this.__ranges().flatMap((range)=>this.__wrapSelectionFragments(range));
|
|
11685
|
+
try {
|
|
11686
|
+
for (const font of elms){
|
|
11687
|
+
if (this.j.isInDestruct || !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, font, true)) {
|
|
11688
|
+
continue;
|
|
11689
|
+
}
|
|
11690
|
+
const { firstChild, lastChild } = font;
|
|
11691
|
+
if (firstChild && firstChild === lastChild && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isMarker)(firstChild)) {
|
|
11692
|
+
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.unwrap(font);
|
|
11693
|
+
continue;
|
|
11694
|
+
}
|
|
11695
|
+
if (firstChild && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isMarker)(firstChild)) {
|
|
11696
|
+
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.before(font, firstChild);
|
|
11697
|
+
}
|
|
11698
|
+
if (lastChild && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isMarker)(lastChild)) {
|
|
11699
|
+
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.after(font, lastChild);
|
|
11700
|
+
}
|
|
11701
|
+
yield font;
|
|
11600
11702
|
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.unwrap(font);
|
|
11601
|
-
continue;
|
|
11602
11703
|
}
|
|
11603
|
-
|
|
11604
|
-
|
|
11605
|
-
|
|
11606
|
-
|
|
11607
|
-
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.after(font, lastChild);
|
|
11608
|
-
}
|
|
11609
|
-
yield font;
|
|
11610
|
-
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.unwrap(font);
|
|
11704
|
+
} finally{
|
|
11705
|
+
// A callback can throw or stop iteration before later wrappers
|
|
11706
|
+
// have been visited. None of the temporary fonts should survive.
|
|
11707
|
+
elms.forEach((font)=>jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.unwrap(font));
|
|
11611
11708
|
}
|
|
11612
11709
|
return;
|
|
11613
11710
|
}
|
|
@@ -11660,7 +11757,7 @@ class Selection {
|
|
|
11660
11757
|
/**
|
|
11661
11758
|
* Split selection on two parts: left and right
|
|
11662
11759
|
*/ splitSelection(currentBox, edge) {
|
|
11663
|
-
if (!this.isCollapsed()) {
|
|
11760
|
+
if (!this.isCollapsed() || !this.isInsideArea || !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, currentBox, true) || !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(currentBox, this.range.startContainer) || edge && !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(currentBox, edge, true)) {
|
|
11664
11761
|
return null;
|
|
11665
11762
|
}
|
|
11666
11763
|
const leftRange = this.createRange();
|
|
@@ -11739,13 +11836,18 @@ class Selection {
|
|
|
11739
11836
|
* edge of their parents are moved out of them (e.g. `<p><b>|test|</b></p>`
|
|
11740
11837
|
* becomes `<p>|<b>test</b>|</p>`)
|
|
11741
11838
|
*/ expandSelection() {
|
|
11742
|
-
if (this.isCollapsed()) {
|
|
11839
|
+
if (this.isCollapsed() || !this.isInsideArea) {
|
|
11743
11840
|
return this;
|
|
11744
11841
|
}
|
|
11745
|
-
const
|
|
11842
|
+
const backward = this.__isBackward();
|
|
11843
|
+
const ranges = this.__ranges().map((range)=>this.__expandRange(range));
|
|
11844
|
+
this.__selectRanges(ranges, backward);
|
|
11845
|
+
return this;
|
|
11846
|
+
}
|
|
11847
|
+
__expandRange(range) {
|
|
11746
11848
|
const c = range.cloneRange();
|
|
11747
11849
|
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.j.editor, range.commonAncestorContainer, true)) {
|
|
11748
|
-
return
|
|
11850
|
+
return range;
|
|
11749
11851
|
}
|
|
11750
11852
|
const moveMaxEdgeFake = (start)=>{
|
|
11751
11853
|
const fake = this.j.createInside.fake();
|
|
@@ -11782,16 +11884,17 @@ class Selection {
|
|
|
11782
11884
|
}
|
|
11783
11885
|
}
|
|
11784
11886
|
}
|
|
11785
|
-
this.selectRange(c);
|
|
11786
11887
|
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeRemove(leftFake, rightFake);
|
|
11787
|
-
if (
|
|
11888
|
+
if (c.collapsed) {
|
|
11788
11889
|
throw (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.error)('Selection is collapsed');
|
|
11789
11890
|
}
|
|
11790
|
-
return
|
|
11891
|
+
return c;
|
|
11791
11892
|
}
|
|
11792
11893
|
constructor(jodit){
|
|
11793
11894
|
;(0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "jodit", void 0);
|
|
11895
|
+
(0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__fakeSelections", void 0);
|
|
11794
11896
|
this.jodit = jodit;
|
|
11897
|
+
this.__fakeSelections = new WeakMap();
|
|
11795
11898
|
jodit.e.on('removeMarkers', ()=>{
|
|
11796
11899
|
this.removeMarkers();
|
|
11797
11900
|
});
|
|
@@ -11825,8 +11928,7 @@ class Selection {
|
|
|
11825
11928
|
/* harmony export */ });
|
|
11826
11929
|
/* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(23211);
|
|
11827
11930
|
/* harmony import */ var jodit_core_helpers_checker_is_marker__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(23175);
|
|
11828
|
-
/* harmony import */ var
|
|
11829
|
-
/* harmony import */ var jodit_core_helpers_utils_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(71125);
|
|
11931
|
+
/* harmony import */ var jodit_core_helpers_utils_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(71125);
|
|
11830
11932
|
/*!
|
|
11831
11933
|
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
11832
11934
|
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
@@ -11834,7 +11936,6 @@ class Selection {
|
|
|
11834
11936
|
*/
|
|
11835
11937
|
|
|
11836
11938
|
|
|
11837
|
-
|
|
11838
11939
|
/**
|
|
11839
11940
|
* If the selection area is inside an element that matches the commit (suitable relative),
|
|
11840
11941
|
* but does not completely fill it.
|
|
@@ -11868,11 +11969,11 @@ class Selection {
|
|
|
11868
11969
|
* @private
|
|
11869
11970
|
*/ function extractAndMove(wrapper, range, left) {
|
|
11870
11971
|
const fragment = range.extractContents();
|
|
11871
|
-
if (
|
|
11972
|
+
if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isEmpty(fragment) && fragment.firstChild) {
|
|
11872
11973
|
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.unwrap(fragment.firstChild);
|
|
11873
11974
|
}
|
|
11874
11975
|
if (wrapper.parentNode) {
|
|
11875
|
-
(0,
|
|
11976
|
+
(0,jodit_core_helpers_utils_utils__WEBPACK_IMPORTED_MODULE_2__.call)(left ? jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.before : jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.after, wrapper, fragment);
|
|
11876
11977
|
}
|
|
11877
11978
|
}
|
|
11878
11979
|
|
|
@@ -12255,12 +12356,14 @@ if (jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__.globalDocument) {
|
|
|
12255
12356
|
;(0,jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_2__.assert)(attrs, 'Attrs must be a non-empty object');
|
|
12256
12357
|
return Object.keys(attrs).every((key)=>{
|
|
12257
12358
|
if (key === 'class' || key === 'className') {
|
|
12258
|
-
|
|
12359
|
+
const classes = String(attrs[key]).match(/[^\t\n\f\r ]+/g) ?? [];
|
|
12360
|
+
return classes.every((name)=>elm.classList.contains(name));
|
|
12259
12361
|
}
|
|
12260
12362
|
if (key === 'style') {
|
|
12261
12363
|
return (0,_has_same_style__WEBPACK_IMPORTED_MODULE_4__.hasSameStyle)(elm, attrs[key]);
|
|
12262
12364
|
}
|
|
12263
|
-
|
|
12365
|
+
const value = attrs[key];
|
|
12366
|
+
return (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.attr)(elm, key) === (value == null ? value : String(value));
|
|
12264
12367
|
});
|
|
12265
12368
|
}
|
|
12266
12369
|
function elementsEqualAttributes(elm1, elm2) {
|
|
@@ -12277,10 +12380,12 @@ function elementsEqualAttributes(elm1, elm2) {
|
|
|
12277
12380
|
|
|
12278
12381
|
"use strict";
|
|
12279
12382
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
12280
|
-
/* harmony export */ isSameStyleChild: function() { return /* binding */ isSameStyleChild; },
|
|
12281
12383
|
/* harmony export */ isSuitElement: function() { return /* binding */ isSuitElement; },
|
|
12282
12384
|
/* harmony export */ suitableClosest: function() { return /* binding */ suitableClosest; }
|
|
12283
12385
|
/* harmony export */ });
|
|
12386
|
+
/* unused harmony export isSameStyleChild */
|
|
12387
|
+
/* unused harmony import specifier */ var hasSameStyleKeys;
|
|
12388
|
+
/* unused harmony import specifier */ var isNormalNode;
|
|
12284
12389
|
/* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(23211);
|
|
12285
12390
|
/* harmony import */ var _has_same_style__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9703);
|
|
12286
12391
|
/* harmony import */ var _is_normal_node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(83653);
|
|
@@ -12336,11 +12441,11 @@ function elementsEqualAttributes(elm1, elm2) {
|
|
|
12336
12441
|
* @private
|
|
12337
12442
|
*/ function isSameStyleChild(commitStyle, elm) {
|
|
12338
12443
|
const { element, options } = commitStyle;
|
|
12339
|
-
if (!elm || !
|
|
12444
|
+
if (!elm || !isNormalNode(elm)) {
|
|
12340
12445
|
return false;
|
|
12341
12446
|
}
|
|
12342
12447
|
const elmIsSame = elm.nodeName.toLowerCase() === element;
|
|
12343
|
-
const elmHasSameStyle = Boolean(options.attributes?.style &&
|
|
12448
|
+
const elmHasSameStyle = Boolean(options.attributes?.style && hasSameStyleKeys(elm, options.attributes?.style));
|
|
12344
12449
|
return elmIsSame && elmHasSameStyle;
|
|
12345
12450
|
}
|
|
12346
12451
|
|
|
@@ -12521,7 +12626,7 @@ const tak = 'toggleAttributes';
|
|
|
12521
12626
|
switch(key){
|
|
12522
12627
|
case 'style':
|
|
12523
12628
|
{
|
|
12524
|
-
mode = toggleStyle(
|
|
12629
|
+
mode = toggleStyle(jodit, value, elm, dry, mode);
|
|
12525
12630
|
break;
|
|
12526
12631
|
}
|
|
12527
12632
|
case 'className':
|
|
@@ -12533,9 +12638,11 @@ const tak = 'toggleAttributes';
|
|
|
12533
12638
|
}
|
|
12534
12639
|
});
|
|
12535
12640
|
}
|
|
12536
|
-
|
|
12641
|
+
// Cleanup belongs to the complete attribute transaction. Removing a
|
|
12642
|
+
// wrapper between CSS rules would apply the remaining rules to a detached node.
|
|
12643
|
+
return !dry && attributes?.style ? removeExtraStyleAttribute(commitStyle, elm, mode) : mode;
|
|
12537
12644
|
}
|
|
12538
|
-
function toggleStyle(
|
|
12645
|
+
function toggleStyle(jodit, style, elm, dry, mode) {
|
|
12539
12646
|
;(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_6__.assert)((0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_3__.isPlainObject)(style) && (0,jodit_core_helpers_size_object_size__WEBPACK_IMPORTED_MODULE_5__.size)(style), 'Style must be an object');
|
|
12540
12647
|
Object.keys(style).forEach((rule)=>{
|
|
12541
12648
|
const inlineValue = (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_7__.cssInline)(elm, rule);
|
|
@@ -12543,39 +12650,50 @@ function toggleStyle(commitStyle, jodit, style, elm, dry, mode) {
|
|
|
12543
12650
|
if (inlineValue === '' && newValue == null) {
|
|
12544
12651
|
return;
|
|
12545
12652
|
}
|
|
12653
|
+
if (newValue == null || newValue === '') {
|
|
12654
|
+
if (inlineValue) {
|
|
12655
|
+
!dry && (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_7__.css)(elm, rule, null);
|
|
12656
|
+
// An explicit reset changes a style; it is not a toggle of
|
|
12657
|
+
// the owning element (notably when resetting list-style-type).
|
|
12658
|
+
mode = (/* inlined export .CHANGE */"change");
|
|
12659
|
+
}
|
|
12660
|
+
return;
|
|
12661
|
+
}
|
|
12546
12662
|
if (getNativeCSSValue(jodit, elm, rule) === (0,jodit_core_helpers_normalize_normalize_css_value__WEBPACK_IMPORTED_MODULE_4__.normalizeCssValue)(rule, newValue)) {
|
|
12547
12663
|
if (!inlineValue) {
|
|
12548
12664
|
return;
|
|
12549
12665
|
}
|
|
12550
12666
|
!dry && (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_7__.css)(elm, rule, null);
|
|
12551
12667
|
mode = (/* inlined export .UNSET */"unset");
|
|
12552
|
-
mode = removeExtraStyleAttribute(commitStyle, elm, mode);
|
|
12553
12668
|
return;
|
|
12554
12669
|
}
|
|
12555
12670
|
mode = (/* inlined export .CHANGE */"change");
|
|
12556
12671
|
if (!dry) {
|
|
12557
12672
|
(0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_7__.css)(elm, rule, newValue);
|
|
12558
|
-
mode = removeExtraStyleAttribute(commitStyle, elm, mode);
|
|
12559
12673
|
}
|
|
12560
12674
|
});
|
|
12561
12675
|
return mode;
|
|
12562
12676
|
}
|
|
12563
12677
|
function toggleClass(jodit, value, elm, mode, dry) {
|
|
12564
12678
|
;(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_6__.assert)((0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_3__.isString)(value), 'Class name must be a string');
|
|
12679
|
+
const classes = value.match(/[^\t\n\f\r ]+/g) ?? [];
|
|
12680
|
+
if (!classes.length) {
|
|
12681
|
+
return mode;
|
|
12682
|
+
}
|
|
12565
12683
|
const hook = jodit.e.fire.bind(jodit.e, `${jodit_core_selection_style_constants__WEBPACK_IMPORTED_MODULE_9__._PREFIX}AfterToggleAttribute`);
|
|
12566
|
-
if (elm.classList.contains(
|
|
12684
|
+
if (classes.every((name)=>elm.classList.contains(name))) {
|
|
12567
12685
|
mode = (/* inlined export .UNSET */"unset");
|
|
12568
12686
|
if (!dry) {
|
|
12569
|
-
elm.classList.remove(
|
|
12687
|
+
elm.classList.remove(...classes);
|
|
12570
12688
|
if (elm.classList.length === 0) {
|
|
12571
12689
|
(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_6__.attr)(elm, 'class', null);
|
|
12572
|
-
hook(mode, elm, 'class', null);
|
|
12573
12690
|
}
|
|
12691
|
+
hook(mode, elm, 'class', (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_6__.attr)(elm, 'class'));
|
|
12574
12692
|
}
|
|
12575
12693
|
} else {
|
|
12576
12694
|
mode = (/* inlined export .CHANGE */"change");
|
|
12577
12695
|
if (!dry) {
|
|
12578
|
-
elm.classList.add(
|
|
12696
|
+
elm.classList.add(...classes);
|
|
12579
12697
|
hook(mode, elm, 'class', value);
|
|
12580
12698
|
}
|
|
12581
12699
|
}
|
|
@@ -12605,7 +12723,7 @@ function toggleAttribute(jodit, value, elm, key, dry, mode) {
|
|
|
12605
12723
|
*/ function removeExtraStyleAttribute(commitStyle, elm, mode) {
|
|
12606
12724
|
if (!(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_6__.attr)(elm, 'style')) {
|
|
12607
12725
|
(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_6__.attr)(elm, 'style', null);
|
|
12608
|
-
if (elm.tagName.toLowerCase() === commitStyle.defaultTag) {
|
|
12726
|
+
if (!elm.attributes.length && elm.tagName.toLowerCase() === commitStyle.defaultTag) {
|
|
12609
12727
|
jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.unwrap(elm);
|
|
12610
12728
|
mode = (/* inlined export .UNWRAP */"unwrap");
|
|
12611
12729
|
}
|
|
@@ -12682,38 +12800,42 @@ function toggleAttribute(jodit, value, elm, key, dry, mode) {
|
|
|
12682
12800
|
const needChangeStyle = [];
|
|
12683
12801
|
let firstElementSuit;
|
|
12684
12802
|
const cssStyle = style.options.attributes?.style;
|
|
12685
|
-
|
|
12686
|
-
|
|
12687
|
-
|
|
12688
|
-
|
|
12689
|
-
|
|
12690
|
-
|
|
12691
|
-
|
|
12692
|
-
|
|
12693
|
-
|
|
12803
|
+
const styleKeys = Object.keys(cssStyle ?? {});
|
|
12804
|
+
const clearedStyle = {};
|
|
12805
|
+
styleKeys.forEach((key)=>{
|
|
12806
|
+
clearedStyle[key] = null;
|
|
12807
|
+
});
|
|
12808
|
+
const clearStyle = (elm)=>{
|
|
12809
|
+
(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.css)(elm, clearedStyle);
|
|
12810
|
+
if (!(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.attr)(elm, 'style')) {
|
|
12811
|
+
(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.attr)(elm, 'style', null);
|
|
12812
|
+
}
|
|
12813
|
+
if (!elm.attributes.length && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(elm, style.element)) {
|
|
12814
|
+
needUnwrap.push(elm);
|
|
12815
|
+
}
|
|
12816
|
+
};
|
|
12817
|
+
for (const elm of jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.eachGen(font)){
|
|
12818
|
+
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isContentEditable(elm, font)) {
|
|
12819
|
+
continue;
|
|
12820
|
+
}
|
|
12821
|
+
if ((0,_is_suit_element__WEBPACK_IMPORTED_MODULE_3__.isSuitElement)(style, elm, true) && (!cssStyle || (0,jodit_core_selection_style_api_has_same_style__WEBPACK_IMPORTED_MODULE_2__.hasSameStyleKeys)(elm, cssStyle))) {
|
|
12822
|
+
if (firstElementSuit === undefined) {
|
|
12823
|
+
firstElementSuit = true;
|
|
12824
|
+
}
|
|
12825
|
+
if (cssStyle) {
|
|
12826
|
+
needChangeStyle.push(()=>clearStyle(elm));
|
|
12827
|
+
} else {
|
|
12694
12828
|
needUnwrap.push(elm);
|
|
12695
|
-
} else if (cssStyle && (0,_is_suit_element__WEBPACK_IMPORTED_MODULE_3__.isSameStyleChild)(style, elm)) {
|
|
12696
|
-
if (firstElementSuit === undefined) {
|
|
12697
|
-
firstElementSuit = false;
|
|
12698
|
-
}
|
|
12699
|
-
needChangeStyle.push(()=>{
|
|
12700
|
-
;(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.css)(elm, Object.keys(cssStyle).reduce((acc, key)=>{
|
|
12701
|
-
acc[key] = null;
|
|
12702
|
-
return acc;
|
|
12703
|
-
}, {}));
|
|
12704
|
-
if (!(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.attr)(elm, 'style')) {
|
|
12705
|
-
(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.attr)(elm, 'style', null);
|
|
12706
|
-
}
|
|
12707
|
-
if (!(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.attr)(elm, 'style') && elm.nodeName.toLowerCase() === style.element) {
|
|
12708
|
-
needUnwrap.push(elm);
|
|
12709
|
-
}
|
|
12710
|
-
});
|
|
12711
|
-
} else if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isEmptyTextNode(elm)) {
|
|
12712
|
-
if (firstElementSuit === undefined) {
|
|
12713
|
-
firstElementSuit = false;
|
|
12714
|
-
}
|
|
12715
12829
|
}
|
|
12716
|
-
|
|
12830
|
+
} else if (cssStyle && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isHTMLElement(elm) && styleKeys.some((key)=>(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.css)(elm, key, true) !== '')) {
|
|
12831
|
+
if (firstElementSuit === undefined) {
|
|
12832
|
+
firstElementSuit = false;
|
|
12833
|
+
}
|
|
12834
|
+
needChangeStyle.push(()=>clearStyle(elm));
|
|
12835
|
+
} else if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isEmptyTextNode(elm)) {
|
|
12836
|
+
if (firstElementSuit === undefined) {
|
|
12837
|
+
firstElementSuit = false;
|
|
12838
|
+
}
|
|
12717
12839
|
}
|
|
12718
12840
|
}
|
|
12719
12841
|
needChangeStyle.forEach((clb)=>clb());
|
|
@@ -12884,35 +13006,32 @@ const WRAP_NODES = new Set([
|
|
|
12884
13006
|
|
|
12885
13007
|
/** @internal */ function ApplyStyle(jodit, cs) {
|
|
12886
13008
|
const { s: sel, editor } = jodit;
|
|
12887
|
-
// sel.save();
|
|
12888
13009
|
editor.firstChild?.normalize(); // FF fix for test "commandsTest - Exec command "bold"
|
|
12889
13010
|
const fakes = sel.fakes();
|
|
12890
|
-
const
|
|
12891
|
-
let
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12899
|
-
|
|
12900
|
-
|
|
12901
|
-
|
|
12902
|
-
|
|
12903
|
-
|
|
12904
|
-
|
|
12905
|
-
|
|
12906
|
-
|
|
12907
|
-
|
|
12908
|
-
//
|
|
12909
|
-
|
|
13011
|
+
const collapsed = sel.isCollapsed();
|
|
13012
|
+
let mode = _constants__WEBPACK_IMPORTED_MODULE_1__.INITIAL;
|
|
13013
|
+
try {
|
|
13014
|
+
// for...of closes the generator on an exception, releasing every
|
|
13015
|
+
// temporary wrapper before the selection is restored in finally.
|
|
13016
|
+
for (const font of sel.wrapInTagGen(fakes)){
|
|
13017
|
+
let state = {
|
|
13018
|
+
collapsed,
|
|
13019
|
+
mode,
|
|
13020
|
+
element: font,
|
|
13021
|
+
next: _transactions__WEBPACK_IMPORTED_MODULE_2__.states.START,
|
|
13022
|
+
jodit,
|
|
13023
|
+
style: cs
|
|
13024
|
+
};
|
|
13025
|
+
const machine = new _api__WEBPACK_IMPORTED_MODULE_0__.FiniteStateMachine(_transactions__WEBPACK_IMPORTED_MODULE_2__.states.START, _transactions__WEBPACK_IMPORTED_MODULE_2__.transactions);
|
|
13026
|
+
while(!jodit.isInDestruct && machine.getState() !== _transactions__WEBPACK_IMPORTED_MODULE_2__.states.END){
|
|
13027
|
+
state = machine.dispatch('exec', state);
|
|
13028
|
+
}
|
|
13029
|
+
// The first selected fragment determines how later fragments toggle.
|
|
13030
|
+
mode = state.mode;
|
|
12910
13031
|
}
|
|
12911
|
-
|
|
12912
|
-
|
|
13032
|
+
} finally{
|
|
13033
|
+
sel.restoreFakes(fakes);
|
|
12913
13034
|
}
|
|
12914
|
-
// sel.restore();
|
|
12915
|
-
sel.restoreFakes(fakes);
|
|
12916
13035
|
}
|
|
12917
13036
|
|
|
12918
13037
|
|
|
@@ -12993,6 +13112,9 @@ class CommitStyle {
|
|
|
12993
13112
|
});
|
|
12994
13113
|
this.__applyMap = new WeakMap();
|
|
12995
13114
|
}
|
|
13115
|
+
if (jodit.isInDestruct) {
|
|
13116
|
+
return;
|
|
13117
|
+
}
|
|
12996
13118
|
jodit.synchronizeValues();
|
|
12997
13119
|
jodit.e.fire('afterCommitStyle', this);
|
|
12998
13120
|
}
|
|
@@ -13072,7 +13194,7 @@ const transactions = {
|
|
|
13072
13194
|
[states.START]: {
|
|
13073
13195
|
exec (value) {
|
|
13074
13196
|
const { element, jodit, style, mode, collapsed } = value;
|
|
13075
|
-
if ((0,jodit_core_selection_style_api__WEBPACK_IMPORTED_MODULE_3__.isInsideInvisibleElement)(element, jodit.editor) || !collapsed && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.isEmptyContent(element)) {
|
|
13197
|
+
if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.isContentEditable(element, jodit.editor) || (0,jodit_core_selection_style_api__WEBPACK_IMPORTED_MODULE_3__.isInsideInvisibleElement)(element, jodit.editor) || !collapsed && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.isEmptyContent(element)) {
|
|
13076
13198
|
return {
|
|
13077
13199
|
...value,
|
|
13078
13200
|
next: states.END
|
|
@@ -18605,11 +18727,13 @@ function addClassNames(className, elm) {
|
|
|
18605
18727
|
|
|
18606
18728
|
|
|
18607
18729
|
|
|
18730
|
+
|
|
18608
18731
|
|
|
18609
18732
|
|
|
18610
18733
|
let exp = {};
|
|
18611
18734
|
exp = {
|
|
18612
18735
|
ar: (jodit_langs_ar__WEBPACK_IMPORTED_MODULE_1___default()),
|
|
18736
|
+
az: (jodit_langs_ar__WEBPACK_IMPORTED_MODULE_1___default()),
|
|
18613
18737
|
cs_cz: (jodit_langs_ar__WEBPACK_IMPORTED_MODULE_1___default()),
|
|
18614
18738
|
de: (jodit_langs_ar__WEBPACK_IMPORTED_MODULE_1___default()),
|
|
18615
18739
|
en: jodit_langs_en__WEBPACK_IMPORTED_MODULE_2__,
|
|
@@ -21898,7 +22022,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__.Config.prototype.history = {
|
|
|
21898
22022
|
* @param first - the first snapshote
|
|
21899
22023
|
* @param second - second shot
|
|
21900
22024
|
*/ static equal(first, second) {
|
|
21901
|
-
return first.html === second.html && JSON.stringify(first.range) === JSON.stringify(second.range);
|
|
22025
|
+
return first.html === second.html && JSON.stringify(first.range) === JSON.stringify(second.range) && JSON.stringify(first.ranges) === JSON.stringify(second.ranges) && Boolean(first.backward) === Boolean(second.backward);
|
|
21902
22026
|
}
|
|
21903
22027
|
/**
|
|
21904
22028
|
* Calc count element before some node in parentNode. All text nodes are joined
|
|
@@ -21992,22 +22116,31 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__.Config.prototype.history = {
|
|
|
21992
22116
|
snapshot.html = this.__getCleanedEditorValue(this.j.editor);
|
|
21993
22117
|
const sel = this.j.s.sel;
|
|
21994
22118
|
if (sel && sel.rangeCount) {
|
|
21995
|
-
const
|
|
21996
|
-
|
|
21997
|
-
|
|
21998
|
-
|
|
21999
|
-
|
|
22000
|
-
startOffset =
|
|
22001
|
-
|
|
22002
|
-
|
|
22003
|
-
|
|
22004
|
-
|
|
22005
|
-
|
|
22006
|
-
|
|
22007
|
-
|
|
22008
|
-
|
|
22009
|
-
|
|
22010
|
-
|
|
22119
|
+
const ranges = [];
|
|
22120
|
+
for(let i = 0; i < sel.rangeCount; i += 1){
|
|
22121
|
+
const range = sel.getRangeAt(i);
|
|
22122
|
+
const startContainer = this.calcHierarchyLadder(range.startContainer);
|
|
22123
|
+
const endContainer = this.calcHierarchyLadder(range.endContainer);
|
|
22124
|
+
let startOffset = Snapshot.strokeOffset(range.startContainer, range.startOffset), endOffset = Snapshot.strokeOffset(range.endContainer, range.endOffset);
|
|
22125
|
+
if (!startContainer.length && range.startContainer !== this.j.editor) {
|
|
22126
|
+
startOffset = 0;
|
|
22127
|
+
}
|
|
22128
|
+
if (!endContainer.length && range.endContainer !== this.j.editor) {
|
|
22129
|
+
endOffset = 0;
|
|
22130
|
+
}
|
|
22131
|
+
ranges.push({
|
|
22132
|
+
startContainer,
|
|
22133
|
+
startOffset,
|
|
22134
|
+
endContainer,
|
|
22135
|
+
endOffset
|
|
22136
|
+
});
|
|
22137
|
+
}
|
|
22138
|
+
snapshot.range = ranges[0];
|
|
22139
|
+
if (ranges.length > 1) {
|
|
22140
|
+
snapshot.ranges = ranges;
|
|
22141
|
+
} else if (!sel.isCollapsed && sel.anchorNode === sel.getRangeAt(0).endContainer && sel.anchorOffset === sel.getRangeAt(0).endOffset) {
|
|
22142
|
+
snapshot.backward = true;
|
|
22143
|
+
}
|
|
22011
22144
|
}
|
|
22012
22145
|
return snapshot;
|
|
22013
22146
|
}
|
|
@@ -22046,10 +22179,21 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__.Config.prototype.history = {
|
|
|
22046
22179
|
*/ restoreOnlySelection(snapshot) {
|
|
22047
22180
|
try {
|
|
22048
22181
|
if (snapshot.range) {
|
|
22049
|
-
const
|
|
22050
|
-
|
|
22051
|
-
|
|
22052
|
-
|
|
22182
|
+
const ranges = (snapshot.ranges ?? [
|
|
22183
|
+
snapshot.range
|
|
22184
|
+
]).map((saved)=>{
|
|
22185
|
+
const range = this.j.ed.createRange();
|
|
22186
|
+
range.setStart(this.getElementByLadder(saved.startContainer), saved.startOffset);
|
|
22187
|
+
range.setEnd(this.getElementByLadder(saved.endContainer), saved.endOffset);
|
|
22188
|
+
return range;
|
|
22189
|
+
});
|
|
22190
|
+
this.j.s.selectRange(ranges[0]);
|
|
22191
|
+
const sel = this.j.s.sel;
|
|
22192
|
+
ranges.slice(1).forEach((range)=>sel?.addRange(range));
|
|
22193
|
+
if (snapshot.backward && ranges.length === 1) {
|
|
22194
|
+
const range = ranges[0];
|
|
22195
|
+
sel?.setBaseAndExtent(range.endContainer, range.endOffset, range.startContainer, range.startOffset);
|
|
22196
|
+
}
|
|
22053
22197
|
}
|
|
22054
22198
|
} catch (__ignore) {
|
|
22055
22199
|
this.j.editor.lastChild && this.j.s.setCursorAfter(this.j.editor.lastChild);
|
|
@@ -26603,13 +26747,13 @@ jodit_config__WEBPACK_IMPORTED_MODULE_1__.Config.prototype.controls['ai-assistan
|
|
|
26603
26747
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
26604
26748
|
|
|
26605
26749
|
"use strict";
|
|
26750
|
+
var _en_js__WEBPACK_IMPORTED_MODULE_0___namespace_cache;
|
|
26606
26751
|
__webpack_require__.r(__webpack_exports__);
|
|
26607
26752
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
26608
|
-
/* harmony export */ en: function() { return /* reexport
|
|
26753
|
+
/* harmony export */ en: function() { return /* reexport fake namespace object from non-harmony */ _en_js__WEBPACK_IMPORTED_MODULE_0___namespace_cache || (_en_js__WEBPACK_IMPORTED_MODULE_0___namespace_cache = __webpack_require__.t(_en_js__WEBPACK_IMPORTED_MODULE_0__, 2)); },
|
|
26609
26754
|
/* harmony export */ es: function() { return /* reexport module object */ _es_js__WEBPACK_IMPORTED_MODULE_1__; }
|
|
26610
26755
|
/* harmony export */ });
|
|
26611
26756
|
/* harmony import */ var _en_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(17918);
|
|
26612
|
-
/* harmony import */ var _en_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_en_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
26613
26757
|
/* harmony import */ var _es_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(41324);
|
|
26614
26758
|
/* harmony import */ var _es_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_es_js__WEBPACK_IMPORTED_MODULE_1__);
|
|
26615
26759
|
/*!
|
|
@@ -44411,7 +44555,7 @@ function __rewriteRelativeImportExtension(path, preserveJsx) {
|
|
|
44411
44555
|
/******/ var priority = deferred[i][2];
|
|
44412
44556
|
/******/ var fulfilled = true;
|
|
44413
44557
|
/******/ for (var j = 0; j < chunkIds.length; j++) {
|
|
44414
|
-
/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every(function(key) { return __webpack_require__.O[key](chunkIds[j]); })) {
|
|
44558
|
+
/******/ if (((priority & 1) === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every(function(key) { return __webpack_require__.O[key](chunkIds[j]); })) {
|
|
44415
44559
|
/******/ chunkIds.splice(j--, 1);
|
|
44416
44560
|
/******/ } else {
|
|
44417
44561
|
/******/ fulfilled = false;
|
|
@@ -44429,59 +44573,76 @@ function __rewriteRelativeImportExtension(path, preserveJsx) {
|
|
|
44429
44573
|
/******/ }();
|
|
44430
44574
|
/******/
|
|
44431
44575
|
/******/ /* webpack/runtime/compat get default export */
|
|
44576
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
44577
|
+
/******/ __webpack_require__.n = function(module) {
|
|
44578
|
+
/******/ var getter = module && module.__esModule ?
|
|
44579
|
+
/******/ function() { return module['default']; } :
|
|
44580
|
+
/******/ function() { return module; };
|
|
44581
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
44582
|
+
/******/ return getter;
|
|
44583
|
+
/******/ };
|
|
44584
|
+
/******/
|
|
44585
|
+
/******/ /* webpack/runtime/create fake namespace object */
|
|
44432
44586
|
/******/ !function() {
|
|
44433
|
-
/******/
|
|
44434
|
-
/******/
|
|
44435
|
-
/******/
|
|
44436
|
-
/******/
|
|
44437
|
-
/******/
|
|
44438
|
-
/******/
|
|
44439
|
-
/******/
|
|
44587
|
+
/******/ var getProto = Object.getPrototypeOf;
|
|
44588
|
+
/******/ var leafPrototypes;
|
|
44589
|
+
/******/ // create a fake namespace object
|
|
44590
|
+
/******/ // mode & 1: value is a module id, require it
|
|
44591
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
|
44592
|
+
/******/ // mode & 4: return value when already ns object
|
|
44593
|
+
/******/ // mode & 16: return value when it's Promise-like
|
|
44594
|
+
/******/ // mode & 8|1: behave like require
|
|
44595
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
|
44596
|
+
/******/ if(mode & 1) value = this(value);
|
|
44597
|
+
/******/ if(mode & 8) return value;
|
|
44598
|
+
/******/ if(typeof value === 'object' && value) {
|
|
44599
|
+
/******/ if((mode & 4) && value.__esModule) return value;
|
|
44600
|
+
/******/ if((mode & 16) && typeof value.then === 'function') return value;
|
|
44601
|
+
/******/ }
|
|
44602
|
+
/******/ var ns = Object.create(null);
|
|
44603
|
+
/******/ __webpack_require__.r(ns);
|
|
44604
|
+
/******/ var def = {};
|
|
44605
|
+
/******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];
|
|
44606
|
+
/******/ for(var current = mode & 2 && value; (typeof current == 'object' || typeof current == 'function') && !~leafPrototypes.indexOf(current); current = getProto(current)) {
|
|
44607
|
+
/******/ Object.getOwnPropertyNames(current).forEach(function(key) { def[key] = function() { return value[key]; }; });
|
|
44608
|
+
/******/ }
|
|
44609
|
+
/******/ def['default'] = function() { return value; };
|
|
44610
|
+
/******/ __webpack_require__.d(ns, def);
|
|
44611
|
+
/******/ return ns;
|
|
44440
44612
|
/******/ };
|
|
44441
44613
|
/******/ }();
|
|
44442
44614
|
/******/
|
|
44443
44615
|
/******/ /* webpack/runtime/define property getters */
|
|
44444
|
-
/******/
|
|
44445
|
-
/******/
|
|
44446
|
-
/******/
|
|
44447
|
-
/******/
|
|
44448
|
-
/******/
|
|
44449
|
-
/******/
|
|
44450
|
-
/******/
|
|
44451
|
-
/******/
|
|
44452
|
-
/******/
|
|
44453
|
-
/******/
|
|
44454
|
-
/******/
|
|
44455
|
-
/******/
|
|
44456
|
-
/******/
|
|
44457
|
-
/******/
|
|
44458
|
-
/******/ } else if(binding === 0) { i++; }
|
|
44459
|
-
/******/ }
|
|
44460
|
-
/******/ } else {
|
|
44461
|
-
/******/ for(var key in definition) {
|
|
44462
|
-
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
44463
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
44464
|
-
/******/ }
|
|
44616
|
+
/******/ // define getter/value functions for harmony exports
|
|
44617
|
+
/******/ __webpack_require__.d = function(exports, definition) {
|
|
44618
|
+
/******/ if(Array.isArray(definition)) {
|
|
44619
|
+
/******/ var i = 0;
|
|
44620
|
+
/******/ while(i < definition.length) {
|
|
44621
|
+
/******/ var key = definition[i++];
|
|
44622
|
+
/******/ var binding = definition[i++];
|
|
44623
|
+
/******/ var descriptor = binding === 0 ? { enumerable: true, value: definition[i++] } : { enumerable: true, get: binding };
|
|
44624
|
+
/******/ if(!__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, descriptor);
|
|
44625
|
+
/******/ }
|
|
44626
|
+
/******/ } else {
|
|
44627
|
+
/******/ for(var key in definition) {
|
|
44628
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
44629
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
44465
44630
|
/******/ }
|
|
44466
44631
|
/******/ }
|
|
44467
|
-
/******/ }
|
|
44468
|
-
/******/ }
|
|
44632
|
+
/******/ }
|
|
44633
|
+
/******/ };
|
|
44469
44634
|
/******/
|
|
44470
44635
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
44471
|
-
/******/
|
|
44472
|
-
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
|
44473
|
-
/******/ }();
|
|
44636
|
+
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); };
|
|
44474
44637
|
/******/
|
|
44475
44638
|
/******/ /* webpack/runtime/make namespace object */
|
|
44476
|
-
/******/
|
|
44477
|
-
/******/
|
|
44478
|
-
/******/
|
|
44479
|
-
/******/
|
|
44480
|
-
/******/
|
|
44481
|
-
/******/
|
|
44482
|
-
/******/
|
|
44483
|
-
/******/ };
|
|
44484
|
-
/******/ }();
|
|
44639
|
+
/******/ // define __esModule on exports
|
|
44640
|
+
/******/ __webpack_require__.r = function(exports) {
|
|
44641
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
44642
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
44643
|
+
/******/ }
|
|
44644
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
44645
|
+
/******/ };
|
|
44485
44646
|
/******/
|
|
44486
44647
|
/******/ /* webpack/runtime/jsonp chunk loading */
|
|
44487
44648
|
/******/ !function() {
|