@kaitify/core 0.0.2 → 0.0.3-beta.1
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/lib/kaitify-core.es.js +21 -13
- package/lib/kaitify-core.umd.js +1 -1
- package/package.json +1 -1
package/lib/kaitify-core.es.js
CHANGED
|
@@ -2607,6 +2607,16 @@ const updateSelection$1 = function() {
|
|
|
2607
2607
|
const range = realSelection.getRangeAt(0);
|
|
2608
2608
|
if (isContains(this.$el, range.startContainer) && isContains(this.$el, range.endContainer)) {
|
|
2609
2609
|
const resolvePoint = (container, rangeOffset, type) => {
|
|
2610
|
+
if (container === this.$el) {
|
|
2611
|
+
const childDoms = Array.from(container.childNodes);
|
|
2612
|
+
if (childDoms.length) {
|
|
2613
|
+
const dom = childDoms[rangeOffset] ? childDoms[rangeOffset] : childDoms[rangeOffset - 1];
|
|
2614
|
+
if (dom.nodeType == 1) {
|
|
2615
|
+
childDoms[rangeOffset] ? this.setSelectionBefore(this.findNode(dom), type) : this.setSelectionAfter(this.findNode(dom), type);
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
return;
|
|
2619
|
+
}
|
|
2610
2620
|
const containerNode = container.nodeType == 3 ? this.findNode(container.parentNode) : this.findNode(container);
|
|
2611
2621
|
if (containerNode.isClosed()) {
|
|
2612
2622
|
this.selection[type] = { node: containerNode, offset: type == "start" ? 0 : 1 };
|
|
@@ -2760,7 +2770,7 @@ const handlerForPasteDrop = async function(dataTransfer) {
|
|
|
2760
2770
|
fillPlaceholderToEmptyBlock.apply(this, [nodes]);
|
|
2761
2771
|
handlerForPasteKeepMarksAndStyles.apply(this, [nodes]);
|
|
2762
2772
|
const useDefault = typeof this.onPasteHtml == "function" ? await this.onPasteHtml.apply(this, [nodes, html]) : true;
|
|
2763
|
-
if (useDefault) {
|
|
2773
|
+
if (useDefault && nodes.length > 0) {
|
|
2764
2774
|
this.insertNode(nodes[0]);
|
|
2765
2775
|
for (let i = nodes.length - 1; i >= 1; i--) {
|
|
2766
2776
|
this.addNodeAfter(nodes[i], nodes[0]);
|
|
@@ -37611,12 +37621,11 @@ class Editor {
|
|
|
37611
37621
|
const scrollHeight = element.getScrollHeight(scrollEl);
|
|
37612
37622
|
const scrollWidth = element.getScrollWidth(scrollEl);
|
|
37613
37623
|
if (scrollEl.clientHeight < scrollHeight || scrollEl.clientWidth < scrollWidth) {
|
|
37614
|
-
|
|
37615
|
-
const
|
|
37616
|
-
const
|
|
37617
|
-
|
|
37618
|
-
|
|
37619
|
-
target = focusDom;
|
|
37624
|
+
let target = focusDom;
|
|
37625
|
+
const sel = window.getSelection();
|
|
37626
|
+
const range = sel && sel.rangeCount ? sel.getRangeAt(0) : null;
|
|
37627
|
+
if (range && range.getClientRects().length > 0) {
|
|
37628
|
+
target = range;
|
|
37620
37629
|
}
|
|
37621
37630
|
const childRect = target.getBoundingClientRect();
|
|
37622
37631
|
const parentRect = scrollEl.getBoundingClientRect();
|
|
@@ -38856,12 +38865,11 @@ class Editor {
|
|
|
38856
38865
|
const scrollHeight = element.getScrollHeight(scrollElement);
|
|
38857
38866
|
const scrollWidth = element.getScrollWidth(scrollElement);
|
|
38858
38867
|
if (scrollElement.clientHeight < scrollHeight || scrollElement.clientWidth < scrollWidth) {
|
|
38859
|
-
|
|
38860
|
-
const
|
|
38861
|
-
const
|
|
38862
|
-
|
|
38863
|
-
|
|
38864
|
-
target = focusDom;
|
|
38868
|
+
let target = focusDom;
|
|
38869
|
+
const sel = window.getSelection();
|
|
38870
|
+
const range = sel && sel.rangeCount ? sel.getRangeAt(0) : null;
|
|
38871
|
+
if (range && range.getClientRects().length > 0) {
|
|
38872
|
+
target = range;
|
|
38865
38873
|
}
|
|
38866
38874
|
const childRect = target.getBoundingClientRect();
|
|
38867
38875
|
const parentRect = scrollElement.getBoundingClientRect();
|