@rspress/plugin-medium-zoom 1.37.2 → 1.37.3

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.d.ts CHANGED
@@ -1,13 +1,675 @@
1
- import { RspressPlugin } from '@rspress/shared';
2
- import { ZoomOptions } from 'medium-zoom';
3
-
4
- interface Options {
5
- selector?: string;
6
- options?: ZoomOptions;
7
- }
8
- /**
9
- * The plugin is used to add medium-zoom to the doc site.
10
- */
11
- declare function pluginMediumZoom(options?: Options): RspressPlugin;
12
-
13
- export { pluginMediumZoom };
1
+ import { PluggableList } from 'unified';
2
+ import { RsbuildConfig } from '@rsbuild/core';
3
+ import { RsbuildPlugin } from '@rsbuild/core';
4
+ import type { ZoomOptions } from 'medium-zoom';
5
+
6
+ /**
7
+ * There are two ways to define what addtion routes represent.
8
+ * 1. Define filepath, then the content will be read from the file.
9
+ * 2. Define content, then then content will be written to temp file and read from it.
10
+ */
11
+ declare interface AdditionalPage {
12
+ routePath: string;
13
+ content?: string;
14
+ filepath?: string;
15
+ }
16
+
17
+ declare interface Config$1 {
18
+ /**
19
+ * Whether to enable dark mode.
20
+ * @default true
21
+ */
22
+ darkMode?: boolean;
23
+ /**
24
+ * Custom outline title in the aside component.
25
+ *
26
+ * @default 'ON THIS PAGE'
27
+ */
28
+ outlineTitle?: string;
29
+ /**
30
+ * Whether to show the sidebar in right position.
31
+ */
32
+ outline?: boolean;
33
+ /**
34
+ * The nav items. When it's an object, the key is the version of current doc.
35
+ */
36
+ nav?: NavItem[] | {
37
+ [key: string]: NavItem[];
38
+ };
39
+ /**
40
+ * The sidebar items.
41
+ */
42
+ sidebar?: Sidebar;
43
+ /**
44
+ * Info for the edit link. If it's undefined, the edit link feature will
45
+ * be disabled.
46
+ */
47
+ editLink?: EditLink;
48
+ /**
49
+ * Set custom last updated text.
50
+ *
51
+ * @default 'Last updated'
52
+ */
53
+ lastUpdatedText?: string;
54
+ /**
55
+ * Set custom last updated text.
56
+ *
57
+ * @default false
58
+ */
59
+ lastUpdated?: boolean;
60
+ /**
61
+ * Set custom prev/next labels.
62
+ */
63
+ docFooter?: DocFooter;
64
+ /**
65
+ * The social links to be displayed at the end of the nav bar. Perfect for
66
+ * placing links to social services such as GitHub, X, Facebook, etc.
67
+ */
68
+ socialLinks?: SocialLink[];
69
+ /**
70
+ * The footer configuration.
71
+ */
72
+ footer?: Footer;
73
+ /**
74
+ * The prev page text.
75
+ */
76
+ prevPageText?: string;
77
+ /**
78
+ * The next page text.
79
+ */
80
+ nextPageText?: string;
81
+ /**
82
+ * The source code text.
83
+ */
84
+ sourceCodeText?: string;
85
+ /**
86
+ * Locale config
87
+ */
88
+ locales?: LocaleConfig[];
89
+ /**
90
+ * Whether to open the full text search
91
+ */
92
+ search?: boolean;
93
+ /**
94
+ * The placeholder of search input
95
+ */
96
+ searchPlaceholderText?: string;
97
+ /**
98
+ * The text of no search result
99
+ */
100
+ searchNoResultsText?: string;
101
+ /**
102
+ * The text of suggested query text when no search result
103
+ */
104
+ searchSuggestedQueryText?: string;
105
+ /**
106
+ * The text of overview filter
107
+ */
108
+ overview?: FilterConfig;
109
+ /**
110
+ * The behavior of hiding navbar
111
+ */
112
+ hideNavbar?: 'always' | 'auto' | 'never';
113
+ /**
114
+ * Whether to enable view transition animation for pages switching
115
+ */
116
+ enableContentAnimation?: boolean;
117
+ /**
118
+ * Whether to enable view transition animation for the theme
119
+ */
120
+ enableAppearanceAnimation?: boolean;
121
+ /**
122
+ * Enable scroll to top button on documentation
123
+ * @default false
124
+ */
125
+ enableScrollToTop?: boolean;
126
+ /**
127
+ * Whether to redirect to the closest locale when the user visits the site
128
+ * @default 'auto'
129
+ */
130
+ localeRedirect?: 'auto' | 'never';
131
+ }
132
+
133
+ declare interface DocFooter {
134
+ /**
135
+ * Custom label for previous page button.
136
+ */
137
+ prev?: SidebarItem;
138
+ /**
139
+ * Custom label for next page button.
140
+ */
141
+ next?: SidebarItem;
142
+ }
143
+
144
+ declare interface EditLink {
145
+ /**
146
+ * Custom repository url for edit link.
147
+ */
148
+ docRepoBaseUrl: string;
149
+ /**
150
+ * Custom text for edit link.
151
+ *
152
+ * @default 'Edit this page'
153
+ */
154
+ text?: string;
155
+ }
156
+
157
+ /**
158
+ * The config of filter component
159
+ */
160
+ declare interface FilterConfig {
161
+ filterNameText?: string;
162
+ filterPlaceholderText?: string;
163
+ filterNoResultText?: string;
164
+ }
165
+
166
+ declare interface Footer {
167
+ message?: string;
168
+ }
169
+
170
+ declare interface Header {
171
+ id: string;
172
+ text: string;
173
+ depth: number;
174
+ charIndex: number;
175
+ }
176
+
177
+ declare interface Locale {
178
+ lang: string;
179
+ label: string;
180
+ title?: string;
181
+ description?: string;
182
+ }
183
+
184
+ /**
185
+ * locale config
186
+ */
187
+ declare interface LocaleConfig {
188
+ /**
189
+ * Site i18n config, which will recover the locales config in the site level.
190
+ */
191
+ lang: string;
192
+ title?: string;
193
+ description?: string;
194
+ label: string;
195
+ /**
196
+ * Theme i18n config
197
+ */
198
+ nav?: Nav;
199
+ sidebar?: Sidebar;
200
+ outlineTitle?: string;
201
+ lastUpdatedText?: string;
202
+ lastUpdated?: boolean;
203
+ editLink?: EditLink;
204
+ prevPageText?: string;
205
+ nextPageText?: string;
206
+ sourceCodeText?: string;
207
+ langRoutePrefix?: string;
208
+ searchPlaceholderText?: string;
209
+ searchNoResultsText?: string;
210
+ searchSuggestedQueryText?: string;
211
+ overview?: FilterConfig;
212
+ }
213
+
214
+ declare type LocalSearchOptions = SearchHooks & {
215
+ mode?: 'local';
216
+ /**
217
+ * Whether to generate separate search index for each version
218
+ */
219
+ versioned?: boolean;
220
+ };
221
+
222
+ declare interface MarkdownOptions {
223
+ remarkPlugins?: PluggableList;
224
+ rehypePlugins?: PluggableList;
225
+ /**
226
+ * Whether to enable check dead links, default is false
227
+ */
228
+ checkDeadLinks?: boolean;
229
+ showLineNumbers?: boolean;
230
+ /**
231
+ * Whether to wrap code by default, default is false
232
+ */
233
+ defaultWrapCode?: boolean;
234
+ /**
235
+ * Register global components in mdx files
236
+ */
237
+ globalComponents?: string[];
238
+ /**
239
+ * Code highlighter, default is prism for performance reason
240
+ */
241
+ codeHighlighter?: 'prism' | 'shiki';
242
+ /**
243
+ * Register prism languages
244
+ */
245
+ highlightLanguages?: (string | [string, string])[];
246
+ /**
247
+ * Whether to enable mdx-rs, default is true
248
+ */
249
+ mdxRs?: boolean | MdxRsOptions;
250
+ /**
251
+ * @deprecated, use `mdxRs` instead
252
+ */
253
+ experimentalMdxRs?: boolean;
254
+ }
255
+
256
+ declare interface MdxRsOptions {
257
+ /**
258
+ * Determine whether the file use mdxRs compiler
259
+ */
260
+ include?: (filepath: string) => boolean;
261
+ }
262
+
263
+ declare type Nav = NavItem[] | {
264
+ [key: string]: NavItem[];
265
+ };
266
+
267
+ declare type NavItem = NavItemWithLink | NavItemWithChildren | NavItemWithLinkAndChildren;
268
+
269
+ declare interface NavItemWithChildren {
270
+ text?: string;
271
+ tag?: string;
272
+ items: NavItemWithLink[];
273
+ position?: 'left' | 'right';
274
+ }
275
+
276
+ declare type NavItemWithLink = {
277
+ text: string;
278
+ link: string;
279
+ tag?: string;
280
+ activeMatch?: string;
281
+ position?: 'left' | 'right';
282
+ };
283
+
284
+ declare interface NavItemWithLinkAndChildren {
285
+ text: string;
286
+ link: string;
287
+ items: NavItemWithLink[];
288
+ tag?: string;
289
+ activeMatch?: string;
290
+ position?: 'left' | 'right';
291
+ }
292
+
293
+ declare interface Options {
294
+ selector?: string;
295
+ options?: ZoomOptions;
296
+ }
297
+
298
+ /**
299
+ * @description search-index.json file
300
+ * "_foo" is the private field that won't be written to search-index.json file
301
+ * and should not be used in the runtime (usePageData).
302
+ */
303
+ declare type PageIndexInfo = {
304
+ id: number;
305
+ title: string;
306
+ routePath: string;
307
+ toc: Header[];
308
+ content: string;
309
+ _html: string;
310
+ frontmatter: Record<string, unknown>;
311
+ lang: string;
312
+ version: string;
313
+ domain: string;
314
+ _filepath: string;
315
+ _relativePath: string;
316
+ };
317
+
318
+ /**
319
+ * The plugin is used to add medium-zoom to the doc site.
320
+ */
321
+ export declare function pluginMediumZoom(options?: Options): RspressPlugin;
322
+
323
+ declare type RemoteSearchIndexInfo = string | {
324
+ value: string;
325
+ label: string;
326
+ };
327
+
328
+ declare type RemoteSearchOptions = SearchHooks & {
329
+ mode: 'remote';
330
+ apiUrl: string;
331
+ domain?: string;
332
+ indexName: string;
333
+ searchIndexes?: RemoteSearchIndexInfo[];
334
+ searchLoading?: boolean;
335
+ };
336
+
337
+ declare interface ReplaceRule {
338
+ search: string | RegExp;
339
+ replace: string;
340
+ }
341
+
342
+ declare interface RouteMeta {
343
+ routePath: string;
344
+ absolutePath: string;
345
+ relativePath: string;
346
+ pageName: string;
347
+ lang: string;
348
+ version: string;
349
+ }
350
+
351
+ declare interface RouteOptions {
352
+ /**
353
+ * The extension name of the filepath that will be converted to a route
354
+ * @default ['js','jsx','ts','tsx','md','mdx']
355
+ */
356
+ extensions?: string[];
357
+ /**
358
+ * Include extra files from being converted to routes
359
+ */
360
+ include?: string[];
361
+ /**
362
+ * Exclude files from being converted to routes
363
+ */
364
+ exclude?: string[];
365
+ /**
366
+ * use links without .html files
367
+ */
368
+ cleanUrls?: boolean;
369
+ }
370
+
371
+ declare interface RspressPlugin {
372
+ /**
373
+ * Name of the plugin.
374
+ */
375
+ name: string;
376
+ /**
377
+ * Global style
378
+ */
379
+ globalStyles?: string;
380
+ /**
381
+ * Markdown options.
382
+ */
383
+ markdown?: {
384
+ remarkPlugins?: PluggableList;
385
+ rehypePlugins?: PluggableList;
386
+ globalComponents?: string[];
387
+ };
388
+ /**
389
+ * Rsbuild config.
390
+ */
391
+ builderConfig?: RsbuildConfig;
392
+ /**
393
+ * Inject global components.
394
+ */
395
+ globalUIComponents?: (string | [string, object])[];
396
+ /**
397
+ * Modify doc config.
398
+ */
399
+ config?: (config: UserConfig, utils: {
400
+ addPlugin: (plugin: RspressPlugin) => void;
401
+ removePlugin: (pluginName: string) => void;
402
+ }, isProd: boolean) => UserConfig | Promise<UserConfig>;
403
+ /**
404
+ * Callback before build
405
+ */
406
+ beforeBuild?: (config: UserConfig, isProd: boolean) => void | Promise<void>;
407
+ /**
408
+ * Callback after build
409
+ */
410
+ afterBuild?: (config: UserConfig, isProd: boolean) => void | Promise<void>;
411
+ /**
412
+ * Extend every page's data
413
+ */
414
+ extendPageData?: (pageData: PageIndexInfo & {
415
+ [key: string]: unknown;
416
+ }, isProd: boolean) => void | Promise<void>;
417
+ /**
418
+ * Add custom route
419
+ */
420
+ addPages?: (config: UserConfig, isProd: boolean) => AdditionalPage[] | Promise<AdditionalPage[]>;
421
+ /**
422
+ * Add runtime modules
423
+ */
424
+ addRuntimeModules?: (config: UserConfig, isProd: boolean) => Record<string, string> | Promise<Record<string, string>>;
425
+ /**
426
+ * Callback after route generated
427
+ */
428
+ routeGenerated?: (routes: RouteMeta[], isProd: boolean) => Promise<void> | void;
429
+ /**
430
+ * Add addition ssg routes, for dynamic routes.
431
+ */
432
+ addSSGRoutes?: (config: UserConfig, isProd: boolean) => {
433
+ path: string;
434
+ }[] | Promise<{
435
+ path: string;
436
+ }[]>;
437
+ /**
438
+ * @private
439
+ * Modify search index data.
440
+ */
441
+ modifySearchIndexData?: (data: PageIndexInfo[], isProd: boolean) => void | Promise<void>;
442
+ }
443
+
444
+ declare interface SearchHooks {
445
+ /**
446
+ * The search hook function path. The corresponding file should export a function named `onSearch`.
447
+ */
448
+ searchHooks?: string;
449
+ }
450
+
451
+ declare type SearchOptions = LocalSearchOptions | RemoteSearchOptions | false;
452
+
453
+ declare interface Sidebar {
454
+ [path: string]: (SidebarGroup | SidebarItem | SidebarDivider | SidebarSectionHeader)[];
455
+ }
456
+
457
+ declare type SidebarDivider = {
458
+ dividerType: 'dashed' | 'solid';
459
+ };
460
+
461
+ declare interface SidebarGroup {
462
+ text: string;
463
+ link?: string;
464
+ tag?: string;
465
+ items: (SidebarItem | SidebarDivider | SidebarGroup | string)[];
466
+ collapsible?: boolean;
467
+ collapsed?: boolean;
468
+ /**
469
+ * For hmr usage in development
470
+ */
471
+ _fileKey?: string;
472
+ overviewHeaders?: number[];
473
+ context?: string;
474
+ }
475
+
476
+ declare type SidebarItem = {
477
+ text: string;
478
+ link: string;
479
+ tag?: string;
480
+ /**
481
+ * For hmr usage in development
482
+ */
483
+ _fileKey?: string;
484
+ overviewHeaders?: number[];
485
+ context?: string;
486
+ };
487
+
488
+ declare type SidebarSectionHeader = {
489
+ sectionHeaderText: string;
490
+ tag?: string;
491
+ };
492
+
493
+ declare interface SocialLink {
494
+ icon: SocialLinkIcon;
495
+ mode: 'link' | 'text' | 'img' | 'dom';
496
+ content: string;
497
+ }
498
+
499
+ declare type SocialLinkIcon = 'lark' | 'discord' | 'facebook' | 'github' | 'instagram' | 'linkedin' | 'slack' | 'x' | 'youtube' | 'wechat' | 'qq' | 'juejin' | 'zhihu' | 'bilibili' | 'weibo' | 'gitlab' | 'X' | {
500
+ svg: string;
501
+ };
502
+
503
+ declare type SSGConfig = boolean | {
504
+ strict?: boolean;
505
+ };
506
+
507
+ declare interface UserConfig<ThemeConfig = Config$1> {
508
+ /**
509
+ * The root directory of the site.
510
+ */
511
+ root?: string;
512
+ /**
513
+ * Path to the logo file in nav bar.
514
+ */
515
+ logo?: string | {
516
+ dark: string;
517
+ light: string;
518
+ };
519
+ /**
520
+ * The text of the logo in nav bar.
521
+ */
522
+ logoText?: string;
523
+ /**
524
+ * Base path of the site.
525
+ */
526
+ base?: string;
527
+ /**
528
+ * Path to html icon file.
529
+ */
530
+ icon?: string;
531
+ /**
532
+ * Language of the site.
533
+ */
534
+ lang?: string;
535
+ /**
536
+ * Title of the site.
537
+ */
538
+ title?: string;
539
+ /**
540
+ * Description of the site.
541
+ */
542
+ description?: string;
543
+ /**
544
+ * Head tags.
545
+ */
546
+ head?: (string | [string, Record<string, string>] | ((route: RouteMeta) => string | [string, Record<string, string>] | undefined))[];
547
+ /**
548
+ * I18n config of the site.
549
+ */
550
+ locales?: Locale[];
551
+ /**
552
+ * The i18n text data source path. Default is `i18n.json` in cwd.
553
+ */
554
+ i18nSourcePath?: string;
555
+ /**
556
+ * Theme config.
557
+ */
558
+ themeConfig?: ThemeConfig;
559
+ /**
560
+ * Rsbuild Configuration
561
+ */
562
+ builderConfig?: RsbuildConfig;
563
+ /**
564
+ * The custom config of vite-plugin-route
565
+ */
566
+ route?: RouteOptions;
567
+ /**
568
+ * The custom config of markdown compile
569
+ */
570
+ markdown?: MarkdownOptions;
571
+ /**
572
+ * Doc plugins
573
+ */
574
+ plugins?: RspressPlugin[];
575
+ /**
576
+ * Replace rule, will replace the content of the page.
577
+ */
578
+ replaceRules?: ReplaceRule[];
579
+ /**
580
+ * Output directory
581
+ */
582
+ outDir?: string;
583
+ /**
584
+ * Custom theme directory
585
+ */
586
+ themeDir?: string;
587
+ /**
588
+ * Global components
589
+ */
590
+ globalUIComponents?: (string | [string, object])[];
591
+ /**
592
+ * Global styles, is a Absolute path
593
+ */
594
+ globalStyles?: string;
595
+ /**
596
+ * Search options
597
+ */
598
+ search?: SearchOptions;
599
+ /**
600
+ * Whether to enable ssg, default is true
601
+ */
602
+ ssg?: SSGConfig;
603
+ /**
604
+ * Whether to enable medium-zoom, default is true
605
+ */
606
+ mediumZoom?: boolean | {
607
+ selector?: string;
608
+ options?: ZoomOptions_2;
609
+ };
610
+ /**
611
+ * Add some extra builder plugins
612
+ */
613
+ builderPlugins?: RsbuildPlugin[];
614
+ /**
615
+ * Multi version config
616
+ */
617
+ multiVersion?: {
618
+ /**
619
+ * The default version
620
+ */
621
+ default?: string;
622
+ /**
623
+ * The version list, such as ['v1', 'v2']
624
+ */
625
+ versions: string[];
626
+ };
627
+ }
628
+
629
+ declare interface ZoomContainer {
630
+ width?: number
631
+ height?: number
632
+ top?: number
633
+ bottom?: number
634
+ right?: number
635
+ left?: number
636
+ }
637
+
638
+ declare interface ZoomOptions_2 {
639
+ /**
640
+ * The space outside the zoomed image.
641
+ *
642
+ * @default 0
643
+ */
644
+ margin?: number
645
+
646
+ /**
647
+ * The background of the overlay.
648
+ *
649
+ * @default '#fff'
650
+ */
651
+ background?: string
652
+
653
+ /**
654
+ * The number of pixels to scroll to close the zoom.
655
+ *
656
+ * @default 40
657
+ */
658
+ scrollOffset?: number
659
+
660
+ /**
661
+ * The viewport to render the zoom in.
662
+ *
663
+ * @default null
664
+ */
665
+ container?: string | HTMLElement | ZoomContainer
666
+
667
+ /**
668
+ * The template element to display on zoom.
669
+ *
670
+ * @default null
671
+ */
672
+ template?: string | HTMLTemplateElement
673
+ }
674
+
675
+ export { }