@mp-lb/mdkit 0.1.0-main.6.1 → 0.1.0-main.9.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/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export { useMdKitDocument } from "./document/useMdKitDocument";
4
4
  export { MdKitConflictPanel } from "./document/MdKitConflictPanel";
5
5
  export { MdKitDocumentToolbar } from "./document/MdKitDocumentToolbar";
6
6
  export { MdKitEditor } from "./markdown/MdKitEditor";
7
+ export { MdKitView } from "./markdown/MdKitView";
7
8
  export { MdKitThemeEditor } from "./theme/MdKitThemeEditor";
8
9
  export { createMdKitRestAdapter } from "./transport/rest";
9
10
  export { createMdKitEditorThemeStyle, darkMdKitEditorTheme, defaultMdKitEditorTheme, } from "./theme/editorTheme";
@@ -16,6 +17,7 @@ export type { MdKitConflictPanelProps } from "./document/MdKitConflictPanel";
16
17
  export type { MdKitDocumentToolbarProps } from "./document/MdKitDocumentToolbar";
17
18
  export type { MdKitEditorProps } from "./markdown/MdKitEditor";
18
19
  export type { MdKitEditorDebugEvent } from "./markdown/editorDebug";
20
+ export type { MdKitViewProps } from "./markdown/MdKitView";
19
21
  export type { MdKitThemeEditorProps } from "./theme/MdKitThemeEditor";
20
22
  export type { CreateMdKitRestAdapterOptions } from "./transport/rest";
21
23
  export type { MdKitEditorTheme, MdKitEditorThemeStyle, } from "./theme/editorTheme";
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ export { useMdKitDocument } from "./document/useMdKitDocument";
4
4
  export { MdKitConflictPanel } from "./document/MdKitConflictPanel";
5
5
  export { MdKitDocumentToolbar } from "./document/MdKitDocumentToolbar";
6
6
  export { MdKitEditor } from "./markdown/MdKitEditor";
7
+ export { MdKitView } from "./markdown/MdKitView";
7
8
  export { MdKitThemeEditor } from "./theme/MdKitThemeEditor";
8
9
  export { createMdKitRestAdapter } from "./transport/rest";
9
10
  export { createMdKitEditorThemeStyle, darkMdKitEditorTheme, defaultMdKitEditorTheme, } from "./theme/editorTheme";
