@mp-lb/mdkit 0.1.0 → 0.2.0-main.12.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",
3
+ "version": "0.2.0-main.12.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%;
@@ -138,6 +142,26 @@
138
142
  flex: 1 1 auto;
139
143
  }
140
144
 
145
+ .mp-lb-mdkit-markdown-view.mp-lb-mdkit-markdown-editor-fill-height
146
+ .mp-lb-mdkit-editor-shell {
147
+ height: auto;
148
+ min-height: 100%;
149
+ overflow: visible;
150
+ }
151
+
152
+ .mp-lb-mdkit-markdown-view.mp-lb-mdkit-markdown-editor-fill-height
153
+ .mp-lb-mdkit-editor-surface {
154
+ overflow: visible;
155
+ }
156
+
157
+ .mp-lb-mdkit-markdown-view.mp-lb-mdkit-markdown-editor-fill-height
158
+ .mp-lb-mdkit-view-content {
159
+ display: block;
160
+ height: auto;
161
+ min-height: 100%;
162
+ flex: 0 0 auto;
163
+ }
164
+
141
165
  .mp-lb-mdkit-tiptap > * + * {
142
166
  margin-top: var(--mp-lb-mdkit-block-gap);
143
167
  }
@@ -224,6 +248,37 @@
224
248
  color: var(--mp-lb-mdkit-muted-foreground);
225
249
  }
226
250
 
251
+ .mp-lb-mdkit-tiptap hr {
252
+ height: 1px;
253
+ border: 0;
254
+ background: var(--mp-lb-mdkit-border);
255
+ margin: var(--mp-lb-mdkit-block-gap) 0;
256
+ }
257
+
258
+ .mp-lb-mdkit-tiptap img {
259
+ max-width: 100%;
260
+ height: auto;
261
+ }
262
+
263
+ .mp-lb-mdkit-tiptap table {
264
+ width: 100%;
265
+ border-collapse: collapse;
266
+ margin: 0 0 var(--mp-lb-mdkit-block-gap);
267
+ }
268
+
269
+ .mp-lb-mdkit-tiptap th,
270
+ .mp-lb-mdkit-tiptap td {
271
+ border: 1px solid var(--mp-lb-mdkit-border);
272
+ padding: 0.35rem 0.5rem;
273
+ text-align: left;
274
+ vertical-align: top;
275
+ }
276
+
277
+ .mp-lb-mdkit-tiptap th {
278
+ background: var(--mp-lb-mdkit-muted);
279
+ font-weight: 650;
280
+ }
281
+
227
282
  .mp-lb-mdkit-tiptap p.is-editor-empty:first-child::before {
228
283
  color: var(--mp-lb-mdkit-muted-foreground);
229
284
  content: attr(data-placeholder);