@powerduck/md-editor 0.11.6 → 0.11.8

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/README.md CHANGED
@@ -83,7 +83,7 @@ const html = editor.getHtml();
83
83
 
84
84
  - [Official Website](https://www.powerduck.com/opensource/md-editor.html)
85
85
  - [Documentation](https://www.powerduck.com/docs/md-editor/introduction)
86
- - [Live Demo](https://www.powerduck.com/demo/md-editor)
86
+ - [Live Demo](https://www.powerduck.com/demo/)
87
87
  - [GitHub](https://github.com/powerducklab/md-editor)
88
88
  - [npm](https://www.npmjs.com/package/@powerduck/md-editor)
89
89
 
@@ -182,8 +182,8 @@ new MarkdownEditor("#editor", {
182
182
  | `preview` | `boolean` | `true` | Show preview pane |
183
183
  | `autoPreview` | `boolean` | `true` | Auto-update preview |
184
184
  | `renderDebounce` | `number` | `200` | Preview render debounce in ms |
185
- | `mention` | `MentionConfig` | - | @mention configuration |
186
- | `docLink` | `DocLinkConfig` | - | Document link card configuration |
185
+ | `mention` | `MentionOptions` | - | @mention configuration |
186
+ | `docLink` | `DocLinkOptions` | - | Document link card configuration |
187
187
 
188
188
  ### Imperative Handle (React)
189
189
 
@@ -193,15 +193,16 @@ interface MarkdownEditorHandle {
193
193
  setValue(value: string): void;
194
194
  getHtml(): string;
195
195
  focus(): void;
196
- blur(): void;
197
- clear(): void;
196
+ setMode(mode: EditorMode): void;
197
+ setTheme(theme: EditorTheme): void;
198
+ renderNow(): void;
198
199
  }
199
200
  ```
200
201
 
201
- ### MentionConfig
202
+ ### MentionOptions
202
203
 
203
204
  ```typescript
204
- interface MentionConfig {
205
+ interface MentionOptions {
205
206
  onMentionSearch: (query: string) => MentionItem[] | Promise<MentionItem[]>;
206
207
  onMentionSelect?: (item: MentionItem) => string;
207
208
  minChars?: number;
@@ -210,10 +211,10 @@ interface MentionConfig {
210
211
  }
211
212
  ```
212
213
 
213
- ### DocLinkConfig
214
+ ### DocLinkOptions
214
215
 
215
216
  ```typescript
216
- interface DocLinkConfig {
217
+ interface DocLinkOptions {
217
218
  onDocSearch: (query: string) => DocItem[] | Promise<DocItem[]>;
218
219
  onFetchDocMeta?: (url: string) => Promise<DocMeta>;
219
220
  insertStyle?: "card" | "link" | "auto";
@@ -232,11 +233,13 @@ import type {
232
233
  MentionItem,
233
234
  DocItem,
234
235
  DocMeta,
235
- MentionConfig,
236
- DocLinkConfig,
236
+ MentionOptions,
237
+ DocLinkOptions,
238
+ } from "@powerduck/md-editor";
239
+ import type {
237
240
  MarkdownEditorHandle,
238
241
  MarkdownEditorProps,
239
- } from "@powerduck/md-editor";
242
+ } from "@powerduck/md-editor/react";
240
243
  ```
241
244
 
242
245
  ---
package/dist/index.cjs CHANGED
@@ -36,7 +36,7 @@ ${r}
36
36
  </div>`).join("")+'</div><div class="md-editor-help-section-title">Syntax</div><div class="md-editor-help-list">'+s.map(o=>`<div class="md-editor-help-row">
37
37
  <span class="md-editor-help-desc">${o.label}</span>
38
38
  <span class="md-editor-help-syntax">${o.hint}</span>
39
- </div>`).join("")+"</div>"}const r=t.el.querySelector(".md-editor-popup-footer");r&&(r.innerHTML='<span class="md-editor-help-brand-text">PowerDuck Markdown Editor</span><a href="https://www.powerduck.com" target="_blank" rel="noopener noreferrer" class="md-editor-help-link">powerduck.com</a>',r.style.justifyContent="space-between",r.style.alignItems="center"),this.activePopup=t,this.activePopup.show()}async handleImageFile(e){if(this.onImageUpload)try{const t=await this.onImageUpload(e);t&&this.codeEditor.insertAtCursor(Re(t,e.name.replace(/\.[^.]+$/,"")||"image"))}catch{}}showTipsPopup(e){var s;(s=this.activePopup)==null||s.destroy();const t=[{key:"notice",label:"Notice",color:"#0969da"},{key:"info",label:"Info",color:"#0969da"},{key:"tip",label:"Tip",color:"#1a7f37"},{key:"success",label:"Success",color:"#1a7f37"},{key:"warning",label:"Warning",color:"#9a6700"},{key:"danger",label:"Danger",color:"#cf222e"}],i=new X(e,{title:"Insert callout",theme:this.theme,fields:[],onSubmit:()=>{}}),r=i.el.querySelector(".md-editor-popup-body");if(r){const o=document.createElement("div");o.className="md-editor-tips-grid";for(const c of t){const l=document.createElement("button");l.type="button",l.className="md-editor-tips-option",l.innerHTML=`<span class="md-editor-tips-dot" style="background:${c.color}"></span><span>${c.label}</span>`,l.addEventListener("click",()=>{this.codeEditor.insertAtCursor(`:::${c.key} ${c.label}
39
+ </div>`).join("")+"</div>"}const r=t.el.querySelector(".md-editor-popup-footer");r&&(r.innerHTML='<span class="md-editor-help-brand-text">Powerduck Markdown Editor</span><a href="https://www.powerduck.com" target="_blank" rel="noopener noreferrer" class="md-editor-help-link">powerduck.com</a>',r.style.justifyContent="space-between",r.style.alignItems="center"),this.activePopup=t,this.activePopup.show()}async handleImageFile(e){if(this.onImageUpload)try{const t=await this.onImageUpload(e);t&&this.codeEditor.insertAtCursor(Re(t,e.name.replace(/\.[^.]+$/,"")||"image"))}catch{}}showTipsPopup(e){var s;(s=this.activePopup)==null||s.destroy();const t=[{key:"notice",label:"Notice",color:"#0969da"},{key:"info",label:"Info",color:"#0969da"},{key:"tip",label:"Tip",color:"#1a7f37"},{key:"success",label:"Success",color:"#1a7f37"},{key:"warning",label:"Warning",color:"#9a6700"},{key:"danger",label:"Danger",color:"#cf222e"}],i=new X(e,{title:"Insert callout",theme:this.theme,fields:[],onSubmit:()=>{}}),r=i.el.querySelector(".md-editor-popup-body");if(r){const o=document.createElement("div");o.className="md-editor-tips-grid";for(const c of t){const l=document.createElement("button");l.type="button",l.className="md-editor-tips-option",l.innerHTML=`<span class="md-editor-tips-dot" style="background:${c.color}"></span><span>${c.label}</span>`,l.addEventListener("click",()=>{this.codeEditor.insertAtCursor(`:::${c.key} ${c.label}
40
40
 
41
41
  Your ${c.key.toLowerCase()} content here.
42
42
 
package/dist/index.mjs CHANGED
@@ -8823,7 +8823,7 @@ ${r}
8823
8823
  ).join("") + "</div>";
8824
8824
  }
8825
8825
  const r = t.el.querySelector(".md-editor-popup-footer");
8826
- r && (r.innerHTML = '<span class="md-editor-help-brand-text">PowerDuck Markdown Editor</span><a href="https://www.powerduck.com" target="_blank" rel="noopener noreferrer" class="md-editor-help-link">powerduck.com</a>', r.style.justifyContent = "space-between", r.style.alignItems = "center"), this.activePopup = t, this.activePopup.show();
8826
+ r && (r.innerHTML = '<span class="md-editor-help-brand-text">Powerduck Markdown Editor</span><a href="https://www.powerduck.com" target="_blank" rel="noopener noreferrer" class="md-editor-help-link">powerduck.com</a>', r.style.justifyContent = "space-between", r.style.alignItems = "center"), this.activePopup = t, this.activePopup.show();
8827
8827
  }
8828
8828
  // ---------- Image upload ----------
8829
8829
  async handleImageFile(e) {