@kaitify/vue 0.0.1-beta.17 → 0.0.1-beta.19

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.
@@ -37807,10 +37807,12 @@ class Editor {
37807
37807
  this.delete();
37808
37808
  return;
37809
37809
  } else if (node.isText()) {
37810
- const deleteChart = node.textContent.substring(offset2 - 1, offset2);
37811
- node.textContent = node.textContent.substring(0, offset2 - 1) + node.textContent.substring(offset2);
37812
- this.selection.start.offset = offset2 - 1;
37813
- this.selection.end.offset = offset2 - 1;
37810
+ const charArray = Array.from(node.textContent.substring(0, offset2));
37811
+ const deleteChart = charArray.pop();
37812
+ const deleteChartLength = deleteChart.length;
37813
+ node.textContent = charArray.join("") + node.textContent.substring(offset2);
37814
+ this.selection.start.offset = offset2 - deleteChartLength;
37815
+ this.selection.end.offset = offset2 - deleteChartLength;
37814
37816
  if (isZeroWidthText(deleteChart)) {
37815
37817
  this.delete();
37816
37818
  return;
@@ -38075,6 +38077,51 @@ class Editor {
38075
38077
  }
38076
38078
  return `<style>${styles2}</style><div class="kaitify">${this.$el.innerHTML}</div>`;
38077
38079
  }
38080
+ /**
38081
+ * 判断光标是否完全在可视范围内
38082
+ */
38083
+ isSelectionInView() {
38084
+ if (this.selection.focused()) {
38085
+ const focusDom = this.findDom(this.selection.end.node);
38086
+ const isInView = (scrollElement) => {
38087
+ const scrollHeight = element.getScrollHeight(scrollElement);
38088
+ const scrollWidth = element.getScrollWidth(scrollElement);
38089
+ if (scrollElement.clientHeight < scrollHeight || scrollElement.clientWidth < scrollWidth) {
38090
+ const selection = window.getSelection();
38091
+ const range = selection.getRangeAt(0);
38092
+ const rects = range.getClientRects();
38093
+ let target = range;
38094
+ if (rects.length == 0) {
38095
+ target = focusDom;
38096
+ }
38097
+ const childRect = target.getBoundingClientRect();
38098
+ const parentRect = scrollElement.getBoundingClientRect();
38099
+ if (scrollElement.clientHeight < scrollHeight) {
38100
+ if (childRect.top < parentRect.top || childRect.bottom > parentRect.bottom) {
38101
+ return false;
38102
+ }
38103
+ }
38104
+ if (scrollElement.clientWidth < scrollWidth) {
38105
+ if (childRect.left < parentRect.left || childRect.right > parentRect.right) {
38106
+ return false;
38107
+ }
38108
+ }
38109
+ }
38110
+ return true;
38111
+ };
38112
+ let inView = true;
38113
+ let dom = focusDom;
38114
+ while (element.isElement(dom) && dom != document.documentElement) {
38115
+ if (!isInView(dom)) {
38116
+ inView = false;
38117
+ break;
38118
+ }
38119
+ dom = dom.parentNode;
38120
+ }
38121
+ return inView;
38122
+ }
38123
+ return true;
38124
+ }
38078
38125
  /**
38079
38126
  * 配置编辑器,返回创建的编辑器
38080
38127
  */