Skip to content

Commit 2b48c8d

Browse files
committed
Add missing files.
1 parent 3fdd3b2 commit 2b48c8d

File tree

10 files changed

+521
-30
lines changed

10 files changed

+521
-30
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ composer.lock
1919

2020
# Testing
2121
/coverage/
22-
.phpunit.result.cache
22+
/.phpunit.result.cache
23+
/.phpunit.cache/
2324

2425
# Temporary files
2526
*.log

CHANGELOG.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
## [1.0.0] - 2024-XX-XX
10+
## [0.1.0] - 2025-XX-XX
1111

1212
### Added
1313

@@ -25,12 +25,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- Dark mode CSS support
2626
- Multisite compatible
2727
- Clean uninstall (removes all options)
28+
- Gutenberg block editor support with live preview
29+
- Native "Djot" block for the block editor
30+
- REST API endpoint for server-side preview rendering
31+
- Toggle between edit and preview modes
32+
- WP-CLI migration commands for converting existing content to Djot
33+
- `wp djot analyze` - Analyze posts for migration complexity
34+
- `wp djot migrate` - Migrate posts from HTML/Markdown to Djot
35+
- `wp djot rollback` - Restore posts to original content
36+
- `wp djot status` - View migration statistics
37+
- Content migration from HTML to Djot (using djot-php HtmlToDjot converter)
38+
- Content migration from Markdown to Djot (using djot-php MarkdownToDjot converter)
39+
- Automatic backup of original content before migration
40+
- Complexity analysis (none, low, medium, high) for migration planning
41+
- Dry-run mode with diff preview
42+
- Batch processing with progress bar
43+
- Preservation of WordPress shortcodes during migration
44+
- Preservation of Gutenberg blocks during migration
2845

2946
### Security
3047

3148
- Safe mode enabled by default for untrusted content
3249
- Comments always processed with safe mode
3350
- XSS protection via djot-php safe mode
3451

35-
[Unreleased]: https://github.com/php-collective/wp-djot/compare/v1.0.0...HEAD
36-
[1.0.0]: https://github.com/php-collective/wp-djot/releases/tag/v1.0.0
52+
[Unreleased]: https://github.com/php-collective/wp-djot/compare/v0.1.0...HEAD
53+
[0.1.0]: https://github.com/php-collective/wp-djot/releases/tag/v0.1.0

README.md

