@djangocfg/ui-tools 2.1.291 → 2.1.293
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/README.md +3 -2
- package/dist/{DocsLayout-IKH7BLSU.cjs → DocsLayout-PLWQJBGU.cjs} +10 -4
- package/dist/DocsLayout-PLWQJBGU.cjs.map +1 -0
- package/dist/{DocsLayout-JPXFUKAR.mjs → DocsLayout-XB55R7YG.mjs} +11 -5
- package/dist/DocsLayout-XB55R7YG.mjs.map +1 -0
- package/dist/index.cjs +73 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -6
- package/dist/index.d.ts +66 -6
- package/dist/index.mjs +73 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -6
- package/src/tools/MarkdownEditor/MarkdownEditor.story.tsx +108 -2
- package/src/tools/MarkdownEditor/MarkdownEditor.tsx +46 -2
- package/src/tools/MarkdownEditor/README.md +82 -3
- package/src/tools/MarkdownEditor/createMentionSuggestion.ts +55 -16
- package/src/tools/MarkdownEditor/index.ts +7 -1
- package/src/tools/MarkdownEditor/mentionPresets.test.ts +107 -0
- package/src/tools/MarkdownEditor/mentionPresets.ts +49 -0
- package/src/tools/MarkdownEditor/types.ts +33 -2
- package/src/tools/OpenapiViewer/README.md +2 -1
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/EndpointRow.tsx +12 -1
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/SidebarBody.tsx +1 -1
- package/src/tools/OpenapiViewer/components/DocsLayout/index.tsx +5 -1
- package/src/tools/OpenapiViewer/types.ts +5 -5
- package/src/tools/index.ts +8 -2
- package/dist/DocsLayout-IKH7BLSU.cjs.map +0 -1
- package/dist/DocsLayout-JPXFUKAR.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useEffect, useRef } from 'react';
|
|
4
4
|
|
|
5
5
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@djangocfg/ui-core/components';
|
|
6
6
|
import { cn } from '@djangocfg/ui-core/lib';
|
|
@@ -35,10 +35,21 @@ export const EndpointRow = React.memo(function EndpointRow({
|
|
|
35
35
|
// in ``.`` which looks like punctuation noise when stacked in a list.
|
|
36
36
|
const displayLabel = row.label.replace(/\.$/, '');
|
|
37
37
|
|
|
38
|
+
// Keep the active row visible inside the sidebar's scroll container.
|
|
39
|
+
// ``block: 'nearest'`` is a no-op when the row is already in view,
|
|
40
|
+
// so this only fires when the user scrolled the docs far enough to
|
|
41
|
+
// push the highlighted endpoint above/below the sidebar viewport.
|
|
42
|
+
const buttonRef = useRef<HTMLButtonElement | null>(null);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!row.isActive || !buttonRef.current) return;
|
|
45
|
+
buttonRef.current.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
46
|
+
}, [row.isActive]);
|
|
47
|
+
|
|
38
48
|
return (
|
|
39
49
|
<Tooltip delayDuration={350}>
|
|
40
50
|
<TooltipTrigger asChild>
|
|
41
51
|
<button
|
|
52
|
+
ref={buttonRef}
|
|
42
53
|
onClick={() => onNavigate(row.anchor, row.schemaId)}
|
|
43
54
|
aria-current={row.isActive ? 'location' : undefined}
|
|
44
55
|
className={cn(
|
|
@@ -24,7 +24,7 @@ export function SidebarBody({ body, onNavigate }: SidebarBodyProps) {
|
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
26
|
return (
|
|
27
|
-
<nav className="
|
|
27
|
+
<nav className="pt-1.5 pb-[10vh]">
|
|
28
28
|
{body.categories.map((cat) => (
|
|
29
29
|
<CategoryBlock key={cat.key} category={cat} onNavigate={onNavigate} />
|
|
30
30
|
))}
|
|
@@ -31,7 +31,11 @@ export const DocsLayout: React.FC = () => {
|
|
|
31
31
|
const grouping = config.schemaGrouping ?? 'selector';
|
|
32
32
|
const preloadAll = grouping === 'sections';
|
|
33
33
|
const urlSyncEnabled =
|
|
34
|
-
|
|
34
|
+
config.urlSync === undefined
|
|
35
|
+
? true
|
|
36
|
+
: typeof config.urlSync === 'boolean'
|
|
37
|
+
? config.urlSync
|
|
38
|
+
: Boolean(config.urlSync.enabled);
|
|
35
39
|
|
|
36
40
|
const {
|
|
37
41
|
endpoints,
|
|
@@ -114,11 +114,11 @@ export interface PlaygroundConfig {
|
|
|
114
114
|
* rendered back-to-back in the docs column. Scrollspy picks the
|
|
115
115
|
* active schema based on what's visible. */
|
|
116
116
|
schemaGrouping?: 'selector' | 'sections';
|
|
117
|
-
/**
|
|
118
|
-
* ``#<schemaId>/<anchor>`` on the browser location
|
|
119
|
-
*
|
|
120
|
-
* ``{ enabled:
|
|
121
|
-
*
|
|
117
|
+
/** URL-hash sync. When enabled, the viewer reads/writes
|
|
118
|
+
* ``#<schemaId>/<anchor>`` on the browser location so deep-links
|
|
119
|
+
* to a specific endpoint work out of the box. Defaults to ``true`` —
|
|
120
|
+
* pass ``false`` (or ``{ enabled: false }``) to opt out if the host
|
|
121
|
+
* page already manages the hash itself. */
|
|
122
122
|
urlSync?: boolean | { enabled: boolean };
|
|
123
123
|
}
|
|
124
124
|
|
package/src/tools/index.ts
CHANGED
|
@@ -223,8 +223,14 @@ export type {
|
|
|
223
223
|
} from './CodeEditor/types';
|
|
224
224
|
|
|
225
225
|
// Export MarkdownEditor (Tiptap ~200KB)
|
|
226
|
-
export { MarkdownEditor } from './MarkdownEditor';
|
|
227
|
-
export type {
|
|
226
|
+
export { MarkdownEditor, mentionPresets } from './MarkdownEditor';
|
|
227
|
+
export type {
|
|
228
|
+
MarkdownEditorProps,
|
|
229
|
+
MentionItem,
|
|
230
|
+
MentionConfig,
|
|
231
|
+
MentionAttrs,
|
|
232
|
+
MentionMarkdownRenderer,
|
|
233
|
+
} from './MarkdownEditor';
|
|
228
234
|
|
|
229
235
|
// Export Media Cache Store
|
|
230
236
|
export {
|