@meowdown/react 0.55.1 → 0.57.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 +2 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +17 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -58,6 +58,8 @@ Slash menu host items can include `keywords` to match hidden terms without chang
|
|
|
58
58
|
|
|
59
59
|
The caret glides between positions by default; pass `caretGlide={false}` to move it instantly (hosts can also tune the duration via the `--meowdown-caret-glide` CSS variable).
|
|
60
60
|
|
|
61
|
+
`MarkdownView` folds collapsed (`+`) bullets like the editor; pass `expandCollapsed` to render them expanded at every depth, for views that show slices of a note (e.g. a backlinks panel) where the source's fold state must not hide the content the view exists to show.
|
|
62
|
+
|
|
61
63
|
### Wiki embeds
|
|
62
64
|
|
|
63
65
|
Obsidian-style wiki embeds (`![[path]]`, with optional `|width` or
|
package/dist/index.d.ts
CHANGED
|
@@ -444,6 +444,13 @@ interface MarkdownViewProps {
|
|
|
444
444
|
* YouTube embeds are omitted before any image resolver runs.
|
|
445
445
|
*/
|
|
446
446
|
interactive?: boolean;
|
|
447
|
+
/**
|
|
448
|
+
* Render collapsed (`+`) bullets expanded, ignoring their fold state at any
|
|
449
|
+
* depth. Off by default. For views that show slices of a note (e.g. a
|
|
450
|
+
* backlinks panel), where the source's fold state must not hide the content
|
|
451
|
+
* the view exists to show.
|
|
452
|
+
*/
|
|
453
|
+
expandCollapsed?: boolean;
|
|
447
454
|
/** Map an image `src` to a displayable URL, or `undefined` to skip it. */
|
|
448
455
|
resolveImageUrl?: (src: string) => string | undefined;
|
|
449
456
|
/**
|
|
@@ -479,7 +486,7 @@ interface MarkdownViewProps {
|
|
|
479
486
|
* Callbacks (`onWikilinkClick`, etc.) and resolvers should be stable; pass them via
|
|
480
487
|
* `useCallback` to avoid re-rendering the whole tree.
|
|
481
488
|
*/
|
|
482
|
-
declare function MarkdownView({ markdown, markMode, frontmatter, interactive, resolveImageUrl, resolveFileLink, resolveWikiEmbed, resolveFileInfo, onWikilinkClick, onLinkClick, onImageClick, onFileClick, onTaskClick, className }: MarkdownViewProps): ReactElement;
|
|
489
|
+
declare function MarkdownView({ markdown, markMode, frontmatter, interactive, expandCollapsed, resolveImageUrl, resolveFileLink, resolveWikiEmbed, resolveFileInfo, onWikilinkClick, onLinkClick, onImageClick, onFileClick, onTaskClick, className }: MarkdownViewProps): ReactElement;
|
|
483
490
|
//#endregion
|
|
484
491
|
//#region src/components/wikilink-hover-card.d.ts
|
|
485
492
|
/** Props for {@link WikilinkHoverCard}. */
|
package/dist/index.js
CHANGED
|
@@ -1708,7 +1708,7 @@ function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onSl
|
|
|
1708
1708
|
function getState() {
|
|
1709
1709
|
return [getMarkdown(), getSelection()];
|
|
1710
1710
|
}
|
|
1711
|
-
function replaceState(markdown, selection, addToHistory = true) {
|
|
1711
|
+
function replaceState(markdown, selection, addToHistory = true, forceMarkdown = false) {
|
|
1712
1712
|
if (markdown == null && !selection) return;
|
|
1713
1713
|
const transaction = editor.state.tr;
|
|
1714
1714
|
if (markdown != null) {
|
|
@@ -1716,7 +1716,10 @@ function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onSl
|
|
|
1716
1716
|
nodes: editor.nodes,
|
|
1717
1717
|
frontmatter
|
|
1718
1718
|
});
|
|
1719
|
-
|
|
1719
|
+
const currentMarkdown = docToMarkdown(transaction.doc, { frontmatter });
|
|
1720
|
+
const nextMarkdown = docToMarkdown(doc, { frontmatter });
|
|
1721
|
+
if (forceMarkdown || currentMarkdown !== nextMarkdown) transaction.replaceWith(0, transaction.doc.content.size, doc.content);
|
|
1722
|
+
else if (!selection) return;
|
|
1720
1723
|
}
|
|
1721
1724
|
if (selection) transaction.setSelection(resolveSelection(transaction.doc, selection)).scrollIntoView();
|
|
1722
1725
|
if (!addToHistory) transaction.setMeta("addToHistory", false);
|
|
@@ -1735,7 +1738,7 @@ function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onSl
|
|
|
1735
1738
|
}
|
|
1736
1739
|
function refreshMarkdownRendering() {
|
|
1737
1740
|
const [markdown, selection] = getState();
|
|
1738
|
-
replaceState(markdown, selection, false);
|
|
1741
|
+
replaceState(markdown, selection, false, true);
|
|
1739
1742
|
}
|
|
1740
1743
|
function insertMarkdown(markdown) {
|
|
1741
1744
|
editor.commands.insertMarkdown(markdown);
|
|
@@ -2455,7 +2458,14 @@ function renderBlock(node, context) {
|
|
|
2455
2458
|
const typeName = node.type.name;
|
|
2456
2459
|
let handleTaskClick;
|
|
2457
2460
|
if (typeName === "list") {
|
|
2458
|
-
|
|
2461
|
+
let attrs = node.attrs;
|
|
2462
|
+
if (context.expandCollapsed && attrs.collapsed) {
|
|
2463
|
+
attrs = {
|
|
2464
|
+
...attrs,
|
|
2465
|
+
collapsed: false
|
|
2466
|
+
};
|
|
2467
|
+
node = node.type.create(attrs, node.content, node.marks);
|
|
2468
|
+
}
|
|
2459
2469
|
const { onTaskClick } = context;
|
|
2460
2470
|
if (attrs.kind === "task" && onTaskClick) {
|
|
2461
2471
|
const index = context.taskCounter.value++;
|
|
@@ -2505,11 +2515,12 @@ function renderBlock(node, context) {
|
|
|
2505
2515
|
* Callbacks (`onWikilinkClick`, etc.) and resolvers should be stable; pass them via
|
|
2506
2516
|
* `useCallback` to avoid re-rendering the whole tree.
|
|
2507
2517
|
*/
|
|
2508
|
-
function MarkdownView({ markdown, markMode = "hide", frontmatter = false, interactive = true, resolveImageUrl, resolveFileLink, resolveWikiEmbed, resolveFileInfo, onWikilinkClick, onLinkClick, onImageClick, onFileClick, onTaskClick, className }) {
|
|
2518
|
+
function MarkdownView({ markdown, markMode = "hide", frontmatter = false, interactive = true, expandCollapsed = false, resolveImageUrl, resolveFileLink, resolveWikiEmbed, resolveFileInfo, onWikilinkClick, onLinkClick, onImageClick, onFileClick, onTaskClick, className }) {
|
|
2509
2519
|
const content = useMemo(() => {
|
|
2510
2520
|
const doc = markdownToDoc(markdown, { frontmatter });
|
|
2511
2521
|
const context = {
|
|
2512
2522
|
interactive,
|
|
2523
|
+
expandCollapsed,
|
|
2513
2524
|
resolveImageUrl,
|
|
2514
2525
|
resolveFileLink,
|
|
2515
2526
|
resolveWikiEmbed,
|
|
@@ -2527,6 +2538,7 @@ function MarkdownView({ markdown, markMode = "hide", frontmatter = false, intera
|
|
|
2527
2538
|
markdown,
|
|
2528
2539
|
frontmatter,
|
|
2529
2540
|
interactive,
|
|
2541
|
+
expandCollapsed,
|
|
2530
2542
|
resolveImageUrl,
|
|
2531
2543
|
resolveFileLink,
|
|
2532
2544
|
resolveWikiEmbed,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.57.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"@ocavue/utils": "^1.7.0",
|
|
26
26
|
"@prosekit/core": "^0.13.0-beta.6",
|
|
27
27
|
"@prosekit/pm": "^0.1.19-beta.3",
|
|
28
|
-
"@prosekit/react": "^0.8.0-beta.
|
|
28
|
+
"@prosekit/react": "^0.8.0-beta.22",
|
|
29
29
|
"beautiful-mermaid": "^1.1.3",
|
|
30
30
|
"clsx": "^2.1.1",
|
|
31
31
|
"github-slugger": "^2.0.0",
|
|
32
32
|
"lucide-react": "^1.24.0",
|
|
33
33
|
"react-property": "^2.0.2",
|
|
34
|
-
"@meowdown/core": "0.
|
|
34
|
+
"@meowdown/core": "0.57.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": "^19.0.0",
|