@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
package/dist/index.cjs
CHANGED
|
@@ -23,6 +23,7 @@ var Placeholder = require('@tiptap/extension-placeholder');
|
|
|
23
23
|
var Mention = require('@tiptap/extension-mention');
|
|
24
24
|
var markdown = require('@tiptap/markdown');
|
|
25
25
|
var lucideReact = require('lucide-react');
|
|
26
|
+
var dom = require('@floating-ui/dom');
|
|
26
27
|
|
|
27
28
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
28
29
|
|
|
@@ -262,7 +263,7 @@ function OpenapiLoadingFallback() {
|
|
|
262
263
|
}
|
|
263
264
|
chunkWGEGR3DF_cjs.__name(OpenapiLoadingFallback, "OpenapiLoadingFallback");
|
|
264
265
|
var LazyDocsLayout = createLazyComponent(
|
|
265
|
-
() => import('./DocsLayout-
|
|
266
|
+
() => import('./DocsLayout-PLWQJBGU.cjs').then((mod) => ({ default: mod.DocsLayout })),
|
|
266
267
|
{
|
|
267
268
|
displayName: "LazyDocsLayout",
|
|
268
269
|
fallback: /* @__PURE__ */ jsxRuntime.jsx(OpenapiLoadingFallback, {})
|
|
@@ -417,7 +418,7 @@ function LottiePlayer(props) {
|
|
|
417
418
|
}
|
|
418
419
|
chunkWGEGR3DF_cjs.__name(LottiePlayer, "LottiePlayer");
|
|
419
420
|
var DocsLayout = React.lazy(
|
|
420
|
-
() => import('./DocsLayout-
|
|
421
|
+
() => import('./DocsLayout-PLWQJBGU.cjs').then((mod) => ({ default: mod.DocsLayout }))
|
|
421
422
|
);
|
|
422
423
|
var LoadingFallback7 = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center min-h-[400px]", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground", children: "Loading API Playground..." }) }), "LoadingFallback");
|
|
423
424
|
var Playground = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ config }) => {
|
|
@@ -1220,6 +1221,38 @@ function createMentionSuggestion(config) {
|
|
|
1220
1221
|
render: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
1221
1222
|
let component = null;
|
|
1222
1223
|
let popup = null;
|
|
1224
|
+
let cleanupAutoUpdate = null;
|
|
1225
|
+
let getReferenceRect = null;
|
|
1226
|
+
const buildVirtualElement = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => ({
|
|
1227
|
+
getBoundingClientRect: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
1228
|
+
const rect = getReferenceRect?.();
|
|
1229
|
+
return rect ?? new DOMRect(0, 0, 0, 0);
|
|
1230
|
+
}, "getBoundingClientRect")
|
|
1231
|
+
}), "buildVirtualElement");
|
|
1232
|
+
const updatePosition = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
1233
|
+
if (!popup) return;
|
|
1234
|
+
const virtualEl = buildVirtualElement();
|
|
1235
|
+
void dom.computePosition(virtualEl, popup, {
|
|
1236
|
+
placement: "bottom-start",
|
|
1237
|
+
middleware: [
|
|
1238
|
+
dom.offset(4),
|
|
1239
|
+
dom.flip({ fallbackPlacements: ["top-start"] }),
|
|
1240
|
+
dom.shift({ padding: 8 })
|
|
1241
|
+
]
|
|
1242
|
+
}).then(({ x, y }) => {
|
|
1243
|
+
if (!popup) return;
|
|
1244
|
+
popup.style.transform = `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`;
|
|
1245
|
+
});
|
|
1246
|
+
}, "updatePosition");
|
|
1247
|
+
const teardown = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
1248
|
+
cleanupAutoUpdate?.();
|
|
1249
|
+
cleanupAutoUpdate = null;
|
|
1250
|
+
popup?.remove();
|
|
1251
|
+
popup = null;
|
|
1252
|
+
component?.destroy();
|
|
1253
|
+
component = null;
|
|
1254
|
+
getReferenceRect = null;
|
|
1255
|
+
}, "teardown");
|
|
1223
1256
|
return {
|
|
1224
1257
|
onStart: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((props) => {
|
|
1225
1258
|
component = new react.ReactRenderer(MentionList, {
|
|
@@ -1232,14 +1265,12 @@ function createMentionSuggestion(config) {
|
|
|
1232
1265
|
editor: props.editor
|
|
1233
1266
|
});
|
|
1234
1267
|
popup = document.createElement("div");
|
|
1235
|
-
popup.style.cssText = "position: absolute; z-index: 99999;";
|
|
1268
|
+
popup.style.cssText = "position: absolute; top: 0; left: 0; z-index: 99999;";
|
|
1236
1269
|
popup.appendChild(component.element);
|
|
1237
|
-
const rect = props.clientRect?.();
|
|
1238
|
-
if (rect) {
|
|
1239
|
-
popup.style.top = `${rect.bottom + window.scrollY + 4}px`;
|
|
1240
|
-
popup.style.left = `${rect.left + window.scrollX}px`;
|
|
1241
|
-
}
|
|
1242
1270
|
document.body.appendChild(popup);
|
|
1271
|
+
getReferenceRect = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => props.clientRect?.() ?? null, "getReferenceRect");
|
|
1272
|
+
const virtualEl = buildVirtualElement();
|
|
1273
|
+
cleanupAutoUpdate = dom.autoUpdate(virtualEl, popup, updatePosition);
|
|
1243
1274
|
}, "onStart"),
|
|
1244
1275
|
onUpdate: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((props) => {
|
|
1245
1276
|
component?.updateProps({
|
|
@@ -1248,29 +1279,41 @@ function createMentionSuggestion(config) {
|
|
|
1248
1279
|
props.command({ id: item.id, label: item.label });
|
|
1249
1280
|
}, "command")
|
|
1250
1281
|
});
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
popup.style.top = `${rect.bottom + window.scrollY + 4}px`;
|
|
1254
|
-
popup.style.left = `${rect.left + window.scrollX}px`;
|
|
1255
|
-
}
|
|
1282
|
+
getReferenceRect = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => props.clientRect?.() ?? null, "getReferenceRect");
|
|
1283
|
+
updatePosition();
|
|
1256
1284
|
}, "onUpdate"),
|
|
1257
1285
|
onKeyDown: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((props) => {
|
|
1258
1286
|
if (props.event.key === "Escape") {
|
|
1259
|
-
|
|
1260
|
-
component?.destroy();
|
|
1287
|
+
teardown();
|
|
1261
1288
|
return true;
|
|
1262
1289
|
}
|
|
1263
1290
|
return component?.ref?.onKeyDown(props.event) ?? false;
|
|
1264
1291
|
}, "onKeyDown"),
|
|
1265
1292
|
onExit: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
1266
|
-
|
|
1267
|
-
component?.destroy();
|
|
1293
|
+
teardown();
|
|
1268
1294
|
}, "onExit")
|
|
1269
1295
|
};
|
|
1270
1296
|
}, "render")
|
|
1271
1297
|
};
|
|
1272
1298
|
}
|
|
1273
1299
|
chunkWGEGR3DF_cjs.__name(createMentionSuggestion, "createMentionSuggestion");
|
|
1300
|
+
|
|
1301
|
+
// src/tools/MarkdownEditor/mentionPresets.ts
|
|
1302
|
+
var escapeMd = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((s) => s.replace(/([\\\[\]()_*~`])/g, "\\$1"), "escapeMd");
|
|
1303
|
+
var mentionPresets = {
|
|
1304
|
+
/** "@Label" — default, ideal for chat where LLMs read the text. */
|
|
1305
|
+
plainAt: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((({ label, id }) => `@${label || id}`), "plainAt"),
|
|
1306
|
+
/** "Label" — bare label, no @ prefix. */
|
|
1307
|
+
plainLabel: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((({ label, id }) => label || id), "plainLabel"),
|
|
1308
|
+
/** "[@Label](baseUrl/id)" — clickable markdown link. */
|
|
1309
|
+
markdownLink: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((baseUrl) => ({ label, id }) => `[@${escapeMd(label || id)}](${baseUrl}${encodeURIComponent(id)})`, "markdownLink"),
|
|
1310
|
+
/** "@[Label](scheme://kind/id)" — Notion / Linear-style custom URI. */
|
|
1311
|
+
customUri: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((scheme, kind) => ({ label, id }) => `@[${escapeMd(label || id)}](${scheme}://${kind}/${encodeURIComponent(id)})`, "customUri"),
|
|
1312
|
+
/** "<@id>" — Slack-style id-only reference (label dropped — receivers resolve it). */
|
|
1313
|
+
slackStyle: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((({ id }) => `<@${id}>`), "slackStyle"),
|
|
1314
|
+
/** Inline HTML span — for products that consume markdown with raw HTML allowed. */
|
|
1315
|
+
htmlSpan: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((className = "mention") => ({ label, id }) => `<span class="${className}" data-mention-id="${encodeURIComponent(id)}">@${escapeMd(label || id)}</span>`, "htmlSpan")
|
|
1316
|
+
};
|
|
1274
1317
|
function getMarkdown(editor) {
|
|
1275
1318
|
const storage = editor.storage.markdown;
|
|
1276
1319
|
if (!storage?.manager) return editor.getText();
|
|
@@ -1314,8 +1357,19 @@ function MarkdownEditor({
|
|
|
1314
1357
|
markdown.Markdown
|
|
1315
1358
|
];
|
|
1316
1359
|
if (mentions) {
|
|
1360
|
+
const renderMarkdown = mentions.renderMarkdown ?? mentionPresets.plainAt;
|
|
1317
1361
|
exts.push(
|
|
1318
|
-
Mention__default.default.
|
|
1362
|
+
Mention__default.default.extend({
|
|
1363
|
+
renderMarkdown(node) {
|
|
1364
|
+
const raw = node.attrs;
|
|
1365
|
+
const attrs = {
|
|
1366
|
+
id: raw?.id ?? "",
|
|
1367
|
+
label: raw?.label ?? ""
|
|
1368
|
+
};
|
|
1369
|
+
if (!attrs.id && !attrs.label) return "";
|
|
1370
|
+
return renderMarkdown(attrs);
|
|
1371
|
+
}
|
|
1372
|
+
}).configure({
|
|
1319
1373
|
HTMLAttributes: { class: "markdown-mention" },
|
|
1320
1374
|
suggestion: createMentionSuggestion(mentions),
|
|
1321
1375
|
renderText: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ node }) => `@${node.attrs.label}`, "renderText")
|
|
@@ -1823,6 +1877,7 @@ exports.MarkdownEditor = MarkdownEditor;
|
|
|
1823
1877
|
exports.OpenapiViewer = OpenapiViewer_default;
|
|
1824
1878
|
exports.Spinner = Spinner;
|
|
1825
1879
|
exports.createLazyComponent = createLazyComponent;
|
|
1880
|
+
exports.mentionPresets = mentionPresets;
|
|
1826
1881
|
exports.useEditor = useEditor;
|
|
1827
1882
|
exports.useEditorContext = useEditorContext;
|
|
1828
1883
|
exports.useLanguage = useLanguage;
|