@kaitify/core 0.0.1-beta.20 → 0.0.1-beta.22

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.
@@ -2865,7 +2865,7 @@ const handlerForNormalInsertParagraph = function() {
2865
2865
  }
2866
2866
  };
2867
2867
  const setPlaceholder = function() {
2868
- if (this.stackNodes.length == 1 && this.isParagraph(this.stackNodes[0]) && this.stackNodes[0].allIsPlaceholder()) {
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,11 +3236,12 @@ 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
- const element2 = range.endContainer;
3243
- const parentElement = element2.parentNode;
3243
+ const element2 = range.endContainer.nodeType == 3 ? range.endContainer : range.endContainer.childNodes[range.endOffset > 0 ? range.endOffset - 1 : 0];
3244
+ const parentElement = element2.parentElement;
3244
3245
  const parentNode = this.findNode(parentElement);
3245
3246
  if (parentNode.isText() && parentNode.textContent != element2.textContent) {
3246
3247
  const textContent = parentNode.textContent || "";
@@ -3262,6 +3263,7 @@ const onComposition = async function(e) {
3262
3263
  await this.updateView();
3263
3264
  }
3264
3265
  this.isComposition = false;
3266
+ setPlaceholder.apply(this);
3265
3267
  }
3266
3268
  };
3267
3269
  const onKeyboard = function(e) {
@@ -37105,6 +37107,12 @@ class Editor {
37105
37107
  isDark() {
37106
37108
  return document.documentElement.hasAttribute("kaitify-dark");
37107
37109
  }
37110
+ /**
37111
+ * 判断编辑器是否为空,这里的空指的是编辑器内只有一个段落,并且段落里只有占位符
37112
+ */
37113
+ isEmpty() {
37114
+ return this.stackNodes.length == 1 && this.isParagraph(this.stackNodes[0]) && this.stackNodes[0].allIsPlaceholder();
37115
+ }
37108
37116
  /**
37109
37117
  * dom转KNode
37110
37118
  */