@kaitify/core 0.0.1-beta.25 → 0.0.1-beta.26
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 +45 -0
- package/lib/kaitify-core.umd.js +1 -1
- package/lib/model/Editor.d.ts +4 -0
- package/package.json +1 -1
package/lib/kaitify-core.es.js
CHANGED
|
@@ -38320,6 +38320,51 @@ class Editor {
|
|
|
38320
38320
|
}
|
|
38321
38321
|
return `<style>${styles2}</style><div class="kaitify">${this.$el.innerHTML}</div>`;
|
|
38322
38322
|
}
|
|
38323
|
+
/**
|
|
38324
|
+
* 判断光标是否完全在可视范围内
|
|
38325
|
+
*/
|
|
38326
|
+
isSelectionInView() {
|
|
38327
|
+
if (this.selection.focused()) {
|
|
38328
|
+
const focusDom = this.findDom(this.selection.end.node);
|
|
38329
|
+
const isInView = (scrollElement) => {
|
|
38330
|
+
const scrollHeight = element.getScrollHeight(scrollElement);
|
|
38331
|
+
const scrollWidth = element.getScrollWidth(scrollElement);
|
|
38332
|
+
if (scrollElement.clientHeight < scrollHeight || scrollElement.clientWidth < scrollWidth) {
|
|
38333
|
+
const selection = window.getSelection();
|
|
38334
|
+
const range = selection.getRangeAt(0);
|
|
38335
|
+
const rects = range.getClientRects();
|
|
38336
|
+
let target = range;
|
|
38337
|
+
if (rects.length == 0) {
|
|
38338
|
+
target = focusDom;
|
|
38339
|
+
}
|
|
38340
|
+
const childRect = target.getBoundingClientRect();
|
|
38341
|
+
const parentRect = scrollElement.getBoundingClientRect();
|
|
38342
|
+
if (scrollElement.clientHeight < scrollHeight) {
|
|
38343
|
+
if (childRect.top < parentRect.top || childRect.bottom > parentRect.bottom) {
|
|
38344
|
+
return false;
|
|
38345
|
+
}
|
|
38346
|
+
}
|
|
38347
|
+
if (scrollElement.clientWidth < scrollWidth) {
|
|
38348
|
+
if (childRect.left < parentRect.left || childRect.right > parentRect.right) {
|
|
38349
|
+
return false;
|
|
38350
|
+
}
|
|
38351
|
+
}
|
|
38352
|
+
}
|
|
38353
|
+
return true;
|
|
38354
|
+
};
|
|
38355
|
+
let inView = true;
|
|
38356
|
+
let dom = focusDom;
|
|
38357
|
+
while (element.isElement(dom) && dom != document.documentElement) {
|
|
38358
|
+
if (!isInView(dom)) {
|
|
38359
|
+
inView = false;
|
|
38360
|
+
break;
|
|
38361
|
+
}
|
|
38362
|
+
dom = dom.parentNode;
|
|
38363
|
+
}
|
|
38364
|
+
return inView;
|
|
38365
|
+
}
|
|
38366
|
+
return true;
|
|
38367
|
+
}
|
|
38323
38368
|
/**
|
|
38324
38369
|
* 配置编辑器,返回创建的编辑器
|
|
38325
38370
|
*/
|