@powerduck/md-editor 0.7.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/README.md CHANGED
@@ -22,6 +22,7 @@ High-performance embeddable Markdown editor built on the markdown-it ecosystem.
22
22
  - **Simple / Complex modes** -- toggle toolbar and status bar at runtime
23
23
  - **Light / Dark themes** -- CSS custom properties, inherits host design tokens
24
24
  - **React component** -- `forwardRef` with imperative handle
25
+ - **Zero Chinese** -- all code, comments, and UI strings in American English
25
26
 
26
27
  ## Installation
27
28
 
@@ -246,6 +247,42 @@ npm run build # vite build + d.ts generation
246
247
 
247
248
  ## Changelog
248
249
 
250
+ ### v0.8.2
251
+
252
+ - **Fixed**: @mention and `/` doc-link dropdowns did not appear. Root cause: v0.8.1 mounted dropdowns inside `.md-editor-root` where ancestor `overflow:hidden` / stacking contexts could clip or misplace `position:fixed` elements. Reverted to `document.body` mounting with `position:fixed`, and added explicit light/dark colors via `data-theme` attribute (no dependency on editor-scoped CSS variables).
253
+ - **Fixed**: Clicking toolbar button icons (SVG) did not open popups. Root cause: `mousedown` event bubbled to `document` and triggered the newly-opened Popup's outside-click handler (because `e.target` was the SVG, not the button). Fixed in two ways: Popup now uses `anchor.contains(target)` instead of `target !== anchor`; toolbar `mousedown` handler calls `e.stopPropagation()`.
254
+ - **Fixed**: Task list checkboxes now render with a clear green checkmark when checked (`- [x]` or `- [X]`). Previously used native `accent-color` (orange) which was hard to distinguish in disabled state. Custom checkbox: gray border when unchecked, solid green with white checkmark when checked.
255
+ - **Added**: Help dialog now includes a "Syntax" section with quick-reference guidance for task lists, @mentions, document links, math, mindmaps, and callouts.
256
+ - **Fixed**: Help dialog and all popup-internal styles no longer use editor-scoped CSS variables (undefined when popup is on `document.body`), ensuring consistent light/dark rendering.
257
+ - **Test**: 310 tests, all passing, zero unhandled errors.
258
+
259
+ ### v0.8.1
260
+
261
+ - **Fixed**: Toolbar buttons now use `mousedown` + `preventDefault` instead of `click`, preventing the editor from losing focus and collapsing the selection before wrap operations. This fixes the long-standing issue where selecting text and clicking quote/list/other toolbar buttons replaced the selection with placeholder text ("quoted text", "list item").
262
+ - **Fixed**: `toggleTaskList()` mixed-state logic. Previously, a mix of checked and unchecked items (or all-unchecked) removed all task markers. Now: mixed or all-unchecked → check all; all-checked → uncheck all. Also supports uppercase `[X]` markers.
263
+ - **Fixed**: Code block copy button now falls back to `document.execCommand('copy')` when `navigator.clipboard` is unavailable (non-HTTPS contexts), instead of silently failing.
264
+ - **Fixed**: @mention and doc-link dropdowns now close when the editor loses focus (blur), with a 150ms delay so clicks on the dropdown itself register first.
265
+ - **Fixed**: @mention and doc-link dropdowns had transparent backgrounds because they used editor-scoped CSS variables (`--_surface`) while being appended to `document.body`. Now appended inside `.md-editor-root` with `position: fixed` (not clipped by `overflow: hidden`), so theme variables resolve correctly.
266
+ - **Fixed**: Popup dialogs (image, video, YouTube, table, help, callout) now respect the editor theme. Previously always light-themed; now dark-themed when the editor is in dark mode.
267
+ - **Test**: 310 tests, all passing, zero unhandled errors.
268
+
269
+ ### v0.8.0
270
+
271
+ - **Added**: Document/article link inserter. Type `/` to open a searchable dropdown of documents. `onDocSearch(query)` returns matching documents; on selection, inserts either a plain markdown link or a `:::doc-link` preview card.
272
+ - **Added**: `:::doc-link` preview card rendering — displays title, thumbnail, description, and domain as a clickable card. Auto-fetches Open Graph / meta tags via `onFetchDocMeta(url)` hook; falls back to plain link when metadata is unavailable or fetch fails.
273
+ - **Added**: `insertStyle` option: `'auto'` (default, card when meta available), `'card'` (always card, fallback to link), `'link'` (always plain link).
274
+ - **Added**: `docLink` option to `MarkdownEditorOptions` and `CodeEditorOptions`, with `triggerChar`, `minChars`, `maxItems` configuration.
275
+ - **Added**: Toolbar button for document link insertion.
276
+ - **Test**: 307 tests, all passing, zero unhandled errors.
277
+
278
+ ### v0.7.0
279
+
280
+ - **Fixed**: Mindmap nested code fences no longer lose content. Custom block rule tracks fence nesting depth (lines with info string open, bare backticks close), so ` ```js ` inside a ` ```mindmap ` block is preserved.
281
+ - **Added**: Task list (checkbox) toolbar button and `toggleTaskList()` API. Toggles `- [ ]` / `- [x]` on current line or selected lines. Renders as checkboxes in preview. Keyboard shortcut: `Ctrl+Shift+9`.
282
+ - **Added**: @mention dropdown with configurable hooks. `onMentionSearch(query)` returns matching items, `onMentionSelect(item)` returns replacement text. Supports keyboard navigation (ArrowUp/Down, Enter, Escape), avatars, descriptions, `minChars`, and `maxItems` options.
283
+ - **Added**: `mention` option to `MarkdownEditorOptions` and `CodeEditorOptions`.
284
+ - **Test**: 281 tests, all passing, zero unhandled errors.
285
+
249
286
  ### v0.6.0
