@kaitify/core 0.0.1-beta.20 → 0.0.1-beta.21
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 +13 -2
- 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
|
@@ -2865,7 +2865,7 @@ const handlerForNormalInsertParagraph = function() {
|
|
|
2865
2865
|
}
|
|
2866
2866
|
};
|
|
2867
2867
|
const setPlaceholder = function() {
|
|
2868
|
-
if (this.
|
|
2868
|
+
if (this.isEmpty() && !this.isComposition) {
|
|
2869
2869
|
this.$el.classList.add("kaitify-showplaceholder");
|
|
2870
2870
|
} else {
|
|
2871
2871
|
this.$el.classList.remove("kaitify-showplaceholder");
|
|
@@ -3236,10 +3236,14 @@ const onComposition = async function(e) {
|
|
|
3236
3236
|
}
|
|
3237
3237
|
if (event2.type == "compositionstart") {
|
|
3238
3238
|
this.isComposition = true;
|
|
3239
|
+
setPlaceholder.apply(this);
|
|
3239
3240
|
} else if (event2.type == "compositionend") {
|
|
3240
3241
|
const realSelection = window.getSelection();
|
|
3241
3242
|
const range = realSelection.getRangeAt(0);
|
|
3242
|
-
|
|
3243
|
+
let element2 = range.endContainer;
|
|
3244
|
+
if (element2.nodeType != 3) {
|
|
3245
|
+
element2 = range.endContainer.childNodes[range.endOffset > 0 ? range.endOffset - 1 : range.endOffset];
|
|
3246
|
+
}
|
|
3243
3247
|
const parentElement = element2.parentNode;
|
|
3244
3248
|
const parentNode = this.findNode(parentElement);
|
|
3245
3249
|
if (parentNode.isText() && parentNode.textContent != element2.textContent) {
|
|
@@ -3262,6 +3266,7 @@ const onComposition = async function(e) {
|
|
|
3262
3266
|
await this.updateView();
|
|
3263
3267
|
}
|
|
3264
3268
|
this.isComposition = false;
|
|
3269
|
+
setPlaceholder.apply(this);
|
|
3265
3270
|
}
|
|
3266
3271
|
};
|
|
3267
3272
|
const onKeyboard = function(e) {
|
|
@@ -37105,6 +37110,12 @@ class Editor {
|
|
|
37105
37110
|
isDark() {
|
|
37106
37111
|
return document.documentElement.hasAttribute("kaitify-dark");
|
|
37107
37112
|
}
|
|
37113
|
+
/**
|
|
37114
|
+
* 判断编辑器是否为空,这里的空指的是编辑器内只有一个段落,并且段落里只有占位符
|
|
37115
|
+
*/
|
|
37116
|
+
isEmpty() {
|
|
37117
|
+
return this.stackNodes.length == 1 && this.isParagraph(this.stackNodes[0]) && this.stackNodes[0].allIsPlaceholder();
|
|
37118
|
+
}
|
|
37108
37119
|
/**
|
|
37109
37120
|
* dom转KNode
|
|
37110
37121
|
*/
|