@kaitify/core 0.0.2-beta.4 → 0.0.2-beta.6

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.
@@ -37252,23 +37252,25 @@ class Editor {
37252
37252
  */
37253
37253
  isEditable() {
37254
37254
  var _a;
37255
- return ((_a = this.$el) == null ? void 0 : _a.getAttribute("contenteditable")) == "true";
37255
+ return ((_a = this.$el) == null ? void 0 : _a.getAttribute("contenteditable")) === "true";
37256
37256
  }
37257
37257
  /**
37258
37258
  * 设置编辑器是否深色模式
37259
37259
  */
37260
37260
  setDark(dark) {
37261
+ var _a, _b;
37261
37262
  if (dark) {
37262
- this.$el.setAttribute("kaitify-dark", "");
37263
+ (_a = this.$el) == null ? void 0 : _a.setAttribute("kaitify-dark", "");
37263
37264
  } else {
37264
- this.$el.removeAttribute("kaitify-dark");
37265
+ (_b = this.$el) == null ? void 0 : _b.removeAttribute("kaitify-dark");
37265
37266
  }
37266
37267
  }
37267
37268
  /**
37268
37269
  * 是否深色模式
37269
37270
  */
37270
37271
  isDark() {
37271
- return this.$el.hasAttribute("kaitify-dark");
37272
+ var _a;
37273
+ return ((_a = this.$el) == null ? void 0 : _a.hasAttribute("kaitify-dark")) ?? false;
37272
37274
  }
37273
37275
  /**
37274
37276
  * 判断编辑器是否为空,这里的空指的是编辑器内只有一个段落,并且段落里只有占位符
@@ -38332,16 +38334,18 @@ class Editor {
38332
38334
  */
38333
38335
  destroy() {
38334
38336
  this.removeDomObserve();
38335
- data.remove(this.$el, "kaitify-init");
38336
- this.$el.classList.remove("kaitify");
38337
- this.$el.removeAttribute("kaitify-placeholder");
38338
- this.setDark(false);
38339
- this.setEditable(false);
38340
- this.$el.innerHTML = "";
38337
+ if (this.$el) {
38338
+ data.remove(this.$el, "kaitify-init");
38339
+ this.$el.classList.remove("kaitify");
38340
+ this.$el.removeAttribute("kaitify-placeholder");
38341
+ this.setDark(false);
38342
+ this.setEditable(false);
38343
+ this.$el.innerHTML = "";
38344
+ event.off(this.$el, "beforeinput.kaitify compositionstart.kaitify compositionupdate.kaitify compositionend.kaitify keydown.kaitify keyup.kaitify copy.kaitify focus.kaitify blur.kaitify");
38345
+ }
38341
38346
  this.selection = new Selection();
38342
38347
  this.history = new History();
38343
38348
  event.off(document, `selectionchange.kaitify_${this.guid}`);
38344
- event.off(this.$el, "beforeinput.kaitify compositionstart.kaitify compositionupdate.kaitify compositionend.kaitify keydown.kaitify keyup.kaitify copy.kaitify focus.kaitify blur.kaitify");
38345
38349
  }
38346
38350
  /**
38347
38351
  * 获取编辑器的纯文本内容,excludeBreak表示是否排除换行符\n,excludeZeroWidthText表示是否排除零宽度空白字符
@@ -38556,6 +38560,7 @@ class Editor {
38556
38560
  */
38557
38561
  static async configure(options) {
38558
38562
  const editor = new Editor();
38563
+ if (options.onCreate) options.onCreate(editor);
38559
38564
  editor.$el = initEditorDom(options.el);
38560
38565
  editor.$el.classList.add("kaitify");
38561
38566
  if (options.dark) editor.setDark(options.dark);
@@ -38607,6 +38612,7 @@ class Editor {
38607
38612
  event.on(editor.$el, "blur.kaitify", onBlur.bind(editor));
38608
38613
  event.on(editor.$el, "copy.kaitify", onCopy.bind(editor));
38609
38614
  event.on(editor.$el, "cut.kaitify", onCut.bind(editor));
38615
+ if (options.onCreated) options.onCreated(editor);
38610
38616
  return editor;
38611
38617
  }
38612
38618
  }