create-markdown 0.2.2 → 2.0.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/dist/index.cjs +24 -1751
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7 -34
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1726
- package/dist/index.js.map +1 -0
- package/dist/preview.cjs +25 -0
- package/dist/preview.cjs.map +1 -0
- package/dist/preview.d.ts +8 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +3 -0
- package/dist/preview.js.map +1 -0
- package/dist/react.cjs +25 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.ts +8 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +3 -0
- package/dist/react.js.map +1 -0
- package/package.json +41 -26
- package/README.md +0 -294
- package/dist/core/blocks.d.ts +0 -136
- package/dist/core/blocks.d.ts.map +0 -1
- package/dist/core/document.d.ts +0 -135
- package/dist/core/document.d.ts.map +0 -1
- package/dist/core/utils.d.ts +0 -80
- package/dist/core/utils.d.ts.map +0 -1
- package/dist/parsers/inline.d.ts +0 -14
- package/dist/parsers/inline.d.ts.map +0 -1
- package/dist/parsers/markdown.d.ts +0 -19
- package/dist/parsers/markdown.d.ts.map +0 -1
- package/dist/parsers/tokenizer.d.ts +0 -38
- package/dist/parsers/tokenizer.d.ts.map +0 -1
- package/dist/react/block-renderer.d.ts +0 -70
- package/dist/react/block-renderer.d.ts.map +0 -1
- package/dist/react/hooks.d.ts +0 -142
- package/dist/react/hooks.d.ts.map +0 -1
- package/dist/react/index.cjs +0 -1814
- package/dist/react/index.d.ts +0 -11
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js +0 -1782
- package/dist/serializers/markdown.d.ts +0 -30
- package/dist/serializers/markdown.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -199
- package/dist/types/index.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * create-markdown\n * Complete block-based markdown notes package\n * \n * This is a convenience bundle that re-exports all @create-markdown packages.\n * For optimal bundle size, import directly from the scoped packages:\n * - @create-markdown/core\n * - @create-markdown/react\n * - @create-markdown/preview\n */\n\n// Re-export everything from core\nexport * from '@create-markdown/core';\n\n/**\n * Package version\n */\nexport const VERSION = '2.0.0';\n"],"mappings":";AAYA,cAAc;AAKP,IAAM,UAAU;","names":[]}
|
package/dist/preview.cjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/preview.ts
|
|
18
|
+
var preview_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(preview_exports);
|
|
20
|
+
__reExport(preview_exports, require("@create-markdown/preview"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@create-markdown/preview")
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=preview.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/preview.ts"],"sourcesContent":["/**\n * create-markdown/preview\n * HTML rendering with syntax highlighting and diagrams\n * \n * Re-exports @create-markdown/preview for convenience.\n */\n\nexport * from '@create-markdown/preview';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAOA,4BAAc,qCAPd;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../src/preview.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,0BAA0B,CAAC"}
|
package/dist/preview.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/preview.ts"],"sourcesContent":["/**\n * create-markdown/preview\n * HTML rendering with syntax highlighting and diagrams\n * \n * Re-exports @create-markdown/preview for convenience.\n */\n\nexport * from '@create-markdown/preview';\n"],"mappings":";AAOA,cAAc;","names":[]}
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/react.ts
|
|
18
|
+
var react_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(react_exports);
|
|
20
|
+
__reExport(react_exports, require("@create-markdown/react"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@create-markdown/react")
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=react.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["/**\n * create-markdown/react\n * React components and hooks\n * \n * Re-exports @create-markdown/react for backwards compatibility.\n */\n\nexport * from '@create-markdown/react';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAOA,0BAAc,mCAPd;","names":[]}
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,wBAAwB,CAAC"}
|
package/dist/react.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["/**\n * create-markdown/react\n * React components and hooks\n * \n * Re-exports @create-markdown/react for backwards compatibility.\n */\n\nexport * from '@create-markdown/react';\n"],"mappings":";AAOA,cAAc;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-markdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Complete block-based markdown notes package - convenience bundle for @create-markdown packages",
|
|
4
5
|
"author": "Val Alexander <val@viewdue.ai>",
|
|
6
|
+
"license": "MIT",
|
|
5
7
|
"repository": {
|
|
6
8
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/BunsDev/create-markdown"
|
|
9
|
+
"url": "git+https://github.com/BunsDev/create-markdown.git",
|
|
10
|
+
"directory": "packages/create-markdown"
|
|
8
11
|
},
|
|
9
12
|
"homepage": "https://github.com/BunsDev/create-markdown",
|
|
10
13
|
"bugs": {
|
|
11
14
|
"url": "https://github.com/BunsDev/create-markdown/issues"
|
|
12
15
|
},
|
|
13
|
-
"description": "Complete block-based markdown notes package with zero dependencies",
|
|
14
|
-
"license": "MIT",
|
|
15
16
|
"keywords": [
|
|
16
17
|
"markdown",
|
|
17
18
|
"md",
|
|
@@ -21,7 +22,6 @@
|
|
|
21
22
|
"parser",
|
|
22
23
|
"serializer",
|
|
23
24
|
"react",
|
|
24
|
-
"bun",
|
|
25
25
|
"typescript"
|
|
26
26
|
],
|
|
27
27
|
"type": "module",
|
|
@@ -41,32 +41,32 @@
|
|
|
41
41
|
},
|
|
42
42
|
"./react": {
|
|
43
43
|
"import": {
|
|
44
|
-
"types": "./dist/react
|
|
45
|
-
"default": "./dist/react
|
|
44
|
+
"types": "./dist/react.d.ts",
|
|
45
|
+
"default": "./dist/react.js"
|
|
46
|
+
},
|
|
47
|
+
"require": {
|
|
48
|
+
"types": "./dist/react.d.ts",
|
|
49
|
+
"default": "./dist/react.cjs"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"./preview": {
|
|
53
|
+
"import": {
|
|
54
|
+
"types": "./dist/preview.d.ts",
|
|
55
|
+
"default": "./dist/preview.js"
|
|
46
56
|
},
|
|
47
57
|
"require": {
|
|
48
|
-
"types": "./dist/
|
|
49
|
-
"default": "./dist/
|
|
58
|
+
"types": "./dist/preview.d.ts",
|
|
59
|
+
"default": "./dist/preview.cjs"
|
|
50
60
|
}
|
|
51
61
|
}
|
|
52
62
|
},
|
|
53
63
|
"files": [
|
|
54
64
|
"dist"
|
|
55
65
|
],
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"build:react-esm": "bun build ./src/react/index.ts --outfile ./dist/react/index.js --format esm --external react",
|
|
61
|
-
"build:react-cjs": "bun build ./src/react/index.ts --outfile ./dist/react/index.cjs --format cjs --external react",
|
|
62
|
-
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
63
|
-
"dev": "bun run --watch src/index.ts",
|
|
64
|
-
"clean": "rm -rf dist",
|
|
65
|
-
"prepublishOnly": "bun run clean && bun run build",
|
|
66
|
-
"deploy": "./deploy.sh",
|
|
67
|
-
"playground": "bun run build && cd playground && bun dev",
|
|
68
|
-
"playground:install": "cd playground && bun install",
|
|
69
|
-
"typecheck": "tsc --noEmit"
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"@create-markdown/core": "^2.0.0",
|
|
68
|
+
"@create-markdown/react": "^2.0.0",
|
|
69
|
+
"@create-markdown/preview": "^2.0.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/react": "^18.2.0",
|
|
@@ -74,15 +74,30 @@
|
|
|
74
74
|
"typescript": "^5.3.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"react": ">=18.0.0"
|
|
77
|
+
"react": ">=18.0.0",
|
|
78
|
+
"shiki": ">=1.0.0",
|
|
79
|
+
"mermaid": ">=10.0.0"
|
|
78
80
|
},
|
|
79
81
|
"peerDependenciesMeta": {
|
|
80
82
|
"react": {
|
|
81
83
|
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"shiki": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"mermaid": {
|
|
89
|
+
"optional": true
|
|
82
90
|
}
|
|
83
91
|
},
|
|
84
92
|
"engines": {
|
|
85
93
|
"node": ">=20.0.0"
|
|
86
94
|
},
|
|
87
|
-
"
|
|
88
|
-
|
|
95
|
+
"scripts": {
|
|
96
|
+
"build": "pnpm run build:js && pnpm run build:types",
|
|
97
|
+
"build:js": "tsup --config tsup.config.ts",
|
|
98
|
+
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
99
|
+
"dev": "tsup --config tsup.config.ts --watch",
|
|
100
|
+
"clean": "rm -rf dist",
|
|
101
|
+
"typecheck": "tsc --noEmit"
|
|
102
|
+
}
|
|
103
|
+
}
|
package/README.md
DELETED
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
# create-markdown
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/create-markdown)
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
|
|
6
|
-
A complete block-based markdown notes package with zero dependencies. Parse, create, and serialize markdown with full TypeScript support.
|
|
7
|
-
|
|
8
|
-
📦 **[View on npm](https://www.npmjs.com/package/create-markdown)**
|
|
9
|
-
|
|
10
|
-
## Features
|
|
11
|
-
|
|
12
|
-
- 🧱 **Block-based architecture** - Work with structured blocks instead of raw strings
|
|
13
|
-
- 🔄 **Bidirectional conversion** - Parse markdown to blocks, serialize blocks to markdown
|
|
14
|
-
- 📝 **Rich inline styles** - Bold, italic, code, links, strikethrough, highlights
|
|
15
|
-
- ⚛️ **React components** - Optional React bindings for rendering and editing
|
|
16
|
-
- ✨ **Live WYSIWYG editing** - Interactive playground with real-time markdown rendering
|
|
17
|
-
- 🪶 **Zero dependencies** - Core package has no runtime dependencies
|
|
18
|
-
- 🔒 **Full TypeScript** - Complete type definitions with generics
|
|
19
|
-
- 🚀 **Framework ready** - Works with Next.js, Vite, Remix, Astro, and more
|
|
20
|
-
|
|
21
|
-
## Installation
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
# Using bun (recommended)
|
|
25
|
-
bun add create-markdown
|
|
26
|
-
|
|
27
|
-
# Using npm
|
|
28
|
-
npm install create-markdown
|
|
29
|
-
|
|
30
|
-
# Using yarn
|
|
31
|
-
yarn add create-markdown
|
|
32
|
-
|
|
33
|
-
# Using pnpm
|
|
34
|
-
pnpm add create-markdown
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Quick Start
|
|
38
|
-
|
|
39
|
-
### Parse Markdown to Blocks
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
import { parse } from 'create-markdown';
|
|
43
|
-
|
|
44
|
-
const blocks = parse(`# Hello World
|
|
45
|
-
|
|
46
|
-
This is **bold** and *italic* text.
|
|
47
|
-
|
|
48
|
-
- Item one
|
|
49
|
-
- Item two
|
|
50
|
-
`);
|
|
51
|
-
|
|
52
|
-
console.log(blocks);
|
|
53
|
-
// [
|
|
54
|
-
// { type: 'heading', props: { level: 1 }, content: [...] },
|
|
55
|
-
// { type: 'paragraph', content: [...] },
|
|
56
|
-
// { type: 'bulletList', children: [...] }
|
|
57
|
-
// ]
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Create Blocks Programmatically
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
import { h1, paragraph, bulletList, bold, italic, spans } from 'create-markdown';
|
|
64
|
-
|
|
65
|
-
const blocks = [
|
|
66
|
-
h1('My Document'),
|
|
67
|
-
paragraph(spans(
|
|
68
|
-
bold('Important: '),
|
|
69
|
-
{ text: 'This is ', styles: {} },
|
|
70
|
-
italic('really'),
|
|
71
|
-
{ text: ' cool!', styles: {} }
|
|
72
|
-
)),
|
|
73
|
-
bulletList(['First item', 'Second item', 'Third item']),
|
|
74
|
-
];
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Serialize Blocks to Markdown
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
import { stringify, h1, paragraph, codeBlock } from 'create-markdown';
|
|
81
|
-
|
|
82
|
-
const markdown = stringify([
|
|
83
|
-
h1('Hello'),
|
|
84
|
-
paragraph('World'),
|
|
85
|
-
codeBlock('console.log("Hi!");', 'javascript'),
|
|
86
|
-
]);
|
|
87
|
-
|
|
88
|
-
console.log(markdown);
|
|
89
|
-
// # Hello
|
|
90
|
-
//
|
|
91
|
-
// World
|
|
92
|
-
//
|
|
93
|
-
// ```javascript
|
|
94
|
-
// console.log("Hi!");
|
|
95
|
-
// ```
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### Document Management
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
import {
|
|
102
|
-
createDocument,
|
|
103
|
-
appendBlock,
|
|
104
|
-
removeBlock,
|
|
105
|
-
findBlock,
|
|
106
|
-
paragraph
|
|
107
|
-
} from 'create-markdown';
|
|
108
|
-
|
|
109
|
-
// Create a document
|
|
110
|
-
let doc = createDocument([paragraph('First paragraph')]);
|
|
111
|
-
|
|
112
|
-
// Add a block
|
|
113
|
-
doc = appendBlock(doc, paragraph('Second paragraph'));
|
|
114
|
-
|
|
115
|
-
// Find a block
|
|
116
|
-
const block = findBlock(doc, 'some-id');
|
|
117
|
-
|
|
118
|
-
// Remove a block
|
|
119
|
-
doc = removeBlock(doc, 'some-id');
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## React Components
|
|
123
|
-
|
|
124
|
-
Optional React bindings are available via a separate import:
|
|
125
|
-
|
|
126
|
-
```tsx
|
|
127
|
-
import { BlockRenderer, useDocument, useMarkdown } from 'create-markdown/react';
|
|
128
|
-
import { paragraph, h1 } from 'create-markdown/react';
|
|
129
|
-
|
|
130
|
-
function Editor() {
|
|
131
|
-
const { blocks, appendBlock, toMarkdown } = useDocument();
|
|
132
|
-
|
|
133
|
-
return (
|
|
134
|
-
<div>
|
|
135
|
-
<BlockRenderer blocks={blocks} />
|
|
136
|
-
<button onClick={() => appendBlock(paragraph('New paragraph'))}>
|
|
137
|
-
Add Paragraph
|
|
138
|
-
</button>
|
|
139
|
-
<button onClick={() => console.log(toMarkdown())}>
|
|
140
|
-
Export Markdown
|
|
141
|
-
</button>
|
|
142
|
-
</div>
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function MarkdownEditor() {
|
|
147
|
-
const { markdown, blocks, setMarkdown } = useMarkdown('# Hello');
|
|
148
|
-
|
|
149
|
-
return (
|
|
150
|
-
<div>
|
|
151
|
-
<textarea
|
|
152
|
-
value={markdown}
|
|
153
|
-
onChange={(e) => setMarkdown(e.target.value)}
|
|
154
|
-
/>
|
|
155
|
-
<BlockRenderer blocks={blocks} />
|
|
156
|
-
</div>
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
## Block Types
|
|
162
|
-
|
|
163
|
-
| Type | Factory Function | Description |
|
|
164
|
-
|------|-----------------|-------------|
|
|
165
|
-
| `paragraph` | `paragraph(content)` | Text paragraph |
|
|
166
|
-
| `heading` | `heading(level, content)` or `h1`-`h6` | Heading levels 1-6 |
|
|
167
|
-
| `bulletList` | `bulletList(items)` | Unordered list |
|
|
168
|
-
| `numberedList` | `numberedList(items)` | Ordered list |
|
|
169
|
-
| `checkList` | `checkList(items)` | Task list with checkboxes |
|
|
170
|
-
| `codeBlock` | `codeBlock(code, language?)` | Fenced code block |
|
|
171
|
-
| `blockquote` | `blockquote(content)` | Block quote |
|
|
172
|
-
| `image` | `image(url, alt?)` | Image |
|
|
173
|
-
| `divider` | `divider()` | Horizontal rule |
|
|
174
|
-
| `table` | `table(headers, rows)` | Table with headers |
|
|
175
|
-
| `callout` | `callout(type, content)` | Callout/admonition |
|
|
176
|
-
|
|
177
|
-
## Inline Styles
|
|
178
|
-
|
|
179
|
-
```typescript
|
|
180
|
-
import { bold, italic, code, link, strikethrough, highlight } from 'create-markdown';
|
|
181
|
-
|
|
182
|
-
// Create styled text spans
|
|
183
|
-
const content = [
|
|
184
|
-
bold('Bold text'),
|
|
185
|
-
italic('Italic text'),
|
|
186
|
-
code('inline code'),
|
|
187
|
-
link('Click here', 'https://example.com'),
|
|
188
|
-
strikethrough('deleted'),
|
|
189
|
-
highlight('highlighted'),
|
|
190
|
-
];
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## API Reference
|
|
194
|
-
|
|
195
|
-
### Parsing
|
|
196
|
-
|
|
197
|
-
- `parse(markdown)` - Parse markdown string to blocks
|
|
198
|
-
- `markdownToBlocks(markdown, options?)` - Full parser with options
|
|
199
|
-
- `markdownToDocument(markdown)` - Parse to a Document object
|
|
200
|
-
|
|
201
|
-
### Serialization
|
|
202
|
-
|
|
203
|
-
- `stringify(blocks)` - Serialize blocks to markdown
|
|
204
|
-
- `blocksToMarkdown(blocks, options?)` - Full serializer with options
|
|
205
|
-
- `documentToMarkdown(doc)` - Serialize a Document
|
|
206
|
-
|
|
207
|
-
### Document Operations
|
|
208
|
-
|
|
209
|
-
- `createDocument(blocks?, options?)` - Create a new document
|
|
210
|
-
- `insertBlock(doc, block, index?)` - Insert block at position
|
|
211
|
-
- `appendBlock(doc, block)` - Add block at end
|
|
212
|
-
- `removeBlock(doc, blockId)` - Remove block by ID
|
|
213
|
-
- `updateBlock(doc, blockId, updates)` - Update block properties
|
|
214
|
-
- `moveBlock(doc, blockId, newIndex)` - Reorder blocks
|
|
215
|
-
- `findBlock(doc, blockId)` - Find block by ID
|
|
216
|
-
|
|
217
|
-
### React Hooks
|
|
218
|
-
|
|
219
|
-
- `useDocument(initialBlocks?)` - Full document state management
|
|
220
|
-
- `useMarkdown(initialMarkdown?)` - Bidirectional markdown/blocks
|
|
221
|
-
- `useBlockEditor(doc)` - Selection and editing operations
|
|
222
|
-
|
|
223
|
-
## Integration
|
|
224
|
-
|
|
225
|
-
For detailed framework-specific setup guides, see the **[Integration Guide](./INTEGRATION.md)**.
|
|
226
|
-
|
|
227
|
-
Quick links:
|
|
228
|
-
- [Next.js (App Router)](./INTEGRATION.md#nextjs-app-router)
|
|
229
|
-
- [Next.js (Pages Router)](./INTEGRATION.md#nextjs-pages-router)
|
|
230
|
-
- [Vite + React](./INTEGRATION.md#vite--react)
|
|
231
|
-
- [Remix](./INTEGRATION.md#remix)
|
|
232
|
-
- [Astro](./INTEGRATION.md#astro)
|
|
233
|
-
- [Node.js / Server-side](./INTEGRATION.md#nodejs--server-side)
|
|
234
|
-
|
|
235
|
-
## Playground
|
|
236
|
-
|
|
237
|
-
The package includes a full WYSIWYG playground editor demonstrating all features:
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
# Run the interactive playground
|
|
241
|
-
bun run playground
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
**Playground Features:**
|
|
245
|
-
- Click-to-edit blocks with live markdown rendering
|
|
246
|
-
- Markdown shortcuts (`#` headings, `-` lists, `>` quotes, ``` code, `---` dividers)
|
|
247
|
-
- Inline formatting (`**bold**`, `*italic*`, `` `code` ``, `~~strike~~`, `==highlight==`, `[link](url)`)
|
|
248
|
-
- Keyboard shortcuts (Cmd/Ctrl+B, Cmd/Ctrl+I, Cmd/Ctrl+U)
|
|
249
|
-
- List item management with Enter/Backspace/Tab
|
|
250
|
-
- Dark/light theme toggle
|
|
251
|
-
- Export to markdown
|
|
252
|
-
|
|
253
|
-
## Development
|
|
254
|
-
|
|
255
|
-
```bash
|
|
256
|
-
# Install dependencies
|
|
257
|
-
bun install
|
|
258
|
-
|
|
259
|
-
# Build the package
|
|
260
|
-
bun run build
|
|
261
|
-
|
|
262
|
-
# Type check
|
|
263
|
-
bun run typecheck
|
|
264
|
-
|
|
265
|
-
# Run the playground
|
|
266
|
-
bun run playground
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
## Requirements
|
|
270
|
-
|
|
271
|
-
- Node.js 20+
|
|
272
|
-
- Bun 1.0+ (for development)
|
|
273
|
-
- React 18+ (optional, for React components)
|
|
274
|
-
|
|
275
|
-
## Documentation
|
|
276
|
-
|
|
277
|
-
| Document | Description |
|
|
278
|
-
|----------|-------------|
|
|
279
|
-
| [README.md](./README.md) | Quick start and API overview |
|
|
280
|
-
| [INTEGRATION.md](./INTEGRATION.md) | Framework-specific setup guides |
|
|
281
|
-
| [CONTRIBUTING.md](./CONTRIBUTING.md) | Contribution guidelines |
|
|
282
|
-
| [CHANGELOG.md](./CHANGELOG.md) | Version history |
|
|
283
|
-
|
|
284
|
-
## Contributing
|
|
285
|
-
|
|
286
|
-
We welcome contributions! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
287
|
-
|
|
288
|
-
## Changelog
|
|
289
|
-
|
|
290
|
-
See [CHANGELOG.md](./CHANGELOG.md) for release history.
|
|
291
|
-
|
|
292
|
-
## License
|
|
293
|
-
|
|
294
|
-
MIT
|
package/dist/core/blocks.d.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* create-markdown - Block Factory Functions
|
|
3
|
-
* Create and manipulate block structures
|
|
4
|
-
*/
|
|
5
|
-
import type { Block, BlockType, TextSpan, InlineStyle, HeadingBlock, ParagraphBlock, BulletListBlock, NumberedListBlock, CheckListBlock, CodeBlockBlock, BlockquoteBlock, ImageBlock, DividerBlock, CalloutBlock, CalloutType, TableBlock } from '../types';
|
|
6
|
-
/**
|
|
7
|
-
* Creates: block with the specified type and properties
|
|
8
|
-
*/
|
|
9
|
-
export declare function createBlock<T extends BlockType>(type: T, content?: TextSpan[], props?: Block<T>['props'], children?: Block[]): Block<T>;
|
|
10
|
-
/**
|
|
11
|
-
* Creates: plain text span with no styles
|
|
12
|
-
*/
|
|
13
|
-
export declare function text(content: string): TextSpan;
|
|
14
|
-
/**
|
|
15
|
-
* Creates: bold text span
|
|
16
|
-
*/
|
|
17
|
-
export declare function bold(content: string): TextSpan;
|
|
18
|
-
/**
|
|
19
|
-
* Creates: italic text span
|
|
20
|
-
*/
|
|
21
|
-
export declare function italic(content: string): TextSpan;
|
|
22
|
-
/**
|
|
23
|
-
* Creates: inline code text span
|
|
24
|
-
*/
|
|
25
|
-
export declare function code(content: string): TextSpan;
|
|
26
|
-
/**
|
|
27
|
-
* Creates: strikethrough text span
|
|
28
|
-
*/
|
|
29
|
-
export declare function strikethrough(content: string): TextSpan;
|
|
30
|
-
/**
|
|
31
|
-
* Creates: underlined text span
|
|
32
|
-
*/
|
|
33
|
-
export declare function underline(content: string): TextSpan;
|
|
34
|
-
/**
|
|
35
|
-
* Creates: highlighted text span
|
|
36
|
-
*/
|
|
37
|
-
export declare function highlight(content: string): TextSpan;
|
|
38
|
-
/**
|
|
39
|
-
* Creates: link text span
|
|
40
|
-
*/
|
|
41
|
-
export declare function link(content: string, url: string, title?: string): TextSpan;
|
|
42
|
-
/**
|
|
43
|
-
* Creates: text span with custom styles
|
|
44
|
-
*/
|
|
45
|
-
export declare function styled(content: string, styles: InlineStyle): TextSpan;
|
|
46
|
-
/**
|
|
47
|
-
* Combines multiple text spans into a content array
|
|
48
|
-
*/
|
|
49
|
-
export declare function spans(...textSpans: TextSpan[]): TextSpan[];
|
|
50
|
-
/**
|
|
51
|
-
* Creates: paragraph block
|
|
52
|
-
*/
|
|
53
|
-
export declare function paragraph(content: string | TextSpan[]): ParagraphBlock;
|
|
54
|
-
/**
|
|
55
|
-
* Creates: heading block
|
|
56
|
-
*/
|
|
57
|
-
export declare function heading(level: 1 | 2 | 3 | 4 | 5 | 6, content: string | TextSpan[]): HeadingBlock;
|
|
58
|
-
export declare const h1: (content: string | TextSpan[]) => HeadingBlock;
|
|
59
|
-
export declare const h2: (content: string | TextSpan[]) => HeadingBlock;
|
|
60
|
-
export declare const h3: (content: string | TextSpan[]) => HeadingBlock;
|
|
61
|
-
export declare const h4: (content: string | TextSpan[]) => HeadingBlock;
|
|
62
|
-
export declare const h5: (content: string | TextSpan[]) => HeadingBlock;
|
|
63
|
-
export declare const h6: (content: string | TextSpan[]) => HeadingBlock;
|
|
64
|
-
/**
|
|
65
|
-
* Creates: bullet list block with items
|
|
66
|
-
*/
|
|
67
|
-
export declare function bulletList(items: (string | TextSpan[] | Block)[]): BulletListBlock;
|
|
68
|
-
/**
|
|
69
|
-
* Creates: numbered list block with items
|
|
70
|
-
*/
|
|
71
|
-
export declare function numberedList(items: (string | TextSpan[] | Block)[]): NumberedListBlock;
|
|
72
|
-
/**
|
|
73
|
-
* Creates: checklist item
|
|
74
|
-
*/
|
|
75
|
-
export declare function checkListItem(content: string | TextSpan[], checked?: boolean): CheckListBlock;
|
|
76
|
-
/**
|
|
77
|
-
* Creates: checklist with multiple items
|
|
78
|
-
*/
|
|
79
|
-
export declare function checkList(items: {
|
|
80
|
-
content: string | TextSpan[];
|
|
81
|
-
checked?: boolean;
|
|
82
|
-
}[]): Block[];
|
|
83
|
-
/**
|
|
84
|
-
* Creates: code block
|
|
85
|
-
*/
|
|
86
|
-
export declare function codeBlock(code: string, language?: string): CodeBlockBlock;
|
|
87
|
-
/**
|
|
88
|
-
* Creates: blockquote
|
|
89
|
-
*/
|
|
90
|
-
export declare function blockquote(content: string | TextSpan[]): BlockquoteBlock;
|
|
91
|
-
/**
|
|
92
|
-
* Creates: horizontal divider
|
|
93
|
-
*/
|
|
94
|
-
export declare function divider(): DividerBlock;
|
|
95
|
-
/**
|
|
96
|
-
* Creates: image block
|
|
97
|
-
*/
|
|
98
|
-
export declare function image(url: string, alt?: string, options?: {
|
|
99
|
-
title?: string;
|
|
100
|
-
width?: number;
|
|
101
|
-
height?: number;
|
|
102
|
-
}): ImageBlock;
|
|
103
|
-
/**
|
|
104
|
-
* Creates: callout block
|
|
105
|
-
*/
|
|
106
|
-
export declare function callout(type: CalloutType, content: string | TextSpan[]): CalloutBlock;
|
|
107
|
-
export declare const infoCallout: (content: string | TextSpan[]) => CalloutBlock;
|
|
108
|
-
export declare const warningCallout: (content: string | TextSpan[]) => CalloutBlock;
|
|
109
|
-
export declare const tipCallout: (content: string | TextSpan[]) => CalloutBlock;
|
|
110
|
-
export declare const dangerCallout: (content: string | TextSpan[]) => CalloutBlock;
|
|
111
|
-
export declare const noteCallout: (content: string | TextSpan[]) => CalloutBlock;
|
|
112
|
-
/**
|
|
113
|
-
* Creates: table block
|
|
114
|
-
*/
|
|
115
|
-
export declare function table(headers: string[], rows: string[][], alignments?: ('left' | 'center' | 'right' | null)[]): TableBlock;
|
|
116
|
-
/**
|
|
117
|
-
* Adds: content to an existing block
|
|
118
|
-
*/
|
|
119
|
-
export declare function appendContent<T extends BlockType>(block: Block<T>, ...newSpans: TextSpan[]): Block<T>;
|
|
120
|
-
/**
|
|
121
|
-
* Prepends: content to an existing block
|
|
122
|
-
*/
|
|
123
|
-
export declare function prependContent<T extends BlockType>(block: Block<T>, ...newSpans: TextSpan[]): Block<T>;
|
|
124
|
-
/**
|
|
125
|
-
* Replaces: the content of a block
|
|
126
|
-
*/
|
|
127
|
-
export declare function setContent<T extends BlockType>(block: Block<T>, content: TextSpan[]): Block<T>;
|
|
128
|
-
/**
|
|
129
|
-
* Adds: children to a block
|
|
130
|
-
*/
|
|
131
|
-
export declare function addChildren<T extends BlockType>(block: Block<T>, ...newChildren: Block[]): Block<T>;
|
|
132
|
-
/**
|
|
133
|
-
* Updates: block properties
|
|
134
|
-
*/
|
|
135
|
-
export declare function updateProps<T extends BlockType>(block: Block<T>, props: Partial<Block<T>['props']>): Block<T>;
|
|
136
|
-
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/core/blocks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,KAAK,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,eAAe,EACf,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,UAAU,EACX,MAAM,UAAU,CAAC;AAOlB;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAC7C,IAAI,EAAE,CAAC,EACP,OAAO,GAAE,QAAQ,EAAO,EACxB,KAAK,GAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAA2B,EAClD,QAAQ,GAAE,KAAK,EAAO,GACrB,KAAK,CAAC,CAAC,CAAC,CAQV;AAMD;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAE9C;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAE9C;AAED;;G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