@powerduck/md-editor 0.8.1 → 0.8.2

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/dist/index.mjs CHANGED
@@ -80,7 +80,14 @@ class Zt {
80
80
  }
81
81
  }
82
82
  show() {
83
- this.trigger && (this.dropdown || (this.dropdown = document.createElement("div"), this.dropdown.className = "md-editor-mention-dropdown", this.dropdown.setAttribute("role", "listbox"), (this.view.dom.closest(".md-editor-root") ?? document.body).appendChild(this.dropdown)), this.renderDropdown(), this.positionDropdown());
83
+ if (this.trigger) {
84
+ if (!this.dropdown) {
85
+ this.dropdown = document.createElement("div"), this.dropdown.className = "md-editor-mention-dropdown", this.dropdown.setAttribute("role", "listbox");
86
+ const e = this.view.dom.closest(".md-editor-root"), t = (e == null ? void 0 : e.getAttribute("data-theme")) ?? "light";
87
+ this.dropdown.setAttribute("data-theme", t), document.body.appendChild(this.dropdown);
88
+ }
89
+ this.renderDropdown(), this.positionDropdown();
90
+ }
84
91
  }
85
92
  renderDropdown() {
86
93
  this.dropdown && (this.dropdown.innerHTML = "", this.items.forEach((e, t) => {
@@ -203,7 +210,14 @@ class Xt {
203
210
  }
204
211
  }
205
212
  show() {
206
- this.trigger && (this.dropdown || (this.dropdown = document.createElement("div"), this.dropdown.className = "md-editor-doclink-dropdown", this.dropdown.setAttribute("role", "listbox"), (this.view.dom.closest(".md-editor-root") ?? document.body).appendChild(this.dropdown)), this.renderDropdown(), this.positionDropdown());
213
+ if (this.trigger) {
214
+ if (!this.dropdown) {
215
+ this.dropdown = document.createElement("div"), this.dropdown.className = "md-editor-doclink-dropdown", this.dropdown.setAttribute("role", "listbox");
216
+ const e = this.view.dom.closest(".md-editor-root"), t = (e == null ? void 0 : e.getAttribute("data-theme")) ?? "light";
217
+ this.dropdown.setAttribute("data-theme", t), document.body.appendChild(this.dropdown);
218
+ }
219
+ this.renderDropdown(), this.positionDropdown();
220
+ }
207
221
  }
208
222
  renderDropdown() {
209
223
  this.dropdown && (this.dropdown.innerHTML = "", this.items.forEach((e, t) => {
@@ -7923,7 +7937,7 @@ class Ui {
7923
7937
  for (const t of e) {
7924
7938
  const i = document.createElement("button");
7925
7939
  if (i.type = "button", i.className = "md-editor-toolbar-btn", t.toggle && i.classList.add("is-toggle"), t.active && i.classList.add("is-active"), i.title = t.title, i.setAttribute("aria-label", t.title), i.setAttribute("data-action", t.name), i.innerHTML = t.icon, i.addEventListener("mousedown", (r) => {
7926
- r.preventDefault(), t.handler(i);
7940
+ r.preventDefault(), r.stopPropagation(), t.handler(i);
7927
7941
  }), this.buttons.set(t.name, i), this.el.appendChild(i), t.groupEnd) {
7928
7942
  const r = document.createElement("span");
7929
7943
  r.className = "md-editor-toolbar-sep", this.el.appendChild(r);
@@ -8137,7 +8151,8 @@ const L = (n) => `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xm
8137
8151
  class ie {
8138
8152
  constructor(e, t) {
8139
8153
  this.inputs = /* @__PURE__ */ new Map(), this.destroyed = !1, this.anchor = e, this.config = t, this.el = document.createElement("div"), this.el.className = "md-editor-popup", this.el.setAttribute("role", "dialog"), this.el.setAttribute("aria-label", t.title), t.theme && this.el.setAttribute("data-theme", t.theme), this.build(), this.onOutsideClick = (i) => {
8140
- !this.el.contains(i.target) && i.target !== this.anchor && this.hide();
8154
+ const r = i.target;
8155
+ !this.el.contains(r) && !this.anchor.contains(r) && this.hide();
8141
8156
  }, this.onKeyDown = (i) => {
8142
8157
  i.key === "Escape" && this.hide();
8143
8158
  };
@@ -8516,12 +8531,27 @@ ${r}
8516
8531
  onSubmit: () => {
8517
8532
  }
8518
8533
  }), i = t.el.querySelector(".md-editor-popup-body");
8519
- i && (i.innerHTML = '<div class="md-editor-help-list">' + this.shortcuts.map(
8520
- (s) => `<div class="md-editor-help-row">
8521
- <span class="md-editor-help-desc">${s.description}</span>
8522
- <span class="md-editor-help-keys">${Xi(s.key)}</span>
8534
+ if (i) {
8535
+ const s = [
8536
+ { label: "Task list", hint: "- [ ] unchecked / - [x] checked" },
8537
+ { label: "@mention", hint: "Type @ then pick a user from the dropdown" },
8538
+ { label: "Document link", hint: "Type / then pick a document" },
8539
+ { label: "Math formula", hint: "$E=mc^2$ inline / $$ block $$" },
8540
+ { label: "Mindmap", hint: "```mindmap fenced block with # headings" },
8541
+ { label: "Callout", hint: ":::warning Title ...content... :::" }
8542
+ ];
8543
+ i.innerHTML = '<div class="md-editor-help-list">' + this.shortcuts.map(
8544
+ (o) => `<div class="md-editor-help-row">
8545
+ <span class="md-editor-help-desc">${o.description}</span>
8546
+ <span class="md-editor-help-keys">${Xi(o.key)}</span>
8547
+ </div>`
8548
+ ).join("") + '</div><div class="md-editor-help-section-title">Syntax</div><div class="md-editor-help-list">' + s.map(
8549
+ (o) => `<div class="md-editor-help-row">
8550
+ <span class="md-editor-help-desc">${o.label}</span>
8551
+ <span class="md-editor-help-syntax">${o.hint}</span>
8523
8552
  </div>`
8524
- ).join("") + "</div>");
8553
+ ).join("") + "</div>";
8554
+ }
8525
8555
  const r = t.el.querySelector(".md-editor-popup-footer");
8526
8556
  r && r.remove(), this.activePopup = t, this.activePopup.show();
8527
8557
  }