docs: Adds instructions to upgrade custom plugins to v5 (#2788)

Co-authored-by: Luffy <lufei@apache.org>
This commit is contained in:
Julien BUSSET
2026-08-19 08:55:04 +02:00
committed by GitHub
parent 92cdd136da
commit bd8f2ea121
+30
View File
@@ -110,6 +110,36 @@ View [Theme Classes](themes.md?id=classes) for more details.
- Update version from `@4` (or non-versioned) to `@5`
- Example: `//cdn.jsdelivr.net/npm/docsify/lib/plugins/emoji.min.js` becomes `//cdn.jsdelivr.net/npm/docsify@5/dist/plugins/emoji.min.js`
#### Plugin Authors
If you've written a custom plugin that uses `window.Docsify.dom.toggleClass`, this helper has been removed in v5. Replace it with the native `Element.classList` API.
Examples:
```js
// v4
window.Docsify.dom.toggleClass(element, 'className');
// v5
element.classList.toggle('className');
```
```js
// v4
window.Docsify.dom.toggleClass(element, 'action', 'className');
// v5
element.classList.action('className');
```
```js
// v4
window.Docsify.dom.toggleClass(element, isDark ? 'add' : 'remove', 'dark');
// v5
element.classList[isDark ? 'add' : 'remove']('dark');
```
## Key Differences Summary
- **CDN Path**: Changed from `/lib/` to `/dist/`