250
287
 
251
288
  - **Fixed**: Mindmap `transform: translate(NaN,NaN) scale(NaN)` console errors (hundreds per mindmap). Root cause: `autoFit: true` computed transform on zero-size SVG before layout, and d3-zoom scheduled hundreds of animation frames each throwing "Expected number". Fix: create with `autoFit: false`, set safe default transform immediately, defer `fit()` to next animation frame with dimension guard.
package/dist/Editor.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { EditorView } from '@codemirror/view';
2
+ import { type MentionOptions } from './plugins/mention.js';
3
+ import { type DocLinkOptions } from './plugins/doclink.js';
2
4
  export interface CodeEditorOptions {
3
5
  value: string;
4
6
  onChange?: (value: string) => void;
@@ -7,12 +9,18 @@ export interface CodeEditorOptions {
7
9
  placeholder?: string;
8
10
  /** Called when an image file is pasted or dropped into the editor. */
9
11
  onImageFile?: (file: File) => void;
12
+ /** @mention dropdown configuration */
13
+ mention?: MentionOptions;
14
+ /** Document link inserter configuration */
15
+ docLink?: DocLinkOptions;
10
16
  }
11
17
  export declare class CodeEditor {
12
18
  readonly view: EditorView;
13
19
  private lineNumbersCompartment;
14
20
  private customKeymapCompartment;
15
21
  private onImageFile?;
22
+ private mention;
23
+ private docLink;
16
24
  constructor(container: HTMLElement, options: CodeEditorOptions);
17
25
  private handlePaste;
18
26
  private handleDrop;
@@ -41,5 +49,17 @@ export declare class CodeEditor {
41
49
  */
42
50
  wrapLines(prefix: string, placeholder: string): void;
43
51
  focus(): void;
52
+ /** Insert @ at cursor and trigger the mention dropdown. */
53
+ insertMention(): void;
54
+ /** Insert trigger char at cursor and trigger the doc-link search dropdown. */
55
+ insertDocLink(): void;
56
+ /**
57
+ * Toggle task list (checkbox) markers on the current line or selected
58
+ * lines. If a line already has `- [ ]` or `- [x]`, the marker is removed.
59
+ * If a line has `- ` (plain list), it is converted to `- [ ] `. Otherwise
60
+ * `- [ ] ` is prepended. Lines with `- [x]` are toggled to `- [ ]` and
61
+ * vice versa when all selected lines are task items.
62
+ */
63
+ toggleTaskList(): void;
44
64
  destroy(): void;
45
65
  }
package/dist/icons.d.ts CHANGED
@@ -10,6 +10,9 @@ export declare const icons: {
10
10
  readonly quote: string;
11
11
  readonly list: string;
12
12
  readonly listOrdered: string;
13
+ readonly taskList: string;
14
+ readonly mention: string;
15
+ readonly fileText: string;
13
16
  readonly table: string;
14
17
  readonly hr: string;
15
18
  readonly alert: string;