@@ -0,0 +1,9 @@
1
+ import type { CSSProperties } from "react";
2
+ export type MdKitViewProps = {
3
+ className?: string;
4
+ fillHeight?: boolean;
5
+ placeholder?: string;
6
+ style?: CSSProperties;
7
+ value: string;
8
+ };
9
+ export declare const MdKitView: ({ className, fillHeight, placeholder, style, value, }: MdKitViewProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import ReactMarkdown from "react-markdown";
3
+ import remarkGfm from "remark-gfm";
4
+ import { joinClassNames } from "../ui/joinClassNames";
5
+ export const MdKitView = ({ className, fillHeight = false, placeholder, style, value, }) => {
6
+ const renderedValue = value.trim().length > 0 ? value : (placeholder ?? "");
7
+ return (_jsx("div", { className: joinClassNames("mp-lb-mdkit-markdown-editor", "mp-lb-mdkit-markdown-view", fillHeight && "mp-lb-mdkit-markdown-editor-fill-height", className), "data-read-only": "true", style: style, children: _jsx("div", { className: "mp-lb-mdkit-editor-shell", children: _jsx("div", { className: "mp-lb-mdkit-editor-surface", children: renderedValue.length > 0 ? (_jsx("div", { className: "mp-lb-mdkit-tiptap mp-lb-mdkit-view-content", children: _jsx(ReactMarkdown, { components: {
8
+ a: ({ children, ...linkProps }) => (_jsx("a", { ...linkProps, rel: "noopener noreferrer", target: "_blank", children: children })),
9
+ }, remarkPlugins: [remarkGfm], children: renderedValue }) })) : (_jsx("div", { className: "mp-lb-mdkit-editor-empty" })) }) }) }));
10
+ };
package/docs/api.md CHANGED
@@ -54,6 +54,26 @@ lists, code blocks, blockquotes, and links. Styling is controlled with CSS
54
54
  variables on `.mp-lb-mdkit-markdown-editor`. See [Styling](./styling.md) for setup,
55
55
  dark mode, fonts, sizing, and theme customization.
56
56
 
57
+ ### `MdKitView`
58
+
59
+ Read-only markdown view that uses the same shell, sizing, and markdown styling
60
+ as `MdKitEditor`, but renders with `react-markdown` instead of Tiptap.
61
+
62
+ ```tsx
63
+ <MdKitView value={markdown} />
64
+ <MdKitView fillHeight value={markdown} />
65
+ ```
66
+
67
+ Props:
68
+
69
+ - `value: string`
70
+ - `placeholder?: string`
71
+ - `fillHeight?: boolean`
72
+ - `className?: string`
73
+ - `style?: CSSProperties`
74
+
75
+ `fillHeight` uses the same full-pane sizing contract as `MdKitEditor`.
76
+
57
77
  ## Document Persistence
58
78
 
59
79
  ### `useMdKitDocument`
@@ -26,6 +26,12 @@ Collaboration needs a different editor engine internally because it is backed by
26
26
  Yjs state and remote cursors, but consumers should not need a separate editor
27
27
  component.
28
28
 
29
+ `MdKitView` is the read-only companion surface. It accepts a markdown `value`
30
+ and uses the same package styling and full-height layout contract as
31
+ `MdKitEditor`, but it renders markdown without Tiptap or ProseMirror. Use it
32
+ when consumers need previews, version snapshots, or readonly document views that
33
+ visually match the editor without paying the editor runtime cost.
34
+
29
35
  ### Headless Hooks
30
36
 
31
37
  Storage, versioning, and collaboration controls should come from hooks and
package/docs/index.md CHANGED
@@ -38,6 +38,24 @@ export function MarkdownEditorExample() {
38
38
 
39
39
  Use this when you want a local editor, a form field, or a debug surface.
40
40
 
41
+ ## Read-only View
42
+
43
+ `MdKitView` renders markdown with the same package stylesheet, CSS variables,
44
+ and `fillHeight` sizing contract as `MdKitEditor`, but it does not mount Tiptap
45
+ or ProseMirror.
46
+
47
+ ```tsx
48
+ import { MdKitView } from "@mp-lb/mdkit";
49
+ import "@mp-lb/mdkit/styles.css";
50
+
51
+ export function MarkdownPreview({ markdown }: { markdown: string }) {
52
+ return <MdKitView fillHeight value={markdown} />;
53
+ }
54
+ ```
55
+
56
+ Use this for document previews, restored-version views, or any readonly markdown
57
+ surface that should visually match the editor.
58
+
41
59
  ## Connected Editor
42
60
 
43
61
  The connected workflow combines:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mp-lb/mdkit",
3
- "version": "0.1.0-main.6.1",
3
+ "version": "0.1.0-main.9.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -78,6 +78,8 @@
78
78
  "@tiptap/react": "^3.14.0",
79
79
  "@tiptap/starter-kit": "^3.14.0",
80
80
  "lucide-react": "^0.554.0",
81
+ "react-markdown": "10.1.0",
82
+ "remark-gfm": "4.0.1",
81
83
  "yjs": "^13.6.24",
82
84
  "zod": "^4.1.12"
83
85
  },
package/src/styles.css CHANGED
@@ -70,6 +70,10 @@
70
70
  cursor: default;
71
71
  }
72
72
 
73
+ .mp-lb-mdkit-markdown-view .mp-lb-mdkit-view-content {
74
+ overflow-wrap: anywhere;
75
+ }
76
+
73
77
  .mp-lb-mdkit-markdown-editor-fill-height {
74
78
  display: flex;
75
79
  height: 100%;
@@ -224,6 +228,37 @@
224
228
  color: var(--mp-lb-mdkit-muted-foreground);
225
229
  }
226
230
 
231
+ .mp-lb-mdkit-tiptap hr {
232
+ height: 1px;
233
+ border: 0;
234
+ background: var(--mp-lb-mdkit-border);
235
+ margin: var(--mp-lb-mdkit-block-gap) 0;
236
+ }
237
+
238
+ .mp-lb-mdkit-tiptap img {
239
+ max-width: 100%;
240
+ height: auto;
241
+ }
242
+
243
+ .mp-lb-mdkit-tiptap table {
244
+ width: 100%;
245
+ border-collapse: collapse;
246
+ margin: 0 0 var(--mp-lb-mdkit-block-gap);
247
+ }
248
+
249
+ .mp-lb-mdkit-tiptap th,
250
+ .mp-lb-mdkit-tiptap td {
251
+ border: 1px solid var(--mp-lb-mdkit-border);
252
+ padding: 0.35rem 0.5rem;
253
+ text-align: left;
254
+ vertical-align: top;
255
+ }
256
+
257
+ .mp-lb-mdkit-tiptap th {
258
+ background: var(--mp-lb-mdkit-muted);
259
+ font-weight: 650;
260
+ }
261
+
227
262
  .mp-lb-mdkit-tiptap p.is-editor-empty:first-child::before {
228
263
  color: var(--mp-lb-mdkit-muted-foreground);
229
264
  content: attr(data-placeholder);