Lines changed: 83 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ Djot is a light markup syntax created by John MacFarlane (creator of CommonMark
1414
## Features
1515

1616
- **Full Djot Support**: Headings, emphasis, links, images, code blocks, tables, footnotes, and more
17+
- **Block Editor Support**: Native Gutenberg block for writing Djot with live preview
1718
- **Shortcode Support**: Use `[djot]...[/djot]` in your content
1819
- **Content Filtering**: Automatically process `{djot}...{/djot}` blocks in posts and pages
1920
- **Safe Mode**: XSS protection for untrusted content (enabled by default for comments)
2021
- **Syntax Highlighting**: Built-in highlight.js integration with multiple themes
2122
- **Admin Settings**: Easy configuration through WordPress admin
2223
- **Template Tags**: `djot_to_html()` and `the_djot()` for theme developers
2324
- **Dark Mode Support**: CSS automatically adapts to dark mode preferences
25+
- **WP-CLI Migration**: Migrate existing HTML/Markdown content to Djot with rollback support
2426

2527
## Requirements
2628

@@ -47,6 +49,16 @@ Search for "WP Djot" in the WordPress plugin directory.
4749

4850
## Usage
4951

52+
### Block Editor (Gutenberg)
53+
54+
Add a **Djot** block from the block inserter (search for "Djot"). The block provides:
55+
56+
- A code editor for writing Djot markup
57+
- Live preview toggle in the sidebar
58+
- Server-side rendering for accurate output
59+
60+
Simply write your Djot content and toggle preview to see the rendered HTML.
61+
5062
### Shortcode
5163

5264
```
@@ -161,37 +173,86 @@ add_filter('wp_djot_post_convert', function(string $html): string {
161173
});
162174
```
163175

164-
## Development
176+
## WP-CLI Commands
165177

166-
### Running Tests
178+
Migrate existing HTML or Markdown content to Djot format using WP-CLI.
179+
180+
### Analyze Content
181+
182+
Analyze posts to determine migration complexity before converting:
167183

168184
```bash
169-
composer install
170-
composer test
185+
# Analyze all posts and pages
186+
wp djot analyze
187+
188+
# Analyze a specific post
189+
wp djot analyze --post-id=123
190+
191+
# Analyze only posts, limit to 10
192+
wp djot analyze --post-type=post --limit=10
193+
194+
# Output as JSON
195+
wp djot analyze --format=json
171196
```
172197

173-
### Code Style
198+
The analysis shows:
199+
- **Complexity**: none, low, medium, high
200+
- **Content types**: HTML, Markdown, Gutenberg blocks, shortcodes
201+
- **Auto-migrate**: Whether the post can be safely auto-migrated
202+
203+
### Migrate Content
204+
205+
Convert posts from HTML/Markdown to Djot:
174206

175207
```bash
176-
composer cs-check
177-
composer cs-fix
208+
# Migrate a single post
209+
wp djot migrate --post-id=123
210+
211+
# Preview migration without saving (dry run)
212+
wp djot migrate --dry-run
213+
214+
# Preview with content diff
215+
wp djot migrate --dry-run --show-diff --post-id=123
216+
217+
# Migrate posts in batches
218+
wp djot migrate --post-type=post --limit=10
219+
220+
# Force migration of high-complexity posts
221+
wp djot migrate --post-id=123 --force
178222
```
179223

180-
### Static Analysis
224+
**Features:**
225+
- Automatic backup of original content
226+
- Preserves WordPress shortcodes
227+
- Preserves Gutenberg blocks
228+
- Converts HTML tags to Djot syntax
229+
- Converts Markdown syntax to Djot
230+
231+
### Rollback Migrations
232+
233+
Restore posts to their original content:
181234

182235
```bash
183-
composer stan
236+
# Rollback a single post
237+
wp djot rollback --post-id=123
238+
239+
# Rollback all migrated posts
240+
wp djot rollback --all
184241
```
185242

186-
## Contributing
243+
### Migration Status
187244

188-
Contributions are welcome! Please feel free to submit a Pull Request.
245+
View migration statistics:
189246

190-
1. Fork the repository
191-
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
192-
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
193-
4. Push to the branch (`git push origin feature/amazing-feature`)
194-
5. Open a Pull Request
247+
```bash
248+
wp djot status
249+
```
250+
251+
Shows count of migrated posts, pending posts, and complexity distribution.
252+
253+
## Contributing
254+
255+
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
195256

196257
## License
197258

@@ -205,12 +266,13 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
205266

206267
## Changelog
207268

208-
### 1.0.0
269+
See [CHANGELOG.md](CHANGELOG.md) for full history.
270+
271+
### 0.1.0
209272

210-
- Initial release
211-
- Full Djot syntax support
273+
- Initial release with full Djot syntax support
212274
- Shortcode and content filtering
213-
- Admin settings page
214-
- Syntax highlighting with highlight.js
275+
- Admin settings page with syntax highlighting
215276
- Safe mode for untrusted content
216277
- Template tags for theme developers
278+
- WP-CLI migration commands for HTML/Markdown to Djot conversion

assets/blocks/djot/block.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"$schema": "https://schemas.wp.org/trunk/block.json",
3+
"apiVersion": 3,
4+
"name": "wp-djot/djot",
5+
"version": "0.1.0",
6+
"title": "Djot",
7+
"category": "text",
8+
"icon": "editor-code",
9+
"description": "Write content using Djot markup language.",
10+
"keywords": ["djot", "markup", "markdown", "text"],
11+
"supports": {
12+
"html": false,
13+
"align": ["wide", "full"],
14+
"className": true
15+
},
16+
"textdomain": "wp-djot",
17+
"attributes": {
18+
"content": {
19+
"type": "string",
20+
"default": ""
21+
}
22+
},
23+
"editorScript": "file:./index.js",
24+
"editorStyle": "file:./editor.css",
25+
"render": "file:./render.php"
26+
}

