Skip to content

Commit 7977389

Browse files
committed
update code mirror to 6
1 parent 70fea1c commit 7977389

101 files changed

Lines changed: 25048 additions & 23123 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# 0.20.4 <small>2026-05-15</small>
2+
3+
## 💅 Improvements
4+
- Upgraded the XML arrangement editor from CodeMirror 5 to CodeMirror 6.
5+
- The editor search is now an inline panel (Ctrl-F / ⌘F) with next/previous/replace buttons.
6+
- Fullscreen mode uses the native browser Fullscreen API (⛶ button, Esc to exit).
7+
- Save shortcut works cross-platform: Ctrl-S on Windows/Linux, ⌘S on Mac.
8+
- Autocomplete triggers on typing `<` in addition to Ctrl-Space.
9+
10+
<!-- CHANGELOG_BOUNDARY -->
11+
112
# 0.20.3 <small>2026-05-08</small>
213

314
## 🐛 Bug Fixes

docs/updating-codemirror6.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Updating CodeMirror 6
2+
3+
CodeMirror 6 is shipped as a pre-built IIFE bundle committed to `wwwroot/Scripts/`. This document explains how to rebuild the bundle when upgrading CM6 packages.
4+
5+
## Prerequisites
6+
7+
- Node.js 20+ (`node --version`)
8+
- npm (included with Node.js)
9+
10+
These are only needed when rebuilding the bundle — not at .NET build time.
11+
12+
## Directory layout
13+
14+
```
15+
src/OrchardCore.Transformalize/
16+
cm6-build/
17+
package.json ← npm dependencies + build script entry
18+
build.mjs ← esbuild runner
19+
entry.js ← CM6 initialization source (IIFE)
20+
node_modules/ ← git-ignored, created by npm install
21+
wwwroot/Scripts/
22+
codemirror6-bundle.js ← committed, produced by npm run build
23+
codemirror6-bundle.min.js ← committed, produced by npm run build
24+
```
25+
26+
## How to upgrade a CM6 package
27+
28+
1. Open `cm6-build/package.json` and update the version of the desired package in the `dependencies` section. Example:
29+
30+
```json
31+
"@codemirror/view": "^6.37.0"
32+
```
33+
34+
2. Run the build from inside the `cm6-build/` directory:
35+
36+
```sh
37+
cd src/OrchardCore.Transformalize/cm6-build
38+
npm install
39+
npm run build
40+
```
41+
42+
3. Verify the two output files were updated:
43+
44+
```sh
45+
ls -lh ../wwwroot/Scripts/codemirror6-bundle*.js
46+
```
47+
48+
4. Open `src/OrchardCore.Transformalize/Common.cs` and increment the version string:
49+
50+
```csharp
51+
public const string CodeMirrorVersion = "6.x.y";
52+
```
53+
54+
This busts the browser cache for users who have the old bundle cached. Use a meaningful string like the date or a sequence number — it does not need to match any npm package version.
55+
56+
5. Test by running the OrchardCore host and editing a Transformalize arrangement or settings. Verify:
57+
- XML syntax highlighting
58+
- Code folding: **Ctrl-Q** folds/unfolds
59+
- Search panel: **Ctrl-F**
60+
- Autocomplete: **Ctrl-Space** (also triggers on `<`)
61+
- Fullscreen: **F11** enters, **Esc** exits
62+
- Save: **Ctrl-S** submits the form
63+
64+
6. Commit the updated files:
65+
- `cm6-build/package.json`
66+
- `cm6-build/package-lock.json`
67+
- `wwwroot/Scripts/codemirror6-bundle.js`
68+
- `wwwroot/Scripts/codemirror6-bundle.min.js`
69+
- `Common.cs`
70+
71+
## Modifying editor behaviour
72+
73+
Edit `cm6-build/entry.js` then re-run `npm run build`. The entry file is the source of truth for:
74+
- Editor extensions (syntax, folding, search, autocomplete, etc.)
75+
- Custom keybindings (Ctrl-Q, Ctrl-S, F11, Tab, etc.)
76+
- Fullscreen implementation
77+
- Textarea sync logic
78+
79+
## CM6 package → feature mapping
80+
81+
| Feature | Package |
82+
|---|---|
83+
| XML syntax highlighting | `@codemirror/lang-xml` |
84+
| Line numbers | `@codemirror/view` |
85+
| Code folding + gutter | `@codemirror/language` |
86+
| Search / replace panel | `@codemirror/search` |
87+
| Autocomplete | `@codemirror/autocomplete` |
88+
| History / undo / redo | `@codemirror/commands` |
89+
| State management | `@codemirror/state` |
90+
| Editor view + keymaps | `@codemirror/view` |
91+
92+
## Further reading
93+
94+
- [CodeMirror 6 reference manual](https://codemirror.net/docs/ref/)
95+
- [CodeMirror 6 extensions guide](https://codemirror.net/docs/guide/)
96+
- [CodeMirror 6 migration guide from v5](https://codemirror.net/docs/migration/)

0 commit comments

Comments
 (0)