From bd8f2ea1217e399f8c2eec201b15aff94c42003e Mon Sep 17 00:00:00 2001 From: Julien BUSSET Date: Wed, 19 Aug 2026 08:55:04 +0200 Subject: [PATCH] docs: Adds instructions to upgrade custom plugins to v5 (#2788) Co-authored-by: Luffy --- docs/v5-upgrade.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/v5-upgrade.md b/docs/v5-upgrade.md index 4a7f6b6cd..7db4000cb 100644 --- a/docs/v5-upgrade.md +++ b/docs/v5-upgrade.md @@ -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/`