@meowdown/react 0.18.0 → 0.20.0

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
@@ -42,7 +42,7 @@ The Markdown editor component. Renders inside a `div.meowdown` wrapper that fill
42
42
  - `initialMarkdown?: string`: first render only.
43
43
  - `onDocChange?: VoidFunction`: called on every user-driven document change. Programmatic `setMarkdown` / `setState` on the handle do not fire it.
44
44
  - `onTagSearch?: (query: string) => TagItem[] | Promise<TagItem[]>`: enables the tag menu, which opens when typing `#` followed by text in a rich mode. Returns ranked rows `{ tag, label?, detail?, onSelect? }` (the menu does not re-sort). Selecting a row inserts `#tag ` then runs its `onSelect`. Omit to disable.
45
- - `onWikilinkSearch?: (query: string) => WikilinkItem[] | Promise<WikilinkItem[]>`: enables the wikilink menu, which opens as soon as `[[` is typed in a rich mode. Returns ranked rows `{ target, label?, detail?, onSelect? }` (the menu does not re-sort). Selecting a row inserts `[[target]]` then runs its `onSelect`. Omit to disable.
45
+ - `onWikilinkSearch?: (query: string) => WikilinkItem[] | Promise<WikilinkItem[]>`: enables the wikilink menu, which opens as soon as `[[` or `@` is typed in a rich mode. Returns ranked rows `{ target, label?, detail?, onSelect? }` (the menu does not re-sort). Selecting a row inserts `[[target]]` then runs its `onSelect`. Omit to disable.
46
46
  - `onWikilinkClick?: (payload: { target: string; event: MouseEvent }) => void`: called when a rendered wiki link is clicked. A plain click inside a link the caret already sits in just places the caret; `Mod`-click always fires. Pass a stable function (e.g. from `useCallback`). Ignored in source mode.
47
47
  - `onLinkClick?: (payload: { href: string; event: MouseEvent }) => void`: called with its `href` when a rendered Markdown link (`[text](url)`) is clicked. A plain click inside a link the caret already sits in just places the caret; `Mod`-click always fires. Pass a stable function (e.g. from `useCallback`). Ignored in source mode.
48
48
  - `resolveImageUrl?: (src: string) => string | undefined`: maps an image `src` to a displayable URL (or `undefined` to skip). Enables inline image rendering: `![alt](src)` stays literal text and the image renders beneath its line. Pass a stable function. Ignored in source mode.
package/dist/index.d.ts CHANGED
@@ -71,8 +71,8 @@ interface WikilinkItem {
71
71
  }
72
72
  /**
73
73
  * Searches notes for the wikilink menu. Receives the query typed after
74
- * `[[` (lowercased, punctuation stripped, may be empty or contain spaces)
75
- * and returns the rows to show, either synchronously or as a promise.
74
+ * `[[` or `@` (lowercased, punctuation stripped, may be empty or contain
75
+ * spaces) and returns the rows to show, either synchronously or as a promise.
76
76
  */
77
77
  type WikilinkSearchHandler = (query: string) => WikilinkItem[] | Promise<WikilinkItem[]>;
78
78
  //#endregion
@@ -105,8 +105,8 @@ interface EditorProps {
105
105
  */
106
106
  onTagSearch?: TagSearchHandler;
107
107
  /**
108
- * Searches notes for the wikilink menu, which opens as soon as `[[` is
109
- * typed in a rich mode. Receives the query (lowercased, punctuation
108
+ * Searches notes for the wikilink menu, which opens as soon as `[[` or `@`
109
+ * is typed in a rich mode. Receives the query (lowercased, punctuation
110
110
  * stripped, may be empty) and returns the note names to show,
111
111
  * synchronously or as a promise. Pass a stable function (e.g. from
112
112
  * `useCallback`). Omit to disable the wikilink menu. Ignored in source
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { Compartment, EditorSelection, EditorState } from "@codemirror/state";
7
7
  import { EditorView, keymap } from "@codemirror/view";
8
8
  import { clamp } from "@ocavue/utils";
9
9
  import { jsx, jsxs } from "react/jsx-runtime";
10
- import { codeBlockLanguages, defineBulletAfterHeading, defineEditorExtension, defineEmbedPaste, defineImage, defineImageClickHandler, defineLinkClickHandler, defineMarkMode, definePlaceholder, defineReadonly, defineWikilinkClickHandler, docToMarkdown, markdownToDoc } from "@meowdown/core";
10
+ import { codeBlockLanguages, defineBulletAfterHeading, defineEditorExtension, defineEmbedPaste, defineHTMLPaste, defineImage, defineImageClickHandler, defineLinkClickHandler, defineMarkMode, defineMarkdownCopy, definePlaceholder, defineReadonly, defineWikilinkClickHandler, docToMarkdown, markdownToDoc } from "@meowdown/core";
11
11
  import { canUseRegexLookbehind, createEditor, defineDocChangeHandler, union } from "@prosekit/core";
12
12
  import { Selection, TextSelection } from "@prosekit/pm/state";
13
13
  import { ProseKit, defineReactNodeView, useEditor, useEditor as useEditor$1, useEditorDerivedValue, useExtension, useExtension as useExtension$1, useKeymap } from "@prosekit/react";
@@ -352,6 +352,8 @@ function EditorExtensions({ markMode, onDocChange, onWikilinkClick, onLinkClick,
352
352
  useExtension$1(useMemo(() => {
353
353
  return embedPaste ? defineEmbedPaste() : null;
354
354
  }, [embedPaste]));
355
+ useExtension$1(useMemo(() => defineHTMLPaste(), []));
356
+ useExtension$1(useMemo(() => defineMarkdownCopy(), []));
355
357
  useExtension$1(useMemo(() => {
356
358
  return bulletAfterHeading ? defineBulletAfterHeading() : null;
357
359
  }, [bulletAfterHeading]));
@@ -693,7 +695,7 @@ function TagMenu({ onTagSearch }) {
693
695
 
694
696
  //#endregion
695
697
  //#region src/components/wikilink-menu.tsx
696
- const regex = /\[\[[^[\]]*$/u;
698
+ const regex = canUseRegexLookbehind() ? /(?:\[\[[^[\]]*|(?<!\S)@(?:[^[\]\s][^[\]]*)?)$/u : /(?:\[\[[^[\]]*|@(?:[^[\]\s][^[\]]*)?)$/u;
697
699
  function WikilinkMenu({ onWikilinkSearch }) {
698
700
  const editor = useEditor$1();
699
701
  const [open, setOpen] = useState(false);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meowdown/react",
3
3
  "type": "module",
4
- "version": "0.18.0",
4
+ "version": "0.20.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -30,7 +30,7 @@
30
30
  "@prosekit/react": "^0.8.0-beta.9",
31
31
  "clsx": "^2.1.1",
32
32
  "lucide-react": "^1.21.0",
33
- "@meowdown/core": "0.18.0"
33
+ "@meowdown/core": "0.20.0"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": "^19.0.0",