fumadocs-core 15.3.0 → 15.3.2

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.
@@ -21,6 +21,7 @@ import {
21
21
  import rehypeShikiFromHighlighter from "@shikijs/rehype/core";
22
22
  import {
23
23
  transformerNotationDiff,
24
+ transformerNotationFocus,
24
25
  transformerNotationHighlight,
25
26
  transformerNotationWordHighlight
26
27
  } from "@shikijs/transformers";
@@ -184,6 +185,14 @@ var metaValues = [
184
185
  {
185
186
  name: "tab",
186
187
  regex: /tab="(?<value>[^"]+)"/
188
+ },
189
+ {
190
+ regex: /lineNumbers=(\d+)|lineNumbers/,
191
+ onSet(map, args) {
192
+ map["data-line-numbers"] = true;
193
+ if (args[0] !== void 0)
194
+ map["data-line-numbers-start"] = Number(args[0]);
195
+ }
187
196
  }
188
197
  ];
189
198
  var rehypeCodeDefaultOptions = {
@@ -201,14 +210,21 @@ var rehypeCodeDefaultOptions = {
201
210
  }),
202
211
  transformerNotationDiff({
203
212
  matchAlgorithm: "v3"
213
+ }),
214
+ transformerNotationFocus({
215
+ matchAlgorithm: "v3"
204
216
  })
205
217
  ],
206
218
  parseMetaString(meta) {
207
219
  const map = {};
208
220
  for (const value of metaValues) {
209
221
  meta = meta.replace(value.regex, (_, ...args) => {
210
- const first = args.at(0);
211
- map[value.name] = typeof first === "string" ? first : "";
222
+ if ("onSet" in value) {
223
+ value.onSet(map, args);
224
+ } else {
225
+ const first = args.at(0);
226
+ map[value.name] = typeof first === "string" ? first : "";
227
+ }
212
228
  return "";
213
229
  });
214
230
  }
package/dist/toc.js CHANGED
@@ -46,8 +46,9 @@ function useAnchorObserver(watch, single) {
46
46
  function onScroll() {
47
47
  const element = document.scrollingElement;
48
48
  if (!element) return;
49
- if (element.scrollTop === 0 && single) setActiveAnchor(watch.slice(0, 1));
50
- else if (element.scrollTop + element.clientHeight >= element.scrollHeight - 6) {
49
+ const top = element.scrollTop;
50
+ if (top <= 0 && single) setActiveAnchor(watch.slice(0, 1));
51
+ else if (top + element.clientHeight >= element.scrollHeight - 6) {
51
52
  setActiveAnchor((active) => {
52
53
  return active.length > 0 && !single ? watch.slice(watch.indexOf(active[0])) : watch.slice(-1);
53
54
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "15.3.0",
3
+ "version": "15.3.2",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",