shiki-transformer-fold 0.1.0 → 0.1.1
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/dist/index.mjs +7 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -124,13 +124,19 @@ function getStyles(classPrefix) {
|
|
|
124
124
|
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region src/listeners.ts
|
|
127
|
+
let toggleListenerAttached = false;
|
|
127
128
|
/**
|
|
129
|
+
|
|
128
130
|
* Attach a delegated click listener for fold toggles.
|
|
131
|
+
|
|
129
132
|
* Uses event delegation so it works with dynamically rendered content.
|
|
133
|
+
|
|
130
134
|
* Only needs to be called once.
|
|
135
|
+
|
|
131
136
|
*/
|
|
132
137
|
function attachFoldToggleListener(classPrefix = "shiki-fold") {
|
|
133
|
-
if (typeof document === "undefined") return;
|
|
138
|
+
if (typeof document === "undefined" || toggleListenerAttached) return;
|
|
139
|
+
toggleListenerAttached = true;
|
|
134
140
|
const hiddenClass = `${classPrefix}-hidden`;
|
|
135
141
|
const summaryClass = `${classPrefix}-summary`;
|
|
136
142
|
document.addEventListener("click", (event) => {
|