@powerduck/md-editor 0.7.0 → 0.8.1
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 +27 -0
- package/dist/Editor.d.ts +20 -0
- package/dist/icons.d.ts +3 -0
- package/dist/index.cjs +21 -16
- package/dist/index.d.ts +17 -0
- package/dist/index.mjs +2184 -1695
- package/dist/plugins/doclink.d.ts +98 -0
- package/dist/plugins/mention.d.ts +69 -0
- package/dist/plugins/mindmap.d.ts +7 -0
- package/dist/plugins/popup.d.ts +1 -0
- package/dist/plugins/tasklist.d.ts +7 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -247,6 +247,33 @@ npm run build # vite build + d.ts generation
|
|
|
247
247
|
|
|
248
248
|
## Changelog
|
|
249
249
|
|
|
250
|
+
### v0.8.1
|
|
251
|
+
|
|
252
|
+
- **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").
|
|
253
|
+
- **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.
|
|
254
|
+
- **Fixed**: Code block copy button now falls back to `document.execCommand('copy')` when `navigator.clipboard` is unavailable (non-HTTPS contexts), instead of silently failing.
|
|
255
|
+
- **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.
|
|
256
|
+
- **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.
|
|
257
|
+
- **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.
|
|
258
|
+
- **Test**: 310 tests, all passing, zero unhandled errors.
|
|
259
|
+
|
|
260
|
+
### v0.8.0
|
|
261
|
+
|
|
262
|
+
- **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.
|
|
263
|
+
- **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.
|
|
264
|
+
- **Added**: `insertStyle` option: `'auto'` (default, card when meta available), `'card'` (always card, fallback to link), `'link'` (always plain link).
|
|
265
|
+
- **Added**: `docLink` option to `MarkdownEditorOptions` and `CodeEditorOptions`, with `triggerChar`, `minChars`, `maxItems` configuration.
|
|
266
|
+
- **Added**: Toolbar button for document link insertion.
|
|
267
|
+
- **Test**: 307 tests, all passing, zero unhandled errors.
|
|
268
|
+
|
|
269
|
+
### v0.7.0
|
|
270
|
+
|
|
271
|
+
- **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.
|
|
272
|
+
- **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`.
|
|
273
|
+
- **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.
|
|
274
|
+
- **Added**: `mention` option to `MarkdownEditorOptions` and `CodeEditorOptions`.
|
|
275
|
+
- **Test**: 281 tests, all passing, zero unhandled errors.
|
|
276
|
+
|
|
250
277
|
### v0.6.0
|
|
251
278
|
|
|
252
279
|
- **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;
|