@shadospace/editor 1.0.0 → 1.0.2
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 +53 -21
- package/package.json +1 -1
- package/scripts/init.js +29 -0
package/README.md
CHANGED
|
@@ -1,21 +1,53 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
# @shadospace/editor
|
|
2
|
+
|
|
3
|
+
A beautiful, feature-rich Tiptap editor scaffolding for Next.js projects using shadcn/ui.
|
|
4
|
+
|
|
5
|
+
This is not just a component library; it's a CLI scaffolding tool that places the editor source files directly into your project so you can customize them fully.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Tiptap Starter Kit** fully integrated.
|
|
10
|
+
- **Dynamic Menu Bar** with essential formatting tools.
|
|
11
|
+
- **Tailwind CSS** styling pre-configured.
|
|
12
|
+
- **Interactive States** and clean UI.
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
Before installing, ensure your project meets the following requirements:
|
|
17
|
+
|
|
18
|
+
1. **Next.js** project.
|
|
19
|
+
2. **shadcn/ui** initialized (requires a `components.json` file in the root).
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
Install the package as a dependency. The installation will automatically trigger the setup script.
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
bun add @shadospace/editor
|
|
27
|
+
# or
|
|
28
|
+
npm install @shadospace/editor
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Configuration
|
|
32
|
+
|
|
33
|
+
The package automatically detects your project structure (with or without a `src` folder) and places files in `components/editor/`. It also references the stylesheet in your global CSS file.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
After installation, the component files will be copied into your project. You can import and use the editor like this (adjust the path if you use a different alias):
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import Editor from "@/components/editor";
|
|
41
|
+
|
|
42
|
+
export default function Page() {
|
|
43
|
+
return (
|
|
44
|
+
<div className="container mx-auto p-6">
|
|
45
|
+
<Editor />
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Customization
|
|
52
|
+
|
|
53
|
+
Since the editor files are copied directly into your project, you can edit them anytime to add new features or change the styling.
|
package/package.json
CHANGED
package/scripts/init.js
CHANGED
|
@@ -11,6 +11,35 @@ const targetDir = process.env.INIT_CWD || process.cwd();
|
|
|
11
11
|
|
|
12
12
|
console.log(`[tiptap-starter] Initializing in ${targetDir}`);
|
|
13
13
|
|
|
14
|
+
// Verify that the target directory is a Next.js project with shadcn installed
|
|
15
|
+
const targetPackageJsonPath = path.join(targetDir, 'package.json');
|
|
16
|
+
|
|
17
|
+
if (!fs.existsSync(targetPackageJsonPath)) {
|
|
18
|
+
console.error(`[tiptap-starter] Error: package.json not found in ${targetDir}. Please run this in the root of your project.`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let pkg;
|
|
23
|
+
try {
|
|
24
|
+
pkg = JSON.parse(fs.readFileSync(targetPackageJsonPath, 'utf8'));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error(`[tiptap-starter] Error: Failed to parse package.json in ${targetDir}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const hasNext = pkg.dependencies?.next || pkg.devDependencies?.next;
|
|
31
|
+
const hasShadcn = fs.existsSync(path.join(targetDir, 'components.json'));
|
|
32
|
+
|
|
33
|
+
if (!hasNext) {
|
|
34
|
+
console.error(`[tiptap-starter] Error: Next.js is not detected. This package is designed for Next.js projects.`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!hasShadcn) {
|
|
39
|
+
console.error(`[tiptap-starter] Error: shadcn/ui is not detected (components.json not found). Please initialize shadcn first.`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
14
43
|
const sourceEditorDir = path.join(__dirname, '../components/editor');
|
|
15
44
|
|
|
16
45
|
// Detect if target project uses src directory
|