assets/blocks/djot/editor.css

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
.wp-djot-block {
2+
border: 1px solid #ddd;
3+
border-radius: 4px;
4+
background: #fff;
5+
}
6+
7+
.wp-djot-block-wrapper {
8+
padding: 0;
9+
}
10+
11+
.wp-djot-block .wp-djot-editor textarea {
12+
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
13+
font-size: 13px;
14+
line-height: 1.6;
15+
min-height: 200px;
16+
width: 100%;
17+
padding: 16px;
18+
border: none;
19+
border-radius: 4px;
20+
resize: vertical;
21+
background: #f9f9f9;
22+
}
23+
24+
.wp-djot-block .wp-djot-editor textarea:focus {
25+
outline: none;
26+
box-shadow: none;
27+
background: #fff;
28+
}
29+
30+
.wp-djot-block .components-base-control__label {
31+
display: none;
32+
}
33+
34+
.wp-djot-preview-wrapper {
35+
background: #fff;
36+
}
37+
38+
.wp-djot-preview-header {
39+
display: flex;
40+
justify-content: space-between;
41+
align-items: center;
42+
padding: 8px 16px;
43+
background: #f0f0f0;
44+
border-bottom: 1px solid #ddd;
45+
font-size: 12px;
46+
font-weight: 500;
47+
text-transform: uppercase;
48+
color: #666;
49+
}
50+
51+
.wp-djot-edit-button {
52+
background: #007cba;
53+
color: #fff;
54+
border: none;
55+
border-radius: 3px;
56+
padding: 4px 12px;
57+
font-size: 12px;
58+
cursor: pointer;
59+
text-transform: none;
60+
}
61+
62+
.wp-djot-edit-button:hover {
63+
background: #005a87;
64+
}
65+
66+
.wp-djot-preview {
67+
padding: 16px;
68+
min-height: 100px;
69+
}
70+
71+
.wp-djot-preview:empty::before {
72+
content: "Preview will appear here...";
73+
color: #999;
74+
font-style: italic;
75+
}
76+
77+
/* Djot content styles in editor */
78+
.wp-djot-preview.djot-content h1,
79+
.wp-djot-preview.djot-content h2,
80+
.wp-djot-preview.djot-content h3,
81+
.wp-djot-preview.djot-content h4,
82+
.wp-djot-preview.djot-content h5,
83+
.wp-djot-preview.djot-content h6 {
84+
margin-top: 0;
85+
}
86+
87+
.wp-djot-preview.djot-content pre {
88+
background: #f4f4f4;
89+
padding: 12px;
90+
border-radius: 4px;
91+
overflow-x: auto;
92+
}
93+
94+
.wp-djot-preview.djot-content code {
95+
background: #f4f4f4;
96+
padding: 2px 6px;
97+
border-radius: 3px;
98+
font-size: 0.9em;
99+
}
100+
101+
.wp-djot-preview.djot-content pre code {
102+
background: none;
103+
padding: 0;
104+
}
105+
106+
.wp-djot-preview.djot-content blockquote {
107+
border-left: 4px solid #ddd;
108+
margin-left: 0;
109+
padding-left: 16px;
110+
color: #666;
111+
}
112+
113+
/* Placeholder styles */
114+
.wp-djot-block .components-placeholder {
115+
min-height: auto;
116+
padding: 24px;
117+
}
118+
119+
.wp-djot-block .components-placeholder .wp-djot-editor textarea {
120+
margin-top: 16px;
121+
}
122+
123+
/* Loading spinner */
124+
.wp-djot-preview-wrapper .components-spinner {
125+
margin: 40px auto;
126+
display: block;
127+
}

0 commit comments

Comments
 (0)